From 0d079e2b8037a98abecb51ef6804ba357129c781 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 4 Feb 2018 16:27:10 -0700 Subject: [PATCH 001/247] general: Remove execute modes from ordinary text files --- dtool/src/cppparser/cppClosureType.cxx | 0 dtool/src/cppparser/cppClosureType.h | 0 dtool/src/interrogatedb/py_compat.cxx | 0 dtool/src/interrogatedb/py_compat.h | 0 dtool/src/interrogatedb/py_wrappers.cxx | 0 dtool/src/interrogatedb/py_wrappers.h | 0 dtool/src/parser-inc/glew/glew.h | 0 dtool/src/parser-inc/ode/ode.h | 0 dtool/src/parser-inc/ogg/os_types.h | 0 dtool/src/parser-inc/openssl/x509v3.h | 0 panda/src/nativenet/socket_address.cxx | 0 11 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 dtool/src/cppparser/cppClosureType.cxx mode change 100755 => 100644 dtool/src/cppparser/cppClosureType.h mode change 100755 => 100644 dtool/src/interrogatedb/py_compat.cxx mode change 100755 => 100644 dtool/src/interrogatedb/py_compat.h mode change 100755 => 100644 dtool/src/interrogatedb/py_wrappers.cxx mode change 100755 => 100644 dtool/src/interrogatedb/py_wrappers.h mode change 100755 => 100644 dtool/src/parser-inc/glew/glew.h mode change 100755 => 100644 dtool/src/parser-inc/ode/ode.h mode change 100755 => 100644 dtool/src/parser-inc/ogg/os_types.h mode change 100755 => 100644 dtool/src/parser-inc/openssl/x509v3.h mode change 100755 => 100644 panda/src/nativenet/socket_address.cxx diff --git a/dtool/src/cppparser/cppClosureType.cxx b/dtool/src/cppparser/cppClosureType.cxx old mode 100755 new mode 100644 diff --git a/dtool/src/cppparser/cppClosureType.h b/dtool/src/cppparser/cppClosureType.h old mode 100755 new mode 100644 diff --git a/dtool/src/interrogatedb/py_compat.cxx b/dtool/src/interrogatedb/py_compat.cxx old mode 100755 new mode 100644 diff --git a/dtool/src/interrogatedb/py_compat.h b/dtool/src/interrogatedb/py_compat.h old mode 100755 new mode 100644 diff --git a/dtool/src/interrogatedb/py_wrappers.cxx b/dtool/src/interrogatedb/py_wrappers.cxx old mode 100755 new mode 100644 diff --git a/dtool/src/interrogatedb/py_wrappers.h b/dtool/src/interrogatedb/py_wrappers.h old mode 100755 new mode 100644 diff --git a/dtool/src/parser-inc/glew/glew.h b/dtool/src/parser-inc/glew/glew.h old mode 100755 new mode 100644 diff --git a/dtool/src/parser-inc/ode/ode.h b/dtool/src/parser-inc/ode/ode.h old mode 100755 new mode 100644 diff --git a/dtool/src/parser-inc/ogg/os_types.h b/dtool/src/parser-inc/ogg/os_types.h old mode 100755 new mode 100644 diff --git a/dtool/src/parser-inc/openssl/x509v3.h b/dtool/src/parser-inc/openssl/x509v3.h old mode 100755 new mode 100644 diff --git a/panda/src/nativenet/socket_address.cxx b/panda/src/nativenet/socket_address.cxx old mode 100755 new mode 100644 From fbe373dfdc0d78a9b7c83f4ab4fee60b86f66962 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 4 Feb 2018 15:55:52 -0700 Subject: [PATCH 002/247] general: Fix includes --- dtool/src/interrogatedb/py_compat.cxx | 1 + dtool/src/interrogatedb/py_panda.h | 1 + panda/src/pgraph/shaderAttrib.cxx | 2 ++ panda/src/physics/physicalNode.cxx | 1 + panda/src/pipeline/pipeline.cxx | 1 - panda/src/pipeline/pipeline.h | 2 ++ panda/src/putil/datagramBuffer.h | 1 + 7 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dtool/src/interrogatedb/py_compat.cxx b/dtool/src/interrogatedb/py_compat.cxx index f7f02607c0..f0dd42cf73 100644 --- a/dtool/src/interrogatedb/py_compat.cxx +++ b/dtool/src/interrogatedb/py_compat.cxx @@ -12,6 +12,7 @@ */ #include "py_compat.h" +#include "py_panda.h" #ifdef HAVE_PYTHON diff --git a/dtool/src/interrogatedb/py_panda.h b/dtool/src/interrogatedb/py_panda.h index 74f13680f8..f4edc8f4ad 100644 --- a/dtool/src/interrogatedb/py_panda.h +++ b/dtool/src/interrogatedb/py_panda.h @@ -22,6 +22,7 @@ #include "pnotify.h" #include "vector_uchar.h" +#include "register_type.h" #if defined(HAVE_PYTHON) && !defined(CPPPARSER) diff --git a/panda/src/pgraph/shaderAttrib.cxx b/panda/src/pgraph/shaderAttrib.cxx index 67bba2d196..711e886828 100644 --- a/panda/src/pgraph/shaderAttrib.cxx +++ b/panda/src/pgraph/shaderAttrib.cxx @@ -25,6 +25,8 @@ #include "datagram.h" #include "datagramIterator.h" #include "nodePath.h" +#include "paramNodePath.h" +#include "paramTexture.h" #include "shaderBuffer.h" TypeHandle ShaderAttrib::_type_handle; diff --git a/panda/src/physics/physicalNode.cxx b/panda/src/physics/physicalNode.cxx index 0fdf995720..daa454aff1 100644 --- a/panda/src/physics/physicalNode.cxx +++ b/panda/src/physics/physicalNode.cxx @@ -12,6 +12,7 @@ */ #include "physicalNode.h" +#include "physicsManager.h" // static stuff. TypeHandle PhysicalNode::_type_handle; diff --git a/panda/src/pipeline/pipeline.cxx b/panda/src/pipeline/pipeline.cxx index 8d8cd2bebb..e6fd1b6cee 100644 --- a/panda/src/pipeline/pipeline.cxx +++ b/panda/src/pipeline/pipeline.cxx @@ -13,7 +13,6 @@ #include "pipeline.h" #include "pipelineCyclerTrueImpl.h" -#include "reMutexHolder.h" #include "configVariableInt.h" #include "config_pipeline.h" diff --git a/panda/src/pipeline/pipeline.h b/panda/src/pipeline/pipeline.h index 3311496ff8..1dbba9429f 100644 --- a/panda/src/pipeline/pipeline.h +++ b/panda/src/pipeline/pipeline.h @@ -18,6 +18,8 @@ #include "pipelineCyclerLinks.h" #include "namable.h" #include "pset.h" +#include "pmutex.h" +#include "mutexHolder.h" #include "reMutex.h" #include "reMutexHolder.h" #include "selectThreadImpl.h" // for THREADED_PIPELINE definition diff --git a/panda/src/putil/datagramBuffer.h b/panda/src/putil/datagramBuffer.h index acb67836f9..8962ddbb2b 100644 --- a/panda/src/putil/datagramBuffer.h +++ b/panda/src/putil/datagramBuffer.h @@ -15,6 +15,7 @@ #define DATAGRAMBUFFER_H #include "pandabase.h" +#include "datagramGenerator.h" #include "datagramSink.h" #include "vector_uchar.h" From fb6c92cf08c313ace638daf5254b099e2391c0ef Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 4 Feb 2018 16:09:30 -0700 Subject: [PATCH 003/247] express: Move all vector_* types to dtoolutil --- dtool/src/dtoolutil/p3dtoolutil_composite2.cxx | 3 +++ .../express => dtool/src/dtoolutil}/vector_double.cxx | 4 ++-- .../express => dtool/src/dtoolutil}/vector_double.h | 10 ++++------ .../express => dtool/src/dtoolutil}/vector_float.cxx | 4 ++-- .../src/express => dtool/src/dtoolutil}/vector_float.h | 10 ++++------ .../express => dtool/src/dtoolutil}/vector_stdfloat.h | 2 +- .../express => dtool/src/dtoolutil}/vector_uchar.cxx | 4 ++-- .../src/express => dtool/src/dtoolutil}/vector_uchar.h | 10 ++++------ panda/src/express/p3express_composite2.cxx | 3 --- 9 files changed, 22 insertions(+), 28 deletions(-) rename {panda/src/express => dtool/src/dtoolutil}/vector_double.cxx (89%) rename {panda/src/express => dtool/src/dtoolutil}/vector_double.h (82%) rename {panda/src/express => dtool/src/dtoolutil}/vector_float.cxx (89%) rename {panda/src/express => dtool/src/dtoolutil}/vector_float.h (81%) rename {panda/src/express => dtool/src/dtoolutil}/vector_stdfloat.h (96%) rename {panda/src/express => dtool/src/dtoolutil}/vector_uchar.cxx (89%) rename {panda/src/express => dtool/src/dtoolutil}/vector_uchar.h (81%) diff --git a/dtool/src/dtoolutil/p3dtoolutil_composite2.cxx b/dtool/src/dtoolutil/p3dtoolutil_composite2.cxx index 2adf532173..10067c84fd 100644 --- a/dtool/src/dtoolutil/p3dtoolutil_composite2.cxx +++ b/dtool/src/dtoolutil/p3dtoolutil_composite2.cxx @@ -8,6 +8,9 @@ #include "stringDecoder.cxx" #include "textEncoder.cxx" #include "unicodeLatinMap.cxx" +#include "vector_double.cxx" +#include "vector_float.cxx" #include "vector_int.cxx" #include "vector_string.cxx" +#include "vector_uchar.cxx" #include "win32ArgParser.cxx" diff --git a/panda/src/express/vector_double.cxx b/dtool/src/dtoolutil/vector_double.cxx similarity index 89% rename from panda/src/express/vector_double.cxx rename to dtool/src/dtoolutil/vector_double.cxx index 165600e2a7..a6def549af 100644 --- a/panda/src/express/vector_double.cxx +++ b/dtool/src/dtoolutil/vector_double.cxx @@ -13,8 +13,8 @@ #include "vector_double.h" -#define EXPCL EXPCL_PANDAEXPRESS -#define EXPTP EXPTP_PANDAEXPRESS +#define EXPCL EXPCL_DTOOL +#define EXPTP EXPTP_DTOOL #define TYPE double #define NAME vector_double diff --git a/panda/src/express/vector_double.h b/dtool/src/dtoolutil/vector_double.h similarity index 82% rename from panda/src/express/vector_double.h rename to dtool/src/dtoolutil/vector_double.h index 1a36c1e425..6757bddc7a 100644 --- a/panda/src/express/vector_double.h +++ b/dtool/src/dtoolutil/vector_double.h @@ -14,19 +14,17 @@ #ifndef VECTOR_DOUBLE_H #define VECTOR_DOUBLE_H -#include "pandabase.h" - -#include "pvector.h" +#include "dtoolbase.h" /** * A vector of doubles. This class is defined once here, and exported to - * PANDA.DLL; other packages that want to use a vector of this type (whether + * DTOOL.DLL; other packages that want to use a vector of this type (whether * they need to export it or not) should include this header file, rather than * defining the vector again. */ -#define EXPCL EXPCL_PANDAEXPRESS -#define EXPTP EXPTP_PANDAEXPRESS +#define EXPCL EXPCL_DTOOL +#define EXPTP EXPTP_DTOOL #define TYPE double #define NAME vector_double diff --git a/panda/src/express/vector_float.cxx b/dtool/src/dtoolutil/vector_float.cxx similarity index 89% rename from panda/src/express/vector_float.cxx rename to dtool/src/dtoolutil/vector_float.cxx index cc0df9289c..a84b030a56 100644 --- a/panda/src/express/vector_float.cxx +++ b/dtool/src/dtoolutil/vector_float.cxx @@ -13,8 +13,8 @@ #include "vector_float.h" -#define EXPCL EXPCL_PANDAEXPRESS -#define EXPTP EXPTP_PANDAEXPRESS +#define EXPCL EXPCL_DTOOL +#define EXPTP EXPTP_DTOOL #define TYPE float #define NAME vector_float diff --git a/panda/src/express/vector_float.h b/dtool/src/dtoolutil/vector_float.h similarity index 81% rename from panda/src/express/vector_float.h rename to dtool/src/dtoolutil/vector_float.h index 862980b15a..36d9f200f9 100644 --- a/panda/src/express/vector_float.h +++ b/dtool/src/dtoolutil/vector_float.h @@ -14,19 +14,17 @@ #ifndef VECTOR_FLOAT_H #define VECTOR_FLOAT_H -#include "pandabase.h" - -#include "pvector.h" +#include "dtoolbase.h" /** * A vector of floats. This class is defined once here, and exported to - * PANDA.DLL; other packages that want to use a vector of this type (whether + * DTOOL.DLL; other packages that want to use a vector of this type (whether * they need to export it or not) should include this header file, rather than * defining the vector again. */ -#define EXPCL EXPCL_PANDAEXPRESS -#define EXPTP EXPTP_PANDAEXPRESS +#define EXPCL EXPCL_DTOOL +#define EXPTP EXPTP_DTOOL #define TYPE float #define NAME vector_float diff --git a/panda/src/express/vector_stdfloat.h b/dtool/src/dtoolutil/vector_stdfloat.h similarity index 96% rename from panda/src/express/vector_stdfloat.h rename to dtool/src/dtoolutil/vector_stdfloat.h index cecf6c18d8..e0100ae6fd 100644 --- a/panda/src/express/vector_stdfloat.h +++ b/dtool/src/dtoolutil/vector_stdfloat.h @@ -14,7 +14,7 @@ #ifndef VECTOR_STDFLOAT_H #define VECTOR_STDFLOAT_H -#include "pandabase.h" +#include "dtoolbase.h" #include "vector_double.h" #include "vector_float.h" diff --git a/panda/src/express/vector_uchar.cxx b/dtool/src/dtoolutil/vector_uchar.cxx similarity index 89% rename from panda/src/express/vector_uchar.cxx rename to dtool/src/dtoolutil/vector_uchar.cxx index 5463ef0724..07434032dd 100644 --- a/panda/src/express/vector_uchar.cxx +++ b/dtool/src/dtoolutil/vector_uchar.cxx @@ -13,8 +13,8 @@ #include "vector_uchar.h" -#define EXPCL EXPCL_PANDAEXPRESS -#define EXPTP EXPTP_PANDAEXPRESS +#define EXPCL EXPCL_DTOOL +#define EXPTP EXPTP_DTOOL #define TYPE unsigned char #define NAME vector_uchar diff --git a/panda/src/express/vector_uchar.h b/dtool/src/dtoolutil/vector_uchar.h similarity index 81% rename from panda/src/express/vector_uchar.h rename to dtool/src/dtoolutil/vector_uchar.h index ce6a1997bb..608472ae7e 100644 --- a/panda/src/express/vector_uchar.h +++ b/dtool/src/dtoolutil/vector_uchar.h @@ -14,19 +14,17 @@ #ifndef VECTOR_UCHAR_H #define VECTOR_UCHAR_H -#include "pandabase.h" - -#include "pvector.h" +#include "dtoolbase.h" /** * A vector of uchars. This class is defined once here, and exported to - * PANDAEXPRESS.DLL; other packages that want to use a vector of this type + * DTOOL.DLL; other packages that want to use a vector of this type * (whether they need to export it or not) should include this header file, * rather than defining the vector again. */ -#define EXPCL EXPCL_PANDAEXPRESS -#define EXPTP EXPTP_PANDAEXPRESS +#define EXPCL EXPCL_DTOOL +#define EXPTP EXPTP_DTOOL #define TYPE unsigned char #define NAME vector_uchar diff --git a/panda/src/express/p3express_composite2.cxx b/panda/src/express/p3express_composite2.cxx index 95c8b0e5fb..5caa03986d 100644 --- a/panda/src/express/p3express_composite2.cxx +++ b/panda/src/express/p3express_composite2.cxx @@ -12,9 +12,6 @@ #include "threadSafePointerToBase.cxx" #include "trueClock.cxx" #include "typedReferenceCount.cxx" -#include "vector_uchar.cxx" -#include "vector_double.cxx" -#include "vector_float.cxx" #include "virtualFile.cxx" #include "virtualFileComposite.cxx" #include "virtualFileList.cxx" From 8a7b47d501d46fbc9e37aa86f3a010ee733187d3 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 4 Feb 2018 23:06:34 -0700 Subject: [PATCH 004/247] audio: Fix memory leak in OpenAL --- panda/src/audiotraits/openalAudioManager.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/panda/src/audiotraits/openalAudioManager.cxx b/panda/src/audiotraits/openalAudioManager.cxx index 2e82a9c718..8d38eeec49 100644 --- a/panda/src/audiotraits/openalAudioManager.cxx +++ b/panda/src/audiotraits/openalAudioManager.cxx @@ -443,6 +443,7 @@ get_sound_data(MovieAudio *movie, int mode) { alBufferData(sd->_sample, (channels>1) ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16, data, samples * channels * 2, stream->audio_rate()); + delete[] data; int err = alGetError(); if (err != AL_NO_ERROR) { audio_error("could not fill OpenAL buffer object with data"); From 2dba9357bb626a9b61ea0d7f64c8c853291ee3cc Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 6 Feb 2018 19:22:09 +0100 Subject: [PATCH 005/247] makepanda: update Android cross-compile for clang and NDK r16 Tested on Windows. --- makepanda/makepanda.py | 81 ++++++++++++++------- makepanda/makepandacore.py | 141 ++++++++++++++++++++----------------- 2 files changed, 134 insertions(+), 88 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index b00c947208..2f21483e78 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -821,9 +821,6 @@ if (COMPILER=="GCC"): SmartPkgEnable("FREETYPE", "freetype2", ("freetype"), ("freetype2", "freetype2/freetype/freetype.h")) SmartPkgEnable("HARFBUZZ", "harfbuzz", ("harfbuzz"), ("harfbuzz", "harfbuzz/hb-ft.h")) SmartPkgEnable("GL", "gl", ("GL"), ("GL/gl.h"), framework = "OpenGL") - SmartPkgEnable("GLES", "glesv1_cm", ("GLESv1_CM"), ("GLES/gl.h"), framework = "OpenGLES") - SmartPkgEnable("GLES2", "glesv2", ("GLESv2"), ("GLES2/gl2.h")) #framework = "OpenGLES"? - SmartPkgEnable("EGL", "egl", ("EGL"), ("EGL/egl.h")) SmartPkgEnable("NVIDIACG", "", ("Cg"), "Cg/cg.h", framework = "Cg") SmartPkgEnable("ODE", "", ("ode"), "ode/ode.h", tool = "ode-config") SmartPkgEnable("OPENAL", "openal", ("openal"), "AL/al.h", framework = "OpenAL") @@ -837,6 +834,12 @@ if (COMPILER=="GCC"): SmartPkgEnable("JPEG", "", ("jpeg"), "jpeglib.h") SmartPkgEnable("PNG", "libpng", ("png"), "png.h", tool = "libpng-config") + # On Android, these are system libraries. + if GetHost() != "android": + SmartPkgEnable("GLES", "glesv1_cm", (), ("GLES/gl.h"), framework = "OpenGLES") + SmartPkgEnable("GLES2", "glesv2", (), ("GLES2/gl2.h")) #framework = "OpenGLES"? + SmartPkgEnable("EGL", "egl", (), ("EGL/egl.h")) + if not PkgSkip("FFMPEG"): if GetTarget() == "darwin": LibName("FFMPEG", "-Wl,-read_only_relocs,suppress") @@ -1251,7 +1254,13 @@ def CompileCxx(obj,src,opts): cmd += " -arch %s" % arch if "SYSROOT" in SDK: - cmd += ' --sysroot=%s -no-canonical-prefixes' % (SDK["SYSROOT"]) + if GetTarget() != "android": + cmd += ' --sysroot=%s' % (SDK["SYSROOT"]) + else: + ndk_dir = SDK["ANDROID_NDK"].replace('\\', '/') + cmd += ' -isystem %s/sysroot/usr/include' % (ndk_dir) + cmd += ' -isystem %s/sysroot/usr/include/%s' % (ndk_dir, SDK["ANDROID_TRIPLE"]) + cmd += ' -no-canonical-prefixes' # Android-specific flags. arch = GetTargetArch() @@ -1261,33 +1270,38 @@ def CompileCxx(obj,src,opts): # just copied from the default Android Makefiles. if "ANDROID_API" in SDK: cmd += ' -D__ANDROID_API__=' + str(SDK["ANDROID_API"]) - if "ANDROID_STL" in SDK: - cmd += ' -I%s/include' % (SDK["ANDROID_STL"]) - cmd += ' -I%s/libs/%s/include' % (SDK["ANDROID_STL"], SDK["ANDROID_ABI"]) + if "ANDROID_GCC_TOOLCHAIN" in SDK: + cmd += ' -gcc-toolchain ' + SDK["ANDROID_GCC_TOOLCHAIN"].replace('\\', '/') cmd += ' -ffunction-sections -funwind-tables' if arch == 'armv7a': - cmd += ' -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__' - cmd += ' -fstack-protector -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16' + cmd += ' -target armv7-none-linux-androideabi' + cmd += ' -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16' + cmd += ' -fno-integrated-as' elif arch == 'arm': - cmd += ' -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__' - cmd += ' -fstack-protector -march=armv5te -mtune=xscale -msoft-float' + cmd += ' -target armv5te-none-linux-androideabi' + cmd += ' -march=armv5te -mtune=xscale -msoft-float' + cmd += ' -fno-integrated-as' + elif arch == 'aarch64': + cmd += ' -target aarch64-none-linux-android' elif arch == 'mips': - cmd += ' -finline-functions -fmessage-length=0' - cmd += ' -fno-inline-functions-called-once -fgcse-after-reload' - cmd += ' -frerun-cse-after-loop -frename-registers' + cmd += ' -target mipsel-none-linux-android' + cmd += ' -mips32' + elif arch == 'mips64': + cmd += ' -target mips64el-none-linux-android' + cmd += ' -fintegrated-as' + elif arch == 'x86': + cmd += ' -target i686-none-linux-android' + cmd += ' -mstackrealign' + elif arch == 'x86_64': + cmd += ' -target x86_64-none-linux-android' cmd += " -Wa,--noexecstack" - # Now add specific release/debug flags. - if optlevel >= 3: - cmd += " -fomit-frame-pointer" - if arch.startswith('arm'): - cmd += ' -finline-limit=64 -mthumb' - elif arch == 'mips': - cmd += ' -funswitch-loops -finline-limit=300' - else: - cmd += ' -fno-omit-frame-pointer' - if arch.startswith('arm'): + # Do we want thumb or arm instructions? + if arch.startswith('arm'): + if optlevel >= 3: + cmd += ' -mthumb' + else: cmd += ' -marm' # Enable SIMD instructions if requested @@ -1745,9 +1759,26 @@ def CompileLink(dll, obj, opts): cmd += " -arch %s" % arch elif GetTarget() == 'android': + arch = GetTargetArch() + if "ANDROID_GCC_TOOLCHAIN" in SDK: + cmd += ' -gcc-toolchain ' + SDK["ANDROID_GCC_TOOLCHAIN"].replace('\\', '/') cmd += " -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now" - if GetTargetArch() == 'armv7a': + if arch == 'armv7a': + cmd += ' -target armv7-none-linux-androideabi' cmd += " -march=armv7-a -Wl,--fix-cortex-a8" + elif arch == 'arm': + cmd += ' -target armv5te-none-linux-androideabi' + elif arch == 'aarch64': + cmd += ' -target aarch64-none-linux-android' + elif arch == 'mips': + cmd += ' -target mipsel-none-linux-android' + cmd += ' -mips32' + elif arch == 'mips64': + cmd += ' -target mips64el-none-linux-android' + elif arch == 'x86': + cmd += ' -target i686-none-linux-android' + elif arch == 'x86_64': + cmd += ' -target x86_64-none-linux-android' cmd += ' -lc -lm' else: cmd += " -pthread" diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 75211d3979..bc0cdc7549 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -37,7 +37,8 @@ TARGET_ARCH = None HAS_TARGET_ARCH = False TOOLCHAIN_PREFIX = "" ANDROID_ABI = None -ANDROID_API = 14 +ANDROID_TRIPLE = None +ANDROID_API = None SYS_LIB_DIRS = [] SYS_INC_DIRS = [] DEBUG_DEPENDENCIES = False @@ -359,40 +360,48 @@ def SetTarget(target, arch=None): if host == 'android': arch = host_arch else: - arch = 'arm' + arch = 'armv7a' # Did we specify an API level? + global ANDROID_API target, _, api = target.partition('-') if api: - global ANDROID_API ANDROID_API = int(api) + elif arch in ('mips64', 'aarch64', 'x86_64'): + # 64-bit platforms were introduced in Android 21. + ANDROID_API = 21 + else: + # Default to the lowest API level supported by NDK r16. + ANDROID_API = 14 # Determine the prefix for our gcc tools, eg. arm-linux-androideabi-gcc - global ANDROID_ABI + global ANDROID_ABI, ANDROID_TRIPLE if arch == 'armv7a': ANDROID_ABI = 'armeabi-v7a' - TOOLCHAIN_PREFIX = 'arm-linux-androideabi-' + ANDROID_TRIPLE = 'arm-linux-androideabi' elif arch == 'arm': ANDROID_ABI = 'armeabi' - TOOLCHAIN_PREFIX = 'arm-linux-androideabi-' + ANDROID_TRIPLE = 'arm-linux-androideabi' elif arch == 'aarch64': ANDROID_ABI = 'arm64-v8a' - TOOLCHAIN_PREFIX = 'aarch64-linux-android-' + ANDROID_TRIPLE = 'aarch64-linux-android' elif arch == 'mips': ANDROID_ABI = 'mips' - TOOLCHAIN_PREFIX = 'mipsel-linux-android-' + ANDROID_TRIPLE = 'mipsel-linux-android' elif arch == 'mips64': ANDROID_ABI = 'mips64' - TOOLCHAIN_PREFIX = 'mips64el-linux-android-' + ANDROID_TRIPLE = 'mips64el-linux-android' elif arch == 'x86': ANDROID_ABI = 'x86' - TOOLCHAIN_PREFIX = 'i686-linux-android-' + ANDROID_TRIPLE = 'i686-linux-android' elif arch == 'x86_64': ANDROID_ABI = 'x86_64' - TOOLCHAIN_PREFIX = 'x86_64-linux-android-' + ANDROID_TRIPLE = 'x86_64-linux-android' else: exit('Android architecture must be arm, armv7a, aarch64, mips, mips64, x86 or x86_64') + TOOLCHAIN_PREFIX = ANDROID_TRIPLE + '-' + elif target == 'linux': if arch is not None: TOOLCHAIN_PREFIX = '%s-linux-gnu-' % arch @@ -2359,6 +2368,8 @@ def SdkLocateAndroid(): """This actually locates the Android NDK, not the Android SDK. NDK_ROOT must be set to its root directory.""" + global TOOLCHAIN_PREFIX + if GetTarget() != 'android': return @@ -2368,6 +2379,7 @@ def SdkLocateAndroid(): abi = ANDROID_ABI SDK["ANDROID_ABI"] = abi + SDK["ANDROID_TRIPLE"] = ANDROID_TRIPLE if GetHost() == 'android': return @@ -2383,36 +2395,58 @@ def SdkLocateAndroid(): SDK["ANDROID_NDK"] = ndk_root # Determine the toolchain location. - gcc_ver = '4.8' + prebuilt_dir = os.path.join(ndk_root, 'toolchains', 'llvm', 'prebuilt') + if not os.path.isdir(prebuilt_dir): + exit('Not found: %s' % (prebuilt_dir)) + + host_tag = GetHost() + '-x86' + if host_64: + host_tag += '_64' + elif host_tag == 'windows-x86': + host_tag = 'windows' + + prebuilt_dir = os.path.join(prebuilt_dir, host_tag) + if host_tag == 'windows-x86_64' and not os.path.isdir(prebuilt_dir): + # Try the 32-bits toolchain instead. + host_tag = 'windows' + prebuilt_dir = os.path.join(prebuilt_dir, host_tag) + + SDK["ANDROID_TOOLCHAIN"] = prebuilt_dir + + # And locate the GCC toolchain, which is needed for some tools (eg. as/ld) arch = GetTargetArch() - if arch == 'armv7a' or arch == 'arm': - arch = 'arm' - toolchain = 'arm-linux-androideabi-' + gcc_ver - elif arch == 'aarch64': - toolchain = 'aarch64-linux-android-' + gcc_ver - elif arch == 'mips': - toolchain = 'mipsel-linux-android-' + gcc_ver - elif arch == 'mips64': - toolchain = 'mips64el-linux-android-' + gcc_ver - elif arch == 'x86': - toolchain = 'x86-' + gcc_ver - elif arch == 'x86_64': - toolchain = 'x86_64-' + gcc_ver - SDK["ANDROID_TOOLCHAIN"] = os.path.join(ndk_root, 'toolchains', toolchain) + for opt in (TOOLCHAIN_PREFIX + '4.9', arch + '-4.9', TOOLCHAIN_PREFIX + '4.8', arch + '-4.8'): + if os.path.isdir(os.path.join(ndk_root, 'toolchains', opt)): + SDK["ANDROID_GCC_TOOLCHAIN"] = os.path.join(ndk_root, 'toolchains', opt, 'prebuilt', host_tag) + break + + # The prebuilt binaries have no toolchain prefix. + TOOLCHAIN_PREFIX = '' # Determine the sysroot directory. - SDK["SYSROOT"] = os.path.join(ndk_root, 'platforms', 'android-%s' % (api), 'arch-%s' % (arch)) + if arch == 'armv7a': + arch_dir = 'arch-arm' + elif arch == 'aarch64': + arch_dir = 'arch-arm64' + else: + arch_dir = 'arch-' + arch + SDK["SYSROOT"] = os.path.join(ndk_root, 'platforms', 'android-%s' % (api), arch_dir).replace('\\', '/') #IncDirectory("ALWAYS", os.path.join(SDK["SYSROOT"], 'usr', 'include')) - stdlibc = os.path.join(ndk_root, 'sources', 'cxx-stl', 'gnu-libstdc++', gcc_ver) - SDK["ANDROID_STL"] = stdlibc + # Starting with NDK r16, libc++ is the recommended STL to use. + stdlibc = os.path.join(ndk_root, 'sources', 'cxx-stl', 'llvm-libc++') + IncDirectory("ALWAYS", os.path.join(stdlibc, 'include').replace('\\', '/')) + LibDirectory("ALWAYS", os.path.join(stdlibc, 'libs', abi).replace('\\', '/')) - #IncDirectory("ALWAYS", os.path.join(stdlibc, 'include')) - #IncDirectory("ALWAYS", os.path.join(stdlibc, 'libs', abi, 'include')) + stl_lib = os.path.join(stdlibc, 'libs', abi, 'libc++_shared.so') + LibName("ALWAYS", stl_lib.replace('\\', '/')) + CopyFile(os.path.join(GetOutputDir(), 'lib', 'libc++_shared.so'), stl_lib) - stl_lib = os.path.join(stdlibc, 'libs', abi, 'libgnustl_shared.so') - LibName("ALWAYS", stl_lib) - CopyFile(os.path.join(GetOutputDir(), 'libs', abi, 'libgnustl_shared.so'), stl_lib) + # The Android support library polyfills C++ features not available in the + # STL that ships with Android. + support = os.path.join(ndk_root, 'sources', 'android', 'support', 'include') + IncDirectory("ALWAYS", support.replace('\\', '/')) + LibName("ALWAYS", "-landroid_support") ######################################################################## ## @@ -2675,6 +2709,10 @@ def SetupBuildEnvironment(compiler): os.environ["LC_ALL"] = "en_US.UTF-8" os.environ["LANGUAGE"] = "en" + # In the case of Android, we have to put the toolchain on the PATH in order to use it. + if GetTarget() == 'android' and GetHost() != 'android': + AddToPathEnv("PATH", os.path.join(SDK["ANDROID_TOOLCHAIN"], "bin")) + if compiler == "MSVC": # Add the visual studio tools to PATH et al. SetupVisualStudioEnviron() @@ -2709,11 +2747,15 @@ def SetupBuildEnvironment(compiler): continue line = line[12:].strip() - for libdir in line.split(':'): - libdir = os.path.normpath(libdir) + libdirs = line.split(':') + while libdirs: + libdir = os.path.normpath(libdirs.pop(0)) if os.path.isdir(libdir): if libdir not in SYS_LIB_DIRS: SYS_LIB_DIRS.append(libdir) + elif len(libdir) == 1: + # Oops, is this a drive letter? Prepend it to the next. + libdirs[0] = libdir + ':' + libdirs[0] elif GetVerbose(): print("Ignoring non-existent library directory %s" % (libdir)) @@ -2771,33 +2813,6 @@ def SetupBuildEnvironment(compiler): for dir in SYS_INC_DIRS: print(" " + dir) - # In the case of Android, we have to put the toolchain on the PATH in order to use it. - if GetTarget() == 'android' and GetHost() != 'android': - # Locate the directory where the toolchain binaries reside. - prebuilt_dir = os.path.join(SDK['ANDROID_TOOLCHAIN'], 'prebuilt') - if not os.path.isdir(prebuilt_dir): - exit('Not found: %s' % (prebuilt_dir)) - - host_tag = GetHost() + '-x86' - if host_64: - host_tag += '_64' - elif host_tag == 'windows-x86': - host_tag = 'windows' - - prebuilt_dir = os.path.join(prebuilt_dir, host_tag) - if host_64 and not os.path.isdir(prebuilt_dir): - # Try the 32-bits toolchain instead. - prebuilt_dir = os.path.join(prebuilt_dir, host_tag) - - if not os.path.isdir(prebuilt_dir): - if host_64: - exit('Not found: %s or %s' % (prebuilt_dir, host_tag)) - else: - exit('Not found: %s' % (prebuilt_dir)) - - # Then, add it to the PATH. - AddToPathEnv("PATH", os.path.join(prebuilt_dir, 'bin')) - # If we're cross-compiling, no point in putting our output dirs on the path. if CrossCompiling(): return From c1fccd311bf0978b8a5edc8c99ebee124b60252c Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 6 Feb 2018 22:31:02 +0100 Subject: [PATCH 006/247] android: properly support multiple Java threads --- panda/src/android/PandaActivity.java | 4 + panda/src/android/android_main.cxx | 34 ++++++-- panda/src/android/config_android.cxx | 9 ++- .../src/android/pnmFileTypeAndroidReader.cxx | 9 ++- panda/src/express/config_express.cxx | 37 --------- panda/src/express/config_express.h | 9 --- panda/src/pipeline/thread.I | 11 +++ panda/src/pipeline/thread.h | 8 ++ panda/src/pipeline/threadPosixImpl.I | 16 ++++ panda/src/pipeline/threadPosixImpl.cxx | 77 ++++++++++++++++--- panda/src/pipeline/threadPosixImpl.h | 14 ++++ 11 files changed, 163 insertions(+), 65 deletions(-) diff --git a/panda/src/android/PandaActivity.java b/panda/src/android/PandaActivity.java index feba4baa4e..8f3240900e 100644 --- a/panda/src/android/PandaActivity.java +++ b/panda/src/android/PandaActivity.java @@ -41,6 +41,10 @@ public class PandaActivity extends NativeActivity { return BitmapFactory.decodeStream(stream, null, options); } + protected static String getCurrentThreadName() { + return Thread.currentThread().getName(); + } + static { System.loadLibrary("gnustl_shared"); System.loadLibrary("p3dtool"); diff --git a/panda/src/android/android_main.cxx b/panda/src/android/android_main.cxx index 32c692489f..8a3d6135fd 100644 --- a/panda/src/android/android_main.cxx +++ b/panda/src/android/android_main.cxx @@ -16,6 +16,7 @@ #include "virtualFileMountAndroidAsset.h" #include "virtualFileSystem.h" #include "filename.h" +#include "thread.h" #include "config_display.h" // #define OPENGLES_1 #include "config_androiddisplay.h" @@ -29,21 +30,44 @@ extern int main(int argc, char **argv); /** * This function is called by native_app_glue to initialize the program. It * simply stores the android_app object and calls main() normally. + * + * Note that this does not run in the main thread, but in a thread created + * specifically for this activity by android_native_app_glue. */ void android_main(struct android_app* app) { panda_android_app = app; - // Attach the current thread to the JVM. + // Attach the app thread to the Java VM. JNIEnv *env; ANativeActivity* activity = app->activity; - int status = activity->vm->AttachCurrentThread(&env, NULL); - if (status < 0 || env == NULL) { + int status = activity->vm->AttachCurrentThread(&env, nullptr); + if (status < 0 || env == nullptr) { android_cat.error() << "Failed to attach thread to JVM!\n"; return; } - // Fetch the data directory. jclass activity_class = env->GetObjectClass(activity->clazz); + + // Get the current Java thread name. This just helps with debugging. + jmethodID methodID = env->GetStaticMethodID(activity_class, "getCurrentThreadName", "()Ljava/lang/String;"); + jstring jthread_name = (jstring) env->CallStaticObjectMethod(activity_class, methodID); + + string thread_name; + if (jthread_name != nullptr) { + const char *c_str = env->GetStringUTFChars(jthread_name, nullptr); + thread_name.assign(c_str); + env->ReleaseStringUTFChars(jthread_name, c_str); + } + + // Before we make any Panda calls, we must make the thread known to Panda. + // This will also cause the JNIEnv pointer to be stored on the thread. + // Note that we must keep a reference to this thread around. + PT(Thread) current_thread = Thread::bind_thread(thread_name, "android_app"); + + android_cat.info() + << "New native activity started on " << *current_thread << "\n"; + + // Fetch the data directory. jmethodID get_appinfo = env->GetMethodID(activity_class, "getApplicationInfo", "()Landroid/content/pm/ApplicationInfo;"); jobject appinfo = env->CallObjectMethod(activity->clazz, get_appinfo); @@ -77,7 +101,7 @@ void android_main(struct android_app* app) { } // Get the path to the APK. - jmethodID methodID = env->GetMethodID(activity_class, "getPackageCodePath", "()Ljava/lang/String;"); + methodID = env->GetMethodID(activity_class, "getPackageCodePath", "()Ljava/lang/String;"); jstring code_path = (jstring) env->CallObjectMethod(activity->clazz, methodID); const char* apk_path; diff --git a/panda/src/android/config_android.cxx b/panda/src/android/config_android.cxx index bf9056c562..92d986669d 100644 --- a/panda/src/android/config_android.cxx +++ b/panda/src/android/config_android.cxx @@ -49,8 +49,9 @@ init_libandroid() { jint JNI_OnLoad(JavaVM *jvm, void *reserved) { init_libandroid(); - JNIEnv *env = get_jni_env(); - assert(env != NULL); + Thread *thread = Thread::get_current_thread(); + JNIEnv *env = thread->get_jni_env(); + nassertr(env != nullptr, -1); jni_PandaActivity = env->FindClass("org/panda3d/android/PandaActivity"); jni_PandaActivity = (jclass) env->NewGlobalRef(jni_PandaActivity); @@ -75,7 +76,9 @@ jint JNI_OnLoad(JavaVM *jvm, void *reserved) { * references. */ void JNI_OnUnload(JavaVM *jvm, void *reserved) { - JNIEnv *env = get_jni_env(); + Thread *thread = Thread::get_current_thread(); + JNIEnv *env = thread->get_jni_env(); + nassertv(env != nullptr); env->DeleteGlobalRef(jni_PandaActivity); env->DeleteGlobalRef(jni_BitmapFactory_Options); diff --git a/panda/src/android/pnmFileTypeAndroidReader.cxx b/panda/src/android/pnmFileTypeAndroidReader.cxx index 50c69cb59c..ac95ce98fd 100644 --- a/panda/src/android/pnmFileTypeAndroidReader.cxx +++ b/panda/src/android/pnmFileTypeAndroidReader.cxx @@ -76,7 +76,14 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : } streampos pos = _file->tellg(); - _env = get_jni_env(); + + Thread *current_thread = Thread::get_current_thread(); + _env = current_thread->get_jni_env(); + nassertd(_env != nullptr) { + _is_valid = false; + return; + } + jobject opts = _env->CallStaticObjectMethod(jni_PandaActivity, jni_PandaActivity_readBitmapSize, (jlong) _file); diff --git a/panda/src/express/config_express.cxx b/panda/src/express/config_express.cxx index dd590fcb38..042b6d8db1 100644 --- a/panda/src/express/config_express.cxx +++ b/panda/src/express/config_express.cxx @@ -194,40 +194,3 @@ get_config_express() { static DConfig config_express; return config_express; } - -#ifdef ANDROID -static JavaVM *panda_jvm = NULL; - -/** - * Called by Java when loading this library. - */ -jint JNI_OnLoad(JavaVM *jvm, void *reserved) { - panda_jvm = jvm; - return JNI_VERSION_1_4; -} - -/** - * Returns a pointer to the JavaVM object. - */ -JavaVM *get_java_vm() { - nassertr(panda_jvm != NULL, NULL); - return panda_jvm; -} - -/** - * Returns a JNIEnv object for the current thread. If it doesn't already - * exist, attaches the JVM to this thread. - */ -JNIEnv *get_jni_env() { - nassertr(panda_jvm != NULL, NULL); - JNIEnv *env = NULL; - int status = panda_jvm->GetEnv((void**) &env, JNI_VERSION_1_4); - - if (status < 0 || env == NULL) { - express_cat.error() << "JVM is not available in this thread!\n"; - return NULL; - } - - return env; -} -#endif diff --git a/panda/src/express/config_express.h b/panda/src/express/config_express.h index 53f33ca36a..eabe20f834 100644 --- a/panda/src/express/config_express.h +++ b/panda/src/express/config_express.h @@ -28,10 +28,6 @@ #include "executionEnvironment.h" #include "lineStream.h" -#ifdef ANDROID -#include -#endif - ConfigureDecl(config_express, EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS); NotifyCategoryDecl(express, EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS); NotifyCategoryDecl(clock, EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS); @@ -65,9 +61,4 @@ END_PUBLISH extern EXPCL_PANDAEXPRESS void init_libexpress(); -#ifdef ANDROID -extern EXPCL_PANDAEXPRESS JavaVM *get_java_vm(); -extern EXPCL_PANDAEXPRESS JNIEnv *get_jni_env(); -#endif - #endif /* __CONFIG_UTIL_H__ */ diff --git a/panda/src/pipeline/thread.I b/panda/src/pipeline/thread.I index 4fcd8a447e..10d7b6e44f 100644 --- a/panda/src/pipeline/thread.I +++ b/panda/src/pipeline/thread.I @@ -300,6 +300,17 @@ prepare_for_exit() { ThreadImpl::prepare_for_exit(); } +#ifdef ANDROID +/** + * Enables interaction with the Java VM on Android. Returns null if the + * thread is not attached to the Java VM (or bind_thread was not called). + */ +INLINE JNIEnv *Thread:: +get_jni_env() const { + return _impl.get_jni_env(); +} +#endif + /** * Stores a PStats index to be associated with this thread. This is used * internally by the PStatClient; you should not need to call this directly. diff --git a/panda/src/pipeline/thread.h b/panda/src/pipeline/thread.h index b519aa75a6..730deb5872 100644 --- a/panda/src/pipeline/thread.h +++ b/panda/src/pipeline/thread.h @@ -23,6 +23,10 @@ #include "pnotify.h" #include "config_pipeline.h" +#ifdef ANDROID +typedef struct _JNIEnv JNIEnv; +#endif + class Mutex; class ReMutex; class MutexDebug; @@ -128,6 +132,10 @@ public: INLINE void set_pstats_callback(PStatsCallback *pstats_callback); INLINE PStatsCallback *get_pstats_callback() const; +#ifdef ANDROID + INLINE JNIEnv *get_jni_env() const; +#endif + private: static void init_main_thread(); static void init_external_thread(); diff --git a/panda/src/pipeline/threadPosixImpl.I b/panda/src/pipeline/threadPosixImpl.I index 93bdce8e8c..62b6026061 100644 --- a/panda/src/pipeline/threadPosixImpl.I +++ b/panda/src/pipeline/threadPosixImpl.I @@ -21,6 +21,9 @@ ThreadPosixImpl(Thread *parent_obj) : _joinable = false; _detached = false; _status = S_new; +#ifdef ANDROID + _jni_env = nullptr; +#endif } /** @@ -60,6 +63,9 @@ bind_thread(Thread *thread) { } int result = pthread_setspecific(_pt_ptr_index, thread); nassertv(result == 0); +#ifdef ANDROID + bind_java_thread(); +#endif } /** @@ -112,3 +118,13 @@ yield() { INLINE void ThreadPosixImpl:: consider_yield() { } + +#ifdef ANDROID +/** + * Returns the JNIEnv object for the current thread. + */ +INLINE JNIEnv *ThreadPosixImpl:: +get_jni_env() const { + return _jni_env; +} +#endif diff --git a/panda/src/pipeline/threadPosixImpl.cxx b/panda/src/pipeline/threadPosixImpl.cxx index 54b3dfd630..5104c67926 100644 --- a/panda/src/pipeline/threadPosixImpl.cxx +++ b/panda/src/pipeline/threadPosixImpl.cxx @@ -24,6 +24,8 @@ #ifdef ANDROID #include "config_express.h" #include + +static JavaVM *java_vm = nullptr; #endif pthread_key_t ThreadPosixImpl::_pt_ptr_index = 0; @@ -183,6 +185,53 @@ get_unique_id() const { return strm.str(); } +#ifdef ANDROID +/** + * Attaches the thread to the Java virtual machine. If this returns true, a + * JNIEnv pointer can be acquired using get_jni_env(). + */ +bool ThreadPosixImpl:: +attach_java_vm() { + JNIEnv *env; + string thread_name = _parent_obj->get_name(); + JavaVMAttachArgs args; + args.version = JNI_VERSION_1_2; + args.name = thread_name.c_str(); + args.group = nullptr; + if (java_vm->AttachCurrentThread(&env, &args) != 0) { + thread_cat.error() + << "Failed to attach Java VM to thread " + << _parent_obj->get_name() << "!\n"; + _jni_env = nullptr; + return false; + } + _jni_env = env; + return true; +} + +/** + * Binds the Panda thread to the current thread, assuming that the current + * thread is already a valid attached Java thread. Called by JNI_OnLoad. + */ +void ThreadPosixImpl:: +bind_java_thread() { + Thread *thread = Thread::get_current_thread(); + nassertv(thread != nullptr); + + // Get the JNIEnv for this Java thread, and store it on the corresponding + // Panda thread object. + JNIEnv *env; + if (java_vm->GetEnv((void **)&env, JNI_VERSION_1_4) == JNI_OK) { + nassertv(thread->_impl._jni_env == nullptr || thread->_impl._jni_env == env); + thread->_impl._jni_env = env; + } else { + thread_cat->error() + << "Called bind_java_thread() on thread " + << *thread << ", which is not attached to Java VM!\n"; + } +} +#endif // ANDROID + /** * The entry point of each thread. */ @@ -209,14 +258,7 @@ root_func(void *data) { #ifdef ANDROID // Attach the Java VM to allow calling Java functions in this thread. - JavaVM *jvm = get_java_vm(); - JNIEnv *env; - if (jvm == NULL || jvm->AttachCurrentThread(&env, NULL) != 0) { - thread_cat.error() - << "Failed to attach Java VM to thread " - << self->_parent_obj->get_name() << "!\n"; - env = NULL; - } + self->attach_java_vm(); #endif self->_parent_obj->thread_main(); @@ -238,8 +280,10 @@ root_func(void *data) { } #ifdef ANDROID - if (env != NULL) { - jvm->DetachCurrentThread(); + // We cannot let the thread end without detaching it. + if (self->_jni_env != nullptr) { + java_vm->DetachCurrentThread(); + self->_jni_env = nullptr; } #endif @@ -276,4 +320,17 @@ init_pt_ptr_index() { nassertv(result == 0); } +#ifdef ANDROID +/** + * Called by Java when loading this library from the Java virtual machine. + */ +jint JNI_OnLoad(JavaVM *jvm, void *reserved) { + // Store the JVM pointer globally. + java_vm = jvm; + + ThreadPosixImpl::bind_java_thread(); + return JNI_VERSION_1_4; +} +#endif // ANDROID + #endif // THREAD_POSIX_IMPL diff --git a/panda/src/pipeline/threadPosixImpl.h b/panda/src/pipeline/threadPosixImpl.h index 0168c38665..ee279c98dd 100644 --- a/panda/src/pipeline/threadPosixImpl.h +++ b/panda/src/pipeline/threadPosixImpl.h @@ -25,6 +25,10 @@ #include +#ifdef ANDROID +typedef struct _JNIEnv JNIEnv; +#endif + class Thread; /** @@ -53,6 +57,12 @@ public: INLINE static void yield(); INLINE static void consider_yield(); +#ifdef ANDROID + INLINE JNIEnv *get_jni_env() const; + bool attach_java_vm(); + static void bind_java_thread(); +#endif + private: static void *root_func(void *data); static void init_pt_ptr_index(); @@ -72,6 +82,10 @@ private: bool _detached; PStatus _status; +#ifdef ANDROID + JNIEnv *_jni_env; +#endif + static pthread_key_t _pt_ptr_index; static bool _got_pt_ptr_index; }; From 10789f6936dc7fd8ac67e4e69d45208ff73c0d70 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 6 Feb 2018 22:33:34 +0100 Subject: [PATCH 007/247] android: fix issue loading some image files --- panda/src/android/pnmFileTypeAndroid.cxx | 5 ++++- panda/src/android/pnmFileTypeAndroidReader.cxx | 1 + panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/panda/src/android/pnmFileTypeAndroid.cxx b/panda/src/android/pnmFileTypeAndroid.cxx index fae5d147c4..c661c6b3b0 100644 --- a/panda/src/android/pnmFileTypeAndroid.cxx +++ b/panda/src/android/pnmFileTypeAndroid.cxx @@ -21,7 +21,10 @@ #include "bamReader.h" static const char * const extensions_android[] = { - "jpg", "jpeg", "gif", "png",//"webp" (android 4.0+) + "jpg", "jpeg", "gif", "png", +#if __ANDROID_API__ >= 14 + "webp" +#endif }; static const int num_extensions_android = sizeof(extensions_android) / sizeof(const char *); diff --git a/panda/src/android/pnmFileTypeAndroidReader.cxx b/panda/src/android/pnmFileTypeAndroidReader.cxx index ac95ce98fd..e18ebcbaea 100644 --- a/panda/src/android/pnmFileTypeAndroidReader.cxx +++ b/panda/src/android/pnmFileTypeAndroidReader.cxx @@ -87,6 +87,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : jobject opts = _env->CallStaticObjectMethod(jni_PandaActivity, jni_PandaActivity_readBitmapSize, (jlong) _file); + _file->clear(); _file->seekg(pos); if (_file->tellg() != pos) { android_cat.error() diff --git a/panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx b/panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx index a87aae11f6..e17e0e9df8 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx @@ -62,7 +62,7 @@ static const char *const stb_extensions[] = { // Expose the extensions that we don't already expose through other loaders. -#ifndef HAVE_JPEG +#if !defined(HAVE_JPEG) && !defined(ANDROID) "jpg", "jpeg", #endif #ifndef HAVE_PNG From ae0f82911b46dae28498b42168ca99ab215bf798 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 6 Feb 2018 22:36:21 +0100 Subject: [PATCH 008/247] android: allow launching pview by opening models (using Intents) Also add code to show notification toasts. Also enable model cache by default (pointing to app cache dir) --- panda/src/android/PandaActivity.java | 44 +++++++++++++++++++++++----- panda/src/android/android_main.cxx | 44 ++++++++++++++++++++++++++-- panda/src/android/config_android.cxx | 18 ++++++++++++ panda/src/android/config_android.h | 4 +++ panda/src/android/pview.cxx | 16 ++++++---- panda/src/android/pview_manifest.xml | 40 +++++++++++++++++++++++-- 6 files changed, 147 insertions(+), 19 deletions(-) diff --git a/panda/src/android/PandaActivity.java b/panda/src/android/PandaActivity.java index 8f3240900e..91e6c38533 100644 --- a/panda/src/android/PandaActivity.java +++ b/panda/src/android/PandaActivity.java @@ -14,6 +14,9 @@ package org.panda3d.android; import android.app.NativeActivity; +import android.content.Intent; +import android.net.Uri; +import android.widget.Toast; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import org.panda3d.android.NativeIStream; @@ -45,14 +48,41 @@ public class PandaActivity extends NativeActivity { return Thread.currentThread().getName(); } + public String getIntentDataPath() { + Intent intent = getIntent(); + Uri data = intent.getData(); + if (data == null) { + return null; + } + String path = data.getPath(); + if (path.startsWith("//")) { + path = path.substring(1); + } + return path; + } + + public String getCacheDirString() { + return getCacheDir().toString(); + } + + public void showToast(final String text, final int duration) { + final PandaActivity activity = this; + runOnUiThread(new Runnable() { + public void run() { + Toast toast = Toast.makeText(activity, text, duration); + toast.show(); + } + }); + } + static { - System.loadLibrary("gnustl_shared"); - System.loadLibrary("p3dtool"); - System.loadLibrary("p3dtoolconfig"); - System.loadLibrary("pandaexpress"); - System.loadLibrary("panda"); - System.loadLibrary("p3android"); - System.loadLibrary("p3framework"); + //System.loadLibrary("gnustl_shared"); + //System.loadLibrary("p3dtool"); + //System.loadLibrary("p3dtoolconfig"); + //System.loadLibrary("pandaexpress"); + //System.loadLibrary("panda"); + //System.loadLibrary("p3android"); + //System.loadLibrary("p3framework"); System.loadLibrary("pandaegg"); System.loadLibrary("pandagles"); } diff --git a/panda/src/android/android_main.cxx b/panda/src/android/android_main.cxx index 8a3d6135fd..c19ba7d58b 100644 --- a/panda/src/android/android_main.cxx +++ b/panda/src/android/android_main.cxx @@ -25,7 +25,7 @@ // struct android_app* panda_android_app = NULL; -extern int main(int argc, char **argv); +extern int main(int argc, const char **argv); /** * This function is called by native_app_glue to initialize the program. It @@ -100,6 +100,20 @@ void android_main(struct android_app* app) { } } + // Get the cache directory. Set the model-path to this location. + methodID = env->GetMethodID(activity_class, "getCacheDirString", "()Ljava/lang/String;"); + jstring jcache_dir = (jstring) env->CallObjectMethod(activity->clazz, methodID); + + if (jcache_dir != nullptr) { + const char *cache_dir; + cache_dir = env->GetStringUTFChars(jcache_dir, nullptr); + android_cat.info() << "Path to cache: " << cache_dir << "\n"; + + ConfigVariableFilename model_cache_dir("model-cache-dir", Filename()); + model_cache_dir.set_value(cache_dir); + env->ReleaseStringUTFChars(jcache_dir, cache_dir); + } + // Get the path to the APK. methodID = env->GetMethodID(activity_class, "getPackageCodePath", "()Ljava/lang/String;"); jstring code_path = (jstring) env->CallObjectMethod(activity->clazz, methodID); @@ -129,9 +143,29 @@ void android_main(struct android_app* app) { //TODO: prevent it from adding the directory multiple times. get_model_path().append_directory(asset_dir); + // Also read the intent filename. + methodID = env->GetMethodID(activity_class, "getIntentDataPath", "()Ljava/lang/String;"); + jstring filename = (jstring) env->CallObjectMethod(activity->clazz, methodID); + const char *filename_str = nullptr; + if (filename != nullptr) { + filename_str = env->GetStringUTFChars(filename, nullptr); + android_cat.info() << "Got intent filename: " << filename_str << "\n"; + + Filename fn(filename_str); + if (!fn.exists()) { + // Show a toast with the failure message. + android_show_toast(activity, string("Unable to access ") + filename_str, 1); + } + } + // Create bogus argc and argv for calling the main function. - char *argv[] = {nullptr}; - int argc = 0; + const char *argv[] = {"pview", nullptr, nullptr}; + int argc = 1; + + if (filename_str != nullptr) { + argv[1] = filename_str; + ++argc; + } while (!app->destroyRequested) { // Call the main function. This will not return until the app is done. @@ -173,6 +207,10 @@ void android_main(struct android_app* app) { android_cat.info() << "Destroy requested, exiting from android_main\n"; + if (filename_str != nullptr) { + env->ReleaseStringUTFChars(filename, filename_str); + } + // Detach the thread before exiting. activity->vm->DetachCurrentThread(); } diff --git a/panda/src/android/config_android.cxx b/panda/src/android/config_android.cxx index 92d986669d..019443be4b 100644 --- a/panda/src/android/config_android.cxx +++ b/panda/src/android/config_android.cxx @@ -24,6 +24,7 @@ struct android_app *panda_android_app = NULL; jclass jni_PandaActivity; jmethodID jni_PandaActivity_readBitmapSize; jmethodID jni_PandaActivity_readBitmap; +jmethodID jni_PandaActivity_showToast; jclass jni_BitmapFactory_Options; jfieldID jni_BitmapFactory_Options_outWidth; @@ -62,6 +63,9 @@ jint JNI_OnLoad(JavaVM *jvm, void *reserved) { jni_PandaActivity_readBitmap = env->GetStaticMethodID(jni_PandaActivity, "readBitmap", "(JI)Landroid/graphics/Bitmap;"); + jni_PandaActivity_showToast = env->GetMethodID(jni_PandaActivity, + "showToast", "(Ljava/lang/String;I)V"); + jni_BitmapFactory_Options = env->FindClass("android/graphics/BitmapFactory$Options"); jni_BitmapFactory_Options = (jclass) env->NewGlobalRef(jni_BitmapFactory_Options); @@ -83,3 +87,17 @@ void JNI_OnUnload(JavaVM *jvm, void *reserved) { env->DeleteGlobalRef(jni_PandaActivity); env->DeleteGlobalRef(jni_BitmapFactory_Options); } + +/** + * Shows a toast notification at the bottom of the activity. The duration + * should be 0 for short and 1 for long. + */ +void android_show_toast(ANativeActivity *activity, const string &message, int duration) { + Thread *thread = Thread::get_current_thread(); + JNIEnv *env = thread->get_jni_env(); + nassertv(env != nullptr); + + jstring jmsg = env->NewStringUTF(message.c_str()); + env->CallVoidMethod(activity->clazz, jni_PandaActivity_showToast, jmsg, (jint)duration); + env->DeleteLocalRef(jmsg); +} diff --git a/panda/src/android/config_android.h b/panda/src/android/config_android.h index a67ac2423f..74599ec3d9 100644 --- a/panda/src/android/config_android.h +++ b/panda/src/android/config_android.h @@ -20,6 +20,7 @@ #include "configVariableBool.h" #include "configVariableInt.h" +#include #include NotifyCategoryDecl(android, EXPORT_CLASS, EXPORT_TEMPL); @@ -30,9 +31,12 @@ extern EXPORT_CLASS struct android_app* panda_android_app; extern jclass jni_PandaActivity; extern jmethodID jni_PandaActivity_readBitmapHeader; extern jmethodID jni_PandaActivity_readBitmap; +extern jmethodID jni_PandaActivity_showToast; extern jclass jni_BitmapFactory_Options; extern jfieldID jni_BitmapFactory_Options_outWidth; extern jfieldID jni_BitmapFactory_Options_outHeight; +EXPORT_CLASS void android_show_toast(ANativeActivity *activity, const string &message, int duration); + #endif diff --git a/panda/src/android/pview.cxx b/panda/src/android/pview.cxx index 9a29b94574..2b31bb7577 100644 --- a/panda/src/android/pview.cxx +++ b/panda/src/android/pview.cxx @@ -63,12 +63,16 @@ int main(int argc, char **argv) { window->enable_keyboard(); window->setup_trackball(); framework.get_models().instance_to(window->get_render()); - // if (argc < 2) { If we have no arguments, get that trusty old triangle - // out. window->load_default_model(framework.get_models()); } else { - // window->load_models(framework.get_models(), argc, argv); } - - window->load_model(framework.get_models(), "panda-model.egg"); - window->load_model(framework.get_models(), "panda-walk4.egg"); + if (argc < 2) { + // If we have no arguments, get that trusty old triangle + // out. + window->load_default_model(framework.get_models()); + } else { + if (!window->load_models(framework.get_models(), argc, argv)) { + framework.close_framework(); + return 1; + } + } window->loop_animations(hierarchy_match_flags); diff --git a/panda/src/android/pview_manifest.xml b/panda/src/android/pview_manifest.xml index 133fa523aa..6b14579a80 100644 --- a/panda/src/android/pview_manifest.xml +++ b/panda/src/android/pview_manifest.xml @@ -5,11 +5,15 @@ android:versionCode="1" android:versionName="1.0"> - - + + + + + + android:configChanges="orientation|keyboardHidden" + android:launchMode="singleInstance"> @@ -17,6 +21,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From d269f7c6c3bfd01d6eacfec5f58e9ebbe300f76a Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 6 Feb 2018 22:42:40 +0100 Subject: [PATCH 009/247] android: allow stdout/stderr capture using extra field on intent This allows launching the Panda apk from termux and getting command-line output back to termux. --- dtool/src/prc/androidLogStream.cxx | 1 + dtool/src/prc/notify.cxx | 3 +-- dtool/src/prc/notifyCategory.cxx | 6 ++++- panda/src/android/PandaActivity.java | 5 +++++ panda/src/android/android_main.cxx | 22 +++++++++++++++++++ .../express/virtualFileMountAndroidAsset.cxx | 2 +- 6 files changed, 35 insertions(+), 4 deletions(-) diff --git a/dtool/src/prc/androidLogStream.cxx b/dtool/src/prc/androidLogStream.cxx index b5512f9f52..6427b9163a 100644 --- a/dtool/src/prc/androidLogStream.cxx +++ b/dtool/src/prc/androidLogStream.cxx @@ -92,6 +92,7 @@ overflow(int ch) { */ void AndroidLogStream::AndroidLogStreamBuf:: write_char(char c) { + nout.put(c); if (c == '\n') { // Write a line to the log file. __android_log_write(_priority, _tag.c_str(), _data.c_str()); diff --git a/dtool/src/prc/notify.cxx b/dtool/src/prc/notify.cxx index f97b7d78ac..f74f55e596 100644 --- a/dtool/src/prc/notify.cxx +++ b/dtool/src/prc/notify.cxx @@ -335,9 +335,8 @@ assert_failure(const char *expression, int line, #ifdef ANDROID __android_log_assert("assert", "Panda3D", "Assertion failed: %s", message.c_str()); -#else - nout << "Assertion failed: " << message << "\n"; #endif + nout << "Assertion failed: " << message << "\n"; // This is redefined here, shadowing the defining in config_prc.h, so we can // guarantee it has already been constructed. diff --git a/dtool/src/prc/notifyCategory.cxx b/dtool/src/prc/notifyCategory.cxx index a6e0a0181c..432dfca159 100644 --- a/dtool/src/prc/notifyCategory.cxx +++ b/dtool/src/prc/notifyCategory.cxx @@ -64,7 +64,11 @@ out(NotifySeverity severity, bool prefix) const { // logging system. We use a special type of stream that redirects it to // Android's log system. if (prefix) { - return AndroidLogStream::out(severity) << *this << ": "; + if (severity == NS_info) { + return AndroidLogStream::out(severity) << *this << ": "; + } else { + return AndroidLogStream::out(severity) << *this << "(" << severity << "): "; + } } else { return AndroidLogStream::out(severity); } diff --git a/panda/src/android/PandaActivity.java b/panda/src/android/PandaActivity.java index 91e6c38533..c9985986f6 100644 --- a/panda/src/android/PandaActivity.java +++ b/panda/src/android/PandaActivity.java @@ -61,6 +61,11 @@ public class PandaActivity extends NativeActivity { return path; } + public String getIntentOutputPath() { + Intent intent = getIntent(); + return intent.getStringExtra("org.panda3d.OUTPUT_PATH"); + } + public String getCacheDirString() { return getCacheDir().toString(); } diff --git a/panda/src/android/android_main.cxx b/panda/src/android/android_main.cxx index c19ba7d58b..05a98b768c 100644 --- a/panda/src/android/android_main.cxx +++ b/panda/src/android/android_main.cxx @@ -158,6 +158,28 @@ void android_main(struct android_app* app) { } } + // Were we given an optional location to write the stdout/stderr streams? + methodID = env->GetMethodID(activity_class, "getIntentOutputPath", "()Ljava/lang/String;"); + jstring joutput_path = (jstring) env->CallObjectMethod(activity->clazz, methodID); + if (joutput_path != nullptr) { + const char *output_path = env->GetStringUTFChars(joutput_path, nullptr); + + if (output_path != nullptr && output_path[0] != 0) { + int fd = open(output_path, O_CREAT | O_TRUNC | O_WRONLY); + if (fd != -1) { + android_cat.info() + << "Writing standard output to file " << output_path << "\n"; + + dup2(fd, 1); + dup2(fd, 2); + } else { + android_cat.error() + << "Failed to open output path " << output_path << "\n"; + } + env->ReleaseStringUTFChars(joutput_path, output_path); + } + } + // Create bogus argc and argv for calling the main function. const char *argv[] = {"pview", nullptr, nullptr}; int argc = 1; diff --git a/panda/src/express/virtualFileMountAndroidAsset.cxx b/panda/src/express/virtualFileMountAndroidAsset.cxx index 3c85aaebb7..d7ffb6254a 100644 --- a/panda/src/express/virtualFileMountAndroidAsset.cxx +++ b/panda/src/express/virtualFileMountAndroidAsset.cxx @@ -78,7 +78,7 @@ is_regular_file(const Filename &file) const { AAsset* asset; asset = AAssetManager_open(_asset_mgr, file.c_str(), AASSET_MODE_UNKNOWN); - express_cat.error() << "is_regular_file " << file << " - " << asset << "\n"; + //express_cat.error() << "is_regular_file " << file << " - " << asset << "\n"; if (asset == NULL) { return false; From c15c05f6424279cb943eeff98bbdc0afb87e3c38 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 6 Feb 2018 22:44:53 +0100 Subject: [PATCH 010/247] android: enable resume key events --- panda/src/androiddisplay/androidGraphicsWindow.cxx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/panda/src/androiddisplay/androidGraphicsWindow.cxx b/panda/src/androiddisplay/androidGraphicsWindow.cxx index d459f56339..8a66cde45a 100644 --- a/panda/src/androiddisplay/androidGraphicsWindow.cxx +++ b/panda/src/androiddisplay/androidGraphicsWindow.cxx @@ -396,8 +396,10 @@ create_surface() { */ void AndroidGraphicsWindow:: handle_command(struct android_app *app, int32_t command) { - AndroidGraphicsWindow* window = (AndroidGraphicsWindow*) app->userData; - window->ns_handle_command(command); + AndroidGraphicsWindow *window = (AndroidGraphicsWindow *)app->userData; + if (window != nullptr) { + window->ns_handle_command(command); + } } /** @@ -517,11 +519,15 @@ handle_key_event(const AInputEvent *event) { // Is it an up or down event? int32_t action = AKeyEvent_getAction(event); if (action == AKEY_EVENT_ACTION_DOWN) { - _input_devices[0].button_down(button); + if (AKeyEvent_getRepeatCount(event) > 0) { + _input_devices[0].button_resume_down(button); + } else { + _input_devices[0].button_down(button); + } } else if (action == AKEY_EVENT_ACTION_UP) { _input_devices[0].button_up(button); } - // TODO getRepeatCount, ACTION_MULTIPLE + // TODO AKEY_EVENT_ACTION_MULTIPLE return 1; } From e15cea433165fb5c500203ec21d9c0d14f7ba33c Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Wed, 7 Feb 2018 11:29:48 -0700 Subject: [PATCH 011/247] general: Remove more unnecessary +x UNIX modes --- contrib/src/panda3dtoolsgui/build_exe.bat | 0 direct/src/plugin_installer/FileAssociation.nsh | 0 direct/src/plugin_installer/VersionInfo.vbs | 0 direct/src/plugin_installer/p3d_installer.nsi | 0 dmodels/src/gui/radio_button_gui.egg | 0 dmodels/src/icons/dot_black.gif | Bin dmodels/src/icons/dot_blue.gif | Bin dmodels/src/icons/dot_green.gif | Bin dmodels/src/icons/dot_red.gif | Bin dmodels/src/icons/dot_white.gif | Bin dmodels/src/icons/folder.gif | Bin dmodels/src/icons/icon_arrowDown.egg | 0 dmodels/src/icons/icon_arrowDown_tall.egg | 0 dmodels/src/icons/icon_circle_cycle.egg | 0 dmodels/src/icons/icon_circle_no.egg | 0 dmodels/src/icons/icon_diamond.egg | 0 dmodels/src/icons/icon_gear1.egg | 0 dmodels/src/icons/icon_hourglass.egg | 0 dmodels/src/icons/icon_lightbulb.egg | 0 dmodels/src/icons/icon_lightning.egg | 0 dmodels/src/icons/icon_pacman.egg | 0 dmodels/src/icons/icon_plus.egg | 0 dmodels/src/icons/icon_ring.egg | 0 dmodels/src/icons/icon_star_5.egg | 0 dmodels/src/icons/icon_star_8.egg | 0 dmodels/src/icons/minusnode.gif | Bin dmodels/src/icons/openfolder.gif | Bin dmodels/src/icons/plusnode.gif | Bin dmodels/src/icons/python.gif | Bin dmodels/src/icons/sphere2.gif | Bin dmodels/src/icons/tk.gif | Bin dmodels/src/maps/Dirlight.png | Bin dmodels/src/maps/Pointlight.png | Bin dmodels/src/maps/Spotlight.png | Bin dmodels/src/maps/circle.png | Bin dmodels/src/maps/lightbulb.tif | Bin dmodels/src/maps/smiley.rgb | Bin dmodels/src/maps/square.tif | Bin dmodels/src/maps/square_opening.tif | Bin dmodels/src/maps/triangle.tif | Bin makepanda/confauto.in | 0 makepanda/config.in | 0 makepanda/installer.nsi | 0 makepanda/makechm.bat | 0 makepanda/makepanda.bat | 0 makepanda/makepanda.sln | 0 makepanda/makepanda.vcproj | 0 makepanda/panda-install.bmp | Bin models/environment.egg | 0 models/panda-model.egg | 0 models/panda-walk4.egg | 0 models/plugin_images/installer.bmp | Bin pandatool/src/mayaprogs/eggImportOptions.mel | 0 pandatool/src/scripts/MayaPandaTool.mel | 0 samples/music-box/music/musicbox.ogg | Bin samples/rocket-console/assets/console.rcss | 0 samples/rocket-console/assets/console.rml | 0 samples/rocket-console/assets/loading.rml | 0 samples/rocket-console/assets/rkt.rcss | 0 samples/rocket-console/assets/window.rcss | 0 samples/rocket-console/assets/window.rml | 0 61 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 contrib/src/panda3dtoolsgui/build_exe.bat mode change 100755 => 100644 direct/src/plugin_installer/FileAssociation.nsh mode change 100755 => 100644 direct/src/plugin_installer/VersionInfo.vbs mode change 100755 => 100644 direct/src/plugin_installer/p3d_installer.nsi mode change 100755 => 100644 dmodels/src/gui/radio_button_gui.egg mode change 100755 => 100644 dmodels/src/icons/dot_black.gif mode change 100755 => 100644 dmodels/src/icons/dot_blue.gif mode change 100755 => 100644 dmodels/src/icons/dot_green.gif mode change 100755 => 100644 dmodels/src/icons/dot_red.gif mode change 100755 => 100644 dmodels/src/icons/dot_white.gif mode change 100755 => 100644 dmodels/src/icons/folder.gif mode change 100755 => 100644 dmodels/src/icons/icon_arrowDown.egg mode change 100755 => 100644 dmodels/src/icons/icon_arrowDown_tall.egg mode change 100755 => 100644 dmodels/src/icons/icon_circle_cycle.egg mode change 100755 => 100644 dmodels/src/icons/icon_circle_no.egg mode change 100755 => 100644 dmodels/src/icons/icon_diamond.egg mode change 100755 => 100644 dmodels/src/icons/icon_gear1.egg mode change 100755 => 100644 dmodels/src/icons/icon_hourglass.egg mode change 100755 => 100644 dmodels/src/icons/icon_lightbulb.egg mode change 100755 => 100644 dmodels/src/icons/icon_lightning.egg mode change 100755 => 100644 dmodels/src/icons/icon_pacman.egg mode change 100755 => 100644 dmodels/src/icons/icon_plus.egg mode change 100755 => 100644 dmodels/src/icons/icon_ring.egg mode change 100755 => 100644 dmodels/src/icons/icon_star_5.egg mode change 100755 => 100644 dmodels/src/icons/icon_star_8.egg mode change 100755 => 100644 dmodels/src/icons/minusnode.gif mode change 100755 => 100644 dmodels/src/icons/openfolder.gif mode change 100755 => 100644 dmodels/src/icons/plusnode.gif mode change 100755 => 100644 dmodels/src/icons/python.gif mode change 100755 => 100644 dmodels/src/icons/sphere2.gif mode change 100755 => 100644 dmodels/src/icons/tk.gif mode change 100755 => 100644 dmodels/src/maps/Dirlight.png mode change 100755 => 100644 dmodels/src/maps/Pointlight.png mode change 100755 => 100644 dmodels/src/maps/Spotlight.png mode change 100755 => 100644 dmodels/src/maps/circle.png mode change 100755 => 100644 dmodels/src/maps/lightbulb.tif mode change 100755 => 100644 dmodels/src/maps/smiley.rgb mode change 100755 => 100644 dmodels/src/maps/square.tif mode change 100755 => 100644 dmodels/src/maps/square_opening.tif mode change 100755 => 100644 dmodels/src/maps/triangle.tif mode change 100755 => 100644 makepanda/confauto.in mode change 100755 => 100644 makepanda/config.in mode change 100755 => 100644 makepanda/installer.nsi mode change 100755 => 100644 makepanda/makechm.bat mode change 100755 => 100644 makepanda/makepanda.bat mode change 100755 => 100644 makepanda/makepanda.sln mode change 100755 => 100644 makepanda/makepanda.vcproj mode change 100755 => 100644 makepanda/panda-install.bmp mode change 100755 => 100644 models/environment.egg mode change 100755 => 100644 models/panda-model.egg mode change 100755 => 100644 models/panda-walk4.egg mode change 100755 => 100644 models/plugin_images/installer.bmp mode change 100755 => 100644 pandatool/src/mayaprogs/eggImportOptions.mel mode change 100755 => 100644 pandatool/src/scripts/MayaPandaTool.mel mode change 100755 => 100644 samples/music-box/music/musicbox.ogg mode change 100755 => 100644 samples/rocket-console/assets/console.rcss mode change 100755 => 100644 samples/rocket-console/assets/console.rml mode change 100755 => 100644 samples/rocket-console/assets/loading.rml mode change 100755 => 100644 samples/rocket-console/assets/rkt.rcss mode change 100755 => 100644 samples/rocket-console/assets/window.rcss mode change 100755 => 100644 samples/rocket-console/assets/window.rml diff --git a/contrib/src/panda3dtoolsgui/build_exe.bat b/contrib/src/panda3dtoolsgui/build_exe.bat old mode 100755 new mode 100644 diff --git a/direct/src/plugin_installer/FileAssociation.nsh b/direct/src/plugin_installer/FileAssociation.nsh old mode 100755 new mode 100644 diff --git a/direct/src/plugin_installer/VersionInfo.vbs b/direct/src/plugin_installer/VersionInfo.vbs old mode 100755 new mode 100644 diff --git a/direct/src/plugin_installer/p3d_installer.nsi b/direct/src/plugin_installer/p3d_installer.nsi old mode 100755 new mode 100644 diff --git a/dmodels/src/gui/radio_button_gui.egg b/dmodels/src/gui/radio_button_gui.egg old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/dot_black.gif b/dmodels/src/icons/dot_black.gif old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/dot_blue.gif b/dmodels/src/icons/dot_blue.gif old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/dot_green.gif b/dmodels/src/icons/dot_green.gif old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/dot_red.gif b/dmodels/src/icons/dot_red.gif old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/dot_white.gif b/dmodels/src/icons/dot_white.gif old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/folder.gif b/dmodels/src/icons/folder.gif old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/icon_arrowDown.egg b/dmodels/src/icons/icon_arrowDown.egg old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/icon_arrowDown_tall.egg b/dmodels/src/icons/icon_arrowDown_tall.egg old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/icon_circle_cycle.egg b/dmodels/src/icons/icon_circle_cycle.egg old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/icon_circle_no.egg b/dmodels/src/icons/icon_circle_no.egg old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/icon_diamond.egg b/dmodels/src/icons/icon_diamond.egg old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/icon_gear1.egg b/dmodels/src/icons/icon_gear1.egg old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/icon_hourglass.egg b/dmodels/src/icons/icon_hourglass.egg old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/icon_lightbulb.egg b/dmodels/src/icons/icon_lightbulb.egg old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/icon_lightning.egg b/dmodels/src/icons/icon_lightning.egg old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/icon_pacman.egg b/dmodels/src/icons/icon_pacman.egg old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/icon_plus.egg b/dmodels/src/icons/icon_plus.egg old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/icon_ring.egg b/dmodels/src/icons/icon_ring.egg old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/icon_star_5.egg b/dmodels/src/icons/icon_star_5.egg old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/icon_star_8.egg b/dmodels/src/icons/icon_star_8.egg old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/minusnode.gif b/dmodels/src/icons/minusnode.gif old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/openfolder.gif b/dmodels/src/icons/openfolder.gif old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/plusnode.gif b/dmodels/src/icons/plusnode.gif old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/python.gif b/dmodels/src/icons/python.gif old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/sphere2.gif b/dmodels/src/icons/sphere2.gif old mode 100755 new mode 100644 diff --git a/dmodels/src/icons/tk.gif b/dmodels/src/icons/tk.gif old mode 100755 new mode 100644 diff --git a/dmodels/src/maps/Dirlight.png b/dmodels/src/maps/Dirlight.png old mode 100755 new mode 100644 diff --git a/dmodels/src/maps/Pointlight.png b/dmodels/src/maps/Pointlight.png old mode 100755 new mode 100644 diff --git a/dmodels/src/maps/Spotlight.png b/dmodels/src/maps/Spotlight.png old mode 100755 new mode 100644 diff --git a/dmodels/src/maps/circle.png b/dmodels/src/maps/circle.png old mode 100755 new mode 100644 diff --git a/dmodels/src/maps/lightbulb.tif b/dmodels/src/maps/lightbulb.tif old mode 100755 new mode 100644 diff --git a/dmodels/src/maps/smiley.rgb b/dmodels/src/maps/smiley.rgb old mode 100755 new mode 100644 diff --git a/dmodels/src/maps/square.tif b/dmodels/src/maps/square.tif old mode 100755 new mode 100644 diff --git a/dmodels/src/maps/square_opening.tif b/dmodels/src/maps/square_opening.tif old mode 100755 new mode 100644 diff --git a/dmodels/src/maps/triangle.tif b/dmodels/src/maps/triangle.tif old mode 100755 new mode 100644 diff --git a/makepanda/confauto.in b/makepanda/confauto.in old mode 100755 new mode 100644 diff --git a/makepanda/config.in b/makepanda/config.in old mode 100755 new mode 100644 diff --git a/makepanda/installer.nsi b/makepanda/installer.nsi old mode 100755 new mode 100644 diff --git a/makepanda/makechm.bat b/makepanda/makechm.bat old mode 100755 new mode 100644 diff --git a/makepanda/makepanda.bat b/makepanda/makepanda.bat old mode 100755 new mode 100644 diff --git a/makepanda/makepanda.sln b/makepanda/makepanda.sln old mode 100755 new mode 100644 diff --git a/makepanda/makepanda.vcproj b/makepanda/makepanda.vcproj old mode 100755 new mode 100644 diff --git a/makepanda/panda-install.bmp b/makepanda/panda-install.bmp old mode 100755 new mode 100644 diff --git a/models/environment.egg b/models/environment.egg old mode 100755 new mode 100644 diff --git a/models/panda-model.egg b/models/panda-model.egg old mode 100755 new mode 100644 diff --git a/models/panda-walk4.egg b/models/panda-walk4.egg old mode 100755 new mode 100644 diff --git a/models/plugin_images/installer.bmp b/models/plugin_images/installer.bmp old mode 100755 new mode 100644 diff --git a/pandatool/src/mayaprogs/eggImportOptions.mel b/pandatool/src/mayaprogs/eggImportOptions.mel old mode 100755 new mode 100644 diff --git a/pandatool/src/scripts/MayaPandaTool.mel b/pandatool/src/scripts/MayaPandaTool.mel old mode 100755 new mode 100644 diff --git a/samples/music-box/music/musicbox.ogg b/samples/music-box/music/musicbox.ogg old mode 100755 new mode 100644 diff --git a/samples/rocket-console/assets/console.rcss b/samples/rocket-console/assets/console.rcss old mode 100755 new mode 100644 diff --git a/samples/rocket-console/assets/console.rml b/samples/rocket-console/assets/console.rml old mode 100755 new mode 100644 diff --git a/samples/rocket-console/assets/loading.rml b/samples/rocket-console/assets/loading.rml old mode 100755 new mode 100644 diff --git a/samples/rocket-console/assets/rkt.rcss b/samples/rocket-console/assets/rkt.rcss old mode 100755 new mode 100644 diff --git a/samples/rocket-console/assets/window.rcss b/samples/rocket-console/assets/window.rcss old mode 100755 new mode 100644 diff --git a/samples/rocket-console/assets/window.rml b/samples/rocket-console/assets/window.rml old mode 100755 new mode 100644 From bdb74b1e30bfdad52635f0fe20d940451f38d1b7 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 9 Feb 2018 19:49:02 +0100 Subject: [PATCH 012/247] makepanda: add code to build an Android package with --installer --- makepanda/makepanda.py | 113 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 2f21483e78..b8aa622429 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -7444,6 +7444,117 @@ def MakeInstallerFreeBSD(): WriteFile("+MANIFEST", manifest_txt) oscmd("pkg create -p pkg-plist -r %s -m . -o . %s" % (os.path.abspath("targetroot"), "--verbose" if GetVerbose() else "--quiet")) +def MakeInstallerAndroid(): + oscmd("rm -rf apkroot") + oscmd("mkdir apkroot") + + # Also remove the temporary apks. + apk_unaligned = os.path.join(GetOutputDir(), "tmp", "panda3d-unaligned.apk") + apk_unsigned = os.path.join(GetOutputDir(), "tmp", "panda3d-unsigned.apk") + if os.path.exists(apk_unaligned): + os.unlink(apk_unaligned) + if os.path.exists(apk_unsigned): + os.unlink(apk_unsigned) + + # Compile the Java classes into a Dalvik executable. + dx_cmd = "dx --dex --output=apkroot/classes.dex " + if GetOptimize() <= 2: + dx_cmd += "--debug " + if GetVerbose(): + dx_cmd += "--verbose " + if "ANDROID_API" in SDK: + dx_cmd += "--min-sdk-version=%d " % (SDK["ANDROID_API"]) + dx_cmd += os.path.join(GetOutputDir(), "classes") + oscmd(dx_cmd) + + # Copy the libraries one by one. In case of library dependencies, strip + # off any suffix (eg. libfile.so.1.0), as Android does not support them. + source_dir = os.path.join(GetOutputDir(), "lib") + target_dir = os.path.join("apkroot", "lib", SDK["ANDROID_ABI"]) + oscmd("mkdir -p %s" % (target_dir)) + + # Determine the library directories we should look in. + libpath = [source_dir] + for dir in os.environ.get("LD_LIBRARY_PATH", "").split(':'): + dir = os.path.expandvars(dir) + dir = os.path.expanduser(dir) + if os.path.isdir(dir): + dir = os.path.realpath(dir) + if not dir.startswith("/system") and not dir.startswith("/vendor"): + libpath.append(dir) + + def copy_library(source, base): + # Copy file to destination, stripping version suffix. + target = os.path.join(target_dir, base) + if not target.endswith('.so'): + target = target.rpartition('.so.')[0] + '.so' + + if os.path.isfile(target): + # Already processed. + return + + oscmd("cp %s %s" % (source, target)) + + # Walk through the library dependencies. + oscmd("ldd %s | grep .so > %s/tmp/otool-libs.txt" % (target, GetOutputDir()), True) + for line in open(GetOutputDir() + "/tmp/otool-libs.txt", "r"): + line = line.strip() + if not line: + continue + if '.so.' in line: + dep = line.rpartition('.so.')[0] + '.so' + oscmd("patchelf --replace-needed %s %s %s" % (line, dep, target)) + else: + dep = line + + # Find it on the LD_LIBRARY_PATH. + for dir in libpath: + fulldep = os.path.join(dir, dep) + if os.path.isfile(fulldep): + copy_library(os.path.realpath(fulldep), dep) + break + + for base in os.listdir(source_dir): + if not base.startswith('lib'): + continue + if not base.endswith('.so') and '.so.' not in base: + continue + + source = os.path.join(source_dir, base) + if os.path.islink(source): + continue + copy_library(source, base) + + # Copy the models as well. + oscmd("mkdir apkroot/assets") + oscmd("cp -R %s apkroot/assets/models" % (os.path.join(GetOutputDir(), "models"))) + + # Make an empty res folder. It's needed for the apk to be installable, apparently. + oscmd("mkdir apkroot/res") + + # Now package up the application + oscmd("cp panda/src/android/pview_manifest.xml apkroot/AndroidManifest.xml") + aapt_cmd = "aapt package" + aapt_cmd += " -F %s" % (apk_unaligned) + aapt_cmd += " -M apkroot/AndroidManifest.xml" + aapt_cmd += " -A apkroot/assets -S apkroot/res" + aapt_cmd += " -I $PREFIX/share/aapt/android.jar" + oscmd(aapt_cmd) + + # And add all the libraries to it. + oscmd("cd apkroot && aapt add ../%s classes.dex lib/%s/lib*.so" % (apk_unaligned, SDK["ANDROID_ABI"])) + + # Now align the .apk, which is necessary for Android to load it. + oscmd("zipalign -v -p 4 %s %s" % (apk_unaligned, apk_unsigned)) + + # Finally, sign it using a debug key. This is generated if it doesn't exist. + oscmd("apksigner debug.ks %s panda3d.apk" % (apk_unsigned)) + + # Clean up. + oscmd("rm -rf apkroot") + os.unlink(apk_unaligned) + os.unlink(apk_unsigned) + try: if INSTALLER: ProgressOutput(100.0, "Building installer") @@ -7478,6 +7589,8 @@ try: MakeInstallerOSX() elif (target == 'freebsd'): MakeInstallerFreeBSD() + elif (target == 'android'): + MakeInstallerAndroid() else: exit("Do not know how to make an installer for this platform") From 730279531a8fa77ba46d19e814a4419053371316 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 10 Feb 2018 12:13:05 +0100 Subject: [PATCH 013/247] makepanda: build on Intel Android machines --- dtool/src/dtoolbase/dtool_platform.h | 2 ++ makepanda/makepanda.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/dtool/src/dtoolbase/dtool_platform.h b/dtool/src/dtoolbase/dtool_platform.h index 9037632738..2a6ed12a9b 100644 --- a/dtool/src/dtoolbase/dtool_platform.h +++ b/dtool/src/dtoolbase/dtool_platform.h @@ -57,6 +57,8 @@ #define DTOOL_PLATFORM "android_arm" #elif defined(__mips__) #define DTOOL_PLATFORM "android_mips" +#elif defined(__x86_64) +#define DTOOL_PLATFORM "android_amd64" #elif defined(__i386__) #define DTOOL_PLATFORM "android_i386" #endif diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index b8aa622429..9b653bfc1c 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1291,9 +1291,11 @@ def CompileCxx(obj,src,opts): cmd += ' -fintegrated-as' elif arch == 'x86': cmd += ' -target i686-none-linux-android' + cmd += ' -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32' cmd += ' -mstackrealign' elif arch == 'x86_64': cmd += ' -target x86_64-none-linux-android' + cmd += ' -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel' cmd += " -Wa,--noexecstack" From b4ad0a69a0f0b71e65584298a60eaa8177813f8e Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 11 Feb 2018 00:55:04 +0100 Subject: [PATCH 014/247] makepanda: automatic dependency scanning for Java sources --- makepanda/makepandacore.py | 54 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index bc0cdc7549..cd9770c1e9 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -764,6 +764,34 @@ def CxxGetIncludes(path): CXXINCLUDECACHE[path] = [date, include] return include +JAVAIMPORTCACHE = {} + +global JavaImportRegex +JavaImportRegex = re.compile('[ \t\r\n;]import[ \t]+([a-zA-Z][^;]+)[ \t\r\n]*;') + +def JavaGetImports(path): + date = GetTimestamp(path) + if path in JAVAIMPORTCACHE: + cached = JAVAIMPORTCACHE[path] + if cached[0] == date: + return cached[1] + try: + source = open(path, 'r').read() + except: + exit("Cannot open source file \"" + path + "\" for reading.") + + imports = [] + try: + for match in JavaImportRegex.finditer(source, 0): + impname = match.group(1) + imports.append(impname.strip()) + except: + print("Failed to determine dependencies of \"" + path +"\".") + raise + + JAVAIMPORTCACHE[path] = [date, imports] + return imports + ######################################################################## ## ## SaveDependencyCache / LoadDependencyCache @@ -862,6 +890,13 @@ def CxxFindHeader(srcfile, incfile, ipath): if GetTimestamp(full) > 0: return full return 0 +def JavaFindClasses(impspec, clspath): + path = clspath + '/' + impspec.replace('.', '/') + '.class' + if '*' in path: + return glob.glob(path) + else: + return [path] + ######################################################################## ## ## CxxCalcDependencies(srcfile, ipath, ignore) @@ -894,6 +929,22 @@ def CxxCalcDependencies(srcfile, ipath, ignore): CxxDependencyCache[srcfile] = result return result +global JavaDependencyCache +JavaDependencyCache = {} + +def JavaCalcDependencies(srcfile, clspath): + if srcfile in JavaDependencyCache: + return JavaDependencyCache[srcfile] + + deps = set((srcfile,)) + JavaDependencyCache[srcfile] = deps + + imports = JavaGetImports(srcfile) + for impspec in imports: + for cls in JavaFindClasses(impspec, clspath): + deps.add(cls) + return deps + ######################################################################## ## ## Registry Key Handling @@ -3314,6 +3365,9 @@ def TargetAdd(target, dummy=0, opts=[], input=[], dep=[], ipath=None, winrc=None if (SUFFIX_INC.count(suffix)): for d in CxxCalcDependencies(fullinput, ipath, []): t.deps[d] = 1 + elif suffix == '.java': + for d in JavaCalcDependencies(fullinput, OUTPUTDIR + "/classes"): + t.deps[d] = 1 # If we are linking statically, add the source DLL's dynamic dependencies. if GetLinkAllStatic() and ORIG_EXT[fullinput] == '.lib' and fullinput in TARGET_TABLE: From c41b694eb3e83cdd52e337a303733049de80172e Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 11 Feb 2018 00:56:25 +0100 Subject: [PATCH 015/247] makepanda: detect public system libraries when building on Android --- makepanda/makepanda.py | 11 ++++------- makepanda/makepandacore.py | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 9b653bfc1c..69c8c93a37 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -821,6 +821,9 @@ if (COMPILER=="GCC"): SmartPkgEnable("FREETYPE", "freetype2", ("freetype"), ("freetype2", "freetype2/freetype/freetype.h")) SmartPkgEnable("HARFBUZZ", "harfbuzz", ("harfbuzz"), ("harfbuzz", "harfbuzz/hb-ft.h")) SmartPkgEnable("GL", "gl", ("GL"), ("GL/gl.h"), framework = "OpenGL") + SmartPkgEnable("GLES", "glesv1_cm", ("GLESv1_CM"), ("GLES/gl.h"), framework = "OpenGLES") + SmartPkgEnable("GLES2", "glesv2", ("GLESv2"), ("GLES2/gl2.h")) #framework = "OpenGLES"? + SmartPkgEnable("EGL", "egl", ("EGL"), ("EGL/egl.h")) SmartPkgEnable("NVIDIACG", "", ("Cg"), "Cg/cg.h", framework = "Cg") SmartPkgEnable("ODE", "", ("ode"), "ode/ode.h", tool = "ode-config") SmartPkgEnable("OPENAL", "openal", ("openal"), "AL/al.h", framework = "OpenAL") @@ -830,16 +833,10 @@ if (COMPILER=="GCC"): SmartPkgEnable("VRPN", "", ("vrpn", "quat"), ("vrpn", "quat.h", "vrpn/vrpn_Types.h")) SmartPkgEnable("BULLET", "bullet", ("BulletSoftBody", "BulletDynamics", "BulletCollision", "LinearMath"), ("bullet", "bullet/btBulletDynamicsCommon.h")) SmartPkgEnable("VORBIS", "vorbisfile",("vorbisfile", "vorbis", "ogg"), ("ogg/ogg.h", "vorbis/vorbisfile.h")) - SmartPkgEnable("OPUS", "opusfile", ("opusfile", "opus", "ogg"), ("ogg/ogg.h", "opus/opusfile.h")) + SmartPkgEnable("OPUS", "opusfile", ("opusfile", "opus", "ogg"), ("ogg/ogg.h", "opus/opusfile.h", "opus")) SmartPkgEnable("JPEG", "", ("jpeg"), "jpeglib.h") SmartPkgEnable("PNG", "libpng", ("png"), "png.h", tool = "libpng-config") - # On Android, these are system libraries. - if GetHost() != "android": - SmartPkgEnable("GLES", "glesv1_cm", (), ("GLES/gl.h"), framework = "OpenGLES") - SmartPkgEnable("GLES2", "glesv2", (), ("GLES2/gl2.h")) #framework = "OpenGLES"? - SmartPkgEnable("EGL", "egl", (), ("EGL/egl.h")) - if not PkgSkip("FFMPEG"): if GetTarget() == "darwin": LibName("FFMPEG", "-Wl,-read_only_relocs,suppress") diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index cd9770c1e9..0bce3f4450 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -59,6 +59,13 @@ else: # case. host_64 = (platform.architecture()[0] == '64bit') +# On Android, get a list of all the public system libraries. +ANDROID_SYS_LIBS = [] +if os.path.exists("/etc/public.libraries.txt"): + for line in open("/etc/public.libraries.txt", "r"): + line = line.strip() + ANDROID_SYS_LIBS.append(line) + ######################################################################## ## ## Visual C++ Version (MSVC) and Visual Studio Information Map @@ -1568,7 +1575,14 @@ def LocateLibrary(lib, lpath=[], prefer_static=False): return None def SystemLibraryExists(lib): - return LocateLibrary(lib, SYS_LIB_DIRS) is not None + result = LocateLibrary(lib, SYS_LIB_DIRS) + if result is not None: + return True + + if GetHost() == "android" and GetTarget() == "android": + return ('lib%s.so' % lib) in ANDROID_SYS_LIBS + + return False def ChooseLib(libs, thirdparty=None): """ Chooses a library from the parameters, in order of preference. Returns the first if none of them were found. """ From ab7dbebf3f224447fe79f9cd92239034cd877126 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Wed, 14 Feb 2018 17:25:37 -0700 Subject: [PATCH 016/247] general: Remove lingering references to Helix Support for Helix has been dropped long ago; it's very unlikely to return. See also de4280ea209d567eedfa08084da0dea761ad5917. --- dtool/src/parser-inc/MainHelix.h | 9 --------- dtool/src/parser-inc/hxcom.h | 6 ------ dtool/src/parser-inc/hxcomm.h | 6 ------ dtool/src/parser-inc/hxcore.h | 6 ------ dtool/src/parser-inc/hxengin.h | 6 ------ dtool/src/parser-inc/hxerror.h | 6 ------ dtool/src/parser-inc/hxfiles.h | 6 ------ dtool/src/parser-inc/hxtbuf.h | 6 ------ dtool/src/parser-inc/hxtbuff.h | 6 ------ dtool/src/parser-inc/hxwin.h | 6 ------ panda/src/pandabase/pandasymbols.h | 3 --- 11 files changed, 66 deletions(-) delete mode 100644 dtool/src/parser-inc/MainHelix.h delete mode 100644 dtool/src/parser-inc/hxcom.h delete mode 100644 dtool/src/parser-inc/hxcomm.h delete mode 100644 dtool/src/parser-inc/hxcore.h delete mode 100644 dtool/src/parser-inc/hxengin.h delete mode 100644 dtool/src/parser-inc/hxerror.h delete mode 100644 dtool/src/parser-inc/hxfiles.h delete mode 100644 dtool/src/parser-inc/hxtbuf.h delete mode 100644 dtool/src/parser-inc/hxtbuff.h delete mode 100644 dtool/src/parser-inc/hxwin.h diff --git a/dtool/src/parser-inc/MainHelix.h b/dtool/src/parser-inc/MainHelix.h deleted file mode 100644 index deeefca994..0000000000 --- a/dtool/src/parser-inc/MainHelix.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef MAINHELIX_H -#define MAINHELIX_H - -// This file is a stub header file. -class DLLAccess {}; -class IHXClientEngine {}; -class IHXPlayer {}; - -#endif diff --git a/dtool/src/parser-inc/hxcom.h b/dtool/src/parser-inc/hxcom.h deleted file mode 100644 index 8c733fddd3..0000000000 --- a/dtool/src/parser-inc/hxcom.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef HXCOM_H -#define HXCOM_H - -// This file is a stub header file. - -#endif diff --git a/dtool/src/parser-inc/hxcomm.h b/dtool/src/parser-inc/hxcomm.h deleted file mode 100644 index 5e1137c6d7..0000000000 --- a/dtool/src/parser-inc/hxcomm.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef HXCOMM_H -#define HXCOMM_H - -// This file is a stub header file. - -#endif diff --git a/dtool/src/parser-inc/hxcore.h b/dtool/src/parser-inc/hxcore.h deleted file mode 100644 index 4848d39d34..0000000000 --- a/dtool/src/parser-inc/hxcore.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef HXCORE_H -#define HXCORE_H - -// This file is a stub header file. - -#endif diff --git a/dtool/src/parser-inc/hxengin.h b/dtool/src/parser-inc/hxengin.h deleted file mode 100644 index 0b6467baae..0000000000 --- a/dtool/src/parser-inc/hxengin.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef HXENGIN_H -#define HXENGIN_H - -// This file is a stub header file. - -#endif diff --git a/dtool/src/parser-inc/hxerror.h b/dtool/src/parser-inc/hxerror.h deleted file mode 100644 index b3cf207ade..0000000000 --- a/dtool/src/parser-inc/hxerror.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef HXERROR_H -#define HXERROR_H - -// This file is a stub header file. - -#endif diff --git a/dtool/src/parser-inc/hxfiles.h b/dtool/src/parser-inc/hxfiles.h deleted file mode 100644 index 4616b8bd11..0000000000 --- a/dtool/src/parser-inc/hxfiles.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef HXFILES_H -#define HXFILES_H - -// This file is a stub header file. - -#endif diff --git a/dtool/src/parser-inc/hxtbuf.h b/dtool/src/parser-inc/hxtbuf.h deleted file mode 100644 index 12210512a1..0000000000 --- a/dtool/src/parser-inc/hxtbuf.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef HXTBUF_H -#define HXTBUF_H - -// This file is a stub header file. - -#endif diff --git a/dtool/src/parser-inc/hxtbuff.h b/dtool/src/parser-inc/hxtbuff.h deleted file mode 100644 index 5ba15806f5..0000000000 --- a/dtool/src/parser-inc/hxtbuff.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef HXTBUFF_H -#define HXTBUFF_H - -// This file is a stub header file. - -#endif diff --git a/dtool/src/parser-inc/hxwin.h b/dtool/src/parser-inc/hxwin.h deleted file mode 100644 index b8601c2a63..0000000000 --- a/dtool/src/parser-inc/hxwin.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef HXWIN_H -#define HXWIN_H - -// This file is a stub header file. - -#endif diff --git a/panda/src/pandabase/pandasymbols.h b/panda/src/pandabase/pandasymbols.h index 4e7389dadc..cc02ff0e12 100644 --- a/panda/src/pandabase/pandasymbols.h +++ b/panda/src/pandabase/pandasymbols.h @@ -429,7 +429,4 @@ #define EXPCL_PANDA_PANDABASE EXPCL_PANDA #define EXPTP_PANDA_PANDABASE EXPTP_PANDA -#define EXPCL_PANDA_HELIX EXPCL_PANDA -#define EXPTP_PANDA_HELIX EXPTP_PANDA - #endif From 854d736882516400a6f8ecb172aa0374275dfcf4 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 17 Feb 2018 17:49:36 +0100 Subject: [PATCH 017/247] pgraph: fix alignment error in 32-bit Windows with Eigen Fixes #251 --- panda/src/pgraph/nodePath.cxx | 22 +++++++++++++++++++++- panda/src/pgraph/nodePath.h | 3 ++- panda/src/pgraph/shaderAttrib.cxx | 17 ++++++++++++++++- panda/src/pgraph/shaderAttrib.h | 3 ++- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/panda/src/pgraph/nodePath.cxx b/panda/src/pgraph/nodePath.cxx index c9ccfd7c90..71bbb3a561 100644 --- a/panda/src/pgraph/nodePath.cxx +++ b/panda/src/pgraph/nodePath.cxx @@ -3262,7 +3262,7 @@ get_shader() const { * */ void NodePath:: -set_shader_input(ShaderInput inp) { +set_shader_input(const ShaderInput &inp) { nassertv_always(!is_empty()); PandaNode *pnode = node(); @@ -3278,6 +3278,26 @@ set_shader_input(ShaderInput inp) { } } +/** + * + */ +void NodePath:: +set_shader_input(ShaderInput &&inp) { + nassertv_always(!is_empty()); + + PandaNode *pnode = node(); + const RenderAttrib *attrib = + pnode->get_attrib(ShaderAttrib::get_class_slot()); + if (attrib != nullptr) { + const ShaderAttrib *sa = (const ShaderAttrib *)attrib; + pnode->set_attrib(sa->set_shader_input(move(inp))); + } else { + // Create a new ShaderAttrib for this node. + CPT(ShaderAttrib) sa = DCAST(ShaderAttrib, ShaderAttrib::make()); + pnode->set_attrib(sa->set_shader_input(move(inp))); + } +} + /** * */ diff --git a/panda/src/pgraph/nodePath.h b/panda/src/pgraph/nodePath.h index 617aac46a5..c5a3902c32 100644 --- a/panda/src/pgraph/nodePath.h +++ b/panda/src/pgraph/nodePath.h @@ -629,7 +629,8 @@ PUBLISHED: void set_shader_auto(BitMask32 shader_switch, int priority=0); void clear_shader(); - void set_shader_input(ShaderInput input); + void set_shader_input(const ShaderInput &input); + void set_shader_input(ShaderInput &&input); INLINE void set_shader_input(CPT_InternalName id, Texture *tex, const SamplerState &sampler, int priority=0); INLINE void set_shader_input(CPT_InternalName id, Texture *tex, bool read, bool write, int z=-1, int n=0, int priority=0); diff --git a/panda/src/pgraph/shaderAttrib.cxx b/panda/src/pgraph/shaderAttrib.cxx index 711e886828..130d85c1b8 100644 --- a/panda/src/pgraph/shaderAttrib.cxx +++ b/panda/src/pgraph/shaderAttrib.cxx @@ -195,7 +195,22 @@ clear_flag(int flag) const { * */ CPT(RenderAttrib) ShaderAttrib:: -set_shader_input(ShaderInput input) const { +set_shader_input(const ShaderInput &input) const { + ShaderAttrib *result = new ShaderAttrib(*this); + Inputs::iterator i = result->_inputs.find(input.get_name()); + if (i == result->_inputs.end()) { + result->_inputs.insert(Inputs::value_type(input.get_name(), input)); + } else { + i->second = input; + } + return return_new(result); +} + +/** + * + */ +CPT(RenderAttrib) ShaderAttrib:: +set_shader_input(ShaderInput &&input) const { ShaderAttrib *result = new ShaderAttrib(*this); Inputs::iterator i = result->_inputs.find(input.get_name()); if (i == result->_inputs.end()) { diff --git a/panda/src/pgraph/shaderAttrib.h b/panda/src/pgraph/shaderAttrib.h index cb1eec37d9..02a3189233 100644 --- a/panda/src/pgraph/shaderAttrib.h +++ b/panda/src/pgraph/shaderAttrib.h @@ -71,7 +71,8 @@ PUBLISHED: CPT(RenderAttrib) clear_shader() const; // Shader Inputs - CPT(RenderAttrib) set_shader_input(ShaderInput input) const; + CPT(RenderAttrib) set_shader_input(const ShaderInput &input) const; + CPT(RenderAttrib) set_shader_input(ShaderInput &&input) const; public: INLINE CPT(RenderAttrib) set_shader_input(CPT_InternalName id, Texture *tex, int priority=0) const; From 6bd19768923d177bbb4fda6bca465e285ea64923 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 17 Feb 2018 18:40:08 +0100 Subject: [PATCH 018/247] android: support writing png/jpg/webp via android.graphics.Bitmap --- makepanda/makepanda.py | 3 +- panda/src/android/NativeOStream.java | 52 +++++++ panda/src/android/PandaActivity.java | 26 ++++ panda/src/android/config_android.cxx | 57 ++++++- panda/src/android/config_android.h | 2 + panda/src/android/jni_NativeOStream.cxx | 54 +++++++ panda/src/android/p3android_composite1.cxx | 4 +- panda/src/android/pnmFileTypeAndroid.cxx | 64 ++++---- panda/src/android/pnmFileTypeAndroid.h | 38 +++-- .../src/android/pnmFileTypeAndroidWriter.cxx | 146 ++++++++++++++++++ panda/src/android/pview_manifest.xml | 1 + panda/src/pnmimage/pnmFileTypeRegistry.cxx | 48 +++++- panda/src/pnmimage/pnmFileTypeRegistry.h | 1 + 13 files changed, 426 insertions(+), 70 deletions(-) create mode 100644 panda/src/android/NativeOStream.java create mode 100644 panda/src/android/jni_NativeOStream.cxx create mode 100644 panda/src/android/pnmFileTypeAndroidWriter.cxx diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 69c8c93a37..ad974d38d0 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -5100,7 +5100,8 @@ if (not RTDIST and not RUNTIME and PkgSkip("PVIEW")==0 and GetTarget() != 'andro if (not RUNTIME and GetTarget() == 'android'): OPTS=['DIR:panda/src/android'] TargetAdd('org/panda3d/android/NativeIStream.class', opts=OPTS, input='NativeIStream.java') - TargetAdd('org/panda3d/android/PandaActivity.class', opts=OPTS, input='PandaActivity.java', dep='org/panda3d/android/NativeIStream.class') + TargetAdd('org/panda3d/android/NativeOStream.class', opts=OPTS, input='NativeOStream.java') + TargetAdd('org/panda3d/android/PandaActivity.class', opts=OPTS, input='PandaActivity.java') TargetAdd('p3android_composite1.obj', opts=OPTS, input='p3android_composite1.cxx') TargetAdd('libp3android.dll', input='p3android_composite1.obj') diff --git a/panda/src/android/NativeOStream.java b/panda/src/android/NativeOStream.java new file mode 100644 index 0000000000..ddd76e485a --- /dev/null +++ b/panda/src/android/NativeOStream.java @@ -0,0 +1,52 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file NativeOStream.java + * @author rdb + * @date 2018-02-10 + */ + +package org.panda3d.android; + +import java.io.OutputStream; + +/** + * An implementation of OutputStream that puts its data into a C++ ostream + * pointer, passed as long. + */ +public class NativeOStream extends OutputStream { + private long streamPtr = 0; + + public NativeOStream(long ptr) { + streamPtr = ptr; + } + + @Override + public void flush() { + nativeFlush(streamPtr); + } + + @Override + public void write(int b) { + nativePut(streamPtr, b); + } + + @Override + public void write(byte[] buffer) { + nativeWrite(streamPtr, buffer, 0, buffer.length); + } + + @Override + public void write(byte[] buffer, int offset, int length) { + nativeWrite(streamPtr, buffer, offset, length); + } + + private static native void nativeFlush(long ptr); + private static native void nativePut(long ptr, int b); + private static native void nativeWrite(long ptr, byte[] buffer, int offset, int length); +} diff --git a/panda/src/android/PandaActivity.java b/panda/src/android/PandaActivity.java index c9985986f6..a4413a2816 100644 --- a/panda/src/android/PandaActivity.java +++ b/panda/src/android/PandaActivity.java @@ -20,12 +20,29 @@ import android.widget.Toast; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import org.panda3d.android.NativeIStream; +import org.panda3d.android.NativeOStream; /** * The entry point for a Panda-based activity. Loads the Panda libraries and * also provides some utility functions. */ public class PandaActivity extends NativeActivity { + private static final Bitmap.Config sConfigs[] = { + null, + Bitmap.Config.ALPHA_8, + null, + Bitmap.Config.RGB_565, + Bitmap.Config.ARGB_4444, + Bitmap.Config.ARGB_8888, + null, //Bitmap.Config.RGBA_F16, + null, //Bitmap.Config.HARDWARE, + }; + private static final Bitmap.CompressFormat sFormats[] = { + Bitmap.CompressFormat.JPEG, + Bitmap.CompressFormat.PNG, + Bitmap.CompressFormat.WEBP, + }; + protected static BitmapFactory.Options readBitmapSize(long istreamPtr) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; @@ -44,6 +61,15 @@ public class PandaActivity extends NativeActivity { return BitmapFactory.decodeStream(stream, null, options); } + protected static Bitmap createBitmap(int width, int height, int config, boolean hasAlpha) { + return Bitmap.createBitmap(width, height, sConfigs[config]); + } + + protected static boolean compressBitmap(Bitmap bitmap, int format, int quality, long ostreamPtr) { + NativeOStream stream = new NativeOStream(ostreamPtr); + return bitmap.compress(sFormats[format], quality, stream); + } + protected static String getCurrentThreadName() { return Thread.currentThread().getName(); } diff --git a/panda/src/android/config_android.cxx b/panda/src/android/config_android.cxx index 019443be4b..afbaf243ff 100644 --- a/panda/src/android/config_android.cxx +++ b/panda/src/android/config_android.cxx @@ -24,12 +24,24 @@ struct android_app *panda_android_app = NULL; jclass jni_PandaActivity; jmethodID jni_PandaActivity_readBitmapSize; jmethodID jni_PandaActivity_readBitmap; +jmethodID jni_PandaActivity_createBitmap; +jmethodID jni_PandaActivity_compressBitmap; jmethodID jni_PandaActivity_showToast; jclass jni_BitmapFactory_Options; jfieldID jni_BitmapFactory_Options_outWidth; jfieldID jni_BitmapFactory_Options_outHeight; +#ifndef HAVE_JPEG +static PNMFileTypeAndroid file_type_jpeg(PNMFileTypeAndroid::CF_jpeg); +#endif +#ifndef HAVE_PNG +static PNMFileTypeAndroid file_type_png(PNMFileTypeAndroid::CF_png); +#endif +#if __ANDROID_API__ >= 14 +static PNMFileTypeAndroid file_type_webp(PNMFileTypeAndroid::CF_webp); +#endif + /** * Initializes the library. This must be called at least once before any of * the functions or classes in this library can be used. Normally, this is @@ -37,10 +49,6 @@ jfieldID jni_BitmapFactory_Options_outHeight; */ void init_libandroid() { - PNMFileTypeRegistry *tr = PNMFileTypeRegistry::get_global_ptr(); - PNMFileTypeAndroid::init_type(); - PNMFileTypeAndroid::register_with_read_factory(); - tr->register_type(new PNMFileTypeAndroid); } /** @@ -48,7 +56,7 @@ init_libandroid() { * references and the method IDs. */ jint JNI_OnLoad(JavaVM *jvm, void *reserved) { - init_libandroid(); + //init_libandroid(); Thread *thread = Thread::get_current_thread(); JNIEnv *env = thread->get_jni_env(); @@ -63,6 +71,12 @@ jint JNI_OnLoad(JavaVM *jvm, void *reserved) { jni_PandaActivity_readBitmap = env->GetStaticMethodID(jni_PandaActivity, "readBitmap", "(JI)Landroid/graphics/Bitmap;"); + jni_PandaActivity_createBitmap = env->GetStaticMethodID(jni_PandaActivity, + "createBitmap", "(IIIZ)Landroid/graphics/Bitmap;"); + + jni_PandaActivity_compressBitmap = env->GetStaticMethodID(jni_PandaActivity, + "compressBitmap", "(Landroid/graphics/Bitmap;IIJ)Z"); + jni_PandaActivity_showToast = env->GetMethodID(jni_PandaActivity, "showToast", "(Ljava/lang/String;I)V"); @@ -72,6 +86,25 @@ jint JNI_OnLoad(JavaVM *jvm, void *reserved) { jni_BitmapFactory_Options_outWidth = env->GetFieldID(jni_BitmapFactory_Options, "outWidth", "I"); jni_BitmapFactory_Options_outHeight = env->GetFieldID(jni_BitmapFactory_Options, "outHeight", "I"); + nassertr(jni_PandaActivity_readBitmapSize, -1); + nassertr(jni_PandaActivity_readBitmap, -1); + nassertr(jni_PandaActivity_createBitmap, -1); + nassertr(jni_PandaActivity_compressBitmap, -1); + nassertr(jni_PandaActivity_showToast, -1); + + // We put this in JNI_OnLoad because it relies on Java classes, which + // are only available when launched from the Java VM. + PNMFileTypeRegistry *tr = PNMFileTypeRegistry::get_global_ptr(); +#ifndef HAVE_JPEG + tr->register_type(&file_type_jpeg); +#endif +#ifndef HAVE_PNG + tr->register_type(&file_type_png); +#endif +#if __ANDROID_API__ >= 14 + tr->register_type(&file_type_webp); +#endif + return JNI_VERSION_1_4; } @@ -86,6 +119,20 @@ void JNI_OnUnload(JavaVM *jvm, void *reserved) { env->DeleteGlobalRef(jni_PandaActivity); env->DeleteGlobalRef(jni_BitmapFactory_Options); + + // These will no longer work without JNI, so unregister them. + PNMFileTypeRegistry *tr = PNMFileTypeRegistry::get_global_ptr(); + if (tr != nullptr) { +#ifndef HAVE_JPEG + tr->unregister_type(&file_type_jpeg); +#endif +#ifndef HAVE_PNG + tr->unregister_type(&file_type_png); +#endif +#if __ANDROID_API__ >= 14 + tr->unregister_type(&file_type_webp); +#endif + } } /** diff --git a/panda/src/android/config_android.h b/panda/src/android/config_android.h index 74599ec3d9..2224dbd065 100644 --- a/panda/src/android/config_android.h +++ b/panda/src/android/config_android.h @@ -31,6 +31,8 @@ extern EXPORT_CLASS struct android_app* panda_android_app; extern jclass jni_PandaActivity; extern jmethodID jni_PandaActivity_readBitmapHeader; extern jmethodID jni_PandaActivity_readBitmap; +extern jmethodID jni_PandaActivity_createBitmap; +extern jmethodID jni_PandaActivity_compressBitmap; extern jmethodID jni_PandaActivity_showToast; extern jclass jni_BitmapFactory_Options; diff --git a/panda/src/android/jni_NativeOStream.cxx b/panda/src/android/jni_NativeOStream.cxx new file mode 100644 index 0000000000..c2779d0174 --- /dev/null +++ b/panda/src/android/jni_NativeOStream.cxx @@ -0,0 +1,54 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file jni_NativeOStream.cxx + * @author rdb + * @date 2018-02-10 + */ + +#include + +#include + +#if __GNUC__ >= 4 +#define EXPORT_JNI extern "C" __attribute__((visibility("default"))) +#else +#define EXPORT_JNI extern "C" +#endif + +/** + * Flushes the stream. + */ +EXPORT_JNI void +Java_org_panda3d_android_NativeOStream_nativeFlush(JNIEnv *env, jclass clazz, jlong ptr) { + std::ostream *stream = (std::ostream *)ptr; + + stream->flush(); +} + +/** + * Writes a single character to the ostream. + */ +EXPORT_JNI void +Java_org_panda3d_android_NativeOStream_nativePut(JNIEnv *env, jclass clazz, jlong ptr, int b) { + std::ostream *stream = (std::ostream *)ptr; + + stream->put((char)(b & 0xff)); +} + +/** + * Writes an array of bytes to the ostream. + */ +EXPORT_JNI void +Java_org_panda3d_android_NativeOStream_nativeWrite(JNIEnv *env, jclass clazz, jlong ptr, jbyteArray byte_array, jint offset, jint length) { + std::ostream *stream = (std::ostream *)ptr; + + jbyte *buffer = (jbyte *)alloca(length); + env->GetByteArrayRegion(byte_array, offset, length, buffer); + stream->write((char *)buffer, length); +} diff --git a/panda/src/android/p3android_composite1.cxx b/panda/src/android/p3android_composite1.cxx index 14b48ab99f..ea14d2b311 100644 --- a/panda/src/android/p3android_composite1.cxx +++ b/panda/src/android/p3android_composite1.cxx @@ -1,4 +1,6 @@ #include "config_android.cxx" #include "jni_NativeIStream.cxx" +#include "jni_NativeOStream.cxx" #include "pnmFileTypeAndroid.cxx" -#include "pnmFileTypeAndroidReader.cxx" \ No newline at end of file +#include "pnmFileTypeAndroidReader.cxx" +#include "pnmFileTypeAndroidWriter.cxx" diff --git a/panda/src/android/pnmFileTypeAndroid.cxx b/panda/src/android/pnmFileTypeAndroid.cxx index c661c6b3b0..aa25b2c777 100644 --- a/panda/src/android/pnmFileTypeAndroid.cxx +++ b/panda/src/android/pnmFileTypeAndroid.cxx @@ -17,24 +17,11 @@ #include "config_pnmimagetypes.h" -#include "pnmFileTypeRegistry.h" -#include "bamReader.h" - -static const char * const extensions_android[] = { - "jpg", "jpeg", "gif", "png", -#if __ANDROID_API__ >= 14 - "webp" -#endif -}; -static const int num_extensions_android = sizeof(extensions_android) / sizeof(const char *); - -TypeHandle PNMFileTypeAndroid::_type_handle; - /** * */ PNMFileTypeAndroid:: -PNMFileTypeAndroid() { +PNMFileTypeAndroid(CompressFormat format) : _format(format) { } /** @@ -51,7 +38,16 @@ get_name() const { */ int PNMFileTypeAndroid:: get_num_extensions() const { - return num_extensions_android; + switch (_format) { + case CF_jpeg: + return 3; + case CF_png: + return 1; + case CF_webp: + return 1; + default: + return 0; + } } /** @@ -60,8 +56,17 @@ get_num_extensions() const { */ string PNMFileTypeAndroid:: get_extension(int n) const { - nassertr(n >= 0 && n < num_extensions_android, string()); - return extensions_android[n]; + static const char *const jpeg_extensions[] = {"jpg", "jpeg", "jpe"}; + switch (_format) { + case CF_jpeg: + return jpeg_extensions[n]; + case CF_png: + return "png"; + case CF_webp: + return "webp"; + default: + return 0; + } } /** @@ -80,30 +85,17 @@ has_magic_number() const { */ PNMReader *PNMFileTypeAndroid:: make_reader(istream *file, bool owns_file, const string &magic_number) { - init_pnm(); return new Reader(this, file, owns_file, magic_number); } /** - * Registers the current object as something that can be read from a Bam file. + * Allocates and returns a new PNMWriter suitable for reading from this file + * type, if possible. If writing files of this type is not supported, returns + * NULL. */ -void PNMFileTypeAndroid:: -register_with_read_factory() { - BamReader::get_factory()-> - register_factory(get_class_type(), make_PNMFileTypeAndroid); -} - -/** - * This method is called by the BamReader when an object of this type is - * encountered in a Bam file; it should allocate and return a new object with - * all the data read. - * - * In the case of the PNMFileType objects, since these objects are all shared, - * we just pull the object from the registry. - */ -TypedWritable *PNMFileTypeAndroid:: -make_PNMFileTypeAndroid(const FactoryParams ¶ms) { - return PNMFileTypeRegistry::get_global_ptr()->get_type_by_handle(get_class_type()); +PNMWriter *PNMFileTypeAndroid:: +make_writer(ostream *file, bool owns_file) { + return new Writer(this, file, owns_file, _format); } #endif // ANDROID diff --git a/panda/src/android/pnmFileTypeAndroid.h b/panda/src/android/pnmFileTypeAndroid.h index cc49fd8f4f..f27cc4f23d 100644 --- a/panda/src/android/pnmFileTypeAndroid.h +++ b/panda/src/android/pnmFileTypeAndroid.h @@ -30,7 +30,13 @@ */ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeAndroid : public PNMFileType { public: - PNMFileTypeAndroid(); + enum CompressFormat : jint { + CF_jpeg = 0, + CF_png = 1, + CF_webp = 2, + }; + + PNMFileTypeAndroid(CompressFormat format); virtual string get_name() const; @@ -41,6 +47,7 @@ public: virtual PNMReader *make_reader(istream *file, bool owns_file = true, const string &magic_number = string()); + virtual PNMWriter *make_writer(ostream *file, bool owns_file = true); public: class Reader : public PNMReader { @@ -60,29 +67,20 @@ public: int32_t _format; }; - // The TypedWritable interface follows. -public: - static void register_with_read_factory(); + class Writer : public PNMWriter { + public: + Writer(PNMFileType *type, ostream *file, bool owns_file, + CompressFormat format); -protected: - static TypedWritable *make_PNMFileTypeAndroid(const FactoryParams ¶ms); + virtual int write_data(xel *array, xelval *alpha); + virtual bool supports_grayscale() const; -public: - static TypeHandle get_class_type() { - return _type_handle; - } - static void init_type() { - PNMFileType::init_type(); - register_type(_type_handle, "PNMFileTypeAndroid", - PNMFileType::get_class_type()); - } - virtual TypeHandle get_type() const { - return get_class_type(); - } - virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + private: + CompressFormat _format; + }; private: - static TypeHandle _type_handle; + CompressFormat _format; }; #endif // ANDROID diff --git a/panda/src/android/pnmFileTypeAndroidWriter.cxx b/panda/src/android/pnmFileTypeAndroidWriter.cxx new file mode 100644 index 0000000000..4677a25cbd --- /dev/null +++ b/panda/src/android/pnmFileTypeAndroidWriter.cxx @@ -0,0 +1,146 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeAndroidWriter.cxx + * @author rdb + * @date 2018-02-10 + */ + +#include "pnmFileTypeAndroid.h" + +#ifdef ANDROID + +#include "config_pnmimagetypes.h" + +#include +#include + +// See android/graphics/Bitmap.java +enum class BitmapConfig : jint { + ALPHA_8 = 1, + RGB_565 = 3, + ARGB_4444 = 4, + ARGB_8888 = 5, + RGBA_F16 = 6, + HARDWARE = 7, +}; + +/** + * + */ +PNMFileTypeAndroid::Writer:: +Writer(PNMFileType *type, ostream *file, bool owns_file, + CompressFormat format) : + PNMWriter(type, file, owns_file), + _format(format) +{ +} + +/** + * Writes out an entire image all at once, including the header, based on the + * image data stored in the given _x_size * _y_size array and alpha pointers. + * (If the image type has no alpha channel, alpha is ignored.) Returns the + * number of rows correctly written. + * + * It is the user's responsibility to fill in the header data via calls to + * set_x_size(), set_num_channels(), etc., or copy_header_from(), before + * calling write_data(). + * + * It is important to delete the PNMWriter class after successfully writing + * the data. Failing to do this may result in some data not getting flushed! + * + * Derived classes need not override this if they instead provide + * supports_streaming() and write_row(), below. + */ +int PNMFileTypeAndroid::Writer:: +write_data(xel *array, xelval *alpha) { + size_t num_pixels = (size_t)_x_size * (size_t)_y_size; + + Thread *current_thread = Thread::get_current_thread(); + JNIEnv *env = current_thread->get_jni_env(); + nassertr(env != nullptr, 0); + + // Create a Bitmap object. + jobject bitmap = + env->CallStaticObjectMethod(jni_PandaActivity, + jni_PandaActivity_createBitmap, + (jint)_x_size, (jint)_y_size, + BitmapConfig::ARGB_8888, + (jboolean)has_alpha()); + nassertr(bitmap != nullptr, 0); + + // Get a writable pointer to write our pixel data to. + uint32_t *out; + int rc = AndroidBitmap_lockPixels(env, bitmap, (void **)&out); + if (rc != 0) { + android_cat.error() + << "Could not lock bitmap pixels (result code " << rc << ")\n"; + return 0; + } + + if (_maxval == 255) { + if (has_alpha() && alpha != nullptr) { + for (size_t i = 0; i < num_pixels; ++i) { + out[i] = (array[i].r) + | (array[i].g << 8u) + | (array[i].b << 16u) + | (alpha[i] << 24u); + } + } else { + for (size_t i = 0; i < num_pixels; ++i) { + out[i] = (array[i].r) + | (array[i].g << 8u) + | (array[i].b << 16u) + | 0xff000000u; + } + } + } else { + double ratio = 255.0 / _maxval; + if (has_alpha() && alpha != nullptr) { + for (size_t i = 0; i < num_pixels; ++i) { + out[i] = ((uint32_t)(array[i].r * ratio)) + | ((uint32_t)(array[i].g * ratio) << 8u) + | ((uint32_t)(array[i].b * ratio) << 16u) + | ((uint32_t)(alpha[i] * ratio) << 24u); + } + } else { + for (size_t i = 0; i < num_pixels; ++i) { + out[i] = ((uint32_t)(array[i].r * ratio)) + | ((uint32_t)(array[i].g * ratio) << 8u) + | ((uint32_t)(array[i].b * ratio) << 16u) + | 0xff000000u; + } + } + } + + // Finally, unlock the pixel data and compress it to the ostream. + AndroidBitmap_unlockPixels(env, bitmap); + jboolean res = + env->CallStaticBooleanMethod(jni_PandaActivity, + jni_PandaActivity_compressBitmap, + bitmap, _format, 85, (jlong)_file); + if (!res) { + android_cat.error() + << "Failed to compress bitmap.\n"; + return 0; + } + return _y_size; +} + +/** + * Returns true if this particular PNMWriter understands grayscale images. If + * this is false, then the rgb values of the xel array will be pre-filled with + * the same value across all three channels, to allow the writer to simply + * write out RGB data for a grayscale image. + */ +bool PNMFileTypeAndroid::Writer:: +supports_grayscale() const { + return false; +} + +#endif // ANDROID diff --git a/panda/src/android/pview_manifest.xml b/panda/src/android/pview_manifest.xml index 6b14579a80..30125c673f 100644 --- a/panda/src/android/pview_manifest.xml +++ b/panda/src/android/pview_manifest.xml @@ -6,6 +6,7 @@ android:versionName="1.0"> + diff --git a/panda/src/pnmimage/pnmFileTypeRegistry.cxx b/panda/src/pnmimage/pnmFileTypeRegistry.cxx index 261f311f11..96e24ef1bb 100644 --- a/panda/src/pnmimage/pnmFileTypeRegistry.cxx +++ b/panda/src/pnmimage/pnmFileTypeRegistry.cxx @@ -49,16 +49,19 @@ register_type(PNMFileType *type) { } // Make sure we haven't already registered this type. - Handles::iterator hi = _handles.find(type->get_type()); - if (hi != _handles.end()) { - pnmimage_cat->warning() - << "Attempt to register PNMFileType " << type->get_name() - << " (" << type->get_type() << ") more than once.\n"; - return; + TypeHandle handle = type->get_type(); + if (handle != PNMFileType::get_class_type()) { + Handles::iterator hi = _handles.find(handle); + if (hi != _handles.end()) { + pnmimage_cat->warning() + << "Attempt to register PNMFileType " << type->get_name() + << " (" << type->get_type() << ") more than once.\n"; + return; + } + _handles.insert(Handles::value_type(handle, type)); } _types.push_back(type); - _handles.insert(Handles::value_type(type->get_type(), type)); // Collect the unique extensions associated with the type. pset unique_extensions; @@ -82,6 +85,37 @@ register_type(PNMFileType *type) { _requires_sort = true; } +/** + * Removes a PNMFileType previously passed to register_type. + */ +void PNMFileTypeRegistry:: +unregister_type(PNMFileType *type) { + if (pnmimage_cat->is_debug()) { + pnmimage_cat->debug() + << "Unregistering image type " << type->get_name() << "\n"; + } + + TypeHandle handle = type->get_type(); + if (handle != PNMFileType::get_class_type()) { + Handles::iterator hi = _handles.find(handle); + if (hi != _handles.end()) { + _handles.erase(hi); + } + } + + _types.erase(std::remove(_types.begin(), _types.end(), type), + _types.end()); + + Extensions::iterator ei; + for (ei = _extensions.begin(); ei != _extensions.end(); ++ei) { + Types &types = ei->second; + types.erase(std::remove(types.begin(), types.end(), type), + types.end()); + } + + _requires_sort = true; +} + /** * Returns the total number of types registered. */ diff --git a/panda/src/pnmimage/pnmFileTypeRegistry.h b/panda/src/pnmimage/pnmFileTypeRegistry.h index aec9327d49..9c8702a961 100644 --- a/panda/src/pnmimage/pnmFileTypeRegistry.h +++ b/panda/src/pnmimage/pnmFileTypeRegistry.h @@ -33,6 +33,7 @@ public: ~PNMFileTypeRegistry(); void register_type(PNMFileType *type); + void unregister_type(PNMFileType *type); PUBLISHED: int get_num_types() const; From 8dea93bf3809c1688319952ea0aebfb2aa8cb2a0 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 17 Feb 2018 18:42:39 +0100 Subject: [PATCH 019/247] android: fix touch/stylus taps triggering mouse1 for compatibility --- panda/src/androiddisplay/androidGraphicsWindow.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/panda/src/androiddisplay/androidGraphicsWindow.cxx b/panda/src/androiddisplay/androidGraphicsWindow.cxx index 8a66cde45a..31cd4e23d6 100644 --- a/panda/src/androiddisplay/androidGraphicsWindow.cxx +++ b/panda/src/androiddisplay/androidGraphicsWindow.cxx @@ -545,6 +545,9 @@ handle_motion_event(const AInputEvent *event) { // The up event doesn't let us know which button is up, so we need to // keep track of the button state ourselves. int32_t button_state = AMotionEvent_getButtonState(event); + if (button_state == 0 && action == AMOTION_EVENT_ACTION_DOWN) { + button_state = AMOTION_EVENT_BUTTON_PRIMARY; + } int32_t changed = _mouse_button_state ^ button_state; if (changed != 0) { if (changed & AMOTION_EVENT_BUTTON_PRIMARY) { From 95eee0cab2ff912c68a9f368a3d7ac7480e30bf5 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 17 Feb 2018 20:07:58 +0100 Subject: [PATCH 020/247] android: load prc files from assets. Move assets to /android_asset --- makepanda/makepanda.py | 3 ++- panda/src/android/android_main.cxx | 35 +++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index ad974d38d0..3f75af73e4 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -7525,9 +7525,10 @@ def MakeInstallerAndroid(): continue copy_library(source, base) - # Copy the models as well. + # Copy the models and config files to the virtual assets filesystem. oscmd("mkdir apkroot/assets") oscmd("cp -R %s apkroot/assets/models" % (os.path.join(GetOutputDir(), "models"))) + oscmd("cp -R %s apkroot/assets/etc" % (os.path.join(GetOutputDir(), "etc"))) # Make an empty res folder. It's needed for the apk to be installable, apparently. oscmd("mkdir apkroot/res") diff --git a/panda/src/android/android_main.cxx b/panda/src/android/android_main.cxx index 05a98b768c..7d4e75e4b2 100644 --- a/panda/src/android/android_main.cxx +++ b/panda/src/android/android_main.cxx @@ -133,7 +133,8 @@ void android_main(struct android_app* app) { asset_mount = new VirtualFileMountAndroidAsset(app->activity->assetManager, apk_fn); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - Filename asset_dir(apk_fn.get_dirname(), "assets"); + //Filename asset_dir(apk_fn.get_dirname(), "assets"); + Filename asset_dir("/android_asset"); vfs->mount(asset_mount, asset_dir, 0); // Release the apk_path. @@ -143,6 +144,33 @@ void android_main(struct android_app* app) { //TODO: prevent it from adding the directory multiple times. get_model_path().append_directory(asset_dir); + // Now load the configuration files. + vector pages; + ConfigPageManager *cp_mgr; + AAssetDir *etc = AAssetManager_openDir(app->activity->assetManager, "etc"); + if (etc != nullptr) { + cp_mgr = ConfigPageManager::get_global_ptr(); + const char *filename = AAssetDir_getNextFileName(etc); + while (filename != nullptr) { + // Does it match any of the configured prc patterns? + for (size_t i = 0; i < cp_mgr->get_num_prc_patterns(); ++i) { + GlobPattern pattern = cp_mgr->get_prc_pattern(i); + if (pattern.matches(filename)) { + Filename prc_fn("etc", filename); + istream *in = asset_mount->open_read_file(prc_fn); + if (in != nullptr) { + ConfigPage *page = cp_mgr->make_explicit_page(Filename("/android_asset", prc_fn)); + page->read_prc(*in); + pages.push_back(page); + } + break; + } + } + filename = AAssetDir_getNextFileName(etc); + } + AAssetDir_close(etc); + } + // Also read the intent filename. methodID = env->GetMethodID(activity_class, "getIntentDataPath", "()Ljava/lang/String;"); jstring filename = (jstring) env->CallObjectMethod(activity->clazz, methodID); @@ -229,6 +257,11 @@ void android_main(struct android_app* app) { android_cat.info() << "Destroy requested, exiting from android_main\n"; + for (ConfigPage *page : pages) { + cp_mgr->delete_explicit_page(page); + } + vfs->unmount(asset_mount); + if (filename_str != nullptr) { env->ReleaseStringUTFChars(filename, filename_str); } From 5c90f64182031d924179aab66cef9edb6f83cfe2 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 17 Feb 2018 20:48:58 +0100 Subject: [PATCH 021/247] text: fix is_whitespace() assertion when invalid chars are included --- panda/src/text/textAssembler.cxx | 7 ++++--- tests/text/test_text_assemble.py | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 tests/text/test_text_assemble.py diff --git a/panda/src/text/textAssembler.cxx b/panda/src/text/textAssembler.cxx index a10179db04..49c507dafd 100644 --- a/panda/src/text/textAssembler.cxx +++ b/panda/src/text/textAssembler.cxx @@ -1626,10 +1626,11 @@ assemble_row(TextAssembler::TextRow &row, } if (first_glyph != (TextGlyph *)NULL) { - assert(!first_glyph->is_whitespace()); advance = first_glyph->get_advance() * advance_scale; - swap(placement._glyph, first_glyph); - placed_glyphs.push_back(placement); + if (!first_glyph->is_whitespace()) { + swap(placement._glyph, first_glyph); + placed_glyphs.push_back(placement); + } } // Check if there is a second glyph to create a hacky ligature or some diff --git a/tests/text/test_text_assemble.py b/tests/text/test_text_assemble.py new file mode 100644 index 0000000000..959097029c --- /dev/null +++ b/tests/text/test_text_assemble.py @@ -0,0 +1,7 @@ +from panda3d import core + +def test_text_assemble_null(): + # Tests that no is_whitespace() assert occurs + assembler = core.TextAssembler(core.TextEncoder()) + assembler.set_wtext(u"\0test") + assembler.assemble_text() From ad7669e12ace60a6b7470617c51054ea259d3ab3 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 16 Feb 2018 04:42:31 -0700 Subject: [PATCH 022/247] mathutil: Update FFTCompressor for FFTW3 This has been due for a while. The last FFTW 2.x release was in 1999. Note that this does change some of the loops; this has two benefits: 1) The halfcomplex storage order is now explained with a comment. 2) It fixed the special case "don't break a run of bytes for a zero" which was never triggering due to the value not being *exactly* 0.0. I have tested these changes against older FFT-compressed animation .bams and no noticeable decompression changes are present, so a .bam version bump is not necessary. --- makepanda/makepanda.py | 5 +- panda/src/mathutil/fftCompressor.cxx | 124 +++++++++++++++++++-------- 2 files changed, 91 insertions(+), 38 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 3f75af73e4..21c0181159 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -648,8 +648,7 @@ if (COMPILER == "MSVC"): if (PkgSkip("HARFBUZZ")==0): LibName("HARFBUZZ", GetThirdpartyDir() + "harfbuzz/lib/harfbuzz.lib") IncDirectory("HARFBUZZ", GetThirdpartyDir() + "harfbuzz/include/harfbuzz") - if (PkgSkip("FFTW")==0): LibName("FFTW", GetThirdpartyDir() + "fftw/lib/rfftw.lib") - if (PkgSkip("FFTW")==0): LibName("FFTW", GetThirdpartyDir() + "fftw/lib/fftw.lib") + if (PkgSkip("FFTW")==0): LibName("FFTW", GetThirdpartyDir() + "fftw/lib/fftw3.lib") if (PkgSkip("ARTOOLKIT")==0):LibName("ARTOOLKIT",GetThirdpartyDir() + "artoolkit/lib/libAR.lib") if (PkgSkip("OPENCV")==0): LibName("OPENCV", GetThirdpartyDir() + "opencv/lib/cv.lib") if (PkgSkip("OPENCV")==0): LibName("OPENCV", GetThirdpartyDir() + "opencv/lib/highgui.lib") @@ -816,7 +815,7 @@ if (COMPILER=="GCC"): SmartPkgEnable("FFMPEG", ffmpeg_libs, ffmpeg_libs, ("libavformat/avformat.h", "libavcodec/avcodec.h", "libavutil/avutil.h")) SmartPkgEnable("SWSCALE", "libswscale", "libswscale", ("libswscale/swscale.h"), target_pkg = "FFMPEG", thirdparty_dir = "ffmpeg") SmartPkgEnable("SWRESAMPLE","libswresample", "libswresample", ("libswresample/swresample.h"), target_pkg = "FFMPEG", thirdparty_dir = "ffmpeg") - SmartPkgEnable("FFTW", "", ("rfftw", "fftw"), ("fftw.h", "rfftw.h")) + SmartPkgEnable("FFTW", "", ("fftw3"), ("fftw.h")) SmartPkgEnable("FMODEX", "", ("fmodex"), ("fmodex", "fmodex/fmod.h")) SmartPkgEnable("FREETYPE", "freetype2", ("freetype"), ("freetype2", "freetype2/freetype/freetype.h")) SmartPkgEnable("HARFBUZZ", "harfbuzz", ("harfbuzz"), ("harfbuzz", "harfbuzz/hb-ft.h")) diff --git a/panda/src/mathutil/fftCompressor.cxx b/panda/src/mathutil/fftCompressor.cxx index f96c6f5f7c..0a5b7425e1 100644 --- a/panda/src/mathutil/fftCompressor.cxx +++ b/panda/src/mathutil/fftCompressor.cxx @@ -29,18 +29,14 @@ #undef howmany #endif -#ifdef PHAVE_DRFFTW_H - #include "drfftw.h" -#else - #include "rfftw.h" -#endif +#include "fftw3.h" // These FFTW support objects can only be defined if we actually have the FFTW // library available. -static rfftw_plan get_real_compress_plan(int length); -static rfftw_plan get_real_decompress_plan(int length); +static fftw_plan get_real_compress_plan(int length); +static fftw_plan get_real_decompress_plan(int length); -typedef pmap RealPlans; +typedef pmap RealPlans; static RealPlans _real_compress_plans; static RealPlans _real_decompress_plans; @@ -262,20 +258,31 @@ write_reals(Datagram &datagram, const PN_stdfloat *array, int length) { } // Now generate the Fourier transform. - double *data = (double *)alloca(length * sizeof(double)); + int fft_length = length / 2 + 1; + fftw_complex *fft_bins = (fftw_complex *)alloca(fft_length * sizeof(fftw_complex)); + + // This is for an in-place transform. It doesn't violate strict aliasing + // rules because &fft_bins[0][0] is still a double pointer. This saves on + // precious stack space. + double *data = &fft_bins[0][0]; int i; for (i = 0; i < length; i++) { data[i] = array[i]; } - double *half_complex = (double *)alloca(length * sizeof(double)); - - rfftw_plan plan = get_real_compress_plan(length); - rfftw_one(plan, data, half_complex); + // Note: This is an in-place DFT. `data` and `fft_bins` are aliases. + fftw_plan plan = get_real_compress_plan(length); + fftw_execute_dft_r2c(plan, data, fft_bins); // Now encode the numbers, run-length encoded by size, so we only write out // the number of bits we need for each number. + // Note that Panda3D has conventionally always used FFTW2's halfcomplex + // format for serializing the bins. In short, this means that for an n-length + // FFT, it stores: + // 1) The real components for bins 0 through floor(n/2), followed by... + // 2) The imaginary components for bins floor((n+1)/2)-1 through 1. + // (Imaginary component for bin 0 is never stored, as that's always zero.) vector_double run; RunWidth run_width = RW_invalid; @@ -286,8 +293,18 @@ write_reals(Datagram &datagram, const PN_stdfloat *array, int length) { static const double max_range_16 = 32767.0; static const double max_range_8 = 127.0; - double scale_factor = get_scale_factor(i, length); - double num = cfloor(half_complex[i] / scale_factor + 0.5); + int bin; // which FFT bin we're storing + int j; // 0=real; 1=imag + if (i < fft_length) { + bin = i; + j = 0; + } else { + bin = length - i; + j = 1; + } + + double scale_factor = get_scale_factor(bin, fft_length); + double num = cfloor(fft_bins[bin][j] / scale_factor + 0.5); // How many bits do we need to encode this integer? double a = fabs(num); @@ -313,16 +330,30 @@ write_reals(Datagram &datagram, const PN_stdfloat *array, int length) { // across a single intervening zero, don't interrupt the run just for // that. if (run_width == RW_8 && num_width == RW_0) { - if (i + 1 >= length || half_complex[i + 1] != 0.0) { + if (run.back() != 0) { num_width = RW_8; } } if (num_width != run_width) { // Now we need to flush the last run. + + // First, however, take care of the special case above: if we're + // switching from RW_8 to RW_0, there could be a zero at the end, which + // should be reclaimed into the RW_0 run. + bool reclaimed_zero = (run_width == RW_8 && num_width == RW_0 && + run.back() == 0); + if (reclaimed_zero) { + run.pop_back(); + } + num_written += write_run(datagram, run_width, run); run.clear(); run_width = num_width; + + if (reclaimed_zero) { + run.push_back(0); + } } run.push_back(num); @@ -595,14 +626,36 @@ read_reals(DatagramIterator &di, vector_stdfloat &array) { nassertr(num_read == length, false); nassertr((int)half_complex.size() == length, false); + int fft_length = length / 2 + 1; + fftw_complex *fft_bins = (fftw_complex *)alloca(fft_length * sizeof(fftw_complex)); + int i; - for (i = 0; i < length; i++) { - half_complex[i] *= get_scale_factor(i, length); + for (i = 0; i < fft_length; i++) { + double scale_factor = get_scale_factor(i, fft_length); + + // For an explanation of this, see the compression code's comment about the + // halfcomplex format. + + fft_bins[i][0] = half_complex[i] * scale_factor; + if (i == 0) { + // First bin doesn't store imaginary component + fft_bins[i][1] = 0.0; + } else if ((i == fft_length - 1) && !(length & 1)) { + // Last bin doesn't store imaginary component with even lengths + fft_bins[i][1] = 0.0; + } else { + fft_bins[i][1] = half_complex[length - i] * scale_factor; + } } - double *data = (double *)alloca(length * sizeof(double)); - rfftw_plan plan = get_real_decompress_plan(length); - rfftw_one(plan, &half_complex[0], data); + // This is for an in-place transform. It doesn't violate strict aliasing + // rules because &fft_bins[0][0] is still a double pointer. This saves on + // precious stack space. + double *data = &fft_bins[0][0]; + + // Note: This is an in-place DFT. `data` and `fft_bins` are aliases. + fftw_plan plan = get_real_decompress_plan(length); + fftw_execute_dft_c2r(plan, fft_bins, data); double scale = 1.0 / (double)length; array.reserve(array.size() + length); @@ -770,14 +823,14 @@ free_storage() { for (pi = _real_compress_plans.begin(); pi != _real_compress_plans.end(); ++pi) { - rfftw_destroy_plan((*pi).second); + fftw_destroy_plan((*pi).second); } _real_compress_plans.clear(); for (pi = _real_decompress_plans.begin(); pi != _real_decompress_plans.end(); ++pi) { - rfftw_destroy_plan((*pi).second); + fftw_destroy_plan((*pi).second); } _real_decompress_plans.clear(); #endif @@ -933,17 +986,18 @@ read_run(DatagramIterator &di, vector_double &run) { } /** - * Returns the appropriate scaling for the given position within the - * halfcomplex array. + * Returns the appropriate scaling for the given bin in the FFT output. + * + * The scale factor is the value of one integer in the quantized data. As such, + * greater bins (higher, more noticeable frequencies) have *lower* scaling + * factors, which means greater precision. */ double FFTCompressor:: get_scale_factor(int i, int length) const { - int m = (length / 2) + 1; - int k = (i < m) ? i : length - i; - nassertr(k >= 0 && k < m, 1.0); + nassertr(i < length, 1.0); return _fft_offset + - _fft_factor * pow((double)(m-1 - k) / (double)(m-1), _fft_exponent); + _fft_factor * pow((double)(length - i) / (double)(length), _fft_exponent); } /** @@ -997,7 +1051,7 @@ get_compressability(const PN_stdfloat *data, int length) const { * Returns a FFTW plan suitable for compressing a float array of the indicated * length. */ -static rfftw_plan +static fftw_plan get_real_compress_plan(int length) { RealPlans::iterator pi; pi = _real_compress_plans.find(length); @@ -1005,8 +1059,8 @@ get_real_compress_plan(int length) { return (*pi).second; } - rfftw_plan plan; - plan = rfftw_create_plan(length, FFTW_REAL_TO_COMPLEX, FFTW_ESTIMATE); + fftw_plan plan; + plan = fftw_plan_dft_r2c_1d(length, NULL, NULL, FFTW_ESTIMATE); _real_compress_plans.insert(RealPlans::value_type(length, plan)); return plan; @@ -1016,7 +1070,7 @@ get_real_compress_plan(int length) { * Returns a FFTW plan suitable for decompressing a float array of the * indicated length. */ -static rfftw_plan +static fftw_plan get_real_decompress_plan(int length) { RealPlans::iterator pi; pi = _real_decompress_plans.find(length); @@ -1024,8 +1078,8 @@ get_real_decompress_plan(int length) { return (*pi).second; } - rfftw_plan plan; - plan = rfftw_create_plan(length, FFTW_COMPLEX_TO_REAL, FFTW_ESTIMATE); + fftw_plan plan; + plan = fftw_plan_dft_c2r_1d(length, NULL, NULL, FFTW_ESTIMATE); _real_decompress_plans.insert(RealPlans::value_type(length, plan)); return plan; From 68b1ecfd32408bfef4ad7d5124f1a6775f8d7b64 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 17 Feb 2018 23:00:26 -0700 Subject: [PATCH 023/247] parser-inc: Add stub for FFTW3 header --- dtool/src/parser-inc/{rfftw.h => fftw3.h} | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) rename dtool/src/parser-inc/{rfftw.h => fftw3.h} (75%) diff --git a/dtool/src/parser-inc/rfftw.h b/dtool/src/parser-inc/fftw3.h similarity index 75% rename from dtool/src/parser-inc/rfftw.h rename to dtool/src/parser-inc/fftw3.h index 47bb2102d1..c5b3b8131d 100644 --- a/dtool/src/parser-inc/rfftw.h +++ b/dtool/src/parser-inc/fftw3.h @@ -6,11 +6,9 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * @file rfftw.h - * @author drose - * @date 2007-06-27 + * @file fftw.h + * @author cfsworks + * @date 2018-02-17 */ -typedef struct _rfftw_plan rfftw_plan; - - +typedef struct _fftw_plan fftw_plan; From bc88566906f80b49fc93cdbdf107189d3d96c606 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 19 Feb 2018 19:15:02 -0700 Subject: [PATCH 024/247] tests: Add xfail test for loading a missing audio file --- tests/audio/conftest.py | 6 ++++++ tests/audio/test_loading.py | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100644 tests/audio/conftest.py create mode 100644 tests/audio/test_loading.py diff --git a/tests/audio/conftest.py b/tests/audio/conftest.py new file mode 100644 index 0000000000..60636e6d6e --- /dev/null +++ b/tests/audio/conftest.py @@ -0,0 +1,6 @@ +import pytest +from panda3d.core import * + +@pytest.fixture(scope='module') +def audiomgr(): + return AudioManager.create_AudioManager() diff --git a/tests/audio/test_loading.py b/tests/audio/test_loading.py new file mode 100644 index 0000000000..ddbec1a1da --- /dev/null +++ b/tests/audio/test_loading.py @@ -0,0 +1,6 @@ +import pytest + +@pytest.mark.xfail +def test_missing_file(audiomgr): + sound = audiomgr.get_sound('/not/a/valid/file.ogg') + assert sound is None From f970bc32292dd669fdc1427aaa4f3f36cd10fbce Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 19 Feb 2018 21:27:28 -0700 Subject: [PATCH 025/247] openal: Don't return OpenALAudioSounds that fail to initialize Also don't register them in _all_sounds, where they won't remove themselves due to having already called cleanup() on themselves. Additionally stops a sound in a cleaned-up state from being passed to the app and played. --- panda/src/audiotraits/openalAudioManager.cxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/panda/src/audiotraits/openalAudioManager.cxx b/panda/src/audiotraits/openalAudioManager.cxx index 8d38eeec49..cbdaadbfa1 100644 --- a/panda/src/audiotraits/openalAudioManager.cxx +++ b/panda/src/audiotraits/openalAudioManager.cxx @@ -471,6 +471,12 @@ get_sound(MovieAudio *sound, bool positional, int mode) { PT(OpenALAudioSound) oas = new OpenALAudioSound(this, sound, positional, mode); + if(!oas->_manager) { + // The sound cleaned itself up immediately. It pretty clearly didn't like + // something, so we should just return a null sound instead. + return get_null_sound(); + } + _all_sounds.insert(oas); PT(AudioSound) res = (AudioSound*)(OpenALAudioSound*)oas; return res; @@ -500,6 +506,12 @@ get_sound(const string &file_name, bool positional, int mode) { PT(OpenALAudioSound) oas = new OpenALAudioSound(this, mva, positional, mode); + if(!oas->_manager) { + // The sound cleaned itself up immediately. It pretty clearly didn't like + // something, so we should just return a null sound instead. + return get_null_sound(); + } + _all_sounds.insert(oas); PT(AudioSound) res = (AudioSound*)(OpenALAudioSound*)oas; return res; From 50b3b87ad51ddba70405b3acc8ae2addf477fff6 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 19 Feb 2018 23:50:05 -0700 Subject: [PATCH 026/247] openal: Explicitly signal a needed cleanup from require_sound_data --- panda/src/audiotraits/openalAudioSound.I | 7 +++++-- panda/src/audiotraits/openalAudioSound.cxx | 12 +++++++----- panda/src/audiotraits/openalAudioSound.h | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/panda/src/audiotraits/openalAudioSound.I b/panda/src/audiotraits/openalAudioSound.I index a68d36ee12..1b7e56a82c 100644 --- a/panda/src/audiotraits/openalAudioSound.I +++ b/panda/src/audiotraits/openalAudioSound.I @@ -37,16 +37,19 @@ get_calibrated_clock(double rtc) const { /** * Makes sure the sound data record is present, and if not, obtains it. + * + * Returns true on success, false on failure. */ -void OpenALAudioSound:: +bool OpenALAudioSound:: require_sound_data() { if (_sd==0) { _sd = _manager->get_sound_data(_movie, _desired_mode); if (_sd==0) { audio_error("Could not open audio " << _movie->get_filename()); - cleanup(); + return false; } } + return true; } /** diff --git a/panda/src/audiotraits/openalAudioSound.cxx b/panda/src/audiotraits/openalAudioSound.cxx index 9abaf24036..d3c5ff7291 100644 --- a/panda/src/audiotraits/openalAudioSound.cxx +++ b/panda/src/audiotraits/openalAudioSound.cxx @@ -69,8 +69,8 @@ OpenALAudioSound(OpenALAudioManager* manager, ReMutexHolder holder(OpenALAudioManager::_lock); - require_sound_data(); - if (_manager == NULL) { + if (!require_sound_data()) { + cleanup(); return; } @@ -130,10 +130,12 @@ play() { stop(); - require_sound_data(); - if (_manager == 0) return; - _manager->starting_sound(this); + if (!require_sound_data()) { + cleanup(); + return; + } + _manager->starting_sound(this); if (!_source) { return; } diff --git a/panda/src/audiotraits/openalAudioSound.h b/panda/src/audiotraits/openalAudioSound.h index 3442acb4f2..f5b02667e5 100644 --- a/panda/src/audiotraits/openalAudioSound.h +++ b/panda/src/audiotraits/openalAudioSound.h @@ -116,7 +116,7 @@ private: int read_stream_data(int bytelen, unsigned char *data); void pull_used_buffers(); void push_fresh_buffers(); - INLINE void require_sound_data(); + INLINE bool require_sound_data(); INLINE void release_sound_data(); private: From 7aedc2151035174632a7f3e55be7563f71e65117 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Tue, 20 Feb 2018 00:55:13 -0700 Subject: [PATCH 027/247] tests: Update audio test to recognize missing sounds as NullAudioSound --- tests/audio/test_loading.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/audio/test_loading.py b/tests/audio/test_loading.py index ddbec1a1da..ea3bdb2cd9 100644 --- a/tests/audio/test_loading.py +++ b/tests/audio/test_loading.py @@ -1,6 +1,5 @@ import pytest -@pytest.mark.xfail def test_missing_file(audiomgr): sound = audiomgr.get_sound('/not/a/valid/file.ogg') - assert sound is None + assert str(sound).startswith('NullAudioSound') From 9afdb78d947e51ce84e09a4885ff3c3895f8bc4e Mon Sep 17 00:00:00 2001 From: deflected Date: Wed, 21 Feb 2018 15:04:47 +0100 Subject: [PATCH 028/247] bullet: make thread-safe by adding global lock mechanism Also addresses some memory leaks. --- .../bulletBaseCharacterControllerNode.h | 4 +- panda/src/bullet/bulletBodyNode.I | 129 ----- panda/src/bullet/bulletBodyNode.cxx | 240 ++++++++- panda/src/bullet/bulletBodyNode.h | 31 +- panda/src/bullet/bulletBoxShape.I | 17 - panda/src/bullet/bulletBoxShape.cxx | 24 + panda/src/bullet/bulletBoxShape.h | 4 +- panda/src/bullet/bulletCapsuleShape.I | 20 - panda/src/bullet/bulletCapsuleShape.cxx | 27 + panda/src/bullet/bulletCapsuleShape.h | 4 +- .../bullet/bulletCharacterControllerNode.I | 2 + .../bullet/bulletCharacterControllerNode.cxx | 46 +- .../bullet/bulletCharacterControllerNode.h | 6 +- panda/src/bullet/bulletConeShape.I | 20 - panda/src/bullet/bulletConeShape.cxx | 26 + panda/src/bullet/bulletConeShape.h | 4 +- panda/src/bullet/bulletConeTwistConstraint.I | 18 - .../src/bullet/bulletConeTwistConstraint.cxx | 31 ++ panda/src/bullet/bulletConeTwistConstraint.h | 4 +- panda/src/bullet/bulletConvexHullShape.I | 16 - panda/src/bullet/bulletConvexHullShape.cxx | 26 + panda/src/bullet/bulletConvexHullShape.h | 4 +- .../src/bullet/bulletConvexPointCloudShape.I | 27 - .../bullet/bulletConvexPointCloudShape.cxx | 32 ++ .../src/bullet/bulletConvexPointCloudShape.h | 6 +- panda/src/bullet/bulletCylinderShape.I | 44 -- panda/src/bullet/bulletCylinderShape.cxx | 55 ++ panda/src/bullet/bulletCylinderShape.h | 10 +- panda/src/bullet/bulletDebugNode.cxx | 5 +- panda/src/bullet/bulletDebugNode.h | 4 +- panda/src/bullet/bulletGenericConstraint.I | 18 - panda/src/bullet/bulletGenericConstraint.cxx | 28 + panda/src/bullet/bulletGenericConstraint.h | 4 +- panda/src/bullet/bulletGhostNode.I | 20 - panda/src/bullet/bulletGhostNode.cxx | 52 +- panda/src/bullet/bulletGhostNode.h | 10 +- panda/src/bullet/bulletHeightfieldShape.I | 30 -- panda/src/bullet/bulletHeightfieldShape.cxx | 40 +- panda/src/bullet/bulletHeightfieldShape.h | 4 +- panda/src/bullet/bulletHingeConstraint.I | 18 - panda/src/bullet/bulletHingeConstraint.cxx | 33 ++ panda/src/bullet/bulletHingeConstraint.h | 4 +- panda/src/bullet/bulletManifoldPoint.I | 225 -------- panda/src/bullet/bulletManifoldPoint.cxx | 266 ++++++++++ panda/src/bullet/bulletManifoldPoint.h | 46 +- panda/src/bullet/bulletMinkowskiSumShape.I | 58 --- panda/src/bullet/bulletMinkowskiSumShape.cxx | 66 +++ panda/src/bullet/bulletMinkowskiSumShape.h | 12 +- panda/src/bullet/bulletMultiSphereShape.I | 45 -- panda/src/bullet/bulletMultiSphereShape.cxx | 52 ++ panda/src/bullet/bulletMultiSphereShape.h | 10 +- panda/src/bullet/bulletPersistentManifold.cxx | 7 + panda/src/bullet/bulletPlaneShape.I | 34 -- panda/src/bullet/bulletPlaneShape.cxx | 40 ++ panda/src/bullet/bulletPlaneShape.h | 8 +- panda/src/bullet/bulletRigidBodyNode.I | 35 -- panda/src/bullet/bulletRigidBodyNode.cxx | 146 +++++- panda/src/bullet/bulletRigidBodyNode.h | 18 +- panda/src/bullet/bulletRotationalLimitMotor.I | 159 +----- .../src/bullet/bulletRotationalLimitMotor.cxx | 176 ++++++- panda/src/bullet/bulletRotationalLimitMotor.h | 38 +- panda/src/bullet/bulletShape.I | 63 --- panda/src/bullet/bulletShape.cxx | 89 +++- panda/src/bullet/bulletShape.h | 15 +- panda/src/bullet/bulletSliderConstraint.I | 18 - panda/src/bullet/bulletSliderConstraint.cxx | 43 ++ panda/src/bullet/bulletSliderConstraint.h | 4 +- panda/src/bullet/bulletSoftBodyConfig.I | 436 ---------------- panda/src/bullet/bulletSoftBodyConfig.cxx | 489 ++++++++++++++++++ panda/src/bullet/bulletSoftBodyConfig.h | 96 ++-- panda/src/bullet/bulletSoftBodyMaterial.I | 63 --- panda/src/bullet/bulletSoftBodyMaterial.cxx | 69 +++ panda/src/bullet/bulletSoftBodyMaterial.h | 14 +- panda/src/bullet/bulletSoftBodyNode.I | 53 -- panda/src/bullet/bulletSoftBodyNode.cxx | 148 +++++- panda/src/bullet/bulletSoftBodyNode.h | 19 +- panda/src/bullet/bulletSoftBodyShape.cxx | 1 + panda/src/bullet/bulletSoftBodyWorldInfo.cxx | 11 + panda/src/bullet/bulletSphereShape.I | 18 - panda/src/bullet/bulletSphereShape.cxx | 23 + panda/src/bullet/bulletSphereShape.h | 4 +- .../src/bullet/bulletSphericalConstraint.cxx | 4 + .../bullet/bulletTranslationalLimitMotor.I | 161 +----- .../bullet/bulletTranslationalLimitMotor.cxx | 179 ++++++- .../bullet/bulletTranslationalLimitMotor.h | 36 +- panda/src/bullet/bulletTriangleMesh.I | 28 - panda/src/bullet/bulletTriangleMesh.cxx | 81 ++- panda/src/bullet/bulletTriangleMesh.h | 12 +- panda/src/bullet/bulletTriangleMeshShape.I | 21 - panda/src/bullet/bulletTriangleMeshShape.cxx | 28 +- panda/src/bullet/bulletTriangleMeshShape.h | 4 +- panda/src/bullet/bulletVehicle.I | 117 +---- panda/src/bullet/bulletVehicle.cxx | 173 ++++++- panda/src/bullet/bulletVehicle.h | 29 +- panda/src/bullet/bulletWheel.I | 71 --- panda/src/bullet/bulletWheel.cxx | 128 +++++ panda/src/bullet/bulletWheel.h | 16 +- panda/src/bullet/bulletWorld.I | 135 ----- panda/src/bullet/bulletWorld.cxx | 436 +++++++++++++--- panda/src/bullet/bulletWorld.h | 65 ++- 100 files changed, 3469 insertions(+), 2519 deletions(-) diff --git a/panda/src/bullet/bulletBaseCharacterControllerNode.h b/panda/src/bullet/bulletBaseCharacterControllerNode.h index e7abe41886..eafc561c67 100644 --- a/panda/src/bullet/bulletBaseCharacterControllerNode.h +++ b/panda/src/bullet/bulletBaseCharacterControllerNode.h @@ -43,8 +43,8 @@ public: virtual btPairCachingGhostObject *get_ghost() const = 0; virtual btCharacterControllerInterface *get_character() const = 0; - virtual void sync_p2b(PN_stdfloat dt, int num_substeps) = 0; - virtual void sync_b2p() = 0; + virtual void do_sync_p2b(PN_stdfloat dt, int num_substeps) = 0; + virtual void do_sync_b2p() = 0; public: static TypeHandle get_class_type() { diff --git a/panda/src/bullet/bulletBodyNode.I b/panda/src/bullet/bulletBodyNode.I index 01e62e8bd6..6f9aac9f45 100644 --- a/panda/src/bullet/bulletBodyNode.I +++ b/panda/src/bullet/bulletBodyNode.I @@ -84,51 +84,6 @@ get_collision_response() const { return !get_collision_flag(btCollisionObject::CF_NO_CONTACT_RESPONSE); } -/** - * - */ -INLINE void BulletBodyNode:: -set_collision_flag(int flag, bool value) { - - int flags = get_object()->getCollisionFlags(); - - if (value == true) { - flags |= flag; - } - else { - flags &= ~(flag); - } - - get_object()->setCollisionFlags(flags); -} - -/** - * - */ -INLINE bool BulletBodyNode:: -get_collision_flag(int flag) const { - - return (get_object()->getCollisionFlags() & flag) ? true : false; -} - -/** - * - */ -INLINE bool BulletBodyNode:: -is_static() const { - - return get_object()->isStaticObject(); -} - -/** - * - */ -INLINE bool BulletBodyNode:: -is_kinematic() const { - - return get_object()->isKinematicObject(); -} - /** * */ @@ -147,90 +102,6 @@ set_kinematic(bool value) { set_collision_flag(btCollisionObject::CF_KINEMATIC_OBJECT, value); } -/** - * - */ -INLINE PN_stdfloat BulletBodyNode:: -get_restitution() const { - - return get_object()->getRestitution(); -} - -/** - * - */ -INLINE void BulletBodyNode:: -set_restitution(PN_stdfloat restitution) { - - return get_object()->setRestitution(restitution); -} - -/** - * - */ -INLINE PN_stdfloat BulletBodyNode:: -get_friction() const { - - return get_object()->getFriction(); -} - -/** - * - */ -INLINE void BulletBodyNode:: -set_friction(PN_stdfloat friction) { - - return get_object()->setFriction(friction); -} - -#if BT_BULLET_VERSION >= 281 -/** - * - */ -INLINE PN_stdfloat BulletBodyNode:: -get_rolling_friction() const { - - return get_object()->getRollingFriction(); -} - -/** - * - */ -INLINE void BulletBodyNode:: -set_rolling_friction(PN_stdfloat friction) { - - return get_object()->setRollingFriction(friction); -} -#endif - -/** - * - */ -INLINE bool BulletBodyNode:: -has_anisotropic_friction() const { - - return get_object()->hasAnisotropicFriction(); -} - -/** - * - */ -INLINE int BulletBodyNode:: -get_num_shapes() const { - - return _shapes.size(); -} - -/** - * - */ -INLINE BulletShape *BulletBodyNode:: -get_shape(int idx) const { - - nassertr(idx >= 0 && idx < (int)_shapes.size(), NULL); - return _shapes[idx]; -} - /** * Enables or disables the debug visualisation for this collision object. By * default the debug visualisation is enabled. diff --git a/panda/src/bullet/bulletBodyNode.cxx b/panda/src/bullet/bulletBodyNode.cxx index b078864ccc..f02641cd96 100644 --- a/panda/src/bullet/bulletBodyNode.cxx +++ b/panda/src/bullet/bulletBodyNode.cxx @@ -41,9 +41,11 @@ BulletBodyNode(const char *name) : PandaNode(name) { */ BulletBodyNode:: BulletBodyNode(const BulletBodyNode ©) : - PandaNode(copy), - _shapes(copy._shapes) + PandaNode(copy) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _shapes = copy._shapes; if (copy._shape && copy._shape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE) { // btCompoundShape does not define a copy constructor. Manually copy. btCompoundShape *shape = new btCompoundShape; @@ -148,16 +150,168 @@ safe_to_flatten_below() const { * */ void BulletBodyNode:: -output(ostream &out) const { +do_output(ostream &out) const { PandaNode::output(out); - out << " (" << get_num_shapes() << " shapes)"; + out << " (" << _shapes.size() << " shapes)"; - out << (is_active() ? " active" : " inactive"); + out << (get_object()->isActive() ? " active" : " inactive"); - if (is_static()) out << " static"; - if (is_kinematic()) out << " kinematic"; + if (get_object()->isStaticObject()) out << " static"; + if (get_object()->isKinematicObject()) out << " kinematic"; +} + +/** + * + */ +void BulletBodyNode:: +output(ostream &out) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + do_output(out); +} + +/** + * + */ +void BulletBodyNode:: +set_collision_flag(int flag, bool value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + int flags = get_object()->getCollisionFlags(); + + if (value == true) { + flags |= flag; + } + else { + flags &= ~(flag); + } + + get_object()->setCollisionFlags(flags); +} + +/** + * + */ +bool BulletBodyNode:: +get_collision_flag(int flag) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (get_object()->getCollisionFlags() & flag) ? true : false; +} + +/** + * + */ +bool BulletBodyNode:: +is_static() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return get_object()->isStaticObject(); +} + +/** + * + */ +bool BulletBodyNode:: +is_kinematic() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return get_object()->isKinematicObject(); +} + +/** + * + */ +PN_stdfloat BulletBodyNode:: +get_restitution() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return get_object()->getRestitution(); +} + +/** + * + */ +void BulletBodyNode:: +set_restitution(PN_stdfloat restitution) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return get_object()->setRestitution(restitution); +} + +/** + * + */ +PN_stdfloat BulletBodyNode:: +get_friction() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return get_object()->getFriction(); +} + +/** + * + */ +void BulletBodyNode:: +set_friction(PN_stdfloat friction) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return get_object()->setFriction(friction); +} + +#if BT_BULLET_VERSION >= 281 +/** + * + */ +PN_stdfloat BulletBodyNode:: +get_rolling_friction() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return get_object()->getRollingFriction(); +} + +/** + * + */ +void BulletBodyNode:: +set_rolling_friction(PN_stdfloat friction) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return get_object()->setRollingFriction(friction); +} +#endif + +/** + * + */ +bool BulletBodyNode:: +has_anisotropic_friction() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return get_object()->hasAnisotropicFriction(); +} + +/** + * + */ +int BulletBodyNode:: +get_num_shapes() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return _shapes.size(); +} + +/** + * + */ +BulletShape *BulletBodyNode:: +get_shape(int idx) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + nassertr(idx >= 0 && idx < (int)_shapes.size(), NULL); + return _shapes[idx]; } /** @@ -165,6 +319,16 @@ output(ostream &out) const { */ void BulletBodyNode:: add_shape(BulletShape *bullet_shape, const TransformState *ts) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + do_add_shape(bullet_shape, ts); +} + +/** + * Assumes the lock(bullet global lock) is held by the caller + */ +void BulletBodyNode:: +do_add_shape(BulletShape *bullet_shape, const TransformState *ts) { nassertv(get_object()); nassertv(ts); @@ -246,7 +410,7 @@ add_shape(BulletShape *bullet_shape, const TransformState *ts) { // Restore the local scaling again np.set_scale(scale); - shape_changed(); + do_shape_changed(); } /** @@ -254,6 +418,7 @@ add_shape(BulletShape *bullet_shape, const TransformState *ts) { */ void BulletBodyNode:: remove_shape(BulletShape *shape) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(get_object()); @@ -312,7 +477,7 @@ remove_shape(BulletShape *shape) { compound->removeChildShape(shape->ptr()); } - shape_changed(); + do_shape_changed(); } } @@ -333,6 +498,7 @@ is_identity(btTransform &trans) { */ LPoint3 BulletBodyNode:: get_shape_pos(int idx) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertr(idx >= 0 && idx < (int)_shapes.size(), LPoint3::zero()); @@ -352,14 +518,17 @@ get_shape_pos(int idx) const { */ LMatrix4 BulletBodyNode:: get_shape_mat(int idx) const { - return get_shape_transform(idx)->get_mat(); + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return do_get_shape_transform(idx)->get_mat(); } /** * */ CPT(TransformState) BulletBodyNode:: -get_shape_transform(int idx) const { +do_get_shape_transform(int idx) const { + nassertr(idx >= 0 && idx < (int)_shapes.size(), TransformState::make_identity()); btCollisionShape *root = get_object()->getCollisionShape(); @@ -386,13 +555,25 @@ get_shape_transform(int idx) const { return TransformState::make_identity(); } +/** + * + */ +CPT(TransformState) BulletBodyNode:: +get_shape_transform(int idx) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return do_get_shape_transform(idx); +} + + /** * Hook which will be called whenever the total shape of a body changed. Used * for example to update the mass properties (inertia) of a rigid body. The * default implementation does nothing. + * Assumes the lock(bullet global lock) is held */ void BulletBodyNode:: -shape_changed() { +do_shape_changed() { } @@ -401,6 +582,7 @@ shape_changed() { */ void BulletBodyNode:: set_deactivation_time(PN_stdfloat dt) { + LightMutexHolder holder(BulletWorld::get_global_lock()); get_object()->setDeactivationTime(dt); } @@ -410,6 +592,7 @@ set_deactivation_time(PN_stdfloat dt) { */ PN_stdfloat BulletBodyNode:: get_deactivation_time() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return get_object()->getDeactivationTime(); } @@ -419,6 +602,7 @@ get_deactivation_time() const { */ bool BulletBodyNode:: is_active() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return get_object()->isActive(); } @@ -428,6 +612,7 @@ is_active() const { */ void BulletBodyNode:: set_active(bool active, bool force) { + LightMutexHolder holder(BulletWorld::get_global_lock()); if (active) { get_object()->activate(force); @@ -457,10 +642,12 @@ force_active(bool active) { */ void BulletBodyNode:: set_deactivation_enabled(bool enabled) { + LightMutexHolder holder(BulletWorld::get_global_lock()); // Don't change the state if it's currently active and we enable // deactivation. - if (enabled != is_deactivation_enabled()) { + bool is_enabled = get_object()->getActivationState() != DISABLE_DEACTIVATION; + if (enabled != is_enabled) { // It's OK to set to ACTIVE_TAG even if we don't mean to activate it; it // will be disabled right away if the deactivation timer has run out. @@ -474,6 +661,7 @@ set_deactivation_enabled(bool enabled) { */ bool BulletBodyNode:: is_deactivation_enabled() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (get_object()->getActivationState() != DISABLE_DEACTIVATION); } @@ -483,6 +671,7 @@ is_deactivation_enabled() const { */ bool BulletBodyNode:: check_collision_with(PandaNode *node) { + LightMutexHolder holder(BulletWorld::get_global_lock()); btCollisionObject *obj = BulletWorld::get_collision_object(node); @@ -499,6 +688,7 @@ check_collision_with(PandaNode *node) { */ LVecBase3 BulletBodyNode:: get_anisotropic_friction() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LVecBase3(get_object()->getAnisotropicFriction()); } @@ -508,6 +698,7 @@ get_anisotropic_friction() const { */ void BulletBodyNode:: set_anisotropic_friction(const LVecBase3 &friction) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(!friction.is_nan()); get_object()->setAnisotropicFriction(LVecBase3_to_btVector3(friction)); @@ -518,6 +709,7 @@ set_anisotropic_friction(const LVecBase3 &friction) { */ bool BulletBodyNode:: has_contact_response() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return get_object()->hasContactResponse(); } @@ -527,7 +719,8 @@ has_contact_response() const { */ PN_stdfloat BulletBodyNode:: get_contact_processing_threshold() const { - + LightMutexHolder holder(BulletWorld::get_global_lock()); + return get_object()->getContactProcessingThreshold(); } @@ -537,6 +730,7 @@ get_contact_processing_threshold() const { */ void BulletBodyNode:: set_contact_processing_threshold(PN_stdfloat threshold) { + LightMutexHolder holder(BulletWorld::get_global_lock()); get_object()->setContactProcessingThreshold(threshold); } @@ -546,6 +740,7 @@ set_contact_processing_threshold(PN_stdfloat threshold) { */ PN_stdfloat BulletBodyNode:: get_ccd_swept_sphere_radius() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return get_object()->getCcdSweptSphereRadius(); } @@ -555,6 +750,7 @@ get_ccd_swept_sphere_radius() const { */ void BulletBodyNode:: set_ccd_swept_sphere_radius(PN_stdfloat radius) { + LightMutexHolder holder(BulletWorld::get_global_lock()); return get_object()->setCcdSweptSphereRadius(radius); } @@ -564,6 +760,7 @@ set_ccd_swept_sphere_radius(PN_stdfloat radius) { */ PN_stdfloat BulletBodyNode:: get_ccd_motion_threshold() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return get_object()->getCcdMotionThreshold(); } @@ -573,6 +770,7 @@ get_ccd_motion_threshold() const { */ void BulletBodyNode:: set_ccd_motion_threshold(PN_stdfloat threshold) { + LightMutexHolder holder(BulletWorld::get_global_lock()); return get_object()->setCcdMotionThreshold(threshold); } @@ -582,6 +780,7 @@ set_ccd_motion_threshold(PN_stdfloat threshold) { */ void BulletBodyNode:: add_shapes_from_collision_solids(CollisionNode *cnode) { + LightMutexHolder holder(BulletWorld::get_global_lock()); PT(BulletTriangleMesh) mesh = NULL; @@ -594,7 +793,7 @@ add_shapes_from_collision_solids(CollisionNode *cnode) { CPT(CollisionSphere) sphere = DCAST(CollisionSphere, solid); CPT(TransformState) ts = TransformState::make_pos(sphere->get_center()); - add_shape(BulletSphereShape::make_from_solid(sphere), ts); + do_add_shape(BulletSphereShape::make_from_solid(sphere), ts); } // CollisionBox @@ -602,14 +801,14 @@ add_shapes_from_collision_solids(CollisionNode *cnode) { CPT(CollisionBox) box = DCAST(CollisionBox, solid); CPT(TransformState) ts = TransformState::make_pos(box->get_center()); - add_shape(BulletBoxShape::make_from_solid(box), ts); + do_add_shape(BulletBoxShape::make_from_solid(box), ts); } // CollisionPlane else if (CollisionPlane::get_class_type() == type) { CPT(CollisionPlane) plane = DCAST(CollisionPlane, solid); - add_shape(BulletPlaneShape::make_from_solid(plane)); + do_add_shape(BulletPlaneShape::make_from_solid(plane)); } // CollisionGeom @@ -625,13 +824,13 @@ add_shapes_from_collision_solids(CollisionNode *cnode) { LPoint3 p2 = polygon->get_point(i-1); LPoint3 p3 = polygon->get_point(i); - mesh->add_triangle(p1, p2, p3, true); + mesh->do_add_triangle(p1, p2, p3, true); } } } - if (mesh && mesh->get_num_triangles() > 0) { - add_shape(new BulletTriangleMeshShape(mesh, true)); + if (mesh && mesh->do_get_num_triangles() > 0) { + do_add_shape(new BulletTriangleMeshShape(mesh, true)); } } @@ -651,6 +850,7 @@ set_transform_dirty() { */ BoundingSphere BulletBodyNode:: get_shape_bounds() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); /* btTransform tr; diff --git a/panda/src/bullet/bulletBodyNode.h b/panda/src/bullet/bulletBodyNode.h index 562e88c7fb..55f8583938 100644 --- a/panda/src/bullet/bulletBodyNode.h +++ b/panda/src/bullet/bulletBodyNode.h @@ -42,8 +42,8 @@ PUBLISHED: void add_shape(BulletShape *shape, const TransformState *xform=TransformState::make_identity()); void remove_shape(BulletShape *shape); - INLINE int get_num_shapes() const; - INLINE BulletShape *get_shape(int idx) const; + int get_num_shapes() const; + BulletShape *get_shape(int idx) const; MAKE_SEQ(get_shapes, get_num_shapes, get_shape); LPoint3 get_shape_pos(int idx) const; @@ -54,8 +54,8 @@ PUBLISHED: void add_shapes_from_collision_solids(CollisionNode *cnode); // Static and kinematic - INLINE bool is_static() const; - INLINE bool is_kinematic() const; + bool is_static() const; + bool is_kinematic() const; INLINE void set_static(bool value); INLINE void set_kinematic(bool value); @@ -92,19 +92,19 @@ PUBLISHED: INLINE bool is_debug_enabled() const; // Friction and Restitution - INLINE PN_stdfloat get_restitution() const; - INLINE void set_restitution(PN_stdfloat restitution); + PN_stdfloat get_restitution() const; + void set_restitution(PN_stdfloat restitution); - INLINE PN_stdfloat get_friction() const; - INLINE void set_friction(PN_stdfloat friction); + PN_stdfloat get_friction() const; + void set_friction(PN_stdfloat friction); #if BT_BULLET_VERSION >= 281 - INLINE PN_stdfloat get_rolling_friction() const; - INLINE void set_rolling_friction(PN_stdfloat friction); + PN_stdfloat get_rolling_friction() const; + void set_rolling_friction(PN_stdfloat friction); MAKE_PROPERTY(rolling_friction, get_rolling_friction, set_rolling_friction); #endif - INLINE bool has_anisotropic_friction() const; + bool has_anisotropic_friction() const; void set_anisotropic_friction(const LVecBase3 &friction); LVecBase3 get_anisotropic_friction() const; @@ -151,10 +151,11 @@ public: virtual bool safe_to_flatten_below() const; virtual void output(ostream &out) const; + virtual void do_output(ostream &out) const; protected: - INLINE void set_collision_flag(int flag, bool value); - INLINE bool get_collision_flag(int flag) const; + void set_collision_flag(int flag, bool value); + bool get_collision_flag(int flag) const; btCollisionShape *_shape; @@ -162,7 +163,9 @@ protected: BulletShapes _shapes; private: - virtual void shape_changed(); + virtual void do_shape_changed(); + void do_add_shape(BulletShape *shape, const TransformState *xform=TransformState::make_identity()); + CPT(TransformState) do_get_shape_transform(int idx) const; static bool is_identity(btTransform &trans); diff --git a/panda/src/bullet/bulletBoxShape.I b/panda/src/bullet/bulletBoxShape.I index 384aace8b6..f432db4a69 100644 --- a/panda/src/bullet/bulletBoxShape.I +++ b/panda/src/bullet/bulletBoxShape.I @@ -28,20 +28,3 @@ INLINE BulletBoxShape:: delete _shape; } - -/** - * - */ -INLINE BulletBoxShape:: -BulletBoxShape(const BulletBoxShape ©) : - _shape(copy._shape), _half_extents(copy._half_extents) { -} - -/** - * - */ -INLINE void BulletBoxShape:: -operator = (const BulletBoxShape ©) { - _shape = copy._shape; - _half_extents = copy._half_extents; -} diff --git a/panda/src/bullet/bulletBoxShape.cxx b/panda/src/bullet/bulletBoxShape.cxx index f523184993..9ae2e16a11 100644 --- a/panda/src/bullet/bulletBoxShape.cxx +++ b/panda/src/bullet/bulletBoxShape.cxx @@ -28,6 +28,28 @@ BulletBoxShape(const LVecBase3 &halfExtents) : _half_extents(halfExtents) { _shape->setUserPointer(this); } +/** + * + */ +BulletBoxShape:: +BulletBoxShape(const BulletBoxShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _shape = copy._shape; + _half_extents = copy._half_extents; +} + +/** + * + */ +void BulletBoxShape:: +operator = (const BulletBoxShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _shape = copy._shape; + _half_extents = copy._half_extents; +} + /** * */ @@ -42,6 +64,7 @@ ptr() const { */ LVecBase3 BulletBoxShape:: get_half_extents_without_margin() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LVecBase3(_shape->getHalfExtentsWithoutMargin()); } @@ -51,6 +74,7 @@ get_half_extents_without_margin() const { */ LVecBase3 BulletBoxShape:: get_half_extents_with_margin() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LVecBase3(_shape->getHalfExtentsWithMargin()); } diff --git a/panda/src/bullet/bulletBoxShape.h b/panda/src/bullet/bulletBoxShape.h index d7fa1c5169..bfb9207e61 100644 --- a/panda/src/bullet/bulletBoxShape.h +++ b/panda/src/bullet/bulletBoxShape.h @@ -33,8 +33,8 @@ private: PUBLISHED: explicit BulletBoxShape(const LVecBase3 &halfExtents); - INLINE BulletBoxShape(const BulletBoxShape ©); - INLINE void operator = (const BulletBoxShape ©); + BulletBoxShape(const BulletBoxShape ©); + void operator = (const BulletBoxShape ©); INLINE ~BulletBoxShape(); LVecBase3 get_half_extents_without_margin() const; diff --git a/panda/src/bullet/bulletCapsuleShape.I b/panda/src/bullet/bulletCapsuleShape.I index feb6cdff57..2491d55d0d 100644 --- a/panda/src/bullet/bulletCapsuleShape.I +++ b/panda/src/bullet/bulletCapsuleShape.I @@ -30,26 +30,6 @@ INLINE BulletCapsuleShape:: delete _shape; } -/** - * - */ -INLINE BulletCapsuleShape:: -BulletCapsuleShape(const BulletCapsuleShape ©) : - _shape(copy._shape), - _radius(copy._radius), - _height(copy._height) { -} - -/** - * - */ -INLINE void BulletCapsuleShape:: -operator = (const BulletCapsuleShape ©) { - _shape = copy._shape; - _radius = copy._radius; - _height = copy._height; -} - /** * Returns the radius that was used to construct this capsule. */ diff --git a/panda/src/bullet/bulletCapsuleShape.cxx b/panda/src/bullet/bulletCapsuleShape.cxx index 9f389985e3..1c396bbdfb 100644 --- a/panda/src/bullet/bulletCapsuleShape.cxx +++ b/panda/src/bullet/bulletCapsuleShape.cxx @@ -38,9 +38,35 @@ BulletCapsuleShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) : break; } + nassertv(_shape); _shape->setUserPointer(this); } +/** + * + */ +BulletCapsuleShape:: +BulletCapsuleShape(const BulletCapsuleShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _shape = copy._shape; + _radius = copy._radius; + _height = copy._height; +} + +/** + * + */ +void BulletCapsuleShape:: +operator = (const BulletCapsuleShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _shape = copy._shape; + _radius = copy._radius; + _height = copy._height; +} + + /** * */ @@ -122,6 +148,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { break; } + nassertv(_shape); _shape->setUserPointer(this); _shape->setMargin(margin); } diff --git a/panda/src/bullet/bulletCapsuleShape.h b/panda/src/bullet/bulletCapsuleShape.h index 5b031cc548..e376674976 100644 --- a/panda/src/bullet/bulletCapsuleShape.h +++ b/panda/src/bullet/bulletCapsuleShape.h @@ -30,8 +30,8 @@ private: PUBLISHED: explicit BulletCapsuleShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up=Z_up); - INLINE BulletCapsuleShape(const BulletCapsuleShape ©); - INLINE void operator = (const BulletCapsuleShape ©); + BulletCapsuleShape(const BulletCapsuleShape ©); + void operator = (const BulletCapsuleShape ©); INLINE ~BulletCapsuleShape(); INLINE PN_stdfloat get_radius() const; diff --git a/panda/src/bullet/bulletCharacterControllerNode.I b/panda/src/bullet/bulletCharacterControllerNode.I index 391e387e67..8017857312 100644 --- a/panda/src/bullet/bulletCharacterControllerNode.I +++ b/panda/src/bullet/bulletCharacterControllerNode.I @@ -17,6 +17,8 @@ INLINE BulletCharacterControllerNode:: ~BulletCharacterControllerNode() { + delete _character; + delete _ghost; } /** diff --git a/panda/src/bullet/bulletCharacterControllerNode.cxx b/panda/src/bullet/bulletCharacterControllerNode.cxx index c6af3842e9..d65948a824 100644 --- a/panda/src/bullet/bulletCharacterControllerNode.cxx +++ b/panda/src/bullet/bulletCharacterControllerNode.cxx @@ -77,6 +77,7 @@ BulletCharacterControllerNode(BulletShape *shape, PN_stdfloat step_height, const */ void BulletCharacterControllerNode:: set_linear_movement(const LVector3 &movement, bool is_local) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(!movement.is_nan()); @@ -89,18 +90,19 @@ set_linear_movement(const LVector3 &movement, bool is_local) { */ void BulletCharacterControllerNode:: set_angular_movement(PN_stdfloat omega) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _angular_movement = omega; } /** - * + * Assumes the lock(bullet global lock) is held by the caller */ void BulletCharacterControllerNode:: -sync_p2b(PN_stdfloat dt, int num_substeps) { +do_sync_p2b(PN_stdfloat dt, int num_substeps) { // Synchronise global transform - transform_changed(); + do_transform_changed(); // Angular rotation btScalar angle = dt * deg_2_rad(_angular_movement); @@ -131,10 +133,10 @@ sync_p2b(PN_stdfloat dt, int num_substeps) { } /** - * + * Assumes the lock(bullet global lock) is held by the caller */ void BulletCharacterControllerNode:: -sync_b2p() { +do_sync_b2p() { NodePath np = NodePath::any_path((PandaNode *)this); LVecBase3 scale = np.get_net_transform()->get_scale(); @@ -154,10 +156,10 @@ sync_b2p() { } /** - * + * Assumes the lock(bullet global lock) is held by the caller */ void BulletCharacterControllerNode:: -transform_changed() { +do_transform_changed() { if (_sync_disable) return; @@ -187,10 +189,23 @@ transform_changed() { _ghost->getWorldTransform().setBasis(m); // Set scale - _shape->set_local_scale(scale); + _shape->do_set_local_scale(scale); } } +/** + * + */ +void BulletCharacterControllerNode:: +transform_changed() { + + if (_sync_disable) return; + + LightMutexHolder holder(BulletWorld::get_global_lock()); + + do_transform_changed(); +} + /** * */ @@ -205,6 +220,7 @@ get_shape() const { */ bool BulletCharacterControllerNode:: is_on_ground() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _character->onGround(); } @@ -214,6 +230,7 @@ is_on_ground() const { */ bool BulletCharacterControllerNode:: can_jump() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _character->canJump(); } @@ -223,6 +240,7 @@ can_jump() const { */ void BulletCharacterControllerNode:: do_jump() { + LightMutexHolder holder(BulletWorld::get_global_lock()); _character->jump(); } @@ -232,6 +250,7 @@ do_jump() { */ void BulletCharacterControllerNode:: set_fall_speed(PN_stdfloat fall_speed) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _character->setFallSpeed((btScalar)fall_speed); } @@ -241,6 +260,7 @@ set_fall_speed(PN_stdfloat fall_speed) { */ void BulletCharacterControllerNode:: set_jump_speed(PN_stdfloat jump_speed) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _character->setJumpSpeed((btScalar)jump_speed); } @@ -250,6 +270,7 @@ set_jump_speed(PN_stdfloat jump_speed) { */ void BulletCharacterControllerNode:: set_max_jump_height(PN_stdfloat max_jump_height) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _character->setMaxJumpHeight((btScalar)max_jump_height); } @@ -259,6 +280,7 @@ set_max_jump_height(PN_stdfloat max_jump_height) { */ void BulletCharacterControllerNode:: set_max_slope(PN_stdfloat max_slope) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _character->setMaxSlope((btScalar)max_slope); } @@ -268,6 +290,7 @@ set_max_slope(PN_stdfloat max_slope) { */ PN_stdfloat BulletCharacterControllerNode:: get_max_slope() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_character->getMaxSlope(); } @@ -277,6 +300,8 @@ get_max_slope() const { */ PN_stdfloat BulletCharacterControllerNode:: get_gravity() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + #if BT_BULLET_VERSION >= 285 return -(PN_stdfloat)_character->getGravity()[_up]; #else @@ -289,6 +314,8 @@ get_gravity() const { */ void BulletCharacterControllerNode:: set_gravity(PN_stdfloat gravity) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + #if BT_BULLET_VERSION >= 285 _character->setGravity(up_vectors[_up] * -(btScalar)gravity); #else @@ -301,6 +328,7 @@ set_gravity(PN_stdfloat gravity) { */ void BulletCharacterControllerNode:: set_use_ghost_sweep_test(bool value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _character->setUseGhostSweepTest(value); -} \ No newline at end of file +} diff --git a/panda/src/bullet/bulletCharacterControllerNode.h b/panda/src/bullet/bulletCharacterControllerNode.h index 0b8574c709..b2c43d8bb4 100644 --- a/panda/src/bullet/bulletCharacterControllerNode.h +++ b/panda/src/bullet/bulletCharacterControllerNode.h @@ -64,8 +64,8 @@ public: INLINE virtual btPairCachingGhostObject *get_ghost() const; INLINE virtual btCharacterControllerInterface *get_character() const; - virtual void sync_p2b(PN_stdfloat dt, int num_substeps); - virtual void sync_b2p(); + virtual void do_sync_p2b(PN_stdfloat dt, int num_substeps); + virtual void do_sync_b2p(); protected: virtual void transform_changed(); @@ -85,6 +85,8 @@ private: bool _linear_movement_is_local; PN_stdfloat _angular_movement; + void do_transform_changed(); + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/bullet/bulletConeShape.I b/panda/src/bullet/bulletConeShape.I index bf618a862b..b9c05664b7 100644 --- a/panda/src/bullet/bulletConeShape.I +++ b/panda/src/bullet/bulletConeShape.I @@ -30,26 +30,6 @@ INLINE BulletConeShape:: delete _shape; } -/** - * - */ -INLINE BulletConeShape:: -BulletConeShape(const BulletConeShape ©) : - _shape(copy._shape), - _radius(copy._radius), - _height(copy._height) { -} - -/** - * - */ -INLINE void BulletConeShape:: -operator = (const BulletConeShape ©) { - _shape = copy._shape; - _radius = copy._radius; - _height = copy._height; -} - /** * Returns the radius that was passed into the constructor. */ diff --git a/panda/src/bullet/bulletConeShape.cxx b/panda/src/bullet/bulletConeShape.cxx index 80e91a038f..30b24a5a18 100644 --- a/panda/src/bullet/bulletConeShape.cxx +++ b/panda/src/bullet/bulletConeShape.cxx @@ -38,9 +38,34 @@ BulletConeShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) : break; } + nassertv(_shape); _shape->setUserPointer(this); } +/** + * + */ +BulletConeShape:: +BulletConeShape(const BulletConeShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _shape = copy._shape; + _radius = copy._radius; + _height = copy._height; +} + +/** + * + */ +void BulletConeShape:: +operator = (const BulletConeShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _shape = copy._shape; + _radius = copy._radius; + _height = copy._height; +} + /** * */ @@ -122,6 +147,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { break; } + nassertv(_shape); _shape->setUserPointer(this); _shape->setMargin(margin); } diff --git a/panda/src/bullet/bulletConeShape.h b/panda/src/bullet/bulletConeShape.h index 081367449b..4d40c61da9 100644 --- a/panda/src/bullet/bulletConeShape.h +++ b/panda/src/bullet/bulletConeShape.h @@ -30,8 +30,8 @@ private: PUBLISHED: explicit BulletConeShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up=Z_up); - INLINE BulletConeShape(const BulletConeShape ©); - INLINE void operator = (const BulletConeShape ©); + BulletConeShape(const BulletConeShape ©); + void operator = (const BulletConeShape ©); INLINE ~BulletConeShape(); INLINE PN_stdfloat get_radius() const; diff --git a/panda/src/bullet/bulletConeTwistConstraint.I b/panda/src/bullet/bulletConeTwistConstraint.I index a29277462d..9f50b20783 100644 --- a/panda/src/bullet/bulletConeTwistConstraint.I +++ b/panda/src/bullet/bulletConeTwistConstraint.I @@ -19,21 +19,3 @@ INLINE BulletConeTwistConstraint:: delete _constraint; } - -/** - * - */ -INLINE CPT(TransformState) BulletConeTwistConstraint:: -get_frame_a() const { - - return btTrans_to_TransformState(_constraint->getAFrame()); -} - -/** - * - */ -INLINE CPT(TransformState) BulletConeTwistConstraint:: -get_frame_b() const { - - return btTrans_to_TransformState(_constraint->getBFrame()); -} diff --git a/panda/src/bullet/bulletConeTwistConstraint.cxx b/panda/src/bullet/bulletConeTwistConstraint.cxx index 93505b33fc..9b60ab31ce 100644 --- a/panda/src/bullet/bulletConeTwistConstraint.cxx +++ b/panda/src/bullet/bulletConeTwistConstraint.cxx @@ -63,6 +63,7 @@ ptr() const { */ void BulletConeTwistConstraint:: set_limit(int index, PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); value = deg_2_rad(value); @@ -74,6 +75,7 @@ set_limit(int index, PN_stdfloat value) { */ void BulletConeTwistConstraint:: set_limit(PN_stdfloat swing1, PN_stdfloat swing2, PN_stdfloat twist, PN_stdfloat softness, PN_stdfloat bias, PN_stdfloat relaxation) { + LightMutexHolder holder(BulletWorld::get_global_lock()); swing1 = deg_2_rad(swing1); swing2 = deg_2_rad(swing2); @@ -87,6 +89,7 @@ set_limit(PN_stdfloat swing1, PN_stdfloat swing2, PN_stdfloat twist, PN_stdfloat */ void BulletConeTwistConstraint:: set_damping(PN_stdfloat damping) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->setDamping(damping); } @@ -96,6 +99,7 @@ set_damping(PN_stdfloat damping) { */ PN_stdfloat BulletConeTwistConstraint:: get_fix_threshold() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _constraint->getFixThresh(); } @@ -105,6 +109,7 @@ get_fix_threshold() const { */ void BulletConeTwistConstraint:: set_fix_threshold(PN_stdfloat threshold) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->setFixThresh(threshold); } @@ -114,6 +119,7 @@ set_fix_threshold(PN_stdfloat threshold) { */ void BulletConeTwistConstraint:: enable_motor(bool enable) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->enableMotor(enable); } @@ -123,6 +129,7 @@ enable_motor(bool enable) { */ void BulletConeTwistConstraint:: set_max_motor_impulse(PN_stdfloat max_impulse) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->setMaxMotorImpulse(max_impulse); } @@ -132,6 +139,7 @@ set_max_motor_impulse(PN_stdfloat max_impulse) { */ void BulletConeTwistConstraint:: set_max_motor_impulse_normalized(PN_stdfloat max_impulse) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->setMaxMotorImpulseNormalized(max_impulse); } @@ -141,6 +149,7 @@ set_max_motor_impulse_normalized(PN_stdfloat max_impulse) { */ void BulletConeTwistConstraint:: set_motor_target(const LQuaternion &quat) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->setMotorTarget(LQuaternion_to_btQuat(quat)); } @@ -150,6 +159,7 @@ set_motor_target(const LQuaternion &quat) { */ void BulletConeTwistConstraint:: set_motor_target_in_constraint_space(const LQuaternion &quat) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->setMotorTargetInConstraintSpace(LQuaternion_to_btQuat(quat)); } @@ -159,9 +169,30 @@ set_motor_target_in_constraint_space(const LQuaternion &quat) { */ void BulletConeTwistConstraint:: set_frames(const TransformState *ts_a, const TransformState *ts_b) { + LightMutexHolder holder(BulletWorld::get_global_lock()); btTransform frame_a = TransformState_to_btTrans(ts_a); btTransform frame_b = TransformState_to_btTrans(ts_b); _constraint->setFrames(frame_a, frame_b); } + +/** + * + */ +CPT(TransformState) BulletConeTwistConstraint:: +get_frame_a() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btTrans_to_TransformState(_constraint->getAFrame()); +} + +/** + * + */ +CPT(TransformState) BulletConeTwistConstraint:: +get_frame_b() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btTrans_to_TransformState(_constraint->getBFrame()); +} diff --git a/panda/src/bullet/bulletConeTwistConstraint.h b/panda/src/bullet/bulletConeTwistConstraint.h index bc4f548dfb..d7fabee508 100644 --- a/panda/src/bullet/bulletConeTwistConstraint.h +++ b/panda/src/bullet/bulletConeTwistConstraint.h @@ -53,8 +53,8 @@ PUBLISHED: void set_motor_target_in_constraint_space(const LQuaternion &quat); void set_frames(const TransformState *ts_a, const TransformState *ts_b); - INLINE CPT(TransformState) get_frame_a() const; - INLINE CPT(TransformState) get_frame_b() const; + CPT(TransformState) get_frame_a() const; + CPT(TransformState) get_frame_b() const; MAKE_PROPERTY(fix_threshold, get_fix_threshold, set_fix_threshold); MAKE_PROPERTY(frame_a, get_frame_a); diff --git a/panda/src/bullet/bulletConvexHullShape.I b/panda/src/bullet/bulletConvexHullShape.I index 71fa3cd190..2016b38e4d 100644 --- a/panda/src/bullet/bulletConvexHullShape.I +++ b/panda/src/bullet/bulletConvexHullShape.I @@ -19,19 +19,3 @@ INLINE BulletConvexHullShape:: delete _shape; } - -/** - * - */ -INLINE BulletConvexHullShape:: -BulletConvexHullShape(const BulletConvexHullShape ©) : - _shape(copy._shape) { -} - -/** - * - */ -INLINE void BulletConvexHullShape:: -operator = (const BulletConvexHullShape ©) { - _shape = copy._shape; -} diff --git a/panda/src/bullet/bulletConvexHullShape.cxx b/panda/src/bullet/bulletConvexHullShape.cxx index 9b3df8dfe2..c796072b4a 100644 --- a/panda/src/bullet/bulletConvexHullShape.cxx +++ b/panda/src/bullet/bulletConvexHullShape.cxx @@ -29,6 +29,26 @@ BulletConvexHullShape() { _shape->setUserPointer(this); } +/** + * + */ +BulletConvexHullShape:: +BulletConvexHullShape(const BulletConvexHullShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _shape = copy._shape; +} + +/** + * + */ +void BulletConvexHullShape:: +operator = (const BulletConvexHullShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _shape = copy._shape; +} + /** * */ @@ -43,6 +63,7 @@ ptr() const { */ void BulletConvexHullShape:: add_point(const LPoint3 &p) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _shape->addPoint(LVecBase3_to_btVector3(p)); } @@ -52,6 +73,10 @@ add_point(const LPoint3 &p) { */ void BulletConvexHullShape:: add_array(const PTA_LVecBase3 &points) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + if (_shape) + delete _shape; _shape = new btConvexHullShape(NULL, 0); _shape->setUserPointer(this); @@ -75,6 +100,7 @@ add_array(const PTA_LVecBase3 &points) { */ void BulletConvexHullShape:: add_geom(const Geom *geom, const TransformState *ts) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(geom); nassertv(ts); diff --git a/panda/src/bullet/bulletConvexHullShape.h b/panda/src/bullet/bulletConvexHullShape.h index f74489bd0e..653c044952 100644 --- a/panda/src/bullet/bulletConvexHullShape.h +++ b/panda/src/bullet/bulletConvexHullShape.h @@ -29,8 +29,8 @@ class EXPCL_PANDABULLET BulletConvexHullShape : public BulletShape { PUBLISHED: BulletConvexHullShape(); - INLINE BulletConvexHullShape(const BulletConvexHullShape ©); - INLINE void operator = (const BulletConvexHullShape ©); + BulletConvexHullShape(const BulletConvexHullShape ©); + void operator = (const BulletConvexHullShape ©); INLINE ~BulletConvexHullShape(); void add_point(const LPoint3 &p); diff --git a/panda/src/bullet/bulletConvexPointCloudShape.I b/panda/src/bullet/bulletConvexPointCloudShape.I index 909dfd2d7e..47e0b62704 100644 --- a/panda/src/bullet/bulletConvexPointCloudShape.I +++ b/panda/src/bullet/bulletConvexPointCloudShape.I @@ -28,30 +28,3 @@ INLINE BulletConvexPointCloudShape:: delete _shape; } - -/** - * - */ -INLINE BulletConvexPointCloudShape:: -BulletConvexPointCloudShape(const BulletConvexPointCloudShape ©) : - _scale(copy._scale), - _shape(copy._shape) { -} - -/** - * - */ -INLINE void BulletConvexPointCloudShape:: -operator = (const BulletConvexPointCloudShape ©) { - _scale = copy._scale; - _shape = copy._shape; -} - -/** - * - */ -INLINE int BulletConvexPointCloudShape:: -get_num_points() const { - - return _shape->getNumPoints(); -} diff --git a/panda/src/bullet/bulletConvexPointCloudShape.cxx b/panda/src/bullet/bulletConvexPointCloudShape.cxx index 1527a712b3..fb7f62287b 100644 --- a/panda/src/bullet/bulletConvexPointCloudShape.cxx +++ b/panda/src/bullet/bulletConvexPointCloudShape.cxx @@ -84,6 +84,38 @@ BulletConvexPointCloudShape(const Geom *geom, LVecBase3 scale) { _shape->setUserPointer(this); } +/** + * + */ +BulletConvexPointCloudShape:: +BulletConvexPointCloudShape(const BulletConvexPointCloudShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _scale = copy._scale; + _shape = copy._shape; +} + +/** + * + */ +void BulletConvexPointCloudShape:: +operator = (const BulletConvexPointCloudShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _scale = copy._scale; + _shape = copy._shape; +} + +/** + * + */ +int BulletConvexPointCloudShape:: +get_num_points() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return _shape->getNumPoints(); +} + /** * Tells the BamReader how to create objects of type BulletShape. */ diff --git a/panda/src/bullet/bulletConvexPointCloudShape.h b/panda/src/bullet/bulletConvexPointCloudShape.h index 293ece996b..da403d8794 100644 --- a/panda/src/bullet/bulletConvexPointCloudShape.h +++ b/panda/src/bullet/bulletConvexPointCloudShape.h @@ -33,11 +33,11 @@ private: PUBLISHED: explicit BulletConvexPointCloudShape(const PTA_LVecBase3 &points, LVecBase3 scale=LVecBase3(1.)); explicit BulletConvexPointCloudShape(const Geom *geom, LVecBase3 scale=LVecBase3(1.)); - INLINE BulletConvexPointCloudShape(const BulletConvexPointCloudShape ©); - INLINE void operator = (const BulletConvexPointCloudShape ©); + BulletConvexPointCloudShape(const BulletConvexPointCloudShape ©); + void operator = (const BulletConvexPointCloudShape ©); INLINE ~BulletConvexPointCloudShape(); - INLINE int get_num_points() const; + int get_num_points() const; MAKE_PROPERTY(num_points, get_num_points); diff --git a/panda/src/bullet/bulletCylinderShape.I b/panda/src/bullet/bulletCylinderShape.I index c389813444..54616905f9 100644 --- a/panda/src/bullet/bulletCylinderShape.I +++ b/panda/src/bullet/bulletCylinderShape.I @@ -28,47 +28,3 @@ INLINE BulletCylinderShape:: delete _shape; } - -/** - * - */ -INLINE BulletCylinderShape:: -BulletCylinderShape(const BulletCylinderShape ©) : - _shape(copy._shape), _half_extents(copy._half_extents) { -} - -/** - * - */ -INLINE void BulletCylinderShape:: -operator = (const BulletCylinderShape ©) { - _shape = copy._shape; - _half_extents = copy._half_extents; -} - -/** - * - */ -INLINE PN_stdfloat BulletCylinderShape:: -get_radius() const { - - return (PN_stdfloat)_shape->getRadius(); -} - -/** - * - */ -INLINE LVecBase3 BulletCylinderShape:: -get_half_extents_without_margin() const { - - return btVector3_to_LVecBase3(_shape->getHalfExtentsWithoutMargin()); -} - -/** - * - */ -INLINE LVecBase3 BulletCylinderShape:: -get_half_extents_with_margin() const { - - return btVector3_to_LVecBase3(_shape->getHalfExtentsWithMargin()); -} diff --git a/panda/src/bullet/bulletCylinderShape.cxx b/panda/src/bullet/bulletCylinderShape.cxx index fec07ce484..8f95bc5591 100644 --- a/panda/src/bullet/bulletCylinderShape.cxx +++ b/panda/src/bullet/bulletCylinderShape.cxx @@ -39,6 +39,7 @@ BulletCylinderShape(const LVector3 &half_extents, BulletUpAxis up) : break; } + nassertv(_shape); _shape->setUserPointer(this); } @@ -66,9 +67,32 @@ BulletCylinderShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) { break; } + nassertv(_shape); _shape->setUserPointer(this); } +/** + * + */ +BulletCylinderShape:: +BulletCylinderShape(const BulletCylinderShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _shape = copy._shape; + _half_extents = copy._half_extents; +} + +/** + * + */ +void BulletCylinderShape:: +operator = (const BulletCylinderShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _shape = copy._shape; + _half_extents = copy._half_extents; +} + /** * */ @@ -78,6 +102,36 @@ ptr() const { return _shape; } +/** + * + */ +PN_stdfloat BulletCylinderShape:: +get_radius() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_shape->getRadius(); +} + +/** + * + */ +LVecBase3 BulletCylinderShape:: +get_half_extents_without_margin() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btVector3_to_LVecBase3(_shape->getHalfExtentsWithoutMargin()); +} + +/** + * + */ +LVecBase3 BulletCylinderShape:: +get_half_extents_with_margin() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btVector3_to_LVecBase3(_shape->getHalfExtentsWithMargin()); +} + /** * Tells the BamReader how to create objects of type BulletShape. */ @@ -150,6 +204,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { break; } + nassertv(_shape); _shape->setUserPointer(this); _shape->setMargin(margin); } diff --git a/panda/src/bullet/bulletCylinderShape.h b/panda/src/bullet/bulletCylinderShape.h index 2cdd854ac4..f53962ec6f 100644 --- a/panda/src/bullet/bulletCylinderShape.h +++ b/panda/src/bullet/bulletCylinderShape.h @@ -31,13 +31,13 @@ private: PUBLISHED: explicit BulletCylinderShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up=Z_up); explicit BulletCylinderShape(const LVector3 &half_extents, BulletUpAxis up=Z_up); - INLINE BulletCylinderShape(const BulletCylinderShape ©); - INLINE void operator = (const BulletCylinderShape ©); + BulletCylinderShape(const BulletCylinderShape ©); + void operator = (const BulletCylinderShape ©); INLINE ~BulletCylinderShape(); - INLINE PN_stdfloat get_radius() const; - INLINE LVecBase3 get_half_extents_without_margin() const; - INLINE LVecBase3 get_half_extents_with_margin() const; + PN_stdfloat get_radius() const; + LVecBase3 get_half_extents_without_margin() const; + LVecBase3 get_half_extents_with_margin() const; MAKE_PROPERTY(radius, get_radius); MAKE_PROPERTY(half_extents_without_margin, get_half_extents_without_margin); diff --git a/panda/src/bullet/bulletDebugNode.cxx b/panda/src/bullet/bulletDebugNode.cxx index 9b8c9c0bfb..743b5163ff 100644 --- a/panda/src/bullet/bulletDebugNode.cxx +++ b/panda/src/bullet/bulletDebugNode.cxx @@ -169,7 +169,7 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { PT(Geom) debug_triangles; { - LightMutexHolder holder(_lock); + LightMutexHolder holder(BulletWorld::get_global_lock()); if (_debug_world == nullptr) { return; } @@ -270,8 +270,7 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { * */ void BulletDebugNode:: -sync_b2p(btDynamicsWorld *world) { - LightMutexHolder holder(_lock); +do_sync_b2p(btDynamicsWorld *world) { _debug_world = world; _debug_stale = true; diff --git a/panda/src/bullet/bulletDebugNode.h b/panda/src/bullet/bulletDebugNode.h index dabe9d13fa..c780429a79 100644 --- a/panda/src/bullet/bulletDebugNode.h +++ b/panda/src/bullet/bulletDebugNode.h @@ -17,7 +17,6 @@ #include "pandabase.h" #include "bullet_includes.h" -#include "lightMutex.h" /** * @@ -55,7 +54,7 @@ public: virtual void add_for_draw(CullTraverser *trav, CullTraverserData &data); private: - void sync_b2p(btDynamicsWorld *world); + void do_sync_b2p(btDynamicsWorld *world); struct Line { LVecBase3 _p0; @@ -101,7 +100,6 @@ private: int _mode; }; - LightMutex _lock; DebugDraw _drawer; bool _debug_stale; diff --git a/panda/src/bullet/bulletGenericConstraint.I b/panda/src/bullet/bulletGenericConstraint.I index 08ee24ccba..da9a6fbc49 100644 --- a/panda/src/bullet/bulletGenericConstraint.I +++ b/panda/src/bullet/bulletGenericConstraint.I @@ -19,21 +19,3 @@ INLINE BulletGenericConstraint:: delete _constraint; } - -/** - * - */ -INLINE CPT(TransformState) BulletGenericConstraint:: -get_frame_a() const { - - return btTrans_to_TransformState(_constraint->getFrameOffsetA()); -} - -/** - * - */ -INLINE CPT(TransformState) BulletGenericConstraint:: -get_frame_b() const { - - return btTrans_to_TransformState(_constraint->getFrameOffsetB()); -} diff --git a/panda/src/bullet/bulletGenericConstraint.cxx b/panda/src/bullet/bulletGenericConstraint.cxx index a68a345ce6..de98b5d40b 100644 --- a/panda/src/bullet/bulletGenericConstraint.cxx +++ b/panda/src/bullet/bulletGenericConstraint.cxx @@ -63,6 +63,7 @@ ptr() const { */ LVector3 BulletGenericConstraint:: get_axis(int axis) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertr(axis >= 0, LVector3::zero()); nassertr(axis <= 3, LVector3::zero()); @@ -76,6 +77,7 @@ get_axis(int axis) const { */ PN_stdfloat BulletGenericConstraint:: get_pivot(int axis) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertr(axis >= 0, 0.0f); nassertr(axis <= 3, 0.0f); @@ -89,6 +91,7 @@ get_pivot(int axis) const { */ PN_stdfloat BulletGenericConstraint:: get_angle(int axis) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertr(axis >= 0, 0.0f); nassertr(axis <= 3, 0.0f); @@ -102,6 +105,7 @@ get_angle(int axis) const { */ void BulletGenericConstraint:: set_linear_limit(int axis, PN_stdfloat low, PN_stdfloat high) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(axis >= 0); nassertv(axis <= 3); @@ -115,6 +119,7 @@ set_linear_limit(int axis, PN_stdfloat low, PN_stdfloat high) { */ void BulletGenericConstraint:: set_angular_limit(int axis, PN_stdfloat low, PN_stdfloat high) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(axis >= 0); nassertv(axis <= 3); @@ -126,11 +131,32 @@ set_angular_limit(int axis, PN_stdfloat low, PN_stdfloat high) { _constraint->setLimit(axis + 3, low, high); } +/** + * + */ +CPT(TransformState) BulletGenericConstraint:: +get_frame_a() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btTrans_to_TransformState(_constraint->getFrameOffsetA()); +} + +/** + * + */ +CPT(TransformState) BulletGenericConstraint:: +get_frame_b() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btTrans_to_TransformState(_constraint->getFrameOffsetB()); +} + /** * */ BulletRotationalLimitMotor BulletGenericConstraint:: get_rotational_limit_motor(int axis) { + LightMutexHolder holder(BulletWorld::get_global_lock()); return BulletRotationalLimitMotor(*_constraint->getRotationalLimitMotor(axis)); } @@ -140,6 +166,7 @@ get_rotational_limit_motor(int axis) { */ BulletTranslationalLimitMotor BulletGenericConstraint:: get_translational_limit_motor() { + LightMutexHolder holder(BulletWorld::get_global_lock()); return BulletTranslationalLimitMotor(*_constraint->getTranslationalLimitMotor()); } @@ -149,6 +176,7 @@ get_translational_limit_motor() { */ void BulletGenericConstraint:: set_frames(const TransformState *ts_a, const TransformState *ts_b) { + LightMutexHolder holder(BulletWorld::get_global_lock()); btTransform frame_a = TransformState_to_btTrans(ts_a); btTransform frame_b = TransformState_to_btTrans(ts_b); diff --git a/panda/src/bullet/bulletGenericConstraint.h b/panda/src/bullet/bulletGenericConstraint.h index a2446ffcd4..f571df1ad6 100644 --- a/panda/src/bullet/bulletGenericConstraint.h +++ b/panda/src/bullet/bulletGenericConstraint.h @@ -57,8 +57,8 @@ PUBLISHED: // Frames void set_frames(const TransformState *ts_a, const TransformState *ts_b); - INLINE CPT(TransformState) get_frame_a() const; - INLINE CPT(TransformState) get_frame_b() const; + CPT(TransformState) get_frame_a() const; + CPT(TransformState) get_frame_b() const; MAKE_PROPERTY(translational_limit_motor, get_translational_limit_motor); MAKE_PROPERTY(frame_a, get_frame_a); diff --git a/panda/src/bullet/bulletGhostNode.I b/panda/src/bullet/bulletGhostNode.I index c4620097a8..d9b24a0950 100644 --- a/panda/src/bullet/bulletGhostNode.I +++ b/panda/src/bullet/bulletGhostNode.I @@ -20,23 +20,3 @@ INLINE BulletGhostNode:: delete _ghost; } -/** - * - */ -INLINE int BulletGhostNode:: -get_num_overlapping_nodes() const { - - return _ghost->getNumOverlappingObjects(); -} - -/** - * - */ -INLINE PandaNode *BulletGhostNode:: -get_overlapping_node(int idx) const { - - nassertr(idx >=0 && idx < _ghost->getNumOverlappingObjects(), NULL); - - btCollisionObject *object = _ghost->getOverlappingObject(idx); - return (object) ? (PandaNode *)object->getUserPointer() : NULL; -} diff --git a/panda/src/bullet/bulletGhostNode.cxx b/panda/src/bullet/bulletGhostNode.cxx index ddead41067..39740ff5a1 100644 --- a/panda/src/bullet/bulletGhostNode.cxx +++ b/panda/src/bullet/bulletGhostNode.cxx @@ -53,6 +53,7 @@ get_object() const { */ void BulletGhostNode:: parents_changed() { + LightMutexHolder holder(BulletWorld::get_global_lock()); Parents parents = get_parents(); for (size_t i = 0; i < parents.get_num_parents(); ++i) { @@ -73,10 +74,10 @@ parents_changed() { } /** - * + * Assumes the lock(bullet global lock) is held by the caller */ void BulletGhostNode:: -transform_changed() { +do_transform_changed() { if (_sync_disable) return; @@ -98,27 +99,60 @@ transform_changed() { if (!scale.almost_equal(LVecBase3(1.0f, 1.0f, 1.0f))) { for (int i=0; iset_local_scale(scale); + shape->do_set_local_scale(scale); } } } } } -/** - * - */ void BulletGhostNode:: -sync_p2b() { +transform_changed() { - transform_changed(); + if (_sync_disable) return; + + LightMutexHolder holder(BulletWorld::get_global_lock()); + + do_transform_changed(); } /** * */ +int BulletGhostNode:: +get_num_overlapping_nodes() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return _ghost->getNumOverlappingObjects(); +} + +/** + * + */ +PandaNode *BulletGhostNode:: +get_overlapping_node(int idx) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + nassertr(idx >=0 && idx < _ghost->getNumOverlappingObjects(), NULL); + + btCollisionObject *object = _ghost->getOverlappingObject(idx); + return (object) ? (PandaNode *)object->getUserPointer() : NULL; +} + +/** + * Assumes the lock(bullet global lock) is held by the caller + */ void BulletGhostNode:: -sync_b2p() { +do_sync_p2b() { + + do_transform_changed(); +} + +/** + * Assumes the lock(bullet global lock) is held by the caller + */ +void BulletGhostNode:: +do_sync_b2p() { NodePath np = NodePath::any_path((PandaNode *)this); LVecBase3 scale = np.get_net_transform()->get_scale(); diff --git a/panda/src/bullet/bulletGhostNode.h b/panda/src/bullet/bulletGhostNode.h index 87a1624f3d..a76c0ce8a1 100644 --- a/panda/src/bullet/bulletGhostNode.h +++ b/panda/src/bullet/bulletGhostNode.h @@ -34,8 +34,8 @@ PUBLISHED: INLINE ~BulletGhostNode(); // Overlapping - INLINE int get_num_overlapping_nodes() const; - INLINE PandaNode *get_overlapping_node(int idx) const; + int get_num_overlapping_nodes() const; + PandaNode *get_overlapping_node(int idx) const; MAKE_SEQ(get_overlapping_nodes, get_num_overlapping_nodes, get_overlapping_node); MAKE_SEQ_PROPERTY(overlapping_nodes, get_num_overlapping_nodes, get_overlapping_node); @@ -43,8 +43,8 @@ PUBLISHED: public: virtual btCollisionObject *get_object() const; - void sync_p2b(); - void sync_b2p(); + void do_sync_p2b(); + void do_sync_b2p(); protected: virtual void parents_changed(); @@ -57,6 +57,8 @@ private: btPairCachingGhostObject *_ghost; + void do_transform_changed(); + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/bullet/bulletHeightfieldShape.I b/panda/src/bullet/bulletHeightfieldShape.I index 5bfceb1e5b..5a2702be9a 100644 --- a/panda/src/bullet/bulletHeightfieldShape.I +++ b/panda/src/bullet/bulletHeightfieldShape.I @@ -32,33 +32,3 @@ INLINE BulletHeightfieldShape:: delete _shape; delete [] _data; } - -/** - * - */ -INLINE BulletHeightfieldShape:: -BulletHeightfieldShape(const BulletHeightfieldShape ©) : - _shape(copy._shape), - _num_rows(copy._num_rows), - _num_cols(copy._num_cols), - _max_height(copy._max_height), - _up(copy._up) { - - size_t size = (size_t)_num_rows * (size_t)_num_cols; - _data = new btScalar[size]; - memcpy(_data, copy._data, size * sizeof(btScalar)); -} - -/** - * - */ -INLINE void BulletHeightfieldShape:: -operator = (const BulletHeightfieldShape ©) { - _shape = copy._shape; - _num_rows = copy._num_rows; - _num_cols = copy._num_cols; - - size_t size = (size_t)_num_rows * (size_t)_num_cols; - _data = new btScalar[size]; - memcpy(_data, copy._data, size * sizeof(btScalar)); -} diff --git a/panda/src/bullet/bulletHeightfieldShape.cxx b/panda/src/bullet/bulletHeightfieldShape.cxx index 6ff476c0a6..1a01876401 100644 --- a/panda/src/bullet/bulletHeightfieldShape.cxx +++ b/panda/src/bullet/bulletHeightfieldShape.cxx @@ -61,6 +61,7 @@ ptr() const { */ void BulletHeightfieldShape:: set_use_diamond_subdivision(bool flag) { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _shape->setUseDiamondSubdivision(flag); } @@ -104,6 +105,42 @@ BulletHeightfieldShape(Texture *tex, PN_stdfloat max_height, BulletUpAxis up) : _shape->setUserPointer(this); } +/** + * + */ +BulletHeightfieldShape:: +BulletHeightfieldShape(const BulletHeightfieldShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _shape = copy._shape; + _num_rows = copy._num_rows; + _num_cols = copy._num_cols; + _max_height = copy._max_height; + _up = copy._up; + + size_t size = (size_t)_num_rows * (size_t)_num_cols; + _data = new btScalar[size]; + memcpy(_data, copy._data, size * sizeof(btScalar)); +} + +/** + * + */ +void BulletHeightfieldShape:: +operator = (const BulletHeightfieldShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _shape = copy._shape; + _num_rows = copy._num_rows; + _num_cols = copy._num_cols; + _max_height = copy._max_height; + _up = copy._up; + + size_t size = (size_t)_num_rows * (size_t)_num_cols; + _data = new btScalar[size]; + memcpy(_data, copy._data, size * sizeof(btScalar)); +} + /** * Tells the BamReader how to create objects of type BulletShape. */ @@ -169,8 +206,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { _num_cols = scan.get_int32(); size_t size = (size_t)_num_rows * (size_t)_num_cols; - delete[] _data; + delete [] _data; _data = new float[size]; + for (size_t i = 0; i < size; ++i) { _data[i] = scan.get_stdfloat(); } diff --git a/panda/src/bullet/bulletHeightfieldShape.h b/panda/src/bullet/bulletHeightfieldShape.h index 2f70fddac8..1bfc6c41c3 100644 --- a/panda/src/bullet/bulletHeightfieldShape.h +++ b/panda/src/bullet/bulletHeightfieldShape.h @@ -34,8 +34,8 @@ private: PUBLISHED: explicit BulletHeightfieldShape(const PNMImage &image, PN_stdfloat max_height, BulletUpAxis up=Z_up); explicit BulletHeightfieldShape(Texture *tex, PN_stdfloat max_height, BulletUpAxis up=Z_up); - INLINE BulletHeightfieldShape(const BulletHeightfieldShape ©); - INLINE void operator = (const BulletHeightfieldShape ©); + BulletHeightfieldShape(const BulletHeightfieldShape ©); + void operator = (const BulletHeightfieldShape ©); INLINE ~BulletHeightfieldShape(); void set_use_diamond_subdivision(bool flag=true); diff --git a/panda/src/bullet/bulletHingeConstraint.I b/panda/src/bullet/bulletHingeConstraint.I index 01614f603a..e5753a5947 100644 --- a/panda/src/bullet/bulletHingeConstraint.I +++ b/panda/src/bullet/bulletHingeConstraint.I @@ -19,21 +19,3 @@ INLINE BulletHingeConstraint:: delete _constraint; } - -/** - * - */ -INLINE CPT(TransformState) BulletHingeConstraint:: -get_frame_a() const { - - return btTrans_to_TransformState(_constraint->getAFrame()); -} - -/** - * - */ -INLINE CPT(TransformState) BulletHingeConstraint:: -get_frame_b() const { - - return btTrans_to_TransformState(_constraint->getBFrame()); -} diff --git a/panda/src/bullet/bulletHingeConstraint.cxx b/panda/src/bullet/bulletHingeConstraint.cxx index a262be88e8..5cbfa44d94 100644 --- a/panda/src/bullet/bulletHingeConstraint.cxx +++ b/panda/src/bullet/bulletHingeConstraint.cxx @@ -111,6 +111,7 @@ ptr() const { */ void BulletHingeConstraint:: set_angular_only(bool value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _constraint->setAngularOnly(value); } @@ -120,6 +121,7 @@ set_angular_only(bool value) { */ bool BulletHingeConstraint:: get_angular_only() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _constraint->getAngularOnly(); } @@ -129,6 +131,7 @@ get_angular_only() const { */ void BulletHingeConstraint:: set_limit(PN_stdfloat low, PN_stdfloat high, PN_stdfloat softness, PN_stdfloat bias, PN_stdfloat relaxation) { + LightMutexHolder holder(BulletWorld::get_global_lock()); low = deg_2_rad(low); high = deg_2_rad(high); @@ -141,6 +144,7 @@ set_limit(PN_stdfloat low, PN_stdfloat high, PN_stdfloat softness, PN_stdfloat b */ void BulletHingeConstraint:: set_axis(const LVector3 &axis) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(!axis.is_nan()); @@ -153,6 +157,7 @@ set_axis(const LVector3 &axis) { */ PN_stdfloat BulletHingeConstraint:: get_lower_limit() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return rad_2_deg(_constraint->getLowerLimit()); } @@ -162,6 +167,7 @@ get_lower_limit() const { */ PN_stdfloat BulletHingeConstraint:: get_upper_limit() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return rad_2_deg(_constraint->getUpperLimit()); } @@ -171,6 +177,7 @@ get_upper_limit() const { */ PN_stdfloat BulletHingeConstraint:: get_hinge_angle() { + LightMutexHolder holder(BulletWorld::get_global_lock()); return rad_2_deg(_constraint->getHingeAngle()); } @@ -184,6 +191,7 @@ get_hinge_angle() { */ void BulletHingeConstraint:: enable_angular_motor(bool enable, PN_stdfloat target_velocity, PN_stdfloat max_impulse) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->enableAngularMotor(enable, target_velocity, max_impulse); } @@ -193,6 +201,7 @@ enable_angular_motor(bool enable, PN_stdfloat target_velocity, PN_stdfloat max_i */ void BulletHingeConstraint:: enable_motor(bool enable) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->enableMotor(enable); } @@ -203,6 +212,7 @@ enable_motor(bool enable) { */ void BulletHingeConstraint:: set_max_motor_impulse(PN_stdfloat max_impulse) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->setMaxMotorImpulse(max_impulse); } @@ -212,6 +222,7 @@ set_max_motor_impulse(PN_stdfloat max_impulse) { */ void BulletHingeConstraint:: set_motor_target(const LQuaternion &quat, PN_stdfloat dt) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->setMotorTarget(LQuaternion_to_btQuat(quat), dt); } @@ -221,6 +232,7 @@ set_motor_target(const LQuaternion &quat, PN_stdfloat dt) { */ void BulletHingeConstraint:: set_motor_target(PN_stdfloat target_angle, PN_stdfloat dt) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->setMotorTarget(target_angle, dt); } @@ -230,9 +242,30 @@ set_motor_target(PN_stdfloat target_angle, PN_stdfloat dt) { */ void BulletHingeConstraint:: set_frames(const TransformState *ts_a, const TransformState *ts_b) { + LightMutexHolder holder(BulletWorld::get_global_lock()); btTransform frame_a = TransformState_to_btTrans(ts_a); btTransform frame_b = TransformState_to_btTrans(ts_b); _constraint->setFrames(frame_a, frame_b); } + +/** + * + */ +CPT(TransformState) BulletHingeConstraint:: +get_frame_a() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btTrans_to_TransformState(_constraint->getAFrame()); +} + +/** + * + */ +CPT(TransformState) BulletHingeConstraint:: +get_frame_b() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btTrans_to_TransformState(_constraint->getBFrame()); +} diff --git a/panda/src/bullet/bulletHingeConstraint.h b/panda/src/bullet/bulletHingeConstraint.h index 12a1b1b2c2..dc6768490b 100644 --- a/panda/src/bullet/bulletHingeConstraint.h +++ b/panda/src/bullet/bulletHingeConstraint.h @@ -69,8 +69,8 @@ PUBLISHED: void set_motor_target(PN_stdfloat target_angle, PN_stdfloat dt); void set_frames(const TransformState *ts_a, const TransformState *ts_b); - INLINE CPT(TransformState) get_frame_a() const; - INLINE CPT(TransformState) get_frame_b() const; + CPT(TransformState) get_frame_a() const; + CPT(TransformState) get_frame_b() const; MAKE_PROPERTY(hinge_angle, get_hinge_angle); MAKE_PROPERTY(lower_limit, get_lower_limit); diff --git a/panda/src/bullet/bulletManifoldPoint.I b/panda/src/bullet/bulletManifoldPoint.I index 6730d2f349..4347bad4f4 100644 --- a/panda/src/bullet/bulletManifoldPoint.I +++ b/panda/src/bullet/bulletManifoldPoint.I @@ -18,228 +18,3 @@ INLINE BulletManifoldPoint:: ~BulletManifoldPoint() { } - -/** - * - */ -INLINE void BulletManifoldPoint:: -set_lateral_friction_initialized(bool value) { -#if BT_BULLET_VERSION >= 285 - if (value) { - _pt.m_contactPointFlags |= BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED; - } else { - _pt.m_contactPointFlags &= ~BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED; - } -#else - _pt.m_lateralFrictionInitialized = value; -#endif -} - -/** - * - */ -INLINE bool BulletManifoldPoint:: -get_lateral_friction_initialized() const { -#if BT_BULLET_VERSION >= 285 - return (_pt.m_contactPointFlags & BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED) != 0; -#else - return _pt.m_lateralFrictionInitialized; -#endif -} - -/** - * - */ -INLINE void BulletManifoldPoint:: -set_lateral_friction_dir1(const LVecBase3 &dir) { - - _pt.m_lateralFrictionDir1 = LVecBase3_to_btVector3(dir); -} - -/** - * - */ -INLINE LVector3 BulletManifoldPoint:: -get_lateral_friction_dir1() const { - - return btVector3_to_LVector3(_pt.m_lateralFrictionDir1); -} - -/** - * - */ -INLINE void BulletManifoldPoint:: -set_lateral_friction_dir2(const LVecBase3 &dir) { - - _pt.m_lateralFrictionDir2 = LVecBase3_to_btVector3(dir); -} - -/** - * - */ -INLINE LVector3 BulletManifoldPoint:: -get_lateral_friction_dir2() const { - - return btVector3_to_LVector3(_pt.m_lateralFrictionDir2); -} - -/** - * - */ -INLINE void BulletManifoldPoint:: -set_contact_motion1(PN_stdfloat value) { - - _pt.m_contactMotion1 = (btScalar)value; -} - -/** - * - */ -INLINE PN_stdfloat BulletManifoldPoint:: -get_contact_motion1() const { - - return (PN_stdfloat)_pt.m_contactMotion1; -} - -/** - * - */ -INLINE void BulletManifoldPoint:: -set_contact_motion2(PN_stdfloat value) { - - _pt.m_contactMotion2 = (btScalar)value; -} - -/** - * - */ -INLINE PN_stdfloat BulletManifoldPoint:: -get_contact_motion2() const { - - return (PN_stdfloat)_pt.m_contactMotion2; -} - -/** - * - */ -INLINE void BulletManifoldPoint:: -set_combined_friction(PN_stdfloat value) { - - _pt.m_combinedFriction = (btScalar)value; -} - -/** - * - */ -INLINE PN_stdfloat BulletManifoldPoint:: -get_combined_friction() const { - - return (PN_stdfloat)_pt.m_combinedFriction; -} - -/** - * - */ -INLINE void BulletManifoldPoint:: -set_combined_restitution(PN_stdfloat value) { - - _pt.m_combinedRestitution = (btScalar)value; -} - -/** - * - */ -INLINE PN_stdfloat BulletManifoldPoint:: -get_combined_restitution() const { - - return (PN_stdfloat)_pt.m_combinedRestitution; -} - -/** - * - */ -INLINE void BulletManifoldPoint:: -set_applied_impulse(PN_stdfloat value) { - - _pt.m_appliedImpulse = (btScalar)value; -} - -/** - * - */ -INLINE void BulletManifoldPoint:: -set_applied_impulse_lateral1(PN_stdfloat value) { - - _pt.m_appliedImpulseLateral1 = (btScalar)value; -} - -/** - * - */ -INLINE PN_stdfloat BulletManifoldPoint:: -get_applied_impulse_lateral1() const { - - return (PN_stdfloat)_pt.m_appliedImpulseLateral1; -} - -/** - * - */ -INLINE void BulletManifoldPoint:: -set_applied_impulse_lateral2(PN_stdfloat value) { - - _pt.m_appliedImpulseLateral2 = (btScalar)value; -} - -/** - * - */ -INLINE PN_stdfloat BulletManifoldPoint:: -get_applied_impulse_lateral2() const { - - return (PN_stdfloat)_pt.m_appliedImpulseLateral2; -} - -/** - * - */ -INLINE void BulletManifoldPoint:: -set_contact_cfm1(PN_stdfloat value) { -#if BT_BULLET_VERSION < 285 - _pt.m_contactCFM1 = (btScalar)value; -#endif -} - -/** - * - */ -INLINE PN_stdfloat BulletManifoldPoint:: -get_contact_cfm1() const { -#if BT_BULLET_VERSION < 285 - return (PN_stdfloat)_pt.m_contactCFM1; -#else - return 0; -#endif -} - -/** - * - */ -INLINE void BulletManifoldPoint:: -set_contact_cfm2(PN_stdfloat value) { -#if BT_BULLET_VERSION < 285 - _pt.m_contactCFM2 = (btScalar)value; -#endif -} - -/** - * - */ -INLINE PN_stdfloat BulletManifoldPoint:: -get_contact_cfm2() const { -#if BT_BULLET_VERSION < 285 - return (PN_stdfloat)_pt.m_contactCFM2; -#else - return 0; -#endif -} diff --git a/panda/src/bullet/bulletManifoldPoint.cxx b/panda/src/bullet/bulletManifoldPoint.cxx index 00651186f0..b56244ed29 100644 --- a/panda/src/bullet/bulletManifoldPoint.cxx +++ b/panda/src/bullet/bulletManifoldPoint.cxx @@ -46,6 +46,7 @@ operator=(const BulletManifoldPoint& other) { */ int BulletManifoldPoint:: get_life_time() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _pt.getLifeTime(); } @@ -55,6 +56,7 @@ get_life_time() const { */ PN_stdfloat BulletManifoldPoint:: get_distance() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_pt.getDistance(); } @@ -64,6 +66,7 @@ get_distance() const { */ PN_stdfloat BulletManifoldPoint:: get_applied_impulse() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_pt.getAppliedImpulse(); } @@ -73,6 +76,7 @@ get_applied_impulse() const { */ LPoint3 BulletManifoldPoint:: get_position_world_on_a() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LPoint3(_pt.getPositionWorldOnA()); } @@ -82,6 +86,7 @@ get_position_world_on_a() const { */ LPoint3 BulletManifoldPoint:: get_position_world_on_b() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LPoint3(_pt.getPositionWorldOnB()); } @@ -91,6 +96,7 @@ get_position_world_on_b() const { */ LVector3 BulletManifoldPoint:: get_normal_world_on_b() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LVector3(_pt.m_normalWorldOnB); } @@ -100,6 +106,7 @@ get_normal_world_on_b() const { */ LPoint3 BulletManifoldPoint:: get_local_point_a() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LPoint3(_pt.m_localPointA); } @@ -109,6 +116,7 @@ get_local_point_a() const { */ LPoint3 BulletManifoldPoint:: get_local_point_b() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LPoint3(_pt.m_localPointB); } @@ -118,6 +126,7 @@ get_local_point_b() const { */ int BulletManifoldPoint:: get_part_id0() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _pt.m_partId0; } @@ -127,6 +136,7 @@ get_part_id0() const { */ int BulletManifoldPoint:: get_part_id1() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _pt.m_partId1; } @@ -136,6 +146,7 @@ get_part_id1() const { */ int BulletManifoldPoint:: get_index0() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _pt.m_index0; } @@ -145,6 +156,261 @@ get_index0() const { */ int BulletManifoldPoint:: get_index1() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _pt.m_index1; } + +/** + * + */ +void BulletManifoldPoint:: +set_lateral_friction_initialized(bool value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + +#if BT_BULLET_VERSION >= 285 + if (value) { + _pt.m_contactPointFlags |= BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED; + } else { + _pt.m_contactPointFlags &= ~BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED; + } +#else + _pt.m_lateralFrictionInitialized = value; +#endif +} + +/** + * + */ +bool BulletManifoldPoint:: +get_lateral_friction_initialized() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + +#if BT_BULLET_VERSION >= 285 + return (_pt.m_contactPointFlags & BT_CONTACT_FLAG_LATERAL_FRICTION_INITIALIZED) != 0; +#else + return _pt.m_lateralFrictionInitialized; +#endif +} + +/** + * + */ +void BulletManifoldPoint:: +set_lateral_friction_dir1(const LVecBase3 &dir) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _pt.m_lateralFrictionDir1 = LVecBase3_to_btVector3(dir); +} + +/** + * + */ +LVector3 BulletManifoldPoint:: +get_lateral_friction_dir1() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btVector3_to_LVector3(_pt.m_lateralFrictionDir1); +} + +/** + * + */ +void BulletManifoldPoint:: +set_lateral_friction_dir2(const LVecBase3 &dir) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _pt.m_lateralFrictionDir2 = LVecBase3_to_btVector3(dir); +} + +/** + * + */ +LVector3 BulletManifoldPoint:: +get_lateral_friction_dir2() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btVector3_to_LVector3(_pt.m_lateralFrictionDir2); +} + +/** + * + */ +void BulletManifoldPoint:: +set_contact_motion1(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _pt.m_contactMotion1 = (btScalar)value; +} + +/** + * + */ +PN_stdfloat BulletManifoldPoint:: +get_contact_motion1() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_pt.m_contactMotion1; +} + +/** + * + */ +void BulletManifoldPoint:: +set_contact_motion2(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _pt.m_contactMotion2 = (btScalar)value; +} + +/** + * + */ +PN_stdfloat BulletManifoldPoint:: +get_contact_motion2() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_pt.m_contactMotion2; +} + +/** + * + */ +void BulletManifoldPoint:: +set_combined_friction(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _pt.m_combinedFriction = (btScalar)value; +} + +/** + * + */ +PN_stdfloat BulletManifoldPoint:: +get_combined_friction() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_pt.m_combinedFriction; +} + +/** + * + */ +void BulletManifoldPoint:: +set_combined_restitution(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _pt.m_combinedRestitution = (btScalar)value; +} + +/** + * + */ +PN_stdfloat BulletManifoldPoint:: +get_combined_restitution() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_pt.m_combinedRestitution; +} + +/** + * + */ +void BulletManifoldPoint:: +set_applied_impulse(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _pt.m_appliedImpulse = (btScalar)value; +} + +/** + * + */ +void BulletManifoldPoint:: +set_applied_impulse_lateral1(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _pt.m_appliedImpulseLateral1 = (btScalar)value; +} + +/** + * + */ +PN_stdfloat BulletManifoldPoint:: +get_applied_impulse_lateral1() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_pt.m_appliedImpulseLateral1; +} + +/** + * + */ +void BulletManifoldPoint:: +set_applied_impulse_lateral2(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _pt.m_appliedImpulseLateral2 = (btScalar)value; +} + +/** + * + */ +PN_stdfloat BulletManifoldPoint:: +get_applied_impulse_lateral2() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_pt.m_appliedImpulseLateral2; +} + +/** + * + */ +void BulletManifoldPoint:: +set_contact_cfm1(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + +#if BT_BULLET_VERSION < 285 + _pt.m_contactCFM1 = (btScalar)value; +#endif +} + +/** + * + */ +PN_stdfloat BulletManifoldPoint:: +get_contact_cfm1() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + +#if BT_BULLET_VERSION < 285 + return (PN_stdfloat)_pt.m_contactCFM1; +#else + return 0; +#endif +} + +/** + * + */ +void BulletManifoldPoint:: +set_contact_cfm2(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + +#if BT_BULLET_VERSION < 285 + _pt.m_contactCFM2 = (btScalar)value; +#endif +} + +/** + * + */ +PN_stdfloat BulletManifoldPoint:: +get_contact_cfm2() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + +#if BT_BULLET_VERSION < 285 + return (PN_stdfloat)_pt.m_contactCFM2; +#else + return 0; +#endif +} diff --git a/panda/src/bullet/bulletManifoldPoint.h b/panda/src/bullet/bulletManifoldPoint.h index a7bc271599..bc4c0f9486 100644 --- a/panda/src/bullet/bulletManifoldPoint.h +++ b/panda/src/bullet/bulletManifoldPoint.h @@ -43,30 +43,30 @@ PUBLISHED: int get_index0() const; int get_index1() const; - INLINE void set_lateral_friction_initialized(bool value); - INLINE void set_lateral_friction_dir1(const LVecBase3 &dir); - INLINE void set_lateral_friction_dir2(const LVecBase3 &dir); - INLINE void set_contact_motion1(PN_stdfloat value); - INLINE void set_contact_motion2(PN_stdfloat value); - INLINE void set_combined_friction(PN_stdfloat value); - INLINE void set_combined_restitution(PN_stdfloat value); - INLINE void set_applied_impulse(PN_stdfloat value); - INLINE void set_applied_impulse_lateral1(PN_stdfloat value); - INLINE void set_applied_impulse_lateral2(PN_stdfloat value); - INLINE void set_contact_cfm1(PN_stdfloat value); - INLINE void set_contact_cfm2(PN_stdfloat value); + void set_lateral_friction_initialized(bool value); + void set_lateral_friction_dir1(const LVecBase3 &dir); + void set_lateral_friction_dir2(const LVecBase3 &dir); + void set_contact_motion1(PN_stdfloat value); + void set_contact_motion2(PN_stdfloat value); + void set_combined_friction(PN_stdfloat value); + void set_combined_restitution(PN_stdfloat value); + void set_applied_impulse(PN_stdfloat value); + void set_applied_impulse_lateral1(PN_stdfloat value); + void set_applied_impulse_lateral2(PN_stdfloat value); + void set_contact_cfm1(PN_stdfloat value); + void set_contact_cfm2(PN_stdfloat value); - INLINE bool get_lateral_friction_initialized() const; - INLINE LVector3 get_lateral_friction_dir1() const; - INLINE LVector3 get_lateral_friction_dir2() const; - INLINE PN_stdfloat get_contact_motion1() const; - INLINE PN_stdfloat get_contact_motion2() const; - INLINE PN_stdfloat get_combined_friction() const; - INLINE PN_stdfloat get_combined_restitution() const; - INLINE PN_stdfloat get_applied_impulse_lateral1() const; - INLINE PN_stdfloat get_applied_impulse_lateral2() const; - INLINE PN_stdfloat get_contact_cfm1() const; - INLINE PN_stdfloat get_contact_cfm2() const; + bool get_lateral_friction_initialized() const; + LVector3 get_lateral_friction_dir1() const; + LVector3 get_lateral_friction_dir2() const; + PN_stdfloat get_contact_motion1() const; + PN_stdfloat get_contact_motion2() const; + PN_stdfloat get_combined_friction() const; + PN_stdfloat get_combined_restitution() const; + PN_stdfloat get_applied_impulse_lateral1() const; + PN_stdfloat get_applied_impulse_lateral2() const; + PN_stdfloat get_contact_cfm1() const; + PN_stdfloat get_contact_cfm2() const; MAKE_PROPERTY(life_time, get_life_time); MAKE_PROPERTY(distance, get_distance); diff --git a/panda/src/bullet/bulletMinkowskiSumShape.I b/panda/src/bullet/bulletMinkowskiSumShape.I index ed4a356f9a..b99d0c7561 100644 --- a/panda/src/bullet/bulletMinkowskiSumShape.I +++ b/panda/src/bullet/bulletMinkowskiSumShape.I @@ -30,64 +30,6 @@ INLINE BulletMinkowskiSumShape:: delete _shape; } -/** - * - */ -INLINE BulletMinkowskiSumShape:: -BulletMinkowskiSumShape(const BulletMinkowskiSumShape ©) : - _shape(copy._shape), - _shape_a(copy._shape_a), - _shape_b(copy._shape_b) { -} - -/** - * - */ -INLINE void BulletMinkowskiSumShape:: -operator = (const BulletMinkowskiSumShape ©) { - _shape = copy._shape; - _shape_a = copy._shape_a; - _shape_b = copy._shape_b; -} - -/** - * - */ -INLINE void BulletMinkowskiSumShape:: -set_transform_a(const TransformState *ts) { - - nassertv(ts); - _shape->setTransformA(TransformState_to_btTrans(ts)); -} - -/** - * - */ -INLINE void BulletMinkowskiSumShape:: -set_transform_b(const TransformState *ts) { - - nassertv(ts); - _shape->setTransformB(TransformState_to_btTrans(ts)); -} - -/** - * - */ -INLINE CPT(TransformState) BulletMinkowskiSumShape:: -get_transform_a() const { - - return btTrans_to_TransformState(_shape->getTransformA()); -} - -/** - * - */ -INLINE CPT(TransformState) BulletMinkowskiSumShape:: -get_transform_b() const { - - return btTrans_to_TransformState(_shape->GetTransformB()); -} - /** * */ diff --git a/panda/src/bullet/bulletMinkowskiSumShape.cxx b/panda/src/bullet/bulletMinkowskiSumShape.cxx index 3dc618adac..cc56d39884 100644 --- a/panda/src/bullet/bulletMinkowskiSumShape.cxx +++ b/panda/src/bullet/bulletMinkowskiSumShape.cxx @@ -33,6 +33,30 @@ BulletMinkowskiSumShape(const BulletShape *shape_a, const BulletShape *shape_b) _shape->setUserPointer(this); } +/** + * + */ +BulletMinkowskiSumShape:: +BulletMinkowskiSumShape(const BulletMinkowskiSumShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _shape = copy._shape; + _shape_a = copy._shape_a; + _shape_b = copy._shape_b; +} + +/** + * + */ +void BulletMinkowskiSumShape:: +operator = (const BulletMinkowskiSumShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _shape = copy._shape; + _shape_a = copy._shape_a; + _shape_b = copy._shape_b; +} + /** * */ @@ -42,6 +66,48 @@ ptr() const { return _shape; } +/** + * + */ +void BulletMinkowskiSumShape:: +set_transform_a(const TransformState *ts) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + nassertv(ts); + _shape->setTransformA(TransformState_to_btTrans(ts)); +} + +/** + * + */ +void BulletMinkowskiSumShape:: +set_transform_b(const TransformState *ts) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + nassertv(ts); + _shape->setTransformB(TransformState_to_btTrans(ts)); +} + +/** + * + */ +CPT(TransformState) BulletMinkowskiSumShape:: +get_transform_a() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btTrans_to_TransformState(_shape->getTransformA()); +} + +/** + * + */ +CPT(TransformState) BulletMinkowskiSumShape:: +get_transform_b() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btTrans_to_TransformState(_shape->GetTransformB()); +} + /** * Tells the BamReader how to create objects of type BulletShape. */ diff --git a/panda/src/bullet/bulletMinkowskiSumShape.h b/panda/src/bullet/bulletMinkowskiSumShape.h index 2e66ab9cae..c8629f2e33 100644 --- a/panda/src/bullet/bulletMinkowskiSumShape.h +++ b/panda/src/bullet/bulletMinkowskiSumShape.h @@ -32,14 +32,14 @@ private: PUBLISHED: explicit BulletMinkowskiSumShape(const BulletShape *shape_a, const BulletShape *shape_b); - INLINE BulletMinkowskiSumShape(const BulletMinkowskiSumShape ©); - INLINE void operator = (const BulletMinkowskiSumShape ©); + BulletMinkowskiSumShape(const BulletMinkowskiSumShape ©); + void operator = (const BulletMinkowskiSumShape ©); INLINE ~BulletMinkowskiSumShape(); - INLINE void set_transform_a(const TransformState *ts); - INLINE void set_transform_b(const TransformState *ts); - INLINE CPT(TransformState) get_transform_a() const; - INLINE CPT(TransformState) get_transform_b() const; + void set_transform_a(const TransformState *ts); + void set_transform_b(const TransformState *ts); + CPT(TransformState) get_transform_a() const; + CPT(TransformState) get_transform_b() const; INLINE const BulletShape *get_shape_a() const; INLINE const BulletShape *get_shape_b() const; diff --git a/panda/src/bullet/bulletMultiSphereShape.I b/panda/src/bullet/bulletMultiSphereShape.I index 1024dce7dc..e4f95c7bf1 100644 --- a/panda/src/bullet/bulletMultiSphereShape.I +++ b/panda/src/bullet/bulletMultiSphereShape.I @@ -19,48 +19,3 @@ INLINE BulletMultiSphereShape:: delete _shape; } - -/** - * - */ -INLINE BulletMultiSphereShape:: -BulletMultiSphereShape(const BulletMultiSphereShape ©) : - _shape(copy._shape) { -} - -/** - * - */ -INLINE void BulletMultiSphereShape:: -operator = (const BulletMultiSphereShape ©) { - _shape = copy._shape; -} - -/** - * - */ -INLINE int BulletMultiSphereShape:: -get_sphere_count() const { - - return _shape->getSphereCount(); -} - -/** - * - */ -INLINE LPoint3 BulletMultiSphereShape:: -get_sphere_pos(int index) const { - - nassertr(index >=0 && index <_shape->getSphereCount(), LPoint3::zero()); - return btVector3_to_LPoint3(_shape->getSpherePosition(index)); -} - -/** - * - */ -INLINE PN_stdfloat BulletMultiSphereShape:: -get_sphere_radius(int index) const { - - nassertr(index >=0 && index <_shape->getSphereCount(), 0.0); - return (PN_stdfloat)_shape->getSphereRadius(index); -} diff --git a/panda/src/bullet/bulletMultiSphereShape.cxx b/panda/src/bullet/bulletMultiSphereShape.cxx index 9defaedc51..ffaed8bafb 100644 --- a/panda/src/bullet/bulletMultiSphereShape.cxx +++ b/panda/src/bullet/bulletMultiSphereShape.cxx @@ -42,6 +42,26 @@ BulletMultiSphereShape(const PTA_LVecBase3 &points, const PTA_stdfloat &radii) { _shape->setUserPointer(this); } +/** + * + */ +BulletMultiSphereShape:: +BulletMultiSphereShape(const BulletMultiSphereShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _shape = copy._shape; +} + +/** + * + */ +void BulletMultiSphereShape:: +operator = (const BulletMultiSphereShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _shape = copy._shape; +} + /** * */ @@ -51,6 +71,38 @@ ptr() const { return _shape; } +/** + * + */ +int BulletMultiSphereShape:: +get_sphere_count() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return _shape->getSphereCount(); +} + +/** + * + */ +LPoint3 BulletMultiSphereShape:: +get_sphere_pos(int index) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + nassertr(index >=0 && index <_shape->getSphereCount(), LPoint3::zero()); + return btVector3_to_LPoint3(_shape->getSpherePosition(index)); +} + +/** + * + */ +PN_stdfloat BulletMultiSphereShape:: +get_sphere_radius(int index) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + nassertr(index >=0 && index <_shape->getSphereCount(), 0.0); + return (PN_stdfloat)_shape->getSphereRadius(index); +} + /** * Tells the BamReader how to create objects of type BulletShape. */ diff --git a/panda/src/bullet/bulletMultiSphereShape.h b/panda/src/bullet/bulletMultiSphereShape.h index 11d3ee936f..d6fd7af7b7 100644 --- a/panda/src/bullet/bulletMultiSphereShape.h +++ b/panda/src/bullet/bulletMultiSphereShape.h @@ -31,13 +31,13 @@ private: PUBLISHED: explicit BulletMultiSphereShape(const PTA_LVecBase3 &points, const PTA_stdfloat &radii); - INLINE BulletMultiSphereShape(const BulletMultiSphereShape ©); - INLINE void operator = (const BulletMultiSphereShape ©); + BulletMultiSphereShape(const BulletMultiSphereShape ©); + void operator = (const BulletMultiSphereShape ©); INLINE ~BulletMultiSphereShape(); - INLINE int get_sphere_count() const; - INLINE LPoint3 get_sphere_pos(int index) const; - INLINE PN_stdfloat get_sphere_radius(int index) const; + int get_sphere_count() const; + LPoint3 get_sphere_pos(int index) const; + PN_stdfloat get_sphere_radius(int index) const; MAKE_PROPERTY(sphere_count, get_sphere_count); MAKE_SEQ_PROPERTY(sphere_pos, get_sphere_count, get_sphere_pos); diff --git a/panda/src/bullet/bulletPersistentManifold.cxx b/panda/src/bullet/bulletPersistentManifold.cxx index 3a4024f8d2..e42ea3c6f8 100644 --- a/panda/src/bullet/bulletPersistentManifold.cxx +++ b/panda/src/bullet/bulletPersistentManifold.cxx @@ -27,6 +27,7 @@ BulletPersistentManifold(btPersistentManifold *manifold) : _manifold(manifold) { */ PN_stdfloat BulletPersistentManifold:: get_contact_breaking_threshold() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_manifold->getContactBreakingThreshold(); } @@ -36,6 +37,7 @@ get_contact_breaking_threshold() const { */ PN_stdfloat BulletPersistentManifold:: get_contact_processing_threshold() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_manifold->getContactProcessingThreshold(); } @@ -45,6 +47,7 @@ get_contact_processing_threshold() const { */ void BulletPersistentManifold:: clear_manifold() { + LightMutexHolder holder(BulletWorld::get_global_lock()); _manifold->clearManifold(); } @@ -54,6 +57,7 @@ clear_manifold() { */ PandaNode *BulletPersistentManifold:: get_node0() { + LightMutexHolder holder(BulletWorld::get_global_lock()); #if BT_BULLET_VERSION >= 281 const btCollisionObject *obj = _manifold->getBody0(); @@ -69,6 +73,7 @@ get_node0() { */ PandaNode *BulletPersistentManifold:: get_node1() { + LightMutexHolder holder(BulletWorld::get_global_lock()); #if BT_BULLET_VERSION >= 281 const btCollisionObject *obj = _manifold->getBody1(); @@ -84,6 +89,7 @@ get_node1() { */ int BulletPersistentManifold:: get_num_manifold_points() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _manifold->getNumContacts(); } @@ -93,6 +99,7 @@ get_num_manifold_points() const { */ BulletManifoldPoint *BulletPersistentManifold:: get_manifold_point(int idx) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertr(idx < _manifold->getNumContacts(), NULL) diff --git a/panda/src/bullet/bulletPlaneShape.I b/panda/src/bullet/bulletPlaneShape.I index f6a4c1e752..0b080ab986 100644 --- a/panda/src/bullet/bulletPlaneShape.I +++ b/panda/src/bullet/bulletPlaneShape.I @@ -19,37 +19,3 @@ INLINE BulletPlaneShape:: delete _shape; } - -/** - * - */ -INLINE BulletPlaneShape:: -BulletPlaneShape(const BulletPlaneShape ©) : - _shape(copy._shape) { -} - -/** - * - */ -INLINE void BulletPlaneShape:: -operator = (const BulletPlaneShape ©) { - _shape = copy._shape; -} - -/** - * - */ -INLINE PN_stdfloat BulletPlaneShape:: -get_plane_constant() const { - - return (PN_stdfloat)_shape->getPlaneConstant(); -} - -/** - * - */ -INLINE LVector3 BulletPlaneShape:: -get_plane_normal() const { - - return btVector3_to_LVector3(_shape->getPlaneNormal()); -} diff --git a/panda/src/bullet/bulletPlaneShape.cxx b/panda/src/bullet/bulletPlaneShape.cxx index 2b410fb0e9..a7804290cd 100644 --- a/panda/src/bullet/bulletPlaneShape.cxx +++ b/panda/src/bullet/bulletPlaneShape.cxx @@ -27,6 +27,26 @@ BulletPlaneShape(const LVector3 &normal, PN_stdfloat constant) { _shape->setUserPointer(this); } +/** + * + */ +BulletPlaneShape:: +BulletPlaneShape(const BulletPlaneShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _shape = copy._shape; +} + +/** + * + */ +void BulletPlaneShape:: +operator = (const BulletPlaneShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _shape = copy._shape; +} + /** * */ @@ -36,6 +56,26 @@ ptr() const { return _shape; } +/** + * + */ +PN_stdfloat BulletPlaneShape:: +get_plane_constant() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_shape->getPlaneConstant(); +} + +/** + * + */ +LVector3 BulletPlaneShape:: +get_plane_normal() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btVector3_to_LVector3(_shape->getPlaneNormal()); +} + /** * */ diff --git a/panda/src/bullet/bulletPlaneShape.h b/panda/src/bullet/bulletPlaneShape.h index 4455328f10..610c5d2412 100644 --- a/panda/src/bullet/bulletPlaneShape.h +++ b/panda/src/bullet/bulletPlaneShape.h @@ -33,12 +33,12 @@ private: PUBLISHED: explicit BulletPlaneShape(const LVector3 &normal, PN_stdfloat constant); - INLINE BulletPlaneShape(const BulletPlaneShape ©); - INLINE void operator = (const BulletPlaneShape ©); + BulletPlaneShape(const BulletPlaneShape ©); + void operator = (const BulletPlaneShape ©); INLINE ~BulletPlaneShape(); - INLINE LVector3 get_plane_normal() const; - INLINE PN_stdfloat get_plane_constant() const; + LVector3 get_plane_normal() const; + PN_stdfloat get_plane_constant() const; static BulletPlaneShape *make_from_solid(const CollisionPlane *solid); diff --git a/panda/src/bullet/bulletRigidBodyNode.I b/panda/src/bullet/bulletRigidBodyNode.I index de1d5eea05..02c9b5dc6d 100644 --- a/panda/src/bullet/bulletRigidBodyNode.I +++ b/panda/src/bullet/bulletRigidBodyNode.I @@ -20,38 +20,3 @@ INLINE BulletRigidBodyNode:: delete _rigid; } -/** - * - */ -INLINE void BulletRigidBodyNode:: -set_linear_damping(PN_stdfloat value) { - - _rigid->setDamping(value, _rigid->getAngularDamping()); -} - -/** - * - */ -INLINE void BulletRigidBodyNode:: -set_angular_damping(PN_stdfloat value) { - - _rigid->setDamping(_rigid->getLinearDamping(), value); -} - -/** - * - */ -INLINE PN_stdfloat BulletRigidBodyNode:: -get_linear_damping() const { - - return (PN_stdfloat)_rigid->getLinearDamping(); -} - -/** - * - */ -INLINE PN_stdfloat BulletRigidBodyNode:: -get_angular_damping() const { - - return (PN_stdfloat)_rigid->getAngularDamping(); -} diff --git a/panda/src/bullet/bulletRigidBodyNode.cxx b/panda/src/bullet/bulletRigidBodyNode.cxx index b8c921e99d..ab8c4327f9 100644 --- a/panda/src/bullet/bulletRigidBodyNode.cxx +++ b/panda/src/bullet/bulletRigidBodyNode.cxx @@ -48,9 +48,11 @@ BulletRigidBodyNode(const char *name) : BulletBodyNode(name) { */ BulletRigidBodyNode:: BulletRigidBodyNode(const BulletRigidBodyNode ©) : - BulletBodyNode(copy), - _motion(copy._motion) + BulletBodyNode(copy) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _motion = copy._motion; _rigid = new btRigidBody(*copy._rigid); _rigid->setUserPointer(this); _rigid->setCollisionShape(_shape); @@ -64,6 +66,7 @@ BulletRigidBodyNode(const BulletRigidBodyNode ©) : */ PandaNode *BulletRigidBodyNode:: make_copy() const { + return new BulletRigidBodyNode(*this); } @@ -72,10 +75,11 @@ make_copy() const { */ void BulletRigidBodyNode:: output(ostream &out) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); - BulletBodyNode::output(out); + BulletBodyNode::do_output(out); - out << " mass=" << get_mass(); + out << " mass=" << do_get_mass(); } /** @@ -93,10 +97,10 @@ get_object() const { * The default implementation does nothing. */ void BulletRigidBodyNode:: -shape_changed() { +do_shape_changed() { - set_mass(get_mass()); - transform_changed(); + do_set_mass(do_get_mass()); + do_transform_changed(); } /** @@ -104,9 +108,10 @@ shape_changed() { * automatically computed from the shape of the body. Setting a value of zero * for mass will make the body static. A value of zero can be considered an * infinite mass. + * Assumes the lock(bullet global lock) is held by the caller */ void BulletRigidBodyNode:: -set_mass(PN_stdfloat mass) { +do_set_mass(PN_stdfloat mass) { btScalar bt_mass = mass; btVector3 bt_inertia(0.0, 0.0, 0.0); @@ -119,12 +124,26 @@ set_mass(PN_stdfloat mass) { _rigid->updateInertiaTensor(); } +/** + * Sets the mass of a rigid body. This also modifies the inertia, which is + * automatically computed from the shape of the body. Setting a value of zero + * for mass will make the body static. A value of zero can be considered an + * infinite mass. + */ +void BulletRigidBodyNode:: +set_mass(PN_stdfloat mass) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + do_set_mass(mass); +} + /** * Returns the total mass of a rigid body. A value of zero means that the * body is staic, i.e. has an infinite mass. + * Assumes the lock(bullet global lock) is held by the caller */ PN_stdfloat BulletRigidBodyNode:: -get_mass() const { +do_get_mass() const { btScalar inv_mass = _rigid->getInvMass(); btScalar mass = (inv_mass == btScalar(0.0)) ? btScalar(0.0) : btScalar(1.0) / inv_mass; @@ -132,11 +151,24 @@ get_mass() const { return mass; } +/** + * Returns the total mass of a rigid body. A value of zero means that the + * body is staic, i.e. has an infinite mass. + */ +PN_stdfloat BulletRigidBodyNode:: +get_mass() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return do_get_mass(); +} + + /** * Returns the inverse mass of a rigid body. */ PN_stdfloat BulletRigidBodyNode:: get_inv_mass() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_rigid->getInvMass(); } @@ -153,6 +185,7 @@ get_inv_mass() const { */ void BulletRigidBodyNode:: set_inertia(const LVecBase3 &inertia) { + LightMutexHolder holder(BulletWorld::get_global_lock()); btVector3 inv_inertia( inertia.get_x() == 0.0 ? btScalar(0.0) : btScalar(1.0 / inertia.get_x()), @@ -171,6 +204,7 @@ set_inertia(const LVecBase3 &inertia) { */ LVector3 BulletRigidBodyNode:: get_inertia() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); btVector3 inv_inertia = _rigid->getInvInertiaDiagLocal(); LVector3 inertia( @@ -187,6 +221,7 @@ get_inertia() const { */ LVector3 BulletRigidBodyNode:: get_inv_inertia_diag_local() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LVector3(_rigid->getInvInertiaDiagLocal()); } @@ -196,6 +231,7 @@ get_inv_inertia_diag_local() const { */ LMatrix3 BulletRigidBodyNode:: get_inv_inertia_tensor_world() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btMatrix3x3_to_LMatrix3(_rigid->getInvInertiaTensorWorld()); } @@ -205,6 +241,7 @@ get_inv_inertia_tensor_world() const { */ void BulletRigidBodyNode:: apply_force(const LVector3 &force, const LPoint3 &pos) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv_always(!force.is_nan()); nassertv_always(!pos.is_nan()); @@ -218,6 +255,7 @@ apply_force(const LVector3 &force, const LPoint3 &pos) { */ void BulletRigidBodyNode:: apply_central_force(const LVector3 &force) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv_always(!force.is_nan()); @@ -229,6 +267,7 @@ apply_central_force(const LVector3 &force) { */ void BulletRigidBodyNode:: apply_torque(const LVector3 &torque) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv_always(!torque.is_nan()); @@ -240,6 +279,7 @@ apply_torque(const LVector3 &torque) { */ void BulletRigidBodyNode:: apply_torque_impulse(const LVector3 &torque) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv_always(!torque.is_nan()); @@ -251,6 +291,7 @@ apply_torque_impulse(const LVector3 &torque) { */ void BulletRigidBodyNode:: apply_impulse(const LVector3 &impulse, const LPoint3 &pos) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv_always(!impulse.is_nan()); nassertv_always(!pos.is_nan()); @@ -264,6 +305,7 @@ apply_impulse(const LVector3 &impulse, const LPoint3 &pos) { */ void BulletRigidBodyNode:: apply_central_impulse(const LVector3 &impulse) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv_always(!impulse.is_nan()); @@ -271,10 +313,10 @@ apply_central_impulse(const LVector3 &impulse) { } /** - * + * Assumes the lock(bullet global lock) is held by the caller */ void BulletRigidBodyNode:: -transform_changed() { +do_transform_changed() { if (_motion.sync_disabled()) return; @@ -289,7 +331,7 @@ transform_changed() { _motion.set_net_transform(ts); // For dynamic or static bodies we directly apply the new transform. - if (!is_kinematic()) { + if (!(get_object()->isKinematicObject())) { btTransform trans = TransformState_to_btTrans(ts); _rigid->setCenterOfMassTransform(trans); } @@ -317,18 +359,31 @@ transform_changed() { * */ void BulletRigidBodyNode:: -sync_p2b() { +transform_changed() { - if (is_kinematic()) { - transform_changed(); + if (_motion.sync_disabled()) return; + + LightMutexHolder holder(BulletWorld::get_global_lock()); + + do_transform_changed(); +} + +/** + * Assumes the lock(bullet global lock) is held by the caller + */ +void BulletRigidBodyNode:: +do_sync_p2b() { + + if (get_object()->isKinematicObject()) { + do_transform_changed(); } } /** - * + * Assumes the lock(bullet global lock) is held by the caller */ void BulletRigidBodyNode:: -sync_b2p() { +do_sync_b2p() { _motion.sync_b2p((PandaNode *)this); } @@ -338,6 +393,7 @@ sync_b2p() { */ LVector3 BulletRigidBodyNode:: get_linear_velocity() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LVector3(_rigid->getLinearVelocity()); } @@ -347,6 +403,7 @@ get_linear_velocity() const { */ LVector3 BulletRigidBodyNode:: get_angular_velocity() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LVector3(_rigid->getAngularVelocity()); } @@ -356,6 +413,7 @@ get_angular_velocity() const { */ void BulletRigidBodyNode:: set_linear_velocity(const LVector3 &velocity) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv_always(!velocity.is_nan()); @@ -367,17 +425,59 @@ set_linear_velocity(const LVector3 &velocity) { */ void BulletRigidBodyNode:: set_angular_velocity(const LVector3 &velocity) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv_always(!velocity.is_nan()); _rigid->setAngularVelocity(LVecBase3_to_btVector3(velocity)); } +/** + * + */ +void BulletRigidBodyNode:: +set_linear_damping(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _rigid->setDamping(value, _rigid->getAngularDamping()); +} + +/** + * + */ +void BulletRigidBodyNode:: +set_angular_damping(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _rigid->setDamping(_rigid->getLinearDamping(), value); +} + +/** + * + */ +PN_stdfloat BulletRigidBodyNode:: +get_linear_damping() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_rigid->getLinearDamping(); +} + +/** + * + */ +PN_stdfloat BulletRigidBodyNode:: +get_angular_damping() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_rigid->getAngularDamping(); +} + /** * */ void BulletRigidBodyNode:: clear_forces() { + LightMutexHolder holder(BulletWorld::get_global_lock()); _rigid->clearForces(); } @@ -387,6 +487,7 @@ clear_forces() { */ PN_stdfloat BulletRigidBodyNode:: get_linear_sleep_threshold() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _rigid->getLinearSleepingThreshold(); } @@ -396,6 +497,7 @@ get_linear_sleep_threshold() const { */ PN_stdfloat BulletRigidBodyNode:: get_angular_sleep_threshold() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _rigid->getAngularSleepingThreshold(); } @@ -405,6 +507,7 @@ get_angular_sleep_threshold() const { */ void BulletRigidBodyNode:: set_linear_sleep_threshold(PN_stdfloat threshold) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _rigid->setSleepingThresholds(threshold, _rigid->getAngularSleepingThreshold()); } @@ -414,6 +517,7 @@ set_linear_sleep_threshold(PN_stdfloat threshold) { */ void BulletRigidBodyNode:: set_angular_sleep_threshold(PN_stdfloat threshold) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _rigid->setSleepingThresholds(_rigid->getLinearSleepingThreshold(), threshold); } @@ -423,6 +527,7 @@ set_angular_sleep_threshold(PN_stdfloat threshold) { */ void BulletRigidBodyNode:: set_gravity(const LVector3 &gravity) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv_always(!gravity.is_nan()); @@ -434,6 +539,7 @@ set_gravity(const LVector3 &gravity) { */ LVector3 BulletRigidBodyNode:: get_gravity() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LVector3(_rigid->getGravity()); } @@ -443,6 +549,7 @@ get_gravity() const { */ LVector3 BulletRigidBodyNode:: get_linear_factor() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LVector3(_rigid->getLinearFactor()); } @@ -452,6 +559,7 @@ get_linear_factor() const { */ LVector3 BulletRigidBodyNode:: get_angular_factor() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LVector3(_rigid->getAngularFactor()); } @@ -461,6 +569,7 @@ get_angular_factor() const { */ void BulletRigidBodyNode:: set_linear_factor(const LVector3 &factor) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _rigid->setLinearFactor(LVecBase3_to_btVector3(factor)); } @@ -470,6 +579,7 @@ set_linear_factor(const LVector3 &factor) { */ void BulletRigidBodyNode:: set_angular_factor(const LVector3 &factor) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _rigid->setAngularFactor(LVecBase3_to_btVector3(factor)); } @@ -479,6 +589,7 @@ set_angular_factor(const LVector3 &factor) { */ LVector3 BulletRigidBodyNode:: get_total_force() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LVector3(_rigid->getTotalForce()); } @@ -488,6 +599,7 @@ get_total_force() const { */ LVector3 BulletRigidBodyNode:: get_total_torque() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LVector3(_rigid->getTotalTorque()); } diff --git a/panda/src/bullet/bulletRigidBodyNode.h b/panda/src/bullet/bulletRigidBodyNode.h index c8afaeb8bb..641fdc9fd9 100644 --- a/panda/src/bullet/bulletRigidBodyNode.h +++ b/panda/src/bullet/bulletRigidBodyNode.h @@ -50,10 +50,10 @@ PUBLISHED: void set_angular_velocity(const LVector3 &velocity); // Damping - INLINE PN_stdfloat get_linear_damping() const; - INLINE PN_stdfloat get_angular_damping() const; - INLINE void set_linear_damping(PN_stdfloat value); - INLINE void set_angular_damping(PN_stdfloat value); + PN_stdfloat get_linear_damping() const; + PN_stdfloat get_angular_damping() const; + void set_linear_damping(PN_stdfloat value); + void set_angular_damping(PN_stdfloat value); // Forces void clear_forces(); @@ -108,14 +108,18 @@ public: virtual void output(ostream &out) const; - void sync_p2b(); - void sync_b2p(); + void do_sync_p2b(); + void do_sync_b2p(); protected: virtual void transform_changed(); private: - virtual void shape_changed(); + virtual void do_shape_changed(); + void do_transform_changed(); + + void do_set_mass(PN_stdfloat mass); + PN_stdfloat do_get_mass() const; // The motion state is used for synchronisation between Bullet and the // Panda3D scene graph. diff --git a/panda/src/bullet/bulletRotationalLimitMotor.I b/panda/src/bullet/bulletRotationalLimitMotor.I index 10ed68435c..35b923a9d3 100644 --- a/panda/src/bullet/bulletRotationalLimitMotor.I +++ b/panda/src/bullet/bulletRotationalLimitMotor.I @@ -14,162 +14,7 @@ /** * */ -INLINE bool BulletRotationalLimitMotor:: -is_limited() const { +INLINE BulletRotationalLimitMotor:: +~BulletRotationalLimitMotor() { - return _motor.isLimited(); -} - -/** - * - */ -INLINE void BulletRotationalLimitMotor:: -set_motor_enabled(bool enabled) { - - _motor.m_enableMotor = enabled; -} - -/** - * - */ -INLINE bool BulletRotationalLimitMotor:: -get_motor_enabled() const { - - return _motor.m_enableMotor; -} - -/** - * - */ -INLINE void BulletRotationalLimitMotor:: -set_low_limit(PN_stdfloat limit) { - - _motor.m_loLimit = (btScalar)limit; -} - -/** - * - */ -INLINE void BulletRotationalLimitMotor:: -set_high_limit(PN_stdfloat limit) { - - _motor.m_hiLimit = (btScalar)limit; -} - -/** - * - */ -INLINE void BulletRotationalLimitMotor:: -set_target_velocity(PN_stdfloat velocity) { - - _motor.m_targetVelocity = (btScalar)velocity; -} - -/** - * - */ -INLINE void BulletRotationalLimitMotor:: -set_max_motor_force(PN_stdfloat force) { - - _motor.m_maxMotorForce = (btScalar)force; -} - -/** - * - */ -INLINE void BulletRotationalLimitMotor:: -set_max_limit_force(PN_stdfloat force) { - - _motor.m_maxLimitForce = (btScalar)force; -} - -/** - * - */ -INLINE void BulletRotationalLimitMotor:: -set_damping(PN_stdfloat damping) { - - _motor.m_damping = (btScalar)damping; -} - -/** - * - */ -INLINE void BulletRotationalLimitMotor:: -set_softness(PN_stdfloat softness) { - - _motor.m_limitSoftness = (btScalar)softness; -} - -/** - * - */ -INLINE void BulletRotationalLimitMotor:: -set_bounce(PN_stdfloat bounce) { - - _motor.m_bounce = (btScalar)bounce; -} - -/** - * - */ -INLINE void BulletRotationalLimitMotor:: -set_normal_cfm(PN_stdfloat cfm) { - - _motor.m_normalCFM = (btScalar)cfm; -} - -/** - * - */ -INLINE void BulletRotationalLimitMotor:: -set_stop_cfm(PN_stdfloat cfm) { - - _motor.m_stopCFM = (btScalar)cfm; -} - -/** - * - */ -INLINE void BulletRotationalLimitMotor:: -set_stop_erp(PN_stdfloat erp) { - - _motor.m_stopERP = (btScalar)erp; -} - -/** - * Retrieves the current value of angle: 0 = free, 1 = at low limit, 2 = at - * high limit. - */ -INLINE int BulletRotationalLimitMotor:: -get_current_limit() const { - - return _motor.m_currentLimit; -} - -/** - * - */ -INLINE PN_stdfloat BulletRotationalLimitMotor:: -get_current_error() const { - - return (PN_stdfloat)_motor.m_currentLimitError; -} - -/** - * - */ -INLINE PN_stdfloat BulletRotationalLimitMotor:: -get_current_position() const { - - return (PN_stdfloat)_motor.m_currentPosition; -} - -/** - * - */ -INLINE PN_stdfloat BulletRotationalLimitMotor:: -get_accumulated_impulse() const { - - return (PN_stdfloat)_motor.m_accumulatedImpulse; } diff --git a/panda/src/bullet/bulletRotationalLimitMotor.cxx b/panda/src/bullet/bulletRotationalLimitMotor.cxx index ce95a1f8d7..d521b7ad94 100644 --- a/panda/src/bullet/bulletRotationalLimitMotor.cxx +++ b/panda/src/bullet/bulletRotationalLimitMotor.cxx @@ -34,7 +34,179 @@ BulletRotationalLimitMotor(const BulletRotationalLimitMotor ©) /** * */ -BulletRotationalLimitMotor:: -~BulletRotationalLimitMotor() { +bool BulletRotationalLimitMotor:: +is_limited() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + return _motor.isLimited(); +} + +/** + * + */ +void BulletRotationalLimitMotor:: +set_motor_enabled(bool enabled) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _motor.m_enableMotor = enabled; +} + +/** + * + */ +bool BulletRotationalLimitMotor:: +get_motor_enabled() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return _motor.m_enableMotor; +} +/** + * + */ +void BulletRotationalLimitMotor:: +set_low_limit(PN_stdfloat limit) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _motor.m_loLimit = (btScalar)limit; +} + +/** + * + */ +void BulletRotationalLimitMotor:: +set_high_limit(PN_stdfloat limit) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _motor.m_hiLimit = (btScalar)limit; +} + +/** + * + */ +void BulletRotationalLimitMotor:: +set_target_velocity(PN_stdfloat velocity) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _motor.m_targetVelocity = (btScalar)velocity; +} + +/** + * + */ +void BulletRotationalLimitMotor:: +set_max_motor_force(PN_stdfloat force) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _motor.m_maxMotorForce = (btScalar)force; +} + +/** + * + */ +void BulletRotationalLimitMotor:: +set_max_limit_force(PN_stdfloat force) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _motor.m_maxLimitForce = (btScalar)force; +} + +/** + * + */ +void BulletRotationalLimitMotor:: +set_damping(PN_stdfloat damping) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _motor.m_damping = (btScalar)damping; +} + +/** + * + */ +void BulletRotationalLimitMotor:: +set_softness(PN_stdfloat softness) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _motor.m_limitSoftness = (btScalar)softness; +} + +/** + * + */ +void BulletRotationalLimitMotor:: +set_bounce(PN_stdfloat bounce) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _motor.m_bounce = (btScalar)bounce; +} + +/** + * + */ +void BulletRotationalLimitMotor:: +set_normal_cfm(PN_stdfloat cfm) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _motor.m_normalCFM = (btScalar)cfm; +} + +/** + * + */ +void BulletRotationalLimitMotor:: +set_stop_cfm(PN_stdfloat cfm) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _motor.m_stopCFM = (btScalar)cfm; +} + +/** + * + */ +void BulletRotationalLimitMotor:: +set_stop_erp(PN_stdfloat erp) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _motor.m_stopERP = (btScalar)erp; +} + +/** + * Retrieves the current value of angle: 0 = free, 1 = at low limit, 2 = at + * high limit. + */ +int BulletRotationalLimitMotor:: +get_current_limit() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return _motor.m_currentLimit; +} + +/** + * + */ +PN_stdfloat BulletRotationalLimitMotor:: +get_current_error() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_motor.m_currentLimitError; +} + +/** + * + */ +PN_stdfloat BulletRotationalLimitMotor:: +get_current_position() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_motor.m_currentPosition; +} + +/** + * + */ +PN_stdfloat BulletRotationalLimitMotor:: +get_accumulated_impulse() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_motor.m_accumulatedImpulse; } diff --git a/panda/src/bullet/bulletRotationalLimitMotor.h b/panda/src/bullet/bulletRotationalLimitMotor.h index a1cce18ff4..d046cd9171 100644 --- a/panda/src/bullet/bulletRotationalLimitMotor.h +++ b/panda/src/bullet/bulletRotationalLimitMotor.h @@ -28,27 +28,27 @@ class EXPCL_PANDABULLET BulletRotationalLimitMotor { PUBLISHED: BulletRotationalLimitMotor(const BulletRotationalLimitMotor ©); - ~BulletRotationalLimitMotor(); + INLINE ~BulletRotationalLimitMotor(); - INLINE void set_motor_enabled(bool enable); - INLINE void set_low_limit(PN_stdfloat limit); - INLINE void set_high_limit(PN_stdfloat limit); - INLINE void set_target_velocity(PN_stdfloat velocity); - INLINE void set_max_motor_force(PN_stdfloat force); - INLINE void set_max_limit_force(PN_stdfloat force); - INLINE void set_damping(PN_stdfloat damping); - INLINE void set_softness(PN_stdfloat softness); - INLINE void set_bounce(PN_stdfloat bounce); - INLINE void set_normal_cfm(PN_stdfloat cfm); - INLINE void set_stop_cfm(PN_stdfloat cfm); - INLINE void set_stop_erp(PN_stdfloat erp); + void set_motor_enabled(bool enable); + void set_low_limit(PN_stdfloat limit); + void set_high_limit(PN_stdfloat limit); + void set_target_velocity(PN_stdfloat velocity); + void set_max_motor_force(PN_stdfloat force); + void set_max_limit_force(PN_stdfloat force); + void set_damping(PN_stdfloat damping); + void set_softness(PN_stdfloat softness); + void set_bounce(PN_stdfloat bounce); + void set_normal_cfm(PN_stdfloat cfm); + void set_stop_cfm(PN_stdfloat cfm); + void set_stop_erp(PN_stdfloat erp); - INLINE bool is_limited() const; - INLINE bool get_motor_enabled() const; - INLINE int get_current_limit() const; - INLINE PN_stdfloat get_current_error() const; - INLINE PN_stdfloat get_current_position() const; - INLINE PN_stdfloat get_accumulated_impulse() const; + bool is_limited() const; + bool get_motor_enabled() const; + int get_current_limit() const; + PN_stdfloat get_current_error() const; + PN_stdfloat get_current_position() const; + PN_stdfloat get_accumulated_impulse() const; MAKE_PROPERTY(limited, is_limited); MAKE_PROPERTY(motor_enabled, get_motor_enabled, set_motor_enabled); diff --git a/panda/src/bullet/bulletShape.I b/panda/src/bullet/bulletShape.I index 35123a868f..c408ccb95b 100644 --- a/panda/src/bullet/bulletShape.I +++ b/panda/src/bullet/bulletShape.I @@ -18,66 +18,3 @@ INLINE BulletShape:: ~BulletShape() { } - -/** - * - */ -INLINE bool BulletShape:: -is_polyhedral() const { - - return ptr()->isPolyhedral(); -} - -/** - * - */ -INLINE bool BulletShape:: -is_convex() const { - - return ptr()->isConvex(); -} - -/** - * - */ -INLINE bool BulletShape:: -is_convex_2d() const { - - return ptr()->isConvex2d(); -} - -/** - * - */ -INLINE bool BulletShape:: -is_concave() const { - - return ptr()->isConcave(); -} - -/** - * - */ -INLINE bool BulletShape:: -is_infinite() const { - - return ptr()->isInfinite(); -} - -/** - * - */ -INLINE bool BulletShape:: -is_non_moving() const { - - return ptr()->isNonMoving(); -} - -/** - * - */ -INLINE bool BulletShape:: -is_soft_body() const { - - return ptr()->isSoftBody(); -} diff --git a/panda/src/bullet/bulletShape.cxx b/panda/src/bullet/bulletShape.cxx index daf8c1e623..49bd6e4f92 100644 --- a/panda/src/bullet/bulletShape.cxx +++ b/panda/src/bullet/bulletShape.cxx @@ -21,6 +21,7 @@ TypeHandle BulletShape::_type_handle; */ const char *BulletShape:: get_name() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return ptr()->getName(); } @@ -30,6 +31,7 @@ get_name() const { */ PN_stdfloat BulletShape:: get_margin() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return ptr()->getMargin(); } @@ -39,6 +41,7 @@ get_margin() const { */ void BulletShape:: set_margin(PN_stdfloat margin) { + LightMutexHolder holder(BulletWorld::get_global_lock()); ptr()->setMargin(margin); } @@ -48,18 +51,29 @@ set_margin(PN_stdfloat margin) { */ LVecBase3 BulletShape:: get_local_scale() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LVecBase3(ptr()->getLocalScaling()); } +/** + * Assumes the lock(bullet global lock) is held by the caller + */ +void BulletShape:: +do_set_local_scale(const LVecBase3 &scale) { + + nassertv(!scale.is_nan()); + ptr()->setLocalScaling(LVecBase3_to_btVector3(scale)); +} + /** * */ void BulletShape:: set_local_scale(const LVecBase3 &scale) { + LightMutexHolder holder(BulletWorld::get_global_lock()); - nassertv(!scale.is_nan()); - ptr()->setLocalScaling(LVecBase3_to_btVector3(scale)); + do_set_local_scale(scale); } /** @@ -67,6 +81,7 @@ set_local_scale(const LVecBase3 &scale) { */ BoundingSphere BulletShape:: get_shape_bounds() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); /* btTransform tr; @@ -87,3 +102,73 @@ cout << "origin " << aabbMin.x() << " " << aabbMin.y() << " " << aabbMin.z() << return bounds; } + +/** + * + */ +bool BulletShape:: +is_polyhedral() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return ptr()->isPolyhedral(); +} + +/** + * + */ +bool BulletShape:: +is_convex() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return ptr()->isConvex(); +} + +/** + * + */ +bool BulletShape:: +is_convex_2d() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return ptr()->isConvex2d(); +} + +/** + * + */ +bool BulletShape:: +is_concave() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return ptr()->isConcave(); +} + +/** + * + */ +bool BulletShape:: +is_infinite() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return ptr()->isInfinite(); +} + +/** + * + */ +bool BulletShape:: +is_non_moving() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return ptr()->isNonMoving(); +} + +/** + * + */ +bool BulletShape:: +is_soft_body() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return ptr()->isSoftBody(); +} diff --git a/panda/src/bullet/bulletShape.h b/panda/src/bullet/bulletShape.h index 8ebeaf9290..e9dd08bf14 100644 --- a/panda/src/bullet/bulletShape.h +++ b/panda/src/bullet/bulletShape.h @@ -31,13 +31,13 @@ protected: PUBLISHED: INLINE virtual ~BulletShape(); - INLINE bool is_polyhedral() const; - INLINE bool is_convex() const; - INLINE bool is_convex_2d() const; - INLINE bool is_concave() const; - INLINE bool is_infinite() const; - INLINE bool is_non_moving() const; - INLINE bool is_soft_body() const; + bool is_polyhedral() const; + bool is_convex() const; + bool is_convex_2d() const; + bool is_concave() const; + bool is_infinite() const; + bool is_non_moving() const; + bool is_soft_body() const; void set_margin(PN_stdfloat margin); const char *get_name() const; @@ -61,6 +61,7 @@ public: virtual btCollisionShape *ptr() const = 0; LVecBase3 get_local_scale() const; void set_local_scale(const LVecBase3 &scale); + void do_set_local_scale(const LVecBase3 &scale); public: static TypeHandle get_class_type() { diff --git a/panda/src/bullet/bulletSliderConstraint.I b/panda/src/bullet/bulletSliderConstraint.I index 4035f1399f..3eca50b143 100644 --- a/panda/src/bullet/bulletSliderConstraint.I +++ b/panda/src/bullet/bulletSliderConstraint.I @@ -19,21 +19,3 @@ INLINE BulletSliderConstraint:: delete _constraint; } - -/** - * - */ -INLINE CPT(TransformState) BulletSliderConstraint:: -get_frame_a() const { - - return btTrans_to_TransformState(_constraint->getFrameOffsetA()); -} - -/** - * - */ -INLINE CPT(TransformState) BulletSliderConstraint:: -get_frame_b() const { - - return btTrans_to_TransformState(_constraint->getFrameOffsetB()); -} diff --git a/panda/src/bullet/bulletSliderConstraint.cxx b/panda/src/bullet/bulletSliderConstraint.cxx index cda213b8c2..c803f509cd 100644 --- a/panda/src/bullet/bulletSliderConstraint.cxx +++ b/panda/src/bullet/bulletSliderConstraint.cxx @@ -65,6 +65,7 @@ ptr() const { */ PN_stdfloat BulletSliderConstraint:: get_lower_linear_limit() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_constraint->getLowerLinLimit(); } @@ -74,6 +75,7 @@ get_lower_linear_limit() const { */ PN_stdfloat BulletSliderConstraint:: get_upper_linear_limit() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_constraint->getUpperLinLimit(); } @@ -83,6 +85,7 @@ get_upper_linear_limit() const { */ PN_stdfloat BulletSliderConstraint:: get_lower_angular_limit() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return rad_2_deg(_constraint->getLowerAngLimit()); } @@ -92,6 +95,7 @@ get_lower_angular_limit() const { */ PN_stdfloat BulletSliderConstraint:: get_upper_angular_limit() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return rad_2_deg(_constraint->getUpperAngLimit()); } @@ -101,6 +105,7 @@ get_upper_angular_limit() const { */ void BulletSliderConstraint:: set_lower_linear_limit(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->setLowerLinLimit((btScalar)value); } @@ -110,6 +115,7 @@ set_lower_linear_limit(PN_stdfloat value) { */ void BulletSliderConstraint:: set_upper_linear_limit(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->setUpperLinLimit((btScalar)value); } @@ -119,6 +125,7 @@ set_upper_linear_limit(PN_stdfloat value) { */ void BulletSliderConstraint:: set_lower_angular_limit(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->setLowerAngLimit((btScalar)deg_2_rad(value)); } @@ -128,6 +135,7 @@ set_lower_angular_limit(PN_stdfloat value) { */ void BulletSliderConstraint:: set_upper_angular_limit(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->setUpperAngLimit((btScalar)deg_2_rad(value)); } @@ -137,6 +145,7 @@ set_upper_angular_limit(PN_stdfloat value) { */ PN_stdfloat BulletSliderConstraint:: get_linear_pos() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_constraint->getLinearPos(); } @@ -146,6 +155,7 @@ get_linear_pos() const { */ PN_stdfloat BulletSliderConstraint:: get_angular_pos() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_constraint->getAngularPos(); } @@ -155,6 +165,7 @@ get_angular_pos() const { */ void BulletSliderConstraint:: set_powered_linear_motor(bool on) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->setPoweredLinMotor(on); } @@ -164,6 +175,7 @@ set_powered_linear_motor(bool on) { */ void BulletSliderConstraint:: set_target_linear_motor_velocity(PN_stdfloat target_velocity) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->setTargetLinMotorVelocity((btScalar)target_velocity); } @@ -173,6 +185,7 @@ set_target_linear_motor_velocity(PN_stdfloat target_velocity) { */ void BulletSliderConstraint:: set_max_linear_motor_force(PN_stdfloat max_force) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->setMaxLinMotorForce((btScalar)max_force); } @@ -182,6 +195,7 @@ set_max_linear_motor_force(PN_stdfloat max_force) { */ bool BulletSliderConstraint:: get_powered_linear_motor() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _constraint->getPoweredLinMotor(); } @@ -191,6 +205,7 @@ get_powered_linear_motor() const { */ PN_stdfloat BulletSliderConstraint:: get_target_linear_motor_velocity() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_constraint->getTargetLinMotorVelocity(); } @@ -200,6 +215,7 @@ get_target_linear_motor_velocity() const { */ PN_stdfloat BulletSliderConstraint:: get_max_linear_motor_force() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_constraint->getMaxLinMotorForce(); } @@ -209,6 +225,7 @@ get_max_linear_motor_force() const { */ void BulletSliderConstraint:: set_powered_angular_motor(bool on) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->setPoweredAngMotor(on); } @@ -218,6 +235,7 @@ set_powered_angular_motor(bool on) { */ void BulletSliderConstraint:: set_target_angular_motor_velocity(PN_stdfloat target_velocity) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->setTargetAngMotorVelocity((btScalar)target_velocity); } @@ -227,6 +245,7 @@ set_target_angular_motor_velocity(PN_stdfloat target_velocity) { */ void BulletSliderConstraint:: set_max_angular_motor_force(PN_stdfloat max_force) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _constraint->setMaxAngMotorForce((btScalar)max_force); } @@ -236,6 +255,7 @@ set_max_angular_motor_force(PN_stdfloat max_force) { */ bool BulletSliderConstraint:: get_powered_angular_motor() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _constraint->getPoweredAngMotor(); } @@ -245,6 +265,7 @@ get_powered_angular_motor() const { */ PN_stdfloat BulletSliderConstraint:: get_target_angular_motor_velocity() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_constraint->getTargetAngMotorVelocity(); } @@ -254,6 +275,7 @@ get_target_angular_motor_velocity() const { */ PN_stdfloat BulletSliderConstraint:: get_max_angular_motor_force() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_constraint->getMaxAngMotorForce(); } @@ -263,9 +285,30 @@ get_max_angular_motor_force() const { */ void BulletSliderConstraint:: set_frames(const TransformState *ts_a, const TransformState *ts_b) { + LightMutexHolder holder(BulletWorld::get_global_lock()); btTransform frame_a = TransformState_to_btTrans(ts_a); btTransform frame_b = TransformState_to_btTrans(ts_b); _constraint->setFrames(frame_a, frame_b); } + +/** + * + */ +CPT(TransformState) BulletSliderConstraint:: +get_frame_a() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btTrans_to_TransformState(_constraint->getFrameOffsetA()); +} + +/** + * + */ +CPT(TransformState) BulletSliderConstraint:: +get_frame_b() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btTrans_to_TransformState(_constraint->getFrameOffsetB()); +} diff --git a/panda/src/bullet/bulletSliderConstraint.h b/panda/src/bullet/bulletSliderConstraint.h index 931e51ec80..6a670867c5 100644 --- a/panda/src/bullet/bulletSliderConstraint.h +++ b/panda/src/bullet/bulletSliderConstraint.h @@ -70,8 +70,8 @@ PUBLISHED: // Frames void set_frames(const TransformState *ts_a, const TransformState *ts_b); - INLINE CPT(TransformState) get_frame_a() const; - INLINE CPT(TransformState) get_frame_b() const; + CPT(TransformState) get_frame_a() const; + CPT(TransformState) get_frame_b() const; MAKE_PROPERTY(linear_pos, get_linear_pos); MAKE_PROPERTY(angular_pos, get_angular_pos); diff --git a/panda/src/bullet/bulletSoftBodyConfig.I b/panda/src/bullet/bulletSoftBodyConfig.I index eed9499bbb..dfd2b36514 100644 --- a/panda/src/bullet/bulletSoftBodyConfig.I +++ b/panda/src/bullet/bulletSoftBodyConfig.I @@ -18,439 +18,3 @@ INLINE BulletSoftBodyConfig:: ~BulletSoftBodyConfig() { } - -/** - * Getter for property kVCF. - */ -INLINE PN_stdfloat BulletSoftBodyConfig:: -get_velocities_correction_factor() const { - - return (PN_stdfloat)_cfg.kVCF; -} - -/** - * Setter for property kVCF. - */ -INLINE void BulletSoftBodyConfig:: -set_velocities_correction_factor(PN_stdfloat value) { - - _cfg.kVCF = (btScalar)value; -} - -/** - * Getter for property kDP. - */ -INLINE PN_stdfloat BulletSoftBodyConfig:: -get_damping_coefficient() const { - - return (PN_stdfloat)_cfg.kDP; -} - -/** - * Setter for property kDP. - */ -INLINE void BulletSoftBodyConfig:: -set_damping_coefficient(PN_stdfloat value) { - - _cfg.kDP = (btScalar)value; -} - -/** - * Getter for property kDG. - */ -INLINE PN_stdfloat BulletSoftBodyConfig:: -get_drag_coefficient() const { - - return (PN_stdfloat)_cfg.kDG; -} - -/** - * Setter for property kDG. - */ -INLINE void BulletSoftBodyConfig:: -set_drag_coefficient(PN_stdfloat value) { - - _cfg.kDG = (btScalar)value; -} - -/** - * Getter for property kLF. - */ -INLINE PN_stdfloat BulletSoftBodyConfig:: -get_lift_coefficient() const { - - return (PN_stdfloat)_cfg.kLF; -} - -/** - * Setter for property kLF. - */ -INLINE void BulletSoftBodyConfig:: -set_lift_coefficient(PN_stdfloat value) { - - _cfg.kLF = (btScalar)value; -} - -/** - * Getter for property kPR. - */ -INLINE PN_stdfloat BulletSoftBodyConfig:: -get_pressure_coefficient() const { - - return (PN_stdfloat)_cfg.kPR; -} - -/** - * Setter for property kPR. - */ -INLINE void BulletSoftBodyConfig:: -set_pressure_coefficient(PN_stdfloat value) { - - _cfg.kPR = (btScalar)value; -} - -/** - * Getter for property kVC. - */ -INLINE PN_stdfloat BulletSoftBodyConfig:: -get_volume_conservation_coefficient() const { - - return (PN_stdfloat)_cfg.kVC; -} - -/** - * Setter for property kVC. - */ -INLINE void BulletSoftBodyConfig:: -set_volume_conservation_coefficient(PN_stdfloat value) { - - _cfg.kVC = (btScalar)value; -} - -/** - * Getter for property kDF. - */ -INLINE PN_stdfloat BulletSoftBodyConfig:: -get_dynamic_friction_coefficient() const { - - return (PN_stdfloat)_cfg.kDF; -} - -/** - * Setter for property kDF. - */ -INLINE void BulletSoftBodyConfig:: -set_dynamic_friction_coefficient(PN_stdfloat value) { - - _cfg.kDF = (btScalar)value; -} - -/** - * Getter for property kMT. - */ -INLINE PN_stdfloat BulletSoftBodyConfig:: -get_pose_matching_coefficient() const { - - return (PN_stdfloat)_cfg.kMT; -} - -/** - * Setter for property kMT. - */ -INLINE void BulletSoftBodyConfig:: -set_pose_matching_coefficient(PN_stdfloat value) { - - _cfg.kMT = (btScalar)value; -} - -/** - * Getter for property kCHR. - */ -INLINE PN_stdfloat BulletSoftBodyConfig:: -get_rigid_contacts_hardness() const { - - return (PN_stdfloat)_cfg.kCHR; -} - -/** - * Setter for property kCHR. - */ -INLINE void BulletSoftBodyConfig:: -set_rigid_contacts_hardness(PN_stdfloat value) { - - _cfg.kCHR = (btScalar)value; -} - -/** - * Getter for property kKHR. - */ -INLINE PN_stdfloat BulletSoftBodyConfig:: -get_kinetic_contacts_hardness() const { - - return (PN_stdfloat)_cfg.kKHR; -} - -/** - * Setter for property kKHR. - */ -INLINE void BulletSoftBodyConfig:: -set_kinetic_contacts_hardness(PN_stdfloat value) { - - _cfg.kKHR = (btScalar)value; -} - -/** - * Getter for property kSHR. - */ -INLINE PN_stdfloat BulletSoftBodyConfig:: -get_soft_contacts_hardness() const { - - return (PN_stdfloat)_cfg.kSHR; -} - -/** - * Setter for property kSHR. - */ -INLINE void BulletSoftBodyConfig:: -set_soft_contacts_hardness(PN_stdfloat value) { - - _cfg.kSHR = (btScalar)value; -} - -/** - * Getter for property kAHR. - */ -INLINE PN_stdfloat BulletSoftBodyConfig:: -get_anchors_hardness() const { - - return (PN_stdfloat)_cfg.kAHR; -} - -/** - * Setter for property kAHR. - */ -INLINE void BulletSoftBodyConfig:: -set_anchors_hardness(PN_stdfloat value) { - - _cfg.kAHR = (btScalar)value; -} - -/** - * Getter for property kSRHR_CL. - */ -INLINE PN_stdfloat BulletSoftBodyConfig:: -get_soft_vs_rigid_hardness() const { - - return (PN_stdfloat)_cfg.kSRHR_CL; -} - -/** - * Setter for property kSRHR_CL. - */ -INLINE void BulletSoftBodyConfig:: -set_soft_vs_rigid_hardness(PN_stdfloat value) { - - _cfg.kSRHR_CL = (btScalar)value; -} - -/** - * Getter for property kSKHR_CL. - */ -INLINE PN_stdfloat BulletSoftBodyConfig:: -get_soft_vs_kinetic_hardness() const { - - return (PN_stdfloat)_cfg.kSKHR_CL; -} - -/** - * Setter for property kSKHR_CL. - */ -INLINE void BulletSoftBodyConfig:: -set_soft_vs_kinetic_hardness(PN_stdfloat value) { - - _cfg.kSKHR_CL = (btScalar)value; -} - -/** - * Getter for property kSSHR_CL. - */ -INLINE PN_stdfloat BulletSoftBodyConfig:: -get_soft_vs_soft_hardness() const { - - return (PN_stdfloat)_cfg.kSSHR_CL; -} - -/** - * Setter for property kSSHR_CL. - */ -INLINE void BulletSoftBodyConfig:: -set_soft_vs_soft_hardness(PN_stdfloat value) { - - _cfg.kSSHR_CL = (btScalar)value; -} - -/** - * Getter for property kSR_SPLT_CL. - */ -INLINE PN_stdfloat BulletSoftBodyConfig:: -get_soft_vs_rigid_impulse_split() const { - - return (PN_stdfloat)_cfg.kSR_SPLT_CL; -} - -/** - * Setter for property kSR_SPLT_CL. - */ -INLINE void BulletSoftBodyConfig:: -set_soft_vs_rigid_impulse_split(PN_stdfloat value) { - - _cfg.kSR_SPLT_CL = (btScalar)value; -} - -/** - * Getter for property kSK_SPLT_CL. - */ -INLINE PN_stdfloat BulletSoftBodyConfig:: -get_soft_vs_kinetic_impulse_split() const { - - return (PN_stdfloat)_cfg.kSK_SPLT_CL; -} - -/** - * Setter for property kSK_SPLT_CL. - */ -INLINE void BulletSoftBodyConfig:: -set_soft_vs_kinetic_impulse_split(PN_stdfloat value) { - - _cfg.kSK_SPLT_CL = (btScalar)value; -} - -/** - * Getter for property kSS_SPLT_CL. - */ -INLINE PN_stdfloat BulletSoftBodyConfig:: -get_soft_vs_soft_impulse_split() const { - - return (PN_stdfloat)_cfg.kSS_SPLT_CL; -} - -/** - * Setter for property kSS_SPLT_CL. - */ -INLINE void BulletSoftBodyConfig:: -set_soft_vs_soft_impulse_split(PN_stdfloat value) { - - _cfg.kSS_SPLT_CL = (btScalar)value; -} - -/** - * Getter for property maxvolume. - */ -INLINE PN_stdfloat BulletSoftBodyConfig:: -get_maxvolume() const { - - return (PN_stdfloat)_cfg.maxvolume; -} - -/** - * Setter for property maxvolume. - */ -INLINE void BulletSoftBodyConfig:: -set_maxvolume(PN_stdfloat value) { - - _cfg.maxvolume = (btScalar)value; -} - -/** - * Getter for property timescale. - */ -INLINE PN_stdfloat BulletSoftBodyConfig:: -get_timescale() const { - - return (PN_stdfloat)_cfg.timescale; -} - -/** - * Setter for property timescale. - */ -INLINE void BulletSoftBodyConfig:: -set_timescale(PN_stdfloat value) { - - _cfg.timescale = (btScalar)value; -} - -/** - * Getter for property piterations. - */ -INLINE int BulletSoftBodyConfig:: -get_positions_solver_iterations() const { - - return _cfg.piterations; -} - -/** - * Setter for property piterations. - */ -INLINE void BulletSoftBodyConfig:: -set_positions_solver_iterations(int value) { - - nassertv(value > 0); - _cfg.piterations = value; -} - -/** - * Getter for property viterations. - */ -INLINE int BulletSoftBodyConfig:: -get_velocities_solver_iterations() const { - - return _cfg.viterations; -} - -/** - * Setter for property viterations. - */ -INLINE void BulletSoftBodyConfig:: -set_velocities_solver_iterations(int value) { - - nassertv(value > 0); - _cfg.viterations = value; -} - -/** - * Getter for property diterations. - */ -INLINE int BulletSoftBodyConfig:: -get_drift_solver_iterations() const { - - return _cfg.diterations; -} - -/** - * Setter for property diterations. - */ -INLINE void BulletSoftBodyConfig:: -set_drift_solver_iterations(int value) { - - nassertv(value > 0); - _cfg.diterations = value; -} - -/** - * Getter for property citerations. - */ -INLINE int BulletSoftBodyConfig:: -get_cluster_solver_iterations() const { - - return _cfg.citerations; -} - -/** - * Setter for property citerations. - */ -INLINE void BulletSoftBodyConfig:: -set_cluster_solver_iterations(int value) { - - nassertv(value > 0); - _cfg.citerations = value; -} diff --git a/panda/src/bullet/bulletSoftBodyConfig.cxx b/panda/src/bullet/bulletSoftBodyConfig.cxx index dc12fde309..a6db77cb96 100644 --- a/panda/src/bullet/bulletSoftBodyConfig.cxx +++ b/panda/src/bullet/bulletSoftBodyConfig.cxx @@ -26,6 +26,7 @@ BulletSoftBodyConfig(btSoftBody::Config &cfg) : _cfg(cfg) { */ void BulletSoftBodyConfig:: clear_all_collision_flags() { + LightMutexHolder holder(BulletWorld::get_global_lock()); _cfg.collisions = 0; } @@ -35,6 +36,7 @@ clear_all_collision_flags() { */ void BulletSoftBodyConfig:: set_collision_flag(CollisionFlag flag, bool value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); if (value == true) { _cfg.collisions |= flag; @@ -49,6 +51,7 @@ set_collision_flag(CollisionFlag flag, bool value) { */ bool BulletSoftBodyConfig:: get_collision_flag(CollisionFlag flag) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (_cfg.collisions & flag) ? true : false; } @@ -58,6 +61,7 @@ get_collision_flag(CollisionFlag flag) const { */ void BulletSoftBodyConfig:: set_aero_model(AeroModel value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _cfg.aeromodel = (btSoftBody::eAeroModel::_)value; } @@ -67,6 +71,491 @@ set_aero_model(AeroModel value) { */ BulletSoftBodyConfig::AeroModel BulletSoftBodyConfig:: get_aero_model() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (AeroModel)_cfg.aeromodel; } + +/** + * Getter for property kVCF. + */ +PN_stdfloat BulletSoftBodyConfig:: +get_velocities_correction_factor() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_cfg.kVCF; +} + +/** + * Setter for property kVCF. + */ +void BulletSoftBodyConfig:: +set_velocities_correction_factor(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _cfg.kVCF = (btScalar)value; +} + +/** + * Getter for property kDP. + */ +PN_stdfloat BulletSoftBodyConfig:: +get_damping_coefficient() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_cfg.kDP; +} + +/** + * Setter for property kDP. + */ +void BulletSoftBodyConfig:: +set_damping_coefficient(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _cfg.kDP = (btScalar)value; +} + +/** + * Getter for property kDG. + */ +PN_stdfloat BulletSoftBodyConfig:: +get_drag_coefficient() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_cfg.kDG; +} + +/** + * Setter for property kDG. + */ +void BulletSoftBodyConfig:: +set_drag_coefficient(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _cfg.kDG = (btScalar)value; +} + +/** + * Getter for property kLF. + */ +PN_stdfloat BulletSoftBodyConfig:: +get_lift_coefficient() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_cfg.kLF; +} + +/** + * Setter for property kLF. + */ +void BulletSoftBodyConfig:: +set_lift_coefficient(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _cfg.kLF = (btScalar)value; +} + +/** + * Getter for property kPR. + */ +PN_stdfloat BulletSoftBodyConfig:: +get_pressure_coefficient() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_cfg.kPR; +} + +/** + * Setter for property kPR. + */ +void BulletSoftBodyConfig:: +set_pressure_coefficient(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _cfg.kPR = (btScalar)value; +} + +/** + * Getter for property kVC. + */ +PN_stdfloat BulletSoftBodyConfig:: +get_volume_conservation_coefficient() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_cfg.kVC; +} + +/** + * Setter for property kVC. + */ +void BulletSoftBodyConfig:: +set_volume_conservation_coefficient(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _cfg.kVC = (btScalar)value; +} + +/** + * Getter for property kDF. + */ +PN_stdfloat BulletSoftBodyConfig:: +get_dynamic_friction_coefficient() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_cfg.kDF; +} + +/** + * Setter for property kDF. + */ +void BulletSoftBodyConfig:: +set_dynamic_friction_coefficient(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _cfg.kDF = (btScalar)value; +} + +/** + * Getter for property kMT. + */ +PN_stdfloat BulletSoftBodyConfig:: +get_pose_matching_coefficient() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_cfg.kMT; +} + +/** + * Setter for property kMT. + */ +void BulletSoftBodyConfig:: +set_pose_matching_coefficient(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _cfg.kMT = (btScalar)value; +} + +/** + * Getter for property kCHR. + */ +PN_stdfloat BulletSoftBodyConfig:: +get_rigid_contacts_hardness() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_cfg.kCHR; +} + +/** + * Setter for property kCHR. + */ +void BulletSoftBodyConfig:: +set_rigid_contacts_hardness(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _cfg.kCHR = (btScalar)value; +} + +/** + * Getter for property kKHR. + */ +PN_stdfloat BulletSoftBodyConfig:: +get_kinetic_contacts_hardness() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_cfg.kKHR; +} + +/** + * Setter for property kKHR. + */ +void BulletSoftBodyConfig:: +set_kinetic_contacts_hardness(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _cfg.kKHR = (btScalar)value; +} + +/** + * Getter for property kSHR. + */ +PN_stdfloat BulletSoftBodyConfig:: +get_soft_contacts_hardness() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_cfg.kSHR; +} + +/** + * Setter for property kSHR. + */ +void BulletSoftBodyConfig:: +set_soft_contacts_hardness(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _cfg.kSHR = (btScalar)value; +} + +/** + * Getter for property kAHR. + */ +PN_stdfloat BulletSoftBodyConfig:: +get_anchors_hardness() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_cfg.kAHR; +} + +/** + * Setter for property kAHR. + */ +void BulletSoftBodyConfig:: +set_anchors_hardness(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _cfg.kAHR = (btScalar)value; +} + +/** + * Getter for property kSRHR_CL. + */ +PN_stdfloat BulletSoftBodyConfig:: +get_soft_vs_rigid_hardness() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_cfg.kSRHR_CL; +} + +/** + * Setter for property kSRHR_CL. + */ +void BulletSoftBodyConfig:: +set_soft_vs_rigid_hardness(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _cfg.kSRHR_CL = (btScalar)value; +} + +/** + * Getter for property kSKHR_CL. + */ +PN_stdfloat BulletSoftBodyConfig:: +get_soft_vs_kinetic_hardness() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_cfg.kSKHR_CL; +} + +/** + * Setter for property kSKHR_CL. + */ +void BulletSoftBodyConfig:: +set_soft_vs_kinetic_hardness(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _cfg.kSKHR_CL = (btScalar)value; +} + +/** + * Getter for property kSSHR_CL. + */ +PN_stdfloat BulletSoftBodyConfig:: +get_soft_vs_soft_hardness() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_cfg.kSSHR_CL; +} + +/** + * Setter for property kSSHR_CL. + */ +void BulletSoftBodyConfig:: +set_soft_vs_soft_hardness(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _cfg.kSSHR_CL = (btScalar)value; +} + +/** + * Getter for property kSR_SPLT_CL. + */ +PN_stdfloat BulletSoftBodyConfig:: +get_soft_vs_rigid_impulse_split() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_cfg.kSR_SPLT_CL; +} + +/** + * Setter for property kSR_SPLT_CL. + */ +void BulletSoftBodyConfig:: +set_soft_vs_rigid_impulse_split(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _cfg.kSR_SPLT_CL = (btScalar)value; +} + +/** + * Getter for property kSK_SPLT_CL. + */ +PN_stdfloat BulletSoftBodyConfig:: +get_soft_vs_kinetic_impulse_split() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_cfg.kSK_SPLT_CL; +} + +/** + * Setter for property kSK_SPLT_CL. + */ +void BulletSoftBodyConfig:: +set_soft_vs_kinetic_impulse_split(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _cfg.kSK_SPLT_CL = (btScalar)value; +} + +/** + * Getter for property kSS_SPLT_CL. + */ +PN_stdfloat BulletSoftBodyConfig:: +get_soft_vs_soft_impulse_split() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_cfg.kSS_SPLT_CL; +} + +/** + * Setter for property kSS_SPLT_CL. + */ +void BulletSoftBodyConfig:: +set_soft_vs_soft_impulse_split(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _cfg.kSS_SPLT_CL = (btScalar)value; +} + +/** + * Getter for property maxvolume. + */ +PN_stdfloat BulletSoftBodyConfig:: +get_maxvolume() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_cfg.maxvolume; +} + +/** + * Setter for property maxvolume. + */ +void BulletSoftBodyConfig:: +set_maxvolume(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _cfg.maxvolume = (btScalar)value; +} + +/** + * Getter for property timescale. + */ +PN_stdfloat BulletSoftBodyConfig:: +get_timescale() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_cfg.timescale; +} + +/** + * Setter for property timescale. + */ +void BulletSoftBodyConfig:: +set_timescale(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _cfg.timescale = (btScalar)value; +} + +/** + * Getter for property piterations. + */ +int BulletSoftBodyConfig:: +get_positions_solver_iterations() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return _cfg.piterations; +} + +/** + * Setter for property piterations. + */ +void BulletSoftBodyConfig:: +set_positions_solver_iterations(int value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + nassertv(value > 0); + _cfg.piterations = value; +} + +/** + * Getter for property viterations. + */ +int BulletSoftBodyConfig:: +get_velocities_solver_iterations() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return _cfg.viterations; +} + +/** + * Setter for property viterations. + */ +void BulletSoftBodyConfig:: +set_velocities_solver_iterations(int value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + nassertv(value > 0); + _cfg.viterations = value; +} + +/** + * Getter for property diterations. + */ +int BulletSoftBodyConfig:: +get_drift_solver_iterations() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return _cfg.diterations; +} + +/** + * Setter for property diterations. + */ +void BulletSoftBodyConfig:: +set_drift_solver_iterations(int value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + nassertv(value > 0); + _cfg.diterations = value; +} + +/** + * Getter for property citerations. + */ +int BulletSoftBodyConfig:: +get_cluster_solver_iterations() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return _cfg.citerations; +} + +/** + * Setter for property citerations. + */ +void BulletSoftBodyConfig:: +set_cluster_solver_iterations(int value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + nassertv(value > 0); + _cfg.citerations = value; +} diff --git a/panda/src/bullet/bulletSoftBodyConfig.h b/panda/src/bullet/bulletSoftBodyConfig.h index 2411797146..18bbd49dfa 100644 --- a/panda/src/bullet/bulletSoftBodyConfig.h +++ b/panda/src/bullet/bulletSoftBodyConfig.h @@ -51,55 +51,55 @@ PUBLISHED: void set_aero_model(AeroModel value); AeroModel get_aero_model() const; - INLINE void set_velocities_correction_factor(PN_stdfloat value); - INLINE void set_damping_coefficient(PN_stdfloat value); - INLINE void set_drag_coefficient(PN_stdfloat value); - INLINE void set_lift_coefficient(PN_stdfloat value); - INLINE void set_pressure_coefficient(PN_stdfloat value); - INLINE void set_volume_conservation_coefficient(PN_stdfloat value); - INLINE void set_dynamic_friction_coefficient(PN_stdfloat value); - INLINE void set_pose_matching_coefficient(PN_stdfloat value); - INLINE void set_rigid_contacts_hardness(PN_stdfloat value); - INLINE void set_kinetic_contacts_hardness(PN_stdfloat value); - INLINE void set_soft_contacts_hardness(PN_stdfloat value); - INLINE void set_anchors_hardness(PN_stdfloat value); - INLINE void set_soft_vs_rigid_hardness(PN_stdfloat value); - INLINE void set_soft_vs_kinetic_hardness(PN_stdfloat value); - INLINE void set_soft_vs_soft_hardness(PN_stdfloat value); - INLINE void set_soft_vs_rigid_impulse_split(PN_stdfloat value); - INLINE void set_soft_vs_kinetic_impulse_split(PN_stdfloat value); - INLINE void set_soft_vs_soft_impulse_split(PN_stdfloat value); - INLINE void set_maxvolume(PN_stdfloat value); - INLINE void set_timescale(PN_stdfloat value); - INLINE void set_positions_solver_iterations(int value); - INLINE void set_velocities_solver_iterations(int value); - INLINE void set_drift_solver_iterations( int value); - INLINE void set_cluster_solver_iterations(int value); + void set_velocities_correction_factor(PN_stdfloat value); + void set_damping_coefficient(PN_stdfloat value); + void set_drag_coefficient(PN_stdfloat value); + void set_lift_coefficient(PN_stdfloat value); + void set_pressure_coefficient(PN_stdfloat value); + void set_volume_conservation_coefficient(PN_stdfloat value); + void set_dynamic_friction_coefficient(PN_stdfloat value); + void set_pose_matching_coefficient(PN_stdfloat value); + void set_rigid_contacts_hardness(PN_stdfloat value); + void set_kinetic_contacts_hardness(PN_stdfloat value); + void set_soft_contacts_hardness(PN_stdfloat value); + void set_anchors_hardness(PN_stdfloat value); + void set_soft_vs_rigid_hardness(PN_stdfloat value); + void set_soft_vs_kinetic_hardness(PN_stdfloat value); + void set_soft_vs_soft_hardness(PN_stdfloat value); + void set_soft_vs_rigid_impulse_split(PN_stdfloat value); + void set_soft_vs_kinetic_impulse_split(PN_stdfloat value); + void set_soft_vs_soft_impulse_split(PN_stdfloat value); + void set_maxvolume(PN_stdfloat value); + void set_timescale(PN_stdfloat value); + void set_positions_solver_iterations(int value); + void set_velocities_solver_iterations(int value); + void set_drift_solver_iterations( int value); + void set_cluster_solver_iterations(int value); - INLINE PN_stdfloat get_velocities_correction_factor() const; - INLINE PN_stdfloat get_damping_coefficient() const; - INLINE PN_stdfloat get_drag_coefficient() const; - INLINE PN_stdfloat get_lift_coefficient() const; - INLINE PN_stdfloat get_pressure_coefficient() const; - INLINE PN_stdfloat get_volume_conservation_coefficient() const; - INLINE PN_stdfloat get_dynamic_friction_coefficient() const; - INLINE PN_stdfloat get_pose_matching_coefficient() const; - INLINE PN_stdfloat get_rigid_contacts_hardness() const; - INLINE PN_stdfloat get_kinetic_contacts_hardness() const; - INLINE PN_stdfloat get_soft_contacts_hardness() const; - INLINE PN_stdfloat get_anchors_hardness() const; - INLINE PN_stdfloat get_soft_vs_rigid_hardness() const; - INLINE PN_stdfloat get_soft_vs_kinetic_hardness() const; - INLINE PN_stdfloat get_soft_vs_soft_hardness() const; - INLINE PN_stdfloat get_soft_vs_rigid_impulse_split() const; - INLINE PN_stdfloat get_soft_vs_kinetic_impulse_split() const; - INLINE PN_stdfloat get_soft_vs_soft_impulse_split() const; - INLINE PN_stdfloat get_maxvolume() const; - INLINE PN_stdfloat get_timescale() const; - INLINE int get_positions_solver_iterations() const; - INLINE int get_velocities_solver_iterations() const; - INLINE int get_drift_solver_iterations() const; - INLINE int get_cluster_solver_iterations() const; + PN_stdfloat get_velocities_correction_factor() const; + PN_stdfloat get_damping_coefficient() const; + PN_stdfloat get_drag_coefficient() const; + PN_stdfloat get_lift_coefficient() const; + PN_stdfloat get_pressure_coefficient() const; + PN_stdfloat get_volume_conservation_coefficient() const; + PN_stdfloat get_dynamic_friction_coefficient() const; + PN_stdfloat get_pose_matching_coefficient() const; + PN_stdfloat get_rigid_contacts_hardness() const; + PN_stdfloat get_kinetic_contacts_hardness() const; + PN_stdfloat get_soft_contacts_hardness() const; + PN_stdfloat get_anchors_hardness() const; + PN_stdfloat get_soft_vs_rigid_hardness() const; + PN_stdfloat get_soft_vs_kinetic_hardness() const; + PN_stdfloat get_soft_vs_soft_hardness() const; + PN_stdfloat get_soft_vs_rigid_impulse_split() const; + PN_stdfloat get_soft_vs_kinetic_impulse_split() const; + PN_stdfloat get_soft_vs_soft_impulse_split() const; + PN_stdfloat get_maxvolume() const; + PN_stdfloat get_timescale() const; + int get_positions_solver_iterations() const; + int get_velocities_solver_iterations() const; + int get_drift_solver_iterations() const; + int get_cluster_solver_iterations() const; MAKE_PROPERTY(aero_model, get_aero_model, set_aero_model); MAKE_PROPERTY(velocities_correction_factor, get_velocities_correction_factor, set_velocities_correction_factor); diff --git a/panda/src/bullet/bulletSoftBodyMaterial.I b/panda/src/bullet/bulletSoftBodyMaterial.I index ff8182f6ed..7514fc7cbf 100644 --- a/panda/src/bullet/bulletSoftBodyMaterial.I +++ b/panda/src/bullet/bulletSoftBodyMaterial.I @@ -30,66 +30,3 @@ empty() { return BulletSoftBodyMaterial(material); } - -/** - * - */ -INLINE btSoftBody::Material &BulletSoftBodyMaterial:: -get_material() const { - - return _material; -} - -/** - * Getter for the property m_kLST. - */ -INLINE PN_stdfloat BulletSoftBodyMaterial:: -get_linear_stiffness() const { - - return (PN_stdfloat)_material.m_kLST; -} - -/** - * Setter for the property m_kLST. - */ -INLINE void BulletSoftBodyMaterial:: -set_linear_stiffness(PN_stdfloat value) { - - _material.m_kLST = (btScalar)value; -} - -/** - * Getter for the property m_kAST. - */ -INLINE PN_stdfloat BulletSoftBodyMaterial:: -get_angular_stiffness() const { - - return (PN_stdfloat)_material.m_kAST; -} - -/** - * Setter for the property m_kAST. - */ -INLINE void BulletSoftBodyMaterial:: -set_angular_stiffness(PN_stdfloat value) { - - _material.m_kAST = (btScalar)value; -} - -/** - * Getter for the property m_kVST. - */ -INLINE PN_stdfloat BulletSoftBodyMaterial:: -get_volume_preservation() const { - - return (PN_stdfloat)_material.m_kVST; -} - -/** - * Setter for the property m_kVST. - */ -INLINE void BulletSoftBodyMaterial:: -set_volume_preservation(PN_stdfloat value) { - - _material.m_kVST = (btScalar)value; -} diff --git a/panda/src/bullet/bulletSoftBodyMaterial.cxx b/panda/src/bullet/bulletSoftBodyMaterial.cxx index 1767513a27..d40a7bd984 100644 --- a/panda/src/bullet/bulletSoftBodyMaterial.cxx +++ b/panda/src/bullet/bulletSoftBodyMaterial.cxx @@ -20,3 +20,72 @@ BulletSoftBodyMaterial:: BulletSoftBodyMaterial(btSoftBody::Material &material) : _material(material) { } + +/** + * + */ +btSoftBody::Material &BulletSoftBodyMaterial:: +get_material() const { + + return _material; +} + +/** + * Getter for the property m_kLST. + */ +PN_stdfloat BulletSoftBodyMaterial:: +get_linear_stiffness() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_material.m_kLST; +} + +/** + * Setter for the property m_kLST. + */ +void BulletSoftBodyMaterial:: +set_linear_stiffness(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _material.m_kLST = (btScalar)value; +} + +/** + * Getter for the property m_kAST. + */ +PN_stdfloat BulletSoftBodyMaterial:: +get_angular_stiffness() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_material.m_kAST; +} + +/** + * Setter for the property m_kAST. + */ +void BulletSoftBodyMaterial:: +set_angular_stiffness(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _material.m_kAST = (btScalar)value; +} + +/** + * Getter for the property m_kVST. + */ +PN_stdfloat BulletSoftBodyMaterial:: +get_volume_preservation() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_material.m_kVST; +} + +/** + * Setter for the property m_kVST. + */ +void BulletSoftBodyMaterial:: +set_volume_preservation(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _material.m_kVST = (btScalar)value; +} diff --git a/panda/src/bullet/bulletSoftBodyMaterial.h b/panda/src/bullet/bulletSoftBodyMaterial.h index 3f1c07a7aa..bf8c8589a9 100644 --- a/panda/src/bullet/bulletSoftBodyMaterial.h +++ b/panda/src/bullet/bulletSoftBodyMaterial.h @@ -27,14 +27,14 @@ PUBLISHED: INLINE ~BulletSoftBodyMaterial(); INLINE static BulletSoftBodyMaterial empty(); - INLINE PN_stdfloat get_linear_stiffness() const; - INLINE void set_linear_stiffness(PN_stdfloat value); + PN_stdfloat get_linear_stiffness() const; + void set_linear_stiffness(PN_stdfloat value); - INLINE PN_stdfloat get_angular_stiffness() const; - INLINE void set_angular_stiffness(PN_stdfloat value); - - INLINE PN_stdfloat get_volume_preservation() const; - INLINE void set_volume_preservation(PN_stdfloat value); + PN_stdfloat get_angular_stiffness() const; + void set_angular_stiffness(PN_stdfloat value); + + PN_stdfloat get_volume_preservation() const; + void set_volume_preservation(PN_stdfloat value); MAKE_PROPERTY(linear_stiffness, get_linear_stiffness, set_linear_stiffness); MAKE_PROPERTY(angular_stiffness, get_angular_stiffness, set_angular_stiffness); diff --git a/panda/src/bullet/bulletSoftBodyNode.I b/panda/src/bullet/bulletSoftBodyNode.I index 086c3396e7..6a60de43f1 100644 --- a/panda/src/bullet/bulletSoftBodyNode.I +++ b/panda/src/bullet/bulletSoftBodyNode.I @@ -40,56 +40,3 @@ empty() { return BulletSoftBodyNodeElement(node); } -/** - * - */ -INLINE LPoint3 BulletSoftBodyNodeElement:: -get_pos() const { - - return btVector3_to_LPoint3(_node.m_x); -} - -/** - * - */ -INLINE LVector3 BulletSoftBodyNodeElement:: -get_normal() const { - - return btVector3_to_LVector3(_node.m_n); -} - -/** - * - */ -INLINE LVector3 BulletSoftBodyNodeElement:: -get_velocity() const { - - return btVector3_to_LVector3(_node.m_v); -} - -/** - * - */ -INLINE PN_stdfloat BulletSoftBodyNodeElement:: -get_inv_mass() const { - - return (PN_stdfloat)_node.m_im; -} - -/** - * - */ -INLINE PN_stdfloat BulletSoftBodyNodeElement:: -get_area() const { - - return (PN_stdfloat)_node.m_area; -} - -/** - * - */ -INLINE int BulletSoftBodyNodeElement:: -is_attached() const { - - return (PN_stdfloat)_node.m_battach; -} diff --git a/panda/src/bullet/bulletSoftBodyNode.cxx b/panda/src/bullet/bulletSoftBodyNode.cxx index 1d5a70d93f..c4094af652 100644 --- a/panda/src/bullet/bulletSoftBodyNode.cxx +++ b/panda/src/bullet/bulletSoftBodyNode.cxx @@ -66,6 +66,7 @@ get_object() const { */ BulletSoftBodyConfig BulletSoftBodyNode:: get_cfg() { + LightMutexHolder holder(BulletWorld::get_global_lock()); return BulletSoftBodyConfig(_soft->m_cfg); } @@ -75,6 +76,7 @@ get_cfg() { */ BulletSoftBodyWorldInfo BulletSoftBodyNode:: get_world_info() { + LightMutexHolder holder(BulletWorld::get_global_lock()); return BulletSoftBodyWorldInfo(*(_soft->m_worldInfo)); } @@ -84,6 +86,7 @@ get_world_info() { */ int BulletSoftBodyNode:: get_num_materials() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _soft->m_materials.size(); } @@ -93,8 +96,9 @@ get_num_materials() const { */ BulletSoftBodyMaterial BulletSoftBodyNode:: get_material(int idx) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); - nassertr(idx >= 0 && idx < get_num_materials(), BulletSoftBodyMaterial::empty()); + nassertr(idx >= 0 && idx < _soft->m_materials.size(), BulletSoftBodyMaterial::empty()); btSoftBody::Material *material = _soft->m_materials[idx]; return BulletSoftBodyMaterial(*material); @@ -105,6 +109,7 @@ get_material(int idx) const { */ BulletSoftBodyMaterial BulletSoftBodyNode:: append_material() { + LightMutexHolder holder(BulletWorld::get_global_lock()); btSoftBody::Material *material = _soft->appendMaterial(); nassertr(material, BulletSoftBodyMaterial::empty()); @@ -117,6 +122,7 @@ append_material() { */ int BulletSoftBodyNode:: get_num_nodes() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _soft->m_nodes.size(); } @@ -126,6 +132,7 @@ get_num_nodes() const { */ BulletSoftBodyNodeElement BulletSoftBodyNode:: get_node(int idx) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertr(idx >=0 && idx < get_num_nodes(), BulletSoftBodyNodeElement::empty()); return BulletSoftBodyNodeElement(_soft->m_nodes[idx]); @@ -136,6 +143,7 @@ get_node(int idx) const { */ void BulletSoftBodyNode:: generate_bending_constraints(int distance, BulletSoftBodyMaterial *material) { + LightMutexHolder holder(BulletWorld::get_global_lock()); if (material) { _soft->generateBendingConstraints(distance, &(material->get_material())); @@ -150,6 +158,7 @@ generate_bending_constraints(int distance, BulletSoftBodyMaterial *material) { */ void BulletSoftBodyNode:: randomize_constraints() { + LightMutexHolder holder(BulletWorld::get_global_lock()); _soft->randomizeConstraints(); } @@ -159,9 +168,10 @@ randomize_constraints() { */ void BulletSoftBodyNode:: transform_changed() { - if (_sync_disable) return; + LightMutexHolder holder(BulletWorld::get_global_lock()); + NodePath np = NodePath::any_path((PandaNode *)this); CPT(TransformState) ts = np.get_net_transform(); @@ -174,7 +184,7 @@ transform_changed() { btTransform trans = TransformState_to_btTrans(ts); // Offset between current approx center and current initial transform - btVector3 pos = LVecBase3_to_btVector3(this->get_aabb().get_approx_center()); + btVector3 pos = LVecBase3_to_btVector3(this->do_get_aabb().get_approx_center()); btVector3 origin = _soft->m_initialWorldTransform.getOrigin(); btVector3 offset = pos - origin; @@ -205,16 +215,16 @@ transform_changed() { * */ void BulletSoftBodyNode:: -sync_p2b() { +do_sync_p2b() { // transform_changed(); Disabled for now... } /** - * + * Assumes the lock(bullet global lock) is held by the caller */ void BulletSoftBodyNode:: -sync_b2p() { +do_sync_b2p() { // Render softbody if (_geom) { @@ -266,7 +276,7 @@ sync_b2p() { // Update the synchronized transform with the current approximate center of // the soft body - LVecBase3 pos = this->get_aabb().get_approx_center(); + LVecBase3 pos = this->do_get_aabb().get_approx_center(); CPT(TransformState) ts = TransformState::make_pos(pos); NodePath np = NodePath::any_path((PandaNode *)this); @@ -291,6 +301,19 @@ sync_b2p() { */ int BulletSoftBodyNode:: get_closest_node_index(LVecBase3 point, bool local) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return do_get_closest_node_index(point, local); +} + +/** + * Returns the index of the node which is closest to the given point. The + * distance between each node and the given point is computed in world space + * if local=false, and in local space if local=true. + * Assumes the lock(bullet global lock) is held by the caller + */ +int BulletSoftBodyNode:: +do_get_closest_node_index(LVecBase3 point, bool local) { btScalar max_dist_sqr = 1e30; btVector3 point_x = LVecBase3_to_btVector3(point); @@ -322,11 +345,12 @@ get_closest_node_index(LVecBase3 point, bool local) { */ void BulletSoftBodyNode:: link_geom(Geom *geom) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(geom->get_vertex_data()->has_column(InternalName::get_vertex())); nassertv(geom->get_vertex_data()->has_column(InternalName::get_normal())); - sync_p2b(); + do_sync_p2b(); _geom = geom; @@ -349,7 +373,7 @@ link_geom(Geom *geom) { while (!vertices.is_at_end()) { LVecBase3 point = vertices.get_data3(); - int node_idx = get_closest_node_index(point, true); + int node_idx = do_get_closest_node_index(point, true); indices.set_data1i(node_idx); } } @@ -359,6 +383,7 @@ link_geom(Geom *geom) { */ void BulletSoftBodyNode:: unlink_geom() { + LightMutexHolder holder(BulletWorld::get_global_lock()); _geom = NULL; } @@ -368,6 +393,7 @@ unlink_geom() { */ void BulletSoftBodyNode:: link_curve(NurbsCurveEvaluator *curve) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(curve->get_num_vertices() == _soft->m_nodes.size()); @@ -379,6 +405,7 @@ link_curve(NurbsCurveEvaluator *curve) { */ void BulletSoftBodyNode:: unlink_curve() { + LightMutexHolder holder(BulletWorld::get_global_lock()); _curve = NULL; } @@ -388,6 +415,7 @@ unlink_curve() { */ void BulletSoftBodyNode:: link_surface(NurbsSurfaceEvaluator *surface) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(surface->get_num_u_vertices() * surface->get_num_v_vertices() == _soft->m_nodes.size()); @@ -399,6 +427,7 @@ link_surface(NurbsSurfaceEvaluator *surface) { */ void BulletSoftBodyNode:: unlink_surface() { + LightMutexHolder holder(BulletWorld::get_global_lock()); _surface = NULL; } @@ -408,6 +437,16 @@ unlink_surface() { */ BoundingBox BulletSoftBodyNode:: get_aabb() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return do_get_aabb(); +} + +/** + * + */ +BoundingBox BulletSoftBodyNode:: +do_get_aabb() const { btVector3 pMin; btVector3 pMax; @@ -425,6 +464,7 @@ get_aabb() const { */ void BulletSoftBodyNode:: set_volume_mass(PN_stdfloat mass) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _soft->setVolumeMass(mass); } @@ -434,6 +474,7 @@ set_volume_mass(PN_stdfloat mass) { */ void BulletSoftBodyNode:: set_total_mass(PN_stdfloat mass, bool fromfaces) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _soft->setTotalMass(mass, fromfaces); } @@ -443,6 +484,7 @@ set_total_mass(PN_stdfloat mass, bool fromfaces) { */ void BulletSoftBodyNode:: set_volume_density(PN_stdfloat density) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _soft->setVolumeDensity(density); } @@ -452,6 +494,7 @@ set_volume_density(PN_stdfloat density) { */ void BulletSoftBodyNode:: set_total_density(PN_stdfloat density) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _soft->setTotalDensity(density); } @@ -461,6 +504,7 @@ set_total_density(PN_stdfloat density) { */ void BulletSoftBodyNode:: set_mass(int node, PN_stdfloat mass) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _soft->setMass(node, mass); } @@ -470,6 +514,7 @@ set_mass(int node, PN_stdfloat mass) { */ PN_stdfloat BulletSoftBodyNode:: get_mass(int node) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _soft->getMass(node); } @@ -479,6 +524,7 @@ get_mass(int node) const { */ PN_stdfloat BulletSoftBodyNode:: get_total_mass() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _soft->getTotalMass(); } @@ -488,6 +534,7 @@ get_total_mass() const { */ PN_stdfloat BulletSoftBodyNode:: get_volume() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _soft->getVolume(); } @@ -497,6 +544,7 @@ get_volume() const { */ void BulletSoftBodyNode:: add_force(const LVector3 &force) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(!force.is_nan()); _soft->addForce(LVecBase3_to_btVector3(force)); @@ -507,6 +555,7 @@ add_force(const LVector3 &force) { */ void BulletSoftBodyNode:: add_force(const LVector3 &force, int node) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(!force.is_nan()); _soft->addForce(LVecBase3_to_btVector3(force), node); @@ -517,6 +566,7 @@ add_force(const LVector3 &force, int node) { */ void BulletSoftBodyNode:: set_velocity(const LVector3 &velocity) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(!velocity.is_nan()); _soft->setVelocity(LVecBase3_to_btVector3(velocity)); @@ -527,6 +577,7 @@ set_velocity(const LVector3 &velocity) { */ void BulletSoftBodyNode:: add_velocity(const LVector3 &velocity) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(!velocity.is_nan()); _soft->addVelocity(LVecBase3_to_btVector3(velocity)); @@ -537,6 +588,7 @@ add_velocity(const LVector3 &velocity) { */ void BulletSoftBodyNode:: add_velocity(const LVector3 &velocity, int node) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(!velocity.is_nan()); _soft->addVelocity(LVecBase3_to_btVector3(velocity), node); @@ -547,6 +599,7 @@ add_velocity(const LVector3 &velocity, int node) { */ void BulletSoftBodyNode:: generate_clusters(int k, int maxiterations) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _soft->generateClusters(k, maxiterations); } @@ -556,6 +609,7 @@ generate_clusters(int k, int maxiterations) { */ void BulletSoftBodyNode:: release_clusters() { + LightMutexHolder holder(BulletWorld::get_global_lock()); _soft->releaseClusters(); } @@ -565,6 +619,7 @@ release_clusters() { */ void BulletSoftBodyNode:: release_cluster(int index) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _soft->releaseCluster(index); } @@ -574,6 +629,7 @@ release_cluster(int index) { */ int BulletSoftBodyNode:: get_num_clusters() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _soft->clusterCount(); } @@ -583,6 +639,7 @@ get_num_clusters() const { */ LVecBase3 BulletSoftBodyNode:: cluster_com(int cluster) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LVecBase3(_soft->clusterCom(cluster)); } @@ -592,6 +649,7 @@ cluster_com(int cluster) const { */ void BulletSoftBodyNode:: set_pose(bool bvolume, bool bframe) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _soft->setPose(bvolume, bframe); } @@ -601,11 +659,12 @@ set_pose(bool bvolume, bool bframe) { */ void BulletSoftBodyNode:: append_anchor(int node, BulletRigidBodyNode *body, bool disable) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(node < _soft->m_nodes.size()) nassertv(body); - body->sync_p2b(); + body->do_sync_p2b(); btRigidBody *ptr = (btRigidBody *)body->get_object(); _soft->appendAnchor(node, ptr, disable); @@ -616,12 +675,13 @@ append_anchor(int node, BulletRigidBodyNode *body, bool disable) { */ void BulletSoftBodyNode:: append_anchor(int node, BulletRigidBodyNode *body, const LVector3 &pivot, bool disable) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(node < _soft->m_nodes.size()) nassertv(body); nassertv(!pivot.is_nan()); - body->sync_p2b(); + body->do_sync_p2b(); btRigidBody *ptr = (btRigidBody *)body->get_object(); _soft->appendAnchor(node, ptr, LVecBase3_to_btVector3(pivot), disable); @@ -642,6 +702,7 @@ BulletSoftBodyNodeElement(btSoftBody::Node &node) : _node(node) { */ int BulletSoftBodyNode:: get_point_index(LVecBase3 p, PTA_LVecBase3 points) { + LightMutexHolder holder(BulletWorld::get_global_lock()); PN_stdfloat eps = 1.0e-6f; // TODO make this a config option @@ -979,6 +1040,7 @@ make_tet_mesh(BulletSoftBodyWorldInfo &info, const char *ele, const char *face, */ void BulletSoftBodyNode:: append_linear_joint(BulletBodyNode *body, int cluster, PN_stdfloat erp, PN_stdfloat cfm, PN_stdfloat split) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(body); @@ -998,6 +1060,7 @@ append_linear_joint(BulletBodyNode *body, int cluster, PN_stdfloat erp, PN_stdfl */ void BulletSoftBodyNode:: append_linear_joint(BulletBodyNode *body, const LPoint3 &pos, PN_stdfloat erp, PN_stdfloat cfm, PN_stdfloat split) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(body); @@ -1017,6 +1080,7 @@ append_linear_joint(BulletBodyNode *body, const LPoint3 &pos, PN_stdfloat erp, P */ void BulletSoftBodyNode:: append_angular_joint(BulletBodyNode *body, const LVector3 &axis, PN_stdfloat erp, PN_stdfloat cfm, PN_stdfloat split, BulletSoftBodyControl *control) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(body); @@ -1037,6 +1101,7 @@ append_angular_joint(BulletBodyNode *body, const LVector3 &axis, PN_stdfloat erp */ void BulletSoftBodyNode:: set_wind_velocity(const LVector3 &velocity) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(!velocity.is_nan()); _soft->setWindVelocity(LVecBase3_to_btVector3(velocity)); @@ -1047,6 +1112,67 @@ set_wind_velocity(const LVector3 &velocity) { */ LVector3 BulletSoftBodyNode:: get_wind_velocity() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LVector3(_soft->getWindVelocity()); } + +/** + * + */ +LPoint3 BulletSoftBodyNodeElement:: +get_pos() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btVector3_to_LPoint3(_node.m_x); +} + +/** + * + */ +LVector3 BulletSoftBodyNodeElement:: +get_normal() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btVector3_to_LVector3(_node.m_n); +} + +/** + * + */ +LVector3 BulletSoftBodyNodeElement:: +get_velocity() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btVector3_to_LVector3(_node.m_v); +} + +/** + * + */ +PN_stdfloat BulletSoftBodyNodeElement:: +get_inv_mass() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_node.m_im; +} + +/** + * + */ +PN_stdfloat BulletSoftBodyNodeElement:: +get_area() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_node.m_area; +} + +/** + * + */ +int BulletSoftBodyNodeElement:: +is_attached() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_node.m_battach; +} diff --git a/panda/src/bullet/bulletSoftBodyNode.h b/panda/src/bullet/bulletSoftBodyNode.h index 0f37217dfe..600e185fac 100644 --- a/panda/src/bullet/bulletSoftBodyNode.h +++ b/panda/src/bullet/bulletSoftBodyNode.h @@ -43,12 +43,12 @@ PUBLISHED: INLINE ~BulletSoftBodyNodeElement(); INLINE static BulletSoftBodyNodeElement empty(); - INLINE LPoint3 get_pos() const; - INLINE LVector3 get_velocity() const; - INLINE LVector3 get_normal() const; - INLINE PN_stdfloat get_inv_mass() const; - INLINE PN_stdfloat get_area() const; - INLINE int is_attached() const; + LPoint3 get_pos() const; + LVector3 get_velocity() const; + LVector3 get_normal() const; + PN_stdfloat get_inv_mass() const; + PN_stdfloat get_area() const; + int is_attached() const; MAKE_PROPERTY(pos, get_pos); MAKE_PROPERTY(velocity, get_velocity); @@ -221,8 +221,8 @@ PUBLISHED: public: virtual btCollisionObject *get_object() const; - void sync_p2b(); - void sync_b2p(); + void do_sync_p2b(); + void do_sync_b2p(); protected: virtual void transform_changed(); @@ -240,6 +240,9 @@ private: static int get_point_index(LVecBase3 p, PTA_LVecBase3 points); static int next_line(const char *buffer); + BoundingBox do_get_aabb() const; + int do_get_closest_node_index(LVecBase3 point, bool local); + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/bullet/bulletSoftBodyShape.cxx b/panda/src/bullet/bulletSoftBodyShape.cxx index f28050ae3b..9e6aa2929b 100644 --- a/panda/src/bullet/bulletSoftBodyShape.cxx +++ b/panda/src/bullet/bulletSoftBodyShape.cxx @@ -40,6 +40,7 @@ ptr() const { */ BulletSoftBodyNode *BulletSoftBodyShape:: get_body() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); if (_shape->m_body) { return (BulletSoftBodyNode *)_shape->m_body->getUserPointer(); diff --git a/panda/src/bullet/bulletSoftBodyWorldInfo.cxx b/panda/src/bullet/bulletSoftBodyWorldInfo.cxx index ee1fddbc96..2fb6957c29 100644 --- a/panda/src/bullet/bulletSoftBodyWorldInfo.cxx +++ b/panda/src/bullet/bulletSoftBodyWorldInfo.cxx @@ -26,6 +26,7 @@ BulletSoftBodyWorldInfo(btSoftBodyWorldInfo &info) : _info(info) { */ void BulletSoftBodyWorldInfo:: garbage_collect(int lifetime) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.m_sparsesdf.GarbageCollect(lifetime); } @@ -35,6 +36,7 @@ garbage_collect(int lifetime) { */ void BulletSoftBodyWorldInfo:: set_air_density(PN_stdfloat density) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.air_density = (btScalar)density; } @@ -44,6 +46,7 @@ set_air_density(PN_stdfloat density) { */ void BulletSoftBodyWorldInfo:: set_water_density(PN_stdfloat density) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.water_density = (btScalar)density; } @@ -53,6 +56,7 @@ set_water_density(PN_stdfloat density) { */ void BulletSoftBodyWorldInfo:: set_water_offset(PN_stdfloat offset) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.water_offset = (btScalar)offset; } @@ -62,6 +66,7 @@ set_water_offset(PN_stdfloat offset) { */ void BulletSoftBodyWorldInfo:: set_water_normal(const LVector3 &normal) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(!normal.is_nan()); _info.water_normal.setValue(normal.get_x(), normal.get_y(), normal.get_z()); @@ -72,6 +77,7 @@ set_water_normal(const LVector3 &normal) { */ void BulletSoftBodyWorldInfo:: set_gravity(const LVector3 &gravity) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(!gravity.is_nan()); _info.m_gravity.setValue(gravity.get_x(), gravity.get_y(), gravity.get_z()); @@ -82,6 +88,7 @@ set_gravity(const LVector3 &gravity) { */ PN_stdfloat BulletSoftBodyWorldInfo:: get_air_density() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_info.air_density; } @@ -91,6 +98,7 @@ get_air_density() const { */ PN_stdfloat BulletSoftBodyWorldInfo:: get_water_density() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_info.water_density; } @@ -100,6 +108,7 @@ get_water_density() const { */ PN_stdfloat BulletSoftBodyWorldInfo:: get_water_offset() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_info.water_offset; } @@ -109,6 +118,7 @@ get_water_offset() const { */ LVector3 BulletSoftBodyWorldInfo:: get_water_normal() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LVector3(_info.water_normal); } @@ -118,6 +128,7 @@ get_water_normal() const { */ LVector3 BulletSoftBodyWorldInfo:: get_gravity() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LVector3(_info.m_gravity); } diff --git a/panda/src/bullet/bulletSphereShape.I b/panda/src/bullet/bulletSphereShape.I index a5177c572a..d410322298 100644 --- a/panda/src/bullet/bulletSphereShape.I +++ b/panda/src/bullet/bulletSphereShape.I @@ -20,24 +20,6 @@ INLINE BulletSphereShape:: delete _shape; } -/** - * - */ -INLINE BulletSphereShape:: -BulletSphereShape(const BulletSphereShape ©) : - _shape(copy._shape), - _radius(copy._radius) { -} - -/** - * - */ -INLINE void BulletSphereShape:: -operator = (const BulletSphereShape ©) { - _shape = copy._shape; - _radius = copy._radius; -} - /** * Returns the radius that was used to construct this sphere. */ diff --git a/panda/src/bullet/bulletSphereShape.cxx b/panda/src/bullet/bulletSphereShape.cxx index 4cda14882b..7b3fee62a4 100644 --- a/panda/src/bullet/bulletSphereShape.cxx +++ b/panda/src/bullet/bulletSphereShape.cxx @@ -25,6 +25,29 @@ BulletSphereShape(PN_stdfloat radius) : _radius(radius) { _shape->setUserPointer(this); } +/** + * + */ +BulletSphereShape:: +BulletSphereShape(const BulletSphereShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _shape = copy._shape; + _radius = copy._radius; +} + +/** + * + */ +void BulletSphereShape:: +operator = (const BulletSphereShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _shape = copy._shape; + _radius = copy._radius; +} + + /** * */ diff --git a/panda/src/bullet/bulletSphereShape.h b/panda/src/bullet/bulletSphereShape.h index c16a1279a6..b11d1c4a32 100644 --- a/panda/src/bullet/bulletSphereShape.h +++ b/panda/src/bullet/bulletSphereShape.h @@ -32,8 +32,8 @@ private: PUBLISHED: explicit BulletSphereShape(PN_stdfloat radius); - INLINE BulletSphereShape(const BulletSphereShape ©); - INLINE void operator = (const BulletSphereShape ©); + BulletSphereShape(const BulletSphereShape ©); + void operator = (const BulletSphereShape ©); INLINE ~BulletSphereShape(); INLINE PN_stdfloat get_radius() const; diff --git a/panda/src/bullet/bulletSphericalConstraint.cxx b/panda/src/bullet/bulletSphericalConstraint.cxx index 021dd69777..8686e1d546 100644 --- a/panda/src/bullet/bulletSphericalConstraint.cxx +++ b/panda/src/bullet/bulletSphericalConstraint.cxx @@ -61,6 +61,7 @@ ptr() const { */ void BulletSphericalConstraint:: set_pivot_a(const LPoint3 &pivot_a) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(!pivot_a.is_nan()); _constraint->setPivotA(LVecBase3_to_btVector3(pivot_a)); @@ -71,6 +72,7 @@ set_pivot_a(const LPoint3 &pivot_a) { */ void BulletSphericalConstraint:: set_pivot_b(const LPoint3 &pivot_b) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(!pivot_b.is_nan()); _constraint->setPivotB(LVecBase3_to_btVector3(pivot_b)); @@ -81,6 +83,7 @@ set_pivot_b(const LPoint3 &pivot_b) { */ LPoint3 BulletSphericalConstraint:: get_pivot_in_a() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LPoint3(_constraint->getPivotInA()); } @@ -90,6 +93,7 @@ get_pivot_in_a() const { */ LPoint3 BulletSphericalConstraint:: get_pivot_in_b() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LPoint3(_constraint->getPivotInB()); } diff --git a/panda/src/bullet/bulletTranslationalLimitMotor.I b/panda/src/bullet/bulletTranslationalLimitMotor.I index 2972994e39..7b41ab9618 100644 --- a/panda/src/bullet/bulletTranslationalLimitMotor.I +++ b/panda/src/bullet/bulletTranslationalLimitMotor.I @@ -14,164 +14,7 @@ /** * */ -INLINE bool BulletTranslationalLimitMotor:: -is_limited(int axis) const { +INLINE BulletTranslationalLimitMotor:: +~BulletTranslationalLimitMotor() { - nassertr((0 <= axis) && (axis <= 2), false); - return _motor.isLimited(axis); -} - -/** - * - */ -INLINE void BulletTranslationalLimitMotor:: -set_motor_enabled(int axis, bool enabled) { - - nassertv((0 <= axis) && (axis <= 2)); - _motor.m_enableMotor[axis] = enabled; -} - -/** - * - */ -INLINE bool BulletTranslationalLimitMotor:: -get_motor_enabled(int axis) const { - - nassertr((0 <= axis) && (axis <= 2), false); - return _motor.m_enableMotor[axis]; -} - -/** - * - */ -INLINE void BulletTranslationalLimitMotor:: -set_low_limit(const LVecBase3 &limit) { - - nassertv(!limit.is_nan()); - _motor.m_lowerLimit = LVecBase3_to_btVector3(limit); -} - -/** - * - */ -INLINE void BulletTranslationalLimitMotor:: -set_high_limit(const LVecBase3 &limit) { - - nassertv(!limit.is_nan()); - _motor.m_upperLimit = LVecBase3_to_btVector3(limit); -} - -/** - * - */ -INLINE void BulletTranslationalLimitMotor:: -set_target_velocity(const LVecBase3 &velocity) { - - nassertv(!velocity.is_nan()); - _motor.m_targetVelocity = LVecBase3_to_btVector3(velocity); -} - -/** - * - */ -INLINE void BulletTranslationalLimitMotor:: -set_max_motor_force(const LVecBase3 &force) { - - nassertv(!force.is_nan()); - _motor.m_maxMotorForce = LVecBase3_to_btVector3(force); -} - -/** - * - */ -INLINE void BulletTranslationalLimitMotor:: -set_damping(PN_stdfloat damping) { - - _motor.m_damping = (btScalar)damping; -} - -/** - * - */ -INLINE void BulletTranslationalLimitMotor:: -set_softness(PN_stdfloat softness) { - - _motor.m_limitSoftness = (btScalar)softness; -} - -/** - * - */ -INLINE void BulletTranslationalLimitMotor:: -set_restitution(PN_stdfloat restitution) { - - _motor.m_restitution = (btScalar)restitution; -} - -/** - * - */ -INLINE void BulletTranslationalLimitMotor:: -set_normal_cfm(const LVecBase3 &cfm) { - - nassertv(!cfm.is_nan()); - _motor.m_normalCFM = LVecBase3_to_btVector3(cfm); -} - -/** - * - */ -INLINE void BulletTranslationalLimitMotor:: -set_stop_cfm(const LVecBase3 &cfm) { - - nassertv(!cfm.is_nan()); - _motor.m_stopCFM = LVecBase3_to_btVector3(cfm); -} - -/** - * - */ -INLINE void BulletTranslationalLimitMotor:: -set_stop_erp(const LVecBase3 &erp) { - - nassertv(!erp.is_nan()); - _motor.m_stopERP = LVecBase3_to_btVector3(erp); -} - -/** - * Retrieves the current value of angle: 0 = free, 1 = at low limit, 2 = at - * high limit. - */ -INLINE int BulletTranslationalLimitMotor:: -get_current_limit(int axis) const { - - nassertr((0 <= axis) && (axis <= 2), false); - return _motor.m_currentLimit[axis]; -} - -/** - * - */ -INLINE LVector3 BulletTranslationalLimitMotor:: -get_current_error() const { - - return btVector3_to_LVector3(_motor.m_currentLimitError); -} - -/** - * - */ -INLINE LPoint3 BulletTranslationalLimitMotor:: -get_current_diff() const { - - return btVector3_to_LPoint3(_motor.m_currentLinearDiff); -} - -/** - * - */ -INLINE LVector3 BulletTranslationalLimitMotor:: -get_accumulated_impulse() const { - - return btVector3_to_LVector3(_motor.m_accumulatedImpulse); } diff --git a/panda/src/bullet/bulletTranslationalLimitMotor.cxx b/panda/src/bullet/bulletTranslationalLimitMotor.cxx index fdf0b55501..48dd7ae3e8 100644 --- a/panda/src/bullet/bulletTranslationalLimitMotor.cxx +++ b/panda/src/bullet/bulletTranslationalLimitMotor.cxx @@ -34,7 +34,182 @@ BulletTranslationalLimitMotor(const BulletTranslationalLimitMotor ©) /** * */ -BulletTranslationalLimitMotor:: -~BulletTranslationalLimitMotor() { +bool BulletTranslationalLimitMotor:: +is_limited(int axis) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + nassertr((0 <= axis) && (axis <= 2), false); + return _motor.isLimited(axis); +} + +/** + * + */ +void BulletTranslationalLimitMotor:: +set_motor_enabled(int axis, bool enabled) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + nassertv((0 <= axis) && (axis <= 2)); + _motor.m_enableMotor[axis] = enabled; +} + +/** + * + */ +bool BulletTranslationalLimitMotor:: +get_motor_enabled(int axis) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + nassertr((0 <= axis) && (axis <= 2), false); + return _motor.m_enableMotor[axis]; +} + + +/** + * + */ +void BulletTranslationalLimitMotor:: +set_low_limit(const LVecBase3 &limit) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + nassertv(!limit.is_nan()); + _motor.m_lowerLimit = LVecBase3_to_btVector3(limit); +} + +/** + * + */ +void BulletTranslationalLimitMotor:: +set_high_limit(const LVecBase3 &limit) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + nassertv(!limit.is_nan()); + _motor.m_upperLimit = LVecBase3_to_btVector3(limit); +} + +/** + * + */ +void BulletTranslationalLimitMotor:: +set_target_velocity(const LVecBase3 &velocity) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + nassertv(!velocity.is_nan()); + _motor.m_targetVelocity = LVecBase3_to_btVector3(velocity); +} + +/** + * + */ +void BulletTranslationalLimitMotor:: +set_max_motor_force(const LVecBase3 &force) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + nassertv(!force.is_nan()); + _motor.m_maxMotorForce = LVecBase3_to_btVector3(force); +} + +/** + * + */ +void BulletTranslationalLimitMotor:: +set_damping(PN_stdfloat damping) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _motor.m_damping = (btScalar)damping; +} + +/** + * + */ +void BulletTranslationalLimitMotor:: +set_softness(PN_stdfloat softness) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _motor.m_limitSoftness = (btScalar)softness; +} + +/** + * + */ +void BulletTranslationalLimitMotor:: +set_restitution(PN_stdfloat restitution) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _motor.m_restitution = (btScalar)restitution; +} + +/** + * + */ +void BulletTranslationalLimitMotor:: +set_normal_cfm(const LVecBase3 &cfm) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + nassertv(!cfm.is_nan()); + _motor.m_normalCFM = LVecBase3_to_btVector3(cfm); +} + +/** + * + */ +void BulletTranslationalLimitMotor:: +set_stop_cfm(const LVecBase3 &cfm) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + nassertv(!cfm.is_nan()); + _motor.m_stopCFM = LVecBase3_to_btVector3(cfm); +} + +/** + * + */ +void BulletTranslationalLimitMotor:: +set_stop_erp(const LVecBase3 &erp) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + nassertv(!erp.is_nan()); + _motor.m_stopERP = LVecBase3_to_btVector3(erp); +} + +/** + * Retrieves the current value of angle: 0 = free, 1 = at low limit, 2 = at + * high limit. + */ +int BulletTranslationalLimitMotor:: +get_current_limit(int axis) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + nassertr((0 <= axis) && (axis <= 2), false); + return _motor.m_currentLimit[axis]; +} + +/** + * + */ +LVector3 BulletTranslationalLimitMotor:: +get_current_error() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btVector3_to_LVector3(_motor.m_currentLimitError); +} + +/** + * + */ +LPoint3 BulletTranslationalLimitMotor:: +get_current_diff() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btVector3_to_LPoint3(_motor.m_currentLinearDiff); +} + +/** + * + */ +LVector3 BulletTranslationalLimitMotor:: +get_accumulated_impulse() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btVector3_to_LVector3(_motor.m_accumulatedImpulse); } diff --git a/panda/src/bullet/bulletTranslationalLimitMotor.h b/panda/src/bullet/bulletTranslationalLimitMotor.h index f339daefef..97c9909ede 100644 --- a/panda/src/bullet/bulletTranslationalLimitMotor.h +++ b/panda/src/bullet/bulletTranslationalLimitMotor.h @@ -28,26 +28,26 @@ class EXPCL_PANDABULLET BulletTranslationalLimitMotor { PUBLISHED: BulletTranslationalLimitMotor(const BulletTranslationalLimitMotor ©); - ~BulletTranslationalLimitMotor(); + INLINE ~BulletTranslationalLimitMotor(); - INLINE void set_motor_enabled(int axis, bool enable); - INLINE void set_low_limit(const LVecBase3 &limit); - INLINE void set_high_limit(const LVecBase3 &limit); - INLINE void set_target_velocity(const LVecBase3 &velocity); - INLINE void set_max_motor_force(const LVecBase3 &force); - INLINE void set_damping(PN_stdfloat damping); - INLINE void set_softness(PN_stdfloat softness); - INLINE void set_restitution(PN_stdfloat restitution); - INLINE void set_normal_cfm(const LVecBase3 &cfm); - INLINE void set_stop_erp(const LVecBase3 &erp); - INLINE void set_stop_cfm(const LVecBase3 &cfm); + void set_motor_enabled(int axis, bool enable); + void set_low_limit(const LVecBase3 &limit); + void set_high_limit(const LVecBase3 &limit); + void set_target_velocity(const LVecBase3 &velocity); + void set_max_motor_force(const LVecBase3 &force); + void set_damping(PN_stdfloat damping); + void set_softness(PN_stdfloat softness); + void set_restitution(PN_stdfloat restitution); + void set_normal_cfm(const LVecBase3 &cfm); + void set_stop_erp(const LVecBase3 &erp); + void set_stop_cfm(const LVecBase3 &cfm); - INLINE bool is_limited(int axis) const; - INLINE bool get_motor_enabled(int axis) const; - INLINE int get_current_limit(int axis) const; - INLINE LVector3 get_current_error() const; - INLINE LPoint3 get_current_diff() const; - INLINE LVector3 get_accumulated_impulse() const; + bool is_limited(int axis) const; + bool get_motor_enabled(int axis) const; + int get_current_limit(int axis) const; + LVector3 get_current_error() const; + LPoint3 get_current_diff() const; + LVector3 get_accumulated_impulse() const; MAKE_PROPERTY(current_error, get_current_error); MAKE_PROPERTY(current_diff, get_current_diff); diff --git a/panda/src/bullet/bulletTriangleMesh.I b/panda/src/bullet/bulletTriangleMesh.I index b6965303aa..33b9b9bf47 100644 --- a/panda/src/bullet/bulletTriangleMesh.I +++ b/panda/src/bullet/bulletTriangleMesh.I @@ -19,34 +19,6 @@ ptr() const { return (btStridingMeshInterface *)&_mesh; } -/** - * Returns the number of vertices in this triangle mesh. - */ -INLINE size_t BulletTriangleMesh:: -get_num_vertices() const { - return _vertices.size(); -} - -/** - * Returns the vertex at the given vertex index. - */ -INLINE LPoint3 BulletTriangleMesh:: -get_vertex(size_t index) const { - nassertr(index < _vertices.size(), LPoint3::zero()); - const btVector3 &vertex = _vertices[index]; - return LPoint3(vertex[0], vertex[1], vertex[2]); -} - -/** - * Returns the vertex indices making up the given triangle index. - */ -INLINE LVecBase3i BulletTriangleMesh:: -get_triangle(size_t index) const { - index *= 3; - nassertr(index + 2 < _indices.size(), LVecBase3i::zero()); - return LVecBase3i(_indices[index], _indices[index + 1], _indices[index + 2]); -} - /** * */ diff --git a/panda/src/bullet/bulletTriangleMesh.cxx b/panda/src/bullet/bulletTriangleMesh.cxx index 3138e28efd..e2d3e0b242 100644 --- a/panda/src/bullet/bulletTriangleMesh.cxx +++ b/panda/src/bullet/bulletTriangleMesh.cxx @@ -36,12 +36,58 @@ BulletTriangleMesh() _mesh.addIndexedMesh(mesh); } +/** + * Returns the number of vertices in this triangle mesh. + */ +size_t BulletTriangleMesh:: +get_num_vertices() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return _vertices.size(); +} + +/** + * Returns the vertex at the given vertex index. + */ +LPoint3 BulletTriangleMesh:: +get_vertex(size_t index) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + nassertr(index < _vertices.size(), LPoint3::zero()); + const btVector3 &vertex = _vertices[index]; + return LPoint3(vertex[0], vertex[1], vertex[2]); +} + +/** + * Returns the vertex indices making up the given triangle index. + */ +LVecBase3i BulletTriangleMesh:: +get_triangle(size_t index) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + index *= 3; + nassertr(index + 2 < _indices.size(), LVecBase3i::zero()); + return LVecBase3i(_indices[index], _indices[index + 1], _indices[index + 2]); +} + +/** + * Returns the number of triangles in this triangle mesh. + * Assumes the lock(bullet global lock) is held by the caller + */ +size_t BulletTriangleMesh:: +do_get_num_triangles() const { + + return _indices.size() / 3; +} + /** * Returns the number of triangles in this triangle mesh. */ size_t BulletTriangleMesh:: get_num_triangles() const { - return _indices.size() / 3; + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return do_get_num_triangles(); } /** @@ -51,6 +97,8 @@ get_num_triangles() const { */ void BulletTriangleMesh:: preallocate(int num_verts, int num_indices) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + _vertices.reserve(num_verts); _indices.reserve(num_indices); @@ -66,9 +114,11 @@ preallocate(int num_verts, int num_indices) { * add duplicate vertices if they already exist in the triangle mesh, within * the tolerance specified by set_welding_distance(). This comes at a * significant performance cost, especially for large meshes. + * Assumes the lock(bullet global lock) is held by the caller */ void BulletTriangleMesh:: -add_triangle(const LPoint3 &p0, const LPoint3 &p1, const LPoint3 &p2, bool remove_duplicate_vertices) { +do_add_triangle(const LPoint3 &p0, const LPoint3 &p1, const LPoint3 &p2, bool remove_duplicate_vertices) { + nassertv(!p0.is_nan()); nassertv(!p1.is_nan()); nassertv(!p2.is_nan()); @@ -96,6 +146,21 @@ add_triangle(const LPoint3 &p0, const LPoint3 &p1, const LPoint3 &p2, bool remov mesh.m_triangleIndexBase = (unsigned char *)&_indices[0]; } +/** + * Adds a triangle with the indicated coordinates. + * + * If remove_duplicate_vertices is true, it will make sure that it does not + * add duplicate vertices if they already exist in the triangle mesh, within + * the tolerance specified by set_welding_distance(). This comes at a + * significant performance cost, especially for large meshes. + */ +void BulletTriangleMesh:: +add_triangle(const LPoint3 &p0, const LPoint3 &p1, const LPoint3 &p2, bool remove_duplicate_vertices) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + do_add_triangle(p0, p1, p2, remove_duplicate_vertices); +} + /** * Sets the square of the distance at which vertices will be merged * together when adding geometry with remove_duplicate_vertices set to true. @@ -105,6 +170,8 @@ add_triangle(const LPoint3 &p0, const LPoint3 &p1, const LPoint3 &p2, bool remov */ void BulletTriangleMesh:: set_welding_distance(PN_stdfloat distance) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + _welding_distance = distance; } @@ -114,6 +181,8 @@ set_welding_distance(PN_stdfloat distance) { */ PN_stdfloat BulletTriangleMesh:: get_welding_distance() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + return _welding_distance; } @@ -129,6 +198,8 @@ get_welding_distance() const { */ void BulletTriangleMesh:: add_geom(const Geom *geom, bool remove_duplicate_vertices, const TransformState *ts) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + nassertv(geom); nassertv(ts); @@ -241,6 +312,8 @@ add_geom(const Geom *geom, bool remove_duplicate_vertices, const TransformState */ void BulletTriangleMesh:: add_array(const PTA_LVecBase3 &points, const PTA_int &indices, bool remove_duplicate_vertices) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + btIndexedMesh &mesh = _mesh.getIndexedMeshArray()[0]; _indices.reserve(_indices.size() + indices.size()); @@ -279,7 +352,9 @@ add_array(const PTA_LVecBase3 &points, const PTA_int &indices, bool remove_dupli */ void BulletTriangleMesh:: output(ostream &out) const { - out << get_type() << ", " << get_num_triangles() << " triangles"; + LightMutexHolder holder(BulletWorld::get_global_lock()); + + out << get_type() << ", " << _indices.size() / 3 << " triangles"; } /** diff --git a/panda/src/bullet/bulletTriangleMesh.h b/panda/src/bullet/bulletTriangleMesh.h index 64973d83e8..0f9cb8174b 100644 --- a/panda/src/bullet/bulletTriangleMesh.h +++ b/panda/src/bullet/bulletTriangleMesh.h @@ -55,10 +55,16 @@ PUBLISHED: virtual void write(ostream &out, int indent_level) const; public: - INLINE size_t get_num_vertices() const; - INLINE LPoint3 get_vertex(size_t index) const; + size_t get_num_vertices() const; + LPoint3 get_vertex(size_t index) const; - INLINE LVecBase3i get_triangle(size_t index) const; + LVecBase3i get_triangle(size_t index) const; + + size_t do_get_num_triangles() const; + void do_add_triangle(const LPoint3 &p0, + const LPoint3 &p1, + const LPoint3 &p2, + bool remove_duplicate_vertices=false); PUBLISHED: MAKE_PROPERTY(welding_distance, get_welding_distance, set_welding_distance); diff --git a/panda/src/bullet/bulletTriangleMeshShape.I b/panda/src/bullet/bulletTriangleMeshShape.I index abb51607b4..f178723ebc 100644 --- a/panda/src/bullet/bulletTriangleMeshShape.I +++ b/panda/src/bullet/bulletTriangleMeshShape.I @@ -11,27 +11,6 @@ * @date 2010-02-09 */ -/** - * - */ -INLINE BulletTriangleMeshShape:: -BulletTriangleMeshShape(const BulletTriangleMeshShape ©) : - _bvh_shape(copy._bvh_shape), - _gimpact_shape(copy._gimpact_shape), - _mesh(copy._mesh) { -} - -/** - * - */ -INLINE void BulletTriangleMeshShape:: -operator = (const BulletTriangleMeshShape ©) { - - _bvh_shape = copy._bvh_shape; - _gimpact_shape = copy._gimpact_shape; - _mesh = copy._mesh; -} - /** * */ diff --git a/panda/src/bullet/bulletTriangleMeshShape.cxx b/panda/src/bullet/bulletTriangleMeshShape.cxx index 22775a6e0a..61905a406a 100644 --- a/panda/src/bullet/bulletTriangleMeshShape.cxx +++ b/panda/src/bullet/bulletTriangleMeshShape.cxx @@ -36,6 +36,7 @@ BulletTriangleMeshShape() : /** * The parameters 'compress' and 'bvh' are only used if 'dynamic' is set to * FALSE. + * Assumes the lock(bullet global lock) is held by the caller */ BulletTriangleMeshShape:: BulletTriangleMeshShape(BulletTriangleMesh *mesh, bool dynamic, bool compress, bool bvh) : @@ -50,7 +51,7 @@ BulletTriangleMeshShape(BulletTriangleMesh *mesh, bool dynamic, bool compress, b } // Assert that mesh has at least one triangle - if (mesh->get_num_triangles() == 0) { + if (mesh->do_get_num_triangles() == 0) { bullet_cat.warning() << "mesh has zero triangles! adding degenerated triangle." << endl; mesh->add_triangle(LPoint3::zero(), LPoint3::zero(), LPoint3::zero()); } @@ -78,6 +79,30 @@ BulletTriangleMeshShape(BulletTriangleMesh *mesh, bool dynamic, bool compress, b } } +/** + * + */ +BulletTriangleMeshShape:: +BulletTriangleMeshShape(const BulletTriangleMeshShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _bvh_shape = copy._bvh_shape; + _gimpact_shape = copy._gimpact_shape; + _mesh = copy._mesh; +} + +/** + * + */ +void BulletTriangleMeshShape:: +operator = (const BulletTriangleMeshShape ©) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _bvh_shape = copy._bvh_shape; + _gimpact_shape = copy._gimpact_shape; + _mesh = copy._mesh; +} + /** * */ @@ -100,6 +125,7 @@ ptr() const { */ void BulletTriangleMeshShape:: refit_tree(const LPoint3 &aabb_min, const LPoint3 &aabb_max) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(!aabb_max.is_nan()); nassertv(!aabb_max.is_nan()); diff --git a/panda/src/bullet/bulletTriangleMeshShape.h b/panda/src/bullet/bulletTriangleMeshShape.h index b76227b46e..079fb2aeb1 100644 --- a/panda/src/bullet/bulletTriangleMeshShape.h +++ b/panda/src/bullet/bulletTriangleMeshShape.h @@ -32,8 +32,8 @@ private: PUBLISHED: explicit BulletTriangleMeshShape(BulletTriangleMesh *mesh, bool dynamic, bool compress=true, bool bvh=true); - INLINE BulletTriangleMeshShape(const BulletTriangleMeshShape ©); - INLINE void operator = (const BulletTriangleMeshShape ©); + BulletTriangleMeshShape(const BulletTriangleMeshShape ©); + void operator = (const BulletTriangleMeshShape ©); INLINE ~BulletTriangleMeshShape(); void refit_tree(const LPoint3 &aabb_min, const LPoint3 &aabb_max); diff --git a/panda/src/bullet/bulletVehicle.I b/panda/src/bullet/bulletVehicle.I index b167ab5303..f4599a63e4 100644 --- a/panda/src/bullet/bulletVehicle.I +++ b/panda/src/bullet/bulletVehicle.I @@ -18,6 +18,7 @@ INLINE BulletVehicle:: ~BulletVehicle() { delete _vehicle; + delete _raycaster; } /** @@ -40,119 +41,3 @@ get_tuning() { return _tuning; } -/** - * Returns the number of wheels this vehicle has. - */ -INLINE int BulletVehicle:: -get_num_wheels() const { - - return _vehicle->getNumWheels(); -} - -/** - * - */ -void BulletVehicleTuning:: -set_suspension_stiffness(PN_stdfloat value) { - - _.m_suspensionStiffness = (btScalar)value; -} - -/** - * - */ -void BulletVehicleTuning:: -set_suspension_compression(PN_stdfloat value) { - - _.m_suspensionCompression = (btScalar)value; -} - -/** - * - */ -void BulletVehicleTuning:: -set_suspension_damping(PN_stdfloat value) { - - _.m_suspensionDamping = (btScalar)value; -} - -/** - * - */ -void BulletVehicleTuning:: -set_max_suspension_travel_cm(PN_stdfloat value) { - - _.m_maxSuspensionTravelCm = (btScalar)value; -} - -/** - * - */ -void BulletVehicleTuning:: -set_friction_slip(PN_stdfloat value) { - - _.m_frictionSlip = (btScalar)value; -} - -/** - * - */ -void BulletVehicleTuning:: -set_max_suspension_force(PN_stdfloat value) { - - _.m_maxSuspensionForce = (btScalar)value; -} - -/** - * - */ -PN_stdfloat BulletVehicleTuning:: -get_suspension_stiffness() const { - - return (PN_stdfloat)_.m_suspensionStiffness; -} - -/** - * - */ -PN_stdfloat BulletVehicleTuning:: -get_suspension_compression() const { - - return (PN_stdfloat)_.m_suspensionCompression; -} - -/** - * - */ -PN_stdfloat BulletVehicleTuning:: -get_suspension_damping() const { - - return (PN_stdfloat)_.m_suspensionDamping; -} - -/** - * - */ -PN_stdfloat BulletVehicleTuning:: -get_max_suspension_travel_cm() const { - - return (PN_stdfloat)_.m_maxSuspensionTravelCm; -} - -/** - * - */ -PN_stdfloat BulletVehicleTuning:: -get_friction_slip() const { - - return (PN_stdfloat)_.m_frictionSlip; -} - -/** - * - */ -PN_stdfloat BulletVehicleTuning:: -get_max_suspension_force() const { - - return (PN_stdfloat)_.m_maxSuspensionForce; -} diff --git a/panda/src/bullet/bulletVehicle.cxx b/panda/src/bullet/bulletVehicle.cxx index 381f8ab6c8..e2d74c131d 100644 --- a/panda/src/bullet/bulletVehicle.cxx +++ b/panda/src/bullet/bulletVehicle.cxx @@ -39,6 +39,7 @@ BulletVehicle(BulletWorld *world, BulletRigidBodyNode *chassis) { */ void BulletVehicle:: set_coordinate_system(BulletUpAxis up) { + LightMutexHolder holder(BulletWorld::get_global_lock()); switch (up) { case X_up: @@ -62,18 +63,30 @@ set_coordinate_system(BulletUpAxis up) { */ LVector3 BulletVehicle:: get_forward_vector() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LVector3(_vehicle->getForwardVector()); } +/** + * Returns the chassis of this vehicle. The chassis is a rigid body node. + * Assumes the lock(bullet global lock) is held by the caller + */ +BulletRigidBodyNode *BulletVehicle:: +do_get_chassis() { + + btRigidBody *bodyPtr = _vehicle->getRigidBody(); + return (bodyPtr) ? (BulletRigidBodyNode *)bodyPtr->getUserPointer() : NULL; +} + /** * Returns the chassis of this vehicle. The chassis is a rigid body node. */ BulletRigidBodyNode *BulletVehicle:: get_chassis() { + LightMutexHolder holder(BulletWorld::get_global_lock()); - btRigidBody *bodyPtr = _vehicle->getRigidBody(); - return (bodyPtr) ? (BulletRigidBodyNode *)bodyPtr->getUserPointer() : NULL; + return do_get_chassis(); } /** @@ -82,6 +95,7 @@ get_chassis() { */ PN_stdfloat BulletVehicle:: get_current_speed_km_hour() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_vehicle->getCurrentSpeedKmHour(); } @@ -91,6 +105,7 @@ get_current_speed_km_hour() const { */ void BulletVehicle:: reset_suspension() { + LightMutexHolder holder(BulletWorld::get_global_lock()); _vehicle->resetSuspension(); } @@ -100,8 +115,9 @@ reset_suspension() { */ PN_stdfloat BulletVehicle:: get_steering_value(int idx) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); - nassertr(idx < get_num_wheels(), 0.0f); + nassertr(idx < _vehicle->getNumWheels(), 0.0f); return rad_2_deg(_vehicle->getSteeringValue(idx)); } @@ -110,8 +126,9 @@ get_steering_value(int idx) const { */ void BulletVehicle:: set_steering_value(PN_stdfloat steering, int idx) { + LightMutexHolder holder(BulletWorld::get_global_lock()); - nassertv(idx < get_num_wheels()); + nassertv(idx < _vehicle->getNumWheels()); _vehicle->setSteeringValue(deg_2_rad(steering), idx); } @@ -120,8 +137,9 @@ set_steering_value(PN_stdfloat steering, int idx) { */ void BulletVehicle:: apply_engine_force(PN_stdfloat force, int idx) { + LightMutexHolder holder(BulletWorld::get_global_lock()); - nassertv(idx < get_num_wheels()); + nassertv(idx < _vehicle->getNumWheels()); _vehicle->applyEngineForce(force, idx); } @@ -130,8 +148,9 @@ apply_engine_force(PN_stdfloat force, int idx) { */ void BulletVehicle:: set_brake(PN_stdfloat brake, int idx) { + LightMutexHolder holder(BulletWorld::get_global_lock()); - nassertv(idx < get_num_wheels()); + nassertv(idx < _vehicle->getNumWheels()); _vehicle->setBrake(brake, idx); } @@ -140,6 +159,7 @@ set_brake(PN_stdfloat brake, int idx) { */ void BulletVehicle:: set_pitch_control(PN_stdfloat pitch) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _vehicle->setPitchControl(pitch); } @@ -149,6 +169,7 @@ set_pitch_control(PN_stdfloat pitch) { */ BulletWheel BulletVehicle:: create_wheel() { + LightMutexHolder holder(BulletWorld::get_global_lock()); btVector3 pos(0.0, 0.0, 0.0); btVector3 direction = get_axis(_vehicle->getUpAxis()); @@ -182,24 +203,35 @@ get_axis(int idx) { } } +/** + * Returns the number of wheels this vehicle has. + */ +int BulletVehicle:: +get_num_wheels() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return _vehicle->getNumWheels(); +} + /** * Returns the BulletWheel with index idx. Causes an AssertionError if idx is * equal or larger than the number of wheels. */ BulletWheel BulletVehicle:: get_wheel(int idx) const { + LightMutexHolder holder(BulletWorld::get_global_lock()); - nassertr(idx < get_num_wheels(), BulletWheel::empty()); + nassertr(idx < _vehicle->getNumWheels(), BulletWheel::empty()); return BulletWheel(_vehicle->getWheelInfo(idx)); } /** - * + * Assumes the lock(bullet global lock) is held by the caller */ void BulletVehicle:: -sync_b2p() { +do_sync_b2p() { - for (int i=0; i < get_num_wheels(); i++) { + for (int i=0; i < _vehicle->getNumWheels(); i++) { btWheelInfo info = _vehicle->getWheelInfo(i); PandaNode *node = (PandaNode *)info.m_clientInfo; @@ -216,3 +248,124 @@ sync_b2p() { } } } + +/** + * + */ +void BulletVehicleTuning:: +set_suspension_stiffness(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _.m_suspensionStiffness = (btScalar)value; +} + +/** + * + */ +void BulletVehicleTuning:: +set_suspension_compression(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _.m_suspensionCompression = (btScalar)value; +} + +/** + * + */ +void BulletVehicleTuning:: +set_suspension_damping(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _.m_suspensionDamping = (btScalar)value; +} + +/** + * + */ +void BulletVehicleTuning:: +set_max_suspension_travel_cm(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _.m_maxSuspensionTravelCm = (btScalar)value; +} + +/** + * + */ +void BulletVehicleTuning:: +set_friction_slip(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _.m_frictionSlip = (btScalar)value; +} + +/** + * + */ +void BulletVehicleTuning:: +set_max_suspension_force(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + _.m_maxSuspensionForce = (btScalar)value; +} + +/** + * + */ +PN_stdfloat BulletVehicleTuning:: +get_suspension_stiffness() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_.m_suspensionStiffness; +} + +/** + * + */ +PN_stdfloat BulletVehicleTuning:: +get_suspension_compression() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_.m_suspensionCompression; +} + +/** + * + */ +PN_stdfloat BulletVehicleTuning:: +get_suspension_damping() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_.m_suspensionDamping; +} + +/** + * + */ +PN_stdfloat BulletVehicleTuning:: +get_max_suspension_travel_cm() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_.m_maxSuspensionTravelCm; +} + +/** + * + */ +PN_stdfloat BulletVehicleTuning:: +get_friction_slip() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_.m_frictionSlip; +} + +/** + * + */ +PN_stdfloat BulletVehicleTuning:: +get_max_suspension_force() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return (PN_stdfloat)_.m_maxSuspensionForce; +} + diff --git a/panda/src/bullet/bulletVehicle.h b/panda/src/bullet/bulletVehicle.h index 8b7f7862c6..9f9da751c3 100644 --- a/panda/src/bullet/bulletVehicle.h +++ b/panda/src/bullet/bulletVehicle.h @@ -32,19 +32,19 @@ class BulletWheel; class EXPCL_PANDABULLET BulletVehicleTuning { PUBLISHED: - INLINE void set_suspension_stiffness(PN_stdfloat value); - INLINE void set_suspension_compression(PN_stdfloat value); - INLINE void set_suspension_damping(PN_stdfloat value); - INLINE void set_max_suspension_travel_cm(PN_stdfloat value); - INLINE void set_friction_slip(PN_stdfloat value); - INLINE void set_max_suspension_force(PN_stdfloat value); + void set_suspension_stiffness(PN_stdfloat value); + void set_suspension_compression(PN_stdfloat value); + void set_suspension_damping(PN_stdfloat value); + void set_max_suspension_travel_cm(PN_stdfloat value); + void set_friction_slip(PN_stdfloat value); + void set_max_suspension_force(PN_stdfloat value); - INLINE PN_stdfloat get_suspension_stiffness() const; - INLINE PN_stdfloat get_suspension_compression() const; - INLINE PN_stdfloat get_suspension_damping() const; - INLINE PN_stdfloat get_max_suspension_travel_cm() const; - INLINE PN_stdfloat get_friction_slip() const; - INLINE PN_stdfloat get_max_suspension_force() const; + PN_stdfloat get_suspension_stiffness() const; + PN_stdfloat get_suspension_compression() const; + PN_stdfloat get_suspension_damping() const; + PN_stdfloat get_max_suspension_travel_cm() const; + PN_stdfloat get_friction_slip() const; + PN_stdfloat get_max_suspension_force() const; MAKE_PROPERTY(suspension_stiffness, get_suspension_stiffness, set_suspension_stiffness); MAKE_PROPERTY(suspension_compression, get_suspension_compression, set_suspension_compression); @@ -87,7 +87,7 @@ PUBLISHED: // Wheels BulletWheel create_wheel(); - INLINE int get_num_wheels() const; + int get_num_wheels() const; BulletWheel get_wheel(int idx) const; MAKE_SEQ(get_wheels, get_num_wheels, get_wheel); @@ -102,8 +102,9 @@ PUBLISHED: public: INLINE btRaycastVehicle *get_vehicle() const; + BulletRigidBodyNode *do_get_chassis(); - void sync_b2p(); + void do_sync_b2p(); private: btRaycastVehicle *_vehicle; diff --git a/panda/src/bullet/bulletWheel.I b/panda/src/bullet/bulletWheel.I index ed724e184b..cbf82a40bc 100644 --- a/panda/src/bullet/bulletWheel.I +++ b/panda/src/bullet/bulletWheel.I @@ -40,74 +40,3 @@ empty() { return BulletWheel(info); } -/** - * - */ -INLINE bool BulletWheelRaycastInfo:: -is_in_contact() const { - - return _info.m_isInContact; -} - -/** - * - */ -INLINE PN_stdfloat BulletWheelRaycastInfo:: -get_suspension_length() const { - - return _info.m_suspensionLength; -} - -/** - * - */ -INLINE LPoint3 BulletWheelRaycastInfo:: -get_contact_point_ws() const { - - return btVector3_to_LPoint3(_info.m_contactPointWS); -} - -/** - * - */ -INLINE LPoint3 BulletWheelRaycastInfo:: -get_hard_point_ws() const { - - return btVector3_to_LPoint3(_info.m_hardPointWS); -} - -/** - * - */ -INLINE LVector3 BulletWheelRaycastInfo:: -get_contact_normal_ws() const { - - return btVector3_to_LVector3(_info.m_contactNormalWS); -} - -/** - * - */ -INLINE LVector3 BulletWheelRaycastInfo:: -get_wheel_direction_ws() const { - - return btVector3_to_LVector3(_info.m_wheelDirectionWS); -} - -/** - * - */ -INLINE LVector3 BulletWheelRaycastInfo:: -get_wheel_axle_ws() const { - - return btVector3_to_LVector3(_info.m_wheelAxleWS); -} - -/** - * - */ -INLINE PandaNode *BulletWheelRaycastInfo:: -get_ground_object() const { - - return _info.m_groundObject ? (PandaNode *)_info.m_groundObject : NULL; -} diff --git a/panda/src/bullet/bulletWheel.cxx b/panda/src/bullet/bulletWheel.cxx index 687e5ea892..149dbd8bf5 100644 --- a/panda/src/bullet/bulletWheel.cxx +++ b/panda/src/bullet/bulletWheel.cxx @@ -34,6 +34,7 @@ BulletWheelRaycastInfo(btWheelInfo::RaycastInfo &info) : _info(info) { */ BulletWheelRaycastInfo BulletWheel:: get_raycast_info() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return BulletWheelRaycastInfo(_info.m_raycastInfo); } @@ -43,6 +44,7 @@ get_raycast_info() const { */ PN_stdfloat BulletWheel:: get_suspension_rest_length() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_info.getSuspensionRestLength(); } @@ -52,6 +54,7 @@ get_suspension_rest_length() const { */ void BulletWheel:: set_suspension_stiffness(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.m_suspensionStiffness = (btScalar)value; } @@ -61,6 +64,7 @@ set_suspension_stiffness(PN_stdfloat value) { */ PN_stdfloat BulletWheel:: get_suspension_stiffness() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_info.m_suspensionStiffness; } @@ -71,6 +75,7 @@ get_suspension_stiffness() const { */ void BulletWheel:: set_max_suspension_travel_cm(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.m_maxSuspensionTravelCm = (btScalar)value; } @@ -80,6 +85,7 @@ set_max_suspension_travel_cm(PN_stdfloat value) { */ PN_stdfloat BulletWheel:: get_max_suspension_travel_cm() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_info.m_maxSuspensionTravelCm; } @@ -89,6 +95,7 @@ get_max_suspension_travel_cm() const { */ void BulletWheel:: set_friction_slip(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.m_frictionSlip = (btScalar)value; } @@ -98,6 +105,7 @@ set_friction_slip(PN_stdfloat value) { */ PN_stdfloat BulletWheel:: get_friction_slip() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_info.m_frictionSlip; } @@ -107,6 +115,7 @@ get_friction_slip() const { */ void BulletWheel:: set_max_suspension_force(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.m_maxSuspensionForce = (btScalar)value; } @@ -116,6 +125,7 @@ set_max_suspension_force(PN_stdfloat value) { */ PN_stdfloat BulletWheel:: get_max_suspension_force() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_info.m_maxSuspensionForce; } @@ -125,6 +135,7 @@ get_max_suspension_force() const { */ void BulletWheel:: set_wheels_damping_compression(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.m_wheelsDampingCompression = (btScalar)value; } @@ -134,6 +145,7 @@ set_wheels_damping_compression(PN_stdfloat value) { */ PN_stdfloat BulletWheel:: get_wheels_damping_compression() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_info.m_wheelsDampingCompression; } @@ -143,6 +155,7 @@ get_wheels_damping_compression() const { */ void BulletWheel:: set_wheels_damping_relaxation(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.m_wheelsDampingRelaxation = (btScalar)value; } @@ -152,6 +165,7 @@ set_wheels_damping_relaxation(PN_stdfloat value) { */ PN_stdfloat BulletWheel:: get_wheels_damping_relaxation() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_info.m_wheelsDampingRelaxation; } @@ -164,6 +178,7 @@ get_wheels_damping_relaxation() const { */ void BulletWheel:: set_roll_influence(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.m_rollInfluence = (btScalar)value; } @@ -174,6 +189,7 @@ set_roll_influence(PN_stdfloat value) { */ PN_stdfloat BulletWheel:: get_roll_influence() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_info.m_rollInfluence; } @@ -183,6 +199,7 @@ get_roll_influence() const { */ void BulletWheel:: set_wheel_radius(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.m_wheelsRadius = (btScalar)value; } @@ -192,6 +209,7 @@ set_wheel_radius(PN_stdfloat value) { */ PN_stdfloat BulletWheel:: get_wheel_radius() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_info.m_wheelsRadius; } @@ -201,6 +219,7 @@ get_wheel_radius() const { */ void BulletWheel:: set_steering(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.m_steering = (btScalar)value; } @@ -210,6 +229,7 @@ set_steering(PN_stdfloat value) { */ PN_stdfloat BulletWheel:: get_steering() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_info.m_steering; } @@ -219,6 +239,7 @@ get_steering() const { */ void BulletWheel:: set_rotation(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.m_rotation = (btScalar)value; } @@ -228,6 +249,7 @@ set_rotation(PN_stdfloat value) { */ PN_stdfloat BulletWheel:: get_rotation() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_info.m_rotation; } @@ -237,6 +259,7 @@ get_rotation() const { */ void BulletWheel:: set_delta_rotation(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.m_deltaRotation = (btScalar)value; } @@ -246,6 +269,7 @@ set_delta_rotation(PN_stdfloat value) { */ PN_stdfloat BulletWheel:: get_delta_rotation() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_info.m_deltaRotation; } @@ -255,6 +279,7 @@ get_delta_rotation() const { */ void BulletWheel:: set_engine_force(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.m_engineForce = (btScalar)value; } @@ -264,6 +289,7 @@ set_engine_force(PN_stdfloat value) { */ PN_stdfloat BulletWheel:: get_engine_force() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_info.m_engineForce; } @@ -273,6 +299,7 @@ get_engine_force() const { */ void BulletWheel:: set_brake(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.m_brake = (btScalar)value; } @@ -282,6 +309,7 @@ set_brake(PN_stdfloat value) { */ PN_stdfloat BulletWheel:: get_brake() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_info.m_brake; } @@ -291,6 +319,7 @@ get_brake() const { */ void BulletWheel:: set_skid_info(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.m_skidInfo = (btScalar)value; } @@ -300,6 +329,7 @@ set_skid_info(PN_stdfloat value) { */ PN_stdfloat BulletWheel:: get_skid_info() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_info.m_skidInfo; } @@ -309,6 +339,7 @@ get_skid_info() const { */ void BulletWheel:: set_wheels_suspension_force(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.m_wheelsSuspensionForce = (btScalar)value; } @@ -318,6 +349,7 @@ set_wheels_suspension_force(PN_stdfloat value) { */ PN_stdfloat BulletWheel:: get_wheels_suspension_force() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_info.m_wheelsSuspensionForce; } @@ -327,6 +359,7 @@ get_wheels_suspension_force() const { */ void BulletWheel:: set_suspension_relative_velocity(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.m_suspensionRelativeVelocity = (btScalar)value; } @@ -336,6 +369,7 @@ set_suspension_relative_velocity(PN_stdfloat value) { */ PN_stdfloat BulletWheel:: get_suspension_relative_velocity() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_info.m_suspensionRelativeVelocity; } @@ -345,6 +379,7 @@ get_suspension_relative_velocity() const { */ void BulletWheel:: set_clipped_inv_connection_point_cs(PN_stdfloat value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.m_clippedInvContactDotSuspension = (btScalar)value; } @@ -354,6 +389,7 @@ set_clipped_inv_connection_point_cs(PN_stdfloat value) { */ PN_stdfloat BulletWheel:: get_clipped_inv_connection_point_cs() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (PN_stdfloat)_info.m_clippedInvContactDotSuspension; } @@ -363,6 +399,7 @@ get_clipped_inv_connection_point_cs() const { */ void BulletWheel:: set_chassis_connection_point_cs(const LPoint3 &pos) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(!pos.is_nan()); _info.m_chassisConnectionPointCS = LVecBase3_to_btVector3(pos); @@ -373,6 +410,7 @@ set_chassis_connection_point_cs(const LPoint3 &pos) { */ LPoint3 BulletWheel:: get_chassis_connection_point_cs() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LPoint3(_info.m_chassisConnectionPointCS); } @@ -383,6 +421,7 @@ get_chassis_connection_point_cs() const { */ void BulletWheel:: set_wheel_direction_cs(const LVector3 &dir) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(!dir.is_nan()); _info.m_wheelDirectionCS = LVecBase3_to_btVector3(dir); @@ -393,6 +432,7 @@ set_wheel_direction_cs(const LVector3 &dir) { */ LVector3 BulletWheel:: get_wheel_direction_cs() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LVector3(_info.m_wheelDirectionCS); } @@ -402,6 +442,7 @@ get_wheel_direction_cs() const { */ void BulletWheel:: set_wheel_axle_cs(const LVector3 &axle) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(!axle.is_nan()); _info.m_wheelAxleCS = LVecBase3_to_btVector3(axle); @@ -412,6 +453,7 @@ set_wheel_axle_cs(const LVector3 &axle) { */ LVector3 BulletWheel:: get_wheel_axle_cs() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btVector3_to_LVector3(_info.m_wheelAxleCS); } @@ -421,6 +463,7 @@ get_wheel_axle_cs() const { */ void BulletWheel:: set_world_transform(const LMatrix4 &mat) { + LightMutexHolder holder(BulletWorld::get_global_lock()); nassertv(!mat.is_nan()); _info.m_worldTransform = LMatrix4_to_btTrans(mat); @@ -431,6 +474,7 @@ set_world_transform(const LMatrix4 &mat) { */ LMatrix4 BulletWheel:: get_world_transform() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return btTrans_to_LMatrix4(_info.m_worldTransform); } @@ -440,6 +484,7 @@ get_world_transform() const { */ void BulletWheel:: set_front_wheel(bool value) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.m_bIsFrontWheel = value; } @@ -449,6 +494,7 @@ set_front_wheel(bool value) { */ bool BulletWheel:: is_front_wheel() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return _info.m_bIsFrontWheel; } @@ -458,6 +504,7 @@ is_front_wheel() const { */ void BulletWheel:: set_node(PandaNode *node) { + LightMutexHolder holder(BulletWorld::get_global_lock()); _info.m_clientInfo = (void *)node; } @@ -468,6 +515,87 @@ set_node(PandaNode *node) { */ PandaNode *BulletWheel:: get_node() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); return (_info.m_clientInfo == NULL) ? NULL : (PandaNode *)_info.m_clientInfo; } + +/** + * + */ +bool BulletWheelRaycastInfo:: +is_in_contact() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return _info.m_isInContact; +} + +/** + * + */ +PN_stdfloat BulletWheelRaycastInfo:: +get_suspension_length() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return _info.m_suspensionLength; +} + +/** + * + */ +LPoint3 BulletWheelRaycastInfo:: +get_contact_point_ws() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btVector3_to_LPoint3(_info.m_contactPointWS); +} + +/** + * + */ +LPoint3 BulletWheelRaycastInfo:: +get_hard_point_ws() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btVector3_to_LPoint3(_info.m_hardPointWS); +} + +/** + * + */ +LVector3 BulletWheelRaycastInfo:: +get_contact_normal_ws() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btVector3_to_LVector3(_info.m_contactNormalWS); +} + +/** + * + */ +LVector3 BulletWheelRaycastInfo:: +get_wheel_direction_ws() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btVector3_to_LVector3(_info.m_wheelDirectionWS); +} + +/** + * + */ +LVector3 BulletWheelRaycastInfo:: +get_wheel_axle_ws() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return btVector3_to_LVector3(_info.m_wheelAxleWS); +} + +/** + * + */ +PandaNode *BulletWheelRaycastInfo:: +get_ground_object() const { + LightMutexHolder holder(BulletWorld::get_global_lock()); + + return _info.m_groundObject ? (PandaNode *)_info.m_groundObject : NULL; +} diff --git a/panda/src/bullet/bulletWheel.h b/panda/src/bullet/bulletWheel.h index 2b6ecd8a80..414ecd94f3 100644 --- a/panda/src/bullet/bulletWheel.h +++ b/panda/src/bullet/bulletWheel.h @@ -30,14 +30,14 @@ class EXPCL_PANDABULLET BulletWheelRaycastInfo { PUBLISHED: INLINE ~BulletWheelRaycastInfo(); - INLINE bool is_in_contact() const; - INLINE PN_stdfloat get_suspension_length() const; - INLINE LVector3 get_contact_normal_ws() const; - INLINE LVector3 get_wheel_direction_ws() const; - INLINE LVector3 get_wheel_axle_ws() const; - INLINE LPoint3 get_contact_point_ws() const; - INLINE LPoint3 get_hard_point_ws() const; - INLINE PandaNode *get_ground_object() const; + bool is_in_contact() const; + PN_stdfloat get_suspension_length() const; + LVector3 get_contact_normal_ws() const; + LVector3 get_wheel_direction_ws() const; + LVector3 get_wheel_axle_ws() const; + LPoint3 get_contact_point_ws() const; + LPoint3 get_hard_point_ws() const; + PandaNode *get_ground_object() const; MAKE_PROPERTY(in_contact, is_in_contact); MAKE_PROPERTY(suspension_length, get_suspension_length); diff --git a/panda/src/bullet/bulletWorld.I b/panda/src/bullet/bulletWorld.I index c2ecd2cec3..61893a1531 100644 --- a/panda/src/bullet/bulletWorld.I +++ b/panda/src/bullet/bulletWorld.I @@ -50,19 +50,6 @@ INLINE BulletWorld:: delete _broadphase; } -/** - * - */ -INLINE void BulletWorld:: -set_debug_node(BulletDebugNode *node) { - nassertv(node); - if (node != _debug) { - clear_debug_node(); - _debug = node; - _world->setDebugDrawer(&(_debug->_drawer)); - } -} - /** * */ @@ -108,125 +95,3 @@ get_dispatcher() const { return _dispatcher; } -/** - * - */ -INLINE int BulletWorld:: -get_num_rigid_bodies() const { - - return _bodies.size(); -} - -/** - * - */ -INLINE BulletRigidBodyNode *BulletWorld:: -get_rigid_body(int idx) const { - - nassertr(idx >= 0 && idx < (int)_bodies.size(), NULL); - return _bodies[idx]; -} - -/** - * - */ -INLINE int BulletWorld:: -get_num_soft_bodies() const { - - return _softbodies.size(); -} - -/** - * - */ -INLINE BulletSoftBodyNode *BulletWorld:: -get_soft_body(int idx) const { - - nassertr(idx >= 0 && idx < (int)_softbodies.size(), NULL); - return _softbodies[idx]; -} - -/** - * - */ -INLINE int BulletWorld:: -get_num_ghosts() const { - - return _ghosts.size(); -} - -/** - * - */ -INLINE BulletGhostNode *BulletWorld:: -get_ghost(int idx) const { - - nassertr(idx >= 0 && idx < (int)_ghosts.size(), NULL); - return _ghosts[idx]; -} - -/** - * - */ -INLINE int BulletWorld:: -get_num_characters() const { - - return _characters.size(); -} - -/** - * - */ -INLINE BulletBaseCharacterControllerNode *BulletWorld:: -get_character(int idx) const { - - nassertr(idx >= 0 && idx < (int)_characters.size(), NULL); - return _characters[idx]; -} - -/** - * - */ -INLINE int BulletWorld:: -get_num_vehicles() const { - - return _vehicles.size(); -} - -/** - * - */ -INLINE BulletVehicle *BulletWorld:: -get_vehicle(int idx) const { - - nassertr(idx >= 0 && idx < (int)_vehicles.size(), NULL); - return _vehicles[idx]; -} - -/** - * - */ -INLINE int BulletWorld:: -get_num_constraints() const { - - return _constraints.size(); -} - -/** - * - */ -INLINE BulletConstraint *BulletWorld:: -get_constraint(int idx) const { - - nassertr(idx >= 0 && idx < (int)_constraints.size(), NULL); - return _constraints[idx]; -} - -/** - * - */ -INLINE int BulletWorld:: -get_num_manifolds() const { - - return _world->getDispatcher()->getNumManifolds(); -} diff --git a/panda/src/bullet/bulletWorld.cxx b/panda/src/bullet/bulletWorld.cxx index d60339f360..f3d48e3c74 100644 --- a/panda/src/bullet/bulletWorld.cxx +++ b/panda/src/bullet/bulletWorld.cxx @@ -118,6 +118,17 @@ BulletWorld() { _world->getSolverInfo().m_numIterations = bullet_solver_iterations; } +/** + * + */ +LightMutex &BulletWorld:: +get_global_lock() { + + static LightMutex lock; + + return lock; +} + /** * */ @@ -127,13 +138,33 @@ get_world_info() { return BulletSoftBodyWorldInfo(_info); } +/** + * + */ +void BulletWorld:: +set_debug_node(BulletDebugNode *node) { + LightMutexHolder holder(get_global_lock()); + + nassertv(node); + if (node != _debug) { + if (_debug != nullptr) { + _debug->_debug_stale = false; + _debug->_debug_world = nullptr; + } + + _debug = node; + _world->setDebugDrawer(&(_debug->_drawer)); + } +} + /** * Removes a debug node that has been assigned to this BulletWorld. */ void BulletWorld:: clear_debug_node() { + LightMutexHolder holder(get_global_lock()); + if (_debug != nullptr) { - LightMutexHolder holder(_debug->_lock); _debug->_debug_stale = false; _debug->_debug_world = nullptr; _world->setDebugDrawer(nullptr); @@ -146,6 +177,7 @@ clear_debug_node() { */ void BulletWorld:: set_gravity(const LVector3 &gravity) { + LightMutexHolder holder(get_global_lock()); _world->setGravity(LVecBase3_to_btVector3(gravity)); _info.m_gravity.setValue(gravity.get_x(), gravity.get_y(), gravity.get_z()); @@ -156,6 +188,7 @@ set_gravity(const LVector3 &gravity) { */ void BulletWorld:: set_gravity(PN_stdfloat gx, PN_stdfloat gy, PN_stdfloat gz) { + LightMutexHolder holder(get_global_lock()); _world->setGravity(btVector3((btScalar)gx, (btScalar)gy, (btScalar)gz)); _info.m_gravity.setValue((btScalar)gx, (btScalar)gy, (btScalar)gz); @@ -166,6 +199,7 @@ set_gravity(PN_stdfloat gx, PN_stdfloat gy, PN_stdfloat gz) { */ const LVector3 BulletWorld:: get_gravity() const { + LightMutexHolder holder(get_global_lock()); return btVector3_to_LVector3(_world->getGravity()); } @@ -175,6 +209,7 @@ get_gravity() const { */ int BulletWorld:: do_physics(PN_stdfloat dt, int max_substeps, PN_stdfloat stepsize) { + LightMutexHolder holder(get_global_lock()); _pstat_physics.start(); @@ -182,7 +217,7 @@ do_physics(PN_stdfloat dt, int max_substeps, PN_stdfloat stepsize) { // Synchronize Panda to Bullet _pstat_p2b.start(); - sync_p2b(dt, num_substeps); + do_sync_p2b(dt, num_substeps); _pstat_p2b.stop(); // Simulation @@ -192,13 +227,13 @@ do_physics(PN_stdfloat dt, int max_substeps, PN_stdfloat stepsize) { // Synchronize Bullet to Panda _pstat_b2p.start(); - sync_b2p(); + do_sync_b2p(); _info.m_sparsesdf.GarbageCollect(bullet_gc_lifetime); _pstat_b2p.stop(); // Render debug if (_debug) { - _debug->sync_b2p(_world); + _debug->do_sync_b2p(_world); } _pstat_physics.stop(); @@ -207,52 +242,52 @@ do_physics(PN_stdfloat dt, int max_substeps, PN_stdfloat stepsize) { } /** - * + * Assumes the lock(bullet global lock) is held by the caller */ void BulletWorld:: -sync_p2b(PN_stdfloat dt, int num_substeps) { +do_sync_p2b(PN_stdfloat dt, int num_substeps) { - for (int i=0; i < get_num_rigid_bodies(); i++) { - get_rigid_body(i)->sync_p2b(); + for (int i=0; i < _bodies.size(); i++) { + _bodies[i]->do_sync_p2b(); } - for (int i=0; i < get_num_soft_bodies(); i++) { - get_soft_body(i)->sync_p2b(); + for (int i=0; i < _softbodies.size(); i++) { + _softbodies[i]->do_sync_p2b(); } - for (int i=0; i < get_num_ghosts(); i++) { - get_ghost(i)->sync_p2b(); + for (int i=0; i < _ghosts.size(); i++) { + _ghosts[i]->do_sync_p2b(); } - for (int i=0; i < get_num_characters(); i++) { - get_character(i)->sync_p2b(dt, num_substeps); + for (int i=0; i < _characters.size(); i++) { + _characters[i]->do_sync_p2b(dt, num_substeps); } } /** - * + * Assumes the lock(bullet global lock) is held by the caller */ void BulletWorld:: -sync_b2p() { +do_sync_b2p() { - for (int i=0; i < get_num_vehicles(); i++) { - get_vehicle(i)->sync_b2p(); + for (int i=0; i < _vehicles.size(); i++) { + _vehicles[i]->do_sync_b2p(); } - for (int i=0; i < get_num_rigid_bodies(); i++) { - get_rigid_body(i)->sync_b2p(); + for (int i=0; i < _bodies.size(); i++) { + _bodies[i]->do_sync_b2p(); } - for (int i=0; i < get_num_soft_bodies(); i++) { - get_soft_body(i)->sync_b2p(); + for (int i=0; i < _softbodies.size(); i++) { + _softbodies[i]->do_sync_b2p(); } - for (int i=0; i < get_num_ghosts(); i++) { - get_ghost(i)->sync_b2p(); + for (int i=0; i < _ghosts.size(); i++) { + _ghosts[i]->do_sync_b2p(); } - for (int i=0; i < get_num_characters(); i++) { - get_character(i)->sync_b2p(); + for (int i=0; i < _characters.size(); i++) { + _characters[i]->do_sync_b2p(); } } @@ -261,24 +296,25 @@ sync_b2p() { */ void BulletWorld:: attach(TypedObject *object) { + LightMutexHolder holder(get_global_lock()); if (object->is_of_type(BulletGhostNode::get_class_type())) { - attach_ghost(DCAST(BulletGhostNode, object)); + do_attach_ghost(DCAST(BulletGhostNode, object)); } else if (object->is_of_type(BulletRigidBodyNode::get_class_type())) { - attach_rigid_body(DCAST(BulletRigidBodyNode, object)); + do_attach_rigid_body(DCAST(BulletRigidBodyNode, object)); } else if (object->is_of_type(BulletSoftBodyNode::get_class_type())) { - attach_soft_body(DCAST(BulletSoftBodyNode, object)); + do_attach_soft_body(DCAST(BulletSoftBodyNode, object)); } else if (object->is_of_type(BulletBaseCharacterControllerNode::get_class_type())) { - attach_character(DCAST(BulletBaseCharacterControllerNode, object)); + do_attach_character(DCAST(BulletBaseCharacterControllerNode, object)); } else if (object->is_of_type(BulletVehicle::get_class_type())) { - attach_vehicle(DCAST(BulletVehicle, object)); + do_attach_vehicle(DCAST(BulletVehicle, object)); } else if (object->is_of_type(BulletConstraint::get_class_type())) { - attach_constraint(DCAST(BulletConstraint, object)); + do_attach_constraint(DCAST(BulletConstraint, object)); } else { bullet_cat->error() << "not a bullet world object!" << endl; @@ -290,24 +326,25 @@ attach(TypedObject *object) { */ void BulletWorld:: remove(TypedObject *object) { + LightMutexHolder holder(get_global_lock()); if (object->is_of_type(BulletGhostNode::get_class_type())) { - remove_ghost(DCAST(BulletGhostNode, object)); + do_remove_ghost(DCAST(BulletGhostNode, object)); } else if (object->is_of_type(BulletRigidBodyNode::get_class_type())) { - remove_rigid_body(DCAST(BulletRigidBodyNode, object)); + do_remove_rigid_body(DCAST(BulletRigidBodyNode, object)); } else if (object->is_of_type(BulletSoftBodyNode::get_class_type())) { - remove_soft_body(DCAST(BulletSoftBodyNode, object)); + do_remove_soft_body(DCAST(BulletSoftBodyNode, object)); } else if (object->is_of_type(BulletBaseCharacterControllerNode::get_class_type())) { - remove_character(DCAST(BulletBaseCharacterControllerNode, object)); + do_remove_character(DCAST(BulletBaseCharacterControllerNode, object)); } else if (object->is_of_type(BulletVehicle::get_class_type())) { - remove_vehicle(DCAST(BulletVehicle, object)); + do_remove_vehicle(DCAST(BulletVehicle, object)); } else if (object->is_of_type(BulletConstraint::get_class_type())) { - remove_constraint(DCAST(BulletConstraint, object)); + do_remove_constraint(DCAST(BulletConstraint, object)); } else { bullet_cat->error() << "not a bullet world object!" << endl; @@ -319,6 +356,127 @@ remove(TypedObject *object) { */ void BulletWorld:: attach_rigid_body(BulletRigidBodyNode *node) { + LightMutexHolder holder(get_global_lock()); + + do_attach_rigid_body(node); +} + +/** + * Deprecated.! Please use BulletWorld::remove + */ +void BulletWorld:: +remove_rigid_body(BulletRigidBodyNode *node) { + LightMutexHolder holder(get_global_lock()); + + do_remove_rigid_body(node); +} + +/** + * Deprecated! Please use BulletWorld::attach + */ +void BulletWorld:: +attach_soft_body(BulletSoftBodyNode *node) { + LightMutexHolder holder(get_global_lock()); + + do_attach_soft_body(node); +} + +/** + * Deprecated.! Please use BulletWorld::remove + */ +void BulletWorld:: +remove_soft_body(BulletSoftBodyNode *node) { + LightMutexHolder holder(get_global_lock()); + + do_remove_soft_body(node); +} + +/** + * Deprecated! Please use BulletWorld::attach + */ +void BulletWorld:: +attach_ghost(BulletGhostNode *node) { + LightMutexHolder holder(get_global_lock()); + + do_attach_ghost(node); +} + +/** + * Deprecated.! Please use BulletWorld::remove + */ +void BulletWorld:: +remove_ghost(BulletGhostNode *node) { + LightMutexHolder holder(get_global_lock()); + + do_remove_ghost(node); +} + +/** + * Deprecated! Please use BulletWorld::attach + */ +void BulletWorld:: +attach_character(BulletBaseCharacterControllerNode *node) { + LightMutexHolder holder(get_global_lock()); + + do_attach_character(node); +} + +/** + * Deprecated.! Please use BulletWorld::remove + */ +void BulletWorld:: +remove_character(BulletBaseCharacterControllerNode *node) { + LightMutexHolder holder(get_global_lock()); + + do_remove_character(node); +} + +/** + * Deprecated! Please use BulletWorld::attach + */ +void BulletWorld:: +attach_vehicle(BulletVehicle *vehicle) { + LightMutexHolder holder(get_global_lock()); + + do_attach_vehicle(vehicle); +} + +/** + * Deprecated.! Please use BulletWorld::remove + */ +void BulletWorld:: +remove_vehicle(BulletVehicle *vehicle) { + LightMutexHolder holder(get_global_lock()); + + do_remove_vehicle(vehicle); +} + +/** + * Attaches a single constraint to a world. Collision checks between the + * linked objects will be disabled if the second parameter is set to TRUE. + */ +void BulletWorld:: +attach_constraint(BulletConstraint *constraint, bool linked_collision) { + LightMutexHolder holder(get_global_lock()); + + do_attach_constraint(constraint, linked_collision); +} + +/** + * Deprecated.! Please use BulletWorld::remove + */ +void BulletWorld:: +remove_constraint(BulletConstraint *constraint) { + LightMutexHolder holder(get_global_lock()); + + do_remove_constraint(constraint); +} + +/** + * Assumes the lock(bullet global lock) is held by the caller + */ +void BulletWorld:: +do_attach_rigid_body(BulletRigidBodyNode *node) { nassertv(node); @@ -338,10 +496,10 @@ attach_rigid_body(BulletRigidBodyNode *node) { } /** - * Deprecated.! Please use BulletWorld::remove + * Assumes the lock(bullet global lock) is held by the caller */ void BulletWorld:: -remove_rigid_body(BulletRigidBodyNode *node) { +do_remove_rigid_body(BulletRigidBodyNode *node) { nassertv(node); @@ -361,10 +519,10 @@ remove_rigid_body(BulletRigidBodyNode *node) { } /** - * Deprecated! Please use BulletWorld::attach + * Assumes the lock(bullet global lock) is held by the caller */ void BulletWorld:: -attach_soft_body(BulletSoftBodyNode *node) { +do_attach_soft_body(BulletSoftBodyNode *node) { nassertv(node); @@ -388,10 +546,10 @@ attach_soft_body(BulletSoftBodyNode *node) { } /** - * Deprecated.! Please use BulletWorld::remove + * Assumes the lock(bullet global lock) is held by the caller */ void BulletWorld:: -remove_soft_body(BulletSoftBodyNode *node) { +do_remove_soft_body(BulletSoftBodyNode *node) { nassertv(node); @@ -411,10 +569,10 @@ remove_soft_body(BulletSoftBodyNode *node) { } /** - * Deprecated! Please use BulletWorld::attach + * Assumes the lock(bullet global lock) is held by the caller */ void BulletWorld:: -attach_ghost(BulletGhostNode *node) { +do_attach_ghost(BulletGhostNode *node) { nassertv(node); @@ -452,10 +610,10 @@ enum CollisionFilterGroups { } /** - * Deprecated.! Please use BulletWorld::remove + * Assumes the lock(bullet global lock) is held by the caller */ void BulletWorld:: -remove_ghost(BulletGhostNode *node) { +do_remove_ghost(BulletGhostNode *node) { nassertv(node); @@ -475,10 +633,10 @@ remove_ghost(BulletGhostNode *node) { } /** - * Deprecated! Please use BulletWorld::attach + * Assumes the lock(bullet global lock) is held by the caller */ void BulletWorld:: -attach_character(BulletBaseCharacterControllerNode *node) { +do_attach_character(BulletBaseCharacterControllerNode *node) { nassertv(node); @@ -501,10 +659,10 @@ attach_character(BulletBaseCharacterControllerNode *node) { } /** - * Deprecated.! Please use BulletWorld::remove + * Assumes the lock(bullet global lock) is held by the caller */ void BulletWorld:: -remove_character(BulletBaseCharacterControllerNode *node) { +do_remove_character(BulletBaseCharacterControllerNode *node) { nassertv(node); @@ -523,10 +681,10 @@ remove_character(BulletBaseCharacterControllerNode *node) { } /** - * Deprecated! Please use BulletWorld::attach + * Assumes the lock(bullet global lock) is held by the caller */ void BulletWorld:: -attach_vehicle(BulletVehicle *vehicle) { +do_attach_vehicle(BulletVehicle *vehicle) { nassertv(vehicle); @@ -544,14 +702,14 @@ attach_vehicle(BulletVehicle *vehicle) { } /** - * Deprecated.! Please use BulletWorld::remove + * Assumes the lock(bullet global lock) is held by the caller */ void BulletWorld:: -remove_vehicle(BulletVehicle *vehicle) { +do_remove_vehicle(BulletVehicle *vehicle) { nassertv(vehicle); - remove_rigid_body(vehicle->get_chassis()); + do_remove_rigid_body(vehicle->do_get_chassis()); BulletVehicles::iterator found; PT(BulletVehicle) ptvehicle = vehicle; @@ -569,9 +727,10 @@ remove_vehicle(BulletVehicle *vehicle) { /** * Attaches a single constraint to a world. Collision checks between the * linked objects will be disabled if the second parameter is set to TRUE. + * Assumes the lock(bullet global lock) is held by the caller */ void BulletWorld:: -attach_constraint(BulletConstraint *constraint, bool linked_collision) { +do_attach_constraint(BulletConstraint *constraint, bool linked_collision) { nassertv(constraint); @@ -589,10 +748,10 @@ attach_constraint(BulletConstraint *constraint, bool linked_collision) { } /** - * Deprecated.! Please use BulletWorld::remove + * Assumes the lock(bullet global lock) is held by the caller */ void BulletWorld:: -remove_constraint(BulletConstraint *constraint) { +do_remove_constraint(BulletConstraint *constraint) { nassertv(constraint); @@ -609,11 +768,148 @@ remove_constraint(BulletConstraint *constraint) { } } +/** + * + */ +int BulletWorld:: +get_num_rigid_bodies() const { + LightMutexHolder holder(get_global_lock()); + + return _bodies.size(); +} + +/** + * + */ +BulletRigidBodyNode *BulletWorld:: +get_rigid_body(int idx) const { + LightMutexHolder holder(get_global_lock()); + + nassertr(idx >= 0 && idx < (int)_bodies.size(), NULL); + return _bodies[idx]; +} + +/** + * + */ +int BulletWorld:: +get_num_soft_bodies() const { + LightMutexHolder holder(get_global_lock()); + + return _softbodies.size(); +} + +/** + * + */ +BulletSoftBodyNode *BulletWorld:: +get_soft_body(int idx) const { + LightMutexHolder holder(get_global_lock()); + + nassertr(idx >= 0 && idx < (int)_softbodies.size(), NULL); + return _softbodies[idx]; +} + +/** + * + */ +int BulletWorld:: +get_num_ghosts() const { + LightMutexHolder holder(get_global_lock()); + + return _ghosts.size(); +} + +/** + * + */ +BulletGhostNode *BulletWorld:: +get_ghost(int idx) const { + LightMutexHolder holder(get_global_lock()); + + nassertr(idx >= 0 && idx < (int)_ghosts.size(), NULL); + return _ghosts[idx]; +} + +/** + * + */ +int BulletWorld:: +get_num_characters() const { + LightMutexHolder holder(get_global_lock()); + + return _characters.size(); +} + +/** + * + */ +BulletBaseCharacterControllerNode *BulletWorld:: +get_character(int idx) const { + LightMutexHolder holder(get_global_lock()); + + nassertr(idx >= 0 && idx < (int)_characters.size(), NULL); + return _characters[idx]; +} + +/** + * + */ +int BulletWorld:: +get_num_vehicles() const { + LightMutexHolder holder(get_global_lock()); + + return _vehicles.size(); +} + +/** + * + */ +BulletVehicle *BulletWorld:: +get_vehicle(int idx) const { + LightMutexHolder holder(get_global_lock()); + + nassertr(idx >= 0 && idx < (int)_vehicles.size(), NULL); + return _vehicles[idx]; +} + +/** + * + */ +int BulletWorld:: +get_num_constraints() const { + LightMutexHolder holder(get_global_lock()); + + return _constraints.size(); +} + +/** + * + */ +BulletConstraint *BulletWorld:: +get_constraint(int idx) const { + LightMutexHolder holder(get_global_lock()); + + nassertr(idx >= 0 && idx < (int)_constraints.size(), NULL); + return _constraints[idx]; +} + +/** + * + */ +int BulletWorld:: +get_num_manifolds() const { + LightMutexHolder holder(get_global_lock()); + + return _world->getDispatcher()->getNumManifolds(); +} + /** * */ BulletClosestHitRayResult BulletWorld:: ray_test_closest(const LPoint3 &from_pos, const LPoint3 &to_pos, const CollideMask &mask) const { + LightMutexHolder holder(get_global_lock()); nassertr(!from_pos.is_nan(), BulletClosestHitRayResult::empty()); nassertr(!to_pos.is_nan(), BulletClosestHitRayResult::empty()); @@ -631,6 +927,7 @@ ray_test_closest(const LPoint3 &from_pos, const LPoint3 &to_pos, const CollideMa */ BulletAllHitsRayResult BulletWorld:: ray_test_all(const LPoint3 &from_pos, const LPoint3 &to_pos, const CollideMask &mask) const { + LightMutexHolder holder(get_global_lock()); nassertr(!from_pos.is_nan(), BulletAllHitsRayResult::empty()); nassertr(!to_pos.is_nan(), BulletAllHitsRayResult::empty()); @@ -648,13 +945,16 @@ ray_test_all(const LPoint3 &from_pos, const LPoint3 &to_pos, const CollideMask & */ BulletClosestHitSweepResult BulletWorld:: sweep_test_closest(BulletShape *shape, const TransformState &from_ts, const TransformState &to_ts, const CollideMask &mask, PN_stdfloat penetration) const { + LightMutexHolder holder(get_global_lock()); nassertr(shape, BulletClosestHitSweepResult::empty()); - nassertr(shape->is_convex(), BulletClosestHitSweepResult::empty()); + + const btConvexShape *convex = (const btConvexShape *) shape->ptr(); + nassertr(convex->isConvex(), BulletClosestHitSweepResult::empty()); + nassertr(!from_ts.is_invalid(), BulletClosestHitSweepResult::empty()); nassertr(!to_ts.is_invalid(), BulletClosestHitSweepResult::empty()); - const btConvexShape *convex = (const btConvexShape *) shape->ptr(); const btVector3 from_pos = LVecBase3_to_btVector3(from_ts.get_pos()); const btVector3 to_pos = LVecBase3_to_btVector3(to_ts.get_pos()); const btTransform from_trans = LMatrix4_to_btTrans(from_ts.get_mat()); @@ -671,6 +971,7 @@ sweep_test_closest(BulletShape *shape, const TransformState &from_ts, const Tran */ bool BulletWorld:: filter_test(PandaNode *node0, PandaNode *node1) const { + LightMutexHolder holder(get_global_lock()); nassertr(node0, false); nassertr(node1, false); @@ -702,6 +1003,7 @@ filter_test(PandaNode *node0, PandaNode *node1) const { */ BulletContactResult BulletWorld:: contact_test(PandaNode *node, bool use_filter) const { + LightMutexHolder holder(get_global_lock()); btCollisionObject *obj = get_collision_object(node); @@ -727,6 +1029,7 @@ contact_test(PandaNode *node, bool use_filter) const { */ BulletContactResult BulletWorld:: contact_test_pair(PandaNode *node0, PandaNode *node1) const { + LightMutexHolder holder(get_global_lock()); btCollisionObject *obj0 = get_collision_object(node0); btCollisionObject *obj1 = get_collision_object(node1); @@ -746,6 +1049,7 @@ contact_test_pair(PandaNode *node0, PandaNode *node1) const { */ BulletPersistentManifold *BulletWorld:: get_manifold(int idx) const { + LightMutexHolder holder(get_global_lock()); nassertr(idx < get_num_manifolds(), NULL); @@ -780,6 +1084,7 @@ get_collision_object(PandaNode *node) { */ void BulletWorld:: set_group_collision_flag(unsigned int group1, unsigned int group2, bool enable) { + LightMutexHolder holder(get_global_lock()); if (bullet_filter_algorithm != FA_groups_mask) { bullet_cat.warning() << "filter algorithm is not 'groups-mask'" << endl; @@ -794,6 +1099,7 @@ set_group_collision_flag(unsigned int group1, unsigned int group2, bool enable) */ bool BulletWorld:: get_group_collision_flag(unsigned int group1, unsigned int group2) const { + LightMutexHolder holder(get_global_lock()); return _filter_cb2._collide[group1].get_bit(group2); } @@ -803,6 +1109,7 @@ get_group_collision_flag(unsigned int group1, unsigned int group2) const { */ void BulletWorld:: set_contact_added_callback(CallbackObject *obj) { + LightMutexHolder holder(get_global_lock()); _world->getSolverInfo().m_solverMode |= SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION; _world->getSolverInfo().m_solverMode |= SOLVER_USE_2_FRICTION_DIRECTIONS; @@ -816,6 +1123,7 @@ set_contact_added_callback(CallbackObject *obj) { */ void BulletWorld:: clear_contact_added_callback() { + LightMutexHolder holder(get_global_lock()); _world->getSolverInfo().m_solverMode &= ~SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION; _world->getSolverInfo().m_solverMode &= ~SOLVER_USE_2_FRICTION_DIRECTIONS; @@ -829,6 +1137,7 @@ clear_contact_added_callback() { */ void BulletWorld:: set_tick_callback(CallbackObject *obj, bool is_pretick) { + LightMutexHolder holder(get_global_lock()); nassertv(obj != NULL); _tick_callback_obj = obj; @@ -840,6 +1149,7 @@ set_tick_callback(CallbackObject *obj, bool is_pretick) { */ void BulletWorld:: clear_tick_callback() { + LightMutexHolder holder(get_global_lock()); _tick_callback_obj = NULL; _world->setInternalTickCallback(NULL); @@ -866,6 +1176,7 @@ tick_callback(btDynamicsWorld *world, btScalar timestep) { */ void BulletWorld:: set_filter_callback(CallbackObject *obj) { + LightMutexHolder holder(get_global_lock()); nassertv(obj != NULL); @@ -881,6 +1192,7 @@ set_filter_callback(CallbackObject *obj) { */ void BulletWorld:: clear_filter_callback() { + LightMutexHolder holder(get_global_lock()); _filter_cb3._filter_callback_obj = NULL; } diff --git a/panda/src/bullet/bulletWorld.h b/panda/src/bullet/bulletWorld.h index 558d086b37..021b6ee268 100644 --- a/panda/src/bullet/bulletWorld.h +++ b/panda/src/bullet/bulletWorld.h @@ -37,6 +37,7 @@ #include "callbackObject.h" #include "collideMask.h" #include "luse.h" +#include "lightMutex.h" class BulletPersistentManifold; class BulletShape; @@ -62,48 +63,43 @@ PUBLISHED: BulletSoftBodyWorldInfo get_world_info(); // Debug - INLINE void set_debug_node(BulletDebugNode *node); + void set_debug_node(BulletDebugNode *node); void clear_debug_node(); INLINE BulletDebugNode *get_debug_node() const; INLINE bool has_debug_node() const; // AttachRemove void attach(TypedObject *object); + void remove(TypedObject *object); void attach_constraint(BulletConstraint *constraint, bool linked_collision=false); - void remove(TypedObject *object); - // Ghost object - INLINE int get_num_ghosts() const; - INLINE BulletGhostNode *get_ghost(int idx) const; + int get_num_ghosts() const; + BulletGhostNode *get_ghost(int idx) const; MAKE_SEQ(get_ghosts, get_num_ghosts, get_ghost); // Rigid body - INLINE int get_num_rigid_bodies() const; - INLINE BulletRigidBodyNode *get_rigid_body(int idx) const; + int get_num_rigid_bodies() const; + BulletRigidBodyNode *get_rigid_body(int idx) const; MAKE_SEQ(get_rigid_bodies, get_num_rigid_bodies, get_rigid_body); // Soft body - INLINE int get_num_soft_bodies() const; - INLINE BulletSoftBodyNode *get_soft_body(int idx) const; + int get_num_soft_bodies() const; + BulletSoftBodyNode *get_soft_body(int idx) const; MAKE_SEQ(get_soft_bodies, get_num_soft_bodies, get_soft_body); // Character controller - INLINE int get_num_characters() const; - INLINE BulletBaseCharacterControllerNode *get_character(int idx) const; + int get_num_characters() const; + BulletBaseCharacterControllerNode *get_character(int idx) const; MAKE_SEQ(get_characters, get_num_characters, get_character); - // Vehicle - void attach_vehicle(BulletVehicle *vehicle); - void remove_vehicle(BulletVehicle *vehicle); - - INLINE int get_num_vehicles() const; - INLINE BulletVehicle *get_vehicle(int idx) const; + int get_num_vehicles() const; + BulletVehicle *get_vehicle(int idx) const; MAKE_SEQ(get_vehicles, get_num_vehicles, get_vehicle); // Constraint - INLINE int get_num_constraints() const; - INLINE BulletConstraint *get_constraint(int idx) const; + int get_num_constraints() const; + BulletConstraint *get_constraint(int idx) const; MAKE_SEQ(get_constraints, get_num_constraints, get_constraint); // Raycast and other queries @@ -130,7 +126,7 @@ PUBLISHED: bool filter_test(PandaNode *node0, PandaNode *node1) const; // Manifolds - INLINE int get_num_manifolds() const; + int get_num_manifolds() const; BulletPersistentManifold *get_manifold(int idx) const; MAKE_SEQ(get_manifolds, get_num_manifolds, get_manifold); @@ -171,7 +167,7 @@ PUBLISHED: MAKE_SEQ_PROPERTY(constraints, get_num_constraints, get_constraint); MAKE_SEQ_PROPERTY(manifolds, get_num_manifolds, get_manifold); -PUBLISHED: // Deprecated methods, will become private soon +PUBLISHED: // Deprecated methods, will be removed soon void attach_ghost(BulletGhostNode *node); void remove_ghost(BulletGhostNode *node); @@ -184,6 +180,9 @@ PUBLISHED: // Deprecated methods, will become private soon void attach_character(BulletBaseCharacterControllerNode *node); void remove_character(BulletBaseCharacterControllerNode *node); + void attach_vehicle(BulletVehicle *vehicle); + void remove_vehicle(BulletVehicle *vehicle); + void remove_constraint(BulletConstraint *constraint); public: @@ -193,9 +192,29 @@ public: INLINE btBroadphaseInterface *get_broadphase() const; INLINE btDispatcher *get_dispatcher() const; + static LightMutex &get_global_lock(); + private: - void sync_p2b(PN_stdfloat dt, int num_substeps); - void sync_b2p(); + void do_sync_p2b(PN_stdfloat dt, int num_substeps); + void do_sync_b2p(); + + void do_attach_ghost(BulletGhostNode *node); + void do_remove_ghost(BulletGhostNode *node); + + void do_attach_rigid_body(BulletRigidBodyNode *node); + void do_remove_rigid_body(BulletRigidBodyNode *node); + + void do_attach_soft_body(BulletSoftBodyNode *node); + void do_remove_soft_body(BulletSoftBodyNode *node); + + void do_attach_character(BulletBaseCharacterControllerNode *node); + void do_remove_character(BulletBaseCharacterControllerNode *node); + + void do_attach_vehicle(BulletVehicle *vehicle); + void do_remove_vehicle(BulletVehicle *vehicle); + + void do_attach_constraint(BulletConstraint *constraint, bool linked_collision=false); + void do_remove_constraint(BulletConstraint *constraint); static void tick_callback(btDynamicsWorld *world, btScalar timestep); From 6c7894f68dab1d8096bc98bc208e051550f1ec4e Mon Sep 17 00:00:00 2001 From: deflected Date: Wed, 21 Feb 2018 15:26:38 +0100 Subject: [PATCH 029/247] terrain: set ShaderTerrainMesh heightfield wrap mode to clamp --- panda/src/grutil/shaderTerrainMesh.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/panda/src/grutil/shaderTerrainMesh.cxx b/panda/src/grutil/shaderTerrainMesh.cxx index a7f6b1d8af..8aac5f0e9a 100644 --- a/panda/src/grutil/shaderTerrainMesh.cxx +++ b/panda/src/grutil/shaderTerrainMesh.cxx @@ -150,6 +150,8 @@ void ShaderTerrainMesh::do_extract_heightfield() { } _heightfield_tex->set_minfilter(SamplerState::FT_linear); _heightfield_tex->set_magfilter(SamplerState::FT_linear); + _heightfield_tex->set_wrap_u(SamplerState::WM_clamp); + _heightfield_tex->set_wrap_v(SamplerState::WM_clamp); } /** From e0569815b536018369a39a7b3655546b4f897dc0 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 21 Feb 2018 15:56:45 +0100 Subject: [PATCH 030/247] tests: add test for prc page and one for light color temperature --- tests/pgraph/test_light.py | 20 ++++++++++++++++++++ tests/prc/test_config_page.py | 12 ++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 tests/pgraph/test_light.py create mode 100644 tests/prc/test_config_page.py diff --git a/tests/pgraph/test_light.py b/tests/pgraph/test_light.py new file mode 100644 index 0000000000..f303080b33 --- /dev/null +++ b/tests/pgraph/test_light.py @@ -0,0 +1,20 @@ +from panda3d import core + +def luminance(col): + return 0.2126 * col[0] + 0.7152 * col[1] + 0.0722 * col[2] + + +def test_light_colortemp(): + # Default is all white, assuming a D65 white point. + light = core.PointLight("light") + assert light.color == (1, 1, 1, 1) + assert light.color_temperature == 6500 + + # When setting color temp, it should preserve luminance. + for temp in range(2000, 15000): + light.color_temperature = temp + assert abs(luminance(light.color) - 1.0) < 0.001 + + # Setting it to the white point will make a white color. + light.color_temperature = 6500 + assert light.color.almost_equal((1, 1, 1, 1), 0.001) diff --git a/tests/prc/test_config_page.py b/tests/prc/test_config_page.py new file mode 100644 index 0000000000..5ca6cdb6ef --- /dev/null +++ b/tests/prc/test_config_page.py @@ -0,0 +1,12 @@ +from panda3d import core + +def test_load_unload_page(): + var = core.ConfigVariableInt("test-var", 1) + assert var.value == 1 + + page = core.load_prc_file_data("test_load_unload_page", "test-var 2") + assert page + assert var.value == 2 + + assert core.unload_prc_file(page) + assert var.value == 1 From 47a9aa4a80ec386909f3557d3dc3d2ccec0661f5 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 22 Feb 2018 02:02:02 -0700 Subject: [PATCH 031/247] bam: Simplify the resolve_*_pointers loops in BamReader This should also be a slight performance boost since breaking out of the loop upon discovering an incomplete child object means we don't bother resolving everything else just to discard it all. --- panda/src/putil/bamReader.cxx | 112 ++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 54 deletions(-) diff --git a/panda/src/putil/bamReader.cxx b/panda/src/putil/bamReader.cxx index 8831a1ca7e..d432d7a4ae 100644 --- a/panda/src/putil/bamReader.cxx +++ b/panda/src/putil/bamReader.cxx @@ -1345,35 +1345,39 @@ resolve_object_pointers(TypedWritable *object, if (child_id == 0) { // A NULL pointer is a NULL pointer. references.push_back((TypedWritable *)NULL); - - } else { - // See if we have the pointer available now. - CreatedObjs::const_iterator oi = _created_objs.find(child_id); - if (oi == _created_objs.end()) { - // No, too bad. - is_complete = false; - - } else { - const CreatedObj &child_obj = (*oi).second; - if (!child_obj._created) { - // The child object hasn't yet been created. - is_complete = false; - } else if (child_obj._change_this != NULL || child_obj._change_this_ref != NULL) { - // It's been created, but the pointer might still change. - is_complete = false; - } else { - if (require_fully_complete && - _object_pointers.find(child_id) != _object_pointers.end()) { - // It's not yet complete itself. - is_complete = false; - - } else { - // Yes, it's ready. - references.push_back(child_obj._ptr); - } - } - } + continue; } + + // See if we have the pointer available now. + CreatedObjs::const_iterator oi = _created_objs.find(child_id); + if (oi == _created_objs.end()) { + // No, too bad. + is_complete = false; + break; + } + + const CreatedObj &child_obj = (*oi).second; + if (!child_obj._created) { + // The child object hasn't yet been created. + is_complete = false; + break; + } + + if (child_obj._change_this != NULL || child_obj._change_this_ref != NULL) { + // It's been created, but the pointer might still change. + is_complete = false; + break; + } + + if (require_fully_complete && + _object_pointers.find(child_id) != _object_pointers.end()) { + // It's not yet complete itself. + is_complete = false; + break; + } + + // Yes, it's ready. + references.push_back(child_obj._ptr); } if (is_complete) { @@ -1433,33 +1437,33 @@ resolve_cycler_pointers(PipelineCyclerBase *cycler, if (child_id == 0) { // A NULL pointer is a NULL pointer. references.push_back((TypedWritable *)NULL); - - } else { - // See if we have the pointer available now. - CreatedObjs::const_iterator oi = _created_objs.find(child_id); - if (oi == _created_objs.end()) { - // No, too bad. - is_complete = false; - - } else { - const CreatedObj &child_obj = (*oi).second; - if (child_obj._change_this != NULL || child_obj._change_this_ref != NULL) { - // It's been created, but the pointer might still change. - is_complete = false; - - } else { - if (require_fully_complete && - _object_pointers.find(child_id) != _object_pointers.end()) { - // It's not yet complete itself. - is_complete = false; - - } else { - // Yes, it's ready. - references.push_back(child_obj._ptr); - } - } - } + continue; } + + // See if we have the pointer available now. + CreatedObjs::const_iterator oi = _created_objs.find(child_id); + if (oi == _created_objs.end()) { + // No, too bad. + is_complete = false; + break; + } + + const CreatedObj &child_obj = (*oi).second; + if (child_obj._change_this != NULL || child_obj._change_this_ref != NULL) { + // It's been created, but the pointer might still change. + is_complete = false; + break; + } + + if (require_fully_complete && + _object_pointers.find(child_id) != _object_pointers.end()) { + // It's not yet complete itself. + is_complete = false; + break; + } + + // Yes, it's ready. + references.push_back(child_obj._ptr); } if (is_complete) { From 293465a5161b621ec3dddb84e94924bcb74e0e60 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 22 Feb 2018 03:13:06 -0700 Subject: [PATCH 032/247] bam: Add sanity-check against object IDs appearing twice Found this by fuzzing; not concerned about updating the writer as the writer itself should never do this. This is just to protect against segfaults in the face of corrupt or malicious bams. --- panda/src/putil/bamReader.cxx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/panda/src/putil/bamReader.cxx b/panda/src/putil/bamReader.cxx index d432d7a4ae..30ad07415a 100644 --- a/panda/src/putil/bamReader.cxx +++ b/panda/src/putil/bamReader.cxx @@ -1159,6 +1159,16 @@ p_read_object() { // This object had already existed; thus, we are just receiving an // update for it. + if (_object_pointers.find(object_id) != _object_pointers.end()) { + // Aieee! This object isn't even complete from the last time we + // encountered it in the stream! This should never happen. Something's + // corrupt or the stream was maliciously crafted. + bam_cat.error() + << "Found object " << object_id << " in bam stream again while " + << "trying to resolve its own pointers.\n"; + return 0; + } + // Update _now_creating during this call so if this function calls // read_pointer() or register_change_this() we'll match it up properly. // This might recursively call back into this p_read_object(), so be From f8e321d155450615f1e7be41241e6ba87b687a05 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 22 Feb 2018 04:57:19 -0700 Subject: [PATCH 033/247] bam: Start more strongly checking pointer types in complete_pointers This just starts with PandaNode, and uses DCAST_INTO_R instead of DCAST to catch bad bams. BamWriter should never produce bam output that will trigger this; I found this with a fuzzer. I'm unsure about the tradeoff between bam loading performance and robustness in the face of bad bams. It certainly makes a lot of sense in debug builds, but we might want to consider a compile flag that forces bam-related asserts always on even in release builds. --- panda/src/pgraph/pandaNode.cxx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/panda/src/pgraph/pandaNode.cxx b/panda/src/pgraph/pandaNode.cxx index 0d64cb0828..96b94dd0c2 100644 --- a/panda/src/pgraph/pandaNode.cxx +++ b/panda/src/pgraph/pandaNode.cxx @@ -3798,9 +3798,13 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = CycleData::complete_pointers(p_list, manager); // Get the state and transform pointers. - _state = DCAST(RenderState, p_list[pi++]); - _transform = DCAST(TransformState, p_list[pi++]); - _prev_transform = _transform; + RenderState *state; + DCAST_INTO_R(state, p_list[pi++], pi); + _state = state; + + TransformState *transform; + DCAST_INTO_R(transform, p_list[pi++], pi); + _prev_transform = _transform = transform; /* * Finalize these pointers now to decrement their artificially-held reference @@ -3817,7 +3821,9 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { // Get the effects pointer. - _effects = DCAST(RenderEffects, p_list[pi++]); + RenderEffects *effects; + DCAST_INTO_R(effects, p_list[pi++], pi); + _effects = effects; /* * Finalize these pointers now to decrement their artificially-held reference From 04cb128140e6d5d2d5189f274e300dc957b5ba04 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 22 Feb 2018 15:18:34 -0700 Subject: [PATCH 034/247] cftalk: Remove this It was an incomplete experiment for distributing rendering pipelines over a LAN of computers all working in concert. Who knows, it may return someday. Until then, it's best not to keep it around. --- makepanda/makepanda.vcproj | 12 --- panda/src/cftalk/cfChannel.I | 12 --- panda/src/cftalk/cfChannel.cxx | 62 --------------- panda/src/cftalk/cfChannel.h | 44 ----------- panda/src/cftalk/cfCommand.I | 41 ---------- panda/src/cftalk/cfCommand.cxx | 93 ---------------------- panda/src/cftalk/cfCommand.h | 98 ------------------------ panda/src/cftalk/config_cftalk.cxx | 46 ----------- panda/src/cftalk/config_cftalk.h | 36 --------- panda/src/cftalk/p3cftalk_composite1.cxx | 1 - panda/src/cftalk/p3cftalk_composite2.cxx | 1 - 11 files changed, 446 deletions(-) delete mode 100644 panda/src/cftalk/cfChannel.I delete mode 100644 panda/src/cftalk/cfChannel.cxx delete mode 100644 panda/src/cftalk/cfChannel.h delete mode 100644 panda/src/cftalk/cfCommand.I delete mode 100644 panda/src/cftalk/cfCommand.cxx delete mode 100644 panda/src/cftalk/cfCommand.h delete mode 100644 panda/src/cftalk/config_cftalk.cxx delete mode 100644 panda/src/cftalk/config_cftalk.h delete mode 100644 panda/src/cftalk/p3cftalk_composite1.cxx delete mode 100644 panda/src/cftalk/p3cftalk_composite2.cxx diff --git a/makepanda/makepanda.vcproj b/makepanda/makepanda.vcproj index a787653e1e..c21322f94a 100644 --- a/makepanda/makepanda.vcproj +++ b/makepanda/makepanda.vcproj @@ -3736,18 +3736,6 @@ - - - - - - - - - - - - diff --git a/panda/src/cftalk/cfChannel.I b/panda/src/cftalk/cfChannel.I deleted file mode 100644 index 4bb6a1c3fa..0000000000 --- a/panda/src/cftalk/cfChannel.I +++ /dev/null @@ -1,12 +0,0 @@ -/** - * PANDA 3D SOFTWARE - * Copyright (c) Carnegie Mellon University. All rights reserved. - * - * All use of this software is subject to the terms of the revised BSD - * license. You should have received a copy of this license along - * with this source code in a file named "LICENSE." - * - * @file cfChannel.I - * @author drose - * @date 2009-03-26 - */ diff --git a/panda/src/cftalk/cfChannel.cxx b/panda/src/cftalk/cfChannel.cxx deleted file mode 100644 index e63ba79077..0000000000 --- a/panda/src/cftalk/cfChannel.cxx +++ /dev/null @@ -1,62 +0,0 @@ -/** - * PANDA 3D SOFTWARE - * Copyright (c) Carnegie Mellon University. All rights reserved. - * - * All use of this software is subject to the terms of the revised BSD - * license. You should have received a copy of this license along - * with this source code in a file named "LICENSE." - * - * @file cfChannel.cxx - * @author drose - * @date 2009-03-26 - */ - -#include "cfChannel.h" - -/** - * The DatagramGenerator and DatagramSink should be newly created on the free - * store (via the new operator). The CFChannel will take ownership of these - * pointers, and will delete them when it destructs. - */ -CFChannel:: -CFChannel(DatagramGenerator *dggen, DatagramSink *dgsink) : - _dggen(dggen), - _dgsink(dgsink), - _reader(dggen), - _writer(dgsink) -{ - bool ok1 = _reader.init(); - bool ok2 = _writer.init(); - nassertv(ok1 && ok2); -} - -/** - * - */ -CFChannel:: -~CFChannel() { - delete _dggen; - delete _dgsink; -} - -/** - * Delivers a single command to the process at the other end of the channel. - */ -void CFChannel:: -send_command(CFCommand *command) { - bool ok = _writer.write_object(command); - nassertv(ok); -} - -/** - * Receives a single command from the process at the other end of the channel. - * If no command is ready, the thread will block until one is. Returns NULL - * when the connection has been closed. - */ -PT(CFCommand) CFChannel:: -receive_command() { - TypedWritable *obj = _reader.read_object(); - CFCommand *command; - DCAST_INTO_R(command, obj, NULL); - return command; -} diff --git a/panda/src/cftalk/cfChannel.h b/panda/src/cftalk/cfChannel.h deleted file mode 100644 index e549327efa..0000000000 --- a/panda/src/cftalk/cfChannel.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * PANDA 3D SOFTWARE - * Copyright (c) Carnegie Mellon University. All rights reserved. - * - * All use of this software is subject to the terms of the revised BSD - * license. You should have received a copy of this license along - * with this source code in a file named "LICENSE." - * - * @file cfChannel.h - * @author drose - * @date 2009-03-26 - */ - -#ifndef CFCHANNEL_H -#define CFCHANNEL_H - -#include "pandabase.h" -#include "referenceCount.h" -#include "bamReader.h" -#include "bamWriter.h" -#include "cfCommand.h" - -/** - * Represents an open communication channel in the connected-frame protocol. - * Commands may be sent and received on this channel. - */ -class EXPCL_CFTALK CFChannel : public ReferenceCount { -public: - CFChannel(DatagramGenerator *dggen, DatagramSink *dgsink); - ~CFChannel(); - - void send_command(CFCommand *command); - PT(CFCommand) receive_command(); - -private: - DatagramGenerator *_dggen; - DatagramSink *_dgsink; - BamReader _reader; - BamWriter _writer; -}; - -#include "cfChannel.I" - -#endif diff --git a/panda/src/cftalk/cfCommand.I b/panda/src/cftalk/cfCommand.I deleted file mode 100644 index fea651c96f..0000000000 --- a/panda/src/cftalk/cfCommand.I +++ /dev/null @@ -1,41 +0,0 @@ -/** - * PANDA 3D SOFTWARE - * Copyright (c) Carnegie Mellon University. All rights reserved. - * - * All use of this software is subject to the terms of the revised BSD - * license. You should have received a copy of this license along - * with this source code in a file named "LICENSE." - * - * @file cfCommand.I - * @author drose - * @date 2009-02-19 - */ - -/** - * - */ -INLINE CFCommand:: -CFCommand() { -} - -/** - * - */ -INLINE CFDoCullCommand:: -CFDoCullCommand() { -} - -/** - * - */ -INLINE CFDoCullCommand:: -CFDoCullCommand(PandaNode *scene) : _scene(scene) { -} - -/** - * - */ -INLINE PandaNode *CFDoCullCommand:: -get_scene() const { - return _scene; -} diff --git a/panda/src/cftalk/cfCommand.cxx b/panda/src/cftalk/cfCommand.cxx deleted file mode 100644 index ca58163242..0000000000 --- a/panda/src/cftalk/cfCommand.cxx +++ /dev/null @@ -1,93 +0,0 @@ -/** - * PANDA 3D SOFTWARE - * Copyright (c) Carnegie Mellon University. All rights reserved. - * - * All use of this software is subject to the terms of the revised BSD - * license. You should have received a copy of this license along - * with this source code in a file named "LICENSE." - * - * @file cfCommand.cxx - * @author drose - * @date 2009-02-19 - */ - -#include "cfCommand.h" - -TypeHandle CFCommand::_type_handle; -TypeHandle CFDoCullCommand::_type_handle; - -/** - * - */ -CFCommand:: -~CFCommand() { -} - -/** - * Tells the BamReader how to create objects of type CFDoCullCommand. - */ -void CFDoCullCommand:: -register_with_read_factory() { - BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); -} - -/** - * Writes the contents of this object to the datagram for shipping out to a - * Bam file. - */ -void CFDoCullCommand:: -write_datagram(BamWriter *manager, Datagram &dg) { - TypedWritable::write_datagram(manager, dg); - manager->write_pointer(dg, _scene); -} - -/** - * Called by the BamWriter when this object has not itself been modified - * recently, but it should check its nested objects for updates. - */ -void CFDoCullCommand:: -update_bam_nested(BamWriter *manager) { - manager->consider_update(_scene); -} - -/** - * Receives an array of pointers, one for each time manager->read_pointer() - * was called in fillin(). Returns the number of pointers processed. - */ -int CFDoCullCommand:: -complete_pointers(TypedWritable **p_list, BamReader *manager) { - int pi = TypedWritable::complete_pointers(p_list, manager); - - PandaNode *scene; - DCAST_INTO_R(scene, p_list[pi++], pi); - _scene = scene; - - return pi; -} - -/** - * This function is called by the BamReader's factory when a new object of - * type CFDoCullCommand is encountered in the Bam file. It should create the - * CFDoCullCommand and extract its information from the file. - */ -TypedWritable *CFDoCullCommand:: -make_from_bam(const FactoryParams ¶ms) { - CFDoCullCommand *node = new CFDoCullCommand; - DatagramIterator scan; - BamReader *manager; - - parse_params(params, scan, manager); - node->fillin(scan, manager); - - return node; -} - -/** - * This internal function is called by make_from_bam to read in all of the - * relevant data from the BamFile for the new CFDoCullCommand. - */ -void CFDoCullCommand:: -fillin(DatagramIterator &scan, BamReader *manager) { - TypedWritable::fillin(scan, manager); - manager->read_pointer(scan); -} diff --git a/panda/src/cftalk/cfCommand.h b/panda/src/cftalk/cfCommand.h deleted file mode 100644 index 84e7e1421c..0000000000 --- a/panda/src/cftalk/cfCommand.h +++ /dev/null @@ -1,98 +0,0 @@ -/** - * PANDA 3D SOFTWARE - * Copyright (c) Carnegie Mellon University. All rights reserved. - * - * All use of this software is subject to the terms of the revised BSD - * license. You should have received a copy of this license along - * with this source code in a file named "LICENSE." - * - * @file cfCommand.h - * @author drose - * @date 2009-02-19 - */ - -#ifndef CFCOMMAND_H -#define CFCOMMAND_H - -#include "pandabase.h" - -#include "typedWritableReferenceCount.h" -#include "pandaNode.h" - -/** - * A single command in the Connected-Frame protocol. This can be sent client- - * to-server or server-to-client. - * - * This is an abstract base class. Individual commands will specialize from - * this. - */ -class EXPCL_CFTALK CFCommand : public TypedWritableReferenceCount { -protected: - CFCommand(); - -PUBLISHED: - virtual ~CFCommand(); - -public: - static TypeHandle get_class_type() { - return _type_handle; - } - static void init_type() { - TypedWritableReferenceCount::init_type(); - register_type(_type_handle, "CFCommand", - TypedWritableReferenceCount::get_class_type()); - } - virtual TypeHandle get_type() const { - return get_class_type(); - } - virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - -private: - static TypeHandle _type_handle; -}; - -/** - * Starts the cull process for a particular DisplayRegion. - */ -class EXPCL_CFTALK CFDoCullCommand : public CFCommand { -protected: - INLINE CFDoCullCommand(); -PUBLISHED: - INLINE CFDoCullCommand(PandaNode *scene); - - INLINE PandaNode *get_scene() const; - -private: - PT(PandaNode) _scene; - -public: - static void register_with_read_factory(); - virtual void write_datagram(BamWriter *manager, Datagram &dg); - virtual void update_bam_nested(BamWriter *manager); - virtual int complete_pointers(TypedWritable **plist, BamReader *manager); - -protected: - static TypedWritable *make_from_bam(const FactoryParams ¶ms); - void fillin(DatagramIterator &scan, BamReader *manager); - -public: - static TypeHandle get_class_type() { - return _type_handle; - } - static void init_type() { - CFCommand::init_type(); - register_type(_type_handle, "CFDoCullCommand", - CFCommand::get_class_type()); - } - virtual TypeHandle get_type() const { - return get_class_type(); - } - virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - -private: - static TypeHandle _type_handle; -}; - -#include "cfCommand.I" - -#endif diff --git a/panda/src/cftalk/config_cftalk.cxx b/panda/src/cftalk/config_cftalk.cxx deleted file mode 100644 index 42c5054526..0000000000 --- a/panda/src/cftalk/config_cftalk.cxx +++ /dev/null @@ -1,46 +0,0 @@ -/** - * PANDA 3D SOFTWARE - * Copyright (c) Carnegie Mellon University. All rights reserved. - * - * All use of this software is subject to the terms of the revised BSD - * license. You should have received a copy of this license along - * with this source code in a file named "LICENSE." - * - * @file config_cftalk.cxx - * @author drose - * @date 2009-03-26 - */ - -#include "config_cftalk.h" -#include "cfCommand.h" -#include "pandaSystem.h" - -ConfigureDef(config_cftalk); -NotifyCategoryDef(cftalk, ""); - -ConfigureFn(config_cftalk) { - init_libcftalk(); -} - -/** - * Initializes the library. This must be called at least once before any of - * the functions or classes in this library can be used. Normally it will be - * called by the static initializers and need not be called explicitly, but - * special cases exist. - */ -void -init_libcftalk() { - static bool initialized = false; - if (initialized) { - return; - } - initialized = true; - - CFCommand::init_type(); - CFDoCullCommand::init_type(); - - CFDoCullCommand::register_with_read_factory(); - - PandaSystem *ps = PandaSystem::get_global_ptr(); - ps->add_system("cftalk"); -} diff --git a/panda/src/cftalk/config_cftalk.h b/panda/src/cftalk/config_cftalk.h deleted file mode 100644 index 707c5f182d..0000000000 --- a/panda/src/cftalk/config_cftalk.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * PANDA 3D SOFTWARE - * Copyright (c) Carnegie Mellon University. All rights reserved. - * - * All use of this software is subject to the terms of the revised BSD - * license. You should have received a copy of this license along - * with this source code in a file named "LICENSE." - * - * @file config_cftalk.h - * @author drose - * @date 2009-03-26 - */ - -#ifndef CONFIG_CFTALK_H -#define CONFIG_CFTALK_H - -#include "pandabase.h" -#include "windowProperties.h" -#include "notifyCategoryProxy.h" -#include "configVariableBool.h" -#include "configVariableString.h" -#include "configVariableList.h" -#include "configVariableInt.h" -#include "configVariableEnum.h" -#include "configVariableFilename.h" -#include "coordinateSystem.h" -#include "dconfig.h" - -#include "pvector.h" - -ConfigureDecl(config_cftalk, EXPCL_CFTALK, EXPTP_CFTALK); -NotifyCategoryDecl(cftalk, EXPCL_CFTALK, EXPTP_CFTALK); - -extern EXPCL_CFTALK void init_libcftalk(); - -#endif /* CONFIG_CFTALK_H */ diff --git a/panda/src/cftalk/p3cftalk_composite1.cxx b/panda/src/cftalk/p3cftalk_composite1.cxx deleted file mode 100644 index 49525d942d..0000000000 --- a/panda/src/cftalk/p3cftalk_composite1.cxx +++ /dev/null @@ -1 +0,0 @@ -#include "cfCommand.cxx" diff --git a/panda/src/cftalk/p3cftalk_composite2.cxx b/panda/src/cftalk/p3cftalk_composite2.cxx deleted file mode 100644 index 79c8aa9fa6..0000000000 --- a/panda/src/cftalk/p3cftalk_composite2.cxx +++ /dev/null @@ -1 +0,0 @@ -#include "cfChannel.cxx" From 10f1ffa9a7fd353166e7b339f94190e6363566ae Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 23 Feb 2018 01:27:34 -0700 Subject: [PATCH 035/247] express: Fix Datagram::modify_array() This just copies the array initialization out of append_data, so a COW/uninitialized Datagram can be initialized with modify_array() --- panda/src/express/datagram.I | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/panda/src/express/datagram.I b/panda/src/express/datagram.I index 0ad4007b26..fa6063805b 100644 --- a/panda/src/express/datagram.I +++ b/panda/src/express/datagram.I @@ -408,6 +408,17 @@ get_array() const { */ INLINE PTA_uchar Datagram:: modify_array() { + if (_data == (uchar *)NULL) { + // Create a new array. + _data = PTA_uchar::empty_array(0); + + } else if (_data.get_ref_count() != 1) { + // Copy on write. + PTA_uchar new_data = PTA_uchar::empty_array(0); + new_data.v() = _data.v(); + _data = new_data; + } + return _data; } From e3cc3eff8261c2b1413108ea2cda32282e6f3802 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 23 Feb 2018 01:29:04 -0700 Subject: [PATCH 036/247] putil: Optimize DatagramInputFile::get_datagram This new loop is better in two ways: 1) It reads straight into the Datagram's internal buffer, saving the trouble of allocating an intermediate buffer and wasting CPU time to copy out of it. 2) It's more cautious in the face of large (>4MB) lengths, which are more likely to be due to corruption than the datagram *actually* being that large. --- panda/src/putil/datagramInputFile.cxx | 39 +++++++++++++-------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/panda/src/putil/datagramInputFile.cxx b/panda/src/putil/datagramInputFile.cxx index 1ac14b58ed..f3bd8a081e 100644 --- a/panda/src/putil/datagramInputFile.cxx +++ b/panda/src/putil/datagramInputFile.cxx @@ -147,37 +147,34 @@ get_datagram(Datagram &data) { // Make sure we have a reasonable datagram size for putting into memory. nassertr(num_bytes == (size_t)num_bytes, false); - // Now, read the datagram itself. + // Now, read the datagram itself. We construct an empty datagram, use + // pad_bytes to make it big enough, and read *directly* into the datagram's + // internal buffer. Doing this saves us a copy operation. + data = Datagram(); - // If the number of bytes is large, we will need to allocate a temporary - // buffer from the heap. Otherwise, we can get away with allocating it on - // the stack, via alloca(). - if (num_bytes > 65536) { - char *buffer = (char *)PANDA_MALLOC_ARRAY(num_bytes); - nassertr(buffer != (char *)NULL, false); + streamsize bytes_read = 0; + while (bytes_read < num_bytes) { + streamsize bytes_left = num_bytes - bytes_read; - _in->read(buffer, num_bytes); - if (_in->fail() || _in->eof()) { - _error = true; - PANDA_FREE_ARRAY(buffer); - return false; - } + // Hold up a second - datagrams >4MB are pretty large by bam/network + // standards. Let's take it 4MB at a time just in case the length is + // corrupt, so we don't allocate potentially a few GBs of RAM only to + // find a truncated file. + bytes_left = min(bytes_left, (streamsize)4*1024*1024); - data = Datagram(buffer, num_bytes); - PANDA_FREE_ARRAY(buffer); + PTA_uchar buffer = data.modify_array(); + buffer.resize(buffer.size() + bytes_left); + unsigned char *ptr = &buffer.p()[bytes_read]; - } else { - char *buffer = (char *)alloca(num_bytes); - nassertr(buffer != (char *)NULL, false); - - _in->read(buffer, num_bytes); + _in->read((char *)ptr, bytes_left); if (_in->fail() || _in->eof()) { _error = true; return false; } - data = Datagram(buffer, num_bytes); + bytes_read += bytes_left; } + Thread::consider_yield(); return true; From 89be2c19af74c62b57961469c779b324c69979f1 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 23 Feb 2018 03:07:47 -0700 Subject: [PATCH 037/247] tests: Add tests for Datagram{,Iterator,InputFile,OutputFile} This also includes a test for my previous commit which changes DatagramInputFile::get_datagram(). --- tests/putil/test_datagram.py | 149 +++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 tests/putil/test_datagram.py diff --git a/tests/putil/test_datagram.py b/tests/putil/test_datagram.py new file mode 100644 index 0000000000..4a34bc88a2 --- /dev/null +++ b/tests/putil/test_datagram.py @@ -0,0 +1,149 @@ +import pytest +from panda3d import core + +# Fixtures for generating interesting datagrams (and verification functions) on +# the fly... + +@pytest.fixture(scope='module', + params=[False, True], + ids=['stdfloat_float', 'stdfloat_double']) +def datagram_small(request): + """Returns a small datagram, along with a verification function.""" + dg = core.Datagram() + + dg.set_stdfloat_double(request.param) + + dg.add_uint8(3) + dg.add_uint16(14159) + dg.add_uint32(0xDEADBEEF) + dg.add_uint64(0x0123456789ABCDEF) + + dg.add_int8(-77) + dg.add_int16(-1) + dg.add_int32(-972965890) + dg.add_int64(-1001001001001001) + + dg.add_string('this is a string') + dg.add_string32('this is another string') + dg.add_string('this is yet a third string') + + dg.add_stdfloat(800.2) + dg.add_stdfloat(3.1415926) + dg.add_stdfloat(2.7182818) + + def readback_function(dgi): + assert dgi.get_remaining_size() > 0 + + assert dgi.get_uint8() == 3 + assert dgi.get_uint16() == 14159 + assert dgi.get_uint32() == 0xDEADBEEF + assert dgi.get_uint64() == 0x0123456789ABCDEF + + assert dgi.get_int8() == -77 + assert dgi.get_int16() == -1 + assert dgi.get_int32() == -972965890 + assert dgi.get_int64() == -1001001001001001 + + assert dgi.get_string() == 'this is a string' + assert dgi.get_string32() == 'this is another string' + assert dgi.get_string() == 'this is yet a third string' + + assert dgi.get_stdfloat() == pytest.approx(800.2) + assert dgi.get_stdfloat() == pytest.approx(3.1415926) + assert dgi.get_stdfloat() == pytest.approx(2.7182818) + + assert dgi.get_remaining_size() == 0 + + return dg, readback_function + +@pytest.fixture(scope='module') +def datagram_large(): + """Returns a big datagram, along with a verification function.""" + + dg = core.Datagram() + for x in range(2000000): + dg.add_uint32(x) + dg.add_string('the magic words are squeamish ossifrage') + + def readback_function(dgi): + assert dgi.get_remaining_size() > 0 + + for x in range(2000000): + assert dgi.get_uint32() == x + assert dgi.get_string() == 'the magic words are squeamish ossifrage' + + assert dgi.get_remaining_size() == 0 + + return dg, readback_function + +def test_iterator(datagram_small): + """This tests Datagram/DatagramIterator, and sort of serves as a self-check + of the test fixtures too.""" + dg, verify = datagram_small + + dgi = core.DatagramIterator(dg) + verify(dgi) + + +# These test DatagramInputFile/DatagramOutputFile: + +def do_file_test(dg, verify, filename): + dof = core.DatagramOutputFile() + dof.open(filename) + dof.put_datagram(dg) + dof.close() + + dg2 = core.Datagram() + dif = core.DatagramInputFile() + dif.open(filename) + assert dif.get_datagram(dg2) + dif.close() + + # This is normally saved by the DatagramOutputFile header. We cheat here. + dg2.set_stdfloat_double(dg.get_stdfloat_double()) + + dgi = core.DatagramIterator(dg2) + verify(dgi) + +def test_file_small(datagram_small, tmpdir): + """This tests DatagramOutputFile/DatagramInputFile on small datagrams.""" + dg, verify = datagram_small + + p = tmpdir.join('datagram.bin') + filename = core.Filename.from_os_specific(str(p)) + + do_file_test(dg, verify, filename) + +def test_file_large(datagram_large, tmpdir): + """This tests DatagramOutputFile/DatagramInputFile on very large datagrams.""" + dg, verify = datagram_large + + p = tmpdir.join('datagram.bin') + filename = core.Filename.from_os_specific(str(p)) + + do_file_test(dg, verify, filename) + +def test_file_corrupt(datagram_small, tmpdir): + """This tests DatagramInputFile's handling of a corrupt size header.""" + dg, verify = datagram_small + + p = tmpdir.join('datagram.bin') + filename = core.Filename.from_os_specific(str(p)) + + dof = core.DatagramOutputFile() + dof.open(filename) + dof.put_datagram(dg) + dof.close() + + # Corrupt the size header to 4GB + with p.open(mode='wb') as f: + f.seek(0) + f.write(b'\xFF\xFF\xFF\xFF') + + dg2 = core.Datagram() + dif = core.DatagramInputFile() + dif.open(filename) + assert not dif.get_datagram(dg2) + dif.close() + + # Should we test that dg2 is unmodified? From 8fd4584bd0625b653c60465161ce15bcd57be0b4 Mon Sep 17 00:00:00 2001 From: deflected Date: Fri, 23 Feb 2018 13:37:07 +0200 Subject: [PATCH 038/247] grutil: Add control over heightfield filtering in shaderTerrainMesh Signed-off-by: deflected --- panda/src/grutil/shaderTerrainMesh.cxx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/panda/src/grutil/shaderTerrainMesh.cxx b/panda/src/grutil/shaderTerrainMesh.cxx index 8aac5f0e9a..8c9c7bd9b6 100644 --- a/panda/src/grutil/shaderTerrainMesh.cxx +++ b/panda/src/grutil/shaderTerrainMesh.cxx @@ -52,6 +52,18 @@ ConfigVariableInt stm_max_views "with. Each camera rendering the terrain corresponds to a view. Lowering this " "value will reduce the data that has to be transferred to the GPU.")); +ConfigVariableEnum stm_heightfield_minfilter +("stm-heightfield-minfilter", SamplerState::FT_linear, + PRC_DESC("This specifies the minfilter that is applied for a heightfield texture. This " + "can be used to create heightfield that is visual correct with collision " + "geometry (for example bullet terrain mesh) by changing it to nearest")); + +ConfigVariableEnum stm_heightfield_magfilter +("stm-heightfield-magfilter", SamplerState::FT_linear, + PRC_DESC("This specifies the magfilter that is applied for a heightfield texture. This " + "can be used to create heightfield that is visual correct with collision " + "geometry (for example bullet terrain mesh) by changing it to nearest")); + PStatCollector ShaderTerrainMesh::_basic_collector("Cull:ShaderTerrainMesh:Setup"); PStatCollector ShaderTerrainMesh::_lod_collector("Cull:ShaderTerrainMesh:CollectLOD"); @@ -148,8 +160,8 @@ void ShaderTerrainMesh::do_extract_heightfield() { } else { _heightfield_tex->set_format(Texture::F_r16); } - _heightfield_tex->set_minfilter(SamplerState::FT_linear); - _heightfield_tex->set_magfilter(SamplerState::FT_linear); + _heightfield_tex->set_minfilter(stm_heightfield_minfilter); + _heightfield_tex->set_magfilter(stm_heightfield_magfilter); _heightfield_tex->set_wrap_u(SamplerState::WM_clamp); _heightfield_tex->set_wrap_v(SamplerState::WM_clamp); } From 0cf605ce7df868d7ec06d421480ef8ee0dd32094 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 23 Feb 2018 21:26:49 +0100 Subject: [PATCH 039/247] showbase: move run() and __dev__ to ShowBaseGlobal Also remove ShowBaseGlobal notify category, it doesn't really add anything --- direct/src/showbase/ShowBase.py | 8 +++----- direct/src/showbase/ShowBaseGlobal.py | 9 ++++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 580f2b6ce7..8e3c223000 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -47,10 +47,6 @@ if __debug__: from . import OnScreenDebug from . import AppRunnerGlobal -def legacyRun(): - assert builtins.base.notify.warning("run() is deprecated, use base.run() instead") - builtins.base.run() - @atexit.register def exitfunc(): if getattr(builtins, 'base', None) is not None: @@ -369,7 +365,6 @@ class ShowBase(DirectObject.DirectObject): builtins.bboard = self.bboard # Config needs to be defined before ShowBase is constructed #builtins.config = self.config - builtins.run = legacyRun builtins.ostream = Notify.out() builtins.directNotify = directNotify builtins.giveNotify = giveNotify @@ -391,7 +386,9 @@ class ShowBase(DirectObject.DirectObject): # Now add this instance to the ShowBaseGlobal module scope. from . import ShowBaseGlobal + builtins.run = ShowBaseGlobal.run ShowBaseGlobal.base = self + ShowBaseGlobal.__dev__ = self.__dev__ if self.__dev__: ShowBase.notify.debug('__dev__ == %s' % self.__dev__) @@ -515,6 +512,7 @@ class ShowBase(DirectObject.DirectObject): # Remove the built-in base reference if getattr(builtins, 'base', None) is self: + del builtins.run del builtins.base del builtins.loader del builtins.taskMgr diff --git a/direct/src/showbase/ShowBaseGlobal.py b/direct/src/showbase/ShowBaseGlobal.py index 1f1c81af1a..c18ebab5fc 100644 --- a/direct/src/showbase/ShowBaseGlobal.py +++ b/direct/src/showbase/ShowBaseGlobal.py @@ -14,6 +14,7 @@ from panda3d.core import ConfigPageManager, ConfigVariableManager from panda3d.direct import get_config_showbase config = get_config_showbase() +__dev__ = config.GetBool('want-dev', __debug__) vfs = VirtualFileSystem.getGlobalPtr() ostream = Notify.out() @@ -25,6 +26,10 @@ pandaSystem = PandaSystem.getGlobalPtr() # Set direct notify categories now that we have config directNotify.setDconfigLevels() +def run(): + assert ShowBase.notify.warning("run() is deprecated, use base.run() instead") + base.run() + def inspect(anObject): # Don't use a regular import, to prevent ModuleFinder from picking # it up as a dependency when building a .p3d package. @@ -41,6 +46,4 @@ builtins.inspect = inspect # this also appears in AIBaseGlobal if (not __debug__) and __dev__: - notify = directNotify.newCategory('ShowBaseGlobal') - notify.error("You must set 'want-dev' to false in non-debug mode.") - del notify + ShowBase.notify.error("You must set 'want-dev' to false in non-debug mode.") From e6c2d3b609036724adbdac5dc0cdf802c9a997e2 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 23 Feb 2018 22:15:34 +0100 Subject: [PATCH 040/247] showbase: allow DirectGui elements to be created before ShowBase This is done by precreating aspect2d inside ShowBaseGlobal. --- direct/src/gui/DirectGuiBase.py | 45 +++++++++++++-------------- direct/src/showbase/ShowBase.py | 12 +++++-- direct/src/showbase/ShowBaseGlobal.py | 4 +++ 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/direct/src/gui/DirectGuiBase.py b/direct/src/gui/DirectGuiBase.py index 6836f7465f..a0f153d07e 100644 --- a/direct/src/gui/DirectGuiBase.py +++ b/direct/src/gui/DirectGuiBase.py @@ -80,7 +80,8 @@ __all__ = ['DirectGuiBase', 'DirectGuiWidget'] from panda3d.core import * -from panda3d.direct import get_config_showbase +from direct.showbase import ShowBaseGlobal +from direct.showbase.ShowBase import ShowBase from . import DirectGuiGlobals as DGG from .OnscreenText import * from .OnscreenGeom import * @@ -633,7 +634,7 @@ class DirectGuiBase(DirectObject.DirectObject): """ # Need to tack on gui item specific id gEvent = event + self.guiId - if get_config_showbase().GetBool('debug-directgui-msgs', False): + if ShowBase.config.GetBool('debug-directgui-msgs', False): from direct.showbase.PythonUtil import StackTrace print(gEvent) print(StackTrace()) @@ -662,7 +663,7 @@ class DirectGuiWidget(DirectGuiBase, NodePath): # Determine the default initial state for inactive (or # unclickable) components. If we are in edit mode, these are # actually clickable by default. - guiEdit = get_config_showbase().GetBool('direct-gui-edit', 0) + guiEdit = ShowBase.config.GetBool('direct-gui-edit', False) if guiEdit: inactiveInitState = DGG.NORMAL else: @@ -723,21 +724,24 @@ class DirectGuiWidget(DirectGuiBase, NodePath): if self['guiId']: self.guiItem.setId(self['guiId']) self.guiId = self.guiItem.getId() - if __dev__: + + if ShowBaseGlobal.__dev__: guiObjectCollector.addLevel(1) guiObjectCollector.flushLevel() # track gui items by guiId for tracking down leaks - if hasattr(base, 'guiItems'): - if self.guiId in base.guiItems: - base.notify.warning('duplicate guiId: %s (%s stomping %s)' % - (self.guiId, self, - base.guiItems[self.guiId])) - base.guiItems[self.guiId] = self - if hasattr(base, 'printGuiCreates'): - printStack() + if ShowBase.config.GetBool('track-gui-items', True): + if not hasattr(ShowBase, 'guiItems'): + ShowBase.guiItems = {} + if self.guiId in ShowBase.guiItems: + ShowBase.notify.warning('duplicate guiId: %s (%s stomping %s)' % + (self.guiId, self, + ShowBase.guiItems[self.guiId])) + ShowBase.guiItems[self.guiId] = self + # Attach button to parent and make that self - if (parent == None): - parent = aspect2d + if parent is None: + parent = ShowBaseGlobal.aspect2d + self.assign(parent.attachNewNode(self.guiItem, self['sortOrder'])) # Update pose to initial values if self['pos']: @@ -1024,17 +1028,12 @@ class DirectGuiWidget(DirectGuiBase, NodePath): def destroy(self): if hasattr(self, "frameStyle"): - if __dev__: + if ShowBaseGlobal.__dev__: guiObjectCollector.subLevel(1) guiObjectCollector.flushLevel() - if hasattr(base, 'guiItems'): - if self.guiId in base.guiItems: - del base.guiItems[self.guiId] - else: - base.notify.warning( - 'DirectGuiWidget.destroy(): ' - 'gui item %s not in base.guiItems' % - self.guiId) + if hasattr(ShowBase, 'guiItems'): + ShowBase.guiItems.pop(self.guiId, None) + # Destroy children for child in self.getChildren(): childGui = self.guiDict.get(child.getName()) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 8e3c223000..fd25018634 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -400,7 +400,8 @@ class ShowBase(DirectObject.DirectObject): if self.__dev__ or self.config.GetBool('want-e3-hacks', False): if self.config.GetBool('track-gui-items', True): # dict of guiId to gui item, for tracking down leaks - self.guiItems = {} + if not hasattr(ShowBase, 'guiItems'): + ShowBase.guiItems = {} # optionally restore the default gui sounds from 1.7.2 and earlier if ConfigVariableBool('orig-gui-sounds', False).getValue(): @@ -520,6 +521,8 @@ class ShowBase(DirectObject.DirectObject): if ShowBaseGlobal: del ShowBaseGlobal.base + self.aspect2d.node().removeAllChildren() + # [gjeon] restore sticky key settings if self.config.GetBool('disable-sticky-keys', 0): allowAccessibilityShortcutKeys(True) @@ -1102,13 +1105,18 @@ class ShowBase(DirectObject.DirectObject): self.render2d.setMaterialOff(1) self.render2d.setTwoSided(1) + # We've already created aspect2d in ShowBaseGlobal, for the + # benefit of creating DirectGui elements before ShowBase. + from . import ShowBaseGlobal + ## The normal 2-d DisplayRegion has an aspect ratio that ## matches the window, but its coordinate system is square. ## This means anything we parent to render2d gets stretched. ## For things where that makes a difference, we set up ## aspect2d, which scales things back to the right aspect ## ratio along the X axis (Z is still from -1 to 1) - self.aspect2d = self.render2d.attachNewNode(PGTop("aspect2d")) + self.aspect2d = ShowBaseGlobal.aspect2d + self.aspect2d.reparentTo(self.render2d) aspectRatio = self.getAspectRatio() self.aspect2d.setScale(1.0 / aspectRatio, 1.0, 1.0) diff --git a/direct/src/showbase/ShowBaseGlobal.py b/direct/src/showbase/ShowBaseGlobal.py index c18ebab5fc..459d5f708f 100644 --- a/direct/src/showbase/ShowBaseGlobal.py +++ b/direct/src/showbase/ShowBaseGlobal.py @@ -11,6 +11,7 @@ from .ShowBase import ShowBase, WindowControls from direct.directnotify.DirectNotifyGlobal import directNotify, giveNotify from panda3d.core import VirtualFileSystem, Notify, ClockObject, PandaSystem from panda3d.core import ConfigPageManager, ConfigVariableManager +from panda3d.core import NodePath, PGTop from panda3d.direct import get_config_showbase config = get_config_showbase() @@ -23,6 +24,9 @@ cpMgr = ConfigPageManager.getGlobalPtr() cvMgr = ConfigVariableManager.getGlobalPtr() pandaSystem = PandaSystem.getGlobalPtr() +# This is defined here so GUI elements can be instantiated before ShowBase. +aspect2d = NodePath(PGTop("aspect2d")) + # Set direct notify categories now that we have config directNotify.setDconfigLevels() From aa90b7b0c052cc8b067d4ad960664b8b40dd8716 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 23 Feb 2018 22:25:24 +0100 Subject: [PATCH 041/247] showbase: disable track-gui-items by default, remove want-e3-hacks --- direct/src/gui/DirectGuiBase.py | 2 +- direct/src/showbase/ShowBase.py | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/direct/src/gui/DirectGuiBase.py b/direct/src/gui/DirectGuiBase.py index a0f153d07e..3180d0dfce 100644 --- a/direct/src/gui/DirectGuiBase.py +++ b/direct/src/gui/DirectGuiBase.py @@ -729,7 +729,7 @@ class DirectGuiWidget(DirectGuiBase, NodePath): guiObjectCollector.addLevel(1) guiObjectCollector.flushLevel() # track gui items by guiId for tracking down leaks - if ShowBase.config.GetBool('track-gui-items', True): + if ShowBase.config.GetBool('track-gui-items', False): if not hasattr(ShowBase, 'guiItems'): ShowBase.guiItems = {} if self.guiId in ShowBase.guiItems: diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index fd25018634..42ee315909 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -397,11 +397,10 @@ class ShowBase(DirectObject.DirectObject): self.createBaseAudioManagers() - if self.__dev__ or self.config.GetBool('want-e3-hacks', False): - if self.config.GetBool('track-gui-items', True): - # dict of guiId to gui item, for tracking down leaks - if not hasattr(ShowBase, 'guiItems'): - ShowBase.guiItems = {} + if self.__dev__ and self.config.GetBool('track-gui-items', False): + # dict of guiId to gui item, for tracking down leaks + if not hasattr(ShowBase, 'guiItems'): + ShowBase.guiItems = {} # optionally restore the default gui sounds from 1.7.2 and earlier if ConfigVariableBool('orig-gui-sounds', False).getValue(): From aaeb925e845b6a6d25d6c937c104676028e5ae05 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 23 Feb 2018 15:50:41 -0700 Subject: [PATCH 042/247] directtools: Fix typo in DirectSelection --- direct/src/directtools/DirectSelection.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/direct/src/directtools/DirectSelection.py b/direct/src/directtools/DirectSelection.py index ef14fb429b..49410656b3 100644 --- a/direct/src/directtools/DirectSelection.py +++ b/direct/src/directtools/DirectSelection.py @@ -623,8 +623,8 @@ class SelectionRay(SelectionQueue): def pickBitMask(self, bitMask = BitMask32.allOff(), targetNodePath = None, skipFlags = SKIP_ALL): - if parentNodePath is None: - parentNodePath = render + if targetNodePath is None: + targetNodePath = render self.collideWithBitMask(bitMask) self.pick(targetNodePath) # Determine collision entry From 97368ec321cbe18fcd01c997df6228512842f9cf Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 23 Feb 2018 15:41:03 -0700 Subject: [PATCH 043/247] distributed: Make a few slight cleanliness changes I brought all of these over from the Astron fork --- direct/src/distributed/CRDataCache.py | 2 ++ direct/src/distributed/ClientRepositoryBase.py | 2 +- direct/src/distributed/ConnectionRepository.py | 1 + direct/src/distributed/DistributedNode.py | 2 ++ direct/src/distributed/DistributedNodeUD.py | 1 - direct/src/distributed/DistributedObjectBase.py | 9 ++++++++- 6 files changed, 14 insertions(+), 3 deletions(-) diff --git a/direct/src/distributed/CRDataCache.py b/direct/src/distributed/CRDataCache.py index 85036544de..b28453c0a3 100755 --- a/direct/src/distributed/CRDataCache.py +++ b/direct/src/distributed/CRDataCache.py @@ -2,6 +2,8 @@ from direct.distributed.CachedDOData import CachedDOData from panda3d.core import ConfigVariableInt +__all__ = ["CRDataCache"] + class CRDataCache: # Stores cached data for DistributedObjects between instantiations on the client diff --git a/direct/src/distributed/ClientRepositoryBase.py b/direct/src/distributed/ClientRepositoryBase.py index 826d3058fd..c4555e94ec 100644 --- a/direct/src/distributed/ClientRepositoryBase.py +++ b/direct/src/distributed/ClientRepositoryBase.py @@ -263,7 +263,7 @@ class ClientRepositoryBase(ConnectionRepository): distObj.setLocation(parentId, zoneId) distObj.updateRequiredFields(dclass, di) # updateRequiredFields calls announceGenerate - print("New DO:%s, dclass:%s"%(doId, dclass.getName())) + self.notify.debug("New DO:%s, dclass:%s" % (doId, dclass.getName())) return distObj def generateWithRequiredOtherFields(self, dclass, doId, di, diff --git a/direct/src/distributed/ConnectionRepository.py b/direct/src/distributed/ConnectionRepository.py index 105b77a9a9..4d6dec5b81 100644 --- a/direct/src/distributed/ConnectionRepository.py +++ b/direct/src/distributed/ConnectionRepository.py @@ -10,6 +10,7 @@ from .PyDatagramIterator import PyDatagramIterator import types import gc +__all__ = ["ConnectionRepository", "GCTrigger"] class ConnectionRepository( DoInterestManager, DoCollectionManager, CConnectionRepository): diff --git a/direct/src/distributed/DistributedNode.py b/direct/src/distributed/DistributedNode.py index 1b0c3412dc..1a88fcc02a 100644 --- a/direct/src/distributed/DistributedNode.py +++ b/direct/src/distributed/DistributedNode.py @@ -15,6 +15,8 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath): self.DistributedNode_initialized = 1 self.gotStringParentToken = 0 DistributedObject.DistributedObject.__init__(self, cr) + if not self.this: + NodePath.__init__(self, "DistributedNode") # initialize gridParent self.gridParent = None diff --git a/direct/src/distributed/DistributedNodeUD.py b/direct/src/distributed/DistributedNodeUD.py index 21d6a2dbbb..39c0489f5e 100755 --- a/direct/src/distributed/DistributedNodeUD.py +++ b/direct/src/distributed/DistributedNodeUD.py @@ -1,4 +1,3 @@ -#from otp.ai.AIBaseGlobal import * from .DistributedObjectUD import DistributedObjectUD class DistributedNodeUD(DistributedObjectUD): diff --git a/direct/src/distributed/DistributedObjectBase.py b/direct/src/distributed/DistributedObjectBase.py index af5f2678f3..3d9b525067 100755 --- a/direct/src/distributed/DistributedObjectBase.py +++ b/direct/src/distributed/DistributedObjectBase.py @@ -1,4 +1,3 @@ - from direct.showbase.DirectObject import DirectObject from direct.directnotify.DirectNotifyGlobal import directNotify @@ -93,3 +92,11 @@ class DistributedObjectBase(DirectObject): def hasParentingRules(self): return self.dclass.getFieldByName('setParentingRules') != None + + def delete(self): + """ + Override this to handle cleanup right before this object + gets deleted. + """ + + pass From 167c6dcafab055a74bbec42bdf9749812e7d0ccb Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 23 Feb 2018 16:11:49 -0700 Subject: [PATCH 044/247] distributed: Change the message numbers to match Astron's I imagine very few Panda3D users depend on the message numbers having particular values. The ones removed belonged to Disney's OTP system, which hasn't been used by anybody in over 4 years. At any rate, old code should continue to work, just at the cost of compatibility between clients and servers running different P3D versions. --- direct/src/dcparser/dcClass.cxx | 8 +- direct/src/dcparser/dcField.cxx | 4 +- direct/src/dcparser/dcmsgtypes.h | 15 +- .../src/distributed/ClientRepositoryBase.py | 4 +- direct/src/distributed/MsgTypes.py | 216 ++++++++++-------- direct/src/distributed/MsgTypesCMU.py | 2 +- direct/src/distributed/OldClientRepository.py | 208 ----------------- .../src/distributed/cConnectionRepository.cxx | 10 +- .../cDistributedSmoothNodeBase.cxx | 4 +- 9 files changed, 148 insertions(+), 323 deletions(-) delete mode 100644 direct/src/distributed/OldClientRepository.py diff --git a/direct/src/dcparser/dcClass.cxx b/direct/src/dcparser/dcClass.cxx index 513d13fd90..302162c412 100644 --- a/direct/src/dcparser/dcClass.cxx +++ b/direct/src/dcparser/dcClass.cxx @@ -946,9 +946,9 @@ ai_format_generate(PyObject *distobj, DOID_TYPE do_id, bool has_optional_fields = (PyObject_IsTrue(optional_fields) != 0); if (has_optional_fields) { - packer.raw_pack_uint16(STATESERVER_OBJECT_GENERATE_WITH_REQUIRED_OTHER); + packer.raw_pack_uint16(STATESERVER_CREATE_OBJECT_WITH_REQUIRED_OTHER); } else { - packer.raw_pack_uint16(STATESERVER_OBJECT_GENERATE_WITH_REQUIRED); + packer.raw_pack_uint16(STATESERVER_CREATE_OBJECT_WITH_REQUIRED); } // Parent is a bit overloaded; this parent is not about inheritance, this @@ -1027,7 +1027,7 @@ ai_database_generate_context( packer.RAW_PACK_CHANNEL(database_server_id); packer.RAW_PACK_CHANNEL(from_channel_id); // packer.raw_pack_uint8('A'); - packer.raw_pack_uint16(STATESERVER_OBJECT_CREATE_WITH_REQUIRED_CONTEXT); + packer.raw_pack_uint16(STATESERVER_OBJECT_ENTER_WITH_REQUIRED_CONTEXT); packer.raw_pack_uint32(parent_id); packer.raw_pack_uint32(zone_id); packer.RAW_PACK_CHANNEL(owner_channel); @@ -1060,7 +1060,7 @@ ai_database_generate_context_old( packer.RAW_PACK_CHANNEL(database_server_id); packer.RAW_PACK_CHANNEL(from_channel_id); // packer.raw_pack_uint8('A'); - packer.raw_pack_uint16(STATESERVER_OBJECT_CREATE_WITH_REQUIRED_CONTEXT); + packer.raw_pack_uint16(STATESERVER_OBJECT_ENTER_WITH_REQUIRED_CONTEXT); packer.raw_pack_uint32(parent_id); packer.raw_pack_uint32(zone_id); packer.raw_pack_uint16(_number); // DCD class ID diff --git a/direct/src/dcparser/dcField.cxx b/direct/src/dcparser/dcField.cxx index 88b9786f51..a44412638a 100644 --- a/direct/src/dcparser/dcField.cxx +++ b/direct/src/dcparser/dcField.cxx @@ -391,7 +391,7 @@ Datagram DCField:: client_format_update(DOID_TYPE do_id, PyObject *args) const { DCPacker packer; - packer.raw_pack_uint16(CLIENT_OBJECT_UPDATE_FIELD); + packer.raw_pack_uint16(CLIENT_OBJECT_SET_FIELD); packer.raw_pack_uint32(do_id); packer.raw_pack_uint16(_number); @@ -417,7 +417,7 @@ ai_format_update(DOID_TYPE do_id, CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, PyOb packer.raw_pack_uint8(1); packer.RAW_PACK_CHANNEL(to_id); packer.RAW_PACK_CHANNEL(from_id); - packer.raw_pack_uint16(STATESERVER_OBJECT_UPDATE_FIELD); + packer.raw_pack_uint16(STATESERVER_OBJECT_SET_FIELD); packer.raw_pack_uint32(do_id); packer.raw_pack_uint16(_number); diff --git a/direct/src/dcparser/dcmsgtypes.h b/direct/src/dcparser/dcmsgtypes.h index e5bbe81614..0e83f384c0 100644 --- a/direct/src/dcparser/dcmsgtypes.h +++ b/direct/src/dcparser/dcmsgtypes.h @@ -17,16 +17,13 @@ // This file defines the server message types used within this module. It // duplicates some symbols defined in MsgTypes.py and AIMsgTypes.py. -#define CLIENT_OBJECT_UPDATE_FIELD 24 -#define CLIENT_CREATE_OBJECT_REQUIRED 34 -#define CLIENT_CREATE_OBJECT_REQUIRED_OTHER 35 +#define CLIENT_OBJECT_SET_FIELD 120 +#define CLIENT_ENTER_OBJECT_REQUIRED 142 +#define CLIENT_ENTER_OBJECT_REQUIRED_OTHER 143 -#define STATESERVER_OBJECT_GENERATE_WITH_REQUIRED 2001 -#define STATESERVER_OBJECT_GENERATE_WITH_REQUIRED_OTHER 2003 -#define STATESERVER_OBJECT_UPDATE_FIELD 2004 -#define STATESERVER_OBJECT_CREATE_WITH_REQUIRED_CONTEXT 2050 -#define STATESERVER_OBJECT_CREATE_WITH_REQUIR_OTHER_CONTEXT 2051 -#define STATESERVER_BOUNCE_MESSAGE 2086 +#define STATESERVER_CREATE_OBJECT_WITH_REQUIRED 2000 +#define STATESERVER_CREATE_OBJECT_WITH_REQUIRED_OTHER 2001 +#define STATESERVER_OBJECT_SET_FIELD 2020 #define CLIENT_OBJECT_GENERATE_CMU 9002 diff --git a/direct/src/distributed/ClientRepositoryBase.py b/direct/src/distributed/ClientRepositoryBase.py index c4555e94ec..5aa7c3fa94 100644 --- a/direct/src/distributed/ClientRepositoryBase.py +++ b/direct/src/distributed/ClientRepositoryBase.py @@ -175,7 +175,7 @@ class ClientRepositoryBase(ConnectionRepository): "generate" messages when they are replayed(). """ - if msgType == CLIENT_CREATE_OBJECT_REQUIRED_OTHER: + if msgType == CLIENT_ENTER_OBJECT_REQUIRED_OTHER: # It's a generate message. doId = extra if doId in self.deferredDoIds: @@ -381,7 +381,7 @@ class ClientRepositoryBase(ConnectionRepository): # The object had been deferred. Great; we don't even have # to generate it now. del self.deferredDoIds[doId] - i = self.deferredGenerates.index((CLIENT_CREATE_OBJECT_REQUIRED_OTHER, doId)) + i = self.deferredGenerates.index((CLIENT_ENTER_OBJECT_REQUIRED_OTHER, doId)) del self.deferredGenerates[i] if len(self.deferredGenerates) == 0: taskMgr.remove('deferredGenerate') diff --git a/direct/src/distributed/MsgTypes.py b/direct/src/distributed/MsgTypes.py index b5e5d260df..14ce6ba55e 100644 --- a/direct/src/distributed/MsgTypes.py +++ b/direct/src/distributed/MsgTypes.py @@ -3,104 +3,140 @@ from direct.showbase.PythonUtil import invertDictLossless MsgName2Id = { - # 2 new params: passwd, char bool 0/1 1 = new account - # 2 new return values: 129 = not found, 12 = bad passwd, - 'CLIENT_LOGIN': 1, - 'CLIENT_LOGIN_RESP': 2, - 'CLIENT_GET_AVATARS': 3, + 'CLIENT_HELLO': 1, + 'CLIENT_HELLO_RESP': 2, + + # Sent by the client when it's leaving. + 'CLIENT_DISCONNECT': 3, + # Sent by the server when it is dropping the connection deliberately. - 'CLIENT_GO_GET_LOST': 4, - 'CLIENT_GET_AVATARS_RESP': 5, - 'CLIENT_CREATE_AVATAR': 6, - 'CLIENT_CREATE_AVATAR_RESP': 7, - 'CLIENT_GET_FRIEND_LIST': 10, - 'CLIENT_GET_FRIEND_LIST_RESP': 11, - 'CLIENT_GET_AVATAR_DETAILS': 14, - 'CLIENT_GET_AVATAR_DETAILS_RESP': 15, - 'CLIENT_LOGIN_2': 16, - 'CLIENT_LOGIN_2_RESP': 17, + 'CLIENT_EJECT': 4, - 'CLIENT_OBJECT_UPDATE_FIELD': 24, - 'CLIENT_OBJECT_UPDATE_FIELD_RESP': 24, - 'CLIENT_OBJECT_DISABLE': 25, - 'CLIENT_OBJECT_DISABLE_RESP': 25, - 'CLIENT_OBJECT_DISABLE_OWNER': 26, - 'CLIENT_OBJECT_DISABLE_OWNER_RESP': 26, - 'CLIENT_OBJECT_DELETE': 27, - 'CLIENT_OBJECT_DELETE_RESP': 27, - 'CLIENT_SET_ZONE_CMU': 29, - 'CLIENT_REMOVE_ZONE': 30, - 'CLIENT_SET_AVATAR': 32, - 'CLIENT_CREATE_OBJECT_REQUIRED': 34, - 'CLIENT_CREATE_OBJECT_REQUIRED_RESP': 34, - 'CLIENT_CREATE_OBJECT_REQUIRED_OTHER': 35, - 'CLIENT_CREATE_OBJECT_REQUIRED_OTHER_RESP': 35, - 'CLIENT_CREATE_OBJECT_REQUIRED_OTHER_OWNER': 36, - 'CLIENT_CREATE_OBJECT_REQUIRED_OTHER_OWNER_RESP':36, + 'CLIENT_HEARTBEAT': 5, - 'CLIENT_REQUEST_GENERATES': 36, + 'CLIENT_OBJECT_SET_FIELD': 120, + 'CLIENT_OBJECT_SET_FIELDS': 121, + 'CLIENT_OBJECT_LEAVING': 132, + 'CLIENT_OBJECT_LEAVING_OWNER': 161, + 'CLIENT_ENTER_OBJECT_REQUIRED': 142, + 'CLIENT_ENTER_OBJECT_REQUIRED_OTHER': 143, + 'CLIENT_ENTER_OBJECT_REQUIRED_OWNER': 172, + 'CLIENT_ENTER_OBJECT_REQUIRED_OTHER_OWNER': 173, - 'CLIENT_DISCONNECT': 37, + 'CLIENT_DONE_INTEREST_RESP': 204, - 'CLIENT_GET_STATE_RESP': 47, - 'CLIENT_DONE_INTEREST_RESP': 48, - - 'CLIENT_DELETE_AVATAR': 49, - - 'CLIENT_DELETE_AVATAR_RESP': 5, - - 'CLIENT_HEARTBEAT': 52, - 'CLIENT_FRIEND_ONLINE': 53, - 'CLIENT_FRIEND_OFFLINE': 54, - 'CLIENT_REMOVE_FRIEND': 56, - - 'CLIENT_CHANGE_PASSWORD': 65, - - 'CLIENT_SET_NAME_PATTERN': 67, - 'CLIENT_SET_NAME_PATTERN_ANSWER': 68, - - 'CLIENT_SET_WISHNAME': 70, - 'CLIENT_SET_WISHNAME_RESP': 71, - 'CLIENT_SET_WISHNAME_CLEAR': 72, - 'CLIENT_SET_SECURITY': 73, - - 'CLIENT_SET_DOID_RANGE': 74, - - 'CLIENT_GET_AVATARS_RESP2': 75, - 'CLIENT_CREATE_AVATAR2': 76, - 'CLIENT_SYSTEM_MESSAGE': 78, - 'CLIENT_SET_AVTYPE': 80, - - 'CLIENT_GET_PET_DETAILS': 81, - 'CLIENT_GET_PET_DETAILS_RESP': 82, - - 'CLIENT_ADD_INTEREST': 97, - 'CLIENT_REMOVE_INTEREST': 99, - 'CLIENT_OBJECT_LOCATION': 102, - - 'CLIENT_LOGIN_3': 111, - 'CLIENT_LOGIN_3_RESP': 110, - - 'CLIENT_GET_FRIEND_LIST_EXTENDED': 115, - 'CLIENT_GET_FRIEND_LIST_EXTENDED_RESP': 116, - - 'CLIENT_SET_FIELD_SENDABLE': 120, - - 'CLIENT_SYSTEMMESSAGE_AKNOWLEDGE': 123, - 'CLIENT_CHANGE_GENERATE_ORDER': 124, - - # new toontown specific login message, adds last logged in, and if child account has parent acount - 'CLIENT_LOGIN_TOONTOWN': 125, - 'CLIENT_LOGIN_TOONTOWN_RESP': 126, + 'CLIENT_ADD_INTEREST': 200, + 'CLIENT_ADD_INTEREST_MULTIPLE': 201, + 'CLIENT_REMOVE_INTEREST': 203, + 'CLIENT_OBJECT_LOCATION': 140, + # These are sent internally inside the Astron cluster. - 'STATESERVER_OBJECT_GENERATE_WITH_REQUIRED': 2001, - 'STATESERVER_OBJECT_GENERATE_WITH_REQUIRED_OTHER': 2003, - 'STATESERVER_OBJECT_UPDATE_FIELD': 2004, - 'STATESERVER_OBJECT_CREATE_WITH_REQUIRED_CONTEXT': 2050, - 'STATESERVER_OBJECT_CREATE_WITH_REQUIR_OTHER_CONTEXT': 2051, - 'STATESERVER_BOUNCE_MESSAGE': 2086, + # Message Director control messages: + 'CONTROL_CHANNEL': 1, + 'CONTROL_ADD_CHANNEL': 9000, + 'CONTROL_REMOVE_CHANNEL': 9001, + 'CONTROL_ADD_RANGE': 9002, + 'CONTROL_REMOVE_RANGE': 9003, + 'CONTROL_ADD_POST_REMOVE': 9010, + 'CONTROL_CLEAR_POST_REMOVES': 9011, + + # State Server control messages: + 'STATESERVER_CREATE_OBJECT_WITH_REQUIRED': 2000, + 'STATESERVER_CREATE_OBJECT_WITH_REQUIRED_OTHER': 2001, + 'STATESERVER_DELETE_AI_OBJECTS': 2009, + 'STATESERVER_OBJECT_GET_FIELD': 2010, + 'STATESERVER_OBJECT_GET_FIELD_RESP': 2011, + 'STATESERVER_OBJECT_GET_FIELDS': 2012, + 'STATESERVER_OBJECT_GET_FIELDS_RESP': 2013, + 'STATESERVER_OBJECT_GET_ALL': 2014, + 'STATESERVER_OBJECT_GET_ALL_RESP': 2015, + 'STATESERVER_OBJECT_SET_FIELD': 2020, + 'STATESERVER_OBJECT_SET_FIELDS': 2021, + 'STATESERVER_OBJECT_DELETE_FIELD_RAM': 2030, + 'STATESERVER_OBJECT_DELETE_FIELDS_RAM': 2031, + 'STATESERVER_OBJECT_DELETE_RAM': 2032, + 'STATESERVER_OBJECT_SET_LOCATION': 2040, + 'STATESERVER_OBJECT_CHANGING_LOCATION': 2041, + 'STATESERVER_OBJECT_ENTER_LOCATION_WITH_REQUIRED': 2042, + 'STATESERVER_OBJECT_ENTER_LOCATION_WITH_REQUIRED_OTHER': 2043, + 'STATESERVER_OBJECT_GET_LOCATION': 2044, + 'STATESERVER_OBJECT_GET_LOCATION_RESP': 2045, + 'STATESERVER_OBJECT_SET_AI': 2050, + 'STATESERVER_OBJECT_CHANGING_AI': 2051, + 'STATESERVER_OBJECT_ENTER_AI_WITH_REQUIRED': 2052, + 'STATESERVER_OBJECT_ENTER_AI_WITH_REQUIRED_OTHER': 2053, + 'STATESERVER_OBJECT_GET_AI': 2054, + 'STATESERVER_OBJECT_GET_AI_RESP': 2055, + 'STATESERVER_OBJECT_SET_OWNER': 2060, + 'STATESERVER_OBJECT_CHANGING_OWNER': 2061, + 'STATESERVER_OBJECT_ENTER_OWNER_WITH_REQUIRED': 2062, + 'STATESERVER_OBJECT_ENTER_OWNER_WITH_REQUIRED_OTHER': 2063, + 'STATESERVER_OBJECT_GET_OWNER': 2064, + 'STATESERVER_OBJECT_GET_OWNER_RESP': 2065, + 'STATESERVER_OBJECT_GET_ZONE_OBJECTS': 2100, + 'STATESERVER_OBJECT_GET_ZONES_OBJECTS': 2102, + 'STATESERVER_OBJECT_GET_CHILDREN': 2104, + 'STATESERVER_OBJECT_GET_ZONE_COUNT': 2110, + 'STATESERVER_OBJECT_GET_ZONE_COUNT_RESP': 2111, + 'STATESERVER_OBJECT_GET_ZONES_COUNT': 2112, + 'STATESERVER_OBJECT_GET_ZONES_COUNT_RESP': 2113, + 'STATESERVER_OBJECT_GET_CHILD_COUNT': 2114, + 'STATESERVER_OBJECT_GET_CHILD_COUNT_RESP': 2115, + 'STATESERVER_OBJECT_DELETE_ZONE': 2120, + 'STATESERVER_OBJECT_DELETE_ZONES': 2122, + 'STATESERVER_OBJECT_DELETE_CHILDREN': 2124, + # DBSS-backed-object messages: + 'DBSS_OBJECT_ACTIVATE_WITH_DEFAULTS': 2200, + 'DBSS_OBJECT_ACTIVATE_WITH_DEFAULTS_OTHER': 2201, + 'DBSS_OBJECT_GET_ACTIVATED': 2207, + 'DBSS_OBJECT_GET_ACTIVATED_RESP': 2208, + 'DBSS_OBJECT_DELETE_FIELD_DISK': 2230, + 'DBSS_OBJECT_DELETE_FIELDS_DISK': 2231, + 'DBSS_OBJECT_DELETE_DISK': 2232, + + # Database Server control messages: + 'DBSERVER_CREATE_OBJECT': 3000, + 'DBSERVER_CREATE_OBJECT_RESP': 3001, + 'DBSERVER_OBJECT_GET_FIELD': 3010, + 'DBSERVER_OBJECT_GET_FIELD_RESP': 3011, + 'DBSERVER_OBJECT_GET_FIELDS': 3012, + 'DBSERVER_OBJECT_GET_FIELDS_RESP': 3013, + 'DBSERVER_OBJECT_GET_ALL': 3014, + 'DBSERVER_OBJECT_GET_ALL_RESP': 3015, + 'DBSERVER_OBJECT_SET_FIELD': 3020, + 'DBSERVER_OBJECT_SET_FIELDS': 3021, + 'DBSERVER_OBJECT_SET_FIELD_IF_EQUALS': 3022, + 'DBSERVER_OBJECT_SET_FIELD_IF_EQUALS_RESP': 3023, + 'DBSERVER_OBJECT_SET_FIELDS_IF_EQUALS': 3024, + 'DBSERVER_OBJECT_SET_FIELDS_IF_EQUALS_RESP': 3025, + 'DBSERVER_OBJECT_SET_FIELD_IF_EMPTY': 3026, + 'DBSERVER_OBJECT_SET_FIELD_IF_EMPTY_RESP': 3027, + 'DBSERVER_OBJECT_DELETE_FIELD': 3030, + 'DBSERVER_OBJECT_DELETE_FIELDS': 3031, + 'DBSERVER_OBJECT_DELETE': 3032, + + # Client Agent control messages: + 'CLIENTAGENT_SET_STATE': 1000, + 'CLIENTAGENT_SET_CLIENT_ID': 1001, + 'CLIENTAGENT_SEND_DATAGRAM': 1002, + 'CLIENTAGENT_EJECT': 1004, + 'CLIENTAGENT_DROP': 1005, + 'CLIENTAGENT_GET_NETWORK_ADDRESS': 1006, + 'CLIENTAGENT_GET_NETWORK_ADDRESS_RESP': 1007, + 'CLIENTAGENT_DECLARE_OBJECT': 1010, + 'CLIENTAGENT_UNDECLARE_OBJECT': 1011, + 'CLIENTAGENT_ADD_SESSION_OBJECT': 1012, + 'CLIENTAGENT_REMOVE_SESSION_OBJECT': 1013, + 'CLIENTAGENT_SET_FIELDS_SENDABLE': 1014, + 'CLIENTAGENT_OPEN_CHANNEL': 1100, + 'CLIENTAGENT_CLOSE_CHANNEL': 1101, + 'CLIENTAGENT_ADD_POST_REMOVE': 1110, + 'CLIENTAGENT_CLEAR_POST_REMOVES': 1111, + 'CLIENTAGENT_ADD_INTEREST': 1200, + 'CLIENTAGENT_ADD_INTEREST_MULTIPLE': 1201, + 'CLIENTAGENT_REMOVE_INTEREST': 1203, } # create id->name table for debugging diff --git a/direct/src/distributed/MsgTypesCMU.py b/direct/src/distributed/MsgTypesCMU.py index c0d1ccd4ca..e7c7501730 100644 --- a/direct/src/distributed/MsgTypesCMU.py +++ b/direct/src/distributed/MsgTypesCMU.py @@ -19,7 +19,7 @@ MsgName2Id = { 'CLIENT_HEARTBEAT_CMU' : 9011, 'CLIENT_OBJECT_UPDATE_FIELD_TARGETED_CMU' : 9011, - 'CLIENT_OBJECT_UPDATE_FIELD' : 24, # Matches MsgTypes.CLIENT_OBJECT_UPDATE_FIELD + 'CLIENT_OBJECT_UPDATE_FIELD' : 120, # Matches MsgTypes.CLIENT_OBJECT_SET_FIELD } # create id->name table for debugging diff --git a/direct/src/distributed/OldClientRepository.py b/direct/src/distributed/OldClientRepository.py deleted file mode 100644 index daeb4af628..0000000000 --- a/direct/src/distributed/OldClientRepository.py +++ /dev/null @@ -1,208 +0,0 @@ -"""OldClientRepository module: contains the OldClientRepository class""" - -from .ClientRepositoryBase import * - -class OldClientRepository(ClientRepositoryBase): - """ - This is the open-source ClientRepository as provided by CMU. It - communicates with the ServerRepository in this same directory. - - If you are looking for the VR Studio's implementation of the - client repository, look to OTPClientRepository (elsewhere). - """ - notify = DirectNotifyGlobal.directNotify.newCategory("ClientRepository") - - def __init__(self, dcFileNames = None): - ClientRepositoryBase.__init__(self, dcFileNames = dcFileNames) - - # The DOID allocator. The CMU LAN server may choose to - # send us a block of DOIDs. If it chooses to do so, then we - # may create objects, using those DOIDs. - self.DOIDbase = 0 - self.DOIDnext = 0 - self.DOIDlast = 0 - - def handleSetDOIDrange(self, di): - self.DOIDbase = di.getUint32() - self.DOIDlast = self.DOIDbase + di.getUint32() - self.DOIDnext = self.DOIDbase - - def handleRequestGenerates(self, di): - # When new clients join the zone of an object, they need to hear - # about it, so we send out all of our information about objects in - # that particular zone. - - assert self.DOIDnext < self.DOIDlast - zone = di.getUint32() - for obj in self.doId2do.values(): - if obj.zone == zone: - id = obj.doId - if (self.isLocalId(id)): - self.send(obj.dclass.clientFormatGenerate(obj, id, zone, [])) - - def createWithRequired(self, className, zoneId = 0, optionalFields=None): - if self.DOIDnext >= self.DOIDlast: - self.notify.error( - "Cannot allocate a distributed object ID: all IDs used up.") - return None - id = self.DOIDnext - self.DOIDnext = self.DOIDnext + 1 - dclass = self.dclassesByName[className] - classDef = dclass.getClassDef() - if classDef == None: - self.notify.error("Could not create an undefined %s object." % ( - dclass.getName())) - obj = classDef(self) - obj.dclass = dclass - obj.zone = zoneId - obj.doId = id - self.doId2do[id] = obj - obj.generateInit() - obj._retrieveCachedData() - obj.generate() - obj.announceGenerate() - datagram = dclass.clientFormatGenerate(obj, id, zoneId, optionalFields) - self.send(datagram) - return obj - - def sendDisableMsg(self, doId): - datagram = PyDatagram() - datagram.addUint16(CLIENT_OBJECT_DISABLE) - datagram.addUint32(doId) - self.send(datagram) - - def sendDeleteMsg(self, doId): - datagram = PyDatagram() - datagram.addUint16(CLIENT_OBJECT_DELETE) - datagram.addUint32(doId) - self.send(datagram) - - def sendRemoveZoneMsg(self, zoneId, visibleZoneList=None): - datagram = PyDatagram() - datagram.addUint16(CLIENT_REMOVE_ZONE) - datagram.addUint32(zoneId) - - # if we have an explicit list of visible zones, add them - if visibleZoneList is not None: - vzl = list(visibleZoneList) - vzl.sort() - assert PythonUtil.uniqueElements(vzl) - for zone in vzl: - datagram.addUint32(zone) - - # send the message - self.send(datagram) - - def sendUpdateZone(self, obj, zoneId): - id = obj.doId - assert self.isLocalId(id) - self.sendDeleteMsg(id, 1) - obj.zone = zoneId - self.send(obj.dclass.clientFormatGenerate(obj, id, zoneId, [])) - - def sendSetZoneMsg(self, zoneId, visibleZoneList=None): - datagram = PyDatagram() - # Add message type - datagram.addUint16(CLIENT_SET_ZONE_CMU) - # Add zone id - datagram.addUint32(zoneId) - - # if we have an explicit list of visible zones, add them - if visibleZoneList is not None: - vzl = list(visibleZoneList) - vzl.sort() - assert PythonUtil.uniqueElements(vzl) - for zone in vzl: - datagram.addUint32(zone) - - # send the message - self.send(datagram) - - def isLocalId(self, id): - return ((id >= self.DOIDbase) and (id < self.DOIDlast)) - - def haveCreateAuthority(self): - return (self.DOIDlast > self.DOIDnext) - - def handleDatagram(self, di): - if self.notify.getDebug(): - print("ClientRepository received datagram:") - di.getDatagram().dumpHex(ostream) - - msgType = self.getMsgType() - - # These are the sort of messages we may expect from the public - # Panda server. - - if msgType == CLIENT_SET_DOID_RANGE: - self.handleSetDOIDrange(di) - elif msgType == CLIENT_CREATE_OBJECT_REQUIRED_RESP: - self.handleGenerateWithRequired(di) - elif msgType == CLIENT_CREATE_OBJECT_REQUIRED_OTHER_RESP: - self.handleGenerateWithRequiredOther(di) - elif msgType == CLIENT_OBJECT_UPDATE_FIELD_RESP: - self.handleUpdateField(di) - elif msgType == CLIENT_OBJECT_DELETE_RESP: - self.handleDelete(di) - elif msgType == CLIENT_OBJECT_DISABLE_RESP: - self.handleDisable(di) - elif msgType == CLIENT_REQUEST_GENERATES: - self.handleRequestGenerates(di) - else: - self.handleMessageType(msgType, di) - - # If we're processing a lot of datagrams within one frame, we - # may forget to send heartbeats. Keep them coming! - self.considerHeartbeat() - - def handleGenerateWithRequired(self, di): - # Get the class Id - classId = di.getUint16() - # Get the DO Id - doId = di.getUint32() - # Look up the dclass - dclass = self.dclassesByNumber[classId] - dclass.startGenerate() - # Create a new distributed object, and put it in the dictionary - distObj = self.generateWithRequiredFields(dclass, doId, di) - dclass.stopGenerate() - - def generateWithRequiredFields(self, dclass, doId, di): - if doId in self.doId2do: - # ...it is in our dictionary. - # Just update it. - distObj = self.doId2do[doId] - assert distObj.dclass == dclass - distObj.generate() - distObj.updateRequiredFields(dclass, di) - # updateRequiredFields calls announceGenerate - elif self.cache.contains(doId): - # ...it is in the cache. - # Pull it out of the cache: - distObj = self.cache.retrieve(doId) - assert distObj.dclass == dclass - # put it in the dictionary: - self.doId2do[doId] = distObj - # and update it. - distObj.generate() - distObj.updateRequiredFields(dclass, di) - # updateRequiredFields calls announceGenerate - else: - # ...it is not in the dictionary or the cache. - # Construct a new one - classDef = dclass.getClassDef() - if classDef == None: - self.notify.error("Could not create an undefined %s object." % ( - dclass.getName())) - distObj = classDef(self) - distObj.dclass = dclass - # Assign it an Id - distObj.doId = doId - # Put the new do in the dictionary - self.doId2do[doId] = distObj - # Update the required fields - distObj.generateInit() # Only called when constructed - distObj.generate() - distObj.updateRequiredFields(dclass, di) - # updateRequiredFields calls announceGenerate - return distObj diff --git a/direct/src/distributed/cConnectionRepository.cxx b/direct/src/distributed/cConnectionRepository.cxx index a19491d825..67d6ec1658 100644 --- a/direct/src/distributed/cConnectionRepository.cxx +++ b/direct/src/distributed/cConnectionRepository.cxx @@ -301,8 +301,8 @@ check_datagram() { switch (_msg_type) { #ifdef HAVE_PYTHON - case CLIENT_OBJECT_UPDATE_FIELD: - case STATESERVER_OBJECT_UPDATE_FIELD: + case CLIENT_OBJECT_SET_FIELD: + case STATESERVER_OBJECT_SET_FIELD: if (_handle_c_updates) { if (_has_owner_view) { if (!handle_update_field_owner()) { @@ -494,7 +494,7 @@ send_message_bundle(unsigned int channel, unsigned int sender_channel) { dg.add_int8(1); dg.add_uint64(channel); dg.add_uint64(sender_channel); - dg.add_uint16(STATESERVER_BOUNCE_MESSAGE); + //dg.add_uint16(STATESERVER_BOUNCE_MESSAGE); // add each bundled message BundledMsgVector::const_iterator bmi; for (bmi = _bundle_msgs.begin(); bmi != _bundle_msgs.end(); bmi++) { @@ -899,11 +899,11 @@ describe_message(ostream &out, const string &prefix, packer.RAW_UNPACK_CHANNEL(); // msg_sender msg_type = packer.raw_unpack_uint16(); - is_update = (msg_type == STATESERVER_OBJECT_UPDATE_FIELD); + is_update = (msg_type == STATESERVER_OBJECT_SET_FIELD); } else { msg_type = packer.raw_unpack_uint16(); - is_update = (msg_type == CLIENT_OBJECT_UPDATE_FIELD); + is_update = (msg_type == CLIENT_OBJECT_SET_FIELD); } if (!is_update) { diff --git a/direct/src/distributed/cDistributedSmoothNodeBase.cxx b/direct/src/distributed/cDistributedSmoothNodeBase.cxx index 70a50f33f5..14a665d9b9 100644 --- a/direct/src/distributed/cDistributedSmoothNodeBase.cxx +++ b/direct/src/distributed/cDistributedSmoothNodeBase.cxx @@ -278,12 +278,12 @@ begin_send_update(DCPacker &packer, const string &field_name) { packer.RAW_PACK_CHANNEL(_do_id); packer.RAW_PACK_CHANNEL(_ai_id); // packer.raw_pack_uint8('A'); - packer.raw_pack_uint16(STATESERVER_OBJECT_UPDATE_FIELD); + packer.raw_pack_uint16(STATESERVER_OBJECT_SET_FIELD); packer.raw_pack_uint32(_do_id); packer.raw_pack_uint16(field->get_number()); } else { - packer.raw_pack_uint16(CLIENT_OBJECT_UPDATE_FIELD); + packer.raw_pack_uint16(CLIENT_OBJECT_SET_FIELD); packer.raw_pack_uint32(_do_id); packer.raw_pack_uint16(field->get_number()); } From f76b8a6ad89ef06c9684c942aff73e1b89bc4f9b Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 23 Feb 2018 16:45:50 -0700 Subject: [PATCH 045/247] distributed: Replace the OTP protocol format with Astron's Again, all this does is affect the 4-years-disused OTP system, leaving the CMU system entirely untouched. This changes the packet formatting in several of distributed's helper classes. --- direct/src/dcparser/dcClass.cxx | 87 +------------------ direct/src/dcparser/dcClass.h | 5 -- direct/src/distributed/DistributedObjectAI.py | 22 ++--- direct/src/distributed/DistributedObjectUD.py | 4 +- direct/src/distributed/DoInterestManager.py | 22 +++-- direct/src/distributed/PyDatagram.py | 13 ++- 6 files changed, 31 insertions(+), 122 deletions(-) diff --git a/direct/src/dcparser/dcClass.cxx b/direct/src/dcparser/dcClass.cxx index 302162c412..d11a116415 100644 --- a/direct/src/dcparser/dcClass.cxx +++ b/direct/src/dcparser/dcClass.cxx @@ -514,15 +514,9 @@ receive_update_broadcast_required_owner(PyObject *distobj, for (int i = 0; i < num_fields && !PyErr_Occurred(); ++i) { DCField *field = get_inherited_field(i); if (field->as_molecular_field() == (DCMolecularField *)NULL && - field->is_required()) { + field->is_required() && (field->is_ownrecv() || field->is_broadcast())) { packer.begin_unpack(field); - if (field->is_ownrecv()) { - field->receive_update(packer, distobj); - } else { - // It's not an ownrecv field; skip over it. It's difficult to filter - // this on the server, ask Roger for the reason. - packer.unpack_skip(); - } + field->receive_update(packer, distobj); if (!packer.end_unpack()) { break; } @@ -951,14 +945,12 @@ ai_format_generate(PyObject *distobj, DOID_TYPE do_id, packer.raw_pack_uint16(STATESERVER_CREATE_OBJECT_WITH_REQUIRED); } + packer.raw_pack_uint32(do_id); // Parent is a bit overloaded; this parent is not about inheritance, this // one is about the visibility container parent, i.e. the zone parent: - if (parent_id) { - packer.raw_pack_uint32(parent_id); - } + packer.raw_pack_uint32(parent_id); packer.raw_pack_uint32(zone_id); packer.raw_pack_uint16(_number); - packer.raw_pack_uint32(do_id); // Specify all of the required fields. int num_fields = get_num_inherited_fields(); @@ -1009,77 +1001,6 @@ ai_format_generate(PyObject *distobj, DOID_TYPE do_id, return Datagram(packer.get_data(), packer.get_length()); } #endif // HAVE_PYTHON -#ifdef HAVE_PYTHON -/** - * Generates a datagram containing the message necessary to create a new - * database distributed object from the AI. - * - * First Pass is to only include required values (with Defaults). - */ -Datagram DCClass:: -ai_database_generate_context( - unsigned int context_id, DOID_TYPE parent_id, ZONEID_TYPE zone_id, - CHANNEL_TYPE owner_channel, - CHANNEL_TYPE database_server_id, CHANNEL_TYPE from_channel_id) const -{ - DCPacker packer; - packer.raw_pack_uint8(1); - packer.RAW_PACK_CHANNEL(database_server_id); - packer.RAW_PACK_CHANNEL(from_channel_id); - // packer.raw_pack_uint8('A'); - packer.raw_pack_uint16(STATESERVER_OBJECT_ENTER_WITH_REQUIRED_CONTEXT); - packer.raw_pack_uint32(parent_id); - packer.raw_pack_uint32(zone_id); - packer.RAW_PACK_CHANNEL(owner_channel); - packer.raw_pack_uint16(_number); // DCD class ID - packer.raw_pack_uint32(context_id); - - // Specify all of the required fields. - int num_fields = get_num_inherited_fields(); - for (int i = 0; i < num_fields; ++i) { - DCField *field = get_inherited_field(i); - if (field->is_required() && field->as_molecular_field() == NULL) { - packer.begin_pack(field); - packer.pack_default_value(); - packer.end_pack(); - } - } - - return Datagram(packer.get_data(), packer.get_length()); -} -#endif // HAVE_PYTHON - -#ifdef HAVE_PYTHON -Datagram DCClass:: -ai_database_generate_context_old( - unsigned int context_id, DOID_TYPE parent_id, ZONEID_TYPE zone_id, - CHANNEL_TYPE database_server_id, CHANNEL_TYPE from_channel_id) const -{ - DCPacker packer; - packer.raw_pack_uint8(1); - packer.RAW_PACK_CHANNEL(database_server_id); - packer.RAW_PACK_CHANNEL(from_channel_id); - // packer.raw_pack_uint8('A'); - packer.raw_pack_uint16(STATESERVER_OBJECT_ENTER_WITH_REQUIRED_CONTEXT); - packer.raw_pack_uint32(parent_id); - packer.raw_pack_uint32(zone_id); - packer.raw_pack_uint16(_number); // DCD class ID - packer.raw_pack_uint32(context_id); - - // Specify all of the required fields. - int num_fields = get_num_inherited_fields(); - for (int i = 0; i < num_fields; ++i) { - DCField *field = get_inherited_field(i); - if (field->is_required() && field->as_molecular_field() == NULL) { - packer.begin_pack(field); - packer.pack_default_value(); - packer.end_pack(); - } - } - - return Datagram(packer.get_data(), packer.get_length()); -} -#endif // HAVE_PYTHON /** * Write a string representation of this instance to . diff --git a/direct/src/dcparser/dcClass.h b/direct/src/dcparser/dcClass.h index 9e981a0097..73ad9e43d3 100644 --- a/direct/src/dcparser/dcClass.h +++ b/direct/src/dcparser/dcClass.h @@ -117,11 +117,6 @@ PUBLISHED: Datagram client_format_generate_CMU(PyObject *distobj, DOID_TYPE do_id, ZONEID_TYPE zone_id, PyObject *optional_fields) const; - Datagram ai_database_generate_context(unsigned int context_id, DOID_TYPE parent_id, ZONEID_TYPE zone_id, CHANNEL_TYPE owner_channel, - CHANNEL_TYPE database_server_id, CHANNEL_TYPE from_channel_id) const; - Datagram ai_database_generate_context_old(unsigned int context_id, DOID_TYPE parent_id, ZONEID_TYPE zone_id, - CHANNEL_TYPE database_server_id, CHANNEL_TYPE from_channel_id) const; - #endif public: diff --git a/direct/src/distributed/DistributedObjectAI.py b/direct/src/distributed/DistributedObjectAI.py index efe5cd02bf..847c0d7657 100644 --- a/direct/src/distributed/DistributedObjectAI.py +++ b/direct/src/distributed/DistributedObjectAI.py @@ -146,8 +146,6 @@ class DistributedObjectAI(DistributedObjectBase): barrier.cleanup() self.__barriers = {} - self.air.stopTrackRequestDeletedDO(self) - # DCR: I've re-enabled this block of code so that Toontown's # AI won't leak channels. # Let me know if it causes trouble. @@ -155,10 +153,9 @@ class DistributedObjectAI(DistributedObjectBase): ### block until a solution is thought out of how to prevent ### this delete message or to handle this message better # TODO: do we still need this check? - if not hasattr(self, "doNotDeallocateChannel"): - if self.air and not hasattr(self.air, "doNotDeallocateChannel"): - if self.air.minChannel <= self.doId <= self.air.maxChannel: - self.air.deallocateChannel(self.doId) + if not getattr(self, "doNotDeallocateChannel", False): + if self.air: + self.air.deallocateChannel(self.doId) self.air = None self.parentId = None @@ -200,9 +197,6 @@ class DistributedObjectAI(DistributedObjectBase): """ pass - def addInterest(self, zoneId, note="", event=None): - self.air.addInterest(self.doId, zoneId, note, event) - def b_setLocation(self, parentId, zoneId): self.d_setLocation(parentId, zoneId) self.setLocation(parentId, zoneId) @@ -274,9 +268,6 @@ class DistributedObjectAI(DistributedObjectBase): dclass.receiveUpdateOther(self, di) - def sendSetZone(self, zoneId): - self.air.sendSetZone(self, zoneId) - def startMessageBundle(self, name): self.air.startMessageBundle(name) def sendMessageBundle(self): @@ -349,10 +340,10 @@ class DistributedObjectAI(DistributedObjectBase): self.air.sendUpdate(self, fieldName, args) def GetPuppetConnectionChannel(self, doId): - return doId + (1 << 32) + return doId + (1001L << 32) def GetAccountConnectionChannel(self, doId): - return doId + (3 << 32) + return doId + (1003L << 32) def GetAccountIDFromChannelCode(self, channel): return channel >> 32 @@ -482,7 +473,6 @@ class DistributedObjectAI(DistributedObjectBase): (self.__class__, doId)) return self.air.requestDelete(self) - self.air.startTrackRequestDeletedDO(self) self._DOAI_requestedDelete = True def taskName(self, taskString): @@ -581,3 +571,5 @@ class DistributedObjectAI(DistributedObjectBase): """ This is a no-op on the AI. """ pass + def setAI(self, aiChannel): + self.air.setAI(self.doId, aiChannel) diff --git a/direct/src/distributed/DistributedObjectUD.py b/direct/src/distributed/DistributedObjectUD.py index c67d0004cc..e9e717a557 100755 --- a/direct/src/distributed/DistributedObjectUD.py +++ b/direct/src/distributed/DistributedObjectUD.py @@ -270,10 +270,10 @@ class DistributedObjectUD(DistributedObjectBase): self.air.sendUpdate(self, fieldName, args) def GetPuppetConnectionChannel(self, doId): - return doId + (1 << 32) + return doId + (1001L << 32) def GetAccountConnectionChannel(self, doId): - return doId + (3 << 32) + return doId + (1003L << 32) def GetAccountIDFromChannelCode(self, channel): return channel >> 32 diff --git a/direct/src/distributed/DoInterestManager.py b/direct/src/distributed/DoInterestManager.py index eb616d3f26..08a2f21657 100755 --- a/direct/src/distributed/DoInterestManager.py +++ b/direct/src/distributed/DoInterestManager.py @@ -111,7 +111,7 @@ class DoInterestManager(DirectObject.DirectObject): self._allInterestsCompleteCallbacks = [] def __verbose(self): - return self.InterestDebug or self.getVerbose() + return self.InterestDebug.getValue() or self.getVerbose() def _getAnonymousEvent(self, desc): return 'anonymous-%s-%s' % (desc, DoInterestManager._SerialGen.next()) @@ -504,18 +504,23 @@ class DoInterestManager(DirectObject.DirectObject): 'trying to set interest to invalid parent: %s' % parentId) datagram = PyDatagram() # Add message type - datagram.addUint16(CLIENT_ADD_INTEREST) - datagram.addUint16(handle) - datagram.addUint32(contextId) - datagram.addUint32(parentId) if isinstance(zoneIdList, list): vzl = list(zoneIdList) vzl.sort() uniqueElements(vzl) + datagram.addUint16(CLIENT_ADD_INTEREST_MULTIPLE) + datagram.addUint32(contextId) + datagram.addUint16(handle) + datagram.addUint32(parentId) + datagram.addUint16(len(vzl)) for zone in vzl: datagram.addUint32(zone) else: - datagram.addUint32(zoneIdList) + datagram.addUint16(CLIENT_ADD_INTEREST) + datagram.addUint32(contextId) + datagram.addUint16(handle) + datagram.addUint32(parentId) + datagram.addUint32(zoneIdList) self.send(datagram) def _sendRemoveInterest(self, handle, contextId): @@ -530,9 +535,8 @@ class DoInterestManager(DirectObject.DirectObject): datagram = PyDatagram() # Add message type datagram.addUint16(CLIENT_REMOVE_INTEREST) + datagram.addUint32(contextId) datagram.addUint16(handle) - if contextId != 0: - datagram.addUint32(contextId) self.send(datagram) if __debug__: state = DoInterestManager._interests[handle] @@ -583,8 +587,8 @@ class DoInterestManager(DirectObject.DirectObject): This handles the interest done messages and may dispatch an event """ assert DoInterestManager.notify.debugCall() - handle = di.getUint16() contextId = di.getUint32() + handle = di.getUint16() if self.__verbose(): print('CR::INTEREST.interestDone(handle=%s)' % handle) DoInterestManager.notify.debug( diff --git a/direct/src/distributed/PyDatagram.py b/direct/src/distributed/PyDatagram.py index 74e73fbf28..eebc06e440 100755 --- a/direct/src/distributed/PyDatagram.py +++ b/direct/src/distributed/PyDatagram.py @@ -7,7 +7,7 @@ from panda3d.core import Datagram from panda3d.direct import * # Import the type numbers -#from otp.ai.AIMsgTypes import * +from direct.distributed.MsgTypes import * class PyDatagram(Datagram): @@ -47,13 +47,10 @@ class PyDatagram(Datagram): self.addUint16(code) -# def addServerControlHeader(self, code): -# self.addInt8(1) -# self.addChannel(CONTROL_MESSAGE) -# self.addUint16(code) -# def addOldServerControlHeader(self, code): -# self.addChannel(CONTROL_MESSAGE) -# self.addUint16(code) + def addServerControlHeader(self, code): + self.addInt8(1) + self.addChannel(CONTROL_CHANNEL) + self.addUint16(code) def putArg(self, arg, subatomicType, divisor=1): if (divisor == 1): From b72d1c198f3bc3d302b434f53f71f4c513908261 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 23 Feb 2018 19:52:37 -0700 Subject: [PATCH 046/247] distributed: Fix the import test (and syntax on Python 3) --- direct/src/distributed/DistributedObjectAI.py | 4 ++-- direct/src/distributed/DistributedObjectUD.py | 4 ++-- makepanda/test_imports.py | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/direct/src/distributed/DistributedObjectAI.py b/direct/src/distributed/DistributedObjectAI.py index 847c0d7657..32b2374fc5 100644 --- a/direct/src/distributed/DistributedObjectAI.py +++ b/direct/src/distributed/DistributedObjectAI.py @@ -340,10 +340,10 @@ class DistributedObjectAI(DistributedObjectBase): self.air.sendUpdate(self, fieldName, args) def GetPuppetConnectionChannel(self, doId): - return doId + (1001L << 32) + return doId + (1001 << 32) def GetAccountConnectionChannel(self, doId): - return doId + (1003L << 32) + return doId + (1003 << 32) def GetAccountIDFromChannelCode(self, channel): return channel >> 32 diff --git a/direct/src/distributed/DistributedObjectUD.py b/direct/src/distributed/DistributedObjectUD.py index e9e717a557..99762cc1d3 100755 --- a/direct/src/distributed/DistributedObjectUD.py +++ b/direct/src/distributed/DistributedObjectUD.py @@ -270,10 +270,10 @@ class DistributedObjectUD(DistributedObjectBase): self.air.sendUpdate(self, fieldName, args) def GetPuppetConnectionChannel(self, doId): - return doId + (1001L << 32) + return doId + (1001 << 32) def GetAccountConnectionChannel(self, doId): - return doId + (1003L << 32) + return doId + (1003 << 32) def GetAccountIDFromChannelCode(self, channel): return channel >> 32 diff --git a/makepanda/test_imports.py b/makepanda/test_imports.py index 290ec03e13..ecd87cbb66 100644 --- a/makepanda/test_imports.py +++ b/makepanda/test_imports.py @@ -98,7 +98,6 @@ import direct.distributed.InterestWatcher import direct.distributed.MsgTypes import direct.distributed.MsgTypesCMU import direct.distributed.NetMessenger -import direct.distributed.OldClientRepository import direct.distributed.ParentMgr import direct.distributed.PyDatagram import direct.distributed.PyDatagramIterator From a5beccc99eb9224c3e632530f8acaa2e6e28d609 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 24 Feb 2018 12:15:56 +0100 Subject: [PATCH 047/247] chan: fix crash when AnimControl is destroyed in threaded pipeline See #254 for related discussion. --- panda/src/chan/animControl.cxx | 2 +- panda/src/chan/partBundle.cxx | 19 +++++++++++++++++++ panda/src/chan/partBundle.h | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/panda/src/chan/animControl.cxx b/panda/src/chan/animControl.cxx index 09660d22c0..35e56374f7 100644 --- a/panda/src/chan/animControl.cxx +++ b/panda/src/chan/animControl.cxx @@ -103,7 +103,7 @@ fail_anim(PartBundle *part) { */ AnimControl:: ~AnimControl() { - get_part()->set_control_effect(this, 0.0f); + get_part()->control_removed(this); } /** diff --git a/panda/src/chan/partBundle.cxx b/panda/src/chan/partBundle.cxx index 3fb797e3c3..f519d09a60 100644 --- a/panda/src/chan/partBundle.cxx +++ b/panda/src/chan/partBundle.cxx @@ -539,6 +539,25 @@ control_activated(AnimControl *control) { } } +/** + * Called by the AnimControl when it destructs. This needs to remove the + * AnimControl pointer from all pipeline stages. + */ +void PartBundle:: +control_removed(AnimControl *control) { + nassertv(control->get_part() == this); + + OPEN_ITERATE_ALL_STAGES(_cycler) { + CDStageWriter cdata(_cycler, pipeline_stage); + ChannelBlend::iterator cbi = cdata->_blend.find(control); + if (cbi != cdata->_blend.end()) { + cdata->_blend.erase(cbi); + cdata->_anim_changed = true; + } + } + CLOSE_ITERATE_ALL_STAGES(_cycler); +} + /** * The internal implementation of bind_anim(), this receives a pointer to an * uninitialized AnimControl and fills it in if the bind is successful. diff --git a/panda/src/chan/partBundle.h b/panda/src/chan/partBundle.h index 60d2b66b8b..80ddb4122d 100644 --- a/panda/src/chan/partBundle.h +++ b/panda/src/chan/partBundle.h @@ -149,6 +149,7 @@ public: // The following functions aren't really part of the public interface; // they're just public so we don't have to declare a bunch of friends. virtual void control_activated(AnimControl *control); + void control_removed(AnimControl *control); INLINE void set_update_delay(double delay); bool do_bind_anim(AnimControl *control, AnimBundle *anim, @@ -204,6 +205,7 @@ private: typedef CycleDataLockedReader CDLockedReader; typedef CycleDataReader CDReader; typedef CycleDataWriter CDWriter; + typedef CycleDataStageWriter CDStageWriter; public: static void register_with_read_factory(); From c3106411f54da1e7ecdfaf3852377c485ff73ba5 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 25 Feb 2018 18:26:43 -0700 Subject: [PATCH 048/247] dtool: Remove 'attach' See #244 for discussion. It's really old, hasn't been used in almost a decade, and doesn't support the current Git workflow either. --- dtool/src/attach/ctallihave | 33 - dtool/src/attach/ctattach.drv | 150 ----- dtool/src/attach/ctattachcc | 86 --- dtool/src/attach/ctattch.pl | 530 ---------------- dtool/src/attach/ctattch.pl.rnd | 954 ---------------------------- dtool/src/attach/ctccase.pl | 430 ------------- dtool/src/attach/ctci | 70 -- dtool/src/attach/ctcm.pl | 579 ----------------- dtool/src/attach/ctco | 69 -- dtool/src/attach/ctcvs.pl | 451 ------------- dtool/src/attach/ctdelta | 57 -- dtool/src/attach/ctdelta.pl | 232 ------- dtool/src/attach/ctdelta.pl.rnd | 232 ------- dtool/src/attach/ctihave | 33 - dtool/src/attach/ctmake | 23 - dtool/src/attach/ctmkdir | 55 -- dtool/src/attach/ctmkelem | 78 --- dtool/src/attach/ctmv | 35 - dtool/src/attach/ctntool.pl | 258 -------- dtool/src/attach/ctproj.pl | 60 -- dtool/src/attach/ctquery | 42 -- dtool/src/attach/ctquery.pl | 37 -- dtool/src/attach/ctrm | 31 - dtool/src/attach/ctsanity | 43 -- dtool/src/attach/cttimewarp | 43 -- dtool/src/attach/ctunattach.drv | 49 -- dtool/src/attach/ctunattach.pl | 251 -------- dtool/src/attach/ctunco | 31 - dtool/src/attach/ctutils.pl | 47 -- dtool/src/attach/ctvspec.pl | 360 ----------- dtool/src/attach/dtool.alias | 37 -- dtool/src/attach/dtool.alias-sh | 46 -- dtool/src/attach/dtool.cshrc | 99 --- dtool/src/attach/dtool.emacs | 295 --------- dtool/src/attach/dtool.init | 10 - dtool/src/attach/dtool.sh | 81 --- dtool/src/attach/get-cttree | 104 --- dtool/src/attach/get-delta | 481 -------------- dtool/src/attach/neartool | 1056 ------------------------------- dtool/src/attach/unco.pl | 31 - dtool/src/attach/update-cttree | 189 ------ 41 files changed, 7778 deletions(-) delete mode 100755 dtool/src/attach/ctallihave delete mode 100755 dtool/src/attach/ctattach.drv delete mode 100755 dtool/src/attach/ctattachcc delete mode 100644 dtool/src/attach/ctattch.pl delete mode 100644 dtool/src/attach/ctattch.pl.rnd delete mode 100644 dtool/src/attach/ctccase.pl delete mode 100644 dtool/src/attach/ctci delete mode 100644 dtool/src/attach/ctcm.pl delete mode 100644 dtool/src/attach/ctco delete mode 100644 dtool/src/attach/ctcvs.pl delete mode 100755 dtool/src/attach/ctdelta delete mode 100644 dtool/src/attach/ctdelta.pl delete mode 100644 dtool/src/attach/ctdelta.pl.rnd delete mode 100755 dtool/src/attach/ctihave delete mode 100644 dtool/src/attach/ctmake delete mode 100644 dtool/src/attach/ctmkdir delete mode 100644 dtool/src/attach/ctmkelem delete mode 100644 dtool/src/attach/ctmv delete mode 100644 dtool/src/attach/ctntool.pl delete mode 100644 dtool/src/attach/ctproj.pl delete mode 100755 dtool/src/attach/ctquery delete mode 100644 dtool/src/attach/ctquery.pl delete mode 100644 dtool/src/attach/ctrm delete mode 100644 dtool/src/attach/ctsanity delete mode 100755 dtool/src/attach/cttimewarp delete mode 100644 dtool/src/attach/ctunattach.drv delete mode 100644 dtool/src/attach/ctunattach.pl delete mode 100644 dtool/src/attach/ctunco delete mode 100644 dtool/src/attach/ctutils.pl delete mode 100644 dtool/src/attach/ctvspec.pl delete mode 100644 dtool/src/attach/dtool.alias delete mode 100644 dtool/src/attach/dtool.alias-sh delete mode 100644 dtool/src/attach/dtool.cshrc delete mode 100644 dtool/src/attach/dtool.emacs delete mode 100644 dtool/src/attach/dtool.init delete mode 100755 dtool/src/attach/dtool.sh delete mode 100755 dtool/src/attach/get-cttree delete mode 100755 dtool/src/attach/get-delta delete mode 100755 dtool/src/attach/neartool delete mode 100644 dtool/src/attach/unco.pl delete mode 100755 dtool/src/attach/update-cttree diff --git a/dtool/src/attach/ctallihave b/dtool/src/attach/ctallihave deleted file mode 100755 index 5e6f7f88ed..0000000000 --- a/dtool/src/attach/ctallihave +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/perl - -if ($#ARGV != -1) { - exit print "Usage: ctihave\n" ; -} - -$tool = $ENV{"DTOOL"} ; -if ( $tool eq "" ) { - die "not configured for using CTtools\n" ; -} - -require "$tool/built/include/ctutils.pl" ; -require "$tool/built/include/ctvspec.pl" ; -require "$tool/built/include/ctquery.pl" ; -require "$tool/built/include/ctproj.pl" ; -require "$tool/built/include/ctcm.pl" ; - -$projs = $ENV{"CTPROJS"} ; -@projsplit = split( / +/, $projs ) ; - -foreach $item ( @projsplit ) { - @items = split( /:/, $item ) ; - $thisproj = $items[0] ; - $thisflav = $items[1] ; - $thisspec = &CTResolveSpec( $thisproj, $thisflav ) ; - $result = $result . &CTCMIHave( $thisproj, $thisflav, $thisspec ) ; -} -if ( $result ne "" ) { - @splitlist = split( /\n/, $result ) ; - foreach $item ( @splitlist ) { - print $item . "\n" ; - } -} diff --git a/dtool/src/attach/ctattach.drv b/dtool/src/attach/ctattach.drv deleted file mode 100755 index c5b02718b8..0000000000 --- a/dtool/src/attach/ctattach.drv +++ /dev/null @@ -1,150 +0,0 @@ -#!/usr/bin/perl - -# acceptable forms: -# ctattach - give usage message -# ctattach project - attach to the personal flavor of the project -# ctattach project flavor - attach to a specific flavor of the project -# ctattach - - list projects that can be attached to -# ctattach project - - list flavors of a given project -# ctattach - flavor - list projects with a certain flavor -# ctattach -def project flavor - attach to project, setting CTDEFAULT_FLAV -# to flavor for the scope of this attach - -sub CTAttachUsage { - print STDERR "Usage: ctattach -def project flavor -or-\n" ; - print STDERR " ctattach project [flavor] -or-\n" ; - print STDERR " ctattach project - -or-\n" ; - print STDERR " ctattach - [flavor]\n" ; - &CTAttachWriteNullScript( $tmpname ) ; - print $tmpname . "\n" ; - exit; -} - -$tool = $ENV{"DTOOL"} ; -if ( $tool eq "" ) { - die "\$" . "DTOOL environment must be set to use CTtools\n" ; -} - -require "$tool/built/include/ctattch.pl" ; - -$tmpname = "/tmp/script.$$" ; - -if ( $#ARGV == -1 ) { - &CTUDebug( "got no arguments\n" ) ; - &CTAttachUsage ; -} - -$idx = 0 ; -$proj = "" ; -$flav = "" ; -$noflav = 0 ; -$defflav = "" ; -$spread = 0 ; -$anydef = 0 ; - -# -# parse arguemnts -# - -if ( $ARGV[$idx] eq "-def" ) { - &CTUDebug( "got '-def' parameter\n" ) ; - if ( $#ARGV < ($idx + 2) ) { - &CTUDebug( "not enough arguments after -def\n" ) ; - &CTAttachUsage ; - } - $defflav = $ARGV[$idx+2] ; - $spread = 1; - &CTUDebug( "spread default flavor is '$defflav'\n" ) ; - $idx++ ; -} else { - if ( $ENV{"CTDEFAULT_FLAV"} ne "" ) { - $defflav = $ENV{"CTDEFAULT_FLAV"} ; - &CTUDebug( "environment default flavor is '$defflav'\n" ) ; - } -} - -$proj = $ARGV[$idx] ; -&CTUDebug( "project is '$proj'\n" ) ; - -if ( $defflav eq "" ) { - $defflav = "default" ; - &CTUDebug( "no environmental default, using 'default'\n" ) ; -} - -if ( $#ARGV > $idx ) { - $flav = $ARGV[$idx+1] ; - &CTUDebug( "provided flavor is '$flav'\n" ) ; -} else { - if ( $proj ne "-" ) { - $flav = $defflav; - &CTUDebug( "using environment default flavor '$flav'\n" ) ; - $noflav = 1 ; - } -} - -if (( $noflav == 1 ) || ( $flav eq "default" )) { - $anydef = 1 ; -} - -# -# act on the arguments we got -# - -require "$tool/built/include/ctquery.pl" ; -require "$tool/built/include/ctvspec.pl" ; - -if (( $proj eq "-" ) || ( $flav eq "-" )) { - if ( $#ARGV == 0 ) { - # list projects that can be attached to - print STDERR "Projects that can be attached to:\n" ; - $_ = &CTListAllProjects ; - @projlist = split ; - foreach $item ( @projlist ) { - print STDERR " $item\n" ; - } - } elsif ( $proj eq "-" ) { - # list project that have a given flavor - print STDERR "Projects that have a '$flav' flavor:\n" ; - $_ = &CTListAllProjects ; - @projlist = split ; - foreach $item ( @projlist ) { - $tmp = &CTResolveSpec( $item, $flav ) ; - if ( $tmp ne "" ) { - print STDERR " $item\n" ; - } - } - } else { - # list flavors of a given project - print STDERR "Flavors of project '$proj':\n" ; - $_ = &CTListAllFlavors( $proj ) ; - @flavlist = split ; - foreach $item ( @flavlist ) { - print STDERR " $item\n" ; - } - } - &CTAttachWriteNullScript( $tmpname ) ; - print $tmpname . "\n" ; -} else { - # output a real attachment - $curflav = &CTQueryProj( $proj ) ; - if (( $curflav eq "" ) || ( $noflav == 0 )) { - $envsep{"PATH"} = ":" ; - $envsep{"LD_LIBRARY_PATH"} = ":" ; - $envsep{"DYLD_LIBRARY_PATH"} = ":" ; - $envsep{"PFPATH"} = ":" ; - $envsep{"SSPATH"} = ":" ; - $envsep{"STKPATH"} = ":" ; - $envsep{"DC_PATH"} = ":" ; - $spec = &CTAttachCompute( $proj, $flav, $anydef ) ; - if ( $spec eq "" ) { - &CTAttachWriteNullScript( $tmpname ) ; - print $tmpname . "\n" ; - } else { - &CTAttachWriteScript( $tmpname ) ; - print $tmpname . "\n" ; - } - } else { - &CTAttachWriteNullScript( $tmpname ) ; - print $tmpname . "\n" ; - } -} diff --git a/dtool/src/attach/ctattachcc b/dtool/src/attach/ctattachcc deleted file mode 100755 index 0a9993c453..0000000000 --- a/dtool/src/attach/ctattachcc +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/perl - -if ( $#ARGV != 5 ) { - print STDERR "This is for internal use by attach ONLY\n" ; - exit ; -} - -$root = $ARGV[0] ; -$view = $ARGV[1] ; -$branch = $ARGV[2] ; -$label = $ARGV[3] ; -$vobname = $ARGV[4] ; -$proj = $ARGV[5] ; -$tmpname = "/tmp/config.$$" ; - -$emitted = 0 ; - -$ctdebug = $ENV{"CTATTACH_DEBUG"} ; - -if ($ctdebug) { - print STDERR "Params:\n 0: '$root'\n 1: '$view'\n 2: '$branch'\n" ; - print STDERR " 3: '$label'\n 4: '$vobname'\n 5: '$proj'\n" ; - print STDERR "making branch and label types for view " . $view . "\n" ; - print STDERR "executing: /usr/atria/bin/cleartool mkbrtype -vob /vobs/$vobname -c \"Branch type for the $view view\" $branch 2> /dev/null > /dev/null\n" ; - print STDERR "executing: /usr/atria/bin/cleartool mklbtype -vob /vobs/$vobname -c \"Label type for the $view view\" $label 2> /dev/null > /dev/null\n" ; -} -system "/usr/atria/bin/cleartool mkbrtype -vob /vobs/$vobname -c \"Branch type for the $view view\" $branch 2> /dev/null > /dev/null\n" ; -system "/usr/atria/bin/cleartool mklbtype -vob /vobs/$vobname -c \"Label type for the $view view\" $label 2> /dev/null > /dev/null\n" ; - -if ($ctdebug) { - print STDERR "creating/updating the config-spec for view " . $view . "\n" ; -} -open( CTINTERFACE, "/usr/atria/bin/cleartool catcs -tag $view |" ) ; -open( TMPFILE, "> $tmpname" ) ; -while ( ) { - if ( $_ =~ "CHECKEDOUT" ) { - if ($ctdebug) { - print STDERR "case 1:\noutputting: '$_'\n" ; - } - print TMPFILE "$_" ; - } elsif (( $_ =~ /^element \*/ ) && ( $_ =~ "/main/LATEST" ) && - !( $_ =~ /\/$proj\// )) { - if ( ! $emitted ) { - $emitted = 1 ; - print TMPFILE "element $root/... .../$branch/LATEST\n" ; - print TMPFILE "element $root/... $label -mkbranch $branch\n" ; - print TMPFILE "element $root/... /main/LATEST -mkbranch $branch\n" ; - if ($ctdebug) { - print STDERR "case 2:\n" ; - print STDERR "outputting: 'element $root/... .../$branch/LATEST'\n" ; - print STDERR "outputting: 'element $root/... $label -mkbranch $branch'\n" ; - print STDERR "outputting: 'element $root/... /main/LATEST -mkbranch $branch'\n" ; - } - } - if ($ctdebug) { - print STDERR "case 3:\n" ; - print STDERR "outputting: '$_'\n" ; - } - print TMPFILE "$_" ; - } elsif ( $_ =~ /\/$proj\// ) { - if ( ! $emitted ) { - $emitted = 1 ; - print TMPFILE "element $root/... .../$branch/LATEST\n" ; - print TMPFILE "element $root/... $label -mkbranch $branch\n" ; - print TMPFILE "element $root/... /main/LATEST -mkbranch $branch\n" ; - if ($ctdebug) { - print STDERR "case 4:\n" ; - print STDERR "outputting: 'element $root/... .../$branch/LATEST'\n" ; - print STDERR "outputting: 'element $root/... $label -mkbranch $branch'\n" ; - print STDERR "outputting: 'element $root/... /main/LATEST -mkbranch $branch'\n" ; - } - } - } else { - if ($ctdebug) { - print STDERR "case 5:\n" ; - print STDERR "outputting: '$_'\n" ; - } - print TMPFILE "$_" ; - } -} -close( CTINTERFACE ) ; -close( TMPFILE ) ; -if ($ctdebug) { - print STDERR "output to execute: '/usr/atria/bin/cleartool setcs -tag $view $tmpname ; rm $tmpname'\n" ; -} -system "/usr/atria/bin/cleartool setcs -tag $view $tmpname ; rm $tmpname\n" ; diff --git a/dtool/src/attach/ctattch.pl b/dtool/src/attach/ctattch.pl deleted file mode 100644 index 69f1a2ed3b..0000000000 --- a/dtool/src/attach/ctattch.pl +++ /dev/null @@ -1,530 +0,0 @@ -require "$tool/built/include/ctutils.pl" ; - -$shell_type = "csh" ; -if ( $ENV{"SHELL_TYPE"} ne "" ) { - if ( $ENV{"SHELL_TYPE"} eq "sh" ) { - $shell_type = "sh" ; - } -} - -$docnt = 0 ; -@attachqueue = () ; - -require "$tool/built/include/ctquery.pl" ; - -# force set a variable in the 'new' environment -# input is in: -# $_[0] = variable -# $_[1] = value -# -# output is in: -# %newenv = variable marked to be set to value -sub CTAttachSet { - if ( ( $_[0] ne "" ) && ( $_[1] ne "" ) ) { - &CTUDebug( "setting " . $_[0] . " to '" . $_[1] . "'\n" ) ; - $newenv{$_[0]} = $_[1] ; - } -} - -# get a variable from the environment and split it out to unified format -# (ie: space separated) -# input is in: -# $_[0] = variable to get -# -# output is in: -# string returned with value -sub CTSpoolEnv { - local( $ret ) = $ENV{$_[0]} ; - if ( $envsep{$_[0]} ne "" ) { - local( @splitlist ) = split( $envsep{$_[0]}, $ret ); - $ret = join( " ", @splitlist ) ; - } - $ret ; -} - -# modify a possibly existing variable to have a value in the 'new' environment -# input is in: -# $_[0] = variable -# $_[1] = value -# $_[2] = root -# $_[3] = project -# -# output is in: -# %newenv = variable adjusted to have the new value -sub CTAttachMod { - &CTUDebug( "in CTAttachMod\n" ) ; - if ( $_[0] eq "CTPROJS" ) { - # as part of the system, this one is special - &CTUDebug( "doing a mod on $CTPROJS\n" ) ; - if ( $newenv{$_[0]} eq "" ) { - $newenv{$_[0]} = $ENV{$_[0]} ; - } - local( $proj ) = $_[3] ; - $proj =~ tr/A-Z/a-z/ ; - local( $curflav ) = &CTQueryProj( $proj ) ; - if ( $curflav ne "" ) { - local( $tmp ) = $_[3] . ":" . $curflav ; - if ( $newenv{$_[0]} =~ /$tmp/ ) { - local( $hold ) = $newenv{$_[0]} ; - $hold =~ s/$tmp/$_[1]/ ; - &CTUDebug( "already attached to " . $_[3] . " changing '" . - $tmp . "' to '" . $_[1] . "' yielding '" . $hold . - "'\n" ) ; - $newenv{$_[0]} = $hold ; - } else { - &CTUDebug( "prepending '" . $_[1] . "' to CTPROJS\n" ) ; - $newenv{$_[0]} = $_[1] . " " . $newenv{$_[0]} ; - } - } else { - &CTUDebug( "writing '" . $_[1] . "' to CTPROJS\n" ) ; - if ( $newenv{$_[0]} eq "" ) { - $newenv{$_[0]} = $_[1] ; - } else { - $newenv{$_[0]} = $_[1] . " " . $newenv{$_[0]} ; - } - } - } elsif ( ( $_[0] ne "" ) && ( $_[1] ne "" ) ) { - local( $dosimple ) = 0 ; - if ( $newenv{$_[0]} eq "" ) { - # not in our 'new' environment yet, add it. - # may still be empty - $newenv{$_[0]} = &CTSpoolEnv( $_[0] ) ; - } - if ( ! ( $newenv{$_[0]} =~ /$_[1]/ )) { - &CTUDebug( "'" . $_[1] . "' exists in " . $_[0] . - " testing for simple modification\n" ) ; - # if it's in there already, we're done before we started. - if ( $_[1] =~ /^$_[2]/ ) { - &CTUDebug( "new value contains root '" . $_[2] . - "', may not be able to do simple edit\n" ) ; - # damn, might need to do an in-place edit - local( $curroot ) = $ENV{$_[3]} ; - &CTUDebug( "current root for '" . $_[3] . "' is '" . - $curroot . "'\n" ) ; - if ( $curroot eq "" ) { - &CTUDebug( "can do simple edit\n" ) ; - $dosimple = 1 ; - } else { - local( $test ) = $_[1] ; - $test =~ s/^$_[2]// ; - $test = $curroot . $test ; - if ( $newenv{$_[0]} =~ /$test/ ) { - # there it is. in-place edit - local( $foo ) = $newenv{$_[0]} ; - $foo =~ s/$test/$_[1]/ ; - &CTUDebug( "doing in-place edit on " . $_[0] . - " changing '" . $test . "' to '" . - $_[1] . "' yielding '" . $foo . "'\n" ) ; - $newenv{$_[0]} = $foo ; - } else { - &CTUDebug( "'" . $test . "' did not appear in $_[0]." . - " Simple edit\n" ) ; - $dosimple = 1 ; - } - } - } else { - &CTUDebug( "new value does not contain root '" . $_[2] . - "', can do simple edit\n" ) ; - # don't have to sweat in-place edits - $dosimple = 1 ; - } - } - if ( $dosimple ) { - if ( $newenv{$_[0]} eq "" ) { - &CTUDebug( "no pre-existing value in " . $_[0] . - " setting it to '" . $_[1] . "'\n" ) ; - $newenv{$_[0]} = $_[1] ; - } elsif ( $envpostpend{$_[0]} ) { - &CTUDebug( "post-pending '" . $_[1] . "' to " . $_[0] . - "\n" ) ; - $newenv{$_[0]} = $newenv{$_[0]} . " " . $_[1] ; - } elsif ( $envpostpendexceptions{$_[0]}{$_[1]} ) { - &CTUDebug( "post-pending (by exception) '" . $_[1] . "' to '" . $_[0] . - "'\n" ) ; - $newenv{$_[0]} = $newenv{$_[0]} . " " . $_[1] ; - } else { - &CTUDebug( "pre-pending '" . $_[1] . "' to " . $_[0] . - "\n" ) ; - $newenv{$_[0]} = $_[1] . " " . $newenv{$_[0]} ; - } - } - } -} - -require "$tool/built/include/ctcm.pl" ; - -# given the project and flavor, build the lists of variables to set/modify -# input is in: -# $_[0] = project -# $_[1] = flavor -# $_[2] = is some kind of default? -# -# output is in: -# return value is config line -# %newenv = an image of those parts of the environment we want to change -# %envsep = seperator -# %envcmd = set or setenv -# %envdo = direct commands to add to attach script -# %envpostpend = flag that variable should be postpended -sub CTAttachCompute { - &CTUDebug( "in CTAttachCompute\n" ) ; - local( $done ) = 0 ; - local( $flav ) = $_[1] ; - local( $prevflav ) = &CTQueryProj( $_[0] ) ; - local( $spec ) ; - local( $root ) ; - if ( $_[2] && ( $prevflav ne "" )) { - # want some form of default attachment, and are already attached. Short - # circuit. - $done = 1 ; - } - - # - # choose real flavor and find/validate root - # - while ( ! $done ) { - $spec = &CTResolveSpec( $_[0], $flav ) ; - #print STDERR "spec line '" . $spec . "' flav: '" . $flav ."'\n"; - &CTUDebug( "spec line = '$spec'\n" ) ; - if ( $spec ne "" ) { - $root = &CTComputeRoot( $_[0], $flav, $spec ) ; - &CTCMSetup( $_[0], $spec, $flav ) ; - if ( -e $root ) { - $done = 1 ; - } - } else { - print STDERR "could not resolve '" . $flav . "'\n" ; - $done = 1 ; - } - if (( ! $done ) && $_[2] ) { - if ( $flav eq "install" ) { - # oh my! are we ever in trouble - # want some sort of default, but couldn't get to what we wanted - print STDERR "ctattach to install failed\n" ; - $spec = "" ; - $done = 1 ; - } elsif ( $flav eq "release" ) { - $flav = "install" ; - } elsif ( $flav eq "ship" ) { - $flav = "release" ; - } else { - $flav = "install" ; - } - } elsif ( ! $done ) { - $spec = "" ; - print STDERR "resolved '" . $flav . "' but '" . $root . - "' does not exist\n" ; - $done = 1 ; - } - } - - # - # start real work - # - if ( $spec ne "" ) { - local( $proj ) = $_[0] ; - $proj =~ tr/a-z/A-Z/ ; - local( $item ) ; - - # we scan the .init file first because if there are needed sub-attaches - # they must happen before the rest of our work - local( $init ) = "$root/built/etc/$_[0].init" ; - local( %localmod ); - local( %localset ); - local( %localsep ); - local( %localcmd ); - local( %localdo ); - local( $localdocnt ) = 0 ; - local( %localpost ); - local( %localpostexceptions ) = () ; - if ( -e $init ) { - &CTUDebug( "scanning " . $_[0] . ".init\n" ) ; - local( @linesplit ) ; - local( $linetmp ) ; - local( $loop ) ; - local( $looptmp ) ; - local( *INITFILE ) ; - open( INITFILE, "< $init" ) ; - while ( ) { - s/\n$// ; - @linesplit = split( /\#/ ) ; - $_ = $linesplit[0] ; - if ( $_ =~ /^MODABS/ ) { - @linesplit = split ; - $linetmp = $linesplit[1] ; - shift( @linesplit ) ; - shift( @linesplit ) ; - $linesplitjoin = join( " ", @linesplit ) ; - if ( $linesplit[0] eq "-" ) { - shift( @linesplit ) ; - $linesplitjoin = join( " ", @linesplit ) ; - $localpostexceptions{$linetmp}{$linesplitjoin} = 1 ; - &CTUDebug( "Creating post-pend exception for '" . - $linetmp . "':'" . $linesplitjoin . "'\n" ) ; - } - if ( $localmod{$linetmp} eq "" ) { - $localmod{$linetmp} = $linesplitjoin ; - } else { - $localmod{$linetmp} = $localmod{$linetmp} . " " . - $linesplitjoin ; - } - } elsif ( $_ =~ /^MODREL/ ) { - @linesplit = split ; - $linetmp = $linesplit[1] ; - shift( @linesplit ) ; - shift( @linesplit ) ; - $postexception = 0 ; - foreach $loop ( @linesplit ) { - if ( $loop eq "-" ) { - $postexception = 1 ; - next ; - } - $looptmp = $root . "/" . &CTUShellEval($loop) ; - if ( $postexception ) { - $localpostexceptions{$linetmp}{$looptmp} = 1 ; - &CTUDebug( "Creating post-pend exception for '" . - $linetmp . "':'" . $looptmp . "'\n" ) ; - } - if ( -e $looptmp ) { - if ( $localmod{$linetmp} eq "" ) { - $localmod{$linetmp} = $looptmp ; - } else { - $localmod{$linetmp} = $localmod{$linetmp} . " " . - $looptmp ; - } - } - } - } elsif ( $_ =~ /^SETABS/ ) { - @linesplit = split ; - $linetmp = $linesplit[1] ; - shift( @linesplit ) ; - shift( @linesplit ) ; - if ( $localset{$linetmp} eq "" ) { - $localset{$linetmp} = join( " ", @linesplit ) ; - } else { - $localset{$linetmp} = $localset{$linetmp} . " " . - join( " ", @linesplit ) ; - } - } elsif ( $_ =~ /^SETREL/ ) { - @linesplit = split ; - $linetmp = $linesplit[1] ; - shift( @linesplit ) ; - shift( @linesplit ) ; - foreach $loop ( @linesplit ) { - $looptmp = $root . "/" . &CTUShellEval($loop) ; - if ( -e $looptmp ) { - if ( $localset{$linetmp} eq "" ) { - $localset{$linetmp} = $looptmp ; - } else { - $localset{$linetmp} = $localset{$linetmp} . " " . - $looptmp ; - } - } - } - } elsif ( $_ =~ /^SEP/ ) { - @linesplit = split ; - $localsep{$linesplit[1]} = $linesplit[2] ; - } elsif ( $_ =~ /^CMD/ ) { - @linesplit = split ; - $localcmd{$linesplit[1]} = $linesplit[2] ; - } elsif ( $_ =~ /^DOCSH/ ) { - if ( $shell_type ne "sh" ) { - @linesplit = split ; - shift( @linesplit ) ; - $localdo{$localdocnt} = join( " ", @linesplit ) ; - $localdocnt++ ; - } - } elsif ( $_ =~ /^DOSH/ ) { - if ( $shell_type eq "sh" ) { - @linesplit = split ; - shift( @linesplit ) ; - $localdo{$localdocnt} = join( " ", @linesplit ) ; - $localdocnt++ ; - } - } elsif ( $_ =~ /^DO/ ) { - @linesplit = split ; - shift( @linesplit ) ; - $localdo{$localdocnt} = join( " ", @linesplit ) ; - $localdocnt++ ; - } elsif ( $_ =~ /^POSTPEND/ ) { - @linesplit = split ; - $localpost{$linesplit[1]} = 1 ; - } elsif ( $_ =~ /^ATTACH/ ) { - @linesplit = split ; - shift( @linesplit ) ; - foreach $loop ( @linesplit ) { - push( @attachqueue, $loop ) ; - } - } elsif ( $_ ne "" ) { - print STDERR "Unknown .init directive '$_'\n" ; - } - } - close( INITFILE ) ; - } - - # now handle sub-attaches - &CTUDebug( "performing sub-attaches\n" ) ; - while ( @attachqueue != () ) { - $item = shift( @attachqueue ) ; - &CTUDebug( "attaching to " . $item . "\n" ) ; - &CTAttachCompute( $item, $defflav, 1 ) ; - } - - # now we will do our extentions, then apply the mods from the .init - # file, if any - &CTUDebug( "extending paths\n" ) ; - local( $type ) = &CTSpecType( $spec ) ; - if ( $type eq "vroot" ) { - &CTAttachMod( "PATH", "/usr/atria/bin", $root, $proj ) ; - } - - # For now, we will not check whether the various /bin, /lib, - # /inc directories exist before adding them to the paths. This - # helps when attaching to unitialized trees that do not have - # these directories yet (but will shortly). - - # However, we *will* filter out any trees whose name ends in - # "MODELS". These don't have subdirectories that we care about - # in the normal sense. - if ( ! ( $proj =~ /MODELS$/ ) ) { - - $item = $root . "/built/bin" ; - #if ( -e $item ) { - &CTAttachMod( "PATH", $item, $root, $proj ) ; - #} - - $item = $root . "/built/lib" ; - #if ( -e $item ) { - &CTAttachMod( "PATH", $item, $root, $proj ) ; - &CTAttachMod( "LD_LIBRARY_PATH", $item, $root, $proj ) ; - &CTAttachMod( "DYLD_LIBRARY_PATH", $item, $root, $proj ) ; - #} - - $item = $root . "/built/include" ; - #if ( -e $item ) { - &CTAttachMod( "CT_INCLUDE_PATH", $item, $root, $proj ) ; - #} - - $item = $root . "/built/etc" ; - #if ( -e $item ) { - &CTAttachMod( "ETC_PATH", $item, $root, $proj ) ; - #} - } - - &CTAttachMod( "CTPROJS", $proj . ":" . $flav, $root, $proj ) ; - &CTAttachSet( $proj, $root ) ; - - # run thru the stuff saved up from the .init file - foreach $item ( keys %localsep ) { - $envsep{$item} = $localsep{$item} ; - } - foreach $item ( keys %localpost ) { - $envpostpend{$item} = $localpost{$item} ; - } - %envpostpendexceptions = %localpostexceptions; - foreach $item ( keys %localmod ) { - local( @splitthis ) = split( / +/, $localmod{$item} ) ; - local( $thing ) ; - foreach $thing ( @splitthis ) { - &CTAttachMod( $item, $thing, $root, $proj ) ; - } - } - foreach $item ( keys %localset ) { - &CTAttachSet( $item, $localset{$item} ) ; - } - foreach $item ( keys %localcmd ) { - $envcmd{$item} = $localcmd{$item} ; - } - for ($item = 0; $item < $localdocnt; $item++) { - $envdo{$docnt} = $localdo{$item} ; - $docnt++ ; - } - %envpostpendexceptions = () ; - } - - &CTUDebug( "out of CTAttachCompute\n" ) ; - $spec ; -} - -# write a script to NOT change the environment -# Input is: -# $_[0] = filename -sub CTAttachWriteNullScript { - &CTUDebug( "in CTAttachWriteNullScript\n" ) ; - local( *OUTFILE ) ; - open( OUTFILE, ">$_[0]" ) ; - print OUTFILE "#!/bin/" . $shell_type . " -f\n" ; - print OUTFILE "echo No attachment actions performed\n" ; - print OUTFILE "rm -f $_[0]\n" ; - close( OUTFILE ) ; - &CTUDebug( "out of CTAtachWriteNullScript\n" ) ; -} - -# write a script to setup the environment -# Input is: -# $_[0] = filename -sub CTAttachWriteScript { - &CTUDebug( "in CTAttachWriteScript\n" ) ; - local( *OUTFILE ) ; - open( OUTFILE, ">$_[0]" ) ; - print OUTFILE "#!/bin/" . $shell_type . " -f\n" ; - local( $item ) ; - - foreach $item ( keys %newenv ) { - local( $sep ) = " " ; - if ( $envsep{$item} ne "" ) { - $sep = $envsep{$item} ; - } - local( @splitlist ) = split( / +/, $newenv{$item} ) ; - local( $outval ) = join( $sep, @splitlist ) ; - - if ( $shell_type eq "sh" ) { - print OUTFILE "$item=\"" . $outval . "\"\n" ; - if ( $envcmd{$item} ne "set" ) { - print OUTFILE "export $item\n" ; - } - } else { - if ( $envcmd{$item} ne "" ) { - print OUTFILE $envcmd{$item} . " $item " ; - if ( $envcmd{$item} eq "set" ) { - print OUTFILE "= ( " ; - } - print OUTFILE $outval ; - if ( $envcmd{$item} eq "set" ) { - print OUTFILE ")" ; - } - print OUTFILE "\n" ; - } else { - print OUTFILE "setenv $item \"$outval\"\n" ; - if ( $ctdebug ) { - print OUTFILE "echo setting " . $item . " to '" . $outval . "'\n" ; - } - } - } - } - - #if ( $newenv{"CDPATH"} ne "" ) { - # if ( $shell_type ne "sh" ) { - # print OUTFILE "set cdpath = ( \$" . "CDPATH )\n" ; - # if ( $ctdebug ) { - # print OUTFILE "echo assigning cdpath\n" ; - # } - # } - #} - for ($item = 0; $item < $docnt; $item++) { - print OUTFILE $envdo{$item} . "\n" ; - if ( $ctdebug ) { - print OUTFILE "echo doing '" . $envdo{$item} . "'\n" ; - } - } - if (! $ctdebug) { - print OUTFILE "rm -f $_[0]\n" ; - } else { - print OUTFILE "echo end of script $_[0]\n" ; - print STDERR "no self-destruct script '" . $_[0] . "'\n" ; - } - close( OUTFILE ) ; - &CTUDebug( "out of CTAttachWriteScript\n" ) ; -} - -1; diff --git a/dtool/src/attach/ctattch.pl.rnd b/dtool/src/attach/ctattch.pl.rnd deleted file mode 100644 index 02edd6103b..0000000000 --- a/dtool/src/attach/ctattch.pl.rnd +++ /dev/null @@ -1,954 +0,0 @@ -require "$tool/built/include/ctutils.pl" ; - -# get list of all projects -sub CTAttachListProj { - if ($ctdebug ne "") { - print STDERR "in CTAttachListProj\n" ; - } - local( $ret ) = "" ; - local( $done ) = 0 ; - local( *DIRFILES ) ; - open( DIRFILES, "(cd /var/etc ; /bin/ls -1 *.vspec ; echo blahblah) |" ) ; - while ( ! $done ) { - $_ = ; - s/\n$// ; - if ( $_ eq "blahblah" ) { - $done = 1 ; - } else { - s/.vspec$// ; - $ret = $ret . " " . $_ ; - } - } - close( DIRFILES ) ; - if ($ctdebug ne "") { - print STDERR "out of CTAttachListProj\n" ; - } - $ret ; -} - -# get list of flavors for a project -# $_[0] = project -sub CTAttachListFlav { - if ($ctdebug) { - print STDERR "in CTAttachListFlav\n" ; - } - local( $ret ) = "" ; - $vobname = $_[0] ; - if ( -e "/var/etc/$_[0].vspec" ) { - local( *SPECFILE ) ; - open( SPECFILE, " ) { - if ( $_ =~ /^VOBNAME/ ) { - @partlist = split( /=/ ) ; - $vobname = $partlist[1] ; - $vobname =~ s/\n$// ; - } else { - @partlist = split( /:/ ) ; - $ret = $ret . " " . $partlist[0] ; - } - } - close( SPECFILE ) ; - } else { - print STDERR "CTAttachListFlav: cannot locate '/var/etc/$_[0]'\n" ; - } - if ($ctdebug) { - print STDERR "out of CTAttachListFlav\n" ; - } - $ret ; -} - -# get the flavor line for the given project -# $_[0] = project -# $_[1] = flavor -sub CTAttachFindFlav { - if ($ctdebug) { - print STDERR "in CTAttachFindFlav\n" ; - } - local( $ret ) = "" ; - $vobname = $_[0] ; - if ( -e "/var/etc/$_[0].vspec" ) { - local( *SPECFILE ) ; - open( SPECFILE, " ) && ! $done ) { - s/\n$// ; - if ( $_ =~ /^VOBNAME/ ) { - @partlist = split( /=/ ) ; - $vobname = $partlist[1] ; - } else { - @partlist = split( /:/ ) ; - if ( $partlist[0] eq $_[1] ) { - $done = 1 ; - $ret = join( " ", @partlist ); - } - } - } - close( SPECFILE ) ; - } else { - print STDERR "CTAttachFindFlav: cannot locate '/var/etc/$_[0]'\n" ; - } - if ($ctdebug) { - if ($ret ne "") { - print STDERR "found flavor " . $_[1] . " of project " . $_[0] . "\n" ; - } else { - print STDERR "did not find flavor " . $_[1] . " of project " . $_[0] . "\n" ; - } - print STDERR "out of CTAttachFindFlav\n" ; - } - $ret ; -} - -# given the project and flavor, resolve the final config line -# $_[0] = project -# $_[1] = flavor -sub CTAttachResolve { - if ($ctdebug) { - print STDERR "in CTAttachResolve\n" ; - } - local( $spec ) = &CTAttachFindFlav( $_[0], $_[1] ) ; - local( $ret ) = "" ; - if ( $spec ne "" ) { - local( @speclist ) ; - @speclist = split( / +/, $spec ) ; - if ( $speclist[1] eq "root" ) { - $ret = join( " " , @speclist ) ; - if ($ctdebug) { - print STDERR "resolved to a 'root'\n" ; - } - } elsif ( $speclist[1] eq "vroot" ) { - if ( $ENV{"HAVE_ATRIA"} ne "" ) { - $ret = join( " " , @speclist ) ; - if ($ctdebug) { - print STDERR "resolved to a 'vroot'\n" ; - } - } - } elsif ( $speclist[1] eq "ref" ) { - local( $tmp ) = &CTUShellEval( $speclist[2] ) ; - if ($ctdebug) { - print STDERR "resolved to a 'ref', recursing\n" ; - } - $ret = &CTAttachResolve( $_[0], $tmp ) ; - } else { - print STDERR "CTAttachResolve: unknown flavor type '$speclist[1]'\n" ; - } - } - if ($ctdebug) { - print STDERR "out of CTAttachResolve\n" ; - } - $ret ; -} - -# given the config line, determine the view name -# $_[0] = config line -sub CTAttachComputeView { - if ($ctdebug) { - print STDERR "in CTAttachComputeView\n" ; - } - local( $ret ) = "" ; - if ( $_[0] ne "" ) { - local( @speclist ) ; - @speclist = split( / +/, $_[0] ) ; - if ( $speclist[1] eq "vroot" ) { - local( $vname ) = $speclist[0] ; - shift( @speclist ) ; - shift( @speclist ) ; - local( $item ) ; - local( @itemlist ) ; - foreach $item ( @speclist ) { - @itemlist = split( /=/, $item ) ; - if ( $itemlist[0] eq "VN" ) { - $vname = $itemlist[1] ; - } - } - $ret = &CTUShellEval( $vname ) ; - } - } - if ($ctdebug) { - print STDERR "config line '" . $_[0] . "' yields view name '" . $ret . "'\n" ; - print STDERR "out of CTAttachComputeView\n" ; - } - $ret ; -} - -# given the config line, determine the branch name -# $_[0] = config line -sub CTAttachComputeBranch { - if ($ctdebug) { - print STDERR "in CTAttachComputeBranch\n" ; - } - local( $ret ) = "" ; - if ( $_[0] ne "" ) { - local( @speclist ) ; - @speclist = split( / +/, $_[0] ) ; - if ( $speclist[1] eq "vroot" ) { - local( $bname ) = &CTAttachComputeView( $_[0] ) ; - shift( @speclist ) ; - shift( @speclist ) ; - local( $item ) ; - local( @itemlist ) ; - foreach $item ( @speclist ) { - @itemlist = split( /=/, $item ) ; - if ( $itemlist[0] eq "BN" ) { - $bname = $itemlist[1] ; - } - } - $ret = &CTUShellEval( $bname ) ; - } - } - if ($ctdebug) { - print STDERR "config line '" . $_[0] . "' yields branch name '" . $ret . "'\n" ; - print STDERR "out of CTAttachComputeBranch\n" ; - } - $ret ; -} - -# given the config line, determine the label name -# $_[0] = config line -sub CTAttachComputeLabel { - if ($ctdebug) { - print STDERR "in CTAttachComputeLabel\n" ; - } - local( $ret ) = "" ; - if ( $_[0] ne "" ) { - local( @speclist ) ; - @speclist = split( / +/, $_[0] ) ; - if ( $speclist[1] eq "vroot" ) { - local( $lname ) = &CTAttachComputeView( $_[0] ) ; - shift( @speclist ) ; - shift( @speclist ) ; - local( $item ) ; - local( @itemlist ) ; - foreach $item ( @speclist ) { - @itemlist = split( /=/, $item ) ; - if ( $itemlist[0] eq "LB" ) { - $lname = $itemlist[1] ; - } - } - $ret = &CTUShellEval( $lname ) ; - $ret =~ tr/a-z/A-Z/ ; - } - } - if ($ctdebug) { - print STDERR "config line '" . $_[0] . "' yields label name '" . $ret . "'\n" ; - print STDERR "out of CTAttachComputeLabel\n" ; - } - $ret ; -} - -# given the project name and config line, determine the root of the project -# $_[0] = project -# $_[1] = config line -sub CTAttachComputeRoot { - if ($ctdebug) { - print STDERR "in CTAttachComputeRoot\n" ; - } - local( $ret ) = "" ; - if ( $_[1] ne "" ) { - local( @speclist ) ; - @speclist = split( / +/, $_[1] ) ; - if ( $speclist[1] eq "root" ) { - $ret = $speclist[2] ; - } elsif ( $speclist[1] eq "vroot" ) { - $ret = &CTAttachComputeView( $_[1] ) ; - $ret = "/view/$ret/vobs/$vobname" ; - } else { - print STDERR "CTAttachComputeRoot: unknown flavor type '$speclist[1]'\n" ; - } - } - if ($ctdebug) { - print STDERR "out of CTAttachComputeRoot\n" ; - } - $ret ; -} - -# given the project name and config line, determine the root of the project as -# needed by the config spec. -# $_[0] = project -# $_[1] = config line -sub CTAttachComputeElemRoot { - if ($ctdebug) { - print STDERR "in CTAttachComputeElemRoot\n" ; - } - local( $ret ) = "" ; - if ( $_[1] ne "" ) { - local( @speclist ) ; - @speclist = split( / +/, $_[1] ) ; - if ( $speclist[1] eq "root" ) { - $ret = $speclist[2] ; - } elsif ( $speclist[1] eq "vroot" ) { - $ret = &CTAttachComputeView( $_[1] ) ; - $ret = "/vobs/$vobname" ; - } else { - print STDERR "CTAttachComputeElemRoot: unknown flavor type '$speclist[1]'\n" ; - } - } - if ($ctdebug) { - print STDERR "out of CTAttachComputeElemRoot\n" ; - } - $ret ; -} - -# do whatever setup is needed for ClearCase -# input is in: -# $_[0] = project -# $_[1] = $spec -sub CTAttachCCSetup { - if ($ctdebug) { - print STDERR "in CTAttachCCSetup\n" ; - } - local( $root ) = &CTAttachComputeElemRoot( $_[0], $_[1] ) ; - local( $view ) = &CTAttachComputeView( $_[1] ) ; - local( $branch ) = &CTAttachComputeBranch( $_[1] ) ; - local( $label ) = &CTAttachComputeLabel( $_[1] ) ; - local( *CTINTERFACE ) ; - local( *TMPFILE ) ; - local( $tmpname ) = "/tmp/config.$$" ; - local( $emitted ) = 0 ; - - if ($ctdebug) { - print STDERR "checking for existance of view '" . $view . "'\n" ; - } - open( CTINTERFACE, "/usr/atria/bin/cleartool lsview $view |" ) ; - $_ = ; - close( CTINTERFACE ) ; - if ( $_ eq "" ) { # need to make the view - if ($ctdebug) { - print STDERR "creating view '" . $view . "'\n" ; - } - system "umask 2 ; /usr/atria/bin/cleartool mkview -tag $view /var/views/$view.vws 2> /dev/null > /dev/null ; /usr/atria/bin/cleartool startview $view 2> /dev/null > /dev/null\n" ; - } elsif ( ! ( $_ =~ /\*/ )) { # need to start the view - if ($ctdebug) { - print STDERR "starting view '" . $view . "'\n" ; - } - system "/usr/atria/bin/cleartool startview $view 2> /dev/null > /dev/null &\n" ; - } - - if ($ctdebug) { - print STDERR "making branch and label types for view " . $view . "\n" ; - } - system "/usr/atria/bin/cleartool mkbrtype -vob /vobs/$vobname -c \"Branch type for the $view view\" $branch 2> /dev/null > /dev/null &\n" ; - system "/usr/atria/bin/cleartool mklbtype -vob /vobs/$vobname -c \"Label type for the $view view\" $label 2> /dev/null > /dev/null &\n" ; - - if ($ctdebug) { - print STDERR "creating/updating the config-spec for view " . $view . "\n" ; - } - open( CTINTERFACE, "/usr/atria/bin/cleartool catcs -tag $view |" ) ; - open( TMPFILE, "> $tmpname" ) ; - while ( ) { - if ( $_ =~ "CHECKEDOUT" ) { - print TMPFILE "$_" ; - } elsif (( $_ =~ /^element \*/ ) && ( $_ =~ "/main/LATEST" ) && - !( $_ =~ /$_[0]/ )) { - if ( ! $emitted ) { - $emitted = 1 ; - print TMPFILE "element $root/... .../$branch/LATEST\n" ; - print TMPFILE "element $root/... $label -mkbranch $branch\n" ; - print TMPFILE "element $root/... /main/LATEST -mkbranch $branch\n" ; - } - print TMPFILE "$_" ; - } elsif ( $_ =~ /$_[0]/ ) { - if ( ! $emitted ) { - $emitted = 1 ; - print TMPFILE "element $root/... .../$branch/LATEST\n" ; - print TMPFILE "element $root/... $label -mkbranch $branch\n" ; - print TMPFILE "element $root/... /main/LATEST -mkbranch $branch\n" ; - } - } else { - print TMPFILE "$_" ; - } - } - close( CTINTERFACE ) ; - close( TMPFILE ) ; - system "/usr/atria/bin/cleartool setcs -tag $view $tmpname ; rm $tmpname &\n" ; - if ($ctdebug) { - print STDERR "out of CTAttachCCSetup\n" ; - } -} - -# do whatever setup is needed for ClearCase, but do it in the background -# input is in: -# $_[0] = project -# $_[1] = $spec -sub CTAttachCCSetupBG { - if ($ctdebug) { - print STDERR "in CTAttachCCSetupBG\n" ; - } - local( $root ) = &CTAttachComputeElemRoot( $_[0], $_[1] ) ; - local( $view ) = &CTAttachComputeView( $_[1] ) ; - local( $branch ) = &CTAttachComputeBranch( $_[1] ) ; - local( $label ) = &CTAttachComputeLabel( $_[1] ) ; - - system "$tool/bin/ctattachcc $root $view $branch $label $vobname $_[0]\n" ; - - if ($ctdebug) { - print STDERR "out of CTAttachCCSetupBG\n" ; - } -} - -# prepend an entry onto the envmod of the given key. -# input is in: -# $_[0] = key -# $_[1] = data -# -# output is in: -# %envmod = has 'data' prepended at 'key' -sub CTAttachPrependMod { - if ( $envmod{$_[0]} eq "" ) { - $envmod{$_[0]} = $_[1] ; - } else { - $envmod{$_[0]} = $_[1] . " " . $envmod{$_[0]} ; - } -} - -# postpend an entry onto the envmod of the given key. -# input is in: -# $_[0] = key -# $_[1] = data -# -# output is in: -# %envmod = has 'data' postpended at 'key' -sub CTAttachPostpendMod { - if ( $envmod{$_[0]} eq "" ) { - $envmod{$_[0]} = $_[1] ; - } else { - $envmod{$_[0]} = $envmod{$_[0]} . " " . $_[1] ; - } -} - -# pre/post-pend an entry onto the envmod of the given key, as set/controlled -# by envpospend, et al. -# input is in: -# $_[0] = key -# $_[1] = data -# -# output is in: -# %envmod = data pre/post pended at the given key -sub CTAttachAddToMod { - if ($envpostpend{$_[0]} ne "") { - &CTAttachPostpendMod( $_[0], $_[1] ) ; - } else { - &CTAttachPrependMod( $_[0], $_[1] ) ; - } -} - -# prepend the given entry to the envset of the given key -# input is in: -# $_[0] = key -# $_[1] = data -# -# output is in: -# %envset = prepended at key with data -sub CTAttachPrependSet { - local( $sep ) = " " ; - if ( $envsep{$_[0]} ne "" ) { - $sep = $envsep{$_[0]} ; - } - if ($envset{$_[0]} ne "") { - $envset{$_[0]} = $_[1] . $sep . $envset{$_[0]} ; - } else { - $envset{$_[0]} = $_[1] ; - } -} - -# postpend the given entry to the envset of the given key -# input is in: -# $_[0] = key -# $_[1] = data -# -# output is in: -# %envset = postpended at key with data -sub CTAttachPostpendSet { - local( $sep ) = " " ; - if ( $envsep{$_[0]} ne "" ) { - $sep = $envsep{$_[0]} ; - } - if ($envset{$_[0]} ne "") { - $envset{$_[0]} = $envset{$_[0]} . $sep . $_[1] ; - } else { - $envset{$_[0]} = $_[1] ; - } -} - -# pre/post-pend an entry onto the envset of the given key, as set/controlled -# by envpospend, et al. -# input is in: -# $_[0] = key -# $_[1] = data -# -# output is in: -# %envset = data pre/post pended at the given key -sub CTAttachAddToSet { - if ($envpostpend{$_[0]} ne "") { - &CTAttachPostpendSet( $_[0], $_[1] ) ; - } else { - &CTAttachPrependSet( $_[0], $_[1] ) ; - } -} - -$docnt = 0 ; -@attachqueue = () ; - -require "$tool/built/include/ctquery.pl" ; - -# given the project and flavor, build the lists of variables to set/modify -# input is in: -# $_[0] = project -# $_[1] = flavor -# $_[2] = is some kind of default? -# -# output is in: -# return value is config line -# %envmod = environment variables to modify -# %envset = environment variables to outright set -# %envsep = seperator -# %envcmd = set or setenv -# %envdo = direct commands to add to attach script -# %envpostpend = flag that variable should be postpended -sub CTAttachCompute { - if ($ctdebug) { - print STDERR "in CTAttachCompute\n" ; - } - local( $done ) = 0 ; - local( $flav ) = $_[1] ; - local( $prevflav ) = &CTQueryProj( $_[0] ) ; - local( $spec ) ; - local( $root ) ; - if ( $_[2] && ( $prevflav ne "" )) { - # short circuit attaching, we're already there. - $done = 1 ; - } - while ( ! $done ) { - $spec = &CTAttachResolve( $_[0], $flav ) ; - if ( $ctdebug ne "" ) { - print STDERR "spec line = '$spec'\n" ; - } - if ( $spec ne "" ) { - $root = &CTAttachComputeRoot( $_[0], $spec ) ; - if ( -e $root ) { - $done = 1 ; - if ( $spec =~ /vroot/ ) { - &CTAttachCCSetupBG( $_[0], $spec ) ; - } - } elsif ( $spec =~ /vroot/ ) { - &CTAttachCCSetup( $_[0], $spec ) ; - if ( -e $root ) { - $done = 1 ; - } - } - } - if (( ! $done ) && $_[2] ) { - if ( $flav eq "install" ) { - # oh my! are we ever in trouble - print STDERR "you are in a strange alien universe\n" ; - $spec = "" ; - $done = 1 ; - } elsif ( $flav eq "release" ) { - $flav = "install" ; - } elsif ( $flav eq "ship" ) { - $flav = "release" ; - } else { - $flav = "ship" ; - } - } - } - - if ( $spec ne "" ) { - local( $proj ) = $_[0] ; - $proj =~ tr/a-z/A-Z/ ; - local( $view ) = &CTAttachComputeView( $spec ) ; - - if ($ctdebug) { - print STDERR "extending paths\n" ; - } - - &CTAttachAddToMod( "PATH", $root . "/bin" ) ; - &CTAttachAddToMod( "LD_LIBRARY_PATH", $root . "/lib" ) ; - &CTAttachAddToMod( "DYLD_LIBRARY_PATH", $root . "/lib" ) ; - #&CTAttachAddToMod( "CDPATH", $root . "/src/all" ) ; - &CTAttachAddToMod( "CT_INCLUDE_PATH", $root . "/include" ) ; - &CTAttachAddToMod( "DC_PATH", $root . "/etc" ) ; - &CTAttachAddToMod( "PFPATH", $root . "/etc/models" ) ; - &CTAttachAddToMod( "SSPATH", $root . "/lib/ss" ) ; - &CTAttachAddToMod( "STKPATH", $root . "/lib/stk" ) ; - &CTAttachAddToMod( "CTPROJS", $proj . ":" . $flav ) ; - $envset{$proj} = $root; - -# if ( $view ne "" ) { -# &CTAttachCCSetup( $_[0], $spec ) ; -# } - - if ( -e "$root/etc/$_[0].init" ) { - if ($ctdebug) { - print STDERR "scanning .init file\n" ; - } - local( @linesplit ) ; - local( $linetmp ) ; - local( $loop ); - local( *INITFILE ) ; - if ( -x "$root/etc/$_[0].init" ) { - open( INITFILE, "$root/etc/$_[0].init $_[0] $_[1] $root |" ) ; - } else { - open( INITFILE, "< $root/etc/$_[0].init" ) ; - } - while ( ) { - s/\n$// ; - if ( $_ =~ /^MODABS/ ) { - @linesplit = split ; - $linetmp = $linesplit[1] ; - shift( @linesplit ) ; - shift( @linesplit ) ; - &CTAttachPostpendMod( $linetmp, &CTUShellEval(join(" ", @linesplit))) ; - } elsif ( $_ =~ /^MODREL/ ) { - @linesplit = split ; - $linetmp = $linesplit[1] ; - shift( @linesplit ) ; - shift( @linesplit ) ; - foreach $loop ( @linesplit ) { - &CTAttachPostpendMod( $linetmp, $root . "/" . &CTUShellEval($loop)) ; - } - } elsif ( $_ =~ /^SETABS/ ) { - @linesplit = split ; - $linetmp = $linesplit[1] ; - shift( @linesplit ) ; - shift( @linesplit ) ; - &CTAttachPrependSet( $linetmp, &CTUShellEval(join(" ", @linesplit))) ; - } elsif ( $_ =~ /^SETREL/ ) { - @linesplit = split ; - $linetmp = $linesplit[1] ; - shift( @linesplit ) ; - shift( @linesplit ) ; - foreach $loop ( @linesplit ) { - &CTAttachPrependSet( $linetmp, $root . "/" . &CTUShellEval($loop)) ; - } - } elsif ( $_ =~ /^SEP/ ) { - @linesplit = split ; - $envsep{$linesplit[1]} = $linesplit[2] ; - } elsif ( $_ =~ /^CMD/ ) { - @linesplit = split ; - $envcmd{$linesplit[1]} = $linesplit[2] ; - } elsif ( $_ =~ /^DO/ ) { - @linesplit = split ; - shift( @linesplit ) ; - $envdo{$docnt} = join( " ", @linesplit ) ; - $docnt++ ; - } elsif ( $_ =~ /^POSTPEND/ ) { - @linesplit = split ; - $envpospend{$linesplit[1]} = 1 ; - } elsif ( $_ =~ /^ATTACH/ ) { - @linesplit = split ; - shift( @linesplit ) ; - foreach $loop ( @linesplit ) { - push( @attachqueue, $loop ) ; - } - } else { - print STDERR "Unknown .init directive '$_'\n" ; - } - } - close( INITFILE ) ; - } - - # save mods away until after sub-attach - local( %locmod ) ; - local( $item ) ; - - foreach $item ( keys %envmod ) { - $locmod{$item} = $envmod{$item} ; - delete $envmod{$item} ; - } - - # do sub-attaches - while ( @attachqueue != () ) { - $item = shift( @attachqueue ) ; - &CTAttachCompute( $item, $defflav, 1 ) ; - } - - # restore saved mods and merge them in with existing - foreach $item ( keys %locmod ) { - $envmod{$item} = $locmod{$item} ; - delete $locmod{$item} ; - } - - &CTAttachCheckVars( $_[0], $spec ) ; - } - if ($ctdebug) { - print STDERR "out of CTAttachCompute\n" ; - } - $spec ; -} - -# take a mod list and merge it into set. Uniqueifying as we go. -# input is in: -# $_[0] = mod list -# $_[1] = key -# -# output is: -# %envset = now has the mod line merged in with it. -sub CTAttachMergeToSet { - if ( $ctdebug ) { - print STDERR "trying to add '$_[0]' to '$envset{$_[1]}'\n" ; - } - local( @splitlist ) ; - local( $loop ) ; - local( $sep ) = " " ; - if ( $envsep{$_[1]} ne "" ) { - $sep = $envsep{$_[1]} ; - } - @splitlist = split( / /, $_[0] ) ; - foreach $loop ( @splitlist ) { - if ( ! (( $envset{$_[1]} eq $loop ) || - ( $envset{$_[1]} =~ /^$loop$sep/ ) || - ( $envset{$_[1]} =~ /$sep$loop$/ ) || - ( $envset{$_[1]} =~ /$sep$loop$sep/ ))) { - &CTAttachPostpendSet( $_[1], $loop ) ; - } - } - if ( $ctdebug ) { - print STDERR "yielding '$envset{$_[1]}'\n" ; - } -} - -# Perform cleanup operations on the variable that are going to be set/modified -# eg: -# * check to see if we're already attached to the project, and alter sets -# based on that -# * move mods of pre-existing variables to sets w/ the changes included -# * move mods of non-existing variables to sets -# -# input: -# $_[0] = project -# $_[1] = config line -sub CTAttachCheckVars { - if ($ctdebug) { - print STDERR "in CTAttachCheckVars\n" ; - } - local( $prevflav ) = &CTQueryProj( $_[0] ) ; - local( $proj ) = $_[0] ; - $proj =~ tr/a-z/A-Z/ ; - local( $atria ) = "/usr/atria/bin" ; - if ( $ENV{"HAVE_ATRIA"} ne "" ) { - if ( !( $ENV{"PATH"} =~ /$atria/ )) { - $envmod{"PATH"} = "$atria " . $envmod{"PATH"} ; - } - } - if ( $prevflav ne "" ) { # are already attached to the project - if ( $ctdebug ne "" ) { - print STDERR "am already attached\n" ; - } - local( $prevspec ) = &CTAttachResolve( $_[0], $prevflav ) ; - local( $prevroot ) = &CTAttachComputeRoot( $_[0], $prevspec ) ; - local( $root ) = &CTAttachComputeRoot( $_[0], $_[1] ) ; - local( $loop ) ; - local( $item ) ; - local( @splitlist ) ; - local( $modsave ) ; - foreach $item ( keys %envmod ) { - if ( $ENV{$item} ne "" ) { - if ( $ctdebug ne "" ) { - print STDERR "'$item' is already in the environment\n" ; - } - if ( $item eq "CTPROJS" ) { - local( $prevmark ) = $proj . ":" . $prevflav ; - local( $curmark ) = $envmod{$item} ; - if ( $ctdebug ne "" ) { - print STDERR "changing '$prevmark' to '$curmark' yielding " ; - } - if ( ! $gotenv{$item} ) { - $envset{$item} = $ENV{$item} ; - } - $envset{$item} =~ s/$prevmark/$curmark/ ; - if ( $ctdebug ne "" ) { - print STDERR "'$envset{$item}'\n" ; - } - delete $envmod{$item} ; - } else { - local( $src ) ; - if ( $gotenv{$item} ) { - $src = $envset{$item} ; - } else { - $src = $ENV{$item} ; - } - if ( $envsep{$item} ne "" ) { - @splitlist = split( $envsep{$item}, $src ) ; - } else { - @splitlist = split( / +/, $src ) ; - } - $modsave = $envmod{$item} ; - delete $envmod{$item} ; - foreach $loop ( @splitlist ) { - $loop =~ s/$prevroot/$root/ ; - &CTAttachPostpendMod( $item, $loop ) ; - } - if ( $ctdebug ne "" ) { - print STDERR "env '$src' -> '$envmod{$item}'\n" ; - } - @splitlist = split( / +/, $modsave ) ; - foreach $loop ( @splitlist ) { - if ( ! (( $envmod{$item} eq $loop ) || - ( $envmod{$item} =~ /^$loop / ) || - ( $envmod{$item} =~ / $loop$/ ) || - ( $envmod{$item} =~ / $loop / ))) { - &CTAttachAddToMod( $item, $loop ) ; - } - } - if ( $ctdebug ne "" ) { - print STDERR "env final = '$envmod{$item}'\n" ; - } - } - } - if ( $envmod{$item} ne "" ) { - $envset{$item} = $envmod{$item} ; - if ( $envsep{$item} ne "" ) { - $envset{$item} =~ s/ /$envsep{$item}/g ; - } - # &CTAttachMergeToSet( $envmod{$item}, $item ) ; - delete $envmod{$item} ; - $gotenv{$item} = 1 ; - } - } - } else { # not already attached. mods -> sets - if ( $ctdebug ne "" ) { - print STDERR "am not already attached\n" ; - } - local( $item ) ; - local( $loop ) ; - local( $modsave ) ; - local( @splitlist ) ; - foreach $item ( keys %envmod ) { - if ( $ENV{$item} ne "" ) { - local( $src ) ; - if ( $gotenv{$item} ) { - $src = $envset{$item} ; - } else { - $src = $ENV{$item} ; - } - if ( $envsep{$item} ne "" ) { - @splitlist = split( $envsep{$item}, $src ) ; - } else { - @splitlist = split( / +/, $src ) ; - } - $modsave = $envmod{$item} ; - delete $envmod{$item} ; - foreach $loop ( @splitlist ) { - &CTAttachPostpendMod( $item, $loop ) ; - } - if ( $ctdebug ne "" ) { - print STDERR "env '$src' -> '$envmod{$item}'\n" ; - } - @splitlist = split( / +/, $modsave ) ; - foreach $loop ( @splitlist ) { - if ( ! (( $envmod{$item} eq $loop ) || - ( $envmod{$item} =~ /^$loop / ) || - ( $envmod{$item} =~ / $loop$/ ) || - ( $envmod{$item} =~ / $loop / ))) { - &CTAttachAddToMod( $item, $loop ) ; - } - } - if ( $ctdebug ne "" ) { - print STDERR "env final = '$envmod{$item}'\n" ; - } - } - $envset{$item} = $envmod{$item} ; - if ( $envsep{$item} ne "" ) { - $envset{$item} =~ s/ /$envsep{$item}/g ; - } - # &CTAttachMergeToSet( $envmod{$item}, $item ) ; - delete $envmod{$item} ; - $gotenv{$item} = 1 ; - } - } - if ($ctdebug) { - print STDERR "out of CTAttachCheckVars\n" ; - } -} - -# write a script to NOT change the environment -# Input is: -# $_[0] = filename -sub CTAttachWriteNullScript { - if ($ctdebug) { - print STDERR "in CTAttachWriteNullScript\n" ; - } - local( *OUTFILE ) ; - open( OUTFILE, ">$_[0]" ) ; - print OUTFILE "#!/bin/csh -f\n" ; - print OUTFILE "echo No attachment actions performed\n" ; - print OUTFILE "/sbin/rm $_[0]\n" ; - close( OUTFILE ) ; - if ($ctdebug) { - print STDERR "out of CTAtachWriteNullScript\n" ; - } -} - -# write a script to setup the environment -# Input is: -# $_[0] = filename -sub CTAttachWriteScript { - if ($ctdebug) { - print STDERR "in CTAttachWriteScript\n" ; - } - local( *OUTFILE ) ; - open( OUTFILE, ">$_[0]" ) ; - print OUTFILE "#!/bin/csh -f\n" ; - local( $item ) ; - foreach $item ( keys %envset ) { - if ( $envcmd{$item} ne "" ) { - print OUTFILE $envcmd{$item} . " $item " ; - if ( $envcmd{$item} eq "set" ) { - print OUTFILE "= " ; - } - print OUTFILE $envset{$item} . "\n" ; - } else { - print OUTFILE "setenv $item \"$envset{$item}\"\n" ; - } - } - foreach $item ( keys %envmod ) { - print STDERR "SHOULD NOT BE HERE\n" ; - if ( $envcmd{$item} ne "" ) { - print OUTFILE $envcmd{$item} . " $item " ; - if ( $envcmd{$item} eq "set" ) { - print OUTFILE "= ( " ; - } else { - print OUTFILE "\"" ; - } - } else { - print OUTFILE "setenv $item \"" ; - } - if ( $envsep{$item} ne "" ) { - @itemlist = split( / +/, $envmod{$item} ) ; - foreach $tmp ( @itemlist ) { - print OUTFILE $tmp . $envsep{$item} ; - } - } else { - print OUTFILE $envmod{$item} ; - } - if ( $envcmd{$item} ne "" ) { - if ( $envcmd{$item} eq "set" ) { - print OUTFILE ")" ; - } else { - print OUTFILE "\"" ; - } - print OUTFILE "\n" ; - } else { - print OUTFILE $ENV{$item} . "\"\n" ; - } - } - #if (( $envset{"CDPATH"} ne "" ) || ( $envmod{"CDPATH"} ne "" )) { - # print OUTFILE "set cdpath = ( \$" . "CDPATH )\n" ; - #} - foreach $item ( keys %envdo ) { - print OUTFILE $envdo{$item} . "\n" ; - } - if (! $ctdebug) { - print OUTFILE "/sbin/rm $_[0]\n" ; - } else { - print STDERR "no self-destruct script '" . $_[0] . "'\n" ; - } - close( OUTFILE ) ; - if ($ctdebug) { - print STDERR "out of CTAttachWriteScript\n" ; - } -} - -1; diff --git a/dtool/src/attach/ctccase.pl b/dtool/src/attach/ctccase.pl deleted file mode 100644 index b02c2c59b1..0000000000 --- a/dtool/src/attach/ctccase.pl +++ /dev/null @@ -1,430 +0,0 @@ -# given the config line, determine the view name -# $_[0] = config line -# $_[1] = flavor -# $_[2] = project -sub CTAttachComputeView { - &CTUDebug( "in CTAttachComputeView\n" ) ; - local( $ret ) = &CTResolveSpecName( $_[2], $_[1] ) ; - local( $options ) = &CTSpecOptions( $_[0] ) ; - if ( $options ne "" ) { - local( $name ) = &CTSpecFindOption( $options, "name" ) ; - if ( $name ne "" ) { - &CTUDebug( "found a name '" . $name . "'\n" ) ; - $ret = $name ; - } else { - &CTUDebug( "no name option found, going with default\n" ) ; - } - } - &CTUDebug( "config line '" . $_[0] . "' yields view name '" . $ret . - "'\n" . "out of CTAttachComputeView\n" ) ; - $ret ; -} - -# given the config line, determine the branch name -# $_[0] = config line -# $_[1] = flavor -# $_[2] = project -sub CTAttachComputeBranch { - &CTUDebug( "in CTAttachComputeBranch\n" ) ; - local( $ret ) = &CTAttachComputeView( $_[0], $_[1], $_[2] ) ; - &CTUDebug( "config line '" . $_[0] . "' yields branch name '" . $ret . - "'\n" . "out of CTAttachComputeBranch\n" ) ; - $ret ; -} - -# given the config line, determine the label name -# $_[0] = config line -# $_[1] = flavor -# $_[2] = project -sub CTAttachComputeLabel { - &CTUDebug( "in CTAttachComputeLabel\n" ) ; - local( $ret ) = &CTAttachComputeView( $_[0], $_[1], $_[2] ) ; - $ret =~ tr/a-z/A-Z/ ; - &CTUDebug( "config line '" . $_[0] . "' yields label name '" . $ret . - "'\n" . "out of CTAttachComputeLabel\n" ) ; - $ret ; -} - -# given the project name and config line, determine the root of the project as -# needed by the config spec. -# $_[0] = project -# $_[1] = config line -# $_[2] = flavor -sub CTAttachComputeElemRoot { - &CTUDebug( "in CTAttachComputeElemRoot\n" ) ; - local( $ret ) = "/vobs/$_[0]" ; - &CTUDebug( "out of CTAttachComputeElemRoot\n" ) ; - $ret ; -} - -# do whatever setup is needed for ClearCase -# input is in: -# $_[0] = project -# $_[1] = $spec -# $_[2] = flavor -sub CTAttachCCSetup { - &CTUDebug( "in CTAttachCCSetup\n" ) ; - local( $root ) = &CTAttachComputeElemRoot( $_[0], $_[1], $_[2] ) ; - local( $view ) = &CTAttachComputeView( $_[1], $_[2], $_[0] ) ; - local( $branch ) = &CTAttachComputeBranch( $_[1], $_[2], $_[0] ) ; - local( $label ) = &CTAttachComputeLabel( $_[1], $_[2], $_[0] ) ; - local( *CTINTERFACE ) ; - local( *TMPFILE ) ; - local( $tmpname ) = "/tmp/config.$$" ; - local( $emitted ) = 0 ; - - &CTUDebug( "checking for existance of view '" . $view . "'\n" ) ; - open( CTINTERFACE, "/usr/atria/bin/cleartool lsview $view |" ) ; - $_ = ; - close( CTINTERFACE ) ; - if ( $_ eq "" ) { # need to make the view - &CTUDebug( "creating view '" . $view . "'\n" ) ; - system "umask 2 ; /usr/atria/bin/cleartool mkview -tag $view /var/views/$view.vws 2> /dev/null > /dev/null ; /usr/atria/bin/cleartool startview $view 2> /dev/null > /dev/null\n" ; - } elsif ( ! ( $_ =~ /\*/ )) { # need to start the view - &CTUDebug( "starting view '" . $view . "'\n" ) ; - system "/usr/atria/bin/cleartool startview $view 2> /dev/null > /dev/null &\n" ; - } - - &CTUDebug( "making branch and label types for view " . $view . "\n" ) ; - system "/usr/atria/bin/cleartool mkbrtype -vob /vobs/$vobname -c \"Branch type for the $view view\" $branch 2> /dev/null > /dev/null &\n" ; - system "/usr/atria/bin/cleartool mklbtype -vob /vobs/$vobname -c \"Label type for the $view view\" $label 2> /dev/null > /dev/null &\n" ; - - &CTUDebug( "creating/updating the config-spec for view " . $view . "\n" ) ; - open( CTINTERFACE, "/usr/atria/bin/cleartool catcs -tag $view |" ) ; - open( TMPFILE, "> $tmpname" ) ; - while ( ) { - if ( $_ =~ "CHECKEDOUT" ) { - print TMPFILE "$_" ; - } elsif (( $_ =~ /^element \*/ ) && ( $_ =~ "/main/LATEST" ) && - !( $_ =~ /$_[0]/ )) { - if ( ! $emitted ) { - $emitted = 1 ; - print TMPFILE "element $root/... .../$branch/LATEST\n" ; - print TMPFILE "element $root/... $label -mkbranch $branch\n" ; - print TMPFILE "element $root/... /main/LATEST -mkbranch $branch\n" ; - } - print TMPFILE "$_" ; - } elsif ( $_ =~ /$_[0]/ ) { - if ( ! $emitted ) { - $emitted = 1 ; - print TMPFILE "element $root/... .../$branch/LATEST\n" ; - print TMPFILE "element $root/... $label -mkbranch $branch\n" ; - print TMPFILE "element $root/... /main/LATEST -mkbranch $branch\n" ; - } - } else { - print TMPFILE "$_" ; - } - } - close( CTINTERFACE ) ; - close( TMPFILE ) ; - system "/usr/atria/bin/cleartool setcs -tag $view $tmpname ; rm -f $tmpname &\n" ; - &CTUDebug( "out of CTAttachCCSetup\n" ) ; -} - -# do whatever setup is needed for ClearCase, but do it in the background -# input is in: -# $_[0] = project -# $_[1] = $spec -# $_[2] = flavor -sub CTAttachCCSetupBG { - &CTUDebug( "in CTAttachCCSetupBG\n" ) ; - local( $root ) = &CTAttachComputeElemRoot( $_[0], $_[1], $_[2] ) ; - local( $view ) = &CTAttachComputeView( $_[1], $_[2], $_[0] ) ; - local( $branch ) = &CTAttachComputeBranch( $_[1], $_[2], $_[0] ) ; - local( $label ) = &CTAttachComputeLabel( $_[1], $_[2], $_[0] ) ; - - system "$tool/bin/ctattachcc $root $view $branch $label $vobname $_[0]\n" ; - - &CTUDebug( "out of CTAttachCCSetupBG\n" ) ; -} - -# given a possibly empty string, format it into a comment or -nc -# input is in: -# $_[0] = possible comment string -# -# output is: -# string for use by ClearCase functions -sub CTCcaseFormatComment { - local( $ret ) = "" ; - if ( $_[0] eq "" ) { - $ret = "-nc" ; - } else { - $ret = "-c \"" . $_[0] . "\"" ; - } - $ret ; -} - -# make a versioned directory -# input is in: -# $_[0] = directory to create -# $_[1] = curr dir -# $_[2] = possible comment -# -# output: -# return success or failure -sub CTCcaseMkdir { - &CTUDebug( "in CTCcaseMkdir\n" ) ; - local( $ret ) = 0 ; - local( $dir ) = $_[0] ; - if ( ! ( $dir =~ /^\// )) { - $dir = $_[1] . "/" . $dir ; - } - local( $comment) = &CTCcaseFormatComment( $_[2] ) ; - # first we have to check out the parent directory - local( @alist ) = split( /\//, $dir ) ; - pop( @alist ) ; - local( $parent ) = join( "/", @alist ) ; - &CTUDebug( "parent directory of '" . $dir . "' is '" . $parent . "'\n" ) ; - $ret = system( "cleartool co -nc $parent\n" ) ; - if ( $ret == 0 ) { - # now make the dir - $ret = &CTURetCode( system( "cleartool mkdir " . $comment . - " $dir\n" )) ; - } else { - $ret = 0 ; - } - &CTUDebug( "out of CTCcaseMkdir\n" ) ; - $ret ; -} - -# make a versioned element -# input is in: -# $_[0] = element to version -# $_[1] = curr dir -# $_[2] = possible comment -# $_[3] = possible eltype -# -# output: -# return success or failure -sub CTCcaseMkelem { - &CTUDebug( "in CTCcaseMkelem\n" ) ; - local( $ret ) = 0 ; - local( $elem ) = $_[0] ; - if ( ! ( $elem =~ /^\// )) { - $elem = $_[1] . "/" . $elem ; - } - local( $comment) = &CTCcaseFormatComment( $_[2] ) ; - local( $eltype ) = $_[3] ; - if ( $eltype ne "" ) { - $eltype = "-eltype " . $eltype ; - } - # first we have to check out the parent directory - local( @alist ) = split( /\//, $elem ) ; - pop( @alist ) ; - local( $parent ) = join( "/", @alist ) ; - &CTUDebug( "parent directory of '" . $elem . "' is '" . $parent . "'\n" ) ; - $ret = system( "cleartool co -nc $parent\n" ) ; - if ( $ret != 0 ) { - &CTUDebug( "checking out the dirctory gave return code: " . $ret . - "\n" ) ; - $ret = 0 ; - } - # now make the elem - $ret = &CTURetCode( system( "cleartool mkelem " . $comment . " " . - $eltype . " $elem\n" )) ; - &CTUDebug( "out of CTCcaseMkelem\n" ) ; - $ret ; -} - -# done here so there will be coherence if multiple deltas are done -require "ctime.pl" ; -$timestamp = &ctime(time) ; -$timestamp =~ s/\n$// ; -@timelist = split( /\s+/, $timestamp ) ; -$timestamp = $timelist[2] . $timelist[1] . $timelist[5] . "_" . $timelist[3] ; -$timestamp =~ s/:/_/g ; - -# delta an element -# input is in: -# $_[0] = element to delta -# -# output: -# return success or failure -sub CTCcaseDelta { - require "$tool/built/include/ctdelta.pl" ; - - &CTUDebug( "in CTCcaseDelta\n" ) ; - local( $ret ) = 0 ; - # this is ripped from the old ctdelta script - &CTDeltaCheckin( $_[0] ) ; - local( $ver ) = &CTDeltaGetVersion( $_[0] ) ; - &CTUDebug( "got version '" . $ver . "'\n" ) ; - if ( &CTDeltaOk( $ver )) { - local( @verlist ) = split( /\//, $ver ) ; - pop( @verlist ) ; - pop( @verlist ) ; - local( $ver2 ) = join( "/", @verlist ) ; - &CTUDebug( "ver2 = '" . $ver2 . "'\n" ) ; - &CTDeltaSafeMerge( $_[0], $ver, $ver2 ) ; - system "cleartool checkin -nc $_[0] 2> /dev/null > /dev/null" ; - &CTUDebug( "merge complete, doing branch check\n" ) ; - &CTDeltaBranchCheck( $_[0], $ver, $timestamp ) ; - &CTUDebug( "logging potentially felonious activity for future" . - " incrimination\n" ) ; - &CTDeltaLog( $_[0], $ver, $ver2 ) ; - # better detection needs to be done - $ret = 1 ; - } else { - &CTUDebug( "cannot merge '" . $_[0] . "', no branches.\n" ) ; - } - &CTUDebug( "out of CTCcaseDelta\n" ) ; - $ret ; -} - -# checkout an element -# input is in: -# $_[0] = element to checkout -# $_[1] = possible comment -# -# output: -# return success or failure -sub CTCcaseCheckout { - &CTUDebug( "in CTCcaseCheckout\n" ) ; - local( $comment) = &CTCcaseFormatComment( $_[1] ) ; - local( $ret ) = &CTURetCode( system( "cleartool co " . $comment . - " $_[0]\n" )) ; - &CTUDebug( "out of CTCcaseCheckout\n" ) ; - $ret ; -} - -# checkin an element -# input is in: -# $_[0] = element to checkin - -# -# output: -# return success or failure -sub CTCcaseCheckin { - &CTUDebug( "in CTCcaseCheckin\n" ) ; - local( $comment) = &CTCcaseFormatComment( $_[1] ) ; - local( $ret ) = &CTURetCode( system( "cleartool ci " . $comment . - " $_[0]\n" )) ; - &CTUDebug( "out of CTCcaseCheckin\n" ) ; - $ret ; -} - -# uncheckout an element -# input is in: -# $_[0] = element to uncheckout -# -# output: -# return success or failure -sub CTCcaseUncheckout { - require "$tool/built/include/unco.pl" ; - &CTUDebug( "in CTCcaseUncheckout\n" ) ; - local( $ret ) = 1 ; - # need better error checking on this - system( "cleartool unco -rm $_[0]\n" ) ; - &CTUncoDoIt( $_[0] ) ; - &CTUDebug( "out of CTCcaseUncheckout\n" ) ; - $ret ; -} - -# figure out what all I have checked out or on my branch -# input is in: -# $_[0] = project -# $_[1] = flavor -# $_[2] = spec line -# -# output: -# return a \n serperated list of elements checked out -sub CTCcaseIHave { - &CTUDebug( "in CTCcaseIHave\n" ) ; - local( $ret ) = "" ; - local( $branch ) = &CTAttachComputeBranch( $_[2], $_[1], $_[0] ) ; - local( $root ) = &CTProjRoot( $_[0] ) ; - local( *OUTPUT ) ; - open( OUTPUT, "cleartool find " . $root . " -element \"brtype(" . - $branch . ")\" -nxn -print |" ) ; - while ( ) { - $ret = $ret . $_ ; - } - close( OUTPUT ) ; - &CTUDebug( "out of CTCcaseIHave\n" ) ; - $ret ; -} - -# remove a versioned element -# input is in: -# $_[0] = element to remove -# $_[1] = curr dir -# -# output: -# return success or failure -sub CTCcaseRmElem { - &CTUDebug( "in CTCcaseRmElem\n" ) ; - local( $ret ) = 0 ; - local( $elem ) = $_[0] ; - if ( ! ( $elem =~ /^\// )) { - $elem = $_[1] . "/" . $elem ; - } - # first we have to check out the parent directory - local( @alist ) = split( /\//, $elem ) ; - pop( @alist ) ; - local( $parent ) = join( "/", @alist ) ; - &CTUDebug( "parent directory of '" . $elem . "' is '" . $parent . "'\n" ) ; - $ret = system( "cleartool co -nc $parent\n" ) ; - if ( $ret == 0 ) { - # now nuke the element - $ret = &CTURetCode( system( "cleartool rmname $elem\n" )) ; - } else { - $ret = 0 ; - } - &CTUDebug( "out of CTCcaseRmElem\n" ) ; - $ret ; -} - -# mv a versioned element from one name to another -# input is in: -# $_[0] = from element -# $_[1] = to element -# $_[2] = current directory -# -# output: -# return success or failure -sub CTCcaseMv { - &CTUDebug( "in CTCcaseMv\n" ) ; - local( $ret ) = 0 ; - local( $elem ) = $_[0] ; - if ( ! ( $elem =~ /^\// )) { - $elem = $_[2] . "/" . $elem ; - } - # first we have to check out the parent directory - local( @alist ) = split( /\//, $elem ) ; - pop( @alist ) ; - local( $parent ) = join( "/", @alist ) ; - &CTUDebug( "parent directory of '" . $elem . "' is '" . $parent . "'\n" ) ; - local( $elem2 ) = $_[1] ; - if ( ! ( $elem2 =~ /^\// )) { - $elem2 = $_[2] . "/" . $elem2 ; - } - local( @alist ) = split( /\//, $elem2 ) ; - pop( @alist ) ; - local( $parent2 ) = join( "/", @alist ) ; - &CTUDebug( "parent directory of '" . $elem2 . "' is '" . $parent2 . - "'\n" ) ; - system( "cleartool co -nc $parent\n" ) ; - system( "cleartool co -nc $parent2\n" ) ; - $ret = &CTURetCode( system( "cleartool mv $elem $elem2\n" )) ; - &CTUDebug( "out of CTCcaseMv\n" ) ; - $ret ; -} - -# build a list of targets -# input is in: -# $_[0] = targets -# -# output: -# return success or failure -sub CTCcaseMake { - &CTUDebug( "in CTCcaseMake\n" ) ; - local( $ret ) = 0 ; - local( $line ) = "clearmake -C gnu " . $_[0] . - " |& grep -v \"^clearmake: Warning: Config\"\n" ; - &CTUDebug( "line = '" . $line . "'\n" ) ; - $ret = &CTURetCode( system( $line )) ; - &CTUDebug( "out of CTCcaseMake\n" ) ; - $ret ; -} - -1; diff --git a/dtool/src/attach/ctci b/dtool/src/attach/ctci deleted file mode 100644 index abf0a5fe03..0000000000 --- a/dtool/src/attach/ctci +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/perl - -sub CTCiUsage { - print STDERR "Usage: ctci [-c \"comment\"] [-nc] element-name [...]\n" ; - print STDERR "Options:\n" ; - print STDERR " -c \"comment\" : provide a comment about this action\n" ; - print STDERR " -nc : expect no comment on this action\n" ; - exit; -} - -if ( $#ARGV < 0 ) { - &CTCiUsage ; -} - -$tool = $ENV{"DTOOL"} ; -if ( $tool eq "" ) { - die "Environment not configured for CTtools" ; -} - -require "$tool/built/include/ctutils.pl" ; -require "$tool/built/include/ctvspec.pl" ; -require "$tool/built/include/ctquery.pl" ; -require "$tool/built/include/ctproj.pl" ; -require "$tool/built/include/ctcm.pl" ; - -$comment = "" ; - -$skip = 0 ; - -@files = () ; - -foreach $item ( @ARGV ) { - if ( $skip == 0 ) { - if ( $item eq "-nc" ) { - &CTUDebug( "-nc processed\n" ) ; - } elsif ( $item eq "-c" ) { - $skip = 1 ; - } else { - push( @files, $item ) ; - &CTUDebug( "added '" . $item . "' to files to be processed\n" ) ; - } - } elsif ( $skip == 1 ) { - $comment = $item ; - &CTUDebug( "setting comment to '" . $comment . "'\n" ) ; - $skip = 0 ; - } else { - &CTUDebug( "got to unknown skip value! (" . $skip . ")\n" ) ; - $skip = 0 ; - } -} - - -if ($#files < 0 ) { - &CTCiUsage ; -} - -$projname = &CTProj ; -$projname =~ tr/A-Z/a-z/ ; -$flav = &CTQueryProj( $projname ) ; -$spec = &CTResolveSpec( $projname, $flav ) ; - -foreach $item ( @files ) { - if ( -e $item ) { - if ( ! &CTCMCheckin( $item, $projname, $spec, $comment ) ) { - print STDERR "Could not checkin '$item'\n" ; - } - } else { - print STDERR "No such file '$item'.\n" ; - } -} diff --git a/dtool/src/attach/ctcm.pl b/dtool/src/attach/ctcm.pl deleted file mode 100644 index cfda27e72e..0000000000 --- a/dtool/src/attach/ctcm.pl +++ /dev/null @@ -1,579 +0,0 @@ -require "$tool/built/include/ctvspec.pl" ; -require "$tool/built/include/ctquery.pl" ; - -# given a spec line, do the 'correct' setup for it -# input is in: -# $_[0] = project -# $_[1] = spec line -# $_[2] = flavor -sub CTCMSetup { - local( $type ) = &CTSpecType( $_[1] ) ; - if ( $type eq "vroot" ) { - &CTUDebug( "running setup for an atria tree\n" ) ; - if ( $ENV{"HAVE_ATRIA"} eq "yes" ) { - require "$tool/built/include/ctccase.pl" ; - &CTAttachCCSetup( $_[0], $_[1], $_[2] ) ; - } else { - &CTUDebug( "don't HAVE_ATRIA!\n" ) ; - } - # if we don't have atria, and it's a vroot, well.. - } elsif ( $type eq "croot" ) { - &CTUDebug( "running setup for CVS\n" ) ; - require "$tool/built/include/ctcvs.pl" ; - local( $serve ) = &CTCvsServerLine( $_[0], $_[1] ) ; - local( $thing ) = &CTCvsLogin( $serve ) ; - if ( ! $thing ) { - print STDERR "CVS login failed given server line '" . $serve . - "'\n" ; - } - } - # no other types have any work that needs to be done at this time -} - -# given a directory, make sure it's versioned -# input is in: -# $_[0] = directory -# $_[1] = project -# $_[2] = spec line -# $_[3] = comment (optional, "" if none) -# -# output: -# return success or failure -sub CTCMMkdir { - &CTUDebug( "in CTCMMkdir\n" ) ; - local( $ret ) = 0 ; - # first check that the directory is in the project, and is not the root - local( $flav ) = &CTQueryProj( $_[1] ) ; - local( $root ) = &CTComputeRoot( $_[1], $flav, $_[2] ) ; - local( $pwd ) = &CTUCurrDir() ; - local( $isok ) = 0 ; - if ( $_[0] =~ /^\// ) { - # starts with a /, might not be in the project we are - if (( $_[0] =~ /^$root/ ) && ( $_[0] ne $root )) { - $isok = 1 ; - } else { - $isok = 0 ; - } - } else { - # are we sitting in the project? - if ( $pwd =~ /^$root/ ) { - $isok = 1 ; - } else { - $isok = 0 ; - } - } - if ( $isok ) { - # ok, it is. Does one already exist? - if ( -e $_[0] ) { - # already one there, nothing to do - &CTUDebug( "directory '" . $_[0] . "' already exists\n" ) ; - $ret = 1 ; - } else { - # now switch off on how to actually do it - local( $type ) = &CTSpecType( $_[2] ) ; - if ( $type eq "vroot" ) { - require "$tool/built/include/ctccase.pl" ; - $ret = &CTCcaseMkdir( $_[0], $pwd, $_[3] ) ; - } elsif ( $type eq "root" ) { - require "$tool/built/include/ctntool.pl" ; - $ret = &CTNtoolMkdir( $_[0], $pwd, $_[3] ) ; - } elsif ( $type eq "croot" ) { - require "$tool/built/include/ctcvs.pl" ; - $ret = &CTCvsMkdir( $_[0], $_[1], $_[2], $_[3] ) ; - } else { - print STDERR "CTCMMkdir::error! got invalid spec type '" . - $type . "'\n" ; - } - } - } else { - print STDERR "directory '" . $_[0] . "' not in project '" . $_[1] . - "' or is the root.\n" ; - } - &CTUDebug( "out of CTCMMkdir\n" ) ; - $ret ; -} - -# given a file, make sure it's versioned -# input is in: -# $_[0] = file -# $_[1] = project -# $_[2] = spec line -# $_[3] = comment (optional, "" if none) -# $_[4] = eltype (optional, "" if none) -# -# output: -# return success or failure -sub CTCMMkelem { - &CTUDebug( "in CTCMMkelem\n" ) ; - local( $ret ) = 0; - # first check that the directory is in the project - local( $flav ) = &CTQueryProj( $_[1] ) ; - local( $root ) = &CTComputeRoot( $_[1], $flav, $_[2] ) ; - local( $isok ) = 0 ; - local( $pwd ) = &CTUCurrDir() ; - # synth an eltype if there is none - if ( ! -e $_[0] ) { - # need it to already exist - $isok = 0 ; - } else { - if ( -d $_[0] ) { - # wrong command for a directory - $isok = 0 ; - } else { - if ( $_[0] =~ /^\// ) { - # starts with a /, might not be in the project we are - if ( $_[0] =~ /^$root/ ) { - $isok = 1 ; - } else { - $isok = 0 ; - } - } else { - # are we sitting in the project? - if ( $pwd =~ /^$root/ ) { - $isok = 1 ; - } else { - $isok = 0 ; - } - } - } - } - if ( $isok ) { - # now switch off on how to actually do the work - local( $type ) = &CTSpecType( $_[2] ) ; - if ( $type eq "vroot" ) { - require "$tool/built/include/ctccase.pl" ; - $ret = &CTCcaseMkelem( $_[0], $pwd, $_[3], $_[4] ) ; - } elsif ( $type eq "root" ) { - require "$tool/built/include/ctntool.pl" ; - $ret = &CTNtoolMkelem( $_[0], $pwd, $_[3], $_[4] ) ; - } elsif ( $type eq "croot" ) { - require "$tool/built/include/ctcvs.pl" ; - $ret = &CTCvsMkelem( $_[0], $_[1], $_[2], $_[3] ) ; - } else { - print STDERR "CTCMMkelem::error! got invalid spec type '" . - $type . "'\n" ; - } - } - &CTUDebug( "out of CTCMMkelem\n" ) ; - $ret ; -} - -# given an element, delta it in -# input is in: -# $_[0] = element -# $_[1] = project -# $_[2] = spec line -# -# output: -# return success or failure -sub CTCMDelta { - &CTUDebug( "in CTCMDelta\n" ) ; - local( $ret ) = 0 ; - # first check that the element is in the project - local( $flav ) = &CTQueryProj( $_[1] ) ; - local( $root ) = &CTComputeRoot( $_[1], $flav, $_[2] ) ; - local( $pwd ) = &CTUCurrDir() ; - local( $isok ) = 0 ; - if ( ! -e $_[0] ) { - # can't delta something that doesn't exist - $isok = 0 ; - } else { - if ( $_[0] =~ /^\// ) { - # starts with a /, might not be in the project we are - if ( $_[0] =~ /^$root/ ) { - $isok = 1 ; - } else { - $isok = 0 ; - } - } else { - # are we sitting in the project? - if ( $pwd =~ /^$root/ ) { - $isok = 1 ; - } else { - $isok = 0 ; - } - } - } - if ( $isok ) { - # now switch off on how to actually do the work - local( $type ) = &CTSpecType( $_[2] ) ; - if ( $type eq "vroot" ) { - require "$tool/built/include/ctccase.pl" ; - $ret = &CTCcaseDelta( $_[0] ) ; - } elsif ( $type eq "root" ) { - require "$tool/built/include/ctntool.pl" ; - $ret = &CTNtoolDelta( $_[0] ) ; - } elsif ( $type eq "croot" ) { - require "$tool/built/include/ctcvs.pl" ; - $ret = &CTCvsDelta( $_[0], $_[1], $_[2] ) ; - } else { - print STDERR "CTCMDelta::error! got invalid spec type '" . $type . - "'\n" ; - } - } else { - &CTUDebug( "failed delta pre-checks\n" ) ; - } - &CTUDebug( "out of CTCMDelta\n" ) ; - $ret ; -} - -# given an element, check it out -# input is in: -# $_[0] = element -# $_[1] = project -# $_[2] = spec line -# $_[3] = comment (optional, "" if none) -# -# output: -# return success or failure -sub CTCMCheckout { - &CTUDebug( "in CTCMCheckout\n" ) ; - local( $ret ) = 0 ; - # first check that the element is in the project - local( $flav ) = &CTQueryProj( $_[1] ) ; - local( $root ) = &CTComputeRoot( $_[1], $flav, $_[2] ) ; - local( $pwd ) = &CTUCurrDir() ; - local( $isok ) = 0 ; - if ( ! -e $_[0] ) { - # can't checkout something that doesn't exist - $isok = 0 ; - } else { - if ( $_[0] =~ /^\// ) { - # starts with a /, might not be in the project we are - if ( $_[0] =~ /^$root/ ) { - $isok = 1 ; - } else { - $isok = 0 ; - } - } else { - # are we sitting in the project? - if ( $pwd =~ /^$root/ ) { - $isok = 1 ; - } else { - $isok = 0 ; - } - } - } - if ( $isok ) { - # now switch off on how to actually do the work - local( $type ) = &CTSpecType( $_[2] ) ; - if ( $type eq "vroot" ) { - require "$tool/built/include/ctccase.pl" ; - $ret = &CTCcaseCheckout( $_[0], $_[3] ) ; - } elsif ( $type eq "root" ) { - require "$tool/built/include/ctntool.pl" ; - $ret = &CTNtoolCheckout( $_[0], $_[3] ) ; - } elsif ( $type eq "croot" ) { - require "$tool/built/include/ctcvs.pl" ; - $ret = &CTCvsCheckout( $_[0], $_[1], $_[2], $_[3] ) ; - } else { - print STDERR "CTCMCheckout::error! got invalid spec type '" . - $type . "'\n" ; - } - } - &CTUDebug( "out of CTCMCheckout\n" ) ; - $ret ; -} - -# given an element, check it in -# input is in: -# $_[0] = element -# $_[1] = project -# $_[2] = spec line -# $_[3] = comment (optional, "" if none) -# -# output: -# return success or failure -sub CTCMCheckin { - &CTUDebug( "in CTCMCheckin\n" ) ; - local( $ret ) = 0 ; - # first check that the element is in the project - local( $flav ) = &CTQueryProj( $_[1] ) ; - local( $root ) = &CTComputeRoot( $_[1], $flav, $_[2] ) ; - local( $pwd ) = &CTUCurrDir() ; - local( $isok ) = 0 ; - if ( ! -e $_[0] ) { - # can't checkin something that doesn't exist - $isok = 0 ; - } else { - if ( $_[0] =~ /^\// ) { - # starts with a /, might not be in the project we are - if ( $_[0] =~ /^$root/ ) { - $isok = 1 ; - } else { - $isok = 0 ; - } - } else { - # are we sitting in the project? - if ( $pwd =~ /^$root/ ) { - $isok = 1 ; - } else { - $isok = 0 ; - } - } - } - if ( $isok ) { - # now switch off on how to actually do the work - local( $type ) = &CTSpecType( $_[2] ) ; - if ( $type eq "vroot" ) { - require "$tool/built/include/ctccase.pl" ; - $ret = &CTCcaseCheckin( $_[0], $_[3] ) ; - } elsif ( $type eq "root" ) { - require "$tool/built/include/ctntool.pl" ; - $ret = &CTNtoolCheckin( $_[0], $_[3] ) ; - } elsif ( $type eq "croot" ) { - require "$tool/built/include/ctcvs.pl" ; - $ret = &CTCvsCheckin( $_[0], $_[1], $_[2], $_[3] ) ; - } else { - print STDERR "CTCMCheckin::error! got invalid spec type '" . - $type . "'\n" ; - } - } - &CTUDebug( "out of CTCMCheckin\n" ) ; - $ret ; -} - -# given an element, uncheck it out -# input is in: -# $_[0] = element -# $_[1] = project -# $_[2] = spec line -# -# output: -# return success or failure -sub CTCMUncheckout { - &CTUDebug( "in CTCMUncheckout\n" ) ; - local( $ret ) = 0 ; - # first check that the element is in the project - local( $flav ) = &CTQueryProj( $_[1] ) ; - local( $root ) = &CTComputeRoot( $_[1], $flav, $_[2] ) ; - local( $pwd ) = &CTUCurrDir() ; - local( $isok ) = 0 ; - if ( ! -e $_[0] ) { - # can't uncheckout something that doesn't exist - $isok = 0 ; - } else { - if ( $_[0] =~ /^\// ) { - # starts with a /, might not be in the project we are - if ( $_[0] =~ /^$root/ ) { - $isok = 1 ; - } else { - $isok = 0 ; - } - } else { - # are we sitting in the project? - if ( $pwd =~ /^$root/ ) { - $isok = 1 ; - } else { - $isok = 0 ; - } - } - } - if ( $isok ) { - # now switch off on how to actually do the work - local( $type ) = &CTSpecType( $_[2] ) ; - if ( $type eq "vroot" ) { - require "$tool/built/include/ctccase.pl" ; - $ret = &CTCcaseUncheckout( $_[0] ) ; - } elsif ( $type eq "root" ) { - require "$tool/built/include/ctntool.pl" ; - $ret = &CTNtoolUncheckout( $_[0] ) ; - } elsif ( $type eq "croot" ) { - require "$tool/built/include/ctcvs.pl" ; - $ret = &CTCvsUncheckout( $_[0], $_[1], $_[2] ) ; - } else { - print STDERR "CTCMUncheckout::error! got invalid spec type '" . - $type . "'\n" ; - } - } - &CTUDebug( "out of CTCMUncheckout\n" ) ; - $ret ; -} - -# figure out what all I have checked out in a project -# input is in: -# $_[0] = project -# $_[1] = flavor -# $_[2] = spec line -# -# output: -# return a \n serperated list of elements checked out -sub CTCMIHave { - &CTUDebug( "in CTCMIHave\n" ) ; - local( $ret ) = "" ; - local( $type ) = &CTSpecType( $_[2] ) ; - if ( $type eq "vroot" ) { - require "$tool/built/include/ctccase.pl" ; - $ret = &CTCcaseIHave( $_[0], $_[1], $_[2] ) ; - } elsif ( $type eq "root" ) { - require "$tool/built/include/ctntool.pl" ; - $ret = &CTNtoolIHave( $_[0], $_[1], $_[2] ) ; - } elsif ( $type eq "croot" ) { - require "$tool/built/include/ctcvs.pl" ; - $ret = &CTCvsIHave( $_[0], $_[1], $_[2] ) ; - } else { - print STDERR "CTCMIHave::error! got invalid spec type '" . $type . - "'\n" ; - } - &CTUDebug( "out of CTCMIHave\n" ) ; - $ret ; -} - -# given an element, remove it from the repository -# input is in: -# $_[0] = element -# $_[1] = project -# $_[2] = spec line -# -# output: -# return success or failure -sub CTCMRmElem { - &CTUDebug( "in CTCMRmElem\n" ) ; - local( $ret ) = 0 ; - # first check that the element is in the project - local( $flav ) = &CTQueryProj( $_[1] ) ; - local( $root ) = &CTComputeRoot( $_[1], $flav, $_[2] ) ; - local( $pwd ) = &CTUCurrDir() ; - local( $isok ) = 0 ; - if ( ! -e $_[0] ) { - # can't rmname something that doesn't exist - $isok = 0 ; - } else { - if ( $_[0] =~ /^\// ) { - # starts with a /, might not be in the project we are - if ( $_[0] =~ /^$root/ ) { - $isok = 1 ; - } else { - $isok = 0 ; - } - } else { - # are we sitting in the project? - if ( $pwd =~ /^$root/ ) { - $isok = 1 ; - } else { - $isok = 0 ; - } - } - } - if ( $isok ) { - # now switch off on how to actually do the work - local( $type ) = &CTSpecType( $_[2] ) ; - if ( $type eq "vroot" ) { - require "$tool/built/include/ctccase.pl" ; - $ret = &CTCcaseRnElem( $_[0], $pwd ) ; - } elsif ( $type eq "root" ) { - require "$tool/built/include/ctntool.pl" ; - $ret = &CTNtoolRmElem( $_[0], $pwd ) ; - } elsif ( $type eq "croot" ) { - require "$tool/built/include/ctcvs.pl" ; - $ret = &CTCvsRmElem( $_[0], $_[1], $_[2] ) ; - } else { - print STDERR "CTCMRmElem::error! got invalid spec type '" . - $type . "'\n" ; - } - } - &CTUDebug( "out of CTCMRmElem\n" ) ; - $ret ; -} - -# move an element from one name to another -# input is in: -# $_[0] = from element -# $_[1] = to element -# $_[2] = project -# $_[3] = spec line -# -# output: -# return success or failure -sub CTCMMv { - &CTUDebug( "in CTCMMv\n" ) ; - local( $ret ) = 0 ; - # first check that the from and to are in the project - local( $flav ) = &CTQueryProj( $_[2] ) ; - local( $root ) = &CTComputeRoot( $_[2], $flav, $_[3] ) ; - local( $pwd ) = &CTUCurrDir() ; - local( $isok ) = 0 ; - if ( $_[0] =~ /^\// ) { - # starts with a /, might not be in the project we are - if ( $_[0] =~ /^$root/ ) { - $isok = 1 ; - } else { - $isok = 0 ; - } - } else { - # are we sitting in the project? - if ( $pwd =~ /^$root/ ) { - $isok = 1 ; - } else { - $isok = 0 ; - } - } - if ( $isok ) { - if ( $_[1] =~ /^\// ) { - # starts with a /, might not be in the project we are - if ( $_[1] =~ /^$root/ ) { - $isok = 1 ; - } else { - $isok = 0 ; - } - } else { - # are we sitting in the project? - if ( $pwd =~ /^$root/ ) { - $isok = 1 ; - } else { - $isok = 0 ; - } - } - } - if ( $isok ) { - # now switch off on how to actually do the work - local( $type ) = &CTSpecType( $_[3] ) ; - if ( $type eq "vroot" ) { - require "$tool/built/include/ctccase.pl" ; - $ret = &CTCcaseMv( $_[0], $_[1], $pwd ) ; - } elsif ( $type eq "root" ) { - require "$tool/built/include/ctntool.pl" ; - $ret = &CTNtoolMv( $_[0], $_[1], $pwd ) ; - } elsif ( $type eq "croot" ) { - require "$tool/built/include/ctcvs.pl" ; - $ret = &CTCvsMv( $_[0], $_[1], $_[2], $_[3] ) ; - } else { - print STDERR "CTCMMv::error! got invalid spec type '" . - $type . "'\n" ; - } - } - &CTUDebug( "out of CTCMMv\n" ) ; - $ret ; -} - -# give a list of targets, build them -# input is in: -# $_[0] = targets -# $_[1] = project -# $_[2] = spec line -# -# output: -# return success or failure -sub CTCMMake { - &CTUDebug( "in CTCMMake\n" ) ; - local( $ret ) = 0 ; - # now switch off on how to actually do the work - local( $type ) = &CTSpecType( $_[2] ) ; - if ( $type eq "vroot" ) { - require "$tool/built/include/ctccase.pl" ; - $ret = &CTCcaseMake( $_[0] ) ; - } elsif ( $type eq "root" ) { - require "$tool/built/include/ctntool.pl" ; - $ret = &CTNtoolMake( $_[0] ) ; - } elsif ( $type eq "croot" ) { - require "$tool/built/include/ctcvs.pl" ; - $ret = &CTCvsMake( $_[0] ) ; - } else { - print STDERR "CTCMMake::error! got invalid spec type '" . $type . - "'\n" ; - } - &CTUDebug( "out of CTCMMake\n" ) ; - $ret ; -} - -1; diff --git a/dtool/src/attach/ctco b/dtool/src/attach/ctco deleted file mode 100644 index a090e68dba..0000000000 --- a/dtool/src/attach/ctco +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/perl - -sub CTCoUsage { - print STDERR "Usage: ctco [-c \"comment\"] [-nc] element-name [...]\n" ; - print STDERR "Options:\n" ; - print STDERR " -c \"comment\" : provide a comment about this action\n" ; - print STDERR " -nc : expect no comment on this action\n" ; - exit; -} - -if ( $#ARGV < 0 ) { - &CTCoUsage ; -} - -$tool = $ENV{"DTOOL"} ; -if ( $tool eq "" ) { - die "Environment not configured for CTtools" ; -} - -require "$tool/built/include/ctutils.pl" ; -require "$tool/built/include/ctvspec.pl" ; -require "$tool/built/include/ctquery.pl" ; -require "$tool/built/include/ctproj.pl" ; -require "$tool/built/include/ctcm.pl" ; - -$comment = "" ; - -$skip = 0 ; - -@files = () ; - -foreach $item ( @ARGV ) { - if ( $skip == 0 ) { - if ( $item eq "-nc" ) { - &CTUDebug( "-nc processed\n" ) ; - } elsif ( $item eq "-c" ) { - $skip = 1 ; - } else { - push( @files, $item ) ; - &CTUDebug( "added '" . $item . "' to files to be processed\n" ) ; - } - } elsif ( $skip == 1 ) { - $comment = $item ; - &CTUDebug( "setting comment to '" . $comment . "'\n" ) ; - $skip = 0 ; - } else { - &CTUDebug( "got to unknown skip value! (" . $skip . ")\n" ) ; - $skip = 0 ; - } -} - -if ( $#files < 0 ) { - &CTCoUsage ; -} - -$projname = &CTProj ; -$projname =~ tr/A-Z/a-z/ ; -$flav = &CTQueryProj( $projname ) ; -$spec = &CTResolveSpec( $projname, $flav ) ; - -foreach $item ( @files ) { - if ( -e $item ) { - if ( ! &CTCMCheckout( $item, $projname, $spec, $comment ) ) { - print STDERR "Could not checkout '$item'\n" ; - } - } else { - print STDERR "No such file '$item'.\n" ; - } -} diff --git a/dtool/src/attach/ctcvs.pl b/dtool/src/attach/ctcvs.pl deleted file mode 100644 index 8e50d75adb..0000000000 --- a/dtool/src/attach/ctcvs.pl +++ /dev/null @@ -1,451 +0,0 @@ -# given a possibly empty string, format it into a comment or -nc -# input is in: -# $_[0] = possible comment string -# -# output is: -# string for use by CVS functions -sub CTCvsFormatComment { - local( $ret ) = "" ; - if ( $_[0] ne "" ) { - $ret = "-m \"" . $_[0] . "\"" ; - } - $ret ; -} - -# given a project and spec line, compute the server line -# input is in: -# $_[0] = project -# $_[1] = spec line -# -# output: -# return a sever line, or "" if not a croot -sub CTCvsServerLine { - &CTUDebug( "in CTCvsServerLine\n" ) ; - local( $ret ) = "" ; - local( $type ) = &CTSpecType( $_[1] ) ; - if ( $type eq "croot" ) { - local( $options ) = &CTSpecOptions( $_[1] ) ; - local( $sline ) = &CTSpecFindOption( $options, "server" ) ; - if ( $sline ne "" ) { - $ret = join( ":", split( /,/, $sline )); - } - } - &CTUDebug( "out of CTCvsServerLine\n" ) ; - $ret ; -} - -# if needed log into a cvs server -# input is in: -# $_[0] = server line -# -# output: -# return success or failure -sub CTCvsLogin { - &CTUDebug( "in CTCvsLogin\n" ) ; - local( $ret ) = 0 ; - &CTUDebug( "server line is '" . $_[0] . "'\n" ) ; - if ( $_[0] ne "" ) { - # ok. we actually have something, lets look in .cvspass - local( $path ) ; - local( *PASSFILE ) ; - if ( $ENV{"PENV"} eq "WIN32" ) { - $path = $ENV{"HOME"} . "/.cvspass" ; - } else { - # $path = "~/.cvspass" ; - $path = $ENV{"HOME"} . "/.cvspass" ; - } - &CTUDebug( "looking for '" . $path . "'\n" ) ; - if ( -e $path ) { - local( $passdone ) = 0 ; - local( $ok ) = 0 ; - open( PASSFILE, "< $path" ) ; - while ( ) { - s/\n$// ; - local( @line ) = split ; - # ok, the server line is in [0] and the password in [1]. - &CTUDebug( "server line from .cvspass is '" . $line[0] . - "'\n" ) ; - if ( $line[0] eq $_[0] ) { - # we're fine, we're already logged in to that - $ret = 1 ; - $passdone = 1; - } - } - if ( ! $passdone ) { - # ran out of lines in the file - local( $line ) = "cvs -d " . $_[0] . " login >/dev/null" ; - &CTUDebug( "about to run '" . $line . "'\n" ) ; - $ret = &CTURetCode( system( $line )) ; - } - } else { - &CTUDebug( $path . " file does not exist\n" ) ; - local( $line ) = "cvs -d " . $_[0] . " login >/dev/null" ; - &CTUDebug( "about to run '" . $line . "'\n" ) ; - $ret = &CTURetCode( system( $line )) ; - } - } - &CTUDebug( "out of CTCvsLogin\n" ) ; - $ret ; -} - -require "$tool/built/include/ctproj.pl" ; - -# add a versioned element to the repository -# input is in: -# $_[0] = element -# $_[1] = project -# $_[2] = spec line -# $_[3] = possible comment -# -# output: -# return success or failure -sub CTCvsAdd { - &CTUDebug( "in CTCvsAdd\n" ) ; - # first we need to 'login' to the repository - local( $comment ) = &CTCvsFormatComment( $_[3] ) ; - local( $serve ) = &CTCvsServerLine( $_[1], $_[2] ) ; - local( $ret ) = &CTCvsLogin( $serve ) ; - if ( $ret ) { - # now issue the add command - local( $root ) = &CTProjRoot( $_[1] ) ; - local( $line ) = "" ; - local( $elem ) = $_[0] ; - if ( $elem =~ /^\// ) { - local( $proj ) = $_[1] ; - $proj =~ tr/a-z/A-Z/ ; - $line = "cd \$" . $proj . "; " ; - $elem =~ s/^$root\/// ; - } - $line = $line . "cvs -d " . $serve . " add " . $comment . " $elem" ; - &CTUDebug( "about to execute '" . $line . "'\n" ) ; - $ret = &CTURetCode( system( $line )) ; - } - &CTUDebug( "out of CTCvsAdd\n" ) ; - $ret ; -} - -# ci a versioned element to the repository -# input is in: -# $_[0] = element -# $_[1] = project -# $_[2] = spec line -# $_[3] = possible comment -# -# output: -# return success or failure -sub CTCvsCi { - &CTUDebug( "in CTCvsCi\n" ) ; - # first we need to 'login' to the repository - local( $comment ) = &CTCvsFormatComment( $_[3] ) ; - local( $serve ) = &CTCvsServerLine( $_[1], $_[2] ) ; - local( $ret ) = &CTCvsLogin( $serve ) ; - if ( $ret ) { - # now issue the add command - local( $root ) = &CTProjRoot( $_[1] ) ; - local( $line ) = "" ; - local( $elem ) = $_[0] ; - if ( $elem =~ /^\// ) { - local ( $proj ) = $_[1] ; - $proj =~ tr/a-z/A-Z/ ; - $line = "cd \$" . $proj . "; " ; - $elem =~ s/^$root\/// ; - } - $line = $line . "cvs -d " . $serve . " ci " . $comment . " $elem" ; - &CTUDebug( "about to execute '" . $line . "'\n" ) ; - $ret = &CTURetCode( system( $line )) ; - } - &CTUDebug( "out of CTCvsCi\n" ) ; - $ret ; -} - -# rm a versioned element from the repository -# input is in: -# $_[0] = element -# $_[1] = project -# $_[2] = spec line -# -# output: -# return success or failure -sub CTCvsRm { - &CTUDebug( "in CTCvsRm\n" ) ; - # first we need to 'login' to the repository - local( $serve ) = &CTCvsServerLine( $_[1], $_[2] ) ; - local( $ret ) = &CTCvsLogin( $serve ) ; - if ( $ret ) { - # now issue the add command - $ret = &CTURetCode( system( "cvs -d " . $serve . " rm $_[0]\n" )) ; - } - &CTUDebug( "out of CTCvsRm\n" ) ; - $ret ; -} - -# make a versioned directory -# input is in: -# $_[0] = directory to create -# $_[1] = project -# $_[2] = spec line -# $_[3] = possible comment -# -# output: -# return success or failure -sub CTCvsMkdir { - &CTUDebug( "in CTCvsMkdir\n" ) ; - local( $ret ) = 0 ; - # first make the dir - $ret = &CTURetCode( system( "mkdir $_[0]\n" )) ; - if ( $ret ) { - # now version it - $ret = &CTCvsAdd( $_[0], $_[1], $_[2], $_[3] ) ; - } else { - &CTUDebug( "could not create directory '" . $_[0] . "'\n" ) ; - $ret = 0 ; - } - &CTUDebug( "out of CTCvsMkdir\n" ) ; - $ret ; -} - -# make a versioned element -# input is in: -# $_[0] = element to version -# $_[1] = project -# $_[2] = spec line -# $_[3] = possible comment -# -# output: -# return success or failure -sub CTCvsMkelem { - &CTUDebug( "in CTCvsMkelem\n" ) ; - # first cvs add the file - local( $ret ) = &CTCvsAdd( $_[0], $_[1], $_[2], $_[3] ) ; - if ( $ret ) { - # now commit it - $ret = &CTCvsCi( $_[0], $_[1], $_[2], $_[3] ) ; - } else { - &CTUDebug( "could not CVS add '" . $_[0] . "'\n" ) ; - $ret = 0 ; - } - &CTUDebug( "out of CTCvsMkelem\n" ) ; - $ret ; -} - -# delta an element -# input is in: -# $_[0] = element to delta -# $_[1] = project -# $_[2] = spec line -# -# output: -# return success or failure -sub CTCvsDelta { - &CTUDebug( "in CTCvsDelta\n" ) ; - local( $ret ) = 0 ; - # for lack of better idea, this is going to be just checkin for now - if ( -d $_[0] ) { - # we don't version directories in CVS - $ret = 1 ; - } else { - $ret = &CTCvsCi( $_[0], $_[1], $_[2] ) ; - } - &CTUDebug( "out of CTCvsDelta\n" ) ; - $ret ; -} - -# checkout an element -# input is in: -# $_[0] = element to checkout -# $_[1] = project -# $_[2] = spec line -# $_[3] = possible comment -# -# output: -# return success or failure -sub CTCvsCheckout { - &CTUDebug( "in CTCvsCheckout\n" ) ; - local( $ret ) = 1 ; - # for my limited understanding of CVS, there doesn't seem to be any - # 'checkout' for it. - &CTUDebug( "out of CTCvsCheckout\n" ) ; - $ret ; -} - -# checkin an element -# input is in: -# $_[0] = element to checkin -# $_[1] = project -# $_[2] = spec line -# $_[3] = possible comment -# -# output: -# return success or failure -sub CTCvsCheckin { - &CTUDebug( "in CTCvsCheckin\n" ) ; - local( $ret ) = 0 ; - if ( -d $_[0] ) { - # we don't version directories in CVS - $ret = 1 ; - } else { - $ret = &CTCvsCi( $_[0], $_[1], $_[2], $_[3] ) ; - } - &CTUDebug( "out of CTCvsCheckin\n" ) ; - $ret ; -} - -# uncheckout an element -# input is in: -# $_[0] = element to uncheckout -# $_[1] = project -# $_[2] = spec line -# -# output: -# return success or failure -sub CTCvsUncheckout { - &CTUDebug( "in CTCvsUncheckout\n" ) ; - local( $ret ) = 0 ; - if ( -d $_[0] ) { - # we don't version directories in CVS - $ret = 1 ; - } else { - $ret = &CTURetCode( system( "rm $_[0]" ) ) ; - if ( $ret ) { - local( $serve ) = &CTCvsServerLine( $_[1], $_[2] ) ; - $ret = &CTCvsLogin( $serve ) ; - if ( $ret ) { - $ret = &CTURetCode( system( "cvs -d " . $serve . " update " . - $_[0] )) ; - } - } - } - &CTUDebug( "out of CTCvsUncheckout\n" ) ; - $ret ; -} - -# figure out what all I have checked out -# input is in: -# $_[0] = project -# $_[1] = flavor -# $_[2] = spec line -# -# output: -# return a \n serperated list of elements checked out -sub CTCvsIHave { - &CTUDebug( "in CTCvsIHave\n" ) ; - local( $ret ) = "" ; - local( $proj ) = $_[0] ; - $proj =~ tr/a-z/A-Z/ ; - local( $line ) = "cd \$" . $proj . "; " ; - local( $serve ) = &CTCvsServerLine( $_[0], $_[2] ) ; - local( $ok ) = &CTCvsLogin( $serve ) ; - if ( $ok ) { - $line = $line . "cvs -n -d " . $serve . " update 2>/dev/null" ; - local( $hold ) = ""; - local( *OUTPUT ) ; - open( OUTPUT, $line . " |" ) ; - while ( ) { - $hold = $hold . $_ ; - } - close( OUTPUT ) ; - local( @lines ) = split( /\n/, $hold ) ; - local( $item ) ; - foreach $item ( @lines ) { - if ( $item =~ /^\?/ ) { - # things that start with a ? are ignored - } elsif ( $item =~ /^cvs/ ) { - # messages from the server are also ignored - } elsif ( $item =~ /^P/ ) { - # new files are ignored - } elsif ( $item =~ /^U/ ) { - # updates are ignored - } elsif ( $item =~ /^M/ ) { - # here's one we modified - local( @foo ) = split( / /, $item ) ; - $ret = $ret . $foo[1] . "\n" ; - } else { - # don't what this means, better complain - local( @foo ) = split( / /, $item ) ; - print STDERR "got unknown update code '" . $foo[0] . - "' for file '" . $foo[1] . "'\n" ; - } - } - } - &CTUDebug( "out of CTCvsIHave\n" ) ; - $ret ; -} - -# remove an element from the repository -# input is in: -# $_[0] = element to uncheckout -# $_[1] = project -# $_[2] = spec line -# -# output: -# return success or failure -sub CTCvsRmElem { - &CTUDebug( "in CTCvsRmElem\n" ) ; - local( $ret ) = 0 ; - if ( -d $_[0] ) { - # CVS doesn't really do this. If there are no files in the directory, - # the next time an update -P is run, it will be deleted. - $ret = 1 ; - } else { - $ret = &CTURetCode( system( "rm $_[0]" ) ) ; - if ( $ret ) { - $ret = &CTCvsRm( $_[0], $_[1], $_[2] ) ; - if ( $ret ) { - $ret = &CTCvsCi( $_[0], $_[1], $_[2] ) ; - } - } - } - &CTUDebug( "out of CTCvsRmElem\n" ) ; - $ret ; -} - -# move a versioned element from one name to another -# input is in: -# $_[0] = from element -# $_[1] = to element -# $_[2] = project -# $_[3] = spec line -# -# output: -# return success or failure -sub CTCvsMv { - &CTUDebug( "in CTCvsMv\n" ) ; - local( $ret ) = 0 ; - if ( -d $_[0] ) { - # don't have code to do directories yet. See pp 54 of the CVS book - $ret = 0 ; - } else { - $ret = &CTURetCode( system( "mv $_[0] $_[1]" ) ) ; - if ( $ret ) { - $ret = &CTCvsRm( $_[0], $_[2], $_[3] ) ; - if ( $ret ) { - $ret = &CTCvsAdd( $_[1], $_[2], $_[3] ); - if ( $ret ) { - $ret = &CTCvsCi( $_[0], $_[2], $_[3] ) ; - if ( $ret ) { - $ret = &CTCvsCi( $_[1], $_[2], $_[3] ) ; - } - } - } - } - } - &CTUDebug( "out of CTCvsMv\n" ) ; - $ret ; -} - -# build a list of targets -# input is in: -# $_[0] = targets -# -# output: -# return success or failure -sub CTCvsMake { - &CTUDebug( "in CTCvsMake\n" ) ; - local( $ret ) = 0 ; - local( $line ) = "make " . $_[0] . "\n" ; - $ret = &CTURetCode( system( $line )) ; - &CTUDebug( "out of CTCvsMake\n" ) ; - $ret ; -} - -1; diff --git a/dtool/src/attach/ctdelta b/dtool/src/attach/ctdelta deleted file mode 100755 index 395c2a37c9..0000000000 --- a/dtool/src/attach/ctdelta +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/perl - -if ($#ARGV < 0) { - exit print "Usage: ctdelta element-name [...]\n" ; -} - -$tool = $ENV{"DTOOL"} ; -if ( $tool eq "" ) { - die "not configured for using ct-tools\n" ; -} - -require "$tool/built/include/ctutils.pl" ; -require "$tool/built/include/ctvspec.pl" ; -require "$tool/built/include/ctquery.pl" ; -require "$tool/built/include/ctproj.pl" ; -require "$tool/built/include/ctcm.pl" ; - -$comment = "" ; -$skip = 0 ; - -@files = () ; - -foreach $item ( @ARGV ) { - if ( $skip == 0 ) { - if ( $item eq "-nc" ) { - &CTUDebug( "-nc processed\n" ) ; - } elsif ( $item eq "-c" ) { - $skip = 1 ; - } else { - push( @files, $item ) ; - &CTUDebug( "added '" . $item . "' to files to be processed\n" ) ; - } - } elsif ( $skip == 1 ) { - $comment = $item ; - &CTUDebug( "setting comment to '" . $comment . "'\n" ) ; - $skip = 0 ; - } else { - &CTUDebug( "got to unknown skip value! (" . $skip . ")\n" ) ; - $skip = 0 ; - } -} - -$projname = &CTProj ; -$projname =~ tr/A-Z/a-z/ ; -$flav = &CTQueryProj( $projname ) ; -$spec = &CTResolveSpec( $projname, $flav ) ; - -foreach $item ( @files ) { - if ( -e $item ) { - &CTCMCheckin( $item, $projname, $spec ) ; - if ( ! &CTCMDelta( $item, $projname, $spec ) ) { - print STDERR "Could not delta '$item'\n" ; - } - } else { - print STDERR "No such file '$item'.\n" ; - } -} diff --git a/dtool/src/attach/ctdelta.pl b/dtool/src/attach/ctdelta.pl deleted file mode 100644 index 2b870fa495..0000000000 --- a/dtool/src/attach/ctdelta.pl +++ /dev/null @@ -1,232 +0,0 @@ -# Check in element if needed -# Input is: -# $_[0] = element name -sub CTDeltaCheckin { - local( $cmd ) = "cleartool ci -nc $_[0] 2> /dev/null > /dev/null" ; - system $cmd ; -} - -# get the version of an element -# Input is: -# $_[0] = element name -sub CTDeltaGetVersion { - local( *CMDFILE ) ; - open( CMDFILE, "cleartool describe -short $_[0] |" ) ; - $_ = ; - close( CMDFILE ) ; - s/\n$// ; - s/^.*@@// ; - s/\"$// ; - $_ ; -} - -# Is it ok to try a merge on this version? -# Input is: -# $_[0] = version -sub CTDeltaOk { - local( $ret ) ; - local( @verlist ) ; - @verlist = split( /\//, $_[0] ) ; - pop( @verlist ) ; - if ( $#verlist > 1 ) { - $ret = 1 ; - } else { - $ret = 0 ; - } - $ret ; -} - -# get the comments from a version of an element -# Input is: -# $_[0] = element name -# $_[1] = version -# -# output in: -# @CTDeltaComments -sub CTDeltaGetComments { - local( *CMDFILE ) ; - local( $done ) = 0 ; - local( $end ) = " element type:" ; - local( $tmp ) = "cleartool describe $_[0]" . "@@" . "$_[1] |" ; - open( CMDFILE, $tmp ) ; - $_ = ; - $_ = ; - while ( ! $done ) { - $_ = ; - if ( $_ =~ /^$end/ ) { - $done = 1 ; - } else { - s/^ // ; - s/^ // ; - s/^\"// ; - s/\n$// ; - s/\"$// ; - push( @CTDeltaComments, $_ ) ; - } - } - close( CMDFILE ) ; -} - -# try automatic merge. If it fails, use xmerge -# Input is: -# $_[0] = element name -# $_[1] = source version -# $_[2] = target version -sub CTDeltaSafeMerge { - @CTDeltaComments = (); - &CTDeltaGetComments($_[0], $_[1]); - local( $ret ) ; - $ret = "cleartool checkout -branch $_[2] -nc $_[0] 2> /dev/null > /dev/null" ; - $ret = system $ret ; - if ( $ret != 0 ) { - print STDERR "got return value $ret from checkout on '$_[0]" . "@@" . "$_[2]'\n" ; - exit -1; - } - local( $item ) ; - foreach $item ( @CTDeltaComments ) { - $ret = "cleartool chevent -append -c \"" . $item . "\" $_[0]" . "@@" . "$_[2]" . "/LATEST 2> /dev/null > /dev/null" ; - system $ret ; - } - print STDERR "merging '$_[0]'...\n" ; - $ret = "cleartool merge -abort -to $_[0] -version $_[1] 2> /dev/null > /dev/null" ; - $ret = system $ret ; - if ( $ret != 0 ) { - $ret = system "cleartool xmerge -to $_[0] -version $_[1]" ; - } - if ( ! -d $_[0] ) { - system "rm $_[0]" . ".contrib" ; - } - $ret ; -} - -# test a branch for 'triviality' -# Input is: -# $_[0] = element name -# $_[1] = branch name -# -# Output is: -# true/false -sub CTDeltaTestBranch { - local( *CTCMD ) ; - local( $ret ) ; - local( $done ) = 0 ; - local( $bfrom ) ; - local( @blist ) ; - local( $bto ) ; - local( $bdiff ) ; - local( $blast ) ; - @blist = split( /\//, $_[1] ) ; - pop( @blist ) ; - $ret = join( "/", @blist ) ; - $ret = "cleartool describe $_[0]" . "@@" . "$ret |" ; - open( CTCMD, $ret ) ; - while ( ! $done ) { - $_ = ; - if ( $_ =~ /^ branched from version/ ) { - $done = 1 ; - } - } - close( CTCMD ) ; - s/^ branched from version: // ; - s/\n$// ; - $bfrom = $_ ; - @blist = split( /\//, $_ ) ; - pop( @blist ) ; - push( @blist, "LATEST" ) ; - $ret = join( "/", @blist ) ; - $ret = "cleartool describe $_[0]" . "@@" . "$ret |" ; - open( CTCMD, $ret ) ; - $_ = ; - close( CTCMD ) ; - s/\n$// ; - s/^.*@@// ; - s/\"$// ; - $bto = $_ ; - @blist = split( /\//, $bfrom ) ; - $bfrom = pop( @blist ) ; - @blist = split( /\//, $bto ) ; - $bto = pop( @blist ) ; - $bdiff = $bto - $bfrom ; - $ret = "cleartool describe $_[0]" . "@@" . "$_[1] |" ; - open( CTCMD, $ret ) ; - $_ = ; - close( CTCMD ) ; - s/\n$// ; - s/^.*@@// ; - s/\"$// ; - @blist = split( /\//, $_ ) ; - $blast = pop( @blist ) ; - if (( $bdiff > 1 ) || ( $blast > 1 )) { - $ret = 0 ; - } else { - $ret = 1 ; - } -} - -# check for trivial branch elimination -# Input is: -# $_[0] = element name -# $_[1] = last branch version -# $_[2] = timestamp string -sub CTDeltaBranchCheck { - local( $test ) = &CTDeltaTestBranch( $_[0], $_[1] ) ; - local( $cmd ) ; - local( @blist ) ; - local( $branch ) ; - @blist = split( /\//, $_[1] ) ; - if ( $test ) { - pop( @blist ) ; - $cmd = join( "/", @blist ) ; - $branch = join( "/", @blist ) ; - $cmd = "cleartool rmbranch -force $_[0]" . "@@" . "$cmd 2> /dev/null > /dev/null" ; - print STDERR "deleting branch '$branch'...\n" ; - system $cmd ; - } else { - pop( @blist ) ; - $branch = join( "/", @blist ) ; - $test = pop( @blist ) ; - $test = $test . $_[2] ; - $cmd = "cleartool mkbrtype -c \"non-trivial branch\" $test 2> /dev/null > /dev/null" ; - system $cmd ; - $cmd = "cleartool chtype -c \"renaming non-trivial branch\" $test $_[0]" . "@@" . "$branch 2> /dev/null > /dev/null" ; - print STDERR "renaming branch '$branch'...\n" ; - system $cmd ; - } -} - -# log merge to /usr/local/etc/delta_log -# Input is: -# $_[0] = element name -# $_[1] = source version -# $_[2] = target version -sub CTDeltaLog { - local( *LOGFILE ) ; - local( *CMDFILE ) ; - local( $cmd ) ; - open( LOGFILE, ">>/usr/local/etc/delta_log" ) ; - print LOGFILE $_[0] . ": " . $_[1] . " -> " . $_[2] . " : " ; - if ( $ctdebug ne "" ) { - print STDERR "CTDeltaLog: outputting '" . $_[0] . ": " . $_[1] . " -> " . $_[2] . " : '\n" ; - } - $cmd = "ypmatch `whoami` passwd | cut -d: -f5 |" ; - open( CMDFILE, $cmd ) ; - $_ = ; - s/\n$//; - print LOGFILE $_ . " " ; - if ( $ctdebug ne "" ) { - print STDERR "CTDeltaLog: outputting '" . $_ . " '\n" ; - } - close( CMDFILE ) ; - $cmd = "/bin/date '+%m/%d/%y %H:%M:%S' |" ; - open( CMDFILE, $cmd ) ; - $_ = ; - s/\n$//; - print LOGFILE $_ . "\n" ; - if ( $ctdebug ne "" ) { - print STDERR "CTDeltaLog: outputting '" . $_ . " '\n" ; - } - close( CMDFILE ) ; - close( LOGFILE ) ; -} - -1; diff --git a/dtool/src/attach/ctdelta.pl.rnd b/dtool/src/attach/ctdelta.pl.rnd deleted file mode 100644 index dde5feb574..0000000000 --- a/dtool/src/attach/ctdelta.pl.rnd +++ /dev/null @@ -1,232 +0,0 @@ -# Check in element if needed -# Input is: -# $_[0] = element name -sub CTDeltaCheckin { - local( $cmd ) = "cleartool ci -nc $_[0] 2> /dev/null > /dev/null" ; - system $cmd ; -} - -# get the version of an element -# Input is: -# $_[0] = element name -sub CTDeltaGetVersion { - local( *CMDFILE ) ; - open( CMDFILE, "cleartool describe -short $_[0] |" ) ; - $_ = ; - close( CMDFILE ) ; - s/\n$// ; - s/^.*@@// ; - s/\"$// ; - $_ ; -} - -# Is it ok to try a merge on this version? -# Input is: -# $_[0] = version -sub CTDeltaOk { - local( $ret ) ; - local( @verlist ) ; - @verlist = split( /\//, $_[0] ) ; - pop( @verlist ) ; - if ( $#verlist > 1 ) { - $ret = 1 ; - } else { - $ret = 0 ; - } - $ret ; -} - -# get the comments from a version of an element -# Input is: -# $_[0] = element name -# $_[1] = version -# -# output in: -# @CTDeltaComments -sub CTDeltaGetComments { - local( *CMDFILE ) ; - local( $done ) = 0 ; - local( $end ) = " element type:" ; - local( $tmp ) = "cleartool describe $_[0]" . "@@" . "$_[1] |" ; - open( CMDFILE, $tmp ) ; - $_ = ; - $_ = ; - while ( ! $done ) { - $_ = ; - if ( $_ =~ /^$end/ ) { - $done = 1 ; - } else { - s/^ // ; - s/^ // ; - s/^\"// ; - s/\n$// ; - s/\"$// ; - push( @CTDeltaComments, $_ ) ; - } - } - close( CMDFILE ) ; -} - -# try automatic merge. If it fails, use xmerge -# Input is: -# $_[0] = element name -# $_[1] = source version -# $_[2] = target version -sub CTDeltaSafeMerge { - @CTDeltaComments = (); - &CTDeltaGetComments($_[0], $_[1]); - local( $ret ) ; - $ret = "cleartool checkout -branch $_[2] -nc $_[0] 2> /dev/null > /dev/null" ; - $ret = system $ret ; - if ( $ret != 0 ) { - print STDERR "got return value $ret from checkout on '$_[0]" . "@@" . "$_[2]'\n" ; - exit -1; - } - local( $item ) ; - foreach $item ( @CTDeltaComments ) { - $ret = "cleartool chevent -append -c \"" . $item . "\" $_[0]" . "@@" . "$_[2]" . "/LATEST 2> /dev/null > /dev/null" ; - system $ret ; - } - print STDERR "merging '$_[0]'...\n" ; - $ret = "cleartool merge -abort -to $_[0] -version $_[1] 2> /dev/null > /dev/null" ; - $ret = system $ret ; - if ( $ret != 0 ) { - $ret = system "cleartool xmerge -to $_[0] -version $_[1]" ; - } - if ( ! -d $_[0] ) { - system "rm $_[0]" . ".contrib" ; - } - $ret ; -} - -# test a branch for 'triviality' -# Input is: -# $_[0] = element name -# $_[1] = branch name -# -# Output is: -# true/false -sub CTDeltaTestBranch { - local( *CTCMD ) ; - local( $ret ) ; - local( $done ) = 0 ; - local( $bfrom ) ; - local( @blist ) ; - local( $bto ) ; - local( $bdiff ) ; - local( $blast ) ; - @blist = split( /\//, $_[1] ) ; - pop( @blist ) ; - $ret = join( "/", @blist ) ; - $ret = "cleartool describe $_[0]" . "@@" . "$ret |" ; - open( CTCMD, $ret ) ; - while ( ! $done ) { - $_ = ; - if ( $_ =~ /^ branched from version/ ) { - $done = 1 ; - } - } - close( CTCMD ) ; - s/^ branched from version: // ; - s/\n$// ; - $bfrom = $_ ; - @blist = split( /\//, $_ ) ; - pop( @blist ) ; - push( @blist, "LATEST" ) ; - $ret = join( "/", @blist ) ; - $ret = "cleartool describe $_[0]" . "@@" . "$ret |" ; - open( CTCMD, $ret ) ; - $_ = ; - close( CTCMD ) ; - s/\n$// ; - s/^.*@@// ; - s/\"$// ; - $bto = $_ ; - @blist = split( /\//, $bfrom ) ; - $bfrom = pop( @blist ) ; - @blist = split( /\//, $bto ) ; - $bto = pop( @blist ) ; - $bdiff = $bto - $bfrom ; - $ret = "cleartool describe $_[0]" . "@@" . "$_[1] |" ; - open( CTCMD, $ret ) ; - $_ = ; - close( CTCMD ) ; - s/\n$// ; - s/^.*@@// ; - s/\"$// ; - @blist = split( /\//, $_ ) ; - $blast = pop( @blist ) ; - if (( $bdiff > 1 ) || ( $blast > 1 )) { - $ret = 0 ; - } else { - $ret = 1 ; - } -} - -# check for trivial branch elimination -# Input is: -# $_[0] = element name -# $_[1] = last branch version -# $_[2] = timestamp string -sub CTDeltaBranchCheck { - local( $test ) = &CTDeltaTestBranch( $_[0], $_[1] ) ; - local( $cmd ) ; - local( @blist ) ; - local( $branch ) ; - @blist = split( /\//, $_[1] ) ; - if ( $test ) { - pop( @blist ) ; - $cmd = join( "/", @blist ) ; - $branch = join( "/", @blist ) ; - $cmd = "cleartool rmbranch -force $_[0]" . "@@" . "$cmd 2> /dev/null > /dev/null" ; - print STDERR "deleting branch '$branch'...\n" ; - system $cmd ; - } else { - pop( @blist ) ; - $branch = join( "/", @blist ) ; - $test = pop( @blist ) ; - $test = $test . $_[2] ; - $cmd = "cleartool mkbrtype -c \"non-trivial branch\" $test 2> /dev/null > /dev/null" ; - system $cmd ; - $cmd = "cleartool chtype -c \"renaming non-trivial branch\" $test $_[0]" . "@@" . "$branch 2> /dev/null > /dev/null" ; - print STDERR "renaming branch '$branch'...\n" ; - system $cmd ; - } -} - -# log merge to /var/etc/delta_log -# Input is: -# $_[0] = element name -# $_[1] = source version -# $_[2] = target version -sub CTDeltaLog { - local( *LOGFILE ) ; - local( *CMDFILE ) ; - local( $cmd ) ; - open( LOGFILE, ">>/var/etc/delta_log" ) ; - print LOGFILE $_[0] . ": " . $_[1] . " -> " . $_[2] . " : " ; - if ( $ctdebug ne "" ) { - print STDERR "CTDeltaLog: outputting '" . $_[0] . ": " . $_[1] . " -> " . $_[2] . " : '\n" ; - } - $cmd = "ypmatch `whoami` passwd | cut -d: -f5 |" ; - open( CMDFILE, $cmd ) ; - $_ = ; - s/\n$//; - print LOGFILE $_ . " " ; - if ( $ctdebug ne "" ) { - print STDERR "CTDeltaLog: outputting '" . $_ . " '\n" ; - } - close( CMDFILE ) ; - $cmd = "/bin/date '+%m/%d/%y %H:%M:%S' |" ; - open( CMDFILE, $cmd ) ; - $_ = ; - s/\n$//; - print LOGFILE $_ . "\n" ; - if ( $ctdebug ne "" ) { - print STDERR "CTDeltaLog: outputting '" . $_ . " '\n" ; - } - close( CMDFILE ) ; - close( LOGFILE ) ; -} - -1; diff --git a/dtool/src/attach/ctihave b/dtool/src/attach/ctihave deleted file mode 100755 index c6cfe5267f..0000000000 --- a/dtool/src/attach/ctihave +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/perl - -if ($#ARGV != -1) { - exit print "Usage: ctihave\n" ; -} - -$tool = $ENV{"DTOOL"} ; -if ( $tool eq "" ) { - die "not configured for using CTtools\n" ; -} - -require "$tool/built/include/ctutils.pl" ; -require "$tool/built/include/ctvspec.pl" ; -require "$tool/built/include/ctquery.pl" ; -require "$tool/built/include/ctproj.pl" ; -require "$tool/built/include/ctcm.pl" ; - -$projname = &CTProj ; -$projname =~ tr/A-Z/a-z/ ; -$flav = &CTQueryProj( $projname ) ; -$spec = &CTResolveSpec( $projname, $flav ) ; - -if ( $projname eq "" ) { - exit print "Not currently in any project tree\n" ; -} - -$result = &CTCMIHave( $projname, $flav, $spec ) ; -if ( $result ne "" ) { - @splitlist = split( /\n/, $result ) ; - foreach $item ( @splitlist ) { - print $item . "\n" ; - } -} diff --git a/dtool/src/attach/ctmake b/dtool/src/attach/ctmake deleted file mode 100644 index 56326744ab..0000000000 --- a/dtool/src/attach/ctmake +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/perl - -$tool = $ENV{"DTOOL"} ; -if ( $tool eq "" ) { - die "not configured for using ct-tools\n" ; -} - -require "$tool/built/include/ctutils.pl" ; -require "$tool/built/include/ctvspec.pl" ; -require "$tool/built/include/ctquery.pl" ; -require "$tool/built/include/ctproj.pl" ; -require "$tool/built/include/ctcm.pl" ; - -$projname = &CTProj ; -$projname =~ tr/A-Z/a-z/ ; -$flav = &CTQueryProj( $projname ) ; -$spec = &CTResolveSpec( $projname, $flav ) ; - -$line = join( " ", @ARGV ) ; - -if ( ! &CTCMMake( $line, $projname, $spec ) ) { - print STDERR "Could not make '$line'\n" ; -} diff --git a/dtool/src/attach/ctmkdir b/dtool/src/attach/ctmkdir deleted file mode 100644 index 678dd9494e..0000000000 --- a/dtool/src/attach/ctmkdir +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/perl - -sub CTMkDirUsage { - print STDERR "Usage: ctmkdir [-c \"comment\"] [-nc] dir-name [...]\n" ; - print STDERR "Options:\n" ; - print STDERR " -c \"comment\" : provide a comment about this action\n" ; - print STDERR " -nc : expect no comment on this action\n" ; - exit ; -} - -if ( $#ARGV < 0 ) { - &CTMkDirUsage ; -} - -$tool = $ENV{"DTOOL"} ; -if ( $tool eq "" ) { - die "Environment not configured for CTtools" ; -} - -require "$tool/built/include/ctutils.pl" ; -require "$tool/built/include/ctvspec.pl" ; -require "$tool/built/include/ctquery.pl" ; -require "$tool/built/include/ctproj.pl" ; -require "$tool/built/include/ctcm.pl" ; - -$comment = "" ; -if ( $ARGV[0] eq "-nc" ) { - shift( @ARGV ) ; - &CTUDebug( "-nc processed\n" ) ; -} -if ( $ARGV[0] eq "-c" ) { - shift( @ARGV ) ; - $comment = $ARGV[0] ; - shift( @ARGV ) ; - &CTUDebug( "setting comment to '" . $comment . "'\n" ) ; -} - -if ( $#ARGV < 0 ) { - &CTMkDirUsage ; -} - -$projname = &CTProj ; -$projname =~ tr/A-Z/a-z/ ; -$flav = &CTQueryProj( $projname ) ; -$spec = &CTResolveSpec( $projname, $flav ) ; - -foreach $item ( @ARGV ) { - if ( -e $item ) { - print STDERR "Name collision on directory '$item'\n" ; - } else { - if ( ! &CTCMMkdir( $item, $projname, $spec, $comment ) ) { - print STDERR "Could name make directory '$item'\n" ; - } - } -} diff --git a/dtool/src/attach/ctmkelem b/dtool/src/attach/ctmkelem deleted file mode 100644 index 3d0018cad7..0000000000 --- a/dtool/src/attach/ctmkelem +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/perl - -sub CTMkElemUsage { - print STDERR "Usage: ctmkelem [-c \"comment\"] [-nc] [-eltype type] element-name [...]\n" ; - print STDERR "Options:\n" ; - print STDERR " -c \"comment\" : provide a comment about this action\n" ; - print STDERR " -nc : expect no comment on this action\n" ; - print STDERR " -eltype type : element type\n" ; - exit ; -} - -if ( $#ARGV < 0 ) { - &CTMkElemUsage ; -} - -$tool = $ENV{"DTOOL"} ; -if ( $tool eq "" ) { - die "Environment not configured for CTtools" ; -} - -require "$tool/built/include/ctutils.pl" ; -require "$tool/built/include/ctvspec.pl" ; -require "$tool/built/include/ctquery.pl" ; -require "$tool/built/include/ctproj.pl" ; -require "$tool/built/include/ctcm.pl" ; - -$comment = "" ; -$eltype = "" ; - -$done = 0 ; - -while ( ! $done ) { - $done = 1 ; - if ( $ARGV[0] eq "-nc" ) { - shift( @ARGV ) ; - &CTUDebug( "-nc processed\n" ) ; - $done = 0 ; - } - if ( $ARGV[0] eq "-c" ) { - shift( @ARGV ) ; - $comment = $ARGV[0] ; - shift( @ARGV ) ; - &CTUDebug( "setting comment to '" . $comment . "'\n" ) ; - $done = 0 ; - } - if ( $ARGV[0] eq "-eltype" ) { - shift( @ARGV ) ; - $eltype = $ARGV[0] ; - shift( @ARGV ) ; - &CTUDebug( "setting eltype to '" . $eltype . "'\n" ) ; - $done = 0 ; - } -} - -if ( $#ARGV < 0 ) { - &CTMkElemUsage ; -} - -$projname = &CTProj ; -$projname =~ tr/A-Z/a-z/ ; -$flav = &CTQueryProj( $projname ) ; -$spec = &CTResolveSpec( $projname, $flav ) ; - -foreach $item ( @ARGV ) { - if ( -e $item ) { - if ( -d $item ) { - print STDERR "Cannot mkelem on an existing directory." . - " Ctmkdir it first.\n" ; - } else { - if ( ! &CTCMMkelem( $item, $projname, $spec, $comment, $eltype )) { - print STDERR "Could not make a versioned element of '" . - $item . "'\n" ; - } - } - } else { - print STDERR "No such file '$item'.\n" ; - } -} diff --git a/dtool/src/attach/ctmv b/dtool/src/attach/ctmv deleted file mode 100644 index 6b4985429e..0000000000 --- a/dtool/src/attach/ctmv +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/perl - -if ( $#ARGV != 1 ) { - exit print "Usage: ctmv from-element to-element\n" ; -} - -$tool = $ENV{"DTOOL"} ; -if ( $tool eq "" ) { - die "Environment not configured for CTtools" ; -} - -require "$tool/built/include/ctutils.pl" ; -require "$tool/built/include/ctvspec.pl" ; -require "$tool/built/include/ctquery.pl" ; -require "$tool/built/include/ctproj.pl" ; -require "$tool/built/include/ctcm.pl" ; - -$projname = &CTProj ; -$projname =~ tr/A-Z/a-z/ ; -$flav = &CTQueryProj( $projname ) ; -$spec = &CTResolveSpec( $projname, $flav ) ; - -$from = $ARGV[0] ; -$to = $ARGV[1] ; - -if ( -e $from ) { - if ( -e $to ) { - print STDERR "'$to' already exists.\n" ; - } else { - if ( ! &CTCMMv( $from, $to, $projname, $spec ) ) { - } - } -} else { - print STDERR "No such element '$from'.\n" ; -} diff --git a/dtool/src/attach/ctntool.pl b/dtool/src/attach/ctntool.pl deleted file mode 100644 index 6920a3ee23..0000000000 --- a/dtool/src/attach/ctntool.pl +++ /dev/null @@ -1,258 +0,0 @@ -# given a possibly empty string, format it into a comment or -nc -# input is in: -# $_[0] = possible comment string -# -# output is: -# string for use by neartool functions -sub CTNtoolFormatComment { - local( $ret ) = "" ; - if ( $_[0] eq "" ) { - $ret = "-nc" ; - } else { - $ret = "-c \"" . $_[0] . "\"" ; - } - $ret ; -} - -# make a versioned directory -# input is in: -# $_[0] = directory to create -# $_[1] = curr dir -# $_[2] = possible comment -# -# output: -# return success or failure -sub CTNtoolMkdir { - &CTUDebug( "in CTNtoolMkdir\n" ) ; - local( $ret ) = 0 ; - local( $dir ) = $_[0] ; - if ( ! ( $dir =~ /^\// )) { - $dir = $_[1] . "/" . $dir ; - } - local( $comment ) = &CTNtoolFormatComment( $_[2] ) ; - # first we have to check out the parent directory - local( @alist ) = split( /\//, $dir ) ; - pop( @alist ) ; - local( $parent ) = join( "/", @alist ) ; - &CTUDebug( "parent directory of '" . $dir . "' is '" . $parent . "'\n" ) ; - $ret = system( "neartool co -nc $parent\n" ) ; - if ( $ret == 0 ) { - # now make the dir - $ret = &CTURetCode( system( "neartool mkdir " . $comment . - " $dir\n" )) ; - } else { - $ret = 0 ; - } - &CTUDebug( "out of CTNtoolMkdir\n" ) ; - $ret ; -} - -# make a versioned element -# input is in: -# $_[0] = element to version -# $_[1] = curr dir -# $_[2] = possible comment -# $_[3] = possible eltype -# -# output: -# return success or failure -sub CTNtoolMkelem { - &CTUDebug( "in CTNtoolMkelem\n" ) ; - local( $ret ) = 0 ; - local( $elem ) = $_[0] ; - if ( ! ( $elem =~ /^\// )) { - $elem = $_[1] . "/" . $elem ; - } - local( $comment ) = &CTNtoolFormatComment( $_[2] ) ; - local( $eltype ) = $_[3] ; - if ( $eltype ne "" ) { - $eltype = "-eltype " . $eltype ; - } - local( $line ) = "neartool mkelem " . $comment . " " . $eltype . " " . - $elem . "\n" ; - &CTUDebug( $line ) ; - $ret = &CTURetCode( system( $line )) ; - &CTUDebug( "out of CTNtoolMkelem\n" ) ; - $ret ; -} - -# delta an element -# input is in: -# $_[0] = element to delta -# -# output: -# return success or failure -sub CTNtoolDelta { - &CTUDebug( "in CTNtoolDelta\n" ) ; - local( $ret ) = 0 ; - # as Dave points out, when working off-line, delta is the same as checkin - $ret = &CTURetCode( system( "neartool ci " . $_[0] )) ; - &CTUDebug( "out of CTNtoolDelta\n" ) ; - $ret ; -} - -# checkout an element -# input is in: -# $_[0] = element to checkout -# $_[1] = possible comment -# -# output: -# return success or failure -sub CTNtoolCheckout { - &CTUDebug( "in CTNtoolCheckout\n" ) ; - local( $ret ) = 0 ; - local( $comment ) = &CTNtoolFormatComment( $_[1] ) ; - if ( ! -d $_[0] ) { - $ret = &CTURetCode( system( "neartool co " . $comment . " " . - $_[0] )) ; - } else { - # neartool doesn't do anything about checking out directories - $ret = 1 ; - } - &CTUDebug( "out of CTNtoolCheckout\n" ) ; - $ret ; -} - -# checkin an element -# input is in: -# $_[0] = element to checkin -# $_[1] = possible comment -# -# output: -# return success or failure -sub CTNtoolCheckin { - &CTUDebug( "in CTNtoolCheckin\n" ) ; - local( $ret ) = 0 ; - local( $comment ) = &CTNtoolFormatComment( $_[1] ) ; - $ret = &CTURetCode( system( "neartool ci " . $comment . " " . $_[0] )) ; - &CTUDebug( "out of CTNtoolCheckin\n" ) ; - $ret ; -} - -# uncheckout an element -# input is in: -# $_[0] = element to uncheckout -# -# output: -# return success or failure -sub CTNtoolUncheckout { - &CTUDebug( "in CTNtoolUncheckout\n" ) ; - local( $ret ) = 0 ; - $ret = &CTURetCode( system( "neartool unco " . $_[0] )) ; - &CTUDebug( "out of CTNtoolUncheckout\n" ) ; - $ret ; -} - -# figure out what all I have checked out -# input is in: -# $_[0] = project -# $_[1] = flavor -# $_[2] = spec line -# -# output: -# return a \n serperated list of elements checked out -sub CTNtoolIHave { - &CTUDebug( "in CTNtoolIHave\n" ) ; - local( $ret ) = "" ; - local( $root ) = &CTProjRoot( $_[0] ) ; - local( *OUTPUT ) ; - open( OUTPUT, "neartool find " . $root . " |" ) ; - while ( ) { - $ret = $ret . $_ ; - } - close( OUTPUT ) ; - &CTUDebug( "out of CTNToolIHave\n" ) ; - $ret ; -} - -# remove a versioned element -# input is in: -# $_[0] = element to remove -# $_[1] = curr dir -# -# output: -# return success or failure -sub CTNtoolRmElem { - &CTUDebug( "in CTNtoolRmElem\n" ) ; - local( $ret ) = 0 ; - local( $elem ) = $_[0] ; - if ( ! ( $elem =~ /^\// )) { - $elem = $_[1] . "/" . $elem ; - } - # first we have to check out the parent directory - local( @alist ) = split( /\//, $elem ) ; - pop( @alist ) ; - local( $parent ) = join( "/", @alist ) ; - &CTUDebug( "parent directory of '" . $elem . "' is '" . $parent . "'\n" ) ; - $ret = system( "neartool co -nc $parent\n" ) ; - if ( $ret == 0 ) { - # now nuke the element - $ret = &CTURetCode( system( "neartool rmname $elem\n" )) ; - } else { - $ret = 0 ; - } - &CTUDebug( "out of CTNtoolRmElem\n" ) ; - $ret ; -} - -# mv a versioned element from one name to another -# input is in: -# $_[0] = from element -# $_[1] = to element -# $_[2] = current directory -# -# output: -# return success or failure -sub CTNtoolMv { - &CTUDebug( "in CTNtoolMv\n" ) ; - local( $ret ) = 0 ; - local( $elem ) = $_[0] ; - if ( ! ( $elem =~ /^\// )) { - $elem = $_[2] . "/" . $elem ; - } - # first we have to check out the parent directory - local( @alist ) = split( /\//, $elem ) ; - pop( @alist ) ; - local( $parent ) = join( "/", @alist ) ; - &CTUDebug( "parent directory of '" . $elem . "' is '" . $parent . "'\n" ) ; - local( $elem2 ) = $_[1] ; - if ( ! ( $elem2 =~ /^\// )) { - $elem2 = $_[2] . "/" . $elem2 ; - } - @alist = split( /\//, $elem2 ) ; - pop( @alist ) ; - local( $parent2 ) = join( "/", @alist ) ; - &CTUDebug( "parent directory of '" . $elem2 . "' is '" . $parent2 . - "'\n" ) ; - $ret = system( "neartool co -nc $parent\n" ) ; - if ( $ret == 0 ) { - $ret = system( "neartool co -nc $parent2\n" ) ; - if ( $ret == 0 ) { - # now move the element - $ret = &CTURetCode( system( "neartool mv $elem $elem2\n" )) ; - } else { - $ret = 0 ; - } - } else { - $ret = 0 ; - } - &CTUDebug( "out of CTNtoolMv\n" ) ; - $ret ; -} - -# build a list of targets -# input is in: -# $_[0] = targets -# -# output: -# return success or failure -sub CTNtoolMake { - &CTUDebug( "in CTNtoolMake\n" ) ; - local( $ret ) = 0 ; - local( $line ) = "make " . $_[0] . "\n" ; - $ret = &CTURetCode( system( $line )) ; - &CTUDebug( "out of CTNtoolMake\n" ) ; - $ret ; -} - -1; diff --git a/dtool/src/attach/ctproj.pl b/dtool/src/attach/ctproj.pl deleted file mode 100644 index 38f5fd269b..0000000000 --- a/dtool/src/attach/ctproj.pl +++ /dev/null @@ -1,60 +0,0 @@ -require "$tool/built/include/ctutils.pl" ; - -# return the root of the given project. -sub CTProjRoot { - local( $CTPRtmp ) = $_[0] ; - $CTPRtmp =~ tr/a-z/A-Z/ ; - local( $CTPRret ) = $ENV{ $CTPRtmp } ; - $CTPRret ; -} - -# return the package we're currently in. -# input: -# $_[0] = project -sub CTProjPkg { - local( $CTPPret ) = &CTUCurrDir() ; - local( $CTPPtmp ) = $_[0] ; - $CTPPtmp =~ tr/a-z/A-Z/ ; - $CTPPret =~ s/$ENV{ $CTPPtmp }// ; - $CTPPret =~ s/\/src\/// ; - $CTPPret =~ s/\/metalibs\/// ; - $CTPPret ; -} - -# reutrn the project containing the given directory. If no directory is given, -# return the project containing the current directory. -sub CTProj { - local( $CTPdir ) ; - if ($_[0] eq "") { - $CTPdir = &CTUCurrDir() ; - } else { - # provided directory - $CTPdir = $_[0] ; - } - local( $CTPprojs ) = $ENV{"CTPROJS"} ; - local( $CTPdone ) = "" ; - local( @CTPlist ) ; - @CTPlist = split( / /, $CTPprojs ) ; - local( @CTPlist2 ) ; - local( $CTPtry ) ; - while (( $CTPdone eq "" ) && ( @CTPlist != () )){ - # pop the first one off the list - $CTPtmp = $CTPlist[0] ; - shift( @CTPlist ) ; - # split the project from it's flavor - @CTPlist2 = split( /:/, $CTPtmp ); - $CTPtry = &CTProjRoot( $CTPlist2[0] ) ; - # is CTPtry prefix of CTPdir? if so we have our winner - if ( $CTPdir =~ /^$CTPtry/ ) { - $CTPdone = "yep" ; - } - } - if ( $CTPdone eq "" ) { - $CTPtry = "" ; - } else { - $CTPtry = $CTPlist2[0] ; - } - $CTPtry ; -} - -1; diff --git a/dtool/src/attach/ctquery b/dtool/src/attach/ctquery deleted file mode 100755 index 89a2380ed8..0000000000 --- a/dtool/src/attach/ctquery +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/perl - -# acceptable forms: -# ctquery - list all attached projects and flavors -# ctquery project - list the attached flavor of the named project -# ctquery - flavor - list all attached projects who are attached with a -# given flavor - -$projs = $ENV{"CTPROJS"} ; -@projlist = split( / +/, $projs ) ; - -if ( $#ARGV == -1 ) { - # list all projects and flavors - print "Currently attached projects (and flavors):\n" ; - foreach $pair ( @projlist ) { - @pairlist = split( /:/, $pair ) ; - ( $pairtmp = $pairlist[0] ) =~ tr/A-Z/a-z/ ; - print " $pairtmp ($pairlist[1])\n" ; - } -} elsif (( $#ARGV == 0 ) && !($ARGV[0] =~ /^\-/)) { - # list the attached flavor of the named project - foreach $pair ( @projlist ) { - @pairlist = split( /:/, $pair ) ; - ( $pairtmp = $pairlist[0] ) =~ tr/A-Z/a-z/ ; - if ( $pairtmp eq $ARGV[0] ) { - print "$pairlist[1]\n" ; - } - } -} elsif (( $#ARGV == 1 ) && ( $ARGV[0] eq "-" )){ - # list all attached projects who are attached with a given flavor - foreach $pair ( @projlist ) { - @pairlist = split( /:/, $pair ) ; - if ( $pairlist[1] eq $ARGV[1] ) { - $pairlist[0] =~ tr/A-Z/a-z/ ; - print "$pairlist[0]\n" ; - } - } -} else { - print "Usage: ctquery [project] -or-\n" ; - print " ctquery - flavor\n" ; - exit ; -} diff --git a/dtool/src/attach/ctquery.pl b/dtool/src/attach/ctquery.pl deleted file mode 100644 index d93d42e9c7..0000000000 --- a/dtool/src/attach/ctquery.pl +++ /dev/null @@ -1,37 +0,0 @@ -# return the attached flavor of given project (or empty string) -sub CTQueryProj { - local( $projs ) = $ENV{"CTPROJS"} ; - local( @projlist ) ; - @projlist = split( / +/, $projs ) ; - local( $pair ) ; - local( @pairlist ) ; - local( $ret ) = "" ; - foreach $pair ( @projlist ) { - @pairlist = split( /:/, $pair ) ; - $pairlist[0] =~ tr/A-Z/a-z/ ; - if ( $pairlist[0] eq $_[0] ) { - $ret = $pairlist[1] ; - } - } - $ret ; -} - -# return all projects attached with a given flavor -sub CTQueryFlav { - local( $projs ) = $ENV{"CTPROJS"} ; - local( @projlist ) ; - @projlist = split( / +/, $projs ) ; - local( $pair ) ; - local( @pairlist ) ; - local( $ret ) = "" ; - foreach $pair ( @projlist ) { - @pairlist = split( /:/, $pair ) ; - if ( $pairlist[1] eq $_[0] ) { - $pairlist[0] =~ tr/A-Z/a-z/ ; - $ret = $ret . " $pairlist[0]" ; - } - } - $ret ; -} - -1; diff --git a/dtool/src/attach/ctrm b/dtool/src/attach/ctrm deleted file mode 100644 index 7cac8c290e..0000000000 --- a/dtool/src/attach/ctrm +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/perl - -if ( $#ARGV < 0 ) { - exit print "Usage: ctrmelem element-name [...]\n" ; -} - -$tool = $ENV{"DTOOL"} ; -if ( $tool eq "" ) { - die "Environment not configured for CTtools" ; -} - -require "$tool/built/include/ctutils.pl" ; -require "$tool/built/include/ctvspec.pl" ; -require "$tool/built/include/ctquery.pl" ; -require "$tool/built/include/ctproj.pl" ; -require "$tool/built/include/ctcm.pl" ; - -$projname = &CTProj ; -$projname =~ tr/A-Z/a-z/ ; -$flav = &CTQueryProj( $projname ) ; -$spec = &CTResolveSpec( $projname, $flav ) ; - -foreach $item ( @ARGV ) { - if ( -e $item ) { - if ( ! &CTCMRmElem( $item, $projname, $spec ) ) { - print STDERR "Could not rmname '$item'\n" ; - } - } else { - print STDERR "No such file '$item'.\n" ; - } -} diff --git a/dtool/src/attach/ctsanity b/dtool/src/attach/ctsanity deleted file mode 100644 index 9d658275bb..0000000000 --- a/dtool/src/attach/ctsanity +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/perl - -$tool = $ENV{"DTOOL"} ; -if ( $tool eq "" ) { - die "Environment not configured to run CTtools" ; -} - -sub CTSanityUsage { - print STDERR "Usage: ctsanity [-v]\n" ; - print STDERR "Options:\n" ; - print STDERR " -v : sanity check the .vspec files \n" ; - exit ; -} - -if ( $#ARGV == -1 ) { - &CTSanityUsage ; -} - -$check_vspecs = 0 ; - -foreach $item ( @ARGV ) { - if ( $item eq "-v" ) { - $check_vspecs = 1 ; - } else { - print STDERR "unknown option '" . $item . "'\n" ; - $CTSanityUsage ; - } -} - -require "$tool/built/include/ctvspec.pl" ; - -if ( $check_vspecs ) { - local( $projs ) = &CTListAllProjects ; - local( @projlist ) = split( / +/, $projs ) ; - local( $item ) ; - foreach $item ( @projlist ) { - print STDERR "checking " . $item . ".vspec:\n" ; - local( $ctsavedebug ) = $ctdebug ; - $ctdebug = 1 ; - &CTReadVSpec( $item ) ; - $ctdebug = $ctsavedebug ; - } -} diff --git a/dtool/src/attach/cttimewarp b/dtool/src/attach/cttimewarp deleted file mode 100755 index e64d121e61..0000000000 --- a/dtool/src/attach/cttimewarp +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/perl - -if ($#ARGV < 0) { - exit print "Usage: cttimewarp [-clear] label [time]\n" ; -} - -@arglist = @ARGV ; - -$clear = 0 ; - -if ( $arglist[0] =~ /^-c/ ) { - $clear = 1 ; - shift( @arglist ) ; -} - -if ( @arglist == () ) { - if ( $clear ) { - exit print "Usage: cttimewarp -clear label\n" ; - } else { - exit print "Usage: cttimewarp label time\n" ; - } -} - -$label = $arglist[0] ; -shift( @arglist ) ; - -if (( ! $clear ) && ( @arglist == () )) { - exit print "Usage: cttimewarp label time\n" ; -} - -$time = $arglist[0] ; - -if ( $clear ) { - $cmd = "cleartool find . -version \"lbtype(" . $label . - ")\" -exec 'cleartool rmlabel -c \"untimewarping\" " . $label . - ' $CLEARCASE_XPN' . "'\n" ; - system( $cmd ) ; -} else { - $cmd = "cleartool mklabel -replace -recurse -c \"rolling time back to " . - $time . "\" -version /main/'{\!created_since(" . $time . ")}' " . - $label . " .\n" ; - system( $cmd ) ; -} diff --git a/dtool/src/attach/ctunattach.drv b/dtool/src/attach/ctunattach.drv deleted file mode 100644 index daea40d5eb..0000000000 --- a/dtool/src/attach/ctunattach.drv +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/perl - -# acceptable forms: -# ctunattach project - attach to the personal flavor of the project - -sub CTUnattachUsage { - print STDERR "Usage: ctattach project(s)\n" ; - &CTAttachWriteNullScript( $tmpname ) ; - print $tmpname . "\n" ; - exit; -} - -$tool = $ENV{"DTOOL"} ; - -require "$tool/built/include/ctattch.pl" ; -require "$tool/built/include/ctunattach.pl" ; -require "$tool/built/include/ctquery.pl" ; - -$tmpname = "/tmp/script.$$" ; - -if ( $#ARGV == -1 ) { - &CTUnattachUsage ; -} - -foreach $proj ( @ARGV ) { - &CTUDebug( "project is '$proj'\n" ) ; - - $curflav = &CTQueryProj( $proj ) ; - if ( $curflav ne "" ) { - $envsep{"PATH"} = ":" ; - $envsep{"LD_LIBRARY_PATH"} = ":" ; - $envsep{"DYLD_LIBRARY_PATH"} = ":" ; - $envsep{"PFPATH"} = ":" ; - $envsep{"SSPATH"} = ":" ; - $envsep{"STKPATH"} = ":" ; - $envsep{"DC_PATH"} = ":" ; - $spec = &CTUnattachCompute( $proj, $curflav ) ; - if ( $spec eq "" ) { - &CTAttachWriteNullScript( $tmpname ) ; - print $tmpname . "\n" ; - } else { - &CTUnattachWriteScript( $tmpname ) ; - print $tmpname . "\n" ; - } - } else { - &CTAttachWriteNullScript( $tmpname ) ; - print $tmpname . "\n" ; - } -} diff --git a/dtool/src/attach/ctunattach.pl b/dtool/src/attach/ctunattach.pl deleted file mode 100644 index 08e867921f..0000000000 --- a/dtool/src/attach/ctunattach.pl +++ /dev/null @@ -1,251 +0,0 @@ -require "$tool/built/include/ctquery.pl" ; - -$shell_type = "csh" ; -if ( $ENV{"SHELL_TYPE"} ne "" ) { - if ( $ENV{"SHELL_TYPE"} eq "sh" ) { - $shell_type = "sh" ; - } -} - -# remove a value from a variable. If it is the only thing remaining in the -# variable, add it to the unset list. -# input is in: -# $_[0] = variable -# $_[1] = value -# -# output is in: -# %newenv = an image of how we want the environment to be -# @unset = a list of variables to unset -sub CTUnattachMod { - &CTUDebug( "in CTUnattachMod\n" ) ; - local( $done ) = 0 ; - # if we didn't get any data, nothing really to do - if ( $_[0] eq "" ) { $done = 1 ; } - if ( $_[1] eq "" ) { $done = 1 ; } - # if the variable is already set to be unset, nothing really to do - if ( join( " ", @unset ) =~ /$_[0]/ ) { $done = 1 ; } - # if the variable isn't in newenv, move it there, if it's empty mark it - # for unsetting - if ( $newenv{$_[0]} eq "" ) { - $newenv{$_[0]} = &CTSpoolEnv( $_[0] ) ; - if ( $newenv{$_[0]} eq "" ) { - push( @unset, $_[0] ) ; - delete $newenv{$_[0]} ; - $done = 1 ; - } - } - # if the value does not appear in the variable, nothing really to do - if ( ! ( $newenv{$_[0]} =~ /$_[1]/ ) ) { $done = 1 ; } - # now down to the real work - if ( ! $done ) { - # if the variable is exactly the value, mark it for unsetting - if ( $newenv{$_[0]} eq $_[1] ) { - push( @unset, $_[0] ) ; - delete $newenv{$_[0]} ; - } elsif ( $newenv{$_[0]} =~ / $_[1]/ ) { - local( $tmp ) = $newenv{$_[0]} ; - $tmp =~ s/ $_[1]// ; - $newenv{$_[0]} = $tmp ; - } elsif ( $newenv{$_[0]} =~ /$_[1] / ) { - local( $tmp ) = $newenv{$_[0]} ; - $tmp =~ s/$_[1] // ; - $newenv{$_[0]} = $tmp ; - } else { - print STDERR "ERROR: variable '" . $_[0] . "' contains '" . - $_[1] . "' (in '" . $newenv{$_[0]} . - "'), but I am too stupid to figure out how to remove it.\n" ; - } - } -} - -# given the project and flavor, build the lists of variables to set/modify -# input is in: -# $_[0] = project -# $_[1] = flavor -# -# output is in: -# return value is config line -# %newenv = an image of what we want the environment to look like -# @unset = list of variables to be unset -# %envsep = seperator -# %envcmd = set or setenv -# %envpostpend = flag that variable should be postpended -sub CTUnattachCompute { - &CTUDebug( "in CTUnattachCompute\n" ) ; - local( $flav ) = $_[1] ; - local( $spec ) = &CTResolveSpec( $_[0], $flav ) ; - local( $root ) = &CTComputeRoot( $_[0], $flav, $spec ) ; - - if ( $spec ne "" ) { - local( $proj ) = $_[0] ; - $proj =~ tr/a-z/A-Z/ ; - local( $item ) ; - - # since we don't have to worry about sub-attaches, it doesn't matter - # if we scan the .init file first or not. So we won't. - &CTUDebug( "extending paths\n" ) ; - - $item = $root . "/built/bin" ; - &CTUnattachMod( "PATH", $item ) ; - $item = $root . "/built/lib" ; - if ( $ENV{"PENV"} eq "WIN32" ) { - &CTUnattachMod( "PATH", $item ) ; - } - &CTUnattachMod( "LD_LIBRARY_PATH", $item ) ; - &CTUnattachMod( "DYLD_LIBRARY_PATH", $item ) ; - #$item = $root . "/src/all" ; - #&CTUnattachMod( "CDPATH", $item ) ; - $item = $root . "/built/include" ; - &CTUnattachMod( "CT_INCLUDE_PATH", $item ) ; - $item = $root . "/built/etc" ; - &CTUnattachMod( "ETC_PATH", $item ) ; - $item = $proj . ":" . $flav ; - &CTUnattachMod( "CTPROJS", $item ) ; - push( @unset, $proj ) ; - - if ( -e "$root/built/etc/$_[0].init" ) { - &CTUDebug( "scanning $_[0].init file\n" ) ; - local( @linesplit ) ; - local( $linetmp ) ; - local( $loop ); - local( *INITFILE ) ; - if ( -x "$root/built/etc/$_[0].init" ) { - open( INITFILE, "$root/built/etc/$_[0].init $_[0] $_[1] $root |" ) ; - } else { - open( INITFILE, "< $root/built/etc/$_[0].init" ) ; - } - while ( ) { - s/\n$// ; - @linesplit = split( /\#/ ) ; - $_ = $linesplit[0] ; - if ( $_ =~ /^MODABS/ ) { - @linesplit = split ; - $linetmp = $linesplit[1] ; - shift( @linesplit ) ; - shift( @linesplit ) ; - foreach $loop ( @linesplit ) { - &CTUnattachMod( $linetmp, $loop ) ; - } - } elsif ( $_ =~ /^MODREL/ ) { - @linesplit = split ; - $linetmp = $linesplit[1] ; - shift( @linesplit ) ; - shift( @linesplit ) ; - foreach $loop ( @linesplit ) { - &CTUnattachMod( $linetmp, $root . "/" . $loop ) ; - } - } elsif ( $_ =~ /^SETABS/ ) { - @linesplit = split ; - $linetmp = $linesplit[1] ; - push( @unset, $linetmp ) ; - } elsif ( $_ =~ /^SETREL/ ) { - @linesplit = split ; - $linetmp = $linesplit[1] ; - push( @unset, $linetmp ) ; - } elsif ( $_ =~ /^SEP/ ) { - @linesplit = split ; - $envsep{$linesplit[1]} = $linesplit[2] ; - } elsif ( $_ =~ /^CMD/ ) { - @linesplit = split ; - $envcmd{$linesplit[1]} = $linesplit[2] ; - } elsif ( $_ =~ /^DOCSH/ ) { - &CTUDebug( "ignoring DO command in .init file\n" ) ; - } elsif ( $_ =~ /^DOSH/ ) { - &CTUDebug( "ignoring DO command in .init file\n" ) ; - } elsif ( $_ =~ /^DO/ ) { - &CTUDebug( "ignoring DO command in .init file\n" ) ; - } elsif ( $_ =~ /^POSTPEND/ ) { - @linesplit = split ; - $envpospend{$linesplit[1]} = 1 ; - } elsif ( $_ =~ /^ATTACH/ ) { - &CTUDebug( "ignoring ATTACH command in .init file\n" ) ; - } else { - print STDERR "Unknown .init directive '$_'\n" ; - } - } - close( INITFILE ) ; - } - } - &CTUDebug( "out of CTUnattachCompute\n" ) ; - $spec ; -} - -# write a script to setup the environment -# Input is: -# $_[0] = filename -sub CTUnattachWriteScript { - &CTUDebug( "in CTAttachWriteScript\n" ) ; - local( *OUTFILE ) ; - open( OUTFILE, ">$_[0]" ) ; - print OUTFILE "#!/bin/" . $shell_type . " -f\n" ; - local( $item ) ; - #local( $unsetcdpath ) = 0 ; - #local( $modcdpath ) = 0 ; - - foreach $item ( @unset ) { - #if ( $item eq "CDPATH" ) { $unsetcdpath = 1 ; } - - if ( $shell_type eq "sh" ) { - print OUTFILE "$item=\n" ; - if ( $envcmd{$item} ne "set" ) { - print OUTFILE "export $item\n" ; - } - } else { - if ( $envcmd{$item} ne "" ) { - print OUTFILE "un" . $envcmd{$item} . " $item\n" ; - } else { - print OUTFILE "unsetenv $item\n" ; - } - } - } - foreach $item ( keys %newenv ) { - #if ( $item eq "CDPATH" ) { $modcdpath = 1 ; } - - local( $sep ) = " " ; - if ( $envsep{$item} ne "" ) { - $sep = $envsep{$item} ; - } - local( @splitlist ) = split( / +/, $newenv{$item} ) ; - local( $outval ) = join( $sep, @splitlist ) ; - - if ( $shell_type eq "sh" ) { - print OUTFILE "$item=\"" . $outval . "\"\n" ; - if ( $envcmd{$item} ne "set" ) { - print OUTFILE "export $item\n" ; - } - } else { - if ( $envcmd{$item} ne "" ) { - PRINT OUTFILE $envcmd{$item} . " $item " ; - if ( $envcmd{$item} eq "set" ) { - print OUTFILE " = ( " ; - } - print OUTFILE $outval ; - if ( $envcmd{$item} eq "set" ) { - print OUTFILE ")" ; - } - print OUTFILE "\n" ; - } else { - print OUTFILE "setenv $item \"$outval\"\n" ; - } - } - } - #if ( $unsetcdpath ) { - # if ( $shell_type ne "sh" ) { - # print OUTFILE "unset cdpath\n" ; - # } - #} elsif ( $modcdpath ) { - # if ( $shell_type ne "sh" ) { - # print OUTFILE "set cdpath = ( \$" . "CDPATH )\n" ; - # } - #} - - if (! $ctdebug) { - print OUTFILE "rm -f $_[0]\n" ; - } else { - print STDERR "no self-destruct script '" . $_[0] . "'\n" ; - } - close( OUTFILE ) ; - &CTUDebug( "out of CTUnattachWriteScript\n" ) ; -} - -1; diff --git a/dtool/src/attach/ctunco b/dtool/src/attach/ctunco deleted file mode 100644 index d96eab41dc..0000000000 --- a/dtool/src/attach/ctunco +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/perl - -if ( $#ARGV < 0 ) { - exit print "Usage ctunco element-name [...]\n" ; -} - -$tool = $ENV{"DTOOL"} ; -if ( $tool eq "" ) { - die "not configured for using CTtools" ; -} - -require "$tool/built/include/ctutils.pl" ; -require "$tool/built/include/ctvspec.pl" ; -require "$tool/built/include/ctquery.pl" ; -require "$tool/built/include/ctproj.pl" ; -require "$tool/built/include/ctcm.pl" ; - -$projname = &CTProj ; -$projname =~ tr/A-Z/a-z/ ; -$flav = &CTQueryProj( $projname ) ; -$spec = &CTResolveSpec( $projname, $flav ) ; - -foreach $item ( @ARGV ) { - if ( -e $item ) { - if ( ! &CTCMUncheckout( $item, $projname, $spec ) ) { - print STDERR "Could not uncheckout '$item'\n" ; - } - } else { - print STDERR "No such file '$item'.\n" ; - } -} diff --git a/dtool/src/attach/ctutils.pl b/dtool/src/attach/ctutils.pl deleted file mode 100644 index a32dd5a6f3..0000000000 --- a/dtool/src/attach/ctutils.pl +++ /dev/null @@ -1,47 +0,0 @@ -# evaluate the given parameter to expand shell variables -sub CTUShellEval { - local( *CTUSEFILE ) ; - open( CTUSEFILE, "echo $_[0] |" ) ; - local( $CTUSEret ) = ; - close( CTUSEFILE ) ; - $CTUSEret =~ s/\n$// ; - $CTUSEret ; -} - -# if debug is on, print the argument -sub CTUDebug { - if ( $ctdebug ) { - print STDERR $_[0] ; - } -} - -use Cwd ; -# get current directory -sub CTUCurrDir { - local( $pwd ) = getcwd() ; - if ( $pwd =~ /^\/vobs/ ) { - local( *VFILE ) ; - open( VFILE, "cleartool pwv -short |" ) ; - local( $view ) = ; - close( VFILE ) ; - $view =~ s/\n$// ; - $pwd = "/view/" . $view . $pwd ; - } - $pwd ; -} - -# turn a shell return code into a success/fail flag -sub CTURetCode { - local( $ret ) ; - if ( $_[0] == 0 ) { - $ret = 1 ; - } else { - $ret = 0 ; - } - $ret ; -} - -$ctdebug = $ENV{"CTATTACH_DEBUG"} ; -$ctvspec_path = '/usr/local/etc' unless $ctvspec_path = $ENV{'CTVSPEC_PATH'}; - -1; diff --git a/dtool/src/attach/ctvspec.pl b/dtool/src/attach/ctvspec.pl deleted file mode 100644 index 8f556d2ee7..0000000000 --- a/dtool/src/attach/ctvspec.pl +++ /dev/null @@ -1,360 +0,0 @@ -require "$tool/built/include/ctutils.pl" ; - -# read a .vspec file into a map -# $_[0] = project -# on exit $ctvspecs{} will contain the data -# -# vspec format: -# tag:type:other data -# -# type: ref, root, vroot, croot -# other data: -# ref: name=_____ - required, take to refference -# root: path=_____ - required, path of tree root -# vroot: name=_____ - optional, name of view to use (if not tag) -# croot: path=_____ - required, local path of tree root -# server=_____ - required, CVS server string, ',' for ':' - -sub CTReadVSpec { - &CTUDebug( "reading vspec file for project " . $_[0] . "\n" ) ; - local( $ret ) = "" ; - local( $thisproj ) = $_[0] ; - if ( -e "$ctvspec_path/$thisproj.vspec" ) { - %ctvspecs = () ; - local( *SPECFILE ) ; - open( SPECFILE, "<$ctvspec_path/$thisproj.vspec" ) ; - local( @partlist ) ; - while ( $_ = ) { - s/\n$// ; - @partlist = split( /\#/ ) ; - $_ = $partlist[0] ; - if ( $_ ne "" ) { - @partlist = split( /:/ ); - local( $tag ) = $partlist[0] ; - shift( @partlist ) ; - local( $spec ) = join( ":", @partlist ) ; - if ( &CTValidateSpec( $spec ) ) { - $ctvspecs{$tag} = $spec ; - if ( $ctdebug ) { - print STDERR "tag(" . $tag . ") = " . $spec . "\n" ; - } - } - } - } - close( SPECFILE ) ; - $ctvspec_read = $_[0] ; - } else { - print STDERR "CTReadVSpec: cannot locate '$ctvspec_path/$thisproj.vspec'\n" ; - print STDERR "(did you forget to run the \$WINTOOLS/cp_vspec script?)\n" ; - } -} - -# given a spec line return it's type -# $_[0] = spec line - -sub CTSpecType { - local( @speclist ) = split( /:/, $_[0] ) ; - $speclist[0] ; -} - -# given a spec line return it's options if any -# $_[0] = spec line - -sub CTSpecOptions { - local( @speclist ) = split( /:/, $_[0] ) ; - shift( @speclist ) ; - join( ":", @speclist ) ; -} - -# given the options part of a spec line, find a given option -# $_[0] = options line -# $_[1] = desired option - -sub CTSpecFindOption { - local( $ret ) = "" ; - local( @options ) = split( /:/, $_[0] ) ; - local( $item ) ; - local( @itemlist ) ; - foreach $item ( @options ) { - @itemlist = split( /=/, $item ) ; - if ( $itemlist[0] eq $_[1] ) { - $ret = $itemlist[1] ; - } - } - $ret ; -} - -# resolve a final spec line for a given flavor -# $_[0] = project -# $_[1] = flavor - -sub CTResolveSpec { - &CTUDebug( "in CTResolveSpec\n" ) ; - local( $proj ) = $_[0] ; - $proj =~ tr/A-Z/a-z/ ; - if ( $ctvspec_read ne $proj ) { - &CTReadVSpec( $proj ) ; - } - local( $spec ) = $ctvspecs{$_[1]} ; - local( $ret ) = "" ; - if ( $spec ne "" ) { - local( $type ) = &CTSpecType( $spec ) ; - local( @speclist ) = split( /:/, &CTSpecOptions( $spec ) ) ; - if ( $type eq "ref" ) { - local( @optionlist ) = split( /=/, $speclist[0] ) ; - if ( $optionlist[0] ne "name" ) { - print STDERR "bad data attached to flavor " . $_[1] . - " of project " . $proj . "\n" ; - } else { - local( $tmp ) = &CTUShellEval( $optionlist[1] ) ; - if ( $ctdebug ) { - print STDERR "resolved a 'ref' to " . $tmp . - ", recuring\n" ; - } - $ret = &CTResolveSpec( $proj, $tmp ) ; - } - } else { - $ret = $spec ; - } - } - if ( $ret eq "" ) { - print STDERR "unknown flavor " . $_[1] . " of project " . $proj . - "\n" ; - } - &CTUDebug( "out of CTResolveSpec\n" ) ; - $ret ; -} - -# resolve the final name for a given flavor -# $_[0] = project -# $_[1] = flavor - -sub CTResolveSpecName { - &CTUDebug( "in CTResolveSpecName\n" ) ; - local( $proj ) = $_[0] ; - $proj =~ tr/A-Z/a-z/ ; - if ( $ctvspec_read ne $proj ) { - &CTReadVSpec( $proj ) ; - } - local( $spec ) = $ctvspecs{$_[1]} ; - local( $ret ) = $_[1] ; - if ( $spec ne "" ) { - local( $type ) = &CTSpecType( $spec ) ; - local( @speclist ) = split( /:/, &CTSpecOptions( $spec ) ) ; - if ( $type eq "ref" ) { - local( @optionlist ) = split( /=/, $speclist[0] ) ; - if ( $optionlist[0] ne "name" ) { - print STDERR "bad data attached to flavor " . $_[1] . - " of project " . $proj . "\n" ; - } else { - local( $tmp ) = &CTUShellEval( $optionlist[1] ) ; - if ( $ctdebug ) { - print STDERR "resolved a 'ref' to " . $tmp . - ", recuring\n" ; - } - $ret = &CTResolveSpecName( $proj, $tmp ) ; - } - } - } - if ( $ret eq "" ) { - print STDERR "unknown flavor " . $_[1] . " of project " . $proj . - "\n" ; - } - &CTUDebug( "out of CTResolveSpecName\n" ) ; - $ret ; -} - -# validate a spec line -# $_[0] = spec line - -sub CTValidateSpec { - local( $ret ) = 0 ; - local( $type ) = &CTSpecType( $_[0] ) ; - local( @speclist ) = split( /:/, &CTSpecOptions( $_[0] ) ) ; - local( $have_error ) = 0 ; - local( $item ) ; - local( @itemlist ) ; - if ( $type eq "ref" ) { - local( $have_name ) = 0 ; - foreach $item ( @speclist ) { - @itemlist = split( /=/, $item ) ; - if ( $itemlist[0] eq "name" ) { - if ( $have_name ) { - $have_error = 1; - &CTUDebug( "multiple name options on 'ref'\n" ) ; - } - $have_name = 1; - } else { - &CTUDebug( "invalid option on 'ref' = " . $item . "\n" ) ; - $have_error = 1 ; - } - } - if ( ! $have_error ) { - if ( $have_name ) { - $ret = 1 ; - } - } - } elsif ( $type eq "root" ) { - local( $have_path ) = 0 ; - foreach $item ( @speclist ) { - @itemlist = split( /=/, $item ) ; - if ( $itemlist[0] eq "path" ) { - if ( $have_path ) { - $have_error = 1 ; - &CTUDebug( "multiple path options on 'root'\n" ) ; - } - $have_path = 1 ; - } else { - &CTUDebug( "invalid option on 'root' = " . $item . "\n" ) ; - $have_error = 1 ; - } - } - if ( ! $have_error ) { - if ( $have_path ) { - $ret = 1 ; - } - } - } elsif ( $type eq "vroot" ) { - local( $have_name ) = 0 ; - foreach $item ( @speclist ) { - @itemlist = split( /=/, $item ) ; - if ( $itemlist[0] eq "name" ) { - if ( $have_name ) { - $have_error = 1 ; - &CTUDebug( "multiple name options on 'vroot'\n" ) ; - } - $have_name = 1 ; - } else { - &CTUDebug( "invalid option on 'vroot' = " . $item . "\n" ) ; - $have_error = 1 ; - } - } - if ( ! $have_error ) { - $ret = 1 ; - } - } elsif ( $type eq "croot" ) { - local( $have_path ) = 0 ; - local( $have_server ) = 0 ; - foreach $item ( @speclist ) { - @itemlist = split( /=/, $item ) ; - if ( $itemlist[0] eq "path" ) { - if ( $have_path ) { - $have_error = 1 ; - &CTUDebug( "multiple path options on 'croot'\n" ) ; - } - $have_path = 1 ; - } elsif ( $itemlist[0] eq "server" ) { - if ( $have_server ) { - $have_error = 1 ; - &CTUDebug( "multiple server options on 'croot'\n" ) ; - } - $have_server = 1 ; - } else { - &CTUDebug( "invalid option on 'croot' = " . $item . "\n" ) ; - $have_error = 1 ; - } - } - if ( ! $have_error ) { - if ( $have_path && $have_server ) { - $ret = 1 ; - } - } - } else { - &CTUDebug( "unknow spec type '" . $speclist[0] . "'\n" ) ; - } - $ret ; -} - -# get a list of all projects - -sub CTListAllProjects { - &CTUDebug( "in CTListAllProjects\n" ) ; - local( $ret ) = "" ; - local( $done ) = 0 ; - local( *DIRFILES ) ; - open( DIRFILES, "(cd $ctvspec_path ; /bin/ls -1 *.vspec ; echo blahblah) |" ) ; - while ( ! $done ) { - $_ = ; - s/\n$// ; - if ( $_ eq "blahblah" ) { - $done = 1 ; - } else { - s/.vspec$// ; - if ( $_ ne "" ) { - if ( $ret eq "" ) { - $ret = $_ ; - } else { - $ret = $ret . " " . $_ ; - } - } - } - } - close( DIRFILES ) ; - &CTUDebug( "final list of projects '" . $ret . "'\n" . - "out of CTListAllProjects\n" ) ; - $ret ; -} - -# list all flavors of a project -# $_[0] = project - -sub CTListAllFlavors { - &CTUDebug( "in CTListAllFlavors\n" ) ; - local( $proj ) = $_[0] ; - $proj =~ tr/A-Z/a-z/ ; - if ( $ctvspec_read ne $proj ) { - &CTReadVSpec( $proj ) ; - } - local( $ret ) = ""; - local( $item ) ; - foreach $item ( keys %ctvspecs ) { - if ( $ret eq "" ) { - $ret = $item ; - } else { - $ret = $ret . " " . $item ; - } - } - &CTUDebug( "out of CTListAllFlavors\n" ) ; - $ret ; -} - -# given a project and a spec, determine the local root of the project -# $_[0] = project -# $_[1] = flavor -# $_[2] = spec line - -sub CTComputeRoot { - &CTUDebug( "in CTComputeRoot\n" ) ; - local( $proj ) = $_[0] ; - $proj =~ tr/A-Z/a-z/ ; - if ( $ctvspec_read ne $proj ) { - &CTReadVSpec( $proj ) ; - } - local( $ret ) = "" ; - local( $type ) = &CTSpecType( $_[2] ) ; - local( $options ) = &CTSpecOptions( $_[2] ) ; - local( $vname ) = &CTResolveSpecName( $proj, $_[1] ) ; - &CTUDebug( "type = '" . $type . "' with options '" . $options . "'\n" ) ; - if ( $type eq "root" ) { - $ret = &CTSpecFindOption( $options, "path" ) ; - } elsif ( $type eq "vroot" ) { - local( $name ) = &CTSpecFindOption( $options, "name" ) ; - if ( $name ne "" ) { - $ret = "/view/$name/vobs/$proj" ; - } else { - $ret = "/view/$vname/vobs/$proj" ; - } - } elsif ( $type eq "croot" ) { - $ret = &CTSpecFindOption( $options, "path" ) ; - } elsif ( $ctdebug) { - print STDERR "unknown flavor type '" . $type . "'\n" ; - } - &CTUDebug( "returning '" . $ret . "'\n" ) ; - &CTUDebug( "out of CTComputeRoot\n" ) ; - $ret ; -} - -%ctvspecs = () ; -$ctvspec_read = "" ; - -1; diff --git a/dtool/src/attach/dtool.alias b/dtool/src/attach/dtool.alias deleted file mode 100644 index eaebd79b6f..0000000000 --- a/dtool/src/attach/dtool.alias +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/csh -f - -setenv OS `uname` -setenv USER `whoami` - -if ( -e $DTOOL/bin/neartool ) setenv HAVE_NEARTOOL "yes" -if ( ! $?HAVE_NEARTOOL ) setenv HAVE_NEARTOOL "no" -if ( ! $?HAVE_ATRIA ) setenv HAVE_ATRIA "no" - -set host=$HOST -if ( ! $?TERM ) setenv TERM "none" -if ( $TERM == "iris-ansi" || $TERM == "iris-ansi-net" ) then - alias ctshowprojs 'echo -n "\033P1.y"$USER"@"$host" -- "$CTPROJS"\033\\"; echo -n "\033P3.y"`echo $CTPROJS | cut -f1 -d:`\($host\)"\033\\"' -else if ( $TERM == "xterm" || $TERM == "color-xterm" || $TERM == "cygwin" ) then - alias ctshowprojs 'echo -n "\033]2;"$USER"@"$host" -- "$CTPROJS"\007"; echo -n "\033]1;"`echo $CTPROJS | cut -f1 -d:`\($host\)"\007"' -else - alias ctshowprojs 'echo $CTPROJS' -endif - -alias ctattach 'source `ctattach.drv \!*`; ctshowprojs' -alias cta 'ctattach' -alias cta-ship 'setenv CTSAVE $CTDEFAULT_FLAV ; setenv CTDEFAULT_FLAV ship ; ctattach \!* ; setenv CTDEFAULT_FLAV $CTSAVE ; unsetenv CTSAVE' -alias cta-release 'setenv CTSAVE $CTDEFAULT_FLAV ; setenv CTDEFAULT_FLAV release ; ctattach \!* ; setenv CTDEFAULT_FLAV $CTSAVE ; unsetenv CTSAVE' -alias cta-install 'setenv CTSAVE $CTDEFAULT_FLAV ; setenv CTDEFAULT_FLAV install ; ctattach \!* ; setenv CTDEFAULT_FLAV $CTSAVE ; unsetenv CTSAVE' -alias ctunattach 'source `ctunattach.drv \!*`; ctshowprojs' -alias ctuna 'ctunattach' - -#Modifications to emacs alias by Jason -#To allow for NTEmacs to run like emacs on unix boxes -if (($OS == "CYGWIN_NT-4.0") || ($OS == "CYGWIN_NT-5.0" ) || ($OS == "CYGWIN_NT-5.1" )) then - alias emacs 'emacs -T "$USER@$HOST $CTPROJS" -xrm "Emacs*iconName: `echo $CTPROJS | cut -f1 -d:`($HOST)" -bg #002040 -fg #00C0FF -cr yellow -ms yellow -l `cygpath -w ~/.emacs` $CTEMACS_OPTS' -else - alias emacs 'emacs -T "$USER@$HOST $CTPROJS" -xrm "Emacs*iconName: `echo $CTPROJS | cut -f1 -d:`($HOST)" $CTEMACS_OPTS' -endif - -alias rlogin 'rlogin \!*; ctshowprojs' -alias telnet 'telnet \!*; ctshowprojs' diff --git a/dtool/src/attach/dtool.alias-sh b/dtool/src/attach/dtool.alias-sh deleted file mode 100644 index 54dddf782b..0000000000 --- a/dtool/src/attach/dtool.alias-sh +++ /dev/null @@ -1,46 +0,0 @@ -#! /bin/sh - -if [ -e $DTOOL/bin/neartool ]; then HAVE_NEARTOOL="yes"; fi -if [ -z "$HAVE_NEARTOOL" ]; then HAVE_NEARTOOL="no"; fi -export HAVE_NEARTOOL - -if [ -z "$HAVE_ATRIA" ]; then HAVE_ATRIA="no"; fi -export HAVE_ATRIA - -if [ $HAVE_NEARTOOL = "yes" ]; then - alias ct='neartool' -else - alias ct='cleartool' -fi - -alias ctshowprojs='echo -n "\033P1.y"$USER"@"$HOST" -- "$CTPROJS"\033\\"; echo -n "\033P3.y"`echo $CTPROJS | cut -f1 -d:`\(`uname -n`\)"\033\\"' -alias ctattach='source `ctattach.drv $*`; ctshowprojs' -alias cta='ctattach' -alias cta-ship='setenv CTSAVE $CTDEFAULT_FLAV ; setenv CTDEFAULT_FLAV ship ; ctattach $* ; setenv CTDEFAULT_FLAV $CTSAVE ; unsetenv CTSAVE' -alias cta-release='setenv CTSAVE $CTDEFAULT_FLAV ; setenv CTDEFAULT_FLAV release ; ctattach $* ; setenv CTDEFAULT_FLAV $CTSAVE ; unsetenv CTSAVE' -alias cta-install='setenv CTSAVE $CTDEFAULT_FLAV ; setenv CTDEFAULT_FLAV install ; ctattach $* ; setenv CTDEFAULT_FLAV $CTSAVE ; unsetenv CTSAVE' -alias ctunattach='source `ctunattach.drv $*`; ctshowprojs' -alias ctuna='ctunattach' - -if [ "$PENV" = "WIN32_DREAMCAST" ]; then - alias ctci='neartool ci' - alias ctco='neartool co' - alias ctmake='gmake' - alias emacs='/emacs/bin/runemacs' - alias emacs='/emacs/bin/runemacs -T "`logname`@`uname -n` $CTPROJS" -xrm "Emacs*iconName: `echo $CTPROJS | cut -f1 -d:`(`uname -n`)" $CTEMACS_OPTS' - -elif [ "$HAVE_NEARTOOL" = "yes" ]; then - alias ctci='neartool ci' - alias ctco='neartool co' - alias ctmake='make' - alias emacs='emacs -T "`logname`@`uname -n` $CTPROJS" -xrm "Emacs*iconName: `echo $CTPROJS | cut -f1 -d:`(`uname -n`)" $CTEMACS_OPTS' - -elif [ "$HAVE_ATRIA" = "yes" ]; then - alias ctci='cleartool ci' - alias ctco='cleartool co' - alias ctmake 'clearmake -C gnu $* |& grep -v "^clearmake: Warning: Config"' - alias emacs='emacs -T "`logname`@`uname -n` $CTPROJS" -xrm "Emacs*iconName: `echo $CTPROJS | cut -f1 -d:`(`uname -n`)" $CTEMACS_OPTS' -fi - -alias rlogin='rlogin $*; ctshowprojs' -alias telnet='telnet $*; ctshowprojs' diff --git a/dtool/src/attach/dtool.cshrc b/dtool/src/attach/dtool.cshrc deleted file mode 100644 index 948f190625..0000000000 --- a/dtool/src/attach/dtool.cshrc +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/csh -f - -setenv OS `uname` - -# careful, security exploit here -setenv LD_LIBRARY_PATH "." -setenv DYLD_LIBRARY_PATH "." - -setenv CTEMACS_FOREHIGHLIGHT white -setenv CTEMACS_BACKHIGHLIGHT blue - -# Setup the initial path -if ( $OS == "Linux" ) then - set path = ( /bin /bin /usr/bin /sbin /usr/sbin /usr/bin/X11 \ - /usr/etc /usr/local/bin /var/local/bin ~/bin ) -else if ( $OS == "Darwin" ) then - set path = ( /bin /usr/bin /sbin /usr/sbin /usr/local/bin ~/bin $path ) -else if ( $OS == "IRIX64" ) then - set path = ( /var/local/bin ~/bin /usr/local/prman/bin \ - /usr/sbin /usr/bsd /sbin /usr/bin /bin /usr/bin/X11 /usr/etc \ - /usr/demos/bin /usr/local/bin ) - setenv LD_LIBRARY_PATH "/usr/local/lib:." -else if (($OS == "CYGWIN_NT-6.1-WOW64") || ($OS == "CYGWIN_NT-6.1") || ($OS == "CYGWIN_NT-5.1") || ($OS == "CYGWIN_NT-6.0") || ($OS == "CYGWIN_NT-6.0-WOW64") || ($OS == "CYGWIN_NT-5.2-WOW64") || ($OS == "CYGWIN_NT-5.0") || ( $OS == "CYGWIN_NT-4.0" ) || ( $OS == "WINNT" )) then - set path = ( /bin /usr/bin /usr/lib /usr/local/bin $path . ) - if ( $?LIB ) then - setenv LIB "$LIB;"`cygpath -w /usr/lib` - else - setenv LIB `cygpath -w /usr/lib` - endif -else if (( $OS == "CYGWIN_98-4.10" ) || ( $OS == "WIN95" )) then - set path = ( /bin /usr/local/bin /contrib/bin /msvc98/Bin \ - /mscommon/MSDev98/Bin /mscommon/Tools /usr/lib $path ) - setenv LIB `cygpath -w /msvc98/mfc/lib`\;`cygpath -w /msvc98/lib`\;`cygpath -w /usr/lib` - setenv INCLUDE `cygpath -w /msvc98/Include` -else - set path = ( /var/local/bin ~/bin /usr/local/prman/bin \ - /usr/sbin /usr/bsd /sbin /usr/bin /bin /usr/bin/X11 /usr/etc \ - /usr/demos/bin /usr/local/bin ) -endif - -# Setup the initial manpath -#if ( $OS == "Linux" ) then -#setenv MANPATH "/usr/local/man:/usr/man/preformat:/usr/man:/usr/X11R6/man" -#else if ( $OS == "IRIX64" ) then -#setenv MANPATH "/usr/share/catman:/usr/catman:/usr/local/share/catman:/usr/local/share/man:/usr/local/man" -#else if (( $OS == "CYGWIN_NT-5.1") || ( $OS == "CYGWIN_NT-5.2-WOW64" ) || ( $OS == "CYGWIN_NT-5.0") || ( $OS == "CYGWIN_NT-4.0" ) || ( $OS == "CYGWIN_98-4.10" ) || ( $OS == "WIN95" )) then -#setenv MANPATH "/usr/man:/contrib/man" -#else -#setenv MANPATH "/usr/share/catman:/usr/catman:/usr/local/share/catman:/usr/local/share/man:/usr/local/man" -#endif - -setenv CT_INCLUDE_PATH "." -#set cdpath = ( . ) -#setenv CDPATH "." -setenv DC_PATH "." -setenv SSPATH "." -setenv STKPATH "." - -if ( ! $?HAVE_ATRIA ) then - if ( -e /usr/atria ) then - /usr/atria/bin/cleartool mount -all >& /dev/null - if ( $status == 0 ) setenv HAVE_ATRIA "yes" - endif -endif - -if ( ! $?CTDEFAULT_FLAV ) setenv CTDEFAULT_FLAV "default" -if ( ! $?CTEMACS_OPTS ) setenv CTEMACS_OPTS "" - -if ( -e /usr/atria/bin ) set path = ( /usr/atria/bin $path ) -rehash - -if ( ! $?PENV ) then - if ( $OS == "Linux" ) then - setenv PENV "Linux" - else if ( $OS == "IRIX64" ) then - setenv PENV "SGI" - else if (( $OS == "CYGWIN_NT-5.1") || ( $OS == "CYGWIN_NT-5.0") || ( $OS == "CYGWIN_NT-6.0")|| ( $OS == "CYGWIN_NT-4.0" ) || ( $OS == "CYGWIN_98-4.10" ) || ( $OS == "WIN95" )) then - setenv PENV "WIN32" - else - setenv PENV "SGI" - endif -endif - -if ( ! $?DTOOL ) setenv DTOOL /beta/player/bootstrap/dtool -if ( $#argv == 0 ) then - setenv SETUP_SCRIPT `$DTOOL/built/bin/ctattach.drv dtool default` -else - setenv SETUP_SCRIPT `$DTOOL/built/bin/ctattach.drv dtool $argv[1]` -endif - -if($SETUP_SCRIPT == "") then - echo "error: ctattach.drv returned NULL string for setup_script filename!" - echo " 'dtool/built/bin/ctattach.drv' probably doesnt exist, need to make install on dtool to copy it from dtool\src\attach" - exit -endif - -source $SETUP_SCRIPT - - diff --git a/dtool/src/attach/dtool.emacs b/dtool/src/attach/dtool.emacs deleted file mode 100644 index dae0bde1cc..0000000000 --- a/dtool/src/attach/dtool.emacs +++ /dev/null @@ -1,295 +0,0 @@ -;; make the mouse pointer avoid the text point -;; Actually, everyone really hates this. -;(cond (window-system -; (require 'avoid) -; (mouse-avoidance-mode 'cat-and-mouse))) - -;; Make sure utf-8 is at the top of the coding-system list; Panda's -;; TextNode uses utf-8 encoding natively, so we may have some -;; documents and code written in utf-8. - -(prefer-coding-system 'utf-8) - - -;; make sure we have the compile library available to us -(load-library "compile") -;; Comment given for last checkout command -(setq last-co-comment "") -;; Comment given for last checkin command -(setq last-ci-comment "") -;; Target given for the last local make -(setq last-lm-target "realinstall") -;; Target given for the last global make -(setq last-gm-target "install") -;; Host given for the last ctrelease -(setq last-rel-host "") -;; Host given for the last ctship -(setq last-ship-host "") - -;; check the environment -(setq ct-tool (getenv "DTOOL")) -(setq have-atria (let ((h-a (getenv "HAVE_ATRIA"))) - (if (string= h-a "yes") t '()))) -;; (setq have-neartool (let ((h-n (getenv "HAVE_NEARTOOL"))) -;; (if (string= h-n "yes") t '()))) -(setq is-cygwin (or (string= (getenv "OS") "CYGWIN_NT-4.0") - (string= (getenv "OS") "CYGWIN_NT-5.0") - (string= (getenv "OS") "CYGWIN_NT-5.1"))) - -;; (setq ct-command (cond -;; (is-cygwin "bash /install/tool/bin/neartool") -;; (have-atria "cleartool") -;; (have-neartool "neartool") -;; t nil)) - -;; Load the Hightlight coloring scheme -(if is-cygwin -;; (let ((filename (concat (getenv "CYGWIN_ROOT") "install\\tool\\etc\\color.emacs"))) - (let ((filename (concat (getenv "CYGWIN_ROOT") ct-tool "\\etc\\color.emacs"))) - (if (file-readable-p filename) (load filename)))) - -;; Checkout element in the current buffer -(defun ct-checkout-curr (comment) - "Checkout version in current buffer with COMMENT." - (interactive (list (read-string "Comment: " last-co-comment))) - (setq last-co-comment comment) - (setq pname (file-name-nondirectory (buffer-file-name))) - (ct-shell-command-verbose - (concat "ctco -c " (ct-quote-string comment) " " pname)) - (ct-find-curr-file-again nil) -) - -;; Uncheckout element in the current buffer -(defun ct-uncheckout-curr () - "Uncheckout version in current buffer and remove private data." - (interactive) - (if (y-or-n-p "Ok to un-checkout? ") - (progn - (setq pname (file-name-nondirectory (buffer-file-name))) - (ct-shell-command-verbose (concat "ctunco " pname)) - (ct-find-curr-file-again t) - ) - (progn - (message "Uncheckout canceled.") - ) - ) -) - -;; Checkin element in the current buffer -(defun ct-checkin-curr () - "Checkin version in current buffer." - (interactive) - (setq pname (file-name-nondirectory (buffer-file-name))) - (setq option nil) - (while (not option) - (setq choice (read-string "Comment: s (same), n (new), l (list): " "s")) - (cond - ((equal choice "s") - (setq option "-nc")) - ((equal choice "n") - (setq comment (read-string "Comment: " last-ci-comment)) - (setq last-ci-comment comment) - (setq option (concat "-c " (ct-quote-string comment)))) - ((equal choice "l") - (ct-shell-command-verbose (concat "ctihave " pname))) - (t - (message (concat "Unrecognized choice: " choice ".")) - (sleep-for 2)))) - - (ct-shell-command-verbose (concat "ctci " option " " pname)) - (ct-find-curr-file-again t) -) - -;; Delta element in the current buffer -(defun ct-delta-curr () - "Delta element in current buffer." - (interactive) - (if (y-or-n-p "Ok to delta? ") - (progn - (setq pname (file-name-nondirectory (buffer-file-name))) - (ct-shell-command-verbose (concat "ctdelta " pname)) - (ct-find-curr-file-again t) - ) - (progn - (message "Delta canceled.") - ) - ) -) - -;; List element checkout data for the current buffer -(defun ct-lscheckout-curr () - "List checkout for the current buffer." - (interactive) - (setq pname (file-name-nondirectory (buffer-file-name))) - (ct-shell-command-verbose (concat "ctihave &")) -) - -;; List elements in the current directory that are checked out -(defun ct-lscheckout-curr-dir () - "List checkouts for the current directory." - (ct-shell-command-verbose (concat "ctihave &")) -) - -;; call clearmake in the local directory -(defun ct-local-make () - "Build TARGET from the current directory." - (interactive) - (setq target (read-string "Local build target: " last-lm-target)) - (setq last-lm-target target) - (if have-atria - (compile-internal - (concat "clearmake -C gnu " target - " |& grep -v \"clearmake: Warning: Config\"") - "No more errors.") - (compile-internal - (concat "make " target) "No more errors.")) -) - -;; call clearmake in the project root directory -(defun ct-global-make () - "Build TARGET from the project root." - (interactive) - (setq target (read-string "Global build target: " last-gm-target)) - (setq last-gm-target target) - (cond - (have-atria - (compile-internal - (concat "cd `ctproj -r` ; clearmake -C gnu " target - " |& grep -v \"clearmake: Warning: Config\"") - "No more errors.")) - (is-cygwin - (compile-internal - (concat "bash -f 'cd `ctproj -r` ; make " target "'") "No more errors.")) - (t - (compile-internal - (concat "cd `ctproj -r` ; make " target) "No more errors.")) - ) - ) - -;; Do an xdiff on the current buffer to see what is different about this -;; file from the previous version. -(defun ct-xdiff-curr () - "Show changes to element in current buffer from the previous version." - (interactive) - (setq pname (file-name-nondirectory (buffer-file-name))) - (if is-cygwin - (ct-shell-command-verbose (concat ct-command " xdiff -pre " pname)) - - ; The is a hack to deal with the fact that diff returns 1 if the - ; two files do not match. - (ct-shell-command-verbose (concat ct-command " xdiff -pre " pname ";:&"))) - ) - - -;; Make a new element for the current buffer -(defun ct-mk-elem () - (interactive) - (if (y-or-n-p (format "Make new element for %s? " - (file-name-nondirectory (buffer-name)))) - (progn - (write-file (buffer-file-name)) - (ct-shell-command-verbose - (concat "ctmkelem -eltype text_file -c '' " - (file-name-nondirectory (buffer-name)))) - ) - (progn - (message "Make element canceled.") - ) - ) - ) - -;; utility functions -(defun ct-shell-command-verbose (command) - "Execute COMMAND in shell with message." - (interactive "Shell command: \n") - (message (concat "Executing: " command " ...")) - (shell-command command) - (message "Done.") -) - -(defun ct-find-curr-file-again (read-only) - "Read in the currect file again, READONLY (t) or not (nil)." - (setq pname (buffer-file-name)) - (setq linenum (1+ (count-lines 1 (point)))) - (kill-buffer (buffer-name)) - (if read-only - (find-file-read-only pname) - (find-file pname)) - (goto-line linenum) -) - -(defun ct-quote-string (string) - "Enclose STRING in single or double quotes." - (setq has-double (string-match "\"" string)) - (setq has-single (string-match "'" string)) - (cond - ((or (and (not has-single) (not has-double)) - (and has-double (not has-single))) - (concat "'" string "'")) - ((and has-single (not has-double)) - (concat "\"" string "\"")) - (t - (message (concat "Can't quote string correctly: " string)) - (sleep-for 3) - (concat "\"" string "\""))) -) - -;; default key bindings -(global-set-key "\C-xco" 'ct-checkout-curr) -(global-set-key "\C-xcu" 'ct-uncheckout-curr) -(global-set-key "\C-xci" 'ct-checkin-curr) -(global-set-key "\C-xcd" 'ct-delta-curr) -(global-set-key "\C-xcl" 'ct-lscheckout-curr) -(global-set-key "\C-xcL" 'ct-lscheckout-curr-dir) -(global-set-key "\C-xcm" 'ct-local-make) -(global-set-key "\C-xcM" 'ct-global-make) -(global-set-key "\C-xcx" 'ct-xdiff-curr) -(global-set-key "\C-xce" 'ct-mk-elem) - -;; ok, lets make sure we load all other .emacs files we might need. This is -;; attach related code. - -(defun ct-load-project-emacs-file (proj-name) - (if (string= proj-name "DTOOL") nil - (let ((pre-name (getenv proj-name))) - (if pre-name - (let ((filename (concat pre-name "/built/etc/" - (downcase proj-name) ".emacs"))) - (if (file-readable-p filename) - (load filename)) - ))) - ) - ) - -(defun ct-break-space-colon-str (string) - (if (string= string "") - '() - (let ((substr-end (string-match ":" string 0))) - (cons (substring string 0 substr-end) - (let ((new-string-start (string-match " " string 0))) - (if (eq nil new-string-start) - '() - (ct-break-space-colon-str - (strip-spaces (substring string (match-end 0))))) - ))) - ) - ) - -(defun strip-spaces (string) - (if (= (string-to-char string) 32) - (if (= (length string) 1) "" - (strip-spaces (substring string 1))) - string) - ) - -(defun ct-load-project-emacs-files () - "Load project specific .emacs files" - (let ((ctprojs (getenv "CTPROJS"))) - (if ctprojs - (mapcar 'ct-load-project-emacs-file - (reverse (ct-break-space-colon-str ctprojs))) - )) - ) - -;; get all of the project specific .emacs files -(ct-load-project-emacs-files) diff --git a/dtool/src/attach/dtool.init b/dtool/src/attach/dtool.init deleted file mode 100644 index 89f62e7047..0000000000 --- a/dtool/src/attach/dtool.init +++ /dev/null @@ -1,10 +0,0 @@ -MODREL ETC_PATH built/etc -DOCSH source $DTOOL/built/etc/dtool.alias -DOCSH unsetenv LASTLOGIN -DOCSH setenv OS_VER `uname -r` -DOCSH ctshowprojs -DOSH source $DTOOL/built/etc/dtool.alias-sh -DOSH LASTLOGIN= -DOSH export LASTLOGIN -DOSH OS_VER=`uname -r` -DOSH export OS_VER diff --git a/dtool/src/attach/dtool.sh b/dtool/src/attach/dtool.sh deleted file mode 100755 index 598cd37cc0..0000000000 --- a/dtool/src/attach/dtool.sh +++ /dev/null @@ -1,81 +0,0 @@ -#! /bin/sh - -OS=`uname` -export OS - -# Setup the initial path -if [ $OS = "Linux" ]; then - PATH=/var/local/bin:~/bin:.:/usr/sbin:/sbin:/usr/bin:/bin:/usr/bin/X11:/usr/etc:/usr/local/bin -elif [ $OS = "IRIX64" ]; then - PATH=/var/local/bin:/usr/local/bin/ptools:~/bin:/usr/local/prman/bin:.:/usr/sbin:/usr/bsd:/sbin:/usr/bin:/bin:/usr/bin/X11:/usr/etc:/usr/demos/bin:/usr/local/bin -elif [ $OS = "CYGWIN_98-4.10" ]; then - PATH=/usr/local/bin:/bin:/CYGNUS/CYGWIN~1/H-I586~1/BIN:/WINDOWS:/WINDOWS:/WINDOWS/COMMAND:/DMI/BIN:/KATANA/UTL/DEV/MAKE:/KATANA/UTL/DEV/HITACHI -else - PATH=/var/local/bin:/usr/local/bin/ptools:~/bin:/usr/local/prman/bin:.:/usr/sbin:/usr/bsd:/sbin:/usr/bin:/bin:/usr/bin/X11:/usr/etc:/usr/demos/bin:/usr/local/bin -fi - -# Setup the initial manpath -#if [ $OS = "Linux" ]; then -# MANPATH=/usr/local/man:/usr/man/preformat:/usr/man:/usr/X11R6/man -#elif [ $OS = "IRIX64" ]; then -# MANPATH=/usr/share/catman:/usr/catman:/usr/local/share/catman:/usr/local/share/man:/usr/local/man -#elif [ $OS = "CYGWIN_98-4.10" ]; then -# MANPATH=/usr/local/man -#else -# MANPATH=/usr/share/catman:/usr/catman:/usr/local/share/catman:/usr/local/share/man:/usr/local/man -#fi -#export MANPATH - -LD_LIBRARY_PATH="." -export LD_LIBRARY_PATH -DYLD_LIBRARY_PATH="." -export DYLD_LIBRARY_PATH -CT_INCLUDE_PATH="." -export CT_INCLUDE_PATH -#cdpath=. -#CDPATH="." -#export CDPATH -DC_PATH="." -export DC_PATH -SSPATH="." -export SSPATH -STKPATH="." -export STKPATH -SHELL_TYPE="sh" -export SHELL_TYPE - -if [ -e /usr/atria ]; then - if /usr/atria/bin/cleartool mount -all > /dev/null 2>&1; then - HAVE_ATRIA=yes - export HAVE_ATRIA - fi -fi - -if [ -z "$CTDEFAULT_FLAV" ]; then - CTDEFAULT_FLAV="default" - export CTDEFAULT_FLAV -fi - -if [ -z "$DTOOL" ]; then - DTOOL=/beta/player/bootstrap/tool - export DTOOL -fi - -if [ -z "$PENV" ]; then - if [ $OS = "Linux" ]; then - PENV="Linux" - elif [ $OS = "IRIX64" ]; then - PENV="SGI" - elif [ $OS = "CYGWIN_98-4.10" ]; then - PENV="WIN32_DREAMCAST" - else - PENV="SGI" - fi -fi -export PENV - -if [ -z "$1" ]; then - source `$DTOOL/built/bin/ctattach.drv dtool default` -else - source `$DTOOL/built/bin/ctattach.drv dtool $1` -fi diff --git a/dtool/src/attach/get-cttree b/dtool/src/attach/get-cttree deleted file mode 100755 index d0e68e4f3f..0000000000 --- a/dtool/src/attach/get-cttree +++ /dev/null @@ -1,104 +0,0 @@ -#! /bin/sh -# -# get-cttree.sh -# -# Usage: -# -# get-cttree.sh [opts] output-file.tgz -# -# This script must be executed from within a project tree. -# -# Options: -# -# None at present. -# -#ENDCOMMENT - -while getopts "h" flag; do - case $flag in - h) sed '/#ENDCOMMENT/,$d' <$0 >&2 - exit 1;; - \?) exit 1; - esac -done - -shift `expr $OPTIND - 1` -output=$1 -projroot=`ctproj -r` - -if [ -z "$projroot" ]; then - echo "" - echo "You must execute this script in a project tree." - echo "" - exit 1 -fi - -if [ -z "$output" ]; then - sed '/#ENDCOMMENT/,$d' <$0 >&2 - exit 1 -fi - - -# Perform some sanity checks on input parameters. - -if [ ! -d "$projroot" ]; then - echo "" - echo "$projroot is not a directory!" - echo "" - exit 1 -fi - -if [ `basename $output .tgz` = `basename $output` ]; then - echo "" - echo "$output should end in .tgz" - echo "" - exit 1 -fi - -if [ ! -d /usr/atria ]; then - echo "" - echo "This script is intended to be run on an actual ClearCase vobs." - echo "" - exit 1 -fi - -projname=`basename $projroot` -projtop=`dirname $projroot` - -if [ "$projname" = "tool" ]; then - echo "" - echo "This script should not be used on the tool tree." - echo "" - exit 1 -fi - -if [ -f "$output" ]; then - if rm -i $output; then - echo "" - else - echo "Not overwriting $output" - exit 1 - fi -elif [ -r "$output" -o -w "$output" ]; then - echo "Cannot overwrite $output" - exit 1 -else - echo "" -fi - -# Check to make sure the local machine doesn't have anything checked out. -cd $projroot -outfile=/tmp/gc.$username.$projname.out -cleartool lsco -s -me -recurse >$outfile -if [ -s $outfile ]; then - echo "" - echo "Cannot build tarball; files still checked out in vobs:" - sed 's/^/ /;s/\.ct0\.//' $outfile - rm -f $outfile - echo "" - exit 1 -fi -rm -f $outfile - -(cd $projtop; cleartool find $projname -nxn -print | grep -v '/lost+found' | cpio -H tar -v -o | gzip) >$output - diff --git a/dtool/src/attach/get-delta b/dtool/src/attach/get-delta deleted file mode 100755 index 5ddb09a6a1..0000000000 --- a/dtool/src/attach/get-delta +++ /dev/null @@ -1,481 +0,0 @@ -#! /usr/local/bin/bash -# -# get-delta.sh -# -# Usage: -# -# get-delta.sh [opts] output-file.sh [file ...] -# -# This script must be executed from within a project tree. It -# examines the set of files that have been checked out (via neartool) -# and modified, and generates a script file that can be used to apply -# the changes made back to the main ClearCase vobs. -# -# By default, it generates a script for all checked-out files. You -# can restrict its operation to certain files and/or directories by -# listing them on the command line. -# -# Options: -# -# -c collapse versioning information on local copy after completion. -# Use this option with caution, as it is irreversible (and -# noninterruptible). Once the versioning information has been -# collapsed, it will be impossible to regenerate a script -# representing the changes that have been made locally; you -# should only do this when you are sure that your changes have -# been successfully applied to the other end. -# -# On the other hand, if you forget to run get-delta with -c after -# you have successfully applied your changes, you may -# inadvertently attempt to apply them again if you subsequently -# try to apply more changes. -# -#ENDCOMMENT - -function usage { - sed '/#ENDCOMMENT/,$d' <$0 >&2 - exit 1 -} - -# -# list_comments ( dirname basename ) -# -# Writes to stdout any comments associated with checked-out versions of -# the indicated file, in order. -# -function list_comments { - local dirname=$1 - local basename=$2 - local filename=$dirname/$basename - local file comment version - - if [ -f $dirname/.ct0.$basename ]; then - # Now look for comments, in version-number order. - - # We use a series of ls commands so we don't try to sort the - # filenames between the one-, two-, and three-digit version - # numbers. - - for file in `(cd $dirname; ls .ct[0-9].$basename; ls .ct[0-9][0-9].$basename; ls .ct[0-9][0-9][0-9].$basename) 2>/dev/null`; do - version=`echo $file | sed "s/^\.ct\([0-9]*\).*$/\1/"` - comment=$dirname/.ct${version}comment.$basename - if [ -f $comment ]; then - cat $comment - fi - done - fi -} - -# -# get_fullpath ( local_dir ) -# -# Sets $fullpath to the fully-qualified pathname associated with $local_dir. -# -function get_fullpath { - local local_dir=$1 - - if [ -z "$local_dir" ]; then - fullpath=`pwd` - else - if [ ! -d "$local_dir" ]; then - echo "Invalid directory: $local_dir" 1>&2 - exit 1 - fi - # If we use pwd instead of /bin/pwd, $PWD will be used, which will give - # the wrong answer - fullpath=`(cd $local_dir; /bin/pwd)` - fi -} - - -# -# get_rel_dir ( root_dir local_dir ) -# -# Sets $rel_dir to the string which represents $local_dir relative to -# $root_dir. This is a simple string-prefix operation, and could fail -# in some obscure cases. -# -function get_rel_dir { - get_fullpath $1 - local root_dir=$fullpath - - get_fullpath $2 - local local_dir=$fullpath - - # Now remove the initial prefix. - if [ "$root_dir" = "$local_dir" ]; then - rel_dir="." - else - rel_dir=`echo $local_dir | sed 's:^'$root_dir/'::'` - - if [ "$rel_dir" = "$local_dir" ]; then - echo "$local_dir is not a directory within $root_dir." 1>&2 - exit 1 - fi - fi -} - - -collapse= -while getopts "ch" flag; do - case $flag in - c) collapse=y;; - h) usage;; - \?) exit 1; - esac -done - -shift `expr $OPTIND - 1` -output=$1 -shift -projroot=`ctproj -r` - -if [ -z "$projroot" ]; then - echo "You must execute this script in a project tree." - exit 1 -fi - -if [ -z "$output" ]; then - usage -fi - - -# Perform some sanity checks on input parameters. - -if [ ! -d "$projroot" ]; then - echo "$projroot is not a directory!" - exit 1 -fi - -if [ `basename $output .sh` = `basename $output` ]; then - echo "$output should end in .sh" - exit 1 -fi - -if [ -f "$output" ]; then - rm -i $output - if [ -f "$output" ]; then - echo "Not overwriting $output" - exit 1 - fi -elif [ -e "$output" ]; then - echo "Cannot overwrite $output" - exit 1 -fi - -echo "" - -# Temporary files we'll build up as we process the files. - -base=`basename $output` -temp_ct0=/tmp/gd.ct0.$base -temp_checkout=/tmp/gd.checkout.$base -temp_dirs=/tmp/gd.dirs.$base -temp_files=/tmp/gd.files.$base -temp_diffs=/tmp/gd.diffs.$base - -rm -f $temp_ct0 $temp_checkout $temp_dirs $temp_files $temp_diffs -touch $temp_ct0 $temp_dirs $temp_files - - -# Get the list of files we'll want to delta in. - -if [ $# -eq 0 ]; then - # No explicit files, get all of them. - (cd $projroot; find . -name .ct0.\* -print) >>$temp_ct0 -else - # An explicit list of files. - for filename in $*; do - if [ -f $filename ]; then - dirname=`dirname $filename` - basename=`basename $filename` - - if [ -f $dirname/.ct0.$basename ]; then - get_rel_dir $projroot $dirname - echo ./$rel_dir/.ct0.$basename >>$temp_ct0 - else - echo $filename has no versions. - fi - - elif [ -d $filename ]; then - get_rel_dir $projroot $filename - - (cd $projroot; find ./$rel_dir -name .ct0.\* -print) >>$temp_ct0 - - else - echo $filename not found. - fi - done -fi - - -# Now start to build up the script. - -echo "#! /bin/sh" >$output -chmod 755 $output - -if [ ! -w $output ]; then - echo "Cannot write to $output!" - exit 1 -fi - -projname=`basename $projroot` - -# This part we cat in quoted, verbatim. -cat << 'EOF' >>$output - -any_opts= -list= -checkout= -patch= -cleanup= -checkin= -delta= -help= -while getopts "lopcidfh" flag; do - any_opts=y - only_list=y - case $flag in - l) list=y;; - o) checkout=y; only_list=;; - p) patch=y; only_list=;; - c) cleanup=y; only_list=;; - i) checkin=y; only_list=;; - d) delta=y; only_list=;; - f) checkout=y - patch=y - cleanup=y - checkin=y - delta=y - only_list=;; - h) help=y;; - \?) exit 1; - esac -done - -EOF - -# This part we cat in unquoted, so we can substitute the projname -# variable. - -cat << EOFOUTER >>$output -if [ \$help ]; then -cat << 'EOF' - -This patch file was generated using get-delta on a remote $projname tree. -It's designed to be run one time to apply the changes made remotely -back to the main branch of the tree. - -It should be run from within your own view, somewhere within the -$projname hierarchy on the ClearCase system. - -Options: - - -l List information about the patch file, including the creation - date and the list of modified files. - - -o Checkout all the relevant files and perform other ClearCase - operations (like renaming, creating, and removing files). - - -p Apply the relevant patches to all files after they have been - checked out. If this operation fails, the rest of the script - will not continue. - - -c Cleanup after successfully patching by removing .orig and .rej - files. - - -i Checkin modified files after successfully patching. - - -d Perform final merge by executing ctdelta on modified files. - - -f Perform full checkout/patch/merge cycle. This is equivalent to - specifying -opcid. - - -h This help page. - -If no options are specified, the default is -opc. - -EOF -exit 0 -fi - -if [ -z "\$any_opts" ]; then - checkout=y - patch=y - cleanup=y -fi -EOFOUTER - -any_merged= - -# We start with the commands given in the project's .ctcmds file. -ctcmds=$projroot/.ctcmds -if [ -f $ctcmds ]; then - any_merged=y - cat $ctcmds >>$temp_checkout - if [ $collapse ]; then - rm $ctcmds - fi -fi - - -for ct0 in `cat $temp_ct0`; do - dir=`dirname $ct0` - base=`basename $ct0 | sed 's/^\.ct0\.//'` - file=$dir/$base - ctnew=$projroot/$dir/.ctnew.$base - - if (cd $projroot; diff -u $ct0 $file >>$temp_diffs); then - # If diff returned success, it means the files were identical. In - # this case, don't bother checking it out. - echo "$file is unchanged." - - else - # Otherwise, the files were genuinely different. Check it out on - # the remote end. - echo $file - - if [ -f $ctnew ]; then - # This file is newly created. We need to create an element for - # it on the remote end. - eltype=`cat $ctnew` - if grep -x $dir $temp_dirs >/dev/null; then - echo directory already checked out >/dev/null - else - echo "ctco -nc $dir" >>$temp_checkout - echo $dir >> $temp_dirs - fi - echo "touch $file" >>$temp_checkout - echo "ctmkelem -eltype $eltype $file << 'EOF' 2>/dev/null" >>$temp_checkout - list_comments $projroot/$dir $base >>$temp_checkout - echo EOF >>$temp_checkout - - echo $file >> $temp_files - else - echo "ctco $file << 'EOF' 2>/dev/null" >>$temp_checkout - list_comments $projroot/$dir $base >>$temp_checkout - echo EOF >>$temp_checkout - - echo $file >> $temp_files - fi - fi - - if [ $collapse ]; then - echo Collapsing $file - neartool collapse $projroot/$file - fi -done -echo "" - -# Handle -l, list files modified -echo "" >>$output -echo 'if [ $list ]; then' >>$output -echo ' echo ""' >>$output -echo ' echo Patch file for '$projname' tree, built on '`date` >> $output -echo ' echo File was built by '`whoami` on `hostname` >>$output -echo ' echo ""' >>$output -echo ' echo Affected files are:' >>$output -echo ' cat <>$output -sed "s/^\./ $projname/" $temp_files >>$output -echo 'EOF' >>$output -echo ' echo ""' >>$output -echo 'fi' >>$output - -# Everything else depends on being in the proper tree. - -cat <>$output -if [ \$only_list ]; then - exit 0 -fi - -projroot=\`ctproj -r\` -if [ -z "\$projroot" ]; then - echo "" - echo "You must execute this script within the $projname tree." - echo "" - exit 1 -fi -if [ \`basename \$projroot\` != "$projname" ]; then - echo "" - echo "This script is intended for the $projname tree." - echo "" - exit 1 -fi -if [ ! -d /usr/atria ]; then - echo "" - echo "This script is intended to be run on an actual ClearCase vobs." - echo "" - exit 1 -fi -tmpfile=\`whoami\`-merge-$projname.tmp -cd \$projroot -touch \$tmpfile -EOF - - -# Handle -o, checkout stuff (and perform general ClearCase changes) -echo "" >>$output -echo 'if [ $checkout ]; then' >>$output -if [ -f $temp_checkout ]; then - cat $temp_checkout >> $output -else - echo 'echo Nothing to checkout.' >>$output -fi -echo 'fi' >>$output - -# Handle -p, apply patch -echo "" >>$output -echo 'if [ $patch ]; then' >>$output -if [ -f $temp_diffs ]; then - any_merged=y; - - echo " echo ''" >> $output - echo " echo Applying patches." >> $output - echo " if sed 's/^X//' << 'EOF' | patch -fsu; then" >>$output - - sed 's/^/X/' < $temp_diffs >>$output - echo EOF >>$output - - echo " echo All patches applied successfully." >>$output - echo " echo ''" >>$output - echo " else" >>$output - echo " echo Some conflicts detected:" >>$output - echo " find . -name '*.rej' -newer \$tmpfile -print" >>$output - echo " rm -f \$tmpfile" >>$output - echo " exit 1" >>$output - echo " fi" >>$output -else - echo ' echo No patches to apply.' >>$output -fi -echo 'fi' >>$output -echo "rm -f \$tmpfile" >>$output - -# Handle -c, cleanup -echo "" >>$output -echo 'if [ $cleanup ]; then' >>$output -sed 's/^\(.*\)$/ rm -f \1.orig \1.rej/' <$temp_files >>$output -echo 'fi' >>$output - -# Handle -i, checkin -echo "" >>$output -echo 'if [ $checkin ]; then' >>$output -sed 's/^\(.*\)$/ ctci -nc \1/' <$temp_files >>$output -sed 's/^\(.*\)$/ ctci -nc \1/' <$temp_dirs >>$output -echo 'fi' >>$output - -# Handle -d, delta -echo "" >>$output -echo 'if [ $delta ]; then' >>$output -sed 's/^\(.*\)$/ ctdelta \1/' <$temp_files >>$output -sed 's/^\(.*\)$/ ctdelta \1/' <$temp_dirs >>$output -echo 'fi' >>$output - -rm -f $temp_ct0 $temp_checkout $temp_dirs $temp_files $temp_diffs - -if [ -z "$any_merged" ]; then - echo "Nothing to do!" - echo "" - rm -f $output - exit 1 -fi - diff --git a/dtool/src/attach/neartool b/dtool/src/attach/neartool deleted file mode 100755 index a737597238..0000000000 --- a/dtool/src/attach/neartool +++ /dev/null @@ -1,1056 +0,0 @@ -#! /usr/local/bin/bash -# -# neartool - a Clearcase emulator for working off-line. -# -# Usage: -# -# neartool mkelem [-c "comment"] [-nc] [-eltype type] filename -# Marks a new file as a versioned element and checks it out. -# -# neartool mkdir [-c "comment"] [-nc] new_dir -# Creates a new Clearcase directory. -# -# neartool mv old-file new-file -# Renames or moves a versioned element. -# -# neartool mv file1 file2 file3 ... to-dir -# Moves a number of versioned elements into a new directory. -# -# neartool (co|checkout) [-c "comment"] [-nc] filename -# "checks out" a file by saving its current version and making a new -# version writable. The file is also marked as "checked-out". -# -# neartool (unco|uncheckout) filename -# Reverses the effect of the previous checkout. -# -# neartool (ci|checkin) [-c "comment"] [-nc] filename -# Marks the file as "checked in" and finalizes its most recent -# version, making it read-only. -# -# neartool revert filename -# Backs up a version on a checked-in filename. -# -# neartool revertall filename -# Reverts a filename all the way to its original state as extracted -# from the Clearcase vobs. -# -# neartool collapse filename -# Collapse all versioning information and mark the file as -# "checked-in" and merged as is. Presumably this should only be -# done after merging the changes back into the actual clearcase -# vobs. -# -# neartool rmname filename -# Removes a filename from a Clearcase directory. -# -# neartool find root [opts] -# Finds all elements with versions at root or below. The options -# are ignored. This is just a hack to support ctihave. -# -# neartool (lsco|lscheckout) [-l] file1 file2 file3... -# Lists which of the files are currently checked out, if any. If no -# filenames are given, lists all of the checked out files in the -# current directory. The -l option is ignored. -# -# neartool diff [-pre] filename -# Performs a diff between the indicated filename and its previous -# version. The option -pre is ignored. -# -# neartool xdiff [-pre] filename -# Performs an xdiff between the indicated filename and its previous -# version. The option -pre is ignored. -# -#ENDCOMMENT - - -# -# get_nth_param ( param-no param1 param2 param3 ... ) -# -# Sets the variable nth_param to the value of the parameter -# corresponding to param-no. -# -function get_nth_param { - local param_no=$1 - shift $param_no - nth_param=$1 -} - -# -# get_last_param ( param1 param2 param3 ... ) -# -# Sets the variable last_param to the value of the last non-blank -# parameter. -# -function get_last_param { - last_param="$1" - shift - while [ ! -z "$*" ]; do - last_param="$1" - shift - done -} - -# -# format_comment ( comment_str ) -# -# Writes the parameter -c '$comment_str', or -nc if the comment is -# empty, to the standard output. Handles nested quotes appropriately. -# -function format_comment { - local comment="$*" - - if [ -z "$comment" ]; then - echo "-nc" - else - # Escaping single quotes inside a single-quoted string doesn't - # seem to work too reliably. Instead, we'll just remove single - # quotes. So there. - - # This absurd number of backslashes is needed to output a single - # backslash through all this nesting. - # echo "-c '"`echo $comment | sed "s/'/\\\\\\\\'/g"`"'" - echo "-c '"`echo $comment | sed "s/'//g"`"'" - fi -} - -# -# list_comments ( dirname basename ) -# -# Writes to stdout any comments associated with checked-out versions of -# the indicated file, in order. -# -function list_comments { - local dirname=$1 - local basename=$2 - local filename=$dirname/$basename - local file comment version - - if [ -f $dirname/.ct0.$basename ]; then - # Now look for comments, in version-number order. - - # We use a series of ls commands so we don't try to sort the - # filenames between the one-, two-, and three-digit version - # numbers. - - for file in `(cd $dirname; ls .ct[0-9].$basename; ls .ct[0-9][0-9].$basename; ls .ct[0-9][0-9][0-9].$basename) 2>/dev/null`; do - version=`echo $file | sed "s/^\.ct\([0-9]*\).*$/\1/"` - comment=$dirname/.ct${version}comment.$basename - if [ -f $comment ]; then - sed s'/^/ /' <$comment - fi - done - fi -} - -# -# get_highest_version ( dirname basename ) -# -# Sets the variable $version to the numeric value that is the highest -# existing version number defined for the given filename. If the -# filename has no previous version numbers, sets $version to -1. -# -function get_highest_version { - local dirname=$1 - local basename=$2 - local filename=$dirname/$basename - local last - - if [ -f $dirname/.ct0.$basename ]; then - # If there are any versions at all, get the highest-numbered one - # and return it. - - # We use a series of ls commands so we don't try to sort the - # filenames between the one-, two-, and three-digit version - # numbers. - - last=`(cd $dirname; ls .ct[0-9].$basename; ls .ct[0-9][0-9].$basename; ls .ct[0-9][0-9][0-9].$basename) 2>/dev/null | tail -1` - version=`echo $last | sed "s/^\.ct\([0-9]*\).*$/\1/"` - else - # If there aren't any versions yet, the highest-numbered existing - # version number is -1. - version=-1 - fi -} - -# -# is_ctinternal ( basename ) -# -# Returns success if the filename matches one of the internal filenames -# generated by this script, failure if it is a perfectly ordinary -# non-ct file. -# -function is_ctinternal { - local basename=$1 - - case $basename in - .ct[0-9].*|ct[0-9][0-9].*|ct[0-9][0-9][0-9].*|\ - .ct[0-9]comment.*|.ct[0-9][0-9]comment.*|.ct[0-9][0-9][0-9]comment*|\ - .ctco.*|.ctnew.*) - return 0;; - esac - return 1 -} - -# -# is_install_dir ( dirname ) -# -# Returns success if the directory is any of the directories known to -# be install directories, such as inc, lib, lib/ss, etc. -# -function is_install_dir { - local dirname=$1 - - get_rel_dir $projroot $dirname - - case $rel_dir in - inc) return 0;; - inc/*) return 0;; - include/*) return 0;; - lib) return 0;; - lib/*) return 0;; - esac - return 1 -} - -# -# rm_all_ctinternals ( dirname basename ) -# -# Removes all the ctinternal files associated with the indicated file. -# -function rm_all_ctinternals { - local dirname=$1 - local basename=$2 - - rm -f $dirname/.ct[0-9].$basename - rm -f $dirname/.ct[0-9][0-9].$basename - rm -f $dirname/.ct[0-9][0-9][0-9].$basename - rm -f $dirname/.ct[0-9]comment.$basename - rm -f $dirname/.ct[0-9][0-9]comment.$basename - rm -f $dirname/.ct[0-9][0-9][0-9]comment.$basename - rm -f $dirname/.ctnew.$basename - rm -f $dirname/.ctco.$basename -} - -# -# sane_filename ( dirname basename ) -# -# Performs some sanity checks on the filename. If the file is -# unusable, exits the script with a status of 1. -# -function sane_filename { - local dirname=$1 - local basename=$2 - local filename=$dirname/$basename - - if [ -z "$basename" ]; then - echo "Filename unspecified." 1>&2 - exit 1 - fi - - if is_ctinternal $basename; then - echo "$filename is an internal filename and should not be checked out." 1>&2 - exit 1 - fi - - # It's easy to accidentally attempt to check something out from the - # inc directory. Let's detect this. - - if is_install_dir $dirname; then - echo "$basename is in an install directory." 1>&2 - echo "It should probably not be checked out." 1>&2 - exit 1 - fi - - if [ -d $filename ]; then - # Let's just quietly ignore directories. If we issue the warning - # statement, it makes ctaddtgt and ctaddpkg seem like they're - # failing. - # echo "Cannot operate on directories." 1>&2 - exit 0 - fi -} - -# -# get_fullpath ( local_dir ) -# -# Sets $fullpath to the fully-qualified pathname associated with $local_dir. -# -function get_fullpath { - local local_dir=$1 - - if [ -z "$local_dir" ]; then - fullpath=`pwd` - else - if [ ! -d "$local_dir" ]; then - echo "Invalid directory: $local_dir" 1>&2 - exit 1 - fi - # If we use pwd instead of /bin/pwd, $PWD will be used, which will give - # the wrong answer - fullpath=`(cd $local_dir; /bin/pwd)` - fi -} - - -# -# get_rel_dir ( root_dir local_dir ) -# -# Sets $rel_dir to the string which represents $local_dir relative to -# $root_dir. This is a simple string-prefix operation, and could fail -# in some obscure cases. -# -function get_rel_dir { - get_fullpath $1 - local root_dir=$fullpath - - get_fullpath $2 - local local_dir=$fullpath - - # Now remove the initial prefix. - if [ "$root_dir" = "$local_dir" ]; then - rel_dir="." - else - rel_dir=`echo $local_dir | sed 's:^'$root_dir/'::'` - - if [ "$rel_dir" = "$local_dir" ]; then - echo "$local_dir is not a directory within $root_dir." 1>&2 - exit 1 - fi - fi -} - -function ctmkelem { - local filename dirname basename - local comment eltype - - eltype=text_file - while getopts c:n:e: flag; do - case $flag in - c) comment="$OPTARG";; - n) comment="";; - e) case $OPTARG in - ltype) get_nth_param $OPTIND "$@" - eltype=$nth_param - OPTIND=`expr $OPTIND + 1`;; - *) echo Invalid switch -e$OPTARG - exit 1; - esac;; - \?) exit 1; - esac - done - shift `expr $OPTIND - 1` - - if [ -z "$1" ]; then - echo "No filenames given." - exit 1 - fi - - for filename in "$@"; do - dirname=`dirname $filename` - basename=`basename $filename` - - sane_filename $dirname $basename - - ctco=$dirname/.ctco.$basename - if [ -f $ctco ]; then - echo "$filename is already checked out." 1>&2 - exit 1 - fi - - if [ ! -f $filename ]; then - # If the file doesn't exist, create it. - echo -n "" >$filename - fi - - get_highest_version $dirname $basename - - if [ $version -ne -1 ]; then - echo "$filename already has versions." 1>&2 - exit 1 - fi - - if [ ! -w $filename ]; then - echo "$filename has no write permission, it's probably already a versioned element." 1>&2 - exit 1 - fi - - # Create a ctnew file to indicate the file is newly created. - ctnew=$dirname/.ctnew.$basename - echo $eltype >$ctnew - chmod uga-w $ctnew - - # Now "check out" the new filename by creating an empty first version. - - next=$dirname/.ct0.$basename - nextcomment=$dirname/.ct0comment.$basename - - if [ ! -z "$comment" ]; then - echo $comment >$nextcomment - chmod uga-w $nextcomment - fi - echo -n "" > $next - - date >$ctco - done -} - -function ctmkdir { - local filename dirname basename - local comment - - while getopts c:n: flag; do - case $flag in - c) comment="$OPTARG";; - n) comment="";; - \?) exit 1; - esac - done - shift `expr $OPTIND - 1` - - if [ -z "$1" ]; then - echo "No filenames given." - exit 1 - fi - - for filename in "$@"; do - dirname=`dirname $filename` - basename=`basename $filename` - - if [ -z "$basename" ]; then - echo "Filename unspecified." 1>&2 - exit 1 - fi - - if is_ctinternal $basename; then - echo "$filename is an internal filename and should not be checked out." 1>&2 - exit 1 - fi - - if mkdir $filename; then - # The directory is successfully made; record this in the - # Clearcase instructions. - get_rel_dir $projroot $dirname - echo "ctco -nc $rel_dir" >>$projroot/.ctcmds - echo "ctmkdir `format_comment $comment` $rel_dir/$basename" >>$projroot/.ctcmds - else - echo "Unable to create directory $filename." 1>&2 - fi - done -} - -# -# do_ctmv ( oldname newname ) -# -# The implementation of ctmv. This renames a single file, possibly -# placing it in a new directory. -# -function do_ctmv { - local oldfilename olddirname oldbasename - local newfilename newdirname newbasename - - oldfilename=$1 - olddirname=`dirname $oldfilename` - oldbasename=`basename $oldfilename` - - newfilename=$2 - newdirname=`dirname $newfilename` - newbasename=`basename $newfilename` - - sane_filename $olddirname $oldbasename - sane_filename $newdirname $newbasename - - if [ ! -f $oldfilename ]; then - echo "$oldfilename does not exist." 1>&2 - exit 1 - fi - - if [ -f $newfilename ]; then - echo "$newfilename already exists--remove it first." 1>&2 - exit 1 - fi - - oldctnew=$olddirname/.ctnew.$oldfilename - - if [ ! -f $oldctnew ]; then - # The filename exists on the actual Clearcase vobs. We need to - # record the renaming. - - get_rel_dir $projroot $olddirname - local oldroot=$rel_dir - get_rel_dir $projroot $newdirname - local newroot=$rel_dir - - echo "ctco -nc $oldroot" >> $projroot/.ctcmds - if [ "$oldroot" != "$newroot" ]; then - echo "ctco -nc $newroot" >> $projroot/.ctcmds - fi - echo "ctmv $oldroot/$oldbasename $newroot/$newbasename" >> $projroot/.ctcmds - fi - - # Now rename our local copy, and all of its version tracking stuff. - get_fullpath $newdirname - local newroot=$fullpath - - (cd $olddirname; - for file in \ - `ls .ct[0-9].$oldbasename \ - .ct[0-9][0-9].$oldbasename \ - .ct[0-9][0-9][0-9].$oldbasename \ - .ct[0-9]comment.$oldbasename \ - .ct[0-9][0-9]comment.$oldbasename \ - .ct[0-9][0-9][0-9]comment.$oldbasename \ - .ctnew.$oldbasename \ - .ctco.$oldbasename \ - $oldbasename 2>/dev/null`; do - ctprefix=`echo $file | sed 's:'$oldbasename'$::'` - mv -i $file $newroot/$ctprefix$newbasename - done) -} - -function ctmv { - local source destination - - while getopts "" flag; do - case $flag in - \?) exit 1; - esac - done - shift `expr $OPTIND - 1` - - get_last_param "$@" - destination=$last_param; - - if [ ! -d "$destination" ]; then - # If we're not moving to a directory, we are renaming a file--and - # thus we can only allow two parameters. - source=$1 - shift 2 - if [ ! -z "$*" ]; then - echo Last filename must be a directory. - exit 1 - fi - - do_ctmv $source $destination - else - - # Otherwise, we're moving a slew of files to a directory. Get - # each filename and move it. - for source in "$@"; do - if [ "$source" != "$destination" ]; then - do_ctmv $source $destination/$source - fi - done - fi -} - -function ctco { - local filename dirname basename - - while getopts c:n: flag; do - case $flag in - c) comment="$OPTARG";; - n) comment="";; - \?) exit 1; - esac - done - shift `expr $OPTIND - 1` - - if [ -z "$1" ]; then - echo "No filenames given." - exit 1 - fi - - for filename in "$@"; do - dirname=`dirname $filename` - basename=`basename $filename` - - sane_filename $dirname $basename - okflag=y - - if [ ! -f $filename ]; then - echo "$filename does not exist." 1>&2 - okflag= - else - ctco=$dirname/.ctco.$basename - if [ -f $ctco ]; then - echo "$filename is already checked out." 1>&2 - okflag= - else - if [ -w $filename ]; then - echo "$filename has write permission, it's probably not a versioned element." 1>&2 - echo "Try neartool mkelem $filename." 1>&2 - okflag= - fi - fi - fi - - if [ ! -z "$okflag" ]; then - get_highest_version $dirname $basename - next=$dirname/.ct`expr $version + 1`.$basename - nextcomment=$dirname/.ct`expr $version + 1`comment.$basename - - if [ ! -z "$comment" ]; then - echo $comment >$nextcomment - chmod uga-w $nextcomment - fi - - mv $filename $next - cp $next $filename - chmod ug+w $filename - - date >$ctco - fi - done -} - - -function ctunco { - local ignore filename dirname basename - - while getopts "r:" flag; do - case $flag in - r) ignore=;; - \?) exit 1; - esac - done - shift `expr $OPTIND - 1` - - if [ -z "$1" ]; then - echo "No filenames given." - exit 1 - fi - - for filename in "$@"; do - dirname=`dirname $filename` - basename=`basename $filename` - - sane_filename $dirname $basename - - if [ ! -f $filename ]; then - echo "$filename does not exist." 1>&2 - exit 1 - fi - - ctco=$dirname/.ctco.$basename - if [ ! -f $ctco ]; then - echo "$filename is not checked out." 1>&2 - exit 1 - fi - - get_highest_version $dirname $basename - last=$dirname/.ct$version.$basename - lastcomment=$dirname/.ct${version}comment.$basename - - mv -f $last $filename - rm -f $lastcomment - rm $ctco - touch $filename # For emacs, and correct make behavior. - done -} - - -function ctci { - local filename dirname basename - local comment - - while getopts c:n: flag; do - case $flag in - c) comment="$OPTARG";; - n) comment="";; - \?) exit 1; - esac - done - shift `expr $OPTIND - 1` - - if [ -z "$1" ]; then - echo "No filenames given." - exit 1 - fi - - for filename in "$@"; do - dirname=`dirname $filename` - basename=`basename $filename` - - sane_filename $dirname $basename - - if [ ! -f $filename ]; then - echo "$filename does not exist." 1>&2 - exit 1 - fi - - - ctco=$dirname/.ctco.$basename - if [ ! -f $ctco ]; then - echo "$filename is not checked out." 1>&2 - exit 1 - fi - - # We touch the file, so emacs will note that it has changed. - touch $filename - chmod uga-w $filename - - rm $ctco - done -} - - -function ctrevert { - local filename dirname basename - - while getopts "" flag; do - case $flag in - \?) exit 1; - esac - done - shift `expr $OPTIND - 1` - - if [ -z "$1" ]; then - echo "No filenames given." - exit 1 - fi - - for filename in "$@"; do - dirname=`dirname $filename` - basename=`basename $filename` - - sane_filename $dirname $basename - - if [ ! -f $filename ]; then - echo "$filename does not exist." 1>&2 - exit 1 - fi - - ctco=$dirname/.ctco.$basename - if [ -f $ctco ]; then - echo "$filename is currently checked out. Use neartool unco $filename." 1>&2 - exit 1 - fi - - get_highest_version $dirname $basename - - if [ $version -eq -1 ]; then - echo "$filename has no versions." 1>&2 - exit 1 - fi - - last=$dirname/.ct$version.$basename - lastcomment=$dirname/.ct${version}comment.$basename - - mv -f $last $filename - rm -f $lastcomment - - if [ $version -eq 0 ]; then - ctnew=$dirname/.ctnew.$basename - if [ -f $ctnew ]; then - echo "Removing newly created element $filename." 1>&2 - rm -f $ctnew $filename - fi - fi - done -} - -function ctrevertall { - local filename dirname basename - - while getopts "" flag; do - case $flag in - \?) exit 1; - esac - done - shift `expr $OPTIND - 1` - - if [ -z "$1" ]; then - echo "No filenames given." - exit 1 - fi - - for filename in "$@"; do - dirname=`dirname $filename` - basename=`basename $filename` - - sane_filename $dirname $basename - - if [ ! -f $filename ]; then - echo "$filename does not exist." 1>&2 - exit 1 - fi - - ct0=$dirname/.ct0.$basename - if [ ! -f $ct0 ]; then - echo "$filename has no versions." 1>&2 - else - ctnew=$dirname/.ctnew.$basename - if [ ! -f $ctnew ]; then - # If we didn't newly create this file, preserve its original version. - mv -f $ct0 $filename - fi - rm_all_ctinternals $dirname $basename - fi - done -} - -function ctcollapse { - local filename dirname basename - - while getopts "" flag; do - case $flag in - \?) exit 1; - esac - done - shift `expr $OPTIND - 1` - - if [ -z "$1" ]; then - echo "No filenames given." - exit 1 - fi - - for filename in "$@"; do - dirname=`dirname $filename` - basename=`basename $filename` - - sane_filename $dirname $basename - - if [ ! -f $filename ]; then - echo "$filename does not exist." 1>&2 - exit 1 - fi - - rm_all_ctinternals $dirname $basename - - chmod uga-w $filename - touch $filename # For Emacs' benefit. - done -} - -function ctrmname { - local filename dirname basename - while getopts "" flag; do - case $flag in - \?) exit 1; - esac - done - shift `expr $OPTIND - 1` - - if [ -z "$1" ]; then - echo "No filenames given." - exit 1 - fi - - for filename in "$@"; do - dirname=`dirname $filename` - basename=`basename $filename` - - sane_filename $dirname $basename - - if [ ! -f $filename ]; then - echo "$filename does not exist." 1>&2 - exit 1 - fi - - ctnew=$dirname/.ctnew.$basename - - if [ ! -f $ctnew ]; then - # The filename exists on the actual Clearcase vobs. We need to - # record the removing. - - get_rel_dir $projroot $dirname - local root=$rel_dir - - echo "ctco -nc $root" >> $projroot/.ctcmds - echo "ctrm $root/$basename" >> $projroot/.ctcmds - fi - - # Now remove all of the versioned stuff. - ctcollapse $filename - - # And remove the file itself. - rm -f $filename - done -} - - -function ctfind { - local root=$1 - - if [ -z "$root" ]; then - echo "Specify a starting point of the find." 1>&2 - exit 1 - fi - - find $root -name .ct0.\* -print | sed 's/\.ct0\.//' -} - -function ctdescribe { - local filename dirname basename - - while getopts "" flag; do - case $flag in - \?) exit 1; - esac - done - shift `expr $OPTIND - 1` - - if [ -z "$1" ]; then - echo "No filenames given." - exit 1 - fi - - for filename in `ls "$@"`; do - dirname=`dirname $filename` - basename=`basename $filename` - - ctco=$dirname/.ctco.$basename - get_highest_version $dirname $basename - version=`expr $version + 1` - - if [ -f $ctco ]; then - if [ $version -eq 0 ]; then - echo "$filename is checked out with no versions." - else - echo "$filename is checked out as version $version." - list_comments $dirname $basename - fi - else - if [ $version -eq 0 ]; then - echo "$filename has not been checked out and has no versions." - else - echo "$filename is checked in as version $version." - list_comments $dirname $basename - fi - fi - done -} - -function ctlsco { - local filename dirname basename - local ignore - while getopts "l" flag; do - case $flag in - l) ignore=;; - \?) exit 1; - esac - done - shift `expr $OPTIND - 1` - - for filename in `ls "$@"`; do - dirname=`dirname $filename` - basename=`basename $filename` - - ctco=$dirname/.ctco.$basename - if [ -f $ctco ]; then - ctdescribe $filename - fi - done -} - -function ctdiff { - local filename dirname basename - local graphical - local ignore - local diff - - while getopts "gp:" flag; do - case $flag in - g) graphical=y;; - p) ignore=;; - \?) exit 1; - esac - done - shift `expr $OPTIND - 1` - - diff=diff - if [ $graphical ]; then - # The user requested a graphical difference; use gdiff if we can - # find it. Otherwise, fall back to diff. - if which gdiff 2>/dev/null >/dev/null; then - diff=gdiff - fi - fi - - if [ -z "$1" ]; then - echo "No filenames given." - exit 1 - fi - - for filename in "$@"; do - dirname=`dirname $filename` - basename=`basename $filename` - - sane_filename $dirname $basename - - if [ ! -f $filename ]; then - echo "$filename does not exist." 1>&2 - exit 1 - fi - - get_highest_version $dirname $basename - - if [ $version -eq -1 ]; then - echo "$filename has no versions." 1>&2 - exit 1 - fi - - last=$dirname/.ct$version.$basename - - # First, call diff (the real diff) just to see if the files are - # different at all. - - if diff $last $filename >/dev/null; then - echo Files are identical. - - else - # If the files ARE different, then invoke diff again (which - # might be gdiff, this time) to actually report the differences. - # We must do it twice like this because gdiff might not return - # non-zero if the files are different. - - $diff $last $filename - fi - done -} - - -function usage { - sed '/#ENDCOMMENT/,$d' <$0 >&2 - exit 1 -} - - -# -# Main entry point -# - -command=$1 -if [ -z "$command" ]; then - usage -fi - -shift - -projroot=`ctproj -r` - -if [ -z "$projroot" ]; then - echo "Not currently in a project tree." 1>&2 - exit 1 -fi - -case $command in - mkelem) ctmkelem "$@";; - mkdir) ctmkdir "$@";; - mv) ctmv "$@";; - co|checkout) ctco "$@";; - unco|uncheckout) ctunco "$@";; - ci|checkin) ctci "$@";; - revert) ctrevert "$@";; - revertall) ctrevertall "$@";; - collapse) ctcollapse "$@";; - rmname) ctrmname "$@";; - find) ctfind "$@";; - lsco|lscheckout) ctlsco "$@";; - describe) ctdescribe "$@";; - diff) ctdiff "$@";; - xdiff) ctdiff -g "$@";; - h|help|-h) usage;; - *) echo "Invalid option: $command" 1>&2 - exit 1; -esac diff --git a/dtool/src/attach/unco.pl b/dtool/src/attach/unco.pl deleted file mode 100644 index dd383ab99f..0000000000 --- a/dtool/src/attach/unco.pl +++ /dev/null @@ -1,31 +0,0 @@ -require "$tool/built/include/ctutils.pl" ; -require "$tool/built/include/ctdelta.pl" ; - -# Remove a branch for an element if needed -# input is in: -# $_[0] = element -sub CTUncoDoIt { - local( $elem ) = $_[0] ; - local( $ver ) = &CTDeltaGetVersion( $elem ) ; - if ( $ctdebug ne "" ) { - print STDERR "Unco script: got version '" . $ver . "'\n" ; - } - local( @verlist ) ; - @verlist = split( /\//, $ver ) ; - local( $vlast ) = pop( @verlist ) ; - if ( $ctdebug ne "" ) { - print STDERR "Unco script: last part of version is '" . $vlast . "'\n" ; - } - if ( $#verlist > 1 ) { - local( $branch ) = join( "/", @verlist ) ; - if ( $vlast == 0 ) { - local( $cmd ) = "cleartool rmbranch -force -nc $elem" . "@@" . "$branch" ; - if ( $ctdebug ne "" ) { - print STDERR "Unco script: command is '" . $cmd . "'\n" ; - } - system $cmd ; - } - } -} - -1; diff --git a/dtool/src/attach/update-cttree b/dtool/src/attach/update-cttree deleted file mode 100755 index 2abf87ee15..0000000000 --- a/dtool/src/attach/update-cttree +++ /dev/null @@ -1,189 +0,0 @@ -#! /bin/sh -# -# update-cttree.sh -# -# Usage: -# -# update-cttree.sh [opts] hostname -# -# Uses rsh and rdist to update the indicated host with a fresh copy of the -# current project tree. -# -# This script must be executed from within a project tree. -# -# Options: -# -# -u username Specify the login name on the remote host. -# -# -d dir Specify the player install dir on the remote host. This -# the directory above the project-tree-specific directory -# like 'panda' or 'tool'. The default is 'player'. -# -# -t Touch the build-request timestamp file after updating. -# This assumes there's a cron job running on the remote -# machine checking the date on this file from time to time. -# -# -f Assume the user knows what he/she is doing, and don't bother -# to check that there are no files checked out in the vobs -# before releasing. This can save considerable time when the -# system is extremely slow; however, it can be dangerous -# to accidentally release a checked-out file (because the -# file will then be write-access on the remote host, and -# neartool will not be able to track local changes made to it.) -# -#ENDCOMMENT - -username=`whoami` -dirname=player -touch_request= -cocky_user= - -while getopts "u:d:tfh" flag; do - case $flag in - u) username=$OPTARG;; - d) dirname=$OPTARG;; - t) touch_request=y;; - f) cocky_user=y;; - h) sed '/#ENDCOMMENT/,$d' <$0 >&2 - exit 1;; - \?) exit 1; - esac -done - -shift `expr $OPTIND - 1` -remote_host=$1 -projroot=`ctproj -r` - -if [ -z "$projroot" ]; then - echo "" - echo "You must execute this script in a project tree." - echo "" - exit 1 -fi - -if [ -z "$remote_host" ]; then - echo "" - echo "You must specify a remote hostname. -h for help." - echo "" - exit 1 -fi - -if [ ! -d /usr/atria ]; then - echo "" - echo "This script is intended to be run on an actual ClearCase vobs." - echo "" - exit 1 -fi - -projname=`basename $projroot` -projtop=`dirname $projroot` - -if [ "$projname" = "tool" ]; then - echo "" - echo "This script should not be used on the tool tree." - echo "" - exit 1 -fi - -outfile=/tmp/uc.$username.$projname.$remote_host.out -errfile=/tmp/uc.$username.$projname.$remote_host.err -rm -f $outfile $errfile - -# Check to make sure we can run rsh to the remote machine, and that -# the remote machine doesn't have anything checked out. - -if rsh $remote_host -l $username "cd $dirname; find $projname -name .ct0.\* -print" >$outfile 2>$errfile; then - if [ ! -f $outfile ]; then - echo "" - echo "Error in processing; unable to generate $outfile." - echo "" - rm -f $outfile $errfile - exit 1 - fi - if [ ! -f $errfile ]; then - echo "" - echo "Error in processing; unable to generate $errfile." - echo "" - rm -f $outfile $errfile - exit 1 - fi - if [ -s $errfile ]; then - echo "" - echo "Unable to scan project tree $dirname/$projname on $remote_host." - echo "" - rm -f $outfile $errfile - exit 1 - fi - if [ -s $outfile ]; then - echo "" - echo "Cannot update $remote_host; files still checked out on remote:" - sed 's/^/ /;s/\.ct0\.//' $outfile - rm -f $outfile $errfile - echo "" - exit 1 - fi -else - echo "" - echo "Cannot rsh to $remote_host as $username." - echo "" - rm -f $outfile $errfile - exit 1 -fi - -# Check to make sure the local machine doesn't have anything checked out. -if [ -z "$cocky_user" ]; then - cd $projroot - cleartool lsco -s -me -recurse >$outfile - if [ -s $outfile ]; then - echo "" - echo "Cannot update from "`hostname`"; files still checked out in vobs:" - sed 's/^/ /;s/\.ct0\.//' $outfile - rm -f $outfile $errfile - echo "" - exit 1 - fi -fi - -rm -f $outfile $errfile - - -# -# Get the complete list of files in the tree we need to update. -# -cd $projtop -filelist=${outfile}.files -rm -f $filelist -cleartool find $projname -nxn -print | grep -v '/lost+found' > $filelist - -# -# Now build up a number of rdist files, as needed, to update these files. -# We have to do this in stages because there seems to be a limit of about -# 2000 files in one rdist file. -# -numlines=`wc -l $filelist | awk '{ print $1 }'` -echo $projname contains $numlines files. - -startline=1 -while [ $startline -le $numlines ]; do - echo "FILES = (" >> $outfile - tail +$startline $filelist | head -2000 >> $outfile - echo ")" >> $outfile - - echo '${FILES} -> '$username@$remote_host >>$outfile - echo " install $dirname;" >> $outfile - - if [ $touch_request ]; then - echo " cmdspecial \"touch $dirname/$projname/build-request\" ;" >>$outfile - fi - - if rdist -onochkowner,nochkgroup,numchkgroup,whole,nodescend -f $outfile; then - rm -f $outfile - else - echo "Error in rdist." - rm -f $outfile $filelist $errfile - exit 1 - fi - startline=`expr $startline + 2000` -done - -rm -f $filelist $errfile From 705fd445f3079853dff487e5a206017a62da8ef4 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 25 Feb 2018 19:05:45 -0700 Subject: [PATCH 049/247] dtool: Fix an inconsistent EXPCL/EXPTP --- dtool/src/dtoolutil/vector_string.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dtool/src/dtoolutil/vector_string.cxx b/dtool/src/dtoolutil/vector_string.cxx index 2b7ba4202a..0e5df2ce1d 100644 --- a/dtool/src/dtoolutil/vector_string.cxx +++ b/dtool/src/dtoolutil/vector_string.cxx @@ -13,8 +13,8 @@ #include "vector_string.h" -#define EXPCL EXPCL_DTOOLCONFIG -#define EXPTP EXPTP_DTOOLCONFIG +#define EXPCL EXPCL_DTOOL +#define EXPTP EXPTP_DTOOL #define TYPE std::string #define NAME vector_string From 01b08357973d7b6211228bf020b70cfcccc593f8 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 26 Feb 2018 00:15:38 -0700 Subject: [PATCH 050/247] pandabase: Remove reference to DIRECTORY_DLLS Nothing defines this under any circumstances. Also this moves the various component EXPCLs and EXPTPs within the include guard of the entire header. --- panda/src/pandabase/pandasymbols.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/panda/src/pandabase/pandasymbols.h b/panda/src/pandabase/pandasymbols.h index cc02ff0e12..6c817f56bd 100644 --- a/panda/src/pandabase/pandasymbols.h +++ b/panda/src/pandabase/pandasymbols.h @@ -326,12 +326,6 @@ #define INLINE_GUI INLINE #define INLINE_AUDIO INLINE -#endif - - -#if defined(DIRECTORY_DLLS) - -#else #define EXPCL_PANDA_PGRAPH EXPCL_PANDA #define EXPTP_PANDA_PGRAPH EXPTP_PANDA From 5523af09ce24ea61e4a89756acc9d7bc9c7d727f Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 27 Feb 2018 12:05:23 +0100 Subject: [PATCH 051/247] makepanda: rebuild modules when interrogate_module is modified --- makepanda/makepandacore.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 0bce3f4450..81163c8179 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -3419,5 +3419,9 @@ def TargetAdd(target, dummy=0, opts=[], input=[], dep=[], ipath=None, winrc=None t.deps[FindLocation("interrogate.exe", [])] = 1 t.deps[FindLocation("dtool_have_python.dat", [])] = 1 + if target.endswith(".obj") and any(x.endswith(".in") for x in input): + if not CrossCompiling(): + t.deps[FindLocation("interrogate_module.exe", [])] = 1 + if target.endswith(".pz") and not CrossCompiling(): t.deps[FindLocation("pzip.exe", [])] = 1 From b62435a37384a3be475bbb80c7dd00c59a9b8ae4 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 27 Feb 2018 15:02:49 +0100 Subject: [PATCH 052/247] general: remove all uses of deprecated upcastTo*() methods These methods have not been needed for a very long time, so we should not encourage their use. --- contrib/src/sceneeditor/seFileSaver.py | 8 ++++---- contrib/src/sceneeditor/seLights.py | 9 +-------- direct/src/showbase/ShadowDemo.py | 4 ++-- direct/src/showbase/ShowBase.py | 3 +-- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/contrib/src/sceneeditor/seFileSaver.py b/contrib/src/sceneeditor/seFileSaver.py index 73c71f5901..317c9427f2 100644 --- a/contrib/src/sceneeditor/seFileSaver.py +++ b/contrib/src/sceneeditor/seFileSaver.py @@ -488,7 +488,7 @@ class FileSaver: out_file.write (i2+ "alight = AmbientLight(\'"+ light.getName() +"\')\n") out_file.write (i2+ "alight.setColor(VBase4("+ str(light.getLightColor().getX())+ "," + str(light.getLightColor().getY())+ "," + str(light.getLightColor().getZ()) + "," + str(light.getLightColor().getW()) + "))\n") out_file.write (i2+ "self.lightAttrib=self.lightAttrib.addLight(alight)\n") - out_file.write (i2+ "self."+light.getName()+"= render.attachNewNode(alight.upcastToPandaNode())\n") + out_file.write (i2+ "self."+light.getName()+"= render.attachNewNode(alight)\n") out_file.write (i2+ "self."+light.getName()+".setTag(\"Metadata\",\"" + light.getTag("Metadata") + "\")\n") out_file.write (i2+ "self.LightDict[\'" + light.getName() + "\']=alight\n") out_file.write (i2+ "self.LightTypes[\'" + light.getName() + "\']=\'" + type + "\'\n") @@ -503,7 +503,7 @@ class FileSaver: #out_file.write (i2+ "alight.setPoint(Point3(" + str(light.getX()) + "," + str(light.getY()) + "," + str(light.getZ()) + "))\n") out_file.write (i2+ "alight.setSpecularColor(Vec4(" + str(light.getSpecColor().getX()) + "," + str(light.getSpecColor().getY()) + "," + str(light.getSpecColor().getZ()) + "," + str(light.getSpecColor().getW()) + "))\n") out_file.write (i2+ "self.lightAttrib=self.lightAttrib.addLight(alight)\n") - out_file.write (i2+ "self."+light.getName()+ "= render.attachNewNode(alight.upcastToPandaNode())\n") + out_file.write (i2+ "self."+light.getName()+ "= render.attachNewNode(alight)\n") out_file.write (i2+ "self."+light.getName()+ ".setPos(Point3(" + str(light.getX()) + "," + str(light.getY()) + "," + str(light.getZ()) + "))\n") out_file.write (i2+ "self."+light.getName()+ ".setHpr(Vec3("+ str(light.getH())+ "," + str(light.getP())+ "," + str(light.getR()) + "))\n") out_file.write (i2+ "self."+light.getName()+ ".setTag(\"Metadata\",\"" + light.getTag("Metadata") + "\")\n") @@ -521,7 +521,7 @@ class FileSaver: out_file.write (i2+ "alight.setSpecularColor(Vec4(" + str(light.getSpecColor().getX()) + "," + str(light.getSpecColor().getY()) + "," + str(light.getSpecColor().getZ()) + "," + str(light.getSpecColor().getW()) + "))\n") out_file.write (i2+ "alight.setAttenuation(Vec3("+ str(light.getAttenuation().getX()) + "," + str(light.getAttenuation().getY()) + "," + str(light.getAttenuation().getZ()) + "))\n") out_file.write (i2+ "self.lightAttrib=self.lightAttrib.addLight(alight)\n") - out_file.write (i2+ "self."+light.getName()+ "= render.attachNewNode(alight.upcastToPandaNode())\n") + out_file.write (i2+ "self."+light.getName()+ "= render.attachNewNode(alight)\n") out_file.write (i2+ "self."+light.getName()+ ".setTag(\"Metadata\",\"" + light.getTag("Metadata") + "\")\n") out_file.write (i2+ "self."+light.getName()+ ".setPos(Point3(" + str(light.getX()) + "," + str(light.getY()) + "," + str(light.getZ()) + "))\n") out_file.write (i2+ "self.LightDict[\'" + light.getName() + "\']=alight\n") @@ -539,7 +539,7 @@ class FileSaver: out_file.write (i2+ "alight.setAttenuation(Vec3("+ str(light.getAttenuation().getX()) + "," + str(light.getAttenuation().getY()) + "," + str(light.getAttenuation().getZ()) + "))\n") out_file.write (i2+ "alight.setExponent(" +str(light.getExponent()) +")\n") out_file.write (i2+ "self.lightAttrib=self.lightAttrib.addLight(alight)\n") - out_file.write (i2+ "self."+light.getName()+ "= render.attachNewNode(alight.upcastToLensNode())\n") + out_file.write (i2+ "self."+light.getName()+ "= render.attachNewNode(alight)\n") out_file.write (i2+ "self."+light.getName()+ ".setTag(\"Metadata\",\"" + light.getTag("Metadata") + "\")\n") out_file.write (i2+ "self."+light.getName()+ ".setPos(Point3(" + str(light.getX()) + "," + str(light.getY()) + "," + str(light.getZ()) + "))\n") out_file.write (i2+ "self."+light.getName()+ ".setHpr(Vec3("+ str(light.getH())+ "," + str(light.getP())+ "," + str(light.getR()) + "))\n") diff --git a/contrib/src/sceneeditor/seLights.py b/contrib/src/sceneeditor/seLights.py index 1a42e9045a..ccc58ce0cd 100644 --- a/contrib/src/sceneeditor/seLights.py +++ b/contrib/src/sceneeditor/seLights.py @@ -63,13 +63,8 @@ class seLight(NodePath): self.lence = lence self.active = True - if isinstance(light, Spotlight): - node = light.upcastToLensNode() - else: - node = light.upcastToPandaNode() - # Attach node to self - self.LightNode=parent.attachNewNode(node) + self.LightNode=parent.attachNewNode(light) self.LightNode.setTag("Metadata",tag) if(self.type=='spot'): self.LightNode.setHpr(self.orientation) @@ -418,8 +413,6 @@ class seLightManager(NodePath): ################################################################# type = lower(light.getType().getName()) - light.upcastToNamable() - specularColor = VBase4(1) position = Point3(0,0,0) orientation = Vec3(1,0,0) diff --git a/direct/src/showbase/ShadowDemo.py b/direct/src/showbase/ShadowDemo.py index daadd58c11..efcc491e71 100755 --- a/direct/src/showbase/ShadowDemo.py +++ b/direct/src/showbase/ShadowDemo.py @@ -201,13 +201,13 @@ def arbitraryShadow(node): ##b.reparentTo((base.localAvatar)) ##a = AmbientLight('cloudAmbientHi') ##a.setColor(Vec4(0.9, 0.9, 0.9, 1.000)) -##aNP = s.attachNewNode(a.upcastToPandaNode()) +##aNP = s.attachNewNode(a) ##b.setLight(aNP) ##d = DirectionalLight("chernabogDirectionalLight") ##d.setDirection(Vec3(0, 1, 0)) ##d.setColor(Vec4(1)) ###d.setColor(Vec4(0.9, 0.7, 0.7, 1.000)) -##dNP = s.attachNewNode(d.upcastToPandaNode()) +##dNP = s.attachNewNode(d) ##b.setLight(dNP) ## ##ival = Sequence(LerpPosInterval(bs.lightPath, 0.0, Vec3(-200, 0, 50)), diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 42ee315909..367ae57d1a 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -1553,8 +1553,7 @@ class ShowBase(DirectObject.DirectObject): # mouse activity. mw = self.buttonThrowers[0].getParent() mouseRecorder = MouseRecorder('mouse') - self.recorder.addRecorder( - 'mouse', mouseRecorder.upcastToRecorderBase()) + self.recorder.addRecorder('mouse', mouseRecorder) np = mw.getParent().attachNewNode(mouseRecorder) mw.reparentTo(np) From 2450f31ef541772613459733c66eab37d93a73e8 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 27 Feb 2018 15:06:12 +0100 Subject: [PATCH 053/247] interrogate: remove deprecated and unneeded downcastTo*() functions They have not been needed for a very long time, and they create an awkward reverse dependency of base classes on derived classes. --- dtool/src/interrogate/interfaceMakerPythonNative.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 3a861a4844..96420ef663 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -3500,6 +3500,10 @@ write_function_for_name(ostream &out, Object *obj, out << " */\n"; + if (has_this && obj == nullptr) { + assert(obj != nullptr); + } + out << function_name << " {\n"; if (has_this) { @@ -7007,7 +7011,7 @@ record_object(TypeIndex type_index) { object->_methods.push_back(function); } } - if (itype.derivation_has_downcast(di)) { + /*if (itype.derivation_has_downcast(di)) { // Downcasts are methods of the base class, not the child class. TypeIndex base_type_index = itype.get_derivation(di); @@ -7020,7 +7024,7 @@ record_object(TypeIndex type_index) { pobject->_methods.push_back(function); } } - } + }*/ } } From fa231664bd34a13c9f2de1621331e832fb757d40 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 27 Feb 2018 18:47:51 +0100 Subject: [PATCH 054/247] interrogate: don't mark base types as global --- dtool/src/interrogate/interrogateBuilder.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dtool/src/interrogate/interrogateBuilder.cxx b/dtool/src/interrogate/interrogateBuilder.cxx index 6cbf8f02c0..63d579c68f 100644 --- a/dtool/src/interrogate/interrogateBuilder.cxx +++ b/dtool/src/interrogate/interrogateBuilder.cxx @@ -2603,7 +2603,7 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, const CPPStructType::Base &base = (*bi); if (base._vis <= V_public) { CPPType *base_type = TypeManager::resolve_type(base._base, scope); - TypeIndex base_index = get_type(base_type, true); + TypeIndex base_index = get_type(base_type, false); if (base_index == 0) { if (base_type != NULL) { From 162b86c6d9430b027499bfbb43767cca05ff4b6e Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 27 Feb 2018 19:33:18 +0100 Subject: [PATCH 055/247] interrogatedb: fix library name setting for typedefs Typedefs are evidently always considered "fully defined", so we need to add another condition to the database merging code to prefer the type that is marked "global" when merging two types. --- dtool/src/interrogatedb/interrogateType.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dtool/src/interrogatedb/interrogateType.cxx b/dtool/src/interrogatedb/interrogateType.cxx index a977ff987a..a6d6e45487 100644 --- a/dtool/src/interrogatedb/interrogateType.cxx +++ b/dtool/src/interrogatedb/interrogateType.cxx @@ -112,14 +112,16 @@ operator = (const InterrogateType ©) { /** * Combines type with the other similar definition. If one type is "fully - * defined" and the other one isn't, the fully-defined type wins. + * defined" and the other one isn't, the fully-defined type wins. If both + * types are fully defined, whichever type is marked "global" wins. */ void InterrogateType:: merge_with(const InterrogateType &other) { // The only thing we care about copying from the non-fully-defined type // right now is the global flag. - if (is_fully_defined()) { + if (is_fully_defined() && + (!other.is_fully_defined() || (other._flags & F_global) == 0)) { // We win. _flags |= (other._flags & F_global); From bdb575e7668dba5d5e802b07c212edcca9f2244a Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 27 Feb 2018 19:44:14 +0100 Subject: [PATCH 056/247] interrogatedb: add interrogate_type_is_global (+regenerate pydtool) --- dtool/metalibs/dtoolconfig/pydtool.cxx | 76 ++++++++++++++++++- .../interrogatedb/interrogate_interface.cxx | 6 ++ .../src/interrogatedb/interrogate_interface.h | 1 + 3 files changed, 81 insertions(+), 2 deletions(-) diff --git a/dtool/metalibs/dtoolconfig/pydtool.cxx b/dtool/metalibs/dtoolconfig/pydtool.cxx index d43ca96f9a..b83fb05e11 100644 --- a/dtool/metalibs/dtoolconfig/pydtool.cxx +++ b/dtool/metalibs/dtoolconfig/pydtool.cxx @@ -1,6 +1,6 @@ /* * This file was generated by: - * interrogate -D EXPCL_DTOOLCONFIG= -nodb -python -promiscuous -I/home/rdb/panda3d-git/built/include -module panda3d.interrogatedb -library interrogatedb -string -true-names -do-module -oc pydtool.cxx ../../src/interrogatedb/interrogate_interface.h ../../src/interrogatedb/interrogate_request.h + * interrogate -D EXPCL_DTOOLCONFIG= -nodb -python -promiscuous -I../../../built/include -module panda3d.interrogatedb -library interrogatedb -string -true-names -do-module -oc pydtool.cxx ../../src/interrogatedb/interrogate_interface.h ../../src/interrogatedb/interrogate_request.h * */ @@ -15,7 +15,7 @@ #define PY_SSIZE_T_CLEAN 1 #if PYTHON_FRAMEWORK - #include "Python/Python.h" + #include #else #include "Python.h" #endif @@ -85,6 +85,9 @@ static PyObject *_inP07ytsqGH(PyObject *self, PyObject *args); static PyObject *_inP07yt7shV(PyObject *self, PyObject *args); static PyObject *_inP07ytA1eF(PyObject *self, PyObject *args); static PyObject *_inP07yt776V(PyObject *self, PyObject *args); +static PyObject *_inP07ytryup(PyObject *self, PyObject *args); +static PyObject *_inP07ytiytI(PyObject *self, PyObject *args); +static PyObject *_inP07ytZc07(PyObject *self, PyObject *args); static PyObject *_inP07ytfaH0(PyObject *self, PyObject *args); static PyObject *_inP07ytGB9D(PyObject *self, PyObject *args); static PyObject *_inP07ytsxxs(PyObject *self, PyObject *args); @@ -94,6 +97,7 @@ static PyObject *_inP07yt4Px8(PyObject *self, PyObject *args); static PyObject *_inP07ytNHcs(PyObject *self, PyObject *args); static PyObject *_inP07ytqHrb(PyObject *self, PyObject *args); static PyObject *_inP07ytaOqq(PyObject *self, PyObject *args); +static PyObject *_inP07ytpTBb(PyObject *self, PyObject *args); static PyObject *_inP07ytqWOw(PyObject *self, PyObject *args); static PyObject *_inP07ytHu7x(PyObject *self, PyObject *args); static PyObject *_inP07ytwGnA(PyObject *self, PyObject *args); @@ -1237,6 +1241,56 @@ _inP07yt776V(PyObject *, PyObject *args) { return (PyObject *)NULL; } +/* + * Python simple wrapper for + * char const *interrogate_make_seq_scoped_name(MakeSeqIndex make_seq) + */ +static PyObject * +_inP07ytryup(PyObject *, PyObject *args) { + int param0; + if (PyArg_ParseTuple(args, "i", ¶m0)) { + char const *return_value = interrogate_make_seq_scoped_name((MakeSeqIndex)param0); +#if PY_MAJOR_VERSION >= 3 + return PyUnicode_FromString(return_value); +#else + return PyString_FromString(return_value); +#endif + } + return (PyObject *)NULL; +} + +/* + * Python simple wrapper for + * bool interrogate_make_seq_has_comment(ElementIndex element) + */ +static PyObject * +_inP07ytiytI(PyObject *, PyObject *args) { + int param0; + if (PyArg_ParseTuple(args, "i", ¶m0)) { + bool return_value = interrogate_make_seq_has_comment((ElementIndex)param0); + return PyBool_FromLong(return_value); + } + return (PyObject *)NULL; +} + +/* + * Python simple wrapper for + * char const *interrogate_make_seq_comment(ElementIndex element) + */ +static PyObject * +_inP07ytZc07(PyObject *, PyObject *args) { + int param0; + if (PyArg_ParseTuple(args, "i", ¶m0)) { + char const *return_value = interrogate_make_seq_comment((ElementIndex)param0); +#if PY_MAJOR_VERSION >= 3 + return PyUnicode_FromString(return_value); +#else + return PyString_FromString(return_value); +#endif + } + return (PyObject *)NULL; +} + /* * Python simple wrapper for * char const *interrogate_make_seq_num_name(MakeSeqIndex make_seq) @@ -1397,6 +1451,20 @@ _inP07ytaOqq(PyObject *, PyObject *args) { return (PyObject *)NULL; } +/* + * Python simple wrapper for + * bool interrogate_type_is_global(TypeIndex type) + */ +static PyObject * +_inP07ytpTBb(PyObject *, PyObject *args) { + int param0; + if (PyArg_ParseTuple(args, "i", ¶m0)) { + bool return_value = interrogate_type_is_global((TypeIndex)param0); + return PyBool_FromLong(return_value); + } + return (PyObject *)NULL; +} + /* * Python simple wrapper for * char const *interrogate_type_name(TypeIndex type) @@ -2416,6 +2484,9 @@ static PyMethodDef python_simple_funcs[] = { { "interrogate_wrapper_unique_name", &_inP07yt7shV, METH_VARARGS }, { "interrogate_get_wrapper_by_unique_name", &_inP07ytA1eF, METH_VARARGS }, { "interrogate_make_seq_seq_name", &_inP07yt776V, METH_VARARGS }, + { "interrogate_make_seq_scoped_name", &_inP07ytryup, METH_VARARGS }, + { "interrogate_make_seq_has_comment", &_inP07ytiytI, METH_VARARGS }, + { "interrogate_make_seq_comment", &_inP07ytZc07, METH_VARARGS }, { "interrogate_make_seq_num_name", &_inP07ytfaH0, METH_VARARGS }, { "interrogate_make_seq_element_name", &_inP07ytGB9D, METH_VARARGS }, { "interrogate_number_of_global_types", &_inP07ytsxxs, METH_VARARGS }, @@ -2425,6 +2496,7 @@ static PyMethodDef python_simple_funcs[] = { { "interrogate_get_type_by_name", &_inP07ytNHcs, METH_VARARGS }, { "interrogate_get_type_by_scoped_name", &_inP07ytqHrb, METH_VARARGS }, { "interrogate_get_type_by_true_name", &_inP07ytaOqq, METH_VARARGS }, + { "interrogate_type_is_global", &_inP07ytpTBb, METH_VARARGS }, { "interrogate_type_name", &_inP07ytqWOw, METH_VARARGS }, { "interrogate_type_scoped_name", &_inP07ytHu7x, METH_VARARGS }, { "interrogate_type_true_name", &_inP07ytwGnA, METH_VARARGS }, diff --git a/dtool/src/interrogatedb/interrogate_interface.cxx b/dtool/src/interrogatedb/interrogate_interface.cxx index bd5493fc39..6e948134d3 100644 --- a/dtool/src/interrogatedb/interrogate_interface.cxx +++ b/dtool/src/interrogatedb/interrogate_interface.cxx @@ -509,6 +509,12 @@ interrogate_get_type_by_true_name(const char *type_name) { return InterrogateDatabase::get_ptr()->lookup_type_by_true_name(type_name); } +bool +interrogate_type_is_global(TypeIndex type) { + // cerr << "interrogate_type_is_global(" << type << ")\n"; + return InterrogateDatabase::get_ptr()->get_type(type).is_global(); +} + const char * interrogate_type_name(TypeIndex type) { // cerr << "interrogate_type_name(" << type << ")\n"; diff --git a/dtool/src/interrogatedb/interrogate_interface.h b/dtool/src/interrogatedb/interrogate_interface.h index 63e385d527..6c434d7833 100644 --- a/dtool/src/interrogatedb/interrogate_interface.h +++ b/dtool/src/interrogatedb/interrogate_interface.h @@ -367,6 +367,7 @@ EXPCL_INTERROGATEDB TypeIndex interrogate_get_type(int n); EXPCL_INTERROGATEDB TypeIndex interrogate_get_type_by_name(const char *type_name); EXPCL_INTERROGATEDB TypeIndex interrogate_get_type_by_scoped_name(const char *type_name); EXPCL_INTERROGATEDB TypeIndex interrogate_get_type_by_true_name(const char *type_name); +EXPCL_INTERROGATEDB bool interrogate_type_is_global(TypeIndex type); EXPCL_INTERROGATEDB const char *interrogate_type_name(TypeIndex type); EXPCL_INTERROGATEDB const char *interrogate_type_scoped_name(TypeIndex type); EXPCL_INTERROGATEDB const char *interrogate_type_true_name(TypeIndex type); From 8b6616814d52e305c7b9ae26aab1c071a0c9b6a6 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 27 Feb 2018 20:20:20 +0100 Subject: [PATCH 057/247] interrogate_module: warn about circular dependencies between classes This will help us catch cases wherein we inadvertently create a circular dependency between component libraries. Right now it only checks inheritance and typedefs, but this can be expanded in the future. Also, sorts the module initialization by dependency topology. This isn't very important right now, but having this guarantee might help when refactoring module initialization in the future. --- dtool/src/interrogate/interrogate_module.cxx | 174 ++++++++++++++++++- 1 file changed, 168 insertions(+), 6 deletions(-) diff --git a/dtool/src/interrogate/interrogate_module.cxx b/dtool/src/interrogate/interrogate_module.cxx index 5feae341b7..8c843e9da1 100644 --- a/dtool/src/interrogate/interrogate_module.cxx +++ b/dtool/src/interrogate/interrogate_module.cxx @@ -76,6 +76,79 @@ upcase_string(const string &str) { } */ +/** + * Finds a dependency cycle between the given dependency mapping, starting at + * the node that is already placed in the given cycle vector. + */ +static bool find_dependency_cycle(vector_string &cycle, map > &dependencies) { + assert(!cycle.empty()); + + const set &deps = dependencies[cycle.back()]; + for (auto it = deps.begin(); it != deps.end(); ++it) { + auto it2 = std::find(cycle.begin(), cycle.end(), *it); + if (it2 != cycle.end()) { + // Chop off the part of the chain that is not relevant. + cycle.erase(cycle.begin(), it2); + cycle.push_back(*it); + return true; + } + + // Recurse. + cycle.push_back(*it); + if (find_dependency_cycle(cycle, dependencies)) { + return true; + } + cycle.pop_back(); + } + + return false; +} + +/** + * Given that a direct link has been established between the two libraries, + * finds the two types that make up this relationship and prints out the + * nature of their dependency. + */ +static bool print_dependent_types(const string &lib1, const string &lib2) { + for (int ti = 0; ti < interrogate_number_of_global_types(); ti++) { + TypeIndex thetype = interrogate_get_global_type(ti); + if (interrogate_type_has_module_name(thetype) && + interrogate_type_has_library_name(thetype) && + lib1 == interrogate_type_library_name(thetype) && + module_name == interrogate_type_module_name(thetype)) { + + // Get the dependencies for this library. + int num_derivations = interrogate_type_number_of_derivations(thetype); + for (int di = 0; di < num_derivations; ++di) { + TypeIndex basetype = interrogate_type_get_derivation(thetype, di); + if (interrogate_type_is_global(basetype) && + interrogate_type_has_library_name(basetype) && + interrogate_type_library_name(basetype) == lib2) { + cerr + << " " << interrogate_type_scoped_name(thetype) << " (" + << lib1 << ") inherits from " + << interrogate_type_scoped_name(basetype) << " (" << lib2 << ")\n"; + return true; + } + } + + // It also counts if this is a typedef pointing to another type. + if (interrogate_type_is_typedef(thetype)) { + TypeIndex wrapped = interrogate_type_wrapped_type(thetype); + if (interrogate_type_is_global(wrapped) && + interrogate_type_has_library_name(wrapped) && + interrogate_type_library_name(wrapped) == lib2) { + cerr + << " " << interrogate_type_scoped_name(thetype) << " (" + << lib1 << ") is a typedef to " + << interrogate_type_scoped_name(wrapped) << " (" << lib2 << ")\n"; + } + } + } + } + return false; +} + int write_python_table_native(ostream &out) { out << "\n#include \"dtoolbase.h\"\n" << "#include \"interrogate_request.h\"\n\n" @@ -83,7 +156,7 @@ int write_python_table_native(ostream &out) { int count = 0; - vector_string libraries; + map > dependencies; // out << "extern \"C\" {\n"; @@ -99,23 +172,112 @@ int write_python_table_native(ostream &out) { // name add it to set of libraries if (interrogate_function_has_library_name(function_index)) { string library_name = interrogate_function_library_name(function_index); - if (std::find(libraries.begin(), libraries.end(), library_name) == libraries.end()) { - libraries.push_back(library_name); - } + dependencies[library_name]; } // } } - for (int ti = 0; ti < interrogate_number_of_types(); ti++) { - TypeIndex thetype = interrogate_get_type(ti); + for (int ti = 0; ti < interrogate_number_of_global_types(); ti++) { + TypeIndex thetype = interrogate_get_global_type(ti); if (interrogate_type_has_module_name(thetype) && module_name == interrogate_type_module_name(thetype)) { if (interrogate_type_has_library_name(thetype)) { string library_name = interrogate_type_library_name(thetype); + set &deps = dependencies[library_name]; + + // Get the dependencies for this library. + int num_derivations = interrogate_type_number_of_derivations(thetype); + for (int di = 0; di < num_derivations; ++di) { + TypeIndex basetype = interrogate_type_get_derivation(thetype, di); + if (interrogate_type_is_global(basetype) && + interrogate_type_has_library_name(basetype)) { + string baselib = interrogate_type_library_name(basetype); + if (baselib != library_name) { + deps.insert(move(baselib)); + } + } + } + + if (interrogate_type_is_typedef(thetype)) { + TypeIndex wrapped = interrogate_type_wrapped_type(thetype); + if (interrogate_type_is_global(wrapped) && + interrogate_type_has_library_name(wrapped)) { + string wrappedlib = interrogate_type_library_name(wrapped); + if (wrappedlib != library_name) { + deps.insert(move(wrappedlib)); + } + } + } + } + } + } + + // Now add the libraries in their proper ordering, based on dependencies. + vector_string libraries; + while (libraries.size() < dependencies.size()) { + // We have this check to make sure we don't enter an infinite loop. + bool added_any = false; + + for (auto it = dependencies.begin(); it != dependencies.end(); ++it) { + const string &library_name = it->first; + set &deps = dependencies[library_name]; + + // Remove the dependencies that have already been added from the deps. + if (!deps.empty()) { + for (auto li = libraries.begin(); li != libraries.end(); ++li) { + deps.erase(*li); + } + } + + if (deps.empty()) { + // OK, no remaining dependencies, so we can add this. if (std::find(libraries.begin(), libraries.end(), library_name) == libraries.end()) { libraries.push_back(library_name); + added_any = true; } } } + + if (!added_any) { + // Oh dear, we must have hit a circular dependency. Go through the + // remaining libraries to figure it out and print it. + cerr << "Circular dependency between libraries detected:\n"; + for (auto it = dependencies.begin(); it != dependencies.end(); ++it) { + const string &library_name = it->first; + set &deps = dependencies[library_name]; + if (deps.empty()) { + continue; + } + + // But since it does indicate a potential architectural flaw, we do + // want to let the user know about this. + vector_string cycle; + cycle.push_back(library_name); + if (!find_dependency_cycle(cycle, dependencies)) { + continue; + } + assert(cycle.size() >= 2); + + // Show the cycle of library dependencies. + auto ci = cycle.begin(); + cerr << " " << *ci; + for (++ci; ci != cycle.end(); ++ci) { + cerr << " -> " << *ci; + } + cerr << "\n"; + + // Now print out the actual types that make up the cycle. + ci = cycle.begin(); + string prev = *ci; + for (++ci; ci != cycle.end(); ++ci) { + print_dependent_types(prev, *ci); + prev = *ci; + } + + // We have to arbitrarily break one of the dependencies in order to be + // able to proceed. Break the first dependency. + dependencies[cycle[0]].erase(cycle[1]); + } + } } vector_string::const_iterator ii; From 361d36380d74306dcbea12f63403f19d1ff63215 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 27 Feb 2018 20:36:53 +0100 Subject: [PATCH 058/247] makepanda: don't put pview metadata in rpm when building without pview Fixes: #260 --- makepanda/makepanda.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 21c0181159..7a8926efd6 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -6937,16 +6937,19 @@ This package contains the SDK for development with Panda3D, install panda3d-runt /etc/Confauto.prc /etc/Config.prc /usr/share/panda3d -/usr/share/mime-info/panda3d.mime -/usr/share/mime-info/panda3d.keys -/usr/share/mime/packages/panda3d.xml -/usr/share/application-registry/panda3d.applications -/usr/share/applications/*.desktop /etc/ld.so.conf.d/panda3d.conf /usr/%_lib/panda3d """ + PYTHON_SITEPACKAGES + """ /usr/include/panda3d """ +if not PkgSkip("PVIEW"): + INSTALLER_SPEC_FILE += \ +"""/usr/share/applications/pview.desktop +/usr/share/mime-info/panda3d.mime +/usr/share/mime-info/panda3d.keys +/usr/share/mime/packages/panda3d.xml +/usr/share/application-registry/panda3d.applications +""" RUNTIME_INSTALLER_SPEC_FILE=""" Summary: Runtime binary and browser plugin for the Panda3D Game Engine From 9638eb47eb929eb3346eca6b447e2da6187974c0 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 1 Mar 2018 21:14:12 +0100 Subject: [PATCH 059/247] Add support for geometry with adjacency information Example code: https://gist.github.com/rdb/7cebb8941b962c59d5a092048efb3855 --- panda/src/display/graphicsStateGuardian.cxx | 33 ++ panda/src/display/graphicsStateGuardian.h | 8 + .../glstuff/glGraphicsStateGuardian_src.cxx | 361 ++++++++++++++++++ .../src/glstuff/glGraphicsStateGuardian_src.h | 16 + panda/src/gobj/config_gobj.cxx | 12 + panda/src/gobj/geom.I | 11 + panda/src/gobj/geom.cxx | 36 ++ panda/src/gobj/geom.h | 2 + panda/src/gobj/geomEnums.h | 3 + panda/src/gobj/geomLines.cxx | 62 +++ panda/src/gobj/geomLines.h | 2 + panda/src/gobj/geomLinesAdjacency.cxx | 132 +++++++ panda/src/gobj/geomLinesAdjacency.h | 70 ++++ panda/src/gobj/geomLinestrips.cxx | 81 ++++ panda/src/gobj/geomLinestrips.h | 3 + panda/src/gobj/geomLinestripsAdjacency.cxx | 210 ++++++++++ panda/src/gobj/geomLinestripsAdjacency.h | 75 ++++ panda/src/gobj/geomPrimitive.cxx | 9 + panda/src/gobj/geomPrimitive.h | 1 + panda/src/gobj/geomTriangles.cxx | 71 ++++ panda/src/gobj/geomTriangles.h | 2 + panda/src/gobj/geomTrianglesAdjacency.cxx | 195 ++++++++++ panda/src/gobj/geomTrianglesAdjacency.h | 72 ++++ panda/src/gobj/geomTristrips.cxx | 138 +++++++ panda/src/gobj/geomTristrips.h | 3 + panda/src/gobj/geomTristripsAdjacency.cxx | 161 ++++++++ panda/src/gobj/geomTristripsAdjacency.h | 73 ++++ panda/src/gobj/p3gobj_composite1.cxx | 4 + panda/src/gsgbase/graphicsStateGuardianBase.h | 4 + tests/gobj/test_geom_primitives.py | 83 ++++ 30 files changed, 1933 insertions(+) create mode 100644 panda/src/gobj/geomLinesAdjacency.cxx create mode 100644 panda/src/gobj/geomLinesAdjacency.h create mode 100644 panda/src/gobj/geomLinestripsAdjacency.cxx create mode 100644 panda/src/gobj/geomLinestripsAdjacency.h create mode 100644 panda/src/gobj/geomTrianglesAdjacency.cxx create mode 100644 panda/src/gobj/geomTrianglesAdjacency.h create mode 100644 panda/src/gobj/geomTristripsAdjacency.cxx create mode 100644 panda/src/gobj/geomTristripsAdjacency.h create mode 100644 tests/gobj/test_geom_primitives.py diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index d590aa8d37..5817b62e4a 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -2381,6 +2381,15 @@ draw_triangles(const GeomPrimitivePipelineReader *, bool) { return false; } + +/** + * Draws a series of disconnected triangles with adjacency information. + */ +bool GraphicsStateGuardian:: +draw_triangles_adj(const GeomPrimitivePipelineReader *, bool) { + return false; +} + /** * Draws a series of triangle strips. */ @@ -2389,6 +2398,14 @@ draw_tristrips(const GeomPrimitivePipelineReader *, bool) { return false; } +/** + * Draws a series of triangle strips with adjacency information. + */ +bool GraphicsStateGuardian:: +draw_tristrips_adj(const GeomPrimitivePipelineReader *, bool) { + return false; +} + /** * Draws a series of triangle fans. */ @@ -2414,6 +2431,14 @@ draw_lines(const GeomPrimitivePipelineReader *, bool) { return false; } +/** + * Draws a series of disconnected line segments with adjacency information. + */ +bool GraphicsStateGuardian:: +draw_lines_adj(const GeomPrimitivePipelineReader *, bool) { + return false; +} + /** * Draws a series of line strips. */ @@ -2422,6 +2447,14 @@ draw_linestrips(const GeomPrimitivePipelineReader *, bool) { return false; } +/** + * Draws a series of line strips with adjacency information. + */ +bool GraphicsStateGuardian:: +draw_linestrips_adj(const GeomPrimitivePipelineReader *, bool) { + return false; +} + /** * Draws a series of disconnected points. */ diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index 9b7855dc31..e508be9c6a 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -371,16 +371,24 @@ public: bool force); virtual bool draw_triangles(const GeomPrimitivePipelineReader *reader, bool force); + virtual bool draw_triangles_adj(const GeomPrimitivePipelineReader *reader, + bool force); virtual bool draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force); + virtual bool draw_tristrips_adj(const GeomPrimitivePipelineReader *reader, + bool force); virtual bool draw_trifans(const GeomPrimitivePipelineReader *reader, bool force); virtual bool draw_patches(const GeomPrimitivePipelineReader *reader, bool force); virtual bool draw_lines(const GeomPrimitivePipelineReader *reader, bool force); + virtual bool draw_lines_adj(const GeomPrimitivePipelineReader *reader, + bool force); virtual bool draw_linestrips(const GeomPrimitivePipelineReader *reader, bool force); + virtual bool draw_linestrips_adj(const GeomPrimitivePipelineReader *reader, + bool force); virtual bool draw_points(const GeomPrimitivePipelineReader *reader, bool force); virtual void end_draw_primitives(); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index af84e2bafd..97917acee0 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -653,6 +653,12 @@ reset() { Geom::GR_line_strip | Geom::GR_flat_last_vertex; +#ifndef OPENGLES + if (_supports_geometry_shaders) { + _supported_geom_rendering |= Geom::GR_adjacency; + } +#endif + _supports_point_parameters = false; #ifdef OPENGLES_1 @@ -4543,6 +4549,68 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { return true; } +/** + * Draws a series of disconnected triangles with adjacency information. + */ +#ifndef OPENGLES +bool CLP(GraphicsStateGuardian):: +draw_triangles_adj(const GeomPrimitivePipelineReader *reader, bool force) { + // PStatGPUTimer timer(this, _draw_primitive_pcollector, + // reader->get_current_thread()); + +#ifndef NDEBUG + if (GLCAT.is_spam()) { + GLCAT.spam() << "draw_triangles_adj: " << *(reader->get_object()) << "\n"; + } +#endif // NDEBUG + +#ifdef SUPPORT_IMMEDIATE_MODE + if (_use_sender) { + draw_immediate_simple_primitives(reader, GL_TRIANGLES_ADJACENCY); + + } else +#endif // SUPPORT_IMMEDIATE_MODE + { + int num_vertices = reader->get_num_vertices(); + _vertices_tri_pcollector.add_level(num_vertices); + _primitive_batches_tri_pcollector.add_level(1); + + if (reader->is_indexed()) { + const unsigned char *client_pointer; + if (!setup_primitive(client_pointer, reader, force)) { + return false; + } + + if (_supports_geometry_instancing && _instance_count > 0) { + _glDrawElementsInstanced(GL_TRIANGLES_ADJACENCY, num_vertices, + get_numeric_type(reader->get_index_type()), + client_pointer, _instance_count); + } else { + _glDrawRangeElements(GL_TRIANGLES_ADJACENCY, + reader->get_min_vertex(), + reader->get_max_vertex(), + num_vertices, + get_numeric_type(reader->get_index_type()), + client_pointer); + } + } else { + if (_supports_geometry_instancing && _instance_count > 0) { + _glDrawArraysInstanced(GL_TRIANGLES_ADJACENCY, + reader->get_first_vertex(), + num_vertices, _instance_count); + } else { + glDrawArrays(GL_TRIANGLES_ADJACENCY, + reader->get_first_vertex(), + num_vertices); + } + } + } + + report_my_gl_errors(); + return true; +} +#endif // OPENGLES + /** * Draws a series of triangle strips. */ @@ -4669,6 +4737,128 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { return true; } +/** + * Draws a series of triangle strips with adjacency information. + */ +#ifndef OPENGLES +bool CLP(GraphicsStateGuardian):: +draw_tristrips_adj(const GeomPrimitivePipelineReader *reader, bool force) { + // PStatGPUTimer timer(this, _draw_primitive_pcollector, + // reader->get_current_thread()); + + report_my_gl_errors(); + +#ifndef NDEBUG + if (GLCAT.is_spam()) { + GLCAT.spam() << "draw_tristrips_adj: " << *(reader->get_object()) << "\n"; + } +#endif // NDEBUG + +#ifdef SUPPORT_IMMEDIATE_MODE + if (_use_sender) { + draw_immediate_composite_primitives(reader, GL_TRIANGLE_STRIP_ADJACENCY); + + } else +#endif // SUPPORT_IMMEDIATE_MODE + { + if (reader->is_indexed() && + (_supported_geom_rendering & GeomEnums::GR_strip_cut_index) != 0) { + // One long line strip, connected by strip cut indices. + if (_explicit_primitive_restart) { + glEnable(GL_PRIMITIVE_RESTART); + _glPrimitiveRestartIndex(reader->get_strip_cut_index()); + } + int num_vertices = reader->get_num_vertices(); + _vertices_tristrip_pcollector.add_level(num_vertices); + _primitive_batches_tristrip_pcollector.add_level(1); + if (reader->is_indexed()) { + const unsigned char *client_pointer; + if (!setup_primitive(client_pointer, reader, force)) { + return false; + } + if (_supports_geometry_instancing && _instance_count > 0) { + _glDrawElementsInstanced(GL_TRIANGLE_STRIP_ADJACENCY, num_vertices, + get_numeric_type(reader->get_index_type()), + client_pointer, _instance_count); + } else { + _glDrawRangeElements(GL_TRIANGLE_STRIP_ADJACENCY, + reader->get_min_vertex(), + reader->get_max_vertex(), + num_vertices, + get_numeric_type(reader->get_index_type()), + client_pointer); + } + } else { + if (_supports_geometry_instancing && _instance_count > 0) { + _glDrawArraysInstanced(GL_TRIANGLE_STRIP_ADJACENCY, + reader->get_first_vertex(), + num_vertices, _instance_count); + } else { + glDrawArrays(GL_TRIANGLE_STRIP_ADJACENCY, + reader->get_first_vertex(), + num_vertices); + } + } + if (_explicit_primitive_restart) { + glDisable(GL_PRIMITIVE_RESTART); + } + } else { + // Send the individual triangle strips, stepping over the degenerate + // vertices. + CPTA_int ends = reader->get_ends(); + + _primitive_batches_tristrip_pcollector.add_level(ends.size()); + if (reader->is_indexed()) { + const unsigned char *client_pointer; + if (!setup_primitive(client_pointer, reader, force)) { + return false; + } + int index_stride = reader->get_index_stride(); + GeomVertexReader mins(reader->get_mins(), 0); + GeomVertexReader maxs(reader->get_maxs(), 0); + nassertr(reader->get_mins()->get_num_rows() == (int)ends.size() && + reader->get_maxs()->get_num_rows() == (int)ends.size(), false); + + unsigned int start = 0; + for (size_t i = 0; i < ends.size(); i++) { + _vertices_tristrip_pcollector.add_level(ends[i] - start); + if (_supports_geometry_instancing && _instance_count > 0) { + _glDrawElementsInstanced(GL_TRIANGLE_STRIP_ADJACENCY, ends[i] - start, + get_numeric_type(reader->get_index_type()), + client_pointer + start * index_stride, + _instance_count); + } else { + _glDrawRangeElements(GL_TRIANGLE_STRIP_ADJACENCY, + mins.get_data1i(), maxs.get_data1i(), + ends[i] - start, + get_numeric_type(reader->get_index_type()), + client_pointer + start * index_stride); + } + start = ends[i] + 1; + } + } else { + unsigned int start = 0; + int first_vertex = reader->get_first_vertex(); + for (size_t i = 0; i < ends.size(); i++) { + _vertices_tristrip_pcollector.add_level(ends[i] - start); + if (_supports_geometry_instancing && _instance_count > 0) { + _glDrawArraysInstanced(GL_TRIANGLE_STRIP_ADJACENCY, first_vertex + start, + ends[i] - start, _instance_count); + } else { + glDrawArrays(GL_TRIANGLE_STRIP_ADJACENCY, first_vertex + start, + ends[i] - start); + } + start = ends[i] + 1; + } + } + } + } + + report_my_gl_errors(); + return true; +} +#endif // OPENGLES + /** * Draws a series of triangle fans. */ @@ -4888,6 +5078,66 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { return true; } +/** + * Draws a series of disconnected line segments with adjacency information. + */ +#ifndef OPENGLES +bool CLP(GraphicsStateGuardian):: +draw_lines_adj(const GeomPrimitivePipelineReader *reader, bool force) { + // PStatGPUTimer timer(this, _draw_primitive_pcollector, + // reader->get_current_thread()); + +#ifndef NDEBUG + if (GLCAT.is_spam()) { + GLCAT.spam() << "draw_lines_adj: " << *(reader->get_object()) << "\n"; + } +#endif // NDEBUG + +#ifdef SUPPORT_IMMEDIATE_MODE + if (_use_sender) { + draw_immediate_simple_primitives(reader, GL_LINES_ADJACENCY); + } else +#endif // SUPPORT_IMMEDIATE_MODE + { + int num_vertices = reader->get_num_vertices(); + _vertices_other_pcollector.add_level(num_vertices); + _primitive_batches_other_pcollector.add_level(1); + + if (reader->is_indexed()) { + const unsigned char *client_pointer; + if (!setup_primitive(client_pointer, reader, force)) { + return false; + } + if (_supports_geometry_instancing && _instance_count > 0) { + _glDrawElementsInstanced(GL_LINES_ADJACENCY, num_vertices, + get_numeric_type(reader->get_index_type()), + client_pointer, _instance_count); + } else { + _glDrawRangeElements(GL_LINES_ADJACENCY, + reader->get_min_vertex(), + reader->get_max_vertex(), + num_vertices, + get_numeric_type(reader->get_index_type()), + client_pointer); + } + } else { + if (_supports_geometry_instancing && _instance_count > 0) { + _glDrawArraysInstanced(GL_LINES_ADJACENCY, + reader->get_first_vertex(), + num_vertices, _instance_count); + } else { + glDrawArrays(GL_LINES_ADJACENCY, + reader->get_first_vertex(), + num_vertices); + } + } + } + + report_my_gl_errors(); + return true; +} +#endif // OPENGLES + /** * Draws a series of line strips. */ @@ -5010,6 +5260,117 @@ draw_linestrips(const GeomPrimitivePipelineReader *reader, bool force) { return true; } +/** + * Draws a series of line strips with adjacency information. + */ +#ifndef OPENGLES +bool CLP(GraphicsStateGuardian):: +draw_linestrips_adj(const GeomPrimitivePipelineReader *reader, bool force) { + // PStatGPUTimer timer(this, _draw_primitive_pcollector, + // reader->get_current_thread()); + + report_my_gl_errors(); + +#ifndef NDEBUG + if (GLCAT.is_spam()) { + GLCAT.spam() << "draw_linestrips_adj: " << *(reader->get_object()) << "\n"; + } +#endif // NDEBUG + +#ifdef SUPPORT_IMMEDIATE_MODE + if (_use_sender) { + draw_immediate_composite_primitives(reader, GL_LINE_STRIP_ADJACENCY); + + } else +#endif // SUPPORT_IMMEDIATE_MODE + { + if (reader->is_indexed() && + (_supported_geom_rendering & GeomEnums::GR_strip_cut_index) != 0) { + // One long line strip, connected by strip cut indices. + if (_explicit_primitive_restart) { + glEnable(GL_PRIMITIVE_RESTART); + _glPrimitiveRestartIndex(reader->get_strip_cut_index()); + } + + int num_vertices = reader->get_num_vertices(); + _vertices_other_pcollector.add_level(num_vertices); + _primitive_batches_other_pcollector.add_level(1); + + const unsigned char *client_pointer; + if (!setup_primitive(client_pointer, reader, force)) { + return false; + } + if (_supports_geometry_instancing && _instance_count > 0) { + _glDrawElementsInstanced(GL_LINE_STRIP_ADJACENCY, num_vertices, + get_numeric_type(reader->get_index_type()), + client_pointer, _instance_count); + } else { + _glDrawRangeElements(GL_LINE_STRIP_ADJACENCY, + reader->get_min_vertex(), + reader->get_max_vertex(), + num_vertices, + get_numeric_type(reader->get_index_type()), + client_pointer); + } + + if (_explicit_primitive_restart) { + glDisable(GL_PRIMITIVE_RESTART); + } + } else { + // Send the individual line strips, stepping over the strip-cut indices. + CPTA_int ends = reader->get_ends(); + + _primitive_batches_other_pcollector.add_level(ends.size()); + if (reader->is_indexed()) { + const unsigned char *client_pointer; + if (!setup_primitive(client_pointer, reader, force)) { + return false; + } + int index_stride = reader->get_index_stride(); + GeomVertexReader mins(reader->get_mins(), 0); + GeomVertexReader maxs(reader->get_maxs(), 0); + nassertr(reader->get_mins()->get_num_rows() == (int)ends.size() && + reader->get_maxs()->get_num_rows() == (int)ends.size(), false); + + unsigned int start = 0; + for (size_t i = 0; i < ends.size(); i++) { + _vertices_other_pcollector.add_level(ends[i] - start); + if (_supports_geometry_instancing && _instance_count > 0) { + _glDrawElementsInstanced(GL_LINE_STRIP_ADJACENCY, ends[i] - start, + get_numeric_type(reader->get_index_type()), + client_pointer + start * index_stride, + _instance_count); + } else { + _glDrawRangeElements(GL_LINE_STRIP_ADJACENCY, + mins.get_data1i(), maxs.get_data1i(), + ends[i] - start, + get_numeric_type(reader->get_index_type()), + client_pointer + start * index_stride); + } + start = ends[i] + 1; + } + } else { + unsigned int start = 0; + int first_vertex = reader->get_first_vertex(); + for (size_t i = 0; i < ends.size(); i++) { + _vertices_other_pcollector.add_level(ends[i] - start); + if (_supports_geometry_instancing && _instance_count > 0) { + _glDrawArraysInstanced(GL_LINE_STRIP_ADJACENCY, first_vertex + start, + ends[i] - start, _instance_count); + } else { + glDrawArrays(GL_LINE_STRIP_ADJACENCY, first_vertex + start, ends[i] - start); + } + start = ends[i] + 1; + } + } + } + } + + report_my_gl_errors(); + return true; +} +#endif // OPENGLES + /** * Draws a series of disconnected points. */ diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index 2b357ece5b..ab1d27a2a4 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -288,16 +288,32 @@ public: bool force); virtual bool draw_triangles(const GeomPrimitivePipelineReader *reader, bool force); +#ifndef OPENGLES + virtual bool draw_triangles_adj(const GeomPrimitivePipelineReader *reader, + bool force); +#endif virtual bool draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force); +#ifndef OPENGLES + virtual bool draw_tristrips_adj(const GeomPrimitivePipelineReader *reader, + bool force); +#endif virtual bool draw_trifans(const GeomPrimitivePipelineReader *reader, bool force); virtual bool draw_patches(const GeomPrimitivePipelineReader *reader, bool force); virtual bool draw_lines(const GeomPrimitivePipelineReader *reader, bool force); +#ifndef OPENGLES + virtual bool draw_lines_adj(const GeomPrimitivePipelineReader *reader, + bool force); +#endif virtual bool draw_linestrips(const GeomPrimitivePipelineReader *reader, bool force); +#ifndef OPENGLES + virtual bool draw_linestrips_adj(const GeomPrimitivePipelineReader *reader, + bool force); +#endif virtual bool draw_points(const GeomPrimitivePipelineReader *reader, bool force); virtual void end_draw_primitives(); diff --git a/panda/src/gobj/config_gobj.cxx b/panda/src/gobj/config_gobj.cxx index 84876a2b8f..058d7463a4 100644 --- a/panda/src/gobj/config_gobj.cxx +++ b/panda/src/gobj/config_gobj.cxx @@ -20,11 +20,15 @@ #include "geomMunger.h" #include "geomPrimitive.h" #include "geomTriangles.h" +#include "geomTrianglesAdjacency.h" #include "geomTristrips.h" +#include "geomTristripsAdjacency.h" #include "geomTrifans.h" #include "geomPatches.h" #include "geomLines.h" +#include "geomLinesAdjacency.h" #include "geomLinestrips.h" +#include "geomLinestripsAdjacency.h" #include "geomPoints.h" #include "geomVertexArrayData.h" #include "geomVertexArrayFormat.h" @@ -546,14 +550,18 @@ ConfigureFn(config_gobj) { GeomPipelineReader::init_type(); GeomContext::init_type(); GeomLines::init_type(); + GeomLinesAdjacency::init_type(); GeomLinestrips::init_type(); + GeomLinestripsAdjacency::init_type(); GeomMunger::init_type(); GeomPoints::init_type(); GeomPrimitive::init_type(); GeomPrimitivePipelineReader::init_type(); GeomTriangles::init_type(); + GeomTrianglesAdjacency::init_type(); GeomTrifans::init_type(); GeomTristrips::init_type(); + GeomTristripsAdjacency::init_type(); GeomPatches::init_type(); GeomVertexArrayData::init_type(); GeomVertexArrayDataHandle::init_type(); @@ -601,11 +609,15 @@ ConfigureFn(config_gobj) { // factory Geom::register_with_read_factory(); GeomLines::register_with_read_factory(); + GeomLinesAdjacency::register_with_read_factory(); GeomLinestrips::register_with_read_factory(); + GeomLinestripsAdjacency::register_with_read_factory(); GeomPoints::register_with_read_factory(); GeomTriangles::register_with_read_factory(); + GeomTrianglesAdjacency::register_with_read_factory(); GeomTrifans::register_with_read_factory(); GeomTristrips::register_with_read_factory(); + GeomTristripsAdjacency::register_with_read_factory(); GeomPatches::register_with_read_factory(); GeomVertexArrayData::register_with_read_factory(); GeomVertexArrayFormat::register_with_read_factory(); diff --git a/panda/src/gobj/geom.I b/panda/src/gobj/geom.I index 340cfd099c..413e2de055 100644 --- a/panda/src/gobj/geom.I +++ b/panda/src/gobj/geom.I @@ -212,6 +212,17 @@ make_patches() const { return new_geom; } +/** + * Returns a new Geom with each primitive converted into a corresponding + * version with adjacency information. + */ +INLINE PT(Geom) Geom:: +make_adjacency() const { + PT(Geom) new_geom = make_copy(); + new_geom->make_adjacency_in_place(); + return new_geom; +} + /** * Returns a sequence number which is guaranteed to change at least every time * any of the primitives in the Geom is modified, or the set of primitives is diff --git a/panda/src/gobj/geom.cxx b/panda/src/gobj/geom.cxx index efdd4ba5ca..26dd3c942c 100644 --- a/panda/src/gobj/geom.cxx +++ b/panda/src/gobj/geom.cxx @@ -834,6 +834,42 @@ make_patches_in_place() { nassertv(all_is_valid); } +/** + * Replaces the GeomPrimitives within this Geom with corresponding versions + * with adjacency information. See GeomPrimitive::make_adjacency(). + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ +void Geom:: +make_adjacency_in_place() { + Thread *current_thread = Thread::get_current_thread(); + CDWriter cdata(_cycler, true, current_thread); + +#ifndef NDEBUG + bool all_is_valid = true; +#endif + Primitives::iterator pi; + for (pi = cdata->_primitives.begin(); pi != cdata->_primitives.end(); ++pi) { + CPT(GeomPrimitive) new_prim = (*pi).get_read_pointer(current_thread)->make_adjacency(); + if (new_prim != nullptr) { + (*pi) = (GeomPrimitive *)new_prim.p(); + +#ifndef NDEBUG + if (!new_prim->check_valid(cdata->_data.get_read_pointer(current_thread))) { + all_is_valid = false; + } +#endif + } + } + + cdata->_modified = Geom::get_next_modified(); + reset_geom_rendering(cdata); + clear_cache_stage(current_thread); + + nassertv(all_is_valid); +} + /** * Copies the primitives from the indicated Geom into this one. This does * require that both Geoms contain the same fundamental type primitives, both diff --git a/panda/src/gobj/geom.h b/panda/src/gobj/geom.h index ec81442703..50b050e578 100644 --- a/panda/src/gobj/geom.h +++ b/panda/src/gobj/geom.h @@ -106,6 +106,7 @@ PUBLISHED: INLINE PT(Geom) make_points() const; INLINE PT(Geom) make_lines() const; INLINE PT(Geom) make_patches() const; + INLINE PT(Geom) make_adjacency() const; void decompose_in_place(); void doubleside_in_place(); @@ -115,6 +116,7 @@ PUBLISHED: void make_points_in_place(); void make_lines_in_place(); void make_patches_in_place(); + void make_adjacency_in_place(); virtual bool copy_primitives_from(const Geom *other); diff --git a/panda/src/gobj/geomEnums.h b/panda/src/gobj/geomEnums.h index 7d55a797a1..80af6d0ea2 100644 --- a/panda/src/gobj/geomEnums.h +++ b/panda/src/gobj/geomEnums.h @@ -132,6 +132,9 @@ PUBLISHED: // If a particular non-fill polygon mode is used. GR_render_mode_wireframe= 0x40000, GR_render_mode_point = 0x80000, + + // The primitive has adjacency information. + GR_adjacency = 0x100000, }; // The shade model specifies whether the per-vertex colors and normals diff --git a/panda/src/gobj/geomLines.cxx b/panda/src/gobj/geomLines.cxx index 1010c814be..20c9aa198b 100644 --- a/panda/src/gobj/geomLines.cxx +++ b/panda/src/gobj/geomLines.cxx @@ -18,6 +18,7 @@ #include "graphicsStateGuardianBase.h" #include "geomVertexReader.h" #include "geomVertexWriter.h" +#include "geomLinesAdjacency.h" TypeHandle GeomLines::_type_handle; @@ -67,6 +68,67 @@ get_primitive_type() const { return PT_lines; } +/** + * Adds adjacency information to this primitive. May return null if this type + * of geometry does not support adjacency information. + */ +CPT(GeomPrimitive) GeomLines:: +make_adjacency() const { + Thread *current_thread = Thread::get_current_thread(); + PT(GeomLinesAdjacency) adj = new GeomLinesAdjacency(get_usage_hint()); + + GeomPrimitivePipelineReader from(this, current_thread); + int num_vertices = from.get_num_vertices(); + + PT(GeomVertexArrayData) new_vertices = adj->make_index_data(); + new_vertices->set_num_rows(num_vertices * 2); + + // First, build a map of each vertex to its next vertex, and another map + // doing the exact reverse. Note that this only considers lines that are + // ordered the same way as being connected; we may need to change this. + map forward_map, reverse_map; + for (int i = 0; i < num_vertices; i += 2) { + int v0 = from.get_vertex(i); + int v1 = from.get_vertex(i + 1); + forward_map[v0] = v1; + reverse_map[v1] = v0; + } + + // Now build up the new vertex data. For each line, we insert the + // appropriate connecting vertex. + { + GeomVertexWriter to(new_vertices, 0); + for (int i = 0; i < num_vertices; i += 2) { + int v0 = from.get_vertex(i); + int v1 = from.get_vertex(i + 1); + + auto it = reverse_map.find(v0); + if (it != reverse_map.end()) { + to.set_data1i(it->second); + } else { + // Um, no adjoining line segment? Just repeat the vertex, I guess. + to.set_data1i(v0); + } + + to.set_data1i(v0); + to.set_data1i(v1); + + // Do the same for the second vertex in the line. + it = forward_map.find(v1); + if (it != forward_map.end()) { + to.set_data1i(it->second); + } else { + to.set_data1i(v1); + } + } + + nassertr(to.is_at_end(), nullptr); + } + + adj->set_vertices(move(new_vertices)); + return adj.p(); +} + /** * If the primitive type is a simple type in which all primitives have the * same number of vertices, like lines, returns the number of vertices per diff --git a/panda/src/gobj/geomLines.h b/panda/src/gobj/geomLines.h index e05a4605c6..fc28c509c5 100644 --- a/panda/src/gobj/geomLines.h +++ b/panda/src/gobj/geomLines.h @@ -31,6 +31,8 @@ public: virtual PT(GeomPrimitive) make_copy() const; virtual PrimitiveType get_primitive_type() const; + CPT(GeomPrimitive) make_adjacency() const; + virtual int get_num_vertices_per_primitive() const; virtual int get_min_num_vertices_per_primitive() const; diff --git a/panda/src/gobj/geomLinesAdjacency.cxx b/panda/src/gobj/geomLinesAdjacency.cxx new file mode 100644 index 0000000000..28567cdade --- /dev/null +++ b/panda/src/gobj/geomLinesAdjacency.cxx @@ -0,0 +1,132 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomLinesAdjacency.cxx + * @author rdb + * @date 2018-03-01 + */ + +#include "geomLinesAdjacency.h" +#include "pStatTimer.h" +#include "bamReader.h" +#include "bamWriter.h" +#include "graphicsStateGuardianBase.h" +#include "geomVertexReader.h" +#include "geomVertexWriter.h" + +TypeHandle GeomLinesAdjacency::_type_handle; + +/** + * + */ +GeomLinesAdjacency:: +GeomLinesAdjacency(GeomEnums::UsageHint usage_hint) : + GeomPrimitive(usage_hint) +{ +} + +/** + * + */ +GeomLinesAdjacency:: +GeomLinesAdjacency(const GeomLinesAdjacency ©) : + GeomPrimitive(copy) +{ +} + +/** + * + */ +GeomLinesAdjacency:: +~GeomLinesAdjacency() { +} + +/** + * + */ +PT(GeomPrimitive) GeomLinesAdjacency:: +make_copy() const { + return new GeomLinesAdjacency(*this); +} + +/** + * Returns the fundamental rendering type of this primitive: whether it is + * points, lines, or polygons. + * + * This is used to set up the appropriate antialiasing settings when + * AntialiasAttrib::M_auto is in effect; it also implies the type of primitive + * that will be produced when decompose() is called. + */ +GeomPrimitive::PrimitiveType GeomLinesAdjacency:: +get_primitive_type() const { + return PT_lines; +} + +/** + * Returns the set of GeomRendering bits that represent the rendering + * properties required to properly render this primitive. + */ +int GeomLinesAdjacency:: +get_geom_rendering() const { + return GeomPrimitive::get_geom_rendering() | GR_adjacency; +} + +/** + * If the primitive type is a simple type in which all primitives have the + * same number of vertices, like lines, returns the number of vertices per + * primitive. If the primitive type is a more complex type in which different + * primitives might have different numbers of vertices, for instance a line + * strip, returns 0. + */ +int GeomLinesAdjacency:: +get_num_vertices_per_primitive() const { + return 4; +} + +/** + * Returns the minimum number of vertices that must be added before + * close_primitive() may legally be called. + */ +int GeomLinesAdjacency:: +get_min_num_vertices_per_primitive() const { + return 4; +} + +/** + * Calls the appropriate method on the GSG to draw the primitive. + */ +bool GeomLinesAdjacency:: +draw(GraphicsStateGuardianBase *gsg, const GeomPrimitivePipelineReader *reader, + bool force) const { + return gsg->draw_lines_adj(reader, force); +} + +/** + * Tells the BamReader how to create objects of type Geom. + */ +void GeomLinesAdjacency:: +register_with_read_factory() { + BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); +} + +/** + * This function is called by the BamReader's factory when a new object of + * type Geom is encountered in the Bam file. It should create the Geom and + * extract its information from the file. + */ +TypedWritable *GeomLinesAdjacency:: +make_from_bam(const FactoryParams ¶ms) { + GeomLinesAdjacency *object = new GeomLinesAdjacency(UH_unspecified); + DatagramIterator scan; + BamReader *manager; + + parse_params(params, scan, manager); + object->fillin(scan, manager); + + return object; +} diff --git a/panda/src/gobj/geomLinesAdjacency.h b/panda/src/gobj/geomLinesAdjacency.h new file mode 100644 index 0000000000..884875cb39 --- /dev/null +++ b/panda/src/gobj/geomLinesAdjacency.h @@ -0,0 +1,70 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomLinesAdjacency.h + * @author rdb + * @date 2018-03-01 + */ + +#ifndef GEOMLINESADJACENCY_H +#define GEOMLINESADJACENCY_H + +#include "pandabase.h" +#include "geomPrimitive.h" + +/** + * Defines a series of disconnected line segments with adjacency information, + * for use with geometry shaders. + */ +class EXPCL_PANDA_GOBJ GeomLinesAdjacency : public GeomPrimitive { +PUBLISHED: + explicit GeomLinesAdjacency(UsageHint usage_hint); + GeomLinesAdjacency(const GeomLinesAdjacency ©); + virtual ~GeomLinesAdjacency(); + ALLOC_DELETED_CHAIN(GeomLinesAdjacency); + +public: + virtual PT(GeomPrimitive) make_copy() const; + virtual PrimitiveType get_primitive_type() const; + virtual int get_geom_rendering() const; + + virtual int get_num_vertices_per_primitive() const; + virtual int get_min_num_vertices_per_primitive() const; + +public: + virtual bool draw(GraphicsStateGuardianBase *gsg, + const GeomPrimitivePipelineReader *reader, + bool force) const; + +public: + static void register_with_read_factory(); + +protected: + static TypedWritable *make_from_bam(const FactoryParams ¶ms); + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + GeomPrimitive::init_type(); + register_type(_type_handle, "GeomLinesAdjacency", + GeomPrimitive::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; + + friend class Geom; +}; + +#endif diff --git a/panda/src/gobj/geomLinestrips.cxx b/panda/src/gobj/geomLinestrips.cxx index 734cf49c55..8a3365a201 100644 --- a/panda/src/gobj/geomLinestrips.cxx +++ b/panda/src/gobj/geomLinestrips.cxx @@ -18,6 +18,7 @@ #include "bamReader.h" #include "bamWriter.h" #include "graphicsStateGuardianBase.h" +#include "geomLinestripsAdjacency.h" TypeHandle GeomLinestrips::_type_handle; @@ -84,6 +85,86 @@ get_geom_rendering() const { } } +/** + * Adds adjacency information to this primitive. May return null if this type + * of geometry does not support adjacency information. + */ +CPT(GeomPrimitive) GeomLinestrips:: +make_adjacency() const { + Thread *current_thread = Thread::get_current_thread(); + PT(GeomLinestripsAdjacency) adj = new GeomLinestripsAdjacency(get_usage_hint()); + + GeomPrimitivePipelineReader from(this, current_thread); + int num_vertices = from.get_num_vertices(); + CPTA_int ends = get_ends(); + + const int num_unused = 1; + + // First, build a map of each vertex to its next vertex, and another map + // doing the exact reverse. + map forward_map, reverse_map; + int vi = -num_unused; + int li = 0; + while (li < (int)ends.size()) { + // Skip unused vertices between linestrips. + vi += num_unused; + int end = ends[li]; + nassertr(vi + 1 <= end, nullptr); + int v0 = from.get_vertex(vi++); + while (vi < end) { + int v1 = from.get_vertex(vi++); + forward_map[v0] = v1; + reverse_map[v1] = v0; + v0 = v1; + } + ++li; + } + nassertr(vi == num_vertices, nullptr); + + // Now build up the new vertex data. For each linestrip, we prepend and + // append the appropriate connecting vertices. + vi = -num_unused; + li = 0; + while (li < (int)ends.size()) { + // Skip unused vertices between linestrips. + vi += num_unused; + int end = ends[li]; + nassertr(vi + 1 <= end, nullptr); + + // Look for the line segment connected to the beginning of this strip. + int v0 = from.get_vertex(vi++); + auto it = reverse_map.find(v0); + if (it != reverse_map.end()) { + adj->add_vertex(it->second); + } else { + // Um, no adjoining line segment? Just repeat the vertex, I guess. + adj->add_vertex(v0); + } + + // Add the actual vertices in the strip. + adj->add_vertex(v0); + int v1; + while (vi < end) { + v1 = from.get_vertex(vi++); + adj->add_vertex(v1); + } + + // Do the same for the last vertex in the strip. + it = forward_map.find(v1); + if (it != forward_map.end()) { + adj->add_vertex(it->second); + } else { + adj->add_vertex(v1); + } + + adj->close_primitive(); + ++li; + } + nassertr(vi == num_vertices, nullptr); + + return adj.p(); +} + /** * Returns the minimum number of vertices that must be added before * close_primitive() may legally be called. diff --git a/panda/src/gobj/geomLinestrips.h b/panda/src/gobj/geomLinestrips.h index ae8956eb3d..39ff5f518a 100644 --- a/panda/src/gobj/geomLinestrips.h +++ b/panda/src/gobj/geomLinestrips.h @@ -31,6 +31,9 @@ public: virtual PT(GeomPrimitive) make_copy() const; virtual PrimitiveType get_primitive_type() const; virtual int get_geom_rendering() const; + + CPT(GeomPrimitive) make_adjacency() const; + virtual int get_min_num_vertices_per_primitive() const; virtual int get_num_unused_vertices_per_primitive() const; diff --git a/panda/src/gobj/geomLinestripsAdjacency.cxx b/panda/src/gobj/geomLinestripsAdjacency.cxx new file mode 100644 index 0000000000..b8c69fc240 --- /dev/null +++ b/panda/src/gobj/geomLinestripsAdjacency.cxx @@ -0,0 +1,210 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomLinestripsAdjacency.cxx + * @author rdb + * @date 2018-03-01 + */ + +#include "geomLinestripsAdjacency.h" +#include "geomLines.h" +#include "geomVertexRewriter.h" +#include "pStatTimer.h" +#include "bamReader.h" +#include "bamWriter.h" +#include "graphicsStateGuardianBase.h" + +TypeHandle GeomLinestripsAdjacency::_type_handle; + +/** + * + */ +GeomLinestripsAdjacency:: +GeomLinestripsAdjacency(GeomEnums::UsageHint usage_hint) : + GeomPrimitive(usage_hint) +{ +} + +/** + * + */ +GeomLinestripsAdjacency:: +GeomLinestripsAdjacency(const GeomLinestripsAdjacency ©) : + GeomPrimitive(copy) +{ +} + +/** + * + */ +GeomLinestripsAdjacency:: +~GeomLinestripsAdjacency() { +} + +/** + * + */ +PT(GeomPrimitive) GeomLinestripsAdjacency:: +make_copy() const { + return new GeomLinestripsAdjacency(*this); +} + +/** + * Returns the fundamental rendering type of this primitive: whether it is + * points, lines, or polygons. + * + * This is used to set up the appropriate antialiasing settings when + * AntialiasAttrib::M_auto is in effect; it also implies the type of primitive + * that will be produced when decompose() is called. + */ +GeomPrimitive::PrimitiveType GeomLinestripsAdjacency:: +get_primitive_type() const { + return PT_lines; +} + +/** + * Returns the set of GeomRendering bits that represent the rendering + * properties required to properly render this primitive. + */ +int GeomLinestripsAdjacency:: +get_geom_rendering() const { + if (is_indexed()) { + if (get_num_primitives() > 1) { + return GR_line_strip | GR_indexed_other | GR_strip_cut_index | GR_adjacency; + } else { + return GR_line_strip | GR_indexed_other | GR_adjacency; + } + } else { + return GR_line_strip | GR_adjacency; + } +} + +/** + * Returns the minimum number of vertices that must be added before + * close_primitive() may legally be called. + */ +int GeomLinestripsAdjacency:: +get_min_num_vertices_per_primitive() const { + return 4; +} + +/** + * Returns the number of vertices that are added between primitives that + * aren't, strictly speaking, part of the primitives themselves. This is + * used, for instance, to define degenerate triangles to connect otherwise + * disconnected triangle strips. + */ +int GeomLinestripsAdjacency:: +get_num_unused_vertices_per_primitive() const { + return 1; +} + +/** + * Calls the appropriate method on the GSG to draw the primitive. + */ +bool GeomLinestripsAdjacency:: +draw(GraphicsStateGuardianBase *gsg, const GeomPrimitivePipelineReader *reader, + bool force) const { + return gsg->draw_linestrips_adj(reader, force); +} + +/** + * Decomposes a complex primitive type into a simpler primitive type, for + * instance line strips to lines, and returns a pointer to the new primitive + * definition. If the decomposition cannot be performed, this might return + * the original object. + * + * This method is useful for application code that wants to iterate through + * the set of lines on the primitive without having to write handlers for each + * possible kind of primitive type. + */ +CPT(GeomPrimitive) GeomLinestripsAdjacency:: +decompose_impl() const { + Thread *current_thread = Thread::get_current_thread(); + PT(GeomLinesAdjacency) lines = new GeomLinesAdjacency(get_usage_hint()); + lines->set_shade_model(get_shade_model()); + + GeomPrimitivePipelineReader from(this, current_thread); + int num_vertices = from.get_num_vertices(); + CPTA_int ends = get_ends(); + + const int num_unused = 1; + + int vi = -num_unused; + int li = 0; + while (li < (int)ends.size()) { + // Skip unused vertices between tristrips. + vi += num_unused; + int end = ends[li]; + nassertr(vi + 3 <= end, lines.p()); + int v0 = from.get_vertex(vi++); + int v1 = from.get_vertex(vi++); + int v2 = from.get_vertex(vi++); + while (vi < end) { + int v3 = from.get_vertex(vi++); + lines->add_vertex(v0); + lines->add_vertex(v1); + lines->add_vertex(v2); + lines->add_vertex(v3); + v0 = v1; + v1 = v2; + v2 = v3; + } + ++li; + } + nassertr(vi == num_vertices, nullptr); + + return lines.p(); +} + +/** + * Should be redefined to return true in any primitive that implements + * append_unused_vertices(). + */ +bool GeomLinestripsAdjacency:: +requires_unused_vertices() const { + return true; +} + +/** + * Called when a new primitive is begun (other than the first primitive), this + * should add some degenerate vertices between primitives, if the primitive + * type requires that. The second parameter is the first vertex that begins + * the new primitive. + */ +void GeomLinestripsAdjacency:: +append_unused_vertices(GeomVertexArrayData *vertices, int vertex) { + GeomVertexWriter to(vertices, 0); + to.set_row_unsafe(vertices->get_num_rows()); + to.add_data1i(get_strip_cut_index()); +} + +/** + * Tells the BamReader how to create objects of type Geom. + */ +void GeomLinestripsAdjacency:: +register_with_read_factory() { + BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); +} + +/** + * This function is called by the BamReader's factory when a new object of + * type Geom is encountered in the Bam file. It should create the Geom and + * extract its information from the file. + */ +TypedWritable *GeomLinestripsAdjacency:: +make_from_bam(const FactoryParams ¶ms) { + GeomLinestripsAdjacency *object = new GeomLinestripsAdjacency(UH_unspecified); + DatagramIterator scan; + BamReader *manager; + + parse_params(params, scan, manager); + object->fillin(scan, manager); + + return object; +} diff --git a/panda/src/gobj/geomLinestripsAdjacency.h b/panda/src/gobj/geomLinestripsAdjacency.h new file mode 100644 index 0000000000..baf3d19255 --- /dev/null +++ b/panda/src/gobj/geomLinestripsAdjacency.h @@ -0,0 +1,75 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomLinestripsAdjacency.h + * @author rdb + * @date 2018-03-01 + */ + +#ifndef GEOMLINESTRIPSADJACENCY_H +#define GEOMLINESTRIPSADJACENCY_H + +#include "pandabase.h" +#include "geomPrimitive.h" + +/** + * Defines a series of line strips. + */ +class EXPCL_PANDA_GOBJ GeomLinestripsAdjacency : public GeomPrimitive { +PUBLISHED: + explicit GeomLinestripsAdjacency(UsageHint usage_hint); + GeomLinestripsAdjacency(const GeomLinestripsAdjacency ©); + virtual ~GeomLinestripsAdjacency(); + ALLOC_DELETED_CHAIN(GeomLinestripsAdjacency); + +public: + virtual PT(GeomPrimitive) make_copy() const; + virtual PrimitiveType get_primitive_type() const; + virtual int get_geom_rendering() const; + + virtual int get_min_num_vertices_per_primitive() const; + virtual int get_num_unused_vertices_per_primitive() const; + +public: + virtual bool draw(GraphicsStateGuardianBase *gsg, + const GeomPrimitivePipelineReader *reader, + bool force) const; + +protected: + virtual CPT(GeomPrimitive) decompose_impl() const; + virtual bool requires_unused_vertices() const; + virtual void append_unused_vertices(GeomVertexArrayData *vertices, + int vertex); + +public: + static void register_with_read_factory(); + +protected: + static TypedWritable *make_from_bam(const FactoryParams ¶ms); + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + GeomPrimitive::init_type(); + register_type(_type_handle, "GeomLinestripsAdjacency", + GeomPrimitive::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; + + friend class Geom; +}; + +#endif diff --git a/panda/src/gobj/geomPrimitive.cxx b/panda/src/gobj/geomPrimitive.cxx index 23a905f8e3..b85747a945 100644 --- a/panda/src/gobj/geomPrimitive.cxx +++ b/panda/src/gobj/geomPrimitive.cxx @@ -1021,6 +1021,15 @@ make_patches() const { return patches; } +/** + * Adds adjacency information to this primitive. May return null if this type + * of geometry does not support adjacency information. + */ +CPT(GeomPrimitive) GeomPrimitive:: +make_adjacency() const { + return nullptr; +} + /** * Returns the number of bytes consumed by the primitive and its index * table(s). diff --git a/panda/src/gobj/geomPrimitive.h b/panda/src/gobj/geomPrimitive.h index d596ae7a8e..8748c86799 100644 --- a/panda/src/gobj/geomPrimitive.h +++ b/panda/src/gobj/geomPrimitive.h @@ -134,6 +134,7 @@ PUBLISHED: CPT(GeomPrimitive) make_points() const; CPT(GeomPrimitive) make_lines() const; CPT(GeomPrimitive) make_patches() const; + virtual CPT(GeomPrimitive) make_adjacency() const; int get_num_bytes() const; INLINE int get_data_size_bytes() const; diff --git a/panda/src/gobj/geomTriangles.cxx b/panda/src/gobj/geomTriangles.cxx index 98074d63c1..a6e3b9480f 100644 --- a/panda/src/gobj/geomTriangles.cxx +++ b/panda/src/gobj/geomTriangles.cxx @@ -17,6 +17,7 @@ #include "bamReader.h" #include "bamWriter.h" #include "graphicsStateGuardianBase.h" +#include "geomTrianglesAdjacency.h" TypeHandle GeomTriangles::_type_handle; @@ -66,6 +67,76 @@ get_primitive_type() const { return PT_polygons; } +/** + * Adds adjacency information to this primitive. May return null if this type + * of geometry does not support adjacency information. + */ +CPT(GeomPrimitive) GeomTriangles:: +make_adjacency() const { + Thread *current_thread = Thread::get_current_thread(); + PT(GeomTrianglesAdjacency) adj = new GeomTrianglesAdjacency(get_usage_hint()); + + GeomPrimitivePipelineReader from(this, current_thread); + int num_vertices = from.get_num_vertices(); + + PT(GeomVertexArrayData) new_vertices = adj->make_index_data(); + new_vertices->set_num_rows(num_vertices * 2); + + // First, build a map of each triangle's halfedges to its opposing vertices. + map, int> edge_map; + for (int i = 0; i < num_vertices; i += 3) { + int v0 = from.get_vertex(i); + int v1 = from.get_vertex(i + 1); + int v2 = from.get_vertex(i + 2); + edge_map[make_pair(v0, v1)] = v2; + edge_map[make_pair(v1, v2)] = v0; + edge_map[make_pair(v2, v0)] = v1; + } + + // Now build up the new vertex data. For each edge, we insert the + // appropriate connecting vertex. + { + GeomVertexWriter to(new_vertices, 0); + for (int i = 0; i < num_vertices; i += 3) { + int v0 = from.get_vertex(i); + int v1 = from.get_vertex(i + 1); + int v2 = from.get_vertex(i + 2); + + // Get the third vertex of the triangle adjoining this edge. + to.set_data1(v0); + auto it = edge_map.find(make_pair(v1, v0)); + if (it != edge_map.end()) { + to.set_data1i(it->second); + } else { + // Um, no adjoining triangle? Just repeat the vertex, I guess. + to.set_data1i(v0); + } + + // Do the same for the other two edges. + to.set_data1(v1); + it = edge_map.find(make_pair(v2, v1)); + if (it != edge_map.end()) { + to.set_data1i(it->second); + } else { + to.set_data1i(v1); + } + + to.set_data1(v2); + it = edge_map.find(make_pair(v0, v2)); + if (it != edge_map.end()) { + to.set_data1i(it->second); + } else { + to.set_data1i(v2); + } + } + + nassertr(to.is_at_end(), nullptr); + } + + adj->set_vertices(move(new_vertices)); + return adj.p(); +} + /** * If the primitive type is a simple type in which all primitives have the * same number of vertices, like triangles, returns the number of vertices per diff --git a/panda/src/gobj/geomTriangles.h b/panda/src/gobj/geomTriangles.h index d78b783b40..390fd78ea2 100644 --- a/panda/src/gobj/geomTriangles.h +++ b/panda/src/gobj/geomTriangles.h @@ -31,6 +31,8 @@ public: virtual PT(GeomPrimitive) make_copy() const; virtual PrimitiveType get_primitive_type() const; + CPT(GeomPrimitive) make_adjacency() const; + virtual int get_num_vertices_per_primitive() const; public: diff --git a/panda/src/gobj/geomTrianglesAdjacency.cxx b/panda/src/gobj/geomTrianglesAdjacency.cxx new file mode 100644 index 0000000000..0dffa74329 --- /dev/null +++ b/panda/src/gobj/geomTrianglesAdjacency.cxx @@ -0,0 +1,195 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomTrianglesAdjacency.cxx + * @author rdb + * @date 2018-03-01 + */ + +#include "geomTrianglesAdjacency.h" +#include "geomVertexRewriter.h" +#include "pStatTimer.h" +#include "bamReader.h" +#include "bamWriter.h" +#include "graphicsStateGuardianBase.h" + +TypeHandle GeomTrianglesAdjacency::_type_handle; + +/** + * + */ +GeomTrianglesAdjacency:: +GeomTrianglesAdjacency(GeomTrianglesAdjacency::UsageHint usage_hint) : + GeomPrimitive(usage_hint) +{ +} + +/** + * + */ +GeomTrianglesAdjacency:: +GeomTrianglesAdjacency(const GeomTrianglesAdjacency ©) : + GeomPrimitive(copy) +{ +} + +/** + * + */ +GeomTrianglesAdjacency:: +~GeomTrianglesAdjacency() { +} + +/** + * + */ +PT(GeomPrimitive) GeomTrianglesAdjacency:: +make_copy() const { + return new GeomTrianglesAdjacency(*this); +} + +/** + * Returns the fundamental rendering type of this primitive: whether it is + * points, lines, or polygons. + * + * This is used to set up the appropriate antialiasing settings when + * AntialiasAttrib::M_auto is in effect; it also implies the type of primitive + * that will be produced when decompose() is called. + */ +GeomPrimitive::PrimitiveType GeomTrianglesAdjacency:: +get_primitive_type() const { + return PT_polygons; +} + +/** + * Returns the set of GeomRendering bits that represent the rendering + * properties required to properly render this primitive. + */ +int GeomTrianglesAdjacency:: +get_geom_rendering() const { + return GeomPrimitive::get_geom_rendering() | GR_adjacency; +} + +/** + * If the primitive type is a simple type in which all primitives have the + * same number of vertices, like triangles, returns the number of vertices per + * primitive. If the primitive type is a more complex type in which different + * primitives might have different numbers of vertices, for instance a + * triangle strip, returns 0. + */ +int GeomTrianglesAdjacency:: +get_num_vertices_per_primitive() const { + return 6; +} + +/** + * Calls the appropriate method on the GSG to draw the primitive. + */ +bool GeomTrianglesAdjacency:: +draw(GraphicsStateGuardianBase *gsg, const GeomPrimitivePipelineReader *reader, + bool force) const { + return gsg->draw_triangles_adj(reader, force); +} + +/** + * The virtual implementation of doubleside(). + */ +CPT(GeomPrimitive) GeomTrianglesAdjacency:: +doubleside_impl() const { + Thread *current_thread = Thread::get_current_thread(); + PT(GeomTrianglesAdjacency) reversed = new GeomTrianglesAdjacency(*this); + + GeomPrimitivePipelineReader from(this, current_thread); + + // This is like reverse(), except we don't clear the vertices first. That + // way we double the vertices up. + + // First, rotate the original copy, if necessary, so the flat-firstflat-last + // nature of the vertices is consistent throughout the primitive. + bool needs_rotate = false; + switch (from.get_shade_model()) { + case SM_flat_first_vertex: + case SM_flat_last_vertex: + reversed = (GeomTrianglesAdjacency *)DCAST(GeomTrianglesAdjacency, reversed->rotate()); + needs_rotate = true; + + default: + break; + } + + // Now append all the new vertices, in reverse order. + for (int i = from.get_num_vertices() - 1; i >= 0; --i) { + reversed->add_vertex(from.get_vertex(i)); + } + + // Finally, re-rotate the whole thing to get back to the original shade + // model. + if (needs_rotate) { + reversed = (GeomTrianglesAdjacency *)DCAST(GeomTrianglesAdjacency, reversed->rotate()); + } + + return reversed.p(); +} + +/** + * The virtual implementation of reverse(). + */ +CPT(GeomPrimitive) GeomTrianglesAdjacency:: +reverse_impl() const { + Thread *current_thread = Thread::get_current_thread(); + PT(GeomTrianglesAdjacency) reversed = new GeomTrianglesAdjacency(*this); + + GeomPrimitivePipelineReader from(this, current_thread); + reversed->clear_vertices(); + + for (int i = from.get_num_vertices() - 1; i >= 0; --i) { + reversed->add_vertex(from.get_vertex(i)); + } + + switch (from.get_shade_model()) { + case SM_flat_first_vertex: + reversed->set_shade_model(SM_flat_last_vertex); + reversed = (GeomTrianglesAdjacency *)DCAST(GeomTrianglesAdjacency, reversed->rotate()); + break; + + case SM_flat_last_vertex: + reversed->set_shade_model(SM_flat_first_vertex); + reversed = (GeomTrianglesAdjacency *)DCAST(GeomTrianglesAdjacency, reversed->rotate()); + break; + + default: + break; + } + + return reversed.p(); +} + +/** + * Tells the BamReader how to create objects of type Geom. + */ +void GeomTrianglesAdjacency:: +register_with_read_factory() { + BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); +} + +/** + * This function is called by the BamReader's factory when a new object of + * type Geom is encountered in the Bam file. It should create the Geom and + * extract its information from the file. + */ +TypedWritable *GeomTrianglesAdjacency:: +make_from_bam(const FactoryParams ¶ms) { + GeomTrianglesAdjacency *object = new GeomTrianglesAdjacency(UH_unspecified); + DatagramIterator scan; + BamReader *manager; + + parse_params(params, scan, manager); + object->fillin(scan, manager); + + return object; +} diff --git a/panda/src/gobj/geomTrianglesAdjacency.h b/panda/src/gobj/geomTrianglesAdjacency.h new file mode 100644 index 0000000000..6ebdbdc6eb --- /dev/null +++ b/panda/src/gobj/geomTrianglesAdjacency.h @@ -0,0 +1,72 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomTrianglesAdjacency.h + * @author rdb + * @date 2018-03-01 + */ + +#ifndef GEOMTRIANGLESADJACENCY_H +#define GEOMTRIANGLESADJACENCY_H + +#include "pandabase.h" +#include "geomPrimitive.h" + +/** + * Defines a series of disconnected triangles, with adjacency information. + */ +class EXPCL_PANDA_GOBJ GeomTrianglesAdjacency : public GeomPrimitive { +PUBLISHED: + explicit GeomTrianglesAdjacency(UsageHint usage_hint); + GeomTrianglesAdjacency(const GeomTrianglesAdjacency ©); + virtual ~GeomTrianglesAdjacency(); + ALLOC_DELETED_CHAIN(GeomTrianglesAdjacency); + +public: + virtual PT(GeomPrimitive) make_copy() const; + virtual PrimitiveType get_primitive_type() const; + virtual int get_geom_rendering() const; + + virtual int get_num_vertices_per_primitive() const; + +public: + virtual bool draw(GraphicsStateGuardianBase *gsg, + const GeomPrimitivePipelineReader *reader, + bool force) const; + +protected: + virtual CPT(GeomPrimitive) doubleside_impl() const; + virtual CPT(GeomPrimitive) reverse_impl() const; + +public: + static void register_with_read_factory(); + +protected: + static TypedWritable *make_from_bam(const FactoryParams ¶ms); + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + GeomPrimitive::init_type(); + register_type(_type_handle, "GeomTrianglesAdjacency", + GeomPrimitive::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; + + friend class Geom; +}; + +#endif diff --git a/panda/src/gobj/geomTristrips.cxx b/panda/src/gobj/geomTristrips.cxx index e6dea04359..ae7bf0bc25 100644 --- a/panda/src/gobj/geomTristrips.cxx +++ b/panda/src/gobj/geomTristrips.cxx @@ -18,6 +18,7 @@ #include "bamReader.h" #include "bamWriter.h" #include "graphicsStateGuardianBase.h" +#include "geomTristripsAdjacency.h" TypeHandle GeomTristrips::_type_handle; @@ -80,6 +81,143 @@ get_geom_rendering() const { } } +/** + * Adds adjacency information to this primitive. May return null if this type + * of geometry does not support adjacency information. + */ +CPT(GeomPrimitive) GeomTristrips:: +make_adjacency() const { + Thread *current_thread = Thread::get_current_thread(); + PT(GeomTristripsAdjacency) adj = new GeomTristripsAdjacency(get_usage_hint()); + CPTA_int ends = get_ends(); + + GeomPrimitivePipelineReader from(this, current_thread); + int num_vertices = from.get_num_vertices(); + const int num_unused = 2; + + // First, build a map of each triangle's halfedges to its opposing vertices. + map, int> edge_map; + + int vi = -num_unused; + int li = 0; + while (li < (int)ends.size()) { + // Skip unused vertices between tristrips. + vi += num_unused; + int end = ends[li]; + nassertr(vi + 2 <= end, nullptr); + + int v0 = from.get_vertex(vi++); + int v1 = from.get_vertex(vi++); + int v2 = from.get_vertex(vi); + edge_map[make_pair(v0, v1)] = v2; + + while (true) { + v2 = from.get_vertex(vi++); + edge_map[make_pair(v2, v0)] = v1; + + if (vi >= end) { + // Edge at the end of the strip + edge_map[make_pair(v1, v2)] = v0; + break; + } + + v0 = v1; + v1 = v2; + v2 = from.get_vertex(vi++); + edge_map[make_pair(v0, v2)] = v1; + + if (vi >= end) { + // Edge at the end of the strip + edge_map[make_pair(v2, v1)] = v0; + break; + } + + v0 = v1; + v1 = v2; + } + ++li; + } + nassertr(vi == num_vertices, nullptr); + + // Now build up the new vertex data. For each edge, we insert the + // appropriate connecting vertex. + vi = -num_unused; + li = 0; + while (li < (int)ends.size()) { + // Skip unused vertices between tristrips. + vi += num_unused; + int end = ends[li]; + nassertr(vi + 2 <= end, nullptr); + + int v0 = from.get_vertex(vi++); + int v1 = from.get_vertex(vi++); + int v2; + adj->add_vertex(v0); + + // Get the third vertex of the triangle adjoining this edge. + auto it = edge_map.find(make_pair(v1, v0)); + if (it != edge_map.end()) { + adj->add_vertex(it->second); + } else { + // Um, no adjoining triangle? Just repeat the vertex, I guess. + adj->add_vertex(v0); + } + adj->add_vertex(v1); + + while (true) { + v2 = from.get_vertex(vi++); + it = edge_map.find(make_pair(v0, v2)); + if (it != edge_map.end()) { + adj->add_vertex(it->second); + } else { + adj->add_vertex(v1); + } + adj->add_vertex(v2); + + if (vi >= end) { + // Edge at the end of the strip + it = edge_map.find(make_pair(v2, v1)); + if (it != edge_map.end()) { + adj->add_vertex(it->second); + } else { + adj->add_vertex(v2); + } + break; + } + + v0 = v1; + v1 = v2; + v2 = from.get_vertex(vi++); + it = edge_map.find(make_pair(v2, v0)); + if (it != edge_map.end()) { + adj->add_vertex(it->second); + } else { + adj->add_vertex(v1); + } + adj->add_vertex(v2); + + if (vi >= end) { + // Edge at the end of the strip + it = edge_map.find(make_pair(v1, v2)); + if (it != edge_map.end()) { + adj->add_vertex(it->second); + } else { + adj->add_vertex(v1); + } + break; + } + + v0 = v1; + v1 = v2; + } + adj->close_primitive(); + ++li; + } + nassertr(vi == num_vertices, nullptr); + + return adj.p(); +} + /** * Returns the minimum number of vertices that must be added before * close_primitive() may legally be called. diff --git a/panda/src/gobj/geomTristrips.h b/panda/src/gobj/geomTristrips.h index 43e7364b22..86778a9976 100644 --- a/panda/src/gobj/geomTristrips.h +++ b/panda/src/gobj/geomTristrips.h @@ -31,6 +31,9 @@ public: virtual PT(GeomPrimitive) make_copy() const; virtual PrimitiveType get_primitive_type() const; virtual int get_geom_rendering() const; + + CPT(GeomPrimitive) make_adjacency() const; + virtual int get_min_num_vertices_per_primitive() const; virtual int get_num_unused_vertices_per_primitive() const; diff --git a/panda/src/gobj/geomTristripsAdjacency.cxx b/panda/src/gobj/geomTristripsAdjacency.cxx new file mode 100644 index 0000000000..eb8a4c2ad8 --- /dev/null +++ b/panda/src/gobj/geomTristripsAdjacency.cxx @@ -0,0 +1,161 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomTristripsAdjacency.cxx + * @author rdb + * @date 2018-03-01 + */ + +#include "geomTristripsAdjacency.h" +#include "geomTriangles.h" +#include "geomVertexRewriter.h" +#include "pStatTimer.h" +#include "bamReader.h" +#include "bamWriter.h" +#include "graphicsStateGuardianBase.h" + +TypeHandle GeomTristripsAdjacency::_type_handle; + +/** + * + */ +GeomTristripsAdjacency:: +GeomTristripsAdjacency(GeomTristripsAdjacency::UsageHint usage_hint) : + GeomPrimitive(usage_hint) +{ +} + +/** + * + */ +GeomTristripsAdjacency:: +GeomTristripsAdjacency(const GeomTristripsAdjacency ©) : + GeomPrimitive(copy) +{ +} + +/** + * + */ +GeomTristripsAdjacency:: +~GeomTristripsAdjacency() { +} + +/** + * + */ +PT(GeomPrimitive) GeomTristripsAdjacency:: +make_copy() const { + return new GeomTristripsAdjacency(*this); +} + +/** + * Returns the fundamental rendering type of this primitive: whether it is + * points, lines, or polygons. + * + * This is used to set up the appropriate antialiasing settings when + * AntialiasAttrib::M_auto is in effect; it also implies the type of primitive + * that will be produced when decompose() is called. + */ +GeomPrimitive::PrimitiveType GeomTristripsAdjacency:: +get_primitive_type() const { + return PT_polygons; +} + +/** + * Returns the set of GeomRendering bits that represent the rendering + * properties required to properly render this primitive. + */ +int GeomTristripsAdjacency:: +get_geom_rendering() const { + if (is_indexed()) { + if (get_num_primitives() > 1) { + return GR_triangle_strip | GR_indexed_other | GR_strip_cut_index | GR_adjacency; + } else { + return GR_triangle_strip | GR_indexed_other | GR_adjacency; + } + } else { + return GR_triangle_strip | GR_adjacency; + } +} + +/** + * Returns the minimum number of vertices that must be added before + * close_primitive() may legally be called. + */ +int GeomTristripsAdjacency:: +get_min_num_vertices_per_primitive() const { + return 6; +} + +/** + * Returns the number of vertices that are added between primitives that + * aren't, strictly speaking, part of the primitives themselves. This is + * used, for instance, to define degenerate triangles to connect otherwise + * disconnected triangle strips. + */ +int GeomTristripsAdjacency:: +get_num_unused_vertices_per_primitive() const { + return 1; +} + +/** + * Calls the appropriate method on the GSG to draw the primitive. + */ +bool GeomTristripsAdjacency:: +draw(GraphicsStateGuardianBase *gsg, const GeomPrimitivePipelineReader *reader, + bool force) const { + return gsg->draw_tristrips_adj(reader, force); +} + +/** + * Should be redefined to return true in any primitive that implements + * append_unused_vertices(). + */ +bool GeomTristripsAdjacency:: +requires_unused_vertices() const { + return true; +} + +/** + * Called when a new primitive is begun (other than the first primitive), this + * should add some degenerate vertices between primitives, if the primitive + * type requires that. The second parameter is the first vertex that begins + * the new primitive. + */ +void GeomTristripsAdjacency:: +append_unused_vertices(GeomVertexArrayData *vertices, int vertex) { + GeomVertexWriter to(vertices, 0); + to.set_row_unsafe(vertices->get_num_rows()); + to.add_data1i(get_strip_cut_index()); +} + +/** + * Tells the BamReader how to create objects of type Geom. + */ +void GeomTristripsAdjacency:: +register_with_read_factory() { + BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); +} + +/** + * This function is called by the BamReader's factory when a new object of + * type Geom is encountered in the Bam file. It should create the Geom and + * extract its information from the file. + */ +TypedWritable *GeomTristripsAdjacency:: +make_from_bam(const FactoryParams ¶ms) { + GeomTristripsAdjacency *object = new GeomTristripsAdjacency(UH_unspecified); + DatagramIterator scan; + BamReader *manager; + + parse_params(params, scan, manager); + object->fillin(scan, manager); + + return object; +} diff --git a/panda/src/gobj/geomTristripsAdjacency.h b/panda/src/gobj/geomTristripsAdjacency.h new file mode 100644 index 0000000000..7811079401 --- /dev/null +++ b/panda/src/gobj/geomTristripsAdjacency.h @@ -0,0 +1,73 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomTristripsAdjacency.h + * @author rdb + * @date 2018-03-01 + */ + +#ifndef GEOMTRISTRIPSADJACENCY_H +#define GEOMTRISTRIPSADJACENCY_H + +#include "pandabase.h" +#include "geomPrimitive.h" + +/** + * Defines a series of triangle strips. + */ +class EXPCL_PANDA_GOBJ GeomTristripsAdjacency : public GeomPrimitive { +PUBLISHED: + explicit GeomTristripsAdjacency(UsageHint usage_hint); + GeomTristripsAdjacency(const GeomTristripsAdjacency ©); + virtual ~GeomTristripsAdjacency(); + ALLOC_DELETED_CHAIN(GeomTristripsAdjacency); + +public: + virtual PT(GeomPrimitive) make_copy() const; + virtual PrimitiveType get_primitive_type() const; + virtual int get_geom_rendering() const; + virtual int get_min_num_vertices_per_primitive() const; + virtual int get_num_unused_vertices_per_primitive() const; + +public: + virtual bool draw(GraphicsStateGuardianBase *gsg, + const GeomPrimitivePipelineReader *reader, + bool force) const; + +protected: + virtual bool requires_unused_vertices() const; + virtual void append_unused_vertices(GeomVertexArrayData *vertices, + int vertex); + +public: + static void register_with_read_factory(); + +protected: + static TypedWritable *make_from_bam(const FactoryParams ¶ms); + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + GeomPrimitive::init_type(); + register_type(_type_handle, "GeomTristripsAdjacency", + GeomPrimitive::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; + + friend class Geom; +}; + +#endif diff --git a/panda/src/gobj/p3gobj_composite1.cxx b/panda/src/gobj/p3gobj_composite1.cxx index a18171f215..1c874b455d 100644 --- a/panda/src/gobj/p3gobj_composite1.cxx +++ b/panda/src/gobj/p3gobj_composite1.cxx @@ -10,14 +10,18 @@ #include "geomContext.cxx" #include "geomEnums.cxx" #include "geomLines.cxx" +#include "geomLinesAdjacency.cxx" #include "geomLinestrips.cxx" +#include "geomLinestripsAdjacency.cxx" #include "geomMunger.cxx" #include "geomPatches.cxx" #include "geomPoints.cxx" #include "geomPrimitive.cxx" #include "geomTriangles.cxx" +#include "geomTrianglesAdjacency.cxx" #include "geomTrifans.cxx" #include "geomTristrips.cxx" +#include "geomTristripsAdjacency.cxx" #include "geomVertexAnimationSpec.cxx" #include "geomVertexArrayData.cxx" #include "geomVertexArrayFormat.cxx" diff --git a/panda/src/gsgbase/graphicsStateGuardianBase.h b/panda/src/gsgbase/graphicsStateGuardianBase.h index 45bf35b958..e993b74de2 100644 --- a/panda/src/gsgbase/graphicsStateGuardianBase.h +++ b/panda/src/gsgbase/graphicsStateGuardianBase.h @@ -201,11 +201,15 @@ public: const GeomVertexDataPipelineReader *data_reader, bool force)=0; virtual bool draw_triangles(const GeomPrimitivePipelineReader *reader, bool force)=0; + virtual bool draw_triangles_adj(const GeomPrimitivePipelineReader *reader, bool force)=0; virtual bool draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force)=0; + virtual bool draw_tristrips_adj(const GeomPrimitivePipelineReader *reader, bool force)=0; virtual bool draw_trifans(const GeomPrimitivePipelineReader *reader, bool force)=0; virtual bool draw_patches(const GeomPrimitivePipelineReader *reader, bool force)=0; virtual bool draw_lines(const GeomPrimitivePipelineReader *reader, bool force)=0; + virtual bool draw_lines_adj(const GeomPrimitivePipelineReader *reader, bool force)=0; virtual bool draw_linestrips(const GeomPrimitivePipelineReader *reader, bool force)=0; + virtual bool draw_linestrips_adj(const GeomPrimitivePipelineReader *reader, bool force)=0; virtual bool draw_points(const GeomPrimitivePipelineReader *reader, bool force)=0; virtual void end_draw_primitives()=0; diff --git a/tests/gobj/test_geom_primitives.py b/tests/gobj/test_geom_primitives.py new file mode 100644 index 0000000000..49cce11e31 --- /dev/null +++ b/tests/gobj/test_geom_primitives.py @@ -0,0 +1,83 @@ +from panda3d import core + + +def test_geom_triangles_adjacency(): + prim = core.GeomTriangles(core.GeomEnums.UH_static) + prim.add_vertex(0) + prim.add_vertex(1) + prim.add_vertex(2) + prim.close_primitive() + prim.add_vertex(2) + prim.add_vertex(1) + prim.add_vertex(3) + prim.close_primitive() + + adj = prim.make_adjacency() + verts = adj.get_vertex_list() + assert tuple(verts) == ( + 0, 0, 1, 3, 2, 2, + 2, 0, 1, 1, 3, 3, + ) + + +def test_geom_lines_adjacency(): + prim = core.GeomLines(core.GeomEnums.UH_static) + prim.add_vertex(0) + prim.add_vertex(1) + prim.close_primitive() + prim.add_vertex(1) + prim.add_vertex(2) + prim.close_primitive() + prim.add_vertex(2) + prim.add_vertex(3) + prim.close_primitive() + + adj = prim.make_adjacency() + verts = adj.get_vertex_list() + assert tuple(verts) == ( + 0, 0, 1, 2, + 0, 1, 2, 3, + 1, 2, 3, 3, + ) + + +def test_geom_linestrips_adjacency(): + prim = core.GeomLinestrips(core.GeomEnums.UH_static) + prim.add_vertex(0) + prim.add_vertex(1) + prim.close_primitive() + prim.add_vertex(1) + prim.add_vertex(2) + prim.add_vertex(3) + prim.close_primitive() + prim.add_vertex(3) + prim.add_vertex(4) + prim.add_vertex(5) + prim.add_vertex(6) + prim.close_primitive() + + adj = prim.make_adjacency() + verts = adj.get_vertex_list() + cut = adj.get_strip_cut_index() + assert tuple(verts) == ( + 0, 0, 1, 2, + cut, + 0, 1, 2, 3, 4, + cut, + 2, 3, 4, 5, 6, 6, + ) + + # Check that it decomposes properly to a lines-adjacency primitive + prim = adj.decompose() + assert isinstance(prim, core.GeomLinesAdjacency) + verts = prim.get_vertex_list() + assert tuple(verts) == ( + 0, 0, 1, 2, + + 0, 1, 2, 3, + 1, 2, 3, 4, + + 2, 3, 4, 5, + 3, 4, 5, 6, + 4, 5, 6, 6, + ) From 8ad4c8e23c3f3554ef2d43866530af3e3441920c Mon Sep 17 00:00:00 2001 From: deflected Date: Thu, 1 Mar 2018 23:16:37 +0200 Subject: [PATCH 060/247] bullet: Fixed deadlock when loading from collision solids - Fixed deadlock when loading ghost nodes from collision solids and have non-identity scale applied. Signed-off-by: deflected --- panda/src/bullet/bulletGhostNode.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/bullet/bulletGhostNode.cxx b/panda/src/bullet/bulletGhostNode.cxx index 39740ff5a1..14b693bda6 100644 --- a/panda/src/bullet/bulletGhostNode.cxx +++ b/panda/src/bullet/bulletGhostNode.cxx @@ -97,7 +97,7 @@ do_transform_changed() { if (ts->has_scale()) { LVecBase3 scale = ts->get_scale(); if (!scale.almost_equal(LVecBase3(1.0f, 1.0f, 1.0f))) { - for (int i=0; ido_set_local_scale(scale); } From ac8417ffdf0f253d8c2653b9a27becee1833778c Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 4 Mar 2018 15:28:39 -0700 Subject: [PATCH 061/247] distributed: `type(x) == types.FooType` -> `inspect.isfoo(x)` This is more compatible across Python 2 vs. 3. [skip ci] --- direct/src/distributed/ConnectionRepository.py | 8 ++++---- direct/src/distributed/ServerRepository.py | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/direct/src/distributed/ConnectionRepository.py b/direct/src/distributed/ConnectionRepository.py index 4d6dec5b81..974c611bcc 100644 --- a/direct/src/distributed/ConnectionRepository.py +++ b/direct/src/distributed/ConnectionRepository.py @@ -7,7 +7,7 @@ from direct.distributed.DoCollectionManager import DoCollectionManager from direct.showbase import GarbageReport from .PyDatagramIterator import PyDatagramIterator -import types +import inspect import gc __all__ = ["ConnectionRepository", "GCTrigger"] @@ -327,13 +327,13 @@ class ConnectionRepository( if classDef is None: self.notify.debug("No class definition for %s." % (className)) else: - if type(classDef) == types.ModuleType: + if inspect.ismodule(classDef): if not hasattr(classDef, className): self.notify.warning("Module %s does not define class %s." % (className, className)) continue classDef = getattr(classDef, className) - if type(classDef) != types.ClassType and type(classDef) != types.TypeType: + if inspect.isclass(classDef): self.notify.error("Symbol %s is not a class name." % (className)) else: dclass.setClassDef(classDef) @@ -388,7 +388,7 @@ class ConnectionRepository( if classDef is None: self.notify.error("No class definition for %s." % className) else: - if type(classDef) == types.ModuleType: + if inspect.ismodule(classDef): if not hasattr(classDef, className): self.notify.error("Module %s does not define class %s." % (className, className)) classDef = getattr(classDef, className) diff --git a/direct/src/distributed/ServerRepository.py b/direct/src/distributed/ServerRepository.py index 4031998b50..7783e2860b 100644 --- a/direct/src/distributed/ServerRepository.py +++ b/direct/src/distributed/ServerRepository.py @@ -7,6 +7,8 @@ from direct.task import Task from direct.directnotify import DirectNotifyGlobal from direct.distributed.PyDatagram import PyDatagram +import inspect + class ServerRepository: @@ -273,12 +275,12 @@ class ServerRepository: if classDef == None: self.notify.debug("No class definition for %s." % (className)) else: - if type(classDef) == types.ModuleType: + if inspect.ismodule(classDef): if not hasattr(classDef, className): self.notify.error("Module %s does not define class %s." % (className, className)) classDef = getattr(classDef, className) - if type(classDef) != types.ClassType and type(classDef) != types.TypeType: + if inspect.isclass(classDef): self.notify.error("Symbol %s is not a class name." % (className)) else: dclass.setClassDef(classDef) From 013af2ac4b5f9a0804864b90fa57e5108f98c469 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 4 Mar 2018 20:28:09 -0700 Subject: [PATCH 062/247] dtool: Delete 'newheader' This is a task better handled by editors/scripts. [skip ci] --- dtool/src/newheader/newheader.cxx | 108 ------------------------------ 1 file changed, 108 deletions(-) delete mode 100644 dtool/src/newheader/newheader.cxx diff --git a/dtool/src/newheader/newheader.cxx b/dtool/src/newheader/newheader.cxx deleted file mode 100644 index 2e97dbb031..0000000000 --- a/dtool/src/newheader/newheader.cxx +++ /dev/null @@ -1,108 +0,0 @@ -/** - * PANDA 3D SOFTWARE - * Copyright (c) Carnegie Mellon University. All rights reserved. - * - * All use of this software is subject to the terms of the revised BSD - * license. You should have received a copy of this license along - * with this source code in a file named "LICENSE." - * - * @file newheader.cxx - * @author drose - * @date 2004-07-05 - */ - -#include "dtoolbase.h" - -#include -#include -#include - -const char *cxx_style = -"// Filename: %s\n" -"// Created by: %s (%s)\n" -"//\n" -"////////////////////////////////////////////////////////////////////\n" -"//\n" -"// PANDA 3D SOFTWARE\n" -"// Copyright (c) Carnegie Mellon University. All rights reserved.\n" -"//\n" -"// All use of this software is subject to the terms of the revised BSD\n" -"// license. You should have received a copy of this license along\n" -"// with this source code in a file named \"LICENSE.\"\n" -"//\n" -"////////////////////////////////////////////////////////////////////\n" -"\n"; - -const char *c_style = -"/* Filename: %s\n" -" * Created by: %s (%s)\n" -" *\n" -" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n" -" *\n" -" * PANDA 3D SOFTWARE\n" -" * Copyright (c) Carnegie Mellon University. All rights reserved.\n" -" *\n" -" * All use of this software is subject to the terms of the revised BSD\n" -" * license. You should have received a copy of this license along\n" -" * with this source code in a file named \"LICENSE.\"\n" -" *\n" -" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n" -"\n"; - -struct FileDef { - const char *extension; - const char *header; -}; - -FileDef file_def[] = { - { "h", cxx_style }, - { "cxx", cxx_style }, - { "I", cxx_style }, - { "T", cxx_style }, - { "c", c_style }, - { NULL, NULL }, -}; - -void -generate_header(const char *header, const string &filename) { - const char *username = getenv("USER"); - if (username == NULL) { - username = ""; - } - - static const size_t max_date_buffer = 128; - char date_buffer[max_date_buffer]; - time_t now = time(NULL); - strftime(date_buffer, max_date_buffer, "%d%b%y", localtime(&now)); - - printf(header, filename.c_str(), username, date_buffer); -} - -int -main(int argc, char *argv[]) { - if (argc < 2) { - cerr << "Must specify the filename to generate a header for.\n"; - exit(1); - } - - string filename = argv[1]; - size_t dot = filename.rfind('.'); - if (dot == string::npos) { - // No extension, no header. - return 0; - } - - string extension = filename.substr(dot + 1); - - size_t i = 0; - while (file_def[i].extension != NULL) { - if (extension == file_def[i].extension) { - generate_header(file_def[i].header, filename); - return 0; - } - i++; - } - - // No matching extension, no problem. - return 0; -} From ebe9e75d849600a061fad31e2a2930811a1cb92b Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 4 Mar 2018 20:28:51 -0700 Subject: [PATCH 063/247] dtoolbase: Delete unused preprocessor macro [skip ci] --- dtool/src/dtoolbase/dtoolsymbols.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/dtool/src/dtoolbase/dtoolsymbols.h b/dtool/src/dtoolbase/dtoolsymbols.h index 971a13ce32..892e1a9fff 100644 --- a/dtool/src/dtoolbase/dtoolsymbols.h +++ b/dtool/src/dtoolbase/dtoolsymbols.h @@ -67,8 +67,6 @@ can define all of these stupid symbols to the empty string. */ -#define EXPCL_EMPTY - #ifdef BUILDING_DTOOL #define EXPCL_DTOOL EXPORT_CLASS #define EXPTP_DTOOL EXPORT_TEMPL From d088341da1a45cf47d27988d27c1a516415d2127 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 5 Mar 2018 02:22:20 -0700 Subject: [PATCH 064/247] bam: Log object IDs when spamming read --- panda/src/putil/bamReader.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/panda/src/putil/bamReader.cxx b/panda/src/putil/bamReader.cxx index 30ad07415a..3ab1386d7f 100644 --- a/panda/src/putil/bamReader.cxx +++ b/panda/src/putil/bamReader.cxx @@ -1278,7 +1278,8 @@ p_read_object() { } else { if (bam_cat.is_spam()) { bam_cat.spam() - << "Read a " << object->get_type() << ": " << (void *)object << "\n"; + << "Read a " << object->get_type() << ": " << (void *)object + << " (id=" << object_id << ")\n"; } } } From 74bb2fef2e20d743974f696579e00bab5d48ebd3 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 5 Mar 2018 04:05:19 -0700 Subject: [PATCH 065/247] bam: Fix typo in ClipPlaneAttrib::fillin --- panda/src/pgraph/clipPlaneAttrib.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/pgraph/clipPlaneAttrib.cxx b/panda/src/pgraph/clipPlaneAttrib.cxx index 2b45be735a..aca61c8bc9 100644 --- a/panda/src/pgraph/clipPlaneAttrib.cxx +++ b/panda/src/pgraph/clipPlaneAttrib.cxx @@ -1017,7 +1017,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _on_planes.resize(num_on_planes); if (manager->get_file_minor_ver() >= 40) { for (int i = 0; i < num_on_planes; i++) { - manager->read_pointer(scan); + _on_planes[i].fillin(scan, manager); } } else { manager->read_pointers(scan, num_on_planes); From fd6eebb7fe88651e71219f70b7a9d2286d0f0043 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 5 Mar 2018 05:21:30 -0700 Subject: [PATCH 066/247] bam: Fix circular reference with ClipPlaneAttrib What's being addressed here is the circumstance where an ancestor of a PlaneNode has a ClipPlaneAttrib that references said PlaneNode. The code here is just being copied out of LightAttrib, which has the exact same mode of operation (it nominates a sorted list of on/off NodePaths) and a compatible structure. LightAttrib has had this problem in the past, so using the same solution makes sense. --- panda/src/pgraph/clipPlaneAttrib.cxx | 135 ++++++++++++++++----------- panda/src/pgraph/clipPlaneAttrib.h | 17 +++- 2 files changed, 99 insertions(+), 53 deletions(-) diff --git a/panda/src/pgraph/clipPlaneAttrib.cxx b/panda/src/pgraph/clipPlaneAttrib.cxx index aca61c8bc9..726b5472b7 100644 --- a/panda/src/pgraph/clipPlaneAttrib.cxx +++ b/panda/src/pgraph/clipPlaneAttrib.cxx @@ -900,12 +900,52 @@ write_datagram(BamWriter *manager, Datagram &dg) { int ClipPlaneAttrib:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = RenderAttrib::complete_pointers(p_list, manager); - AttribNodeRegistry *areg = AttribNodeRegistry::get_global_ptr(); if (manager->get_file_minor_ver() >= 40) { for (size_t i = 0; i < _off_planes.size(); ++i) { pi += _off_planes[i].complete_pointers(p_list + pi, manager); + } + for (size_t i = 0; i < _on_planes.size(); ++i) { + pi += _on_planes[i].complete_pointers(p_list + pi, manager); + } + + } else { + BamAuxData *aux = (BamAuxData *)manager->get_aux_data(this, "planes"); + nassertr(aux != NULL, pi); + + int i; + aux->_off_list.reserve(aux->_num_off_planes); + for (i = 0; i < aux->_num_off_planes; ++i) { + PandaNode *node; + DCAST_INTO_R(node, p_list[pi++], pi); + aux->_off_list.push_back(node); + } + + aux->_on_list.reserve(aux->_num_on_planes); + for (i = 0; i < aux->_num_on_planes; ++i) { + PandaNode *node; + DCAST_INTO_R(node, p_list[pi++], pi); + aux->_on_list.push_back(node); + } + } + + return pi; +} + +/** + * Called by the BamReader to perform any final actions needed for setting up + * the object after all objects have been read and all pointers have been + * completed. + */ +void ClipPlaneAttrib:: +finalize(BamReader *manager) { + if (manager->get_file_minor_ver() >= 40) { + AttribNodeRegistry *areg = AttribNodeRegistry::get_global_ptr(); + + // Check if any of the nodes we loaded are mentioned in the + // AttribNodeRegistry. If so, replace them. + for (size_t i = 0; i < _off_planes.size(); ++i) { int n = areg->find_node(_off_planes[i]); if (n != -1) { // If it's in the registry, replace it. @@ -914,8 +954,6 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { } for (size_t i = 0; i < _on_planes.size(); ++i) { - pi += _on_planes[i].complete_pointers(p_list + pi, manager); - int n = areg->find_node(_on_planes[i]); if (n != -1) { // If it's in the registry, replace it. @@ -924,53 +962,46 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { } } else { - Planes::iterator ci = _off_planes.begin(); - while (ci != _off_planes.end()) { - PandaNode *node; - DCAST_INTO_R(node, p_list[pi++], pi); + // Now it's safe to convert our saved PandaNodes into NodePaths. + BamAuxData *aux = (BamAuxData *)manager->get_aux_data(this, "planes"); + nassertv(aux != NULL); + nassertv(aux->_num_off_planes == (int)aux->_off_list.size()); + nassertv(aux->_num_on_planes == (int)aux->_on_list.size()); - // We go through some effort to look up the node in the registry without - // creating a NodePath around it first (which would up, and then down, - // the reference count, possibly deleting the node). - int ni = areg->find_node(node->get_type(), node->get_name()); - if (ni != -1) { - (*ci) = areg->get_node(ni); + AttribNodeRegistry *areg = AttribNodeRegistry::get_global_ptr(); + + _off_planes.reserve(aux->_off_list.size()); + NodeList::iterator ni; + for (ni = aux->_off_list.begin(); ni != aux->_off_list.end(); ++ni) { + PandaNode *node = (*ni); + int n = areg->find_node(node->get_type(), node->get_name()); + if (n != -1) { + // If it's in the registry, add that NodePath. + _off_planes.push_back(areg->get_node(n)); } else { - (*ci) = NodePath(node); + // Otherwise, add any arbitrary NodePath. Complain if it's ambiguous. + _off_planes.push_back(NodePath(node)); } - ++ci; } - ci = _on_planes.begin(); - while (ci != _on_planes.end()) { - PandaNode *node; - DCAST_INTO_R(node, p_list[pi++], pi); - - int ni = areg->find_node(node->get_type(), node->get_name()); - if (ni != -1) { - (*ci) = areg->get_node(ni); + _on_planes.reserve(aux->_on_list.size()); + for (ni = aux->_on_list.begin(); ni != aux->_on_list.end(); ++ni) { + PandaNode *node = (*ni); + int n = areg->find_node(node->get_type(), node->get_name()); + if (n != -1) { + // If it's in the registry, add that NodePath. + _on_planes.push_back(areg->get_node(n)); + node = _on_planes.back().node(); } else { - (*ci) = NodePath(node); + // Otherwise, add any arbitrary NodePath. Complain if it's ambiguous. + _on_planes.push_back(NodePath(node)); } - ++ci; } } + // Now that the NodePaths have been filled in, we can sort the list. _off_planes.sort(); _on_planes.sort(); - - return pi; -} - -/** - * Some objects require all of their nested pointers to have been completed - * before the objects themselves can be completed. If this is the case, - * override this method to return true, and be careful with circular - * references (which would make the object unreadable from a bam file). - */ -bool ClipPlaneAttrib:: -require_fully_complete() const { - return true; } /** @@ -987,6 +1018,8 @@ make_from_bam(const FactoryParams ¶ms) { parse_params(params, scan, manager); attrib->fillin(scan, manager); + manager->register_finalize(attrib); + return attrib; } @@ -1000,26 +1033,24 @@ fillin(DatagramIterator &scan, BamReader *manager) { _off_all_planes = scan.get_bool(); - int num_off_planes = scan.get_uint16(); - - // Push back an empty NodePath for each off Plane for now, until we get the - // actual list of pointers later in complete_pointers(). - _off_planes.resize(num_off_planes); if (manager->get_file_minor_ver() >= 40) { - for (int i = 0; i < num_off_planes; i++) { + _off_planes.resize(scan.get_uint16()); + for (size_t i = 0; i < _off_planes.size(); ++i) { _off_planes[i].fillin(scan, manager); } - } else { - manager->read_pointers(scan, num_off_planes); - } - int num_on_planes = scan.get_uint16(); - _on_planes.resize(num_on_planes); - if (manager->get_file_minor_ver() >= 40) { - for (int i = 0; i < num_on_planes; i++) { + _on_planes.resize(scan.get_uint16()); + for (size_t i = 0; i < _on_planes.size(); ++i) { _on_planes[i].fillin(scan, manager); } } else { - manager->read_pointers(scan, num_on_planes); + BamAuxData *aux = new BamAuxData; + manager->set_aux_data(this, "planes", aux); + + aux->_num_off_planes = scan.get_uint16(); + manager->read_pointers(scan, aux->_num_off_planes); + + aux->_num_on_planes = scan.get_uint16(); + manager->read_pointers(scan, aux->_num_on_planes); } } diff --git a/panda/src/pgraph/clipPlaneAttrib.h b/panda/src/pgraph/clipPlaneAttrib.h index ca95233b79..b59bb34f9b 100644 --- a/panda/src/pgraph/clipPlaneAttrib.h +++ b/panda/src/pgraph/clipPlaneAttrib.h @@ -125,11 +125,26 @@ PUBLISHED: } MAKE_PROPERTY(class_slot, get_class_slot); +public: + // This data is only needed when reading from a bam file. + typedef pvector NodeList; + class BamAuxData : public BamReader::AuxData { + public: + // We hold a pointer to each of the PandaNodes on the on_list and + // off_list. We will later convert these to NodePaths in + // finalize(). + int _num_off_planes; + int _num_on_planes; + NodeList _off_list; + NodeList _on_list; + }; + public: static void register_with_read_factory(); virtual void write_datagram(BamWriter *manager, Datagram &dg); virtual int complete_pointers(TypedWritable **plist, BamReader *manager); - virtual bool require_fully_complete() const; + + virtual void finalize(BamReader *manager); protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); From 1b1c76b2e84bc4aa27a978d8f071c482e3275ac2 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 5 Mar 2018 06:10:11 -0700 Subject: [PATCH 067/247] pgraph: Fix "Unknown render mode 5" errors This happened when a M_dual transparent object is given the M_filled_wireframe render attrib. M_dual would copy the transparent parts of the object to the transparent back-to-front bin, before the M_filled_wireframe handler could deal with the M_filled_wireframe flag. The solution is just to switch the order - let M_filled_wireframe be dealt with before the transparency code gets a chance to make a copy. --- panda/src/pgraph/cullResult.cxx | 46 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/panda/src/pgraph/cullResult.cxx b/panda/src/pgraph/cullResult.cxx index 0118888108..7dbe002c9e 100644 --- a/panda/src/pgraph/cullResult.cxx +++ b/panda/src/pgraph/cullResult.cxx @@ -128,6 +128,29 @@ add_object(CullableObject *object, const CullTraverser *traverser) { object->_state = object->_state->compose(get_rescale_normal_state(mode)); } + // Check for a special wireframe setting. + const RenderModeAttrib *rmode; + if (object->_state->get_attrib(rmode)) { + if (rmode->get_mode() == RenderModeAttrib::M_filled_wireframe) { + CullableObject *wireframe_part = new CullableObject(*object); + wireframe_part->_state = get_wireframe_overlay_state(rmode); + + if (wireframe_part->munge_geom + (_gsg, _gsg->get_geom_munger(wireframe_part->_state, current_thread), + traverser, force)) { + int wireframe_bin_index = bin_manager->find_bin("fixed"); + CullBin *bin = get_bin(wireframe_bin_index); + nassertv(bin != (CullBin *)NULL); + check_flash_bin(wireframe_part->_state, bin_manager, wireframe_bin_index); + bin->add_object(wireframe_part, current_thread); + } else { + delete wireframe_part; + } + + object->_state = object->_state->compose(get_wireframe_filled_state()); + } + } + // Check to see if there's a special transparency setting. const TransparencyAttrib *trans; if (object->_state->get_attrib(trans)) { @@ -216,29 +239,6 @@ add_object(CullableObject *object, const CullTraverser *traverser) { } } - // Check for a special wireframe setting. - const RenderModeAttrib *rmode; - if (object->_state->get_attrib(rmode)) { - if (rmode->get_mode() == RenderModeAttrib::M_filled_wireframe) { - CullableObject *wireframe_part = new CullableObject(*object); - wireframe_part->_state = get_wireframe_overlay_state(rmode); - - if (wireframe_part->munge_geom - (_gsg, _gsg->get_geom_munger(wireframe_part->_state, current_thread), - traverser, force)) { - int wireframe_bin_index = bin_manager->find_bin("fixed"); - CullBin *bin = get_bin(wireframe_bin_index); - nassertv(bin != (CullBin *)NULL); - check_flash_bin(wireframe_part->_state, bin_manager, wireframe_bin_index); - bin->add_object(wireframe_part, current_thread); - } else { - delete wireframe_part; - } - - object->_state = object->_state->compose(get_wireframe_filled_state()); - } - } - int bin_index = object->_state->get_bin_index(); CullBin *bin = get_bin(bin_index); nassertv(bin != (CullBin *)NULL); From 89799bc024fbc3092ef40bf7a0bb735044c4aec7 Mon Sep 17 00:00:00 2001 From: Michael Wass Date: Mon, 5 Mar 2018 20:32:27 -0500 Subject: [PATCH 068/247] direct: Fix some NameErrors Squashed merge of GitHub PR #273 --- direct/src/interval/MetaInterval.py | 1 - direct/src/showbase/ObjectPool.py | 9 --------- 2 files changed, 10 deletions(-) diff --git a/direct/src/interval/MetaInterval.py b/direct/src/interval/MetaInterval.py index fd379280a7..259d7f66a3 100644 --- a/direct/src/interval/MetaInterval.py +++ b/direct/src/interval/MetaInterval.py @@ -342,7 +342,6 @@ class MetaInterval(CMetaInterval): # with all of their associated Python callbacks: def setManager(self, manager): - rogerroger self.__manager = manager CMetaInterval.setManager(self, manager) diff --git a/direct/src/showbase/ObjectPool.py b/direct/src/showbase/ObjectPool.py index e5970803ab..e82e6cdaae 100755 --- a/direct/src/showbase/ObjectPool.py +++ b/direct/src/showbase/ObjectPool.py @@ -110,15 +110,6 @@ class ObjectPool: print('TYPE: %s, %s objects' % (repr(typ), len(self._type2objs[typ]))) print(getNumberedTypedSortedString(self._type2objs[typ])) - def containerLenStr(self): - s = 'Object Pool: Container Lengths' - s += '\n==============================' - lengths = list(self._len2obj.keys()) - lengths.sort() - lengths.reverse() - for count in counts: - pass - def printReferrers(self, numEach=3): """referrers of the first few of each type of object""" counts = list(set(self._count2types.keys())) From 1862100baca2c8d5e3a4e0f2268ba30bcf7b7b9e Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 1 Mar 2018 14:55:41 -0700 Subject: [PATCH 069/247] openal: Don't assume alSourceUnqueueBuffers is FIFO --- panda/src/audiotraits/openalAudioSound.cxx | 40 +++++++++++++++------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/panda/src/audiotraits/openalAudioSound.cxx b/panda/src/audiotraits/openalAudioSound.cxx index d3c5ff7291..da04514e8b 100644 --- a/panda/src/audiotraits/openalAudioSound.cxx +++ b/panda/src/audiotraits/openalAudioSound.cxx @@ -446,18 +446,34 @@ pull_used_buffers() { int err = alGetError(); if (err == AL_NO_ERROR) { if (_stream_queued[0]._buffer != buffer) { - audio_error("corruption in stream queue"); - cleanup(); - return; - } - _stream_queued.pop_front(); - if (_stream_queued.size()) { - double al = _stream_queued[0]._time_offset + _stream_queued[0]._loop_index * _length; - double rtc = TrueClock::get_global_ptr()->get_short_time(); - correct_calibrated_clock(rtc, al); - } - if (buffer != _sd->_sample) { - alDeleteBuffers(1,&buffer); + // This is certainly atypical: most implementations of OpenAL unqueue + // buffers in FIFO order. However, some (e.g. Apple's) can unqueue + // buffers out-of-order if playback is interrupted. So, we don't freak + // out unless `buffer` isn't in _stream_queued at all. + bool found_culprit = false; + for (auto it = _stream_queued.begin(); it != _stream_queued.end(); ++it) { + if (it->_buffer == buffer) { + // Phew. Found it. Just remove that. + _stream_queued.erase(it); + found_culprit = true; + break; + } + } + if (!found_culprit) { + audio_error("corruption in stream queue"); + cleanup(); + return; + } + } else { + _stream_queued.pop_front(); + if (_stream_queued.size()) { + double al = _stream_queued[0]._time_offset + _stream_queued[0]._loop_index * _length; + double rtc = TrueClock::get_global_ptr()->get_short_time(); + correct_calibrated_clock(rtc, al); + } + if (buffer != _sd->_sample) { + alDeleteBuffers(1,&buffer); + } } } else { break; From 6ca0a68042c8affa4f105db0d6b00695418b2fbb Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 1 Mar 2018 16:44:46 -0700 Subject: [PATCH 070/247] openal: Retry deleting a buffer until success The rationale for this change is Apple's OpenAL implementation, which needs a little time after the `alSourcei(source, AL_BUFFER, 0);` call before any buffers used by that source are free for deletion. The defaults in the config variables are such that the OpenAL manager will attempt to delete a buffer up to 6 times (that is, the original attempt plus 5 reattempts), with delays of 1ms, 2ms, 4ms, 8ms, and 16ms before each reattempt - which means it'll wait a grand total of 31ms for a buffer to be free before assuming that some even greater problem must be happening and giving up. --- panda/src/audiotraits/config_openalAudio.cxx | 17 ++++++++ panda/src/audiotraits/config_openalAudio.h | 2 + panda/src/audiotraits/openalAudioManager.cxx | 41 +++++++++++++++++++- panda/src/audiotraits/openalAudioManager.h | 2 + panda/src/audiotraits/openalAudioSound.cxx | 5 +-- 5 files changed, 63 insertions(+), 4 deletions(-) diff --git a/panda/src/audiotraits/config_openalAudio.cxx b/panda/src/audiotraits/config_openalAudio.cxx index 4f9019c013..36803e7d04 100644 --- a/panda/src/audiotraits/config_openalAudio.cxx +++ b/panda/src/audiotraits/config_openalAudio.cxx @@ -30,6 +30,23 @@ ConfigVariableString openal_device PRC_DESC("Specify the OpenAL device string for audio playback (no quotes). If this " "is not specified, the OpenAL default device is used.")); +ConfigVariableInt openal_buffer_delete_reattempts +("openal-buffer-delete-reattempts", 5, + PRC_DESC("If deleting a buffer fails due to still being in use, the OpenAL " + "sound plugin will wait a moment and reattempt deletion, with an " + "exponentially-increasing delay for each attempt. This number " + "specifies how many repeat attempts (not counting the initial attempt) " + "should be made before giving up and raising an error.")); + +ConfigVariableDouble openal_buffer_delete_delay +("openal-buffer-delete-delay", 0.001, + PRC_DESC("If deleting a buffer fails due to still being in use, the OpenAL " + "sound plugin will wait a moment and reattempt deletion, with an " + "exponentially-increasing delay for each attempt. This number " + "specifies how long, in seconds, the OpenAL plugin will wait after " + "its first failed attempt. The second attempt will be double this " + "delay, the third quadruple, and so on.")); + /** * Initializes the library. This must be called at least once before any of diff --git a/panda/src/audiotraits/config_openalAudio.h b/panda/src/audiotraits/config_openalAudio.h index bcd8481acf..96d3429519 100644 --- a/panda/src/audiotraits/config_openalAudio.h +++ b/panda/src/audiotraits/config_openalAudio.h @@ -26,5 +26,7 @@ extern "C" EXPCL_OPENAL_AUDIO void init_libOpenALAudio(); extern "C" EXPCL_OPENAL_AUDIO Create_AudioManager_proc *get_audio_manager_func_openal_audio(); extern ConfigVariableString openal_device; +extern ConfigVariableInt openal_buffer_delete_reattempts; +extern ConfigVariableDouble openal_buffer_delete_delay; #endif // CONFIG_OPENALAUDIO_H diff --git a/panda/src/audiotraits/openalAudioManager.cxx b/panda/src/audiotraits/openalAudioManager.cxx index cbdaadbfa1..bc254d4791 100644 --- a/panda/src/audiotraits/openalAudioManager.cxx +++ b/panda/src/audiotraits/openalAudioManager.cxx @@ -1052,7 +1052,7 @@ OpenALAudioManager::SoundData:: if (_sample != 0) { if (_manager->_is_valid) { _manager->make_current(); - alDeleteBuffers(1,&_sample); + _manager->delete_buffer(_sample); } _sample = 0; } @@ -1128,3 +1128,42 @@ discard_excess_cache(int sample_limit) { delete sd; } } + +/** + * Deletes an OpenAL buffer. This is a special function because some + * implementations of OpenAL (e.g. Apple's) don't unlock the buffers + * immediately, due to needing to coordinate with another thread. If this is + * the case, the alDeleteBuffers call will error back with AL_INVALID_OPERATION + * as if trying to delete an actively-used buffer, which will tell us to wait a + * bit and try again. + */ +void OpenALAudioManager:: +delete_buffer(ALuint buffer) { + ReMutexHolder holder(_lock); + int attempt = 0; + ALuint error; + + // Keep trying until we succeed (or give up). + while (true) { + alDeleteBuffers(1, &buffer); + error = alGetError(); + + if (error == AL_NO_ERROR) { + // Success! This will happen right away 99% of the time. + return; + } else if (error != AL_INVALID_OPERATION) { + // We weren't expecting that. This should be reported. + break; + } else if (attempt >= openal_buffer_delete_reattempts.get_value()) { + // We ran out of reattempts. Give up. + break; + } else { + // Make another attempt after (delay * 2^n) seconds. + Thread::sleep(openal_buffer_delete_delay.get_value() * (1 << attempt)); + attempt++; + } + } + + // If we got here, one of the breaks above happened, indicating an error. + audio_error("failed to delete a buffer: " << alGetString(error) ); +} diff --git a/panda/src/audiotraits/openalAudioManager.h b/panda/src/audiotraits/openalAudioManager.h index 5917900869..1e16e4000b 100644 --- a/panda/src/audiotraits/openalAudioManager.h +++ b/panda/src/audiotraits/openalAudioManager.h @@ -129,6 +129,8 @@ private: void decrement_client_count(SoundData *sd); void discard_excess_cache(int limit); + void delete_buffer(ALuint buffer); + void starting_sound(OpenALAudioSound* audio); void stopping_sound(OpenALAudioSound* audio); diff --git a/panda/src/audiotraits/openalAudioSound.cxx b/panda/src/audiotraits/openalAudioSound.cxx index da04514e8b..86fc6e2bef 100644 --- a/panda/src/audiotraits/openalAudioSound.cxx +++ b/panda/src/audiotraits/openalAudioSound.cxx @@ -208,8 +208,7 @@ stop() { for (int i=0; i<((int)(_stream_queued.size())); i++) { ALuint buffer = _stream_queued[i]._buffer; if (buffer != _sd->_sample) { - alDeleteBuffers(1, &buffer); - al_audio_errcheck("deleting a buffer"); + _manager->delete_buffer(buffer); } } _stream_queued.resize(0); @@ -472,7 +471,7 @@ pull_used_buffers() { correct_calibrated_clock(rtc, al); } if (buffer != _sd->_sample) { - alDeleteBuffers(1,&buffer); + _manager->delete_buffer(buffer); } } } else { From fd5ce687b3f4b8bc7ba938dd78ea5874d167ce1c Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 1 Mar 2018 20:37:39 -0700 Subject: [PATCH 071/247] openal: Add cleanup guards to buffer functions Without this, the audio might encounter an error, call cleanup() on itself, and (if in the middle of update()) try to dereference its recently cleaned-up _sd pointer. Fixes #230 --- panda/src/audiotraits/openalAudioSound.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/panda/src/audiotraits/openalAudioSound.cxx b/panda/src/audiotraits/openalAudioSound.cxx index 86fc6e2bef..5922239a00 100644 --- a/panda/src/audiotraits/openalAudioSound.cxx +++ b/panda/src/audiotraits/openalAudioSound.cxx @@ -434,6 +434,7 @@ correct_calibrated_clock(double rtc, double t) { void OpenALAudioSound:: pull_used_buffers() { ReMutexHolder holder(OpenALAudioManager::_lock); + if (_manager == 0) return; while (_stream_queued.size()) { ALuint buffer = 0; ALint num_buffers = 0; @@ -489,6 +490,8 @@ push_fresh_buffers() { ReMutexHolder holder(OpenALAudioManager::_lock); static unsigned char data[65536]; + if (_manager == 0) return; + if (_sd->_sample) { while ((_loops_completed < _playing_loops) && (_stream_queued.size() < 100)) { From 1a6fb5300b296a815b9faeba9423184cffc16bd7 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 1 Mar 2018 21:09:32 -0700 Subject: [PATCH 072/247] openal: Be explicit about what constructs like `_sound != 0` mean --- panda/src/audiotraits/openalAudioSound.I | 30 ++++++++++++++++ panda/src/audiotraits/openalAudioSound.cxx | 42 +++++++++++----------- panda/src/audiotraits/openalAudioSound.h | 6 ++-- 3 files changed, 55 insertions(+), 23 deletions(-) diff --git a/panda/src/audiotraits/openalAudioSound.I b/panda/src/audiotraits/openalAudioSound.I index 1b7e56a82c..6263872e1a 100644 --- a/panda/src/audiotraits/openalAudioSound.I +++ b/panda/src/audiotraits/openalAudioSound.I @@ -63,3 +63,33 @@ release_sound_data() { _sd = 0; } } + +/** + * Checks if the sound has NOT been cleaned up yet. + */ +bool OpenALAudioSound:: +is_valid() const { + return _manager != NULL; +} + +/** + * Checks if the sound is playing. This is per the OpenALAudioManager's + * definition of "playing" -- as in, "will be called upon every update" + * + * This is mainly intended for use in asserts. + */ +bool OpenALAudioSound:: +is_playing() const { + // Manager only gives us a _source if we need it (to talk to OpenAL), so: + return _source != 0; +} + +/** + * Checks if the sound has its SoundData structure open at the moment. + * + * This is mainly intended for use in asserts. + */ +bool OpenALAudioSound:: +has_sound_data() const { + return _sd != 0; +} diff --git a/panda/src/audiotraits/openalAudioSound.cxx b/panda/src/audiotraits/openalAudioSound.cxx index 5922239a00..a79060cfb3 100644 --- a/panda/src/audiotraits/openalAudioSound.cxx +++ b/panda/src/audiotraits/openalAudioSound.cxx @@ -99,13 +99,13 @@ OpenALAudioSound:: void OpenALAudioSound:: cleanup() { ReMutexHolder holder(OpenALAudioManager::_lock); - if (_manager == 0) { + if (!is_valid()) { return; } - if (_source) { + if (is_playing()) { stop(); } - if (_sd) { + if (has_sound_data()) { _manager->decrement_client_count(_sd); _sd = 0; } @@ -119,7 +119,7 @@ cleanup() { void OpenALAudioSound:: play() { ReMutexHolder holder(OpenALAudioManager::_lock); - if (_manager == 0) return; + if (!is_valid()) return; PN_stdfloat px,py,pz,vx,vy,vz; @@ -136,7 +136,7 @@ play() { } _manager->starting_sound(this); - if (!_source) { + if (!is_playing()) { return; } @@ -195,9 +195,9 @@ play() { void OpenALAudioSound:: stop() { ReMutexHolder holder(OpenALAudioManager::_lock); - if (_manager==0) return; + if (!is_valid()) return; - if (_source) { + if (is_playing()) { _manager->make_current(); alGetError(); // clear errors @@ -254,7 +254,7 @@ get_loop() const { void OpenALAudioSound:: set_loop_count(unsigned long loop_count) { ReMutexHolder holder(OpenALAudioManager::_lock); - if (_manager==0) return; + if (!is_valid()) return; if (loop_count >= 1000000000) { loop_count = 0; @@ -434,7 +434,7 @@ correct_calibrated_clock(double rtc, double t) { void OpenALAudioSound:: pull_used_buffers() { ReMutexHolder holder(OpenALAudioManager::_lock); - if (_manager == 0) return; + if (!is_valid()) return; while (_stream_queued.size()) { ALuint buffer = 0; ALint num_buffers = 0; @@ -490,7 +490,7 @@ push_fresh_buffers() { ReMutexHolder holder(OpenALAudioManager::_lock); static unsigned char data[65536]; - if (_manager == 0) return; + if (!is_valid()) return; if (_sd->_sample) { while ((_loops_completed < _playing_loops) && @@ -517,9 +517,9 @@ push_fresh_buffers() { break; } ALuint buffer = make_buffer(samples, channels, rate, data); - if (_manager == 0) return; + if (!is_valid()) return; queue_buffer(buffer, samples, loop_index, time_offset); - if (_manager == 0) return; + if (!is_valid()) return; fill += samples; } } @@ -541,7 +541,7 @@ set_time(PN_stdfloat time) { PN_stdfloat OpenALAudioSound:: get_time() const { ReMutexHolder holder(OpenALAudioManager::_lock); - if (_manager == 0) { + if (!is_valid()) { return 0.0; } return _current_time; @@ -553,7 +553,7 @@ get_time() const { void OpenALAudioSound:: cache_time(double rtc) { ReMutexHolder holder(OpenALAudioManager::_lock); - assert(_source != 0); + assert(is_playing()); double t=get_calibrated_clock(rtc); double max = _length * _playing_loops; if (t >= max) { @@ -571,7 +571,7 @@ set_volume(PN_stdfloat volume) { ReMutexHolder holder(OpenALAudioManager::_lock); _volume=volume; - if (_source) { + if (is_playing()) { volume*=_manager->get_volume(); _manager->make_current(); alGetError(); // clear errors @@ -615,7 +615,7 @@ void OpenALAudioSound:: set_play_rate(PN_stdfloat play_rate) { ReMutexHolder holder(OpenALAudioManager::_lock); _play_rate = play_rate; - if (_source) { + if (is_playing()) { alSourcef(_source, AL_PITCH, play_rate); } } @@ -657,7 +657,7 @@ set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx _velocity[1] = vz; _velocity[2] = -vy; - if (_source) { + if (is_playing()) { _manager->make_current(); alGetError(); // clear errors @@ -693,7 +693,7 @@ set_3d_min_distance(PN_stdfloat dist) { ReMutexHolder holder(OpenALAudioManager::_lock); _min_dist = dist; - if (_source) { + if (is_playing()) { _manager->make_current(); alGetError(); // clear errors @@ -718,7 +718,7 @@ set_3d_max_distance(PN_stdfloat dist) { ReMutexHolder holder(OpenALAudioManager::_lock); _max_dist = dist; - if (_source) { + if (is_playing()) { _manager->make_current(); alGetError(); // clear errors @@ -743,7 +743,7 @@ set_3d_drop_off_factor(PN_stdfloat factor) { ReMutexHolder holder(OpenALAudioManager::_lock); _drop_off_factor = factor; - if (_source) { + if (is_playing()) { _manager->make_current(); alGetError(); // clear errors @@ -831,7 +831,7 @@ get_name() const { AudioSound::SoundStatus OpenALAudioSound:: status() const { ReMutexHolder holder(OpenALAudioManager::_lock); - if (_source==0) { + if (!is_playing()) { return AudioSound::READY; } if ((_loops_completed >= _playing_loops)&&(_stream_queued.size()==0)) { diff --git a/panda/src/audiotraits/openalAudioSound.h b/panda/src/audiotraits/openalAudioSound.h index f5b02667e5..b44a889445 100644 --- a/panda/src/audiotraits/openalAudioSound.h +++ b/panda/src/audiotraits/openalAudioSound.h @@ -119,9 +119,11 @@ private: INLINE bool require_sound_data(); INLINE void release_sound_data(); -private: + INLINE bool is_valid() const; + INLINE bool is_playing() const; + INLINE bool has_sound_data() const; - void do_stop(); +private: PT(MovieAudio) _movie; OpenALAudioManager::SoundData *_sd; From 9a5d7d82544f9f263c36d0ee09c8693cb74d55c4 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 1 Mar 2018 21:27:00 -0700 Subject: [PATCH 073/247] openal: Add several asserts This also includes a few slight style fixes. --- panda/src/audiotraits/openalAudioSound.cxx | 36 +++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/panda/src/audiotraits/openalAudioSound.cxx b/panda/src/audiotraits/openalAudioSound.cxx index a79060cfb3..d257fefd72 100644 --- a/panda/src/audiotraits/openalAudioSound.cxx +++ b/panda/src/audiotraits/openalAudioSound.cxx @@ -119,6 +119,7 @@ cleanup() { void OpenALAudioSound:: play() { ReMutexHolder holder(OpenALAudioManager::_lock); + if (!is_valid()) return; PN_stdfloat px,py,pz,vx,vy,vz; @@ -195,11 +196,14 @@ play() { void OpenALAudioSound:: stop() { ReMutexHolder holder(OpenALAudioManager::_lock); + if (!is_valid()) return; if (is_playing()) { _manager->make_current(); + assert(has_sound_data()); + alGetError(); // clear errors alSourceStop(_source); al_audio_errcheck("stopping a source"); @@ -224,6 +228,9 @@ stop() { void OpenALAudioSound:: finished() { ReMutexHolder holder(OpenALAudioManager::_lock); + + if (!is_valid()) return; + stop(); _current_time = _length; if (!_finished_event.empty()) { @@ -254,6 +261,7 @@ get_loop() const { void OpenALAudioSound:: set_loop_count(unsigned long loop_count) { ReMutexHolder holder(OpenALAudioManager::_lock); + if (!is_valid()) return; if (loop_count >= 1000000000) { @@ -281,9 +289,14 @@ void OpenALAudioSound:: restart_stalled_audio() { ReMutexHolder holder(OpenALAudioManager::_lock); ALenum status; + + if (!is_valid()) return; + assert(is_playing()); + if (_stream_queued.size() == 0) { return; } + alGetError(); alGetSourcei(_source, AL_SOURCE_STATE, &status); if (status != AL_PLAYING) { @@ -297,6 +310,9 @@ restart_stalled_audio() { void OpenALAudioSound:: queue_buffer(ALuint buffer, int samples, int loop_index, double time_offset) { ReMutexHolder holder(OpenALAudioManager::_lock); + + assert(is_playing()); + // Now push the buffer into the stream queue. alGetError(); alSourceQueueBuffers(_source,1,&buffer); @@ -321,6 +337,8 @@ ALuint OpenALAudioSound:: make_buffer(int samples, int channels, int rate, unsigned char *data) { ReMutexHolder holder(OpenALAudioManager::_lock); + assert(is_playing()); + // Allocate a buffer to hold the data. alGetError(); ALuint buffer; @@ -353,6 +371,8 @@ int OpenALAudioSound:: read_stream_data(int bytelen, unsigned char *buffer) { ReMutexHolder holder(OpenALAudioManager::_lock); + assert(has_sound_data()); + MovieAudioCursor *cursor = _sd->_stream; double length = cursor->length(); int channels = cursor->audio_channels(); @@ -403,6 +423,9 @@ read_stream_data(int bytelen, unsigned char *buffer) { void OpenALAudioSound:: correct_calibrated_clock(double rtc, double t) { ReMutexHolder holder(OpenALAudioManager::_lock); + + assert(is_playing()); + double cc = (rtc - _calibrated_clock_base) * _calibrated_clock_scale; double diff = cc-t; _calibrated_clock_decavg = (_calibrated_clock_decavg * 0.95) + (diff * 0.05); @@ -434,7 +457,11 @@ correct_calibrated_clock(double rtc, double t) { void OpenALAudioSound:: pull_used_buffers() { ReMutexHolder holder(OpenALAudioManager::_lock); + if (!is_valid()) return; + assert(is_playing()); + assert(has_sound_data()); + while (_stream_queued.size()) { ALuint buffer = 0; ALint num_buffers = 0; @@ -491,6 +518,8 @@ push_fresh_buffers() { static unsigned char data[65536]; if (!is_valid()) return; + assert(is_playing()); + assert(has_sound_data()); if (_sd->_sample) { while ((_loops_completed < _playing_loops) && @@ -553,7 +582,9 @@ get_time() const { void OpenALAudioSound:: cache_time(double rtc) { ReMutexHolder holder(OpenALAudioManager::_lock); + assert(is_playing()); + double t=get_calibrated_clock(rtc); double max = _length * _playing_loops; if (t >= max) { @@ -761,13 +792,16 @@ get_3d_drop_off_factor() const { } /** - * Sets whether the sound is marked "active". By default, the active flag + * Sets whether the sound is marked "active". By default, the active flag is * true for all sounds. If the active flag is set to false for any particular * sound, the sound will not be heard. */ void OpenALAudioSound:: set_active(bool active) { ReMutexHolder holder(OpenALAudioManager::_lock); + + if (!is_valid()) return; + if (_active!=active) { _active=active; if (_active) { From a10cd7d8bb454544fb3800db4dec451fb6d5123c Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 2 Mar 2018 00:53:10 -0700 Subject: [PATCH 074/247] openal: Always use release_sound_data This simplifies cleanup() a little bit. --- panda/src/audiotraits/openalAudioSound.I | 11 +++++++++-- panda/src/audiotraits/openalAudioSound.cxx | 7 +++---- panda/src/audiotraits/openalAudioSound.h | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/panda/src/audiotraits/openalAudioSound.I b/panda/src/audiotraits/openalAudioSound.I index 6263872e1a..03592adfde 100644 --- a/panda/src/audiotraits/openalAudioSound.I +++ b/panda/src/audiotraits/openalAudioSound.I @@ -55,10 +55,17 @@ require_sound_data() { /** * Checks if the sound data record is present and releasable, and if so, * releases it. + * + * The sound data is "releasable" if it's from an ordinary, local file. Remote + * streams cannot necessarily be reopened if lost, so we'll hold onto them if + * so. The `force` argument overrides this, indicating we don't intend to + * reacquire the sound data. */ void OpenALAudioSound:: -release_sound_data() { - if ((_sd!=0) && (!_movie->get_filename().empty())) { +release_sound_data(bool force) { + if (!has_sound_data()) return; + + if (force || !_movie->get_filename().empty()) { _manager->decrement_client_count(_sd); _sd = 0; } diff --git a/panda/src/audiotraits/openalAudioSound.cxx b/panda/src/audiotraits/openalAudioSound.cxx index d257fefd72..628a3a2279 100644 --- a/panda/src/audiotraits/openalAudioSound.cxx +++ b/panda/src/audiotraits/openalAudioSound.cxx @@ -80,7 +80,7 @@ OpenALAudioSound(OpenALAudioManager* manager, audio_warning("stereo sound " << movie->get_filename() << " will not be spatialized"); } } - release_sound_data(); + release_sound_data(false); } @@ -106,8 +106,7 @@ cleanup() { stop(); } if (has_sound_data()) { - _manager->decrement_client_count(_sd); - _sd = 0; + release_sound_data(true); } _manager->release_sound(this); _manager = 0; @@ -219,7 +218,7 @@ stop() { } _manager->stopping_sound(this); - release_sound_data(); + release_sound_data(false); } /** diff --git a/panda/src/audiotraits/openalAudioSound.h b/panda/src/audiotraits/openalAudioSound.h index b44a889445..e10f4f179a 100644 --- a/panda/src/audiotraits/openalAudioSound.h +++ b/panda/src/audiotraits/openalAudioSound.h @@ -117,7 +117,7 @@ private: void pull_used_buffers(); void push_fresh_buffers(); INLINE bool require_sound_data(); - INLINE void release_sound_data(); + INLINE void release_sound_data(bool force); INLINE bool is_valid() const; INLINE bool is_playing() const; From cb85d01de60579c193571080a1792abe91de59b5 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 2 Mar 2018 13:39:31 -0700 Subject: [PATCH 075/247] openal: Always use INLINE in .I files --- panda/src/audiotraits/openalAudioSound.I | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/panda/src/audiotraits/openalAudioSound.I b/panda/src/audiotraits/openalAudioSound.I index 03592adfde..8a60ece6e5 100644 --- a/panda/src/audiotraits/openalAudioSound.I +++ b/panda/src/audiotraits/openalAudioSound.I @@ -40,7 +40,7 @@ get_calibrated_clock(double rtc) const { * * Returns true on success, false on failure. */ -bool OpenALAudioSound:: +INLINE bool OpenALAudioSound:: require_sound_data() { if (_sd==0) { _sd = _manager->get_sound_data(_movie, _desired_mode); @@ -61,7 +61,7 @@ require_sound_data() { * so. The `force` argument overrides this, indicating we don't intend to * reacquire the sound data. */ -void OpenALAudioSound:: +INLINE void OpenALAudioSound:: release_sound_data(bool force) { if (!has_sound_data()) return; @@ -74,7 +74,7 @@ release_sound_data(bool force) { /** * Checks if the sound has NOT been cleaned up yet. */ -bool OpenALAudioSound:: +INLINE bool OpenALAudioSound:: is_valid() const { return _manager != NULL; } @@ -85,7 +85,7 @@ is_valid() const { * * This is mainly intended for use in asserts. */ -bool OpenALAudioSound:: +INLINE bool OpenALAudioSound:: is_playing() const { // Manager only gives us a _source if we need it (to talk to OpenAL), so: return _source != 0; @@ -96,7 +96,7 @@ is_playing() const { * * This is mainly intended for use in asserts. */ -bool OpenALAudioSound:: +INLINE bool OpenALAudioSound:: has_sound_data() const { return _sd != 0; } From c89bb3d030ac1a87b3ed95e36073d2a426cdac4e Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 2 Mar 2018 13:41:44 -0700 Subject: [PATCH 076/247] openal: "reattempt" -> "retry" --- panda/src/audiotraits/config_openalAudio.cxx | 16 ++++++++-------- panda/src/audiotraits/config_openalAudio.h | 2 +- panda/src/audiotraits/openalAudioManager.cxx | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/panda/src/audiotraits/config_openalAudio.cxx b/panda/src/audiotraits/config_openalAudio.cxx index 36803e7d04..a3340477c2 100644 --- a/panda/src/audiotraits/config_openalAudio.cxx +++ b/panda/src/audiotraits/config_openalAudio.cxx @@ -30,21 +30,21 @@ ConfigVariableString openal_device PRC_DESC("Specify the OpenAL device string for audio playback (no quotes). If this " "is not specified, the OpenAL default device is used.")); -ConfigVariableInt openal_buffer_delete_reattempts -("openal-buffer-delete-reattempts", 5, +ConfigVariableInt openal_buffer_delete_retries +("openal-buffer-delete-retries", 5, PRC_DESC("If deleting a buffer fails due to still being in use, the OpenAL " - "sound plugin will wait a moment and reattempt deletion, with an " - "exponentially-increasing delay for each attempt. This number " - "specifies how many repeat attempts (not counting the initial attempt) " + "sound plugin will wait a moment and retry deletion, with an " + "exponentially-increasing delay for each try. This number " + "specifies how many repeat tries (not counting the initial try) " "should be made before giving up and raising an error.")); ConfigVariableDouble openal_buffer_delete_delay ("openal-buffer-delete-delay", 0.001, PRC_DESC("If deleting a buffer fails due to still being in use, the OpenAL " - "sound plugin will wait a moment and reattempt deletion, with an " - "exponentially-increasing delay for each attempt. This number " + "sound plugin will wait a moment and retry deletion, with an " + "exponentially-increasing delay for each try. This number " "specifies how long, in seconds, the OpenAL plugin will wait after " - "its first failed attempt. The second attempt will be double this " + "its first failed try. The second try will be double this " "delay, the third quadruple, and so on.")); diff --git a/panda/src/audiotraits/config_openalAudio.h b/panda/src/audiotraits/config_openalAudio.h index 96d3429519..6817362e31 100644 --- a/panda/src/audiotraits/config_openalAudio.h +++ b/panda/src/audiotraits/config_openalAudio.h @@ -26,7 +26,7 @@ extern "C" EXPCL_OPENAL_AUDIO void init_libOpenALAudio(); extern "C" EXPCL_OPENAL_AUDIO Create_AudioManager_proc *get_audio_manager_func_openal_audio(); extern ConfigVariableString openal_device; -extern ConfigVariableInt openal_buffer_delete_reattempts; +extern ConfigVariableInt openal_buffer_delete_retries; extern ConfigVariableDouble openal_buffer_delete_delay; #endif // CONFIG_OPENALAUDIO_H diff --git a/panda/src/audiotraits/openalAudioManager.cxx b/panda/src/audiotraits/openalAudioManager.cxx index bc254d4791..f093aae8b6 100644 --- a/panda/src/audiotraits/openalAudioManager.cxx +++ b/panda/src/audiotraits/openalAudioManager.cxx @@ -1140,7 +1140,7 @@ discard_excess_cache(int sample_limit) { void OpenALAudioManager:: delete_buffer(ALuint buffer) { ReMutexHolder holder(_lock); - int attempt = 0; + int tries = 0; ALuint error; // Keep trying until we succeed (or give up). @@ -1154,13 +1154,13 @@ delete_buffer(ALuint buffer) { } else if (error != AL_INVALID_OPERATION) { // We weren't expecting that. This should be reported. break; - } else if (attempt >= openal_buffer_delete_reattempts.get_value()) { - // We ran out of reattempts. Give up. + } else if (tries >= openal_buffer_delete_retries.get_value()) { + // We ran out of retries. Give up. break; } else { - // Make another attempt after (delay * 2^n) seconds. - Thread::sleep(openal_buffer_delete_delay.get_value() * (1 << attempt)); - attempt++; + // Make another try after (delay * 2^n) seconds. + Thread::sleep(openal_buffer_delete_delay.get_value() * (1 << tries)); + tries++; } } From 99dc462174382f7065751eb7ea44d0c8fdf16789 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 2 Mar 2018 13:55:03 -0700 Subject: [PATCH 077/247] openal: assert -> nassert --- panda/src/audiotraits/openalAudioManager.cxx | 12 +++++----- panda/src/audiotraits/openalAudioSound.cxx | 24 ++++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/panda/src/audiotraits/openalAudioManager.cxx b/panda/src/audiotraits/openalAudioManager.cxx index f093aae8b6..2ba02c2fa7 100644 --- a/panda/src/audiotraits/openalAudioManager.cxx +++ b/panda/src/audiotraits/openalAudioManager.cxx @@ -524,7 +524,7 @@ get_sound(const string &file_name, bool positional, int mode) { void OpenALAudioManager:: uncache_sound(const string& file_name) { ReMutexHolder holder(_lock); - assert(is_valid()); + nassertv(is_valid()); Filename path = file_name; VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -910,7 +910,7 @@ reduce_sounds_playing_to(unsigned int count) { int limit = _sounds_playing.size() - count; while (limit-- > 0) { SoundsPlaying::iterator sound = _sounds_playing.begin(); - assert(sound != _sounds_playing.end()); + nassertv(sound != _sounds_playing.end()); // When the user stops a sound, there is still a PT in the user's hand. // When we stop a sound here, however, this can remove the last PT. This // can cause an ugly recursion where stop calls the destructor, and the @@ -1111,8 +1111,8 @@ discard_excess_cache(int sample_limit) { while (((int)_expiring_samples.size()) > sample_limit) { SoundData *sd = (SoundData*)(_expiring_samples.front()); - assert(sd->_client_count == 0); - assert(sd->_expire == _expiring_samples.begin()); + nassertv(sd->_client_count == 0); + nassertv(sd->_expire == _expiring_samples.begin()); _expiring_samples.pop_front(); _sample_cache.erase(_sample_cache.find(sd->_movie->get_filename())); audio_debug("Expiring: " << sd->_movie->get_filename().get_basename()); @@ -1121,8 +1121,8 @@ discard_excess_cache(int sample_limit) { while (((int)_expiring_streams.size()) > stream_limit) { SoundData *sd = (SoundData*)(_expiring_streams.front()); - assert(sd->_client_count == 0); - assert(sd->_expire == _expiring_streams.begin()); + nassertv(sd->_client_count == 0); + nassertv(sd->_expire == _expiring_streams.begin()); _expiring_streams.pop_front(); audio_debug("Expiring: " << sd->_movie->get_filename().get_basename()); delete sd; diff --git a/panda/src/audiotraits/openalAudioSound.cxx b/panda/src/audiotraits/openalAudioSound.cxx index 628a3a2279..faa9df5717 100644 --- a/panda/src/audiotraits/openalAudioSound.cxx +++ b/panda/src/audiotraits/openalAudioSound.cxx @@ -201,7 +201,7 @@ stop() { if (is_playing()) { _manager->make_current(); - assert(has_sound_data()); + nassertv(has_sound_data()); alGetError(); // clear errors alSourceStop(_source); @@ -290,7 +290,7 @@ restart_stalled_audio() { ALenum status; if (!is_valid()) return; - assert(is_playing()); + nassertv(is_playing()); if (_stream_queued.size() == 0) { return; @@ -310,7 +310,7 @@ void OpenALAudioSound:: queue_buffer(ALuint buffer, int samples, int loop_index, double time_offset) { ReMutexHolder holder(OpenALAudioManager::_lock); - assert(is_playing()); + nassertv(is_playing()); // Now push the buffer into the stream queue. alGetError(); @@ -336,7 +336,7 @@ ALuint OpenALAudioSound:: make_buffer(int samples, int channels, int rate, unsigned char *data) { ReMutexHolder holder(OpenALAudioManager::_lock); - assert(is_playing()); + nassertr(is_playing(), 0); // Allocate a buffer to hold the data. alGetError(); @@ -370,7 +370,7 @@ int OpenALAudioSound:: read_stream_data(int bytelen, unsigned char *buffer) { ReMutexHolder holder(OpenALAudioManager::_lock); - assert(has_sound_data()); + nassertr(has_sound_data(), 0); MovieAudioCursor *cursor = _sd->_stream; double length = cursor->length(); @@ -423,7 +423,7 @@ void OpenALAudioSound:: correct_calibrated_clock(double rtc, double t) { ReMutexHolder holder(OpenALAudioManager::_lock); - assert(is_playing()); + nassertv(is_playing()); double cc = (rtc - _calibrated_clock_base) * _calibrated_clock_scale; double diff = cc-t; @@ -458,8 +458,8 @@ pull_used_buffers() { ReMutexHolder holder(OpenALAudioManager::_lock); if (!is_valid()) return; - assert(is_playing()); - assert(has_sound_data()); + nassertv(is_playing()); + nassertv(has_sound_data()); while (_stream_queued.size()) { ALuint buffer = 0; @@ -517,8 +517,8 @@ push_fresh_buffers() { static unsigned char data[65536]; if (!is_valid()) return; - assert(is_playing()); - assert(has_sound_data()); + nassertv(is_playing()); + nassertv(has_sound_data()); if (_sd->_sample) { while ((_loops_completed < _playing_loops) && @@ -545,7 +545,7 @@ push_fresh_buffers() { break; } ALuint buffer = make_buffer(samples, channels, rate, data); - if (!is_valid()) return; + if (!is_valid() || !buffer) return; queue_buffer(buffer, samples, loop_index, time_offset); if (!is_valid()) return; fill += samples; @@ -582,7 +582,7 @@ void OpenALAudioSound:: cache_time(double rtc) { ReMutexHolder holder(OpenALAudioManager::_lock); - assert(is_playing()); + nassertv(is_playing()); double t=get_calibrated_clock(rtc); double max = _length * _playing_loops; From d8b48a3837d26aa5c9c6373eaf3b5750bfdd707e Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Tue, 6 Mar 2018 19:01:34 -0700 Subject: [PATCH 078/247] openal: `ptr != 0` -> `ptr != NULL` --- panda/src/audiotraits/openalAudioSound.I | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/audiotraits/openalAudioSound.I b/panda/src/audiotraits/openalAudioSound.I index 8a60ece6e5..9a090adc3d 100644 --- a/panda/src/audiotraits/openalAudioSound.I +++ b/panda/src/audiotraits/openalAudioSound.I @@ -98,5 +98,5 @@ is_playing() const { */ INLINE bool OpenALAudioSound:: has_sound_data() const { - return _sd != 0; + return _sd != NULL; } From 9a3147874425c5677e34c6aec272d0cc7342c542 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 8 Mar 2018 11:19:43 +0100 Subject: [PATCH 079/247] task: remove accidentally committed debug message --- panda/src/event/asyncFuture.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/panda/src/event/asyncFuture.cxx b/panda/src/event/asyncFuture.cxx index f1aaaba842..25ae6bfa1c 100644 --- a/panda/src/event/asyncFuture.cxx +++ b/panda/src/event/asyncFuture.cxx @@ -244,7 +244,6 @@ add_waiting_task(AsyncTask *task) { */ void AsyncFuture:: wake_task(AsyncTask *task) { - cerr << "waking task\n"; AsyncTaskManager *manager = task->_manager; if (manager == nullptr) { // If it's an unscheduled task, schedule it on the same manager as the From b0b32b9d6a1a9b367011ccf3fe892f14f11028f0 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 8 Mar 2018 11:21:14 +0100 Subject: [PATCH 080/247] direct: fix Python 3 support in Pmw-based tools Fixes #276 --- direct/src/showbase/TkGlobal.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/direct/src/showbase/TkGlobal.py b/direct/src/showbase/TkGlobal.py index bfdeb9b48f..673d337e3c 100644 --- a/direct/src/showbase/TkGlobal.py +++ b/direct/src/showbase/TkGlobal.py @@ -12,5 +12,28 @@ else: if '_Pmw' in sys.modules: sys.modules['_Pmw'].__name__ = '_Pmw' +# Hack to workaround broken Pmw.NoteBook in Python 3 +def bordercolors(root, colorName): + lightRGB = [] + darkRGB = [] + for value in Pmw.Color.name2rgb(root, colorName, 1): + value40pc = (14 * value) // 10 + if value40pc > int(Pmw.Color._MAX_RGB): + value40pc = int(Pmw.Color._MAX_RGB) + valueHalfWhite = (int(Pmw.Color._MAX_RGB) + value) // 2; + lightRGB.append(max(value40pc, valueHalfWhite)) + + darkValue = (60 * value) // 100 + darkRGB.append(darkValue) + + return ( + '#%04x%04x%04x' % (lightRGB[0], lightRGB[1], lightRGB[2]), + '#%04x%04x%04x' % (darkRGB[0], darkRGB[1], darkRGB[2]) + ) + +Pmw.Color.bordercolors = bordercolors +del bordercolors + + def spawnTkLoop(): base.spawnTkLoop() From 15f6ed1ba297391e720f4b271101fd64010a18ad Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 8 Mar 2018 11:38:52 +0100 Subject: [PATCH 081/247] androiddisplay: remove error messages leftover from debugging --- panda/src/androiddisplay/androidGraphicsWindow.cxx | 3 --- 1 file changed, 3 deletions(-) diff --git a/panda/src/androiddisplay/androidGraphicsWindow.cxx b/panda/src/androiddisplay/androidGraphicsWindow.cxx index 31cd4e23d6..1a91f21186 100644 --- a/panda/src/androiddisplay/androidGraphicsWindow.cxx +++ b/panda/src/androiddisplay/androidGraphicsWindow.cxx @@ -309,8 +309,6 @@ open_window() { _fb_properties = androidgsg->get_fb_properties(); - androiddisplay_cat.error() << "open_window done\n"; - return true; } @@ -366,7 +364,6 @@ create_surface() { // Create a context. if (androidgsg->_context == EGL_NO_CONTEXT) { - androiddisplay_cat.error() << "creating context\n"; if (!androidgsg->create_context()) { return false; } From bfff7e10008930eafe92b974c0f679ff17e29d29 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 8 Mar 2018 11:41:00 +0100 Subject: [PATCH 082/247] tests: don't assert if pipe cannot create physical windows --- tests/display/conftest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/display/conftest.py b/tests/display/conftest.py index c66ef2f54a..88a2b5f3c3 100644 --- a/tests/display/conftest.py +++ b/tests/display/conftest.py @@ -41,7 +41,9 @@ def window(graphics_pipe, graphics_engine): ) graphics_engine.open_windows() - assert win is not None + if win is None: + pytest.skip("GraphicsPipe cannot make windows") + yield win if win is not None: From b10ee32752f0568a3d1188ef59bb0da871327228 Mon Sep 17 00:00:00 2001 From: Michael Wass Date: Thu, 8 Mar 2018 11:43:47 +0100 Subject: [PATCH 083/247] direct: Fix some more NameErrors Closes #274 --- direct/src/distributed/PyDatagramIterator.py | 6 +----- direct/src/stdpy/threading.py | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/direct/src/distributed/PyDatagramIterator.py b/direct/src/distributed/PyDatagramIterator.py index e97600f6b4..60267a1ab9 100755 --- a/direct/src/distributed/PyDatagramIterator.py +++ b/direct/src/distributed/PyDatagramIterator.py @@ -75,7 +75,7 @@ class PyDatagramIterator(DatagramIterator): b = self.getUint8() retVal.append((a, b)) else: - raise Exception("Error: No such type as: " + str(subAtomicType)) + raise Exception("Error: No such type as: " + str(subatomicType)) else: # See if it is in the handy dict getFunc = self.FuncDict.get(subatomicType) @@ -121,8 +121,4 @@ class PyDatagramIterator(DatagramIterator): else: raise Exception("Error: No such type as: " + str(subatomicType)) - - return retVal - - diff --git a/direct/src/stdpy/threading.py b/direct/src/stdpy/threading.py index b4cb6d9228..466a198a3a 100644 --- a/direct/src/stdpy/threading.py +++ b/direct/src/stdpy/threading.py @@ -302,7 +302,7 @@ class BoundedSemaphore(Semaphore): Semaphore.__init__(value) def release(self): - if self.getCount() > value: + if self.getCount() > self.__max: raise ValueError Semaphore.release(self) From 5d2110c6442b1b0ba5a124153085c5e3c519660d Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 8 Mar 2018 12:19:22 +0100 Subject: [PATCH 084/247] bullet: add force_update_all_aabbs property to BulletWorld --- panda/src/bullet/bulletWorld.cxx | 18 ++++++++++++++++++ panda/src/bullet/bulletWorld.h | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/panda/src/bullet/bulletWorld.cxx b/panda/src/bullet/bulletWorld.cxx index f3d48e3c74..18c23c8896 100644 --- a/panda/src/bullet/bulletWorld.cxx +++ b/panda/src/bullet/bulletWorld.cxx @@ -1104,6 +1104,24 @@ get_group_collision_flag(unsigned int group1, unsigned int group2) const { return _filter_cb2._collide[group1].get_bit(group2); } +/** + * + */ +void BulletWorld:: +set_force_update_all_aabbs(bool force) { + LightMutexHolder holder(get_global_lock()); + _world->setForceUpdateAllAabbs(force); +} + +/** + * + */ +bool BulletWorld:: +get_force_update_all_aabbs() const { + LightMutexHolder holder(get_global_lock()); + return _world->getForceUpdateAllAabbs(); +} + /** * */ diff --git a/panda/src/bullet/bulletWorld.h b/panda/src/bullet/bulletWorld.h index 021b6ee268..36f3723535 100644 --- a/panda/src/bullet/bulletWorld.h +++ b/panda/src/bullet/bulletWorld.h @@ -134,6 +134,9 @@ PUBLISHED: void set_group_collision_flag(unsigned int group1, unsigned int group2, bool enable); bool get_group_collision_flag(unsigned int group1, unsigned int group2) const; + void set_force_update_all_aabbs(bool force); + bool get_force_update_all_aabbs() const; + // Callbacks void set_contact_added_callback(CallbackObject *obj); void clear_contact_added_callback(); @@ -166,6 +169,8 @@ PUBLISHED: MAKE_SEQ_PROPERTY(vehicles, get_num_vehicles, get_vehicle); MAKE_SEQ_PROPERTY(constraints, get_num_constraints, get_constraint); MAKE_SEQ_PROPERTY(manifolds, get_num_manifolds, get_manifold); + MAKE_PROPERTY(force_update_all_aabbs, get_force_update_all_aabbs, + set_force_update_all_aabbs); PUBLISHED: // Deprecated methods, will be removed soon void attach_ghost(BulletGhostNode *node); From 766b38fb7a25db6f6dc13261c051dd572ed671b1 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 8 Mar 2018 12:58:16 +0100 Subject: [PATCH 085/247] dtoolbase: make TypeHandle a constexpr class --- dtool/src/dtoolbase/typeHandle.I | 18 ++++++++++++------ dtool/src/dtoolbase/typeHandle.h | 11 ++++++++--- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/dtool/src/dtoolbase/typeHandle.I b/dtool/src/dtoolbase/typeHandle.I index e002fbb1d7..3e9e53a9ae 100644 --- a/dtool/src/dtoolbase/typeHandle.I +++ b/dtool/src/dtoolbase/typeHandle.I @@ -194,9 +194,9 @@ output(ostream &out) const { /** * Returns a special zero-valued TypeHandle that is used to indicate no type. */ -INLINE TypeHandle TypeHandle:: +CONSTEXPR TypeHandle TypeHandle:: none() { - return _none; + return TypeHandle(0); } /** @@ -213,9 +213,15 @@ operator bool () const { * * See TypeRegistry::find_type_by_id(). */ -INLINE TypeHandle TypeHandle:: +CONSTEXPR TypeHandle TypeHandle:: from_index(int index) { - TypeHandle handle; - handle._index = index; - return handle; + return TypeHandle(index); +} + +/** + * Private constructor for initializing a TypeHandle from an index, used by + * none() and by from_index(). + */ +CONSTEXPR TypeHandle:: +TypeHandle(int index) : _index(index) { } diff --git a/dtool/src/dtoolbase/typeHandle.h b/dtool/src/dtoolbase/typeHandle.h index f770b1810b..58e69646f4 100644 --- a/dtool/src/dtoolbase/typeHandle.h +++ b/dtool/src/dtoolbase/typeHandle.h @@ -80,6 +80,8 @@ class TypedObject; */ class EXPCL_DTOOL TypeHandle FINAL { PUBLISHED: + TypeHandle() NOEXCEPT DEFAULT_CTOR; + enum MemoryClass { MC_singleton, MC_array, @@ -127,7 +129,7 @@ PUBLISHED: INLINE int get_index() const; INLINE void output(ostream &out) const; - INLINE static TypeHandle none(); + CONSTEXPR static TypeHandle none(); INLINE operator bool () const; MAKE_PROPERTY(index, get_index); @@ -140,12 +142,15 @@ public: void *reallocate_array(void *ptr, size_t size) RETURNS_ALIGNED(MEMORY_HOOK_ALIGNMENT); void deallocate_array(void *ptr); - INLINE static TypeHandle from_index(int index); + CONSTEXPR static TypeHandle from_index(int index); private: - int _index; + CONSTEXPR TypeHandle(int index); + + // Only kept temporarily for ABI compatibility. static TypeHandle _none; + int _index; friend class TypeRegistry; }; From 280b13a289dfe4cda226a3828c6e2301a7368fc1 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 8 Mar 2018 13:42:56 -0700 Subject: [PATCH 086/247] char: Remove references to dead "ComputedVertices" class This hasn't been a thing for nearly 13 years. --- panda/src/char/character.h | 1 - panda/src/char/characterJoint.cxx | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/panda/src/char/character.h b/panda/src/char/character.h index 1903d39ab8..80492df93c 100644 --- a/panda/src/char/character.h +++ b/panda/src/char/character.h @@ -30,7 +30,6 @@ #include "sliderTable.h" class CharacterJointBundle; -class ComputedVertices; /** * An animated character, with skeleton-morph animation and either soft- diff --git a/panda/src/char/characterJoint.cxx b/panda/src/char/characterJoint.cxx index 77b3a99e32..9efb002349 100644 --- a/panda/src/char/characterJoint.cxx +++ b/panda/src/char/characterJoint.cxx @@ -60,7 +60,7 @@ CharacterJoint(Character *character, // update_internals() to get our _net_transform set properly. update_internals(root, parent, true, false, current_thread); - // And then compute its inverse. This is needed for ComputedVertices, + // And then compute its inverse. This is needed for JointVertexTransform, // during animation. _initial_net_transform_inverse = invert(_net_transform); } From 5f14d9c48f250ff982a1369b1dce1bb8150bdefc Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 8 Mar 2018 14:27:04 -0700 Subject: [PATCH 087/247] char: Move JointVertexTransform::_matrix to CharacterJoint The rationale is that CharacterJoint should contain all of the joint state information, and JointVertexTransform should be pretty much devoid of state so that we don't have to worry about synchronizing it. JointVertexTransform::_matrix was just a cached/precomputed matrix that transforms from original vertex positions to animated vertex positions, so moving it to CharacterJoint doesn't change any engine functionality. This also removes the useless lock on recomputing that matrix. It was useless because it was computing from shared state in CharacterJoint that wasn't properly synchronized, but this would have to be fixed by making CharacterJoint pipeline-cycled - a lock won't do. --- panda/src/char/characterJoint.cxx | 18 ++++++++++----- panda/src/char/characterJoint.h | 6 +++++ panda/src/char/jointVertexTransform.I | 10 --------- panda/src/char/jointVertexTransform.cxx | 30 +++++-------------------- panda/src/char/jointVertexTransform.h | 7 ------ 5 files changed, 23 insertions(+), 48 deletions(-) diff --git a/panda/src/char/characterJoint.cxx b/panda/src/char/characterJoint.cxx index 9efb002349..6ce5b0be88 100644 --- a/panda/src/char/characterJoint.cxx +++ b/panda/src/char/characterJoint.cxx @@ -39,7 +39,8 @@ CharacterJoint(const CharacterJoint ©) : MovingPartMatrix(copy), _character(NULL), _net_transform(copy._net_transform), - _initial_net_transform_inverse(copy._initial_net_transform_inverse) + _initial_net_transform_inverse(copy._initial_net_transform_inverse), + _skinning_matrix(copy._skinning_matrix) { // We don't copy the sets of transform nodes. } @@ -60,9 +61,12 @@ CharacterJoint(Character *character, // update_internals() to get our _net_transform set properly. update_internals(root, parent, true, false, current_thread); - // And then compute its inverse. This is needed for JointVertexTransform, - // during animation. + // And then compute its inverse. This is needed to track changes in + // _net_transform as the joint moves, so we can recompute _skinning_matrix, + // which maps vertices from their initial positions to their animated + // positions. _initial_net_transform_inverse = invert(_net_transform); + _skinning_matrix = LMatrix4::ident_mat(); } /** @@ -141,11 +145,13 @@ update_internals(PartBundle *root, PartGroup *parent, bool self_changed, } } - // Also tell our related JointVertexTransforms that they now need to - // recompute themselves. + // Recompute the transform used by any vertices animated by this joint. + _skinning_matrix = _initial_net_transform_inverse * _net_transform; + + // Also tell our related JointVertexTransforms that we've changed their + // underlying matrix. VertexTransforms::iterator vti; for (vti = _vertex_transforms.begin(); vti != _vertex_transforms.end(); ++vti) { - (*vti)->_matrix_stale = true; (*vti)->mark_modified(current_thread); } } diff --git a/panda/src/char/characterJoint.h b/panda/src/char/characterJoint.h index 759d175c7e..5da83def66 100644 --- a/panda/src/char/characterJoint.h +++ b/panda/src/char/characterJoint.h @@ -108,6 +108,12 @@ public: LMatrix4 _net_transform; LMatrix4 _initial_net_transform_inverse; + // This is the product of the above; the matrix that gets applied to a + // vertex (whose coordinates are in the coordinate space of the character + // in its neutral pose) to transform it from its neutral position to its + // animated position. + LMatrix4 _skinning_matrix; + public: virtual TypeHandle get_type() const { return get_class_type(); diff --git a/panda/src/char/jointVertexTransform.I b/panda/src/char/jointVertexTransform.I index a5a2a2e8cf..4973ae6d60 100644 --- a/panda/src/char/jointVertexTransform.I +++ b/panda/src/char/jointVertexTransform.I @@ -18,13 +18,3 @@ INLINE const CharacterJoint *JointVertexTransform:: get_joint() const { return _joint; } - -/** - * Recomputes _matrix if it needs it. - */ -INLINE void JointVertexTransform:: -check_matrix() const { - if (_matrix_stale) { - ((JointVertexTransform *)this)->compute_matrix(); - } -} diff --git a/panda/src/char/jointVertexTransform.cxx b/panda/src/char/jointVertexTransform.cxx index cf943669a7..5212aa6cd9 100644 --- a/panda/src/char/jointVertexTransform.cxx +++ b/panda/src/char/jointVertexTransform.cxx @@ -24,8 +24,7 @@ TypeHandle JointVertexTransform::_type_handle; * Constructs an invalid object; used only by the bam loader. */ JointVertexTransform:: -JointVertexTransform() : - _matrix_stale(true) +JointVertexTransform() { } @@ -35,8 +34,7 @@ JointVertexTransform() : */ JointVertexTransform:: JointVertexTransform(CharacterJoint *joint) : - _joint(joint), - _matrix_stale(true) + _joint(joint) { // Tell the joint that we need to be informed when it moves. _joint->_vertex_transforms.insert(this); @@ -57,8 +55,7 @@ JointVertexTransform:: */ void JointVertexTransform:: get_matrix(LMatrix4 &matrix) const { - check_matrix(); - matrix = _matrix; + matrix = _joint->_skinning_matrix; } /** @@ -69,8 +66,7 @@ get_matrix(LMatrix4 &matrix) const { */ void JointVertexTransform:: mult_matrix(LMatrix4 &result, const LMatrix4 &previous) const { - check_matrix(); - result.multiply(_matrix, previous); + result.multiply(_joint->_skinning_matrix, previous); } /** @@ -80,9 +76,7 @@ mult_matrix(LMatrix4 &result, const LMatrix4 &previous) const { */ void JointVertexTransform:: accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const { - check_matrix(); - - accum.accumulate(_matrix, weight); + accum.accumulate(_joint->_skinning_matrix, weight); } /** @@ -93,19 +87,6 @@ output(ostream &out) const { out << _joint->get_name(); } -/** - * Recomputes _matrix if it needs it. Uses locking. - */ -void JointVertexTransform:: -compute_matrix() { - LightMutexHolder holder(_lock); - if (_matrix_stale) { - _matrix = _joint->_initial_net_transform_inverse * _joint->_net_transform; - _matrix_stale = false; - } -} - - /** * Tells the BamReader how to create objects of type JointVertexTransform. */ @@ -165,6 +146,5 @@ fillin(DatagramIterator &scan, BamReader *manager) { VertexTransform::fillin(scan, manager); manager->read_pointer(scan); - _matrix_stale = true; mark_modified(Thread::get_current_thread()); } diff --git a/panda/src/char/jointVertexTransform.h b/panda/src/char/jointVertexTransform.h index 39b531de8d..1be097eba6 100644 --- a/panda/src/char/jointVertexTransform.h +++ b/panda/src/char/jointVertexTransform.h @@ -47,15 +47,8 @@ PUBLISHED: virtual void output(ostream &out) const; private: - INLINE void check_matrix() const; - void compute_matrix(); - PT(CharacterJoint) _joint; - LMatrix4 _matrix; - bool _matrix_stale; - LightMutex _lock; - public: static void register_with_read_factory(); virtual void write_datagram(BamWriter *manager, Datagram &dg); From 2563b652498eb37ca1d7ea69f52634699a8c35ed Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 11 Mar 2018 16:32:33 +0100 Subject: [PATCH 088/247] video4linux: support greyscale pixel format (eg. IR cameras) --- panda/src/vision/webcamVideoCursorV4L.cxx | 5 +++++ panda/src/vision/webcamVideoV4L.cxx | 1 + 2 files changed, 6 insertions(+) diff --git a/panda/src/vision/webcamVideoCursorV4L.cxx b/panda/src/vision/webcamVideoCursorV4L.cxx index 64090c53aa..497115c0dd 100644 --- a/panda/src/vision/webcamVideoCursorV4L.cxx +++ b/panda/src/vision/webcamVideoCursorV4L.cxx @@ -247,6 +247,10 @@ WebcamVideoCursorV4L(WebcamVideoV4L *src) : MovieVideoCursor(src) { _num_components = 4; break; + case V4L2_PIX_FMT_GREY: + _num_components = 1; + break; + default: vision_cat.error() << "Unsupported pixel format " << src->get_pixel_format() << "!\n"; _ready = false; @@ -484,6 +488,7 @@ fetch_buffer() { case V4L2_PIX_FMT_BGR24: case V4L2_PIX_FMT_BGR32: + case V4L2_PIX_FMT_GREY: // Simplest case: copying every row verbatim. nassertr(old_bpl == new_bpl, NULL); diff --git a/panda/src/vision/webcamVideoV4L.cxx b/panda/src/vision/webcamVideoV4L.cxx index b07e1b2071..7d5636f4e0 100644 --- a/panda/src/vision/webcamVideoV4L.cxx +++ b/panda/src/vision/webcamVideoV4L.cxx @@ -174,6 +174,7 @@ void find_all_webcams_v4l() { case V4L2_PIX_FMT_BGR32: case V4L2_PIX_FMT_RGB24: case V4L2_PIX_FMT_RGB32: + case V4L2_PIX_FMT_GREY: break; default: From e0f8d7885abcc57222db6ca717e7061a22d5750f Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 11 Mar 2018 16:33:26 +0100 Subject: [PATCH 089/247] video4linux: don't block on reading camera frames Add v4l-blocking variable to enable the old behaviour. --- panda/src/vision/config_vision.cxx | 4 ++++ panda/src/vision/config_vision.h | 3 +++ panda/src/vision/webcamVideoCursorV4L.cxx | 12 +++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/panda/src/vision/config_vision.cxx b/panda/src/vision/config_vision.cxx index 3b53c0ed02..50d4b8aeb3 100644 --- a/panda/src/vision/config_vision.cxx +++ b/panda/src/vision/config_vision.cxx @@ -26,6 +26,10 @@ Configure(config_vision); NotifyCategoryDef(vision, ""); +ConfigVariableBool v4l_blocking +("v4l-blocking", false, + PRC_DESC("Set this to true if you want to block waiting for webcam frames.")); + ConfigureFn(config_vision) { init_libvision(); } diff --git a/panda/src/vision/config_vision.h b/panda/src/vision/config_vision.h index 5eec1a95b2..1ad2aaa59d 100644 --- a/panda/src/vision/config_vision.h +++ b/panda/src/vision/config_vision.h @@ -16,9 +16,12 @@ #include "pandabase.h" #include "notifyCategoryProxy.h" +#include "configVariableBool.h" NotifyCategoryDecl(vision, EXPCL_VISION, EXPTP_VISION); +extern ConfigVariableBool v4l_blocking; + extern EXPCL_VISION void init_libvision(); #endif diff --git a/panda/src/vision/webcamVideoCursorV4L.cxx b/panda/src/vision/webcamVideoCursorV4L.cxx index 497115c0dd..a78c55135a 100644 --- a/panda/src/vision/webcamVideoCursorV4L.cxx +++ b/panda/src/vision/webcamVideoCursorV4L.cxx @@ -209,7 +209,13 @@ WebcamVideoCursorV4L(WebcamVideoV4L *src) : MovieVideoCursor(src) { _buffers = NULL; _buflens = NULL; - _fd = open(src->_device.c_str(), O_RDWR); + + int mode = O_RDWR; + if (!v4l_blocking) { + mode = O_NONBLOCK; + } + + _fd = open(src->_device.c_str(), mode); if (-1 == _fd) { vision_cat.error() << "Failed to open " << src->_device.c_str() << "\n"; return; @@ -397,6 +403,10 @@ fetch_buffer() { vbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; vbuf.memory = V4L2_MEMORY_MMAP; if (-1 == ioctl(_fd, VIDIOC_DQBUF, &vbuf) && errno != EIO) { + if (errno == EAGAIN) { + // Simply nothing is available yet. + return NULL; + } vision_cat.error() << "Failed to dequeue buffer!\n"; return NULL; } From 319b3315534637dcd2f7d0d82439279e253323e9 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 11 Mar 2018 16:40:21 +0100 Subject: [PATCH 090/247] ShaderGenerator: fix M_modulate_gloss regression It was mapping the alpha channel of M_modulate_gloss to the glow channel. --- panda/src/pgraphnodes/shaderGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index f741b02db8..372bd89e1d 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -344,7 +344,7 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { case TextureStage::M_modulate_gloss: if (shader_attrib->auto_gloss_on()) { - info._flags = ShaderKey::TF_map_glow; + info._flags = ShaderKey::TF_map_gloss; } else { info._mode = TextureStage::M_modulate; info._flags = ShaderKey::TF_has_rgb; From 8e8283cbe1f2845ae7ade0244b8649437638ef82 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 11 Mar 2018 22:36:17 +0100 Subject: [PATCH 091/247] android: enable writing stdout/stderr to a socket This can be done by setting the extra string org.panda3d.OUTPUT_URI to tcp://host:port Writing to a log file can still be done using file:///path/to/log.txt [skip ci] --- panda/src/android/PandaActivity.java | 4 +- panda/src/android/android_main.cxx | 77 ++++++++++++++++++++-------- panda/src/android/pview_manifest.xml | 1 + 3 files changed, 58 insertions(+), 24 deletions(-) diff --git a/panda/src/android/PandaActivity.java b/panda/src/android/PandaActivity.java index a4413a2816..36a8c97521 100644 --- a/panda/src/android/PandaActivity.java +++ b/panda/src/android/PandaActivity.java @@ -87,9 +87,9 @@ public class PandaActivity extends NativeActivity { return path; } - public String getIntentOutputPath() { + public String getIntentOutputUri() { Intent intent = getIntent(); - return intent.getStringExtra("org.panda3d.OUTPUT_PATH"); + return intent.getStringExtra("org.panda3d.OUTPUT_URI"); } public String getCacheDirString() { diff --git a/panda/src/android/android_main.cxx b/panda/src/android/android_main.cxx index 7d4e75e4b2..0565ef5835 100644 --- a/panda/src/android/android_main.cxx +++ b/panda/src/android/android_main.cxx @@ -17,11 +17,14 @@ #include "virtualFileSystem.h" #include "filename.h" #include "thread.h" +#include "urlSpec.h" #include "config_display.h" // #define OPENGLES_1 #include "config_androiddisplay.h" #include +#include +#include // struct android_app* panda_android_app = NULL; @@ -67,6 +70,55 @@ void android_main(struct android_app* app) { android_cat.info() << "New native activity started on " << *current_thread << "\n"; + // Were we given an optional location to write the stdout/stderr streams? + methodID = env->GetMethodID(activity_class, "getIntentOutputUri", "()Ljava/lang/String;"); + jstring joutput_uri = (jstring) env->CallObjectMethod(activity->clazz, methodID); + if (joutput_uri != nullptr) { + const char *output_uri = env->GetStringUTFChars(joutput_uri, nullptr); + + if (output_uri != nullptr && output_uri[0] != 0) { + URLSpec spec(output_uri); + + if (spec.get_scheme() == "file") { + string path = spec.get_path(); + int fd = open(path.c_str(), O_CREAT | O_TRUNC | O_WRONLY); + if (fd != -1) { + android_cat.info() + << "Writing standard output to file " << path << "\n"; + + dup2(fd, 1); + dup2(fd, 2); + } else { + android_cat.error() + << "Failed to open output path " << path << "\n"; + } + } else if (spec.get_scheme() == "tcp") { + string host = spec.get_server(); + int fd = socket(AF_INET, SOCK_STREAM, 0); + struct sockaddr_in serv_addr = {0}; + serv_addr.sin_family = AF_INET; + serv_addr.sin_port = htons(spec.get_port()); + serv_addr.sin_addr.s_addr = inet_addr(host.c_str()); + if (connect(fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) == 0) { + android_cat.info() + << "Writing standard output to socket " + << spec.get_server_and_port() << "\n"; + dup2(fd, 1); + dup2(fd, 2); + } else { + android_cat.error() + << "Failed to open output socket " + << spec.get_server_and_port() << "\n"; + } + close(fd); + } else { + android_cat.error() + << "Unsupported scheme in output URI: " << output_uri << "\n"; + } + env->ReleaseStringUTFChars(joutput_uri, output_uri); + } + } + // Fetch the data directory. jmethodID get_appinfo = env->GetMethodID(activity_class, "getApplicationInfo", "()Landroid/content/pm/ApplicationInfo;"); @@ -186,28 +238,6 @@ void android_main(struct android_app* app) { } } - // Were we given an optional location to write the stdout/stderr streams? - methodID = env->GetMethodID(activity_class, "getIntentOutputPath", "()Ljava/lang/String;"); - jstring joutput_path = (jstring) env->CallObjectMethod(activity->clazz, methodID); - if (joutput_path != nullptr) { - const char *output_path = env->GetStringUTFChars(joutput_path, nullptr); - - if (output_path != nullptr && output_path[0] != 0) { - int fd = open(output_path, O_CREAT | O_TRUNC | O_WRONLY); - if (fd != -1) { - android_cat.info() - << "Writing standard output to file " << output_path << "\n"; - - dup2(fd, 1); - dup2(fd, 2); - } else { - android_cat.error() - << "Failed to open output path " << output_path << "\n"; - } - env->ReleaseStringUTFChars(joutput_path, output_path); - } - } - // Create bogus argc and argv for calling the main function. const char *argv[] = {"pview", nullptr, nullptr}; int argc = 1; @@ -266,6 +296,9 @@ void android_main(struct android_app* app) { env->ReleaseStringUTFChars(filename, filename_str); } + close(1); + close(2); + // Detach the thread before exiting. activity->vm->DetachCurrentThread(); } diff --git a/panda/src/android/pview_manifest.xml b/panda/src/android/pview_manifest.xml index 30125c673f..1560bdd828 100644 --- a/panda/src/android/pview_manifest.xml +++ b/panda/src/android/pview_manifest.xml @@ -7,6 +7,7 @@ + From 94ceace5afefed9bd52ff0f229fd1ca8eb7ecd8b Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 11 Mar 2018 22:50:11 +0100 Subject: [PATCH 092/247] android: add activity for running Python programs It can be launched from the termux shell using the provided run_python.sh script, which can communicate with the Panda activity using a socket (which is the only way we can reliably get command-line output back to the program.) The Python script needs to be readable by the Panda activity (which implies it needs to be in /sdcard). The standard library is packed into the .apk, and loaded using zipimport. Extension modules are included using a special naming convention and import hook in order to comply with Android's strict demands on how libraries must be named to be included in an .apk. [skip ci] --- makepanda/makepanda.py | 80 +++++++++++++++++++++++++-- panda/src/android/PythonActivity.java | 23 ++++++++ panda/src/android/pview_manifest.xml | 39 ++++++++++--- panda/src/android/python_main.cxx | 80 +++++++++++++++++++++++++++ panda/src/android/run_pview.sh | 14 +++++ panda/src/android/run_python.sh | 14 +++++ panda/src/android/site.py | 34 ++++++++++++ 7 files changed, 272 insertions(+), 12 deletions(-) create mode 100644 panda/src/android/PythonActivity.java create mode 100644 panda/src/android/python_main.cxx create mode 100755 panda/src/android/run_pview.sh create mode 100755 panda/src/android/run_python.sh create mode 100644 panda/src/android/site.py diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 7a8926efd6..1c8c95724d 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -5082,7 +5082,7 @@ if (PkgSkip("SPEEDTREE")==0): # DIRECTORY: panda/src/testbed/ # -if (not RTDIST and not RUNTIME and PkgSkip("PVIEW")==0 and GetTarget() != 'android'): +if (not RTDIST and not RUNTIME and PkgSkip("PVIEW")==0): OPTS=['DIR:panda/src/testbed'] TargetAdd('pview_pview.obj', opts=OPTS, input='pview.cxx') TargetAdd('pview.exe', input='pview_pview.obj') @@ -5101,6 +5101,7 @@ if (not RUNTIME and GetTarget() == 'android'): TargetAdd('org/panda3d/android/NativeIStream.class', opts=OPTS, input='NativeIStream.java') TargetAdd('org/panda3d/android/NativeOStream.class', opts=OPTS, input='NativeOStream.java') TargetAdd('org/panda3d/android/PandaActivity.class', opts=OPTS, input='PandaActivity.java') + TargetAdd('org/panda3d/android/PythonActivity.class', opts=OPTS, input='PythonActivity.java') TargetAdd('p3android_composite1.obj', opts=OPTS, input='p3android_composite1.cxx') TargetAdd('libp3android.dll', input='p3android_composite1.obj') @@ -5111,10 +5112,10 @@ if (not RUNTIME and GetTarget() == 'android'): TargetAdd('android_main.obj', opts=OPTS, input='android_main.cxx') if (not RTDIST and PkgSkip("PVIEW")==0): - TargetAdd('pview_pview.obj', opts=OPTS, input='pview.cxx') + TargetAdd('libpview_pview.obj', opts=OPTS, input='pview.cxx') TargetAdd('libpview.dll', input='android_native_app_glue.obj') TargetAdd('libpview.dll', input='android_main.obj') - TargetAdd('libpview.dll', input='pview_pview.obj') + TargetAdd('libpview.dll', input='libpview_pview.obj') TargetAdd('libpview.dll', input='libp3framework.dll') if not PkgSkip("EGG"): TargetAdd('libpview.dll', input='libpandaegg.dll') @@ -5122,6 +5123,17 @@ if (not RUNTIME and GetTarget() == 'android'): TargetAdd('libpview.dll', input=COMMON_PANDA_LIBS) TargetAdd('libpview.dll', opts=['MODULE', 'ANDROID']) + if (not RTDIST and PkgSkip("PYTHON")==0): + OPTS += ['PYTHON'] + TargetAdd('ppython_ppython.obj', opts=OPTS, input='python_main.cxx') + TargetAdd('libppython.dll', input='android_native_app_glue.obj') + TargetAdd('libppython.dll', input='android_main.obj') + TargetAdd('libppython.dll', input='ppython_ppython.obj') + TargetAdd('libppython.dll', input='libp3framework.dll') + TargetAdd('libppython.dll', input='libp3android.dll') + TargetAdd('libppython.dll', input=COMMON_PANDA_LIBS) + TargetAdd('libppython.dll', opts=['MODULE', 'ANDROID', 'PYTHON']) + # # DIRECTORY: panda/src/androiddisplay/ # @@ -7505,7 +7517,7 @@ def MakeInstallerAndroid(): continue if '.so.' in line: dep = line.rpartition('.so.')[0] + '.so' - oscmd("patchelf --replace-needed %s %s %s" % (line, dep, target)) + oscmd("patchelf --replace-needed %s %s %s" % (line, dep, target), True) else: dep = line @@ -7516,6 +7528,7 @@ def MakeInstallerAndroid(): copy_library(os.path.realpath(fulldep), dep) break + # Now copy every lib in the lib dir, and its dependencies. for base in os.listdir(source_dir): if not base.startswith('lib'): continue @@ -7527,6 +7540,59 @@ def MakeInstallerAndroid(): continue copy_library(source, base) + # Same for Python extension modules. However, Android is strict about + # library naming, so we have a special naming scheme for these, in + # conjunction with a custom import hook to find these modules. + if not PkgSkip("PYTHON"): + suffix = GetExtensionSuffix() + source_dir = os.path.join(GetOutputDir(), "panda3d") + for base in os.listdir(source_dir): + if not base.endswith(suffix): + continue + modname = base[:-len(suffix)] + source = os.path.join(source_dir, base) + copy_library(source, "libpy.panda3d.{}.so".format(modname)) + + # Same for standard Python modules. + import _ctypes + source_dir = os.path.dirname(_ctypes.__file__) + for base in os.listdir(source_dir): + if not base.endswith('.so'): + continue + modname = base.partition('.')[0] + source = os.path.join(source_dir, base) + copy_library(source, "libpy.{}.so".format(modname)) + + def copy_python_tree(source_root, target_root): + for source_dir, dirs, files in os.walk(source_root): + if 'site-packages' in dirs: + dirs.remove('site-packages') + + if not any(base.endswith('.py') for base in files): + continue + + target_dir = os.path.join(target_root, os.path.relpath(source_dir, source_root)) + target_dir = os.path.normpath(target_dir) + os.makedirs(target_dir, 0o755) + + for base in files: + if base.endswith('.py'): + target = os.path.join(target_dir, base) + shutil.copy(os.path.join(source_dir, base), target) + + # Copy the Python standard library to the .apk as well. + from distutils.sysconfig import get_python_lib + stdlib_source = get_python_lib(False, True) + stdlib_target = os.path.join("apkroot", "lib", "python{0}.{1}".format(*sys.version_info)) + copy_python_tree(stdlib_source, stdlib_target) + + # But also copy over our custom site.py. + shutil.copy("panda/src/android/site.py", os.path.join(stdlib_target, "site.py")) + + # And now make a site-packages directory containing our direct/panda3d/pandac modules. + for tree in "panda3d", "direct", "pandac": + copy_python_tree(os.path.join(GetOutputDir(), tree), os.path.join(stdlib_target, "site-packages", tree)) + # Copy the models and config files to the virtual assets filesystem. oscmd("mkdir apkroot/assets") oscmd("cp -R %s apkroot/assets/models" % (os.path.join(GetOutputDir(), "models"))) @@ -7545,7 +7611,11 @@ def MakeInstallerAndroid(): oscmd(aapt_cmd) # And add all the libraries to it. - oscmd("cd apkroot && aapt add ../%s classes.dex lib/%s/lib*.so" % (apk_unaligned, SDK["ANDROID_ABI"])) + oscmd("cd apkroot && aapt add ../%s classes.dex" % (apk_unaligned)) + for path, dirs, files in os.walk('apkroot/lib'): + if files: + rel = os.path.relpath(path, 'apkroot') + oscmd("cd apkroot && aapt add ../%s %s/*" % (apk_unaligned, rel)) # Now align the .apk, which is necessary for Android to load it. oscmd("zipalign -v -p 4 %s %s" % (apk_unaligned, apk_unsigned)) diff --git a/panda/src/android/PythonActivity.java b/panda/src/android/PythonActivity.java new file mode 100644 index 0000000000..0d282d84a5 --- /dev/null +++ b/panda/src/android/PythonActivity.java @@ -0,0 +1,23 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file PythonActivity.java + * @author rdb + * @date 2018-02-04 + */ + +package org.panda3d.android; + +import org.panda3d.android.PandaActivity; + +/** + * This is only declared as a separate class from PandaActivity so that we + * can have two separate activity definitions in ApplicationManifest.xml. + */ +public class PythonActivity extends PandaActivity { +} diff --git a/panda/src/android/pview_manifest.xml b/panda/src/android/pview_manifest.xml index 1560bdd828..b462e4018a 100644 --- a/panda/src/android/pview_manifest.xml +++ b/panda/src/android/pview_manifest.xml @@ -45,13 +45,38 @@ - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/panda/src/android/python_main.cxx b/panda/src/android/python_main.cxx new file mode 100644 index 0000000000..c1fc0a39fe --- /dev/null +++ b/panda/src/android/python_main.cxx @@ -0,0 +1,80 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file python_main.cxx + * @author rdb + * @date 2018-02-12 + */ + +#include "dtoolbase.h" +#include "config_android.h" +#include "executionEnvironment.h" + +#undef _POSIX_C_SOURCE +#undef _XOPEN_SOURCE +#include +#if PY_MAJOR_VERSION >= 3 +#include +#endif + +#include + +/** + * The main entry point for the Python activity. Called by android_main. + */ +int main(int argc, char *argv[]) { + if (argc <= 1) { + return 1; + } + + // Help out Python by telling it which encoding to use + Py_FileSystemDefaultEncoding = "utf-8"; + + Py_SetProgramName(Py_DecodeLocale("ppython", nullptr)); + + // Set PYTHONHOME to the location of the .apk file. + string apk_path = ExecutionEnvironment::get_binary_name(); + Py_SetPythonHome(Py_DecodeLocale(apk_path.c_str(), nullptr)); + + // We need to make zlib available to zipimport, but I don't know how + // we could inject our import hook before Py_Initialize, so instead + // load it as though it were a built-in module. + void *zlib = dlopen("libpy.zlib.so", RTLD_NOW); + if (zlib != nullptr) { + void *init = dlsym(zlib, "PyInit_zlib"); + if (init != nullptr) { + PyImport_AppendInittab("zlib", (PyObject *(*)())init); + } + } + + Py_Initialize(); + + // This is used by the import hook to locate the module libraries. + Filename dtool_name = ExecutionEnvironment::get_dtool_name(); + string native_dir = dtool_name.get_dirname(); + PyObject *py_native_dir = PyUnicode_FromStringAndSize(native_dir.c_str(), native_dir.size()); + PySys_SetObject("_native_library_dir", py_native_dir); + Py_DECREF(py_native_dir); + + int sts = 1; + FILE *fp = fopen(argv[1], "r"); + if (fp != nullptr) { + int res = PyRun_AnyFile(fp, argv[1]); + if (res > 0) { + sts = 0; + } else { + android_cat.error() << "Error running " << argv[1] << "\n"; + PyErr_Print(); + } + } else { + android_cat.error() << "Unable to open " << argv[1] << "\n"; + } + + Py_Finalize(); + return sts; +} diff --git a/panda/src/android/run_pview.sh b/panda/src/android/run_pview.sh new file mode 100755 index 0000000000..6f3b6f1476 --- /dev/null +++ b/panda/src/android/run_pview.sh @@ -0,0 +1,14 @@ +# This script can be used for launching the Panda viewer from the Android +# terminal environment, for example from within termux. It uses a socket +# to pipe the command-line output back to the terminal. + +port=12345 + +if [[ $# -eq 0 ]] ; then + echo "Pass full path of model" + exit 1 +fi + +am start --activity-clear-task -n org.panda3d.sdk/org.panda3d.android.PandaActivity --user 0 --es org.panda3d.OUTPUT_URI tcp://127.0.0.1:$port --grant-read-uri-permission --grant-write-uri-permission file://$(realpath $1) + +nc -l -p $port diff --git a/panda/src/android/run_python.sh b/panda/src/android/run_python.sh new file mode 100755 index 0000000000..9a8adc710b --- /dev/null +++ b/panda/src/android/run_python.sh @@ -0,0 +1,14 @@ +# This script can be used for launching a Python script from the Android +# terminal environment, for example from within termux. It uses a socket +# to pipe the command-line output back to the terminal. + +port=12345 + +if [[ $# -eq 0 ]] ; then + echo "Pass full path of script" + exit 1 +fi + +am start --activity-clear-task -n org.panda3d.sdk/org.panda3d.android.PythonActivity --user 0 --es org.panda3d.OUTPUT_URI tcp://127.0.0.1:$port --grant-read-uri-permission --grant-write-uri-permission file://$(realpath $1) + +nc -l -p $port diff --git a/panda/src/android/site.py b/panda/src/android/site.py new file mode 100644 index 0000000000..fd3909ede8 --- /dev/null +++ b/panda/src/android/site.py @@ -0,0 +1,34 @@ +import sys +import os + +from importlib.abc import Loader, MetaPathFinder +from importlib.machinery import ModuleSpec + +if sys.version_info >= (3, 5): + from importlib import _bootstrap_external +else: + from importlib import _bootstrap as _bootstrap_external + +sys.platform = "android" + +class AndroidExtensionFinder(MetaPathFinder): + @classmethod + def find_spec(cls, fullname, path=None, target=None): + soname = 'libpy.' + fullname + '.so' + path = os.path.join(sys._native_library_dir, soname) + + if os.path.exists(path): + loader = _bootstrap_external.ExtensionFileLoader(fullname, path) + return ModuleSpec(fullname, loader, origin=path) + + +def main(): + """Adds the site-packages directory to the sys.path. + Also, registers the import hook for extension modules.""" + + sys.path.append('{0}/lib/python{1}.{2}/site-packages'.format(sys.prefix, *sys.version_info)) + sys.meta_path.append(AndroidExtensionFinder) + + +if not sys.flags.no_site: + main() From de2e35ee9a654893ef81e0a93d54566ba33e4900 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 12 Mar 2018 18:32:48 -0600 Subject: [PATCH 093/247] pandabase: Remove unused defines from pandasymbols --- panda/src/pandabase/pandasymbols.h | 86 ------------------------------ 1 file changed, 86 deletions(-) diff --git a/panda/src/pandabase/pandasymbols.h b/panda/src/pandabase/pandasymbols.h index 6c817f56bd..59d8a28bd8 100644 --- a/panda/src/pandabase/pandasymbols.h +++ b/panda/src/pandabase/pandasymbols.h @@ -21,14 +21,6 @@ C++-style comments, since this file is occasionally included by a C file. */ -#ifdef BUILDING_CFTALK - #define EXPCL_CFTALK EXPORT_CLASS - #define EXPTP_CFTALK EXPORT_TEMPL -#else - #define EXPCL_CFTALK IMPORT_CLASS - #define EXPTP_CFTALK IMPORT_TEMPL -#endif - #ifdef BUILDING_COLLADA #define EXPCL_COLLADA EXPORT_CLASS #define EXPTP_COLLADA EXPORT_TEMPL @@ -53,14 +45,6 @@ #define EXPTP_FRAMEWORK IMPORT_TEMPL #endif -#ifdef BUILDING_LINUX_AUDIO - #define EXPCL_LINUX_AUDIO EXPORT_CLASS - #define EXPTP_LINUX_AUDIO EXPORT_TEMPL -#else - #define EXPCL_LINUX_AUDIO IMPORT_CLASS - #define EXPTP_LINUX_AUDIO IMPORT_TEMPL -#endif - #ifdef BUILDING_MILES_AUDIO #define EXPCL_MILES_AUDIO EXPORT_CLASS #define EXPTP_MILES_AUDIO EXPORT_TEMPL @@ -77,14 +61,6 @@ #define EXPTP_FMOD_AUDIO IMPORT_TEMPL #endif -#ifdef BUILDING_OCULUSVR - #define EXPCL_OCULUSVR EXPORT_CLASS - #define EXPTP_OCULUSVR EXPORT_TEMPL -#else - #define EXPCL_OCULUSVR IMPORT_CLASS - #define EXPTP_OCULUSVR IMPORT_TEMPL -#endif - #ifdef BUILDING_OPENAL_AUDIO #define EXPCL_OPENAL_AUDIO EXPORT_CLASS #define EXPTP_OPENAL_AUDIO EXPORT_TEMPL @@ -117,14 +93,6 @@ #define EXPTP_PANDABULLET IMPORT_TEMPL #endif -#ifdef BUILDING_PANDACR - #define EXPCL_PANDACR EXPORT_CLASS - #define EXPTP_PANDACR EXPORT_TEMPL -#else - #define EXPCL_PANDACR IMPORT_CLASS - #define EXPTP_PANDACR IMPORT_TEMPL -#endif - #ifdef BUILDING_PANDADX #define EXPCL_PANDADX EXPORT_CLASS #define EXPTP_PANDADX EXPORT_TEMPL @@ -245,14 +213,6 @@ #define EXPTP_ROCKET IMPORT_TEMPL #endif -#ifdef BUILDING_SHADER - #define EXPCL_SHADER EXPORT_CLASS - #define EXPTP_SHADER EXPORT_TEMPL -#else - #define EXPCL_SHADER IMPORT_CLASS - #define EXPTP_SHADER IMPORT_TEMPL -#endif - #ifdef BUILDING_TINYDISPLAY #define EXPCL_TINYDISPLAY EXPORT_CLASS #define EXPTP_TINYDISPLAY EXPORT_TEMPL @@ -281,51 +241,11 @@ #define INLINE_LINMATH __forceinline #define INLINE_MATHUTIL __forceinline -#ifdef BUILDING_PANDA -#define INLINE_GRAPH __forceinline -#define INLINE_DISPLAY __forceinline -#else -#define INLINE_GRAPH -#define DONT_INLINE_GRAPH -#define INLINE_DISPLAY -#define DONT_INLINE_DISPLAY -#endif - #else #define INLINE_LINMATH INLINE #define INLINE_MATHUTIL INLINE -#define INLINE_GRAPH INLINE -#define INLINE_DISPLAY INLINE #endif -#define INLINE_CHAR INLINE -#define INLINE_CHAT INLINE -#define INLINE_CHAN INLINE -#define INLINE_CHANCFG INLINE -#define INLINE_COLLIDE INLINE -#define INLINE_CULL INLINE -#define INLINE_DEVICE INLINE -#define INLINE_DGRAPH INLINE -#define INLINE_GOBJ INLINE -#define INLINE_GRUTIL INLINE -#define INLINE_GSGBASE INLINE -#define INLINE_GSGMISC INLINE -#define INLINE_LIGHT INLINE -#define INLINE_PARAMETRICS INLINE -#define INLINE_SGRATTRIB INLINE -#define INLINE_SGMANIP INLINE -#define INLINE_SGRAPH INLINE -#define INLINE_SGRAPHUTIL INLINE -#define INLINE_SWITCHNODE INLINE -#define INLINE_TEXT INLINE -#define INLINE_TFORM INLINE -#define INLINE_LERP INLINE -#define INLINE_LOADER INLINE -#define INLINE_PUTIL INLINE -#define INLINE_EFFECTS INLINE -#define INLINE_GUI INLINE -#define INLINE_AUDIO INLINE - #define EXPCL_PANDA_PGRAPH EXPCL_PANDA #define EXPTP_PANDA_PGRAPH EXPTP_PANDA @@ -408,9 +328,6 @@ #define EXPCL_PANDA_TFORM EXPCL_PANDA #define EXPTP_PANDA_TFORM EXPTP_PANDA -#define EXPCL_PANDA_LERP EXPCL_PANDA -#define EXPTP_PANDA_LERP EXPTP_PANDA - #define EXPCL_PANDA_PUTIL EXPCL_PANDA #define EXPTP_PANDA_PUTIL EXPTP_PANDA @@ -420,7 +337,4 @@ #define EXPCL_PANDA_PGUI EXPCL_PANDA #define EXPTP_PANDA_PGUI EXPTP_PANDA -#define EXPCL_PANDA_PANDABASE EXPCL_PANDA -#define EXPTP_PANDA_PANDABASE EXPTP_PANDA - #endif From 350f437fbe15e5c4da650df053ae034ac2bc5755 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 12 Mar 2018 18:53:01 -0600 Subject: [PATCH 094/247] pandabase: Alphabetically sort pandasymbols.h [skip ci] --- panda/src/pandabase/pandasymbols.h | 94 +++++++++++++++--------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/panda/src/pandabase/pandasymbols.h b/panda/src/pandabase/pandasymbols.h index 59d8a28bd8..dafb15e7f1 100644 --- a/panda/src/pandabase/pandasymbols.h +++ b/panda/src/pandabase/pandasymbols.h @@ -37,6 +37,14 @@ #define EXPTP_FFMPEG IMPORT_TEMPL #endif +#ifdef BUILDING_FMOD_AUDIO + #define EXPCL_FMOD_AUDIO EXPORT_CLASS + #define EXPTP_FMOD_AUDIO EXPORT_TEMPL +#else + #define EXPCL_FMOD_AUDIO IMPORT_CLASS + #define EXPTP_FMOD_AUDIO IMPORT_TEMPL +#endif + #ifdef BUILDING_FRAMEWORK #define EXPCL_FRAMEWORK EXPORT_CLASS #define EXPTP_FRAMEWORK EXPORT_TEMPL @@ -53,14 +61,6 @@ #define EXPTP_MILES_AUDIO IMPORT_TEMPL #endif -#ifdef BUILDING_FMOD_AUDIO - #define EXPCL_FMOD_AUDIO EXPORT_CLASS - #define EXPTP_FMOD_AUDIO EXPORT_TEMPL -#else - #define EXPCL_FMOD_AUDIO IMPORT_CLASS - #define EXPTP_FMOD_AUDIO IMPORT_TEMPL -#endif - #ifdef BUILDING_OPENAL_AUDIO #define EXPCL_OPENAL_AUDIO EXPORT_CLASS #define EXPTP_OPENAL_AUDIO EXPORT_TEMPL @@ -173,14 +173,6 @@ #define EXPTP_PANDAPHYSX IMPORT_TEMPL #endif -#ifdef BUILDING_PANDASPEEDTREE - #define EXPCL_PANDASPEEDTREE EXPORT_CLASS - #define EXPTP_PANDASPEEDTREE EXPORT_TEMPL -#else - #define EXPCL_PANDASPEEDTREE IMPORT_CLASS - #define EXPTP_PANDASPEEDTREE IMPORT_TEMPL -#endif - #ifdef BUILDING_PANDASKEL #define EXPCL_PANDASKEL EXPORT_CLASS #define EXPTP_PANDASKEL EXPORT_TEMPL @@ -189,6 +181,14 @@ #define EXPTP_PANDASKEL IMPORT_TEMPL #endif +#ifdef BUILDING_PANDASPEEDTREE + #define EXPCL_PANDASPEEDTREE EXPORT_CLASS + #define EXPTP_PANDASPEEDTREE EXPORT_TEMPL +#else + #define EXPCL_PANDASPEEDTREE IMPORT_CLASS + #define EXPTP_PANDASPEEDTREE IMPORT_TEMPL +#endif + #ifdef BUILDING_PANDAWIN #define EXPCL_PANDAWIN EXPORT_CLASS #define EXPTP_PANDAWIN EXPORT_TEMPL @@ -247,20 +247,8 @@ #endif -#define EXPCL_PANDA_PGRAPH EXPCL_PANDA -#define EXPTP_PANDA_PGRAPH EXPTP_PANDA - -#define EXPCL_PANDA_PGRAPHNODES EXPCL_PANDA -#define EXPTP_PANDA_PGRAPHNODES EXPTP_PANDA - -#define EXPCL_PANDA_RECORDER EXPCL_PANDA -#define EXPTP_PANDA_RECORDER EXPTP_PANDA - -#define EXPCL_PANDA_PIPELINE EXPCL_PANDA -#define EXPTP_PANDA_PIPELINE EXPTP_PANDA - -#define EXPCL_PANDA_GRUTIL EXPCL_PANDA -#define EXPTP_PANDA_GRUTIL EXPTP_PANDA +#define EXPCL_PANDA_AUDIO EXPCL_PANDA +#define EXPTP_PANDA_AUDIO EXPTP_PANDA #define EXPCL_PANDA_CHAN EXPCL_PANDA #define EXPTP_PANDA_CHAN EXPTP_PANDA @@ -268,9 +256,6 @@ #define EXPCL_PANDA_CHAR EXPCL_PANDA #define EXPTP_PANDA_CHAR EXPTP_PANDA -#define EXPCL_PANDA_PSTATCLIENT EXPCL_PANDA -#define EXPTP_PANDA_PSTATCLIENT EXPTP_PANDA - #define EXPCL_PANDA_COLLIDE EXPCL_PANDA #define EXPTP_PANDA_COLLIDE EXPTP_PANDA @@ -292,6 +277,9 @@ #define EXPCL_PANDA_GOBJ EXPCL_PANDA #define EXPTP_PANDA_GOBJ EXPTP_PANDA +#define EXPCL_PANDA_GRUTIL EXPCL_PANDA +#define EXPTP_PANDA_GRUTIL EXPTP_PANDA + #define EXPCL_PANDA_GSGBASE EXPCL_PANDA #define EXPTP_PANDA_GSGBASE EXPTP_PANDA @@ -304,37 +292,49 @@ #define EXPCL_PANDA_MOVIES EXPCL_PANDA #define EXPTP_PANDA_MOVIES EXPTP_PANDA -#define EXPCL_PANDA_NET EXPCL_PANDA -#define EXPTP_PANDA_NET EXPTP_PANDA - #define EXPCL_PANDA_NATIVENET EXPCL_PANDA #define EXPTP_PANDA_NATIVENET EXPTP_PANDA +#define EXPCL_PANDA_NET EXPCL_PANDA +#define EXPTP_PANDA_NET EXPTP_PANDA + #define EXPCL_PANDA_PARAMETRICS EXPCL_PANDA #define EXPTP_PANDA_PARAMETRICS EXPTP_PANDA -#define EXPCL_PANDA_PNMIMAGETYPES EXPCL_PANDA -#define EXPTP_PANDA_PNMIMAGETYPES EXPTP_PANDA +#define EXPCL_PANDA_PGRAPH EXPCL_PANDA +#define EXPTP_PANDA_PGRAPH EXPTP_PANDA + +#define EXPCL_PANDA_PGRAPHNODES EXPCL_PANDA +#define EXPTP_PANDA_PGRAPHNODES EXPTP_PANDA + +#define EXPCL_PANDA_PGUI EXPCL_PANDA +#define EXPTP_PANDA_PGUI EXPTP_PANDA + +#define EXPCL_PANDA_PIPELINE EXPCL_PANDA +#define EXPTP_PANDA_PIPELINE EXPTP_PANDA #define EXPCL_PANDA_PNMIMAGE EXPCL_PANDA #define EXPTP_PANDA_PNMIMAGE EXPTP_PANDA +#define EXPCL_PANDA_PNMIMAGETYPES EXPCL_PANDA +#define EXPTP_PANDA_PNMIMAGETYPES EXPTP_PANDA + #define EXPCL_PANDA_PNMTEXT EXPCL_PANDA #define EXPTP_PANDA_PNMTEXT EXPTP_PANDA +#define EXPCL_PANDA_PSTATCLIENT EXPCL_PANDA +#define EXPTP_PANDA_PSTATCLIENT EXPTP_PANDA + +#define EXPCL_PANDA_PUTIL EXPCL_PANDA +#define EXPTP_PANDA_PUTIL EXPTP_PANDA + +#define EXPCL_PANDA_RECORDER EXPCL_PANDA +#define EXPTP_PANDA_RECORDER EXPTP_PANDA + #define EXPCL_PANDA_TEXT EXPCL_PANDA #define EXPTP_PANDA_TEXT EXPTP_PANDA #define EXPCL_PANDA_TFORM EXPCL_PANDA #define EXPTP_PANDA_TFORM EXPTP_PANDA -#define EXPCL_PANDA_PUTIL EXPCL_PANDA -#define EXPTP_PANDA_PUTIL EXPTP_PANDA - -#define EXPCL_PANDA_AUDIO EXPCL_PANDA -#define EXPTP_PANDA_AUDIO EXPTP_PANDA - -#define EXPCL_PANDA_PGUI EXPCL_PANDA -#define EXPTP_PANDA_PGUI EXPTP_PANDA - #endif From 32aceab7b4e9ea46cd8975dc5df15ba9129decce Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 15 Mar 2018 12:47:09 -0600 Subject: [PATCH 095/247] grutil: Fix missing EXPCL_PANDA_GRUTIL --- panda/src/grutil/sceneGraphAnalyzerMeter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/grutil/sceneGraphAnalyzerMeter.h b/panda/src/grutil/sceneGraphAnalyzerMeter.h index a788ef2f2b..a20066d9d7 100644 --- a/panda/src/grutil/sceneGraphAnalyzerMeter.h +++ b/panda/src/grutil/sceneGraphAnalyzerMeter.h @@ -36,7 +36,7 @@ class ClockObject; * channel or window. If this is done, it creates a DisplayRegion for itself * and renders itself in the upper-right-hand corner. */ -class EXPCL_PANDA SceneGraphAnalyzerMeter : public TextNode { +class EXPCL_PANDA_GRUTIL SceneGraphAnalyzerMeter : public TextNode { PUBLISHED: explicit SceneGraphAnalyzerMeter(const string &name, PandaNode *node); virtual ~SceneGraphAnalyzerMeter(); From 477e6b75613d31920eaf287a5624d99bd531ef7d Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 15 Mar 2018 12:50:22 -0600 Subject: [PATCH 096/247] dxml: EXPCL_PANDA -> EXPCL_PANDA_DXML --- panda/src/dxml/config_dxml.h | 12 ++++++------ panda/src/pandabase/pandasymbols.h | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/panda/src/dxml/config_dxml.h b/panda/src/dxml/config_dxml.h index 4596df95bb..ca2113f678 100644 --- a/panda/src/dxml/config_dxml.h +++ b/panda/src/dxml/config_dxml.h @@ -28,17 +28,17 @@ #define TIXML_USE_STL #endif -NotifyCategoryDecl(dxml, EXPCL_PANDA, EXPTP_PANDA); +NotifyCategoryDecl(dxml, EXPCL_PANDA_DXML, EXPTP_PANDA_DXML); -extern EXPCL_PANDA void init_libdxml(); +extern EXPCL_PANDA_DXML void init_libdxml(); class TiXmlDocument; class TiXmlNode; BEGIN_PUBLISH -EXPCL_PANDA TiXmlDocument *read_xml_stream(istream &in); -EXPCL_PANDA void write_xml_stream(ostream &out, TiXmlDocument *doc); -EXPCL_PANDA void print_xml(TiXmlNode *xnode); -EXPCL_PANDA void print_xml_to_file(const Filename &filename, TiXmlNode *xnode); +EXPCL_PANDA_DXML TiXmlDocument *read_xml_stream(istream &in); +EXPCL_PANDA_DXML void write_xml_stream(ostream &out, TiXmlDocument *doc); +EXPCL_PANDA_DXML void print_xml(TiXmlNode *xnode); +EXPCL_PANDA_DXML void print_xml_to_file(const Filename &filename, TiXmlNode *xnode); END_PUBLISH #endif diff --git a/panda/src/pandabase/pandasymbols.h b/panda/src/pandabase/pandasymbols.h index dafb15e7f1..b1dad6e422 100644 --- a/panda/src/pandabase/pandasymbols.h +++ b/panda/src/pandabase/pandasymbols.h @@ -271,6 +271,9 @@ #define EXPCL_PANDA_DISPLAY EXPCL_PANDA #define EXPTP_PANDA_DISPLAY EXPTP_PANDA +#define EXPCL_PANDA_DXML EXPCL_PANDA +#define EXPTP_PANDA_DXML EXPTP_PANDA + #define EXPCL_PANDA_EVENT EXPCL_PANDA #define EXPTP_PANDA_EVENT EXPTP_PANDA From adbab8deae333f735a7fde44f464833dd437c914 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 16 Mar 2018 21:22:23 +0100 Subject: [PATCH 097/247] x11display: reenable confined mode on window reconfigure Fixes #280 --- panda/src/x11display/x11GraphicsWindow.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index c57a580aa7..0a1539bd42 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -446,6 +446,21 @@ process_events() { XConfigureWindow(_display, _xwindow, value_mask, &changes); } } + + // If the window was reconfigured, we may need to re-confine the mouse + // pointer. See GitHub bug #280. + if (_properties.get_mouse_mode() == WindowProperties::M_confined) { + X11_Cursor cursor = None; + if (_properties.get_cursor_hidden()) { + x11GraphicsPipe *x11_pipe; + DCAST_INTO_V(x11_pipe, _pipe); + cursor = x11_pipe->get_hidden_cursor(); + } + + XGrabPointer(_display, _xwindow, True, 0, GrabModeAsync, GrabModeAsync, + _xwindow, cursor, CurrentTime); + } + changed_properties = true; } From 2031409a6e62dd9ff4aeca7bca01ba6601d6070a Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 18 Mar 2018 00:27:05 -0600 Subject: [PATCH 098/247] gobj: Fix missing include --- panda/src/gobj/geomLinestripsAdjacency.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/panda/src/gobj/geomLinestripsAdjacency.cxx b/panda/src/gobj/geomLinestripsAdjacency.cxx index b8c69fc240..11d14ab319 100644 --- a/panda/src/gobj/geomLinestripsAdjacency.cxx +++ b/panda/src/gobj/geomLinestripsAdjacency.cxx @@ -13,6 +13,7 @@ #include "geomLinestripsAdjacency.h" #include "geomLines.h" +#include "geomLinesAdjacency.h" #include "geomVertexRewriter.h" #include "pStatTimer.h" #include "bamReader.h" From a4c1b443710c6208fb0b29ca4f56899fc75714f1 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 19 Mar 2018 21:20:10 -0600 Subject: [PATCH 099/247] dtoolbase: Remove EXPORT_TEMPLATES define As of f69354d9fa603ac05dfd924af3844f749fd50cdd, this is just always expected on all platforms. If it's not defined, TemplateClass::_type_handle won't link correctly with some compilers (e.g. Clang) and the lack of 'extern template class' will result in duplicated code in any case. In short, turning it off causes problems. makepanda also always turns this on, so it doesn't represent any optional feature or autodetected platform-specific behavior anyway. --- dtool/src/dtoolbase/dtoolbase_cc.h | 2 +- makepanda/makepanda.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index eb84f1fccd..dee66e04da 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -257,7 +257,7 @@ template typename remove_reference::type &&move(T &&t) { #endif -#if !defined(LINK_ALL_STATIC) && defined(EXPORT_TEMPLATES) +#ifndef LINK_ALL_STATIC // This macro must be used to export an instantiated template class from a // DLL. If the template class name itself contains commas, it may be // necessary to first define a macro for the class name, to allow proper macro diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 1c8c95724d..59633ea892 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2253,7 +2253,6 @@ DTOOL_CONFIG=[ ("SUPPORT_FIXED_FUNCTION", '1', '1'), ("DO_MEMORY_USAGE", 'UNDEF', 'UNDEF'), ("DO_PIPELINING", '1', '1'), - ("EXPORT_TEMPLATES", 'yes', 'yes'), ("DEFAULT_PATHSEP", '";"', '":"'), ("WORDS_BIGENDIAN", 'UNDEF', 'UNDEF'), ("HAVE_NAMESPACE", '1', '1'), From cfd70ebeadd15074f00b3266cc1a1629014cf5fd Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 19 Mar 2018 21:41:23 -0600 Subject: [PATCH 100/247] general: Remove '#pragma interface'/'#pragma implementation' The GCC documentation states that, as of GCC 2.7.2, these aren't necessary for proper program behavior. The documentation further discourages their use because they don't suppress unnecessary code duplication. The Panda codebase these days uses "extern template class" instead, which tells the compiler not to perform implicit template expansion because an explicit template expansion is available for linking elsewhere in the program. This is a more compiler-neutral way of achieving the same thing as '#pragma interface', making '#pragma interface' not only redundant, it could also mask problems in the "extern template class" machinery. --- dtool/src/dtoolutil/vector_double.cxx | 5 ----- dtool/src/dtoolutil/vector_double.h | 5 ----- dtool/src/dtoolutil/vector_float.cxx | 5 ----- dtool/src/dtoolutil/vector_float.h | 5 ----- dtool/src/dtoolutil/vector_int.cxx | 5 ----- dtool/src/dtoolutil/vector_int.h | 5 ----- dtool/src/dtoolutil/vector_string.cxx | 5 ----- dtool/src/dtoolutil/vector_string.h | 5 ----- dtool/src/dtoolutil/vector_uchar.cxx | 5 ----- dtool/src/dtoolutil/vector_uchar.h | 5 ----- panda/src/chan/animChannel.cxx | 5 ----- panda/src/chan/animChannel.h | 6 ------ panda/src/chan/movingPartMatrix.cxx | 5 ----- panda/src/chan/movingPartMatrix.h | 5 ----- panda/src/chan/movingPartScalar.cxx | 5 ----- panda/src/chan/movingPartScalar.h | 5 ----- panda/src/chan/vector_PartGroupStar.cxx | 5 ----- panda/src/chan/vector_PartGroupStar.h | 5 ----- panda/src/display/graphicsWindowInputDevice.cxx | 5 ----- panda/src/display/graphicsWindowInputDevice.h | 5 ----- panda/src/egg/pt_EggMaterial.cxx | 5 ----- panda/src/egg/pt_EggMaterial.h | 5 ----- panda/src/egg/pt_EggTexture.cxx | 5 ----- panda/src/egg/pt_EggTexture.h | 5 ----- panda/src/egg/pt_EggVertex.cxx | 5 ----- panda/src/egg/pt_EggVertex.h | 5 ----- panda/src/egg/vector_PT_EggMaterial.cxx | 5 ----- panda/src/egg/vector_PT_EggMaterial.h | 5 ----- panda/src/egg/vector_PT_EggTexture.cxx | 5 ----- panda/src/egg/vector_PT_EggTexture.h | 5 ----- panda/src/egg/vector_PT_EggVertex.cxx | 5 ----- panda/src/egg/vector_PT_EggVertex.h | 5 ----- panda/src/event/eventParameter.cxx | 5 ----- panda/src/event/eventParameter.h | 5 ----- panda/src/event/pt_Event.cxx | 5 ----- panda/src/event/pt_Event.h | 5 ----- panda/src/express/pta_double.cxx | 5 ----- panda/src/express/pta_double.h | 5 ----- panda/src/express/pta_float.cxx | 5 ----- panda/src/express/pta_float.h | 5 ----- panda/src/express/pta_int.cxx | 5 ----- panda/src/express/pta_int.h | 5 ----- panda/src/express/pta_uchar.cxx | 5 ----- panda/src/express/pta_uchar.h | 5 ----- panda/src/mathutil/linmath_events.cxx | 5 ----- panda/src/mathutil/linmath_events.h | 5 ----- panda/src/mathutil/pta_LMatrix3.cxx | 5 ----- panda/src/mathutil/pta_LMatrix3.h | 5 ----- panda/src/mathutil/pta_LMatrix4.cxx | 5 ----- panda/src/mathutil/pta_LMatrix4.h | 5 ----- panda/src/mathutil/pta_LVecBase2.cxx | 5 ----- panda/src/mathutil/pta_LVecBase2.h | 5 ----- panda/src/mathutil/pta_LVecBase3.cxx | 5 ----- panda/src/mathutil/pta_LVecBase3.h | 5 ----- panda/src/mathutil/pta_LVecBase4.cxx | 5 ----- panda/src/mathutil/pta_LVecBase4.h | 5 ----- panda/src/putil/bitMask.cxx | 5 ----- panda/src/putil/bitMask.h | 5 ----- panda/src/putil/doubleBitMask.cxx | 5 ----- panda/src/putil/doubleBitMask.h | 5 ----- panda/src/putil/paramValue.cxx | 5 ----- panda/src/putil/paramValue.h | 5 ----- panda/src/putil/pta_ushort.cxx | 5 ----- panda/src/putil/pta_ushort.h | 5 ----- panda/src/putil/vector_typedWritable.cxx | 5 ----- panda/src/putil/vector_typedWritable.h | 5 ----- panda/src/putil/vector_ulong.cxx | 5 ----- panda/src/putil/vector_ulong.h | 5 ----- panda/src/putil/vector_ushort.cxx | 5 ----- panda/src/putil/vector_ushort.h | 5 ----- panda/src/putil/vector_writable.cxx | 5 ----- panda/src/putil/vector_writable.h | 5 ----- 72 files changed, 361 deletions(-) diff --git a/dtool/src/dtoolutil/vector_double.cxx b/dtool/src/dtoolutil/vector_double.cxx index a6def549af..e275c5ac8c 100644 --- a/dtool/src/dtoolutil/vector_double.cxx +++ b/dtool/src/dtoolutil/vector_double.cxx @@ -19,8 +19,3 @@ #define NAME vector_double #include "vector_src.cxx" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/dtool/src/dtoolutil/vector_double.h b/dtool/src/dtoolutil/vector_double.h index 6757bddc7a..5e00afd598 100644 --- a/dtool/src/dtoolutil/vector_double.h +++ b/dtool/src/dtoolutil/vector_double.h @@ -30,9 +30,4 @@ #include "vector_src.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/dtool/src/dtoolutil/vector_float.cxx b/dtool/src/dtoolutil/vector_float.cxx index a84b030a56..3d2d1233c5 100644 --- a/dtool/src/dtoolutil/vector_float.cxx +++ b/dtool/src/dtoolutil/vector_float.cxx @@ -19,8 +19,3 @@ #define NAME vector_float #include "vector_src.cxx" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/dtool/src/dtoolutil/vector_float.h b/dtool/src/dtoolutil/vector_float.h index 36d9f200f9..b9033a5ce7 100644 --- a/dtool/src/dtoolutil/vector_float.h +++ b/dtool/src/dtoolutil/vector_float.h @@ -30,9 +30,4 @@ #include "vector_src.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/dtool/src/dtoolutil/vector_int.cxx b/dtool/src/dtoolutil/vector_int.cxx index 1bb9423b7e..3032da29f4 100644 --- a/dtool/src/dtoolutil/vector_int.cxx +++ b/dtool/src/dtoolutil/vector_int.cxx @@ -19,8 +19,3 @@ #define NAME vector_int #include "vector_src.cxx" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/dtool/src/dtoolutil/vector_int.h b/dtool/src/dtoolutil/vector_int.h index 56436a956f..b149c3ddd3 100644 --- a/dtool/src/dtoolutil/vector_int.h +++ b/dtool/src/dtoolutil/vector_int.h @@ -30,9 +30,4 @@ #include "vector_src.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/dtool/src/dtoolutil/vector_string.cxx b/dtool/src/dtoolutil/vector_string.cxx index 0e5df2ce1d..72239b28ac 100644 --- a/dtool/src/dtoolutil/vector_string.cxx +++ b/dtool/src/dtoolutil/vector_string.cxx @@ -19,8 +19,3 @@ #define NAME vector_string #include "vector_src.cxx" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/dtool/src/dtoolutil/vector_string.h b/dtool/src/dtoolutil/vector_string.h index d34ab7b301..117baf8543 100644 --- a/dtool/src/dtoolutil/vector_string.h +++ b/dtool/src/dtoolutil/vector_string.h @@ -30,9 +30,4 @@ #include "vector_src.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/dtool/src/dtoolutil/vector_uchar.cxx b/dtool/src/dtoolutil/vector_uchar.cxx index 07434032dd..e3473584d4 100644 --- a/dtool/src/dtoolutil/vector_uchar.cxx +++ b/dtool/src/dtoolutil/vector_uchar.cxx @@ -19,8 +19,3 @@ #define NAME vector_uchar #include "vector_src.cxx" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/dtool/src/dtoolutil/vector_uchar.h b/dtool/src/dtoolutil/vector_uchar.h index 608472ae7e..bf8d989990 100644 --- a/dtool/src/dtoolutil/vector_uchar.h +++ b/dtool/src/dtoolutil/vector_uchar.h @@ -30,9 +30,4 @@ #include "vector_src.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/chan/animChannel.cxx b/panda/src/chan/animChannel.cxx index 66fc1329f4..dfaf152b7b 100644 --- a/panda/src/chan/animChannel.cxx +++ b/panda/src/chan/animChannel.cxx @@ -15,11 +15,6 @@ #include "compose_matrix.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - template class AnimChannel; template class AnimChannel; diff --git a/panda/src/chan/animChannel.h b/panda/src/chan/animChannel.h index 1c7fd639fc..4137196f52 100644 --- a/panda/src/chan/animChannel.h +++ b/panda/src/chan/animChannel.h @@ -122,10 +122,4 @@ typedef AnimChannel AnimChannelScalar; #include "animChannel.I" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/chan/movingPartMatrix.cxx b/panda/src/chan/movingPartMatrix.cxx index 29ed1f79be..6477728e0d 100644 --- a/panda/src/chan/movingPartMatrix.cxx +++ b/panda/src/chan/movingPartMatrix.cxx @@ -21,11 +21,6 @@ #include "bamWriter.h" #include "config_chan.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - template class MovingPart; TypeHandle MovingPartMatrix::_type_handle; diff --git a/panda/src/chan/movingPartMatrix.h b/panda/src/chan/movingPartMatrix.h index 78352423fc..3c232e63d0 100644 --- a/panda/src/chan/movingPartMatrix.h +++ b/panda/src/chan/movingPartMatrix.h @@ -72,9 +72,4 @@ private: #include "movingPartMatrix.I" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/chan/movingPartScalar.cxx b/panda/src/chan/movingPartScalar.cxx index ed49cddf63..abebb49a32 100644 --- a/panda/src/chan/movingPartScalar.cxx +++ b/panda/src/chan/movingPartScalar.cxx @@ -19,11 +19,6 @@ #include "bamWriter.h" #include "config_chan.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - template class MovingPart; TypeHandle MovingPartScalar::_type_handle; diff --git a/panda/src/chan/movingPartScalar.h b/panda/src/chan/movingPartScalar.h index 5e45e95e4a..90bd049ee5 100644 --- a/panda/src/chan/movingPartScalar.h +++ b/panda/src/chan/movingPartScalar.h @@ -70,9 +70,4 @@ private: #include "movingPartScalar.I" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/chan/vector_PartGroupStar.cxx b/panda/src/chan/vector_PartGroupStar.cxx index e0f6554731..d31dd613bb 100644 --- a/panda/src/chan/vector_PartGroupStar.cxx +++ b/panda/src/chan/vector_PartGroupStar.cxx @@ -19,8 +19,3 @@ #define NAME vector_PartGroupStar #include "vector_src.cxx" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/panda/src/chan/vector_PartGroupStar.h b/panda/src/chan/vector_PartGroupStar.h index 988635dc33..4e5098a8a8 100644 --- a/panda/src/chan/vector_PartGroupStar.h +++ b/panda/src/chan/vector_PartGroupStar.h @@ -32,9 +32,4 @@ #include "vector_src.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/display/graphicsWindowInputDevice.cxx b/panda/src/display/graphicsWindowInputDevice.cxx index 4e0b0a08c2..89d6e9d5b4 100644 --- a/panda/src/display/graphicsWindowInputDevice.cxx +++ b/panda/src/display/graphicsWindowInputDevice.cxx @@ -23,11 +23,6 @@ #include "vector_src.cxx" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - /** * Defines a new InputDevice for the window. Most windows will have exactly * one InputDevice: a keyboard/mouse pair. Some may also add joystick data, diff --git a/panda/src/display/graphicsWindowInputDevice.h b/panda/src/display/graphicsWindowInputDevice.h index 7523ea7e91..5cdff54f29 100644 --- a/panda/src/display/graphicsWindowInputDevice.h +++ b/panda/src/display/graphicsWindowInputDevice.h @@ -142,9 +142,4 @@ private: #include "vector_src.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/egg/pt_EggMaterial.cxx b/panda/src/egg/pt_EggMaterial.cxx index 2750824e5a..af0ae82e6f 100644 --- a/panda/src/egg/pt_EggMaterial.cxx +++ b/panda/src/egg/pt_EggMaterial.cxx @@ -13,11 +13,6 @@ #include "pt_EggMaterial.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - template class PointerToBase; template class PointerTo; template class ConstPointerTo; diff --git a/panda/src/egg/pt_EggMaterial.h b/panda/src/egg/pt_EggMaterial.h index 218de12074..7c5e5f083e 100644 --- a/panda/src/egg/pt_EggMaterial.h +++ b/panda/src/egg/pt_EggMaterial.h @@ -31,9 +31,4 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, ConstPointerTo PT_EggMaterial; typedef ConstPointerTo CPT_EggMaterial; -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/egg/pt_EggTexture.cxx b/panda/src/egg/pt_EggTexture.cxx index 8a90ad2a24..ea2336996f 100644 --- a/panda/src/egg/pt_EggTexture.cxx +++ b/panda/src/egg/pt_EggTexture.cxx @@ -13,11 +13,6 @@ #include "pt_EggTexture.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - template class PointerToBase; template class PointerTo; template class ConstPointerTo; diff --git a/panda/src/egg/pt_EggTexture.h b/panda/src/egg/pt_EggTexture.h index 15a9738f96..bc61025fb6 100644 --- a/panda/src/egg/pt_EggTexture.h +++ b/panda/src/egg/pt_EggTexture.h @@ -31,9 +31,4 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, ConstPointerTo typedef PointerTo PT_EggTexture; typedef ConstPointerTo CPT_EggTexture; -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/egg/pt_EggVertex.cxx b/panda/src/egg/pt_EggVertex.cxx index b1b932328b..9c974e8e63 100644 --- a/panda/src/egg/pt_EggVertex.cxx +++ b/panda/src/egg/pt_EggVertex.cxx @@ -13,11 +13,6 @@ #include "pt_EggVertex.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - template class PointerToBase; template class PointerTo; template class ConstPointerTo; diff --git a/panda/src/egg/pt_EggVertex.h b/panda/src/egg/pt_EggVertex.h index 483a893a13..5c2922b51d 100644 --- a/panda/src/egg/pt_EggVertex.h +++ b/panda/src/egg/pt_EggVertex.h @@ -31,9 +31,4 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, ConstPointerTo) typedef PointerTo PT_EggVertex; typedef ConstPointerTo CPT_EggVertex; -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/egg/vector_PT_EggMaterial.cxx b/panda/src/egg/vector_PT_EggMaterial.cxx index ce183b5aa0..d504d36ca9 100644 --- a/panda/src/egg/vector_PT_EggMaterial.cxx +++ b/panda/src/egg/vector_PT_EggMaterial.cxx @@ -19,8 +19,3 @@ #define NAME vector_PT_EggMaterial #include "vector_src.cxx" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/panda/src/egg/vector_PT_EggMaterial.h b/panda/src/egg/vector_PT_EggMaterial.h index 0aaab728a7..0878ba71c0 100644 --- a/panda/src/egg/vector_PT_EggMaterial.h +++ b/panda/src/egg/vector_PT_EggMaterial.h @@ -35,9 +35,4 @@ #include "vector_src.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/egg/vector_PT_EggTexture.cxx b/panda/src/egg/vector_PT_EggTexture.cxx index f95063202e..bdd2acf2da 100644 --- a/panda/src/egg/vector_PT_EggTexture.cxx +++ b/panda/src/egg/vector_PT_EggTexture.cxx @@ -19,8 +19,3 @@ #define NAME vector_PT_EggTexture #include "vector_src.cxx" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/panda/src/egg/vector_PT_EggTexture.h b/panda/src/egg/vector_PT_EggTexture.h index 44849ec364..12d5f91212 100644 --- a/panda/src/egg/vector_PT_EggTexture.h +++ b/panda/src/egg/vector_PT_EggTexture.h @@ -35,9 +35,4 @@ #include "vector_src.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/egg/vector_PT_EggVertex.cxx b/panda/src/egg/vector_PT_EggVertex.cxx index 0343a4771b..61deffdeac 100644 --- a/panda/src/egg/vector_PT_EggVertex.cxx +++ b/panda/src/egg/vector_PT_EggVertex.cxx @@ -19,8 +19,3 @@ #define NAME vector_PT_EggVertex #include "vector_src.cxx" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/panda/src/egg/vector_PT_EggVertex.h b/panda/src/egg/vector_PT_EggVertex.h index 6827f35783..8d04bccc17 100644 --- a/panda/src/egg/vector_PT_EggVertex.h +++ b/panda/src/egg/vector_PT_EggVertex.h @@ -35,9 +35,4 @@ #include "vector_src.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/event/eventParameter.cxx b/panda/src/event/eventParameter.cxx index 45780e5ff0..e5e55a1bac 100644 --- a/panda/src/event/eventParameter.cxx +++ b/panda/src/event/eventParameter.cxx @@ -14,11 +14,6 @@ #include "eventParameter.h" #include "dcast.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - template class ParamValue; template class ParamValue; diff --git a/panda/src/event/eventParameter.h b/panda/src/event/eventParameter.h index b0cbcc1376..65dbf550c8 100644 --- a/panda/src/event/eventParameter.h +++ b/panda/src/event/eventParameter.h @@ -86,9 +86,4 @@ typedef ParamWstring EventStoreWstring; #include "eventParameter.I" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/event/pt_Event.cxx b/panda/src/event/pt_Event.cxx index 095ce8b56b..66b4897052 100644 --- a/panda/src/event/pt_Event.cxx +++ b/panda/src/event/pt_Event.cxx @@ -13,11 +13,6 @@ #include "pt_Event.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - template class PointerToBase; template class PointerTo; template class ConstPointerTo; diff --git a/panda/src/event/pt_Event.h b/panda/src/event/pt_Event.h index 6c59b8fecd..ce5d8cea39 100644 --- a/panda/src/event/pt_Event.h +++ b/panda/src/event/pt_Event.h @@ -32,9 +32,4 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EVENT, EXPTP_PANDA_EVENT, ConstPointerTo PT_Event; typedef ConstPointerTo CPT_Event; -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/express/pta_double.cxx b/panda/src/express/pta_double.cxx index efb3ec3086..0acc113075 100644 --- a/panda/src/express/pta_double.cxx +++ b/panda/src/express/pta_double.cxx @@ -13,11 +13,6 @@ #include "pta_double.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - template class PointerToBase >; template class PointerToArrayBase; template class PointerToArray; diff --git a/panda/src/express/pta_double.h b/panda/src/express/pta_double.h index 2cb239513f..4db51677eb 100644 --- a/panda/src/express/pta_double.h +++ b/panda/src/express/pta_double.h @@ -34,9 +34,4 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, ConstPointerToArra typedef PointerToArray PTA_double; typedef ConstPointerToArray CPTA_double; -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/express/pta_float.cxx b/panda/src/express/pta_float.cxx index 3d75ca4ac4..f1cfd87a64 100644 --- a/panda/src/express/pta_float.cxx +++ b/panda/src/express/pta_float.cxx @@ -13,11 +13,6 @@ #include "pta_float.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - template class PointerToBase >; template class PointerToArrayBase; template class PointerToArray; diff --git a/panda/src/express/pta_float.h b/panda/src/express/pta_float.h index b2f14953f9..fd84774654 100644 --- a/panda/src/express/pta_float.h +++ b/panda/src/express/pta_float.h @@ -34,9 +34,4 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, ConstPointerToArra typedef PointerToArray PTA_float; typedef ConstPointerToArray CPTA_float; -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/express/pta_int.cxx b/panda/src/express/pta_int.cxx index 417838605c..6dab4d03c8 100644 --- a/panda/src/express/pta_int.cxx +++ b/panda/src/express/pta_int.cxx @@ -13,11 +13,6 @@ #include "pta_int.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - template class PointerToBase >; template class PointerToArrayBase; template class PointerToArray; diff --git a/panda/src/express/pta_int.h b/panda/src/express/pta_int.h index 16a2c504e3..93ed0bb900 100644 --- a/panda/src/express/pta_int.h +++ b/panda/src/express/pta_int.h @@ -34,9 +34,4 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, ConstPointerToArra typedef PointerToArray PTA_int; typedef ConstPointerToArray CPTA_int; -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/express/pta_uchar.cxx b/panda/src/express/pta_uchar.cxx index 58b4b508c0..919eb2bc14 100644 --- a/panda/src/express/pta_uchar.cxx +++ b/panda/src/express/pta_uchar.cxx @@ -13,11 +13,6 @@ #include "pta_uchar.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - template class PointerToBase >; template class PointerToArrayBase; template class PointerToArray; diff --git a/panda/src/express/pta_uchar.h b/panda/src/express/pta_uchar.h index 5715480cd8..1552c6bcab 100644 --- a/panda/src/express/pta_uchar.h +++ b/panda/src/express/pta_uchar.h @@ -38,9 +38,4 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, ConstPointerToArra typedef PointerToArray PTA_uchar; typedef ConstPointerToArray CPTA_uchar; -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/mathutil/linmath_events.cxx b/panda/src/mathutil/linmath_events.cxx index a116cc696a..8dba9c22a4 100644 --- a/panda/src/mathutil/linmath_events.cxx +++ b/panda/src/mathutil/linmath_events.cxx @@ -12,8 +12,3 @@ */ #include "linmath_events.h" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/panda/src/mathutil/linmath_events.h b/panda/src/mathutil/linmath_events.h index d5d3cea907..aec3436316 100644 --- a/panda/src/mathutil/linmath_events.h +++ b/panda/src/mathutil/linmath_events.h @@ -27,9 +27,4 @@ typedef ParamVecBase2 EventStoreVec2; typedef ParamVecBase3 EventStoreVec3; typedef ParamMatrix4 EventStoreMat4; -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/mathutil/pta_LMatrix3.cxx b/panda/src/mathutil/pta_LMatrix3.cxx index e6a273a9fb..fb761a54d7 100644 --- a/panda/src/mathutil/pta_LMatrix3.cxx +++ b/panda/src/mathutil/pta_LMatrix3.cxx @@ -13,11 +13,6 @@ #include "pta_LMatrix3.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - template class PointerToBase >; template class PointerToArrayBase; template class PointerToArray; diff --git a/panda/src/mathutil/pta_LMatrix3.h b/panda/src/mathutil/pta_LMatrix3.h index ccd88e156c..3b0de0672b 100644 --- a/panda/src/mathutil/pta_LMatrix3.h +++ b/panda/src/mathutil/pta_LMatrix3.h @@ -64,9 +64,4 @@ typedef PTA_LMatrix3d PTAMat3d; typedef CPTA_LMatrix3d CPTAMat3d; #endif // CPPPARSER -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/mathutil/pta_LMatrix4.cxx b/panda/src/mathutil/pta_LMatrix4.cxx index 02ba4d48da..11b70bef07 100644 --- a/panda/src/mathutil/pta_LMatrix4.cxx +++ b/panda/src/mathutil/pta_LMatrix4.cxx @@ -13,11 +13,6 @@ #include "pta_LMatrix4.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - template class PointerToBase >; template class PointerToArrayBase; template class PointerToArray; diff --git a/panda/src/mathutil/pta_LMatrix4.h b/panda/src/mathutil/pta_LMatrix4.h index ef5888b465..61ba1495ff 100644 --- a/panda/src/mathutil/pta_LMatrix4.h +++ b/panda/src/mathutil/pta_LMatrix4.h @@ -70,9 +70,4 @@ typedef PTA_LMatrix4d PTAMat4d; typedef CPTA_LMatrix4d CPTAMat4d; #endif // CPPPARSER -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/mathutil/pta_LVecBase2.cxx b/panda/src/mathutil/pta_LVecBase2.cxx index 6c232034df..0f631c452f 100644 --- a/panda/src/mathutil/pta_LVecBase2.cxx +++ b/panda/src/mathutil/pta_LVecBase2.cxx @@ -13,11 +13,6 @@ #include "pta_LVecBase2.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - template class PointerToBase >; template class PointerToArrayBase; template class PointerToArray; diff --git a/panda/src/mathutil/pta_LVecBase2.h b/panda/src/mathutil/pta_LVecBase2.h index b4296df5da..2d87312cd1 100644 --- a/panda/src/mathutil/pta_LVecBase2.h +++ b/panda/src/mathutil/pta_LVecBase2.h @@ -79,9 +79,4 @@ typedef PTA_LVecBase2d PTAVecBase2d; typedef CPTA_LVecBase2d CPTAVecBase2d; #endif // CPPPARSER -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/mathutil/pta_LVecBase3.cxx b/panda/src/mathutil/pta_LVecBase3.cxx index 7248c2638c..501fd86cf6 100644 --- a/panda/src/mathutil/pta_LVecBase3.cxx +++ b/panda/src/mathutil/pta_LVecBase3.cxx @@ -13,11 +13,6 @@ #include "pta_LVecBase3.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - template class PointerToBase >; template class PointerToArrayBase; template class PointerToArray; diff --git a/panda/src/mathutil/pta_LVecBase3.h b/panda/src/mathutil/pta_LVecBase3.h index f883e1acbb..73492e26d6 100644 --- a/panda/src/mathutil/pta_LVecBase3.h +++ b/panda/src/mathutil/pta_LVecBase3.h @@ -79,9 +79,4 @@ typedef PTA_LVecBase3d PTAVecBase3d; typedef CPTA_LVecBase3d CPTAVecBase3d; #endif // CPPPARSER -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/mathutil/pta_LVecBase4.cxx b/panda/src/mathutil/pta_LVecBase4.cxx index b06d7340a4..a638ebdd22 100644 --- a/panda/src/mathutil/pta_LVecBase4.cxx +++ b/panda/src/mathutil/pta_LVecBase4.cxx @@ -13,11 +13,6 @@ #include "pta_LVecBase4.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - template class PointerToBase >; template class PointerToArrayBase; template class PointerToArray; diff --git a/panda/src/mathutil/pta_LVecBase4.h b/panda/src/mathutil/pta_LVecBase4.h index 0d966002c0..e62351ca4a 100644 --- a/panda/src/mathutil/pta_LVecBase4.h +++ b/panda/src/mathutil/pta_LVecBase4.h @@ -88,9 +88,4 @@ typedef PTA_LVecBase4d PTAVecBase4d; typedef CPTA_LVecBase4d CPTAVecBase4d; #endif // CPPPARSER -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/putil/bitMask.cxx b/panda/src/putil/bitMask.cxx index 385d773695..8e51315eb2 100644 --- a/panda/src/putil/bitMask.cxx +++ b/panda/src/putil/bitMask.cxx @@ -13,11 +13,6 @@ #include "bitMask.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - template class BitMask; template class BitMask; template class BitMask; diff --git a/panda/src/putil/bitMask.h b/panda/src/putil/bitMask.h index ff9b15db97..5333562025 100644 --- a/panda/src/putil/bitMask.h +++ b/panda/src/putil/bitMask.h @@ -172,9 +172,4 @@ typedef BitMask64 BitMaskNative; #error No definition for NATIVE_WORDSIZE--should be defined in dtoolbase.h. #endif // NATIVE_WORDSIZE -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/putil/doubleBitMask.cxx b/panda/src/putil/doubleBitMask.cxx index 7d68b48dbe..c35d11613a 100644 --- a/panda/src/putil/doubleBitMask.cxx +++ b/panda/src/putil/doubleBitMask.cxx @@ -13,10 +13,5 @@ #include "doubleBitMask.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - template class DoubleBitMask; template class DoubleBitMask; diff --git a/panda/src/putil/doubleBitMask.h b/panda/src/putil/doubleBitMask.h index 3b3f521ec2..d229eb03a6 100644 --- a/panda/src/putil/doubleBitMask.h +++ b/panda/src/putil/doubleBitMask.h @@ -144,9 +144,4 @@ typedef DoubleBitMask DoubleBitMaskNative; EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, DoubleBitMask); typedef DoubleBitMask QuadBitMaskNative; -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/putil/paramValue.cxx b/panda/src/putil/paramValue.cxx index e2ee6dadf1..6937a27faa 100644 --- a/panda/src/putil/paramValue.cxx +++ b/panda/src/putil/paramValue.cxx @@ -14,11 +14,6 @@ #include "paramValue.h" #include "dcast.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - template class ParamValue; template class ParamValue; diff --git a/panda/src/putil/paramValue.h b/panda/src/putil/paramValue.h index a75b4360b3..b17b2c9c37 100644 --- a/panda/src/putil/paramValue.h +++ b/panda/src/putil/paramValue.h @@ -209,9 +209,4 @@ typedef ParamMatrix3f ParamMatrix3; typedef ParamMatrix4f ParamMatrix4; #endif -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/putil/pta_ushort.cxx b/panda/src/putil/pta_ushort.cxx index 6323614b99..6163184397 100644 --- a/panda/src/putil/pta_ushort.cxx +++ b/panda/src/putil/pta_ushort.cxx @@ -13,11 +13,6 @@ #include "pta_ushort.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif - template class PointerToBase >; template class PointerToArrayBase; template class PointerToArray; diff --git a/panda/src/putil/pta_ushort.h b/panda/src/putil/pta_ushort.h index 51bf61927d..6424ddb237 100644 --- a/panda/src/putil/pta_ushort.h +++ b/panda/src/putil/pta_ushort.h @@ -34,9 +34,4 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ConstPointerToArray< typedef PointerToArray PTA_ushort; typedef ConstPointerToArray CPTA_ushort; -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/putil/vector_typedWritable.cxx b/panda/src/putil/vector_typedWritable.cxx index 7c306f959f..8759e17d13 100644 --- a/panda/src/putil/vector_typedWritable.cxx +++ b/panda/src/putil/vector_typedWritable.cxx @@ -19,8 +19,3 @@ #define NAME vector_typedWritable #include "vector_src.cxx" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/panda/src/putil/vector_typedWritable.h b/panda/src/putil/vector_typedWritable.h index 61e87d19fa..9648c6ef58 100644 --- a/panda/src/putil/vector_typedWritable.h +++ b/panda/src/putil/vector_typedWritable.h @@ -34,9 +34,4 @@ class TypedWritable; #include "vector_src.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/putil/vector_ulong.cxx b/panda/src/putil/vector_ulong.cxx index 58f63aed5c..930b461e31 100644 --- a/panda/src/putil/vector_ulong.cxx +++ b/panda/src/putil/vector_ulong.cxx @@ -19,8 +19,3 @@ #define NAME vector_ulong #include "vector_src.cxx" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/panda/src/putil/vector_ulong.h b/panda/src/putil/vector_ulong.h index 7f86a91d4d..c7a3ba2a6e 100644 --- a/panda/src/putil/vector_ulong.h +++ b/panda/src/putil/vector_ulong.h @@ -32,9 +32,4 @@ #include "vector_src.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/putil/vector_ushort.cxx b/panda/src/putil/vector_ushort.cxx index 274aa9bed0..fd7252ad52 100644 --- a/panda/src/putil/vector_ushort.cxx +++ b/panda/src/putil/vector_ushort.cxx @@ -19,8 +19,3 @@ #define NAME vector_ushort #include "vector_src.cxx" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/panda/src/putil/vector_ushort.h b/panda/src/putil/vector_ushort.h index f336da3236..3ec5c7d07b 100644 --- a/panda/src/putil/vector_ushort.h +++ b/panda/src/putil/vector_ushort.h @@ -32,9 +32,4 @@ #include "vector_src.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif diff --git a/panda/src/putil/vector_writable.cxx b/panda/src/putil/vector_writable.cxx index 3faefc0c2f..ce7fb138c3 100644 --- a/panda/src/putil/vector_writable.cxx +++ b/panda/src/putil/vector_writable.cxx @@ -18,8 +18,3 @@ #define NAME vector_writable #include "vector_src.cxx" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/panda/src/putil/vector_writable.h b/panda/src/putil/vector_writable.h index 8d3fd4b46a..9825ed40ad 100644 --- a/panda/src/putil/vector_writable.h +++ b/panda/src/putil/vector_writable.h @@ -34,9 +34,4 @@ class Writable; #include "vector_src.h" -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - #endif From 09a9a8ff22b193b8e9fa2d6efb5f3ded6449ca28 Mon Sep 17 00:00:00 2001 From: deflected Date: Thu, 22 Mar 2018 12:35:09 +0200 Subject: [PATCH 101/247] multifile: Return vector_uchar from readSubfile - Return vector_uchar from readSubfile instead of string. This will correct problems with Python 3 unicode strings and will return bytes instead. Signed-off-by: deflected Closes #290 --- panda/src/express/multifile.I | 6 +++--- panda/src/express/multifile.h | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/panda/src/express/multifile.I b/panda/src/express/multifile.I index 5e20779f0d..a498534726 100644 --- a/panda/src/express/multifile.I +++ b/panda/src/express/multifile.I @@ -278,12 +278,12 @@ remove_subfile(const string &subfile_name) { } /** - * Returns a string that contains the entire contents of the indicated + * Returns a vector_uchar that contains the entire contents of the indicated * subfile. */ -INLINE string Multifile:: +INLINE vector_uchar Multifile:: read_subfile(int index) { - string result; + vector_uchar result; read_subfile(index, result); return result; } diff --git a/panda/src/express/multifile.h b/panda/src/express/multifile.h index f290c98602..d9f7217dfd 100644 --- a/panda/src/express/multifile.h +++ b/panda/src/express/multifile.h @@ -24,6 +24,7 @@ #include "indirectLess.h" #include "referenceCount.h" #include "pvector.h" +#include "vector_uchar.h" #ifdef HAVE_OPENSSL typedef struct x509_st X509; @@ -125,7 +126,7 @@ PUBLISHED: streampos get_subfile_internal_start(int index) const; size_t get_subfile_internal_length(int index) const; - BLOCKING INLINE string read_subfile(int index); + BLOCKING INLINE vector_uchar read_subfile(int index); BLOCKING istream *open_read_subfile(int index); BLOCKING static void close_read_subfile(istream *stream); BLOCKING bool extract_subfile(int index, const Filename &filename); From 5fec62b6fab0c9bebe3bb00edf2a0da7d7743f1e Mon Sep 17 00:00:00 2001 From: deflected Date: Thu, 22 Mar 2018 12:31:41 +0200 Subject: [PATCH 102/247] bullet: Corrected possible false check - When a bullet world is created it sets the filter algorithm callback that will use. Later changes to PRC config data should not lead to false assumptions that the bullet world is working with the new config. Signed-off-by: deflected Closes #289 --- panda/src/bullet/bulletWorld.cxx | 7 ++++--- panda/src/bullet/bulletWorld.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/panda/src/bullet/bulletWorld.cxx b/panda/src/bullet/bulletWorld.cxx index 18c23c8896..9bfa707e9d 100644 --- a/panda/src/bullet/bulletWorld.cxx +++ b/panda/src/bullet/bulletWorld.cxx @@ -82,7 +82,8 @@ BulletWorld() { _world->getPairCache()->setInternalGhostPairCallback(&_ghost_cb); // Filter callback - switch (bullet_filter_algorithm) { + _filter_algorithm = bullet_filter_algorithm; + switch (_filter_algorithm) { case FA_mask: _filter_cb = &_filter_cb1; break; @@ -1086,7 +1087,7 @@ void BulletWorld:: set_group_collision_flag(unsigned int group1, unsigned int group2, bool enable) { LightMutexHolder holder(get_global_lock()); - if (bullet_filter_algorithm != FA_groups_mask) { + if (_filter_algorithm != FA_groups_mask) { bullet_cat.warning() << "filter algorithm is not 'groups-mask'" << endl; } @@ -1198,7 +1199,7 @@ set_filter_callback(CallbackObject *obj) { nassertv(obj != NULL); - if (bullet_filter_algorithm != FA_callback) { + if (_filter_algorithm != FA_callback) { bullet_cat.warning() << "filter algorithm is not 'callback'" << endl; } diff --git a/panda/src/bullet/bulletWorld.h b/panda/src/bullet/bulletWorld.h index 36f3723535..35a2c8c634 100644 --- a/panda/src/bullet/bulletWorld.h +++ b/panda/src/bullet/bulletWorld.h @@ -265,6 +265,7 @@ private: btGhostPairCallback _ghost_cb; + FilterAlgorithm _filter_algorithm; btFilterCallback1 _filter_cb1; btFilterCallback2 _filter_cb2; btFilterCallback3 _filter_cb3; From 733085e38e3a93c06dcce937446962d6d8911e59 Mon Sep 17 00:00:00 2001 From: deflected Date: Sat, 17 Mar 2018 23:54:59 +0200 Subject: [PATCH 103/247] bullet: Write saved _up value for cylinder shapes - Missed in previous commit. Signed-off-by: deflected --- panda/src/bullet/bulletCylinderShape.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/bullet/bulletCylinderShape.cxx b/panda/src/bullet/bulletCylinderShape.cxx index 8f95bc5591..28ca5d65b4 100644 --- a/panda/src/bullet/bulletCylinderShape.cxx +++ b/panda/src/bullet/bulletCylinderShape.cxx @@ -151,7 +151,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { // parameters to serialize: radius, height, up _half_extents.write_datagram(dg); - dg.add_int8((int8_t)_shape->getUpAxis()); + dg.add_int8((int8_t)_up); } /** From 3a88308f4598d32782117f9b0408d6235de67641 Mon Sep 17 00:00:00 2001 From: deflected Date: Sat, 17 Mar 2018 18:32:52 +0200 Subject: [PATCH 104/247] bullet: Cleanup copying of shapes - Fixed copy constructors - Dropped operator= from shapes Signed-off-by: deflected Closes #283 --- panda/src/bullet/bulletBoxShape.cxx | 14 ++----- panda/src/bullet/bulletBoxShape.h | 1 - panda/src/bullet/bulletCapsuleShape.I | 3 +- panda/src/bullet/bulletCapsuleShape.cxx | 42 +++++++++++-------- panda/src/bullet/bulletCapsuleShape.h | 2 +- panda/src/bullet/bulletConeShape.I | 3 +- panda/src/bullet/bulletConeShape.cxx | 39 ++++++++++------- panda/src/bullet/bulletConeShape.h | 2 +- panda/src/bullet/bulletConvexHullShape.cxx | 17 ++++---- panda/src/bullet/bulletConvexHullShape.h | 1 - .../bullet/bulletConvexPointCloudShape.cxx | 15 +++---- .../src/bullet/bulletConvexPointCloudShape.h | 1 - panda/src/bullet/bulletCylinderShape.I | 3 +- panda/src/bullet/bulletCylinderShape.cxx | 41 +++++++++++------- panda/src/bullet/bulletCylinderShape.h | 2 +- panda/src/bullet/bulletHeightfieldShape.cxx | 25 ++++------- panda/src/bullet/bulletHeightfieldShape.h | 1 - panda/src/bullet/bulletMinkowskiSumShape.cxx | 17 +++----- panda/src/bullet/bulletMinkowskiSumShape.h | 1 - panda/src/bullet/bulletPlaneShape.cxx | 14 ++----- panda/src/bullet/bulletPlaneShape.h | 1 - panda/src/bullet/bulletSphereShape.cxx | 13 +----- panda/src/bullet/bulletSphereShape.h | 1 - panda/src/bullet/bulletTriangleMeshShape.cxx | 28 ++++++------- panda/src/bullet/bulletTriangleMeshShape.h | 1 - 25 files changed, 130 insertions(+), 158 deletions(-) diff --git a/panda/src/bullet/bulletBoxShape.cxx b/panda/src/bullet/bulletBoxShape.cxx index 9ae2e16a11..1e18d77899 100644 --- a/panda/src/bullet/bulletBoxShape.cxx +++ b/panda/src/bullet/bulletBoxShape.cxx @@ -35,19 +35,11 @@ BulletBoxShape:: BulletBoxShape(const BulletBoxShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _shape = copy._shape; _half_extents = copy._half_extents; -} + btVector3 btHalfExtents = LVecBase3_to_btVector3(_half_extents); -/** - * - */ -void BulletBoxShape:: -operator = (const BulletBoxShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); - - _shape = copy._shape; - _half_extents = copy._half_extents; + _shape = new btBoxShape(btHalfExtents); + _shape->setUserPointer(this); } /** diff --git a/panda/src/bullet/bulletBoxShape.h b/panda/src/bullet/bulletBoxShape.h index bfb9207e61..5ac117ac76 100644 --- a/panda/src/bullet/bulletBoxShape.h +++ b/panda/src/bullet/bulletBoxShape.h @@ -34,7 +34,6 @@ private: PUBLISHED: explicit BulletBoxShape(const LVecBase3 &halfExtents); BulletBoxShape(const BulletBoxShape ©); - void operator = (const BulletBoxShape ©); INLINE ~BulletBoxShape(); LVecBase3 get_half_extents_without_margin() const; diff --git a/panda/src/bullet/bulletCapsuleShape.I b/panda/src/bullet/bulletCapsuleShape.I index 2491d55d0d..25caf7b9de 100644 --- a/panda/src/bullet/bulletCapsuleShape.I +++ b/panda/src/bullet/bulletCapsuleShape.I @@ -18,7 +18,8 @@ INLINE BulletCapsuleShape:: BulletCapsuleShape() : _shape(nullptr), _radius(0), - _height(0) { + _height(0), + _up(X_up) { } /** diff --git a/panda/src/bullet/bulletCapsuleShape.cxx b/panda/src/bullet/bulletCapsuleShape.cxx index 1c396bbdfb..44fbc3e501 100644 --- a/panda/src/bullet/bulletCapsuleShape.cxx +++ b/panda/src/bullet/bulletCapsuleShape.cxx @@ -21,7 +21,8 @@ TypeHandle BulletCapsuleShape::_type_handle; BulletCapsuleShape:: BulletCapsuleShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) : _radius(radius), - _height(height) { + _height(height), + _up(up) { switch (up) { case X_up: @@ -49,24 +50,29 @@ BulletCapsuleShape:: BulletCapsuleShape(const BulletCapsuleShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _shape = copy._shape; _radius = copy._radius; _height = copy._height; + _up = copy._up; + + switch (_up) { + case X_up: + _shape = new btCapsuleShapeX(_radius, _height); + break; + case Y_up: + _shape = new btCapsuleShape(_radius, _height); + break; + case Z_up: + _shape = new btCapsuleShapeZ(_radius, _height); + break; + default: + bullet_cat.error() << "invalid up-axis:" << _up << endl; + break; + } + + nassertv(_shape); + _shape->setUserPointer(this); } -/** - * - */ -void BulletCapsuleShape:: -operator = (const BulletCapsuleShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); - - _shape = copy._shape; - _radius = copy._radius; - _height = copy._height; -} - - /** * */ @@ -131,9 +137,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { // parameters to serialize: radius, height, up _radius = scan.get_stdfloat(); _height = scan.get_stdfloat(); - int up = (int) scan.get_int8(); + _up = (BulletUpAxis) scan.get_int8(); - switch (up) { + switch (_up) { case X_up: _shape = new btCapsuleShapeX(_radius, _height); break; @@ -144,7 +150,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _shape = new btCapsuleShapeZ(_radius, _height); break; default: - bullet_cat.error() << "invalid up-axis:" << up << endl; + bullet_cat.error() << "invalid up-axis:" << _up << endl; break; } diff --git a/panda/src/bullet/bulletCapsuleShape.h b/panda/src/bullet/bulletCapsuleShape.h index e376674976..9994d9f1dc 100644 --- a/panda/src/bullet/bulletCapsuleShape.h +++ b/panda/src/bullet/bulletCapsuleShape.h @@ -31,7 +31,6 @@ private: PUBLISHED: explicit BulletCapsuleShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up=Z_up); BulletCapsuleShape(const BulletCapsuleShape ©); - void operator = (const BulletCapsuleShape ©); INLINE ~BulletCapsuleShape(); INLINE PN_stdfloat get_radius() const; @@ -50,6 +49,7 @@ private: btCapsuleShape *_shape; PN_stdfloat _radius; PN_stdfloat _height; + BulletUpAxis _up; public: static void register_with_read_factory(); diff --git a/panda/src/bullet/bulletConeShape.I b/panda/src/bullet/bulletConeShape.I index b9c05664b7..debd0900c9 100644 --- a/panda/src/bullet/bulletConeShape.I +++ b/panda/src/bullet/bulletConeShape.I @@ -18,7 +18,8 @@ INLINE BulletConeShape:: BulletConeShape() : _shape(nullptr), _radius(0), - _height(0) { + _height(0), + _up(X_up) { } /** diff --git a/panda/src/bullet/bulletConeShape.cxx b/panda/src/bullet/bulletConeShape.cxx index 30b24a5a18..84c1fc4157 100644 --- a/panda/src/bullet/bulletConeShape.cxx +++ b/panda/src/bullet/bulletConeShape.cxx @@ -21,7 +21,8 @@ TypeHandle BulletConeShape::_type_handle; BulletConeShape:: BulletConeShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) : _radius(radius), - _height(height) { + _height(height), + _up(up) { switch (up) { case X_up: @@ -49,21 +50,27 @@ BulletConeShape:: BulletConeShape(const BulletConeShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _shape = copy._shape; + _up = copy._up; _radius = copy._radius; _height = copy._height; -} -/** - * - */ -void BulletConeShape:: -operator = (const BulletConeShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); + switch (_up) { + case X_up: + _shape = new btConeShapeX((btScalar)_radius, (btScalar)_height); + break; + case Y_up: + _shape = new btConeShape((btScalar)_radius, (btScalar)_height); + break; + case Z_up: + _shape = new btConeShapeZ((btScalar)_radius, (btScalar)_height); + break; + default: + bullet_cat.error() << "invalid up-axis:" << _up << endl; + break; + } - _shape = copy._shape; - _radius = copy._radius; - _height = copy._height; + nassertv(_shape); + _shape->setUserPointer(this); } /** @@ -95,7 +102,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { // parameters to serialize: radius, height, upIndex dg.add_stdfloat(_radius); dg.add_stdfloat(_height); - dg.add_int8((int8_t)_shape->getConeUpIndex()); + dg.add_int8((int8_t)_up); } /** @@ -130,9 +137,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { // parameters to serialize: radius, height, up _radius = scan.get_stdfloat(); _height = scan.get_stdfloat(); + _up = (BulletUpAxis) scan.get_int8(); - int up_index = (int) scan.get_int8(); - switch (up_index) { + switch (_up) { case 0: _shape = new btConeShapeX((btScalar)_radius, (btScalar)_height); break; @@ -143,7 +150,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _shape = new btConeShapeZ((btScalar)_radius, (btScalar)_height); break; default: - bullet_cat.error() << "invalid up-axis:" << up_index << endl; + bullet_cat.error() << "invalid up-axis:" << _up << endl; break; } diff --git a/panda/src/bullet/bulletConeShape.h b/panda/src/bullet/bulletConeShape.h index 4d40c61da9..89d085f834 100644 --- a/panda/src/bullet/bulletConeShape.h +++ b/panda/src/bullet/bulletConeShape.h @@ -31,7 +31,6 @@ private: PUBLISHED: explicit BulletConeShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up=Z_up); BulletConeShape(const BulletConeShape ©); - void operator = (const BulletConeShape ©); INLINE ~BulletConeShape(); INLINE PN_stdfloat get_radius() const; @@ -47,6 +46,7 @@ private: btConeShape *_shape; PN_stdfloat _radius; PN_stdfloat _height; + BulletUpAxis _up; public: static void register_with_read_factory(); diff --git a/panda/src/bullet/bulletConvexHullShape.cxx b/panda/src/bullet/bulletConvexHullShape.cxx index c796072b4a..75a3182a34 100644 --- a/panda/src/bullet/bulletConvexHullShape.cxx +++ b/panda/src/bullet/bulletConvexHullShape.cxx @@ -36,17 +36,13 @@ BulletConvexHullShape:: BulletConvexHullShape(const BulletConvexHullShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _shape = copy._shape; -} + _shape = new btConvexHullShape(NULL, 0); + _shape->setUserPointer(this); -/** - * - */ -void BulletConvexHullShape:: -operator = (const BulletConvexHullShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); + for(int i = 0; i < copy._shape->getNumPoints(); i++) + _shape->addPoint(copy._shape->getUnscaledPoints()[i], false); - _shape = copy._shape; + _shape->recalcLocalAabb(); } /** @@ -117,6 +113,9 @@ add_geom(const Geom *geom, const TransformState *ts) { points.push_back(m.xform_point(reader.get_data3())); } + if (_shape) + delete _shape; + // Create shape _shape = new btConvexHullShape(NULL, 0); _shape->setUserPointer(this); diff --git a/panda/src/bullet/bulletConvexHullShape.h b/panda/src/bullet/bulletConvexHullShape.h index 653c044952..78485ed12c 100644 --- a/panda/src/bullet/bulletConvexHullShape.h +++ b/panda/src/bullet/bulletConvexHullShape.h @@ -30,7 +30,6 @@ class EXPCL_PANDABULLET BulletConvexHullShape : public BulletShape { PUBLISHED: BulletConvexHullShape(); BulletConvexHullShape(const BulletConvexHullShape ©); - void operator = (const BulletConvexHullShape ©); INLINE ~BulletConvexHullShape(); void add_point(const LPoint3 &p); diff --git a/panda/src/bullet/bulletConvexPointCloudShape.cxx b/panda/src/bullet/bulletConvexPointCloudShape.cxx index fb7f62287b..1a4cb6e16c 100644 --- a/panda/src/bullet/bulletConvexPointCloudShape.cxx +++ b/panda/src/bullet/bulletConvexPointCloudShape.cxx @@ -92,18 +92,13 @@ BulletConvexPointCloudShape(const BulletConvexPointCloudShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); _scale = copy._scale; - _shape = copy._shape; -} -/** - * - */ -void BulletConvexPointCloudShape:: -operator = (const BulletConvexPointCloudShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); + btVector3 *btPoints = copy._shape->getUnscaledPoints(); + int numPoints = copy._shape->getNumPoints(); + btVector3 btScale = LVecBase3_to_btVector3(_scale); - _scale = copy._scale; - _shape = copy._shape; + _shape = new btConvexPointCloudShape(btPoints, numPoints, btScale); + _shape->setUserPointer(this); } /** diff --git a/panda/src/bullet/bulletConvexPointCloudShape.h b/panda/src/bullet/bulletConvexPointCloudShape.h index da403d8794..0bf1d7e427 100644 --- a/panda/src/bullet/bulletConvexPointCloudShape.h +++ b/panda/src/bullet/bulletConvexPointCloudShape.h @@ -34,7 +34,6 @@ PUBLISHED: explicit BulletConvexPointCloudShape(const PTA_LVecBase3 &points, LVecBase3 scale=LVecBase3(1.)); explicit BulletConvexPointCloudShape(const Geom *geom, LVecBase3 scale=LVecBase3(1.)); BulletConvexPointCloudShape(const BulletConvexPointCloudShape ©); - void operator = (const BulletConvexPointCloudShape ©); INLINE ~BulletConvexPointCloudShape(); int get_num_points() const; diff --git a/panda/src/bullet/bulletCylinderShape.I b/panda/src/bullet/bulletCylinderShape.I index 54616905f9..bf0ccb40a9 100644 --- a/panda/src/bullet/bulletCylinderShape.I +++ b/panda/src/bullet/bulletCylinderShape.I @@ -17,7 +17,8 @@ INLINE BulletCylinderShape:: BulletCylinderShape() : _half_extents(LVector3::zero()), - _shape(nullptr) { + _shape(nullptr), + _up(X_up) { } /** diff --git a/panda/src/bullet/bulletCylinderShape.cxx b/panda/src/bullet/bulletCylinderShape.cxx index 28ca5d65b4..6d107bff7a 100644 --- a/panda/src/bullet/bulletCylinderShape.cxx +++ b/panda/src/bullet/bulletCylinderShape.cxx @@ -20,7 +20,8 @@ TypeHandle BulletCylinderShape::_type_handle; */ BulletCylinderShape:: BulletCylinderShape(const LVector3 &half_extents, BulletUpAxis up) : - _half_extents(half_extents){ + _half_extents(half_extents), + _up(up) { btVector3 btHalfExtents = LVecBase3_to_btVector3(half_extents); @@ -47,7 +48,8 @@ BulletCylinderShape(const LVector3 &half_extents, BulletUpAxis up) : * */ BulletCylinderShape:: -BulletCylinderShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) { +BulletCylinderShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) : + _up(up) { switch (up) { case X_up: @@ -78,19 +80,28 @@ BulletCylinderShape:: BulletCylinderShape(const BulletCylinderShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _shape = copy._shape; + _up = copy._up; _half_extents = copy._half_extents; -} -/** - * - */ -void BulletCylinderShape:: -operator = (const BulletCylinderShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); + btVector3 btHalfExtents = LVecBase3_to_btVector3(_half_extents); - _shape = copy._shape; - _half_extents = copy._half_extents; + switch (_up) { + case X_up: + _shape = new btCylinderShapeX(btHalfExtents); + break; + case Y_up: + _shape = new btCylinderShape(btHalfExtents); + break; + case Z_up: + _shape = new btCylinderShapeZ(btHalfExtents); + break; + default: + bullet_cat.error() << "invalid up-axis:" << _up << endl; + break; + } + + nassertv(_shape); + _shape->setUserPointer(this); } /** @@ -185,11 +196,11 @@ fillin(DatagramIterator &scan, BamReader *manager) { // parameters to serialize: radius, height, up _half_extents.read_datagram(scan); - int up = (int) scan.get_int8(); + _up = (BulletUpAxis) scan.get_int8(); btVector3 btHalfExtents = LVecBase3_to_btVector3(_half_extents); - switch (up) { + switch (_up) { case X_up: _shape = new btCylinderShapeX(btHalfExtents); break; @@ -200,7 +211,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _shape = new btCylinderShapeZ(btHalfExtents); break; default: - bullet_cat.error() << "invalid up-axis:" << up << endl; + bullet_cat.error() << "invalid up-axis:" << _up << endl; break; } diff --git a/panda/src/bullet/bulletCylinderShape.h b/panda/src/bullet/bulletCylinderShape.h index f53962ec6f..901e48b4ff 100644 --- a/panda/src/bullet/bulletCylinderShape.h +++ b/panda/src/bullet/bulletCylinderShape.h @@ -32,7 +32,6 @@ PUBLISHED: explicit BulletCylinderShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up=Z_up); explicit BulletCylinderShape(const LVector3 &half_extents, BulletUpAxis up=Z_up); BulletCylinderShape(const BulletCylinderShape ©); - void operator = (const BulletCylinderShape ©); INLINE ~BulletCylinderShape(); PN_stdfloat get_radius() const; @@ -49,6 +48,7 @@ public: private: LVector3 _half_extents; btCylinderShape *_shape; + BulletUpAxis _up; public: static void register_with_read_factory(); diff --git a/panda/src/bullet/bulletHeightfieldShape.cxx b/panda/src/bullet/bulletHeightfieldShape.cxx index 1a01876401..6f5f0529e3 100644 --- a/panda/src/bullet/bulletHeightfieldShape.cxx +++ b/panda/src/bullet/bulletHeightfieldShape.cxx @@ -112,7 +112,6 @@ BulletHeightfieldShape:: BulletHeightfieldShape(const BulletHeightfieldShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _shape = copy._shape; _num_rows = copy._num_rows; _num_cols = copy._num_cols; _max_height = copy._max_height; @@ -121,24 +120,14 @@ BulletHeightfieldShape(const BulletHeightfieldShape ©) { size_t size = (size_t)_num_rows * (size_t)_num_cols; _data = new btScalar[size]; memcpy(_data, copy._data, size * sizeof(btScalar)); -} -/** - * - */ -void BulletHeightfieldShape:: -operator = (const BulletHeightfieldShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); - - _shape = copy._shape; - _num_rows = copy._num_rows; - _num_cols = copy._num_cols; - _max_height = copy._max_height; - _up = copy._up; - - size_t size = (size_t)_num_rows * (size_t)_num_cols; - _data = new btScalar[size]; - memcpy(_data, copy._data, size * sizeof(btScalar)); + _shape = new btHeightfieldTerrainShape(_num_rows, + _num_cols, + _data, + _max_height, + _up, + true, false); + _shape->setUserPointer(this); } /** diff --git a/panda/src/bullet/bulletHeightfieldShape.h b/panda/src/bullet/bulletHeightfieldShape.h index 1bfc6c41c3..3631ca1a9d 100644 --- a/panda/src/bullet/bulletHeightfieldShape.h +++ b/panda/src/bullet/bulletHeightfieldShape.h @@ -35,7 +35,6 @@ PUBLISHED: explicit BulletHeightfieldShape(const PNMImage &image, PN_stdfloat max_height, BulletUpAxis up=Z_up); explicit BulletHeightfieldShape(Texture *tex, PN_stdfloat max_height, BulletUpAxis up=Z_up); BulletHeightfieldShape(const BulletHeightfieldShape ©); - void operator = (const BulletHeightfieldShape ©); INLINE ~BulletHeightfieldShape(); void set_use_diamond_subdivision(bool flag=true); diff --git a/panda/src/bullet/bulletMinkowskiSumShape.cxx b/panda/src/bullet/bulletMinkowskiSumShape.cxx index cc56d39884..d750e22244 100644 --- a/panda/src/bullet/bulletMinkowskiSumShape.cxx +++ b/panda/src/bullet/bulletMinkowskiSumShape.cxx @@ -40,21 +40,14 @@ BulletMinkowskiSumShape:: BulletMinkowskiSumShape(const BulletMinkowskiSumShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _shape = copy._shape; _shape_a = copy._shape_a; _shape_b = copy._shape_b; -} + + const btConvexShape *ptr_a = (const btConvexShape *)_shape_a->ptr(); + const btConvexShape *ptr_b = (const btConvexShape *)_shape_b->ptr(); -/** - * - */ -void BulletMinkowskiSumShape:: -operator = (const BulletMinkowskiSumShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); - - _shape = copy._shape; - _shape_a = copy._shape_a; - _shape_b = copy._shape_b; + _shape = new btMinkowskiSumShape(ptr_a, ptr_b); + _shape->setUserPointer(this); } /** diff --git a/panda/src/bullet/bulletMinkowskiSumShape.h b/panda/src/bullet/bulletMinkowskiSumShape.h index c8629f2e33..f8f531ed99 100644 --- a/panda/src/bullet/bulletMinkowskiSumShape.h +++ b/panda/src/bullet/bulletMinkowskiSumShape.h @@ -33,7 +33,6 @@ private: PUBLISHED: explicit BulletMinkowskiSumShape(const BulletShape *shape_a, const BulletShape *shape_b); BulletMinkowskiSumShape(const BulletMinkowskiSumShape ©); - void operator = (const BulletMinkowskiSumShape ©); INLINE ~BulletMinkowskiSumShape(); void set_transform_a(const TransformState *ts); diff --git a/panda/src/bullet/bulletPlaneShape.cxx b/panda/src/bullet/bulletPlaneShape.cxx index a7804290cd..0d1a97fd4e 100644 --- a/panda/src/bullet/bulletPlaneShape.cxx +++ b/panda/src/bullet/bulletPlaneShape.cxx @@ -34,17 +34,11 @@ BulletPlaneShape:: BulletPlaneShape(const BulletPlaneShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _shape = copy._shape; -} + btVector3 btNormal = copy._shape->getPlaneNormal(); + PN_stdfloat constant = (PN_stdfloat)_shape->getPlaneConstant(); -/** - * - */ -void BulletPlaneShape:: -operator = (const BulletPlaneShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); - - _shape = copy._shape; + _shape = new btStaticPlaneShape(btNormal, constant); + _shape->setUserPointer(this); } /** diff --git a/panda/src/bullet/bulletPlaneShape.h b/panda/src/bullet/bulletPlaneShape.h index 610c5d2412..dfee91f12c 100644 --- a/panda/src/bullet/bulletPlaneShape.h +++ b/panda/src/bullet/bulletPlaneShape.h @@ -34,7 +34,6 @@ private: PUBLISHED: explicit BulletPlaneShape(const LVector3 &normal, PN_stdfloat constant); BulletPlaneShape(const BulletPlaneShape ©); - void operator = (const BulletPlaneShape ©); INLINE ~BulletPlaneShape(); LVector3 get_plane_normal() const; diff --git a/panda/src/bullet/bulletSphereShape.cxx b/panda/src/bullet/bulletSphereShape.cxx index 7b3fee62a4..b05e09e418 100644 --- a/panda/src/bullet/bulletSphereShape.cxx +++ b/panda/src/bullet/bulletSphereShape.cxx @@ -32,19 +32,10 @@ BulletSphereShape:: BulletSphereShape(const BulletSphereShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _shape = copy._shape; _radius = copy._radius; -} -/** - * - */ -void BulletSphereShape:: -operator = (const BulletSphereShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); - - _shape = copy._shape; - _radius = copy._radius; + _shape = new btSphereShape(_radius); + _shape->setUserPointer(this); } diff --git a/panda/src/bullet/bulletSphereShape.h b/panda/src/bullet/bulletSphereShape.h index b11d1c4a32..aad49a145c 100644 --- a/panda/src/bullet/bulletSphereShape.h +++ b/panda/src/bullet/bulletSphereShape.h @@ -33,7 +33,6 @@ private: PUBLISHED: explicit BulletSphereShape(PN_stdfloat radius); BulletSphereShape(const BulletSphereShape ©); - void operator = (const BulletSphereShape ©); INLINE ~BulletSphereShape(); INLINE PN_stdfloat get_radius() const; diff --git a/panda/src/bullet/bulletTriangleMeshShape.cxx b/panda/src/bullet/bulletTriangleMeshShape.cxx index 61905a406a..ced374a3fc 100644 --- a/panda/src/bullet/bulletTriangleMeshShape.cxx +++ b/panda/src/bullet/bulletTriangleMeshShape.cxx @@ -86,21 +86,21 @@ BulletTriangleMeshShape:: BulletTriangleMeshShape(const BulletTriangleMeshShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _bvh_shape = copy._bvh_shape; - _gimpact_shape = copy._gimpact_shape; - _mesh = copy._mesh; -} - -/** - * - */ -void BulletTriangleMeshShape:: -operator = (const BulletTriangleMeshShape ©) { - LightMutexHolder holder(BulletWorld::get_global_lock()); - - _bvh_shape = copy._bvh_shape; - _gimpact_shape = copy._gimpact_shape; + _dynamic = copy._dynamic; + _compress = copy._compress; + _bvh = copy._bvh; _mesh = copy._mesh; + + if (_dynamic) { + _gimpact_shape = new btGImpactMeshShape(_mesh->ptr()); + _gimpact_shape->updateBound(); + _gimpact_shape->setUserPointer(this); + _bvh_shape = NULL; + } else { + _bvh_shape = new btBvhTriangleMeshShape(_mesh->ptr(), _compress, _bvh); + _bvh_shape->setUserPointer(this); + _gimpact_shape = NULL; + } } /** diff --git a/panda/src/bullet/bulletTriangleMeshShape.h b/panda/src/bullet/bulletTriangleMeshShape.h index 079fb2aeb1..199efb75d1 100644 --- a/panda/src/bullet/bulletTriangleMeshShape.h +++ b/panda/src/bullet/bulletTriangleMeshShape.h @@ -33,7 +33,6 @@ private: PUBLISHED: explicit BulletTriangleMeshShape(BulletTriangleMesh *mesh, bool dynamic, bool compress=true, bool bvh=true); BulletTriangleMeshShape(const BulletTriangleMeshShape ©); - void operator = (const BulletTriangleMeshShape ©); INLINE ~BulletTriangleMeshShape(); void refit_tree(const LPoint3 &aabb_min, const LPoint3 &aabb_max); From 69d24993b65d8efa914c075828446f0feda3b612 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 22 Mar 2018 15:30:31 +0100 Subject: [PATCH 105/247] bullet: fix compilation error with Bullet 2.81 --- panda/src/bullet/bulletConvexHullShape.cxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/panda/src/bullet/bulletConvexHullShape.cxx b/panda/src/bullet/bulletConvexHullShape.cxx index 75a3182a34..07d559c2fd 100644 --- a/panda/src/bullet/bulletConvexHullShape.cxx +++ b/panda/src/bullet/bulletConvexHullShape.cxx @@ -39,10 +39,16 @@ BulletConvexHullShape(const BulletConvexHullShape ©) { _shape = new btConvexHullShape(NULL, 0); _shape->setUserPointer(this); - for(int i = 0; i < copy._shape->getNumPoints(); i++) - _shape->addPoint(copy._shape->getUnscaledPoints()[i], false); - +#if BT_BULLET_VERSION >= 282 + for (int i = 0; i < copy._shape->getNumPoints(); ++i) { + _shape->addPoint(copy._shape->getUnscaledPoints()[i], false); + } _shape->recalcLocalAabb(); +#else + for (int i = 0; i < copy._shape->getNumPoints(); ++i) { + _shape->addPoint(copy._shape->getUnscaledPoints()[i]); + } +#endif } /** From 29318992d93811637758adefb3e95afdfea8820d Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 15 Mar 2018 22:41:58 -0600 Subject: [PATCH 106/247] metalibs/panda: EXPCL_PANDA -> EXPCL_LIBPANDA --- panda/metalibs/panda/panda.h | 2 +- panda/src/pandabase/pandasymbols.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/panda/metalibs/panda/panda.h b/panda/metalibs/panda/panda.h index 93811cf60b..9d1ef575c8 100644 --- a/panda/metalibs/panda/panda.h +++ b/panda/metalibs/panda/panda.h @@ -9,6 +9,6 @@ #include "pandabase.h" -EXPCL_PANDA void init_libpanda(); +EXPCL_LIBPANDA void init_libpanda(); #endif diff --git a/panda/src/pandabase/pandasymbols.h b/panda/src/pandabase/pandasymbols.h index b1dad6e422..51d9040392 100644 --- a/panda/src/pandabase/pandasymbols.h +++ b/panda/src/pandabase/pandasymbols.h @@ -247,6 +247,9 @@ #endif +#define EXPCL_LIBPANDA EXPCL_PANDA +#define EXPTP_LIBPANDA EXPTP_PANDA + #define EXPCL_PANDA_AUDIO EXPCL_PANDA #define EXPTP_PANDA_AUDIO EXPTP_PANDA From 9852ada792fa4d6d9c7ed0369d502b06c2db8f44 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 25 Feb 2018 18:19:02 -0700 Subject: [PATCH 107/247] dtoolbase: Change export macros to EXP*_DTOOL_DTOOLBASE This is for consistency with `panda`, which follows this format. --- dtool/src/dtoolbase/addHash.h | 2 +- dtool/src/dtoolbase/atomicAdjustDummyImpl.h | 2 +- dtool/src/dtoolbase/atomicAdjustGccImpl.h | 2 +- dtool/src/dtoolbase/atomicAdjustI386Impl.h | 2 +- dtool/src/dtoolbase/atomicAdjustPosixImpl.h | 2 +- dtool/src/dtoolbase/atomicAdjustWin32Impl.h | 2 +- dtool/src/dtoolbase/deletedBufferChain.h | 2 +- dtool/src/dtoolbase/dtoolbase_cc.h | 12 +++---- dtool/src/dtoolbase/dtoolsymbols.h | 5 +++ dtool/src/dtoolbase/indent.h | 2 +- dtool/src/dtoolbase/lookup3.h | 2 +- dtool/src/dtoolbase/memoryBase.h | 2 +- dtool/src/dtoolbase/memoryHook.h | 2 +- dtool/src/dtoolbase/mutexDummyImpl.h | 2 +- dtool/src/dtoolbase/mutexPosixImpl.h | 4 +-- dtool/src/dtoolbase/mutexSpinlockImpl.h | 2 +- dtool/src/dtoolbase/mutexWin32Impl.h | 2 +- dtool/src/dtoolbase/neverFreeMemory.h | 2 +- dtool/src/dtoolbase/pdtoa.h | 2 +- dtool/src/dtoolbase/pstrtod.h | 4 +-- dtool/src/dtoolbase/register_type.h | 38 ++++++++++----------- dtool/src/dtoolbase/typeHandle.h | 4 +-- dtool/src/dtoolbase/typeRegistry.h | 4 +-- dtool/src/dtoolbase/typeRegistryNode.h | 2 +- dtool/src/dtoolbase/typedObject.h | 2 +- 25 files changed, 56 insertions(+), 51 deletions(-) diff --git a/dtool/src/dtoolbase/addHash.h b/dtool/src/dtoolbase/addHash.h index 11fabf77ce..675f9c3f49 100644 --- a/dtool/src/dtoolbase/addHash.h +++ b/dtool/src/dtoolbase/addHash.h @@ -23,7 +23,7 @@ * of static functions, which are used to wrap calls to Bob Jenkins' public- * domain hash generation function (defined in lookup3.c). */ -class EXPCL_DTOOL AddHash { +class EXPCL_DTOOL_DTOOLBASE AddHash { public: INLINE static size_t add_hash(size_t start, const uint32_t *words, size_t num_words); static size_t add_hash(size_t start, const uint8_t *bytes, size_t num_bytes); diff --git a/dtool/src/dtoolbase/atomicAdjustDummyImpl.h b/dtool/src/dtoolbase/atomicAdjustDummyImpl.h index b6e530f395..120fbe195a 100644 --- a/dtool/src/dtoolbase/atomicAdjustDummyImpl.h +++ b/dtool/src/dtoolbase/atomicAdjustDummyImpl.h @@ -24,7 +24,7 @@ * require multiprogramming, and therefore don't require special atomic * operations. */ -class EXPCL_DTOOL AtomicAdjustDummyImpl { +class EXPCL_DTOOL_DTOOLBASE AtomicAdjustDummyImpl { public: typedef long Integer; typedef void *Pointer; diff --git a/dtool/src/dtoolbase/atomicAdjustGccImpl.h b/dtool/src/dtoolbase/atomicAdjustGccImpl.h index 1012a52721..7ae44037ff 100644 --- a/dtool/src/dtoolbase/atomicAdjustGccImpl.h +++ b/dtool/src/dtoolbase/atomicAdjustGccImpl.h @@ -22,7 +22,7 @@ /** * Uses GCC built-ins to implement atomic adjustments. */ -class EXPCL_DTOOL AtomicAdjustGccImpl { +class EXPCL_DTOOL_DTOOLBASE AtomicAdjustGccImpl { public: #if __GCC_ATOMIC_LONG_LOCK_FREE >= __GCC_ATOMIC_INT_LOCK_FREE // If the long can be more lock-free than int, use it instead. diff --git a/dtool/src/dtoolbase/atomicAdjustI386Impl.h b/dtool/src/dtoolbase/atomicAdjustI386Impl.h index 3084a7172b..eac5ce6a97 100644 --- a/dtool/src/dtoolbase/atomicAdjustI386Impl.h +++ b/dtool/src/dtoolbase/atomicAdjustI386Impl.h @@ -26,7 +26,7 @@ * Although this class is named i386, it actually uses instructions that are * specific to 486 and higher. */ -class EXPCL_DTOOL AtomicAdjustI386Impl { +class EXPCL_DTOOL_DTOOLBASE AtomicAdjustI386Impl { public: typedef ALIGN_4BYTE int32_t Integer; typedef void *UnalignedPointer; diff --git a/dtool/src/dtoolbase/atomicAdjustPosixImpl.h b/dtool/src/dtoolbase/atomicAdjustPosixImpl.h index ff5a55fb60..3b98499129 100644 --- a/dtool/src/dtoolbase/atomicAdjustPosixImpl.h +++ b/dtool/src/dtoolbase/atomicAdjustPosixImpl.h @@ -26,7 +26,7 @@ /** * Uses POSIX to implement atomic adjustments. */ -class EXPCL_DTOOL AtomicAdjustPosixImpl { +class EXPCL_DTOOL_DTOOLBASE AtomicAdjustPosixImpl { public: // In Posix, "long" is generally the native word size (32- or 64-bit), which // is what we'd prefer. diff --git a/dtool/src/dtoolbase/atomicAdjustWin32Impl.h b/dtool/src/dtoolbase/atomicAdjustWin32Impl.h index e249ce6448..6f64d2a781 100644 --- a/dtool/src/dtoolbase/atomicAdjustWin32Impl.h +++ b/dtool/src/dtoolbase/atomicAdjustWin32Impl.h @@ -29,7 +29,7 @@ /** * Uses Windows native calls to implement atomic adjustments. */ -class EXPCL_DTOOL AtomicAdjustWin32Impl { +class EXPCL_DTOOL_DTOOLBASE AtomicAdjustWin32Impl { public: #ifdef _WIN64 // For 64-bit builds, we'd prefer to use a 64-bit integer. diff --git a/dtool/src/dtoolbase/deletedBufferChain.h b/dtool/src/dtoolbase/deletedBufferChain.h index 8f82c1abbc..10ac5847fd 100644 --- a/dtool/src/dtoolbase/deletedBufferChain.h +++ b/dtool/src/dtoolbase/deletedBufferChain.h @@ -55,7 +55,7 @@ enum DeletedChainFlag { * * Use MemoryHook to get a new DeletedBufferChain of a particular size. */ -class EXPCL_DTOOL DeletedBufferChain { +class EXPCL_DTOOL_DTOOLBASE DeletedBufferChain { protected: DeletedBufferChain(size_t buffer_size); diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index dee66e04da..6777ce5611 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -282,8 +282,8 @@ class ReferenceCount; // We need a pointer to a global MemoryHook object, to manage all malloc and // free requests from Panda. See the comments in MemoryHook itself. class MemoryHook; -EXPCL_DTOOL extern MemoryHook *memory_hook; -EXPCL_DTOOL void init_memory_hook(); +EXPCL_DTOOL_DTOOLBASE extern MemoryHook *memory_hook; +EXPCL_DTOOL_DTOOLBASE void init_memory_hook(); // Now redefine some handy macros to hook into the above MemoryHook object. #ifndef USE_MEMORY_NOWRAPPERS @@ -303,8 +303,8 @@ EXPCL_DTOOL void init_memory_hook(); #if defined(HAVE_THREADS) && defined(SIMPLE_THREADS) // We need another forward-reference function to allow low-level code to // cooperatively yield the timeslice, in SIMPLE_THREADS mode. -extern EXPCL_DTOOL void (*global_thread_yield)(); -extern EXPCL_DTOOL void (*global_thread_consider_yield)(); +extern EXPCL_DTOOL_DTOOLBASE void (*global_thread_yield)(); +extern EXPCL_DTOOL_DTOOLBASE void (*global_thread_consider_yield)(); INLINE void thread_yield() { (*global_thread_yield)(); @@ -324,8 +324,8 @@ INLINE void thread_consider_yield() { #if defined(USE_TAU) && defined(WIN32) // Hack around tau's lack of DLL export declarations for Profiler class. -extern EXPCL_DTOOL bool __tau_shutdown; -class EXPCL_DTOOL TauProfile { +extern EXPCL_DTOOL_DTOOLBASE bool __tau_shutdown; +class EXPCL_DTOOL_DTOOLBASE TauProfile { public: TauProfile(void *&tautimer, char *name, char *type, int group, char *group_name) { Tau_profile_c_timer(&tautimer, name, type, group, group_name); diff --git a/dtool/src/dtoolbase/dtoolsymbols.h b/dtool/src/dtoolbase/dtoolsymbols.h index 892e1a9fff..61d49463f2 100644 --- a/dtool/src/dtoolbase/dtoolsymbols.h +++ b/dtool/src/dtoolbase/dtoolsymbols.h @@ -99,6 +99,11 @@ #define EXPTP_MISC IMPORT_TEMPL #endif /* BUILDING_MISC */ + +#define EXPCL_DTOOL_DTOOLBASE EXPCL_DTOOL +#define EXPTP_DTOOL_DTOOLBASE EXPTP_DTOOL + + /* These two are always defined empty, because pystub is statically built. But we leave the symbol around in case we change our minds to make pystub once again be a dynamic library. */ diff --git a/dtool/src/dtoolbase/indent.h b/dtool/src/dtoolbase/indent.h index e7b6cf3c48..93badf5e7d 100644 --- a/dtool/src/dtoolbase/indent.h +++ b/dtool/src/dtoolbase/indent.h @@ -22,7 +22,7 @@ * stream itself. Useful for indenting a series of lines of text by a given * amount. */ -EXPCL_DTOOL ostream & +EXPCL_DTOOL_DTOOLBASE ostream & indent(ostream &out, int indent_level); /** diff --git a/dtool/src/dtoolbase/lookup3.h b/dtool/src/dtoolbase/lookup3.h index d33fbe8305..4c59124ac5 100644 --- a/dtool/src/dtoolbase/lookup3.h +++ b/dtool/src/dtoolbase/lookup3.h @@ -21,7 +21,7 @@ extern "C" { #endif -EXPCL_DTOOL uint32_t hashword(const uint32_t *k, /* the key, an array of uint32_t values */ +EXPCL_DTOOL_DTOOLBASE uint32_t hashword(const uint32_t *k, /* the key, an array of uint32_t values */ size_t length, /* the length of the key, in uint32_ts */ uint32_t initval); diff --git a/dtool/src/dtoolbase/memoryBase.h b/dtool/src/dtoolbase/memoryBase.h index 6d755e695b..b6545ff66e 100644 --- a/dtool/src/dtoolbase/memoryBase.h +++ b/dtool/src/dtoolbase/memoryBase.h @@ -66,7 +66,7 @@ * that seems to cause problems when including header files for C++-based * system libraries (such as are found on OSX). */ -class EXPCL_DTOOL MemoryBase { +class EXPCL_DTOOL_DTOOLBASE MemoryBase { public: ALLOC_MEMORY_BASE; }; diff --git a/dtool/src/dtoolbase/memoryHook.h b/dtool/src/dtoolbase/memoryHook.h index 18ce70c0bb..9472983d75 100644 --- a/dtool/src/dtoolbase/memoryHook.h +++ b/dtool/src/dtoolbase/memoryHook.h @@ -34,7 +34,7 @@ class DeletedBufferChain; * employed for classes which inherit from MemoryBase; otherwise, use the * PANDA_MALLOC macros.) */ -class EXPCL_DTOOL MemoryHook { +class EXPCL_DTOOL_DTOOLBASE MemoryHook { public: MemoryHook(); MemoryHook(const MemoryHook ©); diff --git a/dtool/src/dtoolbase/mutexDummyImpl.h b/dtool/src/dtoolbase/mutexDummyImpl.h index d88eaed1aa..772f3f8201 100644 --- a/dtool/src/dtoolbase/mutexDummyImpl.h +++ b/dtool/src/dtoolbase/mutexDummyImpl.h @@ -21,7 +21,7 @@ * A fake mutex implementation for single-threaded applications that don't * need any synchronization control. This does nothing at all. */ -class EXPCL_DTOOL MutexDummyImpl { +class EXPCL_DTOOL_DTOOLBASE MutexDummyImpl { public: CONSTEXPR MutexDummyImpl() DEFAULT_CTOR; diff --git a/dtool/src/dtoolbase/mutexPosixImpl.h b/dtool/src/dtoolbase/mutexPosixImpl.h index 4d4fb3c11b..44b5ab193f 100644 --- a/dtool/src/dtoolbase/mutexPosixImpl.h +++ b/dtool/src/dtoolbase/mutexPosixImpl.h @@ -26,7 +26,7 @@ /** * Uses Posix threads to implement a mutex. */ -class EXPCL_DTOOL MutexPosixImpl { +class EXPCL_DTOOL_DTOOLBASE MutexPosixImpl { public: CONSTEXPR MutexPosixImpl() NOEXCEPT; INLINE ~MutexPosixImpl(); @@ -50,7 +50,7 @@ private: /** * Uses Posix threads to implement a reentrant mutex. */ -class EXPCL_DTOOL ReMutexPosixImpl { +class EXPCL_DTOOL_DTOOLBASE ReMutexPosixImpl { public: #ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP CONSTEXPR ReMutexPosixImpl() NOEXCEPT; diff --git a/dtool/src/dtoolbase/mutexSpinlockImpl.h b/dtool/src/dtoolbase/mutexSpinlockImpl.h index 06853a1af9..33514127f4 100644 --- a/dtool/src/dtoolbase/mutexSpinlockImpl.h +++ b/dtool/src/dtoolbase/mutexSpinlockImpl.h @@ -27,7 +27,7 @@ * specific application on a specific SMP machine, and you are confident that * you have at least as many CPU's as you have threads. */ -class EXPCL_DTOOL MutexSpinlockImpl { +class EXPCL_DTOOL_DTOOLBASE MutexSpinlockImpl { public: CONSTEXPR MutexSpinlockImpl(); diff --git a/dtool/src/dtoolbase/mutexWin32Impl.h b/dtool/src/dtoolbase/mutexWin32Impl.h index 31a4539e01..08fc6eab24 100644 --- a/dtool/src/dtoolbase/mutexWin32Impl.h +++ b/dtool/src/dtoolbase/mutexWin32Impl.h @@ -26,7 +26,7 @@ /** * Uses Windows native calls to implement a mutex. */ -class EXPCL_DTOOL MutexWin32Impl { +class EXPCL_DTOOL_DTOOLBASE MutexWin32Impl { public: MutexWin32Impl(); INLINE ~MutexWin32Impl(); diff --git a/dtool/src/dtoolbase/neverFreeMemory.h b/dtool/src/dtoolbase/neverFreeMemory.h index 49df06a153..d3f0cf51a1 100644 --- a/dtool/src/dtoolbase/neverFreeMemory.h +++ b/dtool/src/dtoolbase/neverFreeMemory.h @@ -29,7 +29,7 @@ * since this will help reduce fragmentation problems in the dynamic heap. * Also, memory allocated from here will exhibit less wasted space. */ -class EXPCL_DTOOL NeverFreeMemory { +class EXPCL_DTOOL_DTOOLBASE NeverFreeMemory { private: NeverFreeMemory(); diff --git a/dtool/src/dtoolbase/pdtoa.h b/dtool/src/dtoolbase/pdtoa.h index a3d3e46147..908ca24deb 100644 --- a/dtool/src/dtoolbase/pdtoa.h +++ b/dtool/src/dtoolbase/pdtoa.h @@ -15,7 +15,7 @@ extern "C" { #endif -EXPCL_DTOOL void pdtoa(double value, char *buffer); +EXPCL_DTOOL_DTOOLBASE void pdtoa(double value, char *buffer); #ifdef __cplusplus }; /* end of extern "C" */ diff --git a/dtool/src/dtoolbase/pstrtod.h b/dtool/src/dtoolbase/pstrtod.h index 7cd78f2f65..2e2d30599c 100644 --- a/dtool/src/dtoolbase/pstrtod.h +++ b/dtool/src/dtoolbase/pstrtod.h @@ -20,10 +20,10 @@ extern "C" { #endif -EXPCL_DTOOL double +EXPCL_DTOOL_DTOOLBASE double pstrtod(const char *nptr, char **endptr); -EXPCL_DTOOL double +EXPCL_DTOOL_DTOOLBASE double patof(const char *str); #ifdef __cplusplus diff --git a/dtool/src/dtoolbase/register_type.h b/dtool/src/dtoolbase/register_type.h index 7ea6031391..c6b27f2a94 100644 --- a/dtool/src/dtoolbase/register_type.h +++ b/dtool/src/dtoolbase/register_type.h @@ -76,18 +76,18 @@ register_dynamic_type(const string &name, // A few system-wide TypeHandles are defined for some basic types. -extern TypeHandle EXPCL_DTOOL long_type_handle; -extern TypeHandle EXPCL_DTOOL int_type_handle; -extern TypeHandle EXPCL_DTOOL uint_type_handle; -extern TypeHandle EXPCL_DTOOL short_type_handle; -extern TypeHandle EXPCL_DTOOL ushort_type_handle; -extern TypeHandle EXPCL_DTOOL char_type_handle; -extern TypeHandle EXPCL_DTOOL uchar_type_handle; -extern TypeHandle EXPCL_DTOOL bool_type_handle; -extern TypeHandle EXPCL_DTOOL double_type_handle; -extern TypeHandle EXPCL_DTOOL float_type_handle; -extern TypeHandle EXPCL_DTOOL string_type_handle; -extern TypeHandle EXPCL_DTOOL wstring_type_handle; +extern TypeHandle EXPCL_DTOOL_DTOOLBASE long_type_handle; +extern TypeHandle EXPCL_DTOOL_DTOOLBASE int_type_handle; +extern TypeHandle EXPCL_DTOOL_DTOOLBASE uint_type_handle; +extern TypeHandle EXPCL_DTOOL_DTOOLBASE short_type_handle; +extern TypeHandle EXPCL_DTOOL_DTOOLBASE ushort_type_handle; +extern TypeHandle EXPCL_DTOOL_DTOOLBASE char_type_handle; +extern TypeHandle EXPCL_DTOOL_DTOOLBASE uchar_type_handle; +extern TypeHandle EXPCL_DTOOL_DTOOLBASE bool_type_handle; +extern TypeHandle EXPCL_DTOOL_DTOOLBASE double_type_handle; +extern TypeHandle EXPCL_DTOOL_DTOOLBASE float_type_handle; +extern TypeHandle EXPCL_DTOOL_DTOOLBASE string_type_handle; +extern TypeHandle EXPCL_DTOOL_DTOOLBASE wstring_type_handle; extern TypeHandle long_p_type_handle; extern TypeHandle int_p_type_handle; @@ -98,14 +98,14 @@ extern TypeHandle double_p_type_handle; extern TypeHandle float_p_type_handle; extern TypeHandle void_p_type_handle; -extern TypeHandle EXPCL_DTOOL pvector_type_handle; -extern TypeHandle EXPCL_DTOOL ov_set_type_handle; -extern TypeHandle EXPCL_DTOOL pdeque_type_handle; -extern TypeHandle EXPCL_DTOOL plist_type_handle; -extern TypeHandle EXPCL_DTOOL pmap_type_handle; -extern TypeHandle EXPCL_DTOOL pset_type_handle; +extern TypeHandle EXPCL_DTOOL_DTOOLBASE pvector_type_handle; +extern TypeHandle EXPCL_DTOOL_DTOOLBASE ov_set_type_handle; +extern TypeHandle EXPCL_DTOOL_DTOOLBASE pdeque_type_handle; +extern TypeHandle EXPCL_DTOOL_DTOOLBASE plist_type_handle; +extern TypeHandle EXPCL_DTOOL_DTOOLBASE pmap_type_handle; +extern TypeHandle EXPCL_DTOOL_DTOOLBASE pset_type_handle; -void EXPCL_DTOOL init_system_type_handles(); +void EXPCL_DTOOL_DTOOLBASE init_system_type_handles(); // The following template function and its specializations will return a // TypeHandle for any type in the world, from a pointer to that type. diff --git a/dtool/src/dtoolbase/typeHandle.h b/dtool/src/dtoolbase/typeHandle.h index 58e69646f4..3138d51e4b 100644 --- a/dtool/src/dtoolbase/typeHandle.h +++ b/dtool/src/dtoolbase/typeHandle.h @@ -78,7 +78,7 @@ class TypedObject; * that ancestry of a particular type may be queried, and the type name may be * retrieved for run-time display. */ -class EXPCL_DTOOL TypeHandle FINAL { +class EXPCL_DTOOL_DTOOLBASE TypeHandle FINAL { PUBLISHED: TypeHandle() NOEXCEPT DEFAULT_CTOR; @@ -162,7 +162,7 @@ INLINE ostream &operator << (ostream &out, TypeHandle type) { return out; } -EXPCL_DTOOL ostream &operator << (ostream &out, TypeHandle::MemoryClass mem_class); +EXPCL_DTOOL_DTOOLBASE ostream &operator << (ostream &out, TypeHandle::MemoryClass mem_class); // We must include typeRegistry at this point so we can call it from our // inline functions. This is a circular include that is strategically placed diff --git a/dtool/src/dtoolbase/typeRegistry.h b/dtool/src/dtoolbase/typeRegistry.h index 651eb1904b..5c5c09ad4c 100644 --- a/dtool/src/dtoolbase/typeRegistry.h +++ b/dtool/src/dtoolbase/typeRegistry.h @@ -33,7 +33,7 @@ class TypedObject; * should be migrated to shared memory as soon as shared memory becomes * available. */ -class EXPCL_DTOOL TypeRegistry : public MemoryBase { +class EXPCL_DTOOL_DTOOLBASE TypeRegistry : public MemoryBase { public: // User code shouldn't generally need to call TypeRegistry::register_type() // or record_derivation() directly; instead, use the register_type @@ -118,7 +118,7 @@ private: }; // Helper function to allow for "C" interaction into the type system -extern "C" EXPCL_DTOOL int get_best_parent_from_Set(int id, const std::set &this_set); +extern "C" EXPCL_DTOOL_DTOOLBASE int get_best_parent_from_Set(int id, const std::set &this_set); #include "typeHandle.h" diff --git a/dtool/src/dtoolbase/typeRegistryNode.h b/dtool/src/dtoolbase/typeRegistryNode.h index 46e4b9f5a1..a8df5c339e 100644 --- a/dtool/src/dtoolbase/typeRegistryNode.h +++ b/dtool/src/dtoolbase/typeRegistryNode.h @@ -27,7 +27,7 @@ * directly access this class; this class is hidden within the TypeRegistry * accessors. */ -class EXPCL_DTOOL TypeRegistryNode { +class EXPCL_DTOOL_DTOOLBASE TypeRegistryNode { public: TypeRegistryNode(TypeHandle handle, const string &name, TypeHandle &ref); diff --git a/dtool/src/dtoolbase/typedObject.h b/dtool/src/dtoolbase/typedObject.h index cc963b0fac..f3d6c193e3 100644 --- a/dtool/src/dtoolbase/typedObject.h +++ b/dtool/src/dtoolbase/typedObject.h @@ -85,7 +85,7 @@ * } * @endcode */ -class EXPCL_DTOOL TypedObject : public MemoryBase { +class EXPCL_DTOOL_DTOOLBASE TypedObject : public MemoryBase { public: INLINE TypedObject() DEFAULT_CTOR; INLINE TypedObject(const TypedObject ©) DEFAULT_CTOR; From ad5b45811da22f4d90e0b232364db8e3b7083c12 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 26 Feb 2018 01:16:06 -0700 Subject: [PATCH 108/247] dtoolutil: Change export macros to EXP*_DTOOL_DTOOLUTIL This is for consistency with `panda`, which follows this format. --- dtool/src/dtoolbase/dtoolsymbols.h | 3 ++ dtool/src/dtoolutil/dSearchPath.h | 4 +-- dtool/src/dtoolutil/executionEnvironment.h | 2 +- dtool/src/dtoolutil/filename.h | 2 +- dtool/src/dtoolutil/globPattern.h | 2 +- dtool/src/dtoolutil/lineStream.h | 2 +- dtool/src/dtoolutil/lineStreamBuf.h | 2 +- dtool/src/dtoolutil/load_dso.h | 8 ++--- dtool/src/dtoolutil/pandaFileStream.h | 6 ++-- dtool/src/dtoolutil/pandaFileStreamBuf.h | 6 ++-- dtool/src/dtoolutil/pandaSystem.h | 2 +- dtool/src/dtoolutil/panda_getopt_impl.h | 10 +++--- dtool/src/dtoolutil/pfstream.h | 4 +-- dtool/src/dtoolutil/pfstreamBuf.h | 2 +- dtool/src/dtoolutil/preprocess_argv.h | 2 +- dtool/src/dtoolutil/stringDecoder.h | 2 +- dtool/src/dtoolutil/string_utils.h | 40 +++++++++++----------- dtool/src/dtoolutil/textEncoder.h | 8 ++--- dtool/src/dtoolutil/unicodeLatinMap.h | 2 +- dtool/src/dtoolutil/vector_double.cxx | 4 +-- dtool/src/dtoolutil/vector_double.h | 4 +-- dtool/src/dtoolutil/vector_float.cxx | 4 +-- dtool/src/dtoolutil/vector_float.h | 4 +-- dtool/src/dtoolutil/vector_int.cxx | 4 +-- dtool/src/dtoolutil/vector_int.h | 4 +-- dtool/src/dtoolutil/vector_string.cxx | 4 +-- dtool/src/dtoolutil/vector_string.h | 4 +-- dtool/src/dtoolutil/vector_uchar.cxx | 4 +-- dtool/src/dtoolutil/vector_uchar.h | 4 +-- dtool/src/dtoolutil/win32ArgParser.h | 2 +- makepanda/makepanda.py | 4 +-- 31 files changed, 79 insertions(+), 76 deletions(-) diff --git a/dtool/src/dtoolbase/dtoolsymbols.h b/dtool/src/dtoolbase/dtoolsymbols.h index 61d49463f2..ff96a4aaf9 100644 --- a/dtool/src/dtoolbase/dtoolsymbols.h +++ b/dtool/src/dtoolbase/dtoolsymbols.h @@ -103,6 +103,9 @@ #define EXPCL_DTOOL_DTOOLBASE EXPCL_DTOOL #define EXPTP_DTOOL_DTOOLBASE EXPTP_DTOOL +#define EXPCL_DTOOL_DTOOLUTIL EXPCL_DTOOL +#define EXPTP_DTOOL_DTOOLUTIL EXPTP_DTOOL + /* These two are always defined empty, because pystub is statically built. But we leave the symbol around in case we change our minds diff --git a/dtool/src/dtoolutil/dSearchPath.h b/dtool/src/dtoolutil/dSearchPath.h index 67cbd61135..85184df77c 100644 --- a/dtool/src/dtoolutil/dSearchPath.h +++ b/dtool/src/dtoolutil/dSearchPath.h @@ -25,9 +25,9 @@ * traditional searchpath-style string, e.g. a list of directory names * delimited by spaces or colons, but it can also be built up explicitly. */ -class EXPCL_DTOOL DSearchPath { +class EXPCL_DTOOL_DTOOLUTIL DSearchPath { PUBLISHED: - class EXPCL_DTOOL Results { + class EXPCL_DTOOL_DTOOLUTIL Results { PUBLISHED: Results(); Results(const Results ©); diff --git a/dtool/src/dtoolutil/executionEnvironment.h b/dtool/src/dtoolutil/executionEnvironment.h index f954a1e44d..7415f19642 100644 --- a/dtool/src/dtoolutil/executionEnvironment.h +++ b/dtool/src/dtoolutil/executionEnvironment.h @@ -26,7 +26,7 @@ * at the time of execution. This is encapsulated to support accessing these * things during static init time, which seems to be risky at best. */ -class EXPCL_DTOOL ExecutionEnvironment { +class EXPCL_DTOOL_DTOOLUTIL ExecutionEnvironment { private: ExecutionEnvironment(); diff --git a/dtool/src/dtoolutil/filename.h b/dtool/src/dtoolutil/filename.h index e0c4b8c414..76ee5e0b39 100644 --- a/dtool/src/dtoolutil/filename.h +++ b/dtool/src/dtoolutil/filename.h @@ -36,7 +36,7 @@ class DSearchPath; * for file existence and searching a searchpath, as well as the best way to * open an fstream for reading or writing. */ -class EXPCL_DTOOL Filename { +class EXPCL_DTOOL_DTOOLUTIL Filename { PUBLISHED: enum Type { // These type values must fit within the bits allocated for F_type, below. diff --git a/dtool/src/dtoolutil/globPattern.h b/dtool/src/dtoolutil/globPattern.h index 379c3e7dfc..015bde38f9 100644 --- a/dtool/src/dtoolutil/globPattern.h +++ b/dtool/src/dtoolutil/globPattern.h @@ -29,7 +29,7 @@ * the pattern or not. It can be used, for example, to scan a directory for * all files matching a particular pattern. */ -class EXPCL_DTOOL GlobPattern { +class EXPCL_DTOOL_DTOOLUTIL GlobPattern { PUBLISHED: INLINE GlobPattern(const string &pattern = string()); INLINE GlobPattern(const GlobPattern ©); diff --git a/dtool/src/dtoolutil/lineStream.h b/dtool/src/dtoolutil/lineStream.h index 43142f81d1..7f9f5eff4a 100644 --- a/dtool/src/dtoolutil/lineStream.h +++ b/dtool/src/dtoolutil/lineStream.h @@ -28,7 +28,7 @@ * otherwise affected when a line of text is extracted. More text can still * be written to it and continuously extracted. */ -class EXPCL_DTOOL LineStream : public ostream { +class EXPCL_DTOOL_DTOOLUTIL LineStream : public ostream { PUBLISHED: INLINE LineStream(); diff --git a/dtool/src/dtoolutil/lineStreamBuf.h b/dtool/src/dtoolutil/lineStreamBuf.h index 5da4325384..7718371a03 100644 --- a/dtool/src/dtoolutil/lineStreamBuf.h +++ b/dtool/src/dtoolutil/lineStreamBuf.h @@ -23,7 +23,7 @@ * whose contents can be continuously extracted as a sequence of lines of * text. */ -class EXPCL_DTOOL LineStreamBuf : public streambuf { +class EXPCL_DTOOL_DTOOLUTIL LineStreamBuf : public streambuf { public: LineStreamBuf(); virtual ~LineStreamBuf(); diff --git a/dtool/src/dtoolutil/load_dso.h b/dtool/src/dtoolutil/load_dso.h index b4232f4ad2..2c0a5d9d24 100644 --- a/dtool/src/dtoolutil/load_dso.h +++ b/dtool/src/dtoolutil/load_dso.h @@ -22,20 +22,20 @@ // otherwise on success. If the filename is not absolute, searches the path. // If the path is empty, searches the dtool directory. -EXPCL_DTOOL void * +EXPCL_DTOOL_DTOOLUTIL void * load_dso(const DSearchPath &path, const Filename &filename); // true indicates success -EXPCL_DTOOL bool +EXPCL_DTOOL_DTOOLUTIL bool unload_dso(void *dso_handle); // Returns the error message from the last failed load_dso() call. -EXPCL_DTOOL string +EXPCL_DTOOL_DTOOLUTIL string load_dso_error(); // Returns a function pointer or other symbol from a loaded library. -EXPCL_DTOOL void * +EXPCL_DTOOL_DTOOLUTIL void * get_dso_symbol(void *handle, const string &name); #endif diff --git a/dtool/src/dtoolutil/pandaFileStream.h b/dtool/src/dtoolutil/pandaFileStream.h index f5c7e6f766..462e3ce160 100644 --- a/dtool/src/dtoolutil/pandaFileStream.h +++ b/dtool/src/dtoolutil/pandaFileStream.h @@ -26,7 +26,7 @@ * simple-threading implementation (using this interface will block only the * current thread, rather than the entire process, on I/O waits). */ -class EXPCL_DTOOL IFileStream : public istream { +class EXPCL_DTOOL_DTOOLUTIL IFileStream : public istream { PUBLISHED: INLINE IFileStream(); INLINE explicit IFileStream(const char *filename, ios::openmode mode = ios::in); @@ -54,7 +54,7 @@ private: * simple-threading implementation (using this interface will block only the * current thread, rather than the entire process, on I/O waits). */ -class EXPCL_DTOOL OFileStream : public ostream { +class EXPCL_DTOOL_DTOOLUTIL OFileStream : public ostream { PUBLISHED: INLINE OFileStream(); INLINE explicit OFileStream(const char *filename, ios::openmode mode = ios::out); @@ -83,7 +83,7 @@ private: * will block only the current thread, rather than the entire process, on I/O * waits). */ -class EXPCL_DTOOL FileStream : public iostream { +class EXPCL_DTOOL_DTOOLUTIL FileStream : public iostream { PUBLISHED: INLINE FileStream(); INLINE explicit FileStream(const char *filename, ios::openmode mode = ios::in); diff --git a/dtool/src/dtoolutil/pandaFileStreamBuf.h b/dtool/src/dtoolutil/pandaFileStreamBuf.h index cab9556919..9ab6f84082 100644 --- a/dtool/src/dtoolutil/pandaFileStreamBuf.h +++ b/dtool/src/dtoolutil/pandaFileStreamBuf.h @@ -28,7 +28,7 @@ /** * The streambuf object that implements pifstream and pofstream. */ -class EXPCL_DTOOL PandaFileStreamBuf : public streambuf { +class EXPCL_DTOOL_DTOOLUTIL PandaFileStreamBuf : public streambuf { public: PandaFileStreamBuf(); virtual ~PandaFileStreamBuf(); @@ -95,10 +95,10 @@ private: streampos _gpos; }; -EXPCL_DTOOL ostream & +EXPCL_DTOOL_DTOOLUTIL ostream & operator << (ostream &out, PandaFileStreamBuf::NewlineMode newline_mode); -EXPCL_DTOOL istream & +EXPCL_DTOOL_DTOOLUTIL istream & operator >> (istream &in, PandaFileStreamBuf::NewlineMode &newline_mode); #endif // USE_PANDAFILESTREAM diff --git a/dtool/src/dtoolutil/pandaSystem.h b/dtool/src/dtoolutil/pandaSystem.h index 85c1a0ea38..c5adae4898 100644 --- a/dtool/src/dtoolutil/pandaSystem.h +++ b/dtool/src/dtoolutil/pandaSystem.h @@ -23,7 +23,7 @@ * Panda. Application developers can use this class to query the runtime * version or capabilities of the current Panda environment. */ -class EXPCL_DTOOL PandaSystem { +class EXPCL_DTOOL_DTOOLUTIL PandaSystem { protected: PandaSystem(); ~PandaSystem(); diff --git a/dtool/src/dtoolutil/panda_getopt_impl.h b/dtool/src/dtoolutil/panda_getopt_impl.h index 9544f68187..c1691ae069 100644 --- a/dtool/src/dtoolutil/panda_getopt_impl.h +++ b/dtool/src/dtoolutil/panda_getopt_impl.h @@ -40,8 +40,8 @@ extern "C" { #endif -extern EXPCL_DTOOL char *optarg; -extern EXPCL_DTOOL int optind, opterr, optopt; +extern EXPCL_DTOOL_DTOOLUTIL char *optarg; +extern EXPCL_DTOOL_DTOOLUTIL int optind, opterr, optopt; struct option { const char *name; @@ -54,12 +54,12 @@ struct option { #define required_argument 1 #define optional_argument 2 -extern EXPCL_DTOOL int +extern EXPCL_DTOOL_DTOOLUTIL int getopt(int argc, char *const argv[], const char *optstring); -extern EXPCL_DTOOL int +extern EXPCL_DTOOL_DTOOLUTIL int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex); -extern EXPCL_DTOOL int +extern EXPCL_DTOOL_DTOOLUTIL int getopt_long_only(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex); diff --git a/dtool/src/dtoolutil/pfstream.h b/dtool/src/dtoolutil/pfstream.h index c26456bbe6..6beccc16ca 100644 --- a/dtool/src/dtoolutil/pfstream.h +++ b/dtool/src/dtoolutil/pfstream.h @@ -16,7 +16,7 @@ #include "pfstreamBuf.h" -class EXPCL_DTOOL IPipeStream : public istream { +class EXPCL_DTOOL_DTOOLUTIL IPipeStream : public istream { public: INLINE IPipeStream(const std::string); @@ -32,7 +32,7 @@ private: INLINE IPipeStream(); }; -class EXPCL_DTOOL OPipeStream : public ostream { +class EXPCL_DTOOL_DTOOLUTIL OPipeStream : public ostream { public: INLINE OPipeStream(const std::string); diff --git a/dtool/src/dtoolutil/pfstreamBuf.h b/dtool/src/dtoolutil/pfstreamBuf.h index 3fbf055eae..ad0c132f0f 100644 --- a/dtool/src/dtoolutil/pfstreamBuf.h +++ b/dtool/src/dtoolutil/pfstreamBuf.h @@ -41,7 +41,7 @@ #endif // WIN_PIPE_CALLS -class EXPCL_DTOOL PipeStreamBuf : public streambuf { +class EXPCL_DTOOL_DTOOLUTIL PipeStreamBuf : public streambuf { public: enum Direction { Input, Output }; diff --git a/dtool/src/dtoolutil/preprocess_argv.h b/dtool/src/dtoolutil/preprocess_argv.h index 6323c50c05..1c11a2c25f 100644 --- a/dtool/src/dtoolutil/preprocess_argv.h +++ b/dtool/src/dtoolutil/preprocess_argv.h @@ -16,7 +16,7 @@ #include "dtoolbase.h" -extern EXPCL_DTOOL void +extern EXPCL_DTOOL_DTOOLUTIL void preprocess_argv(int &argc, char **&argv); #endif diff --git a/dtool/src/dtoolutil/stringDecoder.h b/dtool/src/dtoolutil/stringDecoder.h index d611ed1751..62c97cbe9e 100644 --- a/dtool/src/dtoolutil/stringDecoder.h +++ b/dtool/src/dtoolutil/stringDecoder.h @@ -21,7 +21,7 @@ * byte streams. Give it a string, then ask it to pull the characters out one * at a time. This also serves as the plain old byte-at-a-time decoder. */ -class EXPCL_DTOOL StringDecoder { +class EXPCL_DTOOL_DTOOLUTIL StringDecoder { public: INLINE StringDecoder(const string &input); virtual ~StringDecoder(); diff --git a/dtool/src/dtoolutil/string_utils.h b/dtool/src/dtoolutil/string_utils.h index a3d931af6e..37f7679efe 100644 --- a/dtool/src/dtoolutil/string_utils.h +++ b/dtool/src/dtoolutil/string_utils.h @@ -22,44 +22,44 @@ // Case-insensitive string comparison, from Stroustrup's C++ third edition. // Works like strcmp(). -EXPCL_DTOOL int cmp_nocase(const string &s, const string &s2); +EXPCL_DTOOL_DTOOLUTIL int cmp_nocase(const string &s, const string &s2); // Similar, except it also accepts hyphen and underscore as equivalent. -EXPCL_DTOOL int cmp_nocase_uh(const string &s, const string &s2); +EXPCL_DTOOL_DTOOLUTIL int cmp_nocase_uh(const string &s, const string &s2); // Returns the string converted to lowercase. -EXPCL_DTOOL string downcase(const string &s); +EXPCL_DTOOL_DTOOLUTIL string downcase(const string &s); // Returns the string converted to uppercase. -EXPCL_DTOOL string upcase(const string &s); +EXPCL_DTOOL_DTOOLUTIL string upcase(const string &s); // Separates the string into words according to whitespace. -EXPCL_DTOOL int extract_words(const string &str, vector_string &words); -EXPCL_DTOOL int extract_words(const wstring &str, pvector &words); +EXPCL_DTOOL_DTOOLUTIL int extract_words(const string &str, vector_string &words); +EXPCL_DTOOL_DTOOLUTIL int extract_words(const wstring &str, pvector &words); // Separates the string into words according to the indicated delimiters. -EXPCL_DTOOL void tokenize(const string &str, vector_string &words, +EXPCL_DTOOL_DTOOLUTIL void tokenize(const string &str, vector_string &words, const string &delimiters, bool discard_repeated_delimiters = false); -EXPCL_DTOOL void tokenize(const wstring &str, pvector &words, +EXPCL_DTOOL_DTOOLUTIL void tokenize(const wstring &str, pvector &words, const wstring &delimiters, bool discard_repeated_delimiters = false); // Trims leading andor trailing whitespace from the string. -EXPCL_DTOOL string trim_left(const string &str); -EXPCL_DTOOL wstring trim_left(const wstring &str); -EXPCL_DTOOL string trim_right(const string &str); -EXPCL_DTOOL wstring trim_right(const wstring &str); -EXPCL_DTOOL string trim(const string &str); -EXPCL_DTOOL wstring trim(const wstring &str); +EXPCL_DTOOL_DTOOLUTIL string trim_left(const string &str); +EXPCL_DTOOL_DTOOLUTIL wstring trim_left(const wstring &str); +EXPCL_DTOOL_DTOOLUTIL string trim_right(const string &str); +EXPCL_DTOOL_DTOOLUTIL wstring trim_right(const wstring &str); +EXPCL_DTOOL_DTOOLUTIL string trim(const string &str); +EXPCL_DTOOL_DTOOLUTIL wstring trim(const wstring &str); // Functions to parse numeric values out of a string. -EXPCL_DTOOL int string_to_int(const string &str, string &tail); -EXPCL_DTOOL bool string_to_int(const string &str, int &result); -EXPCL_DTOOL double string_to_double(const string &str, string &tail); -EXPCL_DTOOL bool string_to_double(const string &str, double &result); -EXPCL_DTOOL bool string_to_float(const string &str, float &result); -EXPCL_DTOOL bool string_to_stdfloat(const string &str, PN_stdfloat &result); +EXPCL_DTOOL_DTOOLUTIL int string_to_int(const string &str, string &tail); +EXPCL_DTOOL_DTOOLUTIL bool string_to_int(const string &str, int &result); +EXPCL_DTOOL_DTOOLUTIL double string_to_double(const string &str, string &tail); +EXPCL_DTOOL_DTOOLUTIL bool string_to_double(const string &str, double &result); +EXPCL_DTOOL_DTOOLUTIL bool string_to_float(const string &str, float &result); +EXPCL_DTOOL_DTOOLUTIL bool string_to_stdfloat(const string &str, PN_stdfloat &result); // Convenience function to make a string from anything that has an ostream // operator. diff --git a/dtool/src/dtoolutil/textEncoder.h b/dtool/src/dtoolutil/textEncoder.h index ca885b15c3..3f57ed4c7f 100644 --- a/dtool/src/dtoolutil/textEncoder.h +++ b/dtool/src/dtoolutil/textEncoder.h @@ -30,7 +30,7 @@ class StringDecoder; * This class is also a base class of TextNode, which inherits this * functionality. */ -class EXPCL_DTOOL TextEncoder { +class EXPCL_DTOOL_DTOOLUTIL TextEncoder { PUBLISHED: enum Encoding { E_iso8859, @@ -112,9 +112,9 @@ private: static Encoding _default_encoding; }; -EXPCL_DTOOL ostream & +EXPCL_DTOOL_DTOOLUTIL ostream & operator << (ostream &out, TextEncoder::Encoding encoding); -EXPCL_DTOOL istream & +EXPCL_DTOOL_DTOOLUTIL istream & operator >> (istream &in, TextEncoder::Encoding &encoding); // We'll define the output operator for wstring here, too. Presumably this @@ -122,7 +122,7 @@ operator >> (istream &in, TextEncoder::Encoding &encoding); // This function is declared inline to minimize the risk of link conflicts // should another third-party module also define the same output operator. -INLINE EXPCL_DTOOL ostream & +INLINE EXPCL_DTOOL_DTOOLUTIL ostream & operator << (ostream &out, const wstring &str); #include "textEncoder.I" diff --git a/dtool/src/dtoolutil/unicodeLatinMap.h b/dtool/src/dtoolutil/unicodeLatinMap.h index dc74fcf8d9..fb94154f7f 100644 --- a/dtool/src/dtoolutil/unicodeLatinMap.h +++ b/dtool/src/dtoolutil/unicodeLatinMap.h @@ -25,7 +25,7 @@ * equivalent without the accent mark; as well as how to switch case from * upper to lower while retaining the Unicode accent marks. */ -class EXPCL_DTOOL UnicodeLatinMap { +class EXPCL_DTOOL_DTOOLUTIL UnicodeLatinMap { public: enum AccentType { AT_none, diff --git a/dtool/src/dtoolutil/vector_double.cxx b/dtool/src/dtoolutil/vector_double.cxx index e275c5ac8c..912de65cd0 100644 --- a/dtool/src/dtoolutil/vector_double.cxx +++ b/dtool/src/dtoolutil/vector_double.cxx @@ -13,8 +13,8 @@ #include "vector_double.h" -#define EXPCL EXPCL_DTOOL -#define EXPTP EXPTP_DTOOL +#define EXPCL EXPCL_DTOOL_DTOOLUTIL +#define EXPTP EXPTP_DTOOL_DTOOLUTIL #define TYPE double #define NAME vector_double diff --git a/dtool/src/dtoolutil/vector_double.h b/dtool/src/dtoolutil/vector_double.h index 5e00afd598..bf06156557 100644 --- a/dtool/src/dtoolutil/vector_double.h +++ b/dtool/src/dtoolutil/vector_double.h @@ -23,8 +23,8 @@ * defining the vector again. */ -#define EXPCL EXPCL_DTOOL -#define EXPTP EXPTP_DTOOL +#define EXPCL EXPCL_DTOOL_DTOOLUTIL +#define EXPTP EXPTP_DTOOL_DTOOLUTIL #define TYPE double #define NAME vector_double diff --git a/dtool/src/dtoolutil/vector_float.cxx b/dtool/src/dtoolutil/vector_float.cxx index 3d2d1233c5..7937306ae8 100644 --- a/dtool/src/dtoolutil/vector_float.cxx +++ b/dtool/src/dtoolutil/vector_float.cxx @@ -13,8 +13,8 @@ #include "vector_float.h" -#define EXPCL EXPCL_DTOOL -#define EXPTP EXPTP_DTOOL +#define EXPCL EXPCL_DTOOL_DTOOLUTIL +#define EXPTP EXPTP_DTOOL_DTOOLUTIL #define TYPE float #define NAME vector_float diff --git a/dtool/src/dtoolutil/vector_float.h b/dtool/src/dtoolutil/vector_float.h index b9033a5ce7..afe596f9a9 100644 --- a/dtool/src/dtoolutil/vector_float.h +++ b/dtool/src/dtoolutil/vector_float.h @@ -23,8 +23,8 @@ * defining the vector again. */ -#define EXPCL EXPCL_DTOOL -#define EXPTP EXPTP_DTOOL +#define EXPCL EXPCL_DTOOL_DTOOLUTIL +#define EXPTP EXPTP_DTOOL_DTOOLUTIL #define TYPE float #define NAME vector_float diff --git a/dtool/src/dtoolutil/vector_int.cxx b/dtool/src/dtoolutil/vector_int.cxx index 3032da29f4..44262c708c 100644 --- a/dtool/src/dtoolutil/vector_int.cxx +++ b/dtool/src/dtoolutil/vector_int.cxx @@ -13,8 +13,8 @@ #include "vector_int.h" -#define EXPCL EXPCL_DTOOL -#define EXPTP EXPTP_DTOOL +#define EXPCL EXPCL_DTOOL_DTOOLUTIL +#define EXPTP EXPTP_DTOOL_DTOOLUTIL #define TYPE int #define NAME vector_int diff --git a/dtool/src/dtoolutil/vector_int.h b/dtool/src/dtoolutil/vector_int.h index b149c3ddd3..c2a899a079 100644 --- a/dtool/src/dtoolutil/vector_int.h +++ b/dtool/src/dtoolutil/vector_int.h @@ -23,8 +23,8 @@ * rather than defining the vector again. */ -#define EXPCL EXPCL_DTOOL -#define EXPTP EXPTP_DTOOL +#define EXPCL EXPCL_DTOOL_DTOOLUTIL +#define EXPTP EXPTP_DTOOL_DTOOLUTIL #define TYPE int #define NAME vector_int diff --git a/dtool/src/dtoolutil/vector_string.cxx b/dtool/src/dtoolutil/vector_string.cxx index 72239b28ac..1dd5b82397 100644 --- a/dtool/src/dtoolutil/vector_string.cxx +++ b/dtool/src/dtoolutil/vector_string.cxx @@ -13,8 +13,8 @@ #include "vector_string.h" -#define EXPCL EXPCL_DTOOL -#define EXPTP EXPTP_DTOOL +#define EXPCL EXPCL_DTOOL_DTOOLUTIL +#define EXPTP EXPTP_DTOOL_DTOOLUTIL #define TYPE std::string #define NAME vector_string diff --git a/dtool/src/dtoolutil/vector_string.h b/dtool/src/dtoolutil/vector_string.h index 117baf8543..8707b20890 100644 --- a/dtool/src/dtoolutil/vector_string.h +++ b/dtool/src/dtoolutil/vector_string.h @@ -23,8 +23,8 @@ * defining the vector again. */ -#define EXPCL EXPCL_DTOOL -#define EXPTP EXPTP_DTOOL +#define EXPCL EXPCL_DTOOL_DTOOLUTIL +#define EXPTP EXPTP_DTOOL_DTOOLUTIL #define TYPE std::string #define NAME vector_string diff --git a/dtool/src/dtoolutil/vector_uchar.cxx b/dtool/src/dtoolutil/vector_uchar.cxx index e3473584d4..78750619bf 100644 --- a/dtool/src/dtoolutil/vector_uchar.cxx +++ b/dtool/src/dtoolutil/vector_uchar.cxx @@ -13,8 +13,8 @@ #include "vector_uchar.h" -#define EXPCL EXPCL_DTOOL -#define EXPTP EXPTP_DTOOL +#define EXPCL EXPCL_DTOOL_DTOOLUTIL +#define EXPTP EXPTP_DTOOL_DTOOLUTIL #define TYPE unsigned char #define NAME vector_uchar diff --git a/dtool/src/dtoolutil/vector_uchar.h b/dtool/src/dtoolutil/vector_uchar.h index bf8d989990..3700b4ba8d 100644 --- a/dtool/src/dtoolutil/vector_uchar.h +++ b/dtool/src/dtoolutil/vector_uchar.h @@ -23,8 +23,8 @@ * rather than defining the vector again. */ -#define EXPCL EXPCL_DTOOL -#define EXPTP EXPTP_DTOOL +#define EXPCL EXPCL_DTOOL_DTOOLUTIL +#define EXPTP EXPTP_DTOOL_DTOOLUTIL #define TYPE unsigned char #define NAME vector_uchar diff --git a/dtool/src/dtoolutil/win32ArgParser.h b/dtool/src/dtoolutil/win32ArgParser.h index 505c6934cb..b7d427a81f 100644 --- a/dtool/src/dtoolutil/win32ArgParser.h +++ b/dtool/src/dtoolutil/win32ArgParser.h @@ -30,7 +30,7 @@ * but it is also supports automatic expansion of glob filenames, e.g. *.egg * is turned into an explicit list of egg files in the directory. */ -class EXPCL_DTOOL Win32ArgParser { +class EXPCL_DTOOL_DTOOLUTIL Win32ArgParser { public: Win32ArgParser(); ~Win32ArgParser(); diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 59633ea892..e7565907b2 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2596,12 +2596,12 @@ PANDAVERSION_H_RUNTIME=""" CHECKPANDAVERSION_CXX=""" # include "dtoolbase.h" -EXPCL_DTOOL int panda_version_$VERSION1_$VERSION2 = 0; +EXPCL_DTOOL_DTOOLUTIL int panda_version_$VERSION1_$VERSION2 = 0; """ CHECKPANDAVERSION_H=""" # include "dtoolbase.h" -extern EXPCL_DTOOL int panda_version_$VERSION1_$VERSION2; +extern EXPCL_DTOOL_DTOOLUTIL int panda_version_$VERSION1_$VERSION2; # ifndef WIN32 /* For Windows, exporting the symbol from the DLL is sufficient; the DLL will not load unless all expected public symbols are defined. From 775fcb5b0b55f0286eb2d8fe38a8a9de15698eea Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 4 Mar 2018 19:52:07 -0700 Subject: [PATCH 109/247] prc: Change export macros to EXP*_DTOOL_PRC This is for consistency with `panda`, which follows this format. --- dtool/src/dtoolbase/dtoolsymbols.h | 3 +++ dtool/src/prc/configDeclaration.h | 2 +- dtool/src/prc/configFlags.h | 2 +- dtool/src/prc/configPage.h | 2 +- dtool/src/prc/configPageManager.h | 2 +- dtool/src/prc/configVariable.h | 2 +- dtool/src/prc/configVariableBase.h | 2 +- dtool/src/prc/configVariableBool.h | 2 +- dtool/src/prc/configVariableCore.h | 2 +- dtool/src/prc/configVariableDouble.h | 2 +- dtool/src/prc/configVariableFilename.h | 2 +- dtool/src/prc/configVariableInt.h | 2 +- dtool/src/prc/configVariableInt64.h | 2 +- dtool/src/prc/configVariableList.h | 2 +- dtool/src/prc/configVariableManager.h | 2 +- dtool/src/prc/configVariableSearchPath.h | 2 +- dtool/src/prc/configVariableString.h | 2 +- dtool/src/prc/config_prc.h | 2 +- dtool/src/prc/encryptStream.h | 4 ++-- dtool/src/prc/encryptStreamBuf.h | 2 +- dtool/src/prc/nativeNumericData.h | 2 +- dtool/src/prc/notifyCategory.h | 2 +- dtool/src/prc/notifySeverity.h | 4 ++-- dtool/src/prc/pnotify.h | 2 +- dtool/src/prc/prcKeyRegistry.h | 2 +- dtool/src/prc/reversedNumericData.h | 2 +- dtool/src/prc/streamReader.h | 2 +- dtool/src/prc/streamWrapper.h | 8 ++++---- dtool/src/prc/streamWriter.h | 2 +- 29 files changed, 36 insertions(+), 33 deletions(-) diff --git a/dtool/src/dtoolbase/dtoolsymbols.h b/dtool/src/dtoolbase/dtoolsymbols.h index ff96a4aaf9..98aab5a489 100644 --- a/dtool/src/dtoolbase/dtoolsymbols.h +++ b/dtool/src/dtoolbase/dtoolsymbols.h @@ -106,6 +106,9 @@ #define EXPCL_DTOOL_DTOOLUTIL EXPCL_DTOOL #define EXPTP_DTOOL_DTOOLUTIL EXPTP_DTOOL +#define EXPCL_DTOOL_PRC EXPCL_DTOOLCONFIG +#define EXPTP_DTOOL_PRC EXPTP_DTOOLCONFIG + /* These two are always defined empty, because pystub is statically built. But we leave the symbol around in case we change our minds diff --git a/dtool/src/prc/configDeclaration.h b/dtool/src/prc/configDeclaration.h index 696f4771d4..9a74acd8d2 100644 --- a/dtool/src/prc/configDeclaration.h +++ b/dtool/src/prc/configDeclaration.h @@ -30,7 +30,7 @@ class ConfigVariableCore; * pairing of a string name (actually, a ConfigVariableCore pointer) to a * string value. */ -class EXPCL_DTOOLCONFIG ConfigDeclaration : public ConfigFlags { +class EXPCL_DTOOL_PRC ConfigDeclaration : public ConfigFlags { private: ConfigDeclaration(ConfigPage *page, ConfigVariableCore *variable, const string &string_value, int decl_seq); diff --git a/dtool/src/prc/configFlags.h b/dtool/src/prc/configFlags.h index 7333c80393..23dfd3fb30 100644 --- a/dtool/src/prc/configFlags.h +++ b/dtool/src/prc/configFlags.h @@ -23,7 +23,7 @@ * It exists only to provide a convenient name scoping for some enumerated * values common to both classes. */ -class EXPCL_DTOOLCONFIG ConfigFlags { +class EXPCL_DTOOL_PRC ConfigFlags { PUBLISHED: enum ValueType { VT_undefined, diff --git a/dtool/src/prc/configPage.h b/dtool/src/prc/configPage.h index 8c143de836..72659fe096 100644 --- a/dtool/src/prc/configPage.h +++ b/dtool/src/prc/configPage.h @@ -27,7 +27,7 @@ class ConfigVariableCore; * it may also represent a list of declarations built up by application code * and explicitly loaded. */ -class EXPCL_DTOOLCONFIG ConfigPage { +class EXPCL_DTOOL_PRC ConfigPage { private: ConfigPage(const string &name, bool implicit_load, int page_seq); ~ConfigPage(); diff --git a/dtool/src/prc/configPageManager.h b/dtool/src/prc/configPageManager.h index ff81b3dc57..1ad8f6c3bd 100644 --- a/dtool/src/prc/configPageManager.h +++ b/dtool/src/prc/configPageManager.h @@ -28,7 +28,7 @@ class ConfigPage; * A global object that maintains the set of ConfigPages everywhere in the * world, and keeps them in sorted order. */ -class EXPCL_DTOOLCONFIG ConfigPageManager : public ConfigFlags { +class EXPCL_DTOOL_PRC ConfigPageManager : public ConfigFlags { protected: ConfigPageManager(); ~ConfigPageManager(); diff --git a/dtool/src/prc/configVariable.h b/dtool/src/prc/configVariable.h index 3e42efe4d0..c4f6d20527 100644 --- a/dtool/src/prc/configVariable.h +++ b/dtool/src/prc/configVariable.h @@ -28,7 +28,7 @@ * and/or ConfigDeclaration, more or less duplicating the interface presented * there. */ -class EXPCL_DTOOLCONFIG ConfigVariable : public ConfigVariableBase { +class EXPCL_DTOOL_PRC ConfigVariable : public ConfigVariableBase { protected: INLINE ConfigVariable(const string &name, ValueType type); INLINE ConfigVariable(const string &name, ValueType type, diff --git a/dtool/src/prc/configVariableBase.h b/dtool/src/prc/configVariableBase.h index cbb7aab183..8bc51a7431 100644 --- a/dtool/src/prc/configVariableBase.h +++ b/dtool/src/prc/configVariableBase.h @@ -42,7 +42,7 @@ * and/or ConfigDeclaration, more or less duplicating the interface presented * there. */ -class EXPCL_DTOOLCONFIG ConfigVariableBase : public ConfigFlags { +class EXPCL_DTOOL_PRC ConfigVariableBase : public ConfigFlags { protected: INLINE ConfigVariableBase(const string &name, ValueType type); ConfigVariableBase(const string &name, ValueType type, diff --git a/dtool/src/prc/configVariableBool.h b/dtool/src/prc/configVariableBool.h index 9f486c4266..c955b6b16f 100644 --- a/dtool/src/prc/configVariableBool.h +++ b/dtool/src/prc/configVariableBool.h @@ -20,7 +20,7 @@ /** * This is a convenience class to specialize ConfigVariable as a boolean type. */ -class EXPCL_DTOOLCONFIG ConfigVariableBool : public ConfigVariable { +class EXPCL_DTOOL_PRC ConfigVariableBool : public ConfigVariable { PUBLISHED: INLINE ConfigVariableBool(const string &name); INLINE ConfigVariableBool(const string &name, bool default_value, diff --git a/dtool/src/prc/configVariableCore.h b/dtool/src/prc/configVariableCore.h index e857dd3cc2..19e03436d2 100644 --- a/dtool/src/prc/configVariableCore.h +++ b/dtool/src/prc/configVariableCore.h @@ -31,7 +31,7 @@ class ConfigDeclaration; * make() method, which may return a shared instance. Once created, these * objects are never destructed. */ -class EXPCL_DTOOLCONFIG ConfigVariableCore : public ConfigFlags { +class EXPCL_DTOOL_PRC ConfigVariableCore : public ConfigFlags { private: ConfigVariableCore(const string &name); ConfigVariableCore(const ConfigVariableCore &templ, const string &name); diff --git a/dtool/src/prc/configVariableDouble.h b/dtool/src/prc/configVariableDouble.h index 817449ae2f..49e9585475 100644 --- a/dtool/src/prc/configVariableDouble.h +++ b/dtool/src/prc/configVariableDouble.h @@ -21,7 +21,7 @@ * This is a convenience class to specialize ConfigVariable as a floating- * point type. */ -class EXPCL_DTOOLCONFIG ConfigVariableDouble : public ConfigVariable { +class EXPCL_DTOOL_PRC ConfigVariableDouble : public ConfigVariable { PUBLISHED: INLINE ConfigVariableDouble(const string &name); INLINE ConfigVariableDouble(const string &name, double default_value, diff --git a/dtool/src/prc/configVariableFilename.h b/dtool/src/prc/configVariableFilename.h index e68c730128..6feb82a24a 100644 --- a/dtool/src/prc/configVariableFilename.h +++ b/dtool/src/prc/configVariableFilename.h @@ -24,7 +24,7 @@ * put OS-specific filenames, or filenames based on environment variables, in * the prc file. */ -class EXPCL_DTOOLCONFIG ConfigVariableFilename : public ConfigVariable { +class EXPCL_DTOOL_PRC ConfigVariableFilename : public ConfigVariable { PUBLISHED: INLINE ConfigVariableFilename(const string &name); INLINE ConfigVariableFilename(const string &name, const Filename &default_value, diff --git a/dtool/src/prc/configVariableInt.h b/dtool/src/prc/configVariableInt.h index 7605b27480..0156bed21a 100644 --- a/dtool/src/prc/configVariableInt.h +++ b/dtool/src/prc/configVariableInt.h @@ -21,7 +21,7 @@ * This is a convenience class to specialize ConfigVariable as an integer * type. */ -class EXPCL_DTOOLCONFIG ConfigVariableInt : public ConfigVariable { +class EXPCL_DTOOL_PRC ConfigVariableInt : public ConfigVariable { PUBLISHED: INLINE ConfigVariableInt(const string &name); INLINE ConfigVariableInt(const string &name, int default_value, diff --git a/dtool/src/prc/configVariableInt64.h b/dtool/src/prc/configVariableInt64.h index 40477f87cc..14d02e2ee9 100644 --- a/dtool/src/prc/configVariableInt64.h +++ b/dtool/src/prc/configVariableInt64.h @@ -22,7 +22,7 @@ * This is a convenience class to specialize ConfigVariable as a 64-bit * integer type. */ -class EXPCL_DTOOLCONFIG ConfigVariableInt64 : public ConfigVariable { +class EXPCL_DTOOL_PRC ConfigVariableInt64 : public ConfigVariable { PUBLISHED: INLINE ConfigVariableInt64(const string &name); INLINE ConfigVariableInt64(const string &name, int64_t default_value, diff --git a/dtool/src/prc/configVariableList.h b/dtool/src/prc/configVariableList.h index 448f8b5886..ca639a94ae 100644 --- a/dtool/src/prc/configVariableList.h +++ b/dtool/src/prc/configVariableList.h @@ -28,7 +28,7 @@ * * A ConfigVariableList cannot be modified locally. */ -class EXPCL_DTOOLCONFIG ConfigVariableList : public ConfigVariableBase { +class EXPCL_DTOOL_PRC ConfigVariableList : public ConfigVariableBase { PUBLISHED: INLINE ConfigVariableList(const string &name, const string &description = string(), diff --git a/dtool/src/prc/configVariableManager.h b/dtool/src/prc/configVariableManager.h index 78b943fef7..713e1bc5d2 100644 --- a/dtool/src/prc/configVariableManager.h +++ b/dtool/src/prc/configVariableManager.h @@ -28,7 +28,7 @@ class ConfigVariableCore; * ConfigVariableCores) everywhere in the world, and keeps them in sorted * order. */ -class EXPCL_DTOOLCONFIG ConfigVariableManager { +class EXPCL_DTOOL_PRC ConfigVariableManager { protected: ConfigVariableManager(); ~ConfigVariableManager(); diff --git a/dtool/src/prc/configVariableSearchPath.h b/dtool/src/prc/configVariableSearchPath.h index 6a6cfeb0ab..4dfe1b0fcf 100644 --- a/dtool/src/prc/configVariableSearchPath.h +++ b/dtool/src/prc/configVariableSearchPath.h @@ -33,7 +33,7 @@ * variable, created by using the same name to the constructor, will not * reflect the local changes. */ -class EXPCL_DTOOLCONFIG ConfigVariableSearchPath : public ConfigVariableBase { +class EXPCL_DTOOL_PRC ConfigVariableSearchPath : public ConfigVariableBase { PUBLISHED: INLINE ConfigVariableSearchPath(const string &name, const string &description = string(), diff --git a/dtool/src/prc/configVariableString.h b/dtool/src/prc/configVariableString.h index 1592e0b836..0b6d615667 100644 --- a/dtool/src/prc/configVariableString.h +++ b/dtool/src/prc/configVariableString.h @@ -20,7 +20,7 @@ /** * This is a convenience class to specialize ConfigVariable as a string type. */ -class EXPCL_DTOOLCONFIG ConfigVariableString : public ConfigVariable { +class EXPCL_DTOOL_PRC ConfigVariableString : public ConfigVariable { PUBLISHED: INLINE ConfigVariableString(const string &name); INLINE ConfigVariableString(const string &name, const string &default_value, diff --git a/dtool/src/prc/config_prc.h b/dtool/src/prc/config_prc.h index 5fbe9ec7d3..43e9b37648 100644 --- a/dtool/src/prc/config_prc.h +++ b/dtool/src/prc/config_prc.h @@ -19,7 +19,7 @@ class ConfigVariableBool; -NotifyCategoryDecl(prc, EXPCL_DTOOLCONFIG, EXPTP_DTOOLCONFIG); +NotifyCategoryDecl(prc, EXPCL_DTOOL_PRC, EXPTP_DTOOL_PRC); // This is aligned to match the shadowed definition in notify.cxx. extern ALIGN_16BYTE ConfigVariableBool assert_abort; diff --git a/dtool/src/prc/encryptStream.h b/dtool/src/prc/encryptStream.h index a5d4972ccd..540d4b3209 100644 --- a/dtool/src/prc/encryptStream.h +++ b/dtool/src/prc/encryptStream.h @@ -31,7 +31,7 @@ * * Seeking is not supported. */ -class EXPCL_DTOOLCONFIG IDecryptStream : public istream { +class EXPCL_DTOOL_PRC IDecryptStream : public istream { PUBLISHED: INLINE IDecryptStream(); INLINE explicit IDecryptStream(istream *source, bool owns_source, @@ -66,7 +66,7 @@ private: * * Seeking is not supported. */ -class EXPCL_DTOOLCONFIG OEncryptStream : public ostream { +class EXPCL_DTOOL_PRC OEncryptStream : public ostream { PUBLISHED: INLINE OEncryptStream(); INLINE explicit OEncryptStream(ostream *dest, bool owns_dest, diff --git a/dtool/src/prc/encryptStreamBuf.h b/dtool/src/prc/encryptStreamBuf.h index b7d95424c2..8a812f1701 100644 --- a/dtool/src/prc/encryptStreamBuf.h +++ b/dtool/src/prc/encryptStreamBuf.h @@ -24,7 +24,7 @@ typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX; /** * The streambuf object that implements IDecompressStream and OCompressStream. */ -class EXPCL_DTOOLCONFIG EncryptStreamBuf : public streambuf { +class EXPCL_DTOOL_PRC EncryptStreamBuf : public streambuf { public: EncryptStreamBuf(); virtual ~EncryptStreamBuf(); diff --git a/dtool/src/prc/nativeNumericData.h b/dtool/src/prc/nativeNumericData.h index db1e9e5b06..04af522643 100644 --- a/dtool/src/prc/nativeNumericData.h +++ b/dtool/src/prc/nativeNumericData.h @@ -36,7 +36,7 @@ * typedeffed to be one of these or the other, according to the machine's * architecture. */ -class EXPCL_DTOOLCONFIG NativeNumericData { +class EXPCL_DTOOL_PRC NativeNumericData { public: INLINE NativeNumericData(const void *data, size_t length); INLINE NativeNumericData(const void *data, size_t start, size_t length); diff --git a/dtool/src/prc/notifyCategory.h b/dtool/src/prc/notifyCategory.h index 343591d122..61f4e71906 100644 --- a/dtool/src/prc/notifyCategory.h +++ b/dtool/src/prc/notifyCategory.h @@ -29,7 +29,7 @@ * a package level; further nested categories can be created within a package * if a finer grain of control is required. */ -class EXPCL_DTOOLCONFIG NotifyCategory : public MemoryBase, public ConfigFlags { +class EXPCL_DTOOL_PRC NotifyCategory : public MemoryBase, public ConfigFlags { private: NotifyCategory(const string &fullname, const string &basename, NotifyCategory *parent); diff --git a/dtool/src/prc/notifySeverity.h b/dtool/src/prc/notifySeverity.h index 8750602d73..d16cdb89d8 100644 --- a/dtool/src/prc/notifySeverity.h +++ b/dtool/src/prc/notifySeverity.h @@ -28,8 +28,8 @@ enum NotifySeverity { }; END_PUBLISH -EXPCL_DTOOLCONFIG ostream &operator << (ostream &out, NotifySeverity severity); -EXPCL_DTOOLCONFIG istream &operator >> (istream &in, NotifySeverity &severity); +EXPCL_DTOOL_PRC ostream &operator << (ostream &out, NotifySeverity severity); +EXPCL_DTOOL_PRC istream &operator >> (istream &in, NotifySeverity &severity); #endif diff --git a/dtool/src/prc/pnotify.h b/dtool/src/prc/pnotify.h index e51022c28a..27a346d0d9 100644 --- a/dtool/src/prc/pnotify.h +++ b/dtool/src/prc/pnotify.h @@ -30,7 +30,7 @@ class NotifyCategory; * independently enabled or disabled, so that error messages may be squelched * or respected according to the wishes of the user. */ -class EXPCL_DTOOLCONFIG Notify { +class EXPCL_DTOOL_PRC Notify { PUBLISHED: Notify(); ~Notify(); diff --git a/dtool/src/prc/prcKeyRegistry.h b/dtool/src/prc/prcKeyRegistry.h index 69e25d949e..0a21d182ad 100644 --- a/dtool/src/prc/prcKeyRegistry.h +++ b/dtool/src/prc/prcKeyRegistry.h @@ -33,7 +33,7 @@ typedef struct evp_pkey_st EVP_PKEY; * * This class requires the OpenSSL library. */ -class EXPCL_DTOOLCONFIG PrcKeyRegistry { +class EXPCL_DTOOL_PRC PrcKeyRegistry { protected: PrcKeyRegistry(); ~PrcKeyRegistry(); diff --git a/dtool/src/prc/reversedNumericData.h b/dtool/src/prc/reversedNumericData.h index d92ab82964..9979fbb3a2 100644 --- a/dtool/src/prc/reversedNumericData.h +++ b/dtool/src/prc/reversedNumericData.h @@ -39,7 +39,7 @@ static const int max_numeric_size = 8; * typedeffed to be one of these or the other, according to the machine's * architecture. */ -class EXPCL_DTOOLCONFIG ReversedNumericData { +class EXPCL_DTOOL_PRC ReversedNumericData { public: INLINE ReversedNumericData(const void *data, size_t length); INLINE ReversedNumericData(const void *data, size_t start, size_t length); diff --git a/dtool/src/prc/streamReader.h b/dtool/src/prc/streamReader.h index 3d8865e21d..bedaa0eeb5 100644 --- a/dtool/src/prc/streamReader.h +++ b/dtool/src/prc/streamReader.h @@ -24,7 +24,7 @@ * A class to read sequential binary data directly from an istream. Its * interface is similar to DatagramIterator by design; see also StreamWriter. */ -class EXPCL_DTOOLCONFIG StreamReader { +class EXPCL_DTOOL_PRC StreamReader { public: INLINE StreamReader(istream &in); PUBLISHED: diff --git a/dtool/src/prc/streamWrapper.h b/dtool/src/prc/streamWrapper.h index 856cf6f855..f3e4028c1b 100644 --- a/dtool/src/prc/streamWrapper.h +++ b/dtool/src/prc/streamWrapper.h @@ -21,7 +21,7 @@ * The base class for both IStreamWrapper and OStreamWrapper, this provides * the common locking interface. */ -class EXPCL_DTOOLCONFIG StreamWrapperBase { +class EXPCL_DTOOL_PRC StreamWrapperBase { protected: INLINE StreamWrapperBase(); @@ -48,7 +48,7 @@ private: * A thread may use this class to perform an atomic seek/read/gcount * operation. */ -class EXPCL_DTOOLCONFIG IStreamWrapper : virtual public StreamWrapperBase { +class EXPCL_DTOOL_PRC IStreamWrapper : virtual public StreamWrapperBase { public: INLINE IStreamWrapper(istream *stream, bool owns_pointer); PUBLISHED: @@ -75,7 +75,7 @@ private: * This class provides a locking wrapper around an arbitrary ostream pointer. * A thread may use this class to perform an atomic seek/write operation. */ -class EXPCL_DTOOLCONFIG OStreamWrapper : virtual public StreamWrapperBase { +class EXPCL_DTOOL_PRC OStreamWrapper : virtual public StreamWrapperBase { public: INLINE OStreamWrapper(ostream *stream, bool owns_pointer, bool stringstream_hack = false); PUBLISHED: @@ -111,7 +111,7 @@ private: * This class provides a locking wrapper around a combination ostream/istream * pointer. */ -class EXPCL_DTOOLCONFIG StreamWrapper : public IStreamWrapper, public OStreamWrapper { +class EXPCL_DTOOL_PRC StreamWrapper : public IStreamWrapper, public OStreamWrapper { public: INLINE StreamWrapper(iostream *stream, bool owns_pointer, bool stringstream_hack = false); PUBLISHED: diff --git a/dtool/src/prc/streamWriter.h b/dtool/src/prc/streamWriter.h index 8e2cf4dc1b..b39db968c0 100644 --- a/dtool/src/prc/streamWriter.h +++ b/dtool/src/prc/streamWriter.h @@ -26,7 +26,7 @@ * primarily intended as a convenience to eliminate the overhead of writing * bytes to a Datagram and then writing the Datagram to a stream. */ -class EXPCL_DTOOLCONFIG StreamWriter { +class EXPCL_DTOOL_PRC StreamWriter { public: INLINE StreamWriter(ostream &out); PUBLISHED: From 97399235931573a59c2f4e2eb067a6351a79f9ca Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 4 Mar 2018 19:52:37 -0700 Subject: [PATCH 110/247] dconfig: Change export macros to EXP*_DTOOL_DCONFIG This is for consistency with `panda`, which follows this format. --- dtool/src/dconfig/config_dconfig.h | 4 ++-- dtool/src/dconfig/dconfig.h | 2 +- dtool/src/dtoolbase/dtoolsymbols.h | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dtool/src/dconfig/config_dconfig.h b/dtool/src/dconfig/config_dconfig.h index 9988086d45..e01fdcf441 100644 --- a/dtool/src/dconfig/config_dconfig.h +++ b/dtool/src/dconfig/config_dconfig.h @@ -23,7 +23,7 @@ #include "dtoolbase.h" #include "notifyCategoryProxy.h" -NotifyCategoryDecl(dconfig, EXPCL_DTOOLCONFIG, EXPTP_DTOOLCONFIG); -NotifyCategoryDecl(microconfig, EXPCL_DTOOLCONFIG, EXPTP_DTOOLCONFIG); +NotifyCategoryDecl(dconfig, EXPCL_DTOOL_DCONFIG, EXPTP_DTOOL_DCONFIG); +NotifyCategoryDecl(microconfig, EXPCL_DTOOL_DCONFIG, EXPTP_DTOOL_DCONFIG); #endif diff --git a/dtool/src/dconfig/dconfig.h b/dtool/src/dconfig/dconfig.h index cf6e7396fd..ede79f596f 100644 --- a/dtool/src/dconfig/dconfig.h +++ b/dtool/src/dconfig/dconfig.h @@ -30,7 +30,7 @@ * used primarily by Python code. For modern code, use the new * ConfigVariable* interface instead of this deprecated interface. */ -class EXPCL_DTOOLCONFIG DConfig { +class EXPCL_DTOOL_DCONFIG DConfig { PUBLISHED: static INLINE bool GetBool(const string &sym, bool def = false); static INLINE int GetInt(const string &sym, int def = 0); diff --git a/dtool/src/dtoolbase/dtoolsymbols.h b/dtool/src/dtoolbase/dtoolsymbols.h index 98aab5a489..a09ec2fb23 100644 --- a/dtool/src/dtoolbase/dtoolsymbols.h +++ b/dtool/src/dtoolbase/dtoolsymbols.h @@ -109,6 +109,9 @@ #define EXPCL_DTOOL_PRC EXPCL_DTOOLCONFIG #define EXPTP_DTOOL_PRC EXPTP_DTOOLCONFIG +#define EXPCL_DTOOL_DCONFIG EXPCL_DTOOLCONFIG +#define EXPTP_DTOOL_DCONFIG EXPTP_DTOOLCONFIG + /* These two are always defined empty, because pystub is statically built. But we leave the symbol around in case we change our minds From 98797d009095de37de90b08238e096a497379bfd Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 15 Mar 2018 12:48:19 -0600 Subject: [PATCH 111/247] pandabase: Introduce BUILDING_ defines for each component This reverses the relationship between EXPCL_PANDA_COMPONENT and BUILDING_PANDA, where BUILDING_PANDA is just shorthand for BUILDING_PANDA_COMPONENT and BUILDING_PANDA_COMPONENT itself sets the EXPCL_PANDA_COMPONENT defines. Also removes EXPCL_PANDA. --- panda/src/pandabase/pandasymbols.h | 389 +++++++++++++++++++++-------- 1 file changed, 288 insertions(+), 101 deletions(-) diff --git a/panda/src/pandabase/pandasymbols.h b/panda/src/pandabase/pandasymbols.h index 51d9040392..beca549740 100644 --- a/panda/src/pandabase/pandasymbols.h +++ b/panda/src/pandabase/pandasymbols.h @@ -69,12 +69,296 @@ #define EXPTP_OPENAL_AUDIO IMPORT_TEMPL #endif +/* BUILDING_PANDA is just a buildsystem shortcut for all of these: */ #ifdef BUILDING_PANDA - #define EXPCL_PANDA EXPORT_CLASS - #define EXPTP_PANDA EXPORT_TEMPL + #define BUILDING_LIBPANDA + #define BUILDING_PANDA_AUDIO + #define BUILDING_PANDA_CHAN + #define BUILDING_PANDA_CHAR + #define BUILDING_PANDA_COLLIDE + #define BUILDING_PANDA_CULL + #define BUILDING_PANDA_DEVICE + #define BUILDING_PANDA_DGRAPH + #define BUILDING_PANDA_DISPLAY + #define BUILDING_PANDA_DXML + #define BUILDING_PANDA_EVENT + #define BUILDING_PANDA_GOBJ + #define BUILDING_PANDA_GRUTIL + #define BUILDING_PANDA_GSGBASE + #define BUILDING_PANDA_LINMATH + #define BUILDING_PANDA_MATHUTIL + #define BUILDING_PANDA_MOVIES + #define BUILDING_PANDA_NATIVENET + #define BUILDING_PANDA_NET + #define BUILDING_PANDA_PARAMETRICS + #define BUILDING_PANDA_PGRAPH + #define BUILDING_PANDA_PGRAPHNODES + #define BUILDING_PANDA_PGUI + #define BUILDING_PANDA_PIPELINE + #define BUILDING_PANDA_PNMIMAGE + #define BUILDING_PANDA_PNMIMAGETYPES + #define BUILDING_PANDA_PNMTEXT + #define BUILDING_PANDA_PSTATCLIENT + #define BUILDING_PANDA_PUTIL + #define BUILDING_PANDA_RECORDER + #define BUILDING_PANDA_TEXT + #define BUILDING_PANDA_TFORM +#endif + +#ifdef BUILDING_LIBPANDA + #define EXPCL_LIBPANDA EXPORT_CLASS + #define EXPTP_LIBPANDA EXPORT_TEMPL #else - #define EXPCL_PANDA IMPORT_CLASS - #define EXPTP_PANDA IMPORT_TEMPL + #define EXPCL_LIBPANDA IMPORT_CLASS + #define EXPTP_LIBPANDA IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_AUDIO + #define EXPCL_PANDA_AUDIO EXPORT_CLASS + #define EXPTP_PANDA_AUDIO EXPORT_TEMPL +#else + #define EXPCL_PANDA_AUDIO IMPORT_CLASS + #define EXPTP_PANDA_AUDIO IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_CHAN + #define EXPCL_PANDA_CHAN EXPORT_CLASS + #define EXPTP_PANDA_CHAN EXPORT_TEMPL +#else + #define EXPCL_PANDA_CHAN IMPORT_CLASS + #define EXPTP_PANDA_CHAN IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_CHAR + #define EXPCL_PANDA_CHAR EXPORT_CLASS + #define EXPTP_PANDA_CHAR EXPORT_TEMPL +#else + #define EXPCL_PANDA_CHAR IMPORT_CLASS + #define EXPTP_PANDA_CHAR IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_COLLIDE + #define EXPCL_PANDA_COLLIDE EXPORT_CLASS + #define EXPTP_PANDA_COLLIDE EXPORT_TEMPL +#else + #define EXPCL_PANDA_COLLIDE IMPORT_CLASS + #define EXPTP_PANDA_COLLIDE IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_CULL + #define EXPCL_PANDA_CULL EXPORT_CLASS + #define EXPTP_PANDA_CULL EXPORT_TEMPL +#else + #define EXPCL_PANDA_CULL IMPORT_CLASS + #define EXPTP_PANDA_CULL IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_DEVICE + #define EXPCL_PANDA_DEVICE EXPORT_CLASS + #define EXPTP_PANDA_DEVICE EXPORT_TEMPL +#else + #define EXPCL_PANDA_DEVICE IMPORT_CLASS + #define EXPTP_PANDA_DEVICE IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_DGRAPH + #define EXPCL_PANDA_DGRAPH EXPORT_CLASS + #define EXPTP_PANDA_DGRAPH EXPORT_TEMPL +#else + #define EXPCL_PANDA_DGRAPH IMPORT_CLASS + #define EXPTP_PANDA_DGRAPH IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_DISPLAY + #define EXPCL_PANDA_DISPLAY EXPORT_CLASS + #define EXPTP_PANDA_DISPLAY EXPORT_TEMPL +#else + #define EXPCL_PANDA_DISPLAY IMPORT_CLASS + #define EXPTP_PANDA_DISPLAY IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_DXML + #define EXPCL_PANDA_DXML EXPORT_CLASS + #define EXPTP_PANDA_DXML EXPORT_TEMPL +#else + #define EXPCL_PANDA_DXML IMPORT_CLASS + #define EXPTP_PANDA_DXML IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_EVENT + #define EXPCL_PANDA_EVENT EXPORT_CLASS + #define EXPTP_PANDA_EVENT EXPORT_TEMPL +#else + #define EXPCL_PANDA_EVENT IMPORT_CLASS + #define EXPTP_PANDA_EVENT IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_GOBJ + #define EXPCL_PANDA_GOBJ EXPORT_CLASS + #define EXPTP_PANDA_GOBJ EXPORT_TEMPL +#else + #define EXPCL_PANDA_GOBJ IMPORT_CLASS + #define EXPTP_PANDA_GOBJ IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_GRUTIL + #define EXPCL_PANDA_GRUTIL EXPORT_CLASS + #define EXPTP_PANDA_GRUTIL EXPORT_TEMPL +#else + #define EXPCL_PANDA_GRUTIL IMPORT_CLASS + #define EXPTP_PANDA_GRUTIL IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_GSGBASE + #define EXPCL_PANDA_GSGBASE EXPORT_CLASS + #define EXPTP_PANDA_GSGBASE EXPORT_TEMPL +#else + #define EXPCL_PANDA_GSGBASE IMPORT_CLASS + #define EXPTP_PANDA_GSGBASE IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_LINMATH + #define EXPCL_PANDA_LINMATH EXPORT_CLASS + #define EXPTP_PANDA_LINMATH EXPORT_TEMPL +#else + #define EXPCL_PANDA_LINMATH IMPORT_CLASS + #define EXPTP_PANDA_LINMATH IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_MATHUTIL + #define EXPCL_PANDA_MATHUTIL EXPORT_CLASS + #define EXPTP_PANDA_MATHUTIL EXPORT_TEMPL +#else + #define EXPCL_PANDA_MATHUTIL IMPORT_CLASS + #define EXPTP_PANDA_MATHUTIL IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_MOVIES + #define EXPCL_PANDA_MOVIES EXPORT_CLASS + #define EXPTP_PANDA_MOVIES EXPORT_TEMPL +#else + #define EXPCL_PANDA_MOVIES IMPORT_CLASS + #define EXPTP_PANDA_MOVIES IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_NATIVENET + #define EXPCL_PANDA_NATIVENET EXPORT_CLASS + #define EXPTP_PANDA_NATIVENET EXPORT_TEMPL +#else + #define EXPCL_PANDA_NATIVENET IMPORT_CLASS + #define EXPTP_PANDA_NATIVENET IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_NET + #define EXPCL_PANDA_NET EXPORT_CLASS + #define EXPTP_PANDA_NET EXPORT_TEMPL +#else + #define EXPCL_PANDA_NET IMPORT_CLASS + #define EXPTP_PANDA_NET IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_PARAMETRICS + #define EXPCL_PANDA_PARAMETRICS EXPORT_CLASS + #define EXPTP_PANDA_PARAMETRICS EXPORT_TEMPL +#else + #define EXPCL_PANDA_PARAMETRICS IMPORT_CLASS + #define EXPTP_PANDA_PARAMETRICS IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_PGRAPH + #define EXPCL_PANDA_PGRAPH EXPORT_CLASS + #define EXPTP_PANDA_PGRAPH EXPORT_TEMPL +#else + #define EXPCL_PANDA_PGRAPH IMPORT_CLASS + #define EXPTP_PANDA_PGRAPH IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_PGRAPHNODES + #define EXPCL_PANDA_PGRAPHNODES EXPORT_CLASS + #define EXPTP_PANDA_PGRAPHNODES EXPORT_TEMPL +#else + #define EXPCL_PANDA_PGRAPHNODES IMPORT_CLASS + #define EXPTP_PANDA_PGRAPHNODES IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_PGUI + #define EXPCL_PANDA_PGUI EXPORT_CLASS + #define EXPTP_PANDA_PGUI EXPORT_TEMPL +#else + #define EXPCL_PANDA_PGUI IMPORT_CLASS + #define EXPTP_PANDA_PGUI IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_PIPELINE + #define EXPCL_PANDA_PIPELINE EXPORT_CLASS + #define EXPTP_PANDA_PIPELINE EXPORT_TEMPL +#else + #define EXPCL_PANDA_PIPELINE IMPORT_CLASS + #define EXPTP_PANDA_PIPELINE IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_PNMIMAGE + #define EXPCL_PANDA_PNMIMAGE EXPORT_CLASS + #define EXPTP_PANDA_PNMIMAGE EXPORT_TEMPL +#else + #define EXPCL_PANDA_PNMIMAGE IMPORT_CLASS + #define EXPTP_PANDA_PNMIMAGE IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_PNMIMAGETYPES + #define EXPCL_PANDA_PNMIMAGETYPES EXPORT_CLASS + #define EXPTP_PANDA_PNMIMAGETYPES EXPORT_TEMPL +#else + #define EXPCL_PANDA_PNMIMAGETYPES IMPORT_CLASS + #define EXPTP_PANDA_PNMIMAGETYPES IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_PNMTEXT + #define EXPCL_PANDA_PNMTEXT EXPORT_CLASS + #define EXPTP_PANDA_PNMTEXT EXPORT_TEMPL +#else + #define EXPCL_PANDA_PNMTEXT IMPORT_CLASS + #define EXPTP_PANDA_PNMTEXT IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_PSTATCLIENT + #define EXPCL_PANDA_PSTATCLIENT EXPORT_CLASS + #define EXPTP_PANDA_PSTATCLIENT EXPORT_TEMPL +#else + #define EXPCL_PANDA_PSTATCLIENT IMPORT_CLASS + #define EXPTP_PANDA_PSTATCLIENT IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_PUTIL + #define EXPCL_PANDA_PUTIL EXPORT_CLASS + #define EXPTP_PANDA_PUTIL EXPORT_TEMPL +#else + #define EXPCL_PANDA_PUTIL IMPORT_CLASS + #define EXPTP_PANDA_PUTIL IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_RECORDER + #define EXPCL_PANDA_RECORDER EXPORT_CLASS + #define EXPTP_PANDA_RECORDER EXPORT_TEMPL +#else + #define EXPCL_PANDA_RECORDER IMPORT_CLASS + #define EXPTP_PANDA_RECORDER IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_TEXT + #define EXPCL_PANDA_TEXT EXPORT_CLASS + #define EXPTP_PANDA_TEXT EXPORT_TEMPL +#else + #define EXPCL_PANDA_TEXT IMPORT_CLASS + #define EXPTP_PANDA_TEXT IMPORT_TEMPL +#endif + +#ifdef BUILDING_PANDA_TFORM + #define EXPCL_PANDA_TFORM EXPORT_CLASS + #define EXPTP_PANDA_TFORM EXPORT_TEMPL +#else + #define EXPCL_PANDA_TFORM IMPORT_CLASS + #define EXPTP_PANDA_TFORM IMPORT_TEMPL #endif #ifdef BUILDING_PANDAAWESOMIUM @@ -246,101 +530,4 @@ #define INLINE_MATHUTIL INLINE #endif - -#define EXPCL_LIBPANDA EXPCL_PANDA -#define EXPTP_LIBPANDA EXPTP_PANDA - -#define EXPCL_PANDA_AUDIO EXPCL_PANDA -#define EXPTP_PANDA_AUDIO EXPTP_PANDA - -#define EXPCL_PANDA_CHAN EXPCL_PANDA -#define EXPTP_PANDA_CHAN EXPTP_PANDA - -#define EXPCL_PANDA_CHAR EXPCL_PANDA -#define EXPTP_PANDA_CHAR EXPTP_PANDA - -#define EXPCL_PANDA_COLLIDE EXPCL_PANDA -#define EXPTP_PANDA_COLLIDE EXPTP_PANDA - -#define EXPCL_PANDA_CULL EXPCL_PANDA -#define EXPTP_PANDA_CULL EXPTP_PANDA - -#define EXPCL_PANDA_DEVICE EXPCL_PANDA -#define EXPTP_PANDA_DEVICE EXPTP_PANDA - -#define EXPCL_PANDA_DGRAPH EXPCL_PANDA -#define EXPTP_PANDA_DGRAPH EXPTP_PANDA - -#define EXPCL_PANDA_DISPLAY EXPCL_PANDA -#define EXPTP_PANDA_DISPLAY EXPTP_PANDA - -#define EXPCL_PANDA_DXML EXPCL_PANDA -#define EXPTP_PANDA_DXML EXPTP_PANDA - -#define EXPCL_PANDA_EVENT EXPCL_PANDA -#define EXPTP_PANDA_EVENT EXPTP_PANDA - -#define EXPCL_PANDA_GOBJ EXPCL_PANDA -#define EXPTP_PANDA_GOBJ EXPTP_PANDA - -#define EXPCL_PANDA_GRUTIL EXPCL_PANDA -#define EXPTP_PANDA_GRUTIL EXPTP_PANDA - -#define EXPCL_PANDA_GSGBASE EXPCL_PANDA -#define EXPTP_PANDA_GSGBASE EXPTP_PANDA - -#define EXPCL_PANDA_LINMATH EXPCL_PANDA -#define EXPTP_PANDA_LINMATH EXPTP_PANDA - -#define EXPCL_PANDA_MATHUTIL EXPCL_PANDA -#define EXPTP_PANDA_MATHUTIL EXPTP_PANDA - -#define EXPCL_PANDA_MOVIES EXPCL_PANDA -#define EXPTP_PANDA_MOVIES EXPTP_PANDA - -#define EXPCL_PANDA_NATIVENET EXPCL_PANDA -#define EXPTP_PANDA_NATIVENET EXPTP_PANDA - -#define EXPCL_PANDA_NET EXPCL_PANDA -#define EXPTP_PANDA_NET EXPTP_PANDA - -#define EXPCL_PANDA_PARAMETRICS EXPCL_PANDA -#define EXPTP_PANDA_PARAMETRICS EXPTP_PANDA - -#define EXPCL_PANDA_PGRAPH EXPCL_PANDA -#define EXPTP_PANDA_PGRAPH EXPTP_PANDA - -#define EXPCL_PANDA_PGRAPHNODES EXPCL_PANDA -#define EXPTP_PANDA_PGRAPHNODES EXPTP_PANDA - -#define EXPCL_PANDA_PGUI EXPCL_PANDA -#define EXPTP_PANDA_PGUI EXPTP_PANDA - -#define EXPCL_PANDA_PIPELINE EXPCL_PANDA -#define EXPTP_PANDA_PIPELINE EXPTP_PANDA - -#define EXPCL_PANDA_PNMIMAGE EXPCL_PANDA -#define EXPTP_PANDA_PNMIMAGE EXPTP_PANDA - -#define EXPCL_PANDA_PNMIMAGETYPES EXPCL_PANDA -#define EXPTP_PANDA_PNMIMAGETYPES EXPTP_PANDA - -#define EXPCL_PANDA_PNMTEXT EXPCL_PANDA -#define EXPTP_PANDA_PNMTEXT EXPTP_PANDA - -#define EXPCL_PANDA_PSTATCLIENT EXPCL_PANDA -#define EXPTP_PANDA_PSTATCLIENT EXPTP_PANDA - -#define EXPCL_PANDA_PUTIL EXPCL_PANDA -#define EXPTP_PANDA_PUTIL EXPTP_PANDA - -#define EXPCL_PANDA_RECORDER EXPCL_PANDA -#define EXPTP_PANDA_RECORDER EXPTP_PANDA - -#define EXPCL_PANDA_TEXT EXPCL_PANDA -#define EXPTP_PANDA_TEXT EXPTP_PANDA - -#define EXPCL_PANDA_TFORM EXPCL_PANDA -#define EXPTP_PANDA_TFORM EXPTP_PANDA - #endif From bd2a9d709ad6070898ccf4a25f847e9d5b91a720 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 16 Mar 2018 15:06:54 -0600 Subject: [PATCH 112/247] dtoolbase: Introduce BUILDING_ defines for each component This mirrors the prior commit. --- dtool/src/dtoolbase/dtoolsymbols.h | 57 ++++++++++++++++++------------ 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/dtool/src/dtoolbase/dtoolsymbols.h b/dtool/src/dtoolbase/dtoolsymbols.h index a09ec2fb23..5f972e776f 100644 --- a/dtool/src/dtoolbase/dtoolsymbols.h +++ b/dtool/src/dtoolbase/dtoolsymbols.h @@ -68,19 +68,45 @@ */ #ifdef BUILDING_DTOOL - #define EXPCL_DTOOL EXPORT_CLASS - #define EXPTP_DTOOL EXPORT_TEMPL -#else - #define EXPCL_DTOOL IMPORT_CLASS - #define EXPTP_DTOOL IMPORT_TEMPL + #define BUILDING_DTOOL_DTOOLBASE + #define BUILDING_DTOOL_DTOOLUTIL #endif #ifdef BUILDING_DTOOLCONFIG - #define EXPCL_DTOOLCONFIG EXPORT_CLASS - #define EXPTP_DTOOLCONFIG EXPORT_TEMPL + #define BUILDING_DTOOL_PRC + #define BUILDING_DTOOL_DCONFIG +#endif + +#ifdef BUILDING_DTOOL_DTOOLBASE + #define EXPCL_DTOOL_DTOOLBASE EXPORT_CLASS + #define EXPTP_DTOOL_DTOOLBASE EXPORT_TEMPL #else - #define EXPCL_DTOOLCONFIG IMPORT_CLASS - #define EXPTP_DTOOLCONFIG IMPORT_TEMPL + #define EXPCL_DTOOL_DTOOLBASE IMPORT_CLASS + #define EXPTP_DTOOL_DTOOLBASE IMPORT_TEMPL +#endif + +#ifdef BUILDING_DTOOL_DTOOLUTIL + #define EXPCL_DTOOL_DTOOLUTIL EXPORT_CLASS + #define EXPTP_DTOOL_DTOOLUTIL EXPORT_TEMPL +#else + #define EXPCL_DTOOL_DTOOLUTIL IMPORT_CLASS + #define EXPTP_DTOOL_DTOOLUTIL IMPORT_TEMPL +#endif + +#ifdef BUILDING_DTOOL_PRC + #define EXPCL_DTOOL_PRC EXPORT_CLASS + #define EXPTP_DTOOL_PRC EXPORT_TEMPL +#else + #define EXPCL_DTOOL_PRC IMPORT_CLASS + #define EXPTP_DTOOL_PRC IMPORT_TEMPL +#endif + +#ifdef BUILDING_DTOOL_DCONFIG + #define EXPCL_DTOOL_DCONFIG EXPORT_CLASS + #define EXPTP_DTOOL_DCONFIG EXPORT_TEMPL +#else + #define EXPCL_DTOOL_DCONFIG IMPORT_CLASS + #define EXPTP_DTOOL_DCONFIG IMPORT_TEMPL #endif #ifdef BUILDING_INTERROGATEDB @@ -100,19 +126,6 @@ #endif /* BUILDING_MISC */ -#define EXPCL_DTOOL_DTOOLBASE EXPCL_DTOOL -#define EXPTP_DTOOL_DTOOLBASE EXPTP_DTOOL - -#define EXPCL_DTOOL_DTOOLUTIL EXPCL_DTOOL -#define EXPTP_DTOOL_DTOOLUTIL EXPTP_DTOOL - -#define EXPCL_DTOOL_PRC EXPCL_DTOOLCONFIG -#define EXPTP_DTOOL_PRC EXPTP_DTOOLCONFIG - -#define EXPCL_DTOOL_DCONFIG EXPCL_DTOOLCONFIG -#define EXPTP_DTOOL_DCONFIG EXPTP_DTOOLCONFIG - - /* These two are always defined empty, because pystub is statically built. But we leave the symbol around in case we change our minds to make pystub once again be a dynamic library. */ From f231ba4cd7ecc689e7827b9c21f79621b8d3f651 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Tue, 20 Mar 2018 00:09:09 -0600 Subject: [PATCH 113/247] directbase: Introduce BUILDING_ defines for each component Ditto everything before, but for direct. --- direct/src/dcparser/dcbase.h | 6 -- direct/src/deadrec/config_deadrec.h | 4 +- direct/src/deadrec/smoothMover.h | 2 +- direct/src/directbase/directsymbols.h | 58 +++++++++++++++++-- direct/src/directd/directd.h | 2 +- .../src/distributed/cConnectionRepository.h | 2 +- .../distributed/cDistributedSmoothNodeBase.h | 2 +- direct/src/distributed/config_distributed.h | 4 +- direct/src/interval/cConstrainHprInterval.h | 2 +- .../src/interval/cConstrainPosHprInterval.h | 2 +- direct/src/interval/cConstrainPosInterval.h | 2 +- .../interval/cConstrainTransformInterval.h | 2 +- direct/src/interval/cConstraintInterval.h | 2 +- direct/src/interval/cInterval.h | 4 +- direct/src/interval/cIntervalManager.h | 2 +- direct/src/interval/cLerpAnimEffectInterval.h | 2 +- direct/src/interval/cLerpInterval.h | 2 +- direct/src/interval/cLerpNodePathInterval.h | 2 +- direct/src/interval/cMetaInterval.h | 2 +- direct/src/interval/config_interval.h | 6 +- direct/src/interval/hideInterval.h | 2 +- direct/src/interval/lerpblend.h | 10 ++-- direct/src/interval/showInterval.h | 2 +- direct/src/interval/waitInterval.h | 2 +- direct/src/motiontrail/cMotionTrail.h | 2 +- direct/src/motiontrail/config_motiontrail.cxx | 2 +- direct/src/motiontrail/config_motiontrail.h | 4 +- direct/src/showbase/showBase.h | 22 +++---- 28 files changed, 100 insertions(+), 56 deletions(-) diff --git a/direct/src/dcparser/dcbase.h b/direct/src/dcparser/dcbase.h index fae53a46f8..6d65f16524 100644 --- a/direct/src/dcparser/dcbase.h +++ b/direct/src/dcparser/dcbase.h @@ -80,12 +80,6 @@ using namespace std; #define nassertv(condition) assert(condition) #define nassertv_always(condition) assert(condition) -// Panda defines these export symbols for building DLL's. Outside of Panda, -// we assume we're not putting this code in a DLL, so we define them to -// nothing. -#define EXPCL_DIRECT -#define EXPTP_DIRECT - // Panda defines a special Filename class. We'll use an ordinary string // instead. typedef string Filename; diff --git a/direct/src/deadrec/config_deadrec.h b/direct/src/deadrec/config_deadrec.h index df1b656e32..7dfc36c898 100644 --- a/direct/src/deadrec/config_deadrec.h +++ b/direct/src/deadrec/config_deadrec.h @@ -18,10 +18,10 @@ #include "notifyCategoryProxy.h" #include "configVariableBool.h" -NotifyCategoryDecl(deadrec, EXPCL_DIRECT, EXPTP_DIRECT); +NotifyCategoryDecl(deadrec, EXPCL_DIRECT_DEADREC, EXPTP_DIRECT_DEADREC); extern ConfigVariableBool accept_clock_skew; -extern EXPCL_DIRECT void init_libdeadrec(); +extern EXPCL_DIRECT_DEADREC void init_libdeadrec(); #endif diff --git a/direct/src/deadrec/smoothMover.h b/direct/src/deadrec/smoothMover.h index e9ca5dc76e..aee12bca8e 100644 --- a/direct/src/deadrec/smoothMover.h +++ b/direct/src/deadrec/smoothMover.h @@ -38,7 +38,7 @@ static const int max_timestamp_delays = 10; * update. The assumption is that all SmoothMovers in the world will be * operating in the same mode together. */ -class EXPCL_DIRECT SmoothMover { +class EXPCL_DIRECT_DEADREC SmoothMover { PUBLISHED: SmoothMover(); ~SmoothMover(); diff --git a/direct/src/directbase/directsymbols.h b/direct/src/directbase/directsymbols.h index 4eb2202c1f..cdd07e1a0c 100644 --- a/direct/src/directbase/directsymbols.h +++ b/direct/src/directbase/directsymbols.h @@ -16,12 +16,62 @@ /* See dtoolsymbols.h for a rant on the purpose of this file. */ +/* BUILDING_DIRECT is just a buildsystem shortcut for all of these: */ #ifdef BUILDING_DIRECT - #define EXPCL_DIRECT EXPORT_CLASS - #define EXPTP_DIRECT EXPORT_TEMPL + #define BUILDING_DIRECT_DEADREC + #define BUILDING_DIRECT_DIRECTD + #define BUILDING_DIRECT_INTERVAL + #define BUILDING_DIRECT_MOTIONTRAIL + #define BUILDING_DIRECT_SHOWBASE + #define BUILDING_DIRECT_DISTRIBUTED +#endif + +#ifdef BUILDING_DIRECT_DEADREC + #define EXPCL_DIRECT_DEADREC EXPORT_CLASS + #define EXPTP_DIRECT_DEADREC EXPORT_TEMPL #else - #define EXPCL_DIRECT IMPORT_CLASS - #define EXPTP_DIRECT IMPORT_TEMPL + #define EXPCL_DIRECT_DEADREC IMPORT_CLASS + #define EXPTP_DIRECT_DEADREC IMPORT_TEMPL +#endif + +#ifdef BUILDING_DIRECT_DIRECTD + #define EXPCL_DIRECT_DIRECTD EXPORT_CLASS + #define EXPTP_DIRECT_DIRECTD EXPORT_TEMPL +#else + #define EXPCL_DIRECT_DIRECTD IMPORT_CLASS + #define EXPTP_DIRECT_DIRECTD IMPORT_TEMPL +#endif + +#ifdef BUILDING_DIRECT_INTERVAL + #define EXPCL_DIRECT_INTERVAL EXPORT_CLASS + #define EXPTP_DIRECT_INTERVAL EXPORT_TEMPL +#else + #define EXPCL_DIRECT_INTERVAL IMPORT_CLASS + #define EXPTP_DIRECT_INTERVAL IMPORT_TEMPL +#endif + +#ifdef BUILDING_DIRECT_MOTIONTRAIL + #define EXPCL_DIRECT_MOTIONTRAIL EXPORT_CLASS + #define EXPTP_DIRECT_MOTIONTRAIL EXPORT_TEMPL +#else + #define EXPCL_DIRECT_MOTIONTRAIL IMPORT_CLASS + #define EXPTP_DIRECT_MOTIONTRAIL IMPORT_TEMPL +#endif + +#ifdef BUILDING_DIRECT_SHOWBASE + #define EXPCL_DIRECT_SHOWBASE EXPORT_CLASS + #define EXPTP_DIRECT_SHOWBASE EXPORT_TEMPL +#else + #define EXPCL_DIRECT_SHOWBASE IMPORT_CLASS + #define EXPTP_DIRECT_SHOWBASE IMPORT_TEMPL +#endif + +#ifdef BUILDING_DIRECT_DISTRIBUTED + #define EXPCL_DIRECT_DISTRIBUTED EXPORT_CLASS + #define EXPTP_DIRECT_DISTRIBUTED EXPORT_TEMPL +#else + #define EXPCL_DIRECT_DISTRIBUTED IMPORT_CLASS + #define EXPTP_DIRECT_DISTRIBUTED IMPORT_TEMPL #endif #endif diff --git a/direct/src/directd/directd.h b/direct/src/directd/directd.h index 3aff05e9df..0623c09b4d 100644 --- a/direct/src/directd/directd.h +++ b/direct/src/directd/directd.h @@ -52,7 +52,7 @@ typedef int HANDLE; * presented in order chronologically by their intended usage. The first * group will probably provide everthing needed for DirectD. */ -class EXPCL_DIRECT DirectD { +class EXPCL_DIRECT_DIRECTD DirectD { PUBLISHED: DirectD(); ~DirectD(); diff --git a/direct/src/distributed/cConnectionRepository.h b/direct/src/distributed/cConnectionRepository.h index fbc494423e..420c995e37 100644 --- a/direct/src/distributed/cConnectionRepository.h +++ b/direct/src/distributed/cConnectionRepository.h @@ -53,7 +53,7 @@ class SocketStream; * the C++ layer, while server messages that are not understood by the C++ * layer are returned up to the Python layer for processing. */ -class EXPCL_DIRECT CConnectionRepository { +class EXPCL_DIRECT_DISTRIBUTED CConnectionRepository { PUBLISHED: explicit CConnectionRepository(bool has_owner_view = false, bool threaded_net = false); diff --git a/direct/src/distributed/cDistributedSmoothNodeBase.h b/direct/src/distributed/cDistributedSmoothNodeBase.h index 53763a6a47..d2c43e285c 100644 --- a/direct/src/distributed/cDistributedSmoothNodeBase.h +++ b/direct/src/distributed/cDistributedSmoothNodeBase.h @@ -28,7 +28,7 @@ class CConnectionRepository; * This class defines some basic methods of DistributedSmoothNodeBase which * have been moved into C++ as a performance optimization. */ -class EXPCL_DIRECT CDistributedSmoothNodeBase { +class EXPCL_DIRECT_DISTRIBUTED CDistributedSmoothNodeBase { PUBLISHED: CDistributedSmoothNodeBase(); ~CDistributedSmoothNodeBase(); diff --git a/direct/src/distributed/config_distributed.h b/direct/src/distributed/config_distributed.h index 1ffbc39df9..22814bfa13 100644 --- a/direct/src/distributed/config_distributed.h +++ b/direct/src/distributed/config_distributed.h @@ -21,13 +21,13 @@ #include "configVariableDouble.h" #include "configVariableBool.h" -NotifyCategoryDecl(distributed, EXPCL_DIRECT, EXPTP_DIRECT); +NotifyCategoryDecl(distributed, EXPCL_DIRECT_DISTRIBUTED, EXPTP_DIRECT_DISTRIBUTED); extern ConfigVariableInt game_server_timeout_ms; extern ConfigVariableDouble min_lag; extern ConfigVariableDouble max_lag; extern ConfigVariableBool handle_datagrams_internally; -extern EXPCL_DIRECT void init_libdistributed(); +extern EXPCL_DIRECT_DISTRIBUTED void init_libdistributed(); #endif diff --git a/direct/src/interval/cConstrainHprInterval.h b/direct/src/interval/cConstrainHprInterval.h index a618b98641..73c790100d 100644 --- a/direct/src/interval/cConstrainHprInterval.h +++ b/direct/src/interval/cConstrainHprInterval.h @@ -24,7 +24,7 @@ * A constraint interval that will constrain the orientation of one node to * the orientation of another. */ -class EXPCL_DIRECT CConstrainHprInterval : public CConstraintInterval { +class EXPCL_DIRECT_INTERVAL CConstrainHprInterval : public CConstraintInterval { PUBLISHED: explicit CConstrainHprInterval(const string &name, double duration, const NodePath &node, const NodePath &target, diff --git a/direct/src/interval/cConstrainPosHprInterval.h b/direct/src/interval/cConstrainPosHprInterval.h index d3ce5efa4f..44fedae0f6 100644 --- a/direct/src/interval/cConstrainPosHprInterval.h +++ b/direct/src/interval/cConstrainPosHprInterval.h @@ -24,7 +24,7 @@ * A constraint interval that will constrain the position and orientation of * one node to the position and orientation of another. */ -class EXPCL_DIRECT CConstrainPosHprInterval : public CConstraintInterval { +class EXPCL_DIRECT_INTERVAL CConstrainPosHprInterval : public CConstraintInterval { PUBLISHED: explicit CConstrainPosHprInterval(const string &name, double duration, const NodePath &node, const NodePath &target, diff --git a/direct/src/interval/cConstrainPosInterval.h b/direct/src/interval/cConstrainPosInterval.h index 92055cd0a4..1e66d3aca0 100644 --- a/direct/src/interval/cConstrainPosInterval.h +++ b/direct/src/interval/cConstrainPosInterval.h @@ -23,7 +23,7 @@ * A constraint interval that will constrain the position of one node to the * position of another. */ -class EXPCL_DIRECT CConstrainPosInterval : public CConstraintInterval { +class EXPCL_DIRECT_INTERVAL CConstrainPosInterval : public CConstraintInterval { PUBLISHED: explicit CConstrainPosInterval(const string &name, double duration, const NodePath &node, const NodePath &target, diff --git a/direct/src/interval/cConstrainTransformInterval.h b/direct/src/interval/cConstrainTransformInterval.h index 897f12aea3..a4bb537ec1 100644 --- a/direct/src/interval/cConstrainTransformInterval.h +++ b/direct/src/interval/cConstrainTransformInterval.h @@ -22,7 +22,7 @@ * A constraint interval that will constrain the transform of one node to the * transform of another. */ -class EXPCL_DIRECT CConstrainTransformInterval : public CConstraintInterval { +class EXPCL_DIRECT_INTERVAL CConstrainTransformInterval : public CConstraintInterval { PUBLISHED: explicit CConstrainTransformInterval(const string &name, double duration, const NodePath &node, diff --git a/direct/src/interval/cConstraintInterval.h b/direct/src/interval/cConstraintInterval.h index 32f90ed978..96a47946ec 100644 --- a/direct/src/interval/cConstraintInterval.h +++ b/direct/src/interval/cConstraintInterval.h @@ -21,7 +21,7 @@ * The base class for a family of intervals that constrain some property to a * value over time. */ -class EXPCL_DIRECT CConstraintInterval : public CInterval { +class EXPCL_DIRECT_INTERVAL CConstraintInterval : public CInterval { PUBLISHED: bool bogus_variable; diff --git a/direct/src/interval/cInterval.h b/direct/src/interval/cInterval.h index d62eadc0c7..07672f352f 100644 --- a/direct/src/interval/cInterval.h +++ b/direct/src/interval/cInterval.h @@ -32,7 +32,7 @@ class CIntervalManager; * C++ will inherit from this class; Intervals that must be implemented in * Python will inherit from the similar Python class. */ -class EXPCL_DIRECT CInterval : public TypedReferenceCount { +class EXPCL_DIRECT_INTERVAL CInterval : public TypedReferenceCount { public: CInterval(const string &name, double duration, bool open_ended); virtual ~CInterval(); @@ -202,7 +202,7 @@ private: }; INLINE ostream &operator << (ostream &out, const CInterval &ival); -EXPCL_DIRECT ostream &operator << (ostream &out, CInterval::State state); +EXPCL_DIRECT_INTERVAL ostream &operator << (ostream &out, CInterval::State state); #include "cInterval.I" diff --git a/direct/src/interval/cIntervalManager.h b/direct/src/interval/cIntervalManager.h index 26616dce91..d4279c25fb 100644 --- a/direct/src/interval/cIntervalManager.h +++ b/direct/src/interval/cIntervalManager.h @@ -36,7 +36,7 @@ class EventQueue; * It is also possible to create multiple IntervalManager objects for special * needs. */ -class EXPCL_DIRECT CIntervalManager { +class EXPCL_DIRECT_INTERVAL CIntervalManager { PUBLISHED: CIntervalManager(); ~CIntervalManager(); diff --git a/direct/src/interval/cLerpAnimEffectInterval.h b/direct/src/interval/cLerpAnimEffectInterval.h index ef84b19df0..af657cb7cc 100644 --- a/direct/src/interval/cLerpAnimEffectInterval.h +++ b/direct/src/interval/cLerpAnimEffectInterval.h @@ -29,7 +29,7 @@ * CLerpAnimEffectInterval to adjust the degree to which each animation * affects the actor. */ -class EXPCL_DIRECT CLerpAnimEffectInterval : public CLerpInterval { +class EXPCL_DIRECT_INTERVAL CLerpAnimEffectInterval : public CLerpInterval { PUBLISHED: INLINE explicit CLerpAnimEffectInterval(const string &name, double duration, BlendType blend_type); diff --git a/direct/src/interval/cLerpInterval.h b/direct/src/interval/cLerpInterval.h index 6a6abbe5c9..7011fd70e9 100644 --- a/direct/src/interval/cLerpInterval.h +++ b/direct/src/interval/cLerpInterval.h @@ -21,7 +21,7 @@ * The base class for a family of intervals that linearly interpolate one or * more numeric values over time. */ -class EXPCL_DIRECT CLerpInterval : public CInterval { +class EXPCL_DIRECT_INTERVAL CLerpInterval : public CInterval { PUBLISHED: enum BlendType { BT_no_blend, diff --git a/direct/src/interval/cLerpNodePathInterval.h b/direct/src/interval/cLerpNodePathInterval.h index 9ac5ae46dc..a134faebf0 100644 --- a/direct/src/interval/cLerpNodePathInterval.h +++ b/direct/src/interval/cLerpNodePathInterval.h @@ -23,7 +23,7 @@ * An interval that lerps one or more properties (like pos, hpr, etc.) on a * NodePath over time. */ -class EXPCL_DIRECT CLerpNodePathInterval : public CLerpInterval { +class EXPCL_DIRECT_INTERVAL CLerpNodePathInterval : public CLerpInterval { PUBLISHED: explicit CLerpNodePathInterval(const string &name, double duration, BlendType blend_type, bool bake_in_start, diff --git a/direct/src/interval/cMetaInterval.h b/direct/src/interval/cMetaInterval.h index ea44225842..f1956f4167 100644 --- a/direct/src/interval/cMetaInterval.h +++ b/direct/src/interval/cMetaInterval.h @@ -29,7 +29,7 @@ * own begin and end times. Some of them may overlap and some of them may * not. */ -class EXPCL_DIRECT CMetaInterval : public CInterval { +class EXPCL_DIRECT_INTERVAL CMetaInterval : public CInterval { PUBLISHED: explicit CMetaInterval(const string &name); virtual ~CMetaInterval(); diff --git a/direct/src/interval/config_interval.h b/direct/src/interval/config_interval.h index 8695f4b140..10af86bfb7 100644 --- a/direct/src/interval/config_interval.h +++ b/direct/src/interval/config_interval.h @@ -20,11 +20,11 @@ #include "configVariableDouble.h" #include "configVariableBool.h" -NotifyCategoryDecl(interval, EXPCL_DIRECT, EXPTP_DIRECT); +NotifyCategoryDecl(interval, EXPCL_DIRECT_INTERVAL, EXPTP_DIRECT_INTERVAL); extern ConfigVariableDouble interval_precision; -extern EXPCL_DIRECT ConfigVariableBool verify_intervals; +extern EXPCL_DIRECT_INTERVAL ConfigVariableBool verify_intervals; -extern EXPCL_DIRECT void init_libinterval(); +extern EXPCL_DIRECT_INTERVAL void init_libinterval(); #endif diff --git a/direct/src/interval/hideInterval.h b/direct/src/interval/hideInterval.h index f2a53307b1..91cd1a9bda 100644 --- a/direct/src/interval/hideInterval.h +++ b/direct/src/interval/hideInterval.h @@ -21,7 +21,7 @@ /** * An interval that calls NodePath::hide(). */ -class EXPCL_DIRECT HideInterval : public CInterval { +class EXPCL_DIRECT_INTERVAL HideInterval : public CInterval { PUBLISHED: explicit HideInterval(const NodePath &node, const string &name = string()); diff --git a/direct/src/interval/lerpblend.h b/direct/src/interval/lerpblend.h index f5c583ace9..d0f0bd8cfc 100644 --- a/direct/src/interval/lerpblend.h +++ b/direct/src/interval/lerpblend.h @@ -17,7 +17,7 @@ #include "directbase.h" #include "typedReferenceCount.h" -class EXPCL_DIRECT LerpBlendType : public TypedReferenceCount { +class EXPCL_DIRECT_INTERVAL LerpBlendType : public TypedReferenceCount { PUBLISHED: LerpBlendType() {} virtual ~LerpBlendType(); @@ -47,7 +47,7 @@ private: static TypeHandle _type_handle; }; -class EXPCL_DIRECT EaseInBlendType : public LerpBlendType { +class EXPCL_DIRECT_INTERVAL EaseInBlendType : public LerpBlendType { PUBLISHED: EaseInBlendType() {} virtual ~EaseInBlendType(); @@ -77,7 +77,7 @@ private: static TypeHandle _type_handle; }; -class EXPCL_DIRECT EaseOutBlendType : public LerpBlendType { +class EXPCL_DIRECT_INTERVAL EaseOutBlendType : public LerpBlendType { PUBLISHED: EaseOutBlendType() {} virtual ~EaseOutBlendType(); @@ -107,7 +107,7 @@ private: static TypeHandle _type_handle; }; -class EXPCL_DIRECT EaseInOutBlendType : public LerpBlendType { +class EXPCL_DIRECT_INTERVAL EaseInOutBlendType : public LerpBlendType { PUBLISHED: EaseInOutBlendType() {} virtual ~EaseInOutBlendType(); @@ -136,7 +136,7 @@ private: static TypeHandle _type_handle; }; -class EXPCL_DIRECT NoBlendType : public LerpBlendType { +class EXPCL_DIRECT_INTERVAL NoBlendType : public LerpBlendType { PUBLISHED: NoBlendType() {} virtual ~NoBlendType(); diff --git a/direct/src/interval/showInterval.h b/direct/src/interval/showInterval.h index 5365581339..bff66d8366 100644 --- a/direct/src/interval/showInterval.h +++ b/direct/src/interval/showInterval.h @@ -21,7 +21,7 @@ /** * An interval that calls NodePath::show(). */ -class EXPCL_DIRECT ShowInterval : public CInterval { +class EXPCL_DIRECT_INTERVAL ShowInterval : public CInterval { PUBLISHED: explicit ShowInterval(const NodePath &node, const string &name = string()); diff --git a/direct/src/interval/waitInterval.h b/direct/src/interval/waitInterval.h index dbf0757843..c3607c27b8 100644 --- a/direct/src/interval/waitInterval.h +++ b/direct/src/interval/waitInterval.h @@ -21,7 +21,7 @@ * This interval does absolutely nothing, and is mainly useful for marking * time between other intervals within a sequence. */ -class EXPCL_DIRECT WaitInterval : public CInterval { +class EXPCL_DIRECT_INTERVAL WaitInterval : public CInterval { PUBLISHED: INLINE explicit WaitInterval(double duration); diff --git a/direct/src/motiontrail/cMotionTrail.h b/direct/src/motiontrail/cMotionTrail.h index ef05b4b1c0..fdb5ba1f56 100644 --- a/direct/src/motiontrail/cMotionTrail.h +++ b/direct/src/motiontrail/cMotionTrail.h @@ -69,7 +69,7 @@ public: * coordinate of the texture corresponds to time and the v coordinate * corresponds to the "shape" of the motion trail. */ -class EXPCL_DIRECT CMotionTrail : public TypedReferenceCount { +class EXPCL_DIRECT_MOTIONTRAIL CMotionTrail : public TypedReferenceCount { PUBLISHED: CMotionTrail(); ~CMotionTrail(); diff --git a/direct/src/motiontrail/config_motiontrail.cxx b/direct/src/motiontrail/config_motiontrail.cxx index c805ae1319..0907457acd 100644 --- a/direct/src/motiontrail/config_motiontrail.cxx +++ b/direct/src/motiontrail/config_motiontrail.cxx @@ -14,7 +14,7 @@ #include "config_motiontrail.h" #include "dconfig.h" -extern EXPCL_DIRECT void init_libmotiontrail(); +extern EXPCL_DIRECT_MOTIONTRAIL void init_libmotiontrail(); Configure(config_motiontrail); NotifyCategoryDef(motiontrail, ""); diff --git a/direct/src/motiontrail/config_motiontrail.h b/direct/src/motiontrail/config_motiontrail.h index 79c516d41c..918c839612 100644 --- a/direct/src/motiontrail/config_motiontrail.h +++ b/direct/src/motiontrail/config_motiontrail.h @@ -20,8 +20,8 @@ #include "cMotionTrail.h" -NotifyCategoryDecl(motiontrail, EXPCL_DIRECT, EXPTP_DIRECT); +NotifyCategoryDecl(motiontrail, EXPCL_DIRECT_MOTIONTRAIL, EXPTP_DIRECT_MOTIONTRAIL); -extern EXPCL_DIRECT void init_libmotiontrail(); +extern EXPCL_DIRECT_MOTIONTRAIL void init_libmotiontrail(); #endif diff --git a/direct/src/showbase/showBase.h b/direct/src/showbase/showBase.h index 2347800789..a38a791d3b 100644 --- a/direct/src/showbase/showBase.h +++ b/direct/src/showbase/showBase.h @@ -26,7 +26,7 @@ #include "configVariableSearchPath.h" #include "nodePath.h" -ConfigureDecl(config_showbase, EXPCL_DIRECT, EXPTP_DIRECT); +ConfigureDecl(config_showbase, EXPCL_DIRECT_SHOWBASE, EXPTP_DIRECT_SHOWBASE); class CollisionTraverser; class Camera; @@ -34,24 +34,24 @@ class GraphicsEngine; BEGIN_PUBLISH -EXPCL_DIRECT ConfigVariableSearchPath &get_particle_path(); +EXPCL_DIRECT_SHOWBASE ConfigVariableSearchPath &get_particle_path(); -EXPCL_DIRECT void throw_new_frame(); +EXPCL_DIRECT_SHOWBASE void throw_new_frame(); -EXPCL_DIRECT DConfig &get_config_showbase(); -EXPCL_DIRECT void init_app_for_gui(); +EXPCL_DIRECT_SHOWBASE DConfig &get_config_showbase(); +EXPCL_DIRECT_SHOWBASE void init_app_for_gui(); // klunky interface since we cant pass array from python->C++ -EXPCL_DIRECT void add_fullscreen_testsize(int xsize, int ysize); -EXPCL_DIRECT void runtest_fullscreen_sizes(GraphicsWindow *win); -EXPCL_DIRECT bool query_fullscreen_testresult(int xsize, int ysize); +EXPCL_DIRECT_SHOWBASE void add_fullscreen_testsize(int xsize, int ysize); +EXPCL_DIRECT_SHOWBASE void runtest_fullscreen_sizes(GraphicsWindow *win); +EXPCL_DIRECT_SHOWBASE bool query_fullscreen_testresult(int xsize, int ysize); // to handle windows stickykeys -EXPCL_DIRECT void store_accessibility_shortcut_keys(); -EXPCL_DIRECT void allow_accessibility_shortcut_keys(bool allowKeys); +EXPCL_DIRECT_SHOWBASE void store_accessibility_shortcut_keys(); +EXPCL_DIRECT_SHOWBASE void allow_accessibility_shortcut_keys(bool allowKeys); #ifdef IS_OSX -EXPCL_DIRECT void activate_osx_application(); +EXPCL_DIRECT_SHOWBASE void activate_osx_application(); #endif END_PUBLISH From 9dd37e9dbc361055b64003509275d97784120e84 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 16 Mar 2018 19:51:56 -0600 Subject: [PATCH 114/247] general: Add guards to ensure proper BUILDING_ macros defined This is designed to sanity-check the buildsystem, ensuring that the expected BUILDING_ macros are defined at the expected time. It also helps catch cases where the wrong BUILDING_/EXPCL_ macros are used. --- direct/src/deadrec/config_deadrec.cxx | 4 ++++ direct/src/directd/directd.cxx | 4 ++++ direct/src/distributed/config_distributed.cxx | 4 ++++ direct/src/interval/config_interval.cxx | 4 ++++ direct/src/motiontrail/config_motiontrail.cxx | 4 ++++ direct/src/showbase/showBase.cxx | 4 ++++ dtool/src/dconfig/config_dconfig.cxx | 4 ++++ dtool/src/dtoolbase/dtoolbase.cxx | 4 ++++ dtool/src/dtoolutil/config_dtoolutil.cxx | 4 ++++ dtool/src/prc/config_prc.cxx | 4 ++++ panda/metalibs/panda/panda.cxx | 4 ++++ panda/src/audio/config_audio.cxx | 4 ++++ panda/src/audiotraits/config_fmodAudio.cxx | 4 ++++ panda/src/audiotraits/config_milesAudio.cxx | 4 ++++ panda/src/audiotraits/config_openalAudio.cxx | 4 ++++ panda/src/awesomium/config_awesomium.cxx | 4 ++++ panda/src/bullet/config_bullet.cxx | 4 ++++ panda/src/chan/config_chan.cxx | 4 ++++ panda/src/char/config_char.cxx | 4 ++++ panda/src/cocoadisplay/config_cocoadisplay.mm | 4 ++++ panda/src/collada/config_collada.cxx | 4 ++++ panda/src/collide/config_collide.cxx | 4 ++++ panda/src/cull/config_cull.cxx | 4 ++++ panda/src/device/config_device.cxx | 4 ++++ panda/src/dgraph/config_dgraph.cxx | 4 ++++ panda/src/display/config_display.cxx | 4 ++++ panda/src/distort/config_distort.cxx | 4 ++++ panda/src/downloader/config_downloader.cxx | 4 ++++ panda/src/dxgsg9/config_dxgsg9.cxx | 4 ++++ panda/src/dxml/config_dxml.cxx | 4 ++++ panda/src/egg/config_egg.cxx | 4 ++++ panda/src/egg2pg/config_egg2pg.cxx | 4 ++++ panda/src/egldisplay/config_egldisplay.cxx | 4 ++++ panda/src/event/config_event.cxx | 4 ++++ panda/src/express/config_express.cxx | 4 ++++ panda/src/ffmpeg/config_ffmpeg.cxx | 4 ++++ panda/src/framework/config_framework.cxx | 4 ++++ panda/src/gles2gsg/config_gles2gsg.cxx | 4 ++++ panda/src/glesgsg/config_glesgsg.cxx | 4 ++++ panda/src/glgsg/config_glgsg.cxx | 4 ++++ panda/src/glxdisplay/config_glxdisplay.cxx | 4 ++++ panda/src/gobj/config_gobj.cxx | 4 ++++ panda/src/grutil/config_grutil.cxx | 4 ++++ panda/src/gsgbase/config_gsgbase.cxx | 4 ++++ panda/src/linmath/config_linmath.cxx | 4 ++++ panda/src/mathutil/config_mathutil.cxx | 4 ++++ panda/src/movies/config_movies.cxx | 4 ++++ panda/src/nativenet/config_nativenet.cxx | 4 ++++ panda/src/net/config_net.cxx | 4 ++++ panda/src/ode/config_ode.cxx | 4 ++++ panda/src/osxdisplay/config_osxdisplay.cxx | 4 ++++ panda/src/parametrics/config_parametrics.cxx | 4 ++++ panda/src/particlesystem/config_particlesystem.cxx | 4 ++++ panda/src/pgraph/config_pgraph.cxx | 4 ++++ panda/src/pgraphnodes/config_pgraphnodes.cxx | 4 ++++ panda/src/pgui/config_pgui.cxx | 4 ++++ panda/src/physics/config_physics.cxx | 4 ++++ panda/src/physx/config_physx.cxx | 4 ++++ panda/src/pipeline/config_pipeline.cxx | 4 ++++ panda/src/pnmimage/config_pnmimage.cxx | 4 ++++ panda/src/pnmimagetypes/config_pnmimagetypes.cxx | 4 ++++ panda/src/pnmtext/config_pnmtext.cxx | 4 ++++ panda/src/pstatclient/config_pstats.cxx | 4 ++++ panda/src/putil/config_util.cxx | 4 ++++ panda/src/recorder/config_recorder.cxx | 4 ++++ panda/src/rocket/config_rocket.cxx | 4 ++++ panda/src/skel/config_skel.cxx | 4 ++++ panda/src/speedtree/config_speedtree.cxx | 4 ++++ panda/src/text/config_text.cxx | 4 ++++ panda/src/tform/config_tform.cxx | 4 ++++ panda/src/tinydisplay/config_tinydisplay.cxx | 4 ++++ panda/src/vision/config_vision.cxx | 4 ++++ panda/src/vrpn/config_vrpn.cxx | 4 ++++ panda/src/wgldisplay/config_wgldisplay.cxx | 4 ++++ panda/src/windisplay/config_windisplay.cxx | 4 ++++ panda/src/x11display/config_x11display.cxx | 4 ++++ 76 files changed, 304 insertions(+) diff --git a/direct/src/deadrec/config_deadrec.cxx b/direct/src/deadrec/config_deadrec.cxx index 72c8c15a14..eb1c43a9c6 100644 --- a/direct/src/deadrec/config_deadrec.cxx +++ b/direct/src/deadrec/config_deadrec.cxx @@ -15,6 +15,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_DEADREC) + #error Buildsystem error: BUILDING_DIRECT_DEADREC not defined +#endif + Configure(config_deadrec); NotifyCategoryDef(deadrec, ""); diff --git a/direct/src/directd/directd.cxx b/direct/src/directd/directd.cxx index 111a4fd847..1b4601fc41 100644 --- a/direct/src/directd/directd.cxx +++ b/direct/src/directd/directd.cxx @@ -30,6 +30,10 @@ #include "pset.h" +#if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_DIRECTD) + #error Buildsystem error: BUILDING_DIRECT_DIRECTD not defined +#endif + namespace { // ...This section is part of the old stuff from the original // implementation. The new stuff that uses job objects doesn't need this diff --git a/direct/src/distributed/config_distributed.cxx b/direct/src/distributed/config_distributed.cxx index 9420bd05df..312964568f 100644 --- a/direct/src/distributed/config_distributed.cxx +++ b/direct/src/distributed/config_distributed.cxx @@ -14,6 +14,10 @@ #include "config_distributed.h" #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_DISTRIBUTED) + #error Buildsystem error: BUILDING_DIRECT_DISTRIBUTED not defined +#endif + Configure(config_distributed); NotifyCategoryDef(distributed, ""); diff --git a/direct/src/interval/config_interval.cxx b/direct/src/interval/config_interval.cxx index d88711c8b9..f56ce67e17 100644 --- a/direct/src/interval/config_interval.cxx +++ b/direct/src/interval/config_interval.cxx @@ -29,6 +29,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_INTERVAL) + #error Buildsystem error: BUILDING_DIRECT_INTERVAL not defined +#endif + Configure(config_interval); NotifyCategoryDef(interval, ""); diff --git a/direct/src/motiontrail/config_motiontrail.cxx b/direct/src/motiontrail/config_motiontrail.cxx index 0907457acd..997a1a3059 100644 --- a/direct/src/motiontrail/config_motiontrail.cxx +++ b/direct/src/motiontrail/config_motiontrail.cxx @@ -14,6 +14,10 @@ #include "config_motiontrail.h" #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_MOTIONTRAIL) + #error Buildsystem error: BUILDING_DIRECT_MOTIONTRAIL not defined +#endif + extern EXPCL_DIRECT_MOTIONTRAIL void init_libmotiontrail(); Configure(config_motiontrail); diff --git a/direct/src/showbase/showBase.cxx b/direct/src/showbase/showBase.cxx index fabc7a9497..12aa08d4bd 100644 --- a/direct/src/showbase/showBase.cxx +++ b/direct/src/showbase/showBase.cxx @@ -34,6 +34,10 @@ TOGGLEKEYS g_StartupToggleKeys = {sizeof(TOGGLEKEYS), 0}; FILTERKEYS g_StartupFilterKeys = {sizeof(FILTERKEYS), 0}; #endif +#if !defined(CPPPARSER) && !defined(BUILDING_DIRECT_SHOWBASE) + #error Buildsystem error: BUILDING_DIRECT_SHOWBASE not defined +#endif + ConfigureDef(config_showbase); ConfigureFn(config_showbase) { } diff --git a/dtool/src/dconfig/config_dconfig.cxx b/dtool/src/dconfig/config_dconfig.cxx index 49708e719a..d0800084ca 100644 --- a/dtool/src/dconfig/config_dconfig.cxx +++ b/dtool/src/dconfig/config_dconfig.cxx @@ -13,5 +13,9 @@ #include "config_dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_DTOOL_DCONFIG) + #error Buildsystem error: BUILDING_DTOOL_DCONFIG not defined +#endif + NotifyCategoryDef(dconfig, ""); NotifyCategoryDef(microconfig, "dconfig"); diff --git a/dtool/src/dtoolbase/dtoolbase.cxx b/dtool/src/dtoolbase/dtoolbase.cxx index 75f25ad253..64b7425057 100644 --- a/dtool/src/dtoolbase/dtoolbase.cxx +++ b/dtool/src/dtoolbase/dtoolbase.cxx @@ -14,6 +14,10 @@ #include "dtoolbase.h" #include "memoryHook.h" +#if !defined(CPPPARSER) && !defined(BUILDING_DTOOL_DTOOLBASE) + #error Buildsystem error: BUILDING_DTOOL_DTOOLBASE not defined +#endif + #if defined(USE_TAU) && defined(WIN32) // Hack around tau's lack of DLL export declarations for Profiler class. bool __tau_shutdown = false; diff --git a/dtool/src/dtoolutil/config_dtoolutil.cxx b/dtool/src/dtoolutil/config_dtoolutil.cxx index eb45fa2f3e..98b3c42760 100644 --- a/dtool/src/dtoolutil/config_dtoolutil.cxx +++ b/dtool/src/dtoolutil/config_dtoolutil.cxx @@ -16,6 +16,10 @@ #include "filename.h" #include "pandaSystem.h" +#if !defined(CPPPARSER) && !defined(BUILDING_DTOOL_DTOOLUTIL) + #error Buildsystem error: BUILDING_DTOOL_DCTOOLUTIL not defined +#endif + /** * Initializes the library. This must be called at least once before any of * the functions or classes in this library can be used. Normally it will be diff --git a/dtool/src/prc/config_prc.cxx b/dtool/src/prc/config_prc.cxx index f2a57d1993..2728e642bd 100644 --- a/dtool/src/prc/config_prc.cxx +++ b/dtool/src/prc/config_prc.cxx @@ -16,6 +16,10 @@ #include "configVariableEnum.h" #include "pandaFileStreamBuf.h" +#if !defined(CPPPARSER) && !defined(BUILDING_DTOOL_PRC) + #error Buildsystem error: BUILDING_DTOOL_PRC not defined +#endif + NotifyCategoryDef(prc, ""); ALIGN_16BYTE ConfigVariableBool assert_abort diff --git a/panda/metalibs/panda/panda.cxx b/panda/metalibs/panda/panda.cxx index 67620867e3..d3a3b0c24a 100644 --- a/panda/metalibs/panda/panda.cxx +++ b/panda/metalibs/panda/panda.cxx @@ -20,6 +20,10 @@ #include "checkPandaVersion.h" +#if !defined(CPPPARSER) && !defined(BUILDING_LIBPANDA) + #error Buildsystem error: BUILDING_LIBPANDA not defined +#endif + /** * Initializes the library. This must be called at least once before any of * the functions or classes in this library can be used. Normally it will be diff --git a/panda/src/audio/config_audio.cxx b/panda/src/audio/config_audio.cxx index e59b3c73ef..0f58e56a32 100644 --- a/panda/src/audio/config_audio.cxx +++ b/panda/src/audio/config_audio.cxx @@ -21,6 +21,10 @@ #include "nullAudioSound.h" #include "string_utils.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_AUDIO) + #error Buildsystem error: BUILDING_PANDA_AUDIO not defined +#endif + Configure(config_audio); NotifyCategoryDef(audio, ""); diff --git a/panda/src/audiotraits/config_fmodAudio.cxx b/panda/src/audiotraits/config_fmodAudio.cxx index affc593636..f0a188fbc5 100644 --- a/panda/src/audiotraits/config_fmodAudio.cxx +++ b/panda/src/audiotraits/config_fmodAudio.cxx @@ -19,6 +19,10 @@ #include "pandaSystem.h" #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_FMOD_AUDIO) + #error Buildsystem error: BUILDING_FMOD_AUDIO not defined +#endif + ConfigureDef(config_fmodAudio); NotifyCategoryDef(fmodAudio, ":audio"); diff --git a/panda/src/audiotraits/config_milesAudio.cxx b/panda/src/audiotraits/config_milesAudio.cxx index 6f3f29dddb..6877b3700e 100644 --- a/panda/src/audiotraits/config_milesAudio.cxx +++ b/panda/src/audiotraits/config_milesAudio.cxx @@ -22,6 +22,10 @@ #include "pandaSystem.h" #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_MILES_AUDIO) + #error Buildsystem error: BUILDING_MILES_AUDIO not defined +#endif + ConfigureDef(config_milesAudio); NotifyCategoryDef(milesAudio, ":audio"); diff --git a/panda/src/audiotraits/config_openalAudio.cxx b/panda/src/audiotraits/config_openalAudio.cxx index a3340477c2..ad51368d75 100644 --- a/panda/src/audiotraits/config_openalAudio.cxx +++ b/panda/src/audiotraits/config_openalAudio.cxx @@ -18,6 +18,10 @@ #include "pandaSystem.h" #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_OPENAL_AUDIO) + #error Buildsystem error: BUILDING_OPENAL_AUDIO not defined +#endif + ConfigureDef(config_openalAudio); NotifyCategoryDef(openalAudio, ":audio"); diff --git a/panda/src/awesomium/config_awesomium.cxx b/panda/src/awesomium/config_awesomium.cxx index 4462dce983..95ce655fe7 100644 --- a/panda/src/awesomium/config_awesomium.cxx +++ b/panda/src/awesomium/config_awesomium.cxx @@ -18,6 +18,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDAAWESOMIUM) + #error Buildsystem error: BUILDING_PANDAAWESOMIUM not defined +#endif + Configure(config_awesomium); NotifyCategoryDef(awesomium, ""); diff --git a/panda/src/bullet/config_bullet.cxx b/panda/src/bullet/config_bullet.cxx index 9878a9f038..4e228427b9 100644 --- a/panda/src/bullet/config_bullet.cxx +++ b/panda/src/bullet/config_bullet.cxx @@ -56,6 +56,10 @@ extern ContactDestroyedCallback gContactDestroyedCallback; #include "dconfig.h" #include "pandaSystem.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDABULLET) + #error Buildsystem error: BUILDING_PANDABULLET not defined +#endif + Configure(config_bullet); NotifyCategoryDef(bullet, ""); diff --git a/panda/src/chan/config_chan.cxx b/panda/src/chan/config_chan.cxx index 9772f2d661..8992cfbbf9 100644 --- a/panda/src/chan/config_chan.cxx +++ b/panda/src/chan/config_chan.cxx @@ -34,6 +34,10 @@ #include "luse.h" #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_CHAN) + #error Buildsystem error: BUILDING_PANDA_CHAN not defined +#endif + Configure(config_chan); NotifyCategoryDef(chan, ""); diff --git a/panda/src/char/config_char.cxx b/panda/src/char/config_char.cxx index f3a8cc6836..5d536bfc4c 100644 --- a/panda/src/char/config_char.cxx +++ b/panda/src/char/config_char.cxx @@ -21,6 +21,10 @@ #include "jointVertexTransform.h" #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_CHAR) + #error Buildsystem error: BUILDING_PANDA_CHAR not defined +#endif + Configure(config_char); NotifyCategoryDef(char, ""); diff --git a/panda/src/cocoadisplay/config_cocoadisplay.mm b/panda/src/cocoadisplay/config_cocoadisplay.mm index 42f2f98a8f..c88177cf66 100644 --- a/panda/src/cocoadisplay/config_cocoadisplay.mm +++ b/panda/src/cocoadisplay/config_cocoadisplay.mm @@ -20,6 +20,10 @@ #include "dconfig.h" #include "pandaSystem.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDAGL) + #error Buildsystem error: BUILDING_PANDAGL not defined +#endif + Configure(config_cocoadisplay); NotifyCategoryDef(cocoadisplay, "display"); diff --git a/panda/src/collada/config_collada.cxx b/panda/src/collada/config_collada.cxx index 81404110f2..fa97023656 100644 --- a/panda/src/collada/config_collada.cxx +++ b/panda/src/collada/config_collada.cxx @@ -17,6 +17,10 @@ #include "loaderFileTypeDae.h" #include "loaderFileTypeRegistry.h" +#if !defined(CPPPARSER) && !defined(BUILDING_COLLADA) + #error Buildsystem error: BUILDING_COLLADA not defined +#endif + ConfigureDef(config_collada); NotifyCategoryDef(collada, ""); diff --git a/panda/src/collide/config_collide.cxx b/panda/src/collide/config_collide.cxx index e1999cd147..01d517df04 100644 --- a/panda/src/collide/config_collide.cxx +++ b/panda/src/collide/config_collide.cxx @@ -42,6 +42,10 @@ #include "collisionVisualizer.h" #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_COLLIDE) + #error Buildsystem error: BUILDING_PANDA_COLLIDE not defined +#endif + Configure(config_collide); NotifyCategoryDef(collide, ""); diff --git a/panda/src/cull/config_cull.cxx b/panda/src/cull/config_cull.cxx index a3b4b4881a..452c69ea0c 100644 --- a/panda/src/cull/config_cull.cxx +++ b/panda/src/cull/config_cull.cxx @@ -22,6 +22,10 @@ #include "cullBinManager.h" #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_CULL) + #error Buildsystem error: BUILDING_PANDA_CULL not defined +#endif + ConfigureDef(config_cull); NotifyCategoryDef(cull, ""); diff --git a/panda/src/device/config_device.cxx b/panda/src/device/config_device.cxx index 51f1159f33..eb8d1a2f10 100644 --- a/panda/src/device/config_device.cxx +++ b/panda/src/device/config_device.cxx @@ -27,6 +27,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_DEVICE) + #error Buildsystem error: BUILDING_PANDA_DEVICE not defined +#endif + Configure(config_device); NotifyCategoryDef(device, ""); diff --git a/panda/src/dgraph/config_dgraph.cxx b/panda/src/dgraph/config_dgraph.cxx index fbaec8b78d..3c91aeea18 100644 --- a/panda/src/dgraph/config_dgraph.cxx +++ b/panda/src/dgraph/config_dgraph.cxx @@ -17,6 +17,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_DGRAPH) + #error Buildsystem error: BUILDING_PANDA_DGRAPH not defined +#endif + Configure(config_dgraph); NotifyCategoryDef(dgraph, ""); diff --git a/panda/src/display/config_display.cxx b/panda/src/display/config_display.cxx index 391a7e8676..0d3fea3937 100644 --- a/panda/src/display/config_display.cxx +++ b/panda/src/display/config_display.cxx @@ -31,6 +31,10 @@ #include "subprocessWindow.h" #include "windowHandle.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_DISPLAY) + #error Buildsystem error: BUILDING_PANDA_DISPLAY not defined +#endif + ConfigureDef(config_display); NotifyCategoryDef(display, ""); NotifyCategoryDef(gsg, display_cat); diff --git a/panda/src/distort/config_distort.cxx b/panda/src/distort/config_distort.cxx index 7dc7055c3c..eaa0147dae 100644 --- a/panda/src/distort/config_distort.cxx +++ b/panda/src/distort/config_distort.cxx @@ -20,6 +20,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDAFX) + #error Buildsystem error: BUILDING_PANDAFX not defined +#endif + Configure(config_distort); NotifyCategoryDef(distort, ""); diff --git a/panda/src/downloader/config_downloader.cxx b/panda/src/downloader/config_downloader.cxx index c1db208d01..9c806dba07 100644 --- a/panda/src/downloader/config_downloader.cxx +++ b/panda/src/downloader/config_downloader.cxx @@ -19,6 +19,10 @@ #include "pandaSystem.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDAEXPRESS) + #error Buildsystem error: BUILDING_PANDAEXPRESS not defined +#endif + ConfigureDef(config_downloader); NotifyCategoryDef(downloader, ""); diff --git a/panda/src/dxgsg9/config_dxgsg9.cxx b/panda/src/dxgsg9/config_dxgsg9.cxx index 64831d08c9..d5777602db 100644 --- a/panda/src/dxgsg9/config_dxgsg9.cxx +++ b/panda/src/dxgsg9/config_dxgsg9.cxx @@ -27,6 +27,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDADX) + #error Buildsystem error: BUILDING_PANDADX not defined +#endif + DToolConfigure(config_dxgsg9); NotifyCategoryDef(dxgsg9, ":display:gsg"); NotifyCategoryDef(wdxdisplay9, "display"); diff --git a/panda/src/dxml/config_dxml.cxx b/panda/src/dxml/config_dxml.cxx index e6691bc676..7e25a58c3a 100644 --- a/panda/src/dxml/config_dxml.cxx +++ b/panda/src/dxml/config_dxml.cxx @@ -19,6 +19,10 @@ BEGIN_PUBLISH #include "tinyxml.h" END_PUBLISH +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_DXML) + #error Buildsystem error: BUILDING_PANDA_DXML not defined +#endif + Configure(config_dxml); NotifyCategoryDef(dxml, ""); diff --git a/panda/src/egg/config_egg.cxx b/panda/src/egg/config_egg.cxx index 83d11dad04..65e08efcbc 100644 --- a/panda/src/egg/config_egg.cxx +++ b/panda/src/egg/config_egg.cxx @@ -58,6 +58,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDAEGG) + #error Buildsystem error: BUILDING_PANDAEGG not defined +#endif + Configure(config_egg); NotifyCategoryDef(egg, ""); diff --git a/panda/src/egg2pg/config_egg2pg.cxx b/panda/src/egg2pg/config_egg2pg.cxx index 79c3e40a2b..f864a8f4d8 100644 --- a/panda/src/egg2pg/config_egg2pg.cxx +++ b/panda/src/egg2pg/config_egg2pg.cxx @@ -20,6 +20,10 @@ #include "configVariableCore.h" #include "eggRenderState.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDAEGG) + #error Buildsystem error: BUILDING_PANDAEGG not defined +#endif + ConfigureDef(config_egg2pg); NotifyCategoryDef(egg2pg, ""); diff --git a/panda/src/egldisplay/config_egldisplay.cxx b/panda/src/egldisplay/config_egldisplay.cxx index 809e73916c..9f9bf13770 100644 --- a/panda/src/egldisplay/config_egldisplay.cxx +++ b/panda/src/egldisplay/config_egldisplay.cxx @@ -19,6 +19,10 @@ #include "dconfig.h" #include "pandaSystem.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDAGLES) && !defined(BUILDING_PANDAGLES2) + #error Buildsystem error: BUILDING_PANDAGLES(2) not defined +#endif + Configure(config_egldisplay); NotifyCategoryDef(egldisplay, "display"); diff --git a/panda/src/event/config_event.cxx b/panda/src/event/config_event.cxx index 85727d2d7c..c7f1c8eecc 100644 --- a/panda/src/event/config_event.cxx +++ b/panda/src/event/config_event.cxx @@ -27,6 +27,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_EVENT) + #error Buildsystem error: BUILDING_PANDA_EVENT not defined +#endif + Configure(config_event); NotifyCategoryDef(event, ""); NotifyCategoryDef(task, ""); diff --git a/panda/src/express/config_express.cxx b/panda/src/express/config_express.cxx index 042b6d8db1..d86e300436 100644 --- a/panda/src/express/config_express.cxx +++ b/panda/src/express/config_express.cxx @@ -36,6 +36,10 @@ #include "dconfig.h" #include "streamWrapper.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDAEXPRESS) + #error Buildsystem error: BUILDING_PANDAEXPRESS not defined +#endif + ConfigureDef(config_express); NotifyCategoryDef(express, ""); NotifyCategoryDef(clock, ":express"); diff --git a/panda/src/ffmpeg/config_ffmpeg.cxx b/panda/src/ffmpeg/config_ffmpeg.cxx index f0d6a5518e..8cbc9f51ec 100644 --- a/panda/src/ffmpeg/config_ffmpeg.cxx +++ b/panda/src/ffmpeg/config_ffmpeg.cxx @@ -24,6 +24,10 @@ extern "C" { #include "libavcodec/avcodec.h" } +#if !defined(CPPPARSER) && !defined(BUILDING_FFMPEG) + #error Buildsystem error: BUILDING_FFMPEG not defined +#endif + ConfigureDef(config_ffmpeg); NotifyCategoryDef(ffmpeg, ""); diff --git a/panda/src/framework/config_framework.cxx b/panda/src/framework/config_framework.cxx index e5c5d42e70..8746d5bff0 100644 --- a/panda/src/framework/config_framework.cxx +++ b/panda/src/framework/config_framework.cxx @@ -22,6 +22,10 @@ #include "checkPandaVersion.h" +#if !defined(CPPPARSER) && !defined(BUILDING_FRAMEWORK) + #error Buildsystem error: BUILDING_FRAMEWORK not defined +#endif + Configure(config_framework); NotifyCategoryDef(framework, ""); diff --git a/panda/src/gles2gsg/config_gles2gsg.cxx b/panda/src/gles2gsg/config_gles2gsg.cxx index 3935783653..aee9c925fb 100644 --- a/panda/src/gles2gsg/config_gles2gsg.cxx +++ b/panda/src/gles2gsg/config_gles2gsg.cxx @@ -16,6 +16,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDAGLES2) + #error Buildsystem error: BUILDING_PANDAGLES2 not defined +#endif + ConfigureDef(config_gles2gsg); NotifyCategoryDef(gles2gsg, ":display:gsg"); diff --git a/panda/src/glesgsg/config_glesgsg.cxx b/panda/src/glesgsg/config_glesgsg.cxx index a1c0496cfc..b30cf23322 100644 --- a/panda/src/glesgsg/config_glesgsg.cxx +++ b/panda/src/glesgsg/config_glesgsg.cxx @@ -16,6 +16,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDAGLES) + #error Buildsystem error: BUILDING_PANDAGLES not defined +#endif + ConfigureDef(config_glesgsg); NotifyCategoryDef(glesgsg, ":display:gsg"); diff --git a/panda/src/glgsg/config_glgsg.cxx b/panda/src/glgsg/config_glgsg.cxx index 8f98e49717..6e60169acc 100644 --- a/panda/src/glgsg/config_glgsg.cxx +++ b/panda/src/glgsg/config_glgsg.cxx @@ -16,6 +16,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDAGL) + #error Buildsystem error: BUILDING_PANDAGL not defined +#endif + ConfigureDef(config_glgsg); NotifyCategoryDef(glgsg, ":display:gsg"); diff --git a/panda/src/glxdisplay/config_glxdisplay.cxx b/panda/src/glxdisplay/config_glxdisplay.cxx index b253c0abf9..fffcd2c264 100644 --- a/panda/src/glxdisplay/config_glxdisplay.cxx +++ b/panda/src/glxdisplay/config_glxdisplay.cxx @@ -23,6 +23,10 @@ #include "dconfig.h" #include "pandaSystem.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDAGL) + #error Buildsystem error: BUILDING_PANDAGL not defined +#endif + Configure(config_glxdisplay); NotifyCategoryDef(glxdisplay, "display"); diff --git a/panda/src/gobj/config_gobj.cxx b/panda/src/gobj/config_gobj.cxx index 058d7463a4..d152f6ebcf 100644 --- a/panda/src/gobj/config_gobj.cxx +++ b/panda/src/gobj/config_gobj.cxx @@ -70,6 +70,10 @@ #include "dconfig.h" #include "string_utils.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_GOBJ) + #error Buildsystem error: BUILDING_PANDA_GOBJ not defined +#endif + Configure(config_gobj); NotifyCategoryDef(gobj, ""); NotifyCategoryDef(shader, ""); diff --git a/panda/src/grutil/config_grutil.cxx b/panda/src/grutil/config_grutil.cxx index 94613f4da6..337abd11bb 100644 --- a/panda/src/grutil/config_grutil.cxx +++ b/panda/src/grutil/config_grutil.cxx @@ -27,6 +27,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_GRUTIL) + #error Buildsystem error: BUILDING_PANDA_GRUTIL not defined +#endif + Configure(config_grutil); NotifyCategoryDef(grutil, ""); diff --git a/panda/src/gsgbase/config_gsgbase.cxx b/panda/src/gsgbase/config_gsgbase.cxx index 2e5ce60aa9..52da83f9c8 100644 --- a/panda/src/gsgbase/config_gsgbase.cxx +++ b/panda/src/gsgbase/config_gsgbase.cxx @@ -17,6 +17,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_GSGBASE) + #error Buildsystem error: BUILDING_PANDA_GSGBASE not defined +#endif + Configure(config_gsgbase); ConfigureFn(config_gsgbase) { diff --git a/panda/src/linmath/config_linmath.cxx b/panda/src/linmath/config_linmath.cxx index 93cf571c40..fb0942aa55 100644 --- a/panda/src/linmath/config_linmath.cxx +++ b/panda/src/linmath/config_linmath.cxx @@ -17,6 +17,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_LINMATH) + #error Buildsystem error: BUILDING_PANDA_LINMATH not defined +#endif + Configure(config_linmath); NotifyCategoryDef(linmath, ""); diff --git a/panda/src/mathutil/config_mathutil.cxx b/panda/src/mathutil/config_mathutil.cxx index 2226b67946..2084b2b670 100644 --- a/panda/src/mathutil/config_mathutil.cxx +++ b/panda/src/mathutil/config_mathutil.cxx @@ -26,6 +26,10 @@ #include "dconfig.h" #include "pandaSystem.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_MATHUTIL) + #error Buildsystem error: BUILDING_PANDA_MATHUTIL not defined +#endif + Configure(config_mathutil); NotifyCategoryDef(mathutil, ""); diff --git a/panda/src/movies/config_movies.cxx b/panda/src/movies/config_movies.cxx index 4884c15f5b..93448cfe8d 100644 --- a/panda/src/movies/config_movies.cxx +++ b/panda/src/movies/config_movies.cxx @@ -32,6 +32,10 @@ #include "wavAudio.h" #include "wavAudioCursor.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_MOVIES) + #error Buildsystem error: BUILDING_PANDA_MOVIES not defined +#endif + ConfigureDef(config_movies); NotifyCategoryDef(movies, ""); diff --git a/panda/src/nativenet/config_nativenet.cxx b/panda/src/nativenet/config_nativenet.cxx index c74a8ca6e2..172e56afa8 100644 --- a/panda/src/nativenet/config_nativenet.cxx +++ b/panda/src/nativenet/config_nativenet.cxx @@ -26,6 +26,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_NATIVENET) + #error Buildsystem error: BUILDING_PANDA_NATIVENET not defined +#endif + Configure(config_nativenet); NotifyCategoryDef(nativenet, ""); diff --git a/panda/src/net/config_net.cxx b/panda/src/net/config_net.cxx index aafea6fc49..ae717bb580 100644 --- a/panda/src/net/config_net.cxx +++ b/panda/src/net/config_net.cxx @@ -18,6 +18,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_NET) + #error Buildsystem error: BUILDING_PANDA_NET not defined +#endif + Configure(config_net); NotifyCategoryDef(net, ""); diff --git a/panda/src/ode/config_ode.cxx b/panda/src/ode/config_ode.cxx index 1994fe1254..214281d579 100644 --- a/panda/src/ode/config_ode.cxx +++ b/panda/src/ode/config_ode.cxx @@ -47,6 +47,10 @@ #include "odeCollisionEntry.h" #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDAODE) + #error Buildsystem error: BUILDING_PANDAODE not defined +#endif + Configure(config_ode); NotifyCategoryDef(ode, ""); NotifyCategoryDef(odeworld, "ode"); diff --git a/panda/src/osxdisplay/config_osxdisplay.cxx b/panda/src/osxdisplay/config_osxdisplay.cxx index 943fe57937..4ac68f5e58 100644 --- a/panda/src/osxdisplay/config_osxdisplay.cxx +++ b/panda/src/osxdisplay/config_osxdisplay.cxx @@ -20,6 +20,10 @@ #include "pandaSystem.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDAGL) + #error Buildsystem error: BUILDING_PANDAGL not defined +#endif + Configure(config_osxdisplay); NotifyCategoryDef(osxdisplay, "display"); diff --git a/panda/src/parametrics/config_parametrics.cxx b/panda/src/parametrics/config_parametrics.cxx index 93a6e3841f..2b07e493bd 100644 --- a/panda/src/parametrics/config_parametrics.cxx +++ b/panda/src/parametrics/config_parametrics.cxx @@ -22,6 +22,10 @@ #include "ropeNode.h" #include "sheetNode.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PARAMETRICS) + #error Buildsystem error: BUILDING_PANDA_PARAMETRICS not defined +#endif + Configure(config_parametrics); NotifyCategoryDef(parametrics, ""); diff --git a/panda/src/particlesystem/config_particlesystem.cxx b/panda/src/particlesystem/config_particlesystem.cxx index 9c2d9e6a09..0eba6c33f1 100644 --- a/panda/src/particlesystem/config_particlesystem.cxx +++ b/panda/src/particlesystem/config_particlesystem.cxx @@ -16,6 +16,10 @@ #include "geomParticleRenderer.h" #include "geomNode.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDAPHYSICS) + #error Buildsystem error: BUILDING_PANDAPHYSICS not defined +#endif + ConfigureDef(config_particlesystem); NotifyCategoryDef(particlesystem, ""); diff --git a/panda/src/pgraph/config_pgraph.cxx b/panda/src/pgraph/config_pgraph.cxx index 237c1d0011..54fa621f7b 100644 --- a/panda/src/pgraph/config_pgraph.cxx +++ b/panda/src/pgraph/config_pgraph.cxx @@ -92,6 +92,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PGRAPH) + #error Buildsystem error: BUILDING_PANDA_PGRAPH not defined +#endif + ConfigureDef(config_pgraph); NotifyCategoryDef(pgraph, ""); NotifyCategoryDef(loader, ""); diff --git a/panda/src/pgraphnodes/config_pgraphnodes.cxx b/panda/src/pgraphnodes/config_pgraphnodes.cxx index f512110858..3879a980b3 100644 --- a/panda/src/pgraphnodes/config_pgraphnodes.cxx +++ b/panda/src/pgraphnodes/config_pgraphnodes.cxx @@ -37,6 +37,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PGRAPHNODES) + #error Buildsystem error: BUILDING_PANDA_PGRAPHNODES not defined +#endif + ConfigureDef(config_pgraphnodes); NotifyCategoryDef(pgraphnodes, ""); diff --git a/panda/src/pgui/config_pgui.cxx b/panda/src/pgui/config_pgui.cxx index 7a1682cc96..c2c3e72405 100644 --- a/panda/src/pgui/config_pgui.cxx +++ b/panda/src/pgui/config_pgui.cxx @@ -28,6 +28,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PGUI) + #error Buildsystem error: BUILDING_PANDA_PGUI not defined +#endif + Configure(config_pgui); NotifyCategoryDef(pgui, ""); diff --git a/panda/src/physics/config_physics.cxx b/panda/src/physics/config_physics.cxx index c0db4dcdf4..5ce5c905f0 100644 --- a/panda/src/physics/config_physics.cxx +++ b/panda/src/physics/config_physics.cxx @@ -26,6 +26,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDAPHYSICS) + #error Buildsystem error: BUILDING_PANDAPHYSICS not defined +#endif + ConfigureDef(config_physics); NotifyCategoryDef(physics, ""); diff --git a/panda/src/physx/config_physx.cxx b/panda/src/physx/config_physx.cxx index e7a4a653e1..4880e37e88 100644 --- a/panda/src/physx/config_physx.cxx +++ b/panda/src/physx/config_physx.cxx @@ -67,6 +67,10 @@ #include "physxWheel.h" #include "physxWheelShape.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDAPHYSX) + #error Buildsystem error: BUILDING_PANDAPHYSX not defined +#endif + ConfigureDef(config_physx); NotifyCategoryDef(physx, ""); diff --git a/panda/src/pipeline/config_pipeline.cxx b/panda/src/pipeline/config_pipeline.cxx index 6dc24178f0..8f82307c86 100644 --- a/panda/src/pipeline/config_pipeline.cxx +++ b/panda/src/pipeline/config_pipeline.cxx @@ -20,6 +20,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PIPELINE) + #error Buildsystem error: BUILDING_PANDA_PIPELINE not defined +#endif + ConfigureDef(config_pipeline); NotifyCategoryDef(pipeline, ""); NotifyCategoryDef(thread, ""); diff --git a/panda/src/pnmimage/config_pnmimage.cxx b/panda/src/pnmimage/config_pnmimage.cxx index 1cb8b24bf8..5bb734cf85 100644 --- a/panda/src/pnmimage/config_pnmimage.cxx +++ b/panda/src/pnmimage/config_pnmimage.cxx @@ -17,6 +17,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PNMIMAGE) + #error Buildsystem error: BUILDING_PANDA_PNMIMAGE not defined +#endif + Configure(config_pnmimage); NotifyCategoryDef(pnmimage, ""); diff --git a/panda/src/pnmimagetypes/config_pnmimagetypes.cxx b/panda/src/pnmimagetypes/config_pnmimagetypes.cxx index 2fc23d574a..b115aa5213 100644 --- a/panda/src/pnmimagetypes/config_pnmimagetypes.cxx +++ b/panda/src/pnmimagetypes/config_pnmimagetypes.cxx @@ -32,6 +32,10 @@ #include "dconfig.h" #include "pandaSystem.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PNMIMAGETYPES) + #error Buildsystem error: BUILDING_PANDA_PNMIMAGETYPES not defined +#endif + Configure(config_pnmimagetypes); NotifyCategoryDefName(pnmimage_sgi, "sgi", pnmimage_cat); NotifyCategoryDefName(pnmimage_tga, "tga", pnmimage_cat); diff --git a/panda/src/pnmtext/config_pnmtext.cxx b/panda/src/pnmtext/config_pnmtext.cxx index b806b8d048..a0a627aca7 100644 --- a/panda/src/pnmtext/config_pnmtext.cxx +++ b/panda/src/pnmtext/config_pnmtext.cxx @@ -16,6 +16,10 @@ #include "dconfig.h" #include "freetypeFace.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PNMTEXT) + #error Buildsystem error: BUILDING_PANDA_PNMTEXT not defined +#endif + Configure(config_pnmtext); NotifyCategoryDef(pnmtext, ""); diff --git a/panda/src/pstatclient/config_pstats.cxx b/panda/src/pstatclient/config_pstats.cxx index 4a25d9e85c..dcd49a4365 100644 --- a/panda/src/pstatclient/config_pstats.cxx +++ b/panda/src/pstatclient/config_pstats.cxx @@ -15,6 +15,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PSTATCLIENT) + #error Buildsystem error: BUILDING_PANDA_PSTATCLIENT not defined +#endif + ConfigureDef(config_pstats); NotifyCategoryDef(pstats, ""); diff --git a/panda/src/putil/config_util.cxx b/panda/src/putil/config_util.cxx index 516c98ce6a..c5956adc2b 100644 --- a/panda/src/putil/config_util.cxx +++ b/panda/src/putil/config_util.cxx @@ -47,6 +47,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_PUTIL) + #error Buildsystem error: BUILDING_PANDA_PUTIL not defined +#endif + ConfigureDef(config_util); NotifyCategoryDef(util, ""); NotifyCategoryDef(bam, util_cat); diff --git a/panda/src/recorder/config_recorder.cxx b/panda/src/recorder/config_recorder.cxx index 6057362134..97335e17cd 100644 --- a/panda/src/recorder/config_recorder.cxx +++ b/panda/src/recorder/config_recorder.cxx @@ -22,6 +22,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_RECORDER) + #error Buildsystem error: BUILDING_PANDA_RECORDER not defined +#endif + ConfigureDef(config_recorder); NotifyCategoryDef(recorder, ""); diff --git a/panda/src/rocket/config_rocket.cxx b/panda/src/rocket/config_rocket.cxx index b4a43f8127..4de7bf3e28 100644 --- a/panda/src/rocket/config_rocket.cxx +++ b/panda/src/rocket/config_rocket.cxx @@ -26,6 +26,10 @@ #include #undef Factory +#if !defined(CPPPARSER) && !defined(BUILDING_ROCKET) + #error Buildsystem error: BUILDING_ROCKET not defined +#endif + Configure(config_rocket); NotifyCategoryDef(rocket, ""); diff --git a/panda/src/skel/config_skel.cxx b/panda/src/skel/config_skel.cxx index 2c307d3270..5fa6f6595c 100644 --- a/panda/src/skel/config_skel.cxx +++ b/panda/src/skel/config_skel.cxx @@ -16,6 +16,10 @@ #include "typedSkel.h" #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDASKEL) + #error Buildsystem error: BUILDING_PANDASKEL not defined +#endif + Configure(config_skel); NotifyCategoryDef(skel, ""); diff --git a/panda/src/speedtree/config_speedtree.cxx b/panda/src/speedtree/config_speedtree.cxx index fd4eb3cd5a..b386bcb59a 100644 --- a/panda/src/speedtree/config_speedtree.cxx +++ b/panda/src/speedtree/config_speedtree.cxx @@ -21,6 +21,10 @@ #include "loaderFileTypeRegistry.h" #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDASPEEDTREE) + #error Buildsystem error: BUILDING_PANDASPEEDTREE not defined +#endif + ConfigureDef(config_speedtree); NotifyCategoryDef(speedtree, ""); diff --git a/panda/src/text/config_text.cxx b/panda/src/text/config_text.cxx index 9475eabf55..2fff80cd0c 100644 --- a/panda/src/text/config_text.cxx +++ b/panda/src/text/config_text.cxx @@ -27,6 +27,10 @@ #include "dconfig.h" #include "config_express.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_TEXT) + #error Buildsystem error: BUILDING_PANDA_TEXT not defined +#endif + Configure(config_text); NotifyCategoryDef(text, ""); diff --git a/panda/src/tform/config_tform.cxx b/panda/src/tform/config_tform.cxx index 1bbb3a7e57..b8a578d07c 100644 --- a/panda/src/tform/config_tform.cxx +++ b/panda/src/tform/config_tform.cxx @@ -25,6 +25,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDA_TFORM) + #error Buildsystem error: BUILDING_PANDA_TFORM not defined +#endif + Configure(config_tform); NotifyCategoryDef(tform, ""); diff --git a/panda/src/tinydisplay/config_tinydisplay.cxx b/panda/src/tinydisplay/config_tinydisplay.cxx index 228be9a1ee..31ef112ee5 100644 --- a/panda/src/tinydisplay/config_tinydisplay.cxx +++ b/panda/src/tinydisplay/config_tinydisplay.cxx @@ -29,6 +29,10 @@ #include "dconfig.h" #include "pandaSystem.h" +#if !defined(CPPPARSER) && !defined(BUILDING_TINYDISPLAY) + #error Buildsystem error: BUILDING_TINYDISPLAY not defined +#endif + Configure(config_tinydisplay); NotifyCategoryDef(tinydisplay, "display"); diff --git a/panda/src/vision/config_vision.cxx b/panda/src/vision/config_vision.cxx index 50d4b8aeb3..ffe3719962 100644 --- a/panda/src/vision/config_vision.cxx +++ b/panda/src/vision/config_vision.cxx @@ -23,6 +23,10 @@ #include "texturePool.h" #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_VISION) + #error Buildsystem error: BUILDING_VISION not defined +#endif + Configure(config_vision); NotifyCategoryDef(vision, ""); diff --git a/panda/src/vrpn/config_vrpn.cxx b/panda/src/vrpn/config_vrpn.cxx index 77d2b198ee..cc577bd328 100644 --- a/panda/src/vrpn/config_vrpn.cxx +++ b/panda/src/vrpn/config_vrpn.cxx @@ -21,6 +21,10 @@ #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_VRPN) + #error Buildsystem error: BUILDING_VRPN not defined +#endif + Configure(config_vrpn); NotifyCategoryDef(vrpn, ""); diff --git a/panda/src/wgldisplay/config_wgldisplay.cxx b/panda/src/wgldisplay/config_wgldisplay.cxx index 9cd4a149f3..93dc2ad36c 100644 --- a/panda/src/wgldisplay/config_wgldisplay.cxx +++ b/panda/src/wgldisplay/config_wgldisplay.cxx @@ -20,6 +20,10 @@ #include "dconfig.h" #include "pandaSystem.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDAGL) + #error Buildsystem error: BUILDING_PANDAGL not defined +#endif + Configure(config_wgldisplay); NotifyCategoryDef(wgldisplay, "display"); diff --git a/panda/src/windisplay/config_windisplay.cxx b/panda/src/windisplay/config_windisplay.cxx index 65447af18d..1af5cf95da 100644 --- a/panda/src/windisplay/config_windisplay.cxx +++ b/panda/src/windisplay/config_windisplay.cxx @@ -16,6 +16,10 @@ #include "winGraphicsWindow.h" #include "dconfig.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDAWIN) + #error Buildsystem error: BUILDING_PANDAWIN not defined +#endif + Configure(config_windisplay); NotifyCategoryDef(windisplay, "display"); diff --git a/panda/src/x11display/config_x11display.cxx b/panda/src/x11display/config_x11display.cxx index c2b89c42b2..bca59d5a17 100644 --- a/panda/src/x11display/config_x11display.cxx +++ b/panda/src/x11display/config_x11display.cxx @@ -18,6 +18,10 @@ #include "dconfig.h" #include "pandaSystem.h" +#if !defined(CPPPARSER) && !defined(BUILDING_PANDAX11) + #error Buildsystem error: BUILDING_PANDAX11 not defined +#endif + Configure(config_x11display); NotifyCategoryDef(x11display, "display"); From 4eb250cb87524907357714703f5bec194fa505cb Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 25 Mar 2018 21:54:21 -0600 Subject: [PATCH 115/247] dcparser: Write ranged-blob parameters correctly --- direct/src/dcparser/dcSimpleParameter.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/direct/src/dcparser/dcSimpleParameter.cxx b/direct/src/dcparser/dcSimpleParameter.cxx index ceead33a5c..bd1d6cd086 100644 --- a/direct/src/dcparser/dcSimpleParameter.cxx +++ b/direct/src/dcparser/dcSimpleParameter.cxx @@ -2238,6 +2238,8 @@ output_instance(ostream &out, bool brief, const string &prename, } break; + case ST_blob: + case ST_blob32: case ST_string: if (!_uint_range.is_empty()) { out << "("; From 63b1e4497776509d3ead67c4d4e2f0015b894ad4 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 29 Mar 2018 14:11:21 +0200 Subject: [PATCH 116/247] framework: fix pview crash when exit is called inside render_frame This can happen when a system event (eg. on macOS) triggers a terminate from within process_events. This is a workaround for a common error; the proper fix is not to put PandaFramework in the global scope. --- panda/src/framework/pandaFramework.cxx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/panda/src/framework/pandaFramework.cxx b/panda/src/framework/pandaFramework.cxx index d5c6b49829..30968e70b3 100644 --- a/panda/src/framework/pandaFramework.cxx +++ b/panda/src/framework/pandaFramework.cxx @@ -1391,11 +1391,17 @@ AsyncTask::DoneStatus PandaFramework:: task_igloop(GenericAsyncTask *task, void *data) { PandaFramework *self = (PandaFramework *)data; - if (self->_engine != (GraphicsEngine *)NULL) { - self->_engine->render_frame(); + // This exists to work around a crash that happens when the PandaFramework + // is destructed because the application is exited during render_frame(). + // The proper fix is not to instantiate PandaFramework in the global scope + // but many C++ applications (including pview) do this anyway. + PT(GraphicsEngine) engine = self->_engine; + if (engine != nullptr) { + engine->render_frame(); + return AsyncTask::DS_cont; + } else { + return AsyncTask::DS_done; } - - return AsyncTask::DS_cont; } /** From 95bffa8503714ba84091893adeb97c6557183afa Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 29 Mar 2018 14:17:39 +0200 Subject: [PATCH 117/247] Fix crash when typing unicode characters above 7fff into text field Can be reproduced when typing Shift+AltGr+5 into a DirectEntry on macOS. --- panda/src/event/buttonEvent.I | 2 +- panda/src/event/buttonEvent.cxx | 4 ++-- panda/src/event/buttonEvent.h | 4 ++-- panda/src/tform/mouseWatcherParameter.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/panda/src/event/buttonEvent.I b/panda/src/event/buttonEvent.I index 16c68cc0bc..41bea9f2d5 100644 --- a/panda/src/event/buttonEvent.I +++ b/panda/src/event/buttonEvent.I @@ -41,7 +41,7 @@ ButtonEvent(ButtonHandle button, ButtonEvent::Type type, double time) : * */ INLINE ButtonEvent:: -ButtonEvent(short keycode, double time) : +ButtonEvent(int keycode, double time) : _button(ButtonHandle::none()), _keycode(keycode), _highlight_start(0), diff --git a/panda/src/event/buttonEvent.cxx b/panda/src/event/buttonEvent.cxx index 7353ce7e54..38dbbffb6a 100644 --- a/panda/src/event/buttonEvent.cxx +++ b/panda/src/event/buttonEvent.cxx @@ -84,7 +84,7 @@ write_datagram(Datagram &dg) const { break; case T_keystroke: - dg.add_int16(_keycode); + dg.add_uint16(_keycode); break; case T_candidate: @@ -119,7 +119,7 @@ read_datagram(DatagramIterator &scan) { break; case T_keystroke: - _keycode = scan.get_int16(); + _keycode = scan.get_uint16(); break; case T_candidate: diff --git a/panda/src/event/buttonEvent.h b/panda/src/event/buttonEvent.h index e37c2fe2ad..d2e2b82176 100644 --- a/panda/src/event/buttonEvent.h +++ b/panda/src/event/buttonEvent.h @@ -86,7 +86,7 @@ public: INLINE ButtonEvent(); INLINE ButtonEvent(ButtonHandle button, Type type, double time = ClockObject::get_global_clock()->get_frame_time()); - INLINE ButtonEvent(short keycode, double time = ClockObject::get_global_clock()->get_frame_time()); + INLINE ButtonEvent(int keycode, double time = ClockObject::get_global_clock()->get_frame_time()); INLINE ButtonEvent(const wstring &candidate_string, size_t highlight_start, size_t highlight_end, size_t cursor_pos); INLINE ButtonEvent(const ButtonEvent ©); @@ -109,7 +109,7 @@ public: // _keycode will be filled in if type is T_keystroke. It will be the // Unicode character that was typed. - short _keycode; + int _keycode; // _candidate_string will be filled in if type is T_candidate. wstring _candidate_string; diff --git a/panda/src/tform/mouseWatcherParameter.h b/panda/src/tform/mouseWatcherParameter.h index bacb2a805b..1da5dcfc45 100644 --- a/panda/src/tform/mouseWatcherParameter.h +++ b/panda/src/tform/mouseWatcherParameter.h @@ -74,7 +74,7 @@ PUBLISHED: public: ButtonHandle _button; - short _keycode; + int _keycode; wstring _candidate_string; size_t _highlight_start; size_t _highlight_end; From 7062da944a3fdec34f1ed608bfad35fc7fcb2151 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 29 Mar 2018 14:22:14 +0200 Subject: [PATCH 118/247] cocoa: fix ability to type AltGr characters and dead keys It would seem that interpretKeyEvents/insertText would be the right way to do this, but while that does handle AltGr keys correctly, it does not handle dead keys at all. This approach seems to do the right things. --- panda/src/cocoadisplay/cocoaGraphicsWindow.h | 1 + panda/src/cocoadisplay/cocoaGraphicsWindow.mm | 47 ++++++++++++++----- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.h b/panda/src/cocoadisplay/cocoaGraphicsWindow.h index 6432ecc3e8..de2bd8d61c 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.h +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.h @@ -87,6 +87,7 @@ private: NSWindow *_window; NSView *_view; NSUInteger _modifier_keys; + UInt32 _dead_key_state; CGDirectDisplayID _display; bool _mouse_hidden; bool _context_needs_update; diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index 39ecf09162..4984c27062 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm @@ -625,6 +625,9 @@ open_window() { } _fb_properties = cocoagsg->get_fb_properties(); + // Reset dead key state. + _dead_key_state = 0; + // Get the initial mouse position. NSPoint pos = [_window mouseLocationOutsideOfEventStream]; NSPoint loc = [_view convertPoint:pos fromView:nil]; @@ -1391,6 +1394,8 @@ handle_foreground_event(bool foreground) { } } + _dead_key_state = 0; + WindowProperties properties; properties.set_foreground(foreground); system_changed_properties(properties); @@ -1564,25 +1569,43 @@ handle_key_event(NSEvent *event) { return; } + if ([event type] == NSKeyDown) { + // Translate it to a unicode character for keystrokes. I would use + // interpretKeyEvents and insertText, but that doesn't handle dead keys. + TISInputSourceRef input_source = TISCopyCurrentKeyboardInputSource(); + CFDataRef layout_data = (CFDataRef)TISGetInputSourceProperty(input_source, kTISPropertyUnicodeKeyLayoutData); + const UCKeyboardLayout *layout = (const UCKeyboardLayout *)CFDataGetBytePtr(layout_data); + + UInt32 modifier_state = (modifierFlags >> 16) & 0xFF; + UniChar ustr[8]; + UniCharCount length; + + UCKeyTranslate(layout, [event keyCode], kUCKeyActionDown, modifier_state, + LMGetKbdType(), 0, &_dead_key_state, sizeof(ustr), &length, ustr); + CFRelease(input_source); + + for (int i = 0; i < length; ++i) { + UniChar c = ustr[i]; + if (cocoadisplay_cat.is_spam()) { + cocoadisplay_cat.spam() + << "Handling keystroke, character " << (int)c; + if (c < 128 && isprint(c)) { + cocoadisplay_cat.spam(false) << " '" << (char)c << "'"; + } + cocoadisplay_cat.spam(false) << "\n"; + } + _input->keystroke(c); + } + } + NSString *str = [event charactersIgnoringModifiers]; if (str == nil || [str length] == 0) { return; } - nassertv([str length] == 1); + nassertv_always([str length] == 1); unichar c = [str characterAtIndex: 0]; ButtonHandle button = map_key(c); - - if (c < 0xF700 || c >= 0xF900) { - // If a down event and not a special function key, process it as keystroke - // as well. - if ([event type] == NSKeyDown) { - NSString *origstr = [event characters]; - c = [str characterAtIndex: 0]; - _input_devices[0].keystroke(c); - } - } - if (button == ButtonHandle::none()) { // That done, continue trying to find out the button handle. if ([str canBeConvertedToEncoding: NSASCIIStringEncoding]) { From 7830aab21d04d523aa564fb2cb6ad00c08e8fc5b Mon Sep 17 00:00:00 2001 From: Donny Lawrence Date: Sun, 25 Feb 2018 22:26:09 -0600 Subject: [PATCH 119/247] cocoa: Fix unresponsive menubar, add default item for application menu. Closes #259 --- panda/src/cocoadisplay/cocoaGraphicsWindow.mm | 23 ++++++++++++++++++- .../src/cocoadisplay/cocoaPandaAppDelegate.h | 22 ++++++++++++++++++ .../src/cocoadisplay/cocoaPandaAppDelegate.mm | 23 +++++++++++++++++++ .../cocoadisplay/p3cocoadisplay_composite1.mm | 1 + 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 panda/src/cocoadisplay/cocoaPandaAppDelegate.h create mode 100644 panda/src/cocoadisplay/cocoaPandaAppDelegate.mm diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index 4984c27062..0d21a352bf 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm @@ -30,6 +30,7 @@ #import "cocoaPandaView.h" #import "cocoaPandaWindow.h" +#import "cocoaPandaAppDelegate.h" #import #import @@ -71,11 +72,31 @@ CocoaGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, if (NSApp == nil) { [CocoaPandaApp sharedApplication]; + CocoaPandaAppDelegate *delegate = [[CocoaPandaAppDelegate alloc] init]; + [NSApp setDelegate:delegate]; + #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; #endif + NSMenu *mainMenu = [[NSMenu alloc] init]; + + NSMenuItem *applicationMenuItem = [[NSMenuItem alloc] init]; + [mainMenu addItem:applicationMenuItem]; + + NSMenu *applicationMenu = [[NSMenu alloc] init]; + + NSMenuItem *item = [[NSMenuItem alloc] init]; + item.action = @selector(terminate:); + item.keyEquivalent = @"q"; + + NSString *appName = [NSRunningApplication currentApplication].localizedName; + item.title = [NSString stringWithFormat:@"Quit %@", appName]; + + [applicationMenu addItem:item]; + + [mainMenu setSubmenu:applicationMenu forItem:applicationMenuItem]; + [NSApp setMainMenu:mainMenu]; [NSApp finishLaunching]; - [NSApp activateIgnoringOtherApps:YES]; } GraphicsWindowInputDevice device = diff --git a/panda/src/cocoadisplay/cocoaPandaAppDelegate.h b/panda/src/cocoadisplay/cocoaPandaAppDelegate.h new file mode 100644 index 0000000000..b4af5deb55 --- /dev/null +++ b/panda/src/cocoadisplay/cocoaPandaAppDelegate.h @@ -0,0 +1,22 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cocoaPandaAppDelegate.h + * @author Donny Lawrence + * @date 2018-02-25 + */ + +#import +#import + +// Cocoa is picky about where and when certain methods are called in the initialization process. +@interface CocoaPandaAppDelegate : NSObject + +- (void)applicationDidFinishLaunching:(NSNotification *)notification; + +@end diff --git a/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm b/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm new file mode 100644 index 0000000000..dbb5452c75 --- /dev/null +++ b/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm @@ -0,0 +1,23 @@ +/** +* PANDA 3D SOFTWARE +* Copyright (c) Carnegie Mellon University. All rights reserved. +* +* All use of this software is subject to the terms of the revised BSD +* license. You should have received a copy of this license along +* with this source code in a file named "LICENSE." +* +* @file cocoaPandaAppDelegate.mm +* @author Donny Lawrence +* @date 2018-02-25 +*/ + +#import "cocoaPandaAppDelegate.h" + +@implementation CocoaPandaAppDelegate + +- (void)applicationDidFinishLaunching:(NSNotification *)notification { + // This only seems to work when called here. + [NSApp activateIgnoringOtherApps:YES]; +} + +@end diff --git a/panda/src/cocoadisplay/p3cocoadisplay_composite1.mm b/panda/src/cocoadisplay/p3cocoadisplay_composite1.mm index e85d1e08eb..335443fab1 100644 --- a/panda/src/cocoadisplay/p3cocoadisplay_composite1.mm +++ b/panda/src/cocoadisplay/p3cocoadisplay_composite1.mm @@ -7,3 +7,4 @@ #include "cocoaPandaView.mm" #include "cocoaPandaWindow.mm" #include "cocoaPandaWindowDelegate.mm" +#include "cocoaPandaAppDelegate.mm" From 2bde4d839a8d3998209373a233ee04d0f9d60818 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 29 Mar 2018 14:36:41 +0200 Subject: [PATCH 120/247] makepanda: set MSVC 2015 as default, deprecate MSVC 2010 support See #288 for discussion; make your voice heard there if you object to this change! [skip ci] --- makepanda/makepanda.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index e7565907b2..b772a4a9e7 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -155,7 +155,7 @@ def usage(problem): print(" --everything (enable every third-party lib)") print(" --directx-sdk=X (specify version of DirectX SDK to use: jun2010, aug2009, mar2009, aug2006)") print(" --windows-sdk=X (specify Windows SDK version, eg. 7.0, 7.1 or 10. Default is 7.1)") - print(" --msvc-version=X (specify Visual C++ version, eg. 10, 11, 12, 14. Default is 10)") + print(" --msvc-version=X (specify Visual C++ version, eg. 10, 11, 12, 14. Default is 14)") print(" --use-icl (experimental setting to use an intel compiler instead of MSVC on Windows)") print("") print("The simplest way to compile panda is to just type:") @@ -315,17 +315,33 @@ def parseopts(args): usage("Invalid SHA-1 hash given for --git-commit option!") if GetTarget() == 'windows': + show_warning = False if not MSVC_VERSION: - print("No MSVC version specified. Defaulting to 10 (Visual Studio 2010).") - MSVC_VERSION = (10, 0) + show_warning = True + print("No MSVC version specified. Defaulting to 14 (Visual Studio 2015).") + MSVC_VERSION = (14, 0) else: try: MSVC_VERSION = tuple(int(d) for d in MSVC_VERSION.split('.'))[:2] if (len(MSVC_VERSION) == 1): MSVC_VERSION += (0,) + if MSVC_VERSION < (14, 0): + show_warning = True except: usage("Invalid setting for --msvc-version") + if show_warning: + warn_prefix = "%sWARNING:%s " % (GetColor("red"), GetColor()) + print("=========================================================================") + print(warn_prefix + "Support for MSVC versions before 2015 will soon be discontinued.") + print(warn_prefix + "If you wish to keep using MSVC 2010, make your voice heard at:") + print(warn_prefix + " https://github.com/panda3d/panda3d/issues/288") + if MSVC_VERSION >= (14, 0): + print(warn_prefix + "To squelch this warning, pass --msvc-version {0}.{1}".format(*MSVC_VERSION)) + print("=========================================================================") + sys.stdout.flush() + time.sleep(1.0) + if not WINDOWS_SDK: print("No Windows SDK version specified. Defaulting to '7.1'.") WINDOWS_SDK = '7.1' From b8af5bf64fc836b0a132a2a77eff06f5424ea313 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 29 Mar 2018 14:44:10 +0200 Subject: [PATCH 121/247] cocoa: fix compile error caused by faulty merge [skip ci] --- panda/src/cocoadisplay/cocoaGraphicsWindow.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index 0d21a352bf..72c9d57c0f 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm @@ -1615,7 +1615,7 @@ handle_key_event(NSEvent *event) { } cocoadisplay_cat.spam(false) << "\n"; } - _input->keystroke(c); + _input_devices[0].keystroke(c); } } From 30cf1dbbb113b30e64668c8724153b674048f0c4 Mon Sep 17 00:00:00 2001 From: deflected Date: Fri, 30 Mar 2018 13:32:17 +0300 Subject: [PATCH 122/247] pgraphnodes: Fixed the type of texture bytes in sceneGraphAnalyzer - Corrected the type of texture bytes variable as it is possible to wrap it around Signed-off-by: deflected --- panda/src/pgraphnodes/sceneGraphAnalyzer.I | 2 +- panda/src/pgraphnodes/sceneGraphAnalyzer.cxx | 2 +- panda/src/pgraphnodes/sceneGraphAnalyzer.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/panda/src/pgraphnodes/sceneGraphAnalyzer.I b/panda/src/pgraphnodes/sceneGraphAnalyzer.I index 3d7ef0a08d..865326ff65 100644 --- a/panda/src/pgraphnodes/sceneGraphAnalyzer.I +++ b/panda/src/pgraphnodes/sceneGraphAnalyzer.I @@ -224,7 +224,7 @@ get_num_vertices_in_patches() const { /** * */ -int SceneGraphAnalyzer:: +size_t SceneGraphAnalyzer:: get_texture_bytes() const { return _texture_bytes; } diff --git a/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx b/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx index cb4c892e7c..b24678b333 100644 --- a/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx +++ b/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx @@ -485,7 +485,7 @@ collect_statistics(Texture *texture) { _textures.insert(Textures::value_type(texture, 1)); // Attempt to guess how many bytes of texture memory this one requires. - int bytes = + size_t bytes = texture->get_x_size() * texture->get_y_size() * texture->get_num_components() * texture->get_component_width(); diff --git a/panda/src/pgraphnodes/sceneGraphAnalyzer.h b/panda/src/pgraphnodes/sceneGraphAnalyzer.h index f8d0201766..68ca0d14df 100644 --- a/panda/src/pgraphnodes/sceneGraphAnalyzer.h +++ b/panda/src/pgraphnodes/sceneGraphAnalyzer.h @@ -81,7 +81,7 @@ PUBLISHED: INLINE int get_num_triangles_in_fans() const; INLINE int get_num_vertices_in_patches() const; - INLINE int get_texture_bytes() const; + INLINE size_t get_texture_bytes() const; INLINE int get_num_long_normals() const; INLINE int get_num_short_normals() const; @@ -150,7 +150,7 @@ private: int _num_triangles_in_fans; int _num_vertices_in_patches; - int _texture_bytes; + size_t _texture_bytes; int _num_long_normals; int _num_short_normals; From 84915073e1e2bc2ad1dc9a395c823ca771574751 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 30 Mar 2018 20:15:13 +0200 Subject: [PATCH 123/247] Fix compilation warning on MSVC 2015 --- dtool/src/interrogatedb/py_panda.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index 76733237a8..362f5ec6ca 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -736,7 +736,7 @@ PyObject *Dtool_AddToDictionary(PyObject *self1, PyObject *args) { Py_hash_t DTOOL_PyObject_HashPointer(PyObject *self) { if (self != nullptr && DtoolInstance_Check(self)) { - return (Py_hash_t)DtoolInstance_VOID_PTR(self); + return (Py_hash_t)(intptr_t)DtoolInstance_VOID_PTR(self); } return -1; } From 78377ca10cc155c6e25897c33503695457572f1f Mon Sep 17 00:00:00 2001 From: Sebastian Hoffmann Date: Sun, 25 Feb 2018 15:41:26 +0100 Subject: [PATCH 124/247] Cursor after newline character appears on beginning of next line. DirectEntry.updateNumLines updates text geom. DirectEntry API less inadequate. Closes #257 --- direct/src/gui/DirectEntry.py | 6 ++++++ panda/src/pgui/pgEntry.I | 1 + panda/src/pgui/pgEntry.cxx | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/direct/src/gui/DirectEntry.py b/direct/src/gui/DirectEntry.py index 6955e550a2..e345c526e9 100644 --- a/direct/src/gui/DirectEntry.py +++ b/direct/src/gui/DirectEntry.py @@ -302,12 +302,18 @@ class DirectEntry(DirectFrame): else: return self.guiItem.getText() + def getCursorPosition(self): + return self.guiItem.getCursorPosition() + def setCursorPosition(self, pos): if (pos < 0): self.guiItem.setCursorPosition(self.guiItem.getNumCharacters() + pos) else: self.guiItem.setCursorPosition(pos) + def getNumCharacters(self): + return self.guiItem.getNumCharacters() + def enterText(self, text): """ sets the entry's text, and moves the cursor to the end """ self.set(text) diff --git a/panda/src/pgui/pgEntry.I b/panda/src/pgui/pgEntry.I index e90ebce374..dec418c9fd 100644 --- a/panda/src/pgui/pgEntry.I +++ b/panda/src/pgui/pgEntry.I @@ -208,6 +208,7 @@ set_num_lines(int num_lines) { nassertv(num_lines >= 1); _num_lines = num_lines; _text_geom_stale = true; + update_text(); } /** diff --git a/panda/src/pgui/pgEntry.cxx b/panda/src/pgui/pgEntry.cxx index 12e2636e9a..c9f84fae4f 100644 --- a/panda/src/pgui/pgEntry.cxx +++ b/panda/src/pgui/pgEntry.cxx @@ -864,6 +864,10 @@ update_cursor() { ypos = _obscure_text.get_ypos(row, column); } else { _text.calc_r_c(row, column, _cursor_position); + if (_cursor_position > 0 && _text.get_character(_cursor_position - 1) == '\n') { + row += 1; + column = 0; + } xpos = _text.get_xpos(row, column); ypos = _text.get_ypos(row, column); } From 0b1ad67e13533fc9bd2fbb5d26738ee0e3286bad Mon Sep 17 00:00:00 2001 From: Tohka Date: Sat, 31 Mar 2018 13:01:35 +0300 Subject: [PATCH 125/247] distributed: Fix DC file reading regression (#295) --- direct/src/distributed/ConnectionRepository.py | 2 +- direct/src/distributed/ServerRepository.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/direct/src/distributed/ConnectionRepository.py b/direct/src/distributed/ConnectionRepository.py index 974c611bcc..348a4390b6 100644 --- a/direct/src/distributed/ConnectionRepository.py +++ b/direct/src/distributed/ConnectionRepository.py @@ -333,7 +333,7 @@ class ConnectionRepository( continue classDef = getattr(classDef, className) - if inspect.isclass(classDef): + if not inspect.isclass(classDef): self.notify.error("Symbol %s is not a class name." % (className)) else: dclass.setClassDef(classDef) diff --git a/direct/src/distributed/ServerRepository.py b/direct/src/distributed/ServerRepository.py index 7783e2860b..894dfb1349 100644 --- a/direct/src/distributed/ServerRepository.py +++ b/direct/src/distributed/ServerRepository.py @@ -280,7 +280,7 @@ class ServerRepository: self.notify.error("Module %s does not define class %s." % (className, className)) classDef = getattr(classDef, className) - if inspect.isclass(classDef): + if not inspect.isclass(classDef): self.notify.error("Symbol %s is not a class name." % (className)) else: dclass.setClassDef(classDef) From 65210a5e49f4360b718acd29ecf454bddc934e60 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 30 Mar 2018 23:30:54 -0600 Subject: [PATCH 126/247] ffmpeg: Fix a typo in version detection See f0b3e08e9c75e5cdcd98c0f3142469918d1d2fd5 --- panda/src/ffmpeg/ffmpegAudioCursor.cxx | 2 +- panda/src/ffmpeg/ffmpegVideoCursor.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.cxx b/panda/src/ffmpeg/ffmpegAudioCursor.cxx index 659925cce3..b45770d20a 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.cxx +++ b/panda/src/ffmpeg/ffmpegAudioCursor.cxx @@ -143,7 +143,7 @@ FfmpegAudioCursor(FfmpegAudio *src) : _can_seek = true; _can_seek_fast = true; -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 59, 100) +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 45, 101) _frame = av_frame_alloc(); #else _frame = avcodec_alloc_frame(); diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.cxx b/panda/src/ffmpeg/ffmpegVideoCursor.cxx index 8a23853811..ffcccc8aab 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx +++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx @@ -96,7 +96,7 @@ init_from(FfmpegVideo *source) { ReMutexHolder av_holder(_av_lock); -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 59, 100) +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 45, 101) _frame = av_frame_alloc(); _frame_out = av_frame_alloc(); #else From a19e9aea63a44751bedbd3e1b8ba35b4f242fe10 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Tue, 27 Mar 2018 13:43:01 -0600 Subject: [PATCH 127/247] ffmpeg: Enforce minimum supported versions of ffmpeg lavcodec: 54.86.100 lavformat: 54.59.106 lavutil: 52.13.100 These are the versions included in FFmpeg 1.1, which is the oldest release that works with Panda already: we've been using `av_opt_set_sample_fmt` (introduced in FFmpeg 1.1) since 03e96d8c4a903be7222365b40613429768659892 (August 2013) and nobody has complained since. In other words, I'm not dropping support for anything here, I'm just making the supported versions explicit. --- panda/src/ffmpeg/config_ffmpeg.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/panda/src/ffmpeg/config_ffmpeg.cxx b/panda/src/ffmpeg/config_ffmpeg.cxx index 8cbc9f51ec..be788eb2f8 100644 --- a/panda/src/ffmpeg/config_ffmpeg.cxx +++ b/panda/src/ffmpeg/config_ffmpeg.cxx @@ -22,12 +22,26 @@ extern "C" { #include "libavcodec/avcodec.h" + #include "libavformat/avformat.h" + #include "libavutil/avutil.h" } #if !defined(CPPPARSER) && !defined(BUILDING_FFMPEG) #error Buildsystem error: BUILDING_FFMPEG not defined #endif +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 86, 100) + #error Minimum supported version of libavcodec is 54.86.100. +#endif + +#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(54, 59, 106) + #error Minimum supported version of libavformat is 54.59.106. +#endif + +#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(52, 13, 100) + #error Minimum supported version of libavutil is 52.13.100. +#endif + ConfigureDef(config_ffmpeg); NotifyCategoryDef(ffmpeg, ""); From 148010c5f020b46e7b38a5b8c3254185f59023a3 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Tue, 27 Mar 2018 13:51:08 -0600 Subject: [PATCH 128/247] ffmpeg: Remove code to support deprecated versions See previous commit; now that we're enforcing explicit minimums, any code to support anything older than those minimums is trivially dead. --- panda/src/ffmpeg/ffmpegAudioCursor.cxx | 43 +------------------------- panda/src/ffmpeg/ffmpegVideoCursor.cxx | 29 +---------------- panda/src/ffmpeg/ffmpegVirtualFile.cxx | 15 --------- 3 files changed, 2 insertions(+), 85 deletions(-) diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.cxx b/panda/src/ffmpeg/ffmpegAudioCursor.cxx index b45770d20a..83ae9dcf28 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.cxx +++ b/panda/src/ffmpeg/ffmpegAudioCursor.cxx @@ -63,11 +63,7 @@ FfmpegAudioCursor(FfmpegAudio *src) : _format_ctx = _ffvfile.get_format_context(); nassertv(_format_ctx != NULL); -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53, 6, 0) if (avformat_find_stream_info(_format_ctx, NULL) < 0) { -#else - if (av_find_stream_info(_format_ctx) < 0) { -#endif cleanup(); return; } @@ -94,31 +90,20 @@ FfmpegAudioCursor(FfmpegAudio *src) : return; } -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53, 8, 0) AVDictionary *opts = NULL; av_dict_set(&opts, "request_sample_fmt", "s16", 0); if (avcodec_open2(_audio_ctx, pAudioCodec, NULL) < 0) { -#else - if (avcodec_open(_audio_ctx, pAudioCodec) < 0) { -#endif cleanup(); return; } -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53, 8, 0) av_dict_free(&opts); -#endif // Set up the resample context if necessary. if (_audio_ctx->sample_fmt != AV_SAMPLE_FMT_S16) { #ifdef HAVE_SWRESAMPLE -#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 25, 0) - ffmpeg_cat.error() - << "Codec does not use signed 16-bit sample format. Upgrade libavcodec to 53.25.0 or higher.\n"; -#else ffmpeg_cat.debug() << "Codec does not use signed 16-bit sample format. Setting up swresample context.\n"; -#endif _resample_ctx = swr_alloc(); av_opt_set_int(_resample_ctx, "in_channel_layout", _audio_ctx->channel_layout, 0); @@ -191,10 +176,8 @@ cleanup() { if (_frame) { #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 45, 101) av_frame_free(&_frame); -#elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 59, 100) - avcodec_free_frame(&_frame); #else - av_free(&_frame); + avcodec_free_frame(&_frame); #endif _frame = NULL; } @@ -284,25 +267,6 @@ reload_buffer() { return true; } else if (_packet_size > 0) { int bufsize = _buffer_size * 2; -#if LIBAVCODEC_VERSION_INT < 3349504 - int len = avcodec_decode_audio(_audio_ctx, _buffer, &bufsize, - _packet_data, _packet_size); - movies_debug("avcodec_decode_audio returned " << len); -#elif LIBAVCODEC_VERSION_INT < 3414272 - int len = avcodec_decode_audio2(_audio_ctx, _buffer, &bufsize, - _packet_data, _packet_size); - movies_debug("avcodec_decode_audio2 returned " << len); -#elif LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 25, 0) - // We should technically also consider resampling in this case, but - // whatever. Just upgrade your ffmpeg version if you get garbage. - AVPacket pkt; - av_init_packet(&pkt); - pkt.data = _packet_data; - pkt.size = _packet_size; - int len = avcodec_decode_audio3(_audio_ctx, _buffer, &bufsize, &pkt); - movies_debug("avcodec_decode_audio3 returned " << len); - av_free_packet(&pkt); -#else int got_frame; AVPacket pkt; av_init_packet(&pkt); @@ -332,7 +296,6 @@ reload_buffer() { } #if LIBAVUTIL_VERSION_INT > AV_VERSION_INT(52, 19, 100) av_frame_unref(_frame); -#endif #endif if (len < 0) { @@ -376,11 +339,7 @@ seek(double t) { cleanup(); return; } -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53, 8, 0) if (avcodec_open2(_audio_ctx, pAudioCodec, NULL) < 0) { -#else - if (avcodec_open(_audio_ctx, pAudioCodec) < 0) { -#endif cleanup(); return; } diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.cxx b/panda/src/ffmpeg/ffmpegVideoCursor.cxx index ffcccc8aab..4000343ba8 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx +++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx @@ -36,21 +36,10 @@ PStatCollector FfmpegVideoCursor::_fetch_buffer_pcollector("*:FFMPEG Video Decod PStatCollector FfmpegVideoCursor::_seek_pcollector("*:FFMPEG Video Decoding:Seek"); PStatCollector FfmpegVideoCursor::_export_frame_pcollector("*:FFMPEG Convert Video to BGR"); -#if LIBAVFORMAT_VERSION_MAJOR < 53 - #define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO -#endif - #if LIBAVCODEC_VERSION_MAJOR < 54 #define AV_CODEC_ID_VP8 CODEC_ID_VP8 #endif -#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(51, 74, 100) -#define AV_PIX_FMT_NONE PIX_FMT_NONE -#define AV_PIX_FMT_BGR24 PIX_FMT_BGR24 -#define AV_PIX_FMT_BGRA PIX_FMT_BGRA -typedef PixelFormat AVPixelFormat; -#endif - #if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(52, 32, 100) #define AV_PIX_FMT_FLAG_ALPHA PIX_FMT_ALPHA #endif @@ -120,7 +109,6 @@ init_from(FfmpegVideo *source) { _eof_known = false; _eof_frame = 0; -#if LIBAVUTIL_VERSION_MAJOR >= 52 // Check if we got an alpha format. Please note that some video codecs // (eg. libvpx) change the pix_fmt after decoding the first frame, which is // why we didn't do this earlier. @@ -128,9 +116,7 @@ init_from(FfmpegVideo *source) { if (desc && (desc->flags & AV_PIX_FMT_FLAG_ALPHA) != 0) { _num_components = 4; _pixel_format = (int)AV_PIX_FMT_BGRA; - } else -#endif - { + } else { _num_components = 3; _pixel_format = (int)AV_PIX_FMT_BGR24; } @@ -493,11 +479,7 @@ open_stream() { _format_ctx = _ffvfile.get_format_context(); nassertr(_format_ctx != NULL, false); -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53, 6, 0) if (avformat_find_stream_info(_format_ctx, NULL) < 0) { -#else - if (av_find_stream_info(_format_ctx) < 0) { -#endif ffmpeg_cat.info() << "Couldn't find stream info\n"; close_stream(); @@ -539,11 +521,7 @@ open_stream() { close_stream(); return false; } -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53, 8, 0) if (avcodec_open2(_video_ctx, pVideoCodec, NULL) < 0) { -#else - if (avcodec_open(_video_ctx, pVideoCodec) < 0) { -#endif ffmpeg_cat.info() << "Couldn't open codec\n"; close_stream(); @@ -883,12 +861,7 @@ decode_frame(int &finished) { */ void FfmpegVideoCursor:: do_decode_frame(int &finished) { -#if LIBAVCODEC_VERSION_INT < 3414272 - avcodec_decode_video(_video_ctx, _frame, - &finished, _packet->data, _packet->size); -#else avcodec_decode_video2(_video_ctx, _frame, &finished, _packet); -#endif } /** diff --git a/panda/src/ffmpeg/ffmpegVirtualFile.cxx b/panda/src/ffmpeg/ffmpegVirtualFile.cxx index df8f077406..8819db74bc 100644 --- a/panda/src/ffmpeg/ffmpegVirtualFile.cxx +++ b/panda/src/ffmpeg/ffmpegVirtualFile.cxx @@ -107,11 +107,7 @@ open_vfs(const Filename &filename) { // Now we can open the stream. int result = -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53, 4, 0) avformat_open_input(&_format_context, "", NULL, NULL); -#else - av_open_input_file(&_format_context, "", NULL, 0, NULL); -#endif if (result < 0) { close(); return false; @@ -159,11 +155,7 @@ open_subfile(const SubfileInfo &info) { // Now we can open the stream. int result = -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53, 4, 0) avformat_open_input(&_format_context, fname.c_str(), NULL, NULL); -#else - av_open_input_file(&_format_context, fname.c_str(), NULL, 0, NULL); -#endif if (result < 0) { close(); return false; @@ -179,12 +171,7 @@ open_subfile(const SubfileInfo &info) { void FfmpegVirtualFile:: close() { if (_format_context != NULL) { -#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53, 17, 0) avformat_close_input(&_format_context); -#else - av_close_input_file(_format_context); - _format_context = NULL; -#endif } if (_io_context != NULL) { @@ -218,9 +205,7 @@ register_protocol() { av_register_all(); // And this one. -#if LIBAVFORMAT_VERSION_INT >= 0x351400 avformat_network_init(); -#endif // Let's also register the logging to Panda's notify callback. av_log_set_callback(&log_callback); From cc77c5dbe2e9ef9f889e6b36a4e5aaee441493d5 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 31 Mar 2018 01:33:28 -0600 Subject: [PATCH 129/247] ffmpeg: Clean up ffmpeg_prefer_libvpx implementation --- panda/src/ffmpeg/ffmpegVideoCursor.cxx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.cxx b/panda/src/ffmpeg/ffmpegVideoCursor.cxx index 4000343ba8..ff3f46a538 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx +++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx @@ -36,12 +36,8 @@ PStatCollector FfmpegVideoCursor::_fetch_buffer_pcollector("*:FFMPEG Video Decod PStatCollector FfmpegVideoCursor::_seek_pcollector("*:FFMPEG Video Decoding:Seek"); PStatCollector FfmpegVideoCursor::_export_frame_pcollector("*:FFMPEG Convert Video to BGR"); -#if LIBAVCODEC_VERSION_MAJOR < 54 -#define AV_CODEC_ID_VP8 CODEC_ID_VP8 -#endif - #if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(52, 32, 100) -#define AV_PIX_FMT_FLAG_ALPHA PIX_FMT_ALPHA + #define AV_PIX_FMT_FLAG_ALPHA PIX_FMT_ALPHA #endif /** @@ -506,9 +502,12 @@ open_stream() { AVCodec *pVideoCodec = NULL; if (ffmpeg_prefer_libvpx) { - if ((int)_video_ctx->codec_id == 168) { // AV_CODEC_ID_VP9 +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 0, 0) + if (_video_ctx->codec_id == AV_CODEC_ID_VP9) { pVideoCodec = avcodec_find_decoder_by_name("libvpx-vp9"); - } else if (_video_ctx->codec_id == AV_CODEC_ID_VP8) { + } else +#endif + if (_video_ctx->codec_id == AV_CODEC_ID_VP8) { pVideoCodec = avcodec_find_decoder_by_name("libvpx"); } } From 95960952945f79f1a5acc458570703e1c9250b4e Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 31 Mar 2018 01:36:39 -0600 Subject: [PATCH 130/247] ffmpeg: Use AVStream.codecpar AVStream.codec is deprecated as of libavformat version 57.41.100, so if this version is detected, we switch to AVStream.codecpar instead. Note this also makes it necessary to construct and use our own codec context - but doing that is a cleaner approach anyway. --- panda/src/ffmpeg/ffmpegAudioCursor.cxx | 49 ++++++++++++++++++--- panda/src/ffmpeg/ffmpegVideoCursor.cxx | 59 +++++++++++++++++++++----- 2 files changed, 91 insertions(+), 17 deletions(-) diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.cxx b/panda/src/ffmpeg/ffmpegAudioCursor.cxx index 83ae9dcf28..2a94dd25b9 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.cxx +++ b/panda/src/ffmpeg/ffmpegAudioCursor.cxx @@ -68,28 +68,58 @@ FfmpegAudioCursor(FfmpegAudio *src) : return; } + // As of libavformat version 57.41.100, AVStream.codec is deprecated in favor + // of AVStream.codecpar. Fortunately, the two structures have + // similarly-named members, so we can just switch out the declaration. +#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 41, 100) + AVCodecParameters *codecpar; +#else + AVCodecContext *codecpar; +#endif + // Find the audio stream + AVStream *stream = nullptr; for (int i = 0; i < (int)_format_ctx->nb_streams; i++) { - if (_format_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) { +#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 41, 100) + codecpar = _format_ctx->streams[i]->codecpar; +#else + codecpar = _format_ctx->streams[i]->codec; +#endif + if (codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { _audio_index = i; - _audio_ctx = _format_ctx->streams[i]->codec; - _audio_timebase = av_q2d(_format_ctx->streams[i]->time_base); - _audio_rate = _audio_ctx->sample_rate; - _audio_channels = _audio_ctx->channels; + stream = _format_ctx->streams[i]; + break; } } - if (_audio_ctx == 0) { + if (stream == nullptr) { cleanup(); return; } - AVCodec *pAudioCodec = avcodec_find_decoder(_audio_ctx->codec_id); + _audio_timebase = av_q2d(stream->time_base); + _audio_rate = codecpar->sample_rate; + _audio_channels = codecpar->channels; + + AVCodec *pAudioCodec = avcodec_find_decoder(codecpar->codec_id); if (pAudioCodec == 0) { cleanup(); return; } + _audio_ctx = avcodec_alloc_context3(pAudioCodec); + + if (_audio_ctx == nullptr) { + cleanup(); + return; + } + +#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 41, 100) + avcodec_parameters_to_context(_audio_ctx, codecpar); +#else + avcodec_copy_context(_audio_ctx, codecpar); +#endif + AVDictionary *opts = NULL; av_dict_set(&opts, "request_sample_fmt", "s16", 0); if (avcodec_open2(_audio_ctx, pAudioCodec, NULL) < 0) { @@ -202,6 +232,11 @@ cleanup() { if ((_audio_ctx)&&(_audio_ctx->codec)) { avcodec_close(_audio_ctx); +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 52, 0) + avcodec_free_context(&_audio_ctx); +#else + delete _audio_ctx; +#endif } _audio_ctx = NULL; diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.cxx b/panda/src/ffmpeg/ffmpegVideoCursor.cxx index ff3f46a538..33d0a1d411 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx +++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx @@ -482,37 +482,55 @@ open_stream() { return false; } - // Find the video stream nassertr(_video_ctx == NULL, false); + + // As of libavformat version 57.41.100, AVStream.codec is deprecated in favor + // of AVStream.codecpar. Fortunately, the two structures have + // similarly-named members, so we can just switch out the declaration. +#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 41, 100) + AVCodecParameters *codecpar; +#else + AVCodecContext *codecpar; +#endif + + // Find the video stream + AVStream *stream = nullptr; for (int i = 0; i < (int)_format_ctx->nb_streams; ++i) { - if (_format_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) { +#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 41, 100) + codecpar = _format_ctx->streams[i]->codecpar; +#else + codecpar = _format_ctx->streams[i]->codec; +#endif + if (codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { _video_index = i; - _video_ctx = _format_ctx->streams[i]->codec; - _video_timebase = av_q2d(_format_ctx->streams[i]->time_base); - _min_fseek = (int)(3.0 / _video_timebase); + stream = _format_ctx->streams[i]; + break; } } - if (_video_ctx == NULL) { + if (stream == nullptr) { ffmpeg_cat.info() - << "Couldn't find video_ctx\n"; + << "Couldn't find stream\n"; close_stream(); return false; } + _video_timebase = av_q2d(stream->time_base); + _min_fseek = (int)(3.0 / _video_timebase); + AVCodec *pVideoCodec = NULL; if (ffmpeg_prefer_libvpx) { #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 0, 0) - if (_video_ctx->codec_id == AV_CODEC_ID_VP9) { + if (codecpar->codec_id == AV_CODEC_ID_VP9) { pVideoCodec = avcodec_find_decoder_by_name("libvpx-vp9"); } else #endif - if (_video_ctx->codec_id == AV_CODEC_ID_VP8) { + if (codecpar->codec_id == AV_CODEC_ID_VP8) { pVideoCodec = avcodec_find_decoder_by_name("libvpx"); } } if (pVideoCodec == NULL) { - pVideoCodec = avcodec_find_decoder(_video_ctx->codec_id); + pVideoCodec = avcodec_find_decoder(codecpar->codec_id); } if (pVideoCodec == NULL) { ffmpeg_cat.info() @@ -520,6 +538,22 @@ open_stream() { close_stream(); return false; } + + _video_ctx = avcodec_alloc_context3(pVideoCodec); + + if (_video_ctx == nullptr) { + ffmpeg_cat.info() + << "Couldn't allocate _video_ctx\n"; + close_stream(); + return false; + } + +#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 41, 100) + avcodec_parameters_to_context(_video_ctx, codecpar); +#else + avcodec_copy_context(_video_ctx, codecpar); +#endif + if (avcodec_open2(_video_ctx, pVideoCodec, NULL) < 0) { ffmpeg_cat.info() << "Couldn't open codec\n"; @@ -547,6 +581,11 @@ close_stream() { if ((_video_ctx)&&(_video_ctx->codec)) { avcodec_close(_video_ctx); +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 52, 0) + avcodec_free_context(&_video_ctx); +#else + delete _video_ctx; +#endif } _video_ctx = NULL; From eb591674e09bb0a7a39b9b3b36f43c54d820756f Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Tue, 27 Mar 2018 21:25:55 -0600 Subject: [PATCH 131/247] ffmpeg: Prefer av_packet_alloc over allocating AVPacket ourselves av_packet_alloc/av_packet_free will know the correct size of AVPacket, even if the ABI should change. So, we use it when it's available. --- panda/src/ffmpeg/ffmpegAudioCursor.cxx | 36 ++++++++++++++++++-------- panda/src/ffmpeg/ffmpegVideoCursor.cxx | 12 ++++++--- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.cxx b/panda/src/ffmpeg/ffmpegAudioCursor.cxx index 2a94dd25b9..dafcc8f2c5 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.cxx +++ b/panda/src/ffmpeg/ffmpegAudioCursor.cxx @@ -164,7 +164,12 @@ FfmpegAudioCursor(FfmpegAudio *src) : _frame = avcodec_alloc_frame(); #endif +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) + _packet = av_packet_alloc(); +#else _packet = new AVPacket; +#endif + _buffer_size = AVCODEC_MAX_AUDIO_FRAME_SIZE / 2; _buffer_alloc = new int16_t[_buffer_size + 64]; @@ -213,15 +218,15 @@ cleanup() { } if (_packet) { - if (_packet->data) { #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) - av_packet_unref(_packet); + av_packet_free(&_packet); #else + if (_packet->data) { av_free_packet(_packet); -#endif } delete _packet; _packet = NULL; +#endif } if (_buffer_alloc) { @@ -303,16 +308,25 @@ reload_buffer() { } else if (_packet_size > 0) { int bufsize = _buffer_size * 2; int got_frame; - AVPacket pkt; - av_init_packet(&pkt); - pkt.data = _packet_data; - pkt.size = _packet_size; - int len = avcodec_decode_audio4(_audio_ctx, _frame, &got_frame, &pkt); - movies_debug("avcodec_decode_audio4 returned " << len); + + AVPacket *pkt; #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) - av_packet_unref(&pkt); + pkt = av_packet_alloc(); #else - av_free_packet(&pkt); + AVPacket _pkt; + pkt = &_pkt; + av_init_packet(pkt); +#endif + pkt->data = _packet_data; + pkt->size = _packet_size; + + int len = avcodec_decode_audio4(_audio_ctx, _frame, &got_frame, pkt); + movies_debug("avcodec_decode_audio4 returned " << len); + +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) + av_packet_free(&pkt); +#else + av_free_packet(pkt); #endif bufsize = 0; diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.cxx b/panda/src/ffmpeg/ffmpegVideoCursor.cxx index 33d0a1d411..cf2b01bf5c 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx +++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx @@ -94,8 +94,12 @@ init_from(FfmpegVideo *source) { return; } +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) + _packet = av_packet_alloc(); +#else _packet = new AVPacket; - memset(_packet, 0, sizeof(AVPacket)); + av_init_packet(_packet); +#endif fetch_packet(0); fetch_frame(-1); @@ -624,15 +628,15 @@ cleanup() { } if (_packet) { - if (_packet->data) { #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) - av_packet_unref(_packet); + av_packet_free(&_packet); #else + if (_packet->data) { av_free_packet(_packet); -#endif } delete _packet; _packet = NULL; +#endif } } From 4ffd3644158f7972d91534a7aa5da1c96e16d5a9 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 31 Mar 2018 02:54:48 -0600 Subject: [PATCH 132/247] ffmpeg: Simplify ffmpegAudioCursor.cxx a little This refactors the `reload_buffer` loop so all of the decode logic is inside the loop, and all of the resampling logic is outside. --- panda/src/ffmpeg/ffmpegAudioCursor.cxx | 112 ++++++++++++------------- 1 file changed, 54 insertions(+), 58 deletions(-) diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.cxx b/panda/src/ffmpeg/ffmpegAudioCursor.cxx index dafcc8f2c5..a897174bc2 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.cxx +++ b/panda/src/ffmpeg/ffmpegAudioCursor.cxx @@ -297,71 +297,67 @@ fetch_packet() { */ bool FfmpegAudioCursor:: reload_buffer() { - - while (_buffer_head == _buffer_tail) { + int got_frame = 0; + while (!got_frame) { // If we're out of packets, generate silence. - if (_packet->data == 0) { + if (_packet->data == nullptr) { _buffer_head = 0; _buffer_tail = _buffer_size; memset(_buffer, 0, _buffer_size * 2); return true; - } else if (_packet_size > 0) { - int bufsize = _buffer_size * 2; - int got_frame; - - AVPacket *pkt; -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) - pkt = av_packet_alloc(); -#else - AVPacket _pkt; - pkt = &_pkt; - av_init_packet(pkt); -#endif - pkt->data = _packet_data; - pkt->size = _packet_size; - - int len = avcodec_decode_audio4(_audio_ctx, _frame, &got_frame, pkt); - movies_debug("avcodec_decode_audio4 returned " << len); - -#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) - av_packet_free(&pkt); -#else - av_free_packet(pkt); -#endif - - bufsize = 0; - if (got_frame) { -#ifdef HAVE_SWRESAMPLE - if (_resample_ctx) { - // Resample the data to signed 16-bit sample format. - bufsize = swr_convert(_resample_ctx, (uint8_t **)&_buffer, _buffer_size / 2, (const uint8_t**)_frame->extended_data, _frame->nb_samples); - bufsize *= _audio_channels * 2; - } else -#endif - { - bufsize = _frame->linesize[0]; - memcpy(_buffer, _frame->data[0], bufsize); - } - } -#if LIBAVUTIL_VERSION_INT > AV_VERSION_INT(52, 19, 100) - av_frame_unref(_frame); -#endif - - if (len < 0) { - return false; - } else if (len == 0){ - return true; - } - _packet_data += len; - _packet_size -= len; - if (bufsize > 0) { - _buffer_head = 0; - _buffer_tail = (bufsize/2); - return true; - } - } else { + } else if (_packet_size == 0) { fetch_packet(); } + + AVPacket *pkt; +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) + pkt = av_packet_alloc(); +#else + AVPacket _pkt; + pkt = &_pkt; + av_init_packet(pkt); +#endif + pkt->data = _packet_data; + pkt->size = _packet_size; + + int len = avcodec_decode_audio4(_audio_ctx, _frame, &got_frame, pkt); + movies_debug("avcodec_decode_audio4 returned " << len); + +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) + av_packet_free(&pkt); +#else + av_free_packet(pkt); +#endif + + if (len < 0) { + return false; + } else if (len == 0) { + return true; + } + _packet_data += len; + _packet_size -= len; + } + + int bufsize; +#ifdef HAVE_SWRESAMPLE + if (_resample_ctx) { + // Resample the data to signed 16-bit sample format. + bufsize = swr_convert(_resample_ctx, (uint8_t **)&_buffer, _buffer_size / 2, (const uint8_t**)_frame->extended_data, _frame->nb_samples); + bufsize *= _audio_channels * 2; + } else +#endif + { + bufsize = _frame->linesize[0]; + memcpy(_buffer, _frame->data[0], bufsize); + } +#if LIBAVUTIL_VERSION_INT > AV_VERSION_INT(52, 19, 100) + av_frame_unref(_frame); +#endif + + if (bufsize > 0) { + _buffer_head = 0; + _buffer_tail = (bufsize/2); + return true; } return true; } From 62f9de101ad2c8aa7f09cc1214011b3832fd1d6d Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 31 Mar 2018 02:59:00 -0600 Subject: [PATCH 133/247] ffmpeg: Tell swresample the channel count --- panda/src/ffmpeg/ffmpegAudioCursor.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.cxx b/panda/src/ffmpeg/ffmpegAudioCursor.cxx index a897174bc2..bb12085774 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.cxx +++ b/panda/src/ffmpeg/ffmpegAudioCursor.cxx @@ -136,6 +136,8 @@ FfmpegAudioCursor(FfmpegAudio *src) : << "Codec does not use signed 16-bit sample format. Setting up swresample context.\n"; _resample_ctx = swr_alloc(); + av_opt_set_int(_resample_ctx, "in_channel_count", _audio_channels, 0); + av_opt_set_int(_resample_ctx, "out_channel_count", _audio_channels, 0); av_opt_set_int(_resample_ctx, "in_channel_layout", _audio_ctx->channel_layout, 0); av_opt_set_int(_resample_ctx, "out_channel_layout", _audio_ctx->channel_layout, 0); av_opt_set_int(_resample_ctx, "in_sample_rate", _audio_ctx->sample_rate, 0); From e430428703c149f400922399fa42c56a92023bb9 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 31 Mar 2018 03:12:00 -0600 Subject: [PATCH 134/247] ffmpeg: Add async audio decoding loop This leverages libavcodec >= 57.37.100's new asynchronous API, which both allows decoding in hardware and in a separate thread, and in any case would free up more CPU time for Panda's app loop. This also avoids use of the now-deprecated `avcodec_decode_audio4` --- panda/src/ffmpeg/ffmpegAudioCursor.cxx | 57 ++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.cxx b/panda/src/ffmpeg/ffmpegAudioCursor.cxx index bb12085774..651ec7cfb6 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.cxx +++ b/panda/src/ffmpeg/ffmpegAudioCursor.cxx @@ -299,6 +299,62 @@ fetch_packet() { */ bool FfmpegAudioCursor:: reload_buffer() { +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 37, 100) + // lavc >= 57.37.100 deprecates the old (avcodec_decode_audio*) API in favor + // of a newer, asynchronous API. This is great for our purposes - it gives + // the codec the opportunity to decode in the background (e.g. in another + // thread or on a dedicated hardware coprocessor). + + // First, let's fill the codec's input buffer with as many packets as it'll + // take: + int ret; + while (_packet->data != nullptr) { + ret = avcodec_send_packet(_audio_ctx, _packet); + + if (ret != 0) { + // Nonzero return code is an error. + break; + } + + // If we got here, the codec took the packet! Fetch another one. + fetch_packet(); + if (_packet->data == nullptr) { + // fetch_packet() says we're out of packets. Let the codec know. + ret = avcodec_send_packet(_audio_ctx, NULL); + } + } + + // Expected ret codes are 0 (we ran out of packets) and EAGAIN (codec full) + if ((ret != 0) && (ret != AVERROR(EAGAIN))) { + // Some odd error happened. We can't proceed. + ffmpeg_cat.error() + << "avcodec_send_packet returned " << ret << "\n"; + return false; + } + + // Now we retrieve our frame! + ret = avcodec_receive_frame(_audio_ctx, _frame); + + if (ret == AVERROR_EOF) { + // The only way for this to happen is if we're out of packets. + nassertr(_packet->data == nullptr, false); + + // Synthesize silence: + _buffer_head = 0; + _buffer_tail = _buffer_size; + memset(_buffer, 0, _buffer_size * 2); + return true; + + } else if (ret != 0) { + // Some odd error happened. We can't proceed. + ffmpeg_cat.error() + << "avcodec_receive_frame returned " << ret << "\n"; + return false; + } + + // We now have _frame. It will be handled below. + +#else int got_frame = 0; while (!got_frame) { // If we're out of packets, generate silence. @@ -339,6 +395,7 @@ reload_buffer() { _packet_data += len; _packet_size -= len; } +#endif int bufsize; #ifdef HAVE_SWRESAMPLE From 8d36908556d42d0c6feaf3199edb78f6c0cdb312 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 31 Mar 2018 03:25:03 -0600 Subject: [PATCH 135/247] ffmpeg: Use `avcodec_flush_buffers` when seeking Previously this would close and reopen the codec context; that's entirely unnecessary, as all supported versions of libavcodec support flushing the buffers instead. --- panda/src/ffmpeg/ffmpegAudioCursor.cxx | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.cxx b/panda/src/ffmpeg/ffmpegAudioCursor.cxx index 651ec7cfb6..ef6cd14d92 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.cxx +++ b/panda/src/ffmpeg/ffmpegAudioCursor.cxx @@ -437,16 +437,7 @@ seek(double t) { cleanup(); return; } - avcodec_close(_audio_ctx); - AVCodec *pAudioCodec = avcodec_find_decoder(_audio_ctx->codec_id); - if(pAudioCodec == 0) { - cleanup(); - return; - } - if (avcodec_open2(_audio_ctx, pAudioCodec, NULL) < 0) { - cleanup(); - return; - } + avcodec_flush_buffers(_audio_ctx); _buffer_head = 0; _buffer_tail = 0; fetch_packet(); From bb6e0abeba379a4820ce5c04bd6148343f22fc3b Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 31 Mar 2018 03:35:59 -0600 Subject: [PATCH 136/247] ffmpeg: Switch the video cursor to the new decoding API --- panda/src/ffmpeg/ffmpegVideoCursor.cxx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.cxx b/panda/src/ffmpeg/ffmpegVideoCursor.cxx index cf2b01bf5c..21137b30e8 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx +++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx @@ -903,7 +903,18 @@ decode_frame(int &finished) { */ void FfmpegVideoCursor:: do_decode_frame(int &finished) { +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 37, 100) + // While the audio cursor has a really nice async loop for decoding, we + // don't really do that much with video since we're already delegated to + // another thread here. This is just to silence the deprecation warning + // on avcodec_decode_video2. + avcodec_send_packet(_video_ctx, _packet); + + int ret = avcodec_receive_frame(_video_ctx, _frame); + finished = (ret == 0); +#else avcodec_decode_video2(_video_ctx, _frame, &finished, _packet); +#endif } /** From fadbcd91e5f77019d9ec3e346247e3c8ded46f87 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 31 Mar 2018 05:22:04 -0600 Subject: [PATCH 137/247] ffmpeg: Bump supported minimums lower for libav 9.20 We need to support this because Ubuntu 14.04 ships with this version, and has no "backports" option to bring in a newer version (without use of a PPA or compiling it yourself). We can consider raising the minimums again once Trusty is EOL. --- panda/src/ffmpeg/config_ffmpeg.cxx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/panda/src/ffmpeg/config_ffmpeg.cxx b/panda/src/ffmpeg/config_ffmpeg.cxx index be788eb2f8..850cf62937 100644 --- a/panda/src/ffmpeg/config_ffmpeg.cxx +++ b/panda/src/ffmpeg/config_ffmpeg.cxx @@ -30,16 +30,19 @@ extern "C" { #error Buildsystem error: BUILDING_FFMPEG not defined #endif -#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 86, 100) - #error Minimum supported version of libavcodec is 54.86.100. +// Minimum supported versions: +// FFmpeg: 1.1 +// libav: 9.20 (for Ubuntu 14.04) +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 35, 1) + #error Minimum supported version of libavcodec is 54.35.1. #endif -#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(54, 59, 106) - #error Minimum supported version of libavformat is 54.59.106. +#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(54, 20, 4) + #error Minimum supported version of libavformat is 54.20.4. #endif -#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(52, 13, 100) - #error Minimum supported version of libavutil is 52.13.100. +#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(52, 3, 0) + #error Minimum supported version of libavutil is 52.3.0. #endif ConfigureDef(config_ffmpeg); From e9ae7dcc407d8198a701b761d0431f456c8ad925 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 2 Apr 2018 23:16:03 +0200 Subject: [PATCH 138/247] Use vector_uchar instead of string for binary network/file data This distinction allows us to better support Python 3, since it will raise exceptions when trying to put arbitrary binary data in a str object. This also adds some convenience functions for efficiently initializing a Datagram or PTA_uchar from a vector_uchar. --- .../src/distributed/cConnectionRepository.cxx | 6 +- dtool/src/prc/encryptStreamBuf.cxx | 7 ++- dtool/src/prc/streamReader.cxx | 12 ++-- dtool/src/prc/streamReader.h | 3 +- panda/src/downloader/downloadDb.cxx | 55 ++++++---------- panda/src/downloader/downloadDb.h | 8 +-- panda/src/downloader/socketStream.cxx | 19 +++--- panda/src/downloader/socketStream.h | 3 +- panda/src/express/datagram.I | 62 +++---------------- panda/src/express/datagram.h | 13 +--- panda/src/express/datagramIterator.I | 11 ++-- panda/src/express/datagramIterator.cxx | 14 ++--- panda/src/express/datagramIterator.h | 4 +- panda/src/express/hashVal.cxx | 6 +- panda/src/express/hashVal.h | 4 +- panda/src/express/multifile.cxx | 6 +- panda/src/express/pointerToArray.I | 26 ++++++++ panda/src/express/pointerToArray.h | 2 + panda/src/express/pointerToArrayBase.I | 10 +++ panda/src/express/pointerToArrayBase.h | 1 + panda/src/gobj/texture.cxx | 4 +- panda/src/movies/wavAudioCursor.cxx | 11 ++-- panda/src/recorder/socketStreamRecorder.cxx | 6 +- pandatool/src/flt/fltBeadID.cxx | 12 ++-- pandatool/src/flt/fltRecord.cxx | 5 +- 25 files changed, 143 insertions(+), 167 deletions(-) diff --git a/direct/src/distributed/cConnectionRepository.cxx b/direct/src/distributed/cConnectionRepository.cxx index 67d6ec1658..e247c2bd55 100644 --- a/direct/src/distributed/cConnectionRepository.cxx +++ b/direct/src/distributed/cConnectionRepository.cxx @@ -803,8 +803,9 @@ handle_update_field_owner() { Py_DECREF(dclass_this); // check if we should forward this update to the owner view + vector_uchar data = _di.get_remaining_bytes(); DCPacker packer; - packer.set_unpack_data(_di.get_remaining_bytes()); + packer.set_unpack_data((const char *)data.data(), data.size(), false); int field_id = packer.raw_unpack_uint16(); DCField *field = dclass->get_field_by_index(field_id); if (field->is_ownrecv()) { @@ -845,8 +846,9 @@ handle_update_field_owner() { Py_DECREF(dclass_this); // check if we should forward this update to the owner view + vector_uchar data = _di.get_remaining_bytes(); DCPacker packer; - packer.set_unpack_data(_di.get_remaining_bytes()); + packer.set_unpack_data((const char *)data.data(), data.size(), false); int field_id = packer.raw_unpack_uint16(); DCField *field = dclass->get_field_by_index(field_id); if (true) {//field->is_broadcast()) { diff --git a/dtool/src/prc/encryptStreamBuf.cxx b/dtool/src/prc/encryptStreamBuf.cxx index 21a33f93c0..dc38ac5894 100644 --- a/dtool/src/prc/encryptStreamBuf.cxx +++ b/dtool/src/prc/encryptStreamBuf.cxx @@ -146,14 +146,15 @@ open_read(istream *source, bool owns_source, const string &password) { int iv_length = EVP_CIPHER_iv_length(cipher); _read_block_size = EVP_CIPHER_block_size(cipher); - string iv = sr.extract_bytes(iv_length); + unsigned char *iv = (unsigned char *)alloca(iv_length); + iv_length = (int)sr.extract_bytes(iv, iv_length); _read_ctx = EVP_CIPHER_CTX_new(); nassertv(_read_ctx != NULL); // Initialize the context int result; - result = EVP_DecryptInit(_read_ctx, cipher, NULL, (unsigned char *)iv.data()); + result = EVP_DecryptInit(_read_ctx, cipher, NULL, (unsigned char *)iv); nassertv(result > 0); result = EVP_CIPHER_CTX_set_key_length(_read_ctx, key_length); @@ -170,7 +171,7 @@ open_read(istream *source, bool owns_source, const string &password) { unsigned char *key = (unsigned char *)alloca(key_length); result = PKCS5_PBKDF2_HMAC_SHA1((const char *)password.data(), password.length(), - (unsigned char *)iv.data(), iv.length(), + iv, iv_length, count * iteration_count_factor + 1, key_length, key); nassertv(result > 0); diff --git a/dtool/src/prc/streamReader.cxx b/dtool/src/prc/streamReader.cxx index 17252f5dd2..e9fa173ad1 100644 --- a/dtool/src/prc/streamReader.cxx +++ b/dtool/src/prc/streamReader.cxx @@ -117,16 +117,18 @@ extract_bytes(unsigned char *into, size_t size) { * Extracts the indicated number of bytes in the stream and returns them as a * string. Returns empty string at end-of-file. */ -string StreamReader:: +vector_uchar StreamReader:: extract_bytes(size_t size) { + vector_uchar buffer; if (_in->eof() || _in->fail()) { - return string(); + return buffer; } - char *buffer = (char *)alloca(size); - _in->read(buffer, size); + buffer.resize(size); + _in->read((char *)&buffer[0], size); size_t read_bytes = _in->gcount(); - return string(buffer, read_bytes); + buffer.resize(read_bytes); + return buffer; } /** diff --git a/dtool/src/prc/streamReader.h b/dtool/src/prc/streamReader.h index bedaa0eeb5..1643dd4a9c 100644 --- a/dtool/src/prc/streamReader.h +++ b/dtool/src/prc/streamReader.h @@ -19,6 +19,7 @@ #include "numeric_types.h" #include "littleEndian.h" #include "bigEndian.h" +#include "vector_uchar.h" /** * A class to read sequential binary data directly from an istream. Its @@ -71,7 +72,7 @@ PUBLISHED: EXTENSION(BLOCKING PyObject *readlines()); public: - BLOCKING string extract_bytes(size_t size); + BLOCKING vector_uchar extract_bytes(size_t size); BLOCKING string readline(); private: diff --git a/panda/src/downloader/downloadDb.cxx b/panda/src/downloader/downloadDb.cxx index f2a734af17..a210fba8bd 100644 --- a/panda/src/downloader/downloadDb.cxx +++ b/panda/src/downloader/downloadDb.cxx @@ -583,9 +583,7 @@ add_multifile_record(PT(MultifileRecord) mfr) { * Verifies magic number, returns the number of multifiles or -1 if invalid */ int DownloadDb::Db:: -parse_header(const string &data) { - Datagram dg(data); - +parse_header(Datagram dg) { // Make sure we have a good header DatagramIterator di(dg); uint32_t magic_number = di.get_uint32(); @@ -623,8 +621,7 @@ parse_header(const string &data) { * record */ int DownloadDb::Db:: -parse_record_header(const string &data) { - Datagram dg(data); +parse_record_header(Datagram dg) { DatagramIterator di(dg); int32_t record_length = di.get_int32(); downloader_cat.spam() @@ -639,14 +636,12 @@ parse_record_header(const string &data) { * Parses a multifile record (mfr) and returns one */ PT(DownloadDb::MultifileRecord) DownloadDb::Db:: -parse_mfr(const string &data) { +parse_mfr(Datagram dg) { PT(DownloadDb::MultifileRecord) mfr = new DownloadDb::MultifileRecord; - Datagram dg(data); DatagramIterator di(dg); - int32_t mfr_name_length = di.get_int32(); - mfr->_name = di.extract_bytes(mfr_name_length); + mfr->_name = di.get_string32(); mfr->_phase = di.get_float64(); mfr->_size = di.get_int32(); mfr->_status = di.get_int32(); @@ -676,14 +671,12 @@ parse_mfr(const string &data) { * Parses a file record (fr) and returns one */ PT(DownloadDb::FileRecord) DownloadDb::Db:: -parse_fr(const string &data) { +parse_fr(Datagram dg) { PT(DownloadDb::FileRecord) fr = new DownloadDb::FileRecord; - Datagram dg(data); DatagramIterator di(dg); - int32_t fr_name_length = di.get_int32(); - fr->_name = di.extract_bytes(fr_name_length); + fr->_name = di.get_string32(); // At one time, we stored files in the database with a backslash separator. // Nowadays we use a forward slash, but we should make sure we properly @@ -706,15 +699,14 @@ parse_fr(const string &data) { bool DownloadDb::Db:: read(StreamReader &sr, bool want_server_info) { // Read the header - string header; - header = sr.extract_bytes(_header_length); + vector_uchar header = sr.extract_bytes(_header_length); if (header.size() != (size_t)_header_length) { downloader_cat.error() << "truncated db file" << endl; return false; } // Parse the header - int num_multifiles = parse_header(header); + int num_multifiles = parse_header(Datagram(move(header))); if (num_multifiles < 0) { downloader_cat.error() << "invalid db header" << endl; return false; @@ -727,26 +719,26 @@ read(StreamReader &sr, bool want_server_info) { // of the record int mfr_header_length = sizeof(int32_t); - string mfr_header = sr.extract_bytes(mfr_header_length); + vector_uchar mfr_header = sr.extract_bytes(mfr_header_length); if (mfr_header.size() != (size_t)mfr_header_length) { downloader_cat.error() << "invalid mfr header" << endl; return false; } // Parse the header - int mfr_length = parse_record_header(mfr_header); + int mfr_length = parse_record_header(Datagram(move(mfr_header))); // Ok, now that we know the size of the mfr, read it in Make a buffer to // read the multifile record into do not count the header length twice int read_length = (mfr_length - mfr_header_length); - string mfr_record = sr.extract_bytes(read_length); + vector_uchar mfr_record = sr.extract_bytes(read_length); if (mfr_record.size() != (size_t)read_length) { downloader_cat.error() << "invalid mfr record" << endl; return false; } // Parse the mfr - PT(DownloadDb::MultifileRecord) mfr = parse_mfr(mfr_record); + PT(DownloadDb::MultifileRecord) mfr = parse_mfr(Datagram(move(mfr_record))); // Only read in the individual file info if you are the server if (want_server_info) { @@ -758,27 +750,27 @@ read(StreamReader &sr, bool want_server_info) { int fr_header_length = sizeof(int32_t); // Read the header - string fr_header = sr.extract_bytes(fr_header_length); + vector_uchar fr_header = sr.extract_bytes(fr_header_length); if (fr_header.size() != (size_t)fr_header_length) { downloader_cat.error() << "invalid fr header" << endl; return false; } // Parse the header - int fr_length = parse_record_header(fr_header); + int fr_length = parse_record_header(Datagram(move(fr_header))); // Ok, now that we know the size of the mfr, read it in do not count // the header length twice int read_length = (fr_length - fr_header_length); - string fr_record = sr.extract_bytes(read_length); + vector_uchar fr_record = sr.extract_bytes(read_length); if (fr_record.size() != (size_t)read_length) { downloader_cat.error() << "invalid fr record" << endl; return false; } // Parse the file record - PT(DownloadDb::FileRecord) fr = parse_fr(fr_record); + PT(DownloadDb::FileRecord) fr = parse_fr(Datagram(move(fr_record))); // Add this file record to the current multifilerecord mfr->add_file_record(fr); @@ -900,12 +892,10 @@ write_header(ostream &write_stream) { // Write the number of multifiles dg.add_int32(get_num_multifiles()); - string msg = dg.get_message(); - // Seek back to the beginning of the write stream write_stream.seekp(0); // Overwrite the old bogus header with the real header - write_stream.write(msg.data(), msg.length()); + write_stream.write((const char *)dg.get_data(), dg.get_length()); return true; } @@ -1100,17 +1090,8 @@ read_version_map(StreamReader &sr) { for (int i = 0; i < num_entries; i++) { - // Get the length of the file name - int name_length = sr.get_int32(); - if (sr.get_istream()->fail()) { - return false; - } - downloader_cat.spam() - << "DownloadDb::read_version_map() - name length: " << name_length - << endl; - // Get the file name - string name = sr.extract_bytes(name_length); + string name = sr.get_string32(); downloader_cat.spam() << "DownloadDb::read_version_map() - name: " << name << endl; diff --git a/panda/src/downloader/downloadDb.h b/panda/src/downloader/downloadDb.h index 02adedb3d6..b7f206c3b6 100644 --- a/panda/src/downloader/downloadDb.h +++ b/panda/src/downloader/downloadDb.h @@ -171,10 +171,10 @@ public: bool multifile_exists(string mfname) const; PT(MultifileRecord) get_multifile_record_named(string mfname) const; void add_multifile_record(PT(MultifileRecord) mfr); - int parse_header(const string &data); - int parse_record_header(const string &data); - PT(MultifileRecord) parse_mfr(const string &data); - PT(FileRecord) parse_fr(const string &data); + int parse_header(Datagram dg); + int parse_record_header(Datagram dg); + PT(MultifileRecord) parse_mfr(Datagram dg); + PT(FileRecord) parse_fr(Datagram dg); bool read(StreamReader &sr, bool want_server_info); bool write(StreamWriter &sw, bool want_server_info); Filename _filename; diff --git a/panda/src/downloader/socketStream.cxx b/panda/src/downloader/socketStream.cxx index af43847fb5..4e441f8f2b 100644 --- a/panda/src/downloader/socketStream.cxx +++ b/panda/src/downloader/socketStream.cxx @@ -50,17 +50,17 @@ SSReader:: bool SSReader:: do_receive_datagram(Datagram &dg) { if (_tcp_header_size == 0) { - _data_expected = _data_so_far.length(); + _data_expected = _data_so_far.size(); } if (_data_expected == 0) { // Read the first two bytes: the datagram length. - while ((int)_data_so_far.length() < _tcp_header_size) { + while ((int)_data_so_far.size() < _tcp_header_size) { int ch = _istream->get(); if (_istream->eof() || _istream->fail()) { _istream->clear(); return false; } - _data_so_far += (char)ch; + _data_so_far.push_back((unsigned char)ch); } Datagram header(_data_so_far); @@ -70,7 +70,7 @@ do_receive_datagram(Datagram &dg) { } else if (_tcp_header_size == 4) { _data_expected = di.get_uint32(); } - _data_so_far = _data_so_far.substr(_tcp_header_size); + _data_so_far.erase(_data_so_far.begin(), _data_so_far.begin() + _tcp_header_size); if (_data_expected == 0) { // Empty datagram. @@ -84,20 +84,19 @@ do_receive_datagram(Datagram &dg) { static const size_t buffer_size = 1024; char buffer[buffer_size]; - size_t read_count = min(_data_expected - _data_so_far.length(), - buffer_size); + size_t read_count = min(_data_expected - _data_so_far.size(), buffer_size); _istream->read(buffer, read_count); size_t count = _istream->gcount(); while (count != 0) { - _data_so_far.append(buffer, count); + _data_so_far.insert(_data_so_far.end(), buffer, buffer + count); - read_count = min(_data_expected - _data_so_far.length(), + read_count = min(_data_expected - _data_so_far.size(), buffer_size); _istream->read(buffer, read_count); count = _istream->gcount(); } - if (_data_so_far.length() < _data_expected) { + if (_data_so_far.size() < _data_expected) { // Not yet here. Clear the istream error flag and return false to // indicate more coming. _istream->clear(); @@ -108,7 +107,7 @@ do_receive_datagram(Datagram &dg) { dg.append_data(_data_so_far); _data_expected = 0; - _data_so_far = string(); + _data_so_far.clear(); return true; } diff --git a/panda/src/downloader/socketStream.h b/panda/src/downloader/socketStream.h index 36065e42af..84ce907a5e 100644 --- a/panda/src/downloader/socketStream.h +++ b/panda/src/downloader/socketStream.h @@ -21,6 +21,7 @@ #include "pdeque.h" #include "typedReferenceCount.h" #include "pointerTo.h" +#include "vector_uchar.h" // At the present, this module is not compiled if OpenSSL is not available, // since the only current use for it is to implement OpenSSL-defined @@ -54,7 +55,7 @@ private: istream *_istream; size_t _data_expected; - string _data_so_far; + vector_uchar _data_so_far; int _tcp_header_size; #ifdef SIMULATE_NETWORK_DELAY diff --git a/panda/src/express/datagram.I b/panda/src/express/datagram.I index fa6063805b..3bd7812969 100644 --- a/panda/src/express/datagram.I +++ b/panda/src/express/datagram.I @@ -42,58 +42,16 @@ Datagram(const void *data, size_t size) : * Constructs a datagram from an existing block of data. */ INLINE Datagram:: -Datagram(const string &data) : +Datagram(vector_uchar data) : + _data(move(data)), #ifdef STDFLOAT_DOUBLE _stdfloat_double(true) #else _stdfloat_double(false) #endif { - append_data(data); } -/** - * - */ -INLINE Datagram:: -Datagram(const Datagram ©) : - _data(copy._data), - _stdfloat_double(copy._stdfloat_double) -{ -} - -/** - * - */ -INLINE void Datagram:: -operator = (const Datagram ©) { - _data = copy._data; - _stdfloat_double = copy._stdfloat_double; -} - -#ifdef USE_MOVE_SEMANTICS -/** - * - */ -INLINE Datagram:: -Datagram(Datagram &&from) NOEXCEPT : - _data(move(from._data)), - _stdfloat_double(from._stdfloat_double) -{ -} -#endif // USE_MOVE_SEMANTICS - -#ifdef USE_MOVE_SEMANTICS -/** - * - */ -INLINE void Datagram:: -operator = (Datagram &&from) NOEXCEPT { - _data = move(from._data); - _stdfloat_double = from._stdfloat_double; -} -#endif // USE_MOVE_SEMANTICS - /** * Adds a boolean value to the datagram. */ @@ -291,7 +249,7 @@ add_string(const string &str) { add_uint16((uint16_t)str.length()); // Add the string - append_data(str); + append_data(str.data(), str.length()); } /** @@ -304,18 +262,18 @@ add_string32(const string &str) { add_uint32((uint32_t)str.length()); // Add the string - append_data(str); + append_data(str.data(), str.length()); } /** * Adds a variable-length string to the datagram, as a NULL-terminated string. */ INLINE void Datagram:: -add_z_string(string str) { +add_z_string(const string &str) { // We must not have any nested null characters in the string. size_t null_pos = str.find('\0'); // Add the string (sans the null character). - append_data(str.substr(0, null_pos)); + append_data(str.data(), std::min(null_pos, str.length())); // And the null character. add_uint8('\0'); @@ -329,11 +287,11 @@ add_z_string(string str) { INLINE void Datagram:: add_fixed_string(const string &str, size_t size) { if (str.length() < size) { - append_data(str); + append_data(str.data(), str.length()); pad_bytes(size - str.length()); } else { // str.length() >= size - append_data(str.substr(0, size)); + append_data(str.data(), size); } } @@ -341,8 +299,8 @@ add_fixed_string(const string &str, size_t size) { * Appends some more raw data to the end of the datagram. */ INLINE void Datagram:: -append_data(const string &data) { - append_data(data.data(), data.length()); +append_data(const vector_uchar &data) { + append_data(data.data(), data.size()); } /** diff --git a/panda/src/express/datagram.h b/panda/src/express/datagram.h index c2cb3b4c8b..9250ac89d3 100644 --- a/panda/src/express/datagram.h +++ b/panda/src/express/datagram.h @@ -39,14 +39,7 @@ class EXPCL_PANDAEXPRESS Datagram : public TypedObject { PUBLISHED: INLINE Datagram(); INLINE Datagram(const void *data, size_t size); - INLINE Datagram(const string &data); - INLINE Datagram(const Datagram ©); - INLINE void operator = (const Datagram ©); - -#ifdef USE_MOVE_SEMANTICS - INLINE Datagram(Datagram &&from) NOEXCEPT; - INLINE void operator = (Datagram &&from) NOEXCEPT; -#endif + INLINE explicit Datagram(vector_uchar data); virtual ~Datagram(); @@ -80,13 +73,13 @@ PUBLISHED: INLINE void add_string(const string &str); INLINE void add_string32(const string &str); - INLINE void add_z_string(string str); + INLINE void add_z_string(const string &str); INLINE void add_fixed_string(const string &str, size_t size); void add_wstring(const wstring &str); void pad_bytes(size_t size); void append_data(const void *data, size_t size); - INLINE void append_data(const string &data); + INLINE void append_data(const vector_uchar &data); void assign(const void *data, size_t size); diff --git a/panda/src/express/datagramIterator.I b/panda/src/express/datagramIterator.I index cefde399f2..42c25eeed4 100644 --- a/panda/src/express/datagramIterator.I +++ b/panda/src/express/datagramIterator.I @@ -422,14 +422,13 @@ skip_bytes(size_t size) { * Returns the remaining bytes in the datagram as a string, but does not * extract them from the iterator. */ -INLINE string DatagramIterator:: +INLINE vector_uchar DatagramIterator:: get_remaining_bytes() const { - nassertr(_datagram != (const Datagram *)NULL, ""); - nassertr(_current_index <= _datagram->get_length(), ""); + nassertr(_datagram != (const Datagram *)NULL, vector_uchar()); + nassertr(_current_index <= _datagram->get_length(), vector_uchar()); - const char *ptr = (const char *)_datagram->get_data(); - size_t remaining_size = _datagram->get_length() - _current_index; - return string(ptr + _current_index, remaining_size); + const unsigned char *ptr = (const unsigned char *)_datagram->get_data(); + return vector_uchar(ptr + _current_index, ptr + _datagram->get_length()); } /** diff --git a/panda/src/express/datagramIterator.cxx b/panda/src/express/datagramIterator.cxx index 22ac9ecb19..880719f32b 100644 --- a/panda/src/express/datagramIterator.cxx +++ b/panda/src/express/datagramIterator.cxx @@ -119,18 +119,18 @@ get_wstring() { * Extracts the indicated number of bytes in the datagram and returns them as * a string. */ -string DatagramIterator:: +vector_uchar DatagramIterator:: extract_bytes(size_t size) { - nassertr((int)size >= 0, ""); - nassertr(_datagram != (const Datagram *)NULL, ""); - nassertr(_current_index + size <= _datagram->get_length(), ""); + nassertr((int)size >= 0, vector_uchar()); + nassertr(_datagram != (const Datagram *)NULL, vector_uchar()); + nassertr(_current_index + size <= _datagram->get_length(), vector_uchar()); - const char *ptr = (const char *)_datagram->get_data(); - size_t last_index = _current_index; + const unsigned char *ptr = (const unsigned char *)_datagram->get_data(); + ptr += _current_index; _current_index += size; - return string(ptr + last_index, size); + return vector_uchar(ptr, ptr + size); } /** diff --git a/panda/src/express/datagramIterator.h b/panda/src/express/datagramIterator.h index 7126901324..ec76be3f07 100644 --- a/panda/src/express/datagramIterator.h +++ b/panda/src/express/datagramIterator.h @@ -62,10 +62,10 @@ PUBLISHED: wstring get_wstring(); INLINE void skip_bytes(size_t size); - string extract_bytes(size_t size); + vector_uchar extract_bytes(size_t size); size_t extract_bytes(unsigned char *into, size_t size); - INLINE string get_remaining_bytes() const; + INLINE vector_uchar get_remaining_bytes() const; INLINE size_t get_remaining_size() const; INLINE const Datagram &get_datagram() const; diff --git a/panda/src/express/hashVal.cxx b/panda/src/express/hashVal.cxx index 7d52dc5a5e..aa08714668 100644 --- a/panda/src/express/hashVal.cxx +++ b/panda/src/express/hashVal.cxx @@ -143,11 +143,11 @@ set_from_hex(const string &text) { /** * Returns the HashVal as a 16-byte binary string. */ -string HashVal:: +vector_uchar HashVal:: as_bin() const { Datagram dg; write_datagram(dg); - return dg.get_message(); + return vector_uchar((unsigned char *)dg.get_data(), (unsigned char *)dg.get_data() + dg.get_length()); } /** @@ -155,7 +155,7 @@ as_bin() const { * false otherwise. */ bool HashVal:: -set_from_bin(const string &text) { +set_from_bin(const vector_uchar &text) { nassertr(text.size() == 16, false); Datagram dg(text); DatagramIterator dgi(dg); diff --git a/panda/src/express/hashVal.h b/panda/src/express/hashVal.h index d0652d1e01..a4b3754614 100644 --- a/panda/src/express/hashVal.h +++ b/panda/src/express/hashVal.h @@ -55,8 +55,8 @@ PUBLISHED: string as_hex() const; bool set_from_hex(const string &text); - string as_bin() const; - bool set_from_bin(const string &text); + vector_uchar as_bin() const; + bool set_from_bin(const vector_uchar &text); INLINE void write_datagram(Datagram &destination) const; INLINE void read_datagram(DatagramIterator &source); diff --git a/panda/src/express/multifile.cxx b/panda/src/express/multifile.cxx index 0d98849efe..5a7d86f17b 100644 --- a/panda/src/express/multifile.cxx +++ b/panda/src/express/multifile.cxx @@ -2402,7 +2402,7 @@ check_signatures() { nassertv(stream != NULL); StreamReader reader(*stream); size_t sig_size = reader.get_uint32(); - string sig_string = reader.extract_bytes(sig_size); + vector_uchar sig_data = reader.extract_bytes(sig_size); size_t num_certs = reader.get_uint32(); @@ -2470,9 +2470,7 @@ check_signatures() { // Now check that the signature matches the hash. int verify_result = - EVP_VerifyFinal(md_ctx, - (unsigned char *)sig_string.data(), - sig_string.size(), pkey); + EVP_VerifyFinal(md_ctx, sig_data.data(), sig_data.size(), pkey); if (verify_result == 1) { // The signature matches; save the certificate and its chain. _signatures.push_back(chain); diff --git a/panda/src/express/pointerToArray.I b/panda/src/express/pointerToArray.I index c3a10f3737..535de63d01 100644 --- a/panda/src/express/pointerToArray.I +++ b/panda/src/express/pointerToArray.I @@ -92,6 +92,19 @@ PointerToArray(PointerToArray &&from) NOEXCEPT : } #endif // USE_MOVE_SEMANTICS +#ifdef USE_MOVE_SEMANTICS +/** + * Initializes the PTA from a vector. + */ +template +INLINE PointerToArray:: +PointerToArray(pvector &&from, TypeHandle type_handle) : + PointerToArrayBase(new ReferenceCountedVector(move(from))), + _type_handle(type_handle) +{ +} +#endif // USE_MOVE_SEMANTICS + /** * */ @@ -710,6 +723,19 @@ ConstPointerToArray(ConstPointerToArray &&from) NOEXCEPT : } #endif // USE_MOVE_SEMANTICS +#ifdef USE_MOVE_SEMANTICS +/** + * Initializes the PTA from a vector. + */ +template +INLINE ConstPointerToArray:: +ConstPointerToArray(pvector &&from, TypeHandle type_handle) : + PointerToArrayBase(new ReferenceCountedVector(move(from))), + _type_handle(type_handle) +{ +} +#endif // USE_MOVE_SEMANTICS + /** * */ diff --git a/panda/src/express/pointerToArray.h b/panda/src/express/pointerToArray.h index 762a6cb8ce..4e8a052e0f 100644 --- a/panda/src/express/pointerToArray.h +++ b/panda/src/express/pointerToArray.h @@ -141,6 +141,7 @@ public: #ifdef USE_MOVE_SEMANTICS INLINE PointerToArray(PointerToArray &&from) NOEXCEPT; + INLINE explicit PointerToArray(pvector &&from, TypeHandle type_handle = get_type_handle(Element)); #endif public: @@ -302,6 +303,7 @@ PUBLISHED: #ifdef USE_MOVE_SEMANTICS INLINE ConstPointerToArray(PointerToArray &&from) NOEXCEPT; INLINE ConstPointerToArray(ConstPointerToArray &&from) NOEXCEPT; + INLINE explicit ConstPointerToArray(pvector &&from, TypeHandle type_handle = get_type_handle(Element)); #endif // Duplicating the interface of vector. diff --git a/panda/src/express/pointerToArrayBase.I b/panda/src/express/pointerToArrayBase.I index 89acba1206..de8c17d843 100644 --- a/panda/src/express/pointerToArrayBase.I +++ b/panda/src/express/pointerToArrayBase.I @@ -39,6 +39,16 @@ ReferenceCountedVector(const Element *begin, const Element *end, TypeHandle type { } +/** + * Creates an array that takes its elements from the given vector. + */ +template +INLINE ReferenceCountedVector:: +ReferenceCountedVector(pvector &&from) : + pvector(move(from)) +{ +} + /** * */ diff --git a/panda/src/express/pointerToArrayBase.h b/panda/src/express/pointerToArrayBase.h index 3220ca4c70..8c33f69be2 100644 --- a/panda/src/express/pointerToArrayBase.h +++ b/panda/src/express/pointerToArrayBase.h @@ -43,6 +43,7 @@ public: INLINE ReferenceCountedVector(TypeHandle type_handle); INLINE ReferenceCountedVector(size_type initial_size, TypeHandle type_handle); INLINE ReferenceCountedVector(const Element *begin, const Element *end, TypeHandle type_handle); + INLINE ReferenceCountedVector(pvector &&from); ALLOC_DELETED_CHAIN(ReferenceCountedVector); INLINE size_type size() const; diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index c4a8149ab4..5328b921d9 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -4207,7 +4207,9 @@ bool Texture:: do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only) { StreamReader ktx(in); - if (ktx.extract_bytes(12) != "\xABKTX 11\xBB\r\n\x1A\n") { + unsigned char magic[12]; + if (ktx.extract_bytes(magic, 12) != 12 || + memcmp(magic, "\xABKTX 11\xBB\r\n\x1A\n", 12) != 0) { gobj_cat.error() << filename << " is not a KTX file.\n"; return false; diff --git a/panda/src/movies/wavAudioCursor.cxx b/panda/src/movies/wavAudioCursor.cxx index 3b220749c4..ccfaa9733e 100644 --- a/panda/src/movies/wavAudioCursor.cxx +++ b/panda/src/movies/wavAudioCursor.cxx @@ -106,7 +106,8 @@ WavAudioCursor(WavAudio *src, istream *stream) : nassertv(stream != NULL); // Beginning of "RIFF" chunk. - if (_reader.extract_bytes(4) != "RIFF") { + unsigned char magic[4]; + if (_reader.extract_bytes(magic, 4) != 4 || memcmp(magic, "RIFF", 4) != 0) { movies_cat.error() << ".wav file is not a valid RIFF file.\n"; return; @@ -114,7 +115,7 @@ WavAudioCursor(WavAudio *src, istream *stream) : unsigned int chunk_size = _reader.get_uint32(); - if (_reader.extract_bytes(4) != "WAVE") { + if (_reader.extract_bytes(magic, 4) != 4 || memcmp(magic, "WAVE", 4) != 0) { movies_cat.error() << ".wav file is a RIFF file but does not start with a WAVE chunk.\n"; return; @@ -126,10 +127,10 @@ WavAudioCursor(WavAudio *src, istream *stream) : while ((!have_fmt || !have_data) && _stream->good() && (bytes_read + 8) < chunk_size) { - string subchunk_id = _reader.extract_bytes(4); + _reader.extract_bytes(magic, 4); unsigned int subchunk_size = _reader.get_uint32(); - if (subchunk_id == "fmt ") { + if (memcmp(magic, "fmt ", 4) == 0) { // The format chunk specifies information about the storage. nassertv(subchunk_size >= 16); have_fmt = true; @@ -202,7 +203,7 @@ WavAudioCursor(WavAudio *src, istream *stream) : _reader.skip_bytes(subchunk_size - read_bytes); } - } else if (subchunk_id == "data") { + } else if (memcmp(magic, "data", 4) == 0) { // The data chunk contains the actual sammples. if (!have_fmt) { movies_cat.error() diff --git a/panda/src/recorder/socketStreamRecorder.cxx b/panda/src/recorder/socketStreamRecorder.cxx index 1b9493fc03..6209239044 100644 --- a/panda/src/recorder/socketStreamRecorder.cxx +++ b/panda/src/recorder/socketStreamRecorder.cxx @@ -82,8 +82,10 @@ play_frame(DatagramIterator &scan, BamReader *manager) { int num_packets = scan.get_uint16(); for (int i = 0; i < num_packets; i++) { - string packet = scan.get_string(); - _data.push_back(Datagram(packet)); + size_t size = scan.get_uint16(); + vector_uchar packet(size); + scan.extract_bytes(&packet[0], size); + _data.push_back(Datagram(move(packet))); } } diff --git a/pandatool/src/flt/fltBeadID.cxx b/pandatool/src/flt/fltBeadID.cxx index 6346d6282e..f55d3e88cc 100644 --- a/pandatool/src/flt/fltBeadID.cxx +++ b/pandatool/src/flt/fltBeadID.cxx @@ -78,9 +78,8 @@ extract_record(FltRecordReader &reader) { bool FltBeadID:: extract_ancillary(FltRecordReader &reader) { if (reader.get_opcode() == FO_long_id) { - string s = reader.get_iterator().get_remaining_bytes(); - size_t zero_byte = s.find('\0'); - _id = s.substr(0, zero_byte); + vector_uchar s = reader.get_iterator().get_remaining_bytes(); + _id.assign((const char *)s.data(), strnlen((const char *)s.data(), s.size())); return true; } @@ -109,14 +108,11 @@ build_record(FltRecordWriter &writer) const { FltError FltBeadID:: write_ancillary(FltRecordWriter &writer) const { if (_id.length() > 7) { + Datagram dc; // Although the manual mentions nothing of this, it is essential that the // length of the record be a multiple of 4 bytes. - string id = _id; - while ((id.length() % 4) != 0) { - id += '\0'; - } - Datagram dc(id); + dc.add_fixed_string(_id, (_id.length() + 3) & ~3); FltError result = writer.write_record(FO_long_id, dc); if (result != FE_ok) { diff --git a/pandatool/src/flt/fltRecord.cxx b/pandatool/src/flt/fltRecord.cxx index c3dc21d070..a0af83e180 100644 --- a/pandatool/src/flt/fltRecord.cxx +++ b/pandatool/src/flt/fltRecord.cxx @@ -621,7 +621,8 @@ extract_record(FltRecordReader &) { bool FltRecord:: extract_ancillary(FltRecordReader &reader) { if (reader.get_opcode() == FO_comment) { - _comment = reader.get_iterator().get_remaining_bytes(); + vector_uchar s = reader.get_iterator().get_remaining_bytes(); + _comment.assign((const char *)s.data(), strnlen((const char *)s.data(), s.size())); return true; } @@ -735,7 +736,7 @@ build_record(FltRecordWriter &) const { FltError FltRecord:: write_ancillary(FltRecordWriter &writer) const { if (!_comment.empty()) { - Datagram dc(_comment); + Datagram dc(_comment.data(), _comment.size()); FltError result = writer.write_record(FO_comment, dc); if (result != FE_ok) { return result; From 7cbdd3b6c49312b90489ba7ebfce5b2b0f22910b Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 4 Apr 2018 21:36:10 +0200 Subject: [PATCH 139/247] gobj: release GIL for (un)compress_ram_image --- panda/src/gobj/texture.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/panda/src/gobj/texture.h b/panda/src/gobj/texture.h index 5816b8c538..890710a216 100644 --- a/panda/src/gobj/texture.h +++ b/panda/src/gobj/texture.h @@ -464,10 +464,10 @@ PUBLISHED: MAKE_PROPERTY(keep_ram_image, get_keep_ram_image, set_keep_ram_image); MAKE_PROPERTY(cacheable, is_cacheable); - INLINE bool compress_ram_image(CompressionMode compression = CM_on, - QualityLevel quality_level = QL_default, - GraphicsStateGuardianBase *gsg = NULL); - INLINE bool uncompress_ram_image(); + BLOCKING INLINE bool compress_ram_image(CompressionMode compression = CM_on, + QualityLevel quality_level = QL_default, + GraphicsStateGuardianBase *gsg = NULL); + BLOCKING INLINE bool uncompress_ram_image(); INLINE int get_num_ram_mipmap_images() const; INLINE bool has_ram_mipmap_image(int n) const; From 94476fd1f0e402a237f1b4cf5d77347a7ec4f682 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 4 Apr 2018 21:46:01 +0200 Subject: [PATCH 140/247] glgsg: fix invalid operation error with multisample FBO Panda is forgetting to reset the current FBO when resolving multisamples. --- panda/src/glstuff/glGraphicsBuffer_src.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index 43f3dbd809..35daa0b225 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -1767,6 +1767,7 @@ resolve_multisamples() { } glgsg->_glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, fbo); glgsg->_glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, _fbo_multisample); + glgsg->_current_fbo = fbo; // If the depth buffer is shared, resolve it only on the last to render FBO. bool do_depth_blit = false; From 552a649ef3fcad1690f99e53b1d50e7494bce21c Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 4 Apr 2018 21:48:02 +0200 Subject: [PATCH 141/247] interrogate: add back NULL definition, fixes some keyword arguments I am not sure why the definition of NULL was removed; it might have been by mistake, but in any case it broke code like this: img = PNMImage(w, h, color_space=CS_srgb) since it would not understand the default value (NULL) for the argument preceding color_space. --- dtool/src/parser-inc/stdtypedefs.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dtool/src/parser-inc/stdtypedefs.h b/dtool/src/parser-inc/stdtypedefs.h index c1febd3955..f971d7e1f2 100644 --- a/dtool/src/parser-inc/stdtypedefs.h +++ b/dtool/src/parser-inc/stdtypedefs.h @@ -41,6 +41,11 @@ inline namespace std { struct timeval; +#ifdef __cplusplus +#define NULL 0L +#else +#define NULL ((void *)0) +#endif typedef decltype(nullptr) nullptr_t; // One day, we might extend interrogate to be able to parse this, From 7125a3e5877edc056b6e076285b54f3869dce9f6 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 5 Apr 2018 20:49:13 +0200 Subject: [PATCH 142/247] interrogate: allow passing None for args that have NULL as default value --- .../interfaceMakerPythonNative.cxx | 64 ++++++++++++++++--- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 96420ef663..5ae2d3fca9 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -5414,6 +5414,18 @@ write_function_instance(ostream &out, FunctionRemap *remap, parameter_list += ", &" + param_name; } + // If the default value is NULL, we also accept a None value. + bool maybe_none = false; + if (default_value != nullptr && (return_flags & RF_coerced) == 0) { + CPPExpression::Result res = param->get_default_value()->evaluate(); + if (res._type == CPPExpression::RT_integer || + res._type == CPPExpression::RT_pointer) { + if (res.as_integer() == 0) { + maybe_none = true; + } + } + } + string class_name = obj_type->get_local_name(&parser); // need to a forward scope for this class.. @@ -5464,17 +5476,27 @@ write_function_instance(ostream &out, FunctionRemap *remap, type->output_instance(extra_convert, param_name + "_this", &parser); - if (is_optional) { + if (is_optional && maybe_none) { + extra_convert + << default_expr << ";\n" + << "if (" << param_name << " != NULL && " << param_name << " != Py_None) {\n" + << " " << param_name << "_this"; + } else if (is_optional) { extra_convert << default_expr << ";\n" << "if (" << param_name << " != NULL) {\n" << " " << param_name << "_this"; + } else if (maybe_none) { + extra_convert + << " = NULL;\n" + << "if (" << param_name << " != Py_None) {\n" + << " " << param_name << "_this"; } extra_convert << " = Dtool_Coerce_" + make_safe_name(class_name) + "(" + param_name + ", " + param_name + "_local);\n"; - if (is_optional) { + if (is_optional || maybe_none) { extra_convert << "}\n"; } @@ -5485,8 +5507,12 @@ write_function_instance(ostream &out, FunctionRemap *remap, if (report_errors) { // We were asked to report any errors. Let's do it. - if (is_optional) { + if (is_optional && maybe_none) { + extra_convert << "if (" << param_name << " != NULL && " << param_name << " != Py_None && !" << coerce_call << ") {\n"; + } else if (is_optional) { extra_convert << "if (" << param_name << " != NULL && !" << coerce_call << ") {\n"; + } else if (maybe_none) { + extra_convert << "if (" << param_name << " != Py_None && !" << coerce_call << ") {\n"; } else { extra_convert << "if (!" << coerce_call << ") {\n"; } @@ -5509,19 +5535,35 @@ write_function_instance(ostream &out, FunctionRemap *remap, } extra_convert << "}\n"; + } else if (is_optional && maybe_none) { + extra_param_check << " && (" << param_name << " == NULL || " << param_name << " == Py_None || " << coerce_call << ")"; + } else if (is_optional) { extra_param_check << " && (" << param_name << " == NULL || " << coerce_call << ")"; + } else if (maybe_none) { + extra_param_check << " && (" << param_name << " == Py_None || " << coerce_call << ")"; + } else { extra_param_check << " && " << coerce_call; } - } else { + } else { // The regular, non-coercion case. type->output_instance(extra_convert, param_name + "_this", &parser); - if (is_optional) { + if (is_optional && maybe_none) { extra_convert << default_expr << ";\n" - << "if (" << param_name << " != (PyObject *)NULL) {\n" + << "if (" << param_name << " != NULL && " << param_name << " != Py_None) {\n" + << " " << param_name << "_this"; + } else if (is_optional) { + extra_convert + << default_expr << ";\n" + << "if (" << param_name << " != NULL) {\n" + << " " << param_name << "_this"; + } else if (maybe_none) { + extra_convert + << " = NULL;\n" + << "if (" << param_name << " != Py_None) {\n" << " " << param_name << "_this"; } if (const_ok && !report_errors) { @@ -5529,7 +5571,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, // simpler. But maybe we should just reorganize these functions // entirely? extra_convert << " = NULL;\n"; - int indent_level = is_optional ? 2 : 0; + int indent_level = (is_optional || maybe_none) ? 2 : 0; indent(extra_convert, indent_level) << "DtoolInstance_GetPointer(" << param_name << ", " << param_name << "_this" @@ -5545,9 +5587,15 @@ write_function_instance(ostream &out, FunctionRemap *remap, << "\", " << const_ok << ", " << report_errors << ");\n"; } - if (is_optional) { + if (is_optional && maybe_none) { + extra_convert << "}\n"; + extra_param_check << " && (" << param_name << " == NULL || " << param_name << " == Py_None || " << param_name << "_this != NULL)"; + } else if (is_optional) { extra_convert << "}\n"; extra_param_check << " && (" << param_name << " == NULL || " << param_name << "_this != NULL)"; + } else if (maybe_none) { + extra_convert << "}\n"; + extra_param_check << " && (" << param_name << " == Py_None || " << param_name << "_this != NULL)"; } else { extra_param_check << " && " << param_name << "_this != NULL"; } From de6d753f79886ab45d8c3cec6b231d15afe64d94 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 6 Apr 2018 17:16:18 +0200 Subject: [PATCH 143/247] net: don't use get_message() when constructing datagram header This is causing an unnecessary copy operation. --- panda/src/net/datagramTCPHeader.cxx | 13 ++++++------- panda/src/net/datagramUDPHeader.cxx | 15 ++++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/panda/src/net/datagramTCPHeader.cxx b/panda/src/net/datagramTCPHeader.cxx index 533e3e671b..bd013f0c33 100644 --- a/panda/src/net/datagramTCPHeader.cxx +++ b/panda/src/net/datagramTCPHeader.cxx @@ -24,23 +24,23 @@ */ DatagramTCPHeader:: DatagramTCPHeader(const NetDatagram &datagram, int header_size) { - const string &str = datagram.get_message(); + size_t length = datagram.get_length(); switch (header_size) { case 0: break; case datagram_tcp16_header_size: { - uint16_t size = str.length(); - nassertv(size == str.length()); + uint16_t size = (uint16_t)length; + nassertv((size_t)size == length); _header.add_uint16(size); } break; case datagram_tcp32_header_size: { - uint32_t size = str.length(); - nassertv(size == str.length()); + uint32_t size = (uint32_t)length; + nassertv((size_t)size == length); _header.add_uint32(size); } break; @@ -93,8 +93,7 @@ verify_datagram(const NetDatagram &datagram, int header_size) const { return true; } - const string &str = datagram.get_message(); - int actual_size = str.length(); + int actual_size = (int)datagram.get_length(); int expected_size = get_datagram_size(header_size); if (actual_size == expected_size) { return true; diff --git a/panda/src/net/datagramUDPHeader.cxx b/panda/src/net/datagramUDPHeader.cxx index b491190187..2191c0241a 100644 --- a/panda/src/net/datagramUDPHeader.cxx +++ b/panda/src/net/datagramUDPHeader.cxx @@ -24,10 +24,11 @@ */ DatagramUDPHeader:: DatagramUDPHeader(const NetDatagram &datagram) { - const string &str = datagram.get_message(); + const unsigned char *begin = (const unsigned char *)datagram.get_data(); + const unsigned char *end = begin + datagram.get_length(); uint16_t checksum = 0; - for (size_t p = 0; p < str.size(); p++) { - checksum += (uint16_t)(uint8_t)str[p]; + for (const unsigned char *p = begin; p != end; ++p) { + checksum += (uint16_t)(uint8_t)*p; } // Now pack the header. @@ -49,11 +50,11 @@ DatagramUDPHeader(const void *data) : _header(data, datagram_udp_header_size) { */ bool DatagramUDPHeader:: verify_datagram(const NetDatagram &datagram) const { - const string &str = datagram.get_message(); - + const unsigned char *begin = (const unsigned char *)datagram.get_data(); + const unsigned char *end = begin + datagram.get_length(); uint16_t checksum = 0; - for (size_t p = 0; p < str.size(); p++) { - checksum += (uint16_t)(uint8_t)str[p]; + for (const unsigned char *p = begin; p != end; ++p) { + checksum += (uint16_t)(uint8_t)*p; } if (checksum == get_datagram_checksum()) { From b4d29e609657e15a807da4832aaed20373b5ab26 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 6 Apr 2018 17:41:12 +0200 Subject: [PATCH 144/247] express: allow using bytes() on Datagram Closes: #297 --- panda/src/express/datagram.I | 12 ++++++++++++ panda/src/express/datagram.h | 1 + tests/putil/test_datagram.py | 10 ++++++++++ 3 files changed, 23 insertions(+) diff --git a/panda/src/express/datagram.I b/panda/src/express/datagram.I index 3bd7812969..499bfab48b 100644 --- a/panda/src/express/datagram.I +++ b/panda/src/express/datagram.I @@ -316,6 +316,18 @@ get_message() const { } } +/** + * Returns the datagram's data as a bytes object. + */ +INLINE vector_uchar Datagram:: +__bytes__() const { + if (!_data.empty()) { + return vector_uchar(_data.v()); + } else { + return vector_uchar(); + } +} + /** * Returns a pointer to the beginning of the datagram's data. */ diff --git a/panda/src/express/datagram.h b/panda/src/express/datagram.h index 9250ac89d3..00a46ef36f 100644 --- a/panda/src/express/datagram.h +++ b/panda/src/express/datagram.h @@ -84,6 +84,7 @@ PUBLISHED: void assign(const void *data, size_t size); INLINE string get_message() const; + INLINE vector_uchar __bytes__() const; INLINE const void *get_data() const; INLINE size_t get_length() const; diff --git a/tests/putil/test_datagram.py b/tests/putil/test_datagram.py index 4a34bc88a2..ceadff67b8 100644 --- a/tests/putil/test_datagram.py +++ b/tests/putil/test_datagram.py @@ -76,6 +76,16 @@ def datagram_large(): return dg, readback_function +def test_datagram_bytes(): + """Tests that we can put and get a bytes object on Datagram.""" + dg = core.Datagram(b'abc\x00') + dg.append_data(b'\xff123') + assert bytes(dg) == b'abc\x00\xff123' + + dgi = core.DatagramIterator(dg) + dgi.get_remaining_bytes() == b'abc\x00\xff123' + + def test_iterator(datagram_small): """This tests Datagram/DatagramIterator, and sort of serves as a self-check of the test fixtures too.""" From 22f933a41970e285d6abc4fd6c5d19e50fd423de Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 6 Apr 2018 20:34:48 +0200 Subject: [PATCH 145/247] tests: disable datagram bytes() test on Python 2 See #297 --- tests/putil/test_datagram.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/putil/test_datagram.py b/tests/putil/test_datagram.py index ceadff67b8..1349bd5656 100644 --- a/tests/putil/test_datagram.py +++ b/tests/putil/test_datagram.py @@ -1,5 +1,6 @@ import pytest from panda3d import core +import sys # Fixtures for generating interesting datagrams (and verification functions) on # the fly... @@ -76,6 +77,7 @@ def datagram_large(): return dg, readback_function +@pytest.mark.skipif(sys.version_info < (3, 0), reason="Requires Python 3") def test_datagram_bytes(): """Tests that we can put and get a bytes object on Datagram.""" dg = core.Datagram(b'abc\x00') From d13464104c19be8cb5c41390a6db4aab58ca0817 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 6 Apr 2018 20:49:43 +0200 Subject: [PATCH 146/247] Fix compilation issue with --nothing on MSVC I have no idea why this error happens, but it does not seem worth the effort to investigate further, so I'm just reverting the previous change to this file. --- dtool/src/dtoolbase/pvector.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dtool/src/dtoolbase/pvector.h b/dtool/src/dtoolbase/pvector.h index b146947543..14bd542f37 100644 --- a/dtool/src/dtoolbase/pvector.h +++ b/dtool/src/dtoolbase/pvector.h @@ -46,9 +46,24 @@ public: typedef TYPENAME base_class::size_type size_type; explicit pvector(TypeHandle type_handle = pvector_type_handle) : base_class(allocator(type_handle)) { } + pvector(const pvector ©) : base_class(copy) { } explicit pvector(size_type n, TypeHandle type_handle = pvector_type_handle) : base_class(n, Type(), allocator(type_handle)) { } explicit pvector(size_type n, const Type &value, TypeHandle type_handle = pvector_type_handle) : base_class(n, value, allocator(type_handle)) { } pvector(const Type *begin, const Type *end, TypeHandle type_handle = pvector_type_handle) : base_class(begin, end, allocator(type_handle)) { } + +#ifdef USE_MOVE_SEMANTICS + pvector(pvector &&from) NOEXCEPT : base_class(move(from)) {}; + + pvector &operator =(pvector &&from) NOEXCEPT { + base_class::operator =(move(from)); + return *this; + } +#endif + + pvector &operator =(const pvector ©) { + base_class::operator =(copy); + return *this; + } }; #endif // USE_STL_ALLOCATOR From 753ae3974079ec54a49315381cecc091f25692ff Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 8 Apr 2018 13:50:33 +0200 Subject: [PATCH 147/247] readme: use MSVC 2015 instead of 2010 (see #288) [skip ci] --- README.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index fde01c38f0..cf45f0dfd2 100644 --- a/README.md +++ b/README.md @@ -43,24 +43,26 @@ Building Panda3D Windows ------- -We currently build using the Microsoft Visual C++ 2010 compiler. You do not -need Microsoft Visual Studio to build Panda3D, though - the relevant compilers -are included as part of the Windows 7.1 SDK. +We currently build using the Microsoft Visual C++ 2015 compiler. You will +also need to install the [Windows 10 SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk), +and if you intend to target Windows XP, you will also need the +[Windows 7.1 SDK](https://www.microsoft.com/en-us/download/details.aspx?id=8279). You will also need to have the third-party dependency libraries available for the build scripts to use. These are available from one of these two URLs, -depending on whether you are on a 32-bit or 64-bit system: -https://www.panda3d.org/download/panda3d-1.9.4/panda3d-1.9.4-tools-win32.zip -https://www.panda3d.org/download/panda3d-1.9.4/panda3d-1.9.4-tools-win64.zip +depending on whether you are on a 32-bit or 64-bit system, or you can +[click here](https://github.com/rdb/panda3d-thirdparty) for instructions on +building them from source. -(It is also possible to build using MSVC 2015 and 2017, which requires a -different set of thirdparty libraries, but that is not described here.) +http://rdb.name/thirdparty-vc14-x64.7z +http://rdb.name/thirdparty-vc14.7z After acquiring these dependencies, you may simply build Panda3D from the -command prompt using the following command: +command prompt using the following command. (Add the `--windows-sdk=10` +option if you don't need to support Windows XP.) ```bash -makepanda\makepanda.bat --everything --installer --no-eigen +makepanda\makepanda.bat --everything --installer --no-eigen --threads=2 ``` When the build succeeds, it will produce an .exe file that you can use to From 9ca0d089a669f3f3e63f58f329d354055917700b Mon Sep 17 00:00:00 2001 From: Younguk Kim Date: Tue, 10 Apr 2018 19:45:54 +0900 Subject: [PATCH 148/247] event: fix a crash when removing a task is not owned by user --- panda/src/event/asyncTaskChain.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/panda/src/event/asyncTaskChain.cxx b/panda/src/event/asyncTaskChain.cxx index 47299d31ef..c7d732eca9 100644 --- a/panda/src/event/asyncTaskChain.cxx +++ b/panda/src/event/asyncTaskChain.cxx @@ -477,6 +477,7 @@ do_remove(AsyncTask *task, bool upon_death) { { int index = find_task_on_heap(_sleeping, task); nassertr(index != -1, false); + PT(AsyncTask) hold_task = task; _sleeping.erase(_sleeping.begin() + index); make_heap(_sleeping.begin(), _sleeping.end(), AsyncTaskSortWakeTime()); cleanup_task(task, upon_death, false); @@ -486,6 +487,7 @@ do_remove(AsyncTask *task, bool upon_death) { case AsyncTask::S_active: { // Active, but not being serviced, easy. + PT(AsyncTask) hold_task = task; int index = find_task_on_heap(_active, task); if (index != -1) { _active.erase(_active.begin() + index); @@ -769,7 +771,6 @@ cleanup_task(AsyncTask *task, bool upon_death, bool clean_exit) { } nassertv(task->_chain == this); - PT(AsyncTask) hold_task = task; task->_state = AsyncTask::S_inactive; task->_chain = nullptr; From 607af9ff4963db086b1233e195db45f7aeda68c1 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 10 Apr 2018 15:29:43 +0200 Subject: [PATCH 149/247] flt: fix compile error on macOS 10.6 (which has no strnlen) --- pandatool/src/flt/fltBeadID.cxx | 4 ++-- pandatool/src/flt/fltRecord.cxx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandatool/src/flt/fltBeadID.cxx b/pandatool/src/flt/fltBeadID.cxx index f55d3e88cc..32348d583e 100644 --- a/pandatool/src/flt/fltBeadID.cxx +++ b/pandatool/src/flt/fltBeadID.cxx @@ -78,8 +78,8 @@ extract_record(FltRecordReader &reader) { bool FltBeadID:: extract_ancillary(FltRecordReader &reader) { if (reader.get_opcode() == FO_long_id) { - vector_uchar s = reader.get_iterator().get_remaining_bytes(); - _id.assign((const char *)s.data(), strnlen((const char *)s.data(), s.size())); + DatagramIterator &di = reader.get_iterator(); + _id = di.get_fixed_string(di.get_remaining_size()); return true; } diff --git a/pandatool/src/flt/fltRecord.cxx b/pandatool/src/flt/fltRecord.cxx index a0af83e180..53844f0636 100644 --- a/pandatool/src/flt/fltRecord.cxx +++ b/pandatool/src/flt/fltRecord.cxx @@ -621,8 +621,8 @@ extract_record(FltRecordReader &) { bool FltRecord:: extract_ancillary(FltRecordReader &reader) { if (reader.get_opcode() == FO_comment) { - vector_uchar s = reader.get_iterator().get_remaining_bytes(); - _comment.assign((const char *)s.data(), strnlen((const char *)s.data(), s.size())); + DatagramIterator &di = reader.get_iterator(); + _comment = di.get_fixed_string(di.get_remaining_size()); return true; } From e1675f1a539c22fdb3c5ebdacaa6a5c0fb383152 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 10 Apr 2018 15:31:48 +0200 Subject: [PATCH 150/247] makepanda: fix compile error on Windows with some versions of flex --- makepanda/makepanda.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index b772a4a9e7..3f597f90b7 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -552,6 +552,7 @@ if (COMPILER == "MSVC"): PkgDisable("EGL") PkgDisable("CARBON") PkgDisable("COCOA") + DefSymbol("FLEX", "YY_NO_UNISTD_H") if (PkgSkip("PYTHON")==0): IncDirectory("ALWAYS", SDK["PYTHON"] + "/include") LibDirectory("ALWAYS", SDK["PYTHON"] + "/libs") @@ -1396,7 +1397,7 @@ def CompileBison(wobj, wsrc, opts): CopyFile(wdsth, GetOutputDir()+"/tmp/"+ifile+".h") # Finally, compile the generated source file. - CompileCxx(wobj,wdstc,opts) + CompileCxx(wobj, wdstc, opts + ["FLEX"]) ######################################################################## ## From 0cef19fd900977bd67eb7ed17200a62aa317f28c Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 11 Apr 2018 17:29:49 +0200 Subject: [PATCH 151/247] putil: more validation in DatagramInputFile::get_datagram Intended to fix test_file_corrupt for 32-bit platforms. See discussion in 89be2c19af74c62b57961469c779b324c69979f1 --- panda/src/putil/datagramInputFile.cxx | 28 ++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/panda/src/putil/datagramInputFile.cxx b/panda/src/putil/datagramInputFile.cxx index f3bd8a081e..f81381d02e 100644 --- a/panda/src/putil/datagramInputFile.cxx +++ b/panda/src/putil/datagramInputFile.cxx @@ -138,35 +138,45 @@ get_datagram(Datagram &data) { return true; } - streamsize num_bytes = (streamsize)num_bytes_32; + size_t num_bytes = (size_t)num_bytes_32; if (num_bytes_32 == (uint32_t)-1) { // Another special case for a value larger than 32 bits. - num_bytes = reader.get_uint64(); - } + uint64_t num_bytes_64 = reader.get_uint64(); - // Make sure we have a reasonable datagram size for putting into memory. - nassertr(num_bytes == (size_t)num_bytes, false); + if (_in->fail() || _in->eof()) { + _error = true; + return false; + } + + num_bytes = (size_t)num_bytes_64; + + // Make sure we have a reasonable datagram size for putting into memory. + if (num_bytes_64 != (uint64_t)num_bytes) { + _error = true; + return false; + } + } // Now, read the datagram itself. We construct an empty datagram, use // pad_bytes to make it big enough, and read *directly* into the datagram's // internal buffer. Doing this saves us a copy operation. data = Datagram(); - streamsize bytes_read = 0; + size_t bytes_read = 0; while (bytes_read < num_bytes) { - streamsize bytes_left = num_bytes - bytes_read; + size_t bytes_left = num_bytes - bytes_read; // Hold up a second - datagrams >4MB are pretty large by bam/network // standards. Let's take it 4MB at a time just in case the length is // corrupt, so we don't allocate potentially a few GBs of RAM only to // find a truncated file. - bytes_left = min(bytes_left, (streamsize)4*1024*1024); + bytes_left = min(bytes_left, (size_t)4*1024*1024); PTA_uchar buffer = data.modify_array(); buffer.resize(buffer.size() + bytes_left); unsigned char *ptr = &buffer.p()[bytes_read]; - _in->read((char *)ptr, bytes_left); + _in->read((char *)ptr, (streamsize)bytes_left); if (_in->fail() || _in->eof()) { _error = true; return false; From f979c4d3121ded6bc0ea3f2cfea68c5d686ab137 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 11 Apr 2018 17:41:16 +0200 Subject: [PATCH 152/247] makepanda: don't use pkg-config for assimp It seems that they removed the -I option, which we need to build with. This commit is intended to fix the Ubuntu Bionic build. --- makepanda/makepanda.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 3f597f90b7..5ae064b649 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -828,7 +828,7 @@ if (COMPILER=="GCC"): SmartPkgEnable("EIGEN", "eigen3", (), ("Eigen/Dense",), target_pkg = 'ALWAYS') SmartPkgEnable("ARTOOLKIT", "", ("AR"), "AR/ar.h") SmartPkgEnable("FCOLLADA", "", ChooseLib(fcollada_libs, "FCOLLADA"), ("FCollada", "FCollada/FCollada.h")) - SmartPkgEnable("ASSIMP", "assimp", ("assimp"), "assimp") + SmartPkgEnable("ASSIMP", "", ("assimp"), "assimp") SmartPkgEnable("FFMPEG", ffmpeg_libs, ffmpeg_libs, ("libavformat/avformat.h", "libavcodec/avcodec.h", "libavutil/avutil.h")) SmartPkgEnable("SWSCALE", "libswscale", "libswscale", ("libswscale/swscale.h"), target_pkg = "FFMPEG", thirdparty_dir = "ffmpeg") SmartPkgEnable("SWRESAMPLE","libswresample", "libswresample", ("libswresample/swresample.h"), target_pkg = "FFMPEG", thirdparty_dir = "ffmpeg") From 4877e8350d58cafa42f12fe026c795656a4984a3 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 18 Apr 2018 18:25:29 +0200 Subject: [PATCH 153/247] tests: fix unit test on 64-bit Ubuntu due to float imprecision [skip ci] --- tests/bullet/test_bullet_bam.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/bullet/test_bullet_bam.py b/tests/bullet/test_bullet_bam.py index c6b9d2c282..11523a4f51 100644 --- a/tests/bullet/test_bullet_bam.py +++ b/tests/bullet/test_bullet_bam.py @@ -88,8 +88,8 @@ def test_minkowski_sum_shape(): assert type(shape) is type(shape2) assert shape.margin == shape2.margin assert shape.name == shape2.name - assert shape.transform_a.compare_to(shape2.transform_a, True) == 0 - assert shape.transform_b.compare_to(shape2.transform_b, True) == 0 + assert shape.transform_a.mat.compare_to(shape2.transform_a.mat) == 0 + assert shape.transform_b.mat.compare_to(shape2.transform_b.mat) == 0 assert type(shape.shape_a) == type(shape2.shape_a) assert type(shape.shape_b) == type(shape2.shape_b) From fc172f89183ca23b64ae4bbc0f35978f82ab5082 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 20 Apr 2018 12:48:26 +0200 Subject: [PATCH 154/247] tests: fix unit test on 32-bit Ubuntu due to float imprecision --- tests/bullet/test_bullet_bam.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/bullet/test_bullet_bam.py b/tests/bullet/test_bullet_bam.py index 11523a4f51..e22aa57ba2 100644 --- a/tests/bullet/test_bullet_bam.py +++ b/tests/bullet/test_bullet_bam.py @@ -88,8 +88,8 @@ def test_minkowski_sum_shape(): assert type(shape) is type(shape2) assert shape.margin == shape2.margin assert shape.name == shape2.name - assert shape.transform_a.mat.compare_to(shape2.transform_a.mat) == 0 - assert shape.transform_b.mat.compare_to(shape2.transform_b.mat) == 0 + assert shape.transform_a.mat.compare_to(shape2.transform_a.mat, 0.001) == 0 + assert shape.transform_b.mat.compare_to(shape2.transform_b.mat, 0.001) == 0 assert type(shape.shape_a) == type(shape2.shape_a) assert type(shape.shape_b) == type(shape2.shape_b) From e6e39cce0e9140de96febc3aba3d709cdffe8de1 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 20 Apr 2018 12:48:57 +0200 Subject: [PATCH 155/247] bullet: fix deadlock in get_manifold --- panda/src/bullet/bulletWorld.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/bullet/bulletWorld.cxx b/panda/src/bullet/bulletWorld.cxx index 9bfa707e9d..9732760460 100644 --- a/panda/src/bullet/bulletWorld.cxx +++ b/panda/src/bullet/bulletWorld.cxx @@ -1052,7 +1052,7 @@ BulletPersistentManifold *BulletWorld:: get_manifold(int idx) const { LightMutexHolder holder(get_global_lock()); - nassertr(idx < get_num_manifolds(), NULL); + nassertr(idx < _dispatcher->getNumManifolds(), NULL); btPersistentManifold *ptr = _dispatcher->getManifoldByIndexInternal(idx); return (ptr) ? new BulletPersistentManifold(ptr) : NULL; From 1ac351d594e559b5fa20bcdacb6b939b1b1ac8c0 Mon Sep 17 00:00:00 2001 From: deflected Date: Fri, 20 Apr 2018 21:25:41 +0300 Subject: [PATCH 156/247] bullet: Allow intractions with bullet world during tick callbacks - Release the global lock during the user tick callback and allow interactions with bullet world - Acquire the lock again after the callback Signed-off-by: deflected --- panda/src/bullet/bulletWorld.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/panda/src/bullet/bulletWorld.cxx b/panda/src/bullet/bulletWorld.cxx index 9732760460..6098759581 100644 --- a/panda/src/bullet/bulletWorld.cxx +++ b/panda/src/bullet/bulletWorld.cxx @@ -1186,7 +1186,12 @@ tick_callback(btDynamicsWorld *world, btScalar timestep) { CallbackObject *obj = w->_tick_callback_obj; if (obj) { BulletTickCallbackData cbdata(timestep); + // Release the global lock that we are holding during the tick callback + // and allow interactions with bullet world in the user callback + get_global_lock().release(); obj->do_callback(&cbdata); + // Acquire the global lock again and protect the execution + get_global_lock().acquire(); } } From 574000aedd9c4ef48f4a22b5cab52e373ba12c86 Mon Sep 17 00:00:00 2001 From: Donny Lawrence Date: Fri, 20 Apr 2018 22:25:01 -0500 Subject: [PATCH 157/247] Add getter and setter for Content-Type header Fixes #296 Closes #305 --- panda/src/downloader/httpChannel.I | 17 +++++++++++++++++ panda/src/downloader/httpChannel.cxx | 3 ++- panda/src/downloader/httpChannel.h | 4 ++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/panda/src/downloader/httpChannel.I b/panda/src/downloader/httpChannel.I index ccc30d504d..1a254e478a 100644 --- a/panda/src/downloader/httpChannel.I +++ b/panda/src/downloader/httpChannel.I @@ -426,6 +426,23 @@ get_max_updates_per_second() const { return _max_updates_per_second; } +/** + * Specifies the Content-Type header, useful for applications that require + * different types of content, such as JSON. + */ +INLINE void HTTPChannel:: +set_content_type(string content_type) { + _content_type = content_type; +} + +/** + * Returns the value of the Content-Type header. + */ +INLINE string HTTPChannel:: +get_content_type() const { + return _content_type; +} + /** * This may be called immediately after a call to get_document() or some * related function to specify the expected size of the document we are diff --git a/panda/src/downloader/httpChannel.cxx b/panda/src/downloader/httpChannel.cxx index a7eb5f58d3..93e04f1432 100644 --- a/panda/src/downloader/httpChannel.cxx +++ b/panda/src/downloader/httpChannel.cxx @@ -100,6 +100,7 @@ HTTPChannel(HTTPClient *client) : _response_type = RT_none; _http_version = _client->get_http_version(); _http_version_string = _client->get_http_version_string(); + _content_type = "application/x-www-form-urlencoded"; _state = S_new; _done_state = S_new; _started_download = false; @@ -3624,7 +3625,7 @@ make_header() { if (!_body.empty()) { stream - << "Content-Type: application/x-www-form-urlencoded\r\n" + << "Content-Type: " << _content_type << "\r\n" << "Content-Length: " << _body.length() << "\r\n"; } diff --git a/panda/src/downloader/httpChannel.h b/panda/src/downloader/httpChannel.h index b9131eba9a..7de0e17e83 100644 --- a/panda/src/downloader/httpChannel.h +++ b/panda/src/downloader/httpChannel.h @@ -143,6 +143,9 @@ PUBLISHED: INLINE void set_max_updates_per_second(double max_updates_per_second); INLINE double get_max_updates_per_second() const; + INLINE void set_content_type(string content_type); + INLINE string get_content_type() const; + INLINE void set_expected_file_size(size_t file_size); streamsize get_file_size() const; INLINE bool is_file_size_known() const; @@ -336,6 +339,7 @@ private: string request_path; string _header; string _body; + string _content_type; bool _want_ssl; bool _proxy_serves_document; bool _proxy_tunnel_now; From f986f8de1b7734205da4d60cd43318fe2d3e24ec Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 21 Apr 2018 11:20:49 +0200 Subject: [PATCH 158/247] showbase: add back clampScalar and PriorityCallbacks to PythonUtil These were removed by 88dbb31daa02779405ef5326677eefb5cf93f3c8 under the assumption that they were not used, but it has recently come to my attention that there is still code out there that uses these. PriorityCallbacks has been updated to be compatible with Python 3 by only comparing the priority, rather than the (priority, callback) tuple. This also has the side-effect of ditching the bisect dependency. Also moves testing code from the source to the unit tests. --- direct/src/showbase/PythonUtil.py | 105 ++++++++++++++---------------- tests/showbase/test_PythonUtil.py | 105 ++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+), 57 deletions(-) create mode 100644 tests/showbase/test_PythonUtil.py diff --git a/direct/src/showbase/PythonUtil.py b/direct/src/showbase/PythonUtil.py index 0c850f51a0..2cd4e62d15 100644 --- a/direct/src/showbase/PythonUtil.py +++ b/direct/src/showbase/PythonUtil.py @@ -10,7 +10,7 @@ __all__ = ['indent', 'bound', 'clamp', 'lerp', 'average', 'addListsByValue', 'boolEqual', 'lineupPos', 'formatElapsedSeconds', 'solveQuadratic', 'findPythonModule', 'mostDerivedLast', -'weightedChoice', 'randFloat', 'normalDistrib', +'clampScalar', 'weightedChoice', 'randFloat', 'normalDistrib', 'weightedRand', 'randUint31', 'randInt32', 'SerialNumGen', 'serialNum', 'uniqueName', 'Enum', 'Singleton', 'SingletonError', 'printListEnum', 'safeRepr', @@ -178,27 +178,6 @@ class Queue: def __len__(self): return len(self.__list) -if __debug__ and __name__ == '__main__': - q = Queue() - assert q.isEmpty() - q.clear() - assert q.isEmpty() - q.push(10) - assert not q.isEmpty() - q.push(20) - assert not q.isEmpty() - assert len(q) == 2 - assert q.front() == 10 - assert q.back() == 20 - assert q.top() == 10 - assert q.top() == 10 - assert q.pop() == 10 - assert len(q) == 1 - assert not q.isEmpty() - assert q.pop() == 20 - assert len(q) == 0 - assert q.isEmpty() - def indent(stream, numIndents, str): """ @@ -1130,6 +1109,23 @@ def findPythonModule(module): return None +def clampScalar(value, a, b): + # calling this ought to be faster than calling both min and max + if a < b: + if value < a: + return a + elif value > b: + return b + else: + return value + else: + if value < b: + return b + elif value > a: + return a + else: + return value + def weightedChoice(choiceList, rng=random.random, sum=None): """given a list of (weight, item) pairs, chooses an item based on the weights. rng must return 0..1. if you happen to have the sum of the @@ -2313,36 +2309,6 @@ def flywheel(*args, **kArgs): pass return flywheel -if __debug__ and __name__ == '__main__': - f = flywheel(['a','b','c','d'], countList=[11,20,3,4]) - obj2count = {} - for obj in f: - obj2count.setdefault(obj, 0) - obj2count[obj] += 1 - assert obj2count['a'] == 11 - assert obj2count['b'] == 20 - assert obj2count['c'] == 3 - assert obj2count['d'] == 4 - - f = flywheel([1,2,3,4], countFunc=lambda x: x*2) - obj2count = {} - for obj in f: - obj2count.setdefault(obj, 0) - obj2count[obj] += 1 - assert obj2count[1] == 2 - assert obj2count[2] == 4 - assert obj2count[3] == 6 - assert obj2count[4] == 8 - - f = flywheel([1,2,3,4], countFunc=lambda x: x, scale = 3) - obj2count = {} - for obj in f: - obj2count.setdefault(obj, 0) - obj2count[obj] += 1 - assert obj2count[1] == 1 * 3 - assert obj2count[2] == 2 * 3 - assert obj2count[3] == 3 * 3 - assert obj2count[4] == 4 * 3 if __debug__: def quickProfile(name="unnamed"): @@ -2687,11 +2653,36 @@ def unescapeHtmlString(s): result += char return result -if __debug__ and __name__ == '__main__': - assert unescapeHtmlString('asdf') == 'asdf' - assert unescapeHtmlString('as+df') == 'as df' - assert unescapeHtmlString('as%32df') == 'as2df' - assert unescapeHtmlString('asdf%32') == 'asdf2' +class PriorityCallbacks: + """ manage a set of prioritized callbacks, and allow them to be invoked in order of priority """ + def __init__(self): + self._callbacks = [] + + def clear(self): + del self._callbacks[:] + + def add(self, callback, priority=None): + if priority is None: + priority = 0 + callbacks = self._callbacks + lo = 0 + hi = len(callbacks) + while lo < hi: + mid = (lo + hi) // 2 + if priority < callbacks[mid][0]: + hi = mid + else: + lo = mid + 1 + item = (priority, callback) + callbacks.insert(lo, item) + return item + + def remove(self, item): + self._callbacks.remove(item) + + def __call__(self): + for priority, callback in self._callbacks: + callback() builtins.Functor = Functor builtins.Stack = Stack diff --git a/tests/showbase/test_PythonUtil.py b/tests/showbase/test_PythonUtil.py new file mode 100644 index 0000000000..faf5da269f --- /dev/null +++ b/tests/showbase/test_PythonUtil.py @@ -0,0 +1,105 @@ +from direct.showbase import PythonUtil + + +def test_queue(): + q = PythonUtil.Queue() + assert q.isEmpty() + q.clear() + assert q.isEmpty() + q.push(10) + assert not q.isEmpty() + q.push(20) + assert not q.isEmpty() + assert len(q) == 2 + assert q.front() == 10 + assert q.back() == 20 + assert q.top() == 10 + assert q.top() == 10 + assert q.pop() == 10 + assert len(q) == 1 + assert not q.isEmpty() + assert q.pop() == 20 + assert len(q) == 0 + assert q.isEmpty() + + +def test_flywheel(): + f = PythonUtil.flywheel(['a','b','c','d'], countList=[11,20,3,4]) + obj2count = {} + for obj in f: + obj2count.setdefault(obj, 0) + obj2count[obj] += 1 + assert obj2count['a'] == 11 + assert obj2count['b'] == 20 + assert obj2count['c'] == 3 + assert obj2count['d'] == 4 + + f = PythonUtil.flywheel([1,2,3,4], countFunc=lambda x: x*2) + obj2count = {} + for obj in f: + obj2count.setdefault(obj, 0) + obj2count[obj] += 1 + assert obj2count[1] == 2 + assert obj2count[2] == 4 + assert obj2count[3] == 6 + assert obj2count[4] == 8 + + f = PythonUtil.flywheel([1,2,3,4], countFunc=lambda x: x, scale = 3) + obj2count = {} + for obj in f: + obj2count.setdefault(obj, 0) + obj2count[obj] += 1 + assert obj2count[1] == 1 * 3 + assert obj2count[2] == 2 * 3 + assert obj2count[3] == 3 * 3 + assert obj2count[4] == 4 * 3 + + +def test_unescape_html_string(): + assert PythonUtil.unescapeHtmlString('asdf') == 'asdf' + assert PythonUtil.unescapeHtmlString('as+df') == 'as df' + assert PythonUtil.unescapeHtmlString('as%32df') == 'as2df' + assert PythonUtil.unescapeHtmlString('asdf%32') == 'asdf2' + + +def test_priority_callbacks(): + l = [] + def a(l=l): + l.append('a') + def b(l=l): + l.append('b') + def c(l=l): + l.append('c') + + pc = PythonUtil.PriorityCallbacks() + pc.add(a) + pc() + assert l == ['a'] + + del l[:] + bItem = pc.add(b) + pc() + assert 'a' in l + assert 'b' in l + assert len(l) == 2 + + del l[:] + pc.remove(bItem) + pc() + assert l == ['a'] + + del l[:] + pc.add(c, 2) + bItem = pc.add(b, 10) + pc() + assert l == ['a', 'c', 'b'] + + del l[:] + pc.remove(bItem) + pc() + assert l == ['a', 'c'] + + del l[:] + pc.clear() + pc() + assert len(l) == 0 From 3b4d4b0804ae7539bd271cbc7812311ee268c12c Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 30 Apr 2018 19:13:54 -0400 Subject: [PATCH 159/247] glgsg: fix broken upload of downscaled texture without mipmaps Fixes #306 --- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 97917acee0..f5a42e2e45 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -12647,7 +12647,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, int depth = tex->get_expected_mipmap_z_size(mipmap_bias); // Determine the number of images to upload. - int num_levels = 1; + int num_levels = mipmap_bias + 1; if (uses_mipmaps) { num_levels = tex->get_expected_num_mipmap_levels(); } From 9db74bca1d855230edbc5c3b6616e56c5de44127 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 1 May 2018 15:06:27 +0200 Subject: [PATCH 160/247] task: use consistent ordering for tasks with same sort value We don't guarantee a specific order in this case, especially because they can be run in either order if there is more than one thread, but it is still useful to have a defined order for single-threaded task chains. To that end, tasks are now run in the order in which they were added to taskMgr.add (in absence of any other ordering constraints). Fixes #309 --- panda/src/event/asyncTask.h | 1 + panda/src/event/asyncTaskChain.cxx | 6 +++++- panda/src/event/asyncTaskChain.h | 9 ++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/panda/src/event/asyncTask.h b/panda/src/event/asyncTask.h index d514b2f5a3..9712daa0f5 100644 --- a/panda/src/event/asyncTask.h +++ b/panda/src/event/asyncTask.h @@ -119,6 +119,7 @@ protected: double _wake_time; int _sort; int _priority; + unsigned int _implicit_sort; State _state; Thread *_servicing_thread; diff --git a/panda/src/event/asyncTaskChain.cxx b/panda/src/event/asyncTaskChain.cxx index c7d732eca9..bb82e00f92 100644 --- a/panda/src/event/asyncTaskChain.cxx +++ b/panda/src/event/asyncTaskChain.cxx @@ -51,7 +51,8 @@ AsyncTaskChain(AsyncTaskManager *manager, const string &name) : _needs_cleanup(false), _current_frame(0), _time_in_frame(0.0), - _block_till_next_frame(false) + _block_till_next_frame(false), + _next_implicit_sort(0) { } @@ -418,6 +419,9 @@ do_add(AsyncTask *task) { task->_start_time = now; task->_start_frame = _manager->_clock->get_frame_count(); + // Remember the order in which tasks were added to the chain. + task->_implicit_sort = _next_implicit_sort++; + _manager->add_task_by_name(task); if (task->has_delay()) { diff --git a/panda/src/event/asyncTaskChain.h b/panda/src/event/asyncTaskChain.h index 512a7b9fa0..5f81f6c3dd 100644 --- a/panda/src/event/asyncTaskChain.h +++ b/panda/src/event/asyncTaskChain.h @@ -146,7 +146,12 @@ protected: if (a->get_priority() != b->get_priority()) { return a->get_priority() < b->get_priority(); } - return a->get_start_time() > b->get_start_time(); + if (a->get_start_time() != b->get_start_time()) { + return a->get_start_time() > b->get_start_time(); + } + // Failing any other ordering criteria, we sort the tasks based on the + // order in which they were added to the task chain. + return a->_implicit_sort > b->_implicit_sort; } }; @@ -186,6 +191,8 @@ protected: double _time_in_frame; bool _block_till_next_frame; + unsigned int _next_implicit_sort; + static PStatCollector _task_pcollector; static PStatCollector _wait_pcollector; From b45726001e817278783500b8b358513979d0b031 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 5 May 2018 20:53:04 +0200 Subject: [PATCH 161/247] task: fix double free when failing to retrieve coroutine exception --- panda/src/event/pythonTask.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/panda/src/event/pythonTask.cxx b/panda/src/event/pythonTask.cxx index 996587885e..6a818ad19c 100644 --- a/panda/src/event/pythonTask.cxx +++ b/panda/src/event/pythonTask.cxx @@ -94,6 +94,9 @@ PythonTask:: PyErr_Restore(_exception, _exc_value, _exc_traceback); PyErr_Print(); PyErr_Restore(nullptr, nullptr, nullptr); + _exception = nullptr; + _exc_value = nullptr; + _exc_traceback = nullptr; } #endif From 11e21af52cead7c7f1fb5cfa613ea28dee76ea6a Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 5 May 2018 22:01:10 +0200 Subject: [PATCH 162/247] showbase: fix iris/fade transitions for extreme aspect ratios Fixes #311 --- direct/src/showbase/Transitions.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/direct/src/showbase/Transitions.py b/direct/src/showbase/Transitions.py index e26d0e93ec..aacb7afcc5 100644 --- a/direct/src/showbase/Transitions.py +++ b/direct/src/showbase/Transitions.py @@ -94,7 +94,9 @@ class Transitions: """ #self.noTransitions() masad: this creates a one frame pop, is it necessary? self.loadFade() - transitionIval = Sequence(Func(self.fade.reparentTo, aspect2d, DGG.FADE_SORT_INDEX), + + parent = aspect2d if self.fadeModel else render2d + transitionIval = Sequence(Func(self.fade.reparentTo, parent, DGG.FADE_SORT_INDEX), Func(self.fade.showThrough), # in case aspect2d is hidden for some reason self.lerpFunc(self.fade, t, self.alphaOff, @@ -115,7 +117,8 @@ class Transitions: self.noTransitions() self.loadFade() - transitionIval = Sequence(Func(self.fade.reparentTo,aspect2d,DGG.FADE_SORT_INDEX), + parent = aspect2d if self.fadeModel else render2d + transitionIval = Sequence(Func(self.fade.reparentTo, parent, DGG.FADE_SORT_INDEX), Func(self.fade.showThrough), # in case aspect2d is hidden for some reason self.lerpFunc(self.fade, t, self.alphaOn, @@ -167,7 +170,9 @@ class Transitions: # Fade out immediately with no lerp self.noTransitions() self.loadFade() - self.fade.reparentTo(aspect2d, DGG.FADE_SORT_INDEX) + + parent = aspect2d if self.fadeModel else render2d + self.fade.reparentTo(parent, DGG.FADE_SORT_INDEX) self.fade.setColor(self.alphaOn) elif ConfigVariableBool('no-loading-screen', False): if finishIval: @@ -191,7 +196,9 @@ class Transitions: #print "transitiosn: fadeScreen" self.noTransitions() self.loadFade() - self.fade.reparentTo(aspect2d, DGG.FADE_SORT_INDEX) + + parent = aspect2d if self.fadeModel else render2d + self.fade.reparentTo(parent, DGG.FADE_SORT_INDEX) self.fade.setColor(self.alphaOn[0], self.alphaOn[1], self.alphaOn[2], @@ -206,7 +213,9 @@ class Transitions: #print "transitiosn: fadeScreenColor" self.noTransitions() self.loadFade() - self.fade.reparentTo(aspect2d, DGG.FADE_SORT_INDEX) + + parent = aspect2d if self.fadeModel else render2d + self.fade.reparentTo(parent, DGG.FADE_SORT_INDEX) self.fade.setColor(color) def noFade(self): @@ -250,8 +259,9 @@ class Transitions: else: self.iris.reparentTo(aspect2d, DGG.FADE_SORT_INDEX) + scale = 0.18 * max(base.a2dRight, base.a2dTop) self.transitionIval = Sequence(LerpScaleInterval(self.iris, t, - scale = 0.18, + scale = scale, startScale = 0.01), Func(self.iris.detachNode), name = self.irisTaskName, @@ -277,9 +287,10 @@ class Transitions: else: self.iris.reparentTo(aspect2d, DGG.FADE_SORT_INDEX) + scale = 0.18 * max(base.a2dRight, base.a2dTop) self.transitionIval = Sequence(LerpScaleInterval(self.iris, t, scale = 0.01, - startScale = 0.18), + startScale = scale), Func(self.iris.detachNode), # Use the fade to cover up the hole that the iris would leave Func(self.fadeOut, 0), From cf58de4d04da6f9fd176bd8c127546699eeb6444 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 5 May 2018 23:02:11 +0200 Subject: [PATCH 163/247] showbase: make base.movie() awaitable (by returning a future) --- direct/src/showbase/ShowBase.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 367ae57d1a..13b9839255 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -2672,15 +2672,18 @@ class ShowBase(DirectObject.DirectObject): output file name (e.g. if sd = 4, movie_0001.png) - source is the Window, Buffer, DisplayRegion, or Texture from which to save the resulting images. The default is the main window. + + The task is returned, so that it can be awaited. """ globalClock.setMode(ClockObject.MNonRealTime) globalClock.setDt(1.0/float(fps)) - t = taskMgr.add(self._movieTask, namePrefix + '_task') + t = self.taskMgr.add(self._movieTask, namePrefix + '_task') t.frameIndex = 0 # Frame 0 is not captured. t.numFrames = int(duration * fps) t.source = source t.outputString = namePrefix + '_%0' + repr(sd) + 'd.' + format t.setUponDeath(lambda state: globalClock.setMode(ClockObject.MNormal)) + return t def _movieTask(self, state): if state.frameIndex != 0: From 71eee6df3fc9ce0099ea985e4d843790eee59216 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 5 May 2018 23:05:50 +0200 Subject: [PATCH 164/247] showbase: make iris/fade/letterbox transitions awaitable This allows using a coroutine to build up a more complex sequence including transitions (eg. scripted cutscene), as well as provide a standard way to register callbacks upon completion of the transition. --- direct/src/showbase/Transitions.py | 58 +++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/direct/src/showbase/Transitions.py b/direct/src/showbase/Transitions.py index aacb7afcc5..5c449c6997 100644 --- a/direct/src/showbase/Transitions.py +++ b/direct/src/showbase/Transitions.py @@ -23,7 +23,9 @@ class Transitions: scale=3.0, pos=Vec3(0, 0, 0)): self.transitionIval = None + self.__transitionFuture = None self.letterboxIval = None + self.__letterboxFuture = None self.iris = None self.fade = None self.letterbox = None @@ -151,11 +153,17 @@ class Transitions: self.noTransitions() self.loadFade() self.fade.detachNode() + fut = AsyncFuture() + fut.setResult(None) + return fut else: # Create a sequence that lerps the color out, then # parents the fade to hidden self.transitionIval = self.getFadeInIval(t, finishIval) + self.transitionIval.append(Func(self.__finishTransition)) + self.__transitionFuture = AsyncFuture() self.transitionIval.start() + return self.__transitionFuture def fadeOut(self, t=0.5, finishIval=None): """ @@ -181,8 +189,16 @@ class Transitions: else: # Create a sequence that lerps the color out, then # parents the fade to hidden - self.transitionIval = self.getFadeOutIval(t,finishIval) + self.transitionIval = self.getFadeOutIval(t, finishIval) + self.transitionIval.append(Func(self.__finishTransition)) + self.__transitionFuture = AsyncFuture() self.transitionIval.start() + return self.__transitionFuture + + # Immediately done, so return a dummy future. + fut = AsyncFuture() + fut.setResult(None) + return fut def fadeOutActive(self): return self.fade and self.fade.getColor()[3] > 0 @@ -226,6 +242,9 @@ class Transitions: if self.transitionIval: self.transitionIval.pause() self.transitionIval = None + if self.__transitionFuture: + self.__transitionFuture.cancel() + self.__transitionFuture = None if self.fade: # Make sure to reset the color, since fadeOutActive() is looking at it self.fade.setColor(self.alphaOff) @@ -256,6 +275,9 @@ class Transitions: self.loadIris() if (t == 0): self.iris.detachNode() + fut = AsyncFuture() + fut.setResult(None) + return fut else: self.iris.reparentTo(aspect2d, DGG.FADE_SORT_INDEX) @@ -264,11 +286,14 @@ class Transitions: scale = scale, startScale = 0.01), Func(self.iris.detachNode), + Func(self.__finishTransition), name = self.irisTaskName, ) + self.__transitionFuture = AsyncFuture() if finishIval: self.transitionIval.append(finishIval) self.transitionIval.start() + return self.__transitionFuture def irisOut(self, t=0.5, finishIval=None): """ @@ -284,6 +309,9 @@ class Transitions: if (t == 0): self.iris.detachNode() self.fadeOut(0) + fut = AsyncFuture() + fut.setResult(None) + return fut else: self.iris.reparentTo(aspect2d, DGG.FADE_SORT_INDEX) @@ -294,11 +322,14 @@ class Transitions: Func(self.iris.detachNode), # Use the fade to cover up the hole that the iris would leave Func(self.fadeOut, 0), + Func(self.__finishTransition), name = self.irisTaskName, ) + self.__transitionFuture = AsyncFuture() if finishIval: self.transitionIval.append(finishIval) self.transitionIval.start() + return self.__transitionFuture def noIris(self): """ @@ -322,6 +353,11 @@ class Transitions: # Letterbox is not really a transition, it is a screen overlay # self.noLetterbox() + def __finishTransition(self): + if self.__transitionFuture: + self.__transitionFuture.setResult(None) + self.__transitionFuture = None + ################################################## # Letterbox ################################################## @@ -394,9 +430,17 @@ class Transitions: if self.letterboxIval: self.letterboxIval.pause() self.letterboxIval = None + if self.__letterboxFuture: + self.__letterboxFuture.cancel() + self.__letterboxFuture = None if self.letterbox: self.letterbox.stash() + def __finishLetterbox(self): + if self.__letterboxFuture: + self.__letterboxFuture.setResult(None) + self.__letterboxFuture = None + def letterboxOn(self, t=0.25, finishIval=None): """ Move black bars in over t seconds. @@ -407,7 +451,11 @@ class Transitions: if (t == 0): self.letterboxBottom.setPos(0, 0, -1) self.letterboxTop.setPos(0, 0, 0.8) + fut = AsyncFuture() + fut.setResult(None) + return fut else: + self.__letterboxFuture = AsyncFuture() self.letterboxIval = Sequence(Parallel( LerpPosInterval(self.letterboxBottom, t, @@ -420,11 +468,13 @@ class Transitions: # startPos = Vec3(0, 0, 1), ), ), + Func(self.__finishLetterbox), name = self.letterboxTaskName, ) if finishIval: self.letterboxIval.append(finishIval) self.letterboxIval.start() + return self.__letterboxFuture def letterboxOff(self, t=0.25, finishIval=None): """ @@ -435,7 +485,11 @@ class Transitions: self.letterbox.unstash() if (t == 0): self.letterbox.stash() + fut = AsyncFuture() + fut.setResult(None) + return fut else: + self.__letterboxFuture = AsyncFuture() self.letterboxIval = Sequence(Parallel( LerpPosInterval(self.letterboxBottom, t, @@ -449,9 +503,11 @@ class Transitions: ), ), Func(self.letterbox.stash), + Func(self.__finishLetterbox), Func(messenger.send,'letterboxOff'), name = self.letterboxTaskName, ) if finishIval: self.letterboxIval.append(finishIval) self.letterboxIval.start() + return self.__letterboxFuture From 8a98bf42a3bf5ecd473fe5cfd77059b17a340747 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 5 May 2018 23:09:39 +0200 Subject: [PATCH 165/247] general: enable use of tie and tuple on macOS (from TR1, for now) --- dtool/src/dtoolbase/dtoolbase_cc.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index 6777ce5611..81968085bc 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -122,6 +122,11 @@ typedef ios::seekdir ios_seekdir; // Apple has an outdated libstdc++. Not all is lost, though, as we can fill // in some important missing functions. #if defined(__GLIBCXX__) && __GLIBCXX__ <= 20070719 +#include + +using std::tr1::tuple; +using std::tr1::tie; + typedef decltype(nullptr) nullptr_t; template struct remove_reference {typedef T type;}; From 549301d0f01976eb321055dc2a168368089050ef Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 5 May 2018 23:10:41 +0200 Subject: [PATCH 166/247] putil: keep reference to objects queued for writing This prevents a crash when a reference counted object is destroyed right after a write_pointer call. Fixes #310 --- panda/src/putil/bamWriter.cxx | 30 ++++++++++++++++++++++++++++-- panda/src/putil/bamWriter.h | 3 ++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/panda/src/putil/bamWriter.cxx b/panda/src/putil/bamWriter.cxx index 679600b664..0fcfd2fe1f 100644 --- a/panda/src/putil/bamWriter.cxx +++ b/panda/src/putil/bamWriter.cxx @@ -94,6 +94,10 @@ BamWriter:: for (si = _state_map.begin(); si != _state_map.end(); ++si) { TypedWritable *object = (TypedWritable *)(*si).first; object->remove_bam_writer(this); + + if ((*si).second._refcount != nullptr) { + unref_delete((*si).second._refcount); + } } } @@ -529,6 +533,9 @@ object_destructs(TypedWritable *object) { // we're in trouble when we do write it out. nassertv(!(*si).second._written_seq.is_initial()); + // This cannot be called if we are still holding a reference to it. + nassertv((*si).second._refcount == nullptr); + int object_id = (*si).second._object_id; _freed_object_ids.push_back(object_id); @@ -606,8 +613,10 @@ enqueue_object(const TypedWritable *object) { // No, it hasn't, so assign it the next number in sequence arbitrarily. object_id = _next_object_id; - bool inserted = - _state_map.insert(StateMap::value_type(object, StoreState(_next_object_id))).second; + StateMap::iterator si; + bool inserted; + tie(si, inserted) = + _state_map.insert(StateMap::value_type(object, StoreState(_next_object_id))); nassertr(inserted, false); // Store ourselves on the TypedWritable so that we get notified when it @@ -615,6 +624,14 @@ enqueue_object(const TypedWritable *object) { (const_cast(object))->add_bam_writer(this); _next_object_id++; + // Increase the reference count if this inherits from ReferenceCount, + // until we get a chance to write this object for the first time. + const ReferenceCount *rc = ((TypedWritable *)object)->as_reference_count(); + if (rc != nullptr) { + rc->ref(); + (*si).second._refcount = rc; + } + } else { // Yes, it has; get the object ID. object_id = (*si).second._object_id; @@ -703,6 +720,15 @@ flush_queue() { (*si).second._written_seq = _writing_seq; (*si).second._modified = object->get_bam_modified(); + // Now release any reference we hold to it, so that it may destruct. + const ReferenceCount *rc = (*si).second._refcount; + if (rc != nullptr) { + // We need to assign this pointer to null before deleting the object, + // since that may end up calling object_destructs. + (*si).second._refcount = nullptr; + unref_delete(rc); + } + } else { // On subsequent times when we write a particular object, we write // simply TypeHandle::none(), followed by the object ID. The occurrence diff --git a/panda/src/putil/bamWriter.h b/panda/src/putil/bamWriter.h index c2b04b3757..bcd4a76ce6 100644 --- a/panda/src/putil/bamWriter.h +++ b/panda/src/putil/bamWriter.h @@ -140,8 +140,9 @@ private: int _object_id; UpdateSeq _written_seq; UpdateSeq _modified; + const ReferenceCount *_refcount; - StoreState(int object_id) : _object_id(object_id) {} + StoreState(int object_id) : _object_id(object_id), _refcount(nullptr) {} }; typedef phash_map StateMap; StateMap _state_map; From ed54856e9fff6229750671fff3adc0af1c36f573 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 6 May 2018 22:18:30 +0200 Subject: [PATCH 167/247] makepanda: don't fail building Windows installer if Pmw is missing --- makepanda/installer.nsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makepanda/installer.nsi b/makepanda/installer.nsi index bd139f7083..39b7dd3518 100644 --- a/makepanda/installer.nsi +++ b/makepanda/installer.nsi @@ -368,7 +368,7 @@ SectionGroup "Python support" SetOutPath $INSTDIR\pandac\input File /r "${BUILT}\pandac\input\*" SetOutPath $INSTDIR\Pmw - File /r /x CVS "${BUILT}\Pmw\*" + File /nonfatal /r /x CVS "${BUILT}\Pmw\*" !ifdef REGVIEW SetRegView ${REGVIEW} From 666591ff48f036917fa224091ed0afe3eae8fbb4 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 6 May 2018 22:19:33 +0200 Subject: [PATCH 168/247] cppparser: fix compile warnings on MSVC --- dtool/src/cppparser/cppExpression.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dtool/src/cppparser/cppExpression.cxx b/dtool/src/cppparser/cppExpression.cxx index adbbaea14e..139ac72d1b 100644 --- a/dtool/src/cppparser/cppExpression.cxx +++ b/dtool/src/cppparser/cppExpression.cxx @@ -81,7 +81,7 @@ as_integer() const { case RT_pointer: // We don't mind if this loses precision. - return (int)reinterpret_cast(_u._pointer); + return (int)(intptr_t)(_u._pointer); default: cerr << "Invalid type\n"; @@ -104,7 +104,7 @@ as_real() const { case RT_pointer: // We don't mind if this loses precision. - return (double)reinterpret_cast(_u._pointer); + return (double)(uintptr_t)(_u._pointer); default: cerr << "Invalid type\n"; @@ -120,10 +120,10 @@ void *CPPExpression::Result:: as_pointer() const { switch (_type) { case RT_integer: - return reinterpret_cast((long)_u._integer); + return (void *)(intptr_t)_u._integer; case RT_real: - return reinterpret_cast((long)_u._real); + return (void *)(uintptr_t)_u._real; case RT_pointer: return _u._pointer; From 6175e79c5797c3be3ff67a33eac3fe3e6f909be7 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 6 May 2018 22:20:09 +0200 Subject: [PATCH 169/247] cppparser: fix infinite recursion stack overflow with enum classes --- dtool/src/cppparser/cppEnumType.cxx | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/dtool/src/cppparser/cppEnumType.cxx b/dtool/src/cppparser/cppEnumType.cxx index 927488585d..fbc3a7df53 100644 --- a/dtool/src/cppparser/cppEnumType.cxx +++ b/dtool/src/cppparser/cppEnumType.cxx @@ -224,12 +224,24 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, bool any_changed = false; for (size_t i = 0; i < _elements.size(); ++i) { - CPPInstance *elem_rep = - _elements[i]->substitute_decl(subst, current_scope, global_scope) - ->as_instance(); + // We don't just do substitute_decl on the instance, which could lead to + // an infinite recursion. + CPPInstance *element = _elements[i]; + CPPExpression *value = element->_initializer-> + substitute_decl(subst, current_scope, global_scope)->as_expression(); - if (elem_rep != _elements[i]) { - rep->_elements[i] = elem_rep; + if (is_scoped()) { + // For a strong enum, we consider the elements to be of this type. + if (value != element->_initializer) { + rep->_elements[i] = new CPPInstance(rep, element->_ident); + rep->_elements[i]->_initializer = value; + any_changed = true; + } + } else if (value != element->_initializer || + rep->get_underlying_type() != get_underlying_type()) { + // In an unscoped enum, the elements are integers. + rep->_elements[i] = new CPPInstance(rep->get_underlying_type(), element->_ident); + rep->_elements[i]->_initializer = value; any_changed = true; } } From 87c11d80187923960d6783dd6eef86da53ead2e7 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Wed, 9 May 2018 15:28:56 -0600 Subject: [PATCH 170/247] pstatclient: Rename config_pstats to config_pstatclient --- makepanda/makepanda.vcproj | 4 ++-- panda/metalibs/panda/panda.cxx | 2 +- panda/src/display/graphicsStateGuardian.cxx | 2 +- panda/src/display/pStatGPUTimer.h | 2 +- .../{config_pstats.cxx => config_pstatclient.cxx} | 8 ++++---- .../pstatclient/{config_pstats.h => config_pstatclient.h} | 4 ++-- panda/src/pstatclient/p3pstatclient_composite1.cxx | 2 +- panda/src/pstatclient/pStatClient.cxx | 2 +- panda/src/pstatclient/pStatClientControlMessage.cxx | 2 +- panda/src/pstatclient/pStatClientImpl.cxx | 2 +- panda/src/pstatclient/pStatFrameData.cxx | 2 +- panda/src/pstatclient/pStatProperties.cxx | 2 +- panda/src/pstatclient/pStatServerControlMessage.cxx | 2 +- panda/src/pstatclient/test_client.cxx | 2 +- pandatool/src/gtk-stats/gtkStats.cxx | 2 +- pandatool/src/pstatserver/pStatGraph.cxx | 2 +- pandatool/src/pstatserver/pStatPianoRoll.cxx | 2 +- pandatool/src/pstatserver/pStatServer.cxx | 2 +- pandatool/src/pstatserver/pStatStripChart.cxx | 2 +- pandatool/src/pstatserver/pStatThreadData.cxx | 2 +- pandatool/src/text-stats/textStats.cxx | 2 +- pandatool/src/win-stats/winStats.cxx | 2 +- 22 files changed, 27 insertions(+), 27 deletions(-) rename panda/src/pstatclient/{config_pstats.cxx => config_pstatclient.cxx} (96%) rename panda/src/pstatclient/{config_pstats.h => config_pstatclient.h} (93%) diff --git a/makepanda/makepanda.vcproj b/makepanda/makepanda.vcproj index c21322f94a..8041faf55c 100644 --- a/makepanda/makepanda.vcproj +++ b/makepanda/makepanda.vcproj @@ -2322,8 +2322,8 @@ - - + + diff --git a/panda/metalibs/panda/panda.cxx b/panda/metalibs/panda/panda.cxx index d3a3b0c24a..8a193a8a28 100644 --- a/panda/metalibs/panda/panda.cxx +++ b/panda/metalibs/panda/panda.cxx @@ -11,7 +11,7 @@ #include "config_display.h" #include "config_pgraph.h" #ifdef DO_PSTATS -#include "config_pstats.h" +#include "config_pstatclient.h" #endif // By including checkPandaVersion.h, we guarantee that runtime attempts to diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 5817b62e4a..5f282b82ce 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -58,7 +58,7 @@ #include "colorScaleAttrib.h" #include "clipPlaneAttrib.h" #include "fogAttrib.h" -#include "config_pstats.h" +#include "config_pstatclient.h" #include #include diff --git a/panda/src/display/pStatGPUTimer.h b/panda/src/display/pStatGPUTimer.h index f5185778ec..1e0accdc04 100644 --- a/panda/src/display/pStatGPUTimer.h +++ b/panda/src/display/pStatGPUTimer.h @@ -17,7 +17,7 @@ #include "pandabase.h" #include "pStatTimer.h" #include "pStatCollector.h" -#include "config_pstats.h" +#include "config_pstatclient.h" #include "timerQueryContext.h" class Thread; diff --git a/panda/src/pstatclient/config_pstats.cxx b/panda/src/pstatclient/config_pstatclient.cxx similarity index 96% rename from panda/src/pstatclient/config_pstats.cxx rename to panda/src/pstatclient/config_pstatclient.cxx index dcd49a4365..4be7472441 100644 --- a/panda/src/pstatclient/config_pstats.cxx +++ b/panda/src/pstatclient/config_pstatclient.cxx @@ -6,12 +6,12 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * @file config_pstats.cxx + * @file config_pstatclient.cxx * @author drose * @date 2000-07-09 */ -#include "config_pstats.h" +#include "config_pstatclient.h" #include "dconfig.h" @@ -19,10 +19,10 @@ #error Buildsystem error: BUILDING_PANDA_PSTATCLIENT not defined #endif -ConfigureDef(config_pstats); +ConfigureDef(config_pstatclient); NotifyCategoryDef(pstats, ""); -ConfigureFn(config_pstats) { +ConfigureFn(config_pstatclient) { init_libpstatclient(); } diff --git a/panda/src/pstatclient/config_pstats.h b/panda/src/pstatclient/config_pstatclient.h similarity index 93% rename from panda/src/pstatclient/config_pstats.h rename to panda/src/pstatclient/config_pstatclient.h index d3136ad736..6de3c5c120 100644 --- a/panda/src/pstatclient/config_pstats.h +++ b/panda/src/pstatclient/config_pstatclient.h @@ -6,7 +6,7 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * @file config_pstats.h + * @file config_pstatclient.h * @author drose * @date 2000-07-09 */ @@ -25,7 +25,7 @@ // Configure variables for pstats package. -ConfigureDecl(config_pstats, EXPCL_PANDA_PSTATCLIENT, EXPTP_PANDA_PSTATCLIENT); +ConfigureDecl(config_pstatclient, EXPCL_PANDA_PSTATCLIENT, EXPTP_PANDA_PSTATCLIENT); NotifyCategoryDecl(pstats, EXPCL_PANDA_PSTATCLIENT, EXPTP_PANDA_PSTATCLIENT); extern EXPCL_PANDA_PSTATCLIENT ConfigVariableString pstats_name; diff --git a/panda/src/pstatclient/p3pstatclient_composite1.cxx b/panda/src/pstatclient/p3pstatclient_composite1.cxx index e1a29761d7..b20594b02a 100644 --- a/panda/src/pstatclient/p3pstatclient_composite1.cxx +++ b/panda/src/pstatclient/p3pstatclient_composite1.cxx @@ -1,5 +1,5 @@ -#include "config_pstats.cxx" +#include "config_pstatclient.cxx" #include "pStatClient.cxx" #include "pStatClientImpl.cxx" #include "pStatClientVersion.cxx" diff --git a/panda/src/pstatclient/pStatClient.cxx b/panda/src/pstatclient/pStatClient.cxx index 906d99a29a..a735ea080e 100644 --- a/panda/src/pstatclient/pStatClient.cxx +++ b/panda/src/pstatclient/pStatClient.cxx @@ -21,7 +21,7 @@ #include "pStatServerControlMessage.h" #include "pStatCollector.h" #include "pStatThread.h" -#include "config_pstats.h" +#include "config_pstatclient.h" #include "pStatProperties.h" #include "thread.h" #include "clockObject.h" diff --git a/panda/src/pstatclient/pStatClientControlMessage.cxx b/panda/src/pstatclient/pStatClientControlMessage.cxx index 0cecb2aead..e7fd765547 100644 --- a/panda/src/pstatclient/pStatClientControlMessage.cxx +++ b/panda/src/pstatclient/pStatClientControlMessage.cxx @@ -11,7 +11,7 @@ * @date 2000-07-09 */ -#include "config_pstats.h" +#include "config_pstatclient.h" #include "pStatClientControlMessage.h" #include "pStatClientVersion.h" diff --git a/panda/src/pstatclient/pStatClientImpl.cxx b/panda/src/pstatclient/pStatClientImpl.cxx index 56f044d2a1..d126c6c753 100644 --- a/panda/src/pstatclient/pStatClientImpl.cxx +++ b/panda/src/pstatclient/pStatClientImpl.cxx @@ -21,7 +21,7 @@ #include "pStatServerControlMessage.h" #include "pStatCollector.h" #include "pStatThread.h" -#include "config_pstats.h" +#include "config_pstatclient.h" #include "pStatProperties.h" #include "cmath.h" diff --git a/panda/src/pstatclient/pStatFrameData.cxx b/panda/src/pstatclient/pStatFrameData.cxx index 835b30f1df..f15f6bc61e 100644 --- a/panda/src/pstatclient/pStatFrameData.cxx +++ b/panda/src/pstatclient/pStatFrameData.cxx @@ -13,7 +13,7 @@ #include "pStatFrameData.h" #include "pStatClientVersion.h" -#include "config_pstats.h" +#include "config_pstatclient.h" #include "datagram.h" #include "datagramIterator.h" diff --git a/panda/src/pstatclient/pStatProperties.cxx b/panda/src/pstatclient/pStatProperties.cxx index 25d2bfd591..01411f3f74 100644 --- a/panda/src/pstatclient/pStatProperties.cxx +++ b/panda/src/pstatclient/pStatProperties.cxx @@ -14,7 +14,7 @@ #include "pStatProperties.h" #include "pStatCollectorDef.h" #include "pStatClient.h" -#include "config_pstats.h" +#include "config_pstatclient.h" #include "configVariableBool.h" #include "configVariableColor.h" #include "configVariableDouble.h" diff --git a/panda/src/pstatclient/pStatServerControlMessage.cxx b/panda/src/pstatclient/pStatServerControlMessage.cxx index f5003ba18c..e75f9eebec 100644 --- a/panda/src/pstatclient/pStatServerControlMessage.cxx +++ b/panda/src/pstatclient/pStatServerControlMessage.cxx @@ -11,7 +11,7 @@ * @date 2000-07-09 */ -#include "config_pstats.h" +#include "config_pstatclient.h" #include "pStatServerControlMessage.h" #include "datagram.h" diff --git a/panda/src/pstatclient/test_client.cxx b/panda/src/pstatclient/test_client.cxx index 11f6f392fe..35a79a8cbd 100644 --- a/panda/src/pstatclient/test_client.cxx +++ b/panda/src/pstatclient/test_client.cxx @@ -11,7 +11,7 @@ * @date 2000-07-09 */ -#include "config_pstats.h" +#include "config_pstatclient.h" #include "pStatClient.h" #include "pStatCollector.h" #include "thread.h" diff --git a/pandatool/src/gtk-stats/gtkStats.cxx b/pandatool/src/gtk-stats/gtkStats.cxx index b76bc292f3..5f3cf83e82 100644 --- a/pandatool/src/gtk-stats/gtkStats.cxx +++ b/pandatool/src/gtk-stats/gtkStats.cxx @@ -14,7 +14,7 @@ #include "pandatoolbase.h" #include "gtkStats.h" #include "gtkStatsServer.h" -#include "config_pstats.h" +#include "config_pstatclient.h" GtkWidget *main_window; static GtkStatsServer *server = NULL; diff --git a/pandatool/src/pstatserver/pStatGraph.cxx b/pandatool/src/pstatserver/pStatGraph.cxx index a216950117..f65dafbc3b 100644 --- a/pandatool/src/pstatserver/pStatGraph.cxx +++ b/pandatool/src/pstatserver/pStatGraph.cxx @@ -16,7 +16,7 @@ #include "pStatFrameData.h" #include "pStatCollectorDef.h" #include "string_utils.h" -#include "config_pstats.h" +#include "config_pstatclient.h" #include // for sprintf diff --git a/pandatool/src/pstatserver/pStatPianoRoll.cxx b/pandatool/src/pstatserver/pStatPianoRoll.cxx index 517fca358a..923c3991e7 100644 --- a/pandatool/src/pstatserver/pStatPianoRoll.cxx +++ b/pandatool/src/pstatserver/pStatPianoRoll.cxx @@ -16,7 +16,7 @@ #include "pStatFrameData.h" #include "pStatCollectorDef.h" #include "string_utils.h" -#include "config_pstats.h" +#include "config_pstatclient.h" #include diff --git a/pandatool/src/pstatserver/pStatServer.cxx b/pandatool/src/pstatserver/pStatServer.cxx index ddb6926995..1e295ee4f9 100644 --- a/pandatool/src/pstatserver/pStatServer.cxx +++ b/pandatool/src/pstatserver/pStatServer.cxx @@ -14,7 +14,7 @@ #include "pStatServer.h" #include "pStatReader.h" #include "thread.h" -#include "config_pstats.h" +#include "config_pstatclient.h" /** * diff --git a/pandatool/src/pstatserver/pStatStripChart.cxx b/pandatool/src/pstatserver/pStatStripChart.cxx index 28b28d6240..9b64abaa02 100644 --- a/pandatool/src/pstatserver/pStatStripChart.cxx +++ b/pandatool/src/pstatserver/pStatStripChart.cxx @@ -18,7 +18,7 @@ #include "pStatFrameData.h" #include "pStatCollectorDef.h" #include "string_utils.h" -#include "config_pstats.h" +#include "config_pstatclient.h" #include diff --git a/pandatool/src/pstatserver/pStatThreadData.cxx b/pandatool/src/pstatserver/pStatThreadData.cxx index eb3aa92702..fd5e3f411b 100644 --- a/pandatool/src/pstatserver/pStatThreadData.cxx +++ b/pandatool/src/pstatserver/pStatThreadData.cxx @@ -15,7 +15,7 @@ #include "pStatFrameData.h" #include "pStatCollectorDef.h" -#include "config_pstats.h" +#include "config_pstatclient.h" PStatFrameData PStatThreadData::_null_frame; diff --git a/pandatool/src/text-stats/textStats.cxx b/pandatool/src/text-stats/textStats.cxx index 2cbf69b4d9..cc1e2392c1 100644 --- a/pandatool/src/text-stats/textStats.cxx +++ b/pandatool/src/text-stats/textStats.cxx @@ -15,7 +15,7 @@ #include "textMonitor.h" #include "pStatServer.h" -#include "config_pstats.h" +#include "config_pstatclient.h" #include diff --git a/pandatool/src/win-stats/winStats.cxx b/pandatool/src/win-stats/winStats.cxx index e8995edaba..5c54535210 100644 --- a/pandatool/src/win-stats/winStats.cxx +++ b/pandatool/src/win-stats/winStats.cxx @@ -14,7 +14,7 @@ #include "pandatoolbase.h" #include "winStatsServer.h" -#include "config_pstats.h" +#include "config_pstatclient.h" #include From 52e7c952b30a0b274499a8c8c9a42cd8934575b9 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Wed, 9 May 2018 15:30:19 -0600 Subject: [PATCH 171/247] putil: Rename config_util to config_putil --- makepanda/makepanda.vcproj | 4 ++-- panda/src/android/android_main.cxx | 2 +- panda/src/audio/audioManager.cxx | 2 +- panda/src/audiotraits/fmodAudioManager.cxx | 2 +- panda/src/audiotraits/milesAudioManager.cxx | 2 +- panda/src/audiotraits/openalAudioManager.cxx | 2 +- panda/src/collada/load_collada_file.cxx | 2 +- panda/src/display/graphicsPipeSelection.cxx | 2 +- panda/src/egg/eggData.cxx | 2 +- panda/src/egg2pg/load_egg_file.cxx | 2 +- panda/src/egg2pg/save_egg_file.cxx | 2 +- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 2 +- panda/src/gobj/config_gobj.cxx | 2 +- panda/src/gobj/shader.cxx | 2 +- panda/src/gobj/texture.cxx | 2 +- panda/src/gobj/texturePool.cxx | 2 +- panda/src/iphonedisplay/iPhoneGraphicsWindow.mm | 2 +- panda/src/movies/movieTypeRegistry.cxx | 2 +- panda/src/osxdisplay/osxGraphicsWindow.mm | 2 +- panda/src/pgraph/bamFile.cxx | 2 +- panda/src/pgraph/loader.cxx | 2 +- panda/src/pgraph/shaderPool.cxx | 2 +- panda/src/physx/physxEnums.cxx | 2 +- panda/src/pnmtext/freetypeFont.cxx | 2 +- panda/src/putil/autoTextureScale.cxx | 2 +- panda/src/putil/bamCache.cxx | 2 +- panda/src/putil/bamCacheIndex.cxx | 2 +- panda/src/putil/bamCacheRecord.cxx | 2 +- panda/src/putil/bamEnums.cxx | 2 +- panda/src/putil/bamReader.cxx | 2 +- panda/src/putil/bamReader_ext.cxx | 2 +- panda/src/putil/bamWriter.cxx | 2 +- panda/src/putil/buttonRegistry.cxx | 2 +- panda/src/putil/clockObject.cxx | 2 +- panda/src/putil/colorSpace.cxx | 2 +- panda/src/putil/{config_util.N => config_putil.N} | 0 panda/src/putil/{config_util.cxx => config_putil.cxx} | 8 ++++---- panda/src/putil/{config_util.h => config_putil.h} | 4 ++-- panda/src/putil/copyOnWritePointer.cxx | 2 +- panda/src/putil/datagramInputFile.cxx | 2 +- panda/src/putil/datagramOutputFile.h | 2 +- panda/src/putil/factoryBase.cxx | 2 +- panda/src/putil/globalPointerRegistry.cxx | 2 +- panda/src/putil/keyboardButton.cxx | 2 +- panda/src/putil/load_prc_file.cxx | 2 +- panda/src/putil/loaderOptions.cxx | 4 ++-- panda/src/putil/mouseButton.cxx | 2 +- panda/src/putil/p3putil_composite1.cxx | 2 +- panda/src/putil/pythonCallbackObject.cxx | 2 +- panda/src/putil/simpleHashMap.h | 2 +- panda/src/putil/test_filename.cxx | 2 +- panda/src/putil/weakKeyHashMap.h | 2 +- panda/src/speedtree/speedTreeNode.cxx | 2 +- panda/src/text/dynamicTextFont.cxx | 2 +- panda/src/text/fontPool.cxx | 2 +- panda/src/tinydisplay/tinyOsxGraphicsWindow.mm | 2 +- panda/src/windisplay/winGraphicsWindow.cxx | 2 +- pandatool/src/bam/eggToBam.cxx | 2 +- pandatool/src/bam/ptsToBam.cxx | 2 +- pandatool/src/converter/somethingToEggConverter.h | 2 +- pandatool/src/egg-palettize/txaFileFilter.cxx | 2 +- pandatool/src/eggbase/eggReader.cxx | 2 +- pandatool/src/eggbase/somethingToEgg.cxx | 2 +- pandatool/src/flt/fltTexture.cxx | 2 +- pandatool/src/maxegg/maxToEggConverter.cxx | 2 +- pandatool/src/mayaprogs/mayaPview.cxx | 2 +- pandatool/src/pandatoolbase/pathReplace.cxx | 2 +- pandatool/src/ptloader/loaderFileTypePandatool.cxx | 2 +- 68 files changed, 73 insertions(+), 73 deletions(-) rename panda/src/putil/{config_util.N => config_putil.N} (100%) rename panda/src/putil/{config_util.cxx => config_putil.cxx} (98%) rename panda/src/putil/{config_util.h => config_putil.h} (95%) diff --git a/makepanda/makepanda.vcproj b/makepanda/makepanda.vcproj index 8041faf55c..b8bdcbf07b 100644 --- a/makepanda/makepanda.vcproj +++ b/makepanda/makepanda.vcproj @@ -1228,7 +1228,7 @@ - + @@ -1307,7 +1307,7 @@ - + diff --git a/panda/src/android/android_main.cxx b/panda/src/android/android_main.cxx index 0565ef5835..865936e2ed 100644 --- a/panda/src/android/android_main.cxx +++ b/panda/src/android/android_main.cxx @@ -12,7 +12,7 @@ */ #include "config_android.h" -#include "config_util.h" +#include "config_putil.h" #include "virtualFileMountAndroidAsset.h" #include "virtualFileSystem.h" #include "filename.h" diff --git a/panda/src/audio/audioManager.cxx b/panda/src/audio/audioManager.cxx index c09bbffc05..b52ceb50e5 100644 --- a/panda/src/audio/audioManager.cxx +++ b/panda/src/audio/audioManager.cxx @@ -18,7 +18,7 @@ #include "nullAudioManager.h" #include "windowsRegistry.h" #include "virtualFileSystem.h" -#include "config_util.h" +#include "config_putil.h" #include "load_dso.h" #ifdef WIN32 diff --git a/panda/src/audiotraits/fmodAudioManager.cxx b/panda/src/audiotraits/fmodAudioManager.cxx index cc1b8ecd0b..012fd103cd 100644 --- a/panda/src/audiotraits/fmodAudioManager.cxx +++ b/panda/src/audiotraits/fmodAudioManager.cxx @@ -20,7 +20,7 @@ // Panda headers. #include "config_audio.h" -#include "config_util.h" +#include "config_putil.h" #include "fmodAudioManager.h" #include "fmodAudioSound.h" #include "filename.h" diff --git a/panda/src/audiotraits/milesAudioManager.cxx b/panda/src/audiotraits/milesAudioManager.cxx index 750475dee1..c20ebd1a9a 100644 --- a/panda/src/audiotraits/milesAudioManager.cxx +++ b/panda/src/audiotraits/milesAudioManager.cxx @@ -21,7 +21,7 @@ #include "milesAudioStream.h" #include "globalMilesManager.h" #include "config_audio.h" -#include "config_util.h" +#include "config_putil.h" #include "config_express.h" #include "virtualFileSystem.h" #include "nullAudioSound.h" diff --git a/panda/src/audiotraits/openalAudioManager.cxx b/panda/src/audiotraits/openalAudioManager.cxx index 2ba02c2fa7..1a91185ecf 100644 --- a/panda/src/audiotraits/openalAudioManager.cxx +++ b/panda/src/audiotraits/openalAudioManager.cxx @@ -14,7 +14,7 @@ // Panda headers. #include "config_audio.h" -#include "config_util.h" +#include "config_putil.h" #include "config_express.h" #include "config_openalAudio.h" #include "openalAudioManager.h" diff --git a/panda/src/collada/load_collada_file.cxx b/panda/src/collada/load_collada_file.cxx index bda9641c6f..1d849f0f79 100644 --- a/panda/src/collada/load_collada_file.cxx +++ b/panda/src/collada/load_collada_file.cxx @@ -16,7 +16,7 @@ #include "config_collada.h" #include "sceneGraphReducer.h" #include "virtualFileSystem.h" -#include "config_util.h" +#include "config_putil.h" #include "bamCacheRecord.h" static PT(PandaNode) diff --git a/panda/src/display/graphicsPipeSelection.cxx b/panda/src/display/graphicsPipeSelection.cxx index cef68b22c2..1134cc0553 100644 --- a/panda/src/display/graphicsPipeSelection.cxx +++ b/panda/src/display/graphicsPipeSelection.cxx @@ -19,7 +19,7 @@ #include "config_display.h" #include "typeRegistry.h" #include "pset.h" -#include "config_util.h" +#include "config_putil.h" #include diff --git a/panda/src/egg/eggData.cxx b/panda/src/egg/eggData.cxx index f81755f8d9..69eb4eb6e6 100644 --- a/panda/src/egg/eggData.cxx +++ b/panda/src/egg/eggData.cxx @@ -18,7 +18,7 @@ #include "eggComment.h" #include "eggPoolUniquifier.h" #include "config_egg.h" -#include "config_util.h" +#include "config_putil.h" #include "config_express.h" #include "string_utils.h" #include "dSearchPath.h" diff --git a/panda/src/egg2pg/load_egg_file.cxx b/panda/src/egg2pg/load_egg_file.cxx index a3a5dd5fbf..36b60bb92c 100644 --- a/panda/src/egg2pg/load_egg_file.cxx +++ b/panda/src/egg2pg/load_egg_file.cxx @@ -16,7 +16,7 @@ #include "config_egg2pg.h" #include "sceneGraphReducer.h" #include "virtualFileSystem.h" -#include "config_util.h" +#include "config_putil.h" #include "bamCacheRecord.h" static PT(PandaNode) diff --git a/panda/src/egg2pg/save_egg_file.cxx b/panda/src/egg2pg/save_egg_file.cxx index 520987da68..bda4205943 100644 --- a/panda/src/egg2pg/save_egg_file.cxx +++ b/panda/src/egg2pg/save_egg_file.cxx @@ -17,7 +17,7 @@ #include "modelRoot.h" #include "sceneGraphReducer.h" #include "virtualFileSystem.h" -#include "config_util.h" +#include "config_putil.h" /** * A convenience function; converts the indicated scene graph to an egg file diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index f5a42e2e45..c4dd42ceb3 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -14,7 +14,7 @@ * get_supports_cg_profile) */ -#include "config_util.h" +#include "config_putil.h" #include "displayRegion.h" #include "renderBuffer.h" #include "geom.h" diff --git a/panda/src/gobj/config_gobj.cxx b/panda/src/gobj/config_gobj.cxx index d152f6ebcf..b7d0e02eb5 100644 --- a/panda/src/gobj/config_gobj.cxx +++ b/panda/src/gobj/config_gobj.cxx @@ -13,7 +13,7 @@ #include "animateVerticesRequest.h" #include "bufferContext.h" -#include "config_util.h" +#include "config_putil.h" #include "config_gobj.h" #include "geom.h" #include "geomCacheEntry.h" diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index add7acef2f..35fd3ce560 100644 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -19,7 +19,7 @@ #include "shader.h" #include "preparedGraphicsObjects.h" #include "virtualFileSystem.h" -#include "config_util.h" +#include "config_putil.h" #include "bamCache.h" #include "string_utils.h" diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 5328b921d9..fa85fd44f0 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -16,7 +16,7 @@ #include "pandabase.h" #include "texture.h" #include "config_gobj.h" -#include "config_util.h" +#include "config_putil.h" #include "texturePool.h" #include "textureContext.h" #include "bamCache.h" diff --git a/panda/src/gobj/texturePool.cxx b/panda/src/gobj/texturePool.cxx index dd850c98ad..6b4c0a5168 100644 --- a/panda/src/gobj/texturePool.cxx +++ b/panda/src/gobj/texturePool.cxx @@ -15,7 +15,7 @@ #include "texturePool.h" #include "config_gobj.h" -#include "config_util.h" +#include "config_putil.h" #include "config_express.h" #include "string_utils.h" #include "virtualFileSystem.h" diff --git a/panda/src/iphonedisplay/iPhoneGraphicsWindow.mm b/panda/src/iphonedisplay/iPhoneGraphicsWindow.mm index cae0463e6b..07be09f580 100644 --- a/panda/src/iphonedisplay/iPhoneGraphicsWindow.mm +++ b/panda/src/iphonedisplay/iPhoneGraphicsWindow.mm @@ -31,7 +31,7 @@ #include "throw_event.h" #include "pnmImage.h" #include "virtualFileSystem.h" -#include "config_util.h" +#include "config_putil.h" #include "pset.h" #include "pmutex.h" diff --git a/panda/src/movies/movieTypeRegistry.cxx b/panda/src/movies/movieTypeRegistry.cxx index bca56d3628..9c747b6fe3 100644 --- a/panda/src/movies/movieTypeRegistry.cxx +++ b/panda/src/movies/movieTypeRegistry.cxx @@ -14,7 +14,7 @@ #include "movieTypeRegistry.h" #include "string_utils.h" #include "config_movies.h" -#include "config_util.h" +#include "config_putil.h" #include "load_dso.h" MovieTypeRegistry *MovieTypeRegistry::_global_ptr = NULL; diff --git a/panda/src/osxdisplay/osxGraphicsWindow.mm b/panda/src/osxdisplay/osxGraphicsWindow.mm index 4fe2c45965..293f2fd2a3 100644 --- a/panda/src/osxdisplay/osxGraphicsWindow.mm +++ b/panda/src/osxdisplay/osxGraphicsWindow.mm @@ -36,7 +36,7 @@ #include "throw_event.h" #include "pnmImage.h" #include "virtualFileSystem.h" -#include "config_util.h" +#include "config_putil.h" #include "pset.h" #include "pmutex.h" diff --git a/panda/src/pgraph/bamFile.cxx b/panda/src/pgraph/bamFile.cxx index 83256c340a..871ec94587 100644 --- a/panda/src/pgraph/bamFile.cxx +++ b/panda/src/pgraph/bamFile.cxx @@ -16,7 +16,7 @@ #include "bam.h" #include "bamCacheRecord.h" -#include "config_util.h" +#include "config_putil.h" #include "bamReader.h" #include "bamWriter.h" #include "filename.h" diff --git a/panda/src/pgraph/loader.cxx b/panda/src/pgraph/loader.cxx index 32187508e0..7e8c201daf 100644 --- a/panda/src/pgraph/loader.cxx +++ b/panda/src/pgraph/loader.cxx @@ -19,7 +19,7 @@ #include "modelLoadRequest.h" #include "modelSaveRequest.h" #include "config_express.h" -#include "config_util.h" +#include "config_putil.h" #include "virtualFileSystem.h" #include "filename.h" #include "load_dso.h" diff --git a/panda/src/pgraph/shaderPool.cxx b/panda/src/pgraph/shaderPool.cxx index 6334d83789..ba9f99e8c2 100644 --- a/panda/src/pgraph/shaderPool.cxx +++ b/panda/src/pgraph/shaderPool.cxx @@ -12,7 +12,7 @@ */ #include "shaderPool.h" -#include "config_util.h" +#include "config_putil.h" #include "config_express.h" #include "virtualFileSystem.h" #include "loader.h" diff --git a/panda/src/physx/physxEnums.cxx b/panda/src/physx/physxEnums.cxx index 5b186445c2..172e6013b3 100644 --- a/panda/src/physx/physxEnums.cxx +++ b/panda/src/physx/physxEnums.cxx @@ -14,7 +14,7 @@ #include "physxEnums.h" #include "string_utils.h" -#include "config_util.h" +#include "config_putil.h" ostream & operator << (ostream &out, PhysxEnums::PhysxUpAxis axis) { diff --git a/panda/src/pnmtext/freetypeFont.cxx b/panda/src/pnmtext/freetypeFont.cxx index f42b5b72bc..379a139426 100644 --- a/panda/src/pnmtext/freetypeFont.cxx +++ b/panda/src/pnmtext/freetypeFont.cxx @@ -16,7 +16,7 @@ #ifdef HAVE_FREETYPE #include "config_pnmtext.h" -#include "config_util.h" +#include "config_putil.h" #include "config_express.h" #include "virtualFileSystem.h" #include "nurbsCurveEvaluator.h" diff --git a/panda/src/putil/autoTextureScale.cxx b/panda/src/putil/autoTextureScale.cxx index 38f1c0a62a..ea17b6f08b 100644 --- a/panda/src/putil/autoTextureScale.cxx +++ b/panda/src/putil/autoTextureScale.cxx @@ -13,7 +13,7 @@ #include "autoTextureScale.h" #include "string_utils.h" -#include "config_util.h" +#include "config_putil.h" ostream & operator << (ostream &out, AutoTextureScale ats) { diff --git a/panda/src/putil/bamCache.cxx b/panda/src/putil/bamCache.cxx index 5576e16a43..94c31665c6 100644 --- a/panda/src/putil/bamCache.cxx +++ b/panda/src/putil/bamCache.cxx @@ -18,7 +18,7 @@ #include "hashVal.h" #include "datagramInputFile.h" #include "datagramOutputFile.h" -#include "config_util.h" +#include "config_putil.h" #include "bam.h" #include "typeRegistry.h" #include "string_utils.h" diff --git a/panda/src/putil/bamCacheIndex.cxx b/panda/src/putil/bamCacheIndex.cxx index 600ee6c328..31c62ec3a5 100644 --- a/panda/src/putil/bamCacheIndex.cxx +++ b/panda/src/putil/bamCacheIndex.cxx @@ -14,7 +14,7 @@ #include "bamCacheIndex.h" #include "bamReader.h" #include "bamWriter.h" -#include "config_util.h" // util_cat +#include "config_putil.h" // util_cat #include "indent.h" #include diff --git a/panda/src/putil/bamCacheRecord.cxx b/panda/src/putil/bamCacheRecord.cxx index 487d2b1e5d..8fabae7326 100644 --- a/panda/src/putil/bamCacheRecord.cxx +++ b/panda/src/putil/bamCacheRecord.cxx @@ -17,7 +17,7 @@ #include "virtualFileSystem.h" #include "virtualFile.h" #include "indent.h" -#include "config_util.h" // util_cat +#include "config_putil.h" // util_cat TypeHandle BamCacheRecord::_type_handle; diff --git a/panda/src/putil/bamEnums.cxx b/panda/src/putil/bamEnums.cxx index 292227d359..ed1b18ac58 100644 --- a/panda/src/putil/bamEnums.cxx +++ b/panda/src/putil/bamEnums.cxx @@ -13,7 +13,7 @@ #include "bamEnums.h" #include "string_utils.h" -#include "config_util.h" +#include "config_putil.h" ostream & operator << (ostream &out, BamEnums::BamEndian be) { diff --git a/panda/src/putil/bamReader.cxx b/panda/src/putil/bamReader.cxx index 3ab1386d7f..eab309c9d6 100644 --- a/panda/src/putil/bamReader.cxx +++ b/panda/src/putil/bamReader.cxx @@ -17,7 +17,7 @@ #include "bam.h" #include "bamReader.h" #include "datagramIterator.h" -#include "config_util.h" +#include "config_putil.h" #include "pipelineCyclerBase.h" TypeHandle BamReaderAuxData::_type_handle; diff --git a/panda/src/putil/bamReader_ext.cxx b/panda/src/putil/bamReader_ext.cxx index 1648d7e24c..444688a654 100644 --- a/panda/src/putil/bamReader_ext.cxx +++ b/panda/src/putil/bamReader_ext.cxx @@ -12,7 +12,7 @@ */ #include "bamReader_ext.h" -#include "config_util.h" +#include "config_putil.h" #include "pythonThread.h" #ifdef HAVE_PYTHON diff --git a/panda/src/putil/bamWriter.cxx b/panda/src/putil/bamWriter.cxx index 0fcfd2fe1f..ac3ac6b8ad 100644 --- a/panda/src/putil/bamWriter.cxx +++ b/panda/src/putil/bamWriter.cxx @@ -15,7 +15,7 @@ #include "pnotify.h" #include "typedWritable.h" -#include "config_util.h" +#include "config_putil.h" #include "bam.h" #include "bamWriter.h" #include "bamReader.h" diff --git a/panda/src/putil/buttonRegistry.cxx b/panda/src/putil/buttonRegistry.cxx index ff181c95ae..594a5864fd 100644 --- a/panda/src/putil/buttonRegistry.cxx +++ b/panda/src/putil/buttonRegistry.cxx @@ -12,7 +12,7 @@ */ #include "buttonRegistry.h" -#include "config_util.h" +#include "config_putil.h" #include diff --git a/panda/src/putil/clockObject.cxx b/panda/src/putil/clockObject.cxx index 09353ab739..341a11374a 100644 --- a/panda/src/putil/clockObject.cxx +++ b/panda/src/putil/clockObject.cxx @@ -12,7 +12,7 @@ */ #include "clockObject.h" -#include "config_util.h" +#include "config_putil.h" #include "configVariableEnum.h" #include "string_utils.h" #include "thread.h" diff --git a/panda/src/putil/colorSpace.cxx b/panda/src/putil/colorSpace.cxx index 34c37ee423..075eb438a1 100644 --- a/panda/src/putil/colorSpace.cxx +++ b/panda/src/putil/colorSpace.cxx @@ -12,7 +12,7 @@ */ #include "colorSpace.h" -#include "config_util.h" +#include "config_putil.h" #include "configVariableEnum.h" #include "string_utils.h" diff --git a/panda/src/putil/config_util.N b/panda/src/putil/config_putil.N similarity index 100% rename from panda/src/putil/config_util.N rename to panda/src/putil/config_putil.N diff --git a/panda/src/putil/config_util.cxx b/panda/src/putil/config_putil.cxx similarity index 98% rename from panda/src/putil/config_util.cxx rename to panda/src/putil/config_putil.cxx index c5956adc2b..5461b73f3f 100644 --- a/panda/src/putil/config_util.cxx +++ b/panda/src/putil/config_putil.cxx @@ -6,12 +6,12 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * @file config_util.cxx + * @file config_putil.cxx * @author cary * @date 2000-01-04 */ -#include "config_util.h" +#include "config_putil.h" #include "animInterface.h" #include "bamCacheIndex.h" #include "bamCacheRecord.h" @@ -51,7 +51,7 @@ #error Buildsystem error: BUILDING_PANDA_PUTIL not defined #endif -ConfigureDef(config_util); +ConfigureDef(config_putil); NotifyCategoryDef(util, ""); NotifyCategoryDef(bam, util_cat); @@ -88,7 +88,7 @@ ConfigVariableEnum bam_texture_mode PRC_DESC("Set this to specify how textures should be written into Bam files." "See the panda source or documentation for available options.")); -ConfigureFn(config_util) { +ConfigureFn(config_putil) { init_libputil(); } diff --git a/panda/src/putil/config_util.h b/panda/src/putil/config_putil.h similarity index 95% rename from panda/src/putil/config_util.h rename to panda/src/putil/config_putil.h index 34ff4abc2d..ec9f683378 100644 --- a/panda/src/putil/config_util.h +++ b/panda/src/putil/config_putil.h @@ -6,7 +6,7 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * @file config_util.h + * @file config_putil.h * @author cary * @date 2000-01-04 */ @@ -24,7 +24,7 @@ class DSearchPath; -ConfigureDecl(config_util, EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL); +ConfigureDecl(config_putil, EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL); NotifyCategoryDecl(util, EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL); NotifyCategoryDecl(bam, EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL); diff --git a/panda/src/putil/copyOnWritePointer.cxx b/panda/src/putil/copyOnWritePointer.cxx index 03ed76e24b..4beb105ada 100644 --- a/panda/src/putil/copyOnWritePointer.cxx +++ b/panda/src/putil/copyOnWritePointer.cxx @@ -12,7 +12,7 @@ */ #include "copyOnWritePointer.h" -#include "config_util.h" +#include "config_putil.h" #include "config_pipeline.h" #ifdef COW_THREADED diff --git a/panda/src/putil/datagramInputFile.cxx b/panda/src/putil/datagramInputFile.cxx index f81381d02e..4fc9b47ffb 100644 --- a/panda/src/putil/datagramInputFile.cxx +++ b/panda/src/putil/datagramInputFile.cxx @@ -16,7 +16,7 @@ #include "numeric_types.h" #include "datagramIterator.h" #include "profileTimer.h" -#include "config_util.h" +#include "config_putil.h" #include "config_express.h" #include "virtualFileSystem.h" #include "streamReader.h" diff --git a/panda/src/putil/datagramOutputFile.h b/panda/src/putil/datagramOutputFile.h index bd2007219a..c81dcdf986 100644 --- a/panda/src/putil/datagramOutputFile.h +++ b/panda/src/putil/datagramOutputFile.h @@ -21,7 +21,7 @@ #include "fileReference.h" #include "virtualFile.h" #include "virtualFileSystem.h" -#include "config_util.h" +#include "config_putil.h" /** * This class can be used to write a binary file that consists of an arbitrary diff --git a/panda/src/putil/factoryBase.cxx b/panda/src/putil/factoryBase.cxx index 52704e92cd..d34035177c 100644 --- a/panda/src/putil/factoryBase.cxx +++ b/panda/src/putil/factoryBase.cxx @@ -13,7 +13,7 @@ #include "factoryBase.h" #include "indent.h" -#include "config_util.h" +#include "config_putil.h" /** * diff --git a/panda/src/putil/globalPointerRegistry.cxx b/panda/src/putil/globalPointerRegistry.cxx index dcec8579bd..40e062d9c0 100644 --- a/panda/src/putil/globalPointerRegistry.cxx +++ b/panda/src/putil/globalPointerRegistry.cxx @@ -12,7 +12,7 @@ */ #include "globalPointerRegistry.h" -#include "config_util.h" +#include "config_putil.h" // In general, we use the util_cat->info() syntax in this file (instead of // util_cat.info()), because much of this work is done at static init time, diff --git a/panda/src/putil/keyboardButton.cxx b/panda/src/putil/keyboardButton.cxx index 07e5265c03..e6d7162d50 100644 --- a/panda/src/putil/keyboardButton.cxx +++ b/panda/src/putil/keyboardButton.cxx @@ -84,7 +84,7 @@ DEFINE_KEYBD_BUTTON_HANDLE(rmeta) /** * This is intended to be called only once, by the static initialization - * performed in config_util.cxx. + * performed in config_putil.cxx. */ void KeyboardButton:: init_keyboard_buttons() { diff --git a/panda/src/putil/load_prc_file.cxx b/panda/src/putil/load_prc_file.cxx index d35a3b9c29..5663c49038 100644 --- a/panda/src/putil/load_prc_file.cxx +++ b/panda/src/putil/load_prc_file.cxx @@ -16,7 +16,7 @@ #include "configVariableManager.h" #include "virtualFileSystem.h" #include "config_express.h" -#include "config_util.h" +#include "config_putil.h" #include "hashVal.h" /** diff --git a/panda/src/putil/loaderOptions.cxx b/panda/src/putil/loaderOptions.cxx index 61aeb4f5d1..7f57d77fef 100644 --- a/panda/src/putil/loaderOptions.cxx +++ b/panda/src/putil/loaderOptions.cxx @@ -12,7 +12,7 @@ */ #include "loaderOptions.h" -#include "config_util.h" +#include "config_putil.h" #include "indent.h" /** @@ -25,7 +25,7 @@ LoaderOptions(int flags) : _texture_num_views(0), _auto_texture_scale(ATS_unspecified) { - // Shadowing the variables in config_util for static init ordering issues. + // Shadowing the variables in config_putil for static init ordering issues. static ConfigVariableBool *preload_textures; static ConfigVariableBool *preload_simple_textures; static ConfigVariableBool *compressed_textures; diff --git a/panda/src/putil/mouseButton.cxx b/panda/src/putil/mouseButton.cxx index 5f3ebabbe1..ef3802edca 100644 --- a/panda/src/putil/mouseButton.cxx +++ b/panda/src/putil/mouseButton.cxx @@ -129,7 +129,7 @@ is_mouse_button(ButtonHandle button) { /** * This is intended to be called only once, by the static initialization - * performed in config_util.cxx. + * performed in config_putil.cxx. */ void MouseButton:: init_mouse_buttons() { diff --git a/panda/src/putil/p3putil_composite1.cxx b/panda/src/putil/p3putil_composite1.cxx index 4fc6fcaf70..446f7f1f07 100644 --- a/panda/src/putil/p3putil_composite1.cxx +++ b/panda/src/putil/p3putil_composite1.cxx @@ -17,7 +17,7 @@ #include "callbackObject.cxx" #include "clockObject.cxx" #include "colorSpace.cxx" -#include "config_util.cxx" +#include "config_putil.cxx" #include "configurable.cxx" #include "copyOnWriteObject.cxx" #include "copyOnWritePointer.cxx" diff --git a/panda/src/putil/pythonCallbackObject.cxx b/panda/src/putil/pythonCallbackObject.cxx index fd1c9aa64f..b1917c6e0e 100644 --- a/panda/src/putil/pythonCallbackObject.cxx +++ b/panda/src/putil/pythonCallbackObject.cxx @@ -18,7 +18,7 @@ #include "py_panda.h" #include "pythonThread.h" #include "callbackData.h" -#include "config_util.h" +#include "config_putil.h" TypeHandle PythonCallbackObject::_type_handle; diff --git a/panda/src/putil/simpleHashMap.h b/panda/src/putil/simpleHashMap.h index 50a7e3af12..68f6352a88 100644 --- a/panda/src/putil/simpleHashMap.h +++ b/panda/src/putil/simpleHashMap.h @@ -16,7 +16,7 @@ #include "pandabase.h" #include "pvector.h" -#include "config_util.h" +#include "config_putil.h" /** * Entry in the SimpleHashMap. diff --git a/panda/src/putil/test_filename.cxx b/panda/src/putil/test_filename.cxx index a4cbfa76e6..b6703d7387 100644 --- a/panda/src/putil/test_filename.cxx +++ b/panda/src/putil/test_filename.cxx @@ -12,7 +12,7 @@ */ #include "filename.h" -#include "config_util.h" +#include "config_putil.h" #include "dSearchPath.h" diff --git a/panda/src/putil/weakKeyHashMap.h b/panda/src/putil/weakKeyHashMap.h index bbb7077998..3769660fbc 100644 --- a/panda/src/putil/weakKeyHashMap.h +++ b/panda/src/putil/weakKeyHashMap.h @@ -16,7 +16,7 @@ #include "pandabase.h" #include "pvector.h" -#include "config_util.h" +#include "config_putil.h" #include "weakPointerTo.h" /** diff --git a/panda/src/speedtree/speedTreeNode.cxx b/panda/src/speedtree/speedTreeNode.cxx index 61150a5a01..c455e848f5 100644 --- a/panda/src/speedtree/speedTreeNode.cxx +++ b/panda/src/speedtree/speedTreeNode.cxx @@ -15,7 +15,7 @@ #include "speedTreeNode.h" #include "stBasicTerrain.h" #include "virtualFileSystem.h" -#include "config_util.h" +#include "config_putil.h" #include "cullTraverser.h" #include "cullableObject.h" #include "cullHandler.h" diff --git a/panda/src/text/dynamicTextFont.cxx b/panda/src/text/dynamicTextFont.cxx index 3a349a6d69..f02328009e 100644 --- a/panda/src/text/dynamicTextFont.cxx +++ b/panda/src/text/dynamicTextFont.cxx @@ -28,7 +28,7 @@ #endif #include "config_text.h" -#include "config_util.h" +#include "config_putil.h" #include "config_express.h" #include "virtualFileSystem.h" #include "geomVertexData.h" diff --git a/panda/src/text/fontPool.cxx b/panda/src/text/fontPool.cxx index 1fab675bff..ac7d476c63 100644 --- a/panda/src/text/fontPool.cxx +++ b/panda/src/text/fontPool.cxx @@ -14,7 +14,7 @@ #include "fontPool.h" #include "staticTextFont.h" #include "dynamicTextFont.h" -#include "config_util.h" +#include "config_putil.h" #include "config_express.h" #include "virtualFileSystem.h" #include "nodePath.h" diff --git a/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm b/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm index da3630a572..01892094b0 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm +++ b/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm @@ -26,7 +26,7 @@ #include "throw_event.h" #include "pnmImage.h" #include "virtualFileSystem.h" -#include "config_util.h" +#include "config_putil.h" #include diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index 054581e1fd..f8fa283020 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -19,7 +19,7 @@ #include "keyboardButton.h" #include "mouseButton.h" #include "clockObject.h" -#include "config_util.h" +#include "config_putil.h" #include "throw_event.h" #include "nativeWindowHandle.h" diff --git a/pandatool/src/bam/eggToBam.cxx b/pandatool/src/bam/eggToBam.cxx index 238eba17cf..f6c9bf4b52 100644 --- a/pandatool/src/bam/eggToBam.cxx +++ b/pandatool/src/bam/eggToBam.cxx @@ -13,7 +13,7 @@ #include "eggToBam.h" -#include "config_util.h" +#include "config_putil.h" #include "bamFile.h" #include "load_egg_file.h" #include "config_egg2pg.h" diff --git a/pandatool/src/bam/ptsToBam.cxx b/pandatool/src/bam/ptsToBam.cxx index 5f570d309b..4db96663ca 100644 --- a/pandatool/src/bam/ptsToBam.cxx +++ b/pandatool/src/bam/ptsToBam.cxx @@ -13,7 +13,7 @@ #include "ptsToBam.h" -#include "config_util.h" +#include "config_putil.h" #include "geomPoints.h" #include "bamFile.h" #include "pandaNode.h" diff --git a/pandatool/src/converter/somethingToEggConverter.h b/pandatool/src/converter/somethingToEggConverter.h index 0388ca8fb4..b3e71b6ab5 100644 --- a/pandatool/src/converter/somethingToEggConverter.h +++ b/pandatool/src/converter/somethingToEggConverter.h @@ -17,7 +17,7 @@ #include "pandatoolbase.h" #include "filename.h" -#include "config_util.h" // for get_model_path() +#include "config_putil.h" // for get_model_path() #include "animationConvert.h" #include "pathReplace.h" #include "pointerTo.h" diff --git a/pandatool/src/egg-palettize/txaFileFilter.cxx b/pandatool/src/egg-palettize/txaFileFilter.cxx index a8f6c21507..5c673c51a1 100644 --- a/pandatool/src/egg-palettize/txaFileFilter.cxx +++ b/pandatool/src/egg-palettize/txaFileFilter.cxx @@ -20,7 +20,7 @@ #include "dconfig.h" #include "configVariableFilename.h" #include "virtualFileSystem.h" -#include "config_util.h" +#include "config_putil.h" NotifyCategoryDeclNoExport(txafile); NotifyCategoryDef(txafile, ""); diff --git a/pandatool/src/eggbase/eggReader.cxx b/pandatool/src/eggbase/eggReader.cxx index dce7b64c51..e570b8aa9d 100644 --- a/pandatool/src/eggbase/eggReader.cxx +++ b/pandatool/src/eggbase/eggReader.cxx @@ -14,7 +14,7 @@ #include "eggReader.h" #include "pnmImage.h" -#include "config_util.h" +#include "config_putil.h" #include "eggTextureCollection.h" #include "eggGroup.h" #include "eggGroupNode.h" diff --git a/pandatool/src/eggbase/somethingToEgg.cxx b/pandatool/src/eggbase/somethingToEgg.cxx index 497761ea06..4f33599761 100644 --- a/pandatool/src/eggbase/somethingToEgg.cxx +++ b/pandatool/src/eggbase/somethingToEgg.cxx @@ -14,7 +14,7 @@ #include "somethingToEgg.h" #include "somethingToEggConverter.h" -#include "config_util.h" +#include "config_putil.h" /** * The first parameter to the constructor should be the one-word name of the diff --git a/pandatool/src/flt/fltTexture.cxx b/pandatool/src/flt/fltTexture.cxx index dfc2b9d987..c3c61cf130 100644 --- a/pandatool/src/flt/fltTexture.cxx +++ b/pandatool/src/flt/fltTexture.cxx @@ -16,7 +16,7 @@ #include "fltRecordWriter.h" #include "fltHeader.h" #include "pathReplace.h" -#include "config_util.h" +#include "config_putil.h" TypeHandle FltTexture::_type_handle; diff --git a/pandatool/src/maxegg/maxToEggConverter.cxx b/pandatool/src/maxegg/maxToEggConverter.cxx index b07c1fd77d..6e79178fc5 100644 --- a/pandatool/src/maxegg/maxToEggConverter.cxx +++ b/pandatool/src/maxegg/maxToEggConverter.cxx @@ -25,7 +25,7 @@ */ #include "maxEgg.h" -#include "config_util.h" +#include "config_putil.h" /** * diff --git a/pandatool/src/mayaprogs/mayaPview.cxx b/pandatool/src/mayaprogs/mayaPview.cxx index 60af297044..286d94ad67 100644 --- a/pandatool/src/mayaprogs/mayaPview.cxx +++ b/pandatool/src/mayaprogs/mayaPview.cxx @@ -19,7 +19,7 @@ #include "mayaToEggConverter.h" #include "eggData.h" #include "load_egg_file.h" -#include "config_util.h" +#include "config_putil.h" #include "config_chan.h" #include "config_gobj.h" #include "textNode.h" diff --git a/pandatool/src/pandatoolbase/pathReplace.cxx b/pandatool/src/pandatoolbase/pathReplace.cxx index 786bb6ae03..c3891cf047 100644 --- a/pandatool/src/pandatoolbase/pathReplace.cxx +++ b/pandatool/src/pandatoolbase/pathReplace.cxx @@ -12,7 +12,7 @@ */ #include "pathReplace.h" -#include "config_util.h" +#include "config_putil.h" #include "config_pandatoolbase.h" #include "indent.h" #include "virtualFileSystem.h" diff --git a/pandatool/src/ptloader/loaderFileTypePandatool.cxx b/pandatool/src/ptloader/loaderFileTypePandatool.cxx index 48625154f2..0de02c19de 100644 --- a/pandatool/src/ptloader/loaderFileTypePandatool.cxx +++ b/pandatool/src/ptloader/loaderFileTypePandatool.cxx @@ -15,7 +15,7 @@ #include "config_ptloader.h" #include "somethingToEggConverter.h" #include "eggToSomethingConverter.h" -#include "config_util.h" +#include "config_putil.h" #include "load_egg_file.h" #include "save_egg_file.h" #include "eggData.h" From c81229c1a88a35507dade535e5abdfc2318ae63b Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Wed, 9 May 2018 15:57:34 -0600 Subject: [PATCH 172/247] pfmprogs: Rename config_pfm to config_pfmprogs --- makepanda/makepanda.py | 4 ++-- .../src/pfmprogs/{config_pfm.cxx => config_pfmprogs.cxx} | 8 ++++---- .../src/pfmprogs/{config_pfm.h => config_pfmprogs.h} | 2 +- pandatool/src/pfmprogs/pfmBba.cxx | 2 +- pandatool/src/pfmprogs/pfmTrans.cxx | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) rename pandatool/src/pfmprogs/{config_pfm.cxx => config_pfmprogs.cxx} (89%) rename pandatool/src/pfmprogs/{config_pfm.h => config_pfmprogs.h} (95%) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 5ae064b649..0e196654a2 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -6110,9 +6110,9 @@ if not PkgSkip("PANDATOOL"): TargetAdd('pfm-trans.exe', opts=['ADVAPI']) TargetAdd('pfm-bba_pfmBba.obj', opts=OPTS, input='pfmBba.cxx') - TargetAdd('pfm-bba_config_pfm.obj', opts=OPTS, input='config_pfm.cxx') + TargetAdd('pfm-bba_config_pfmprogs.obj', opts=OPTS, input='config_pfmprogs.cxx') TargetAdd('pfm-bba.exe', input='pfm-bba_pfmBba.obj') - TargetAdd('pfm-bba.exe', input='pfm-bba_config_pfm.obj') + TargetAdd('pfm-bba.exe', input='pfm-bba_config_pfmprogs.obj') TargetAdd('pfm-bba.exe', input='libp3progbase.lib') TargetAdd('pfm-bba.exe', input='libp3pandatoolbase.lib') TargetAdd('pfm-bba.exe', input=COMMON_PANDA_LIBS) diff --git a/pandatool/src/pfmprogs/config_pfm.cxx b/pandatool/src/pfmprogs/config_pfmprogs.cxx similarity index 89% rename from pandatool/src/pfmprogs/config_pfm.cxx rename to pandatool/src/pfmprogs/config_pfmprogs.cxx index fc8cea6bf3..afa49ef91b 100644 --- a/pandatool/src/pfmprogs/config_pfm.cxx +++ b/pandatool/src/pfmprogs/config_pfmprogs.cxx @@ -6,16 +6,16 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * @file config_pfm.cxx + * @file config_pfmprogs.cxx * @author drose * @date 2010-12-23 */ -#include "config_pfm.h" +#include "config_pfmprogs.h" #include "dconfig.h" -Configure(config_pfm); +Configure(config_pfmprogs); NotifyCategoryDef(pfm, ""); ConfigVariableDouble pfm_bba_dist @@ -23,7 +23,7 @@ ConfigVariableDouble pfm_bba_dist PRC_DESC("Specifies the point_dist and sample_radius, in UV space, for " "compute bba files with pfm_trans.")); -ConfigureFn(config_pfm) { +ConfigureFn(config_pfmprogs) { init_libpfm(); } diff --git a/pandatool/src/pfmprogs/config_pfm.h b/pandatool/src/pfmprogs/config_pfmprogs.h similarity index 95% rename from pandatool/src/pfmprogs/config_pfm.h rename to pandatool/src/pfmprogs/config_pfmprogs.h index 5da1fcbb4e..98777496e7 100644 --- a/pandatool/src/pfmprogs/config_pfm.h +++ b/pandatool/src/pfmprogs/config_pfmprogs.h @@ -6,7 +6,7 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * @file config_pfm.h + * @file config_pfmprogs.h * @author drose * @date 2010-12-23 */ diff --git a/pandatool/src/pfmprogs/pfmBba.cxx b/pandatool/src/pfmprogs/pfmBba.cxx index 5517e45a63..5456efad27 100644 --- a/pandatool/src/pfmprogs/pfmBba.cxx +++ b/pandatool/src/pfmprogs/pfmBba.cxx @@ -12,7 +12,7 @@ */ #include "pfmBba.h" -#include "config_pfm.h" +#include "config_pfmprogs.h" #include "pfmFile.h" /** diff --git a/pandatool/src/pfmprogs/pfmTrans.cxx b/pandatool/src/pfmprogs/pfmTrans.cxx index 270d6a03af..123b098768 100644 --- a/pandatool/src/pfmprogs/pfmTrans.cxx +++ b/pandatool/src/pfmprogs/pfmTrans.cxx @@ -12,7 +12,7 @@ */ #include "pfmTrans.h" -#include "config_pfm.h" +#include "config_pfmprogs.h" #include "pfmFile.h" #include "pfmVizzer.h" #include "texture.h" From 47f7d3f29733bdcbc39ece033006f7f9f2d3857b Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 11 May 2018 19:13:22 -0600 Subject: [PATCH 173/247] general: Add headers explaining the renamed config_*.h --- makepanda/makepanda.py | 2 ++ panda/src/pstatclient/config_pstats.h | 2 ++ panda/src/putil/config_util.h | 2 ++ 3 files changed, 6 insertions(+) create mode 100644 panda/src/pstatclient/config_pstats.h create mode 100644 panda/src/putil/config_util.h diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 0e196654a2..56ffecdbd5 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -3668,6 +3668,7 @@ if (not RUNTIME): OPTS=['DIR:panda/src/putil', 'ZLIB', 'PYTHON'] IGATEFILES=GetDirectoryContents('panda/src/putil', ["*.h", "*_composite*.cxx"]) IGATEFILES.remove("test_bam.h") + IGATEFILES.remove("config_util.h") TargetAdd('libp3putil.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3putil.in', opts=['IMOD:panda3d.core', 'ILIB:libp3putil', 'SRCDIR:panda/src/putil']) TargetAdd('libp3putil_igate.obj', input='libp3putil.in', opts=["DEPENDENCYONLY"]) @@ -3794,6 +3795,7 @@ if (not RUNTIME): OPTS=['DIR:panda/src/pstatclient', 'PYTHON'] IGATEFILES=GetDirectoryContents('panda/src/pstatclient', ["*.h", "*_composite*.cxx"]) + IGATEFILES.remove("config_pstats.h") TargetAdd('libp3pstatclient.in', opts=OPTS, input=IGATEFILES) TargetAdd('libp3pstatclient.in', opts=['IMOD:panda3d.core', 'ILIB:libp3pstatclient', 'SRCDIR:panda/src/pstatclient']) TargetAdd('libp3pstatclient_igate.obj', input='libp3pstatclient.in', opts=["DEPENDENCYONLY"]) diff --git a/panda/src/pstatclient/config_pstats.h b/panda/src/pstatclient/config_pstats.h new file mode 100644 index 0000000000..84f42df553 --- /dev/null +++ b/panda/src/pstatclient/config_pstats.h @@ -0,0 +1,2 @@ +// This file to remain during the whole 1.10.x cycle; remove after that. +#error config_pstats.h has been renamed to config_pstatclient.h - please update your project. diff --git a/panda/src/putil/config_util.h b/panda/src/putil/config_util.h new file mode 100644 index 0000000000..6886f3257d --- /dev/null +++ b/panda/src/putil/config_util.h @@ -0,0 +1,2 @@ +// This file to remain during the whole 1.10.x cycle; remove after that. +#error config_util.h has been renamed to config_putil.h - please update your project. From 0bb81a43c9e4fffb37cc2234c1b0fbae42020ceb Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 15 May 2018 13:34:42 +0200 Subject: [PATCH 174/247] express: make a thread safe weak pointer implementation (#321) To access a WeakPointerTo in a thread-safe way, use something like this: if (auto ptr = weak_ptr.lock()) { ..use ptr as regular PointerTo } The new implementation no longer needs a reference to be stored to all weak pointers on the WeakReferenceList; a mere count of weak pointers is sufficient. Therefore, callbacks theoretically no longer require a WeakPointerTo to be constructed. The WeakPointerTo class is not actually atomic; it could be made so, but I don't believe it's worth it at this time. --- dtool/src/dtoolbase/atomicAdjustDummyImpl.I | 7 +- dtool/src/dtoolbase/atomicAdjustDummyImpl.h | 2 +- dtool/src/dtoolbase/atomicAdjustGccImpl.I | 5 +- dtool/src/dtoolbase/atomicAdjustGccImpl.h | 2 +- dtool/src/dtoolbase/atomicAdjustI386Impl.I | 8 +- dtool/src/dtoolbase/atomicAdjustI386Impl.h | 2 +- dtool/src/dtoolbase/atomicAdjustPosixImpl.I | 7 +- dtool/src/dtoolbase/atomicAdjustPosixImpl.h | 2 +- dtool/src/dtoolbase/atomicAdjustWin32Impl.I | 12 +- dtool/src/dtoolbase/atomicAdjustWin32Impl.h | 2 +- panda/src/chan/partBundle.cxx | 2 +- panda/src/char/characterJointEffect.I | 8 +- panda/src/char/characterJointEffect.cxx | 20 +-- panda/src/char/characterJointEffect.h | 2 +- panda/src/express/referenceCount.I | 32 ++-- panda/src/express/referenceCount.h | 4 +- panda/src/express/weakPointerTo.I | 40 +++++ panda/src/express/weakPointerTo.h | 2 + panda/src/express/weakPointerToBase.I | 162 ++++++++++++++---- panda/src/express/weakPointerToBase.h | 4 + panda/src/express/weakPointerToVoid.I | 46 ++--- panda/src/express/weakPointerToVoid.h | 9 +- panda/src/express/weakReferenceList.I | 27 +++ panda/src/express/weakReferenceList.cxx | 71 +++++--- panda/src/express/weakReferenceList.h | 40 +++-- panda/src/glstuff/glCgShaderContext_src.cxx | 21 +-- panda/src/glstuff/glGeomMunger_src.cxx | 29 ++-- panda/src/glstuff/glShaderContext_src.cxx | 23 +-- panda/src/glstuff/glTimerQueryContext_src.cxx | 6 +- panda/src/pgraph/stateMunger.cxx | 4 +- panda/src/pgraph/weakNodePath.I | 26 +-- panda/src/pgraph/weakNodePath.h | 4 +- panda/src/pstatclient/pStatClient.I | 7 +- panda/src/pstatclient/pStatClient.h | 2 +- panda/src/putil/weakKeyHashMap.I | 2 +- 35 files changed, 434 insertions(+), 208 deletions(-) diff --git a/dtool/src/dtoolbase/atomicAdjustDummyImpl.I b/dtool/src/dtoolbase/atomicAdjustDummyImpl.I index a08d6ce130..54d6e6b860 100644 --- a/dtool/src/dtoolbase/atomicAdjustDummyImpl.I +++ b/dtool/src/dtoolbase/atomicAdjustDummyImpl.I @@ -30,10 +30,13 @@ dec(TVOLATILE AtomicAdjustDummyImpl::Integer &var) { /** * Atomically computes var += delta. It is legal for delta to be negative. + * Returns the result of the addition. */ -ALWAYS_INLINE void AtomicAdjustDummyImpl:: +ALWAYS_INLINE AtomicAdjustDummyImpl::Integer AtomicAdjustDummyImpl:: add(TVOLATILE AtomicAdjustDummyImpl::Integer &var, AtomicAdjustDummyImpl::Integer delta) { - var += delta; + Integer new_value = var + delta; + var = new_value; + return new_value; } /** diff --git a/dtool/src/dtoolbase/atomicAdjustDummyImpl.h b/dtool/src/dtoolbase/atomicAdjustDummyImpl.h index 120fbe195a..3257ae8dfd 100644 --- a/dtool/src/dtoolbase/atomicAdjustDummyImpl.h +++ b/dtool/src/dtoolbase/atomicAdjustDummyImpl.h @@ -31,7 +31,7 @@ public: ALWAYS_INLINE static void inc(TVOLATILE Integer &var); ALWAYS_INLINE static bool dec(TVOLATILE Integer &var); - ALWAYS_INLINE static void add(TVOLATILE Integer &var, Integer delta); + ALWAYS_INLINE static Integer add(TVOLATILE Integer &var, Integer delta); ALWAYS_INLINE static Integer set(TVOLATILE Integer &var, Integer new_value); ALWAYS_INLINE static Integer get(const TVOLATILE Integer &var); diff --git a/dtool/src/dtoolbase/atomicAdjustGccImpl.I b/dtool/src/dtoolbase/atomicAdjustGccImpl.I index 5becaaa4c0..682b14bed3 100644 --- a/dtool/src/dtoolbase/atomicAdjustGccImpl.I +++ b/dtool/src/dtoolbase/atomicAdjustGccImpl.I @@ -30,11 +30,12 @@ dec(TVOLATILE AtomicAdjustGccImpl::Integer &var) { /** * Atomically computes var += delta. It is legal for delta to be negative. + * Returns the result of the addition. */ -INLINE void AtomicAdjustGccImpl:: +INLINE AtomicAdjustGccImpl::Integer AtomicAdjustGccImpl:: add(TVOLATILE AtomicAdjustGccImpl::Integer &var, AtomicAdjustGccImpl::Integer delta) { - __atomic_fetch_add(&var, delta, __ATOMIC_SEQ_CST); + return __atomic_add_fetch(&var, delta, __ATOMIC_SEQ_CST); } /** diff --git a/dtool/src/dtoolbase/atomicAdjustGccImpl.h b/dtool/src/dtoolbase/atomicAdjustGccImpl.h index 7ae44037ff..57389c1349 100644 --- a/dtool/src/dtoolbase/atomicAdjustGccImpl.h +++ b/dtool/src/dtoolbase/atomicAdjustGccImpl.h @@ -35,7 +35,7 @@ public: INLINE static void inc(TVOLATILE Integer &var); INLINE static bool dec(TVOLATILE Integer &var); - INLINE static void add(TVOLATILE Integer &var, Integer delta); + INLINE static Integer add(TVOLATILE Integer &var, Integer delta); INLINE static Integer set(TVOLATILE Integer &var, Integer new_value); INLINE static Integer get(const TVOLATILE Integer &var); diff --git a/dtool/src/dtoolbase/atomicAdjustI386Impl.I b/dtool/src/dtoolbase/atomicAdjustI386Impl.I index 3841479b28..98208c8655 100644 --- a/dtool/src/dtoolbase/atomicAdjustI386Impl.I +++ b/dtool/src/dtoolbase/atomicAdjustI386Impl.I @@ -59,14 +59,18 @@ dec(TVOLATILE AtomicAdjustI386Impl::Integer &var) { /** * Atomically computes var += delta. It is legal for delta to be negative. + * Returns the result of the addition. */ -INLINE void AtomicAdjustI386Impl:: +INLINE AtomicAdjustI386Impl::Integer AtomicAdjustI386Impl:: add(TVOLATILE AtomicAdjustI386Impl::Integer &var, AtomicAdjustI386Impl::Integer delta) { assert((((size_t)&var) & (sizeof(Integer) - 1)) == 0); Integer orig_value = var; - while (compare_and_exchange(var, orig_value, orig_value + delta) != orig_value) { + Integer new_value = orig_value + delta; + while (compare_and_exchange(var, orig_value, new_value) != orig_value) { orig_value = var; + new_value = orig_value + delta; } + return new_value; } /** diff --git a/dtool/src/dtoolbase/atomicAdjustI386Impl.h b/dtool/src/dtoolbase/atomicAdjustI386Impl.h index eac5ce6a97..bcd1a62c61 100644 --- a/dtool/src/dtoolbase/atomicAdjustI386Impl.h +++ b/dtool/src/dtoolbase/atomicAdjustI386Impl.h @@ -34,7 +34,7 @@ public: INLINE static void inc(TVOLATILE Integer &var); INLINE static bool dec(TVOLATILE Integer &var); - INLINE static void add(TVOLATILE Integer &var, Integer delta); + INLINE static Integer add(TVOLATILE Integer &var, Integer delta); INLINE static Integer set(TVOLATILE Integer &var, Integer new_value); INLINE static Integer get(const TVOLATILE Integer &var); diff --git a/dtool/src/dtoolbase/atomicAdjustPosixImpl.I b/dtool/src/dtoolbase/atomicAdjustPosixImpl.I index ef3d43f053..09636c39c7 100644 --- a/dtool/src/dtoolbase/atomicAdjustPosixImpl.I +++ b/dtool/src/dtoolbase/atomicAdjustPosixImpl.I @@ -35,13 +35,16 @@ dec(TVOLATILE AtomicAdjustPosixImpl::Integer &var) { /** * Atomically computes var += delta. It is legal for delta to be negative. + * Returns the result of the addition. */ -INLINE void AtomicAdjustPosixImpl:: +INLINE AtomicAdjustPosixImpl::Integer AtomicAdjustPosixImpl:: add(TVOLATILE AtomicAdjustPosixImpl::Integer &var, AtomicAdjustPosixImpl::Integer delta) { pthread_mutex_lock(&_mutex); - var += delta; + Integer new_value = var + delta; + var = new_value; pthread_mutex_unlock(&_mutex); + return new_value; } /** diff --git a/dtool/src/dtoolbase/atomicAdjustPosixImpl.h b/dtool/src/dtoolbase/atomicAdjustPosixImpl.h index 3b98499129..8c2b2b5887 100644 --- a/dtool/src/dtoolbase/atomicAdjustPosixImpl.h +++ b/dtool/src/dtoolbase/atomicAdjustPosixImpl.h @@ -35,7 +35,7 @@ public: INLINE static void inc(TVOLATILE Integer &var); INLINE static bool dec(TVOLATILE Integer &var); - INLINE static void add(TVOLATILE Integer &var, Integer delta); + INLINE static Integer add(TVOLATILE Integer &var, Integer delta); INLINE static Integer set(TVOLATILE Integer &var, Integer new_value); INLINE static Integer get(const TVOLATILE Integer &var); diff --git a/dtool/src/dtoolbase/atomicAdjustWin32Impl.I b/dtool/src/dtoolbase/atomicAdjustWin32Impl.I index a0e213c638..851c9f05e2 100644 --- a/dtool/src/dtoolbase/atomicAdjustWin32Impl.I +++ b/dtool/src/dtoolbase/atomicAdjustWin32Impl.I @@ -40,17 +40,21 @@ dec(TVOLATILE AtomicAdjustWin32Impl::Integer &var) { /** * Atomically computes var += delta. It is legal for delta to be negative. + * Returns the result of the addition. */ -INLINE void AtomicAdjustWin32Impl:: +INLINE AtomicAdjustWin32Impl::Integer AtomicAdjustWin32Impl:: add(TVOLATILE AtomicAdjustWin32Impl::Integer &var, AtomicAdjustWin32Impl::Integer delta) { assert((((size_t)&var) & (sizeof(Integer) - 1)) == 0); #ifdef _WIN64 - InterlockedAdd64(&var, delta); + return InterlockedAdd64(&var, delta); #else - AtomicAdjustWin32Impl::Integer orig_value = var; - while (compare_and_exchange(var, orig_value, orig_value + delta) != orig_value) { + Integer orig_value = var; + Integer new_value = orig_value + delta; + while (compare_and_exchange(var, orig_value, new_value) != orig_value) { orig_value = var; + new_value = orig_value + delta; } + return new_value; #endif // _WIN64 } diff --git a/dtool/src/dtoolbase/atomicAdjustWin32Impl.h b/dtool/src/dtoolbase/atomicAdjustWin32Impl.h index 6f64d2a781..25f2e78066 100644 --- a/dtool/src/dtoolbase/atomicAdjustWin32Impl.h +++ b/dtool/src/dtoolbase/atomicAdjustWin32Impl.h @@ -44,7 +44,7 @@ public: ALWAYS_INLINE static void inc(TVOLATILE Integer &var); ALWAYS_INLINE static bool dec(TVOLATILE Integer &var); - INLINE static void add(TVOLATILE Integer &var, Integer delta); + INLINE static Integer add(TVOLATILE Integer &var, Integer delta); ALWAYS_INLINE static Integer set(TVOLATILE Integer &var, Integer new_value); ALWAYS_INLINE static Integer get(const TVOLATILE Integer &var); diff --git a/panda/src/chan/partBundle.cxx b/panda/src/chan/partBundle.cxx index f519d09a60..3806f812a5 100644 --- a/panda/src/chan/partBundle.cxx +++ b/panda/src/chan/partBundle.cxx @@ -153,7 +153,7 @@ apply_transform(const TransformState *transform) { if ((*ati).first.is_valid_pointer() && (*ati).second.is_valid_pointer()) { // Here's our cached result. - return (*ati).second.p(); + return (*ati).second.lock(); } } diff --git a/panda/src/char/characterJointEffect.I b/panda/src/char/characterJointEffect.I index fb911569b3..c63c90d1a7 100644 --- a/panda/src/char/characterJointEffect.I +++ b/panda/src/char/characterJointEffect.I @@ -23,11 +23,7 @@ CharacterJointEffect() { * Returns the Character that will get update() called on it when this node's * relative transform is queried, or NULL if there is no such character. */ -INLINE Character *CharacterJointEffect:: +INLINE PT(Character) CharacterJointEffect:: get_character() const { - if (_character.is_valid_pointer()) { - return _character; - } else { - return NULL; - } + return _character.lock(); } diff --git a/panda/src/char/characterJointEffect.cxx b/panda/src/char/characterJointEffect.cxx index 33441e35c2..50b1a878e8 100644 --- a/panda/src/char/characterJointEffect.cxx +++ b/panda/src/char/characterJointEffect.cxx @@ -89,8 +89,9 @@ safe_to_combine() const { void CharacterJointEffect:: output(ostream &out) const { out << get_type(); - if (_character.is_valid_pointer()) { - out << "(" << _character->get_name() << ")"; + PT(Character) character = get_character(); + if (character != nullptr) { + out << "(" << character->get_name() << ")"; } else { out << "(**invalid**)"; } @@ -122,8 +123,8 @@ void CharacterJointEffect:: cull_callback(CullTraverser *trav, CullTraverserData &data, CPT(TransformState) &node_transform, CPT(RenderState) &) const { - if (_character.is_valid_pointer()) { - _character->update(); + if (auto character = _character.lock()) { + character->update(); } node_transform = data.node()->get_transform(); } @@ -150,8 +151,8 @@ void CharacterJointEffect:: adjust_transform(CPT(TransformState) &net_transform, CPT(TransformState) &node_transform, const PandaNode *node) const { - if (_character.is_valid_pointer()) { - _character->update(); + if (auto character = _character.lock()) { + character->update(); } node_transform = node->get_transform(); } @@ -202,11 +203,8 @@ void CharacterJointEffect:: write_datagram(BamWriter *manager, Datagram &dg) { RenderEffect::write_datagram(manager, dg); - if (_character.is_valid_pointer()) { - manager->write_pointer(dg, _character); - } else { - manager->write_pointer(dg, NULL); - } + PT(Character) character = get_character(); + manager->write_pointer(dg, character); } /** diff --git a/panda/src/char/characterJointEffect.h b/panda/src/char/characterJointEffect.h index 0df4cea6fd..d06ca802fb 100644 --- a/panda/src/char/characterJointEffect.h +++ b/panda/src/char/characterJointEffect.h @@ -38,7 +38,7 @@ private: PUBLISHED: static CPT(RenderEffect) make(Character *character); - INLINE Character *get_character() const; + INLINE PT(Character) get_character() const; public: virtual bool safe_to_transform() const; diff --git a/panda/src/express/referenceCount.I b/panda/src/express/referenceCount.I index c1d54da5da..3a05a68766 100644 --- a/panda/src/express/referenceCount.I +++ b/panda/src/express/referenceCount.I @@ -112,9 +112,9 @@ ReferenceCount:: nassertv(_ref_count == 0 || _ref_count == local_ref_count); // Tell our weak reference holders that we're going away now. - if (_weak_list != (WeakReferenceList *)NULL) { - delete (WeakReferenceList *)_weak_list; - _weak_list = (WeakReferenceList *)NULL; + if (_weak_list != nullptr) { + ((WeakReferenceList *)_weak_list)->mark_deleted(); + _weak_list = nullptr; } #ifndef NDEBUG @@ -253,6 +253,9 @@ has_weak_list() const { * Returns the WeakReferenceList associated with this ReferenceCount object. * If there has never been a WeakReferenceList associated with this object, * creates one now. + * + * The returned object will be deleted automatically when all weak and strong + * references to the object have gone. */ INLINE WeakReferenceList *ReferenceCount:: get_weak_list() const { @@ -264,14 +267,21 @@ get_weak_list() const { /** * Adds the indicated PointerToVoid as a weak reference to this object. + * Returns an object that will persist as long as any reference (strong or + * weak) exists, for calling unref() or checking whether the object still + * exists. */ -INLINE void ReferenceCount:: -weak_ref(WeakPointerToVoid *ptv) { +INLINE WeakReferenceList *ReferenceCount:: +weak_ref() { TAU_PROFILE("void ReferenceCount::weak_ref()", " ", TAU_USER); #ifdef _DEBUG - nassertv(test_ref_count_integrity()); + nassertr(test_ref_count_integrity(), nullptr); +#else + nassertr(_ref_count != deleted_ref_count, nullptr); #endif - get_weak_list()->add_reference(ptv); + WeakReferenceList *weak_ref = get_weak_list(); + weak_ref->ref(); + return weak_ref; } /** @@ -279,13 +289,15 @@ weak_ref(WeakPointerToVoid *ptv) { * must have previously been added via a call to weak_ref(). */ INLINE void ReferenceCount:: -weak_unref(WeakPointerToVoid *ptv) { +weak_unref() { TAU_PROFILE("void ReferenceCount::weak_unref()", " ", TAU_USER); #ifdef _DEBUG nassertv(test_ref_count_integrity()); #endif - nassertv(has_weak_list()); - ((WeakReferenceList *)_weak_list)->clear_reference(ptv); + WeakReferenceList *weak_list = (WeakReferenceList *)_weak_list; + nassertv(weak_list != nullptr); + bool nonzero = weak_list->unref(); + nassertv(nonzero); } /** diff --git a/panda/src/express/referenceCount.h b/panda/src/express/referenceCount.h index 72425dcd8d..2260cf2e8c 100644 --- a/panda/src/express/referenceCount.h +++ b/panda/src/express/referenceCount.h @@ -60,8 +60,8 @@ public: INLINE bool has_weak_list() const; INLINE WeakReferenceList *get_weak_list() const; - INLINE void weak_ref(WeakPointerToVoid *ptv); - INLINE void weak_unref(WeakPointerToVoid *ptv); + INLINE WeakReferenceList *weak_ref(); + INLINE void weak_unref(); protected: bool do_test_ref_count_integrity() const; diff --git a/panda/src/express/weakPointerTo.I b/panda/src/express/weakPointerTo.I index aec710288f..9061affcad 100644 --- a/panda/src/express/weakPointerTo.I +++ b/panda/src/express/weakPointerTo.I @@ -72,6 +72,26 @@ operator T * () const { return (To *)WeakPointerToBase::_void_ptr; } +/** + * A thread-safe way to access the underlying pointer; will silently return + * null if the underlying pointer was deleted or null. + */ +template +INLINE PointerTo WeakPointerTo:: +lock() const { + WeakReferenceList *weak_ref = this->_weak_ref; + if (weak_ref != nullptr) { + PointerTo ptr; + weak_ref->_lock.acquire(); + if (!weak_ref->was_deleted()) { + ptr = (To *)WeakPointerToBase::_void_ptr; + } + weak_ref->_lock.release(); + return ptr; + } + return nullptr; +} + /** * Returns an ordinary pointer instead of a WeakPointerTo. Useful to work * around compiler problems, particularly for implicit upcasts. @@ -207,6 +227,26 @@ operator const T * () const { return (To *)WeakPointerToBase::_void_ptr; } +/** + * A thread-safe way to access the underlying pointer; will silently return + * null if the underlying pointer was deleted or null. + */ +template +INLINE ConstPointerTo WeakConstPointerTo:: +lock() const { + WeakReferenceList *weak_ref = this->_weak_ref; + if (weak_ref != nullptr) { + ConstPointerTo ptr; + weak_ref->_lock.acquire(); + if (!weak_ref->was_deleted()) { + ptr = (const To *)WeakPointerToBase::_void_ptr; + } + weak_ref->_lock.release(); + return ptr; + } + return nullptr; +} + /** * Returns an ordinary pointer instead of a WeakConstPointerTo. Useful to * work around compiler problems, particularly for implicit upcasts. diff --git a/panda/src/express/weakPointerTo.h b/panda/src/express/weakPointerTo.h index 44d9561eb3..897c46a210 100644 --- a/panda/src/express/weakPointerTo.h +++ b/panda/src/express/weakPointerTo.h @@ -41,6 +41,7 @@ public: INLINE operator T *() const; PUBLISHED: + INLINE PointerTo lock() const; INLINE To *p() const; INLINE To *get_orig() const; @@ -77,6 +78,7 @@ public: INLINE operator const T *() const; PUBLISHED: + INLINE ConstPointerTo lock() const; INLINE const To *p() const; INLINE const To *get_orig() const; diff --git a/panda/src/express/weakPointerToBase.I b/panda/src/express/weakPointerToBase.I index cb60c43fc2..252e5e9aa7 100644 --- a/panda/src/express/weakPointerToBase.I +++ b/panda/src/express/weakPointerToBase.I @@ -17,7 +17,13 @@ template INLINE WeakPointerToBase:: WeakPointerToBase(To *ptr) { - reassign(ptr); + _void_ptr = (To *)ptr; + if (ptr != nullptr) { + _weak_ref = ptr->weak_ref(); +#ifdef DO_MEMORY_USAGE + update_type(ptr); +#endif + } } /** @@ -26,7 +32,13 @@ WeakPointerToBase(To *ptr) { template INLINE WeakPointerToBase:: WeakPointerToBase(const PointerToBase ©) { - reassign(copy); + // This double-casting is a bit of a cheat to get around the inheritance + // issue--it's difficult to declare a template class to be a friend. + To *ptr = (To *)((const WeakPointerToBase *)©)->_void_ptr; + _void_ptr = ptr; + if (ptr != nullptr) { + _weak_ref = ptr->weak_ref(); + } } /** @@ -36,11 +48,35 @@ template INLINE WeakPointerToBase:: WeakPointerToBase(const WeakPointerToBase ©) { _void_ptr = copy._void_ptr; - _ptr_was_deleted = copy._ptr_was_deleted; - if (is_valid_pointer()) { - To *ptr = (To *)_void_ptr; - ptr->weak_ref(this); + // Don't bother increasing the weak reference count if the object was + // already deleted. + WeakReferenceList *weak_ref = copy._weak_ref; + if (weak_ref != nullptr && !weak_ref->was_deleted()) { + _weak_ref = copy._weak_ref; + _weak_ref->ref(); + } +} + +/** + * + */ +template +INLINE WeakPointerToBase:: +WeakPointerToBase(WeakPointerToBase &&from) NOEXCEPT { + // Protect against self-move-assignment. + if (from._void_ptr != this->_void_ptr) { + WeakReferenceList *old_ref = (To *)this->_weak_ref; + + this->_void_ptr = from._void_ptr; + this->_weak_ref = from._weak_ref; + from._void_ptr = nullptr; + from._weak_ref = nullptr; + + // Now delete the old pointer. + if (old_ref != nullptr && !old_ref->unref()) { + delete old_ref; + } } } @@ -50,7 +86,10 @@ WeakPointerToBase(const WeakPointerToBase ©) { template INLINE WeakPointerToBase:: ~WeakPointerToBase() { - reassign((To *)NULL); + WeakReferenceList *old_ref = (WeakReferenceList *)_weak_ref; + if (old_ref != nullptr && !old_ref->unref()) { + delete old_ref; + } } /** @@ -60,34 +99,23 @@ INLINE WeakPointerToBase:: template void WeakPointerToBase:: reassign(To *ptr) { - if (ptr != (To *)_void_ptr || _ptr_was_deleted) { - To *old_ptr = (To *)_void_ptr; + if (ptr != (To *)_void_ptr) { + WeakReferenceList *old_ref = (WeakReferenceList *)_weak_ref; _void_ptr = (void *)ptr; - if (ptr != (To *)NULL) { - ptr->weak_ref(this); + if (ptr != nullptr) { + _weak_ref = ptr->weak_ref(); #ifdef DO_MEMORY_USAGE - if (MemoryUsage::get_track_memory_usage()) { - // Make sure the MemoryUsage record knows what the TypeHandle is, if - // we know it ourselves. - TypeHandle type = get_type_handle(To); - if (type == TypeHandle::none()) { - do_init_type(To); - type = get_type_handle(To); - } - if (type != TypeHandle::none()) { - MemoryUsage::update_type(ptr, type); - } - } + update_type(ptr); #endif + } else { + _weak_ref = nullptr; } // Now remove the old reference. - if (old_ptr != (To *)NULL && !_ptr_was_deleted) { - old_ptr->weak_unref(this); + if (old_ref != nullptr && !old_ref->unref()) { + delete old_ref; } - - _ptr_was_deleted = false; } } @@ -108,8 +136,69 @@ reassign(const PointerToBase ©) { template INLINE void WeakPointerToBase:: reassign(const WeakPointerToBase ©) { - nassertv(!copy.was_deleted()); - reassign((To *)copy._void_ptr); + void *new_ptr = copy._void_ptr; + if (new_ptr != _void_ptr) { + WeakReferenceList *old_ref = (WeakReferenceList *)_weak_ref; + _void_ptr = new_ptr; + + // Don't bother increasing the weak reference count if the object was + // already deleted. + WeakReferenceList *weak_ref = copy._weak_ref; + if (weak_ref != nullptr && !weak_ref->was_deleted()) { + weak_ref->ref(); + _weak_ref = weak_ref; + } else { + _weak_ref = nullptr; + } + + // Now remove the old reference. + if (old_ref != nullptr && !old_ref->unref()) { + delete old_ref; + } + } +} + +/** + * + */ +template +INLINE void WeakPointerToBase:: +reassign(WeakPointerToBase &&from) NOEXCEPT { + // Protect against self-move-assignment. + if (from._void_ptr != this->_void_ptr) { + WeakReferenceList *old_ref = (WeakReferenceList *)this->_weak_ref; + + this->_void_ptr = from._void_ptr; + this->_weak_ref = from._weak_ref; + from._void_ptr = nullptr; + from._weak_ref = nullptr; + + // Now delete the old pointer. + if (old_ref != nullptr && !old_ref->unref()) { + delete old_ref; + } + } +} + +/** + * Ensures that the MemoryUsage record for the pointer has the right type of + * object, if we know the type ourselves. + */ +template +INLINE void WeakPointerToBase:: +update_type(To *ptr) { +#ifdef DO_MEMORY_USAGE + if (MemoryUsage::get_track_memory_usage()) { + TypeHandle type = get_type_handle(To); + if (type == TypeHandle::none()) { + do_init_type(To); + type = get_type_handle(To); + } + if (type != TypeHandle::none()) { + MemoryUsage::update_type(ptr, type); + } + } +#endif // DO_MEMORY_USAGE } #ifndef CPPPARSER @@ -323,8 +412,6 @@ operator < (const PointerToBase &other) const { #endif // CPPPARSER - - /** * A convenient way to set the PointerTo object to NULL. (Assignment to a NULL * pointer also works, of course.) @@ -332,7 +419,14 @@ operator < (const PointerToBase &other) const { template INLINE void WeakPointerToBase:: clear() { - reassign((To *)NULL); + WeakReferenceList *old_ref = (WeakReferenceList *)_weak_ref; + _void_ptr = nullptr; + _weak_ref = nullptr; + + // Now remove the old reference. + if (old_ref != nullptr && !old_ref->unref()) { + delete old_ref; + } } /** @@ -346,7 +440,9 @@ clear() { template INLINE void WeakPointerToBase:: refresh() const { - ((WeakPointerToBase *)this)->reassign((To *)_void_ptr); + if (_void_ptr != nullptr) { + ((WeakPointerToBase *)this)->reassign((To *)_void_ptr); + } } /** diff --git a/panda/src/express/weakPointerToBase.h b/panda/src/express/weakPointerToBase.h index 04d55b8b1d..6d3ce456b0 100644 --- a/panda/src/express/weakPointerToBase.h +++ b/panda/src/express/weakPointerToBase.h @@ -31,11 +31,15 @@ protected: INLINE WeakPointerToBase(To *ptr); INLINE WeakPointerToBase(const PointerToBase ©); INLINE WeakPointerToBase(const WeakPointerToBase ©); + INLINE WeakPointerToBase(WeakPointerToBase &&from) NOEXCEPT; INLINE ~WeakPointerToBase(); void reassign(To *ptr); INLINE void reassign(const PointerToBase ©); INLINE void reassign(const WeakPointerToBase ©); + INLINE void reassign(WeakPointerToBase &&from) NOEXCEPT; + + INLINE void update_type(To *ptr); // No assignment or retrieval functions are declared in WeakPointerToBase, // because we will have to specialize on const vs. non-const later. diff --git a/panda/src/express/weakPointerToVoid.I b/panda/src/express/weakPointerToVoid.I index bc778630b7..120836510d 100644 --- a/panda/src/express/weakPointerToVoid.I +++ b/panda/src/express/weakPointerToVoid.I @@ -15,46 +15,34 @@ * */ INLINE WeakPointerToVoid:: -WeakPointerToVoid() : - _ptr_was_deleted(false), - _callback(NULL) { +WeakPointerToVoid() : _weak_ref(nullptr) { } /** - * This is intended only to be called by the WeakPointerList destructor. It - * indicates that the object that we were pointing to has just been deleted. - */ -INLINE void WeakPointerToVoid:: -mark_deleted() { - nassertv(!_ptr_was_deleted); - _ptr_was_deleted = true; - if (_callback != (WeakPointerCallback *)NULL) { - _callback->wp_callback(_void_ptr); - } -} - -/** - * Sets a callback that will be made when the pointer is deleted. If a - * previous callback has already been set, it will be replaced. + * Sets a callback that will be made when the pointer is deleted. Does + * nothing if this is a null pointer. * * If the pointer has already been deleted, the callback will be made * immediately. */ INLINE void WeakPointerToVoid:: -set_callback(WeakPointerCallback *callback) { - _callback = callback; - if (_ptr_was_deleted && _callback != (WeakPointerCallback *)NULL) { - _callback->wp_callback(_void_ptr); +add_callback(WeakPointerCallback *callback) const { + if (_weak_ref != nullptr && !_weak_ref->was_deleted()) { + _weak_ref->add_callback(callback, _void_ptr); + } else if (_void_ptr != nullptr) { + callback->wp_callback(_void_ptr); + _weak_ref = nullptr; } } /** - * Returns the callback that will be made when the pointer is deleted, or NULL - * if no callback has been set. + * Removes a previously added callback. */ -INLINE WeakPointerCallback *WeakPointerToVoid:: -get_callback() const { - return _callback; +INLINE void WeakPointerToVoid:: +remove_callback(WeakPointerCallback *callback) const { + if (_weak_ref != nullptr) { + _weak_ref->remove_callback(callback); + } } /** @@ -63,7 +51,7 @@ get_callback() const { */ INLINE bool WeakPointerToVoid:: was_deleted() const { - return _ptr_was_deleted; + return _void_ptr != nullptr && (_weak_ref == nullptr || _weak_ref->was_deleted()); } /** @@ -72,5 +60,5 @@ was_deleted() const { */ INLINE bool WeakPointerToVoid:: is_valid_pointer() const { - return (_void_ptr != (void *)NULL) && !_ptr_was_deleted; + return _weak_ref != nullptr && !_weak_ref->was_deleted(); } diff --git a/panda/src/express/weakPointerToVoid.h b/panda/src/express/weakPointerToVoid.h index 98a481e49e..5ac1049fe3 100644 --- a/panda/src/express/weakPointerToVoid.h +++ b/panda/src/express/weakPointerToVoid.h @@ -27,18 +27,15 @@ protected: INLINE WeakPointerToVoid(); public: - INLINE void mark_deleted(); - - INLINE void set_callback(WeakPointerCallback *callback); - INLINE WeakPointerCallback *get_callback() const; + INLINE void add_callback(WeakPointerCallback *callback) const; + INLINE void remove_callback(WeakPointerCallback *callback) const; PUBLISHED: INLINE bool was_deleted() const; INLINE bool is_valid_pointer() const; protected: - bool _ptr_was_deleted; - WeakPointerCallback *_callback; + mutable WeakReferenceList *_weak_ref; }; #include "weakPointerToVoid.I" diff --git a/panda/src/express/weakReferenceList.I b/panda/src/express/weakReferenceList.I index 661c4c268f..0e4efc8c52 100644 --- a/panda/src/express/weakReferenceList.I +++ b/panda/src/express/weakReferenceList.I @@ -10,3 +10,30 @@ * @author drose * @date 2004-09-27 */ + +/** + * Increases the number of weak references. + */ +INLINE void WeakReferenceList:: +ref() const { + AtomicAdjust::inc(_count); +} + +/** + * Decreases the number of weak references. Returns true if, after this, + * there are still any weak or strong references remaining, or false if this + * structure should be deleted right away. + */ +INLINE bool WeakReferenceList:: +unref() const { + return AtomicAdjust::dec(_count); +} + +/** + * Returns true if the object represented has been deleted, ie. there are only + * weak references left pointing to the object. + */ +INLINE bool WeakReferenceList:: +was_deleted() const { + return AtomicAdjust::get(_count) < _alive_offset; +} diff --git a/panda/src/express/weakReferenceList.cxx b/panda/src/express/weakReferenceList.cxx index cd940b2ecf..af7755a26e 100644 --- a/panda/src/express/weakReferenceList.cxx +++ b/panda/src/express/weakReferenceList.cxx @@ -19,7 +19,7 @@ * */ WeakReferenceList:: -WeakReferenceList() { +WeakReferenceList() : _count(_alive_offset) { } /** @@ -27,30 +27,33 @@ WeakReferenceList() { */ WeakReferenceList:: ~WeakReferenceList() { - _lock.acquire(); - Pointers::iterator pi; - for (pi = _pointers.begin(); pi != _pointers.end(); ++pi) { - (*pi)->mark_deleted(); - } - _lock.release(); + nassertv(_count == 0); } /** - * Intended to be called only by WeakPointerTo (or by any class implementing a - * weak reference-counting pointer), this adds the indicated PointerToVoid - * structure to the list of such structures that are maintaining a weak - * pointer to this object. + * Adds the callback to the list of callbacks that will be called when the + * underlying pointer is deleted. If it has already been deleted, it will + * be called immediately. * - * When the WeakReferenceList destructs (presumably because its owning object - * destructs), the pointer within the PointerToVoid object will be set to - * NULL. + * The data pointer can be an arbitrary pointer and is passed as only argument + * to the callback. */ void WeakReferenceList:: -add_reference(WeakPointerToVoid *ptv) { +add_callback(WeakPointerCallback *callback, void *data) { + nassertv(callback != nullptr); _lock.acquire(); - bool inserted = _pointers.insert(ptv).second; + // We need to check again whether the object is deleted after grabbing the + // lock, despite having already done this in weakPointerTo.I, since it may + // have been deleted in the meantime. + bool deleted = was_deleted(); + if (!deleted) { + _callbacks.insert(make_pair(callback, data)); + } _lock.release(); - nassertv(inserted); + + if (deleted) { + callback->wp_callback(data); + } } /** @@ -60,13 +63,33 @@ add_reference(WeakPointerToVoid *ptv) { * pointer to this object. */ void WeakReferenceList:: -clear_reference(WeakPointerToVoid *ptv) { +remove_callback(WeakPointerCallback *callback) { + nassertv(callback != nullptr); _lock.acquire(); - Pointers::iterator pi = _pointers.find(ptv); - bool valid = (pi != _pointers.end()); - if (valid) { - _pointers.erase(pi); - } + _callbacks.erase(callback); _lock.release(); - nassertv(valid); +} + +/** + * Called only by the ReferenceCount pointer to indicate that it has been + * deleted. + */ +void WeakReferenceList:: +mark_deleted() { + _lock.acquire(); + Callbacks::iterator ci; + for (ci = _callbacks.begin(); ci != _callbacks.end(); ++ci) { + (*ci).first->wp_callback((*ci).second); + } + _callbacks.clear(); + + // Decrement the special offset added to the weak pointer count to indicate + // that it can be deleted when all the weak references have gone. + AtomicAdjust::Integer result = AtomicAdjust::add(_count, -_alive_offset); + _lock.release(); + if (result == 0) { + // There are no weak references remaining either, so delete this. + delete this; + } + nassertv(result >= 0); } diff --git a/panda/src/express/weakReferenceList.h b/panda/src/express/weakReferenceList.h index 16651b7364..49f352c103 100644 --- a/panda/src/express/weakReferenceList.h +++ b/panda/src/express/weakReferenceList.h @@ -15,30 +15,48 @@ #define WEAKREFERENCELIST_H #include "pandabase.h" -#include "pset.h" +#include "pmap.h" #include "mutexImpl.h" -class WeakPointerToVoid; +class WeakPointerCallback; /** - * This is a list of WeakPointerTo's that share a reference to a given - * ReferenceCount object. It is stored in a separate class since it is - * assumed that most ReferenceCount objects do not need to store this list at - * all; this avoids bloating every ReferenceCount object in the world with the - * size of this object. + * This is an object shared by all the weak pointers that point to the same + * ReferenceCount object. It is created whenever a weak reference to an + * object is created, and can outlive the object until all weak references + * have disappeared. */ class EXPCL_PANDAEXPRESS WeakReferenceList { public: WeakReferenceList(); ~WeakReferenceList(); - void add_reference(WeakPointerToVoid *ptv); - void clear_reference(WeakPointerToVoid *ptv); + INLINE void ref() const; + INLINE bool unref() const; + INLINE bool was_deleted() const; + + void add_callback(WeakPointerCallback *callback, void *data); + void remove_callback(WeakPointerCallback *callback); private: - typedef pset Pointers; - Pointers _pointers; + void mark_deleted(); + +public: + // This lock protects the callbacks below, but it also protects the object + // from being deleted during a call to WeakPointerTo::lock(). MutexImpl _lock; + +private: + typedef pmap Callbacks; + Callbacks _callbacks; + + // This has a very large number added to it if the object is still alive. + // It could be 1, but having it be a large number makes it easy to check + // whether the object has been deleted or not. + static const AtomicAdjust::Integer _alive_offset = (1 << 30); + mutable AtomicAdjust::Integer _count; + + friend class ReferenceCount; }; #include "weakReferenceList.I" diff --git a/panda/src/glstuff/glCgShaderContext_src.cxx b/panda/src/glstuff/glCgShaderContext_src.cxx index 9f6e242968..23efd27d9a 100644 --- a/panda/src/glstuff/glCgShaderContext_src.cxx +++ b/panda/src/glstuff/glCgShaderContext_src.cxx @@ -436,42 +436,43 @@ set_state_and_transform(const RenderState *target_rs, altered |= Shader::SSD_projection; } - if (_state_rs.was_deleted() || _state_rs == (const RenderState *)NULL) { + CPT(RenderState) state_rs = _state_rs.lock(); + if (state_rs == nullptr) { // Reset all of the state. altered |= Shader::SSD_general; _state_rs = target_rs; - } else if (_state_rs != target_rs) { + } else if (state_rs != target_rs) { // The state has changed since last time. - if (_state_rs->get_attrib(ColorAttrib::get_class_slot()) != + if (state_rs->get_attrib(ColorAttrib::get_class_slot()) != target_rs->get_attrib(ColorAttrib::get_class_slot())) { altered |= Shader::SSD_color; } - if (_state_rs->get_attrib(ColorScaleAttrib::get_class_slot()) != + if (state_rs->get_attrib(ColorScaleAttrib::get_class_slot()) != target_rs->get_attrib(ColorScaleAttrib::get_class_slot())) { altered |= Shader::SSD_colorscale; } - if (_state_rs->get_attrib(MaterialAttrib::get_class_slot()) != + if (state_rs->get_attrib(MaterialAttrib::get_class_slot()) != target_rs->get_attrib(MaterialAttrib::get_class_slot())) { altered |= Shader::SSD_material; } - if (_state_rs->get_attrib(ShaderAttrib::get_class_slot()) != + if (state_rs->get_attrib(ShaderAttrib::get_class_slot()) != target_rs->get_attrib(ShaderAttrib::get_class_slot())) { altered |= Shader::SSD_shaderinputs; } - if (_state_rs->get_attrib(FogAttrib::get_class_slot()) != + if (state_rs->get_attrib(FogAttrib::get_class_slot()) != target_rs->get_attrib(FogAttrib::get_class_slot())) { altered |= Shader::SSD_fog; } - if (_state_rs->get_attrib(LightAttrib::get_class_slot()) != + if (state_rs->get_attrib(LightAttrib::get_class_slot()) != target_rs->get_attrib(LightAttrib::get_class_slot())) { altered |= Shader::SSD_light; } - if (_state_rs->get_attrib(ClipPlaneAttrib::get_class_slot()) != + if (state_rs->get_attrib(ClipPlaneAttrib::get_class_slot()) != target_rs->get_attrib(ClipPlaneAttrib::get_class_slot())) { altered |= Shader::SSD_clip_planes; } - if (_state_rs->get_attrib(TexMatrixAttrib::get_class_slot()) != + if (state_rs->get_attrib(TexMatrixAttrib::get_class_slot()) != target_rs->get_attrib(TexMatrixAttrib::get_class_slot())) { altered |= Shader::SSD_tex_matrix; } diff --git a/panda/src/glstuff/glGeomMunger_src.cxx b/panda/src/glstuff/glGeomMunger_src.cxx index 5a1649f832..eea42762ce 100644 --- a/panda/src/glstuff/glGeomMunger_src.cxx +++ b/panda/src/glstuff/glGeomMunger_src.cxx @@ -39,8 +39,8 @@ CLP(GeomMunger)(GraphicsStateGuardian *gsg, const RenderState *state) : // TexGen object gets deleted. _texture = (const TextureAttrib *)state->get_attrib(TextureAttrib::get_class_slot()); _tex_gen = (const TexGenAttrib *)state->get_attrib(TexGenAttrib::get_class_slot()); - _texture.set_callback(this); - _tex_gen.set_callback(this); + _texture.add_callback(this); + _tex_gen.add_callback(this); } } @@ -56,6 +56,11 @@ CLP(GeomMunger):: (*gci)->remove_munger(this); } _geom_contexts.clear(); + + if ((_flags & F_parallel_arrays) == 0) { + _texture.remove_callback(this); + _tex_gen.remove_callback(this); + } } /** @@ -220,15 +225,15 @@ munge_format_impl(const GeomVertexFormat *orig, } // Put only the used texture coordinates into the interleaved array. - if (_texture != (TextureAttrib *)NULL) { + if (auto texture = _texture.lock()) { typedef pset UsedStages; UsedStages used_stages; - int num_stages = _texture->get_num_on_stages(); + int num_stages = texture->get_num_on_stages(); for (int i = 0; i < num_stages; ++i) { - TextureStage *stage = _texture->get_on_stage(i); - if (_tex_gen == (TexGenAttrib *)NULL || - !_tex_gen->has_stage(stage)) { + TextureStage *stage = texture->get_on_stage(i); + CPT(TexGenAttrib) tex_gen = _tex_gen.lock(); + if (tex_gen == nullptr || !tex_gen->has_stage(stage)) { InternalName *name = stage->get_texcoord_name(); if (used_stages.insert(name).second) { // This is the first time we've encountered this texcoord name. @@ -360,15 +365,15 @@ premunge_format_impl(const GeomVertexFormat *orig) { // Put only the used texture coordinates into the interleaved array. The // others will be kept around, but in a parallel array. - if (_texture != (TextureAttrib *)NULL) { + if (auto texture = _texture.lock()) { typedef pset UsedStages; UsedStages used_stages; - int num_stages = _texture->get_num_on_stages(); + int num_stages = texture->get_num_on_stages(); for (int i = 0; i < num_stages; ++i) { - TextureStage *stage = _texture->get_on_stage(i); - if (_tex_gen == (TexGenAttrib *)NULL || - !_tex_gen->has_stage(stage)) { + TextureStage *stage = texture->get_on_stage(i); + CPT(TexGenAttrib) tex_gen = _tex_gen.lock(); + if (tex_gen == nullptr || !tex_gen->has_stage(stage)) { InternalName *name = stage->get_texcoord_name(); if (used_stages.insert(name).second) { // This is the first time we've encountered this texcoord name. diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index f2c3b30a9b..b5fd39350d 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -1899,46 +1899,47 @@ set_state_and_transform(const RenderState *target_rs, altered |= Shader::SSD_projection; } - if (_state_rs.was_deleted() || _state_rs == (const RenderState *)NULL) { + CPT(RenderState) state_rs = _state_rs.lock(); + if (state_rs == nullptr) { // Reset all of the state. altered |= Shader::SSD_general; _state_rs = target_rs; - } else if (_state_rs != target_rs) { + } else if (state_rs != target_rs) { // The state has changed since last time. - if (_state_rs->get_attrib(ColorAttrib::get_class_slot()) != + if (state_rs->get_attrib(ColorAttrib::get_class_slot()) != target_rs->get_attrib(ColorAttrib::get_class_slot())) { altered |= Shader::SSD_color; } - if (_state_rs->get_attrib(ColorScaleAttrib::get_class_slot()) != + if (state_rs->get_attrib(ColorScaleAttrib::get_class_slot()) != target_rs->get_attrib(ColorScaleAttrib::get_class_slot())) { altered |= Shader::SSD_colorscale; } - if (_state_rs->get_attrib(MaterialAttrib::get_class_slot()) != + if (state_rs->get_attrib(MaterialAttrib::get_class_slot()) != target_rs->get_attrib(MaterialAttrib::get_class_slot())) { altered |= Shader::SSD_material; } - if (_state_rs->get_attrib(ShaderAttrib::get_class_slot()) != + if (state_rs->get_attrib(ShaderAttrib::get_class_slot()) != target_rs->get_attrib(ShaderAttrib::get_class_slot())) { altered |= Shader::SSD_shaderinputs; } - if (_state_rs->get_attrib(FogAttrib::get_class_slot()) != + if (state_rs->get_attrib(FogAttrib::get_class_slot()) != target_rs->get_attrib(FogAttrib::get_class_slot())) { altered |= Shader::SSD_fog; } - if (_state_rs->get_attrib(LightAttrib::get_class_slot()) != + if (state_rs->get_attrib(LightAttrib::get_class_slot()) != target_rs->get_attrib(LightAttrib::get_class_slot())) { altered |= Shader::SSD_light; } - if (_state_rs->get_attrib(ClipPlaneAttrib::get_class_slot()) != + if (state_rs->get_attrib(ClipPlaneAttrib::get_class_slot()) != target_rs->get_attrib(ClipPlaneAttrib::get_class_slot())) { altered |= Shader::SSD_clip_planes; } - if (_state_rs->get_attrib(TexMatrixAttrib::get_class_slot()) != + if (state_rs->get_attrib(TexMatrixAttrib::get_class_slot()) != target_rs->get_attrib(TexMatrixAttrib::get_class_slot())) { altered |= Shader::SSD_tex_matrix; } - if (_state_rs->get_attrib(TextureAttrib::get_class_slot()) != + if (state_rs->get_attrib(TextureAttrib::get_class_slot()) != target_rs->get_attrib(TextureAttrib::get_class_slot())) { altered |= Shader::SSD_texture; } diff --git a/panda/src/glstuff/glTimerQueryContext_src.cxx b/panda/src/glstuff/glTimerQueryContext_src.cxx index 36cfefb91e..a7b4ecb612 100644 --- a/panda/src/glstuff/glTimerQueryContext_src.cxx +++ b/panda/src/glstuff/glTimerQueryContext_src.cxx @@ -30,9 +30,9 @@ CLP(TimerQueryContext):: // has already shut down, though, too bad. This means we never get to // free this index, but presumably the app is already shutting down // anyway. - if (!_glgsg.was_deleted()) { - LightMutexHolder holder(_glgsg->_lock); - _glgsg->_deleted_queries.push_back(_index); + if (auto glgsg = _glgsg.lock()) { + LightMutexHolder holder(glgsg->_lock); + glgsg->_deleted_queries.push_back(_index); _index = 0; } } diff --git a/panda/src/pgraph/stateMunger.cxx b/panda/src/pgraph/stateMunger.cxx index db94c81ba8..8eba900f70 100644 --- a/panda/src/pgraph/stateMunger.cxx +++ b/panda/src/pgraph/stateMunger.cxx @@ -32,8 +32,8 @@ munge_state(const RenderState *state) { int id = get_gsg()->_id; int mi = munged_states.find(id); if (mi != -1) { - if (!munged_states.get_data(mi).was_deleted()) { - return munged_states.get_data(mi).p(); + if (auto munged_state = munged_states.get_data(mi).lock()) { + return munged_state; } else { munged_states.remove_element(mi); } diff --git a/panda/src/pgraph/weakNodePath.I b/panda/src/pgraph/weakNodePath.I index 36cdbdbf60..5e323bc3c1 100644 --- a/panda/src/pgraph/weakNodePath.I +++ b/panda/src/pgraph/weakNodePath.I @@ -74,23 +74,30 @@ was_deleted() const { } /** - * Returns the NodePath held within this object. + * Returns the NodePath held within this object, or an empty NodePath with the + * error flag set if the object was deleted. */ INLINE NodePath WeakNodePath:: get_node_path() const { - nassertr_always(!was_deleted(), NodePath::fail()); NodePath result; - result._head = _head; + result._head = _head.lock(); + if (!_head.is_null() && result._head == nullptr) { + result._error_type = NodePath::ET_fail; + } return result; } /** - * Returns the PandaNode held within this object. + * Returns the PandaNode held within this object, or nullptr if the object was + * deleted. */ -INLINE PandaNode *WeakNodePath:: +INLINE PT(PandaNode) WeakNodePath:: node() const { - nassertr_always(!is_empty(), (PandaNode *)NULL); - return _head->get_node(); + if (auto head = _head.lock()) { + return head->get_node(); + } else { + return nullptr; + } } /** @@ -190,10 +197,9 @@ compare_to(const WeakNodePath &other) const { */ INLINE int WeakNodePath:: get_key() const { - if (is_empty() || was_deleted()) { - return _backup_key; + if (auto head = _head.lock()) { + _backup_key = head->get_key(); } - ((WeakNodePath *)this)->_backup_key = _head->get_key(); return _backup_key; } diff --git a/panda/src/pgraph/weakNodePath.h b/panda/src/pgraph/weakNodePath.h index e5b9b79c90..763df494ac 100644 --- a/panda/src/pgraph/weakNodePath.h +++ b/panda/src/pgraph/weakNodePath.h @@ -42,7 +42,7 @@ public: INLINE bool was_deleted() const; INLINE NodePath get_node_path() const; - INLINE PandaNode *node() const; + INLINE PT(PandaNode) node() const; INLINE bool operator == (const NodePath &other) const; INLINE bool operator != (const NodePath &other) const; @@ -60,7 +60,7 @@ public: private: WPT(NodePathComponent) _head; - int _backup_key; + mutable int _backup_key; }; INLINE ostream &operator << (ostream &out, const WeakNodePath &node_path); diff --git a/panda/src/pstatclient/pStatClient.I b/panda/src/pstatclient/pStatClient.I index 8ce9381978..2338eaa0ad 100644 --- a/panda/src/pstatclient/pStatClient.I +++ b/panda/src/pstatclient/pStatClient.I @@ -60,14 +60,11 @@ get_thread_sync_name(int index) const { /** * Returns the Panda Thread object associated with the indicated PStatThread. */ -INLINE Thread *PStatClient:: +INLINE PT(Thread) PStatClient:: get_thread_object(int index) const { nassertr(index >= 0 && index < AtomicAdjust::get(_num_threads), NULL); InternalThread *thread = get_thread_ptr(index); - if (thread->_thread.was_deleted()) { - return NULL; - } - return thread->_thread; + return thread->_thread.lock(); } /** diff --git a/panda/src/pstatclient/pStatClient.h b/panda/src/pstatclient/pStatClient.h index 2d285c6f8a..6fb41c4c3c 100644 --- a/panda/src/pstatclient/pStatClient.h +++ b/panda/src/pstatclient/pStatClient.h @@ -73,7 +73,7 @@ PUBLISHED: MAKE_SEQ(get_threads, get_num_threads, get_thread); INLINE string get_thread_name(int index) const; INLINE string get_thread_sync_name(int index) const; - INLINE Thread *get_thread_object(int index) const; + INLINE PT(Thread) get_thread_object(int index) const; PStatThread get_main_thread() const; PStatThread get_current_thread() const; diff --git a/panda/src/putil/weakKeyHashMap.I b/panda/src/putil/weakKeyHashMap.I index f894411f24..a3246c19ec 100644 --- a/panda/src/putil/weakKeyHashMap.I +++ b/panda/src/putil/weakKeyHashMap.I @@ -337,7 +337,7 @@ remove_element(size_t n) { clear_element(i); --_num_entries; } else { - size_t wants_index = get_hash(_table[i]._key); + size_t wants_index = get_hash(_table[i]._key.get_orig()); if (wants_index != i) { // This one was a hash conflict; try to put it where it belongs. We // can't just put it in n, since maybe it belongs somewhere after n. From 140644d8b6e68a2a6ed3e0cfc491cbf7ce437819 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 20 May 2018 11:50:32 +0200 Subject: [PATCH 175/247] stdpy: add Python 3 stuff to glob module, remove re dependency --- direct/src/stdpy/glob.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/direct/src/stdpy/glob.py b/direct/src/stdpy/glob.py index 28eee2cb6e..d1a4946c0e 100755 --- a/direct/src/stdpy/glob.py +++ b/direct/src/stdpy/glob.py @@ -4,7 +4,6 @@ virtual file system. """ import sys import os -import re import fnmatch from direct.stdpy import file @@ -76,7 +75,27 @@ def glob0(dirname, basename): return [] -magic_check = re.compile('[*?[]') - def has_magic(s): - return magic_check.search(s) is not None + if isinstance(s, bytes): + return b'*' in s or b'?' in s or b'[' in s + else: + return '*' in s or '?' in s or '[' in s + +def escape(pathname): + drive, pathname = os.path.splitdrive(pathname) + if sys.version_info >= (3, 0) and isinstance(pathname, bytes): + newpath = bytearray(drive) + for c in pathname: + if c == 42 or c == 63 or c == 91: + newpath += bytes((91, c, 93)) + else: + newpath.append(c) + return bytes(newpath) + else: + newpath = drive + for c in pathname: + if c == '*' or c == '?' or c == '[': + newpath += '[' + c + ']' + else: + newpath += c + return newpath From 14f118b672809a78a971acdc75e2e2dec915d6e9 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 20 May 2018 15:56:58 +0200 Subject: [PATCH 176/247] pgraph: expose WeakNodePath to Python --- panda/src/pgraph/weakNodePath.I | 18 ++++++++++++++++++ panda/src/pgraph/weakNodePath.h | 7 ++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/panda/src/pgraph/weakNodePath.I b/panda/src/pgraph/weakNodePath.I index 5e323bc3c1..613afe0800 100644 --- a/panda/src/pgraph/weakNodePath.I +++ b/panda/src/pgraph/weakNodePath.I @@ -56,6 +56,24 @@ operator = (const WeakNodePath ©) { _backup_key = copy._backup_key; } +/** + * Sets this NodePath to the empty NodePath. It will no longer point to any + * node. + */ +INLINE void WeakNodePath:: +clear() { + _head.clear(); + _backup_key = 0; +} + +/** + * Returns true if this NodePath points to a valid, non-null node. + */ +INLINE WeakNodePath:: +operator bool () const { + return _head.is_valid_pointer(); +} + /** * Returns true if the NodePath contains no nodes, or if it has been deleted. */ diff --git a/panda/src/pgraph/weakNodePath.h b/panda/src/pgraph/weakNodePath.h index 763df494ac..dc82431023 100644 --- a/panda/src/pgraph/weakNodePath.h +++ b/panda/src/pgraph/weakNodePath.h @@ -30,7 +30,7 @@ * associated NodePath. */ class EXPCL_PANDA_PGRAPH WeakNodePath { -public: +PUBLISHED: INLINE WeakNodePath(const NodePath &node_path); INLINE WeakNodePath(const WeakNodePath ©); INLINE ~WeakNodePath(); @@ -38,6 +38,9 @@ public: INLINE void operator = (const NodePath &node_path); INLINE void operator = (const WeakNodePath ©); + INLINE void clear(); + + INLINE operator bool () const; INLINE bool is_empty() const; INLINE bool was_deleted() const; @@ -61,6 +64,8 @@ public: private: WPT(NodePathComponent) _head; mutable int _backup_key; + + friend class NodePath; }; INLINE ostream &operator << (ostream &out, const WeakNodePath &node_path); From 941fda6ec38ff675db10b7a6be26e0aa12292b94 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 20 May 2018 15:57:23 +0200 Subject: [PATCH 177/247] pgraph: fix comparisons between WeakNodePath and NodePath Previously it would only work correctly if the WeakNodePath appeared on the left side of the comparison operator. --- panda/src/pgraph/nodePath.cxx | 50 +++++++++++++++++++++++++++++++++++ panda/src/pgraph/nodePath.h | 6 +++++ tests/pgraph/test_nodepath.py | 16 +++++++++++ 3 files changed, 72 insertions(+) diff --git a/panda/src/pgraph/nodePath.cxx b/panda/src/pgraph/nodePath.cxx index 71bbb3a561..41e02b0821 100644 --- a/panda/src/pgraph/nodePath.cxx +++ b/panda/src/pgraph/nodePath.cxx @@ -71,6 +71,7 @@ #include "bam.h" #include "bamWriter.h" #include "datagramBuffer.h" +#include "weakNodePath.h" // stack seems to overflow on Intel C++ at 7000. If we need more than 7000, // need to increase stack size. @@ -5164,6 +5165,55 @@ get_stashed_ancestor(Thread *current_thread) const { return not_found(); } +/** + * Returns true if the two paths are equivalent; that is, if they contain the + * same list of nodes in the same order. + */ +bool NodePath:: +operator == (const WeakNodePath &other) const { + return _head == other._head; +} + +/** + * Returns true if the two paths are not equivalent. + */ +bool NodePath:: +operator != (const WeakNodePath &other) const { + return _head != other._head; +} + +/** + * Returns true if this NodePath sorts before the other one, false otherwise. + * The sorting order of two nonequivalent NodePaths is consistent but + * undefined, and is useful only for storing NodePaths in a sorted container + * like an STL set. + */ +bool NodePath:: +operator < (const WeakNodePath &other) const { + return _head < other._head; +} + +/** + * Returns a number less than zero if this NodePath sorts before the other + * one, greater than zero if it sorts after, or zero if they are equivalent. + * + * Two NodePaths are considered equivalent if they consist of exactly the same + * list of nodes in the same order. Otherwise, they are different; different + * NodePaths will be ranked in a consistent but undefined ordering; the + * ordering is useful only for placing the NodePaths in a sorted container + * like an STL set. + */ +int NodePath:: +compare_to(const WeakNodePath &other) const { + // Nowadays, the NodePathComponents at the head are pointerwise equivalent + // if and only if the NodePaths are equivalent. So we only have to compare + // pointers. + if (_head != other._head) { + return _head < other._head ? -1 : 1; + } + return 0; +} + /** * Returns true if all of the nodes described in the NodePath are connected, * or false otherwise. diff --git a/panda/src/pgraph/nodePath.h b/panda/src/pgraph/nodePath.h index c5a3902c32..11d7437113 100644 --- a/panda/src/pgraph/nodePath.h +++ b/panda/src/pgraph/nodePath.h @@ -63,6 +63,7 @@ class SamplerState; class Shader; class ShaderBuffer; class ShaderInput; +class WeakNodePath; // // A NodePath is the fundamental unit of high-level interaction with the scene @@ -879,6 +880,11 @@ PUBLISHED: INLINE bool operator < (const NodePath &other) const; INLINE int compare_to(const NodePath &other) const; + bool operator == (const WeakNodePath &other) const; + bool operator != (const WeakNodePath &other) const; + bool operator < (const WeakNodePath &other) const; + int compare_to(const WeakNodePath &other) const; + // Miscellaneous bool verify_complete(Thread *current_thread = Thread::get_current_thread()) const; diff --git a/tests/pgraph/test_nodepath.py b/tests/pgraph/test_nodepath.py index a625533634..9c97d4260a 100644 --- a/tests/pgraph/test_nodepath.py +++ b/tests/pgraph/test_nodepath.py @@ -79,3 +79,19 @@ def test_nodepath_transform_composition(): leg2 = node1.get_transform().compose(node3.get_transform()) relative_transform = leg1.get_inverse().compose(leg2) assert np1.get_transform(np2) == relative_transform + + +def test_weak_nodepath_comparison(): + from panda3d.core import NodePath, WeakNodePath + + path = NodePath("node") + weak = WeakNodePath(path) + + assert path == weak + assert weak == path + assert weak <= path + assert path <= weak + + assert hash(path) == hash(weak) + assert weak.get_node_path() == path + assert weak.node() == path.node() From 8c80ff16815387e78baf4e1e4a00b4681cf8e59c Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 20 May 2018 18:46:27 +0200 Subject: [PATCH 178/247] Audio3DManager: remove sounds when attached object is deleted This now uses WeakNodePaths in order to prevent holding a reference to the corresponding nodes. Closes #145 --- direct/src/showbase/Audio3DManager.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/direct/src/showbase/Audio3DManager.py b/direct/src/showbase/Audio3DManager.py index 463d3b5bf0..4a67c9bc27 100644 --- a/direct/src/showbase/Audio3DManager.py +++ b/direct/src/showbase/Audio3DManager.py @@ -2,8 +2,8 @@ __all__ = ['Audio3DManager'] -from panda3d.core import Vec3, VBase3 -from direct.task import Task +from panda3d.core import Vec3, VBase3, WeakNodePath +from direct.task.TaskManagerGlobal import Task, taskMgr # class Audio3DManager: @@ -181,7 +181,8 @@ class Audio3DManager: def attachSoundToObject(self, sound, object): """ - Sound will come from the location of the object it is attached to + Sound will come from the location of the object it is attached to. + If the object is deleted, the sound will automatically be removed. """ # sound is an AudioSound # object is any Panda object with coordinates @@ -197,7 +198,7 @@ class Audio3DManager: del self.sound_dict[known_object] if object not in self.sound_dict: - self.sound_dict[object] = [] + self.sound_dict[WeakNodePath(object)] = [] self.sound_dict[object].append(sound) return 1 @@ -258,14 +259,18 @@ class Audio3DManager: if self.audio_manager.getActive()==0: return Task.cont - for known_object in list(self.sound_dict.keys()): - tracked_sound = 0 - while tracked_sound < len(self.sound_dict[known_object]): - sound = self.sound_dict[known_object][tracked_sound] - pos = known_object.getPos(self.root) + for known_object, sounds in list(self.sound_dict.items()): + node_path = known_object.getNodePath() + if not node_path: + # The node has been deleted. + del self.sound_dict[known_object] + continue + + pos = node_path.getPos(self.root) + + for sound in sounds: vel = self.getSoundVelocity(sound) sound.set3dAttributes(pos[0], pos[1], pos[2], vel[0], vel[1], vel[2]) - tracked_sound += 1 # Update the position of the listener based on the object # to which it is attached From 3b4d12cb993857a58f79471665aa25e7368c5048 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 21 May 2018 11:55:46 +0200 Subject: [PATCH 179/247] interrogate: also fall back to compare_to in Python 2 This is to create the same behaviour in Python 2 and 3. --- dtool/src/interrogate/interfaceMakerPythonNative.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 5ae2d3fca9..7542569d46 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -2601,7 +2601,6 @@ write_module_class(ostream &out, Object *obj) { // compare_to function, which is mapped to the tp_compare slot, which // Python 3 no longer has. So, we'll write code to fall back to that if // no matching comparison operator was found. - out << "#if PY_MAJOR_VERSION >= 3\n"; out << " // All is not lost; we still have the compare_to function to fall back onto.\n"; out << " int cmpval = " << slots["tp_compare"]._wrapper_name << "(self, arg);\n"; out << " if (cmpval == -1 && _PyErr_OCCURRED()) {\n"; @@ -2625,7 +2624,6 @@ write_module_class(ostream &out, Object *obj) { out << " case Py_GE:\n"; out << " return PyBool_FromLong(cmpval >= 0);\n"; out << " }\n"; - out << "#endif\n\n"; } out << " Py_INCREF(Py_NotImplemented);\n"; From 3653413cd4902b729e2b2e05405c715605b3a39a Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 23 May 2018 16:55:17 +0200 Subject: [PATCH 180/247] bullet: fix BulletSoftBodyNode::get_node deadlock --- panda/src/bullet/bulletSoftBodyNode.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/bullet/bulletSoftBodyNode.cxx b/panda/src/bullet/bulletSoftBodyNode.cxx index c4094af652..8321c610f1 100644 --- a/panda/src/bullet/bulletSoftBodyNode.cxx +++ b/panda/src/bullet/bulletSoftBodyNode.cxx @@ -134,7 +134,7 @@ BulletSoftBodyNodeElement BulletSoftBodyNode:: get_node(int idx) const { LightMutexHolder holder(BulletWorld::get_global_lock()); - nassertr(idx >=0 && idx < get_num_nodes(), BulletSoftBodyNodeElement::empty()); + nassertr(idx >= 0 && idx < _soft->m_nodes.size(), BulletSoftBodyNodeElement::empty()); return BulletSoftBodyNodeElement(_soft->m_nodes[idx]); } From f45ddcab2f5a48a0ecf2bea4424ea2bcee5f0ebd Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 23 May 2018 20:37:56 +0200 Subject: [PATCH 181/247] general: switch to C++11 Lockable semantics for mutexes This renames acquire/release to lock/unlock in order to be compatible with std::lock_guard and std::unique_lock (which will eventually replace the *MutexHolder classes). It will also allow us to typedef MutexImpl to std::mutex later on. --- dtool/src/dtoolbase/deletedBufferChain.cxx | 10 +- dtool/src/dtoolbase/memoryHook.cxx | 44 ++++----- dtool/src/dtoolbase/mutexDummyImpl.I | 6 +- dtool/src/dtoolbase/mutexDummyImpl.h | 6 +- dtool/src/dtoolbase/mutexPosixImpl.I | 40 +++----- dtool/src/dtoolbase/mutexPosixImpl.h | 16 ++-- dtool/src/dtoolbase/mutexSpinlockImpl.I | 8 +- dtool/src/dtoolbase/mutexSpinlockImpl.h | 6 +- dtool/src/dtoolbase/mutexWin32Impl.I | 6 +- dtool/src/dtoolbase/mutexWin32Impl.h | 6 +- dtool/src/dtoolbase/neverFreeMemory.I | 4 +- dtool/src/dtoolbase/neverFreeMemory.cxx | 6 +- dtool/src/dtoolbase/typeRegistry.cxx | 88 ++++++++--------- dtool/src/prc/configVariableFilename.cxx | 4 +- dtool/src/prc/configVariableString.cxx | 4 +- dtool/src/prc/streamWrapper.I | 4 +- panda/src/downloader/multiplexStreamBuf.cxx | 16 ++-- panda/src/downloader/virtualFileMountHTTP.cxx | 8 +- panda/src/event/asyncFuture.cxx | 4 +- panda/src/event/asyncTask.cxx | 4 +- panda/src/event/asyncTaskChain.cxx | 12 +-- panda/src/event/asyncTaskManager.cxx | 4 +- panda/src/express/trueClock.I | 4 +- panda/src/express/virtualFileMountRamdisk.cxx | 96 +++++++++---------- panda/src/express/virtualFileSystem.cxx | 74 +++++++------- panda/src/express/virtualFileSystem.h | 2 +- panda/src/express/weakPointerTo.I | 8 +- panda/src/express/weakReferenceList.cxx | 12 +-- panda/src/gobj/adaptiveLru.cxx | 4 +- panda/src/gobj/simpleLru.cxx | 4 +- panda/src/gobj/texture.cxx | 4 +- panda/src/pipeline/conditionVarDebug.cxx | 26 ++--- panda/src/pipeline/conditionVarFullDebug.cxx | 32 +++---- panda/src/pipeline/conditionVarSimpleImpl.cxx | 8 +- panda/src/pipeline/lightMutexDirect.I | 34 ++++++- panda/src/pipeline/lightMutexDirect.h | 9 +- panda/src/pipeline/lightReMutexDirect.I | 54 +++++++++-- panda/src/pipeline/lightReMutexDirect.h | 11 ++- panda/src/pipeline/mutexDebug.I | 61 +++++++++--- panda/src/pipeline/mutexDebug.cxx | 18 ++-- panda/src/pipeline/mutexDebug.h | 11 ++- panda/src/pipeline/mutexDirect.I | 36 ++++++- panda/src/pipeline/mutexDirect.h | 7 +- panda/src/pipeline/mutexSimpleImpl.I | 30 ++---- panda/src/pipeline/mutexSimpleImpl.cxx | 6 +- panda/src/pipeline/mutexSimpleImpl.h | 17 ++-- panda/src/pipeline/pipeline.cxx | 38 ++++---- panda/src/pipeline/reMutexDirect.I | 60 +++++++++--- panda/src/pipeline/reMutexDirect.cxx | 28 +++--- panda/src/pipeline/reMutexDirect.h | 17 ++-- panda/src/pipeline/test_mutex.cxx | 8 +- panda/src/pipeline/threadPosixImpl.cxx | 30 +++--- panda/src/pipeline/threadWin32Impl.cxx | 26 ++--- panda/src/putil/bamCache.cxx | 4 +- panda/src/putil/copyOnWritePointer.cxx | 8 +- 55 files changed, 624 insertions(+), 469 deletions(-) diff --git a/dtool/src/dtoolbase/deletedBufferChain.cxx b/dtool/src/dtoolbase/deletedBufferChain.cxx index 27d7214d79..71756f3e25 100644 --- a/dtool/src/dtoolbase/deletedBufferChain.cxx +++ b/dtool/src/dtoolbase/deletedBufferChain.cxx @@ -43,11 +43,11 @@ allocate(size_t size, TypeHandle type_handle) { ObjectNode *obj; - _lock.acquire(); + _lock.lock(); if (_deleted_chain != (ObjectNode *)NULL) { obj = _deleted_chain; _deleted_chain = _deleted_chain->_next; - _lock.release(); + _lock.unlock(); #ifdef USE_DELETEDCHAINFLAG assert(obj->_flag == (AtomicAdjust::Integer)DCF_deleted); @@ -64,7 +64,7 @@ allocate(size_t size, TypeHandle type_handle) { return ptr; } - _lock.release(); + _lock.unlock(); // If we get here, the deleted_chain is empty; we have to allocate a new // object from the system pool. @@ -126,12 +126,12 @@ deallocate(void *ptr, TypeHandle type_handle) { assert(orig_flag == (AtomicAdjust::Integer)DCF_alive); #endif // USE_DELETEDCHAINFLAG - _lock.acquire(); + _lock.lock(); obj->_next = _deleted_chain; _deleted_chain = obj; - _lock.release(); + _lock.unlock(); #else // USE_DELETED_CHAIN PANDA_FREE_SINGLE(ptr); diff --git a/dtool/src/dtoolbase/memoryHook.cxx b/dtool/src/dtoolbase/memoryHook.cxx index 510b5b2688..710ea9e65f 100644 --- a/dtool/src/dtoolbase/memoryHook.cxx +++ b/dtool/src/dtoolbase/memoryHook.cxx @@ -223,9 +223,9 @@ MemoryHook(const MemoryHook ©) : _total_mmap_size(copy._total_mmap_size), _max_heap_size(copy._max_heap_size) { - copy._lock.acquire(); + copy._lock.lock(); _deleted_chains = copy._deleted_chains; - copy._lock.release(); + copy._lock.unlock(); } /** @@ -249,9 +249,9 @@ heap_alloc_single(size_t size) { size_t inflated_size = inflate_size(size); #ifdef MEMORY_HOOK_MALLOC_LOCK - _lock.acquire(); + _lock.lock(); void *alloc = call_malloc(inflated_size); - _lock.release(); + _lock.unlock(); #else void *alloc = call_malloc(inflated_size); #endif @@ -259,9 +259,9 @@ heap_alloc_single(size_t size) { while (alloc == (void *)NULL) { alloc_fail(inflated_size); #ifdef MEMORY_HOOK_MALLOC_LOCK - _lock.acquire(); + _lock.lock(); alloc = call_malloc(inflated_size); - _lock.release(); + _lock.unlock(); #else alloc = call_malloc(inflated_size); #endif @@ -305,9 +305,9 @@ heap_free_single(void *ptr) { #endif // DO_MEMORY_USAGE #ifdef MEMORY_HOOK_MALLOC_LOCK - _lock.acquire(); + _lock.lock(); call_free(alloc); - _lock.release(); + _lock.unlock(); #else call_free(alloc); #endif @@ -326,9 +326,9 @@ heap_alloc_array(size_t size) { size_t inflated_size = inflate_size(size); #ifdef MEMORY_HOOK_MALLOC_LOCK - _lock.acquire(); + _lock.lock(); void *alloc = call_malloc(inflated_size); - _lock.release(); + _lock.unlock(); #else void *alloc = call_malloc(inflated_size); #endif @@ -336,9 +336,9 @@ heap_alloc_array(size_t size) { while (alloc == (void *)NULL) { alloc_fail(inflated_size); #ifdef MEMORY_HOOK_MALLOC_LOCK - _lock.acquire(); + _lock.lock(); alloc = call_malloc(inflated_size); - _lock.release(); + _lock.unlock(); #else alloc = call_malloc(inflated_size); #endif @@ -380,9 +380,9 @@ heap_realloc_array(void *ptr, size_t size) { void *alloc1 = alloc; #ifdef MEMORY_HOOK_MALLOC_LOCK - _lock.acquire(); + _lock.lock(); alloc1 = call_realloc(alloc1, inflated_size); - _lock.release(); + _lock.unlock(); #else alloc1 = call_realloc(alloc1, inflated_size); #endif @@ -394,9 +394,9 @@ heap_realloc_array(void *ptr, size_t size) { alloc1 = alloc; #ifdef MEMORY_HOOK_MALLOC_LOCK - _lock.acquire(); + _lock.lock(); alloc1 = call_realloc(alloc1, inflated_size); - _lock.release(); + _lock.unlock(); #else alloc1 = call_realloc(alloc1, inflated_size); #endif @@ -453,9 +453,9 @@ heap_free_array(void *ptr) { #endif // DO_MEMORY_USAGE #ifdef MEMORY_HOOK_MALLOC_LOCK - _lock.acquire(); + _lock.lock(); call_free(alloc); - _lock.release(); + _lock.unlock(); #else call_free(alloc); #endif @@ -478,11 +478,11 @@ heap_trim(size_t pad) { // Since malloc_trim() isn't standard C, we can't be sure it exists on a // given platform. But if we're using dlmalloc, we know we have // dlmalloc_trim. - _lock.acquire(); + _lock.lock(); if (dlmalloc_trim(pad)) { trimmed = true; } - _lock.release(); + _lock.unlock(); #endif #ifdef WIN32 @@ -596,7 +596,7 @@ DeletedBufferChain *MemoryHook:: get_deleted_chain(size_t buffer_size) { DeletedBufferChain *chain; - _lock.acquire(); + _lock.lock(); DeletedChains::iterator dci = _deleted_chains.find(buffer_size); if (dci != _deleted_chains.end()) { chain = (*dci).second; @@ -606,7 +606,7 @@ get_deleted_chain(size_t buffer_size) { _deleted_chains.insert(DeletedChains::value_type(buffer_size, chain)); } - _lock.release(); + _lock.unlock(); return chain; } diff --git a/dtool/src/dtoolbase/mutexDummyImpl.I b/dtool/src/dtoolbase/mutexDummyImpl.I index 94afaa2cc5..26a4dd6242 100644 --- a/dtool/src/dtoolbase/mutexDummyImpl.I +++ b/dtool/src/dtoolbase/mutexDummyImpl.I @@ -15,14 +15,14 @@ * */ ALWAYS_INLINE void MutexDummyImpl:: -acquire() { +lock() { } /** * */ ALWAYS_INLINE bool MutexDummyImpl:: -try_acquire() { +try_lock() { return true; } @@ -30,5 +30,5 @@ try_acquire() { * */ ALWAYS_INLINE void MutexDummyImpl:: -release() { +unlock() { } diff --git a/dtool/src/dtoolbase/mutexDummyImpl.h b/dtool/src/dtoolbase/mutexDummyImpl.h index 772f3f8201..cbb6132f90 100644 --- a/dtool/src/dtoolbase/mutexDummyImpl.h +++ b/dtool/src/dtoolbase/mutexDummyImpl.h @@ -30,9 +30,9 @@ private: MutexDummyImpl &operator = (const MutexDummyImpl ©) DELETED_ASSIGN; public: - ALWAYS_INLINE void acquire(); - ALWAYS_INLINE bool try_acquire(); - ALWAYS_INLINE void release(); + ALWAYS_INLINE void lock(); + ALWAYS_INLINE bool try_lock(); + ALWAYS_INLINE void unlock(); }; #include "mutexDummyImpl.I" diff --git a/dtool/src/dtoolbase/mutexPosixImpl.I b/dtool/src/dtoolbase/mutexPosixImpl.I index 05acfae1c2..5b884dcde5 100644 --- a/dtool/src/dtoolbase/mutexPosixImpl.I +++ b/dtool/src/dtoolbase/mutexPosixImpl.I @@ -32,8 +32,8 @@ INLINE MutexPosixImpl:: * */ INLINE void MutexPosixImpl:: -acquire() { - TAU_PROFILE("void MutexPosixImpl::acquire", " ", TAU_USER); +lock() { + TAU_PROFILE("void MutexPosixImpl::lock", " ", TAU_USER); int result = pthread_mutex_lock(&_lock); assert(result == 0); } @@ -42,8 +42,8 @@ acquire() { * */ INLINE bool MutexPosixImpl:: -try_acquire() { - TAU_PROFILE("bool MutexPosixImpl::try_acquire", " ", TAU_USER); +try_lock() { + TAU_PROFILE("bool MutexPosixImpl::try_lock", " ", TAU_USER); int result = pthread_mutex_trylock(&_lock); assert(result == 0 || result == EBUSY); return (result == 0); @@ -53,20 +53,12 @@ try_acquire() { * */ INLINE void MutexPosixImpl:: -release() { - TAU_PROFILE("void MutexPosixImpl::release", " ", TAU_USER); +unlock() { + TAU_PROFILE("void MutexPosixImpl::unlock", " ", TAU_USER); int result = pthread_mutex_unlock(&_lock); assert(result == 0); } -/** - * Returns the underlying Posix lock handle. - */ -INLINE pthread_mutex_t *MutexPosixImpl:: -get_posix_lock() { - return &_lock; -} - /** * */ @@ -101,8 +93,8 @@ INLINE ReMutexPosixImpl:: * */ INLINE void ReMutexPosixImpl:: -acquire() { - TAU_PROFILE("void ReMutexPosixImpl::acquire", " ", TAU_USER); +lock() { + TAU_PROFILE("void ReMutexPosixImpl::lock", " ", TAU_USER); int result = pthread_mutex_lock(&_lock); assert(result == 0); } @@ -111,8 +103,8 @@ acquire() { * */ INLINE bool ReMutexPosixImpl:: -try_acquire() { - TAU_PROFILE("bool ReMutexPosixImpl::try_acquire", " ", TAU_USER); +try_lock() { + TAU_PROFILE("bool ReMutexPosixImpl::try_lock", " ", TAU_USER); int result = pthread_mutex_trylock(&_lock); assert(result == 0 || result == EBUSY); return (result == 0); @@ -122,16 +114,8 @@ try_acquire() { * */ INLINE void ReMutexPosixImpl:: -release() { - TAU_PROFILE("void ReMutexPosixImpl::release", " ", TAU_USER); +unlock() { + TAU_PROFILE("void ReMutexPosixImpl::unlock", " ", TAU_USER); int result = pthread_mutex_unlock(&_lock); assert(result == 0); } - -/** - * Returns the underlying Posix lock handle. - */ -INLINE pthread_mutex_t *ReMutexPosixImpl:: -get_posix_lock() { - return &_lock; -} diff --git a/dtool/src/dtoolbase/mutexPosixImpl.h b/dtool/src/dtoolbase/mutexPosixImpl.h index 44b5ab193f..6baf70d962 100644 --- a/dtool/src/dtoolbase/mutexPosixImpl.h +++ b/dtool/src/dtoolbase/mutexPosixImpl.h @@ -36,11 +36,9 @@ private: MutexPosixImpl &operator = (const MutexPosixImpl ©) DELETED_ASSIGN; public: - INLINE void acquire(); - INLINE bool try_acquire(); - INLINE void release(); - - INLINE pthread_mutex_t *get_posix_lock(); + INLINE void lock(); + INLINE bool try_lock(); + INLINE void unlock(); private: pthread_mutex_t _lock; @@ -64,11 +62,9 @@ private: ReMutexPosixImpl &operator = (const ReMutexPosixImpl ©) DELETED; public: - INLINE void acquire(); - INLINE bool try_acquire(); - INLINE void release(); - - INLINE pthread_mutex_t *get_posix_lock(); + INLINE void lock(); + INLINE bool try_lock(); + INLINE void unlock(); private: pthread_mutex_t _lock; diff --git a/dtool/src/dtoolbase/mutexSpinlockImpl.I b/dtool/src/dtoolbase/mutexSpinlockImpl.I index 9fca1e9bf6..97838772d2 100644 --- a/dtool/src/dtoolbase/mutexSpinlockImpl.I +++ b/dtool/src/dtoolbase/mutexSpinlockImpl.I @@ -22,8 +22,8 @@ MutexSpinlockImpl() : _lock(0) { * */ INLINE void MutexSpinlockImpl:: -acquire() { - if (!try_acquire()) { +lock() { + if (!try_lock()) { do_lock(); } } @@ -32,7 +32,7 @@ acquire() { * */ INLINE bool MutexSpinlockImpl:: -try_acquire() { +try_lock() { return (AtomicAdjust::compare_and_exchange(_lock, 0, 1) == 0); } @@ -40,6 +40,6 @@ try_acquire() { * */ INLINE void MutexSpinlockImpl:: -release() { +unlock() { AtomicAdjust::set(_lock, 0); } diff --git a/dtool/src/dtoolbase/mutexSpinlockImpl.h b/dtool/src/dtoolbase/mutexSpinlockImpl.h index 33514127f4..0c51522b1e 100644 --- a/dtool/src/dtoolbase/mutexSpinlockImpl.h +++ b/dtool/src/dtoolbase/mutexSpinlockImpl.h @@ -36,9 +36,9 @@ private: MutexSpinlockImpl &operator = (const MutexSpinlockImpl ©) DELETED_ASSIGN; public: - INLINE void acquire(); - INLINE bool try_acquire(); - INLINE void release(); + INLINE void lock(); + INLINE bool try_lock(); + INLINE void unlock(); private: void do_lock(); diff --git a/dtool/src/dtoolbase/mutexWin32Impl.I b/dtool/src/dtoolbase/mutexWin32Impl.I index cd9b3d1fb1..acbbd68b56 100644 --- a/dtool/src/dtoolbase/mutexWin32Impl.I +++ b/dtool/src/dtoolbase/mutexWin32Impl.I @@ -23,7 +23,7 @@ INLINE MutexWin32Impl:: * */ INLINE void MutexWin32Impl:: -acquire() { +lock() { EnterCriticalSection(&_lock); } @@ -31,7 +31,7 @@ acquire() { * */ INLINE bool MutexWin32Impl:: -try_acquire() { +try_lock() { return (TryEnterCriticalSection(&_lock) != 0); } @@ -39,6 +39,6 @@ try_acquire() { * */ INLINE void MutexWin32Impl:: -release() { +unlock() { LeaveCriticalSection(&_lock); } diff --git a/dtool/src/dtoolbase/mutexWin32Impl.h b/dtool/src/dtoolbase/mutexWin32Impl.h index 08fc6eab24..017832694c 100644 --- a/dtool/src/dtoolbase/mutexWin32Impl.h +++ b/dtool/src/dtoolbase/mutexWin32Impl.h @@ -36,9 +36,9 @@ private: MutexWin32Impl &operator = (const MutexWin32Impl ©) DELETED_ASSIGN; public: - INLINE void acquire(); - INLINE bool try_acquire(); - INLINE void release(); + INLINE void lock(); + INLINE bool try_lock(); + INLINE void unlock(); private: CRITICAL_SECTION _lock; diff --git a/dtool/src/dtoolbase/neverFreeMemory.I b/dtool/src/dtoolbase/neverFreeMemory.I index 2156209616..f34bdae28d 100644 --- a/dtool/src/dtoolbase/neverFreeMemory.I +++ b/dtool/src/dtoolbase/neverFreeMemory.I @@ -48,9 +48,9 @@ get_total_used() { INLINE size_t NeverFreeMemory:: get_total_unused() { NeverFreeMemory *global_ptr = get_global_ptr(); - global_ptr->_lock.acquire(); + global_ptr->_lock.lock(); size_t total_unused = global_ptr->_total_alloc - global_ptr->_total_used; - global_ptr->_lock.release(); + global_ptr->_lock.unlock(); return total_unused; } diff --git a/dtool/src/dtoolbase/neverFreeMemory.cxx b/dtool/src/dtoolbase/neverFreeMemory.cxx index fd10b683d8..a1f720cfba 100644 --- a/dtool/src/dtoolbase/neverFreeMemory.cxx +++ b/dtool/src/dtoolbase/neverFreeMemory.cxx @@ -37,7 +37,7 @@ NeverFreeMemory() { */ void *NeverFreeMemory:: ns_alloc(size_t size) { - _lock.acquire(); + _lock.lock(); //NB: we no longer do alignment here. The only class that uses this is // DeletedBufferChain, and we can do the alignment potentially more @@ -55,7 +55,7 @@ ns_alloc(size_t size) { if (page._remaining >= min_page_remaining_size) { _pages.insert(page); } - _lock.release(); + _lock.unlock(); return result; } @@ -71,7 +71,7 @@ ns_alloc(size_t size) { if (page._remaining >= min_page_remaining_size) { _pages.insert(page); } - _lock.release(); + _lock.unlock(); return result; } diff --git a/dtool/src/dtoolbase/typeRegistry.cxx b/dtool/src/dtoolbase/typeRegistry.cxx index 01b8ec498a..7935f3221a 100644 --- a/dtool/src/dtoolbase/typeRegistry.cxx +++ b/dtool/src/dtoolbase/typeRegistry.cxx @@ -32,7 +32,7 @@ TypeRegistry *TypeRegistry::_global_pointer = NULL; */ bool TypeRegistry:: register_type(TypeHandle &type_handle, const string &name) { - _lock->acquire(); + _lock->lock(); if (type_handle != TypeHandle::none()) { // Here's a type that was already registered. Just make sure everything's @@ -40,7 +40,7 @@ register_type(TypeHandle &type_handle, const string &name) { TypeRegistryNode *rnode = look_up(type_handle, NULL); if (&type_handle == &rnode->_ref) { // No problem. - _lock->release(); + _lock->unlock(); assert(rnode->_name == name); return false; } @@ -62,7 +62,7 @@ register_type(TypeHandle &type_handle, const string &name) { _derivations_fresh = false; type_handle = new_handle; - _lock->release(); + _lock->unlock(); return true; } TypeRegistryNode *rnode = (*ri).second; @@ -78,7 +78,7 @@ register_type(TypeHandle &type_handle, const string &name) { if (type_handle == rnode->_handle) { // No problem. - _lock->release(); + _lock->unlock(); return false; } // But wait--the type_handle has changed! We kept a reference to the @@ -87,7 +87,7 @@ register_type(TypeHandle &type_handle, const string &name) { // time, but now it's different! Bad juju. cerr << "Reregistering " << name << "\n"; type_handle = rnode->_handle; - _lock->release(); + _lock->unlock(); return false; } @@ -103,7 +103,7 @@ register_type(TypeHandle &type_handle, const string &name) { type_handle = rnode->_handle; } - _lock->release(); + _lock->unlock(); return false; } @@ -114,7 +114,7 @@ register_type(TypeHandle &type_handle, const string &name) { */ TypeHandle TypeRegistry:: register_dynamic_type(const string &name) { - _lock->acquire(); + _lock->lock(); NameRegistry::iterator ri; ri = _name_registry.find(name); @@ -134,14 +134,14 @@ register_dynamic_type(const string &name) { _name_registry[name] = rnode; _derivations_fresh = false; - _lock->release(); + _lock->unlock(); return *new_handle; } // Return the TypeHandle previously obtained. TypeRegistryNode *rnode = (*ri).second; TypeHandle handle = rnode->_handle; - _lock->release(); + _lock->unlock(); return handle; } @@ -152,7 +152,7 @@ register_dynamic_type(const string &name) { */ void TypeRegistry:: record_derivation(TypeHandle child, TypeHandle parent) { - _lock->acquire(); + _lock->lock(); TypeRegistryNode *cnode = look_up(child, NULL); assert(cnode != (TypeRegistryNode *)NULL); @@ -171,7 +171,7 @@ record_derivation(TypeHandle child, TypeHandle parent) { _derivations_fresh = false; } - _lock->release(); + _lock->unlock(); } /** @@ -182,7 +182,7 @@ record_derivation(TypeHandle child, TypeHandle parent) { */ void TypeRegistry:: record_alternate_name(TypeHandle type, const string &name) { - _lock->acquire(); + _lock->lock(); TypeRegistryNode *rnode = look_up(type, (TypedObject *)NULL); if (rnode != (TypeRegistryNode *)NULL) { @@ -190,7 +190,7 @@ record_alternate_name(TypeHandle type, const string &name) { _name_registry.insert(NameRegistry::value_type(name, rnode)).first; if ((*ri).second != rnode) { - _lock->release(); + _lock->unlock(); cerr << "Name " << name << " already assigned to TypeHandle " << rnode->_name << "; cannot reassign to " << type << "\n"; @@ -199,7 +199,7 @@ record_alternate_name(TypeHandle type, const string &name) { } - _lock->release(); + _lock->unlock(); } /** @@ -208,7 +208,7 @@ record_alternate_name(TypeHandle type, const string &name) { */ TypeHandle TypeRegistry:: find_type(const string &name) const { - _lock->acquire(); + _lock->lock(); TypeHandle handle = TypeHandle::none(); NameRegistry::const_iterator ri; @@ -216,7 +216,7 @@ find_type(const string &name) const { if (ri != _name_registry.end()) { handle = (*ri).second->_handle; } - _lock->release(); + _lock->unlock(); return handle; } @@ -248,11 +248,11 @@ find_type_by_id(int id) const { */ string TypeRegistry:: get_name(TypeHandle type, TypedObject *object) const { - _lock->acquire(); + _lock->lock(); TypeRegistryNode *rnode = look_up(type, object); assert(rnode != (TypeRegistryNode *)NULL); string name = rnode->_name; - _lock->release(); + _lock->unlock(); return name; } @@ -273,7 +273,7 @@ get_name(TypeHandle type, TypedObject *object) const { bool TypeRegistry:: is_derived_from(TypeHandle child, TypeHandle base, TypedObject *child_object) { - _lock->acquire(); + _lock->lock(); const TypeRegistryNode *child_node = look_up(child, child_object); const TypeRegistryNode *base_node = look_up(base, (TypedObject *)NULL); @@ -284,7 +284,7 @@ is_derived_from(TypeHandle child, TypeHandle base, freshen_derivations(); bool result = TypeRegistryNode::is_derived_from(child_node, base_node); - _lock->release(); + _lock->unlock(); return result; } @@ -293,9 +293,9 @@ is_derived_from(TypeHandle child, TypeHandle base, */ int TypeRegistry:: get_num_typehandles() { - _lock->acquire(); + _lock->lock(); int num_types = (int)_handle_registry.size(); - _lock->release(); + _lock->unlock(); return num_types; } @@ -304,12 +304,12 @@ get_num_typehandles() { */ TypeHandle TypeRegistry:: get_typehandle(int n) { - _lock->acquire(); + _lock->lock(); TypeRegistryNode *rnode = NULL; if (n >= 0 && n < (int)_handle_registry.size()) { rnode = _handle_registry[n]; } - _lock->release(); + _lock->unlock(); if (rnode != (TypeRegistryNode *)NULL) { return rnode->_handle; @@ -324,10 +324,10 @@ get_typehandle(int n) { */ int TypeRegistry:: get_num_root_classes() { - _lock->acquire(); + _lock->lock(); freshen_derivations(); int num_roots = (int)_root_classes.size(); - _lock->release(); + _lock->unlock(); return num_roots; } @@ -336,7 +336,7 @@ get_num_root_classes() { */ TypeHandle TypeRegistry:: get_root_class(int n) { - _lock->acquire(); + _lock->lock(); freshen_derivations(); TypeHandle handle; if (n >= 0 && n < (int)_root_classes.size()) { @@ -344,7 +344,7 @@ get_root_class(int n) { } else { handle = TypeHandle::none(); } - _lock->release(); + _lock->unlock(); return handle; } @@ -362,11 +362,11 @@ get_root_class(int n) { */ int TypeRegistry:: get_num_parent_classes(TypeHandle child, TypedObject *child_object) const { - _lock->acquire(); + _lock->lock(); TypeRegistryNode *rnode = look_up(child, child_object); assert(rnode != (TypeRegistryNode *)NULL); int num_parents = (int)rnode->_parent_classes.size(); - _lock->release(); + _lock->unlock(); return num_parents; } @@ -376,7 +376,7 @@ get_num_parent_classes(TypeHandle child, TypedObject *child_object) const { */ TypeHandle TypeRegistry:: get_parent_class(TypeHandle child, int index) const { - _lock->acquire(); + _lock->lock(); TypeHandle handle; TypeRegistryNode *rnode = look_up(child, (TypedObject *)NULL); assert(rnode != (TypeRegistryNode *)NULL); @@ -385,7 +385,7 @@ get_parent_class(TypeHandle child, int index) const { } else { handle = TypeHandle::none(); } - _lock->release(); + _lock->unlock(); return handle; } @@ -399,11 +399,11 @@ get_parent_class(TypeHandle child, int index) const { */ int TypeRegistry:: get_num_child_classes(TypeHandle child, TypedObject *child_object) const { - _lock->acquire(); + _lock->lock(); TypeRegistryNode *rnode = look_up(child, child_object); assert(rnode != (TypeRegistryNode *)NULL); int num_children = (int)rnode->_child_classes.size(); - _lock->release(); + _lock->unlock(); return num_children; } @@ -413,7 +413,7 @@ get_num_child_classes(TypeHandle child, TypedObject *child_object) const { */ TypeHandle TypeRegistry:: get_child_class(TypeHandle child, int index) const { - _lock->acquire(); + _lock->lock(); TypeHandle handle; TypeRegistryNode *rnode = look_up(child, (TypedObject *)NULL); assert(rnode != (TypeRegistryNode *)NULL); @@ -422,7 +422,7 @@ get_child_class(TypeHandle child, int index) const { } else { handle = TypeHandle::none(); } - _lock->release(); + _lock->unlock(); return handle; } @@ -439,7 +439,7 @@ get_child_class(TypeHandle child, int index) const { TypeHandle TypeRegistry:: get_parent_towards(TypeHandle child, TypeHandle base, TypedObject *child_object) { - _lock->acquire(); + _lock->lock(); TypeHandle handle; const TypeRegistryNode *child_node = look_up(child, child_object); const TypeRegistryNode *base_node = look_up(base, NULL); @@ -447,7 +447,7 @@ get_parent_towards(TypeHandle child, TypeHandle base, base_node != (TypeRegistryNode *)NULL); freshen_derivations(); handle = TypeRegistryNode::get_parent_towards(child_node, base_node); - _lock->release(); + _lock->unlock(); return handle; } @@ -462,7 +462,7 @@ get_parent_towards(TypeHandle child, TypeHandle base, void TypeRegistry:: reregister_types() { init_lock(); - _lock->acquire(); + _lock->lock(); HandleRegistry::iterator ri; TypeRegistry *reg = ptr(); for (ri = reg->_handle_registry.begin(); @@ -473,7 +473,7 @@ reregister_types() { cerr << "Reregistering " << rnode->_name << "\n"; } } - _lock->release(); + _lock->unlock(); } @@ -483,9 +483,9 @@ reregister_types() { */ void TypeRegistry:: write(ostream &out) const { - _lock->acquire(); + _lock->lock(); do_write(out); - _lock->release(); + _lock->unlock(); } /** @@ -613,9 +613,9 @@ look_up_invalid(TypeHandle handle, TypedObject *object) const { // But we're lucky enough to have a TypedObject pointer handy! Maybe we // can use it to resolve the error. We have to drop the lock while we // do this, so we don't get a recursive lock. - _lock->release(); + _lock->unlock(); handle = object->force_init_type(); - _lock->acquire(); + _lock->lock(); if (handle._index == 0) { // Strange. diff --git a/dtool/src/prc/configVariableFilename.cxx b/dtool/src/prc/configVariableFilename.cxx index 3939199148..1679082ef5 100644 --- a/dtool/src/prc/configVariableFilename.cxx +++ b/dtool/src/prc/configVariableFilename.cxx @@ -23,7 +23,7 @@ reload_cache() { // thread-safe manner. But chances are that the first time this is called // is at static init time, when there is no risk of data races. static MutexImpl lock; - lock.acquire(); + lock.lock(); // We check again for cache validity since another thread may have beaten // us to the punch while we were waiting for the lock. @@ -42,5 +42,5 @@ reload_cache() { mark_cache_valid(_local_modified); } - lock.release(); + lock.unlock(); } diff --git a/dtool/src/prc/configVariableString.cxx b/dtool/src/prc/configVariableString.cxx index 3dcaaf6deb..ebb4a751d2 100644 --- a/dtool/src/prc/configVariableString.cxx +++ b/dtool/src/prc/configVariableString.cxx @@ -22,7 +22,7 @@ reload_cache() { // thread-safe manner. But chances are that the first time this is called // is at static init time, when there is no risk of data races. static MutexImpl lock; - lock.acquire(); + lock.lock(); // We check again for cache validity since another thread may have beaten // us to the punch while we were waiting for the lock. @@ -31,5 +31,5 @@ reload_cache() { mark_cache_valid(_local_modified); } - lock.release(); + lock.unlock(); } diff --git a/dtool/src/prc/streamWrapper.I b/dtool/src/prc/streamWrapper.I index 788498aceb..a6438e318e 100644 --- a/dtool/src/prc/streamWrapper.I +++ b/dtool/src/prc/streamWrapper.I @@ -36,7 +36,7 @@ StreamWrapperBase() { */ INLINE void StreamWrapperBase:: acquire() { - _lock.acquire(); + _lock.lock(); #ifdef SIMPLE_THREADS while (_lock_flag) { thread_yield(); @@ -55,7 +55,7 @@ release() { assert(_lock_flag); _lock_flag = false; #endif - _lock.release(); + _lock.unlock(); } /** diff --git a/panda/src/downloader/multiplexStreamBuf.cxx b/panda/src/downloader/multiplexStreamBuf.cxx index 96d4a22755..783558f587 100644 --- a/panda/src/downloader/multiplexStreamBuf.cxx +++ b/panda/src/downloader/multiplexStreamBuf.cxx @@ -122,9 +122,9 @@ add_output(MultiplexStreamBuf::BufferType buffer_type, o._owns_obj = owns_obj; // Ensure that we have the mutex while we fiddle with the list of outputs. - _lock.acquire(); + _lock.lock(); _outputs.push_back(o); - _lock.release(); + _lock.unlock(); } @@ -133,9 +133,9 @@ add_output(MultiplexStreamBuf::BufferType buffer_type, */ void MultiplexStreamBuf:: flush() { - _lock.acquire(); + _lock.lock(); write_chars("", 0, true); - _lock.release(); + _lock.unlock(); } /** @@ -144,7 +144,7 @@ flush() { */ int MultiplexStreamBuf:: overflow(int ch) { - _lock.acquire(); + _lock.lock(); streamsize n = pptr() - pbase(); @@ -159,7 +159,7 @@ overflow(int ch) { write_chars(&c, 1, false); } - _lock.release(); + _lock.unlock(); return 0; } @@ -169,7 +169,7 @@ overflow(int ch) { */ int MultiplexStreamBuf:: sync() { - _lock.acquire(); + _lock.lock(); streamsize n = pptr() - pbase(); @@ -181,7 +181,7 @@ sync() { write_chars(pbase(), n, false); pbump(-n); - _lock.release(); + _lock.unlock(); return 0; // Return 0 for success, EOF to indicate write full. } diff --git a/panda/src/downloader/virtualFileMountHTTP.cxx b/panda/src/downloader/virtualFileMountHTTP.cxx index 78b06a2f44..9ad783da87 100644 --- a/panda/src/downloader/virtualFileMountHTTP.cxx +++ b/panda/src/downloader/virtualFileMountHTTP.cxx @@ -238,7 +238,7 @@ output(ostream &out) const { PT(HTTPChannel) VirtualFileMountHTTP:: get_channel() { PT(HTTPChannel) channel; - _channels_lock.acquire(); + _channels_lock.lock(); if (!_channels.empty()) { // If we have some channels sitting around, grab one. Grab the one on the @@ -251,7 +251,7 @@ get_channel() { channel = _http->make_channel(true); } - _channels_lock.release(); + _channels_lock.unlock(); return channel; } @@ -262,9 +262,9 @@ get_channel() { */ void VirtualFileMountHTTP:: recycle_channel(HTTPChannel *channel) { - _channels_lock.acquire(); + _channels_lock.lock(); _channels.push_back(channel); - _channels_lock.release(); + _channels_lock.unlock(); } #endif // HAVE_OPENSSL diff --git a/panda/src/event/asyncFuture.cxx b/panda/src/event/asyncFuture.cxx index 25ae6bfa1c..d97173d54d 100644 --- a/panda/src/event/asyncFuture.cxx +++ b/panda/src/event/asyncFuture.cxx @@ -273,9 +273,9 @@ wake_task(AsyncTask *task) { } { - manager->_lock.release(); + manager->_lock.unlock(); task->upon_birth(manager); - manager->_lock.acquire(); + manager->_lock.lock(); nassertv(task->_manager == nullptr && task->_state == AsyncTask::S_inactive); diff --git a/panda/src/event/asyncTask.cxx b/panda/src/event/asyncTask.cxx index 9f70f0e5ad..95b4e5aad1 100644 --- a/panda/src/event/asyncTask.cxx +++ b/panda/src/event/asyncTask.cxx @@ -415,7 +415,7 @@ unlock_and_do_task() { #endif // __GNUC__ // It's important to release the lock while the task is being serviced. - _manager->_lock.release(); + _manager->_lock.unlock(); double start = clock->get_real_time(); _task_pcollector.start(); @@ -424,7 +424,7 @@ unlock_and_do_task() { double end = clock->get_real_time(); // Now reacquire the lock (so we can return with the lock held). - _manager->_lock.acquire(); + _manager->_lock.lock(); _dt = end - start; _max_dt = max(_dt, _max_dt); diff --git a/panda/src/event/asyncTaskChain.cxx b/panda/src/event/asyncTaskChain.cxx index bb82e00f92..1d131d62df 100644 --- a/panda/src/event/asyncTaskChain.cxx +++ b/panda/src/event/asyncTaskChain.cxx @@ -596,11 +596,11 @@ do_cleanup() { nassertv(_num_tasks == 0 || _num_tasks == 1); // Now go back and call the upon_death functions. - _manager->_lock.release(); + _manager->_lock.unlock(); for (ti = dead.begin(); ti != dead.end(); ++ti) { (*ti)->upon_death(_manager, false); } - _manager->_lock.acquire(); + _manager->_lock.lock(); if (task_cat.is_spam()) { do_output(task_cat.spam()); @@ -791,9 +791,9 @@ cleanup_task(AsyncTask *task, bool upon_death, bool clean_exit) { task->_manager = nullptr; if (upon_death) { - _manager->_lock.release(); + _manager->_lock.unlock(); task->upon_death(_manager, clean_exit); - _manager->_lock.acquire(); + _manager->_lock.lock(); } } @@ -1031,7 +1031,7 @@ do_stop_threads() { // We have to release the lock while we join, so the threads can wake up // and see that we're shutting down. - _manager->_lock.release(); + _manager->_lock.unlock(); Threads::iterator ti; for (ti = wait_threads.begin(); ti != wait_threads.end(); ++ti) { if (task_cat.is_debug()) { @@ -1046,7 +1046,7 @@ do_stop_threads() { << *Thread::get_current_thread() << "\n"; } } - _manager->_lock.acquire(); + _manager->_lock.lock(); _state = S_initial; diff --git a/panda/src/event/asyncTaskManager.cxx b/panda/src/event/asyncTaskManager.cxx index 5e1bf9601c..c19c194e60 100644 --- a/panda/src/event/asyncTaskManager.cxx +++ b/panda/src/event/asyncTaskManager.cxx @@ -200,9 +200,9 @@ add(AsyncTask *task) { task->_state == AsyncTask::S_inactive); nassertv(!do_has_task(task)); - _lock.release(); + _lock.unlock(); task->upon_birth(this); - _lock.acquire(); + _lock.lock(); nassertv(task->_manager == NULL && task->_state == AsyncTask::S_inactive); nassertv(!do_has_task(task)); diff --git a/panda/src/express/trueClock.I b/panda/src/express/trueClock.I index da51e8628f..e9bc56aed4 100644 --- a/panda/src/express/trueClock.I +++ b/panda/src/express/trueClock.I @@ -21,7 +21,7 @@ get_short_time() { bool is_paranoid_clock = get_paranoid_clock(); if (is_paranoid_clock) { - _lock.acquire(); + _lock.lock(); } double time = get_short_raw_time(); @@ -30,7 +30,7 @@ get_short_time() { // Check for rollforwards, rollbacks, and compensate for Speed Gear type // programs by verifying against the time of day clock. time = correct_time(time); - _lock.release(); + _lock.unlock(); } return time; diff --git a/panda/src/express/virtualFileMountRamdisk.cxx b/panda/src/express/virtualFileMountRamdisk.cxx index 244f5c79df..78652e9cc3 100644 --- a/panda/src/express/virtualFileMountRamdisk.cxx +++ b/panda/src/express/virtualFileMountRamdisk.cxx @@ -32,9 +32,9 @@ VirtualFileMountRamdisk() : _root("") { */ bool VirtualFileMountRamdisk:: has_file(const Filename &file) const { - _lock.acquire(); + _lock.lock(); PT(FileBase) f = _root.do_find_file(file); - _lock.release(); + _lock.unlock(); return (f != NULL); } @@ -45,9 +45,9 @@ has_file(const Filename &file) const { */ bool VirtualFileMountRamdisk:: create_file(const Filename &file) { - _lock.acquire(); + _lock.lock(); PT(File) f = _root.do_create_file(file); - _lock.release(); + _lock.unlock(); return (f != NULL); } @@ -58,9 +58,9 @@ create_file(const Filename &file) { */ bool VirtualFileMountRamdisk:: delete_file(const Filename &file) { - _lock.acquire(); + _lock.lock(); PT(FileBase) f = _root.do_delete_file(file); - _lock.release(); + _lock.unlock(); return (f != NULL); } @@ -72,10 +72,10 @@ delete_file(const Filename &file) { */ bool VirtualFileMountRamdisk:: rename_file(const Filename &orig_filename, const Filename &new_filename) { - _lock.acquire(); + _lock.lock(); PT(FileBase) orig_fb = _root.do_find_file(orig_filename); if (orig_fb == NULL) { - _lock.release(); + _lock.unlock(); return false; } @@ -84,7 +84,7 @@ rename_file(const Filename &orig_filename, const Filename &new_filename) { Directory *orig_d = DCAST(Directory, orig_fb); PT(Directory) new_d = _root.do_make_directory(new_filename); if (new_d == NULL || !new_d->_files.empty()) { - _lock.release(); + _lock.unlock(); return false; } @@ -95,7 +95,7 @@ rename_file(const Filename &orig_filename, const Filename &new_filename) { new_d->_files.swap(orig_d->_files); _root.do_delete_file(orig_filename); - _lock.release(); + _lock.unlock(); return true; } @@ -103,7 +103,7 @@ rename_file(const Filename &orig_filename, const Filename &new_filename) { File *orig_f = DCAST(File, orig_fb); PT(File) new_f = _root.do_create_file(new_filename); if (new_f == NULL) { - _lock.release(); + _lock.unlock(); return false; } @@ -115,7 +115,7 @@ rename_file(const Filename &orig_filename, const Filename &new_filename) { new_f->_data.str(orig_f->_data.str()); _root.do_delete_file(orig_filename); - _lock.release(); + _lock.unlock(); return true; } @@ -127,10 +127,10 @@ rename_file(const Filename &orig_filename, const Filename &new_filename) { */ bool VirtualFileMountRamdisk:: copy_file(const Filename &orig_filename, const Filename &new_filename) { - _lock.acquire(); + _lock.lock(); PT(FileBase) orig_fb = _root.do_find_file(orig_filename); if (orig_fb == NULL || orig_fb->is_directory()) { - _lock.release(); + _lock.unlock(); return false; } @@ -138,7 +138,7 @@ copy_file(const Filename &orig_filename, const Filename &new_filename) { File *orig_f = DCAST(File, orig_fb); PT(File) new_f = _root.do_create_file(new_filename); if (new_f == NULL) { - _lock.release(); + _lock.unlock(); return false; } @@ -149,7 +149,7 @@ copy_file(const Filename &orig_filename, const Filename &new_filename) { new_f->_data.str(orig_f->_data.str()); - _lock.release(); + _lock.unlock(); return true; } @@ -161,9 +161,9 @@ copy_file(const Filename &orig_filename, const Filename &new_filename) { */ bool VirtualFileMountRamdisk:: make_directory(const Filename &file) { - _lock.acquire(); + _lock.lock(); PT(Directory) f = _root.do_make_directory(file); - _lock.release(); + _lock.unlock(); return (f != NULL); } @@ -173,9 +173,9 @@ make_directory(const Filename &file) { */ bool VirtualFileMountRamdisk:: is_directory(const Filename &file) const { - _lock.acquire(); + _lock.lock(); PT(FileBase) f = _root.do_find_file(file); - _lock.release(); + _lock.unlock(); return (f != NULL && f->is_directory()); } @@ -185,9 +185,9 @@ is_directory(const Filename &file) const { */ bool VirtualFileMountRamdisk:: is_regular_file(const Filename &file) const { - _lock.acquire(); + _lock.lock(); PT(FileBase) f = _root.do_find_file(file); - _lock.release(); + _lock.unlock(); return (f != NULL && !f->is_directory()); } @@ -207,9 +207,9 @@ is_writable(const Filename &file) const { */ istream *VirtualFileMountRamdisk:: open_read_file(const Filename &file) const { - _lock.acquire(); + _lock.lock(); PT(FileBase) f = _root.do_find_file(file); - _lock.release(); + _lock.unlock(); if (f == (FileBase *)NULL || f->is_directory()) { return NULL; } @@ -225,9 +225,9 @@ open_read_file(const Filename &file) const { */ ostream *VirtualFileMountRamdisk:: open_write_file(const Filename &file, bool truncate) { - _lock.acquire(); + _lock.lock(); PT(File) f = _root.do_create_file(file); - _lock.release(); + _lock.unlock(); if (f == (File *)NULL) { return NULL; } @@ -254,9 +254,9 @@ open_write_file(const Filename &file, bool truncate) { */ ostream *VirtualFileMountRamdisk:: open_append_file(const Filename &file) { - _lock.acquire(); + _lock.lock(); PT(File) f = _root.do_create_file(file); - _lock.release(); + _lock.unlock(); if (f == (File *)NULL) { return NULL; } @@ -271,9 +271,9 @@ open_append_file(const Filename &file) { */ iostream *VirtualFileMountRamdisk:: open_read_write_file(const Filename &file, bool truncate) { - _lock.acquire(); + _lock.lock(); PT(File) f = _root.do_create_file(file); - _lock.release(); + _lock.unlock(); if (f == (File *)NULL) { return NULL; } @@ -296,9 +296,9 @@ open_read_write_file(const Filename &file, bool truncate) { */ iostream *VirtualFileMountRamdisk:: open_read_append_file(const Filename &file) { - _lock.acquire(); + _lock.lock(); PT(FileBase) f = _root.do_find_file(file); - _lock.release(); + _lock.unlock(); if (f == (FileBase *)NULL || f->is_directory()) { return NULL; } @@ -314,9 +314,9 @@ open_read_append_file(const Filename &file) { */ streamsize VirtualFileMountRamdisk:: get_file_size(const Filename &file, istream *stream) const { - _lock.acquire(); + _lock.lock(); PT(FileBase) f = _root.do_find_file(file); - _lock.release(); + _lock.unlock(); if (f == (FileBase *)NULL || f->is_directory()) { return 0; } @@ -331,9 +331,9 @@ get_file_size(const Filename &file, istream *stream) const { */ streamsize VirtualFileMountRamdisk:: get_file_size(const Filename &file) const { - _lock.acquire(); + _lock.lock(); PT(FileBase) f = _root.do_find_file(file); - _lock.release(); + _lock.unlock(); if (f == (FileBase *)NULL || f->is_directory()) { return 0; } @@ -354,14 +354,14 @@ get_file_size(const Filename &file) const { */ time_t VirtualFileMountRamdisk:: get_timestamp(const Filename &file) const { - _lock.acquire(); + _lock.lock(); PT(FileBase) f = _root.do_find_file(file); if (f.is_null()) { - _lock.release(); + _lock.unlock(); return 0; } time_t timestamp = f->_timestamp; - _lock.release(); + _lock.unlock(); return timestamp; } @@ -372,17 +372,17 @@ get_timestamp(const Filename &file) const { */ bool VirtualFileMountRamdisk:: scan_directory(vector_string &contents, const Filename &dir) const { - _lock.acquire(); + _lock.lock(); PT(FileBase) f = _root.do_find_file(dir); if (f == (FileBase *)NULL || !f->is_directory()) { - _lock.release(); + _lock.unlock(); return false; } Directory *f2 = DCAST(Directory, f); bool result = f2->do_scan_directory(contents); - _lock.release(); + _lock.unlock(); return result; } @@ -393,10 +393,10 @@ bool VirtualFileMountRamdisk:: atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents, const string &old_contents, const string &new_contents) { - _lock.acquire(); + _lock.lock(); PT(FileBase) f = _root.do_find_file(file); if (f == (FileBase *)NULL || f->is_directory()) { - _lock.release(); + _lock.unlock(); return false; } @@ -409,7 +409,7 @@ atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents retval = true; } - _lock.release(); + _lock.unlock(); return retval; } @@ -418,17 +418,17 @@ atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents */ bool VirtualFileMountRamdisk:: atomic_read_contents(const Filename &file, string &contents) const { - _lock.acquire(); + _lock.lock(); PT(FileBase) f = _root.do_find_file(file); if (f == (FileBase *)NULL || f->is_directory()) { - _lock.release(); + _lock.unlock(); return false; } File *f2 = DCAST(File, f); contents = f2->_data.str(); - _lock.release(); + _lock.unlock(); return true; } diff --git a/panda/src/express/virtualFileSystem.cxx b/panda/src/express/virtualFileSystem.cxx index da7797ec9d..d69f518bc1 100644 --- a/panda/src/express/virtualFileSystem.cxx +++ b/panda/src/express/virtualFileSystem.cxx @@ -190,9 +190,9 @@ mount(VirtualFileMount *mount, const Filename &mount_point, int flags) { << "mount " << *mount << " under " << mount_point << "\n"; } - _lock.acquire(); + _lock.lock(); bool result = do_mount(mount, mount_point, flags); - _lock.release(); + _lock.unlock(); return result; } @@ -202,7 +202,7 @@ mount(VirtualFileMount *mount, const Filename &mount_point, int flags) { */ int VirtualFileSystem:: unmount(Multifile *multifile) { - _lock.acquire(); + _lock.lock(); Mounts::iterator ri, wi; wi = ri = _mounts.begin(); while (ri != _mounts.end()) { @@ -234,7 +234,7 @@ unmount(Multifile *multifile) { int num_removed = _mounts.end() - wi; _mounts.erase(wi, _mounts.end()); ++_mount_seq; - _lock.release(); + _lock.unlock(); return num_removed; } @@ -244,7 +244,7 @@ unmount(Multifile *multifile) { */ int VirtualFileSystem:: unmount(const Filename &physical_filename) { - _lock.acquire(); + _lock.lock(); Mounts::iterator ri, wi; wi = ri = _mounts.begin(); while (ri != _mounts.end()) { @@ -293,7 +293,7 @@ unmount(const Filename &physical_filename) { int num_removed = _mounts.end() - wi; _mounts.erase(wi, _mounts.end()); ++_mount_seq; - _lock.release(); + _lock.unlock(); return num_removed; } @@ -303,7 +303,7 @@ unmount(const Filename &physical_filename) { */ int VirtualFileSystem:: unmount(VirtualFileMount *mount) { - _lock.acquire(); + _lock.lock(); Mounts::iterator ri, wi; wi = ri = _mounts.begin(); while (ri != _mounts.end()) { @@ -326,7 +326,7 @@ unmount(VirtualFileMount *mount) { int num_removed = _mounts.end() - wi; _mounts.erase(wi, _mounts.end()); ++_mount_seq; - _lock.release(); + _lock.unlock(); return num_removed; } @@ -336,7 +336,7 @@ unmount(VirtualFileMount *mount) { */ int VirtualFileSystem:: unmount_point(const Filename &mount_point) { - _lock.acquire(); + _lock.lock(); Filename nmp = normalize_mount_point(mount_point); Mounts::iterator ri, wi; wi = ri = _mounts.begin(); @@ -362,7 +362,7 @@ unmount_point(const Filename &mount_point) { int num_removed = _mounts.end() - wi; _mounts.erase(wi, _mounts.end()); ++_mount_seq; - _lock.release(); + _lock.unlock(); return num_removed; } @@ -372,7 +372,7 @@ unmount_point(const Filename &mount_point) { */ int VirtualFileSystem:: unmount_all() { - _lock.acquire(); + _lock.lock(); Mounts::iterator ri; for (ri = _mounts.begin(); ri != _mounts.end(); ++ri) { VirtualFileMount *mount = (*ri); @@ -386,7 +386,7 @@ unmount_all() { int num_removed = _mounts.size(); _mounts.clear(); ++_mount_seq; - _lock.release(); + _lock.unlock(); return num_removed; } @@ -395,9 +395,9 @@ unmount_all() { */ int VirtualFileSystem:: get_num_mounts() const { - ((VirtualFileSystem *)this)->_lock.acquire(); + _lock.lock(); int result = _mounts.size(); - ((VirtualFileSystem *)this)->_lock.release(); + _lock.unlock(); return result; } @@ -406,13 +406,13 @@ get_num_mounts() const { */ PT(VirtualFileMount) VirtualFileSystem:: get_mount(int n) const { - ((VirtualFileSystem *)this)->_lock.acquire(); + _lock.lock(); nassertd(n >= 0 && n < (int)_mounts.size()) { - ((VirtualFileSystem *)this)->_lock.release(); + _lock.unlock(); return NULL; } PT(VirtualFileMount) result = _mounts[n]; - ((VirtualFileSystem *)this)->_lock.release(); + _lock.unlock(); return result; } @@ -423,21 +423,21 @@ get_mount(int n) const { */ bool VirtualFileSystem:: chdir(const Filename &new_directory) { - _lock.acquire(); + _lock.lock(); if (new_directory == "/") { // We can always return to the root. _cwd = new_directory; - _lock.release(); + _lock.unlock(); return true; } PT(VirtualFile) file = do_get_file(new_directory, OF_status_only); if (file != (VirtualFile *)NULL && file->is_directory()) { _cwd = file->get_filename(); - _lock.release(); + _lock.unlock(); return true; } - _lock.release(); + _lock.unlock(); return false; } @@ -446,9 +446,9 @@ chdir(const Filename &new_directory) { */ Filename VirtualFileSystem:: get_cwd() const { - ((VirtualFileSystem *)this)->_lock.acquire(); + _lock.lock(); Filename result = _cwd; - ((VirtualFileSystem *)this)->_lock.release(); + _lock.unlock(); return result; } @@ -460,9 +460,9 @@ get_cwd() const { */ bool VirtualFileSystem:: make_directory(const Filename &filename) { - _lock.acquire(); + _lock.lock(); PT(VirtualFile) result = do_get_file(filename, OF_make_directory); - _lock.release(); + _lock.unlock(); nassertr_always(result != NULL, false); return result->is_directory(); } @@ -474,7 +474,7 @@ make_directory(const Filename &filename) { */ bool VirtualFileSystem:: make_directory_full(const Filename &filename) { - _lock.acquire(); + _lock.lock(); // First, make sure everything up to the last path is known. We don't care // too much if any of these fail; maybe they failed because the directory @@ -489,7 +489,7 @@ make_directory_full(const Filename &filename) { // Now make the last one, and check the return value. PT(VirtualFile) result = do_get_file(filename, OF_make_directory); - _lock.release(); + _lock.unlock(); nassertr_always(result != NULL, false); return result->is_directory(); } @@ -508,9 +508,9 @@ make_directory_full(const Filename &filename) { PT(VirtualFile) VirtualFileSystem:: get_file(const Filename &filename, bool status_only) const { int open_flags = status_only ? OF_status_only : 0; - ((VirtualFileSystem *)this)->_lock.acquire(); + _lock.lock(); PT(VirtualFile) result = do_get_file(filename, open_flags); - ((VirtualFileSystem *)this)->_lock.release(); + _lock.unlock(); return result; } @@ -522,9 +522,9 @@ get_file(const Filename &filename, bool status_only) const { */ PT(VirtualFile) VirtualFileSystem:: create_file(const Filename &filename) { - ((VirtualFileSystem *)this)->_lock.acquire(); + _lock.lock(); PT(VirtualFile) result = do_get_file(filename, OF_create_file); - ((VirtualFileSystem *)this)->_lock.release(); + _lock.unlock(); return result; } @@ -588,20 +588,20 @@ delete_file(const Filename &filename) { */ bool VirtualFileSystem:: rename_file(const Filename &orig_filename, const Filename &new_filename) { - _lock.acquire(); + _lock.lock(); PT(VirtualFile) orig_file = do_get_file(orig_filename, OF_status_only); if (orig_file == (VirtualFile *)NULL) { - _lock.release(); + _lock.unlock(); return false; } PT(VirtualFile) new_file = do_get_file(new_filename, OF_status_only | OF_allow_nonexist); if (new_file == (VirtualFile *)NULL) { - _lock.release(); + _lock.unlock(); return false; } - _lock.release(); + _lock.unlock(); return orig_file->rename_file(new_file); } @@ -712,13 +712,13 @@ find_all_files(const Filename &filename, const DSearchPath &searchpath, */ void VirtualFileSystem:: write(ostream &out) const { - ((VirtualFileSystem *)this)->_lock.acquire(); + _lock.lock(); Mounts::const_iterator mi; for (mi = _mounts.begin(); mi != _mounts.end(); ++mi) { VirtualFileMount *mount = (*mi); mount->write(out); } - ((VirtualFileSystem *)this)->_lock.release(); + _lock.unlock(); } diff --git a/panda/src/express/virtualFileSystem.h b/panda/src/express/virtualFileSystem.h index 2ff1fa4e95..e1d7e6fd37 100644 --- a/panda/src/express/virtualFileSystem.h +++ b/panda/src/express/virtualFileSystem.h @@ -157,7 +157,7 @@ private: int open_flags) const; bool consider_mount_mf(const Filename &filename); - MutexImpl _lock; + mutable MutexImpl _lock; typedef pvector Mounts; Mounts _mounts; unsigned int _mount_seq; diff --git a/panda/src/express/weakPointerTo.I b/panda/src/express/weakPointerTo.I index 9061affcad..09dba7640b 100644 --- a/panda/src/express/weakPointerTo.I +++ b/panda/src/express/weakPointerTo.I @@ -82,11 +82,11 @@ lock() const { WeakReferenceList *weak_ref = this->_weak_ref; if (weak_ref != nullptr) { PointerTo ptr; - weak_ref->_lock.acquire(); + weak_ref->_lock.lock(); if (!weak_ref->was_deleted()) { ptr = (To *)WeakPointerToBase::_void_ptr; } - weak_ref->_lock.release(); + weak_ref->_lock.unlock(); return ptr; } return nullptr; @@ -237,11 +237,11 @@ lock() const { WeakReferenceList *weak_ref = this->_weak_ref; if (weak_ref != nullptr) { ConstPointerTo ptr; - weak_ref->_lock.acquire(); + weak_ref->_lock.lock(); if (!weak_ref->was_deleted()) { ptr = (const To *)WeakPointerToBase::_void_ptr; } - weak_ref->_lock.release(); + weak_ref->_lock.unlock(); return ptr; } return nullptr; diff --git a/panda/src/express/weakReferenceList.cxx b/panda/src/express/weakReferenceList.cxx index af7755a26e..f9e92d6009 100644 --- a/panda/src/express/weakReferenceList.cxx +++ b/panda/src/express/weakReferenceList.cxx @@ -41,7 +41,7 @@ WeakReferenceList:: void WeakReferenceList:: add_callback(WeakPointerCallback *callback, void *data) { nassertv(callback != nullptr); - _lock.acquire(); + _lock.lock(); // We need to check again whether the object is deleted after grabbing the // lock, despite having already done this in weakPointerTo.I, since it may // have been deleted in the meantime. @@ -49,7 +49,7 @@ add_callback(WeakPointerCallback *callback, void *data) { if (!deleted) { _callbacks.insert(make_pair(callback, data)); } - _lock.release(); + _lock.unlock(); if (deleted) { callback->wp_callback(data); @@ -65,9 +65,9 @@ add_callback(WeakPointerCallback *callback, void *data) { void WeakReferenceList:: remove_callback(WeakPointerCallback *callback) { nassertv(callback != nullptr); - _lock.acquire(); + _lock.lock(); _callbacks.erase(callback); - _lock.release(); + _lock.unlock(); } /** @@ -76,7 +76,7 @@ remove_callback(WeakPointerCallback *callback) { */ void WeakReferenceList:: mark_deleted() { - _lock.acquire(); + _lock.lock(); Callbacks::iterator ci; for (ci = _callbacks.begin(); ci != _callbacks.end(); ++ci) { (*ci).first->wp_callback((*ci).second); @@ -86,7 +86,7 @@ mark_deleted() { // Decrement the special offset added to the weak pointer count to indicate // that it can be deleted when all the weak references have gone. AtomicAdjust::Integer result = AtomicAdjust::add(_count, -_alive_offset); - _lock.release(); + _lock.unlock(); if (result == 0) { // There are no weak references remaining either, so delete this. delete this; diff --git a/panda/src/gobj/adaptiveLru.cxx b/panda/src/gobj/adaptiveLru.cxx index a74fcfcb0d..eb2d945177 100644 --- a/panda/src/gobj/adaptiveLru.cxx +++ b/panda/src/gobj/adaptiveLru.cxx @@ -360,9 +360,9 @@ do_evict_to(size_t target_size, bool hard_evict) { } else { // We must release the lock while we call evict_lru(). - _lock.release(); + _lock.unlock(); page->evict_lru(); - _lock.acquire(); + _lock.lock(); if (_total_size <= target_size) { // We've evicted enough to satisfy our target. diff --git a/panda/src/gobj/simpleLru.cxx b/panda/src/gobj/simpleLru.cxx index 97e979df63..8531c321bc 100644 --- a/panda/src/gobj/simpleLru.cxx +++ b/panda/src/gobj/simpleLru.cxx @@ -169,9 +169,9 @@ do_evict_to(size_t target_size, bool hard_evict) { SimpleLruPage *next = (SimpleLruPage *)node->_next; // We must release the lock while we call evict_lru(). - _global_lock.release(); + _global_lock.unlock(); node->evict_lru(); - _global_lock.acquire(); + _global_lock.lock(); if (node == end || node == _prev) { // If we reach the original tail of the list, stop. diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index fa85fd44f0..d751405a66 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -5239,14 +5239,14 @@ unlocked_ensure_ram_image(bool allow_compression) { PT(Texture) tex = do_make_copy(cdata); _cycler.release_read(cdata); - _lock.release(); + _lock.unlock(); // Perform the actual reload in a copy of the texture, while our own mutex // is left unlocked. CDWriter cdata_tex(tex->_cycler, true); tex->do_reload_ram_image(cdata_tex, allow_compression); - _lock.acquire(); + _lock.lock(); CData *cdataw = _cycler.write_upstream(false, current_thread); diff --git a/panda/src/pipeline/conditionVarDebug.cxx b/panda/src/pipeline/conditionVarDebug.cxx index d8c838196e..0cc738542f 100644 --- a/panda/src/pipeline/conditionVarDebug.cxx +++ b/panda/src/pipeline/conditionVarDebug.cxx @@ -57,7 +57,7 @@ ConditionVarDebug:: */ void ConditionVarDebug:: wait() { - _mutex._global_lock->acquire(); + _mutex._global_lock->lock(); Thread *current_thread = Thread::get_current_thread(); @@ -66,7 +66,7 @@ wait() { ostr << *current_thread << " attempted to wait on " << *this << " without holding " << _mutex; nassert_raise(ostr.str()); - _mutex._global_lock->release(); + _mutex._global_lock->unlock(); return; } @@ -80,9 +80,9 @@ wait() { } current_thread->_waiting_on_cvar = this; - _mutex.do_release(); + _mutex.do_unlock(); _impl.wait(); // temporarily releases _global_lock - _mutex.do_acquire(current_thread); + _mutex.do_lock(current_thread); nassertd(current_thread->_waiting_on_cvar == this) { } @@ -93,7 +93,7 @@ wait() { << *current_thread << " awake on " << *this << "\n"; } - _mutex._global_lock->release(); + _mutex._global_lock->unlock(); } /** @@ -106,7 +106,7 @@ wait() { */ void ConditionVarDebug:: wait(double timeout) { - _mutex._global_lock->acquire(); + _mutex._global_lock->lock(); Thread *current_thread = Thread::get_current_thread(); @@ -115,7 +115,7 @@ wait(double timeout) { ostr << *current_thread << " attempted to wait on " << *this << " without holding " << _mutex; nassert_raise(ostr.str()); - _mutex._global_lock->release(); + _mutex._global_lock->unlock(); return; } @@ -130,9 +130,9 @@ wait(double timeout) { } current_thread->_waiting_on_cvar = this; - _mutex.do_release(); + _mutex.do_unlock(); _impl.wait(timeout); // temporarily releases _global_lock - _mutex.do_acquire(current_thread); + _mutex.do_lock(current_thread); nassertd(current_thread->_waiting_on_cvar == this) { } @@ -143,7 +143,7 @@ wait(double timeout) { << *current_thread << " awake on " << *this << "\n"; } - _mutex._global_lock->release(); + _mutex._global_lock->unlock(); } /** @@ -160,7 +160,7 @@ wait(double timeout) { */ void ConditionVarDebug:: notify() { - _mutex._global_lock->acquire(); + _mutex._global_lock->lock(); Thread *current_thread = Thread::get_current_thread(); @@ -169,7 +169,7 @@ notify() { ostr << *current_thread << " attempted to notify " << *this << " without holding " << _mutex; nassert_raise(ostr.str()); - _mutex._global_lock->release(); + _mutex._global_lock->unlock(); return; } @@ -179,7 +179,7 @@ notify() { } _impl.notify(); - _mutex._global_lock->release(); + _mutex._global_lock->unlock(); } /** diff --git a/panda/src/pipeline/conditionVarFullDebug.cxx b/panda/src/pipeline/conditionVarFullDebug.cxx index 4c76b513d0..8f59702a3f 100644 --- a/panda/src/pipeline/conditionVarFullDebug.cxx +++ b/panda/src/pipeline/conditionVarFullDebug.cxx @@ -57,7 +57,7 @@ ConditionVarFullDebug:: */ void ConditionVarFullDebug:: wait() { - _mutex._global_lock->acquire(); + _mutex._global_lock->lock(); Thread *current_thread = Thread::get_current_thread(); @@ -66,7 +66,7 @@ wait() { ostr << *current_thread << " attempted to wait on " << *this << " without holding " << _mutex; nassert_raise(ostr.str()); - _mutex._global_lock->release(); + _mutex._global_lock->unlock(); return; } @@ -80,9 +80,9 @@ wait() { } current_thread->_waiting_on_cvar_full = this; - _mutex.do_release(); + _mutex.do_unlock(); _impl.wait(); // temporarily releases _global_lock - _mutex.do_acquire(current_thread); + _mutex.do_lock(current_thread); nassertd(current_thread->_waiting_on_cvar_full == this) { } @@ -93,7 +93,7 @@ wait() { << *current_thread << " awake on " << *this << "\n"; } - _mutex._global_lock->release(); + _mutex._global_lock->unlock(); } /** @@ -106,7 +106,7 @@ wait() { */ void ConditionVarFullDebug:: wait(double timeout) { - _mutex._global_lock->acquire(); + _mutex._global_lock->lock(); Thread *current_thread = Thread::get_current_thread(); @@ -115,7 +115,7 @@ wait(double timeout) { ostr << *current_thread << " attempted to wait on " << *this << " without holding " << _mutex; nassert_raise(ostr.str()); - _mutex._global_lock->release(); + _mutex._global_lock->unlock(); return; } @@ -130,9 +130,9 @@ wait(double timeout) { } current_thread->_waiting_on_cvar_full = this; - _mutex.do_release(); + _mutex.do_unlock(); _impl.wait(timeout); // temporarily releases _global_lock - _mutex.do_acquire(current_thread); + _mutex.do_lock(current_thread); nassertd(current_thread->_waiting_on_cvar_full == this) { } @@ -143,7 +143,7 @@ wait(double timeout) { << *current_thread << " awake on " << *this << "\n"; } - _mutex._global_lock->release(); + _mutex._global_lock->unlock(); } /** @@ -160,7 +160,7 @@ wait(double timeout) { */ void ConditionVarFullDebug:: notify() { - _mutex._global_lock->acquire(); + _mutex._global_lock->lock(); Thread *current_thread = Thread::get_current_thread(); @@ -169,7 +169,7 @@ notify() { ostr << *current_thread << " attempted to notify " << *this << " without holding " << _mutex; nassert_raise(ostr.str()); - _mutex._global_lock->release(); + _mutex._global_lock->unlock(); return; } @@ -179,7 +179,7 @@ notify() { } _impl.notify(); - _mutex._global_lock->release(); + _mutex._global_lock->unlock(); } /** @@ -193,7 +193,7 @@ notify() { */ void ConditionVarFullDebug:: notify_all() { - _mutex._global_lock->acquire(); + _mutex._global_lock->lock(); Thread *current_thread = Thread::get_current_thread(); @@ -202,7 +202,7 @@ notify_all() { ostr << *current_thread << " attempted to notify " << *this << " without holding " << _mutex; nassert_raise(ostr.str()); - _mutex._global_lock->release(); + _mutex._global_lock->unlock(); return; } @@ -212,7 +212,7 @@ notify_all() { } _impl.notify_all(); - _mutex._global_lock->release(); + _mutex._global_lock->unlock(); } /** diff --git a/panda/src/pipeline/conditionVarSimpleImpl.cxx b/panda/src/pipeline/conditionVarSimpleImpl.cxx index 9c60c98ff0..761798d227 100644 --- a/panda/src/pipeline/conditionVarSimpleImpl.cxx +++ b/panda/src/pipeline/conditionVarSimpleImpl.cxx @@ -23,14 +23,14 @@ */ void ConditionVarSimpleImpl:: wait() { - _mutex.release_quietly(); + _mutex.unlock_quietly(); ThreadSimpleManager *manager = ThreadSimpleManager::get_global_ptr(); ThreadSimpleImpl *thread = manager->get_current_thread(); manager->enqueue_block(thread, this); manager->next_context(); - _mutex.acquire(); + _mutex.lock(); } /** @@ -38,7 +38,7 @@ wait() { */ void ConditionVarSimpleImpl:: wait(double timeout) { - _mutex.release_quietly(); + _mutex.unlock_quietly(); // TODO. For now this will release every frame, since we don't have an // interface yet on ThreadSimpleManager to do a timed wait. Maybe that's @@ -49,7 +49,7 @@ wait(double timeout) { manager->enqueue_ready(thread, true); manager->next_context(); - _mutex.acquire(); + _mutex.lock(); } /** diff --git a/panda/src/pipeline/lightMutexDirect.I b/panda/src/pipeline/lightMutexDirect.I index 052ba9a8bf..e9d838d3fb 100644 --- a/panda/src/pipeline/lightMutexDirect.I +++ b/panda/src/pipeline/lightMutexDirect.I @@ -41,6 +41,36 @@ operator = (const LightMutexDirect ©) { nassertv(false); } +/** + * Alias for acquire() to match C++11 semantics. + * @see acquire() + */ +INLINE void LightMutexDirect:: +lock() { + TAU_PROFILE("void LightMutexDirect::acquire()", " ", TAU_USER); + _impl.lock(); +} + +/** + * Alias for try_acquire() to match C++11 semantics. + * @see try_acquire() + */ +INLINE bool LightMutexDirect:: +try_lock() { + TAU_PROFILE("void LightMutexDirect::try_acquire()", " ", TAU_USER); + return _impl.try_lock(); +} + +/** + * Alias for release() to match C++11 semantics. + * @see release() + */ +INLINE void LightMutexDirect:: +unlock() { + TAU_PROFILE("void LightMutexDirect::unlock()", " ", TAU_USER); + _impl.unlock(); +} + /** * Grabs the lightMutex if it is available. If it is not available, blocks * until it becomes available, then grabs it. In either case, the function @@ -55,7 +85,7 @@ operator = (const LightMutexDirect ©) { INLINE void LightMutexDirect:: acquire() const { TAU_PROFILE("void LightMutexDirect::acquire()", " ", TAU_USER); - ((LightMutexDirect *)this)->_impl.acquire(); + _impl.lock(); } /** @@ -68,7 +98,7 @@ acquire() const { INLINE void LightMutexDirect:: release() const { TAU_PROFILE("void LightMutexDirect::release()", " ", TAU_USER); - ((LightMutexDirect *)this)->_impl.release(); + _impl.unlock(); } /** diff --git a/panda/src/pipeline/lightMutexDirect.h b/panda/src/pipeline/lightMutexDirect.h index e2085f6d29..54fca1a0ee 100644 --- a/panda/src/pipeline/lightMutexDirect.h +++ b/panda/src/pipeline/lightMutexDirect.h @@ -36,6 +36,11 @@ private: INLINE LightMutexDirect(const LightMutexDirect ©); INLINE void operator = (const LightMutexDirect ©); +public: + INLINE void lock(); + INLINE bool try_lock(); + INLINE void unlock(); + PUBLISHED: BLOCKING INLINE void acquire() const; INLINE void release() const; @@ -54,9 +59,9 @@ private: // even in the SIMPLE_THREADS case. We have to do this since any PStatTimer // call may trigger a context switch, and any low-level context switch // requires all containing mutexes to be true mutexes. - MutexTrueImpl _impl; + mutable MutexTrueImpl _impl; #else - MutexImpl _impl; + mutable MutexImpl _impl; #endif // DO_PSTATS }; diff --git a/panda/src/pipeline/lightReMutexDirect.I b/panda/src/pipeline/lightReMutexDirect.I index be78a3919e..1cfbe15723 100644 --- a/panda/src/pipeline/lightReMutexDirect.I +++ b/panda/src/pipeline/lightReMutexDirect.I @@ -53,6 +53,36 @@ operator = (const LightReMutexDirect ©) { nassertv(false); } +/** + * Alias for acquire() to match C++11 semantics. + * @see acquire() + */ +INLINE void LightReMutexDirect:: +lock() { + TAU_PROFILE("void LightReMutexDirect::acquire()", " ", TAU_USER); + _impl.lock(); +} + +/** + * Alias for try_acquire() to match C++11 semantics. + * @see try_acquire() + */ +INLINE bool LightReMutexDirect:: +try_lock() { + TAU_PROFILE("void LightReMutexDirect::try_acquire()", " ", TAU_USER); + return _impl.try_lock(); +} + +/** + * Alias for release() to match C++11 semantics. + * @see release() + */ +INLINE void LightReMutexDirect:: +unlock() { + TAU_PROFILE("void LightReMutexDirect::unlock()", " ", TAU_USER); + _impl.unlock(); +} + /** * Grabs the lightReMutex if it is available. If it is not available, blocks * until it becomes available, then grabs it. In either case, the function @@ -67,7 +97,11 @@ operator = (const LightReMutexDirect ©) { INLINE void LightReMutexDirect:: acquire() const { TAU_PROFILE("void LightReMutexDirect::acquire()", " ", TAU_USER); - ((LightReMutexDirect *)this)->_impl.acquire(); +#ifdef HAVE_REMUTEXTRUEIMPL + _impl.lock(); +#else + _impl.do_lock(Thread::get_current_thread()); +#endif } /** @@ -77,10 +111,10 @@ acquire() const { INLINE void LightReMutexDirect:: acquire(Thread *current_thread) const { TAU_PROFILE("void LightReMutexDirect::acquire(Thread *)", " ", TAU_USER); -#ifdef HAVE_REMUTEXIMPL - ((LightReMutexDirect *)this)->_impl.acquire(); +#ifdef HAVE_REMUTEXTRUEIMPL + _impl.lock(); #else - ((LightReMutexDirect *)this)->_impl.do_lock(current_thread); + _impl.do_lock(current_thread); #endif // HAVE_REMUTEXIMPL } @@ -97,10 +131,10 @@ acquire(Thread *current_thread) const { INLINE void LightReMutexDirect:: elevate_lock() const { TAU_PROFILE("void LightReMutexDirect::elevate_lock()", " ", TAU_USER); -#ifdef HAVE_REMUTEXIMPL - ((LightReMutexDirect *)this)->_impl.acquire(); +#ifdef HAVE_REMUTEXTRUEIMPL + _impl.lock(); #else - ((LightReMutexDirect *)this)->_impl.do_elevate_lock(); + _impl.do_elevate_lock(); #endif // HAVE_REMUTEXIMPL } @@ -114,7 +148,11 @@ elevate_lock() const { INLINE void LightReMutexDirect:: release() const { TAU_PROFILE("void LightReMutexDirect::release()", " ", TAU_USER); - ((LightReMutexDirect *)this)->_impl.release(); +#ifdef HAVE_REMUTEXTRUEIMPL + _impl.unlock(); +#else + _impl.do_unlock(Thread::get_current_thread()); +#endif } /** diff --git a/panda/src/pipeline/lightReMutexDirect.h b/panda/src/pipeline/lightReMutexDirect.h index 9daeff46a2..7976b90e2c 100644 --- a/panda/src/pipeline/lightReMutexDirect.h +++ b/panda/src/pipeline/lightReMutexDirect.h @@ -35,6 +35,11 @@ private: INLINE LightReMutexDirect(const LightReMutexDirect ©); INLINE void operator = (const LightReMutexDirect ©); +public: + INLINE void lock(); + INLINE bool try_lock(); + INLINE void unlock(); + PUBLISHED: BLOCKING INLINE void acquire() const; BLOCKING INLINE void acquire(Thread *current_thread) const; @@ -51,13 +56,13 @@ PUBLISHED: void output(ostream &out) const; private: -#if defined(HAVE_REMUTEXIMPL) && !defined(DO_PSTATS) - ReMutexImpl _impl; +#ifdef HAVE_REMUTEXTRUEIMPL + mutable ReMutexImpl _impl; #else // If we don't have a reentrant mutex, use the one we hand-rolled in // ReMutexDirect. - ReMutexDirect _impl; + mutable ReMutexDirect _impl; #endif // HAVE_REMUTEXIMPL }; diff --git a/panda/src/pipeline/mutexDebug.I b/panda/src/pipeline/mutexDebug.I index 6a487bde8f..724078b033 100644 --- a/panda/src/pipeline/mutexDebug.I +++ b/panda/src/pipeline/mutexDebug.I @@ -27,6 +27,43 @@ operator = (const MutexDebug ©) { nassertv(false); } +/** + * Alias for acquire() to match C++11 semantics. + * @see acquire() + */ +INLINE void MutexDebug:: +lock() { + TAU_PROFILE("void MutexDebug::acquire()", " ", TAU_USER); + _global_lock->lock(); + ((MutexDebug *)this)->do_lock(Thread::get_current_thread()); + _global_lock->unlock(); +} + +/** + * Alias for try_acquire() to match C++11 semantics. + * @see try_acquire() + */ +INLINE bool MutexDebug:: +try_lock() { + TAU_PROFILE("void MutexDebug::try_lock()", " ", TAU_USER); + _global_lock->lock(); + bool acquired = ((MutexDebug *)this)->do_try_lock(Thread::get_current_thread()); + _global_lock->unlock(); + return acquired; +} + +/** + * Alias for release() to match C++11 semantics. + * @see release() + */ +INLINE void MutexDebug:: +unlock() { + TAU_PROFILE("void MutexDebug::unlock()", " ", TAU_USER); + _global_lock->lock(); + ((MutexDebug *)this)->do_unlock(); + _global_lock->unlock(); +} + /** * Grabs the mutex if it is available. If it is not available, blocks until * it becomes available, then grabs it. In either case, the function does not @@ -41,9 +78,9 @@ INLINE void MutexDebug:: acquire(Thread *current_thread) const { TAU_PROFILE("void MutexDebug::acquire(Thread *)", " ", TAU_USER); nassertv(current_thread == Thread::get_current_thread()); - _global_lock->acquire(); - ((MutexDebug *)this)->do_acquire(current_thread); - _global_lock->release(); + _global_lock->lock(); + ((MutexDebug *)this)->do_lock(current_thread); + _global_lock->unlock(); } /** @@ -52,11 +89,11 @@ acquire(Thread *current_thread) const { */ INLINE bool MutexDebug:: try_acquire(Thread *current_thread) const { - TAU_PROFILE("void MutexDebug::acquire(Thread *)", " ", TAU_USER); + TAU_PROFILE("void MutexDebug::try_acquire(Thread *)", " ", TAU_USER); nassertr(current_thread == Thread::get_current_thread(), false); - _global_lock->acquire(); - bool acquired = ((MutexDebug *)this)->do_try_acquire(current_thread); - _global_lock->release(); + _global_lock->lock(); + bool acquired = ((MutexDebug *)this)->do_try_lock(current_thread); + _global_lock->unlock(); return acquired; } @@ -93,9 +130,9 @@ elevate_lock() const { INLINE void MutexDebug:: release() const { TAU_PROFILE("void MutexDebug::release()", " ", TAU_USER); - _global_lock->acquire(); - ((MutexDebug *)this)->do_release(); - _global_lock->release(); + _global_lock->lock(); + ((MutexDebug *)this)->do_unlock(); + _global_lock->unlock(); } /** @@ -107,9 +144,9 @@ release() const { INLINE bool MutexDebug:: debug_is_locked() const { TAU_PROFILE("bool MutexDebug::debug_is_locked()", " ", TAU_USER); - _global_lock->acquire(); + _global_lock->lock(); bool is_locked = do_debug_is_locked(); - _global_lock->release(); + _global_lock->unlock(); return is_locked; } diff --git a/panda/src/pipeline/mutexDebug.cxx b/panda/src/pipeline/mutexDebug.cxx index d22a923694..ea75142fc6 100644 --- a/panda/src/pipeline/mutexDebug.cxx +++ b/panda/src/pipeline/mutexDebug.cxx @@ -84,12 +84,12 @@ output(ostream &out) const { */ void MutexDebug:: output_with_holder(ostream &out) const { - _global_lock->acquire(); + _global_lock->lock(); output(out); if (_locking_thread != (Thread *)NULL) { out << " (held by " << *_locking_thread << ")\n"; } - _global_lock->release(); + _global_lock->unlock(); } /** @@ -99,9 +99,9 @@ output_with_holder(ostream &out) const { */ void MutexDebug:: increment_pstats() { - _global_lock->acquire(); + _global_lock->lock(); ++_pstats_count; - _global_lock->release(); + _global_lock->unlock(); } /** @@ -110,16 +110,16 @@ increment_pstats() { */ void MutexDebug:: decrement_pstats() { - _global_lock->acquire(); + _global_lock->lock(); --_pstats_count; - _global_lock->release(); + _global_lock->unlock(); } /** * The private implementation of acquire() assumes that _lock_impl is held. */ void MutexDebug:: -do_acquire(Thread *current_thread) { +do_lock(Thread *current_thread) { // If this assertion is triggered, you tried to lock a recently-destructed // mutex. nassertd(_lock_count != -100) { @@ -235,7 +235,7 @@ do_acquire(Thread *current_thread) { * held. */ bool MutexDebug:: -do_try_acquire(Thread *current_thread) { +do_try_lock(Thread *current_thread) { // If this assertion is triggered, you tried to lock a recently-destructed // mutex. nassertd(_lock_count != -100) { @@ -301,7 +301,7 @@ do_try_acquire(Thread *current_thread) { * The private implementation of acquire() assumes that _lock_impl is held. */ void MutexDebug:: -do_release() { +do_unlock() { // If this assertion is triggered, you tried to release a recently- // destructed mutex. nassertd(_lock_count != -100) { diff --git a/panda/src/pipeline/mutexDebug.h b/panda/src/pipeline/mutexDebug.h index 24b8b6500f..2ced4beca0 100644 --- a/panda/src/pipeline/mutexDebug.h +++ b/panda/src/pipeline/mutexDebug.h @@ -35,6 +35,11 @@ private: INLINE MutexDebug(const MutexDebug ©); INLINE void operator = (const MutexDebug ©); +public: + INLINE void lock(); + INLINE bool try_lock(); + INLINE void unlock(); + PUBLISHED: BLOCKING INLINE void acquire(Thread *current_thread = Thread::get_current_thread()) const; BLOCKING INLINE bool try_acquire(Thread *current_thread = Thread::get_current_thread()) const; @@ -52,9 +57,9 @@ public: static void decrement_pstats(); private: - void do_acquire(Thread *current_thread); - bool do_try_acquire(Thread *current_thread); - void do_release(); + void do_lock(Thread *current_thread); + bool do_try_lock(Thread *current_thread); + void do_unlock(); bool do_debug_is_locked() const; void report_deadlock(Thread *current_thread); diff --git a/panda/src/pipeline/mutexDirect.I b/panda/src/pipeline/mutexDirect.I index 0fb8c8b954..73cde8b33b 100644 --- a/panda/src/pipeline/mutexDirect.I +++ b/panda/src/pipeline/mutexDirect.I @@ -41,6 +41,36 @@ operator = (const MutexDirect ©) { nassertv(false); } +/** + * Alias for acquire() to match C++11 semantics. + * @see acquire() + */ +INLINE void MutexDirect:: +lock() { + TAU_PROFILE("void MutexDirect::acquire()", " ", TAU_USER); + _impl.lock(); +} + +/** + * Alias for try_acquire() to match C++11 semantics. + * @see try_acquire() + */ +INLINE bool MutexDirect:: +try_lock() { + TAU_PROFILE("void MutexDirect::try_acquire()", " ", TAU_USER); + return _impl.try_lock(); +} + +/** + * Alias for release() to match C++11 semantics. + * @see release() + */ +INLINE void MutexDirect:: +unlock() { + TAU_PROFILE("void MutexDirect::unlock()", " ", TAU_USER); + _impl.unlock(); +} + /** * Grabs the mutex if it is available. If it is not available, blocks until * it becomes available, then grabs it. In either case, the function does not @@ -54,7 +84,7 @@ operator = (const MutexDirect ©) { INLINE void MutexDirect:: acquire() const { TAU_PROFILE("void MutexDirect::acquire()", " ", TAU_USER); - ((MutexDirect *)this)->_impl.acquire(); + _impl.lock(); } /** @@ -64,7 +94,7 @@ acquire() const { INLINE bool MutexDirect:: try_acquire() const { TAU_PROFILE("void MutexDirect::acquire(bool)", " ", TAU_USER); - return ((MutexDirect *)this)->_impl.try_acquire(); + return _impl.try_lock(); } /** @@ -77,7 +107,7 @@ try_acquire() const { INLINE void MutexDirect:: release() const { TAU_PROFILE("void MutexDirect::release()", " ", TAU_USER); - ((MutexDirect *)this)->_impl.release(); + _impl.unlock(); } /** diff --git a/panda/src/pipeline/mutexDirect.h b/panda/src/pipeline/mutexDirect.h index 494c067a12..6f888e0af6 100644 --- a/panda/src/pipeline/mutexDirect.h +++ b/panda/src/pipeline/mutexDirect.h @@ -35,6 +35,11 @@ private: INLINE MutexDirect(const MutexDirect ©); INLINE void operator = (const MutexDirect ©); +public: + INLINE void lock(); + INLINE bool try_lock(); + INLINE void unlock(); + PUBLISHED: BLOCKING INLINE void acquire() const; BLOCKING INLINE bool try_acquire() const; @@ -49,7 +54,7 @@ PUBLISHED: void output(ostream &out) const; private: - MutexTrueImpl _impl; + mutable MutexTrueImpl _impl; friend class ConditionVarDirect; friend class ConditionVarFullDirect; diff --git a/panda/src/pipeline/mutexSimpleImpl.I b/panda/src/pipeline/mutexSimpleImpl.I index 82b3f5fa51..61123f83f6 100644 --- a/panda/src/pipeline/mutexSimpleImpl.I +++ b/panda/src/pipeline/mutexSimpleImpl.I @@ -11,27 +11,13 @@ * @date 2007-06-19 */ -/** - * - */ -INLINE MutexSimpleImpl:: -MutexSimpleImpl() { -} - -/** - * - */ -INLINE MutexSimpleImpl:: -~MutexSimpleImpl() { -} - /** * */ INLINE void MutexSimpleImpl:: -acquire() { - if (!try_acquire()) { - do_acquire(); +lock() { + if (!try_lock()) { + do_lock(); } } @@ -39,7 +25,7 @@ acquire() { * */ INLINE bool MutexSimpleImpl:: -try_acquire() { +try_lock() { if ((_flags & F_lock_count) != 0) { return false; } @@ -52,12 +38,12 @@ try_acquire() { * waiters on the mutex. */ INLINE void MutexSimpleImpl:: -release() { +unlock() { nassertv((_flags & F_lock_count) != 0); _flags &= ~F_lock_count; if (_flags & F_has_waiters) { - do_release(); + do_unlock(); } } @@ -65,11 +51,11 @@ release() { * Releases the mutex, without allowing a context switch to occur. */ INLINE void MutexSimpleImpl:: -release_quietly() { +unlock_quietly() { nassertv((_flags & F_lock_count) != 0); _flags &= ~F_lock_count; if (_flags & F_has_waiters) { - do_release_quietly(); + do_unlock_quietly(); } } diff --git a/panda/src/pipeline/mutexSimpleImpl.cxx b/panda/src/pipeline/mutexSimpleImpl.cxx index 0908104ae7..624a1989eb 100644 --- a/panda/src/pipeline/mutexSimpleImpl.cxx +++ b/panda/src/pipeline/mutexSimpleImpl.cxx @@ -23,7 +23,7 @@ * */ void MutexSimpleImpl:: -do_acquire() { +do_lock() { // By the time we get here, we already know that someone else is holding the // lock: (_flags & F_lock_count) != 0. ThreadSimpleManager *manager = ThreadSimpleManager::get_global_ptr(); @@ -41,7 +41,7 @@ do_acquire() { * */ void MutexSimpleImpl:: -do_release() { +do_unlock() { // By the time we get here, we already know that someone else is blocked on // this mutex: (_flags & F_waiters) != 0. ThreadSimpleManager *manager = ThreadSimpleManager::get_global_ptr(); @@ -58,7 +58,7 @@ do_release() { * */ void MutexSimpleImpl:: -do_release_quietly() { +do_unlock_quietly() { ThreadSimpleManager *manager = ThreadSimpleManager::get_global_ptr(); manager->unblock_one(this); } diff --git a/panda/src/pipeline/mutexSimpleImpl.h b/panda/src/pipeline/mutexSimpleImpl.h index 60b5bc56b1..31a50c306c 100644 --- a/panda/src/pipeline/mutexSimpleImpl.h +++ b/panda/src/pipeline/mutexSimpleImpl.h @@ -36,18 +36,17 @@ */ class EXPCL_PANDA_PIPELINE MutexSimpleImpl : public BlockerSimple { public: - INLINE MutexSimpleImpl(); - INLINE ~MutexSimpleImpl(); + CONSTEXPR MutexSimpleImpl() DEFAULT_CTOR; - INLINE void acquire(); - INLINE bool try_acquire(); - INLINE void release(); - INLINE void release_quietly(); + INLINE void lock(); + INLINE bool try_lock(); + INLINE void unlock(); + INLINE void unlock_quietly(); private: - void do_acquire(); - void do_release(); - void do_release_quietly(); + void do_lock(); + void do_unlock(); + void do_unlock_quietly(); friend class ThreadSimpleManager; }; diff --git a/panda/src/pipeline/pipeline.cxx b/panda/src/pipeline/pipeline.cxx index e6fd1b6cee..94e1ff3c2a 100644 --- a/panda/src/pipeline/pipeline.cxx +++ b/panda/src/pipeline/pipeline.cxx @@ -134,7 +134,7 @@ cycle() { while (link != &prev_dirty) { PipelineCyclerTrueImpl *cycler = (PipelineCyclerTrueImpl *)link; - if (!cycler->_lock.try_acquire()) { + if (!cycler->_lock.try_lock()) { // No big deal, just move on to the next one for now, and we'll // come back around to it. It's important not to block here in // order to prevent one cycler from deadlocking another. @@ -144,7 +144,7 @@ cycle() { } else { // Well, we are the last cycler left, so we might as well wait. // This is necessary to trigger the deadlock detection code. - cycler->_lock.acquire(); + cycler->_lock.lock(); } } @@ -162,7 +162,7 @@ cycle() { #ifdef DEBUG_THREADS inc_cycler_type(_dirty_cycler_types, cycler->get_parent_type(), -1); #endif - cycler->_lock.release(); + cycler->_lock.unlock(); break; } } @@ -174,7 +174,7 @@ cycle() { while (link != &prev_dirty) { PipelineCyclerTrueImpl *cycler = (PipelineCyclerTrueImpl *)link; - if (!cycler->_lock.try_acquire()) { + if (!cycler->_lock.try_lock()) { // No big deal, just move on to the next one for now, and we'll // come back around to it. It's important not to block here in // order to prevent one cycler from deadlocking another. @@ -184,7 +184,7 @@ cycle() { } else { // Well, we are the last cycler left, so we might as well wait. // This is necessary to trigger the deadlock detection code. - cycler->_lock.acquire(); + cycler->_lock.lock(); } } @@ -206,7 +206,7 @@ cycle() { inc_cycler_type(_dirty_cycler_types, cycler->get_parent_type(), -1); #endif } - cycler->_lock.release(); + cycler->_lock.unlock(); break; } } @@ -218,7 +218,7 @@ cycle() { while (link != &prev_dirty) { PipelineCyclerTrueImpl *cycler = (PipelineCyclerTrueImpl *)link; - if (!cycler->_lock.try_acquire()) { + if (!cycler->_lock.try_lock()) { // No big deal, just move on to the next one for now, and we'll // come back around to it. It's important not to block here in // order to prevent one cycler from deadlocking another. @@ -228,7 +228,7 @@ cycle() { } else { // Well, we are the last cycler left, so we might as well wait. // This is necessary to trigger the deadlock detection code. - cycler->_lock.acquire(); + cycler->_lock.lock(); } } @@ -250,7 +250,7 @@ cycle() { inc_cycler_type(_dirty_cycler_types, cycler->get_parent_type(), -1); #endif } - cycler->_lock.release(); + cycler->_lock.unlock(); break; } } @@ -293,11 +293,11 @@ set_num_stages(int num_stages) { PipelineCyclerLinks *links; for (links = _clean._next; links != &_clean; links = links->_next) { PipelineCyclerTrueImpl *cycler = (PipelineCyclerTrueImpl *)links; - cycler->_lock.acquire(); + cycler->_lock.lock(); } for (links = _dirty._next; links != &_dirty; links = links->_next) { PipelineCyclerTrueImpl *cycler = (PipelineCyclerTrueImpl *)links; - cycler->_lock.acquire(); + cycler->_lock.lock(); } _num_stages = num_stages; @@ -315,12 +315,12 @@ set_num_stages(int num_stages) { int count = 0; for (links = _clean._next; links != &_clean; links = links->_next) { PipelineCyclerTrueImpl *cycler = (PipelineCyclerTrueImpl *)links; - cycler->_lock.release(); + cycler->_lock.unlock(); ++count; } for (links = _dirty._next; links != &_dirty; links = links->_next) { PipelineCyclerTrueImpl *cycler = (PipelineCyclerTrueImpl *)links; - cycler->_lock.release(); + cycler->_lock.unlock(); ++count; } nassertv(count == _num_cyclers); @@ -402,7 +402,7 @@ remove_cycler(PipelineCyclerTrueImpl *cycler) { // during cycle only if it's 0 (clean) or _next_cycle_seq (scheduled for the // next cycle, so not owned by the current one). while (cycler->_dirty != 0 && cycler->_dirty != _next_cycle_seq) { - if (_cycle_lock.try_acquire()) { + if (_cycle_lock.try_lock()) { // OK, great, we got the lock, so it finished cycling already. nassertv(!_cycling); @@ -417,16 +417,16 @@ remove_cycler(PipelineCyclerTrueImpl *cycler) { inc_cycler_type(_dirty_cycler_types, cycler->get_parent_type(), -1); #endif - _cycle_lock.release(); + _cycle_lock.unlock(); return; } else { // It's possibly currently being cycled. We will wait for the cycler // to be done with it, so that we can safely remove it. - _lock.release(); - cycler->_lock.release(); + _lock.unlock(); + cycler->_lock.unlock(); Thread::force_yield(); - cycler->_lock.acquire(); - _lock.acquire(); + cycler->_lock.lock(); + _lock.lock(); } } diff --git a/panda/src/pipeline/reMutexDirect.I b/panda/src/pipeline/reMutexDirect.I index abdce3562f..7d0319ad61 100644 --- a/panda/src/pipeline/reMutexDirect.I +++ b/panda/src/pipeline/reMutexDirect.I @@ -53,6 +53,36 @@ operator = (const ReMutexDirect ©) { nassertv(false); } +/** + * Alias for acquire() to match C++11 semantics. + * @see acquire() + */ +INLINE void ReMutexDirect:: +lock() { + TAU_PROFILE("void ReMutexDirect::acquire()", " ", TAU_USER); + _impl.lock(); +} + +/** + * Alias for try_acquire() to match C++11 semantics. + * @see try_acquire() + */ +INLINE bool ReMutexDirect:: +try_lock() { + TAU_PROFILE("void ReMutexDirect::try_acquire()", " ", TAU_USER); + return _impl.try_lock(); +} + +/** + * Alias for release() to match C++11 semantics. + * @see release() + */ +INLINE void ReMutexDirect:: +unlock() { + TAU_PROFILE("void ReMutexDirect::unlock()", " ", TAU_USER); + _impl.unlock(); +} + /** * Grabs the reMutex if it is available. If it is not available, blocks until * it becomes available, then grabs it. In either case, the function does not @@ -67,9 +97,9 @@ INLINE void ReMutexDirect:: acquire() const { TAU_PROFILE("void ReMutexDirect::acquire()", " ", TAU_USER); #ifdef HAVE_REMUTEXTRUEIMPL - ((ReMutexDirect *)this)->_impl.acquire(); + _impl.lock(); #else - ((ReMutexDirect *)this)->do_acquire(); + ((ReMutexDirect *)this)->do_lock(); #endif // HAVE_REMUTEXTRUEIMPL } @@ -81,9 +111,9 @@ INLINE void ReMutexDirect:: acquire(Thread *current_thread) const { TAU_PROFILE("void ReMutexDirect::acquire(Thread *)", " ", TAU_USER); #ifdef HAVE_REMUTEXTRUEIMPL - ((ReMutexDirect *)this)->_impl.acquire(); + _impl.lock(); #else - ((ReMutexDirect *)this)->do_acquire(current_thread); + ((ReMutexDirect *)this)->do_lock(current_thread); #endif // HAVE_REMUTEXTRUEIMPL } @@ -95,9 +125,9 @@ INLINE bool ReMutexDirect:: try_acquire() const { TAU_PROFILE("void ReMutexDirect::acquire(bool)", " ", TAU_USER); #ifdef HAVE_REMUTEXTRUEIMPL - return ((ReMutexDirect *)this)->_impl.try_acquire(); + return _impl.try_lock(); #else - return ((ReMutexDirect *)this)->do_try_acquire(); + return ((ReMutexDirect *)this)->do_try_lock(); #endif // HAVE_REMUTEXTRUEIMPL } @@ -109,9 +139,9 @@ INLINE bool ReMutexDirect:: try_acquire(Thread *current_thread) const { TAU_PROFILE("void ReMutexDirect::acquire(bool)", " ", TAU_USER); #ifdef HAVE_REMUTEXTRUEIMPL - return ((ReMutexDirect *)this)->_impl.try_acquire(); + return _impl.try_lock(); #else - return ((ReMutexDirect *)this)->do_try_acquire(current_thread); + return ((ReMutexDirect *)this)->do_try_lock(current_thread); #endif // HAVE_REMUTEXTRUEIMPL } @@ -129,7 +159,7 @@ INLINE void ReMutexDirect:: elevate_lock() const { TAU_PROFILE("void ReMutexDirect::elevate_lock()", " ", TAU_USER); #ifdef HAVE_REMUTEXTRUEIMPL - ((ReMutexDirect *)this)->_impl.acquire(); + _impl.lock(); #else ((ReMutexDirect *)this)->do_elevate_lock(); #endif // HAVE_REMUTEXTRUEIMPL @@ -146,9 +176,9 @@ INLINE void ReMutexDirect:: release() const { TAU_PROFILE("void ReMutexDirect::release()", " ", TAU_USER); #ifdef HAVE_REMUTEXTRUEIMPL - ((ReMutexDirect *)this)->_impl.release(); + _impl.unlock(); #else - ((ReMutexDirect *)this)->do_release(); + ((ReMutexDirect *)this)->do_unlock(); #endif // HAVE_REMUTEXTRUEIMPL } @@ -201,8 +231,8 @@ get_name() const { * mutex). */ INLINE void ReMutexDirect:: -do_acquire() { - do_acquire(Thread::get_current_thread()); +do_lock() { + do_lock(Thread::get_current_thread()); } #endif @@ -214,7 +244,7 @@ do_acquire() { * mutex). */ INLINE bool ReMutexDirect:: -do_try_acquire() { - return do_try_acquire(Thread::get_current_thread()); +do_try_lock() { + return do_try_lock(Thread::get_current_thread()); } #endif diff --git a/panda/src/pipeline/reMutexDirect.cxx b/panda/src/pipeline/reMutexDirect.cxx index 33ff64c4cc..b82ed0f364 100644 --- a/panda/src/pipeline/reMutexDirect.cxx +++ b/panda/src/pipeline/reMutexDirect.cxx @@ -33,8 +33,8 @@ output(ostream &out) const { * mutex). */ void ReMutexDirect:: -do_acquire(Thread *current_thread) { - _lock_impl.acquire(); +do_lock(Thread *current_thread) { + _lock_impl.lock(); if (_locking_thread == (Thread *)NULL) { // The mutex is not already locked by anyone. Lock it. @@ -61,7 +61,7 @@ do_acquire(Thread *current_thread) { nassertd(_lock_count == 1) { } } - _lock_impl.release(); + _lock_impl.unlock(); } #endif // !HAVE_REMUTEXTRUEIMPL @@ -73,9 +73,9 @@ do_acquire(Thread *current_thread) { * mutex). */ bool ReMutexDirect:: -do_try_acquire(Thread *current_thread) { +do_try_lock(Thread *current_thread) { bool acquired = true; - _lock_impl.acquire(); + _lock_impl.lock(); if (_locking_thread == (Thread *)NULL) { // The mutex is not already locked by anyone. Lock it. @@ -94,7 +94,7 @@ do_try_acquire(Thread *current_thread) { // The mutex is locked by some other thread. Return false. acquired = false; } - _lock_impl.release(); + _lock_impl.unlock(); return acquired; } @@ -109,16 +109,16 @@ do_try_acquire(Thread *current_thread) { */ void ReMutexDirect:: do_elevate_lock() { - _lock_impl.acquire(); + _lock_impl.lock(); #ifdef _DEBUG nassertd(_locking_thread == Thread::get_current_thread()) { - _lock_impl.release(); + _lock_impl.unlock(); return; } #elif !defined(NDEBUG) nassertd(_locking_thread != (Thread *)NULL) { - _lock_impl.release(); + _lock_impl.unlock(); return; } #endif // NDEBUG @@ -129,7 +129,7 @@ do_elevate_lock() { nassertd(_lock_count > 0) { } - _lock_impl.release(); + _lock_impl.unlock(); } #endif // !HAVE_REMUTEXTRUEIMPL @@ -141,8 +141,8 @@ do_elevate_lock() { * mutex). */ void ReMutexDirect:: -do_release() { - _lock_impl.acquire(); +do_unlock() { + _lock_impl.lock(); #ifdef _DEBUG if (_locking_thread != Thread::get_current_thread()) { @@ -150,7 +150,7 @@ do_release() { ostr << *_locking_thread << " attempted to release " << *this << " which it does not own"; nassert_raise(ostr.str()); - _lock_impl.release(); + _lock_impl.unlock(); return; } #endif // _DEBUG @@ -164,7 +164,7 @@ do_release() { _locking_thread = (Thread *)NULL; _cvar_impl.notify(); } - _lock_impl.release(); + _lock_impl.unlock(); } #endif // !HAVE_REMUTEXTRUEIMPL diff --git a/panda/src/pipeline/reMutexDirect.h b/panda/src/pipeline/reMutexDirect.h index ce86e774f0..fd18a38fc2 100644 --- a/panda/src/pipeline/reMutexDirect.h +++ b/panda/src/pipeline/reMutexDirect.h @@ -35,6 +35,11 @@ private: INLINE ReMutexDirect(const ReMutexDirect ©); INLINE void operator = (const ReMutexDirect ©); +public: + INLINE void lock(); + INLINE bool try_lock(); + INLINE void unlock(); + PUBLISHED: BLOCKING INLINE void acquire() const; BLOCKING INLINE void acquire(Thread *current_thread) const; @@ -54,16 +59,16 @@ PUBLISHED: private: #ifdef HAVE_REMUTEXTRUEIMPL - ReMutexImpl _impl; + mutable ReMutexImpl _impl; #else // If we don't have a reentrant mutex, we have to hand-roll one. - INLINE void do_acquire(); - void do_acquire(Thread *current_thread); - INLINE bool do_try_acquire(); - bool do_try_acquire(Thread *current_thread); + INLINE void do_lock(); + void do_lock(Thread *current_thread); + INLINE bool do_try_lock(); + bool do_try_lock(Thread *current_thread); void do_elevate_lock(); - void do_release(); + void do_unlock(); Thread *_locking_thread; int _lock_count; diff --git a/panda/src/pipeline/test_mutex.cxx b/panda/src/pipeline/test_mutex.cxx index 39f5e8a24c..f02ccd1434 100644 --- a/panda/src/pipeline/test_mutex.cxx +++ b/panda/src/pipeline/test_mutex.cxx @@ -33,9 +33,9 @@ public: double start = clock->get_short_time(); double end = start + thread_duration; while (clock->get_short_time() < end) { - _m1.acquire(); + _m1.lock(); Thread::sleep(_period); - _m1.release(); + _m1.unlock(); } } @@ -47,8 +47,8 @@ int main(int argc, char *argv[]) { MutexImpl _m1; - _m1.acquire(); - _m1.release(); + _m1.lock(); + _m1.unlock(); cerr << "Making threads.\n"; MyThread *a = new MyThread("a", _m1, 1.0); diff --git a/panda/src/pipeline/threadPosixImpl.cxx b/panda/src/pipeline/threadPosixImpl.cxx index 5104c67926..9983ad24ea 100644 --- a/panda/src/pipeline/threadPosixImpl.cxx +++ b/panda/src/pipeline/threadPosixImpl.cxx @@ -41,14 +41,14 @@ ThreadPosixImpl:: << "Deleting thread " << _parent_obj->get_name() << "\n"; } - _mutex.acquire(); + _mutex.lock(); if (!_detached) { pthread_detach(_thread); _detached = true; } - _mutex.release(); + _mutex.unlock(); } /** @@ -65,13 +65,13 @@ setup_main_thread() { */ bool ThreadPosixImpl:: start(ThreadPriority priority, bool joinable) { - _mutex.acquire(); + _mutex.lock(); if (thread_cat->is_debug()) { thread_cat.debug() << "Starting " << *_parent_obj << "\n"; } nassertd(_status == S_new) { - _mutex.release(); + _mutex.unlock(); return false; } @@ -148,12 +148,12 @@ start(ThreadPriority priority, bool joinable) { // Oops, we couldn't start the thread. Be sure to decrement the reference // count we incremented above, and return false to indicate failure. unref_delete(_parent_obj); - _mutex.release(); + _mutex.unlock(); return false; } // Thread was successfully started. - _mutex.release(); + _mutex.unlock(); return true; } @@ -163,15 +163,15 @@ start(ThreadPriority priority, bool joinable) { */ void ThreadPosixImpl:: join() { - _mutex.acquire(); + _mutex.lock(); if (!_detached) { - _mutex.release(); + _mutex.unlock(); void *return_val; pthread_join(_thread, &return_val); _detached = true; return; } - _mutex.release(); + _mutex.unlock(); } /** @@ -246,14 +246,14 @@ root_func(void *data) { nassertr(result == 0, NULL); { - self->_mutex.acquire(); + self->_mutex.lock(); nassertd(self->_status == S_start_called) { - self->_mutex.release(); + self->_mutex.unlock(); return NULL; } self->_status = S_running; - self->_mutex.release(); + self->_mutex.unlock(); } #ifdef ANDROID @@ -270,13 +270,13 @@ root_func(void *data) { } { - self->_mutex.acquire(); + self->_mutex.lock(); nassertd(self->_status == S_running) { - self->_mutex.release(); + self->_mutex.unlock(); return NULL; } self->_status = S_finished; - self->_mutex.release(); + self->_mutex.unlock(); } #ifdef ANDROID diff --git a/panda/src/pipeline/threadWin32Impl.cxx b/panda/src/pipeline/threadWin32Impl.cxx index 006a98441e..8508f23ac6 100644 --- a/panda/src/pipeline/threadWin32Impl.cxx +++ b/panda/src/pipeline/threadWin32Impl.cxx @@ -49,13 +49,13 @@ setup_main_thread() { */ bool ThreadWin32Impl:: start(ThreadPriority priority, bool joinable) { - _mutex.acquire(); + _mutex.lock(); if (thread_cat->is_debug()) { thread_cat.debug() << "Starting " << *_parent_obj << "\n"; } nassertd(_status == S_new && _thread == 0) { - _mutex.release(); + _mutex.unlock(); return false; } @@ -76,7 +76,7 @@ start(ThreadPriority priority, bool joinable) { // Oops, we couldn't start the thread. Be sure to decrement the reference // count we incremented above, and return false to indicate failure. unref_delete(_parent_obj); - _mutex.release(); + _mutex.unlock(); return false; } @@ -100,7 +100,7 @@ start(ThreadPriority priority, bool joinable) { break; } - _mutex.release(); + _mutex.unlock(); return true; } @@ -110,16 +110,16 @@ start(ThreadPriority priority, bool joinable) { */ void ThreadWin32Impl:: join() { - _mutex.acquire(); + _mutex.lock(); nassertd(_joinable && _status != S_new) { - _mutex.release(); + _mutex.unlock(); return; } while (_status != S_finished) { _cv.wait(); } - _mutex.release(); + _mutex.unlock(); } /** @@ -147,14 +147,14 @@ root_func(LPVOID data) { nassertr(result, 1); { - self->_mutex.acquire(); + self->_mutex.lock(); nassertd(self->_status == S_start_called) { - self->_mutex.release(); + self->_mutex.unlock(); return 1; } self->_status = S_running; self->_cv.notify(); - self->_mutex.release(); + self->_mutex.unlock(); } self->_parent_obj->thread_main(); @@ -166,14 +166,14 @@ root_func(LPVOID data) { } { - self->_mutex.acquire(); + self->_mutex.lock(); nassertd(self->_status == S_running) { - self->_mutex.release(); + self->_mutex.unlock(); return 1; } self->_status = S_finished; self->_cv.notify(); - self->_mutex.release(); + self->_mutex.unlock(); } // Now drop the parent object reference that we grabbed in start(). This diff --git a/panda/src/putil/bamCache.cxx b/panda/src/putil/bamCache.cxx index 94c31665c6..cd3fab2113 100644 --- a/panda/src/putil/bamCache.cxx +++ b/panda/src/putil/bamCache.cxx @@ -311,7 +311,7 @@ emergency_read_only() { void BamCache:: consider_flush_index() { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) - if (!_lock.try_acquire()) { + if (!_lock.try_lock()) { // If we can't grab the lock, no big deal. We don't want to hold up // the frame waiting for a cache operation. We can try again later. return; @@ -326,7 +326,7 @@ consider_flush_index() { } #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) - _lock.release(); + _lock.unlock(); #endif } diff --git a/panda/src/putil/copyOnWritePointer.cxx b/panda/src/putil/copyOnWritePointer.cxx index 4beb105ada..5a8f1700b6 100644 --- a/panda/src/putil/copyOnWritePointer.cxx +++ b/panda/src/putil/copyOnWritePointer.cxx @@ -66,7 +66,7 @@ get_write_pointer() { Thread *current_thread = Thread::get_current_thread(); - _cow_object->_lock_mutex.acquire(); + _cow_object->_lock_mutex.lock(); while (_cow_object->_lock_status == CopyOnWriteObject::LS_locked_write && _cow_object->_locking_thread != current_thread) { if (util_cat.is_debug()) { @@ -89,7 +89,7 @@ get_write_pointer() { PT(CopyOnWriteObject) new_object = _cow_object->make_cow_copy(); _cow_object->CachedTypedWritableReferenceCount::cache_unref(); - _cow_object->_lock_mutex.release(); + _cow_object->_lock_mutex.unlock(); MutexHolder holder(new_object->_lock_mutex); _cow_object = new_object; @@ -112,7 +112,7 @@ get_write_pointer() { PT(CopyOnWriteObject) new_object = _cow_object->make_cow_copy(); _cow_object->CachedTypedWritableReferenceCount::cache_unref(); - _cow_object->_lock_mutex.release(); + _cow_object->_lock_mutex.unlock(); MutexHolder holder(new_object->_lock_mutex); _cow_object = new_object; @@ -132,7 +132,7 @@ get_write_pointer() { // reference. _cow_object->_lock_status = CopyOnWriteObject::LS_locked_write; _cow_object->_locking_thread = current_thread; - _cow_object->_lock_mutex.release(); + _cow_object->_lock_mutex.unlock(); } return _cow_object; From 9fad3dba6020c2411465c5eed138c9081bc9a27b Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 23 May 2018 23:30:39 +0200 Subject: [PATCH 182/247] general: remove macros for compatibility with non-C++11 compilers Now that we require MSVC 2015, we no longer need all this nonsense, so we can write cleaner code. --- dtool/src/dtoolbase/dtoolbase_cc.h | 141 ++---------------- dtool/src/dtoolbase/fakestringstream.h | 2 - dtool/src/dtoolbase/memoryHook.I | 2 +- dtool/src/dtoolbase/memoryHook.h | 2 +- dtool/src/dtoolbase/mutexDummyImpl.h | 7 +- dtool/src/dtoolbase/mutexPosixImpl.I | 8 +- dtool/src/dtoolbase/mutexPosixImpl.h | 14 +- dtool/src/dtoolbase/mutexSpinlockImpl.I | 2 +- dtool/src/dtoolbase/mutexSpinlockImpl.h | 7 +- dtool/src/dtoolbase/mutexWin32Impl.h | 5 +- dtool/src/dtoolbase/nearly_zero.h | 6 +- dtool/src/dtoolbase/pallocator.T | 4 +- dtool/src/dtoolbase/pallocator.h | 8 +- dtool/src/dtoolbase/pvector.h | 17 +-- dtool/src/dtoolbase/typeHandle.I | 6 +- dtool/src/dtoolbase/typeHandle.h | 10 +- dtool/src/dtoolbase/typedObject.h | 6 +- dtool/src/dtoolutil/filename.I | 25 +--- dtool/src/dtoolutil/filename.h | 14 +- dtool/src/prc/notifyCategory.I | 4 +- dtool/src/prc/notifyCategory.h | 4 +- dtool/src/prc/notifyCategoryProxy.I | 4 +- dtool/src/prc/notifyCategoryProxy.h | 4 +- dtool/src/prc/streamWrapper.h | 4 +- makepanda/makepanda.py | 2 - panda/src/bullet/bulletTriangleMesh.h | 2 +- panda/src/display/displayRegion.I | 5 - panda/src/display/graphicsEngine.cxx | 2 +- panda/src/display/graphicsPipe.h | 5 +- panda/src/display/graphicsStateGuardian.h | 2 +- panda/src/event/asyncFuture.h | 2 +- panda/src/event/asyncTask.h | 4 +- panda/src/event/eventParameter.h | 2 +- panda/src/event/pythonTask.h | 2 +- panda/src/express/nodePointerTo.I | 16 +- panda/src/express/nodePointerTo.h | 20 +-- panda/src/express/nodePointerToBase.I | 6 +- panda/src/express/nodePointerToBase.h | 6 +- panda/src/express/pointerTo.I | 52 +++---- panda/src/express/pointerTo.h | 44 +++--- panda/src/express/pointerToArray.I | 28 +--- panda/src/express/pointerToArray.h | 24 +-- panda/src/express/pointerToArrayBase.I | 4 +- panda/src/express/pointerToArrayBase.h | 5 +- panda/src/express/pointerToBase.I | 6 +- panda/src/express/pointerToBase.h | 9 +- panda/src/express/pointerToVoid.I | 8 +- panda/src/express/pointerToVoid.h | 8 +- panda/src/express/weakPointerToBase.I | 4 +- panda/src/express/weakPointerToBase.h | 4 +- panda/src/glstuff/glCgShaderContext_src.h | 2 +- panda/src/glstuff/glShaderContext_src.h | 2 +- panda/src/glstuff/glTextureContext_src.h | 2 +- panda/src/gobj/geom.I | 8 +- panda/src/gobj/geom.h | 19 +-- panda/src/gobj/geomMunger.cxx | 5 +- panda/src/gobj/geomPrimitive.h | 9 +- panda/src/gobj/geomVertexArrayData.I | 2 +- panda/src/gobj/geomVertexArrayData.h | 2 +- panda/src/gobj/geomVertexArrayFormat.cxx | 22 +-- panda/src/gobj/geomVertexArrayFormat.h | 2 +- panda/src/gobj/geomVertexColumn.I | 2 +- panda/src/gobj/geomVertexColumn.h | 14 +- panda/src/gobj/geomVertexData.I | 12 +- panda/src/gobj/geomVertexData.cxx | 5 +- panda/src/gobj/geomVertexData.h | 17 +-- panda/src/gobj/geomVertexFormat.h | 2 +- panda/src/gobj/geomVertexReader.I | 2 +- panda/src/gobj/geomVertexRewriter.I | 4 +- panda/src/gobj/geomVertexWriter.I | 2 +- panda/src/gobj/internalName.I | 18 +-- panda/src/gobj/internalName.h | 15 +- panda/src/gobj/preparedGraphicsObjects.h | 4 +- panda/src/gobj/shaderBuffer.h | 2 +- panda/src/gobj/texture.cxx | 4 +- panda/src/gobj/texture_ext.cxx | 6 +- panda/src/linmath/lpoint2_src.h | 2 +- panda/src/linmath/lpoint3_src.h | 2 +- panda/src/linmath/lpoint4_src.h | 2 +- panda/src/linmath/lvecBase2_src.h | 6 +- panda/src/linmath/lvecBase3_src.h | 6 +- panda/src/linmath/lvecBase4_src.h | 12 +- panda/src/linmath/lvector2_src.h | 2 +- panda/src/linmath/lvector3_src.h | 2 +- panda/src/linmath/lvector4_src.h | 2 +- panda/src/mathutil/geometricBoundingVolume.h | 4 +- panda/src/pgraph/cullableObject.cxx | 5 - panda/src/pgraph/geomNode.I | 10 +- panda/src/pgraph/geomNode.h | 8 +- panda/src/pgraph/nodePath.I | 6 +- panda/src/pgraph/nodePath.cxx | 2 +- panda/src/pgraph/nodePath.h | 11 +- panda/src/pgraph/nodePathCollection.h | 2 +- panda/src/pgraph/nodePathComponent.h | 2 +- panda/src/pgraph/pandaNode.I | 26 ++-- panda/src/pgraph/pandaNode.h | 24 ++- panda/src/pgraph/paramNodePath.I | 6 +- panda/src/pgraph/paramNodePath.h | 5 +- panda/src/pgraph/renderAttrib.h | 2 +- panda/src/pgraph/renderAttribRegistry.I | 2 +- panda/src/pgraph/renderAttribRegistry.h | 2 +- panda/src/pgraph/shaderInput.I | 66 ++++---- panda/src/pgraph/shaderInput.cxx | 6 +- panda/src/pgraph/shaderInput.h | 2 +- panda/src/pgraph/transformState.h | 2 +- panda/src/pgraphnodes/ambientLight.h | 2 +- panda/src/pgraphnodes/directionalLight.h | 2 +- panda/src/pgraphnodes/pointLight.h | 4 +- panda/src/pgraphnodes/rectangleLight.h | 2 +- panda/src/pgraphnodes/spotlight.h | 6 +- panda/src/pipeline/cycleData.h | 6 +- panda/src/pipeline/cycleDataLockedReader.I | 6 +- panda/src/pipeline/cycleDataLockedReader.h | 8 +- .../src/pipeline/cycleDataLockedStageReader.I | 6 +- .../src/pipeline/cycleDataLockedStageReader.h | 8 +- panda/src/pipeline/cycleDataStageWriter.I | 6 +- panda/src/pipeline/cycleDataStageWriter.h | 10 +- panda/src/pipeline/cycleDataWriter.I | 6 +- panda/src/pipeline/cycleDataWriter.h | 8 +- panda/src/pipeline/lightMutex.I | 28 ---- panda/src/pipeline/lightMutex.h | 8 +- panda/src/pipeline/lightMutexDirect.I | 30 ---- panda/src/pipeline/lightMutexDirect.h | 10 +- panda/src/pipeline/lightReMutexDirect.I | 27 ---- panda/src/pipeline/lightReMutexDirect.h | 8 +- panda/src/pipeline/mutexDebug.I | 16 -- panda/src/pipeline/mutexDebug.h | 6 +- panda/src/pipeline/mutexDirect.I | 30 ---- panda/src/pipeline/mutexDirect.h | 10 +- panda/src/pipeline/mutexSimpleImpl.h | 2 +- panda/src/pipeline/pmutex.I | 28 ---- panda/src/pipeline/pmutex.h | 8 +- panda/src/pipeline/reMutex.I | 15 -- panda/src/pipeline/reMutex.h | 8 +- panda/src/pipeline/reMutexDirect.I | 27 ---- panda/src/pipeline/reMutexDirect.h | 8 +- panda/src/putil/bitArray.I | 6 +- panda/src/putil/bitArray.h | 6 +- panda/src/putil/bitMask.I | 6 +- panda/src/putil/bitMask.h | 6 +- panda/src/putil/buttonHandle.I | 4 +- panda/src/putil/buttonHandle.h | 8 +- panda/src/putil/copyOnWritePointer.I | 20 +-- panda/src/putil/copyOnWritePointer.h | 26 ++-- panda/src/putil/doubleBitMask.I | 6 +- panda/src/putil/doubleBitMask.h | 6 +- panda/src/putil/factoryParams.I | 10 +- panda/src/putil/factoryParams.h | 6 +- panda/src/putil/iterator_types.h | 6 +- panda/src/putil/simpleHashMap.I | 8 +- panda/src/putil/simpleHashMap.h | 12 +- panda/src/putil/updateSeq.I | 14 +- panda/src/putil/updateSeq.h | 12 +- panda/src/putil/weakKeyHashMap.I | 8 +- panda/src/putil/weakKeyHashMap.h | 11 +- panda/src/putil/writableParam.h | 2 +- panda/src/recorder/mouseRecorder.h | 6 +- panda/src/recorder/socketStreamRecorder.h | 6 +- panda/src/text/textAssembler.cxx | 8 +- 159 files changed, 522 insertions(+), 1021 deletions(-) diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index 81968085bc..491bd92c22 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -33,16 +33,7 @@ using namespace std; #define INLINE inline #define ALWAYS_INLINE inline #define TYPENAME typename -#define CONSTEXPR constexpr -#define ALWAYS_INLINE_CONSTEXPR constexpr -#define NOEXCEPT noexcept -#define FINAL final #define MOVE(x) x -#define DEFAULT_CTOR = default -#define DEFAULT_DTOR = default -#define DEFAULT_ASSIGN = default -#define DELETED = delete -#define DELETED_ASSIGN = delete #define EXPORT_TEMPLATE_CLASS(expcl, exptp, classname) @@ -81,15 +72,9 @@ typedef int ios_seekdir; #include #include -#ifdef HAVE_NAMESPACE using namespace std; -#endif -#ifdef HAVE_TYPENAME #define TYPENAME typename -#else -#define TYPENAME -#endif #ifndef HAVE_WCHAR_T // Some C++ libraries (os x 3.1) don't define this. @@ -124,18 +109,20 @@ typedef ios::seekdir ios_seekdir; #if defined(__GLIBCXX__) && __GLIBCXX__ <= 20070719 #include -using std::tr1::tuple; -using std::tr1::tie; +namespace std { + using std::tr1::tuple; + using std::tr1::tie; -typedef decltype(nullptr) nullptr_t; + typedef decltype(nullptr) nullptr_t; -template struct remove_reference {typedef T type;}; -template struct remove_reference {typedef T type;}; -template struct remove_reference{typedef T type;}; + template struct remove_reference {typedef T type;}; + template struct remove_reference {typedef T type;}; + template struct remove_reference{typedef T type;}; -template typename remove_reference::type &&move(T &&t) { - return static_cast::type&&>(t); -} + template typename remove_reference::type &&move(T &&t) { + return static_cast::type&&>(t); + } +}; #endif #ifdef _MSC_VER @@ -156,110 +143,12 @@ template typename remove_reference::type &&move(T &&t) { #endif // Determine the availability of C++11 features. -#if defined(__has_extension) // Clang magic. -# if __has_extension(cxx_constexpr) -# if !defined(__apple_build_version__) || __apple_build_version__ >= 5000000 -# define CONSTEXPR constexpr -# endif -# endif -# if __has_extension(cxx_noexcept) -# define NOEXCEPT noexcept -# endif -# if __has_extension(cxx_rvalue_references) && (__cplusplus >= 201103L) -# define USE_MOVE_SEMANTICS -# define MOVE(x) move(x) -# endif -# if __has_extension(cxx_override_control) && (__cplusplus >= 201103L) -# define FINAL final -# endif -# if __has_extension(cxx_defaulted_functions) -# define DEFAULT_CTOR = default -# define DEFAULT_DTOR = default -# define DEFAULT_ASSIGN = default -# endif -# if __has_extension(cxx_deleted_functions) -# define DELETED = delete -# endif -#elif defined(__GNUC__) // GCC - -// Starting at GCC 4.4 -# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) -# define DEFAULT_CTOR = default -# define DEFAULT_DTOR = default -# define DEFAULT_ASSIGN = default -# define DELETED = delete -# endif - -// Starting at GCC 4.6 -# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) -# define CONSTEXPR constexpr -# define NOEXCEPT noexcept -# define USE_MOVE_SEMANTICS -# define MOVE(x) move(x) -# endif - -// Starting at GCC 4.7 -# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) -# define FINAL final -# endif - -// GCC defines several macros which we can query. List of all supported -// builtin macros: https://gcc.gnu.org/projects/cxx-status.html -# if !defined(CONSTEXPR) && __cpp_constexpr >= 200704 -# define CONSTEXPR constexpr -# endif - -#elif defined(_MSC_VER) && _MSC_VER >= 1900 // Visual Studio 2015 -# define CONSTEXPR constexpr -# define NOEXCEPT noexcept -# define USE_MOVE_SEMANTICS -# define FINAL final -# define MOVE(x) move(x) -#elif defined(_MSC_VER) && _MSC_VER >= 1600 // Visual Studio 2010 -# define NOEXCEPT throw() -# define USE_MOVE_SEMANTICS -# define FINAL sealed -# define MOVE(x) move(x) +#if defined(_MSC_VER) && _MSC_VER < 1900 // Visual Studio 2015 +#error Microsoft Visual C++ 2015 or later is required to compile Panda3D. #endif -#if defined(_MSC_VER) && _MSC_VER >= 1800 // Visual Studio 2013 -# define DEFAULT_CTOR = default -# define DEFAULT_DTOR = default -# define DEFAULT_ASSIGN = default -# define DELETED = delete -#endif - -// Fallbacks if features are not supported -#ifndef CONSTEXPR -# define CONSTEXPR INLINE -# define ALWAYS_INLINE_CONSTEXPR ALWAYS_INLINE -#else -# define ALWAYS_INLINE_CONSTEXPR ALWAYS_INLINE CONSTEXPR -#endif -#ifndef NOEXCEPT -# define NOEXCEPT -#endif -#ifndef MOVE -# define MOVE(x) x -#endif -#ifndef FINAL -# define FINAL -#endif -#ifndef DEFAULT_CTOR -# define DEFAULT_CTOR {} -#endif -#ifndef DEFAULT_DTOR -# define DEFAULT_DTOR {} -#endif -#ifndef DEFAULT_ASSIGN -# define DEFAULT_ASSIGN {return *this;} -#endif -#ifndef DELETED -# define DELETED {assert(false);} -# define DELETED_ASSIGN {assert(false);return *this;} -#else -# define DELETED_ASSIGN DELETED -#endif +// This is just to support code generated with older versions of interrogate. +#define MOVE(x) (std::move(x)) #ifndef LINK_ALL_STATIC diff --git a/dtool/src/dtoolbase/fakestringstream.h b/dtool/src/dtoolbase/fakestringstream.h index 6711eb8d2a..4ff2a971f0 100644 --- a/dtool/src/dtoolbase/fakestringstream.h +++ b/dtool/src/dtoolbase/fakestringstream.h @@ -18,9 +18,7 @@ #include #include -#ifdef HAVE_NAMESPACE using namespace std; -#endif class fake_istream_buffer { public: diff --git a/dtool/src/dtoolbase/memoryHook.I b/dtool/src/dtoolbase/memoryHook.I index bd5a55af79..055856f37b 100644 --- a/dtool/src/dtoolbase/memoryHook.I +++ b/dtool/src/dtoolbase/memoryHook.I @@ -38,7 +38,7 @@ dec_heap(size_t size) { * Returns the global memory alignment. This is the number of bytes at which * each allocated memory pointer will be aligned. */ -CONSTEXPR size_t MemoryHook:: +constexpr size_t MemoryHook:: get_memory_alignment() { return MEMORY_HOOK_ALIGNMENT; } diff --git a/dtool/src/dtoolbase/memoryHook.h b/dtool/src/dtoolbase/memoryHook.h index 9472983d75..b5fceacd53 100644 --- a/dtool/src/dtoolbase/memoryHook.h +++ b/dtool/src/dtoolbase/memoryHook.h @@ -52,7 +52,7 @@ public: bool heap_trim(size_t pad); - CONSTEXPR static size_t get_memory_alignment(); + constexpr static size_t get_memory_alignment(); virtual void *mmap_alloc(size_t size, bool allow_exec); virtual void mmap_free(void *ptr, size_t size); diff --git a/dtool/src/dtoolbase/mutexDummyImpl.h b/dtool/src/dtoolbase/mutexDummyImpl.h index cbb6132f90..3474d443ed 100644 --- a/dtool/src/dtoolbase/mutexDummyImpl.h +++ b/dtool/src/dtoolbase/mutexDummyImpl.h @@ -23,11 +23,10 @@ */ class EXPCL_DTOOL_DTOOLBASE MutexDummyImpl { public: - CONSTEXPR MutexDummyImpl() DEFAULT_CTOR; + constexpr MutexDummyImpl() = default; + MutexDummyImpl(const MutexDummyImpl ©) = delete; -private: - MutexDummyImpl(const MutexDummyImpl ©) DELETED; - MutexDummyImpl &operator = (const MutexDummyImpl ©) DELETED_ASSIGN; + MutexDummyImpl &operator = (const MutexDummyImpl ©) = delete; public: ALWAYS_INLINE void lock(); diff --git a/dtool/src/dtoolbase/mutexPosixImpl.I b/dtool/src/dtoolbase/mutexPosixImpl.I index 5b884dcde5..0bc338a2eb 100644 --- a/dtool/src/dtoolbase/mutexPosixImpl.I +++ b/dtool/src/dtoolbase/mutexPosixImpl.I @@ -14,8 +14,8 @@ /** * */ -CONSTEXPR MutexPosixImpl:: -MutexPosixImpl() NOEXCEPT : _lock(PTHREAD_MUTEX_INITIALIZER) { +constexpr MutexPosixImpl:: +MutexPosixImpl() noexcept : _lock(PTHREAD_MUTEX_INITIALIZER) { } /** @@ -63,8 +63,8 @@ unlock() { * */ #ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP -CONSTEXPR ReMutexPosixImpl:: -ReMutexPosixImpl() NOEXCEPT : _lock(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) { +constexpr ReMutexPosixImpl:: +ReMutexPosixImpl() noexcept : _lock(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) { } #else INLINE ReMutexPosixImpl:: diff --git a/dtool/src/dtoolbase/mutexPosixImpl.h b/dtool/src/dtoolbase/mutexPosixImpl.h index 6baf70d962..996001b114 100644 --- a/dtool/src/dtoolbase/mutexPosixImpl.h +++ b/dtool/src/dtoolbase/mutexPosixImpl.h @@ -28,12 +28,11 @@ */ class EXPCL_DTOOL_DTOOLBASE MutexPosixImpl { public: - CONSTEXPR MutexPosixImpl() NOEXCEPT; + constexpr MutexPosixImpl() noexcept; + MutexPosixImpl(const MutexPosixImpl ©) = delete; INLINE ~MutexPosixImpl(); -private: - MutexPosixImpl(const MutexPosixImpl ©) DELETED; - MutexPosixImpl &operator = (const MutexPosixImpl ©) DELETED_ASSIGN; + MutexPosixImpl &operator = (const MutexPosixImpl ©) = delete; public: INLINE void lock(); @@ -51,15 +50,14 @@ private: class EXPCL_DTOOL_DTOOLBASE ReMutexPosixImpl { public: #ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP - CONSTEXPR ReMutexPosixImpl() NOEXCEPT; + constexpr ReMutexPosixImpl() noexcept; #else INLINE ReMutexPosixImpl(); #endif + ReMutexPosixImpl(const ReMutexPosixImpl ©) = delete; INLINE ~ReMutexPosixImpl(); -private: - ReMutexPosixImpl(const ReMutexPosixImpl ©) DELETED; - ReMutexPosixImpl &operator = (const ReMutexPosixImpl ©) DELETED; + ReMutexPosixImpl &operator = (const ReMutexPosixImpl ©) = delete; public: INLINE void lock(); diff --git a/dtool/src/dtoolbase/mutexSpinlockImpl.I b/dtool/src/dtoolbase/mutexSpinlockImpl.I index 97838772d2..b3eb084181 100644 --- a/dtool/src/dtoolbase/mutexSpinlockImpl.I +++ b/dtool/src/dtoolbase/mutexSpinlockImpl.I @@ -14,7 +14,7 @@ /** * */ -CONSTEXPR MutexSpinlockImpl:: +constexpr MutexSpinlockImpl:: MutexSpinlockImpl() : _lock(0) { } diff --git a/dtool/src/dtoolbase/mutexSpinlockImpl.h b/dtool/src/dtoolbase/mutexSpinlockImpl.h index 0c51522b1e..c7dfb72cf2 100644 --- a/dtool/src/dtoolbase/mutexSpinlockImpl.h +++ b/dtool/src/dtoolbase/mutexSpinlockImpl.h @@ -29,11 +29,10 @@ */ class EXPCL_DTOOL_DTOOLBASE MutexSpinlockImpl { public: - CONSTEXPR MutexSpinlockImpl(); + constexpr MutexSpinlockImpl(); + MutexSpinlockImpl(const MutexSpinlockImpl ©) = delete; -private: - MutexSpinlockImpl(const MutexSpinlockImpl ©) DELETED; - MutexSpinlockImpl &operator = (const MutexSpinlockImpl ©) DELETED_ASSIGN; + MutexSpinlockImpl &operator = (const MutexSpinlockImpl ©) = delete; public: INLINE void lock(); diff --git a/dtool/src/dtoolbase/mutexWin32Impl.h b/dtool/src/dtoolbase/mutexWin32Impl.h index 017832694c..550d4944ab 100644 --- a/dtool/src/dtoolbase/mutexWin32Impl.h +++ b/dtool/src/dtoolbase/mutexWin32Impl.h @@ -29,11 +29,10 @@ class EXPCL_DTOOL_DTOOLBASE MutexWin32Impl { public: MutexWin32Impl(); + MutexWin32Impl(const MutexWin32Impl ©) = delete; INLINE ~MutexWin32Impl(); -private: - MutexWin32Impl(const MutexWin32Impl ©) DELETED; - MutexWin32Impl &operator = (const MutexWin32Impl ©) DELETED_ASSIGN; + MutexWin32Impl &operator = (const MutexWin32Impl ©) = delete; public: INLINE void lock(); diff --git a/dtool/src/dtoolbase/nearly_zero.h b/dtool/src/dtoolbase/nearly_zero.h index af71ad9419..0f31fdfb2e 100644 --- a/dtool/src/dtoolbase/nearly_zero.h +++ b/dtool/src/dtoolbase/nearly_zero.h @@ -24,17 +24,17 @@ // identifier, and then returning the value of that identifier, seems to lead // to compilation errors (at least in VC7) in which sometimes // IS_THRESHOLD_COMPEQ(a, a, get_nearly_zero_value(a)) != 0. -CONSTEXPR double +constexpr double get_nearly_zero_value(double) { return 1.0e-12; } -CONSTEXPR float +constexpr float get_nearly_zero_value(float) { return 1.0e-6f; } -CONSTEXPR int +constexpr int get_nearly_zero_value(int) { // This is a bit silly, but we should nevertheless define it in case it is // called for an integer type. diff --git a/dtool/src/dtoolbase/pallocator.T b/dtool/src/dtoolbase/pallocator.T index e9bfd3f98e..59af0f0ec1 100644 --- a/dtool/src/dtoolbase/pallocator.T +++ b/dtool/src/dtoolbase/pallocator.T @@ -13,7 +13,7 @@ template INLINE pallocator_single:: -pallocator_single(TypeHandle type_handle) NOEXCEPT : +pallocator_single(TypeHandle type_handle) noexcept : _type_handle(type_handle) { } @@ -37,7 +37,7 @@ deallocate(TYPENAME pallocator_single::pointer p, TYPENAME pallocator_sing template INLINE pallocator_array:: -pallocator_array(TypeHandle type_handle) NOEXCEPT : +pallocator_array(TypeHandle type_handle) noexcept : _type_handle(type_handle) { } diff --git a/dtool/src/dtoolbase/pallocator.h b/dtool/src/dtoolbase/pallocator.h index 3c91b6cc7e..8dfbb8178d 100644 --- a/dtool/src/dtoolbase/pallocator.h +++ b/dtool/src/dtoolbase/pallocator.h @@ -52,11 +52,11 @@ public: typedef TYPENAME allocator::const_reference const_reference; typedef TYPENAME allocator::size_type size_type; - INLINE pallocator_single(TypeHandle type_handle) NOEXCEPT; + INLINE pallocator_single(TypeHandle type_handle) noexcept; // template member functions in VC++ can only be defined in-class. template - INLINE pallocator_single(const pallocator_single ©) NOEXCEPT : + INLINE pallocator_single(const pallocator_single ©) noexcept : _type_handle(copy._type_handle) { } INLINE Type *allocate(size_type n, allocator::const_pointer hint = 0) @@ -81,11 +81,11 @@ public: typedef TYPENAME allocator::const_reference const_reference; typedef TYPENAME allocator::size_type size_type; - INLINE pallocator_array(TypeHandle type_handle = TypeHandle::none()) NOEXCEPT; + INLINE pallocator_array(TypeHandle type_handle = TypeHandle::none()) noexcept; // template member functions in VC++ can only be defined in-class. template - INLINE pallocator_array(const pallocator_array ©) NOEXCEPT : + INLINE pallocator_array(const pallocator_array ©) noexcept : _type_handle(copy._type_handle) { } INLINE Type *allocate(size_type n, allocator::const_pointer hint = 0) diff --git a/dtool/src/dtoolbase/pvector.h b/dtool/src/dtoolbase/pvector.h index 14bd542f37..8da0e88b85 100644 --- a/dtool/src/dtoolbase/pvector.h +++ b/dtool/src/dtoolbase/pvector.h @@ -43,27 +43,24 @@ class pvector : public vector > { public: typedef pallocator_array allocator; typedef vector base_class; - typedef TYPENAME base_class::size_type size_type; + typedef typename base_class::size_type size_type; explicit pvector(TypeHandle type_handle = pvector_type_handle) : base_class(allocator(type_handle)) { } pvector(const pvector ©) : base_class(copy) { } + pvector(pvector &&from) noexcept : base_class(move(from)) {}; explicit pvector(size_type n, TypeHandle type_handle = pvector_type_handle) : base_class(n, Type(), allocator(type_handle)) { } explicit pvector(size_type n, const Type &value, TypeHandle type_handle = pvector_type_handle) : base_class(n, value, allocator(type_handle)) { } pvector(const Type *begin, const Type *end, TypeHandle type_handle = pvector_type_handle) : base_class(begin, end, allocator(type_handle)) { } -#ifdef USE_MOVE_SEMANTICS - pvector(pvector &&from) NOEXCEPT : base_class(move(from)) {}; - - pvector &operator =(pvector &&from) NOEXCEPT { - base_class::operator =(move(from)); - return *this; - } -#endif - pvector &operator =(const pvector ©) { base_class::operator =(copy); return *this; } + + pvector &operator =(pvector &&from) noexcept { + base_class::operator =(move(from)); + return *this; + } }; #endif // USE_STL_ALLOCATOR diff --git a/dtool/src/dtoolbase/typeHandle.I b/dtool/src/dtoolbase/typeHandle.I index 3e9e53a9ae..bb7a737bf2 100644 --- a/dtool/src/dtoolbase/typeHandle.I +++ b/dtool/src/dtoolbase/typeHandle.I @@ -194,7 +194,7 @@ output(ostream &out) const { /** * Returns a special zero-valued TypeHandle that is used to indicate no type. */ -CONSTEXPR TypeHandle TypeHandle:: +constexpr TypeHandle TypeHandle:: none() { return TypeHandle(0); } @@ -213,7 +213,7 @@ operator bool () const { * * See TypeRegistry::find_type_by_id(). */ -CONSTEXPR TypeHandle TypeHandle:: +constexpr TypeHandle TypeHandle:: from_index(int index) { return TypeHandle(index); } @@ -222,6 +222,6 @@ from_index(int index) { * Private constructor for initializing a TypeHandle from an index, used by * none() and by from_index(). */ -CONSTEXPR TypeHandle:: +constexpr TypeHandle:: TypeHandle(int index) : _index(index) { } diff --git a/dtool/src/dtoolbase/typeHandle.h b/dtool/src/dtoolbase/typeHandle.h index 3138d51e4b..ed539e0619 100644 --- a/dtool/src/dtoolbase/typeHandle.h +++ b/dtool/src/dtoolbase/typeHandle.h @@ -78,9 +78,9 @@ class TypedObject; * that ancestry of a particular type may be queried, and the type name may be * retrieved for run-time display. */ -class EXPCL_DTOOL_DTOOLBASE TypeHandle FINAL { +class EXPCL_DTOOL_DTOOLBASE TypeHandle final { PUBLISHED: - TypeHandle() NOEXCEPT DEFAULT_CTOR; + TypeHandle() noexcept = default; enum MemoryClass { MC_singleton, @@ -129,7 +129,7 @@ PUBLISHED: INLINE int get_index() const; INLINE void output(ostream &out) const; - CONSTEXPR static TypeHandle none(); + constexpr static TypeHandle none(); INLINE operator bool () const; MAKE_PROPERTY(index, get_index); @@ -142,10 +142,10 @@ public: void *reallocate_array(void *ptr, size_t size) RETURNS_ALIGNED(MEMORY_HOOK_ALIGNMENT); void deallocate_array(void *ptr); - CONSTEXPR static TypeHandle from_index(int index); + constexpr static TypeHandle from_index(int index); private: - CONSTEXPR TypeHandle(int index); + constexpr TypeHandle(int index); // Only kept temporarily for ABI compatibility. static TypeHandle _none; diff --git a/dtool/src/dtoolbase/typedObject.h b/dtool/src/dtoolbase/typedObject.h index f3d6c193e3..dd60515f16 100644 --- a/dtool/src/dtoolbase/typedObject.h +++ b/dtool/src/dtoolbase/typedObject.h @@ -87,9 +87,9 @@ */ class EXPCL_DTOOL_DTOOLBASE TypedObject : public MemoryBase { public: - INLINE TypedObject() DEFAULT_CTOR; - INLINE TypedObject(const TypedObject ©) DEFAULT_CTOR; - INLINE TypedObject &operator = (const TypedObject ©) DEFAULT_ASSIGN; + INLINE TypedObject() = default; + INLINE TypedObject(const TypedObject ©) = default; + INLINE TypedObject &operator = (const TypedObject ©) = default; PUBLISHED: // A virtual destructor is just a good idea. diff --git a/dtool/src/dtoolutil/filename.I b/dtool/src/dtoolutil/filename.I index 9bc23dfca3..2f099548e3 100644 --- a/dtool/src/dtoolutil/filename.I +++ b/dtool/src/dtoolutil/filename.I @@ -54,24 +54,20 @@ Filename(const Filename ©) : { } -#ifdef USE_MOVE_SEMANTICS /** * */ INLINE Filename:: -Filename(string &&filename) NOEXCEPT { - _flags = 0; - (*this) = move(filename); +Filename(string &&filename) noexcept : _flags(0) { + (*this) = std::move(filename); } -#endif // USE_MOVE_SEMANTICS -#ifdef USE_MOVE_SEMANTICS /** * */ INLINE Filename:: -Filename(Filename &&from) NOEXCEPT : - _filename(move(from._filename)), +Filename(Filename &&from) noexcept : + _filename(std::move(from._filename)), _dirname_end(from._dirname_end), _basename_start(from._basename_start), _basename_end(from._basename_end), @@ -81,7 +77,6 @@ Filename(Filename &&from) NOEXCEPT : _flags(from._flags) { } -#endif // USE_MOVE_SEMANTICS /** * Creates an empty Filename. @@ -217,28 +212,25 @@ operator = (const Filename ©) { return *this; } -#ifdef USE_MOVE_SEMANTICS /** * */ INLINE Filename &Filename:: -operator = (string &&filename) NOEXCEPT { - _filename = move(filename); +operator = (string &&filename) noexcept { + _filename = std::move(filename); locate_basename(); locate_extension(); locate_hash(); return *this; } -#endif // USE_MOVE_SEMANTICS -#ifdef USE_MOVE_SEMANTICS /** * */ INLINE Filename &Filename:: -operator = (Filename &&from) NOEXCEPT { - _filename = move(from._filename); +operator = (Filename &&from) noexcept { + _filename = std::move(from._filename); _dirname_end = from._dirname_end; _basename_start = from._basename_start; _basename_end = from._basename_end; @@ -248,7 +240,6 @@ operator = (Filename &&from) NOEXCEPT { _flags = from._flags; return *this; } -#endif // USE_MOVE_SEMANTICS /** * diff --git a/dtool/src/dtoolutil/filename.h b/dtool/src/dtoolutil/filename.h index 76ee5e0b39..07927a846c 100644 --- a/dtool/src/dtoolutil/filename.h +++ b/dtool/src/dtoolutil/filename.h @@ -58,11 +58,8 @@ public: INLINE Filename(const string &filename); INLINE Filename(const wstring &filename); INLINE Filename(const Filename ©); - -#ifdef USE_MOVE_SEMANTICS - INLINE Filename(string &&filename) NOEXCEPT; - INLINE Filename(Filename &&from) NOEXCEPT; -#endif + INLINE Filename(string &&filename) noexcept; + INLINE Filename(Filename &&from) noexcept; PUBLISHED: INLINE Filename(); @@ -106,11 +103,8 @@ PUBLISHED: INLINE Filename &operator = (const wstring &filename); INLINE Filename &operator = (const char *filename); INLINE Filename &operator = (const Filename ©); - -#ifdef USE_MOVE_SEMANTICS - INLINE Filename &operator = (string &&filename) NOEXCEPT; - INLINE Filename &operator = (Filename &&from) NOEXCEPT; -#endif + INLINE Filename &operator = (string &&filename) noexcept; + INLINE Filename &operator = (Filename &&from) noexcept; // And retrieval is by any of the classic string operations. INLINE operator const string & () const; diff --git a/dtool/src/prc/notifyCategory.I b/dtool/src/prc/notifyCategory.I index 46aca56bb2..62a332b388 100644 --- a/dtool/src/prc/notifyCategory.I +++ b/dtool/src/prc/notifyCategory.I @@ -88,7 +88,7 @@ is_debug() const { * "debug" severities, and these methods are redefined to be static to make it * more obvious to the compiler. */ -CONSTEXPR bool NotifyCategory:: +constexpr bool NotifyCategory:: is_spam() { return false; } @@ -98,7 +98,7 @@ is_spam() { * "debug" severities, and these methods are redefined to be static to make it * more obvious to the compiler. */ -CONSTEXPR bool NotifyCategory:: +constexpr bool NotifyCategory:: is_debug() { return false; } diff --git a/dtool/src/prc/notifyCategory.h b/dtool/src/prc/notifyCategory.h index 61f4e71906..ee25b56268 100644 --- a/dtool/src/prc/notifyCategory.h +++ b/dtool/src/prc/notifyCategory.h @@ -55,8 +55,8 @@ PUBLISHED: INLINE bool is_spam() const; INLINE bool is_debug() const; #else - CONSTEXPR static bool is_spam(); - CONSTEXPR static bool is_debug(); + constexpr static bool is_spam(); + constexpr static bool is_debug(); #endif INLINE bool is_info() const; INLINE bool is_warning() const; diff --git a/dtool/src/prc/notifyCategoryProxy.I b/dtool/src/prc/notifyCategoryProxy.I index 9a05f35625..8c0a5dc47d 100644 --- a/dtool/src/prc/notifyCategoryProxy.I +++ b/dtool/src/prc/notifyCategoryProxy.I @@ -74,7 +74,7 @@ is_spam() { } #else template -CONSTEXPR bool NotifyCategoryProxy:: +constexpr bool NotifyCategoryProxy:: is_spam() { return false; } @@ -92,7 +92,7 @@ is_debug() { } #else template -CONSTEXPR bool NotifyCategoryProxy:: +constexpr bool NotifyCategoryProxy:: is_debug() { return false; } diff --git a/dtool/src/prc/notifyCategoryProxy.h b/dtool/src/prc/notifyCategoryProxy.h index 653da558de..eaa83a8282 100644 --- a/dtool/src/prc/notifyCategoryProxy.h +++ b/dtool/src/prc/notifyCategoryProxy.h @@ -75,8 +75,8 @@ public: INLINE bool is_spam(); INLINE bool is_debug(); #else - CONSTEXPR static bool is_spam(); - CONSTEXPR static bool is_debug(); + constexpr static bool is_spam(); + constexpr static bool is_debug(); #endif INLINE bool is_info(); INLINE bool is_warning(); diff --git a/dtool/src/prc/streamWrapper.h b/dtool/src/prc/streamWrapper.h index f3e4028c1b..62e57fa9e1 100644 --- a/dtool/src/prc/streamWrapper.h +++ b/dtool/src/prc/streamWrapper.h @@ -24,9 +24,7 @@ class EXPCL_DTOOL_PRC StreamWrapperBase { protected: INLINE StreamWrapperBase(); - -private: - INLINE StreamWrapperBase(const StreamWrapperBase ©) DELETED; + INLINE StreamWrapperBase(const StreamWrapperBase ©) = delete; PUBLISHED: INLINE void acquire(); diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 56ffecdbd5..5c42bb9bf5 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2272,12 +2272,10 @@ DTOOL_CONFIG=[ ("DO_PIPELINING", '1', '1'), ("DEFAULT_PATHSEP", '";"', '":"'), ("WORDS_BIGENDIAN", 'UNDEF', 'UNDEF'), - ("HAVE_NAMESPACE", '1', '1'), ("HAVE_OPEN_MASK", 'UNDEF', 'UNDEF'), ("HAVE_LOCKF", '1', '1'), ("HAVE_WCHAR_T", '1', '1'), ("HAVE_WSTRING", '1', '1'), - ("HAVE_TYPENAME", '1', '1'), ("SIMPLE_STRUCT_POINTERS", '1', 'UNDEF'), ("HAVE_DINKUM", 'UNDEF', 'UNDEF'), ("HAVE_STL_HASH", 'UNDEF', 'UNDEF'), diff --git a/panda/src/bullet/bulletTriangleMesh.h b/panda/src/bullet/bulletTriangleMesh.h index 0f9cb8174b..27c0598b13 100644 --- a/panda/src/bullet/bulletTriangleMesh.h +++ b/panda/src/bullet/bulletTriangleMesh.h @@ -32,7 +32,7 @@ class EXPCL_PANDABULLET BulletTriangleMesh : public TypedWritableReferenceCount { PUBLISHED: BulletTriangleMesh(); - ~BulletTriangleMesh() DEFAULT_DTOR; + ~BulletTriangleMesh() = default; void add_triangle(const LPoint3 &p0, const LPoint3 &p1, diff --git a/panda/src/display/displayRegion.I b/panda/src/display/displayRegion.I index 8982461879..e402e0ad7b 100644 --- a/panda/src/display/displayRegion.I +++ b/panda/src/display/displayRegion.I @@ -479,13 +479,8 @@ INLINE void DisplayRegion:: set_cull_result(PT(CullResult) cull_result, PT(SceneSetup) scene_setup, Thread *current_thread) { CDCullWriter cdata(_cycler_cull, true, current_thread); -#ifdef USE_MOVE_SEMANTICS cdata->_cull_result = move(cull_result); cdata->_scene_setup = move(scene_setup); -#else - swap(cdata->_cull_result, cull_result); - swap(cdata->_scene_setup, scene_setup); -#endif } /** diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index f65c5377fc..b3f931e44b 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -1538,7 +1538,7 @@ cull_to_bins(GraphicsEngine::Windows wlist, Thread *current_thread) { } // Save the results for next frame. - dr->set_cull_result(MOVE(cull_result), MOVE(scene_setup), current_thread); + dr->set_cull_result(move(cull_result), MOVE(scene_setup), current_thread); } } } diff --git a/panda/src/display/graphicsPipe.h b/panda/src/display/graphicsPipe.h index f7994b92e1..501cc535be 100644 --- a/panda/src/display/graphicsPipe.h +++ b/panda/src/display/graphicsPipe.h @@ -52,9 +52,8 @@ class DisplayInformation; class EXPCL_PANDA_DISPLAY GraphicsPipe : public TypedReferenceCount { protected: GraphicsPipe(); -private: - GraphicsPipe(const GraphicsPipe ©) DELETED; - GraphicsPipe &operator = (const GraphicsPipe ©) DELETED_ASSIGN; + GraphicsPipe(const GraphicsPipe ©) = delete; + GraphicsPipe &operator = (const GraphicsPipe ©) = delete; PUBLISHED: virtual ~GraphicsPipe(); diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index e508be9c6a..fecce7e56a 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -286,7 +286,7 @@ PUBLISHED: MAKE_PROPERTY(driver_shader_version_minor, get_driver_shader_version_minor); bool set_scene(SceneSetup *scene_setup); - virtual SceneSetup *get_scene() const FINAL; + virtual SceneSetup *get_scene() const final; MAKE_PROPERTY(scene, get_scene, set_scene); public: diff --git a/panda/src/event/asyncFuture.h b/panda/src/event/asyncFuture.h index cbed94b158..18d5b773f1 100644 --- a/panda/src/event/asyncFuture.h +++ b/panda/src/event/asyncFuture.h @@ -160,7 +160,7 @@ INLINE ostream &operator << (ostream &out, const AsyncFuture &fut) { /** * Specific future that collects the results of several futures. */ -class EXPCL_PANDA_EVENT AsyncGatheringFuture FINAL : public AsyncFuture { +class EXPCL_PANDA_EVENT AsyncGatheringFuture final : public AsyncFuture { private: AsyncGatheringFuture(AsyncFuture::Futures futures); diff --git a/panda/src/event/asyncTask.h b/panda/src/event/asyncTask.h index 9712daa0f5..e36c3c8324 100644 --- a/panda/src/event/asyncTask.h +++ b/panda/src/event/asyncTask.h @@ -103,8 +103,8 @@ protected: void jump_to_task_chain(AsyncTaskManager *manager); DoneStatus unlock_and_do_task(); - virtual bool cancel() FINAL; - virtual bool is_task() const FINAL {return true;} + virtual bool cancel() final; + virtual bool is_task() const final {return true;} virtual bool is_runnable(); virtual DoneStatus do_task(); diff --git a/panda/src/event/eventParameter.h b/panda/src/event/eventParameter.h index 65dbf550c8..24ea3ec1e2 100644 --- a/panda/src/event/eventParameter.h +++ b/panda/src/event/eventParameter.h @@ -34,7 +34,7 @@ */ class EXPCL_PANDA_EVENT EventParameter { PUBLISHED: - INLINE EventParameter() DEFAULT_CTOR; + INLINE EventParameter() = default; INLINE EventParameter(nullptr_t) {}; INLINE EventParameter(const TypedWritableReferenceCount *ptr); INLINE EventParameter(const TypedReferenceCount *ptr); diff --git a/panda/src/event/pythonTask.h b/panda/src/event/pythonTask.h index 48826769de..33dde9af0a 100644 --- a/panda/src/event/pythonTask.h +++ b/panda/src/event/pythonTask.h @@ -26,7 +26,7 @@ * This class exists to allow association of a Python function or coroutine * with the AsyncTaskManager. */ -class PythonTask FINAL : public AsyncTask { +class PythonTask final : public AsyncTask { PUBLISHED: PythonTask(PyObject *function = Py_None, const string &name = string()); virtual ~PythonTask(); diff --git a/panda/src/express/nodePointerTo.I b/panda/src/express/nodePointerTo.I index 5485adcaaa..c035cd34cf 100644 --- a/panda/src/express/nodePointerTo.I +++ b/panda/src/express/nodePointerTo.I @@ -33,14 +33,13 @@ NodePointerTo(const NodePointerTo ©) : } #endif // CPPPARSER -#ifdef USE_MOVE_SEMANTICS #ifndef CPPPARSER /** * */ template INLINE NodePointerTo:: -NodePointerTo(NodePointerTo &&from) NOEXCEPT : +NodePointerTo(NodePointerTo &&from) noexcept : NodePointerToBase((NodePointerToBase &&)from) { } @@ -52,12 +51,11 @@ NodePointerTo(NodePointerTo &&from) NOEXCEPT : */ template INLINE NodePointerTo &NodePointerTo:: -operator = (NodePointerTo &&from) NOEXCEPT { +operator = (NodePointerTo &&from) noexcept { this->reassign(move(from)); return *this; } #endif // CPPPARSER -#endif // USE_MOVE_SEMANTICS #ifndef CPPPARSER /** @@ -167,14 +165,13 @@ NodeConstPointerTo(const NodeConstPointerTo ©) : } #endif // CPPPARSER -#ifdef USE_MOVE_SEMANTICS #ifndef CPPPARSER /** * */ template INLINE NodeConstPointerTo:: -NodeConstPointerTo(NodePointerTo &&from) NOEXCEPT : +NodeConstPointerTo(NodePointerTo &&from) noexcept : NodePointerToBase((NodePointerToBase &&)from) { } @@ -186,7 +183,7 @@ NodeConstPointerTo(NodePointerTo &&from) NOEXCEPT : */ template INLINE NodeConstPointerTo:: -NodeConstPointerTo(NodeConstPointerTo &&from) NOEXCEPT : +NodeConstPointerTo(NodeConstPointerTo &&from) noexcept : NodePointerToBase((NodePointerToBase &&)from) { } @@ -198,7 +195,7 @@ NodeConstPointerTo(NodeConstPointerTo &&from) NOEXCEPT : */ template INLINE NodeConstPointerTo &NodeConstPointerTo:: -operator = (NodePointerTo &&from) NOEXCEPT { +operator = (NodePointerTo &&from) noexcept { this->reassign(move(from)); return *this; } @@ -210,12 +207,11 @@ operator = (NodePointerTo &&from) NOEXCEPT { */ template INLINE NodeConstPointerTo &NodeConstPointerTo:: -operator = (NodeConstPointerTo &&from) NOEXCEPT { +operator = (NodeConstPointerTo &&from) noexcept { this->reassign(move(from)); return *this; } #endif // CPPPARSER -#endif // USE_MOVE_SEMANTICS #ifndef CPPPARSER /** diff --git a/panda/src/express/nodePointerTo.h b/panda/src/express/nodePointerTo.h index ca9832d424..169aeb71e5 100644 --- a/panda/src/express/nodePointerTo.h +++ b/panda/src/express/nodePointerTo.h @@ -31,11 +31,9 @@ public: typedef TYPENAME NodePointerToBase::To To; INLINE NodePointerTo(To *ptr = (To *)NULL); INLINE NodePointerTo(const NodePointerTo ©); + INLINE NodePointerTo(NodePointerTo &&from) noexcept; -#ifdef USE_MOVE_SEMANTICS - INLINE NodePointerTo(NodePointerTo &&from) NOEXCEPT; - INLINE NodePointerTo &operator = (NodePointerTo &&from) NOEXCEPT; -#endif + INLINE NodePointerTo &operator = (NodePointerTo &&from) noexcept; INLINE To &operator *() const; INLINE To *operator -> () const; @@ -65,13 +63,11 @@ public: INLINE NodeConstPointerTo(const To *ptr = (const To *)NULL); INLINE NodeConstPointerTo(const NodePointerTo ©); INLINE NodeConstPointerTo(const NodeConstPointerTo ©); + INLINE NodeConstPointerTo(NodePointerTo &&from) noexcept; + INLINE NodeConstPointerTo(NodeConstPointerTo &&from) noexcept; -#ifdef USE_MOVE_SEMANTICS - INLINE NodeConstPointerTo(NodePointerTo &&from) NOEXCEPT; - INLINE NodeConstPointerTo(NodeConstPointerTo &&from) NOEXCEPT; - INLINE NodeConstPointerTo &operator = (NodePointerTo &&from) NOEXCEPT; - INLINE NodeConstPointerTo &operator = (NodeConstPointerTo &&from) NOEXCEPT; -#endif + INLINE NodeConstPointerTo &operator = (NodePointerTo &&from) noexcept; + INLINE NodeConstPointerTo &operator = (NodeConstPointerTo &&from) noexcept; INLINE const To &operator *() const; INLINE const To *operator -> () const; @@ -86,12 +82,12 @@ public: }; template -void swap(NodePointerTo &one, NodePointerTo &two) NOEXCEPT { +void swap(NodePointerTo &one, NodePointerTo &two) noexcept { one.swap(two); } template -void swap(NodeConstPointerTo &one, NodeConstPointerTo &two) NOEXCEPT { +void swap(NodeConstPointerTo &one, NodeConstPointerTo &two) noexcept { one.swap(two); } diff --git a/panda/src/express/nodePointerToBase.I b/panda/src/express/nodePointerToBase.I index 18f04def9a..1cb22132d5 100644 --- a/panda/src/express/nodePointerToBase.I +++ b/panda/src/express/nodePointerToBase.I @@ -38,13 +38,12 @@ INLINE NodePointerToBase:: reassign((To *)NULL); } -#ifdef USE_MOVE_SEMANTICS /** * */ template INLINE NodePointerToBase:: -NodePointerToBase(NodePointerToBase &&from) NOEXCEPT { +NodePointerToBase(NodePointerToBase &&from) noexcept { _void_ptr = from._void_ptr; from._void_ptr = (void *)NULL; } @@ -57,7 +56,7 @@ NodePointerToBase(NodePointerToBase &&from) NOEXCEPT { */ template INLINE void NodePointerToBase:: -reassign(NodePointerToBase &&from) NOEXCEPT { +reassign(NodePointerToBase &&from) noexcept { To *old_ptr = (To *)this->_void_ptr; this->_void_ptr = from._void_ptr; @@ -68,7 +67,6 @@ reassign(NodePointerToBase &&from) NOEXCEPT { node_unref_delete(old_ptr); } } -#endif // USE_MOVE_SEMANTICS /** * This is the main work of the NodePointerTo family. When the pointer is diff --git a/panda/src/express/nodePointerToBase.h b/panda/src/express/nodePointerToBase.h index e7bb9ad526..0b28a5c6bc 100644 --- a/panda/src/express/nodePointerToBase.h +++ b/panda/src/express/nodePointerToBase.h @@ -36,11 +36,9 @@ protected: INLINE NodePointerToBase(To *ptr); INLINE NodePointerToBase(const NodePointerToBase ©); INLINE ~NodePointerToBase(); + INLINE NodePointerToBase(NodePointerToBase &&from) noexcept; -#ifdef USE_MOVE_SEMANTICS - INLINE NodePointerToBase(NodePointerToBase &&from) NOEXCEPT; - INLINE void reassign(NodePointerToBase &&from) NOEXCEPT; -#endif + INLINE void reassign(NodePointerToBase &&from) noexcept; void reassign(To *ptr); INLINE void reassign(const NodePointerToBase ©); diff --git a/panda/src/express/pointerTo.I b/panda/src/express/pointerTo.I index 62962a83e3..bc71cfbfd9 100644 --- a/panda/src/express/pointerTo.I +++ b/panda/src/express/pointerTo.I @@ -16,7 +16,7 @@ */ template ALWAYS_INLINE PointerTo:: -PointerTo(To *ptr) NOEXCEPT : PointerToBase(ptr) { +PointerTo(To *ptr) noexcept : PointerToBase(ptr) { } /** @@ -29,13 +29,12 @@ PointerTo(const PointerTo ©) : { } -#ifdef USE_MOVE_SEMANTICS /** * */ template INLINE PointerTo:: -PointerTo(PointerTo &&from) NOEXCEPT : +PointerTo(PointerTo &&from) noexcept : PointerToBase(move(from)) { } @@ -45,18 +44,17 @@ PointerTo(PointerTo &&from) NOEXCEPT : */ template INLINE PointerTo &PointerTo:: -operator = (PointerTo &&from) NOEXCEPT { +operator = (PointerTo &&from) noexcept { this->reassign(move(from)); return *this; } -#endif // USE_MOVE_SEMANTICS /** * */ template -CONSTEXPR TYPENAME PointerTo::To &PointerTo:: -operator *() const NOEXCEPT { +constexpr TYPENAME PointerTo::To &PointerTo:: +operator *() const noexcept { return *((To *)(this->_void_ptr)); } @@ -64,8 +62,8 @@ operator *() const NOEXCEPT { * */ template -CONSTEXPR TYPENAME PointerTo::To *PointerTo:: -operator -> () const NOEXCEPT { +constexpr TYPENAME PointerTo::To *PointerTo:: +operator -> () const noexcept { return (To *)(this->_void_ptr); } @@ -76,8 +74,8 @@ operator -> () const NOEXCEPT { * goes because either will be correct. */ template -CONSTEXPR PointerTo:: -operator T * () const NOEXCEPT { +constexpr PointerTo:: +operator T * () const noexcept { return (To *)(this->_void_ptr); } @@ -99,8 +97,8 @@ cheat() { * compiler problems, particularly for implicit upcasts. */ template -CONSTEXPR TYPENAME PointerTo::To *PointerTo:: -p() const NOEXCEPT { +constexpr TYPENAME PointerTo::To *PointerTo:: +p() const noexcept { return (To *)(this->_void_ptr); } @@ -129,7 +127,7 @@ operator = (const PointerTo ©) { */ template ALWAYS_INLINE ConstPointerTo:: -ConstPointerTo(const TYPENAME ConstPointerTo::To *ptr) NOEXCEPT : +ConstPointerTo(const TYPENAME ConstPointerTo::To *ptr) noexcept : PointerToBase((TYPENAME ConstPointerTo::To *)ptr) { } @@ -154,13 +152,12 @@ ConstPointerTo(const ConstPointerTo ©) : { } -#ifdef USE_MOVE_SEMANTICS /** * */ template INLINE ConstPointerTo:: -ConstPointerTo(PointerTo &&from) NOEXCEPT : +ConstPointerTo(PointerTo &&from) noexcept : PointerToBase(move(from)) { } @@ -170,7 +167,7 @@ ConstPointerTo(PointerTo &&from) NOEXCEPT : */ template INLINE ConstPointerTo:: -ConstPointerTo(ConstPointerTo &&from) NOEXCEPT : +ConstPointerTo(ConstPointerTo &&from) noexcept : PointerToBase(move(from)) { } @@ -180,7 +177,7 @@ ConstPointerTo(ConstPointerTo &&from) NOEXCEPT : */ template INLINE ConstPointerTo &ConstPointerTo:: -operator = (PointerTo &&from) NOEXCEPT { +operator = (PointerTo &&from) noexcept { this->reassign(move(from)); return *this; } @@ -190,18 +187,17 @@ operator = (PointerTo &&from) NOEXCEPT { */ template INLINE ConstPointerTo &ConstPointerTo:: -operator = (ConstPointerTo &&from) NOEXCEPT { +operator = (ConstPointerTo &&from) noexcept { this->reassign(move(from)); return *this; } -#endif // USE_MOVE_SEMANTICS /** * */ template -CONSTEXPR const TYPENAME ConstPointerTo::To &ConstPointerTo:: -operator *() const NOEXCEPT { +constexpr const TYPENAME ConstPointerTo::To &ConstPointerTo:: +operator *() const noexcept { return *((To *)(this->_void_ptr)); } @@ -209,8 +205,8 @@ operator *() const NOEXCEPT { * */ template -CONSTEXPR const TYPENAME ConstPointerTo::To *ConstPointerTo:: -operator -> () const NOEXCEPT { +constexpr const TYPENAME ConstPointerTo::To *ConstPointerTo:: +operator -> () const noexcept { return (To *)(this->_void_ptr); } @@ -221,8 +217,8 @@ operator -> () const NOEXCEPT { * don't care which way it goes because either will be correct. */ template -CONSTEXPR ConstPointerTo:: -operator const T * () const NOEXCEPT { +constexpr ConstPointerTo:: +operator const T * () const noexcept { return (To *)(this->_void_ptr); } @@ -244,8 +240,8 @@ cheat() { * around compiler problems, particularly for implicit upcasts. */ template -CONSTEXPR const TYPENAME ConstPointerTo::To *ConstPointerTo:: -p() const NOEXCEPT { +constexpr const TYPENAME ConstPointerTo::To *ConstPointerTo:: +p() const noexcept { return (To *)(this->_void_ptr); } diff --git a/panda/src/express/pointerTo.h b/panda/src/express/pointerTo.h index 62abdf8e57..313ad41a55 100644 --- a/panda/src/express/pointerTo.h +++ b/panda/src/express/pointerTo.h @@ -70,20 +70,18 @@ class PointerTo : public PointerToBase { public: typedef TYPENAME PointerToBase::To To; PUBLISHED: - ALWAYS_INLINE_CONSTEXPR PointerTo() NOEXCEPT DEFAULT_CTOR; - ALWAYS_INLINE PointerTo(To *ptr) NOEXCEPT; + ALWAYS_INLINE constexpr PointerTo() noexcept = default; + ALWAYS_INLINE PointerTo(To *ptr) noexcept; INLINE PointerTo(const PointerTo ©); public: -#ifdef USE_MOVE_SEMANTICS - INLINE PointerTo(PointerTo &&from) NOEXCEPT; - INLINE PointerTo &operator = (PointerTo &&from) NOEXCEPT; -#endif + INLINE PointerTo(PointerTo &&from) noexcept; + INLINE PointerTo &operator = (PointerTo &&from) noexcept; - CONSTEXPR To &operator *() const NOEXCEPT; - CONSTEXPR To *operator -> () const NOEXCEPT; + constexpr To &operator *() const noexcept; + constexpr To *operator -> () const noexcept; // MSVC.NET 2005 insists that we use T *, and not To *, here. - CONSTEXPR operator T *() const NOEXCEPT; + constexpr operator T *() const noexcept; INLINE T *&cheat(); @@ -100,7 +98,7 @@ PUBLISHED: // the DCAST macro defined in typedObject.h instead, e.g. DCAST(MyType, // ptr). This provides a clean downcast that doesn't require .p() or any // double-casting, and it can be run-time checked for correctness. - CONSTEXPR To *p() const NOEXCEPT; + constexpr To *p() const noexcept; INLINE PointerTo &operator = (To *ptr); INLINE PointerTo &operator = (const PointerTo ©); @@ -133,27 +131,25 @@ class ConstPointerTo : public PointerToBase { public: typedef TYPENAME PointerToBase::To To; PUBLISHED: - ALWAYS_INLINE_CONSTEXPR ConstPointerTo() NOEXCEPT DEFAULT_CTOR; - ALWAYS_INLINE ConstPointerTo(const To *ptr) NOEXCEPT; + ALWAYS_INLINE constexpr ConstPointerTo() noexcept = default; + ALWAYS_INLINE ConstPointerTo(const To *ptr) noexcept; INLINE ConstPointerTo(const PointerTo ©); INLINE ConstPointerTo(const ConstPointerTo ©); public: -#ifdef USE_MOVE_SEMANTICS - INLINE ConstPointerTo(PointerTo &&from) NOEXCEPT; - INLINE ConstPointerTo(ConstPointerTo &&from) NOEXCEPT; - INLINE ConstPointerTo &operator = (PointerTo &&from) NOEXCEPT; - INLINE ConstPointerTo &operator = (ConstPointerTo &&from) NOEXCEPT; -#endif + INLINE ConstPointerTo(PointerTo &&from) noexcept; + INLINE ConstPointerTo(ConstPointerTo &&from) noexcept; + INLINE ConstPointerTo &operator = (PointerTo &&from) noexcept; + INLINE ConstPointerTo &operator = (ConstPointerTo &&from) noexcept; - CONSTEXPR const To &operator *() const NOEXCEPT; - CONSTEXPR const To *operator -> () const NOEXCEPT; - CONSTEXPR operator const T *() const NOEXCEPT; + constexpr const To &operator *() const noexcept; + constexpr const To *operator -> () const noexcept; + constexpr operator const T *() const noexcept; INLINE const T *&cheat(); PUBLISHED: - CONSTEXPR const To *p() const NOEXCEPT; + constexpr const To *p() const noexcept; INLINE ConstPointerTo &operator = (const To *ptr); INLINE ConstPointerTo &operator = (const PointerTo ©); @@ -173,12 +169,12 @@ PUBLISHED: // PointerTo objects without incurring the cost of unnecessary reference count // changes. The performance difference is dramatic! template -void swap(PointerTo &one, PointerTo &two) NOEXCEPT { +void swap(PointerTo &one, PointerTo &two) noexcept { one.swap(two); } template -void swap(ConstPointerTo &one, ConstPointerTo &two) NOEXCEPT { +void swap(ConstPointerTo &one, ConstPointerTo &two) noexcept { one.swap(two); } diff --git a/panda/src/express/pointerToArray.I b/panda/src/express/pointerToArray.I index 535de63d01..f665e38415 100644 --- a/panda/src/express/pointerToArray.I +++ b/panda/src/express/pointerToArray.I @@ -79,20 +79,17 @@ PointerToArray(const Element *begin, const Element *end, TypeHandle type_handle) { } -#ifdef USE_MOVE_SEMANTICS /** * */ template INLINE PointerToArray:: -PointerToArray(PointerToArray &&from) NOEXCEPT : +PointerToArray(PointerToArray &&from) noexcept : PointerToArrayBase(move(from)), _type_handle(from._type_handle) { } -#endif // USE_MOVE_SEMANTICS -#ifdef USE_MOVE_SEMANTICS /** * Initializes the PTA from a vector. */ @@ -103,7 +100,6 @@ PointerToArray(pvector &&from, TypeHandle type_handle) : _type_handle(type_handle) { } -#endif // USE_MOVE_SEMANTICS /** * @@ -628,18 +624,16 @@ operator = (const PointerToArray ©) { return *this; } -#ifdef USE_MOVE_SEMANTICS /** * */ template INLINE PointerToArray &PointerToArray:: -operator = (PointerToArray &&from) NOEXCEPT { +operator = (PointerToArray &&from) noexcept { _type_handle = from._type_handle; ((PointerToArray *)this)->reassign(move(from)); return *this; } -#endif // USE_MOVE_SEMANTICS /** * To empty the PTA, use the clear() method, since assignment to NULL is @@ -697,33 +691,28 @@ ConstPointerToArray(const ConstPointerToArray ©) : { } -#ifdef USE_MOVE_SEMANTICS /** * */ template INLINE ConstPointerToArray:: -ConstPointerToArray(PointerToArray &&from) NOEXCEPT : +ConstPointerToArray(PointerToArray &&from) noexcept : PointerToArrayBase(move(from)), _type_handle(from._type_handle) { } -#endif // USE_MOVE_SEMANTICS -#ifdef USE_MOVE_SEMANTICS /** * */ template INLINE ConstPointerToArray:: -ConstPointerToArray(ConstPointerToArray &&from) NOEXCEPT : +ConstPointerToArray(ConstPointerToArray &&from) noexcept : PointerToArrayBase(move(from)), _type_handle(from._type_handle) { } -#endif // USE_MOVE_SEMANTICS -#ifdef USE_MOVE_SEMANTICS /** * Initializes the PTA from a vector. */ @@ -734,7 +723,6 @@ ConstPointerToArray(pvector &&from, TypeHandle type_handle) : _type_handle(type_handle) { } -#endif // USE_MOVE_SEMANTICS /** * @@ -1090,31 +1078,27 @@ operator = (const ConstPointerToArray ©) { return *this; } -#ifdef USE_MOVE_SEMANTICS /** * */ template INLINE ConstPointerToArray &ConstPointerToArray:: -operator = (PointerToArray &&from) NOEXCEPT { +operator = (PointerToArray &&from) noexcept { _type_handle = from._type_handle; ((ConstPointerToArray *)this)->reassign(move(from)); return *this; } -#endif // USE_MOVE_SEMANTICS -#ifdef USE_MOVE_SEMANTICS /** * */ template INLINE ConstPointerToArray &ConstPointerToArray:: -operator = (ConstPointerToArray &&from) NOEXCEPT { +operator = (ConstPointerToArray &&from) noexcept { _type_handle = from._type_handle; ((ConstPointerToArray *)this)->reassign(move(from)); return *this; } -#endif // USE_MOVE_SEMANTICS /** * To empty the PTA, use the clear() method, since assignment to NULL is diff --git a/panda/src/express/pointerToArray.h b/panda/src/express/pointerToArray.h index 4e8a052e0f..251102f5e3 100644 --- a/panda/src/express/pointerToArray.h +++ b/panda/src/express/pointerToArray.h @@ -138,11 +138,8 @@ public: INLINE PointerToArray(size_type n, const Element &value, TypeHandle type_handle = get_type_handle(Element)); INLINE PointerToArray(const Element *begin, const Element *end, TypeHandle type_handle = get_type_handle(Element)); INLINE PointerToArray(const PointerToArray ©); - -#ifdef USE_MOVE_SEMANTICS - INLINE PointerToArray(PointerToArray &&from) NOEXCEPT; + INLINE PointerToArray(PointerToArray &&from) noexcept; INLINE explicit PointerToArray(pvector &&from, TypeHandle type_handle = get_type_handle(Element)); -#endif public: // Duplicating the interface of vector. The following member functions are @@ -224,11 +221,8 @@ public: operator = (ReferenceCountedVector *ptr); INLINE PointerToArray & operator = (const PointerToArray ©); - -#ifdef USE_MOVE_SEMANTICS INLINE PointerToArray & - operator = (PointerToArray &&from) NOEXCEPT; -#endif + operator = (PointerToArray &&from) noexcept; INLINE void clear(); @@ -299,12 +293,9 @@ PUBLISHED: INLINE ConstPointerToArray(const Element *begin, const Element *end, TypeHandle type_handle = get_type_handle(Element)); INLINE ConstPointerToArray(const PointerToArray ©); INLINE ConstPointerToArray(const ConstPointerToArray ©); - -#ifdef USE_MOVE_SEMANTICS - INLINE ConstPointerToArray(PointerToArray &&from) NOEXCEPT; - INLINE ConstPointerToArray(ConstPointerToArray &&from) NOEXCEPT; + INLINE ConstPointerToArray(PointerToArray &&from) noexcept; + INLINE ConstPointerToArray(ConstPointerToArray &&from) noexcept; INLINE explicit ConstPointerToArray(pvector &&from, TypeHandle type_handle = get_type_handle(Element)); -#endif // Duplicating the interface of vector. @@ -358,13 +349,10 @@ PUBLISHED: operator = (const PointerToArray ©); INLINE ConstPointerToArray & operator = (const ConstPointerToArray ©); - -#ifdef USE_MOVE_SEMANTICS INLINE ConstPointerToArray & - operator = (PointerToArray &&from) NOEXCEPT; + operator = (PointerToArray &&from) noexcept; INLINE ConstPointerToArray & - operator = (ConstPointerToArray &&from) NOEXCEPT; -#endif + operator = (ConstPointerToArray &&from) noexcept; INLINE void clear(); diff --git a/panda/src/express/pointerToArrayBase.I b/panda/src/express/pointerToArrayBase.I index de8c17d843..2b60162abc 100644 --- a/panda/src/express/pointerToArrayBase.I +++ b/panda/src/express/pointerToArrayBase.I @@ -132,17 +132,15 @@ PointerToArrayBase(const PointerToArrayBase ©) : { } -#ifdef USE_MOVE_SEMANTICS /** * */ template INLINE PointerToArrayBase:: -PointerToArrayBase(PointerToArrayBase &&from) NOEXCEPT : +PointerToArrayBase(PointerToArrayBase &&from) noexcept : PointerToBase >(move(from)) { } -#endif // USE_MOVE_SEMANTICS /** * diff --git a/panda/src/express/pointerToArrayBase.h b/panda/src/express/pointerToArrayBase.h index 8c33f69be2..6f6128e26b 100644 --- a/panda/src/express/pointerToArrayBase.h +++ b/panda/src/express/pointerToArrayBase.h @@ -73,10 +73,7 @@ public: protected: INLINE PointerToArrayBase(ReferenceCountedVector *ptr); INLINE PointerToArrayBase(const PointerToArrayBase ©); - -#ifdef USE_MOVE_SEMANTICS - INLINE PointerToArrayBase(PointerToArrayBase &&from) NOEXCEPT; -#endif + INLINE PointerToArrayBase(PointerToArrayBase &&from) noexcept; PUBLISHED: INLINE ~PointerToArrayBase(); diff --git a/panda/src/express/pointerToBase.I b/panda/src/express/pointerToBase.I index bf4ff877f0..27a02daa46 100644 --- a/panda/src/express/pointerToBase.I +++ b/panda/src/express/pointerToBase.I @@ -51,13 +51,12 @@ INLINE PointerToBase:: } } -#ifdef USE_MOVE_SEMANTICS /** * */ template INLINE PointerToBase:: -PointerToBase(PointerToBase &&from) NOEXCEPT { +PointerToBase(PointerToBase &&from) noexcept { _void_ptr = from._void_ptr; from._void_ptr = (void *)NULL; } @@ -70,7 +69,7 @@ PointerToBase(PointerToBase &&from) NOEXCEPT { */ template INLINE void PointerToBase:: -reassign(PointerToBase &&from) NOEXCEPT { +reassign(PointerToBase &&from) noexcept { // Protect against self-move-assignment. if (from._void_ptr != this->_void_ptr) { To *old_ptr = (To *)this->_void_ptr; @@ -84,7 +83,6 @@ reassign(PointerToBase &&from) NOEXCEPT { } } } -#endif // USE_MOVE_SEMANTICS /** * This is the main work of the PointerTo family. When the pointer is diff --git a/panda/src/express/pointerToBase.h b/panda/src/express/pointerToBase.h index 919f596c33..4ac546993c 100644 --- a/panda/src/express/pointerToBase.h +++ b/panda/src/express/pointerToBase.h @@ -31,18 +31,15 @@ public: typedef T To; protected: - ALWAYS_INLINE_CONSTEXPR PointerToBase() NOEXCEPT DEFAULT_CTOR; + ALWAYS_INLINE constexpr PointerToBase() noexcept = default; INLINE PointerToBase(To *ptr); INLINE PointerToBase(const PointerToBase ©); + INLINE PointerToBase(PointerToBase &&from) noexcept; INLINE ~PointerToBase(); -#ifdef USE_MOVE_SEMANTICS - INLINE PointerToBase(PointerToBase &&from) NOEXCEPT; - INLINE void reassign(PointerToBase &&from) NOEXCEPT; -#endif - INLINE void reassign(To *ptr); INLINE void reassign(const PointerToBase ©); + INLINE void reassign(PointerToBase &&from) noexcept; INLINE void update_type(To *ptr); diff --git a/panda/src/express/pointerToVoid.I b/panda/src/express/pointerToVoid.I index ee3a36e303..c6f981a7fb 100644 --- a/panda/src/express/pointerToVoid.I +++ b/panda/src/express/pointerToVoid.I @@ -14,8 +14,8 @@ /** * */ -CONSTEXPR PointerToVoid:: -PointerToVoid() NOEXCEPT : _void_ptr(nullptr) { +constexpr PointerToVoid:: +PointerToVoid() noexcept : _void_ptr(nullptr) { } /** @@ -30,7 +30,7 @@ PointerToVoid() NOEXCEPT : _void_ptr(nullptr) { * Returns true if the PointerTo is a NULL pointer, false otherwise. (Direct * comparison to a NULL pointer also works.) */ -CONSTEXPR bool PointerToVoid:: +constexpr bool PointerToVoid:: is_null() const { return _void_ptr == nullptr; } @@ -82,7 +82,7 @@ operator != (const PointerToVoid &other) const { * For internal use only. Use the global swap() function instead. */ INLINE void PointerToVoid:: -swap(PointerToVoid &other) NOEXCEPT { +swap(PointerToVoid &other) noexcept { AtomicAdjust::Pointer temp = _void_ptr; _void_ptr = other._void_ptr; other._void_ptr = temp; diff --git a/panda/src/express/pointerToVoid.h b/panda/src/express/pointerToVoid.h index 0d2c1d33e9..aca9ba15e7 100644 --- a/panda/src/express/pointerToVoid.h +++ b/panda/src/express/pointerToVoid.h @@ -32,14 +32,14 @@ */ class EXPCL_PANDAEXPRESS PointerToVoid : public MemoryBase { protected: - CONSTEXPR PointerToVoid() NOEXCEPT; + constexpr PointerToVoid() noexcept; //INLINE ~PointerToVoid(); private: - PointerToVoid(const PointerToVoid ©) DELETED; + PointerToVoid(const PointerToVoid ©) = delete; PUBLISHED: - CONSTEXPR bool is_null() const; + constexpr bool is_null() const; INLINE size_t get_hash() const; public: @@ -51,7 +51,7 @@ public: INLINE bool operator == (const PointerToVoid &other) const; INLINE bool operator != (const PointerToVoid &other) const; - INLINE void swap(PointerToVoid &other) NOEXCEPT; + INLINE void swap(PointerToVoid &other) noexcept; protected: // Within the PointerToVoid class, we only store a void pointer. This is diff --git a/panda/src/express/weakPointerToBase.I b/panda/src/express/weakPointerToBase.I index 252e5e9aa7..1c831529a1 100644 --- a/panda/src/express/weakPointerToBase.I +++ b/panda/src/express/weakPointerToBase.I @@ -63,7 +63,7 @@ WeakPointerToBase(const WeakPointerToBase ©) { */ template INLINE WeakPointerToBase:: -WeakPointerToBase(WeakPointerToBase &&from) NOEXCEPT { +WeakPointerToBase(WeakPointerToBase &&from) noexcept { // Protect against self-move-assignment. if (from._void_ptr != this->_void_ptr) { WeakReferenceList *old_ref = (To *)this->_weak_ref; @@ -163,7 +163,7 @@ reassign(const WeakPointerToBase ©) { */ template INLINE void WeakPointerToBase:: -reassign(WeakPointerToBase &&from) NOEXCEPT { +reassign(WeakPointerToBase &&from) noexcept { // Protect against self-move-assignment. if (from._void_ptr != this->_void_ptr) { WeakReferenceList *old_ref = (WeakReferenceList *)this->_weak_ref; diff --git a/panda/src/express/weakPointerToBase.h b/panda/src/express/weakPointerToBase.h index 6d3ce456b0..4870ef21d8 100644 --- a/panda/src/express/weakPointerToBase.h +++ b/panda/src/express/weakPointerToBase.h @@ -31,13 +31,13 @@ protected: INLINE WeakPointerToBase(To *ptr); INLINE WeakPointerToBase(const PointerToBase ©); INLINE WeakPointerToBase(const WeakPointerToBase ©); - INLINE WeakPointerToBase(WeakPointerToBase &&from) NOEXCEPT; + INLINE WeakPointerToBase(WeakPointerToBase &&from) noexcept; INLINE ~WeakPointerToBase(); void reassign(To *ptr); INLINE void reassign(const PointerToBase ©); INLINE void reassign(const WeakPointerToBase ©); - INLINE void reassign(WeakPointerToBase &&from) NOEXCEPT; + INLINE void reassign(WeakPointerToBase &&from) noexcept; INLINE void update_type(To *ptr); diff --git a/panda/src/glstuff/glCgShaderContext_src.h b/panda/src/glstuff/glCgShaderContext_src.h index d5bc721e61..63338b3520 100644 --- a/panda/src/glstuff/glCgShaderContext_src.h +++ b/panda/src/glstuff/glCgShaderContext_src.h @@ -25,7 +25,7 @@ class CLP(GraphicsStateGuardian); /** * xyz */ -class EXPCL_GL CLP(CgShaderContext) FINAL : public ShaderContext { +class EXPCL_GL CLP(CgShaderContext) final : public ShaderContext { public: friend class CLP(GraphicsStateGuardian); diff --git a/panda/src/glstuff/glShaderContext_src.h b/panda/src/glstuff/glShaderContext_src.h index 9ecfe9ed39..79ceeb713d 100644 --- a/panda/src/glstuff/glShaderContext_src.h +++ b/panda/src/glstuff/glShaderContext_src.h @@ -26,7 +26,7 @@ class CLP(GraphicsStateGuardian); /** * xyz */ -class EXPCL_GL CLP(ShaderContext) FINAL : public ShaderContext { +class EXPCL_GL CLP(ShaderContext) final : public ShaderContext { public: friend class CLP(GraphicsStateGuardian); diff --git a/panda/src/glstuff/glTextureContext_src.h b/panda/src/glstuff/glTextureContext_src.h index 9a345b397d..667e356d60 100644 --- a/panda/src/glstuff/glTextureContext_src.h +++ b/panda/src/glstuff/glTextureContext_src.h @@ -42,7 +42,7 @@ public: #endif #ifdef OPENGLES_1 - static CONSTEXPR bool needs_barrier(GLbitfield barrier) { return false; }; + static constexpr bool needs_barrier(GLbitfield barrier) { return false; }; #else bool needs_barrier(GLbitfield barrier); void mark_incoherent(bool wrote); diff --git a/panda/src/gobj/geom.I b/panda/src/gobj/geom.I index 413e2de055..0f504f4dac 100644 --- a/panda/src/gobj/geom.I +++ b/panda/src/gobj/geom.I @@ -443,17 +443,15 @@ CacheKey(const CacheKey ©) : { } -#ifdef USE_MOVE_SEMANTICS /** * */ INLINE Geom::CacheKey:: -CacheKey(CacheKey &&from) NOEXCEPT : +CacheKey(CacheKey &&from) noexcept : _source_data(move(from._source_data)), _modifier(move(from._modifier)) { } -#endif // USE_MOVE_SEMANTICS /** * Provides a unique ordering within the map. @@ -493,17 +491,15 @@ CacheEntry(Geom *source, const Geom::CacheKey &key) : { } -#ifdef USE_MOVE_SEMANTICS /** * */ INLINE Geom::CacheEntry:: -CacheEntry(Geom *source, Geom::CacheKey &&key) NOEXCEPT : +CacheEntry(Geom *source, Geom::CacheKey &&key) noexcept : _source(source), _key(move(key)) { } -#endif // USE_MOVE_SEMANTICS /** * diff --git a/panda/src/gobj/geom.h b/panda/src/gobj/geom.h index 50b050e578..41ac95adea 100644 --- a/panda/src/gobj/geom.h +++ b/panda/src/gobj/geom.h @@ -256,9 +256,8 @@ public: INLINE CacheKey(const GeomVertexData *source_data, const GeomMunger *modifier); INLINE CacheKey(const CacheKey ©); -#ifdef USE_MOVE_SEMANTICS - INLINE CacheKey(CacheKey &&from) NOEXCEPT; -#endif + INLINE CacheKey(CacheKey &&from) noexcept; + INLINE bool operator < (const CacheKey &other) const; CPT(GeomVertexData) _source_data; @@ -271,9 +270,8 @@ public: const GeomVertexData *source_data, const GeomMunger *modifier); INLINE CacheEntry(Geom *source, const CacheKey &key); -#ifdef USE_MOVE_SEMANTICS - INLINE CacheEntry(Geom *source, CacheKey &&key) NOEXCEPT; -#endif + INLINE CacheEntry(Geom *source, CacheKey &&key) noexcept; + ALLOC_DELETED_CHAIN(CacheEntry); virtual void evict_callback(); @@ -406,14 +404,13 @@ class EXPCL_PANDA_GOBJ GeomPipelineReader : public GeomEnums { public: INLINE GeomPipelineReader(Thread *current_thread); INLINE GeomPipelineReader(const Geom *object, Thread *current_thread); -private: - GeomPipelineReader(const GeomPipelineReader ©) DELETED; - GeomPipelineReader &operator = (const GeomPipelineReader ©) DELETED_ASSIGN; - -public: + GeomPipelineReader(const GeomPipelineReader ©) = delete; INLINE ~GeomPipelineReader(); + ALLOC_DELETED_CHAIN(GeomPipelineReader); + GeomPipelineReader &operator = (const GeomPipelineReader ©) = delete; + INLINE void set_object(const Geom *object); INLINE const Geom *get_object() const; INLINE Thread *get_current_thread() const; diff --git a/panda/src/gobj/geomMunger.cxx b/panda/src/gobj/geomMunger.cxx index fccbdab0b6..bbbc9e3522 100644 --- a/panda/src/gobj/geomMunger.cxx +++ b/panda/src/gobj/geomMunger.cxx @@ -147,12 +147,9 @@ munge_geom(CPT(Geom) &geom, CPT(GeomVertexData) &data, // Record the new result in the cache. if (entry == (Geom::CacheEntry *)NULL) { // Create a new entry for the result. -#ifdef USE_MOVE_SEMANTICS // We don't need the key anymore, move the pointers into the CacheEntry. entry = new Geom::CacheEntry(orig_geom, move(key)); -#else - entry = new Geom::CacheEntry(orig_geom, key); -#endif + { LightMutexHolder holder(orig_geom->_cache_lock); bool inserted = orig_geom->_cache.insert(Geom::Cache::value_type(&entry->_key, entry)).second; diff --git a/panda/src/gobj/geomPrimitive.h b/panda/src/gobj/geomPrimitive.h index 8748c86799..50cb5695aa 100644 --- a/panda/src/gobj/geomPrimitive.h +++ b/panda/src/gobj/geomPrimitive.h @@ -351,14 +351,13 @@ private: class EXPCL_PANDA_GOBJ GeomPrimitivePipelineReader : public GeomEnums { public: INLINE GeomPrimitivePipelineReader(CPT(GeomPrimitive) object, Thread *current_thread); -private: - GeomPrimitivePipelineReader(const GeomPrimitivePipelineReader ©) DELETED; - GeomPrimitivePipelineReader &operator = (const GeomPrimitivePipelineReader ©) DELETED_ASSIGN; - -public: + GeomPrimitivePipelineReader(const GeomPrimitivePipelineReader ©) = delete; INLINE ~GeomPrimitivePipelineReader(); + ALLOC_DELETED_CHAIN(GeomPrimitivePipelineReader); + GeomPrimitivePipelineReader &operator = (const GeomPrimitivePipelineReader ©) = delete; + INLINE const GeomPrimitive *get_object() const; INLINE Thread *get_current_thread() const; diff --git a/panda/src/gobj/geomVertexArrayData.I b/panda/src/gobj/geomVertexArrayData.I index 624525360d..97811498a4 100644 --- a/panda/src/gobj/geomVertexArrayData.I +++ b/panda/src/gobj/geomVertexArrayData.I @@ -239,7 +239,7 @@ CData(UsageHint usage_hint) : * */ INLINE GeomVertexArrayData::CData:: -CData(GeomVertexArrayData::CData &&from) NOEXCEPT : +CData(GeomVertexArrayData::CData &&from) noexcept : _usage_hint(move(from._usage_hint)), _buffer(move(from._buffer)), _modified(move(from._modified)), diff --git a/panda/src/gobj/geomVertexArrayData.h b/panda/src/gobj/geomVertexArrayData.h index 4a49d26881..7047358adc 100644 --- a/panda/src/gobj/geomVertexArrayData.h +++ b/panda/src/gobj/geomVertexArrayData.h @@ -151,7 +151,7 @@ private: class EXPCL_PANDA_GOBJ CData : public CycleData { public: INLINE CData(UsageHint usage_hint = UH_unspecified); - INLINE CData(CData &&from) NOEXCEPT; + INLINE CData(CData &&from) noexcept; INLINE CData(const CData ©); INLINE void operator = (const CData ©); diff --git a/panda/src/gobj/geomVertexArrayFormat.cxx b/panda/src/gobj/geomVertexArrayFormat.cxx index 20568fa1a3..c8adfa81eb 100644 --- a/panda/src/gobj/geomVertexArrayFormat.cxx +++ b/panda/src/gobj/geomVertexArrayFormat.cxx @@ -52,7 +52,7 @@ GeomVertexArrayFormat(CPT_InternalName name0, int num_components0, _divisor(0), _columns_unsorted(false) { - add_column(MOVE(name0), num_components0, numeric_type0, contents0); + add_column(move(name0), num_components0, numeric_type0, contents0); } /** @@ -72,8 +72,8 @@ GeomVertexArrayFormat(CPT_InternalName name0, int num_components0, _divisor(0), _columns_unsorted(false) { - add_column(MOVE(name0), num_components0, numeric_type0, contents0); - add_column(MOVE(name1), num_components1, numeric_type1, contents1); + add_column(move(name0), num_components0, numeric_type0, contents0); + add_column(move(name1), num_components1, numeric_type1, contents1); } /** @@ -96,9 +96,9 @@ GeomVertexArrayFormat(CPT_InternalName name0, int num_components0, _divisor(0), _columns_unsorted(false) { - add_column(MOVE(name0), num_components0, numeric_type0, contents0); - add_column(MOVE(name1), num_components1, numeric_type1, contents1); - add_column(MOVE(name2), num_components2, numeric_type2, contents2); + add_column(move(name0), num_components0, numeric_type0, contents0); + add_column(move(name1), num_components1, numeric_type1, contents1); + add_column(move(name2), num_components2, numeric_type2, contents2); } /** @@ -124,10 +124,10 @@ GeomVertexArrayFormat(CPT_InternalName name0, int num_components0, _divisor(0), _columns_unsorted(false) { - add_column(MOVE(name0), num_components0, numeric_type0, contents0); - add_column(MOVE(name1), num_components1, numeric_type1, contents1); - add_column(MOVE(name2), num_components2, numeric_type2, contents2); - add_column(MOVE(name3), num_components3, numeric_type3, contents3); + add_column(move(name0), num_components0, numeric_type0, contents0); + add_column(move(name1), num_components1, numeric_type1, contents1); + add_column(move(name2), num_components2, numeric_type2, contents2); + add_column(move(name3), num_components3, numeric_type3, contents3); } /** @@ -219,7 +219,7 @@ add_column(CPT_InternalName name, int num_components, start = _total_bytes; } - return add_column(GeomVertexColumn(MOVE(name), num_components, numeric_type, contents, + return add_column(GeomVertexColumn(move(name), num_components, numeric_type, contents, start, column_alignment)); } diff --git a/panda/src/gobj/geomVertexArrayFormat.h b/panda/src/gobj/geomVertexArrayFormat.h index 3b8ca3a221..fbd697fe3a 100644 --- a/panda/src/gobj/geomVertexArrayFormat.h +++ b/panda/src/gobj/geomVertexArrayFormat.h @@ -44,7 +44,7 @@ class BamReader; * "normal", "texcoord", and "color"; other kinds of data may be piggybacked * into the data record simply by choosing a unique name. */ -class EXPCL_PANDA_GOBJ GeomVertexArrayFormat FINAL : public TypedWritableReferenceCount, public GeomEnums { +class EXPCL_PANDA_GOBJ GeomVertexArrayFormat final : public TypedWritableReferenceCount, public GeomEnums { PUBLISHED: GeomVertexArrayFormat(); GeomVertexArrayFormat(const GeomVertexArrayFormat ©); diff --git a/panda/src/gobj/geomVertexColumn.I b/panda/src/gobj/geomVertexColumn.I index 4d6c5c3b68..262c19c3a2 100644 --- a/panda/src/gobj/geomVertexColumn.I +++ b/panda/src/gobj/geomVertexColumn.I @@ -28,7 +28,7 @@ GeomVertexColumn(CPT_InternalName name, int num_components, NumericType numeric_type, Contents contents, int start, int column_alignment, int num_elements, int element_stride) : - _name(MOVE(name)), + _name(std::move(name)), _num_components(num_components), _numeric_type(numeric_type), _contents(contents), diff --git a/panda/src/gobj/geomVertexColumn.h b/panda/src/gobj/geomVertexColumn.h index 5e8df9821e..6e31233946 100644 --- a/panda/src/gobj/geomVertexColumn.h +++ b/panda/src/gobj/geomVertexColumn.h @@ -342,7 +342,7 @@ private: } }; - class Packer_nativedouble_3 FINAL : public Packer_float64_3 { + class Packer_nativedouble_3 final : public Packer_float64_3 { public: virtual const LVecBase3d &get_data3d(const unsigned char *pointer); @@ -351,7 +351,7 @@ private: } }; - class Packer_point_nativedouble_2 FINAL : public Packer_point_float64_2 { + class Packer_point_nativedouble_2 final : public Packer_point_float64_2 { public: virtual const LVecBase2d &get_data2d(const unsigned char *pointer); @@ -360,7 +360,7 @@ private: } }; - class Packer_point_nativedouble_3 FINAL : public Packer_point_float64_3 { + class Packer_point_nativedouble_3 final : public Packer_point_float64_3 { public: virtual const LVecBase3d &get_data3d(const unsigned char *pointer); @@ -378,7 +378,7 @@ private: } }; - class Packer_argb_packed FINAL : public Packer_color { + class Packer_argb_packed final : public Packer_color { public: virtual const LVecBase4f &get_data4f(const unsigned char *pointer); virtual void set_data4f(unsigned char *pointer, const LVecBase4f &value); @@ -388,7 +388,7 @@ private: } }; - class Packer_rgba_uint8_4 FINAL : public Packer_color { + class Packer_rgba_uint8_4 final : public Packer_color { public: virtual const LVecBase4f &get_data4f(const unsigned char *pointer); virtual void set_data4f(unsigned char *pointer, const LVecBase4f &value); @@ -408,7 +408,7 @@ private: } }; - class Packer_rgba_nativefloat_4 FINAL : public Packer_rgba_float32_4 { + class Packer_rgba_nativefloat_4 final : public Packer_rgba_float32_4 { public: virtual const LVecBase4f &get_data4f(const unsigned char *pointer); @@ -417,7 +417,7 @@ private: } }; - class Packer_uint16_1 FINAL : public Packer { + class Packer_uint16_1 final : public Packer { public: virtual int get_data1i(const unsigned char *pointer); virtual void set_data1i(unsigned char *pointer, int value); diff --git a/panda/src/gobj/geomVertexData.I b/panda/src/gobj/geomVertexData.I index 5a24b166a5..849a3548f3 100644 --- a/panda/src/gobj/geomVertexData.I +++ b/panda/src/gobj/geomVertexData.I @@ -519,16 +519,14 @@ CacheKey(const CacheKey ©) : { } -#ifdef USE_MOVE_SEMANTICS /** * */ INLINE GeomVertexData::CacheKey:: -CacheKey(CacheKey &&from) NOEXCEPT : - _modifier(move(from._modifier)) +CacheKey(CacheKey &&from) noexcept : + _modifier(std::move(from._modifier)) { } -#endif // USE_MOVE_SEMANTICS /** * Provides a unique ordering within the set. @@ -558,17 +556,15 @@ CacheEntry(GeomVertexData *source, const CacheKey &key) : { } -#ifdef USE_MOVE_SEMANTICS /** * */ INLINE GeomVertexData::CacheEntry:: -CacheEntry(GeomVertexData *source, CacheKey &&key) NOEXCEPT : +CacheEntry(GeomVertexData *source, CacheKey &&key) noexcept : _source(source), - _key(move(key)) + _key(std::move(key)) { } -#endif // USE_MOVE_SEMANTICS /** * diff --git a/panda/src/gobj/geomVertexData.cxx b/panda/src/gobj/geomVertexData.cxx index 7d8e0e63f3..05992e5378 100644 --- a/panda/src/gobj/geomVertexData.cxx +++ b/panda/src/gobj/geomVertexData.cxx @@ -760,12 +760,9 @@ convert_to(const GeomVertexFormat *new_format) const { // Record the new result in the cache. if (entry == (CacheEntry *)NULL) { // Create a new entry for the result. -#ifdef USE_MOVE_SEMANTICS // We don't need the key anymore, move the pointers into the CacheEntry. entry = new CacheEntry((GeomVertexData *)this, move(key)); -#else - entry = new CacheEntry((GeomVertexData *)this, key); -#endif + { LightMutexHolder holder(_cache_lock); bool inserted = ((GeomVertexData *)this)->_cache.insert(Cache::value_type(&entry->_key, entry)).second; diff --git a/panda/src/gobj/geomVertexData.h b/panda/src/gobj/geomVertexData.h index d86dd36fc4..2a7db8115b 100644 --- a/panda/src/gobj/geomVertexData.h +++ b/panda/src/gobj/geomVertexData.h @@ -246,9 +246,7 @@ public: public: INLINE CacheKey(const GeomVertexFormat *modifier); INLINE CacheKey(const CacheKey ©); -#ifdef USE_MOVE_SEMANTICS - INLINE CacheKey(CacheKey &&from) NOEXCEPT; -#endif + INLINE CacheKey(CacheKey &&from) noexcept; INLINE bool operator < (const CacheKey &other) const; @@ -260,9 +258,8 @@ public: INLINE CacheEntry(GeomVertexData *source, const GeomVertexFormat *modifier); INLINE CacheEntry(GeomVertexData *source, const CacheKey &key); -#ifdef USE_MOVE_SEMANTICS - INLINE CacheEntry(GeomVertexData *source, CacheKey &&key) NOEXCEPT; -#endif + INLINE CacheEntry(GeomVertexData *source, CacheKey &&key) noexcept; + ALLOC_DELETED_CHAIN(CacheEntry); virtual void evict_callback(); @@ -410,14 +407,12 @@ protected: Thread *current_thread, GeomVertexData::CData *cdata); -private: - GeomVertexDataPipelineBase(const GeomVertexDataPipelineBase ©) DELETED; - GeomVertexDataPipelineBase &operator = (const GeomVertexDataPipelineBase ©) DELETED_ASSIGN; - public: + GeomVertexDataPipelineBase(const GeomVertexDataPipelineBase ©) = delete; INLINE ~GeomVertexDataPipelineBase(); -public: + GeomVertexDataPipelineBase &operator = (const GeomVertexDataPipelineBase ©) = delete; + INLINE Thread *get_current_thread() const; INLINE const GeomVertexFormat *get_format() const; diff --git a/panda/src/gobj/geomVertexFormat.h b/panda/src/gobj/geomVertexFormat.h index aa2ef4606a..6e4f668436 100644 --- a/panda/src/gobj/geomVertexFormat.h +++ b/panda/src/gobj/geomVertexFormat.h @@ -52,7 +52,7 @@ class GeomMunger; * standard and/or user-defined columns in your custom GeomVertexFormat * constructions. */ -class EXPCL_PANDA_GOBJ GeomVertexFormat FINAL : public TypedWritableReferenceCount, public GeomEnums { +class EXPCL_PANDA_GOBJ GeomVertexFormat final : public TypedWritableReferenceCount, public GeomEnums { PUBLISHED: GeomVertexFormat(); GeomVertexFormat(const GeomVertexArrayFormat *array_format); diff --git a/panda/src/gobj/geomVertexReader.I b/panda/src/gobj/geomVertexReader.I index 810f7e8f33..412bfa611d 100644 --- a/panda/src/gobj/geomVertexReader.I +++ b/panda/src/gobj/geomVertexReader.I @@ -50,7 +50,7 @@ GeomVertexReader(const GeomVertexData *vertex_data, _current_thread(current_thread) { initialize(); - set_column(MOVE(name)); + set_column(std::move(name)); } /** diff --git a/panda/src/gobj/geomVertexRewriter.I b/panda/src/gobj/geomVertexRewriter.I index 933c545885..ac092d6979 100644 --- a/panda/src/gobj/geomVertexRewriter.I +++ b/panda/src/gobj/geomVertexRewriter.I @@ -45,7 +45,7 @@ GeomVertexRewriter(GeomVertexData *vertex_data, CPT_InternalName name, GeomVertexWriter(vertex_data, current_thread), GeomVertexReader(vertex_data, current_thread) { - set_column(MOVE(name)); + set_column(std::move(name)); } /** @@ -184,7 +184,7 @@ set_column(CPT_InternalName name) { // It's important to invoke the writer first, then the reader. See // set_row(). GeomVertexWriter::set_column(name); - return GeomVertexReader::set_column(MOVE(name)); + return GeomVertexReader::set_column(std::move(name)); } /** diff --git a/panda/src/gobj/geomVertexWriter.I b/panda/src/gobj/geomVertexWriter.I index d3e1da87a3..f21280c3ad 100644 --- a/panda/src/gobj/geomVertexWriter.I +++ b/panda/src/gobj/geomVertexWriter.I @@ -48,7 +48,7 @@ GeomVertexWriter(GeomVertexData *vertex_data, CPT_InternalName name, _current_thread(current_thread) { initialize(); - set_column(MOVE(name)); + set_column(std::move(name)); } /** diff --git a/panda/src/gobj/internalName.I b/panda/src/gobj/internalName.I index 69e88c4563..d7475550e9 100644 --- a/panda/src/gobj/internalName.I +++ b/panda/src/gobj/internalName.I @@ -422,13 +422,12 @@ CPT_InternalName(const char (&literal)[N]) : { } -#ifdef USE_MOVE_SEMANTICS /** * */ INLINE CPT_InternalName:: -CPT_InternalName(PointerTo &&from) NOEXCEPT : - ConstPointerTo(move(from)) +CPT_InternalName(PointerTo &&from) noexcept : + ConstPointerTo(std::move(from)) { } @@ -436,8 +435,8 @@ CPT_InternalName(PointerTo &&from) NOEXCEPT : * */ INLINE CPT_InternalName:: -CPT_InternalName(ConstPointerTo &&from) NOEXCEPT : - ConstPointerTo(move(from)) +CPT_InternalName(ConstPointerTo &&from) noexcept : + ConstPointerTo(std::move(from)) { } @@ -445,8 +444,8 @@ CPT_InternalName(ConstPointerTo &&from) NOEXCEPT : * */ INLINE CPT_InternalName &CPT_InternalName:: -operator = (PointerTo &&from) NOEXCEPT { - this->reassign(move(from)); +operator = (PointerTo &&from) noexcept { + this->reassign(std::move(from)); return *this; } @@ -454,11 +453,10 @@ operator = (PointerTo &&from) NOEXCEPT { * */ INLINE CPT_InternalName &CPT_InternalName:: -operator = (ConstPointerTo &&from) NOEXCEPT { - this->reassign(move(from)); +operator = (ConstPointerTo &&from) noexcept { + this->reassign(std::move(from)); return *this; } -#endif // USE_MOVE_SEMANTICS /** * diff --git a/panda/src/gobj/internalName.h b/panda/src/gobj/internalName.h index eff928b668..7706723021 100644 --- a/panda/src/gobj/internalName.h +++ b/panda/src/gobj/internalName.h @@ -35,7 +35,7 @@ class FactoryParams; * composition of one or more other names, or by giving it a source string * directly. */ -class EXPCL_PANDA_GOBJ InternalName FINAL : public TypedWritableReferenceCount { +class EXPCL_PANDA_GOBJ InternalName final : public TypedWritableReferenceCount { private: InternalName(InternalName *parent, const string &basename); @@ -198,25 +198,22 @@ class CPT_InternalName : public ConstPointerTo { public: INLINE CPT_InternalName(const To *ptr = (const To *)NULL); INLINE CPT_InternalName(const PointerTo ©); + INLINE CPT_InternalName(PointerTo &&from) noexcept; INLINE CPT_InternalName(const ConstPointerTo ©); + INLINE CPT_InternalName(ConstPointerTo &&from) noexcept; INLINE CPT_InternalName(const string &name); template INLINE CPT_InternalName(const char (&literal)[N]); -#ifdef USE_MOVE_SEMANTICS - INLINE CPT_InternalName(PointerTo &&from) NOEXCEPT; - INLINE CPT_InternalName(ConstPointerTo &&from) NOEXCEPT; - INLINE CPT_InternalName &operator = (PointerTo &&from) NOEXCEPT; - INLINE CPT_InternalName &operator = (ConstPointerTo &&from) NOEXCEPT; -#endif // USE_MOVE_SEMANTICS - INLINE CPT_InternalName &operator = (const To *ptr); INLINE CPT_InternalName &operator = (const PointerTo ©); INLINE CPT_InternalName &operator = (const ConstPointerTo ©); + INLINE CPT_InternalName &operator = (PointerTo &&from) noexcept; + INLINE CPT_InternalName &operator = (ConstPointerTo &&from) noexcept; }; -INLINE void swap(CPT_InternalName &one, CPT_InternalName &two) NOEXCEPT { +INLINE void swap(CPT_InternalName &one, CPT_InternalName &two) noexcept { one.swap(two); } #endif // CPPPARSER diff --git a/panda/src/gobj/preparedGraphicsObjects.h b/panda/src/gobj/preparedGraphicsObjects.h index 3eaed37167..3d673b615b 100644 --- a/panda/src/gobj/preparedGraphicsObjects.h +++ b/panda/src/gobj/preparedGraphicsObjects.h @@ -164,7 +164,7 @@ public: * This is a handle to an enqueued object, from which the result can be * obtained upon completion. */ - class EXPCL_PANDA_GOBJ EnqueuedObject FINAL : public AsyncFuture { + class EXPCL_PANDA_GOBJ EnqueuedObject final : public AsyncFuture { public: EnqueuedObject(PreparedGraphicsObjects *pgo, TypedWritableReferenceCount *object); @@ -173,7 +173,7 @@ public: void set_result(SavedContext *result); void notify_removed(); - virtual bool cancel() FINAL; + virtual bool cancel() final; PUBLISHED: MAKE_PROPERTY(object, get_object); diff --git a/panda/src/gobj/shaderBuffer.h b/panda/src/gobj/shaderBuffer.h index 8d48fed425..53c110048b 100644 --- a/panda/src/gobj/shaderBuffer.h +++ b/panda/src/gobj/shaderBuffer.h @@ -29,7 +29,7 @@ class PreparedGraphicsObjects; */ class EXPCL_PANDA_GOBJ ShaderBuffer : public TypedWritableReferenceCount, public Namable, public GeomEnums { private: - INLINE ShaderBuffer() DEFAULT_CTOR; + INLINE ShaderBuffer() = default; PUBLISHED: ~ShaderBuffer(); diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index d751405a66..d48c6a7c73 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -4895,14 +4895,14 @@ do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only) } } - do_set_ram_mipmap_image(cdata, (int)n, MOVE(image), + do_set_ram_mipmap_image(cdata, (int)n, move(image), row_size * do_get_expected_mipmap_y_size(cdata, (int)n)); } else { // Compressed image. We'll trust that the file has the right size. image = PTA_uchar::empty_array(image_size); ktx.extract_bytes(image.p(), image_size); - do_set_ram_mipmap_image(cdata, (int)n, MOVE(image), image_size / depth); + do_set_ram_mipmap_image(cdata, (int)n, move(image), image_size / depth); } ktx.skip_bytes(3 - ((image_size + 3) & 3)); diff --git a/panda/src/gobj/texture_ext.cxx b/panda/src/gobj/texture_ext.cxx index e81d40c15f..3cd291843f 100644 --- a/panda/src/gobj/texture_ext.cxx +++ b/panda/src/gobj/texture_ext.cxx @@ -77,7 +77,7 @@ set_ram_image(PyObject *image, Texture::CompressionMode compression, PTA_uchar data = PTA_uchar::empty_array(view.len, Texture::get_class_type()); memcpy(data.p(), view.buf, view.len); - _this->set_ram_image(MOVE(data), compression, page_size); + _this->set_ram_image(move(data), compression, page_size); PyBuffer_Release(&view); return; @@ -102,7 +102,7 @@ set_ram_image(PyObject *image, Texture::CompressionMode compression, PTA_uchar data = PTA_uchar::empty_array(buffer_len, Texture::get_class_type()); memcpy(data.p(), buffer, buffer_len); - _this->set_ram_image(MOVE(data), compression, page_size); + _this->set_ram_image(move(data), compression, page_size); return; } #endif @@ -155,7 +155,7 @@ set_ram_image_as(PyObject *image, const string &provided_format) { PTA_uchar data = PTA_uchar::empty_array(view.len, Texture::get_class_type()); memcpy(data.p(), view.buf, view.len); - _this->set_ram_image_as(MOVE(data), provided_format); + _this->set_ram_image_as(move(data), provided_format); PyBuffer_Release(&view); return; diff --git a/panda/src/linmath/lpoint2_src.h b/panda/src/linmath/lpoint2_src.h index 090b49d4b9..fef5c791f9 100644 --- a/panda/src/linmath/lpoint2_src.h +++ b/panda/src/linmath/lpoint2_src.h @@ -17,7 +17,7 @@ class EXPCL_PANDA_LINMATH FLOATNAME(LPoint2) : public FLOATNAME(LVecBase2) { PUBLISHED: - INLINE_LINMATH FLOATNAME(LPoint2)() DEFAULT_CTOR; + INLINE_LINMATH FLOATNAME(LPoint2)() = default; INLINE_LINMATH FLOATNAME(LPoint2)(const FLOATNAME(LVecBase2)& copy); INLINE_LINMATH FLOATNAME(LPoint2)(FLOATTYPE fill_value); INLINE_LINMATH FLOATNAME(LPoint2)(FLOATTYPE x, FLOATTYPE y); diff --git a/panda/src/linmath/lpoint3_src.h b/panda/src/linmath/lpoint3_src.h index 3465fc37d1..5089e81c9e 100644 --- a/panda/src/linmath/lpoint3_src.h +++ b/panda/src/linmath/lpoint3_src.h @@ -20,7 +20,7 @@ */ class EXPCL_PANDA_LINMATH FLOATNAME(LPoint3) : public FLOATNAME(LVecBase3) { PUBLISHED: - INLINE_LINMATH FLOATNAME(LPoint3)() DEFAULT_CTOR; + INLINE_LINMATH FLOATNAME(LPoint3)() = default; INLINE_LINMATH FLOATNAME(LPoint3)(const FLOATNAME(LVecBase3) ©); INLINE_LINMATH FLOATNAME(LPoint3)(FLOATTYPE fill_value); INLINE_LINMATH FLOATNAME(LPoint3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z); diff --git a/panda/src/linmath/lpoint4_src.h b/panda/src/linmath/lpoint4_src.h index 103c018738..1eda6fa4fe 100644 --- a/panda/src/linmath/lpoint4_src.h +++ b/panda/src/linmath/lpoint4_src.h @@ -16,7 +16,7 @@ */ class EXPCL_PANDA_LINMATH FLOATNAME(LPoint4) : public FLOATNAME(LVecBase4) { PUBLISHED: - INLINE_LINMATH FLOATNAME(LPoint4)() DEFAULT_CTOR; + INLINE_LINMATH FLOATNAME(LPoint4)() = default; INLINE_LINMATH FLOATNAME(LPoint4)(const FLOATNAME(LVecBase4) ©); INLINE_LINMATH FLOATNAME(LPoint4)(FLOATTYPE fill_value); INLINE_LINMATH FLOATNAME(LPoint4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w); diff --git a/panda/src/linmath/lvecBase2_src.h b/panda/src/linmath/lvecBase2_src.h index d0c0693f55..5d35293544 100644 --- a/panda/src/linmath/lvecBase2_src.h +++ b/panda/src/linmath/lvecBase2_src.h @@ -30,7 +30,7 @@ PUBLISHED: #endif }; - INLINE_LINMATH FLOATNAME(LVecBase2)() DEFAULT_CTOR; + INLINE_LINMATH FLOATNAME(LVecBase2)() = default; INLINE_LINMATH FLOATNAME(LVecBase2)(FLOATTYPE fill_value); INLINE_LINMATH FLOATNAME(LVecBase2)(FLOATTYPE x, FLOATTYPE y); ALLOC_DELETED_CHAIN(FLOATNAME(LVecBase2)); @@ -50,7 +50,7 @@ PUBLISHED: INLINE_LINMATH FLOATTYPE operator [](int i) const; INLINE_LINMATH FLOATTYPE &operator [](int i); - CONSTEXPR static int size() { return 2; } + constexpr static int size() { return 2; } INLINE_LINMATH bool is_nan() const; @@ -74,7 +74,7 @@ PUBLISHED: INLINE_LINMATH void add_y(FLOATTYPE value); INLINE_LINMATH const FLOATTYPE *get_data() const; - CONSTEXPR static int get_num_components() { return 2; } + constexpr static int get_num_components() { return 2; } public: INLINE_LINMATH iterator begin(); diff --git a/panda/src/linmath/lvecBase3_src.h b/panda/src/linmath/lvecBase3_src.h index fb9b67ca27..5def855cdd 100644 --- a/panda/src/linmath/lvecBase3_src.h +++ b/panda/src/linmath/lvecBase3_src.h @@ -30,7 +30,7 @@ PUBLISHED: #endif }; - INLINE_LINMATH FLOATNAME(LVecBase3)() DEFAULT_CTOR; + INLINE_LINMATH FLOATNAME(LVecBase3)() = default; INLINE_LINMATH FLOATNAME(LVecBase3)(FLOATTYPE fill_value); INLINE_LINMATH FLOATNAME(LVecBase3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z); INLINE_LINMATH FLOATNAME(LVecBase3)(const FLOATNAME(LVecBase2) ©, FLOATTYPE z); @@ -52,7 +52,7 @@ PUBLISHED: INLINE_LINMATH FLOATTYPE operator [](int i) const; INLINE_LINMATH FLOATTYPE &operator [](int i); - CONSTEXPR static int size() { return 3; } + constexpr static int size() { return 3; } INLINE_LINMATH bool is_nan() const; @@ -87,7 +87,7 @@ PUBLISHED: INLINE_LINMATH void add_z(FLOATTYPE value); INLINE_LINMATH const FLOATTYPE *get_data() const; - CONSTEXPR static int get_num_components() { return 3; } + constexpr static int get_num_components() { return 3; } public: INLINE_LINMATH iterator begin(); diff --git a/panda/src/linmath/lvecBase4_src.h b/panda/src/linmath/lvecBase4_src.h index d04201d988..b76d89a7ae 100644 --- a/panda/src/linmath/lvecBase4_src.h +++ b/panda/src/linmath/lvecBase4_src.h @@ -36,7 +36,7 @@ PUBLISHED: #endif }; - INLINE_LINMATH FLOATNAME(LVecBase4)() DEFAULT_CTOR; + INLINE_LINMATH FLOATNAME(LVecBase4)() = default; INLINE_LINMATH FLOATNAME(LVecBase4)(FLOATTYPE fill_value); INLINE_LINMATH FLOATNAME(LVecBase4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w); INLINE_LINMATH FLOATNAME(LVecBase4)(const FLOATNAME(UnalignedLVecBase4) ©); @@ -62,7 +62,7 @@ PUBLISHED: INLINE_LINMATH FLOATTYPE operator [](int i) const; INLINE_LINMATH FLOATTYPE &operator [](int i); - CONSTEXPR static int size() { return 4; } + constexpr static int size() { return 4; } INLINE_LINMATH bool is_nan() const; @@ -100,7 +100,7 @@ PUBLISHED: INLINE_LINMATH void add_w(FLOATTYPE value); INLINE_LINMATH const FLOATTYPE *get_data() const; - CONSTEXPR static int get_num_components() { return 4; } + constexpr static int get_num_components() { return 4; } INLINE_LINMATH void extract_data(float*){}; public: @@ -228,7 +228,7 @@ PUBLISHED: #endif }; - INLINE_LINMATH FLOATNAME(UnalignedLVecBase4)() DEFAULT_CTOR; + INLINE_LINMATH FLOATNAME(UnalignedLVecBase4)() = default; INLINE_LINMATH FLOATNAME(UnalignedLVecBase4)(const FLOATNAME(LVecBase4) ©); INLINE_LINMATH FLOATNAME(UnalignedLVecBase4)(FLOATTYPE fill_value); INLINE_LINMATH FLOATNAME(UnalignedLVecBase4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w); @@ -238,10 +238,10 @@ PUBLISHED: INLINE_LINMATH FLOATTYPE operator [](int i) const; INLINE_LINMATH FLOATTYPE &operator [](int i); - CONSTEXPR static int size() { return 4; } + constexpr static int size() { return 4; } INLINE_LINMATH const FLOATTYPE *get_data() const; - CONSTEXPR static int get_num_components() { return 4; } + constexpr static int get_num_components() { return 4; } INLINE_LINMATH bool operator == (const FLOATNAME(UnalignedLVecBase4) &other) const; INLINE_LINMATH bool operator != (const FLOATNAME(UnalignedLVecBase4) &other) const; diff --git a/panda/src/linmath/lvector2_src.h b/panda/src/linmath/lvector2_src.h index 4a78cc7519..9b6020e00a 100644 --- a/panda/src/linmath/lvector2_src.h +++ b/panda/src/linmath/lvector2_src.h @@ -17,7 +17,7 @@ class EXPCL_PANDA_LINMATH FLOATNAME(LVector2) : public FLOATNAME(LVecBase2) { PUBLISHED: - INLINE_LINMATH FLOATNAME(LVector2)() DEFAULT_CTOR; + INLINE_LINMATH FLOATNAME(LVector2)() = default; INLINE_LINMATH FLOATNAME(LVector2)(const FLOATNAME(LVecBase2)& copy); INLINE_LINMATH FLOATNAME(LVector2)(FLOATTYPE fill_value); INLINE_LINMATH FLOATNAME(LVector2)(FLOATTYPE x, FLOATTYPE y); diff --git a/panda/src/linmath/lvector3_src.h b/panda/src/linmath/lvector3_src.h index e8f010cec7..777a064ffd 100644 --- a/panda/src/linmath/lvector3_src.h +++ b/panda/src/linmath/lvector3_src.h @@ -20,7 +20,7 @@ */ class EXPCL_PANDA_LINMATH FLOATNAME(LVector3) : public FLOATNAME(LVecBase3) { PUBLISHED: - INLINE_LINMATH FLOATNAME(LVector3)() DEFAULT_CTOR; + INLINE_LINMATH FLOATNAME(LVector3)() = default; INLINE_LINMATH FLOATNAME(LVector3)(const FLOATNAME(LVecBase3) ©); INLINE_LINMATH FLOATNAME(LVector3)(FLOATTYPE fill_value); INLINE_LINMATH FLOATNAME(LVector3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z); diff --git a/panda/src/linmath/lvector4_src.h b/panda/src/linmath/lvector4_src.h index 4c576e8406..93f821b08b 100644 --- a/panda/src/linmath/lvector4_src.h +++ b/panda/src/linmath/lvector4_src.h @@ -16,7 +16,7 @@ */ class EXPCL_PANDA_LINMATH FLOATNAME(LVector4) : public FLOATNAME(LVecBase4) { PUBLISHED: - INLINE_LINMATH FLOATNAME(LVector4)() DEFAULT_CTOR; + INLINE_LINMATH FLOATNAME(LVector4)() = default; INLINE_LINMATH FLOATNAME(LVector4)(const FLOATNAME(LVecBase4) ©); INLINE_LINMATH FLOATNAME(LVector4)(FLOATTYPE fill_value); INLINE_LINMATH FLOATNAME(LVector4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w); diff --git a/panda/src/mathutil/geometricBoundingVolume.h b/panda/src/mathutil/geometricBoundingVolume.h index a27c19a724..a8f75a226f 100644 --- a/panda/src/mathutil/geometricBoundingVolume.h +++ b/panda/src/mathutil/geometricBoundingVolume.h @@ -51,8 +51,8 @@ PUBLISHED: virtual void xform(const LMatrix4 &mat)=0; public: - virtual GeometricBoundingVolume *as_geometric_bounding_volume() FINAL; - virtual const GeometricBoundingVolume *as_geometric_bounding_volume() const FINAL; + virtual GeometricBoundingVolume *as_geometric_bounding_volume() final; + virtual const GeometricBoundingVolume *as_geometric_bounding_volume() const final; protected: // Some virtual functions to implement fundamental bounding operations on diff --git a/panda/src/pgraph/cullableObject.cxx b/panda/src/pgraph/cullableObject.cxx index d38fc4f5a4..8c8b24f1c0 100644 --- a/panda/src/pgraph/cullableObject.cxx +++ b/panda/src/pgraph/cullableObject.cxx @@ -583,12 +583,7 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { } _geom = new_geom.p(); - -#ifdef USE_MOVE_SEMANTICS _munged_data = move(new_data); -#else - _munged_data = new_data; -#endif return true; } diff --git a/panda/src/pgraph/geomNode.I b/panda/src/pgraph/geomNode.I index 431d5e1d2e..7766631662 100644 --- a/panda/src/pgraph/geomNode.I +++ b/panda/src/pgraph/geomNode.I @@ -255,13 +255,12 @@ operator = (const GeomNode::Geoms ©) { _geoms = copy._geoms; } -#ifdef USE_MOVE_SEMANTICS /** * */ INLINE GeomNode::Geoms:: -Geoms(GeomNode::Geoms &&from) NOEXCEPT : - _geoms(move(from._geoms)) +Geoms(GeomNode::Geoms &&from) noexcept : + _geoms(std::move(from._geoms)) { } @@ -269,10 +268,9 @@ Geoms(GeomNode::Geoms &&from) NOEXCEPT : * */ INLINE void GeomNode::Geoms:: -operator = (GeomNode::Geoms &&from) NOEXCEPT { - _geoms = move(from._geoms); +operator = (GeomNode::Geoms &&from) noexcept { + _geoms = std::move(from._geoms); } -#endif // USE_MOVE_SEMANTICS /** * Returns the number of geoms of the node. diff --git a/panda/src/pgraph/geomNode.h b/panda/src/pgraph/geomNode.h index d17903027a..0b5bccd492 100644 --- a/panda/src/pgraph/geomNode.h +++ b/panda/src/pgraph/geomNode.h @@ -164,12 +164,10 @@ public: INLINE Geoms(); INLINE Geoms(const CData *cdata); INLINE Geoms(const Geoms ©); - INLINE void operator = (const Geoms ©); + INLINE Geoms(Geoms &&from) noexcept; -#ifdef USE_MOVE_SEMANTICS - INLINE Geoms(Geoms &&from) NOEXCEPT; - INLINE void operator = (Geoms &&from) NOEXCEPT; -#endif + INLINE void operator = (const Geoms ©); + INLINE void operator = (Geoms &&from) noexcept; INLINE int get_num_geoms() const; INLINE CPT(Geom) get_geom(int n) const; diff --git a/panda/src/pgraph/nodePath.I b/panda/src/pgraph/nodePath.I index c7d75da2c1..8860fff331 100644 --- a/panda/src/pgraph/nodePath.I +++ b/panda/src/pgraph/nodePath.I @@ -90,12 +90,11 @@ operator = (const NodePath ©) { _error_type = copy._error_type; } -#ifdef USE_MOVE_SEMANTICS /** * */ INLINE NodePath:: -NodePath(NodePath &&from) NOEXCEPT : +NodePath(NodePath &&from) noexcept : _head(move(from._head)), _backup_key(from._backup_key), _error_type(from._error_type) @@ -106,12 +105,11 @@ NodePath(NodePath &&from) NOEXCEPT : * */ INLINE void NodePath:: -operator = (NodePath &&from) NOEXCEPT { +operator = (NodePath &&from) noexcept { _head = move(from._head); _backup_key = from._backup_key; _error_type = from._error_type; } -#endif // USE_MOVE_SEMANTICS /** * Sets this NodePath to the empty NodePath. It will no longer point to any diff --git a/panda/src/pgraph/nodePath.cxx b/panda/src/pgraph/nodePath.cxx index 41e02b0821..f8d7d6c4b0 100644 --- a/panda/src/pgraph/nodePath.cxx +++ b/panda/src/pgraph/nodePath.cxx @@ -5412,7 +5412,7 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool found_any = false; node()->calc_tight_bounds(min_point, max_point, found_any, - MOVE(transform), current_thread); + move(transform), current_thread); return found_any; } diff --git a/panda/src/pgraph/nodePath.h b/panda/src/pgraph/nodePath.h index 11d7437113..bdd9d3f2d7 100644 --- a/panda/src/pgraph/nodePath.h +++ b/panda/src/pgraph/nodePath.h @@ -177,13 +177,12 @@ PUBLISHED: Thread *current_thread = Thread::get_current_thread()); INLINE NodePath(const NodePath ©); - INLINE void operator = (const NodePath ©); - INLINE void clear(); + INLINE NodePath(NodePath &&from) noexcept; -#ifdef USE_MOVE_SEMANTICS - INLINE NodePath(NodePath &&from) NOEXCEPT; - INLINE void operator = (NodePath &&from) NOEXCEPT; -#endif + INLINE void operator = (const NodePath ©); + INLINE void operator = (NodePath &&from) noexcept; + + INLINE void clear(); EXTENSION(NodePath __copy__() const); EXTENSION(PyObject *__deepcopy__(PyObject *self, PyObject *memo) const); diff --git a/panda/src/pgraph/nodePathCollection.h b/panda/src/pgraph/nodePathCollection.h index 9eb0c1ce90..7535a28718 100644 --- a/panda/src/pgraph/nodePathCollection.h +++ b/panda/src/pgraph/nodePathCollection.h @@ -25,7 +25,7 @@ */ class EXPCL_PANDA_PGRAPH NodePathCollection { PUBLISHED: - NodePathCollection() DEFAULT_CTOR; + NodePathCollection() = default; #ifdef HAVE_PYTHON EXTENSION(NodePathCollection(PyObject *self, PyObject *sequence)); diff --git a/panda/src/pgraph/nodePathComponent.h b/panda/src/pgraph/nodePathComponent.h index 2106430b7d..3752d7e834 100644 --- a/panda/src/pgraph/nodePathComponent.h +++ b/panda/src/pgraph/nodePathComponent.h @@ -39,7 +39,7 @@ * graph, and the NodePathComponents are stored in the nodes themselves to * allow the nodes to keep these up to date as the scene graph is manipulated. */ -class EXPCL_PANDA_PGRAPH NodePathComponent FINAL : public ReferenceCount { +class EXPCL_PANDA_PGRAPH NodePathComponent final : public ReferenceCount { private: NodePathComponent(PandaNode *node, NodePathComponent *next, int pipeline_stage, Thread *current_thread); diff --git a/panda/src/pgraph/pandaNode.I b/panda/src/pgraph/pandaNode.I index de6682e911..93bf19cc2d 100644 --- a/panda/src/pgraph/pandaNode.I +++ b/panda/src/pgraph/pandaNode.I @@ -929,12 +929,11 @@ operator = (const PandaNode::Children ©) { _down = copy._down; } -#ifdef USE_MOVE_SEMANTICS /** * */ INLINE PandaNode::Children:: -Children(PandaNode::Children &&from) NOEXCEPT : +Children(PandaNode::Children &&from) noexcept : _down(move(from._down)) { } @@ -943,10 +942,9 @@ Children(PandaNode::Children &&from) NOEXCEPT : * */ INLINE void PandaNode::Children:: -operator = (PandaNode::Children &&from) NOEXCEPT { +operator = (PandaNode::Children &&from) noexcept { _down = move(from._down); } -#endif // USE_MOVE_SEMANTICS /** * Returns the number of children of the node. @@ -1011,13 +1009,12 @@ operator = (const PandaNode::Stashed ©) { _stashed = copy._stashed; } -#ifdef USE_MOVE_SEMANTICS /** * */ INLINE PandaNode::Stashed:: -Stashed(PandaNode::Stashed &&from) NOEXCEPT : - _stashed(move(from._stashed)) +Stashed(PandaNode::Stashed &&from) noexcept : + _stashed(std::move(from._stashed)) { } @@ -1025,10 +1022,9 @@ Stashed(PandaNode::Stashed &&from) NOEXCEPT : * */ INLINE void PandaNode::Stashed:: -operator = (PandaNode::Stashed &&from) NOEXCEPT { - _stashed = move(from._stashed); +operator = (PandaNode::Stashed &&from) noexcept { + _stashed = std::move(from._stashed); } -#endif // USE_MOVE_SEMANTICS /** * Returns the number of stashed children of the node. @@ -1093,13 +1089,12 @@ operator = (const PandaNode::Parents ©) { _up = copy._up; } -#ifdef USE_MOVE_SEMANTICS /** * */ INLINE PandaNode::Parents:: -Parents(PandaNode::Parents &&from) NOEXCEPT : - _up(move(from._up)) +Parents(PandaNode::Parents &&from) noexcept : + _up(std::move(from._up)) { } @@ -1107,10 +1102,9 @@ Parents(PandaNode::Parents &&from) NOEXCEPT : * */ INLINE void PandaNode::Parents:: -operator = (PandaNode::Parents &&from) NOEXCEPT { - _up = move(from._up); +operator = (PandaNode::Parents &&from) noexcept { + _up = std::move(from._up); } -#endif // USE_MOVE_SEMANTICS /** * Returns the number of parents of the node. diff --git a/panda/src/pgraph/pandaNode.h b/panda/src/pgraph/pandaNode.h index 1b42e5ed2d..74d362113e 100644 --- a/panda/src/pgraph/pandaNode.h +++ b/panda/src/pgraph/pandaNode.h @@ -710,12 +710,10 @@ PUBLISHED: INLINE Children(); INLINE Children(const CData *cdata); INLINE Children(const Children ©); - INLINE void operator = (const Children ©); + INLINE Children(Children &&from) noexcept; -#ifdef USE_MOVE_SEMANTICS - INLINE Children(Children &&from) NOEXCEPT; - INLINE void operator = (Children &&from) NOEXCEPT; -#endif + INLINE void operator = (const Children ©); + INLINE void operator = (Children &&from) noexcept; INLINE size_t get_num_children() const; INLINE PandaNode *get_child(size_t n) const; @@ -735,12 +733,10 @@ PUBLISHED: INLINE Stashed(); INLINE Stashed(const CData *cdata); INLINE Stashed(const Stashed ©); - INLINE void operator = (const Stashed ©); + INLINE Stashed(Stashed &&from) noexcept; -#ifdef USE_MOVE_SEMANTICS - INLINE Stashed(Stashed &&from) NOEXCEPT; - INLINE void operator = (Stashed &&from) NOEXCEPT; -#endif + INLINE void operator = (const Stashed ©); + INLINE void operator = (Stashed &&from) noexcept; INLINE size_t get_num_stashed() const; INLINE PandaNode *get_stashed(size_t n) const; @@ -760,12 +756,10 @@ PUBLISHED: INLINE Parents(); INLINE Parents(const CData *cdata); INLINE Parents(const Parents ©); - INLINE void operator = (const Parents ©); + INLINE Parents(Parents &&from) noexcept; -#ifdef USE_MOVE_SEMANTICS - INLINE Parents(Parents &&from) NOEXCEPT; - INLINE void operator = (Parents &&from) NOEXCEPT; -#endif + INLINE void operator = (const Parents ©); + INLINE void operator = (Parents &&from) noexcept; INLINE size_t get_num_parents() const; INLINE PandaNode *get_parent(size_t n) const; diff --git a/panda/src/pgraph/paramNodePath.I b/panda/src/pgraph/paramNodePath.I index beaa9c5c85..89d6a9e67b 100644 --- a/panda/src/pgraph/paramNodePath.I +++ b/panda/src/pgraph/paramNodePath.I @@ -20,16 +20,14 @@ ParamNodePath(const NodePath &node_path) : { } -#ifdef USE_MOVE_SEMANTICS /** * Creates a new ParamNodePath storing the given node path object. */ INLINE ParamNodePath:: -ParamNodePath(NodePath &&node_path) NOEXCEPT : - _node_path(move(node_path)) +ParamNodePath(NodePath &&node_path) noexcept : + _node_path(std::move(node_path)) { } -#endif // USE_MOVE_SEMANTICS /** * Returns NodePath::get_class_type(). diff --git a/panda/src/pgraph/paramNodePath.h b/panda/src/pgraph/paramNodePath.h index 25812d8b0f..86f027eb99 100644 --- a/panda/src/pgraph/paramNodePath.h +++ b/panda/src/pgraph/paramNodePath.h @@ -27,10 +27,7 @@ protected: PUBLISHED: INLINE ParamNodePath(const NodePath &node_path); - -#ifdef USE_MOVE_SEMANTICS - INLINE ParamNodePath(NodePath &&node_path) NOEXCEPT; -#endif + INLINE ParamNodePath(NodePath &&node_path) noexcept; INLINE virtual TypeHandle get_value_type() const; INLINE const NodePath &get_value() const; diff --git a/panda/src/pgraph/renderAttrib.h b/panda/src/pgraph/renderAttrib.h index 5bf54cf32f..fe364d8ea4 100644 --- a/panda/src/pgraph/renderAttrib.h +++ b/panda/src/pgraph/renderAttrib.h @@ -72,7 +72,7 @@ PUBLISHED: INLINE size_t get_hash() const; INLINE CPT(RenderAttrib) get_unique() const; - virtual bool unref() const FINAL; + virtual bool unref() const final; virtual void output(ostream &out) const; virtual void write(ostream &out, int indent_level) const; diff --git a/panda/src/pgraph/renderAttribRegistry.I b/panda/src/pgraph/renderAttribRegistry.I index 1a807794a9..fab7f22d24 100644 --- a/panda/src/pgraph/renderAttribRegistry.I +++ b/panda/src/pgraph/renderAttribRegistry.I @@ -32,7 +32,7 @@ get_slot(TypeHandle type_handle) const { * * This number will not change during the lifetime of the application. */ -CONSTEXPR int RenderAttribRegistry:: +constexpr int RenderAttribRegistry:: get_max_slots() { return _max_slots; } diff --git a/panda/src/pgraph/renderAttribRegistry.h b/panda/src/pgraph/renderAttribRegistry.h index 59194fd278..ae47bd39a8 100644 --- a/panda/src/pgraph/renderAttribRegistry.h +++ b/panda/src/pgraph/renderAttribRegistry.h @@ -54,7 +54,7 @@ public: PUBLISHED: INLINE int get_slot(TypeHandle type_handle) const; - static CONSTEXPR int get_max_slots(); + static constexpr int get_max_slots(); INLINE int get_num_slots() const; INLINE TypeHandle get_slot_type(int slot) const; diff --git a/panda/src/pgraph/shaderInput.I b/panda/src/pgraph/shaderInput.I index 8c37322082..b8e182421f 100644 --- a/panda/src/pgraph/shaderInput.I +++ b/panda/src/pgraph/shaderInput.I @@ -18,7 +18,7 @@ */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_invalid), _priority(priority) { @@ -29,7 +29,7 @@ ShaderInput(CPT_InternalName name, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, Texture *tex, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_texture), _priority(priority), _value(tex) @@ -41,7 +41,7 @@ ShaderInput(CPT_InternalName name, Texture *tex, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, ParamValueBase *param, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_param), _priority(priority), _value(param) @@ -53,7 +53,7 @@ ShaderInput(CPT_InternalName name, ParamValueBase *param, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, ShaderBuffer *buf, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_buffer), _priority(priority), _value(buf) @@ -65,7 +65,7 @@ ShaderInput(CPT_InternalName name, ShaderBuffer *buf, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_float &ptr, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(ptr) @@ -77,7 +77,7 @@ ShaderInput(CPT_InternalName name, const PTA_float &ptr, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LVecBase4f &ptr, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(ptr) @@ -89,7 +89,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase4f &ptr, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LVecBase3f &ptr, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(ptr) @@ -101,7 +101,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase3f &ptr, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LVecBase2f &ptr, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(ptr) @@ -113,7 +113,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase2f &ptr, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LVecBase4f &vec, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_vector), _priority(priority), _stored_ptr(vec), @@ -126,7 +126,7 @@ ShaderInput(CPT_InternalName name, const LVecBase4f &vec, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LVecBase3f &vec, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_vector), _priority(priority), _stored_ptr(vec), @@ -139,7 +139,7 @@ ShaderInput(CPT_InternalName name, const LVecBase3f &vec, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LVecBase2f &vec, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_vector), _priority(priority), _stored_ptr(vec), @@ -152,7 +152,7 @@ ShaderInput(CPT_InternalName name, const LVecBase2f &vec, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LMatrix4f &ptr, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(ptr) @@ -164,7 +164,7 @@ ShaderInput(CPT_InternalName name, const PTA_LMatrix4f &ptr, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LMatrix3f &ptr, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(ptr) @@ -176,7 +176,7 @@ ShaderInput(CPT_InternalName name, const PTA_LMatrix3f &ptr, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LMatrix4f &mat, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(mat) @@ -188,7 +188,7 @@ ShaderInput(CPT_InternalName name, const LMatrix4f &mat, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LMatrix3f &mat, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(mat) @@ -200,7 +200,7 @@ ShaderInput(CPT_InternalName name, const LMatrix3f &mat, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_double &ptr, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(ptr) @@ -212,7 +212,7 @@ ShaderInput(CPT_InternalName name, const PTA_double &ptr, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LVecBase4d &ptr, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(ptr) @@ -224,7 +224,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase4d &ptr, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LVecBase3d &ptr, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(ptr) @@ -236,7 +236,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase3d &ptr, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LVecBase2d &ptr, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(ptr) @@ -248,7 +248,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase2d &ptr, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LVecBase4d &vec, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(vec), @@ -261,7 +261,7 @@ ShaderInput(CPT_InternalName name, const LVecBase4d &vec, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LVecBase3d &vec, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(vec), @@ -274,7 +274,7 @@ ShaderInput(CPT_InternalName name, const LVecBase3d &vec, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LVecBase2d &vec, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(vec), @@ -287,7 +287,7 @@ ShaderInput(CPT_InternalName name, const LVecBase2d &vec, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LMatrix4d &ptr, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(ptr) @@ -299,7 +299,7 @@ ShaderInput(CPT_InternalName name, const PTA_LMatrix4d &ptr, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LMatrix3d &ptr, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(ptr) @@ -311,7 +311,7 @@ ShaderInput(CPT_InternalName name, const PTA_LMatrix3d &ptr, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LMatrix4d &mat, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(mat) @@ -323,7 +323,7 @@ ShaderInput(CPT_InternalName name, const LMatrix4d &mat, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LMatrix3d &mat, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(mat) @@ -335,7 +335,7 @@ ShaderInput(CPT_InternalName name, const LMatrix3d &mat, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_int &ptr, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(ptr) @@ -347,7 +347,7 @@ ShaderInput(CPT_InternalName name, const PTA_int &ptr, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LVecBase4i &ptr, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(ptr) @@ -359,7 +359,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase4i &ptr, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LVecBase3i &ptr, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(ptr) @@ -371,7 +371,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase3i &ptr, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LVecBase2i &ptr, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(ptr) @@ -383,7 +383,7 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase2i &ptr, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LVecBase4i &vec, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(vec), @@ -396,7 +396,7 @@ ShaderInput(CPT_InternalName name, const LVecBase4i &vec, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LVecBase3i &vec, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(vec), @@ -409,7 +409,7 @@ ShaderInput(CPT_InternalName name, const LVecBase3i &vec, int priority) : */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LVecBase2i &vec, int priority) : - _name(MOVE(name)), + _name(std::move(name)), _type(M_numeric), _priority(priority), _stored_ptr(vec), diff --git a/panda/src/pgraph/shaderInput.cxx b/panda/src/pgraph/shaderInput.cxx index 44fb91cf23..86a3912ec4 100644 --- a/panda/src/pgraph/shaderInput.cxx +++ b/panda/src/pgraph/shaderInput.cxx @@ -30,7 +30,7 @@ get_blank() { */ ShaderInput:: ShaderInput(CPT_InternalName name, const NodePath &np, int priority) : - _name(MOVE(name)), + _name(move(name)), _type(M_nodepath), _priority(priority), _value(new ParamNodePath(np)) @@ -42,7 +42,7 @@ ShaderInput(CPT_InternalName name, const NodePath &np, int priority) : */ ShaderInput:: ShaderInput(CPT_InternalName name, Texture *tex, bool read, bool write, int z, int n, int priority) : - _name(MOVE(name)), + _name(move(name)), _type(M_texture_image), _priority(priority), _value(new ParamTextureImage(tex, read, write, z, n)) @@ -54,7 +54,7 @@ ShaderInput(CPT_InternalName name, Texture *tex, bool read, bool write, int z, i */ ShaderInput:: ShaderInput(CPT_InternalName name, Texture *tex, const SamplerState &sampler, int priority) : - _name(MOVE(name)), + _name(move(name)), _type(M_texture_sampler), _priority(priority), _value(new ParamTextureSampler(tex, sampler)) diff --git a/panda/src/pgraph/shaderInput.h b/panda/src/pgraph/shaderInput.h index 39a4e32fe8..39ae9ba835 100644 --- a/panda/src/pgraph/shaderInput.h +++ b/panda/src/pgraph/shaderInput.h @@ -124,7 +124,7 @@ PUBLISHED: const SamplerState &get_sampler() const; public: - ShaderInput() DEFAULT_CTOR; + ShaderInput() = default; INLINE ParamValueBase *get_param() const; INLINE TypedWritableReferenceCount *get_value() const; diff --git a/panda/src/pgraph/transformState.h b/panda/src/pgraph/transformState.h index b770e7bf52..2313ea136f 100644 --- a/panda/src/pgraph/transformState.h +++ b/panda/src/pgraph/transformState.h @@ -51,7 +51,7 @@ class FactoryParams; * directly. Instead, call one of the make() functions to create one for you. * And instead of modifying a TransformState object, create a new one. */ -class EXPCL_PANDA_PGRAPH TransformState FINAL : public NodeCachedReferenceCount { +class EXPCL_PANDA_PGRAPH TransformState final : public NodeCachedReferenceCount { protected: TransformState(); diff --git a/panda/src/pgraphnodes/ambientLight.h b/panda/src/pgraphnodes/ambientLight.h index f3582e54fd..959a2d1485 100644 --- a/panda/src/pgraphnodes/ambientLight.h +++ b/panda/src/pgraphnodes/ambientLight.h @@ -33,7 +33,7 @@ protected: public: virtual PandaNode *make_copy() const; virtual void write(ostream &out, int indent_level) const; - virtual bool is_ambient_light() const FINAL; + virtual bool is_ambient_light() const final; PUBLISHED: virtual int get_class_priority() const; diff --git a/panda/src/pgraphnodes/directionalLight.h b/panda/src/pgraphnodes/directionalLight.h index df2a198273..c78f76f81e 100644 --- a/panda/src/pgraphnodes/directionalLight.h +++ b/panda/src/pgraphnodes/directionalLight.h @@ -39,7 +39,7 @@ public: const LMatrix4 &to_object_space); PUBLISHED: - INLINE const LColor &get_specular_color() const FINAL; + INLINE const LColor &get_specular_color() const final; INLINE void set_specular_color(const LColor &color); INLINE void clear_specular_color(); MAKE_PROPERTY(specular_color, get_specular_color, set_specular_color); diff --git a/panda/src/pgraphnodes/pointLight.h b/panda/src/pgraphnodes/pointLight.h index ba3a334d47..bb37237883 100644 --- a/panda/src/pgraphnodes/pointLight.h +++ b/panda/src/pgraphnodes/pointLight.h @@ -39,12 +39,12 @@ public: const LMatrix4 &to_object_space); PUBLISHED: - INLINE const LColor &get_specular_color() const FINAL; + INLINE const LColor &get_specular_color() const final; INLINE void set_specular_color(const LColor &color); INLINE void clear_specular_color(); MAKE_PROPERTY(specular_color, get_specular_color, set_specular_color); - INLINE const LVecBase3 &get_attenuation() const FINAL; + INLINE const LVecBase3 &get_attenuation() const final; INLINE void set_attenuation(const LVecBase3 &attenuation); MAKE_PROPERTY(attenuation, get_attenuation, set_attenuation); diff --git a/panda/src/pgraphnodes/rectangleLight.h b/panda/src/pgraphnodes/rectangleLight.h index 3870b4f8f7..b6a4e173c1 100644 --- a/panda/src/pgraphnodes/rectangleLight.h +++ b/panda/src/pgraphnodes/rectangleLight.h @@ -35,7 +35,7 @@ public: virtual void write(ostream &out, int indent_level) const; PUBLISHED: - INLINE const LColor &get_specular_color() const FINAL; + INLINE const LColor &get_specular_color() const final; INLINE PN_stdfloat get_max_distance() const; INLINE void set_max_distance(PN_stdfloat max_distance); diff --git a/panda/src/pgraphnodes/spotlight.h b/panda/src/pgraphnodes/spotlight.h index c9a6962b07..d1e56a88b3 100644 --- a/panda/src/pgraphnodes/spotlight.h +++ b/panda/src/pgraphnodes/spotlight.h @@ -46,16 +46,16 @@ public: const LMatrix4 &to_object_space); PUBLISHED: - INLINE PN_stdfloat get_exponent() const FINAL; + INLINE PN_stdfloat get_exponent() const final; INLINE void set_exponent(PN_stdfloat exponent); MAKE_PROPERTY(exponent, get_exponent, set_exponent); - INLINE const LColor &get_specular_color() const FINAL; + INLINE const LColor &get_specular_color() const final; INLINE void set_specular_color(const LColor &color); INLINE void clear_specular_color(); MAKE_PROPERTY(specular_color, get_specular_color, set_specular_color); - INLINE const LVecBase3 &get_attenuation() const FINAL; + INLINE const LVecBase3 &get_attenuation() const final; INLINE void set_attenuation(const LVecBase3 &attenuation); MAKE_PROPERTY(attenuation, get_attenuation, set_attenuation); diff --git a/panda/src/pipeline/cycleData.h b/panda/src/pipeline/cycleData.h index 72ba074088..44c0a7b88c 100644 --- a/panda/src/pipeline/cycleData.h +++ b/panda/src/pipeline/cycleData.h @@ -49,9 +49,9 @@ class EXPCL_PANDA_PIPELINE CycleData #endif // DO_PIPELINING { public: - INLINE CycleData() DEFAULT_CTOR; - INLINE CycleData(CycleData &&from) DEFAULT_CTOR; - INLINE CycleData(const CycleData ©) DEFAULT_CTOR; + INLINE CycleData() = default; + INLINE CycleData(CycleData &&from) = default; + INLINE CycleData(const CycleData ©) = default; virtual ~CycleData(); virtual CycleData *make_copy() const=0; diff --git a/panda/src/pipeline/cycleDataLockedReader.I b/panda/src/pipeline/cycleDataLockedReader.I index 0ac88ebb67..311314e1dd 100644 --- a/panda/src/pipeline/cycleDataLockedReader.I +++ b/panda/src/pipeline/cycleDataLockedReader.I @@ -61,13 +61,12 @@ operator = (const CycleDataLockedReader ©) { _cycler->increment_read(_pointer); } -#ifdef USE_MOVE_SEMANTICS /** * */ template INLINE CycleDataLockedReader:: -CycleDataLockedReader(CycleDataLockedReader &&from) NOEXCEPT : +CycleDataLockedReader(CycleDataLockedReader &&from) noexcept : _cycler(from._cycler), _current_thread(from._current_thread), _pointer(from._pointer) @@ -80,7 +79,7 @@ CycleDataLockedReader(CycleDataLockedReader &&from) NOEXCEPT : */ template INLINE void CycleDataLockedReader:: -operator = (CycleDataLockedReader &&from) NOEXCEPT { +operator = (CycleDataLockedReader &&from) noexcept { nassertv(_pointer == (CycleDataType *)NULL); nassertv(_current_thread == from._current_thread); @@ -89,7 +88,6 @@ operator = (CycleDataLockedReader &&from) NOEXCEPT { from._pointer = NULL; } -#endif // USE_MOVE_SEMANTICS /** * diff --git a/panda/src/pipeline/cycleDataLockedReader.h b/panda/src/pipeline/cycleDataLockedReader.h index f66143fab4..62c1a72b1a 100644 --- a/panda/src/pipeline/cycleDataLockedReader.h +++ b/panda/src/pipeline/cycleDataLockedReader.h @@ -45,12 +45,10 @@ public: INLINE CycleDataLockedReader(const PipelineCycler &cycler, Thread *current_thread = Thread::get_current_thread()); INLINE CycleDataLockedReader(const CycleDataLockedReader ©); - INLINE void operator = (const CycleDataLockedReader ©); + INLINE CycleDataLockedReader(CycleDataLockedReader &&from) noexcept; -#if defined(USE_MOVE_SEMANTICS) && defined(DO_PIPELINING) - INLINE CycleDataLockedReader(CycleDataLockedReader &&from) NOEXCEPT; - INLINE void operator = (CycleDataLockedReader &&from) NOEXCEPT; -#endif + INLINE void operator = (const CycleDataLockedReader ©); + INLINE void operator = (CycleDataLockedReader &&from) noexcept; INLINE ~CycleDataLockedReader(); diff --git a/panda/src/pipeline/cycleDataLockedStageReader.I b/panda/src/pipeline/cycleDataLockedStageReader.I index 9f2c74d23a..d65d9da889 100644 --- a/panda/src/pipeline/cycleDataLockedStageReader.I +++ b/panda/src/pipeline/cycleDataLockedStageReader.I @@ -64,13 +64,12 @@ operator = (const CycleDataLockedStageReader ©) { _cycler->increment_read(_pointer); } -#ifdef USE_MOVE_SEMANTICS /** * */ template INLINE CycleDataLockedStageReader:: -CycleDataLockedStageReader(CycleDataLockedStageReader &&from) NOEXCEPT : +CycleDataLockedStageReader(CycleDataLockedStageReader &&from) noexcept : _cycler(from._cycler), _current_thread(from._current_thread), _pointer(from._pointer), @@ -84,7 +83,7 @@ CycleDataLockedStageReader(CycleDataLockedStageReader &&from) NOE */ template INLINE void CycleDataLockedStageReader:: -operator = (CycleDataLockedStageReader &&from) NOEXCEPT { +operator = (CycleDataLockedStageReader &&from) noexcept { nassertv(_pointer == (CycleDataType *)NULL); nassertv(_current_thread == from._current_thread); @@ -94,7 +93,6 @@ operator = (CycleDataLockedStageReader &&from) NOEXCEPT { from._pointer = NULL; } -#endif // USE_MOVE_SEMANTICS /** * diff --git a/panda/src/pipeline/cycleDataLockedStageReader.h b/panda/src/pipeline/cycleDataLockedStageReader.h index 6837a6edf4..4220a2ce0f 100644 --- a/panda/src/pipeline/cycleDataLockedStageReader.h +++ b/panda/src/pipeline/cycleDataLockedStageReader.h @@ -32,12 +32,10 @@ public: INLINE CycleDataLockedStageReader(const PipelineCycler &cycler, int stage, Thread *current_thread = Thread::get_current_thread()); INLINE CycleDataLockedStageReader(const CycleDataLockedStageReader ©); - INLINE void operator = (const CycleDataLockedStageReader ©); + INLINE CycleDataLockedStageReader(CycleDataLockedStageReader &&from) noexcept; -#if defined(USE_MOVE_SEMANTICS) && defined(DO_PIPELINING) - INLINE CycleDataLockedStageReader(CycleDataLockedStageReader &&from) NOEXCEPT; - INLINE void operator = (CycleDataLockedStageReader &&from) NOEXCEPT; -#endif + INLINE void operator = (const CycleDataLockedStageReader ©); + INLINE void operator = (CycleDataLockedStageReader &&from) noexcept; INLINE ~CycleDataLockedStageReader(); diff --git a/panda/src/pipeline/cycleDataStageWriter.I b/panda/src/pipeline/cycleDataStageWriter.I index 3e6d464768..a4ccc54c60 100644 --- a/panda/src/pipeline/cycleDataStageWriter.I +++ b/panda/src/pipeline/cycleDataStageWriter.I @@ -114,13 +114,12 @@ CycleDataStageWriter(PipelineCycler &cycler, int stage, force_to_0, _current_thread); } -#ifdef USE_MOVE_SEMANTICS /** * */ template INLINE CycleDataStageWriter:: -CycleDataStageWriter(CycleDataStageWriter &&from) NOEXCEPT : +CycleDataStageWriter(CycleDataStageWriter &&from) noexcept : _cycler(from._cycler), _current_thread(from._current_thread), _pointer(from._pointer), @@ -134,7 +133,7 @@ CycleDataStageWriter(CycleDataStageWriter &&from) NOEXCEPT : */ template INLINE void CycleDataStageWriter:: -operator = (CycleDataStageWriter &&from) NOEXCEPT { +operator = (CycleDataStageWriter &&from) noexcept { nassertv(_pointer == (CycleDataType *)NULL); nassertv(_current_thread == from._current_thread); @@ -144,7 +143,6 @@ operator = (CycleDataStageWriter &&from) NOEXCEPT { from._pointer = NULL; } -#endif // USE_MOVE_SEMANTICS /** * diff --git a/panda/src/pipeline/cycleDataStageWriter.h b/panda/src/pipeline/cycleDataStageWriter.h index d154adb6d8..0357d1863d 100644 --- a/panda/src/pipeline/cycleDataStageWriter.h +++ b/panda/src/pipeline/cycleDataStageWriter.h @@ -39,7 +39,7 @@ public: bool force_to_0, Thread *current_thread = Thread::get_current_thread()); INLINE CycleDataStageWriter(const CycleDataStageWriter ©); - INLINE void operator = (const CycleDataStageWriter ©); + INLINE CycleDataStageWriter(CycleDataStageWriter &&from) noexcept; INLINE CycleDataStageWriter(PipelineCycler &cycler, int stage, CycleDataLockedStageReader &take_from); @@ -47,13 +47,11 @@ public: CycleDataLockedStageReader &take_from, bool force_to_0); -#if defined(USE_MOVE_SEMANTICS) && defined(DO_PIPELINING) - INLINE CycleDataStageWriter(CycleDataStageWriter &&from) NOEXCEPT; - INLINE void operator = (CycleDataStageWriter &&from) NOEXCEPT; -#endif - INLINE ~CycleDataStageWriter(); + INLINE void operator = (const CycleDataStageWriter ©); + INLINE void operator = (CycleDataStageWriter &&from) noexcept; + INLINE CycleDataType *operator -> (); INLINE const CycleDataType *operator -> () const; diff --git a/panda/src/pipeline/cycleDataWriter.I b/panda/src/pipeline/cycleDataWriter.I index 3706468612..e142c38b3a 100644 --- a/panda/src/pipeline/cycleDataWriter.I +++ b/panda/src/pipeline/cycleDataWriter.I @@ -130,13 +130,12 @@ CycleDataWriter(PipelineCycler &cycler, force_to_0, _current_thread); } -#ifdef USE_MOVE_SEMANTICS /** * */ template INLINE CycleDataWriter:: -CycleDataWriter(CycleDataWriter &&from) NOEXCEPT : +CycleDataWriter(CycleDataWriter &&from) noexcept : _cycler(from._cycler), _current_thread(from._current_thread), _pointer(from._pointer) @@ -149,7 +148,7 @@ CycleDataWriter(CycleDataWriter &&from) NOEXCEPT : */ template INLINE void CycleDataWriter:: -operator = (CycleDataWriter &&from) NOEXCEPT { +operator = (CycleDataWriter &&from) noexcept { nassertv(_pointer == (CycleDataType *)NULL); nassertv(_current_thread == from._current_thread); @@ -158,7 +157,6 @@ operator = (CycleDataWriter &&from) NOEXCEPT { from._pointer = NULL; } -#endif // USE_MOVE_SEMANTICS /** * diff --git a/panda/src/pipeline/cycleDataWriter.h b/panda/src/pipeline/cycleDataWriter.h index e2a4da7831..616ddae28e 100644 --- a/panda/src/pipeline/cycleDataWriter.h +++ b/panda/src/pipeline/cycleDataWriter.h @@ -44,15 +44,13 @@ public: CycleDataType *locked_cdata, Thread *current_thread = Thread::get_current_thread()); INLINE CycleDataWriter(const CycleDataWriter ©); - INLINE void operator = (const CycleDataWriter ©); + INLINE CycleDataWriter(CycleDataWriter &&from) noexcept; INLINE CycleDataWriter(PipelineCycler &cycler, CycleDataLockedReader &take_from); INLINE CycleDataWriter(PipelineCycler &cycler, CycleDataLockedReader &take_from, bool force_to_0); -#if defined(USE_MOVE_SEMANTICS) && defined(DO_PIPELINING) - INLINE CycleDataWriter(CycleDataWriter &&from) NOEXCEPT; - INLINE void operator = (CycleDataWriter &&from) NOEXCEPT; -#endif + INLINE void operator = (CycleDataWriter &&from) noexcept; + INLINE void operator = (const CycleDataWriter ©); INLINE ~CycleDataWriter(); diff --git a/panda/src/pipeline/lightMutex.I b/panda/src/pipeline/lightMutex.I index a7bb09ed17..4121d607e2 100644 --- a/panda/src/pipeline/lightMutex.I +++ b/panda/src/pipeline/lightMutex.I @@ -46,31 +46,3 @@ LightMutex(const string &) #endif // DEBUG_THREADS { } - -/** - * - */ -INLINE LightMutex:: -~LightMutex() { -} - -/** - * Do not attempt to copy lightMutexes. - */ -INLINE LightMutex:: -#ifdef DEBUG_THREADS -LightMutex(const LightMutex ©) : MutexDebug(string(), false, true) -#else - LightMutex(const LightMutex ©) -#endif // DEBUG_THREADS -{ - nassertv(false); -} - -/** - * Do not attempt to copy lightMutexes. - */ -INLINE void LightMutex:: -operator = (const LightMutex ©) { - nassertv(false); -} diff --git a/panda/src/pipeline/lightMutex.h b/panda/src/pipeline/lightMutex.h index 77ad4b26ae..164db7195e 100644 --- a/panda/src/pipeline/lightMutex.h +++ b/panda/src/pipeline/lightMutex.h @@ -45,10 +45,10 @@ public: INLINE explicit LightMutex(const char *name); PUBLISHED: INLINE explicit LightMutex(const string &name); - INLINE ~LightMutex(); -private: - INLINE LightMutex(const LightMutex ©); - INLINE void operator = (const LightMutex ©); + LightMutex(const LightMutex ©) = delete; + ~LightMutex() = default; + + void operator = (const LightMutex ©) = delete; }; #include "lightMutex.I" diff --git a/panda/src/pipeline/lightMutexDirect.I b/panda/src/pipeline/lightMutexDirect.I index e9d838d3fb..041f388ce2 100644 --- a/panda/src/pipeline/lightMutexDirect.I +++ b/panda/src/pipeline/lightMutexDirect.I @@ -11,36 +11,6 @@ * @date 2008-10-08 */ -/** - * - */ -INLINE LightMutexDirect:: -LightMutexDirect() { -} - -/** - * - */ -INLINE LightMutexDirect:: -~LightMutexDirect() { -} - -/** - * Do not attempt to copy lightMutexes. - */ -INLINE LightMutexDirect:: -LightMutexDirect(const LightMutexDirect ©) { - nassertv(false); -} - -/** - * Do not attempt to copy lightMutexes. - */ -INLINE void LightMutexDirect:: -operator = (const LightMutexDirect ©) { - nassertv(false); -} - /** * Alias for acquire() to match C++11 semantics. * @see acquire() diff --git a/panda/src/pipeline/lightMutexDirect.h b/panda/src/pipeline/lightMutexDirect.h index 54fca1a0ee..78ffcce433 100644 --- a/panda/src/pipeline/lightMutexDirect.h +++ b/panda/src/pipeline/lightMutexDirect.h @@ -30,11 +30,11 @@ class Thread; */ class EXPCL_PANDA_PIPELINE LightMutexDirect { protected: - INLINE LightMutexDirect(); - INLINE ~LightMutexDirect(); -private: - INLINE LightMutexDirect(const LightMutexDirect ©); - INLINE void operator = (const LightMutexDirect ©); + LightMutexDirect() = default; + LightMutexDirect(const LightMutexDirect ©) = delete; + ~LightMutexDirect() = default; + + void operator = (const LightMutexDirect ©) = delete; public: INLINE void lock(); diff --git a/panda/src/pipeline/lightReMutexDirect.I b/panda/src/pipeline/lightReMutexDirect.I index 1cfbe15723..388387517c 100644 --- a/panda/src/pipeline/lightReMutexDirect.I +++ b/panda/src/pipeline/lightReMutexDirect.I @@ -26,33 +26,6 @@ LightReMutexDirect() #endif } -/** - * - */ -INLINE LightReMutexDirect:: -~LightReMutexDirect() { -} - -/** - * Do not attempt to copy lightReMutexes. - */ -INLINE LightReMutexDirect:: -LightReMutexDirect(const LightReMutexDirect ©) -#ifndef HAVE_REMUTEXIMPL - : _cvar_impl(_lock_impl) -#endif -{ - nassertv(false); -} - -/** - * Do not attempt to copy lightReMutexes. - */ -INLINE void LightReMutexDirect:: -operator = (const LightReMutexDirect ©) { - nassertv(false); -} - /** * Alias for acquire() to match C++11 semantics. * @see acquire() diff --git a/panda/src/pipeline/lightReMutexDirect.h b/panda/src/pipeline/lightReMutexDirect.h index 7976b90e2c..21f25c1c31 100644 --- a/panda/src/pipeline/lightReMutexDirect.h +++ b/panda/src/pipeline/lightReMutexDirect.h @@ -30,10 +30,10 @@ class Thread; class EXPCL_PANDA_PIPELINE LightReMutexDirect { protected: INLINE LightReMutexDirect(); - INLINE ~LightReMutexDirect(); -private: - INLINE LightReMutexDirect(const LightReMutexDirect ©); - INLINE void operator = (const LightReMutexDirect ©); + LightReMutexDirect(const LightReMutexDirect ©) = delete; + ~LightReMutexDirect() = default; + + void operator = (const LightReMutexDirect ©) = delete; public: INLINE void lock(); diff --git a/panda/src/pipeline/mutexDebug.I b/panda/src/pipeline/mutexDebug.I index 724078b033..9262f3e6d3 100644 --- a/panda/src/pipeline/mutexDebug.I +++ b/panda/src/pipeline/mutexDebug.I @@ -11,22 +11,6 @@ * @date 2006-02-13 */ -/** - * Do not attempt to copy mutexes. - */ -INLINE MutexDebug:: -MutexDebug(const MutexDebug ©) : _cvar_impl(*get_global_lock()) { - nassertv(false); -} - -/** - * Do not attempt to copy mutexes. - */ -INLINE void MutexDebug:: -operator = (const MutexDebug ©) { - nassertv(false); -} - /** * Alias for acquire() to match C++11 semantics. * @see acquire() diff --git a/panda/src/pipeline/mutexDebug.h b/panda/src/pipeline/mutexDebug.h index 2ced4beca0..4fc3e4eeaa 100644 --- a/panda/src/pipeline/mutexDebug.h +++ b/panda/src/pipeline/mutexDebug.h @@ -30,10 +30,10 @@ class EXPCL_PANDA_PIPELINE MutexDebug : public Namable { protected: MutexDebug(const string &name, bool allow_recursion, bool lightweight); + MutexDebug(const MutexDebug ©) = delete; virtual ~MutexDebug(); -private: - INLINE MutexDebug(const MutexDebug ©); - INLINE void operator = (const MutexDebug ©); + + void operator = (const MutexDebug ©) = delete; public: INLINE void lock(); diff --git a/panda/src/pipeline/mutexDirect.I b/panda/src/pipeline/mutexDirect.I index 73cde8b33b..e12442289c 100644 --- a/panda/src/pipeline/mutexDirect.I +++ b/panda/src/pipeline/mutexDirect.I @@ -11,36 +11,6 @@ * @date 2006-02-13 */ -/** - * - */ -INLINE MutexDirect:: -MutexDirect() { -} - -/** - * - */ -INLINE MutexDirect:: -~MutexDirect() { -} - -/** - * Do not attempt to copy mutexes. - */ -INLINE MutexDirect:: -MutexDirect(const MutexDirect ©) { - nassertv(false); -} - -/** - * Do not attempt to copy mutexes. - */ -INLINE void MutexDirect:: -operator = (const MutexDirect ©) { - nassertv(false); -} - /** * Alias for acquire() to match C++11 semantics. * @see acquire() diff --git a/panda/src/pipeline/mutexDirect.h b/panda/src/pipeline/mutexDirect.h index 6f888e0af6..b288dc0648 100644 --- a/panda/src/pipeline/mutexDirect.h +++ b/panda/src/pipeline/mutexDirect.h @@ -29,11 +29,11 @@ class Thread; */ class EXPCL_PANDA_PIPELINE MutexDirect { protected: - INLINE MutexDirect(); - INLINE ~MutexDirect(); -private: - INLINE MutexDirect(const MutexDirect ©); - INLINE void operator = (const MutexDirect ©); + MutexDirect() = default; + MutexDirect(const MutexDirect ©) = delete; + ~MutexDirect() = default; + + void operator = (const MutexDirect ©) = delete; public: INLINE void lock(); diff --git a/panda/src/pipeline/mutexSimpleImpl.h b/panda/src/pipeline/mutexSimpleImpl.h index 31a50c306c..3c194a08f1 100644 --- a/panda/src/pipeline/mutexSimpleImpl.h +++ b/panda/src/pipeline/mutexSimpleImpl.h @@ -36,7 +36,7 @@ */ class EXPCL_PANDA_PIPELINE MutexSimpleImpl : public BlockerSimple { public: - CONSTEXPR MutexSimpleImpl() DEFAULT_CTOR; + constexpr MutexSimpleImpl() = default; INLINE void lock(); INLINE bool try_lock(); diff --git a/panda/src/pipeline/pmutex.I b/panda/src/pipeline/pmutex.I index 1cdfd011d4..9a5ca4c926 100644 --- a/panda/src/pipeline/pmutex.I +++ b/panda/src/pipeline/pmutex.I @@ -46,31 +46,3 @@ Mutex(const string &) #endif // DEBUG_THREADS { } - -/** - * - */ -INLINE Mutex:: -~Mutex() { -} - -/** - * Do not attempt to copy mutexes. - */ -INLINE Mutex:: -#ifdef DEBUG_THREADS -Mutex(const Mutex ©) : MutexDebug(string(), false, false) -#else - Mutex(const Mutex ©) -#endif // DEBUG_THREADS -{ - nassertv(false); -} - -/** - * Do not attempt to copy mutexes. - */ -INLINE void Mutex:: -operator = (const Mutex ©) { - nassertv(false); -} diff --git a/panda/src/pipeline/pmutex.h b/panda/src/pipeline/pmutex.h index c5d471ae0c..bc547afab3 100644 --- a/panda/src/pipeline/pmutex.h +++ b/panda/src/pipeline/pmutex.h @@ -44,10 +44,10 @@ public: INLINE Mutex(const char *name); PUBLISHED: INLINE explicit Mutex(const string &name); - INLINE ~Mutex(); -private: - INLINE Mutex(const Mutex ©); - INLINE void operator = (const Mutex ©); + Mutex(const Mutex ©) = delete; + ~Mutex() = default; + + void operator = (const Mutex ©) = delete; public: // This is a global mutex set aside for the purpose of protecting Notify diff --git a/panda/src/pipeline/reMutex.I b/panda/src/pipeline/reMutex.I index e67f378c35..361d3a1c85 100644 --- a/panda/src/pipeline/reMutex.I +++ b/panda/src/pipeline/reMutex.I @@ -46,18 +46,3 @@ ReMutex(const string &) #endif // DEBUG_THREADS { } - -/** - * - */ -INLINE ReMutex:: -~ReMutex() { -} - -/** - * Do not attempt to copy mutexes. - */ -INLINE void ReMutex:: -operator = (const ReMutex ©) { - nassertv(false); -} diff --git a/panda/src/pipeline/reMutex.h b/panda/src/pipeline/reMutex.h index fd6a710b55..1597c2d7c4 100644 --- a/panda/src/pipeline/reMutex.h +++ b/panda/src/pipeline/reMutex.h @@ -38,10 +38,10 @@ public: INLINE explicit ReMutex(const char *name); PUBLISHED: INLINE explicit ReMutex(const string &name); - INLINE ~ReMutex(); -private: - INLINE ReMutex(const ReMutex ©); - INLINE void operator = (const ReMutex ©); + ReMutex(const ReMutex ©) = delete; + ~ReMutex() = default; + + void operator = (const ReMutex ©) = delete; }; #include "reMutex.I" diff --git a/panda/src/pipeline/reMutexDirect.I b/panda/src/pipeline/reMutexDirect.I index 7d0319ad61..cdcc7fd45e 100644 --- a/panda/src/pipeline/reMutexDirect.I +++ b/panda/src/pipeline/reMutexDirect.I @@ -26,33 +26,6 @@ ReMutexDirect() #endif } -/** - * - */ -INLINE ReMutexDirect:: -~ReMutexDirect() { -} - -/** - * Do not attempt to copy reMutexes. - */ -INLINE ReMutexDirect:: -ReMutexDirect(const ReMutexDirect ©) -#ifndef HAVE_REMUTEXTRUEIMPL - : _cvar_impl(_lock_impl) -#endif -{ - nassertv(false); -} - -/** - * Do not attempt to copy reMutexes. - */ -INLINE void ReMutexDirect:: -operator = (const ReMutexDirect ©) { - nassertv(false); -} - /** * Alias for acquire() to match C++11 semantics. * @see acquire() diff --git a/panda/src/pipeline/reMutexDirect.h b/panda/src/pipeline/reMutexDirect.h index fd18a38fc2..c47c4b02bd 100644 --- a/panda/src/pipeline/reMutexDirect.h +++ b/panda/src/pipeline/reMutexDirect.h @@ -30,10 +30,10 @@ class Thread; class EXPCL_PANDA_PIPELINE ReMutexDirect { protected: INLINE ReMutexDirect(); - INLINE ~ReMutexDirect(); -private: - INLINE ReMutexDirect(const ReMutexDirect ©); - INLINE void operator = (const ReMutexDirect ©); + ReMutexDirect(const ReMutexDirect ©) = delete; + ~ReMutexDirect() = default; + + void operator = (const ReMutexDirect ©) = delete; public: INLINE void lock(); diff --git a/panda/src/putil/bitArray.I b/panda/src/putil/bitArray.I index f746a9ba77..2a3341833d 100644 --- a/panda/src/putil/bitArray.I +++ b/panda/src/putil/bitArray.I @@ -87,7 +87,7 @@ range(int low_bit, int size) { * bits. This method is defined so generic programming algorithms can use * BitMask or BitArray interchangeably. */ -CONSTEXPR bool BitArray:: +constexpr bool BitArray:: has_max_num_bits() { return false; } @@ -101,7 +101,7 @@ has_max_num_bits() { * number of bits. This method is defined so generic programming algorithms * can use BitMask or BitArray interchangeably. */ -CONSTEXPR int BitArray:: +constexpr int BitArray:: get_max_num_bits() { return INT_MAX; } @@ -111,7 +111,7 @@ get_max_num_bits() { * only in that it limits the maximum number of bits that may be queried or * set at once by extract() and store(). */ -CONSTEXPR int BitArray:: +constexpr int BitArray:: get_num_bits_per_word() { return num_bits_per_word; } diff --git a/panda/src/putil/bitArray.h b/panda/src/putil/bitArray.h index 72ef1f656d..42070ad3f8 100644 --- a/panda/src/putil/bitArray.h +++ b/panda/src/putil/bitArray.h @@ -54,10 +54,10 @@ PUBLISHED: INLINE static BitArray bit(int index); INLINE static BitArray range(int low_bit, int size); - CONSTEXPR static bool has_max_num_bits(); - CONSTEXPR static int get_max_num_bits(); + constexpr static bool has_max_num_bits(); + constexpr static int get_max_num_bits(); - CONSTEXPR static int get_num_bits_per_word(); + constexpr static int get_num_bits_per_word(); INLINE size_t get_num_bits() const; INLINE bool get_bit(int index) const; INLINE void set_bit(int index); diff --git a/panda/src/putil/bitMask.I b/panda/src/putil/bitMask.I index 0411d06042..837101a961 100644 --- a/panda/src/putil/bitMask.I +++ b/panda/src/putil/bitMask.I @@ -110,7 +110,7 @@ range(int low_bit, int size) { * programming algorithms can use BitMask or BitArray interchangeably. */ template -CONSTEXPR bool BitMask:: +constexpr bool BitMask:: has_max_num_bits() { return true; } @@ -125,7 +125,7 @@ has_max_num_bits() { * can use BitMask or BitArray interchangeably. */ template -CONSTEXPR int BitMask:: +constexpr int BitMask:: get_max_num_bits() { return num_bits; } @@ -134,7 +134,7 @@ get_max_num_bits() { * Returns the number of bits available to set in the bitmask. */ template -CONSTEXPR int BitMask:: +constexpr int BitMask:: get_num_bits() { return num_bits; } diff --git a/panda/src/putil/bitMask.h b/panda/src/putil/bitMask.h index 5333562025..589c4dd73c 100644 --- a/panda/src/putil/bitMask.h +++ b/panda/src/putil/bitMask.h @@ -45,10 +45,10 @@ PUBLISHED: INLINE static BitMask bit(int index); INLINE static BitMask range(int low_bit, int size); - CONSTEXPR static bool has_max_num_bits(); - CONSTEXPR static int get_max_num_bits(); + constexpr static bool has_max_num_bits(); + constexpr static int get_max_num_bits(); - CONSTEXPR static int get_num_bits(); + constexpr static int get_num_bits(); INLINE bool get_bit(int index) const; INLINE void set_bit(int index); INLINE void clear_bit(int index); diff --git a/panda/src/putil/buttonHandle.I b/panda/src/putil/buttonHandle.I index 2353b01689..2df12e8cd0 100644 --- a/panda/src/putil/buttonHandle.I +++ b/panda/src/putil/buttonHandle.I @@ -15,7 +15,7 @@ * Constructs a ButtonHandle with the corresponding index number, which may * have been returned by an earlier call to ButtonHandle::get_index(). */ -CONSTEXPR ButtonHandle:: +constexpr ButtonHandle:: ButtonHandle(int index) : _index(index) { } @@ -124,7 +124,7 @@ matches(const ButtonHandle &other) const { * opaque classes. This is provided for the convenience of non-C++ scripting * languages to build a hashtable of ButtonHandles. */ -CONSTEXPR int ButtonHandle:: +constexpr int ButtonHandle:: get_index() const { return _index; } diff --git a/panda/src/putil/buttonHandle.h b/panda/src/putil/buttonHandle.h index 429108249f..4ee27b01ae 100644 --- a/panda/src/putil/buttonHandle.h +++ b/panda/src/putil/buttonHandle.h @@ -23,14 +23,14 @@ * keyboard buttons and mouse buttons (but see KeyboardButton and * MouseButton). */ -class EXPCL_PANDA_PUTIL ButtonHandle FINAL { +class EXPCL_PANDA_PUTIL ButtonHandle final { PUBLISHED: // The default constructor must do nothing, because we can't guarantee // ordering of static initializers. If the constructor tried to initialize // its value, it might happen after the value had already been set // previously by another static initializer! - INLINE ButtonHandle() DEFAULT_CTOR; - CONSTEXPR ButtonHandle(int index); + INLINE ButtonHandle() = default; + constexpr ButtonHandle(int index); ButtonHandle(const string &name); PUBLISHED: @@ -51,7 +51,7 @@ PUBLISHED: INLINE bool matches(const ButtonHandle &other) const; - CONSTEXPR int get_index() const; + constexpr int get_index() const; INLINE void output(ostream &out) const; INLINE static ButtonHandle none(); diff --git a/panda/src/putil/copyOnWritePointer.I b/panda/src/putil/copyOnWritePointer.I index 9e996355fa..9354fe350a 100644 --- a/panda/src/putil/copyOnWritePointer.I +++ b/panda/src/putil/copyOnWritePointer.I @@ -69,12 +69,11 @@ INLINE CopyOnWritePointer:: } } -#ifdef USE_MOVE_SEMANTICS /** * */ INLINE CopyOnWritePointer:: -CopyOnWritePointer(CopyOnWritePointer &&from) NOEXCEPT : +CopyOnWritePointer(CopyOnWritePointer &&from) noexcept : _cow_object(from._cow_object) { // Steal the other's reference count. @@ -85,7 +84,7 @@ CopyOnWritePointer(CopyOnWritePointer &&from) NOEXCEPT : * */ INLINE CopyOnWritePointer:: -CopyOnWritePointer(PointerTo &&from) NOEXCEPT : +CopyOnWritePointer(PointerTo &&from) noexcept : _cow_object(from.p()) { // Steal the other's reference count, but because it is a regular pointer, @@ -100,7 +99,7 @@ CopyOnWritePointer(PointerTo &&from) NOEXCEPT : * */ INLINE void CopyOnWritePointer:: -operator = (CopyOnWritePointer &&from) NOEXCEPT { +operator = (CopyOnWritePointer &&from) noexcept { // Protect against self-move-assignment. if (from._cow_object != _cow_object) { CopyOnWriteObject *old_object = _cow_object; @@ -117,7 +116,7 @@ operator = (CopyOnWritePointer &&from) NOEXCEPT { * */ INLINE void CopyOnWritePointer:: -operator = (PointerTo &&from) NOEXCEPT { +operator = (PointerTo &&from) noexcept { if (from.p() != _cow_object) { CopyOnWriteObject *old_object = _cow_object; @@ -132,7 +131,6 @@ operator = (PointerTo &&from) NOEXCEPT { } } } -#endif // USE_MOVE_SEMANTICS /** * @@ -290,14 +288,13 @@ operator = (To *object) { } #endif // CPPPARSER -#ifdef USE_MOVE_SEMANTICS #ifndef CPPPARSER /** * */ template INLINE CopyOnWritePointerTo:: -CopyOnWritePointerTo(CopyOnWritePointerTo &&from) NOEXCEPT : +CopyOnWritePointerTo(CopyOnWritePointerTo &&from) noexcept : CopyOnWritePointer((CopyOnWritePointer &&)from) { } @@ -309,7 +306,7 @@ CopyOnWritePointerTo(CopyOnWritePointerTo &&from) NOEXCEPT : */ template INLINE CopyOnWritePointerTo:: -CopyOnWritePointerTo(PointerTo &&from) NOEXCEPT { +CopyOnWritePointerTo(PointerTo &&from) noexcept { // Steal the other's reference count, but because it is a regular pointer, // we do need to include the cache reference count. _cow_object = from.p(); @@ -326,7 +323,7 @@ CopyOnWritePointerTo(PointerTo &&from) NOEXCEPT { */ template INLINE void CopyOnWritePointerTo:: -operator = (CopyOnWritePointerTo &&from) NOEXCEPT { +operator = (CopyOnWritePointerTo &&from) noexcept { CopyOnWritePointer::operator = ((CopyOnWritePointer &&)from); } #endif // CPPPARSER @@ -337,7 +334,7 @@ operator = (CopyOnWritePointerTo &&from) NOEXCEPT { */ template INLINE void CopyOnWritePointerTo:: -operator = (PointerTo &&from) NOEXCEPT { +operator = (PointerTo &&from) noexcept { if (from.p() != _cow_object) { CopyOnWriteObject *old_object = _cow_object; @@ -353,7 +350,6 @@ operator = (PointerTo &&from) NOEXCEPT { } } #endif // CPPPARSER -#endif // USE_MOVE_SEMANTICS #ifndef CPPPARSER #ifdef COW_THREADED diff --git a/panda/src/putil/copyOnWritePointer.h b/panda/src/putil/copyOnWritePointer.h index 2178b6b433..a98599361a 100644 --- a/panda/src/putil/copyOnWritePointer.h +++ b/panda/src/putil/copyOnWritePointer.h @@ -32,16 +32,14 @@ class EXPCL_PANDA_PUTIL CopyOnWritePointer { public: INLINE CopyOnWritePointer(CopyOnWriteObject *object = NULL); INLINE CopyOnWritePointer(const CopyOnWritePointer ©); - INLINE void operator = (const CopyOnWritePointer ©); - INLINE void operator = (CopyOnWriteObject *object); + INLINE CopyOnWritePointer(CopyOnWritePointer &&from) noexcept; + INLINE CopyOnWritePointer(PointerTo &&from) noexcept; INLINE ~CopyOnWritePointer(); -#ifdef USE_MOVE_SEMANTICS - INLINE CopyOnWritePointer(CopyOnWritePointer &&from) NOEXCEPT; - INLINE CopyOnWritePointer(PointerTo &&from) NOEXCEPT; - INLINE void operator = (CopyOnWritePointer &&from) NOEXCEPT; - INLINE void operator = (PointerTo &&from) NOEXCEPT; -#endif + INLINE void operator = (const CopyOnWritePointer ©); + INLINE void operator = (CopyOnWritePointer &&from) noexcept; + INLINE void operator = (PointerTo &&from) noexcept; + INLINE void operator = (CopyOnWriteObject *object); INLINE bool operator == (const CopyOnWritePointer &other) const; INLINE bool operator != (const CopyOnWritePointer &other) const; @@ -82,15 +80,13 @@ public: INLINE CopyOnWritePointerTo(To *object = NULL); INLINE CopyOnWritePointerTo(const CopyOnWritePointerTo ©); + INLINE CopyOnWritePointerTo(CopyOnWritePointerTo &&from) noexcept; + INLINE CopyOnWritePointerTo(PointerTo &&from) noexcept; + INLINE void operator = (const CopyOnWritePointerTo ©); INLINE void operator = (To *object); - -#ifdef USE_MOVE_SEMANTICS - INLINE CopyOnWritePointerTo(CopyOnWritePointerTo &&from) NOEXCEPT; - INLINE CopyOnWritePointerTo(PointerTo &&from) NOEXCEPT; - INLINE void operator = (CopyOnWritePointerTo &&from) NOEXCEPT; - INLINE void operator = (PointerTo &&from) NOEXCEPT; -#endif + INLINE void operator = (CopyOnWritePointerTo &&from) noexcept; + INLINE void operator = (PointerTo &&from) noexcept; #ifdef COW_THREADED INLINE CPT(To) get_read_pointer(Thread *current_thread = Thread::get_current_thread()) const; diff --git a/panda/src/putil/doubleBitMask.I b/panda/src/putil/doubleBitMask.I index a6997af549..0b08768229 100644 --- a/panda/src/putil/doubleBitMask.I +++ b/panda/src/putil/doubleBitMask.I @@ -128,7 +128,7 @@ INLINE DoubleBitMask:: * programming algorithms can use DoubleBitMask or BitArray interchangeably. */ template -CONSTEXPR bool DoubleBitMask:: +constexpr bool DoubleBitMask:: has_max_num_bits() { return true; } @@ -143,7 +143,7 @@ has_max_num_bits() { * can use DoubleBitMask or BitArray interchangeably. */ template -CONSTEXPR int DoubleBitMask:: +constexpr int DoubleBitMask:: get_max_num_bits() { return num_bits; } @@ -152,7 +152,7 @@ get_max_num_bits() { * Returns the number of bits available to set in the doubleBitMask. */ template -CONSTEXPR int DoubleBitMask:: +constexpr int DoubleBitMask:: get_num_bits() { return num_bits; } diff --git a/panda/src/putil/doubleBitMask.h b/panda/src/putil/doubleBitMask.h index d229eb03a6..472a1ddc3f 100644 --- a/panda/src/putil/doubleBitMask.h +++ b/panda/src/putil/doubleBitMask.h @@ -49,10 +49,10 @@ PUBLISHED: INLINE ~DoubleBitMask(); - CONSTEXPR static bool has_max_num_bits(); - CONSTEXPR static int get_max_num_bits(); + constexpr static bool has_max_num_bits(); + constexpr static int get_max_num_bits(); - CONSTEXPR static int get_num_bits(); + constexpr static int get_num_bits(); INLINE bool get_bit(int index) const; INLINE void set_bit(int index); INLINE void clear_bit(int index); diff --git a/panda/src/putil/factoryParams.I b/panda/src/putil/factoryParams.I index 0c6fdd09e7..04b7d2c634 100644 --- a/panda/src/putil/factoryParams.I +++ b/panda/src/putil/factoryParams.I @@ -35,24 +35,22 @@ INLINE FactoryParams:: ~FactoryParams() { } -#ifdef USE_MOVE_SEMANTICS /** * */ INLINE FactoryParams:: -FactoryParams(FactoryParams &&from) NOEXCEPT : - _params(move(from._params)), +FactoryParams(FactoryParams &&from) noexcept : + _params(std::move(from._params)), _user_data(from._user_data) {} /** * */ INLINE void FactoryParams:: -operator = (FactoryParams &&from) NOEXCEPT { - _params = move(from._params); +operator = (FactoryParams &&from) noexcept { + _params = std::move(from._params); _user_data = from._user_data; } -#endif /** * Returns the custom pointer that was associated with the factory function. diff --git a/panda/src/putil/factoryParams.h b/panda/src/putil/factoryParams.h index 5c45a6e2ee..3f987e7f66 100644 --- a/panda/src/putil/factoryParams.h +++ b/panda/src/putil/factoryParams.h @@ -37,12 +37,10 @@ class EXPCL_PANDA_PUTIL FactoryParams { public: INLINE FactoryParams(); INLINE FactoryParams(const FactoryParams ©); + INLINE FactoryParams(FactoryParams &&from) noexcept; INLINE ~FactoryParams(); -#ifdef USE_MOVE_SEMANTICS - INLINE FactoryParams(FactoryParams &&from) NOEXCEPT; - INLINE void operator = (FactoryParams &&from) NOEXCEPT; -#endif + INLINE void operator = (FactoryParams &&from) noexcept; void add_param(FactoryParam *param); void clear(); diff --git a/panda/src/putil/iterator_types.h b/panda/src/putil/iterator_types.h index 2f2966cde7..80d8f32882 100644 --- a/panda/src/putil/iterator_types.h +++ b/panda/src/putil/iterator_types.h @@ -26,7 +26,7 @@ class first_of_pair_iterator : public pair_iterator { public: typedef TYPENAME pair_iterator::value_type::first_type value_type; - first_of_pair_iterator() DEFAULT_CTOR; + first_of_pair_iterator() = default; first_of_pair_iterator(const pair_iterator &init) : pair_iterator(init) { } value_type operator *() { @@ -44,7 +44,7 @@ class second_of_pair_iterator : public pair_iterator { public: typedef TYPENAME pair_iterator::value_type::second_type value_type; - second_of_pair_iterator() DEFAULT_CTOR; + second_of_pair_iterator() = default; second_of_pair_iterator(const pair_iterator &init) : pair_iterator(init) { } value_type operator *() { @@ -61,7 +61,7 @@ class typecast_iterator : public base_iterator { public: typedef new_type value_type; - typecast_iterator() DEFAULT_CTOR; + typecast_iterator() = default; typecast_iterator(const base_iterator &init) : base_iterator(init) { } value_type operator *() { diff --git a/panda/src/putil/simpleHashMap.I b/panda/src/putil/simpleHashMap.I index 26728f1e01..2cc4e006df 100644 --- a/panda/src/putil/simpleHashMap.I +++ b/panda/src/putil/simpleHashMap.I @@ -15,7 +15,7 @@ * */ template -CONSTEXPR SimpleHashMap:: +constexpr SimpleHashMap:: SimpleHashMap(const Compare &comp) : _table(nullptr), _deleted_chain(nullptr), @@ -55,7 +55,7 @@ SimpleHashMap(const SimpleHashMap ©) : */ template INLINE SimpleHashMap:: -SimpleHashMap(SimpleHashMap &&from) NOEXCEPT : +SimpleHashMap(SimpleHashMap &&from) noexcept : _table(from._table), _deleted_chain(from._deleted_chain), _table_size(from._table_size), @@ -109,7 +109,7 @@ operator = (const SimpleHashMap ©) { */ template INLINE SimpleHashMap &SimpleHashMap:: -operator = (SimpleHashMap &&from) NOEXCEPT { +operator = (SimpleHashMap &&from) noexcept { if (this != &from) { _table = from._table; _deleted_chain = from._deleted_chain; @@ -360,7 +360,7 @@ operator [] (const Key &key) { * Returns the total number of entries in the table. Same as get_num_entries. */ template -CONSTEXPR size_t SimpleHashMap:: +constexpr size_t SimpleHashMap:: size() const { return _num_entries; } diff --git a/panda/src/putil/simpleHashMap.h b/panda/src/putil/simpleHashMap.h index 68f6352a88..6d08de5554 100644 --- a/panda/src/putil/simpleHashMap.h +++ b/panda/src/putil/simpleHashMap.h @@ -59,8 +59,8 @@ public: Key _key; - ALWAYS_INLINE_CONSTEXPR static nullptr_t get_data() { return nullptr; } - ALWAYS_INLINE_CONSTEXPR static nullptr_t modify_data() { return nullptr; } + ALWAYS_INLINE constexpr static nullptr_t get_data() { return nullptr; } + ALWAYS_INLINE constexpr static nullptr_t modify_data() { return nullptr; } ALWAYS_INLINE static void set_data(nullptr_t) {} }; @@ -85,13 +85,13 @@ class SimpleHashMap { public: #ifndef CPPPARSER - CONSTEXPR SimpleHashMap(const Compare &comp = Compare()); + constexpr SimpleHashMap(const Compare &comp = Compare()); INLINE SimpleHashMap(const SimpleHashMap ©); - INLINE SimpleHashMap(SimpleHashMap &&from) NOEXCEPT; + INLINE SimpleHashMap(SimpleHashMap &&from) noexcept; INLINE ~SimpleHashMap(); INLINE SimpleHashMap &operator = (const SimpleHashMap ©); - INLINE SimpleHashMap &operator = (SimpleHashMap &&from) NOEXCEPT; + INLINE SimpleHashMap &operator = (SimpleHashMap &&from) noexcept; INLINE void swap(SimpleHashMap &other); @@ -101,7 +101,7 @@ public: void clear(); INLINE Value &operator [] (const Key &key); - CONSTEXPR size_t size() const; + constexpr size_t size() const; INLINE const Key &get_key(size_t n) const; INLINE const Value &get_data(size_t n) const; diff --git a/panda/src/putil/updateSeq.I b/panda/src/putil/updateSeq.I index 99703059d4..1df2577c35 100644 --- a/panda/src/putil/updateSeq.I +++ b/panda/src/putil/updateSeq.I @@ -14,21 +14,21 @@ /** * Creates an UpdateSeq in the given state. */ -CONSTEXPR UpdateSeq:: +constexpr UpdateSeq:: UpdateSeq(unsigned int seq) : _seq(seq) { } /** * Creates an UpdateSeq in the 'initial' state. */ -CONSTEXPR UpdateSeq:: +constexpr UpdateSeq:: UpdateSeq() : _seq((unsigned int)SC_initial) { } /** * Returns an UpdateSeq in the 'initial' state. */ -CONSTEXPR UpdateSeq UpdateSeq:: +constexpr UpdateSeq UpdateSeq:: initial() { return UpdateSeq((unsigned int)SC_initial); } @@ -36,7 +36,7 @@ initial() { /** * Returns an UpdateSeq in the 'old' state. */ -CONSTEXPR UpdateSeq UpdateSeq:: +constexpr UpdateSeq UpdateSeq:: old() { return UpdateSeq((unsigned int)SC_old); } @@ -44,7 +44,7 @@ old() { /** * Returns an UpdateSeq in the 'fresh' state. */ -CONSTEXPR UpdateSeq UpdateSeq:: +constexpr UpdateSeq UpdateSeq:: fresh() { return UpdateSeq((unsigned int)SC_fresh); } @@ -59,8 +59,8 @@ UpdateSeq(const UpdateSeq ©) : _seq(AtomicAdjust::get(copy._seq)) { /** * */ -CONSTEXPR UpdateSeq:: -UpdateSeq(const UpdateSeq &&from) NOEXCEPT : _seq(from._seq) { +constexpr UpdateSeq:: +UpdateSeq(const UpdateSeq &&from) noexcept : _seq(from._seq) { } /** diff --git a/panda/src/putil/updateSeq.h b/panda/src/putil/updateSeq.h index 5ba9de908f..4a982df279 100644 --- a/panda/src/putil/updateSeq.h +++ b/panda/src/putil/updateSeq.h @@ -36,16 +36,16 @@ */ class EXPCL_PANDA_PUTIL UpdateSeq { private: - CONSTEXPR UpdateSeq(unsigned int seq); + constexpr UpdateSeq(unsigned int seq); PUBLISHED: - CONSTEXPR UpdateSeq(); - CONSTEXPR static UpdateSeq initial(); - CONSTEXPR static UpdateSeq old(); - CONSTEXPR static UpdateSeq fresh(); + constexpr UpdateSeq(); + constexpr static UpdateSeq initial(); + constexpr static UpdateSeq old(); + constexpr static UpdateSeq fresh(); INLINE UpdateSeq(const UpdateSeq ©); - CONSTEXPR UpdateSeq(const UpdateSeq &&from) NOEXCEPT; + constexpr UpdateSeq(const UpdateSeq &&from) noexcept; INLINE UpdateSeq &operator = (const UpdateSeq ©); INLINE void clear(); diff --git a/panda/src/putil/weakKeyHashMap.I b/panda/src/putil/weakKeyHashMap.I index a3246c19ec..514818a9be 100644 --- a/panda/src/putil/weakKeyHashMap.I +++ b/panda/src/putil/weakKeyHashMap.I @@ -295,7 +295,6 @@ set_data(size_t n, const Value &data) { _table[n]._data = data; } -#ifdef USE_MOVE_SEMANTICS /** * Changes the data for the nth slot of the table. * @@ -309,7 +308,6 @@ set_data(size_t n, Value &&data) { nassertv(has_element(n)); _table[n]._data = move(data); } -#endif // USE_MOVE_SEMANTICS /** * Removes the nth slot from the table. @@ -611,13 +609,9 @@ expand_table() { new_index = (new_index + 1) & (_table_size - 1); } -#ifdef USE_MOVE_SEMANTICS // Use C++11 rvalue references to invoke the move constructor, which may // be more efficient. - new(&_table[new_index]) TableEntry(move(old_map._table[i])); -#else - new(&_table[new_index]) TableEntry(old_map._table[i]); -#endif + new(&_table[new_index]) TableEntry(std::move(old_map._table[i])); exists_array[new_index] = true; ++_num_entries; } diff --git a/panda/src/putil/weakKeyHashMap.h b/panda/src/putil/weakKeyHashMap.h index 3769660fbc..b29a846e96 100644 --- a/panda/src/putil/weakKeyHashMap.h +++ b/panda/src/putil/weakKeyHashMap.h @@ -50,9 +50,7 @@ public: INLINE const Value &get_data(size_t n) const; INLINE Value &modify_data(size_t n); INLINE void set_data(size_t n, const Value &data); -#ifdef USE_MOVE_SEMANTICS INLINE void set_data(size_t n, Value &&data); -#endif void remove_element(size_t n); INLINE size_t get_num_entries() const; @@ -82,11 +80,10 @@ private: INLINE TableEntry(const TableEntry ©) : _key(copy._key), _data(copy._data) {} -#ifdef USE_MOVE_SEMANTICS - INLINE TableEntry(TableEntry &&from) NOEXCEPT : - _key(move(from._key)), - _data(move(from._data)) {} -#endif + INLINE TableEntry(TableEntry &&from) noexcept : + _key(std::move(from._key)), + _data(std::move(from._data)) {} + WCPT(Key) _key; Value _data; }; diff --git a/panda/src/putil/writableParam.h b/panda/src/putil/writableParam.h index 7bd49ebd30..bc0f600696 100644 --- a/panda/src/putil/writableParam.h +++ b/panda/src/putil/writableParam.h @@ -39,7 +39,7 @@ public: private: // The assignment operator cannot be used for this class. - WritableParam &operator = (const WritableParam &other) DELETED_ASSIGN; + WritableParam &operator = (const WritableParam &other) = delete; public: virtual TypeHandle get_type() const { diff --git a/panda/src/recorder/mouseRecorder.h b/panda/src/recorder/mouseRecorder.h index f43150c2b8..7122c12299 100644 --- a/panda/src/recorder/mouseRecorder.h +++ b/panda/src/recorder/mouseRecorder.h @@ -77,9 +77,9 @@ public: virtual void write_datagram(BamWriter *manager, Datagram &dg); virtual void write_recorder(BamWriter *manager, Datagram &dg); - INLINE virtual int get_ref_count() const FINAL { return ReferenceCount::get_ref_count(); }; - INLINE virtual void ref() const FINAL { ReferenceCount::ref(); }; - INLINE virtual bool unref() const FINAL { return ReferenceCount::unref(); }; + INLINE virtual int get_ref_count() const final { return ReferenceCount::get_ref_count(); }; + INLINE virtual void ref() const final { ReferenceCount::ref(); }; + INLINE virtual bool unref() const final { return ReferenceCount::unref(); }; protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); diff --git a/panda/src/recorder/socketStreamRecorder.h b/panda/src/recorder/socketStreamRecorder.h index 3b43f5ffcd..231ac19f28 100644 --- a/panda/src/recorder/socketStreamRecorder.h +++ b/panda/src/recorder/socketStreamRecorder.h @@ -74,9 +74,9 @@ public: static void register_with_read_factory(); virtual void write_recorder(BamWriter *manager, Datagram &dg); - INLINE virtual int get_ref_count() const FINAL { return ReferenceCount::get_ref_count(); }; - INLINE virtual void ref() const FINAL { ReferenceCount::ref(); }; - INLINE virtual bool unref() const FINAL { return ReferenceCount::unref(); }; + INLINE virtual int get_ref_count() const final { return ReferenceCount::get_ref_count(); }; + INLINE virtual void ref() const final { ReferenceCount::ref(); }; + INLINE virtual bool unref() const final { return ReferenceCount::unref(); }; protected: static RecorderBase *make_recorder(const FactoryParams ¶ms); diff --git a/panda/src/text/textAssembler.cxx b/panda/src/text/textAssembler.cxx index 49c507dafd..6abe29d7a0 100644 --- a/panda/src/text/textAssembler.cxx +++ b/panda/src/text/textAssembler.cxx @@ -1222,7 +1222,7 @@ generate_quads(GeomNode *geom_node, const QuadMap &quad_map) { *(idx_ptr++) = i + 3; i += 4; - glyphs.push_back(MOVE(quad._glyph)); + glyphs.push_back(move(quad._glyph)); } } else { // 16-bit index case. @@ -1278,7 +1278,7 @@ generate_quads(GeomNode *geom_node, const QuadMap &quad_map) { *(idx_ptr++) = i + 3; i += 4; - glyphs.push_back(MOVE(quad._glyph)); + glyphs.push_back(move(quad._glyph)); } } } @@ -1796,7 +1796,7 @@ draw_underscore(TextAssembler::PlacedGlyphs &placed_glyphs, // LVecBase4(0), RenderState::make_empty()); GlyphPlacement placement; - placement._glyph = MOVE(glyph); + placement._glyph = move(glyph); placement._xpos = 0; placement._ypos = 0; placement._scale = 1; @@ -2453,7 +2453,7 @@ assign_quad_to(QuadMap &quad_map, const RenderState *state, quad._dimensions += LVecBase4(offset[0], -offset[1], offset[0], -offset[1]); quad._glyph = _glyph; - quad_map[state->compose(_glyph->get_state())].push_back(MOVE(quad)); + quad_map[state->compose(_glyph->get_state())].push_back(move(quad)); } } From 3077316782c6ba9601b21e07a06c0a66273931bb Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 23 May 2018 23:35:27 +0200 Subject: [PATCH 183/247] general: use proper deleted funcs instead of stubs with asserts This gives better compile-time diagnostics and saves on code, while also better communicating intent. --- panda/src/display/displayRegion.I | 16 -------- panda/src/display/displayRegion.cxx | 19 ---------- panda/src/display/displayRegion.h | 11 ++---- panda/src/display/graphicsDevice.cxx | 16 -------- panda/src/display/graphicsDevice.h | 6 +-- panda/src/display/graphicsOutput.cxx | 19 ---------- panda/src/display/graphicsOutput.h | 6 +-- panda/src/express/multifile.cxx | 19 ---------- panda/src/express/multifile.h | 5 +-- panda/src/ffmpeg/ffmpegVirtualFile.cxx | 16 -------- panda/src/ffmpeg/ffmpegVirtualFile.h | 7 ++-- panda/src/gobj/geomVertexArrayData.I | 17 --------- panda/src/gobj/geomVertexArrayData.h | 6 ++- panda/src/grutil/movieTexture.cxx | 11 ------ panda/src/grutil/movieTexture.h | 4 +- .../src/grutil/pipeOcclusionCullTraverser.cxx | 10 ----- panda/src/grutil/pipeOcclusionCullTraverser.h | 2 +- panda/src/pgraph/nodePathComponent.I | 17 --------- panda/src/pgraph/nodePathComponent.h | 6 ++- panda/src/pgraph/pandaNode.cxx | 9 ----- panda/src/pgraph/pandaNode.h | 4 +- panda/src/pgraph/renderAttrib.cxx | 16 -------- panda/src/pgraph/renderAttrib.h | 6 +-- panda/src/pgraph/renderEffect.cxx | 16 -------- panda/src/pgraph/renderEffect.h | 6 +-- panda/src/pgraph/renderEffects.cxx | 16 -------- panda/src/pgraph/renderEffects.h | 7 ++-- panda/src/pgraph/renderState.cxx | 8 ---- panda/src/pgraph/renderState.h | 3 +- panda/src/pgraph/transformState.cxx | 16 -------- panda/src/pgraph/transformState.h | 7 ++-- panda/src/pipeline/conditionVar.I | 38 ------------------- panda/src/pipeline/conditionVar.h | 17 ++++----- panda/src/pipeline/conditionVarDebug.I | 19 ---------- panda/src/pipeline/conditionVarDebug.h | 6 +-- panda/src/pipeline/conditionVarDirect.I | 26 ------------- panda/src/pipeline/conditionVarDirect.h | 8 ++-- panda/src/pipeline/conditionVarFull.I | 29 -------------- panda/src/pipeline/conditionVarFull.h | 9 ++--- panda/src/pipeline/conditionVarFullDebug.I | 19 ---------- panda/src/pipeline/conditionVarFullDebug.h | 6 +-- panda/src/pipeline/conditionVarFullDirect.I | 26 ------------- panda/src/pipeline/conditionVarFullDirect.h | 8 ++-- panda/src/pipeline/cyclerHolder.I | 16 -------- panda/src/pipeline/cyclerHolder.h | 6 +-- panda/src/pipeline/lightMutex.h | 2 +- panda/src/pipeline/lightMutexHolder.I | 16 -------- panda/src/pipeline/lightMutexHolder.h | 6 +-- panda/src/pipeline/lightReMutex.I | 15 -------- panda/src/pipeline/lightReMutex.h | 8 ++-- panda/src/pipeline/lightReMutexHolder.I | 16 -------- panda/src/pipeline/lightReMutexHolder.h | 6 +-- panda/src/pipeline/mutexHolder.I | 16 -------- panda/src/pipeline/mutexHolder.h | 6 +-- .../src/pipeline/pipelineCyclerTrivialImpl.I | 29 -------------- .../src/pipeline/pipelineCyclerTrivialImpl.h | 9 ++--- panda/src/pipeline/psemaphore.I | 25 ------------ panda/src/pipeline/psemaphore.h | 8 ++-- panda/src/pipeline/reMutexHolder.I | 16 -------- panda/src/pipeline/reMutexHolder.h | 6 +-- panda/src/pipeline/thread.I | 16 -------- panda/src/pipeline/thread.h | 7 ++-- panda/src/speedtree/stTree.cxx | 9 ----- panda/src/speedtree/stTree.h | 3 +- panda/src/text/dynamicTextGlyph.I | 19 ---------- panda/src/text/dynamicTextGlyph.h | 6 +-- panda/src/vision/openCVTexture.cxx | 12 ------ panda/src/vision/openCVTexture.h | 4 +- 68 files changed, 101 insertions(+), 719 deletions(-) diff --git a/panda/src/display/displayRegion.I b/panda/src/display/displayRegion.I index e402e0ad7b..a1f55f5e7f 100644 --- a/panda/src/display/displayRegion.I +++ b/panda/src/display/displayRegion.I @@ -567,22 +567,6 @@ DisplayRegionPipelineReader(DisplayRegion *object, Thread *current_thread) : #endif // _DEBUG } -/** - * Don't attempt to copy these objects. - */ -INLINE DisplayRegionPipelineReader:: -DisplayRegionPipelineReader(const DisplayRegionPipelineReader &) { - nassertv(false); -} - -/** - * Don't attempt to copy these objects. - */ -INLINE void DisplayRegionPipelineReader:: -operator = (const DisplayRegionPipelineReader &) { - nassertv(false); -} - /** * */ diff --git a/panda/src/display/displayRegion.cxx b/panda/src/display/displayRegion.cxx index 99aea51477..a84a8728e8 100644 --- a/panda/src/display/displayRegion.cxx +++ b/panda/src/display/displayRegion.cxx @@ -46,25 +46,6 @@ DisplayRegion(GraphicsOutput *window, const LVecBase4 &dimensions) : _window->add_display_region(this); } -/** - * - */ -DisplayRegion:: -DisplayRegion(const DisplayRegion ©) : - _window(NULL), - _cull_region_pcollector("Cull:Invalid"), - _draw_region_pcollector("Draw:Invalid") -{ -} - -/** - * - */ -void DisplayRegion:: -operator = (const DisplayRegion&) { - nassertv(false); -} - /** * */ diff --git a/panda/src/display/displayRegion.h b/panda/src/display/displayRegion.h index 091f17e13f..7599f17c9d 100644 --- a/panda/src/display/displayRegion.h +++ b/panda/src/display/displayRegion.h @@ -57,10 +57,8 @@ class CullTraverser; class EXPCL_PANDA_DISPLAY DisplayRegion : public TypedReferenceCount, public DrawableRegion { protected: DisplayRegion(GraphicsOutput *window, const LVecBase4 &dimensions); - -private: - DisplayRegion(const DisplayRegion ©); - void operator = (const DisplayRegion ©); + DisplayRegion(const DisplayRegion ©) = delete; + void operator = (const DisplayRegion ©) = delete; public: virtual ~DisplayRegion(); @@ -310,9 +308,8 @@ private: class EXPCL_PANDA_DISPLAY DisplayRegionPipelineReader { public: INLINE DisplayRegionPipelineReader(DisplayRegion *object, Thread *current_thread); -private: - INLINE DisplayRegionPipelineReader(const DisplayRegionPipelineReader ©); - INLINE void operator = (const DisplayRegionPipelineReader ©); + DisplayRegionPipelineReader(const DisplayRegionPipelineReader ©) = delete; + void operator = (const DisplayRegionPipelineReader ©) = delete; public: INLINE ~DisplayRegionPipelineReader(); diff --git a/panda/src/display/graphicsDevice.cxx b/panda/src/display/graphicsDevice.cxx index fb74bca7d8..665e12534e 100644 --- a/panda/src/display/graphicsDevice.cxx +++ b/panda/src/display/graphicsDevice.cxx @@ -34,22 +34,6 @@ GraphicsDevice(GraphicsPipe *pipe) { } } -/** - * - */ -GraphicsDevice:: -GraphicsDevice(const GraphicsDevice &) { - nassertv(false); -} - -/** - * - */ -void GraphicsDevice:: -operator = (const GraphicsDevice &) { - nassertv(false); -} - /** * */ diff --git a/panda/src/display/graphicsDevice.h b/panda/src/display/graphicsDevice.h index afb1edb697..532024642a 100644 --- a/panda/src/display/graphicsDevice.h +++ b/panda/src/display/graphicsDevice.h @@ -30,10 +30,8 @@ class GraphicsPipe; class EXPCL_PANDA_DISPLAY GraphicsDevice : public TypedReferenceCount { public: GraphicsDevice(GraphicsPipe *pipe); - -private: - GraphicsDevice(const GraphicsDevice ©); - void operator = (const GraphicsDevice ©); + GraphicsDevice(const GraphicsDevice ©) = delete; + GraphicsDevice &operator = (const GraphicsDevice ©) = delete; PUBLISHED: virtual ~GraphicsDevice(); diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index 4d8a1e27a1..cb2f69ff6c 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -159,25 +159,6 @@ GraphicsOutput(GraphicsEngine *engine, GraphicsPipe *pipe, set_clear_color(background_color.get_value()); } -/** - * - */ -GraphicsOutput:: -GraphicsOutput(const GraphicsOutput &) : - _cull_window_pcollector(_cull_pcollector, "Invalid"), - _draw_window_pcollector(_draw_pcollector, "Invalid") -{ - nassertv(false); -} - -/** - * - */ -void GraphicsOutput:: -operator = (const GraphicsOutput &) { - nassertv(false); -} - /** * */ diff --git a/panda/src/display/graphicsOutput.h b/panda/src/display/graphicsOutput.h index 2f9eff8683..93db287a74 100644 --- a/panda/src/display/graphicsOutput.h +++ b/panda/src/display/graphicsOutput.h @@ -70,10 +70,8 @@ protected: GraphicsStateGuardian *gsg, GraphicsOutput *host, bool default_stereo_flags); - -private: - GraphicsOutput(const GraphicsOutput ©); - void operator = (const GraphicsOutput ©); + GraphicsOutput(const GraphicsOutput ©) = delete; + GraphicsOutput &operator = (const GraphicsOutput ©) = delete; PUBLISHED: enum RenderTextureMode { diff --git a/panda/src/express/multifile.cxx b/panda/src/express/multifile.cxx index 5a7d86f17b..0bedba8909 100644 --- a/panda/src/express/multifile.cxx +++ b/panda/src/express/multifile.cxx @@ -136,25 +136,6 @@ Multifile:: close(); } -/** - * Don't try to copy Multifiles. - */ -Multifile:: -Multifile(const Multifile ©) : - _read_filew(_read_file), - _read_write_filew(_read_write_file) -{ - nassertv(false); -} - -/** - * Don't try to copy Multifiles. - */ -void Multifile:: -operator = (const Multifile ©) { - nassertv(false); -} - /** * Opens the named Multifile on disk for reading. The Multifile index is read * in, and the list of subfiles becomes available; individual subfiles may diff --git a/panda/src/express/multifile.h b/panda/src/express/multifile.h index d9f7217dfd..ad0296055c 100644 --- a/panda/src/express/multifile.h +++ b/panda/src/express/multifile.h @@ -37,11 +37,10 @@ typedef struct evp_pkey_st EVP_PKEY; class EXPCL_PANDAEXPRESS Multifile : public ReferenceCount { PUBLISHED: Multifile(); + Multifile(const Multifile ©) = delete; ~Multifile(); -private: - Multifile(const Multifile ©); - void operator = (const Multifile ©); + Multifile &operator = (const Multifile ©) = delete; PUBLISHED: BLOCKING bool open_read(const Filename &multifile_name, const streampos &offset = 0); diff --git a/panda/src/ffmpeg/ffmpegVirtualFile.cxx b/panda/src/ffmpeg/ffmpegVirtualFile.cxx index 8819db74bc..0d97f0b5f4 100644 --- a/panda/src/ffmpeg/ffmpegVirtualFile.cxx +++ b/panda/src/ffmpeg/ffmpegVirtualFile.cxx @@ -47,22 +47,6 @@ FfmpegVirtualFile:: close(); } -/** - * These objects are not meant to be copied. - */ -FfmpegVirtualFile:: -FfmpegVirtualFile(const FfmpegVirtualFile ©) { - nassertv(false); -} - -/** - * These objects are not meant to be copied. - */ -void FfmpegVirtualFile:: -operator = (const FfmpegVirtualFile ©) { - nassertv(false); -} - /** * Opens the movie file via Panda's VFS. Returns true on success, false on * failure. If successful, use get_format_context() to get the open file diff --git a/panda/src/ffmpeg/ffmpegVirtualFile.h b/panda/src/ffmpeg/ffmpegVirtualFile.h index 746fec67a0..197320d4dc 100644 --- a/panda/src/ffmpeg/ffmpegVirtualFile.h +++ b/panda/src/ffmpeg/ffmpegVirtualFile.h @@ -34,12 +34,11 @@ struct AVFormatContext; class EXPCL_FFMPEG FfmpegVirtualFile { public: FfmpegVirtualFile(); + FfmpegVirtualFile(const FfmpegVirtualFile ©) = delete; ~FfmpegVirtualFile(); -private: - FfmpegVirtualFile(const FfmpegVirtualFile ©); - void operator = (const FfmpegVirtualFile ©); -public: + FfmpegVirtualFile &operator = (const FfmpegVirtualFile ©) = delete; + bool open_vfs(const Filename &filename); bool open_subfile(const SubfileInfo &info); void close(); diff --git a/panda/src/gobj/geomVertexArrayData.I b/panda/src/gobj/geomVertexArrayData.I index 97811498a4..a9005fde12 100644 --- a/panda/src/gobj/geomVertexArrayData.I +++ b/panda/src/gobj/geomVertexArrayData.I @@ -371,23 +371,6 @@ GeomVertexArrayDataHandle(GeomVertexArrayData *object, #endif } -/** - * Don't attempt to copy these objects. - */ -INLINE GeomVertexArrayDataHandle:: -GeomVertexArrayDataHandle(const GeomVertexArrayDataHandle ©) - : _current_thread(copy._current_thread) { - nassertv(false); -} - -/** - * Don't attempt to copy these objects. - */ -INLINE void GeomVertexArrayDataHandle:: -operator = (const GeomVertexArrayDataHandle &) { - nassertv(false); -} - /** * */ diff --git a/panda/src/gobj/geomVertexArrayData.h b/panda/src/gobj/geomVertexArrayData.h index 7047358adc..264c9a1971 100644 --- a/panda/src/gobj/geomVertexArrayData.h +++ b/panda/src/gobj/geomVertexArrayData.h @@ -257,15 +257,17 @@ private: Thread *current_thread); INLINE GeomVertexArrayDataHandle(GeomVertexArrayData *object, Thread *current_thread); - INLINE GeomVertexArrayDataHandle(const GeomVertexArrayDataHandle &); - INLINE void operator = (const GeomVertexArrayDataHandle &); PUBLISHED: INLINE ~GeomVertexArrayDataHandle(); public: + GeomVertexArrayDataHandle(const GeomVertexArrayDataHandle &) = delete; + ALLOC_DELETED_CHAIN_DECL(GeomVertexArrayDataHandle); + GeomVertexArrayDataHandle &operator = (const GeomVertexArrayDataHandle &) = delete; + INLINE Thread *get_current_thread() const; INLINE const unsigned char *get_read_pointer(bool force) const RETURNS_ALIGNED(MEMORY_HOOK_ALIGNMENT); diff --git a/panda/src/grutil/movieTexture.cxx b/panda/src/grutil/movieTexture.cxx index a2d8d3bc3a..8f2850380b 100644 --- a/panda/src/grutil/movieTexture.cxx +++ b/panda/src/grutil/movieTexture.cxx @@ -92,17 +92,6 @@ make_copy() const { return new CData(*this); } -/** - * Use MovieTexture::make_copy() to make a duplicate copy of an existing - * MovieTexture. - */ -MovieTexture:: -MovieTexture(const MovieTexture ©) : - Texture(copy) -{ - nassertv(false); -} - /** * xxx */ diff --git a/panda/src/grutil/movieTexture.h b/panda/src/grutil/movieTexture.h index d719f21d87..0881552036 100644 --- a/panda/src/grutil/movieTexture.h +++ b/panda/src/grutil/movieTexture.h @@ -34,9 +34,7 @@ class EXPCL_PANDA_GRUTIL MovieTexture : public Texture { PUBLISHED: explicit MovieTexture(const string &name); explicit MovieTexture(MovieVideo *video); -private: - MovieTexture(const MovieTexture ©); -PUBLISHED: + MovieTexture(const MovieTexture ©) = delete; virtual ~MovieTexture(); INLINE double get_video_length() const; diff --git a/panda/src/grutil/pipeOcclusionCullTraverser.cxx b/panda/src/grutil/pipeOcclusionCullTraverser.cxx index 1052d5ace5..d257611767 100644 --- a/panda/src/grutil/pipeOcclusionCullTraverser.cxx +++ b/panda/src/grutil/pipeOcclusionCullTraverser.cxx @@ -119,16 +119,6 @@ PipeOcclusionCullTraverser(GraphicsOutput *host) { _live = true; } -/** - * - */ -PipeOcclusionCullTraverser:: -PipeOcclusionCullTraverser(const PipeOcclusionCullTraverser ©) : - CullTraverser(copy) -{ - nassertv(false); -} - /** * */ diff --git a/panda/src/grutil/pipeOcclusionCullTraverser.h b/panda/src/grutil/pipeOcclusionCullTraverser.h index 55d2a795ce..d41c5acff4 100644 --- a/panda/src/grutil/pipeOcclusionCullTraverser.h +++ b/panda/src/grutil/pipeOcclusionCullTraverser.h @@ -42,7 +42,7 @@ class EXPCL_PANDA_GRUTIL PipeOcclusionCullTraverser : public CullTraverser, public CullHandler { PUBLISHED: explicit PipeOcclusionCullTraverser(GraphicsOutput *host); - PipeOcclusionCullTraverser(const PipeOcclusionCullTraverser ©); + PipeOcclusionCullTraverser(const PipeOcclusionCullTraverser ©) = delete; virtual void set_scene(SceneSetup *scene_setup, GraphicsStateGuardianBase *gsg, diff --git a/panda/src/pgraph/nodePathComponent.I b/panda/src/pgraph/nodePathComponent.I index d3abe36c07..b54d4cfc7d 100644 --- a/panda/src/pgraph/nodePathComponent.I +++ b/panda/src/pgraph/nodePathComponent.I @@ -29,23 +29,6 @@ CData(const NodePathComponent::CData ©) : { } -/** - * NodePathComponents should not be copied. - */ -INLINE NodePathComponent:: -NodePathComponent(const NodePathComponent ©) { - nassertv(false); -} - -/** - * NodePathComponents should not be copied. - */ -INLINE void NodePathComponent:: -operator = (const NodePathComponent ©) { - nassertv(false); -} - - /** * */ diff --git a/panda/src/pgraph/nodePathComponent.h b/panda/src/pgraph/nodePathComponent.h index 3752d7e834..b6957ffd9a 100644 --- a/panda/src/pgraph/nodePathComponent.h +++ b/panda/src/pgraph/nodePathComponent.h @@ -43,13 +43,15 @@ class EXPCL_PANDA_PGRAPH NodePathComponent final : public ReferenceCount { private: NodePathComponent(PandaNode *node, NodePathComponent *next, int pipeline_stage, Thread *current_thread); - INLINE NodePathComponent(const NodePathComponent ©); - INLINE void operator = (const NodePathComponent ©); public: + NodePathComponent(const NodePathComponent ©) = delete; INLINE ~NodePathComponent(); + ALLOC_DELETED_CHAIN(NodePathComponent); + NodePathComponent &operator = (const NodePathComponent ©) = delete; + INLINE PandaNode *get_node() const; INLINE bool has_key() const; int get_key() const; diff --git a/panda/src/pgraph/pandaNode.cxx b/panda/src/pgraph/pandaNode.cxx index 96b94dd0c2..91afd2f768 100644 --- a/panda/src/pgraph/pandaNode.cxx +++ b/panda/src/pgraph/pandaNode.cxx @@ -175,15 +175,6 @@ PandaNode(const PandaNode ©) : } } -/** - * Do not call the copy assignment operator at all. Use make_copy() or - * copy_subgraph() to make a copy of a node. - */ -void PandaNode:: -operator = (const PandaNode ©) { - nassertv(false); -} - /** * This is similar to make_copy(), but it makes a copy for the specific * purpose of flatten. Typically, this will be a new PandaNode with a new diff --git a/panda/src/pgraph/pandaNode.h b/panda/src/pgraph/pandaNode.h index 74d362113e..f5cc0fee78 100644 --- a/panda/src/pgraph/pandaNode.h +++ b/panda/src/pgraph/pandaNode.h @@ -71,8 +71,8 @@ PUBLISHED: protected: PandaNode(const PandaNode ©); -private: - void operator = (const PandaNode ©); + + PandaNode &operator = (const PandaNode ©) = delete; public: virtual PandaNode *dupe_for_flatten() const; diff --git a/panda/src/pgraph/renderAttrib.cxx b/panda/src/pgraph/renderAttrib.cxx index 385d7ee740..45f8ea2fb9 100644 --- a/panda/src/pgraph/renderAttrib.cxx +++ b/panda/src/pgraph/renderAttrib.cxx @@ -37,22 +37,6 @@ RenderAttrib() { _saved_entry = -1; } -/** - * RenderAttribs are not meant to be copied. - */ -RenderAttrib:: -RenderAttrib(const RenderAttrib &) { - nassertv(false); -} - -/** - * RenderAttribs are not meant to be copied. - */ -void RenderAttrib:: -operator = (const RenderAttrib &) { - nassertv(false); -} - /** * The destructor is responsible for removing the RenderAttrib from the global * set if it is there. diff --git a/panda/src/pgraph/renderAttrib.h b/panda/src/pgraph/renderAttrib.h index fe364d8ea4..b506d64841 100644 --- a/panda/src/pgraph/renderAttrib.h +++ b/panda/src/pgraph/renderAttrib.h @@ -51,13 +51,13 @@ class RenderState; class EXPCL_PANDA_PGRAPH RenderAttrib : public TypedWritableReferenceCount { protected: RenderAttrib(); -private: - RenderAttrib(const RenderAttrib ©); - void operator = (const RenderAttrib ©); public: + RenderAttrib(const RenderAttrib ©) = delete; virtual ~RenderAttrib(); + RenderAttrib &operator = (const RenderAttrib ©) = delete; + PUBLISHED: INLINE CPT(RenderAttrib) compose(const RenderAttrib *other) const; INLINE CPT(RenderAttrib) invert_compose(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/renderEffect.cxx b/panda/src/pgraph/renderEffect.cxx index 09572cc445..585db7db26 100644 --- a/panda/src/pgraph/renderEffect.cxx +++ b/panda/src/pgraph/renderEffect.cxx @@ -35,22 +35,6 @@ RenderEffect() { _saved_entry = _effects->end(); } -/** - * RenderEffects are not meant to be copied. - */ -RenderEffect:: -RenderEffect(const RenderEffect &) { - nassertv(false); -} - -/** - * RenderEffects are not meant to be copied. - */ -void RenderEffect:: -operator = (const RenderEffect &) { - nassertv(false); -} - /** * The destructor is responsible for removing the RenderEffect from the global * set if it is there. diff --git a/panda/src/pgraph/renderEffect.h b/panda/src/pgraph/renderEffect.h index d739f5cee7..65a9942fa7 100644 --- a/panda/src/pgraph/renderEffect.h +++ b/panda/src/pgraph/renderEffect.h @@ -48,13 +48,13 @@ class PandaNode; class EXPCL_PANDA_PGRAPH RenderEffect : public TypedWritableReferenceCount { protected: RenderEffect(); -private: - RenderEffect(const RenderEffect ©); - void operator = (const RenderEffect ©); public: + RenderEffect(const RenderEffect ©) = delete; virtual ~RenderEffect(); + RenderEffect &operator = (const RenderEffect ©) = delete; + virtual bool safe_to_transform() const; virtual CPT(TransformState) prepare_flatten_transform(const TransformState *net_transform) const; virtual bool safe_to_combine() const; diff --git a/panda/src/pgraph/renderEffects.cxx b/panda/src/pgraph/renderEffects.cxx index 639f11be9b..aaa81773ce 100644 --- a/panda/src/pgraph/renderEffects.cxx +++ b/panda/src/pgraph/renderEffects.cxx @@ -48,22 +48,6 @@ RenderEffects() : _lock("RenderEffects") { _flags = 0; } -/** - * RenderEffects are not meant to be copied. - */ -RenderEffects:: -RenderEffects(const RenderEffects &) { - nassertv(false); -} - -/** - * RenderEffects are not meant to be copied. - */ -void RenderEffects:: -operator = (const RenderEffects &) { - nassertv(false); -} - /** * The destructor is responsible for removing the RenderEffects from the * global set if it is there. diff --git a/panda/src/pgraph/renderEffects.h b/panda/src/pgraph/renderEffects.h index 1e54c30533..7a8f18aed3 100644 --- a/panda/src/pgraph/renderEffects.h +++ b/panda/src/pgraph/renderEffects.h @@ -42,13 +42,12 @@ class EXPCL_PANDA_PGRAPH RenderEffects : public TypedWritableReferenceCount { protected: RenderEffects(); -private: - RenderEffects(const RenderEffects ©); - void operator = (const RenderEffects ©); - public: + RenderEffects(const RenderEffects ©) = delete; virtual ~RenderEffects(); + RenderEffects &operator = (const RenderEffects ©) = delete; + bool safe_to_transform() const; virtual CPT(TransformState) prepare_flatten_transform(const TransformState *net_transform) const; bool safe_to_combine() const; diff --git a/panda/src/pgraph/renderState.cxx b/panda/src/pgraph/renderState.cxx index 6f035a6557..a4d2952e50 100644 --- a/panda/src/pgraph/renderState.cxx +++ b/panda/src/pgraph/renderState.cxx @@ -105,14 +105,6 @@ RenderState(const RenderState ©) : #endif } -/** - * RenderStates are not meant to be copied. - */ -void RenderState:: -operator = (const RenderState &) { - nassertv(false); -} - /** * The destructor is responsible for removing the RenderState from the global * set if it is there. diff --git a/panda/src/pgraph/renderState.h b/panda/src/pgraph/renderState.h index 1052687314..433582fd2c 100644 --- a/panda/src/pgraph/renderState.h +++ b/panda/src/pgraph/renderState.h @@ -50,12 +50,13 @@ protected: private: RenderState(const RenderState ©); - void operator = (const RenderState ©); public: virtual ~RenderState(); ALLOC_DELETED_CHAIN(RenderState); + RenderState &operator = (const RenderState ©) = delete; + typedef RenderAttribRegistry::SlotMask SlotMask; PUBLISHED: diff --git a/panda/src/pgraph/transformState.cxx b/panda/src/pgraph/transformState.cxx index bff497298e..c66bd3a281 100644 --- a/panda/src/pgraph/transformState.cxx +++ b/panda/src/pgraph/transformState.cxx @@ -68,22 +68,6 @@ TransformState() : _lock("TransformState") { #endif } -/** - * TransformStates are not meant to be copied. - */ -TransformState:: -TransformState(const TransformState &) { - nassertv(false); -} - -/** - * TransformStates are not meant to be copied. - */ -void TransformState:: -operator = (const TransformState &) { - nassertv(false); -} - /** * The destructor is responsible for removing the TransformState from the * global set if it is there. diff --git a/panda/src/pgraph/transformState.h b/panda/src/pgraph/transformState.h index 2313ea136f..5edd8985d6 100644 --- a/panda/src/pgraph/transformState.h +++ b/panda/src/pgraph/transformState.h @@ -55,14 +55,13 @@ class EXPCL_PANDA_PGRAPH TransformState final : public NodeCachedReferenceCount protected: TransformState(); -private: - TransformState(const TransformState ©); - void operator = (const TransformState ©); - public: + TransformState(const TransformState ©) = delete; virtual ~TransformState(); ALLOC_DELETED_CHAIN(TransformState); + TransformState &operator = (const TransformState ©) = delete; + PUBLISHED: INLINE bool operator != (const TransformState &other) const; INLINE int compare_to(const TransformState &other) const; diff --git a/panda/src/pipeline/conditionVar.I b/panda/src/pipeline/conditionVar.I index d797ab2390..196e4283d0 100644 --- a/panda/src/pipeline/conditionVar.I +++ b/panda/src/pipeline/conditionVar.I @@ -27,44 +27,6 @@ ConditionVar(Mutex &mutex) : { } -/** - * - */ -INLINE ConditionVar:: -~ConditionVar() { -} - -/** - * Do not attempt to copy condition variables. - */ -INLINE ConditionVar:: -ConditionVar(const ConditionVar ©) : -#ifdef DEBUG_THREADS - ConditionVarDebug(copy.get_mutex()) -#else - ConditionVarDirect(copy.get_mutex()) -#endif // DEBUG_THREADS -{ - nassertv(false); -} - -/** - * Do not attempt to copy condition variables. - */ -INLINE void ConditionVar:: -operator = (const ConditionVar ©) { - nassertv(false); -} - -/** - * The notify_all() method is specifically *not* provided by ConditionVar. - * Use ConditionVarFull if you need to call this method. - */ -INLINE void ConditionVar:: -notify_all() { - nassertv(false); -} - /** * Returns the mutex associated with this condition variable. */ diff --git a/panda/src/pipeline/conditionVar.h b/panda/src/pipeline/conditionVar.h index 3c94e03a34..fe90e22063 100644 --- a/panda/src/pipeline/conditionVar.h +++ b/panda/src/pipeline/conditionVar.h @@ -43,20 +43,19 @@ class EXPCL_PANDA_PIPELINE ConditionVar : public ConditionVarDirect { PUBLISHED: INLINE explicit ConditionVar(Mutex &mutex); - INLINE ~ConditionVar(); -private: - INLINE ConditionVar(const ConditionVar ©); - INLINE void operator = (const ConditionVar ©); + ConditionVar(const ConditionVar ©) = delete; + ~ConditionVar() = default; - // These methods are inherited from the base class. INLINE void wait(); - // INLINE void notify(); + ConditionVar &operator = (const ConditionVar ©) = delete; + + // These methods are inherited from the base class. + //INLINE void wait(); + //INLINE void notify(); -private: // The notify_all() method is specifically *not* provided by ConditionVar. // Use ConditionVarFull if you need to call this method. - INLINE void notify_all(); + void notify_all() = delete; -PUBLISHED: INLINE Mutex &get_mutex() const; }; diff --git a/panda/src/pipeline/conditionVarDebug.I b/panda/src/pipeline/conditionVarDebug.I index 6b16125a0e..f7804b22b2 100644 --- a/panda/src/pipeline/conditionVarDebug.I +++ b/panda/src/pipeline/conditionVarDebug.I @@ -11,25 +11,6 @@ * @date 2006-02-13 */ -/** - * Do not attempt to copy condition variables. - */ -INLINE ConditionVarDebug:: -ConditionVarDebug(const ConditionVarDebug ©) : - _mutex(copy._mutex), - _impl(*_mutex._global_lock) -{ - nassertv(false); -} - -/** - * Do not attempt to copy condition variables. - */ -INLINE void ConditionVarDebug:: -operator = (const ConditionVarDebug ©) { - nassertv(false); -} - /** * Returns the mutex associated with this condition variable. */ diff --git a/panda/src/pipeline/conditionVarDebug.h b/panda/src/pipeline/conditionVarDebug.h index 7cbacbaf0d..b8243438c9 100644 --- a/panda/src/pipeline/conditionVarDebug.h +++ b/panda/src/pipeline/conditionVarDebug.h @@ -32,10 +32,10 @@ class EXPCL_PANDA_PIPELINE ConditionVarDebug { public: explicit ConditionVarDebug(MutexDebug &mutex); + ConditionVarDebug(const ConditionVarDebug ©) = delete; virtual ~ConditionVarDebug(); -private: - INLINE ConditionVarDebug(const ConditionVarDebug ©); - INLINE void operator = (const ConditionVarDebug ©); + + ConditionVarDebug &operator = (const ConditionVarDebug ©) = delete; PUBLISHED: INLINE MutexDebug &get_mutex() const; diff --git a/panda/src/pipeline/conditionVarDirect.I b/panda/src/pipeline/conditionVarDirect.I index 6b9d0351bf..bf8e42aea5 100644 --- a/panda/src/pipeline/conditionVarDirect.I +++ b/panda/src/pipeline/conditionVarDirect.I @@ -24,32 +24,6 @@ ConditionVarDirect(MutexDirect &mutex) : { } -/** - * - */ -INLINE ConditionVarDirect:: -~ConditionVarDirect() { -} - -/** - * Do not attempt to copy condition variables. - */ -INLINE ConditionVarDirect:: -ConditionVarDirect(const ConditionVarDirect ©) : - _mutex(copy._mutex), - _impl(_mutex._impl) -{ - nassertv(false); -} - -/** - * Do not attempt to copy condition variables. - */ -INLINE void ConditionVarDirect:: -operator = (const ConditionVarDirect ©) { - nassertv(false); -} - /** * Returns the mutex associated with this condition variable. */ diff --git a/panda/src/pipeline/conditionVarDirect.h b/panda/src/pipeline/conditionVarDirect.h index 116f22b899..7315c0b0bb 100644 --- a/panda/src/pipeline/conditionVarDirect.h +++ b/panda/src/pipeline/conditionVarDirect.h @@ -32,10 +32,10 @@ class EXPCL_PANDA_PIPELINE ConditionVarDirect { public: INLINE explicit ConditionVarDirect(MutexDirect &mutex); - INLINE ~ConditionVarDirect(); -private: - INLINE ConditionVarDirect(const ConditionVarDirect ©); - INLINE void operator = (const ConditionVarDirect ©); + ConditionVarDirect(const ConditionVarDirect ©) = delete; + ~ConditionVarDirect() = default; + + ConditionVarDirect &operator = (const ConditionVarDirect ©) = delete; PUBLISHED: INLINE MutexDirect &get_mutex() const; diff --git a/panda/src/pipeline/conditionVarFull.I b/panda/src/pipeline/conditionVarFull.I index 21b93b5ec6..b796e7aed2 100644 --- a/panda/src/pipeline/conditionVarFull.I +++ b/panda/src/pipeline/conditionVarFull.I @@ -27,35 +27,6 @@ ConditionVarFull(Mutex &mutex) : { } -/** - * - */ -INLINE ConditionVarFull:: -~ConditionVarFull() { -} - -/** - * Do not attempt to copy condition variables. - */ -INLINE ConditionVarFull:: -ConditionVarFull(const ConditionVarFull ©) : -#ifdef DEBUG_THREADS - ConditionVarFullDebug(copy.get_mutex()) -#else - ConditionVarFullDirect(copy.get_mutex()) -#endif // DEBUG_THREADS -{ - nassertv(false); -} - -/** - * Do not attempt to copy condition variables. - */ -INLINE void ConditionVarFull:: -operator = (const ConditionVarFull ©) { - nassertv(false); -} - /** * Returns the mutex associated with this condition variable. */ diff --git a/panda/src/pipeline/conditionVarFull.h b/panda/src/pipeline/conditionVarFull.h index 5f8b7ea731..37a9af1e11 100644 --- a/panda/src/pipeline/conditionVarFull.h +++ b/panda/src/pipeline/conditionVarFull.h @@ -46,12 +46,11 @@ class EXPCL_PANDA_PIPELINE ConditionVarFull : public ConditionVarFullDirect { PUBLISHED: INLINE explicit ConditionVarFull(Mutex &mutex); - INLINE ~ConditionVarFull(); -private: - INLINE ConditionVarFull(const ConditionVarFull ©); - INLINE void operator = (const ConditionVarFull ©); + ConditionVarFull(const ConditionVarFull ©) = delete; + ~ConditionVarFull() = default; + + ConditionVarFull &operator = (const ConditionVarFull ©) = delete; -PUBLISHED: INLINE Mutex &get_mutex() const; }; diff --git a/panda/src/pipeline/conditionVarFullDebug.I b/panda/src/pipeline/conditionVarFullDebug.I index bbf60f603d..5a09f03a3d 100644 --- a/panda/src/pipeline/conditionVarFullDebug.I +++ b/panda/src/pipeline/conditionVarFullDebug.I @@ -11,25 +11,6 @@ * @date 2006-08-28 */ -/** - * Do not attempt to copy condition variables. - */ -INLINE ConditionVarFullDebug:: -ConditionVarFullDebug(const ConditionVarFullDebug ©) : - _mutex(copy._mutex), - _impl(*_mutex._global_lock) -{ - nassertv(false); -} - -/** - * Do not attempt to copy condition variables. - */ -INLINE void ConditionVarFullDebug:: -operator = (const ConditionVarFullDebug ©) { - nassertv(false); -} - /** * Returns the mutex associated with this condition variable. */ diff --git a/panda/src/pipeline/conditionVarFullDebug.h b/panda/src/pipeline/conditionVarFullDebug.h index 02c5957f72..696a57e2cf 100644 --- a/panda/src/pipeline/conditionVarFullDebug.h +++ b/panda/src/pipeline/conditionVarFullDebug.h @@ -32,10 +32,10 @@ class EXPCL_PANDA_PIPELINE ConditionVarFullDebug { public: explicit ConditionVarFullDebug(MutexDebug &mutex); + ConditionVarFullDebug(const ConditionVarFullDebug ©) = delete; virtual ~ConditionVarFullDebug(); -private: - INLINE ConditionVarFullDebug(const ConditionVarFullDebug ©); - INLINE void operator = (const ConditionVarFullDebug ©); + + ConditionVarFullDebug &operator = (const ConditionVarFullDebug ©) = delete; PUBLISHED: INLINE MutexDebug &get_mutex() const; diff --git a/panda/src/pipeline/conditionVarFullDirect.I b/panda/src/pipeline/conditionVarFullDirect.I index fa0da2b3c6..207cb01538 100644 --- a/panda/src/pipeline/conditionVarFullDirect.I +++ b/panda/src/pipeline/conditionVarFullDirect.I @@ -24,32 +24,6 @@ ConditionVarFullDirect(MutexDirect &mutex) : { } -/** - * - */ -INLINE ConditionVarFullDirect:: -~ConditionVarFullDirect() { -} - -/** - * Do not attempt to copy condition variables. - */ -INLINE ConditionVarFullDirect:: -ConditionVarFullDirect(const ConditionVarFullDirect ©) : - _mutex(copy._mutex), - _impl(_mutex._impl) -{ - nassertv(false); -} - -/** - * Do not attempt to copy condition variables. - */ -INLINE void ConditionVarFullDirect:: -operator = (const ConditionVarFullDirect ©) { - nassertv(false); -} - /** * Returns the mutex associated with this condition variable. */ diff --git a/panda/src/pipeline/conditionVarFullDirect.h b/panda/src/pipeline/conditionVarFullDirect.h index 45cd0ac3f4..e2db984ab9 100644 --- a/panda/src/pipeline/conditionVarFullDirect.h +++ b/panda/src/pipeline/conditionVarFullDirect.h @@ -32,10 +32,10 @@ class EXPCL_PANDA_PIPELINE ConditionVarFullDirect { public: INLINE explicit ConditionVarFullDirect(MutexDirect &mutex); - INLINE ~ConditionVarFullDirect(); -private: - INLINE ConditionVarFullDirect(const ConditionVarFullDirect ©); - INLINE void operator = (const ConditionVarFullDirect ©); + ConditionVarFullDirect(const ConditionVarFullDirect ©) = delete; + ~ConditionVarFullDirect() = default; + + ConditionVarFullDirect &operator = (const ConditionVarFullDirect ©) = delete; PUBLISHED: INLINE MutexDirect &get_mutex() const; diff --git a/panda/src/pipeline/cyclerHolder.I b/panda/src/pipeline/cyclerHolder.I index d9d2782373..f30ca75751 100644 --- a/panda/src/pipeline/cyclerHolder.I +++ b/panda/src/pipeline/cyclerHolder.I @@ -31,19 +31,3 @@ INLINE CyclerHolder:: _cycler->release(); #endif } - -/** - * Do not attempt to copy CyclerHolders. - */ -INLINE CyclerHolder:: -CyclerHolder(const CyclerHolder ©) { - nassertv(false); -} - -/** - * Do not attempt to copy CyclerHolders. - */ -INLINE void CyclerHolder:: -operator = (const CyclerHolder ©) { - nassertv(false); -} diff --git a/panda/src/pipeline/cyclerHolder.h b/panda/src/pipeline/cyclerHolder.h index fa5b81a30f..f1888345be 100644 --- a/panda/src/pipeline/cyclerHolder.h +++ b/panda/src/pipeline/cyclerHolder.h @@ -25,10 +25,10 @@ class EXPCL_PANDA_PIPELINE CyclerHolder { public: INLINE CyclerHolder(PipelineCyclerBase &cycler); + CyclerHolder(const CyclerHolder ©) = delete; INLINE ~CyclerHolder(); -private: - INLINE CyclerHolder(const CyclerHolder ©); - INLINE void operator = (const CyclerHolder ©); + + CyclerHolder &operator = (const CyclerHolder ©) = delete; private: #ifdef DO_PIPELINING diff --git a/panda/src/pipeline/lightMutex.h b/panda/src/pipeline/lightMutex.h index 164db7195e..4e2d1fa67b 100644 --- a/panda/src/pipeline/lightMutex.h +++ b/panda/src/pipeline/lightMutex.h @@ -48,7 +48,7 @@ PUBLISHED: LightMutex(const LightMutex ©) = delete; ~LightMutex() = default; - void operator = (const LightMutex ©) = delete; + LightMutex &operator = (const LightMutex ©) = delete; }; #include "lightMutex.I" diff --git a/panda/src/pipeline/lightMutexHolder.I b/panda/src/pipeline/lightMutexHolder.I index 392a234b29..fb8a8951e4 100644 --- a/panda/src/pipeline/lightMutexHolder.I +++ b/panda/src/pipeline/lightMutexHolder.I @@ -50,19 +50,3 @@ INLINE LightMutexHolder:: _mutex->release(); #endif } - -/** - * Do not attempt to copy LightMutexHolders. - */ -INLINE LightMutexHolder:: -LightMutexHolder(const LightMutexHolder ©) { - nassertv(false); -} - -/** - * Do not attempt to copy LightMutexHolders. - */ -INLINE void LightMutexHolder:: -operator = (const LightMutexHolder ©) { - nassertv(false); -} diff --git a/panda/src/pipeline/lightMutexHolder.h b/panda/src/pipeline/lightMutexHolder.h index 778ac69722..fde6a4ba9a 100644 --- a/panda/src/pipeline/lightMutexHolder.h +++ b/panda/src/pipeline/lightMutexHolder.h @@ -26,10 +26,10 @@ class EXPCL_PANDA_PIPELINE LightMutexHolder { public: INLINE LightMutexHolder(const LightMutex &mutex); INLINE LightMutexHolder(LightMutex *&mutex); + LightMutexHolder(const LightMutexHolder ©) = delete; INLINE ~LightMutexHolder(); -private: - INLINE LightMutexHolder(const LightMutexHolder ©); - INLINE void operator = (const LightMutexHolder ©); + + LightMutexHolder &operator = (const LightMutexHolder ©) = delete; private: #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) diff --git a/panda/src/pipeline/lightReMutex.I b/panda/src/pipeline/lightReMutex.I index e1993f5dee..c0cb459c87 100644 --- a/panda/src/pipeline/lightReMutex.I +++ b/panda/src/pipeline/lightReMutex.I @@ -46,18 +46,3 @@ LightReMutex(const string &) #endif // DEBUG_THREADS { } - -/** - * - */ -INLINE LightReMutex:: -~LightReMutex() { -} - -/** - * Do not attempt to copy mutexes. - */ -INLINE void LightReMutex:: -operator = (const LightReMutex ©) { - nassertv(false); -} diff --git a/panda/src/pipeline/lightReMutex.h b/panda/src/pipeline/lightReMutex.h index 6959c4ab17..2fff13a1ee 100644 --- a/panda/src/pipeline/lightReMutex.h +++ b/panda/src/pipeline/lightReMutex.h @@ -36,10 +36,10 @@ public: INLINE explicit LightReMutex(const char *name); PUBLISHED: INLINE explicit LightReMutex(const string &name); - INLINE ~LightReMutex(); -private: - INLINE LightReMutex(const LightReMutex ©); - INLINE void operator = (const LightReMutex ©); + LightReMutex(const LightReMutex ©) = delete; + ~LightReMutex() = default; + + LightReMutex &operator = (const LightReMutex ©) = delete; }; #include "lightReMutex.I" diff --git a/panda/src/pipeline/lightReMutexHolder.I b/panda/src/pipeline/lightReMutexHolder.I index 96141251d7..4158d92c26 100644 --- a/panda/src/pipeline/lightReMutexHolder.I +++ b/panda/src/pipeline/lightReMutexHolder.I @@ -62,19 +62,3 @@ INLINE LightReMutexHolder:: _mutex->release(); #endif } - -/** - * Do not attempt to copy LightReMutexHolders. - */ -INLINE LightReMutexHolder:: -LightReMutexHolder(const LightReMutexHolder ©) { - nassertv(false); -} - -/** - * Do not attempt to copy LightReMutexHolders. - */ -INLINE void LightReMutexHolder:: -operator = (const LightReMutexHolder ©) { - nassertv(false); -} diff --git a/panda/src/pipeline/lightReMutexHolder.h b/panda/src/pipeline/lightReMutexHolder.h index 462b22180b..019206fbac 100644 --- a/panda/src/pipeline/lightReMutexHolder.h +++ b/panda/src/pipeline/lightReMutexHolder.h @@ -27,10 +27,10 @@ public: INLINE LightReMutexHolder(const LightReMutex &mutex); INLINE LightReMutexHolder(const LightReMutex &mutex, Thread *current_thread); INLINE LightReMutexHolder(LightReMutex *&mutex); + LightReMutexHolder(const LightReMutexHolder ©) = delete; INLINE ~LightReMutexHolder(); -private: - INLINE LightReMutexHolder(const LightReMutexHolder ©); - INLINE void operator = (const LightReMutexHolder ©); + + LightReMutexHolder &operator = (const LightReMutexHolder ©) = delete; private: #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) diff --git a/panda/src/pipeline/mutexHolder.I b/panda/src/pipeline/mutexHolder.I index 9b1b99d6b6..c2b6204e5a 100644 --- a/panda/src/pipeline/mutexHolder.I +++ b/panda/src/pipeline/mutexHolder.I @@ -64,19 +64,3 @@ INLINE MutexHolder:: _mutex->release(); #endif } - -/** - * Do not attempt to copy MutexHolders. - */ -INLINE MutexHolder:: -MutexHolder(const MutexHolder ©) { - nassertv(false); -} - -/** - * Do not attempt to copy MutexHolders. - */ -INLINE void MutexHolder:: -operator = (const MutexHolder ©) { - nassertv(false); -} diff --git a/panda/src/pipeline/mutexHolder.h b/panda/src/pipeline/mutexHolder.h index 26f1af5d9d..ccd7b321a8 100644 --- a/panda/src/pipeline/mutexHolder.h +++ b/panda/src/pipeline/mutexHolder.h @@ -27,10 +27,10 @@ public: INLINE MutexHolder(const Mutex &mutex); INLINE MutexHolder(const Mutex &mutex, Thread *current_thread); INLINE MutexHolder(Mutex *&mutex); + MutexHolder(const MutexHolder ©) = delete; INLINE ~MutexHolder(); -private: - INLINE MutexHolder(const MutexHolder ©); - INLINE void operator = (const MutexHolder ©); + + MutexHolder &operator = (const MutexHolder ©) = delete; private: // If HAVE_THREADS is defined, the Mutex class implements an actual mutex diff --git a/panda/src/pipeline/pipelineCyclerTrivialImpl.I b/panda/src/pipeline/pipelineCyclerTrivialImpl.I index 5cc1eecf39..316cadae30 100644 --- a/panda/src/pipeline/pipelineCyclerTrivialImpl.I +++ b/panda/src/pipeline/pipelineCyclerTrivialImpl.I @@ -30,35 +30,6 @@ PipelineCyclerTrivialImpl(CycleData *initial_data, Pipeline *) { #endif // SIMPLE_STRUCT_POINTERS } -/** - * - */ -INLINE PipelineCyclerTrivialImpl:: -PipelineCyclerTrivialImpl(const PipelineCyclerTrivialImpl &) { - // The copy constructor for the PipelineCyclerTrivialImpl case doesn't work. - // Don't try to use it. The PipelineCycler template class is ifdeffed - // appropriately to call the normal constructor instead. - nassertv(false); -} - -/** - * - */ -INLINE void PipelineCyclerTrivialImpl:: -operator = (const PipelineCyclerTrivialImpl &) { - // The copy assignment operator for the PipelineCyclerTrivialImpl case - // doesn't work. Don't try to use it. The PipelineCycler template class is - // ifdeffed appropriately not to call this method. - nassertv(false); -} - -/** - * - */ -INLINE PipelineCyclerTrivialImpl:: -~PipelineCyclerTrivialImpl() { -} - /** * Grabs an overall lock on the cycler. Release it with a call to release(). * This lock should be held while walking the list of stages. diff --git a/panda/src/pipeline/pipelineCyclerTrivialImpl.h b/panda/src/pipeline/pipelineCyclerTrivialImpl.h index ea0593ba24..9bcc9f12c9 100644 --- a/panda/src/pipeline/pipelineCyclerTrivialImpl.h +++ b/panda/src/pipeline/pipelineCyclerTrivialImpl.h @@ -41,11 +41,10 @@ class Pipeline; struct EXPCL_PANDA_PIPELINE PipelineCyclerTrivialImpl { public: INLINE PipelineCyclerTrivialImpl(CycleData *initial_data, Pipeline *pipeline = NULL); -private: - INLINE PipelineCyclerTrivialImpl(const PipelineCyclerTrivialImpl ©); - INLINE void operator = (const PipelineCyclerTrivialImpl ©); -public: - INLINE ~PipelineCyclerTrivialImpl(); + PipelineCyclerTrivialImpl(const PipelineCyclerTrivialImpl ©) = delete; + ~PipelineCyclerTrivialImpl() = default; + + PipelineCyclerTrivialImpl &operator = (const PipelineCyclerTrivialImpl ©) = delete; INLINE void acquire(Thread *current_thread = NULL); INLINE void release(); diff --git a/panda/src/pipeline/psemaphore.I b/panda/src/pipeline/psemaphore.I index 1111e01857..0d1fe57bdf 100644 --- a/panda/src/pipeline/psemaphore.I +++ b/panda/src/pipeline/psemaphore.I @@ -23,31 +23,6 @@ Semaphore(int initial_count) : nassertv(_count >= 0); } -/** - * - */ -INLINE Semaphore:: -~Semaphore() { -} - -/** - * Do not attempt to copy semaphores. - */ -INLINE Semaphore:: -Semaphore(const Semaphore ©) : - _cvar(_lock) -{ - nassertv(false); -} - -/** - * Do not attempt to copy semaphores. - */ -INLINE void Semaphore:: -operator = (const Semaphore ©) { - nassertv(false); -} - /** * Decrements the internal count. If the count was already at zero, blocks * until the count is nonzero, then decrements it. diff --git a/panda/src/pipeline/psemaphore.h b/panda/src/pipeline/psemaphore.h index 6fd9162cc2..9c724a94c1 100644 --- a/panda/src/pipeline/psemaphore.h +++ b/panda/src/pipeline/psemaphore.h @@ -30,10 +30,10 @@ class EXPCL_PANDA_PIPELINE Semaphore { PUBLISHED: INLINE explicit Semaphore(int initial_count = 1); - INLINE ~Semaphore(); -private: - INLINE Semaphore(const Semaphore ©); - INLINE void operator = (const Semaphore ©); + Semaphore(const Semaphore ©) = delete; + ~Semaphore() = default; + + Semaphore &operator = (const Semaphore ©) = delete; PUBLISHED: BLOCKING INLINE void acquire(); diff --git a/panda/src/pipeline/reMutexHolder.I b/panda/src/pipeline/reMutexHolder.I index 25a0032b4e..00cd980e01 100644 --- a/panda/src/pipeline/reMutexHolder.I +++ b/panda/src/pipeline/reMutexHolder.I @@ -61,19 +61,3 @@ INLINE ReMutexHolder:: _mutex->release(); #endif } - -/** - * Do not attempt to copy ReMutexHolders. - */ -INLINE ReMutexHolder:: -ReMutexHolder(const ReMutexHolder ©) { - nassertv(false); -} - -/** - * Do not attempt to copy ReMutexHolders. - */ -INLINE void ReMutexHolder:: -operator = (const ReMutexHolder ©) { - nassertv(false); -} diff --git a/panda/src/pipeline/reMutexHolder.h b/panda/src/pipeline/reMutexHolder.h index f0830803fb..3411f7e3f8 100644 --- a/panda/src/pipeline/reMutexHolder.h +++ b/panda/src/pipeline/reMutexHolder.h @@ -27,10 +27,10 @@ public: INLINE ReMutexHolder(const ReMutex &mutex); INLINE ReMutexHolder(const ReMutex &mutex, Thread *current_thread); INLINE ReMutexHolder(ReMutex *&mutex); + ReMutexHolder(const ReMutexHolder ©) = delete; INLINE ~ReMutexHolder(); -private: - INLINE ReMutexHolder(const ReMutexHolder ©); - INLINE void operator = (const ReMutexHolder ©); + + ReMutexHolder &operator = (const ReMutexHolder ©) = delete; private: #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) diff --git a/panda/src/pipeline/thread.I b/panda/src/pipeline/thread.I index 10d7b6e44f..d108f025dd 100644 --- a/panda/src/pipeline/thread.I +++ b/panda/src/pipeline/thread.I @@ -11,22 +11,6 @@ * @date 2002-08-08 */ -/** - * Do not attempt to copy threads. - */ -INLINE Thread:: -Thread(const Thread ©) : _impl(this) { - nassertv(false); -} - -/** - * Do not attempt to copy threads. - */ -INLINE void Thread:: -operator = (const Thread ©) { - nassertv(false); -} - /** * Returns the sync name of the thread. This name collects threads into "sync * groups", which are expected to run synchronously. This is mainly used for diff --git a/panda/src/pipeline/thread.h b/panda/src/pipeline/thread.h index 730deb5872..6749883fb6 100644 --- a/panda/src/pipeline/thread.h +++ b/panda/src/pipeline/thread.h @@ -46,15 +46,14 @@ class AsyncTask; class EXPCL_PANDA_PIPELINE Thread : public TypedReferenceCount, public Namable { protected: Thread(const string &name, const string &sync_name); + Thread(const Thread ©) = delete; PUBLISHED: virtual ~Thread(); -private: - INLINE Thread(const Thread ©); - INLINE void operator = (const Thread ©); - protected: + Thread &operator = (const Thread ©) = delete; + virtual void thread_main()=0; PUBLISHED: diff --git a/panda/src/speedtree/stTree.cxx b/panda/src/speedtree/stTree.cxx index fb00fc1bea..7a09205d6e 100644 --- a/panda/src/speedtree/stTree.cxx +++ b/panda/src/speedtree/stTree.cxx @@ -61,15 +61,6 @@ STTree(const Filename &fullpath) : _is_valid = true; } - -/** - * An STTree copy constructor is not supported. - */ -STTree:: -STTree(const STTree ©) { - nassertv(false); -} - /** * */ diff --git a/panda/src/speedtree/stTree.h b/panda/src/speedtree/stTree.h index 55c4dacbb7..379223aa97 100644 --- a/panda/src/speedtree/stTree.h +++ b/panda/src/speedtree/stTree.h @@ -28,8 +28,7 @@ class SpeedTreeNode; class EXPCL_PANDASPEEDTREE STTree : public TypedReferenceCount, public Namable { PUBLISHED: STTree(const Filename &fullpath); -private: - STTree(const STTree ©); + STTree(const STTree ©) = delete; PUBLISHED: INLINE const Filename &get_fullpath() const; diff --git a/panda/src/text/dynamicTextGlyph.I b/panda/src/text/dynamicTextGlyph.I index e6406e0d0d..23e44ee8ce 100644 --- a/panda/src/text/dynamicTextGlyph.I +++ b/panda/src/text/dynamicTextGlyph.I @@ -39,25 +39,6 @@ DynamicTextGlyph(int character, PN_stdfloat advance) : { } -/** - * Copying DynamicTextGlyph objects is not allowed. - */ -INLINE DynamicTextGlyph:: -DynamicTextGlyph(const DynamicTextGlyph &) : - TextGlyph(0) -{ - nassertv(false); -} - -/** - * Copying DynamicTextGlyph objects is not allowed. - */ -INLINE void DynamicTextGlyph:: -operator = (const DynamicTextGlyph &) { - nassertv(false); -} - - /** * Returns the DynamicTextPage that this glyph is on. */ diff --git a/panda/src/text/dynamicTextGlyph.h b/panda/src/text/dynamicTextGlyph.h index a90308977c..73ec2835a8 100644 --- a/panda/src/text/dynamicTextGlyph.h +++ b/panda/src/text/dynamicTextGlyph.h @@ -34,9 +34,9 @@ public: int x, int y, int x_size, int y_size, int margin, PN_stdfloat advance); INLINE DynamicTextGlyph(int character, PN_stdfloat advance); -private: - INLINE DynamicTextGlyph(const DynamicTextGlyph ©); - INLINE void operator = (const DynamicTextGlyph ©); + DynamicTextGlyph(const DynamicTextGlyph ©) = delete; + + DynamicTextGlyph &operator = (const DynamicTextGlyph ©) = delete; PUBLISHED: virtual ~DynamicTextGlyph(); diff --git a/panda/src/vision/openCVTexture.cxx b/panda/src/vision/openCVTexture.cxx index 7d09636b0c..5990e77321 100644 --- a/panda/src/vision/openCVTexture.cxx +++ b/panda/src/vision/openCVTexture.cxx @@ -48,18 +48,6 @@ OpenCVTexture(const string &name) : { } -/** - * Use OpenCVTexture::make_copy() to make a duplicate copy of an existing - * OpenCVTexture. - */ -OpenCVTexture:: -OpenCVTexture(const OpenCVTexture ©) : - VideoTexture(copy), - _pages(copy._pages) -{ - nassertv(false); -} - /** * */ diff --git a/panda/src/vision/openCVTexture.h b/panda/src/vision/openCVTexture.h index 1ad8e11a7a..7226202a7f 100644 --- a/panda/src/vision/openCVTexture.h +++ b/panda/src/vision/openCVTexture.h @@ -29,9 +29,7 @@ struct CvCapture; class EXPCL_VISION OpenCVTexture : public VideoTexture { PUBLISHED: OpenCVTexture(const string &name = string()); -protected: - OpenCVTexture(const OpenCVTexture ©); -PUBLISHED: + OpenCVTexture(const OpenCVTexture ©) = delete; virtual ~OpenCVTexture(); bool from_camera(int camera_index = -1, int z = 0, From 49dfcb09b9f5dca11c2a64c5858c7bd237bbf1f0 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 23 May 2018 23:39:43 +0200 Subject: [PATCH 184/247] makepanda: refuse building with MSVC versions older than 2015 Panda3D no longer compiles with any version older than Visual Studio 2015 (14.0). Closes #288 --- makepanda/makepanda.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 5c42bb9bf5..9f0f1d928e 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -315,9 +315,7 @@ def parseopts(args): usage("Invalid SHA-1 hash given for --git-commit option!") if GetTarget() == 'windows': - show_warning = False if not MSVC_VERSION: - show_warning = True print("No MSVC version specified. Defaulting to 14 (Visual Studio 2015).") MSVC_VERSION = (14, 0) else: @@ -325,22 +323,19 @@ def parseopts(args): MSVC_VERSION = tuple(int(d) for d in MSVC_VERSION.split('.'))[:2] if (len(MSVC_VERSION) == 1): MSVC_VERSION += (0,) - if MSVC_VERSION < (14, 0): - show_warning = True except: usage("Invalid setting for --msvc-version") - if show_warning: - warn_prefix = "%sWARNING:%s " % (GetColor("red"), GetColor()) + if MSVC_VERSION < (14, 0): + warn_prefix = "%sERROR:%s " % (GetColor("red"), GetColor()) print("=========================================================================") - print(warn_prefix + "Support for MSVC versions before 2015 will soon be discontinued.") - print(warn_prefix + "If you wish to keep using MSVC 2010, make your voice heard at:") + print(warn_prefix + "Support for MSVC versions before 2015 has been discontinued.") + print(warn_prefix + "For more information, or any questions, please visit:") print(warn_prefix + " https://github.com/panda3d/panda3d/issues/288") - if MSVC_VERSION >= (14, 0): - print(warn_prefix + "To squelch this warning, pass --msvc-version {0}.{1}".format(*MSVC_VERSION)) print("=========================================================================") sys.stdout.flush() time.sleep(1.0) + sys.exit(1) if not WINDOWS_SDK: print("No Windows SDK version specified. Defaulting to '7.1'.") From 8eeab7a26a3cb69c62f8d92e79d48503e56ad67d Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 24 May 2018 14:26:21 +0200 Subject: [PATCH 185/247] dxgsg9: fix compile error due to WeakPointerTo changes --- panda/src/dxgsg9/dxGeomMunger9.I | 4 ++-- panda/src/dxgsg9/dxGeomMunger9.cxx | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/panda/src/dxgsg9/dxGeomMunger9.I b/panda/src/dxgsg9/dxGeomMunger9.I index eee877c668..223e6478cb 100644 --- a/panda/src/dxgsg9/dxGeomMunger9.I +++ b/panda/src/dxgsg9/dxGeomMunger9.I @@ -31,6 +31,6 @@ DXGeomMunger9(GraphicsStateGuardian *gsg, const RenderState *state) : } // Set a callback to unregister ourselves when either the Texture or the // TexGen object gets deleted. - _texture.set_callback(this); - _tex_gen.set_callback(this); + _texture.add_callback(this); + _tex_gen.add_callback(this); } diff --git a/panda/src/dxgsg9/dxGeomMunger9.cxx b/panda/src/dxgsg9/dxGeomMunger9.cxx index 44729ae0cd..e9b9ba498e 100644 --- a/panda/src/dxgsg9/dxGeomMunger9.cxx +++ b/panda/src/dxgsg9/dxGeomMunger9.cxx @@ -28,6 +28,9 @@ DXGeomMunger9:: unref_delete(_filtered_texture); _reffed_filtered_texture = false; } + + _texture.remove_callback(this); + _tex_gen.remove_callback(this); } /** From 5e0ce969fe15c808e71c04618cd12729aa8ba830 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 24 May 2018 14:30:08 +0200 Subject: [PATCH 186/247] Work around clang 3.1 compile error with static constexpr There is a bug in clang versions before 3.2 (including the one shipped with Xcode) that makes it give a "conflicting types" compile error when there is a static constexpr function defined outside the class. The way to work around this is either to remove one of the "static" or "constexpr" keywords, or to simply put the definition inline. See: https://stackoverflow.com/a/17494592/2135754 I would try and upgrade Xcode to version 5 to see if the problem is fixed, but the buildbot still runs OS X Lion (10.7) and the last version of Xcode that works on Lion is 4.6.3, so it seems easier to just apply these workarounds for now. --- dtool/src/dtoolbase/memoryHook.I | 9 ------ dtool/src/dtoolbase/memoryHook.h | 4 ++- dtool/src/dtoolbase/typeHandle.I | 19 ------------- dtool/src/dtoolbase/typeHandle.h | 4 +-- panda/src/pgraph/renderAttribRegistry.I | 13 --------- panda/src/pgraph/renderAttribRegistry.h | 2 +- panda/src/putil/bitArray.I | 38 ------------------------- panda/src/putil/bitArray.h | 6 ++-- panda/src/putil/bitMask.I | 31 +------------------- panda/src/putil/bitMask.h | 6 ++-- panda/src/putil/doubleBitMask.I | 31 +------------------- panda/src/putil/doubleBitMask.h | 6 ++-- panda/src/putil/updateSeq.I | 24 ---------------- panda/src/putil/updateSeq.h | 8 +++--- 14 files changed, 21 insertions(+), 180 deletions(-) diff --git a/dtool/src/dtoolbase/memoryHook.I b/dtool/src/dtoolbase/memoryHook.I index 055856f37b..cc4f972f6b 100644 --- a/dtool/src/dtoolbase/memoryHook.I +++ b/dtool/src/dtoolbase/memoryHook.I @@ -34,15 +34,6 @@ dec_heap(size_t size) { #endif // DO_MEMORY_USAGE } -/** - * Returns the global memory alignment. This is the number of bytes at which - * each allocated memory pointer will be aligned. - */ -constexpr size_t MemoryHook:: -get_memory_alignment() { - return MEMORY_HOOK_ALIGNMENT; -} - /** * Returns the operating system page size. This is the minimum granularity * required for calls to mmap_alloc(). Also see round_up_to_page_size(). diff --git a/dtool/src/dtoolbase/memoryHook.h b/dtool/src/dtoolbase/memoryHook.h index b5fceacd53..bb30e7f03d 100644 --- a/dtool/src/dtoolbase/memoryHook.h +++ b/dtool/src/dtoolbase/memoryHook.h @@ -52,7 +52,9 @@ public: bool heap_trim(size_t pad); - constexpr static size_t get_memory_alignment(); + constexpr static size_t get_memory_alignment() { + return MEMORY_HOOK_ALIGNMENT; + } virtual void *mmap_alloc(size_t size, bool allow_exec); virtual void mmap_free(void *ptr, size_t size); diff --git a/dtool/src/dtoolbase/typeHandle.I b/dtool/src/dtoolbase/typeHandle.I index bb7a737bf2..c63524c18c 100644 --- a/dtool/src/dtoolbase/typeHandle.I +++ b/dtool/src/dtoolbase/typeHandle.I @@ -191,14 +191,6 @@ output(ostream &out) const { out << get_name(); } -/** - * Returns a special zero-valued TypeHandle that is used to indicate no type. - */ -constexpr TypeHandle TypeHandle:: -none() { - return TypeHandle(0); -} - /** * TypeHandle::none() evaluates to false, everything else evaluates to true. */ @@ -207,17 +199,6 @@ operator bool () const { return (_index != 0); } -/** - * Creates a TypeHandle from a type index without error checking, for use by - * internal functions. - * - * See TypeRegistry::find_type_by_id(). - */ -constexpr TypeHandle TypeHandle:: -from_index(int index) { - return TypeHandle(index); -} - /** * Private constructor for initializing a TypeHandle from an index, used by * none() and by from_index(). diff --git a/dtool/src/dtoolbase/typeHandle.h b/dtool/src/dtoolbase/typeHandle.h index ed539e0619..b1b99c4ae0 100644 --- a/dtool/src/dtoolbase/typeHandle.h +++ b/dtool/src/dtoolbase/typeHandle.h @@ -129,7 +129,7 @@ PUBLISHED: INLINE int get_index() const; INLINE void output(ostream &out) const; - constexpr static TypeHandle none(); + constexpr static TypeHandle none() { return TypeHandle(0); } INLINE operator bool () const; MAKE_PROPERTY(index, get_index); @@ -142,7 +142,7 @@ public: void *reallocate_array(void *ptr, size_t size) RETURNS_ALIGNED(MEMORY_HOOK_ALIGNMENT); void deallocate_array(void *ptr); - constexpr static TypeHandle from_index(int index); + constexpr static TypeHandle from_index(int index) { return TypeHandle(index); } private: constexpr TypeHandle(int index); diff --git a/panda/src/pgraph/renderAttribRegistry.I b/panda/src/pgraph/renderAttribRegistry.I index fab7f22d24..5ad950dd4d 100644 --- a/panda/src/pgraph/renderAttribRegistry.I +++ b/panda/src/pgraph/renderAttribRegistry.I @@ -24,19 +24,6 @@ get_slot(TypeHandle type_handle) const { return _slots_by_type[(size_t)type_index]; } -/** - * Returns the maximum number that any slot number is allowed to grow. - * Actually, this number will be one higher than the highest possible slot - * number. This puts an upper bound on the number of RenderAttrib slots that - * may be allocated, and allows other code to define an array of slots. - * - * This number will not change during the lifetime of the application. - */ -constexpr int RenderAttribRegistry:: -get_max_slots() { - return _max_slots; -} - /** * Returns the number of RenderAttrib slots that have been allocated. This is * one more than the highest slot number in use. diff --git a/panda/src/pgraph/renderAttribRegistry.h b/panda/src/pgraph/renderAttribRegistry.h index ae47bd39a8..c7cf71b044 100644 --- a/panda/src/pgraph/renderAttribRegistry.h +++ b/panda/src/pgraph/renderAttribRegistry.h @@ -54,7 +54,7 @@ public: PUBLISHED: INLINE int get_slot(TypeHandle type_handle) const; - static constexpr int get_max_slots(); + static constexpr int get_max_slots() { return _max_slots; } INLINE int get_num_slots() const; INLINE TypeHandle get_slot_type(int slot) const; diff --git a/panda/src/putil/bitArray.I b/panda/src/putil/bitArray.I index 2a3341833d..605cf40a57 100644 --- a/panda/src/putil/bitArray.I +++ b/panda/src/putil/bitArray.I @@ -78,44 +78,6 @@ range(int low_bit, int size) { return result; } -/** - * Returns true if there is a maximum number of bits that may be stored in - * this structure, false otherwise. If this returns true, the number may be - * queried in get_max_num_bits(). - * - * This method always returns false. The BitArray has no maximum number of - * bits. This method is defined so generic programming algorithms can use - * BitMask or BitArray interchangeably. - */ -constexpr bool BitArray:: -has_max_num_bits() { - return false; -} - -/** - * If get_max_num_bits() returned true, this method may be called to return - * the maximum number of bits that may be stored in this structure. It is an - * error to call this if get_max_num_bits() return false. - * - * It is always an error to call this method. The BitArray has no maximum - * number of bits. This method is defined so generic programming algorithms - * can use BitMask or BitArray interchangeably. - */ -constexpr int BitArray:: -get_max_num_bits() { - return INT_MAX; -} - -/** - * Returns the number of bits stored per word internally. This is of interest - * only in that it limits the maximum number of bits that may be queried or - * set at once by extract() and store(). - */ -constexpr int BitArray:: -get_num_bits_per_word() { - return num_bits_per_word; -} - /** * Returns the current number of possibly different bits in this array. There * are actually an infinite number of bits, but every bit higher than this bit diff --git a/panda/src/putil/bitArray.h b/panda/src/putil/bitArray.h index 42070ad3f8..bb00dea0d7 100644 --- a/panda/src/putil/bitArray.h +++ b/panda/src/putil/bitArray.h @@ -54,10 +54,10 @@ PUBLISHED: INLINE static BitArray bit(int index); INLINE static BitArray range(int low_bit, int size); - constexpr static bool has_max_num_bits(); - constexpr static int get_max_num_bits(); + constexpr static bool has_max_num_bits() { return false; } + constexpr static int get_max_num_bits() { return INT_MAX; } - constexpr static int get_num_bits_per_word(); + constexpr static int get_num_bits_per_word() { return num_bits_per_word; } INLINE size_t get_num_bits() const; INLINE bool get_bit(int index) const; INLINE void set_bit(int index); diff --git a/panda/src/putil/bitMask.I b/panda/src/putil/bitMask.I index 837101a961..fa1073ad4b 100644 --- a/panda/src/putil/bitMask.I +++ b/panda/src/putil/bitMask.I @@ -101,41 +101,12 @@ range(int low_bit, int size) { return result; } -/** - * Returns true if there is a maximum number of bits that may be stored in - * this structure, false otherwise. If this returns true, the number may be - * queried in get_max_num_bits(). - * - * This method always returns true. This method is defined so generic - * programming algorithms can use BitMask or BitArray interchangeably. - */ -template -constexpr bool BitMask:: -has_max_num_bits() { - return true; -} - -/** - * If get_max_num_bits() returned true, this method may be called to return - * the maximum number of bits that may be stored in this structure. It is an - * error to call this if get_max_num_bits() return false. - * - * It is never an error to call this method. This returns the same thing as - * get_num_bits(). This method is defined so generic programming algorithms - * can use BitMask or BitArray interchangeably. - */ -template -constexpr int BitMask:: -get_max_num_bits() { - return num_bits; -} - /** * Returns the number of bits available to set in the bitmask. */ template constexpr int BitMask:: -get_num_bits() { +get_num_bits() const { return num_bits; } diff --git a/panda/src/putil/bitMask.h b/panda/src/putil/bitMask.h index 589c4dd73c..3d73089b50 100644 --- a/panda/src/putil/bitMask.h +++ b/panda/src/putil/bitMask.h @@ -45,10 +45,10 @@ PUBLISHED: INLINE static BitMask bit(int index); INLINE static BitMask range(int low_bit, int size); - constexpr static bool has_max_num_bits(); - constexpr static int get_max_num_bits(); + constexpr static bool has_max_num_bits() { return true; } + constexpr static int get_max_num_bits() { return num_bits; } - constexpr static int get_num_bits(); + constexpr int get_num_bits() const; INLINE bool get_bit(int index) const; INLINE void set_bit(int index); INLINE void clear_bit(int index); diff --git a/panda/src/putil/doubleBitMask.I b/panda/src/putil/doubleBitMask.I index 0b08768229..0768263afe 100644 --- a/panda/src/putil/doubleBitMask.I +++ b/panda/src/putil/doubleBitMask.I @@ -119,41 +119,12 @@ INLINE DoubleBitMask:: ~DoubleBitMask() { } -/** - * Returns true if there is a maximum number of bits that may be stored in - * this structure, false otherwise. If this returns true, the number may be - * queried in get_max_num_bits(). - * - * This method always returns true. This method is defined so generic - * programming algorithms can use DoubleBitMask or BitArray interchangeably. - */ -template -constexpr bool DoubleBitMask:: -has_max_num_bits() { - return true; -} - -/** - * If get_max_num_bits() returned true, this method may be called to return - * the maximum number of bits that may be stored in this structure. It is an - * error to call this if get_max_num_bits() return false. - * - * It is never an error to call this method. This returns the same thing as - * get_num_bits(). This method is defined so generic programming algorithms - * can use DoubleBitMask or BitArray interchangeably. - */ -template -constexpr int DoubleBitMask:: -get_max_num_bits() { - return num_bits; -} - /** * Returns the number of bits available to set in the doubleBitMask. */ template constexpr int DoubleBitMask:: -get_num_bits() { +get_num_bits() const { return num_bits; } diff --git a/panda/src/putil/doubleBitMask.h b/panda/src/putil/doubleBitMask.h index 472a1ddc3f..6c32cd0122 100644 --- a/panda/src/putil/doubleBitMask.h +++ b/panda/src/putil/doubleBitMask.h @@ -49,10 +49,10 @@ PUBLISHED: INLINE ~DoubleBitMask(); - constexpr static bool has_max_num_bits(); - constexpr static int get_max_num_bits(); + constexpr static bool has_max_num_bits() {return true;} + constexpr static int get_max_num_bits() {return num_bits;} - constexpr static int get_num_bits(); + constexpr int get_num_bits() const; INLINE bool get_bit(int index) const; INLINE void set_bit(int index); INLINE void clear_bit(int index); diff --git a/panda/src/putil/updateSeq.I b/panda/src/putil/updateSeq.I index 1df2577c35..0083c98bca 100644 --- a/panda/src/putil/updateSeq.I +++ b/panda/src/putil/updateSeq.I @@ -25,30 +25,6 @@ constexpr UpdateSeq:: UpdateSeq() : _seq((unsigned int)SC_initial) { } -/** - * Returns an UpdateSeq in the 'initial' state. - */ -constexpr UpdateSeq UpdateSeq:: -initial() { - return UpdateSeq((unsigned int)SC_initial); -} - -/** - * Returns an UpdateSeq in the 'old' state. - */ -constexpr UpdateSeq UpdateSeq:: -old() { - return UpdateSeq((unsigned int)SC_old); -} - -/** - * Returns an UpdateSeq in the 'fresh' state. - */ -constexpr UpdateSeq UpdateSeq:: -fresh() { - return UpdateSeq((unsigned int)SC_fresh); -} - /** * */ diff --git a/panda/src/putil/updateSeq.h b/panda/src/putil/updateSeq.h index 4a982df279..bdddadde6e 100644 --- a/panda/src/putil/updateSeq.h +++ b/panda/src/putil/updateSeq.h @@ -40,9 +40,9 @@ private: PUBLISHED: constexpr UpdateSeq(); - constexpr static UpdateSeq initial(); - constexpr static UpdateSeq old(); - constexpr static UpdateSeq fresh(); + constexpr static UpdateSeq initial() { return UpdateSeq(SC_initial); } + constexpr static UpdateSeq old() { return UpdateSeq(SC_old); } + constexpr static UpdateSeq fresh() { return UpdateSeq(SC_fresh); } INLINE UpdateSeq(const UpdateSeq ©); constexpr UpdateSeq(const UpdateSeq &&from) noexcept; @@ -76,7 +76,7 @@ private: INLINE static bool priv_le(AtomicAdjust::Integer a, AtomicAdjust::Integer b); private: - enum SpecialCases { + enum SpecialCases : unsigned int { SC_initial = 0, SC_old = 1, SC_fresh = ~(unsigned int)0, From 323ddc7d67f856bed50ae156de3c26ea4cbe04c9 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 24 May 2018 21:37:58 +0200 Subject: [PATCH 187/247] putil: fix UpdateSeq::fresh().is_special() return value --- panda/src/putil/updateSeq.I | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/putil/updateSeq.I b/panda/src/putil/updateSeq.I index 0083c98bca..ea9af8427c 100644 --- a/panda/src/putil/updateSeq.I +++ b/panda/src/putil/updateSeq.I @@ -87,7 +87,7 @@ is_fresh() const { INLINE bool UpdateSeq:: is_special() const { // This relies on the assumption that (~0 + 1) == 0. - return ((AtomicAdjust::get(_seq) + 1) <= 2); + return (((unsigned int)AtomicAdjust::get(_seq) + 1u) <= 2u); } /** From ae8e9d159d59602dc9168220a224997f918b3d2f Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 24 May 2018 21:38:25 +0200 Subject: [PATCH 188/247] tests: add some unit tests for UpdateSeq --- tests/putil/test_updateseq.py | 105 ++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 tests/putil/test_updateseq.py diff --git a/tests/putil/test_updateseq.py b/tests/putil/test_updateseq.py new file mode 100644 index 0000000000..68883e6f23 --- /dev/null +++ b/tests/putil/test_updateseq.py @@ -0,0 +1,105 @@ +from panda3d.core import UpdateSeq + + +def test_updateseq_initial(): + seq = UpdateSeq() + assert seq == UpdateSeq.initial() + + assert seq.is_special() + assert seq.is_initial() + assert not seq.is_old() + assert not seq.is_fresh() + + assert seq.seq == 0 + + initial = UpdateSeq.initial() + assert seq == initial + assert seq >= initial + assert seq <= initial + assert not (seq != initial) + assert not (seq > initial) + assert not (seq < initial) + + fresh = UpdateSeq.fresh() + assert not (seq == fresh) + assert not (seq >= fresh) + assert seq <= fresh + assert seq != fresh + assert not (seq > fresh) + assert seq < fresh + + old = UpdateSeq.old() + assert not (seq == old) + assert not (seq >= old) + assert not (seq > old) + assert seq != old + assert seq <= old + assert seq < old + + +def test_updateseq_fresh(): + seq = UpdateSeq.fresh() + + assert seq.is_special() + assert not seq.is_initial() + assert not seq.is_old() + assert seq.is_fresh() + + initial = UpdateSeq.initial() + assert not (seq == initial) + assert seq != initial + assert seq > initial + assert seq >= initial + assert not (seq < initial) + assert not (seq <= initial) + + fresh = UpdateSeq.fresh() + assert seq == fresh + assert seq >= fresh + assert seq <= fresh + assert not (seq != fresh) + assert not (seq > fresh) + assert not (seq < fresh) + + old = UpdateSeq.old() + assert not (seq == old) + assert not (seq >= old) + assert not (seq > old) + assert seq != old + assert seq <= old + assert seq < old + + +def test_updateseq_old(): + seq = UpdateSeq.old() + + assert seq.is_special() + assert not seq.is_initial() + assert seq.is_old() + assert not seq.is_fresh() + + assert seq.seq == 1 + + initial = UpdateSeq.initial() + assert not (seq == initial) + assert not (seq <= initial) + assert not (seq < initial) + assert seq != initial + assert seq > initial + assert seq >= initial + + fresh = UpdateSeq.fresh() + assert not (seq == fresh) + assert not (seq >= fresh) + assert not (seq > fresh) + assert seq <= fresh + assert seq != fresh + assert seq < fresh + + old = UpdateSeq.old() + assert seq == old + assert seq >= old + assert seq <= old + assert not (seq != old) + assert not (seq > old) + assert not (seq < old) From 2e7bca90b053223797e04ba74cc0934a0354cc8c Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 24 May 2018 21:39:19 +0200 Subject: [PATCH 189/247] express: fix PointerToArray coercibility regression, fix clear() This was caused by the assignment operators not being visible to interrogate. --- panda/src/express/pointerToArray.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/panda/src/express/pointerToArray.h b/panda/src/express/pointerToArray.h index 251102f5e3..1df1193b3c 100644 --- a/panda/src/express/pointerToArray.h +++ b/panda/src/express/pointerToArray.h @@ -98,6 +98,8 @@ PUBLISHED: EXTENSION(PointerToArray(PyObject *self, PyObject *source)); + INLINE void clear(); + INLINE size_type size() const; INLINE void push_back(const Element &x); INLINE void pop_back(); @@ -157,6 +159,8 @@ public: INLINE size_type max_size() const; INLINE bool empty() const; + INLINE void clear(); + // Functions specific to vectors. INLINE void reserve(size_type n); INLINE void resize(size_type n); @@ -216,6 +220,9 @@ public: INLINE size_t count(const Element &) const; +#endif // CPPPARSER + +public: // Reassignment is by pointer, not memberwise as with a vector. INLINE PointerToArray & operator = (ReferenceCountedVector *ptr); @@ -224,18 +231,14 @@ public: INLINE PointerToArray & operator = (PointerToArray &&from) noexcept; - INLINE void clear(); - private: TypeHandle _type_handle; -private: // This static empty array is kept around just so we can return something // meaningful when begin() or end() is called and we have a NULL pointer. // It might not be shared properly between different .so's, since it's a // static member of a template class, but we don't really care. static pvector _empty_array; -#endif // CPPPARSER friend class ConstPointerToArray; }; @@ -256,6 +259,8 @@ PUBLISHED: INLINE ConstPointerToArray(const PointerToArray ©); INLINE ConstPointerToArray(const ConstPointerToArray ©); + INLINE void clear(); + typedef TYPENAME pvector::size_type size_type; INLINE size_type size() const; INLINE const Element &get_element(size_type n) const; @@ -311,6 +316,8 @@ PUBLISHED: INLINE size_type max_size() const; INLINE bool empty() const; + INLINE void clear(); + // Functions specific to vectors. INLINE size_type capacity() const; INLINE reference front() const; @@ -342,6 +349,9 @@ PUBLISHED: INLINE size_t count(const Element &) const; +#endif // CPPPARSER + +public: // Reassignment is by pointer, not memberwise as with a vector. INLINE ConstPointerToArray & operator = (ReferenceCountedVector *ptr); @@ -354,18 +364,14 @@ PUBLISHED: INLINE ConstPointerToArray & operator = (ConstPointerToArray &&from) noexcept; - INLINE void clear(); - private: TypeHandle _type_handle; -private: // This static empty array is kept around just so we can return something // meangful when begin() or end() is called and we have a NULL pointer. It // might not be shared properly between different .so's, since it's a static // member of a template class, but we don't really care. static pvector _empty_array; -#endif // CPPPARSER friend class PointerToArray; }; From ec04dbed0cfe655c85ffbe72158b7ffc707ece22 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 24 May 2018 21:40:48 +0200 Subject: [PATCH 190/247] gobj: fix static init ordering issue with VertexTransform cycler This comes up when building with DEBUG_THREADS; there is a PipelineCycler created at static init time, and the type tracking in Pipeline won't work properly if the CData's parent's TypeHandle has not yet been initialized. --- panda/src/gobj/vertexTransform.h | 1 + 1 file changed, 1 insertion(+) diff --git a/panda/src/gobj/vertexTransform.h b/panda/src/gobj/vertexTransform.h index 51e84c9edb..ff106bf56e 100644 --- a/panda/src/gobj/vertexTransform.h +++ b/panda/src/gobj/vertexTransform.h @@ -67,6 +67,7 @@ private: virtual int complete_pointers(TypedWritable **plist, BamReader *manager); virtual void fillin(DatagramIterator &scan, BamReader *manager); virtual TypeHandle get_parent_type() const { + VertexTransform::init_type(); return VertexTransform::get_class_type(); } From ddc45e35297f000b34ea53ac9b5456e4f3ba226f Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 24 May 2018 22:25:20 +0200 Subject: [PATCH 191/247] tests: fix broken test case, add more WeakNodePath comparisons --- tests/pgraph/test_nodepath.py | 8 ++++++++ tests/putil/test_updateseq.py | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/pgraph/test_nodepath.py b/tests/pgraph/test_nodepath.py index 9c97d4260a..d60aa312ba 100644 --- a/tests/pgraph/test_nodepath.py +++ b/tests/pgraph/test_nodepath.py @@ -91,6 +91,14 @@ def test_weak_nodepath_comparison(): assert weak == path assert weak <= path assert path <= weak + assert weak >= path + assert path >= weak + assert not (path != weak) + assert not (weak != path) + assert not (weak > path) + assert not (path > weak) + assert not (weak < path) + assert not (path < weak) assert hash(path) == hash(weak) assert weak.get_node_path() == path diff --git a/tests/putil/test_updateseq.py b/tests/putil/test_updateseq.py index 68883e6f23..5cd7312595 100644 --- a/tests/putil/test_updateseq.py +++ b/tests/putil/test_updateseq.py @@ -63,11 +63,11 @@ def test_updateseq_fresh(): old = UpdateSeq.old() assert not (seq == old) - assert not (seq >= old) - assert not (seq > old) + assert not (seq <= old) + assert not (seq < old) assert seq != old - assert seq <= old - assert seq < old + assert seq >= old + assert seq > old def test_updateseq_old(): From 5c9705c21c551c072dc0861965d6e8f4b7cbe657 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 24 May 2018 22:43:48 +0200 Subject: [PATCH 192/247] pgraph: fix crash accessing python_tags via dict property Fixes #326 --- panda/src/pgraph/pandaNode_ext.cxx | 30 ++++++++++++++++++++---------- panda/src/pgraph/pandaNode_ext.h | 2 ++ tests/pgraph/test_nodepath.py | 20 ++++++++++++++++++++ 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/panda/src/pgraph/pandaNode_ext.cxx b/panda/src/pgraph/pandaNode_ext.cxx index aa24e623ee..4f0a1b4e8d 100644 --- a/panda/src/pgraph/pandaNode_ext.cxx +++ b/panda/src/pgraph/pandaNode_ext.cxx @@ -94,14 +94,9 @@ get_tag_keys() const { */ PyObject *Extension:: get_python_tags() { - if (_this->_python_tag_data == NULL) { - _this->_python_tag_data = new PythonTagDataImpl; - - } else if (_this->_python_tag_data->get_ref_count() > 1) { - // Copy-on-write. - _this->_python_tag_data = new PythonTagDataImpl(*(PythonTagDataImpl *)_this->_python_tag_data.p()); - } - return ((PythonTagDataImpl *)_this->_python_tag_data.p())->_dict; + PyObject *dict = do_get_python_tags(); + Py_INCREF(dict); + return dict; } /** @@ -116,7 +111,7 @@ get_python_tags() { */ int Extension:: set_python_tag(PyObject *key, PyObject *value) { - return PyDict_SetItem(get_python_tags(), key, value); + return PyDict_SetItem(do_get_python_tags(), key, value); } /** @@ -166,7 +161,7 @@ clear_python_tag(PyObject *key) { return; } - PyObject *dict = get_python_tags(); + PyObject *dict = do_get_python_tags(); if (PyDict_GetItem(dict, key) != NULL) { PyDict_DelItem(dict, key); } @@ -201,6 +196,21 @@ __traverse__(visitproc visit, void *arg) { return 0; } +/** + * Same as get_python_tags, without incrementing the reference count. + */ +PyObject *Extension:: +do_get_python_tags() { + if (_this->_python_tag_data == NULL) { + _this->_python_tag_data = new PythonTagDataImpl; + + } else if (_this->_python_tag_data->get_ref_count() > 1) { + // Copy-on-write. + _this->_python_tag_data = new PythonTagDataImpl(*(PythonTagDataImpl *)_this->_python_tag_data.p()); + } + return ((PythonTagDataImpl *)_this->_python_tag_data.p())->_dict; +} + /** * Destroys the tags associated with the node. */ diff --git a/panda/src/pgraph/pandaNode_ext.h b/panda/src/pgraph/pandaNode_ext.h index 86527d42d4..d19bc5475f 100644 --- a/panda/src/pgraph/pandaNode_ext.h +++ b/panda/src/pgraph/pandaNode_ext.h @@ -45,6 +45,8 @@ public: int __traverse__(visitproc visit, void *arg); private: + PyObject *do_get_python_tags(); + // This is what actually stores the Python tags. class PythonTagDataImpl : public PandaNode::PythonTagData { public: diff --git a/tests/pgraph/test_nodepath.py b/tests/pgraph/test_nodepath.py index d60aa312ba..1b98da32d7 100644 --- a/tests/pgraph/test_nodepath.py +++ b/tests/pgraph/test_nodepath.py @@ -1,3 +1,5 @@ +import pytest, sys + def test_nodepath_empty(): """Tests NodePath behavior for empty NodePaths.""" from panda3d.core import NodePath @@ -103,3 +105,21 @@ def test_weak_nodepath_comparison(): assert hash(path) == hash(weak) assert weak.get_node_path() == path assert weak.node() == path.node() + + +def test_nodepath_python_tags(): + from panda3d.core import NodePath + + path = NodePath("node") + + with pytest.raises(KeyError): + path.python_tags["foo"] + + path.python_tags["foo"] = "bar" + + assert path.python_tags["foo"] == "bar" + + # Make sure reference count stays the same + rc1 = sys.getrefcount(path.python_tags) + rc2 = sys.getrefcount(path.python_tags) + assert rc1 == rc2 From e4c9526e081c58298153516956e0090179ae8c3e Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 26 May 2018 15:17:34 -0600 Subject: [PATCH 193/247] ffmpeg: Make read_packet return AVERROR_EOF Newer versions of FFmpeg deprecate returning 0 to indicate EOF, and instead request use of AVERROR_EOF. The oldest supported versions of FFmpeg/libav will treat any error code the same as returning 0. Fixes #315 --- panda/src/ffmpeg/ffmpegVirtualFile.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/ffmpeg/ffmpegVirtualFile.cxx b/panda/src/ffmpeg/ffmpegVirtualFile.cxx index 0d97f0b5f4..b671ce0ba6 100644 --- a/panda/src/ffmpeg/ffmpegVirtualFile.cxx +++ b/panda/src/ffmpeg/ffmpegVirtualFile.cxx @@ -209,7 +209,7 @@ read_packet(void *opaque, uint8_t *buf, int size) { streampos remaining = self->_start + (streampos)self->_size - in->tellg(); if (remaining < ssize) { if (remaining <= 0) { - return 0; + return AVERROR_EOF; } ssize = remaining; From 339e1ce4d861d15084fd7f099d84a8ec7ba3dd88 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sat, 26 May 2018 18:33:05 -0600 Subject: [PATCH 194/247] tests: Update the datagram tests --- tests/putil/test_datagram.py | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/tests/putil/test_datagram.py b/tests/putil/test_datagram.py index 1349bd5656..47b1432368 100644 --- a/tests/putil/test_datagram.py +++ b/tests/putil/test_datagram.py @@ -96,6 +96,24 @@ def test_iterator(datagram_small): dgi = core.DatagramIterator(dg) verify(dgi) +# This tests the copy constructor: +@pytest.mark.xfail +def test_copy(datagram_small): + dg, verify = datagram_small + + dg2 = core.Datagram(dg) + dgi = core.DatagramIterator(dg2) + verify(dgi) + +@pytest.mark.xfail +def test_assign(datagram_small): + dg, verify = datagram_small + + dg2 = core.Datagram() + dg2.assign(dg) + dgi = core.DatagramIterator(dg2) + verify(dgi) + # These test DatagramInputFile/DatagramOutputFile: @@ -147,10 +165,10 @@ def test_file_corrupt(datagram_small, tmpdir): dof.put_datagram(dg) dof.close() - # Corrupt the size header to 4GB - with p.open(mode='wb') as f: + # Corrupt the size header to 1GB + with p.open(mode='r+b') as f: f.seek(0) - f.write(b'\xFF\xFF\xFF\xFF') + f.write(b'\xFF\xFF\xFF\x4F') dg2 = core.Datagram() dif = core.DatagramInputFile() @@ -158,4 +176,15 @@ def test_file_corrupt(datagram_small, tmpdir): assert not dif.get_datagram(dg2) dif.close() + # Truncate the file + for size in [12, 8, 4, 3, 2, 1, 0]: + with p.open(mode='r+b') as f: + f.truncate(size) + + dg2 = core.Datagram() + dif = core.DatagramInputFile() + dif.open(filename) + assert not dif.get_datagram(dg2) + dif.close() + # Should we test that dg2 is unmodified? From 35ab16d38f66aa2083a74e1d8dedea7cb21953a4 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 24 May 2018 14:57:09 -0600 Subject: [PATCH 195/247] makepanda: Update checkPandaVersion.h This makes it possible to include it multiple times in a single translation unit, and/or multiple times in a single dynamic library (and without excess code bloat, too). --- makepanda/makepanda.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 9f0f1d928e..ef37ac1964 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2606,18 +2606,21 @@ PANDAVERSION_H_RUNTIME=""" CHECKPANDAVERSION_CXX=""" # include "dtoolbase.h" -EXPCL_DTOOL_DTOOLUTIL int panda_version_$VERSION1_$VERSION2 = 0; +EXPCL_DTOOL_DTOOLBASE int panda_version_$VERSION1_$VERSION2 = 0; """ CHECKPANDAVERSION_H=""" +# ifndef CHECKPANDAVERSION_H +# define CHECKPANDAVERSION_H # include "dtoolbase.h" -extern EXPCL_DTOOL_DTOOLUTIL int panda_version_$VERSION1_$VERSION2; -# ifndef WIN32 -/* For Windows, exporting the symbol from the DLL is sufficient; the - DLL will not load unless all expected public symbols are defined. - Other systems may not mind if the symbol is absent unless we - explictly write code that references it. */ -static int check_panda_version = panda_version_$VERSION1_$VERSION2; +extern EXPCL_DTOOL_DTOOLBASE int panda_version_$VERSION1_$VERSION2; +// Hack to forcibly depend on the check +template +class CheckPandaVersion { +public: + int check() { return panda_version_$VERSION1_$VERSION2; } +}; +template class CheckPandaVersion; # endif """ From 0ce9dc98b1d5abf05abd31cb53cb2e1e5eab1665 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 24 May 2018 15:01:35 -0600 Subject: [PATCH 196/247] general: Move inclusion of checkPandaVersion.h to dtoolbase This includes it everywhere, meaning developers no longer must remember to include it in each metalib init file. --- dtool/src/dtoolbase/dtoolbase_cc.h | 7 +++++++ panda/metalibs/panda/panda.cxx | 6 ------ panda/metalibs/pandabullet/pandabullet.cxx | 6 ------ panda/metalibs/pandadx9/pandadx9.cxx | 6 ------ panda/metalibs/pandaegg/pandaegg.cxx | 6 ------ panda/metalibs/pandaegg/pandaeggnopg.cxx | 6 ------ panda/metalibs/pandaexpress/pandaexpress.cxx | 6 ------ panda/metalibs/pandafx/pandafx.cxx | 6 ------ panda/metalibs/pandagl/pandagl.cxx | 6 ------ panda/metalibs/pandagles/pandagles.cxx | 6 ------ panda/metalibs/pandagles2/pandagles2.cxx | 6 ------ panda/metalibs/pandaode/pandaode.cxx | 6 ------ panda/metalibs/pandaphysics/pandaphysics.cxx | 6 ------ panda/metalibs/pandaphysx/pandaphysx.cxx | 6 ------ panda/src/android/pview.cxx | 6 ------ panda/src/framework/config_framework.cxx | 6 ------ panda/src/testbed/pview.cxx | 6 ------ 17 files changed, 7 insertions(+), 96 deletions(-) diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index 491bd92c22..98bf992cf9 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -19,6 +19,13 @@ #ifdef __cplusplus +// By including checkPandaVersion.h, we guarantee that runtime attempts to +// load any DLL will fail if they inadvertently link with the wrong version of +// dtool, which, transitively, means all DLLs must be from the same +// (ABI-compatible) version of Panda. + +#include "checkPandaVersion.h" + #ifdef USE_TAU // Tau provides this destructive version of stdbool.h that we must mask. #define __PDT_STDBOOL_H_ diff --git a/panda/metalibs/panda/panda.cxx b/panda/metalibs/panda/panda.cxx index 8a193a8a28..9c9cb8bb60 100644 --- a/panda/metalibs/panda/panda.cxx +++ b/panda/metalibs/panda/panda.cxx @@ -14,12 +14,6 @@ #include "config_pstatclient.h" #endif -// By including checkPandaVersion.h, we guarantee that runtime attempts to -// load libpanda.so.dll will fail if they inadvertently link with the wrong -// version of libdtool.so.dll. - -#include "checkPandaVersion.h" - #if !defined(CPPPARSER) && !defined(BUILDING_LIBPANDA) #error Buildsystem error: BUILDING_LIBPANDA not defined #endif diff --git a/panda/metalibs/pandabullet/pandabullet.cxx b/panda/metalibs/pandabullet/pandabullet.cxx index 4eaa6fcd04..588d47266e 100644 --- a/panda/metalibs/pandabullet/pandabullet.cxx +++ b/panda/metalibs/pandabullet/pandabullet.cxx @@ -7,12 +7,6 @@ #include "pandabullet.h" #include "config_bullet.h" -// By including checkPandaVersion.h, we guarantee that runtime attempts to -// load libpandabullet.so.dll will fail if they inadvertently link with the -// wrong version of libdtool.so.dll. - -#include "checkPandaVersion.h" - /** * Initializes the library. This must be called at least once before any of * the functions or classes in this library can be used. Normally it will be diff --git a/panda/metalibs/pandadx9/pandadx9.cxx b/panda/metalibs/pandadx9/pandadx9.cxx index 8953365225..a54bb7dbf2 100644 --- a/panda/metalibs/pandadx9/pandadx9.cxx +++ b/panda/metalibs/pandadx9/pandadx9.cxx @@ -9,12 +9,6 @@ #include "config_dxgsg9.h" #include "wdxGraphicsPipe9.h" -// By including checkPandaVersion.h, we guarantee that runtime attempts to -// load libpandadx9.dll will fail if they inadvertently link with the wrong -// version of libdtool.dll. - -#include "checkPandaVersion.h" - /** * Initializes the library. This must be called at least once before any of * the functions or classes in this library can be used. Normally it will be diff --git a/panda/metalibs/pandaegg/pandaegg.cxx b/panda/metalibs/pandaegg/pandaegg.cxx index 7bb592e488..235dc62a5b 100644 --- a/panda/metalibs/pandaegg/pandaegg.cxx +++ b/panda/metalibs/pandaegg/pandaegg.cxx @@ -9,12 +9,6 @@ #include "config_egg.h" #include "config_egg2pg.h" -// By including checkPandaVersion.h, we guarantee that runtime attempts to -// load libpandaegg.so.dll will fail if they inadvertently link with the wrong -// version of libdtool.so.dll. - -#include "checkPandaVersion.h" - /** * Initializes the library. This must be called at least once before any of * the functions or classes in this library can be used. Normally it will be diff --git a/panda/metalibs/pandaegg/pandaeggnopg.cxx b/panda/metalibs/pandaegg/pandaeggnopg.cxx index 1b72143237..2a5c86fead 100644 --- a/panda/metalibs/pandaegg/pandaeggnopg.cxx +++ b/panda/metalibs/pandaegg/pandaeggnopg.cxx @@ -8,12 +8,6 @@ #include "config_egg.h" -// By including checkPandaVersion.h, we guarantee that runtime attempts to -// load libpandaegg.so.dll will fail if they inadvertently link with the wrong -// version of libdtool.so.dll. - -#include "checkPandaVersion.h" - /** * Initializes the library. This must be called at least once before any of * the functions or classes in this library can be used. Normally it will be diff --git a/panda/metalibs/pandaexpress/pandaexpress.cxx b/panda/metalibs/pandaexpress/pandaexpress.cxx index 6c6adc0e77..d50aead132 100644 --- a/panda/metalibs/pandaexpress/pandaexpress.cxx +++ b/panda/metalibs/pandaexpress/pandaexpress.cxx @@ -3,9 +3,3 @@ * @author drose * @date 2000-05-15 */ - -// By including checkPandaVersion.h, we guarantee that runtime attempts to -// load libpandaexpress.so.dll will fail if they inadvertently link with the -// wrong version of libdtool.so.dll. - -#include "checkPandaVersion.h" diff --git a/panda/metalibs/pandafx/pandafx.cxx b/panda/metalibs/pandafx/pandafx.cxx index 968ab2f285..64f4a3abd8 100644 --- a/panda/metalibs/pandafx/pandafx.cxx +++ b/panda/metalibs/pandafx/pandafx.cxx @@ -8,12 +8,6 @@ #include "config_distort.h" -// By including checkPandaVersion.h, we guarantee that runtime attempts to -// load libpandafx.so.dll will fail if they inadvertently link with the wrong -// version of libdtool.so.dll. - -#include "checkPandaVersion.h" - /** * Initializes the library. This must be called at least once before any of * the functions or classes in this library can be used. Normally it will be diff --git a/panda/metalibs/pandagl/pandagl.cxx b/panda/metalibs/pandagl/pandagl.cxx index 71b6e83025..0e33961c9f 100644 --- a/panda/metalibs/pandagl/pandagl.cxx +++ b/panda/metalibs/pandagl/pandagl.cxx @@ -30,12 +30,6 @@ #error One of HAVE_WGL, HAVE_COCOA, HAVE_CARBON or HAVE_GLX must be defined when compiling pandagl! #endif -// By including checkPandaVersion.h, we guarantee that runtime attempts to -// load libpandagl.so.dll will fail if they inadvertently link with the wrong -// version of libdtool.so.dll. - -#include "checkPandaVersion.h" - /** * Initializes the library. This must be called at least once before any of * the functions or classes in this library can be used. Normally it will be diff --git a/panda/metalibs/pandagles/pandagles.cxx b/panda/metalibs/pandagles/pandagles.cxx index 27053534c6..f2ed5f3e1a 100644 --- a/panda/metalibs/pandagles/pandagles.cxx +++ b/panda/metalibs/pandagles/pandagles.cxx @@ -17,12 +17,6 @@ #include "eglGraphicsPipe.h" #endif -// By including checkPandaVersion.h, we guarantee that runtime attempts to -// load libpandagles.so.dll will fail if they inadvertently link with the -// wrong version of libdtool.so.dll. - -#include "checkPandaVersion.h" - /** * Initializes the library. This must be called at least once before any of * the functions or classes in this library can be used. Normally it will be diff --git a/panda/metalibs/pandagles2/pandagles2.cxx b/panda/metalibs/pandagles2/pandagles2.cxx index 4810bd60af..b0b36c63ff 100644 --- a/panda/metalibs/pandagles2/pandagles2.cxx +++ b/panda/metalibs/pandagles2/pandagles2.cxx @@ -12,12 +12,6 @@ #include "config_egldisplay.h" #include "eglGraphicsPipe.h" -// By including checkPandaVersion.h, we guarantee that runtime attempts to -// load libpandagles2.so.dll will fail if they inadvertently link with the -// wrong version of libdtool.so.dll. - -#include "checkPandaVersion.h" - /** * Initializes the library. This must be called at least once before any of * the functions or classes in this library can be used. Normally it will be diff --git a/panda/metalibs/pandaode/pandaode.cxx b/panda/metalibs/pandaode/pandaode.cxx index 583b9c3a9d..2b19c71e3b 100644 --- a/panda/metalibs/pandaode/pandaode.cxx +++ b/panda/metalibs/pandaode/pandaode.cxx @@ -7,12 +7,6 @@ #include "pandaode.h" #include "config_ode.h" -// By including checkPandaVersion.h, we guarantee that runtime attempts to -// load libpandaode.so.dll will fail if they inadvertently link with the wrong -// version of libdtool.so.dll. - -#include "checkPandaVersion.h" - /** * Initializes the library. This must be called at least once before any of * the functions or classes in this library can be used. Normally it will be diff --git a/panda/metalibs/pandaphysics/pandaphysics.cxx b/panda/metalibs/pandaphysics/pandaphysics.cxx index 890d450d47..02997a1505 100644 --- a/panda/metalibs/pandaphysics/pandaphysics.cxx +++ b/panda/metalibs/pandaphysics/pandaphysics.cxx @@ -8,12 +8,6 @@ #include "config_physics.h" #include "config_particlesystem.h" -// By including checkPandaVersion.h, we guarantee that runtime attempts to -// load libpandaphysics.so.dll will fail if they inadvertently link with the -// wrong version of libdtool.so.dll. - -#include "checkPandaVersion.h" - /** * Initializes the library. This must be called at least once before any of * the functions or classes in this library can be used. Normally it will be diff --git a/panda/metalibs/pandaphysx/pandaphysx.cxx b/panda/metalibs/pandaphysx/pandaphysx.cxx index fd75ee86b5..3e505f1d7d 100644 --- a/panda/metalibs/pandaphysx/pandaphysx.cxx +++ b/panda/metalibs/pandaphysx/pandaphysx.cxx @@ -7,12 +7,6 @@ #include "pandaphysx.h" #include "config_physx.h" -// By including checkPandaVersion.h, we guarantee that runtime attempts to -// load libpandaphysx.so.dll will fail if they inadvertently link with the -// wrong version of libdtool.so.dll. - -#include "checkPandaVersion.h" - /** * Initializes the library. This must be called at least once before any of * the functions or classes in this library can be used. Normally it will be diff --git a/panda/src/android/pview.cxx b/panda/src/android/pview.cxx index 2b31bb7577..6683b6206b 100644 --- a/panda/src/android/pview.cxx +++ b/panda/src/android/pview.cxx @@ -21,12 +21,6 @@ #include "bamCache.h" #include "virtualFileSystem.h" -// By including checkPandaVersion.h, we guarantee that runtime attempts to run -// pview will fail if it inadvertently links with the wrong version of -// libdtool.so.dll. - -#include "checkPandaVersion.h" - int main(int argc, char **argv) { PandaFramework framework; framework.open_framework(argc, argv); diff --git a/panda/src/framework/config_framework.cxx b/panda/src/framework/config_framework.cxx index 8746d5bff0..4ddc4b553a 100644 --- a/panda/src/framework/config_framework.cxx +++ b/panda/src/framework/config_framework.cxx @@ -16,12 +16,6 @@ #include "dconfig.h" #include "windowFramework.h" -// By including checkPandaVersion.h, we guarantee that runtime attempts to -// load libframework.so.dll will fail if they inadvertently link with the -// wrong version of libdtool.so.dll. - -#include "checkPandaVersion.h" - #if !defined(CPPPARSER) && !defined(BUILDING_FRAMEWORK) #error Buildsystem error: BUILDING_FRAMEWORK not defined #endif diff --git a/panda/src/testbed/pview.cxx b/panda/src/testbed/pview.cxx index 6d68f099ab..b5bb629b0c 100644 --- a/panda/src/testbed/pview.cxx +++ b/panda/src/testbed/pview.cxx @@ -29,12 +29,6 @@ #include "asyncTask.h" #include "boundingSphere.h" -// By including checkPandaVersion.h, we guarantee that runtime attempts to run -// pview will fail if it inadvertently links with the wrong version of -// libdtool.so.dll. - -#include "checkPandaVersion.h" - PandaFramework framework; ConfigVariableBool pview_test_hack From 0de981d0b8a6b88536fb165a136924c1cc453db0 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 27 May 2018 12:59:41 +0200 Subject: [PATCH 197/247] ai: make AICharacter reference counted This lets one drop the reference to AICharacter after adding it to a flock or AIWorld without crashes. Also replace the silly and inefficient custom-rolled linked list implementation of AICharPool with a vector, and add additional safety checks. Fixes #318 --- contrib/src/ai/aiCharacter.cxx | 3 + contrib/src/ai/aiCharacter.h | 3 +- contrib/src/ai/aiWorld.cxx | 130 ++++++++------------------------- contrib/src/ai/aiWorld.h | 24 +----- contrib/src/ai/flock.h | 2 +- 5 files changed, 37 insertions(+), 125 deletions(-) diff --git a/contrib/src/ai/aiCharacter.cxx b/contrib/src/ai/aiCharacter.cxx index 7009a353f1..240f1a4ea3 100644 --- a/contrib/src/ai/aiCharacter.cxx +++ b/contrib/src/ai/aiCharacter.cxx @@ -24,6 +24,8 @@ AICharacter::AICharacter(string model_name, NodePath model_np, double mass, doub _velocity = LVecBase3(0.0, 0.0, 0.0); _steering_force = LVecBase3(0.0, 0.0, 0.0); + _world = nullptr; + _steering = new AIBehaviors(); _steering->_ai_char = this; @@ -31,6 +33,7 @@ AICharacter::AICharacter(string model_name, NodePath model_np, double mass, doub } AICharacter::~AICharacter() { + nassertv(_world == nullptr); } /** diff --git a/contrib/src/ai/aiCharacter.h b/contrib/src/ai/aiCharacter.h index 244f9bc45e..30adf21ced 100644 --- a/contrib/src/ai/aiCharacter.h +++ b/contrib/src/ai/aiCharacter.h @@ -15,6 +15,7 @@ #define _AICHARACTER_H #include "aiBehaviors.h" +#include "referenceCount.h" /** * This class is used for creating the AI characters. It assigns both physics @@ -25,7 +26,7 @@ class AIBehaviors; class AIWorld; -class EXPCL_PANDAAI AICharacter { +class EXPCL_PANDAAI AICharacter : public ReferenceCount { public: double _mass; double _max_force; diff --git a/contrib/src/ai/aiWorld.cxx b/contrib/src/ai/aiWorld.cxx index 6abac9f990..8210046497 100644 --- a/contrib/src/ai/aiWorld.cxx +++ b/contrib/src/ai/aiWorld.cxx @@ -14,44 +14,56 @@ #include "aiWorld.h" AIWorld::AIWorld(NodePath render) { - _ai_char_pool = new AICharPool(); - _render = render; + _render = move(render); } AIWorld::~AIWorld() { } void AIWorld::add_ai_char(AICharacter *ai_char) { - _ai_char_pool->append(ai_char); + _ai_char_pool.push_back(ai_char); ai_char->_window_render = _render; ai_char->_world = this; } void AIWorld::remove_ai_char(string name) { - _ai_char_pool->del(name); - remove_ai_char_from_flock(name); + AICharPool::iterator it; + for (it = _ai_char_pool.begin(); it != _ai_char_pool.end(); ++it) { + AICharacter *ai_char = *it; + if (ai_char->_name == name) { + nassertv(ai_char->_world == this); + ai_char->_world = nullptr; + _ai_char_pool.erase(it); + break; + } + } + + remove_ai_char_from_flock(move(name)); } void AIWorld::remove_ai_char_from_flock(string name) { - AICharPool::node *ai_pool; - ai_pool = _ai_char_pool->_head; - while((ai_pool) != NULL) { - for(unsigned int i = 0; i < _flock_pool.size(); ++i) { - if(ai_pool->_ai_char->_ai_char_flock_id == _flock_pool[i]->get_id()) { - for(unsigned int j = 0; j<_flock_pool[i]->_ai_char_list.size(); ++j) { - if(_flock_pool[i]->_ai_char_list[j]->_name == name) { - _flock_pool[i]->_ai_char_list.erase(_flock_pool[i]->_ai_char_list.begin() + j); + for (AICharacter *ai_char : _ai_char_pool) { + for (Flock *flock : _flock_pool) { + if (ai_char->_ai_char_flock_id == flock->get_id()) { + for (size_t j = 0; j < flock->_ai_char_list.size(); ++j) { + if (flock->_ai_char_list[j]->_name == name) { + flock->_ai_char_list.erase(flock->_ai_char_list.begin() + j); return; } } } } - ai_pool = ai_pool->_next; } } +/** + * This function prints the names of the AI characters that have been added to + * the AIWorld. Useful for debugging purposes. + */ void AIWorld::print_list() { - _ai_char_pool->print_list(); + for (AICharacter *ai_char : _ai_char_pool) { + cout << ai_char->_name << endl; + } } /** @@ -59,12 +71,8 @@ void AIWorld::print_list() { * characters which have been added to the AIWorld. */ void AIWorld::update() { - AICharPool::node *ai_pool; - ai_pool = _ai_char_pool->_head; - - while((ai_pool)!=NULL) { - ai_pool->_ai_char->update(); - ai_pool = ai_pool->_next; + for (AICharacter *ai_char : _ai_char_pool) { + ai_char->update(); } } @@ -142,86 +150,6 @@ void AIWorld::flock_on(unsigned int flock_id) { } } -AICharPool::AICharPool() { - _head = NULL; -} - -AICharPool::~AICharPool() { -} - -void AICharPool::append(AICharacter *ai_ch) { - node *q; - node *t; - - if(_head == NULL) { - q = new node(); - q->_ai_char = ai_ch; - q->_next = NULL; - _head = q; - } - else { - q = _head; - while( q->_next != NULL) { - q = q->_next; - } - - t = new node(); - t->_ai_char = ai_ch; - t->_next = NULL; - q->_next = t; - } -} - -void AICharPool::del(string name) { - node *q; - node *r; - q = _head; - - if(_head==NULL) { - return; - } - - // Only one node in the linked list - if(q->_next == NULL) { - if(q->_ai_char->_name == name) { - _head = NULL; - delete q; - } - return; - } - - r = q; - while( q != NULL) { - if( q->_ai_char->_name == name) { - // Special case - if(q == _head) { - _head = q->_next; - delete q; - return; - } - - r->_next = q->_next; - delete q; - return; - } - r = q; - q = q->_next; - } -} - -/** - * This function prints the ai characters in the AICharPool. Used for - * debugging purposes. - */ -void AICharPool::print_list() { - node* q; - q = _head; - while(q != NULL) { - cout<_ai_char->_name<_next; - } -} - /** * This function adds the nodepath as an obstacle that is needed by the * obstacle avoidance behavior. diff --git a/contrib/src/ai/aiWorld.h b/contrib/src/ai/aiWorld.h index f85e1dc584..64cecefc2d 100644 --- a/contrib/src/ai/aiWorld.h +++ b/contrib/src/ai/aiWorld.h @@ -21,27 +21,6 @@ class AICharacter; class Flock; -/** - * This class implements a linked list of AI Characters allowing the user to - * add and delete characters from the linked list. This will be used in the - * AIWorld class. - */ -class EXPCL_PANDAAI AICharPool { - public: - struct node { - AICharacter * _ai_char; - node * _next; - } ; - - node* _head; - AICharPool(); - ~AICharPool(); - void append(AICharacter *ai_ch); - void del(string name); - void print_list(); -}; - - /** * A class that implements the virtual AI world which keeps track of the AI * characters active at any given time. It contains a linked list of AI @@ -51,7 +30,8 @@ class EXPCL_PANDAAI AICharPool { */ class EXPCL_PANDAAI AIWorld { private: - AICharPool * _ai_char_pool; + typedef std::vector AICharPool; + AICharPool _ai_char_pool; NodePath _render; public: vector _obstacles; diff --git a/contrib/src/ai/flock.h b/contrib/src/ai/flock.h index c5e508a837..c353781890 100644 --- a/contrib/src/ai/flock.h +++ b/contrib/src/ai/flock.h @@ -40,7 +40,7 @@ public: unsigned int _alignment_wt; // This vector will hold all the ai characters which belong to this flock. - typedef std::vector AICharList; + typedef std::vector AICharList; AICharList _ai_char_list; PUBLISHED: From f2d429b81745e475609f1e981c1dac5ec513acc3 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 27 May 2018 13:06:57 +0200 Subject: [PATCH 198/247] express: weakptr.lock() should return null during object destruction This came up in #330; the Character destructor caused something to call lock() on a weak pointer to that character, which would induce a ref() and unref() pair, but since the refcount was 0, this would call the destructor and thereby create infinite recursion. I considered instead calling mark_deleted() inside unref() so that the callbacks get to run before the object is actually deleted, and was_deleted() will become true as soon as unref() reaches 0. However, this would require grabbing the lock in unref() to be fully thread-safe, since we would need to bring the refcount to 0 and mark the object as deleted in one atomic operation, so this would be an unacceptable general performance penalty. Instead, WeakPointerTo::lock() now atomically increments the reference count if it is not already zero, and returns null otherwise. This should be safe because the object cannot be deleted while the WeakReferenceList lock is held. --- panda/src/express/referenceCount.I | 21 +++++++++++++++++++++ panda/src/express/referenceCount.h | 2 ++ panda/src/express/weakPointerTo.I | 19 +++++++++++++++++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/panda/src/express/referenceCount.I b/panda/src/express/referenceCount.I index 3a05a68766..f18c60a02c 100644 --- a/panda/src/express/referenceCount.I +++ b/panda/src/express/referenceCount.I @@ -300,6 +300,27 @@ weak_unref() { nassertv(nonzero); } +/** + * Atomically increases the reference count of this object if it is not zero. + * Do not use this. This exists only to implement a special case for weak + * pointers. + * @return true if the reference count was incremented, false if it was zero. + */ +INLINE bool ReferenceCount:: +ref_if_nonzero() const { +#ifdef _DEBUG + test_ref_count_integrity(); +#endif + AtomicAdjust::Integer ref_count; + do { + ref_count = AtomicAdjust::get(_ref_count); + if (ref_count <= 0) { + return false; + } + } while (ref_count != AtomicAdjust::compare_and_exchange(_ref_count, ref_count, ref_count + 1)); + return true; +} + /** * This global helper function will unref the given ReferenceCount object, and * if the reference count reaches zero, automatically delete it. It can't be diff --git a/panda/src/express/referenceCount.h b/panda/src/express/referenceCount.h index 2260cf2e8c..ba27ac7db8 100644 --- a/panda/src/express/referenceCount.h +++ b/panda/src/express/referenceCount.h @@ -63,6 +63,8 @@ public: INLINE WeakReferenceList *weak_ref(); INLINE void weak_unref(); + INLINE bool ref_if_nonzero() const; + protected: bool do_test_ref_count_integrity() const; bool do_test_ref_count_nonzero() const; diff --git a/panda/src/express/weakPointerTo.I b/panda/src/express/weakPointerTo.I index 09dba7640b..60ac8a1917 100644 --- a/panda/src/express/weakPointerTo.I +++ b/panda/src/express/weakPointerTo.I @@ -75,6 +75,9 @@ operator T * () const { /** * A thread-safe way to access the underlying pointer; will silently return * null if the underlying pointer was deleted or null. + * Note that this may return null even if was_deleted() still returns true, + * which can occur if the object has reached reference count 0 and is about to + * be destroyed. */ template INLINE PointerTo WeakPointerTo:: @@ -84,7 +87,13 @@ lock() const { PointerTo ptr; weak_ref->_lock.lock(); if (!weak_ref->was_deleted()) { - ptr = (To *)WeakPointerToBase::_void_ptr; + // We also need to check that the reference count is not zero (which can + // happen if the object is currently being destructed), since that could + // cause double deletion. + To *plain_ptr = (To *)WeakPointerToBase::_void_ptr; + if (plain_ptr != nullptr && plain_ptr->ref_if_nonzero()) { + ptr.cheat() = plain_ptr; + } } weak_ref->_lock.unlock(); return ptr; @@ -239,7 +248,13 @@ lock() const { ConstPointerTo ptr; weak_ref->_lock.lock(); if (!weak_ref->was_deleted()) { - ptr = (const To *)WeakPointerToBase::_void_ptr; + // We also need to check that the reference count is not zero (which can + // happen if the object is currently being destructed), since that could + // cause double deletion. + const To *plain_ptr = (const To *)WeakPointerToBase::_void_ptr; + if (plain_ptr != nullptr && plain_ptr->ref_if_nonzero()) { + ptr.cheat() = plain_ptr; + } } weak_ref->_lock.unlock(); return ptr; From 3d49986ce26652871847594de2592f1452f5536d Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 27 May 2018 15:37:45 +0200 Subject: [PATCH 199/247] char: fix crash during Character destructor (regression) This was a regression in 0bb81a43c9e4fffb37cc2234c1b0fbae42020ceb which was not keeping an edge case in mind if a weak pointer is locked during object destruction. This issue was fixed by 525a05ea2b1d00a1db901f883f1755943aeff33c, but that is not enough since it causes CharacterJointEffect::get_character() to return null now, so we need a separate method to check if a CharacterJointEffect belongs to a given character. This is more efficient, too. Fixes #330 --- panda/src/char/characterJoint.cxx | 12 ++++++------ panda/src/char/characterJointEffect.I | 10 ++++++++++ panda/src/char/characterJointEffect.h | 2 ++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/panda/src/char/characterJoint.cxx b/panda/src/char/characterJoint.cxx index 6ce5b0be88..fee1a90f76 100644 --- a/panda/src/char/characterJoint.cxx +++ b/panda/src/char/characterJoint.cxx @@ -214,7 +214,7 @@ bool CharacterJoint:: remove_net_transform(PandaNode *node) { CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); if (effect != (RenderEffect *)NULL && - DCAST(CharacterJointEffect, effect)->get_character() == _character) { + DCAST(CharacterJointEffect, effect)->matches_character(_character)) { node->clear_effect(CharacterJointEffect::get_class_type()); } @@ -244,7 +244,7 @@ clear_net_transforms() { CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); if (effect != (RenderEffect *)NULL && - DCAST(CharacterJointEffect, effect)->get_character() == _character) { + DCAST(CharacterJointEffect, effect)->matches_character(_character)) { node->clear_effect(CharacterJointEffect::get_class_type()); } } @@ -306,7 +306,7 @@ bool CharacterJoint:: remove_local_transform(PandaNode *node) { CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); if (effect != (RenderEffect *)NULL && - DCAST(CharacterJointEffect, effect)->get_character() == _character) { + DCAST(CharacterJointEffect, effect)->matches_character(_character)) { node->clear_effect(CharacterJointEffect::get_class_type()); } @@ -336,7 +336,7 @@ clear_local_transforms() { CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); if (effect != (RenderEffect *)NULL && - DCAST(CharacterJointEffect, effect)->get_character() == _character) { + DCAST(CharacterJointEffect, effect)->matches_character(_character)) { node->clear_effect(CharacterJointEffect::get_class_type()); } } @@ -427,7 +427,7 @@ set_character(Character *character) { CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); if (effect != (RenderEffect *)NULL && - DCAST(CharacterJointEffect, effect)->get_character() == _character) { + DCAST(CharacterJointEffect, effect)->matches_character(_character)) { node->clear_effect(CharacterJointEffect::get_class_type()); } } @@ -438,7 +438,7 @@ set_character(Character *character) { CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); if (effect != (RenderEffect *)NULL && - DCAST(CharacterJointEffect, effect)->get_character() == _character) { + DCAST(CharacterJointEffect, effect)->matches_character(_character)) { node->clear_effect(CharacterJointEffect::get_class_type()); } } diff --git a/panda/src/char/characterJointEffect.I b/panda/src/char/characterJointEffect.I index c63c90d1a7..e4d596dafe 100644 --- a/panda/src/char/characterJointEffect.I +++ b/panda/src/char/characterJointEffect.I @@ -27,3 +27,13 @@ INLINE PT(Character) CharacterJointEffect:: get_character() const { return _character.lock(); } + +/** + * Returns true if this CharacterJointEffect contains the given Character. + * This exists because it is faster to check than get_character() and can even + * be called while the Character is destructing. + */ +INLINE bool CharacterJointEffect:: +matches_character(Character *character) const { + return _character == character; +} diff --git a/panda/src/char/characterJointEffect.h b/panda/src/char/characterJointEffect.h index d06ca802fb..372013df54 100644 --- a/panda/src/char/characterJointEffect.h +++ b/panda/src/char/characterJointEffect.h @@ -41,6 +41,8 @@ PUBLISHED: INLINE PT(Character) get_character() const; public: + INLINE bool matches_character(Character *character) const; + virtual bool safe_to_transform() const; virtual bool safe_to_combine() const; virtual void output(ostream &out) const; From 8d84c58d73fa3a7b781aa6070c931d20538929ec Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 27 May 2018 15:38:19 +0200 Subject: [PATCH 200/247] express: explicitly declare defaulted Datagram copy/move ctor/assign Fixes #329 --- panda/src/express/datagram.h | 6 +++++- tests/putil/test_datagram.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/panda/src/express/datagram.h b/panda/src/express/datagram.h index 00a46ef36f..7cf50368fc 100644 --- a/panda/src/express/datagram.h +++ b/panda/src/express/datagram.h @@ -40,9 +40,13 @@ PUBLISHED: INLINE Datagram(); INLINE Datagram(const void *data, size_t size); INLINE explicit Datagram(vector_uchar data); - + Datagram(const Datagram ©) = default; + Datagram(Datagram &&from) noexcept = default; virtual ~Datagram(); + Datagram &operator = (const Datagram ©) = default; + Datagram &operator = (Datagram &&from) noexcept = default; + virtual void clear(); void dump_hex(ostream &out, unsigned int indent=0) const; diff --git a/tests/putil/test_datagram.py b/tests/putil/test_datagram.py index 47b1432368..171363109a 100644 --- a/tests/putil/test_datagram.py +++ b/tests/putil/test_datagram.py @@ -96,8 +96,8 @@ def test_iterator(datagram_small): dgi = core.DatagramIterator(dg) verify(dgi) + # This tests the copy constructor: -@pytest.mark.xfail def test_copy(datagram_small): dg, verify = datagram_small @@ -105,7 +105,7 @@ def test_copy(datagram_small): dgi = core.DatagramIterator(dg2) verify(dgi) -@pytest.mark.xfail + def test_assign(datagram_small): dg, verify = datagram_small From 239f66cf1144d866c4d12c1cf483b5e4055982ef Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 27 May 2018 15:39:02 +0200 Subject: [PATCH 201/247] makepanda: fix macOS compile error in CheckPandaVersion See #327 --- makepanda/makepanda.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index ef37ac1964..fdfd682ff4 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2618,7 +2618,7 @@ extern EXPCL_DTOOL_DTOOLBASE int panda_version_$VERSION1_$VERSION2; template class CheckPandaVersion { public: - int check() { return panda_version_$VERSION1_$VERSION2; } + int check_version() { return panda_version_$VERSION1_$VERSION2; } }; template class CheckPandaVersion; # endif From 24c8ef988710484d96a26d5db87dfc49c30885d0 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 27 May 2018 13:08:34 -0600 Subject: [PATCH 202/247] general: Fix missing include --- panda/src/express/weakPointerToVoid.h | 1 + 1 file changed, 1 insertion(+) diff --git a/panda/src/express/weakPointerToVoid.h b/panda/src/express/weakPointerToVoid.h index 5ac1049fe3..5b130463e6 100644 --- a/panda/src/express/weakPointerToVoid.h +++ b/panda/src/express/weakPointerToVoid.h @@ -17,6 +17,7 @@ #include "pandabase.h" #include "pointerToVoid.h" #include "weakPointerCallback.h" +#include "weakReferenceList.h" /** * This is the specialization of PointerToVoid for weak pointers. It needs an From a251c6dd8fcd2770e9f0bcc694a70dbac594668f Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 27 May 2018 13:51:48 -0600 Subject: [PATCH 203/247] general: Change HAVE_LOCKF to PHAVE_LOCKF HAVE_LOCKF is already defined by pyconfig.h in (at least) Python 3.6 - changing the macro name here avoids warnings --- dtool/src/dtoolutil/filename.cxx | 6 +++--- makepanda/makepanda.py | 4 ++-- panda/src/gobj/vertexDataSaveFile.cxx | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dtool/src/dtoolutil/filename.cxx b/dtool/src/dtoolutil/filename.cxx index d2c566b557..42bdf12e2f 100644 --- a/dtool/src/dtoolutil/filename.cxx +++ b/dtool/src/dtoolutil/filename.cxx @@ -48,7 +48,7 @@ #include #endif -#if defined(__ANDROID__) && !defined(HAVE_LOCKF) +#if defined(__ANDROID__) && !defined(PHAVE_LOCKF) // Needed for flock. #include #endif @@ -2752,7 +2752,7 @@ atomic_compare_and_exchange_contents(string &orig_contents, orig_contents = string(); -#ifdef HAVE_LOCKF +#ifdef PHAVE_LOCKF if (lockf(fd, F_LOCK, 0) != 0) { #else if (flock(fd, LOCK_EX) != 0) { @@ -2868,7 +2868,7 @@ atomic_read_contents(string &contents) const { contents = string(); -#ifdef HAVE_LOCKF +#ifdef PHAVE_LOCKF if (lockf(fd, F_LOCK, 0) != 0) { #else if (flock(fd, LOCK_EX) != 0) { diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index fdfd682ff4..a810da13af 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2268,7 +2268,7 @@ DTOOL_CONFIG=[ ("DEFAULT_PATHSEP", '";"', '":"'), ("WORDS_BIGENDIAN", 'UNDEF', 'UNDEF'), ("HAVE_OPEN_MASK", 'UNDEF', 'UNDEF'), - ("HAVE_LOCKF", '1', '1'), + ("PHAVE_LOCKF", '1', '1'), ("HAVE_WCHAR_T", '1', '1'), ("HAVE_WSTRING", '1', '1'), ("SIMPLE_STRUCT_POINTERS", '1', 'UNDEF'), @@ -2445,7 +2445,7 @@ def WriteConfigSettings(): # Android does have RTTI, but we disable it anyway. dtool_config["HAVE_RTTI"] = 'UNDEF' dtool_config["PHAVE_GLOB_H"] = 'UNDEF' - dtool_config["HAVE_LOCKF"] = 'UNDEF' + dtool_config["PHAVE_LOCKF"] = 'UNDEF' dtool_config["HAVE_VIDEO4LINUX"] = 'UNDEF' if (GetOptimize() <= 2 and GetTarget() == "windows"): diff --git a/panda/src/gobj/vertexDataSaveFile.cxx b/panda/src/gobj/vertexDataSaveFile.cxx index fd7087ba5d..e602b51129 100644 --- a/panda/src/gobj/vertexDataSaveFile.cxx +++ b/panda/src/gobj/vertexDataSaveFile.cxx @@ -23,7 +23,7 @@ #include #endif // _WIN32 -#if defined(__ANDROID__) && !defined(HAVE_LOCKF) +#if defined(__ANDROID__) && !defined(PHAVE_LOCKF) // Needed for flock. #include #endif @@ -130,7 +130,7 @@ VertexDataSaveFile(const Filename &directory, const string &prefix, // Now try to lock the file, so we can be sure that no other process is // simultaneously writing to the same save file. -#ifdef HAVE_LOCKF +#ifdef PHAVE_LOCKF int result = lockf(_fd, F_TLOCK, 0); #else int result = flock(_fd, LOCK_EX | LOCK_NB); From 527e4840ff71ef79c0556b163c672b777fe9bf6b Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 27 May 2018 14:11:55 -0600 Subject: [PATCH 204/247] makepanda: Fix table alignment --- makepanda/makepanda.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index a810da13af..6ba8974c8e 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2268,7 +2268,7 @@ DTOOL_CONFIG=[ ("DEFAULT_PATHSEP", '";"', '":"'), ("WORDS_BIGENDIAN", 'UNDEF', 'UNDEF'), ("HAVE_OPEN_MASK", 'UNDEF', 'UNDEF'), - ("PHAVE_LOCKF", '1', '1'), + ("PHAVE_LOCKF", '1', '1'), ("HAVE_WCHAR_T", '1', '1'), ("HAVE_WSTRING", '1', '1'), ("SIMPLE_STRUCT_POINTERS", '1', 'UNDEF'), From 32e1ca225231daa5bebe7d919405b9befbded5c4 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Tue, 29 May 2018 22:08:42 -0600 Subject: [PATCH 205/247] general: Fix several miscategorized EXPCL_PANDA_* macros --- panda/src/android/pnmFileTypeAndroid.h | 2 +- panda/src/chan/bindAnimRequest.h | 2 +- panda/src/display/displayRegionCullCallbackData.h | 2 +- panda/src/display/displayRegionDrawCallbackData.h | 2 +- panda/src/event/asyncTaskCollection.h | 2 +- panda/src/event/genericAsyncTask.h | 2 +- panda/src/gobj/animateVerticesRequest.h | 2 +- panda/src/parametrics/curveFitter.h | 2 +- panda/src/pgraph/paramNodePath.h | 2 +- panda/src/putil/bamReader.h | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/panda/src/android/pnmFileTypeAndroid.h b/panda/src/android/pnmFileTypeAndroid.h index f27cc4f23d..d872c58578 100644 --- a/panda/src/android/pnmFileTypeAndroid.h +++ b/panda/src/android/pnmFileTypeAndroid.h @@ -28,7 +28,7 @@ * Wrapper class around the Android Bitmap mechanism to allow loading images * on Android without needing libpng or libjpeg. */ -class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeAndroid : public PNMFileType { +class PNMFileTypeAndroid : public PNMFileType { public: enum CompressFormat : jint { CF_jpeg = 0, diff --git a/panda/src/chan/bindAnimRequest.h b/panda/src/chan/bindAnimRequest.h index fed5e5d596..1c555de10a 100644 --- a/panda/src/chan/bindAnimRequest.h +++ b/panda/src/chan/bindAnimRequest.h @@ -25,7 +25,7 @@ class AnimControl; * This class object manages an asynchronous load-and-bind animation request, * as issued through PartBundle::load_bind_anim(). */ -class EXPCL_PANDA_PGRAPH BindAnimRequest : public ModelLoadRequest { +class EXPCL_PANDA_CHAN BindAnimRequest : public ModelLoadRequest { public: ALLOC_DELETED_CHAIN(BindAnimRequest); diff --git a/panda/src/display/displayRegionCullCallbackData.h b/panda/src/display/displayRegionCullCallbackData.h index 509f5e2e2c..bb78dbc9c9 100644 --- a/panda/src/display/displayRegionCullCallbackData.h +++ b/panda/src/display/displayRegionCullCallbackData.h @@ -24,7 +24,7 @@ class SceneSetup; * This specialization on CallbackData is passed when the callback is * initiated from the cull traversal, for a DisplayRegion. */ -class EXPCL_PANDA_PGRAPH DisplayRegionCullCallbackData : public CallbackData { +class EXPCL_PANDA_DISPLAY DisplayRegionCullCallbackData : public CallbackData { public: DisplayRegionCullCallbackData(CullHandler *cull_handler, SceneSetup *scene_setup); diff --git a/panda/src/display/displayRegionDrawCallbackData.h b/panda/src/display/displayRegionDrawCallbackData.h index 55f76baf2e..bbdfdc99b3 100644 --- a/panda/src/display/displayRegionDrawCallbackData.h +++ b/panda/src/display/displayRegionDrawCallbackData.h @@ -24,7 +24,7 @@ class SceneSetup; * This specialization on CallbackData is passed when the callback is * initiated from the draw traversal, for a DisplayRegion. */ -class EXPCL_PANDA_PGRAPH DisplayRegionDrawCallbackData : public CallbackData { +class EXPCL_PANDA_DISPLAY DisplayRegionDrawCallbackData : public CallbackData { public: DisplayRegionDrawCallbackData(CullResult *cull_result, SceneSetup *scene_setup); diff --git a/panda/src/event/asyncTaskCollection.h b/panda/src/event/asyncTaskCollection.h index 4ed6f6a59b..70918bc49f 100644 --- a/panda/src/event/asyncTaskCollection.h +++ b/panda/src/event/asyncTaskCollection.h @@ -24,7 +24,7 @@ * * TODO: None of this is thread-safe yet. */ -class EXPCL_PANDA_PGRAPH AsyncTaskCollection { +class EXPCL_PANDA_EVENT AsyncTaskCollection { PUBLISHED: AsyncTaskCollection(); AsyncTaskCollection(const AsyncTaskCollection ©); diff --git a/panda/src/event/genericAsyncTask.h b/panda/src/event/genericAsyncTask.h index 9ff7ae272a..6530a8112a 100644 --- a/panda/src/event/genericAsyncTask.h +++ b/panda/src/event/genericAsyncTask.h @@ -23,7 +23,7 @@ * You can use this when you want to create an AsyncTask without having to * subclass. */ -class EXPCL_PANDA_PIPELINE GenericAsyncTask : public AsyncTask { +class EXPCL_PANDA_EVENT GenericAsyncTask : public AsyncTask { public: typedef DoneStatus TaskFunc(GenericAsyncTask *task, void *user_data); typedef void BirthFunc(GenericAsyncTask *task, void *user_data); diff --git a/panda/src/gobj/animateVerticesRequest.h b/panda/src/gobj/animateVerticesRequest.h index be20651a13..0d804a927d 100644 --- a/panda/src/gobj/animateVerticesRequest.h +++ b/panda/src/gobj/animateVerticesRequest.h @@ -30,7 +30,7 @@ * requests are being run (presumably on multiple CPUs/cores), to ensure that * the data has been computed by the time it's needed. */ -class EXPCL_PANDA_PGRAPH AnimateVerticesRequest : public AsyncTask { +class EXPCL_PANDA_GOBJ AnimateVerticesRequest : public AsyncTask { public: ALLOC_DELETED_CHAIN(AnimateVerticesRequest); diff --git a/panda/src/parametrics/curveFitter.h b/panda/src/parametrics/curveFitter.h index a83778951f..a07fd532a4 100644 --- a/panda/src/parametrics/curveFitter.h +++ b/panda/src/parametrics/curveFitter.h @@ -30,7 +30,7 @@ class NurbsCurve; /** * */ -class EXPCL_PANDA_GOBJ CurveFitter { +class EXPCL_PANDA_PARAMETRICS CurveFitter { PUBLISHED: CurveFitter(); ~CurveFitter(); diff --git a/panda/src/pgraph/paramNodePath.h b/panda/src/pgraph/paramNodePath.h index 86f027eb99..dae621443f 100644 --- a/panda/src/pgraph/paramNodePath.h +++ b/panda/src/pgraph/paramNodePath.h @@ -21,7 +21,7 @@ /** * A class object for storing a NodePath as a parameter. */ -class EXPCL_PANDA_GOBJ ParamNodePath : public ParamValueBase { +class EXPCL_PANDA_PGRAPH ParamNodePath : public ParamValueBase { protected: INLINE ParamNodePath() {}; diff --git a/panda/src/putil/bamReader.h b/panda/src/putil/bamReader.h index bf88ced2af..14403f6cae 100644 --- a/panda/src/putil/bamReader.h +++ b/panda/src/putil/bamReader.h @@ -58,7 +58,7 @@ * object's read pass. To use this, subclass BamReaderAuxData and add * whatever additional data you require. */ -class EXPCL_PANDA_PGRAPH BamReaderAuxData : public TypedReferenceCount { +class EXPCL_PANDA_PUTIL BamReaderAuxData : public TypedReferenceCount { public: INLINE BamReaderAuxData(); From 314cee133a78da0fff1d13645de6030bf2b8e4b9 Mon Sep 17 00:00:00 2001 From: Psychotropos Date: Tue, 29 May 2018 21:59:51 +0100 Subject: [PATCH 206/247] dtoolbase: The bug in question is glibc-specific, treat it as such. --- dtool/src/dtoolbase/dtoolbase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dtool/src/dtoolbase/dtoolbase.h b/dtool/src/dtoolbase/dtoolbase.h index 3f8e07f998..4e7b73ba9a 100644 --- a/dtool/src/dtoolbase/dtoolbase.h +++ b/dtool/src/dtoolbase/dtoolbase.h @@ -123,7 +123,7 @@ // This is a workaround for a glibc bug that is triggered by clang when // compiling with -ffast-math. -#ifdef __clang__ +#if defined(__clang__) && defined(__GLIBC__) #include #ifndef __extern_always_inline #define __extern_always_inline extern __always_inline From 3029780f88fd959b7f6a53894943af82dcfaa538 Mon Sep 17 00:00:00 2001 From: Psychotropos Date: Tue, 29 May 2018 22:10:30 +0100 Subject: [PATCH 207/247] dtoolutil: Don't assume RTLD_DI_ORIGIN and RTLD_SELF are present, fall back to using RTLD_DI_LINKMAP if necessary Closes #334 --- dtool/src/dtoolutil/executionEnvironment.cxx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/dtool/src/dtoolutil/executionEnvironment.cxx b/dtool/src/dtoolutil/executionEnvironment.cxx index c4f2e5093e..9a2921efd2 100644 --- a/dtool/src/dtoolutil/executionEnvironment.cxx +++ b/dtool/src/dtoolutil/executionEnvironment.cxx @@ -577,8 +577,8 @@ read_args() { } #endif -#if defined(IS_FREEBSD) || (defined(IS_LINUX) && !defined(__ANDROID__)) - // FreeBSD and Linux have a function to get the origin of a loaded library. +#if defined(RTLD_DI_ORIGIN) + // When building with glibc/uClibc, we typically have access to RTLD_DI_ORIGIN in Unix-like operating systems. char origin[PATH_MAX + 1]; @@ -598,12 +598,16 @@ read_args() { } #endif -#if defined(IS_FREEBSD) - // On FreeBSD, we can use dlinfo to get the linked libraries. - +#if !defined(RTLD_DI_ORIGIN) && defined(RTLD_DI_LINKMAP) + // On platforms without RTLD_DI_ORIGIN, we can use dlinfo with RTLD_DI_LINKMAP to get the origin of a loaded library. if (_dtool_name.empty()) { - Link_map *map; - dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &map); + struct link_map *map; +#ifdef RTLD_SELF + void *self = RTLD_SELF; +#else + void *self = dlopen(NULL, RTLD_NOW | RTLD_NOLOAD); +#endif + dlinfo(self, RTLD_DI_LINKMAP, &map); while (map != NULL) { const char *tail = strrchr(map->l_name, '/'); From 6b726fa697a86c80419b30f19f981bfe2a7bc228 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 30 May 2018 11:09:35 +0200 Subject: [PATCH 208/247] general: fix various compiler warnings and issues exposed thereby --- .../src/distributed/cConnectionRepository.cxx | 5 ++-- dtool/src/cppparser/cppBison.cxx.prebuilt | 1 - dtool/src/cppparser/cppBison.yxx | 1 - dtool/src/dtoolbase/memoryHook.cxx | 4 +-- .../interfaceMakerPythonNative.cxx | 15 ++++++---- panda/src/bullet/bulletBodyNode.cxx | 2 +- .../collide/collisionHandlerFluidPusher.cxx | 4 +-- panda/src/collide/collisionTraverser.h | 1 - panda/src/display/graphicsStateGuardian.cxx | 2 +- panda/src/display/graphicsStateGuardian.h | 2 +- panda/src/egg2pg/eggLoader.cxx | 2 +- panda/src/egg2pg/eggSaver.cxx | 1 - panda/src/event/asyncFuture.I | 4 +-- panda/src/express/pointerToArray_ext.I | 2 ++ panda/src/express/virtualFileSimple.I | 3 +- panda/src/express/virtualFileSimple.h | 1 - .../glstuff/glGraphicsStateGuardian_src.cxx | 12 ++------ panda/src/glstuff/glShaderContext_src.cxx | 2 +- panda/src/gobj/adaptiveLru.cxx | 2 -- panda/src/gobj/adaptiveLru.h | 1 - panda/src/gobj/geomVertexColumn.cxx | 28 +++++++++---------- panda/src/gobj/geomVertexData.I | 1 - panda/src/gobj/geomVertexData.h | 1 - panda/src/gobj/preparedGraphicsObjects.cxx | 1 - panda/src/gobj/shader.cxx | 1 - panda/src/grutil/movieTexture.cxx | 2 +- panda/src/grutil/movieTexture.h | 2 +- .../particlesystem/orientedParticleFactory.h | 2 +- panda/src/physics/actorNode.cxx | 2 +- panda/src/physics/actorNode.h | 2 +- panda/src/physics/angularEulerIntegrator.cxx | 2 +- panda/src/physics/angularEulerIntegrator.h | 2 +- panda/src/physics/angularForce.cxx | 2 +- panda/src/physics/angularForce.h | 2 +- panda/src/physics/angularIntegrator.cxx | 2 +- panda/src/physics/angularIntegrator.h | 2 +- panda/src/physics/angularVectorForce.cxx | 2 +- panda/src/physics/angularVectorForce.h | 2 +- panda/src/physics/baseIntegrator.cxx | 6 ++-- panda/src/physics/baseIntegrator.h | 6 ++-- panda/src/physics/forceNode.cxx | 4 +-- panda/src/physics/forceNode.h | 4 +-- panda/src/physics/linearControlForce.cxx | 2 +- panda/src/physics/linearControlForce.h | 2 +- .../src/physics/linearCylinderVortexForce.cxx | 2 +- panda/src/physics/linearCylinderVortexForce.h | 2 +- panda/src/physics/linearDistanceForce.cxx | 2 +- panda/src/physics/linearDistanceForce.h | 2 +- panda/src/physics/linearEulerIntegrator.cxx | 2 +- panda/src/physics/linearEulerIntegrator.h | 2 +- panda/src/physics/linearForce.cxx | 2 +- panda/src/physics/linearForce.h | 2 +- panda/src/physics/linearFrictionForce.cxx | 2 +- panda/src/physics/linearFrictionForce.h | 2 +- panda/src/physics/linearIntegrator.cxx | 2 +- panda/src/physics/linearIntegrator.h | 2 +- panda/src/physics/linearJitterForce.cxx | 2 +- panda/src/physics/linearJitterForce.h | 2 +- panda/src/physics/linearNoiseForce.cxx | 2 +- panda/src/physics/linearNoiseForce.h | 2 +- panda/src/physics/linearRandomForce.cxx | 2 +- panda/src/physics/linearRandomForce.h | 2 +- panda/src/physics/linearSinkForce.cxx | 2 +- panda/src/physics/linearSinkForce.h | 2 +- panda/src/physics/linearSourceForce.cxx | 2 +- panda/src/physics/linearSourceForce.h | 2 +- panda/src/physics/linearUserDefinedForce.cxx | 2 +- panda/src/physics/linearUserDefinedForce.h | 2 +- panda/src/physics/linearVectorForce.cxx | 2 +- panda/src/physics/linearVectorForce.h | 2 +- panda/src/physics/physical.cxx | 8 +++--- panda/src/physics/physical.h | 8 +++--- panda/src/physics/physicalNode.cxx | 2 +- panda/src/physics/physicalNode.h | 2 +- panda/src/physics/physicsManager.cxx | 10 +++---- panda/src/physics/physicsManager.h | 10 +++---- panda/src/physics/physicsObject.cxx | 2 +- panda/src/physics/physicsObject.h | 2 +- panda/src/pnmimage/pnmImage.cxx | 6 ++-- panda/src/pnmimagetypes/pnmFileTypeEXR.h | 1 - panda/src/pnmimagetypes/pnmFileTypeJPG.h | 12 -------- panda/src/text/staticTextFont.h | 1 - panda/src/text/textNode.h | 1 - panda/src/tinydisplay/store_pixel.h | 8 +++--- panda/src/tinydisplay/zfeatures.h | 6 ++++ panda/src/tinydisplay/ztriangle_two.h | 18 ++++++------ pandatool/src/egg-palettize/eggPalettize.h | 1 - pandatool/src/eggbase/eggWriter.h | 1 - pandatool/src/objegg/eggToObjConverter.h | 2 -- pandatool/src/palettizer/eggFile.h | 1 - pandatool/src/palettizer/texturePlacement.h | 1 - pandatool/src/pfmprogs/pfmBba.h | 1 - 92 files changed, 138 insertions(+), 167 deletions(-) diff --git a/direct/src/distributed/cConnectionRepository.cxx b/direct/src/distributed/cConnectionRepository.cxx index e247c2bd55..2ce5beb0c7 100644 --- a/direct/src/distributed/cConnectionRepository.cxx +++ b/direct/src/distributed/cConnectionRepository.cxx @@ -849,8 +849,9 @@ handle_update_field_owner() { vector_uchar data = _di.get_remaining_bytes(); DCPacker packer; packer.set_unpack_data((const char *)data.data(), data.size(), false); - int field_id = packer.raw_unpack_uint16(); - DCField *field = dclass->get_field_by_index(field_id); + + //int field_id = packer.raw_unpack_uint16(); + //DCField *field = dclass->get_field_by_index(field_id); if (true) {//field->is_broadcast()) { // It's a good idea to ensure the reference count to distobj is raised // while we call the update method--otherwise, the update method might diff --git a/dtool/src/cppparser/cppBison.cxx.prebuilt b/dtool/src/cppparser/cppBison.cxx.prebuilt index 2167d06578..6ee30a3510 100644 --- a/dtool/src/cppparser/cppBison.cxx.prebuilt +++ b/dtool/src/cppparser/cppBison.cxx.prebuilt @@ -110,7 +110,6 @@ static CPPEnumType *current_enum = NULL; static int current_storage_class = 0; static CPPType *current_type = NULL; static CPPExpression *current_expr = NULL; -static CPPClosureType *current_closure = NULL; static int publish_nest_level = 0; static CPPVisibility publish_previous; static YYLTYPE publish_loc; diff --git a/dtool/src/cppparser/cppBison.yxx b/dtool/src/cppparser/cppBison.yxx index 68f4f96706..64fc1cf4f1 100644 --- a/dtool/src/cppparser/cppBison.yxx +++ b/dtool/src/cppparser/cppBison.yxx @@ -45,7 +45,6 @@ static CPPEnumType *current_enum = NULL; static int current_storage_class = 0; static CPPType *current_type = NULL; static CPPExpression *current_expr = NULL; -static CPPClosureType *current_closure = NULL; static int publish_nest_level = 0; static CPPVisibility publish_previous; static YYLTYPE publish_loc; diff --git a/dtool/src/dtoolbase/memoryHook.cxx b/dtool/src/dtoolbase/memoryHook.cxx index 710ea9e65f..30b53769e2 100644 --- a/dtool/src/dtoolbase/memoryHook.cxx +++ b/dtool/src/dtoolbase/memoryHook.cxx @@ -216,12 +216,12 @@ MemoryHook() { */ MemoryHook:: MemoryHook(const MemoryHook ©) : - _page_size(copy._page_size), _total_heap_single_size(copy._total_heap_single_size), _total_heap_array_size(copy._total_heap_array_size), _requested_heap_size(copy._requested_heap_size), _total_mmap_size(copy._total_mmap_size), - _max_heap_size(copy._max_heap_size) { + _max_heap_size(copy._max_heap_size), + _page_size(copy._page_size) { copy._lock.lock(); _deleted_chains = copy._deleted_chains; diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 7542569d46..3fd5d0245a 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -2636,8 +2636,6 @@ write_module_class(ostream &out, Object *obj) { if (obj->_properties.size() > 0) { // Write out the array of properties, telling Python which getter and // setter to call when they are assigned or queried in Python code. - out << "static PyGetSetDef Dtool_Properties_" << ClassName << "[] = {\n"; - Properties::const_iterator pit; for (pit = obj->_properties.begin(); pit != obj->_properties.end(); ++pit) { Property *property = (*pit); @@ -2646,6 +2644,10 @@ write_module_class(ostream &out, Object *obj) { continue; } + if (num_getset == 0) { + out << "static PyGetSetDef Dtool_Properties_" << ClassName << "[] = {\n"; + } + ++num_getset; string name1 = methodNameFromCppName(ielem.get_name(), "", false); @@ -2679,8 +2681,10 @@ write_module_class(ostream &out, Object *obj) { }*/ } - out << " {NULL},\n"; - out << "};\n\n"; + if (num_getset != 0) { + out << " {NULL},\n"; + out << "};\n\n"; + } } // These fields are inherited together. We should either write all of them @@ -7077,9 +7081,8 @@ record_object(TypeIndex type_index) { int num_elements = itype.number_of_elements(); for (int ei = 0; ei < num_elements; ei++) { ElementIndex element_index = itype.get_element(ei); - const InterrogateElement &ielement = idb->get_element(element_index); - Property *property = record_property(itype, itype.get_element(ei)); + Property *property = record_property(itype, element_index); if (property != nullptr) { object->_properties.push_back(property); } else { diff --git a/panda/src/bullet/bulletBodyNode.cxx b/panda/src/bullet/bulletBodyNode.cxx index f02641cd96..1b85a75779 100644 --- a/panda/src/bullet/bulletBodyNode.cxx +++ b/panda/src/bullet/bulletBodyNode.cxx @@ -864,7 +864,7 @@ cout << "origin " << aabbMin.x() << " " << aabbMin.y() << " " << aabbMin.z() << */ btVector3 center; - btScalar radius; + btScalar radius = 0; if (_shape) { _shape->getBoundingSphere(center, radius); diff --git a/panda/src/collide/collisionHandlerFluidPusher.cxx b/panda/src/collide/collisionHandlerFluidPusher.cxx index 0a48381d01..476aacb82b 100644 --- a/panda/src/collide/collisionHandlerFluidPusher.cxx +++ b/panda/src/collide/collisionHandlerFluidPusher.cxx @@ -154,7 +154,7 @@ handle_entries() { // unit vector pointing out to the right relative to the direction of // motion, looking into the direction of motion - const LVector3 right_unit(LVector3::up().cross(reverse_vec)); + //const LVector3 right_unit(LVector3::up().cross(reverse_vec)); // iterate until the mover runs out of movement or gets stuck while (true) { @@ -214,7 +214,7 @@ handle_entries() { from_node_path.set_prev_transform(wrt_node, prev_trans); { - const LPoint3 new_pos(from_node_path.get_pos(wrt_node)); + //const LPoint3 new_pos(from_node_path.get_pos(wrt_node)); CPT(TransformState) new_prev_trans(from_node_path.get_prev_transform(wrt_node)); const LPoint3 new_prev_pos(new_prev_trans->get_pos()); } diff --git a/panda/src/collide/collisionTraverser.h b/panda/src/collide/collisionTraverser.h index 8aaa0fd475..5f5ebe0b13 100644 --- a/panda/src/collide/collisionTraverser.h +++ b/panda/src/collide/collisionTraverser.h @@ -111,7 +111,6 @@ private: private: PT(CollisionHandler) _default_handler; - TypeHandle _graph_type; class OrderedColliderDef { public: diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 5f282b82ce..e754b9bf4d 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -551,7 +551,7 @@ get_scene() const { * call Texture::prepare(). */ TextureContext *GraphicsStateGuardian:: -prepare_texture(Texture *) { +prepare_texture(Texture *, int view) { return (TextureContext *)NULL; } diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index fecce7e56a..5a7bec86dd 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -290,7 +290,7 @@ PUBLISHED: MAKE_PROPERTY(scene, get_scene, set_scene); public: - virtual TextureContext *prepare_texture(Texture *tex); + virtual TextureContext *prepare_texture(Texture *tex, int view); virtual bool update_texture(TextureContext *tc, bool force); virtual void release_texture(TextureContext *tc); virtual bool extract_texture_data(Texture *tex); diff --git a/panda/src/egg2pg/eggLoader.cxx b/panda/src/egg2pg/eggLoader.cxx index e093990ef9..6e07b82d26 100644 --- a/panda/src/egg2pg/eggLoader.cxx +++ b/panda/src/egg2pg/eggLoader.cxx @@ -3792,7 +3792,7 @@ TextureStage::CombineOperand EggLoader:: get_combine_operand(const EggTexture *egg_tex, EggTexture::CombineChannel channel, int n) { switch (egg_tex->get_combine_operand(channel, n)) { - case EggTexture::CS_unspecified: + case EggTexture::CO_unspecified: if (channel == EggTexture::CC_rgb) { // The default operand for RGB is src_color, except for the third // parameter, which defaults to src_alpha. diff --git a/panda/src/egg2pg/eggSaver.cxx b/panda/src/egg2pg/eggSaver.cxx index 63b114ed54..43dcb06a5b 100644 --- a/panda/src/egg2pg/eggSaver.cxx +++ b/panda/src/egg2pg/eggSaver.cxx @@ -839,7 +839,6 @@ convert_primitive(const GeomVertexData *vertex_data, } // Check the backface flag. - bool bface = false; const CullFaceAttrib *cfa; if (net_state->get_attrib(cfa)) { if (cfa->get_effective_mode() == CullFaceAttrib::M_cull_none) { diff --git a/panda/src/event/asyncFuture.I b/panda/src/event/asyncFuture.I index a11fb6b36a..44fb0a8247 100644 --- a/panda/src/event/asyncFuture.I +++ b/panda/src/event/asyncFuture.I @@ -17,8 +17,8 @@ INLINE AsyncFuture:: AsyncFuture() : _manager(nullptr), - _future_state(FS_pending), - _result(nullptr) { + _result(nullptr), + _future_state(FS_pending) { } /** diff --git a/panda/src/express/pointerToArray_ext.I b/panda/src/express/pointerToArray_ext.I index 644b5f0645..fb42878b3f 100644 --- a/panda/src/express/pointerToArray_ext.I +++ b/panda/src/express/pointerToArray_ext.I @@ -37,6 +37,8 @@ INLINE void set_matrix_view(Py_buffer &view, int flags, int length, int size, bo mat_size = sizeof(UnalignedLMatrix4f); } else if (size == 4 && double_prec) { mat_size = sizeof(UnalignedLMatrix4d); + } else { + assert(false); } view.len = length * mat_size; diff --git a/panda/src/express/virtualFileSimple.I b/panda/src/express/virtualFileSimple.I index dcdd7cec90..1d30ef08e5 100644 --- a/panda/src/express/virtualFileSimple.I +++ b/panda/src/express/virtualFileSimple.I @@ -19,8 +19,7 @@ VirtualFileSimple(VirtualFileMount *mount, const Filename &local_filename, bool implicit_pz_file, int open_flags) : _mount(mount), _local_filename(local_filename), - _implicit_pz_file(implicit_pz_file), - _open_flags(open_flags) + _implicit_pz_file(implicit_pz_file) { } diff --git a/panda/src/express/virtualFileSimple.h b/panda/src/express/virtualFileSimple.h index 917898791e..c0f1da1fc7 100644 --- a/panda/src/express/virtualFileSimple.h +++ b/panda/src/express/virtualFileSimple.h @@ -74,7 +74,6 @@ private: VirtualFileMount *_mount; Filename _local_filename; bool _implicit_pz_file; - int _open_flags; public: virtual TypeHandle get_type() const { diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index c4dd42ceb3..f5e56585e0 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -2643,7 +2643,6 @@ reset() { GLint max_3d_texture_size = 0; GLint max_2d_texture_array_layers = 0; GLint max_cube_map_size = 0; - GLint max_buffer_texture_size = 0; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size); _max_texture_dimension = max_texture_size; @@ -2671,6 +2670,7 @@ reset() { #ifndef OPENGLES if (_supports_buffer_texture) { + GLint max_buffer_texture_size = 0; glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, &max_buffer_texture_size); _max_buffer_texture_size = max_buffer_texture_size; } else { @@ -2678,8 +2678,8 @@ reset() { } #endif // !OPENGLES - GLint max_elements_vertices = 0, max_elements_indices = 0; #ifndef OPENGLES + GLint max_elements_vertices = 0, max_elements_indices = 0; if (is_at_least_gl_version(1, 2) || has_extension("GL_EXT_draw_range_elements")) { glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, &max_elements_vertices); glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &max_elements_indices); @@ -7604,7 +7604,6 @@ do_issue_blending() { #endif if (color_channels == ColorWriteAttrib::C_off) { - int color_write_slot = ColorWriteAttrib::get_class_slot(); enable_multisample_alpha_one(false); enable_multisample_alpha_mask(false); if (gl_color_mask) { @@ -8311,7 +8310,6 @@ report_extensions() const { ostream &out = GLCAT.debug(); out << "GL Extensions:\n"; - size_t maxlen = 0; pset::const_iterator ei; for (ei = _extensions.begin(); ei != _extensions.end(); ++ei) { size_t len = (*ei).size(); @@ -10915,7 +10913,6 @@ set_state_and_transform(const RenderState *target, !_state_mask.get_bit(texture_slot)) { // PStatGPUTimer timer(this, _draw_set_state_texture_pcollector); determine_target_texture(); - int prev_active = _num_active_texture_stages; do_issue_texture(); // Since the TexGen and TexMatrix states depend partly on the particular @@ -12264,10 +12261,8 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { } if (image_compression != Texture::CM_off) { - Texture::QualityLevel quality_level = tex->get_effective_quality_level(); - #ifndef OPENGLES - switch (quality_level) { + switch (tex->get_effective_quality_level()) { case Texture::QL_fastest: glHint(GL_TEXTURE_COMPRESSION_HINT, GL_FASTEST); break; @@ -13150,7 +13145,6 @@ get_texture_memory_size(CLP(TextureContext) *gtc) { int height = tex->get_y_size(); int depth = 1; int scale = 1; - bool has_mipmaps = tex->uses_mipmaps(); size_t num_bytes = 2; // Temporary assumption? diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index b5fd39350d..27fabc899e 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -2660,9 +2660,9 @@ update_shader_texture_bindings(ShaderContext *prev) { continue; } +#ifndef OPENGLES GLint p = spec._id._seqno; -#ifndef OPENGLES // If it was recently written to, we will have to issue a memory barrier // soon. if (gtc->needs_barrier(GL_TEXTURE_FETCH_BARRIER_BIT)) { diff --git a/panda/src/gobj/adaptiveLru.cxx b/panda/src/gobj/adaptiveLru.cxx index eb2d945177..ecb4d033c9 100644 --- a/panda/src/gobj/adaptiveLru.cxx +++ b/panda/src/gobj/adaptiveLru.cxx @@ -455,7 +455,6 @@ AdaptiveLruPage(size_t lru_size) : _update_frame_identifier(0), _current_frame_usage(0), _last_frame_usage(0), - _total_usage(0), _update_total_usage(0), _average_frame_utilization(1.0f) { @@ -474,7 +473,6 @@ AdaptiveLruPage(const AdaptiveLruPage ©) : _update_frame_identifier(0), _current_frame_usage(0), _last_frame_usage(0), - _total_usage(0), _update_total_usage(0), _average_frame_utilization(1.0f) { diff --git a/panda/src/gobj/adaptiveLru.h b/panda/src/gobj/adaptiveLru.h index 99b78b482d..4729f63f2c 100644 --- a/panda/src/gobj/adaptiveLru.h +++ b/panda/src/gobj/adaptiveLru.h @@ -172,7 +172,6 @@ private: int _current_frame_usage; int _last_frame_usage; - int _total_usage; int _update_total_usage; PN_stdfloat _average_frame_utilization; diff --git a/panda/src/gobj/geomVertexColumn.cxx b/panda/src/gobj/geomVertexColumn.cxx index 3227eb7b42..06a3af8a97 100644 --- a/panda/src/gobj/geomVertexColumn.cxx +++ b/panda/src/gobj/geomVertexColumn.cxx @@ -3869,9 +3869,9 @@ set_data3f(unsigned char *pointer, const LVecBase3f &data) { { LVecBase3f scaled = data * 4294967295.0f; uint32_t *pi = (uint32_t *)pointer; - pi[0] = (unsigned int)data[0]; - pi[1] = (unsigned int)data[1]; - pi[2] = (unsigned int)data[2]; + pi[0] = (unsigned int)scaled[0]; + pi[1] = (unsigned int)scaled[1]; + pi[2] = (unsigned int)scaled[2]; } break; @@ -3960,10 +3960,10 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) { { LVecBase4f scaled = data * 4294967295.0f; uint32_t *pi = (uint32_t *)pointer; - pi[0] = (unsigned int)data[0]; - pi[1] = (unsigned int)data[1]; - pi[2] = (unsigned int)data[2]; - pi[3] = (unsigned int)data[3]; + pi[0] = (unsigned int)scaled[0]; + pi[1] = (unsigned int)scaled[1]; + pi[2] = (unsigned int)scaled[2]; + pi[3] = (unsigned int)scaled[3]; } break; @@ -4072,9 +4072,9 @@ set_data3d(unsigned char *pointer, const LVecBase3d &data) { { LVecBase3d scaled = data * 4294967295.0; uint32_t *pi = (uint32_t *)pointer; - pi[0] = (unsigned int)data[0]; - pi[1] = (unsigned int)data[1]; - pi[2] = (unsigned int)data[2]; + pi[0] = (unsigned int)scaled[0]; + pi[1] = (unsigned int)scaled[1]; + pi[2] = (unsigned int)scaled[2]; } break; @@ -4163,10 +4163,10 @@ set_data4d(unsigned char *pointer, const LVecBase4d &data) { { LVecBase4d scaled = data * 4294967295.0; uint32_t *pi = (uint32_t *)pointer; - pi[0] = (unsigned int)data[0]; - pi[1] = (unsigned int)data[1]; - pi[2] = (unsigned int)data[2]; - pi[3] = (unsigned int)data[3]; + pi[0] = (unsigned int)scaled[0]; + pi[1] = (unsigned int)scaled[1]; + pi[2] = (unsigned int)scaled[2]; + pi[3] = (unsigned int)scaled[3]; } break; diff --git a/panda/src/gobj/geomVertexData.I b/panda/src/gobj/geomVertexData.I index 849a3548f3..1d42671e67 100644 --- a/panda/src/gobj/geomVertexData.I +++ b/panda/src/gobj/geomVertexData.I @@ -837,7 +837,6 @@ GeomVertexDataPipelineWriter(GeomVertexData *object, bool force_to_0, Thread *current_thread) : GeomVertexDataPipelineBase(object, current_thread, object->_cycler.write_upstream(force_to_0, current_thread)), - _force_to_0(force_to_0), _got_array_writers(false) { #ifdef _DEBUG diff --git a/panda/src/gobj/geomVertexData.h b/panda/src/gobj/geomVertexData.h index 2a7db8115b..806f5887d3 100644 --- a/panda/src/gobj/geomVertexData.h +++ b/panda/src/gobj/geomVertexData.h @@ -530,7 +530,6 @@ private: void make_array_writers(); void delete_array_writers(); - bool _force_to_0; bool _got_array_writers; typedef pvector ArrayWriters; ArrayWriters _array_writers; diff --git a/panda/src/gobj/preparedGraphicsObjects.cxx b/panda/src/gobj/preparedGraphicsObjects.cxx index 233edb46b3..8a7beb7ffe 100644 --- a/panda/src/gobj/preparedGraphicsObjects.cxx +++ b/panda/src/gobj/preparedGraphicsObjects.cxx @@ -1580,7 +1580,6 @@ begin_frame(GraphicsStateGuardianBase *gsg, Thread *current_thread) { qti != _enqueued_textures.end(); ++qti) { Texture *tex = qti->first; - TextureContext *first_tc = nullptr; for (int view = 0; view < tex->get_num_views(); ++view) { TextureContext *tc = tex->prepare_now(view, this, gsg); if (tc != nullptr) { diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index 35fd3ce560..94c90c644d 100644 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -2709,7 +2709,6 @@ r_preprocess_source(ostream &out, const Filename &fn, // Check for an #endif after an include. We have to restore the line // number in case the include happened under an #if block. out << line << "\n"; - int nread = 0; if (had_include) { out << "#line " << (lineno + 1) << " " << fileno << "\n"; } diff --git a/panda/src/grutil/movieTexture.cxx b/panda/src/grutil/movieTexture.cxx index 8f2850380b..e395916bce 100644 --- a/panda/src/grutil/movieTexture.cxx +++ b/panda/src/grutil/movieTexture.cxx @@ -387,7 +387,7 @@ cull_callback(CullTraverser *, const CullTraverserData &) const { * independently of the original. */ PT(Texture) MovieTexture:: -make_copy_impl() { +make_copy_impl() const { Texture::CDReader cdata_tex(Texture::_cycler); CDReader cdata(_cycler); PT(MovieTexture) copy = new MovieTexture(get_name()); diff --git a/panda/src/grutil/movieTexture.h b/panda/src/grutil/movieTexture.h index 0881552036..ab4d549b86 100644 --- a/panda/src/grutil/movieTexture.h +++ b/panda/src/grutil/movieTexture.h @@ -80,7 +80,7 @@ public: protected: class CData; - virtual PT(Texture) make_copy_impl(); + virtual PT(Texture) make_copy_impl() const; void do_assign(CData *cdata, Texture::CData *cdata_tex, const MovieTexture *copy, const CData *cdata_copy, const Texture::CData *cdata_copy_tex); diff --git a/panda/src/particlesystem/orientedParticleFactory.h b/panda/src/particlesystem/orientedParticleFactory.h index 0df2326ed4..5258d7e256 100644 --- a/panda/src/particlesystem/orientedParticleFactory.h +++ b/panda/src/particlesystem/orientedParticleFactory.h @@ -33,7 +33,7 @@ PUBLISHED: INLINE LOrientation get_final_orientation() const; virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: virtual void populate_child_particle(BaseParticle *bp) const; diff --git a/panda/src/physics/actorNode.cxx b/panda/src/physics/actorNode.cxx index e77e8e5ca5..b216036009 100644 --- a/panda/src/physics/actorNode.cxx +++ b/panda/src/physics/actorNode.cxx @@ -120,7 +120,7 @@ transform_changed() { * Write a string representation of this instance to . */ void ActorNode:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"ActorNode:\n"; out.width(indent+2); out<<""; out<<"_ok_to_callback "<<_ok_to_callback<<"\n"; diff --git a/panda/src/physics/actorNode.h b/panda/src/physics/actorNode.h index aacdec669e..bfa4ffff66 100644 --- a/panda/src/physics/actorNode.h +++ b/panda/src/physics/actorNode.h @@ -39,7 +39,7 @@ PUBLISHED: void update_transform(); void set_transform_limit(PN_stdfloat limit) { _transform_limit = limit; }; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: PhysicsObject *_mass_center; diff --git a/panda/src/physics/angularEulerIntegrator.cxx b/panda/src/physics/angularEulerIntegrator.cxx index 9900223d4c..3207450871 100644 --- a/panda/src/physics/angularEulerIntegrator.cxx +++ b/panda/src/physics/angularEulerIntegrator.cxx @@ -152,7 +152,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void AngularEulerIntegrator:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"AngularEulerIntegrator:\n"; AngularIntegrator::write(out, indent+2); diff --git a/panda/src/physics/angularEulerIntegrator.h b/panda/src/physics/angularEulerIntegrator.h index 5e342b10f9..3e0790950c 100644 --- a/panda/src/physics/angularEulerIntegrator.h +++ b/panda/src/physics/angularEulerIntegrator.h @@ -26,7 +26,7 @@ PUBLISHED: virtual ~AngularEulerIntegrator(); virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: virtual void child_integrate(Physical *physical, diff --git a/panda/src/physics/angularForce.cxx b/panda/src/physics/angularForce.cxx index 722a4611ab..06c71289ae 100644 --- a/panda/src/physics/angularForce.cxx +++ b/panda/src/physics/angularForce.cxx @@ -69,7 +69,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void AngularForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"AngularForce (id "<. */ void AngularIntegrator:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"AngularIntegrator:\n"; out.width(indent+2); out<<""; out<<"_max_angular_dt "<<_max_angular_dt<<" (class const)\n"; diff --git a/panda/src/physics/angularIntegrator.h b/panda/src/physics/angularIntegrator.h index 4ee8d41009..5ca3fd729a 100644 --- a/panda/src/physics/angularIntegrator.h +++ b/panda/src/physics/angularIntegrator.h @@ -32,7 +32,7 @@ public: PUBLISHED: virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; protected: AngularIntegrator(); diff --git a/panda/src/physics/angularVectorForce.cxx b/panda/src/physics/angularVectorForce.cxx index d9ab88b054..736deec04f 100644 --- a/panda/src/physics/angularVectorForce.cxx +++ b/panda/src/physics/angularVectorForce.cxx @@ -78,7 +78,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void AngularVectorForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"AngularVectorForce:\n"; out.width(indent+2); out<<""; out<<"_fvec "<<_fvec<<"\n"; diff --git a/panda/src/physics/angularVectorForce.h b/panda/src/physics/angularVectorForce.h index aab32eaaae..f42c2f0c81 100644 --- a/panda/src/physics/angularVectorForce.h +++ b/panda/src/physics/angularVectorForce.h @@ -32,7 +32,7 @@ PUBLISHED: INLINE LRotation get_local_quat() const; virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: LRotation _fvec; diff --git a/panda/src/physics/baseIntegrator.cxx b/panda/src/physics/baseIntegrator.cxx index b21fd38612..f0cbe93893 100644 --- a/panda/src/physics/baseIntegrator.cxx +++ b/panda/src/physics/baseIntegrator.cxx @@ -149,7 +149,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void BaseIntegrator:: -write_precomputed_linear_matrices(ostream &out, unsigned int indent) const { +write_precomputed_linear_matrices(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_precomputed_linear_matrices\n"; @@ -165,7 +165,7 @@ write_precomputed_linear_matrices(ostream &out, unsigned int indent) const { * Write a string representation of this instance to . */ void BaseIntegrator:: -write_precomputed_angular_matrices(ostream &out, unsigned int indent) const { +write_precomputed_angular_matrices(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_precomputed_angular_matrices\n"; @@ -181,7 +181,7 @@ write_precomputed_angular_matrices(ostream &out, unsigned int indent) const { * Write a string representation of this instance to . */ void BaseIntegrator:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"BaseIntegrator:\n"; write_precomputed_linear_matrices(out, indent+2); diff --git a/panda/src/physics/baseIntegrator.h b/panda/src/physics/baseIntegrator.h index aaedce91cd..9d134fa2ee 100644 --- a/panda/src/physics/baseIntegrator.h +++ b/panda/src/physics/baseIntegrator.h @@ -42,10 +42,10 @@ public: PUBLISHED: virtual void output(ostream &out) const; virtual void write_precomputed_linear_matrices(ostream &out, - unsigned int indent=0) const; + int indent=0) const; virtual void write_precomputed_angular_matrices(ostream &out, - unsigned int indent=0) const; - virtual void write(ostream &out, unsigned int indent=0) const; + int indent=0) const; + virtual void write(ostream &out, int indent=0) const; protected: BaseIntegrator(); diff --git a/panda/src/physics/forceNode.cxx b/panda/src/physics/forceNode.cxx index 0e186a98b3..e317052561 100644 --- a/panda/src/physics/forceNode.cxx +++ b/panda/src/physics/forceNode.cxx @@ -133,7 +133,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void ForceNode:: -write_forces(ostream &out, unsigned int indent) const { +write_forces(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_forces ("<<_forces.size()<<" forces)"<<"\n"; for (ForceVector::const_iterator i=_forces.begin(); @@ -149,7 +149,7 @@ write_forces(ostream &out, unsigned int indent) const { * Write a string representation of this instance to . */ void ForceNode:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"ForceNode (id "<. */ void LinearControlForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearControlForce:\n"; out.width(indent+2); out<<""; out<<"_fvec "<<_fvec<<"\n"; diff --git a/panda/src/physics/linearControlForce.h b/panda/src/physics/linearControlForce.h index d39a9c2581..b1a28a5405 100644 --- a/panda/src/physics/linearControlForce.h +++ b/panda/src/physics/linearControlForce.h @@ -39,7 +39,7 @@ PUBLISHED: INLINE LVector3 get_local_vector() const; virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: CPT(PhysicsObject) _physics_object; diff --git a/panda/src/physics/linearCylinderVortexForce.cxx b/panda/src/physics/linearCylinderVortexForce.cxx index 9976d6b1eb..ab91296af0 100644 --- a/panda/src/physics/linearCylinderVortexForce.cxx +++ b/panda/src/physics/linearCylinderVortexForce.cxx @@ -127,7 +127,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearCylinderVortexForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearCylinderVortexForce:\n"; LinearForce::write(out, indent+2); diff --git a/panda/src/physics/linearCylinderVortexForce.h b/panda/src/physics/linearCylinderVortexForce.h index 5698aa9d8d..e04328580f 100644 --- a/panda/src/physics/linearCylinderVortexForce.h +++ b/panda/src/physics/linearCylinderVortexForce.h @@ -43,7 +43,7 @@ PUBLISHED: INLINE PN_stdfloat get_length() const; virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: PN_stdfloat _radius; diff --git a/panda/src/physics/linearDistanceForce.cxx b/panda/src/physics/linearDistanceForce.cxx index 65922d0a2a..b48907feeb 100644 --- a/panda/src/physics/linearDistanceForce.cxx +++ b/panda/src/physics/linearDistanceForce.cxx @@ -57,7 +57,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearDistanceForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearDistanceForce:\n"; out.width(indent+2); out<<""; out<<"_force_center "<<_force_center<<"\n"; diff --git a/panda/src/physics/linearDistanceForce.h b/panda/src/physics/linearDistanceForce.h index 4afa6f2d11..208fc38bfd 100644 --- a/panda/src/physics/linearDistanceForce.h +++ b/panda/src/physics/linearDistanceForce.h @@ -40,7 +40,7 @@ PUBLISHED: INLINE PN_stdfloat get_scalar_term() const; virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: LPoint3 _force_center; diff --git a/panda/src/physics/linearEulerIntegrator.cxx b/panda/src/physics/linearEulerIntegrator.cxx index f208eda299..0ba61f7be4 100644 --- a/panda/src/physics/linearEulerIntegrator.cxx +++ b/panda/src/physics/linearEulerIntegrator.cxx @@ -199,7 +199,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearEulerIntegrator:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"LinearEulerIntegrator:\n"; diff --git a/panda/src/physics/linearEulerIntegrator.h b/panda/src/physics/linearEulerIntegrator.h index c7b6d3ff47..566c16d1d2 100644 --- a/panda/src/physics/linearEulerIntegrator.h +++ b/panda/src/physics/linearEulerIntegrator.h @@ -26,7 +26,7 @@ PUBLISHED: virtual ~LinearEulerIntegrator(); virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: virtual void child_integrate(Physical *physical, diff --git a/panda/src/physics/linearForce.cxx b/panda/src/physics/linearForce.cxx index dde98eba84..e7481a2703 100644 --- a/panda/src/physics/linearForce.cxx +++ b/panda/src/physics/linearForce.cxx @@ -92,7 +92,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearForce (id "<. */ void LinearFrictionForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearFrictionForce:\n"; out.width(indent+2); out<<""; out<<"_coef "<<_coef<<":\n"; diff --git a/panda/src/physics/linearFrictionForce.h b/panda/src/physics/linearFrictionForce.h index 8ba4d19534..6e58b6d332 100644 --- a/panda/src/physics/linearFrictionForce.h +++ b/panda/src/physics/linearFrictionForce.h @@ -29,7 +29,7 @@ PUBLISHED: INLINE PN_stdfloat get_coef() const; virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: PN_stdfloat _coef; diff --git a/panda/src/physics/linearIntegrator.cxx b/panda/src/physics/linearIntegrator.cxx index c58f9a4904..ebb6655a91 100644 --- a/panda/src/physics/linearIntegrator.cxx +++ b/panda/src/physics/linearIntegrator.cxx @@ -78,7 +78,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearIntegrator:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearIntegrator:\n"; out.width(indent+2); out<<""; out<<"_max_linear_dt "<<_max_linear_dt<<" (class static)\n"; diff --git a/panda/src/physics/linearIntegrator.h b/panda/src/physics/linearIntegrator.h index d5e6a1375d..85d717677b 100644 --- a/panda/src/physics/linearIntegrator.h +++ b/panda/src/physics/linearIntegrator.h @@ -33,7 +33,7 @@ public: PUBLISHED: virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; protected: LinearIntegrator(); diff --git a/panda/src/physics/linearJitterForce.cxx b/panda/src/physics/linearJitterForce.cxx index d74a14fac6..80809a0f28 100644 --- a/panda/src/physics/linearJitterForce.cxx +++ b/panda/src/physics/linearJitterForce.cxx @@ -68,7 +68,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearJitterForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearJitterForce:\n"; LinearRandomForce::write(out, indent+2); diff --git a/panda/src/physics/linearJitterForce.h b/panda/src/physics/linearJitterForce.h index 076d7d12ca..eba7b0c9ff 100644 --- a/panda/src/physics/linearJitterForce.h +++ b/panda/src/physics/linearJitterForce.h @@ -27,7 +27,7 @@ PUBLISHED: virtual ~LinearJitterForce(); virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: virtual LVector3 get_child_vector(const PhysicsObject *po); diff --git a/panda/src/physics/linearNoiseForce.cxx b/panda/src/physics/linearNoiseForce.cxx index b7d9109f8f..b86754b8fe 100644 --- a/panda/src/physics/linearNoiseForce.cxx +++ b/panda/src/physics/linearNoiseForce.cxx @@ -146,7 +146,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearNoiseForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"LinearNoiseForce:"; diff --git a/panda/src/physics/linearNoiseForce.h b/panda/src/physics/linearNoiseForce.h index b87fec2256..74b1ccd2d7 100644 --- a/panda/src/physics/linearNoiseForce.h +++ b/panda/src/physics/linearNoiseForce.h @@ -28,7 +28,7 @@ PUBLISHED: virtual ~LinearNoiseForce(); virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; public: static ConfigVariableInt _random_seed; diff --git a/panda/src/physics/linearRandomForce.cxx b/panda/src/physics/linearRandomForce.cxx index 252397c5bc..f961fdba4e 100644 --- a/panda/src/physics/linearRandomForce.cxx +++ b/panda/src/physics/linearRandomForce.cxx @@ -60,7 +60,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearRandomForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearRandomForce:\n"; LinearForce::write(out, indent+2); diff --git a/panda/src/physics/linearRandomForce.h b/panda/src/physics/linearRandomForce.h index 2c05fd9763..ad440c034f 100644 --- a/panda/src/physics/linearRandomForce.h +++ b/panda/src/physics/linearRandomForce.h @@ -27,7 +27,7 @@ PUBLISHED: virtual ~LinearRandomForce(); virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; protected: static PN_stdfloat bounded_rand(); diff --git a/panda/src/physics/linearSinkForce.cxx b/panda/src/physics/linearSinkForce.cxx index bee27f2d48..066fc64bef 100644 --- a/panda/src/physics/linearSinkForce.cxx +++ b/panda/src/physics/linearSinkForce.cxx @@ -78,7 +78,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearSinkForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearSinkForce:\n"; LinearDistanceForce::write(out, indent+2); diff --git a/panda/src/physics/linearSinkForce.h b/panda/src/physics/linearSinkForce.h index 42f158d184..d8127049f1 100644 --- a/panda/src/physics/linearSinkForce.h +++ b/panda/src/physics/linearSinkForce.h @@ -28,7 +28,7 @@ PUBLISHED: virtual ~LinearSinkForce(); virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: virtual LVector3 get_child_vector(const PhysicsObject *po); diff --git a/panda/src/physics/linearSourceForce.cxx b/panda/src/physics/linearSourceForce.cxx index 88db962127..87e8d4e6ef 100644 --- a/panda/src/physics/linearSourceForce.cxx +++ b/panda/src/physics/linearSourceForce.cxx @@ -78,7 +78,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearSourceForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearSourceForce:\n"; LinearDistanceForce::write(out, indent+2); diff --git a/panda/src/physics/linearSourceForce.h b/panda/src/physics/linearSourceForce.h index f6b2358c22..7d757a032f 100644 --- a/panda/src/physics/linearSourceForce.h +++ b/panda/src/physics/linearSourceForce.h @@ -28,7 +28,7 @@ PUBLISHED: virtual ~LinearSourceForce(); virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: virtual LVector3 get_child_vector(const PhysicsObject *po); diff --git a/panda/src/physics/linearUserDefinedForce.cxx b/panda/src/physics/linearUserDefinedForce.cxx index 4f6c4f4063..8e009aa6d9 100644 --- a/panda/src/physics/linearUserDefinedForce.cxx +++ b/panda/src/physics/linearUserDefinedForce.cxx @@ -72,7 +72,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearUserDefinedForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearUserDefinedForce:\n"; LinearForce::write(out, indent+2); diff --git a/panda/src/physics/linearUserDefinedForce.h b/panda/src/physics/linearUserDefinedForce.h index 3f05b1ea77..6a1d4bed42 100644 --- a/panda/src/physics/linearUserDefinedForce.h +++ b/panda/src/physics/linearUserDefinedForce.h @@ -29,7 +29,7 @@ PUBLISHED: INLINE void set_proc(LVector3 (*proc)(const PhysicsObject *)); virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: LVector3 (*_proc)(const PhysicsObject *po); diff --git a/panda/src/physics/linearVectorForce.cxx b/panda/src/physics/linearVectorForce.cxx index 47848073ec..ed2012dccf 100644 --- a/panda/src/physics/linearVectorForce.cxx +++ b/panda/src/physics/linearVectorForce.cxx @@ -84,7 +84,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void LinearVectorForce:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"LinearVectorForce:\n"; out.width(indent+2); out<<""; out<<"_fvec "<<_fvec<<"\n"; diff --git a/panda/src/physics/linearVectorForce.h b/panda/src/physics/linearVectorForce.h index ca12ab6bc5..c0a5cd2ea6 100644 --- a/panda/src/physics/linearVectorForce.h +++ b/panda/src/physics/linearVectorForce.h @@ -34,7 +34,7 @@ PUBLISHED: INLINE LVector3 get_local_vector() const; virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; public: INLINE LinearVectorForce& operator += (const LinearVectorForce &other); diff --git a/panda/src/physics/physical.cxx b/panda/src/physics/physical.cxx index f7e64e0507..9ca8f28b7a 100644 --- a/panda/src/physics/physical.cxx +++ b/panda/src/physics/physical.cxx @@ -134,7 +134,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void Physical:: -write_physics_objects(ostream &out, unsigned int indent) const { +write_physics_objects(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_physics_objects ("<<_physics_objects.size()<<" objects)\n"; @@ -150,7 +150,7 @@ write_physics_objects(ostream &out, unsigned int indent) const { * Write a string representation of this instance to . */ void Physical:: -write_linear_forces(ostream &out, unsigned int indent) const { +write_linear_forces(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_linear_forces ("<<_linear_forces.size()<<" forces)\n"; @@ -166,7 +166,7 @@ write_linear_forces(ostream &out, unsigned int indent) const { * Write a string representation of this instance to . */ void Physical:: -write_angular_forces(ostream &out, unsigned int indent) const { +write_angular_forces(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_angular_forces ("<<_angular_forces.size()<<" forces)\n"; @@ -182,7 +182,7 @@ write_angular_forces(ostream &out, unsigned int indent) const { * Write a string representation of this instance to . */ void Physical:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"Physical\n"; write_physics_objects(out, indent+2); diff --git a/panda/src/physics/physical.h b/panda/src/physics/physical.h index 64550823af..8a51e43e51 100644 --- a/panda/src/physics/physical.h +++ b/panda/src/physics/physical.h @@ -75,12 +75,12 @@ PUBLISHED: virtual void output(ostream &out = cout) const; virtual void write_physics_objects( - ostream &out = cout, unsigned int indent=0) const; + ostream &out = cout, int indent=0) const; virtual void write_linear_forces( - ostream &out = cout, unsigned int indent=0) const; + ostream &out = cout, int indent=0) const; virtual void write_angular_forces( - ostream &out = cout, unsigned int indent=0) const; - virtual void write(ostream &out = cout, unsigned int indent=0) const; + ostream &out = cout, int indent=0) const; + virtual void write(ostream &out = cout, int indent=0) const; public: INLINE const PhysicsObject::Vector &get_object_vector() const; diff --git a/panda/src/physics/physicalNode.cxx b/panda/src/physics/physicalNode.cxx index daa454aff1..31343f925a 100644 --- a/panda/src/physics/physicalNode.cxx +++ b/panda/src/physics/physicalNode.cxx @@ -133,7 +133,7 @@ remove_physical(size_t index) { * Write a string representation of this instance to . */ void PhysicalNode:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"PhysicalNode:\n"; // PandaNode::write(out, indent+2); diff --git a/panda/src/physics/physicalNode.h b/panda/src/physics/physicalNode.h index 24bd272fdc..42f6822dde 100644 --- a/panda/src/physics/physicalNode.h +++ b/panda/src/physics/physicalNode.h @@ -43,7 +43,7 @@ PUBLISHED: MAKE_SEQ_PROPERTY(physicals, get_num_physicals, get_physical, set_physical, remove_physical, insert_physical); - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; public: virtual ~PhysicalNode(); diff --git a/panda/src/physics/physicsManager.cxx b/panda/src/physics/physicsManager.cxx index b108176dd6..60d237d167 100644 --- a/panda/src/physics/physicsManager.cxx +++ b/panda/src/physics/physicsManager.cxx @@ -186,7 +186,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void PhysicsManager:: -write_physicals(ostream &out, unsigned int indent) const { +write_physicals(ostream &out, int indent) const { #ifndef NDEBUG //[ if (indent>10) { return; @@ -206,7 +206,7 @@ write_physicals(ostream &out, unsigned int indent) const { * Write a string representation of this instance to . */ void PhysicsManager:: -write_linear_forces(ostream &out, unsigned int indent) const { +write_linear_forces(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_linear_forces ("<<_linear_forces.size()<<" forces)\n"; @@ -222,7 +222,7 @@ write_linear_forces(ostream &out, unsigned int indent) const { * Write a string representation of this instance to . */ void PhysicsManager:: -write_angular_forces(ostream &out, unsigned int indent) const { +write_angular_forces(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"_angular_forces ("<<_angular_forces.size()<<" forces)\n"; @@ -238,7 +238,7 @@ write_angular_forces(ostream &out, unsigned int indent) const { * Write a string representation of this instance to . */ void PhysicsManager:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"PhysicsManager:\n"; if (indent>20) { @@ -268,7 +268,7 @@ write(ostream &out, unsigned int indent) const { * Write a string representation of this instance to . */ void PhysicsManager:: -debug_output(ostream &out, unsigned int indent) const { +debug_output(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"PhysicsManager li"<<(_linear_integrator?1:0)<<" ai"<<(_angular_integrator?1:0)<<"\n"; out<<" _physicals "<<_physicals.size()<<"\n"; diff --git a/panda/src/physics/physicsManager.h b/panda/src/physics/physicsManager.h index 80319ef2f0..c79c180dab 100644 --- a/panda/src/physics/physicsManager.h +++ b/panda/src/physics/physicsManager.h @@ -72,12 +72,12 @@ PUBLISHED: void init_random_seed(); virtual void output(ostream &out) const; - virtual void write_physicals(ostream &out, unsigned int indent=0) const; - virtual void write_linear_forces(ostream &out, unsigned int indent=0) const; - virtual void write_angular_forces(ostream &out, unsigned int indent=0) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write_physicals(ostream &out, int indent=0) const; + virtual void write_linear_forces(ostream &out, int indent=0) const; + virtual void write_angular_forces(ostream &out, int indent=0) const; + virtual void write(ostream &out, int indent=0) const; - virtual void debug_output(ostream &out, unsigned int indent=0) const; + virtual void debug_output(ostream &out, int indent=0) const; public: friend class Physical; diff --git a/panda/src/physics/physicsObject.cxx b/panda/src/physics/physicsObject.cxx index dc9b663771..96651949d5 100644 --- a/panda/src/physics/physicsObject.cxx +++ b/panda/src/physics/physicsObject.cxx @@ -160,7 +160,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ void PhysicsObject:: -write(ostream &out, unsigned int indent) const { +write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"PhysicsObject "<<_name<<"\n"; diff --git a/panda/src/physics/physicsObject.h b/panda/src/physics/physicsObject.h index 5cb266ae7f..7f30b373f7 100644 --- a/panda/src/physics/physicsObject.h +++ b/panda/src/physics/physicsObject.h @@ -97,7 +97,7 @@ PUBLISHED: #endif virtual void output(ostream &out) const; - virtual void write(ostream &out, unsigned int indent=0) const; + virtual void write(ostream &out, int indent=0) const; private: // physical diff --git a/panda/src/pnmimage/pnmImage.cxx b/panda/src/pnmimage/pnmImage.cxx index 3e3829ac52..d4fed72b3c 100644 --- a/panda/src/pnmimage/pnmImage.cxx +++ b/panda/src/pnmimage/pnmImage.cxx @@ -1016,9 +1016,9 @@ blend(int x, int y, float r, float g, float b, float alpha) { } else { // Blend the color with the previous color. LRGBColorf prev_rgb = get_xel(x, y); - r = r + (1.0f - alpha) * (get_red(x, y) - r); - g = g + (1.0f - alpha) * (get_green(x, y) - g); - b = b + (1.0f - alpha) * (get_blue(x, y) - b); + r = r + (1.0f - alpha) * (prev_rgb[0] - r); + g = g + (1.0f - alpha) * (prev_rgb[1] - g); + b = b + (1.0f - alpha) * (prev_rgb[2] - b); alpha = prev_alpha + alpha * (1.0f - prev_alpha); if (has_alpha()) { diff --git a/panda/src/pnmimagetypes/pnmFileTypeEXR.h b/panda/src/pnmimagetypes/pnmFileTypeEXR.h index 3a0827a74e..58292d11a8 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeEXR.h +++ b/panda/src/pnmimagetypes/pnmFileTypeEXR.h @@ -69,7 +69,6 @@ public: typedef std::vector ChannelNames; ChannelNames _channel_names; - IMF::PixelType _best_pixel_type; }; class Writer : public PNMWriter { diff --git a/panda/src/pnmimagetypes/pnmFileTypeJPG.h b/panda/src/pnmimagetypes/pnmFileTypeJPG.h index b82534189a..591c7fe247 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeJPG.h +++ b/panda/src/pnmimagetypes/pnmFileTypeJPG.h @@ -89,18 +89,6 @@ public: }; typedef struct my_error_mgr *_my_error_ptr; struct my_error_mgr _jerr; - unsigned long pos; - - unsigned long offBits; - - unsigned short cBitCount; - int indexed; - int classv; - - pixval R[256]; /* reds */ - pixval G[256]; /* greens */ - pixval B[256]; /* blues */ - bool _is_valid; }; diff --git a/panda/src/text/staticTextFont.h b/panda/src/text/staticTextFont.h index 95f8430975..99a3e2d309 100644 --- a/panda/src/text/staticTextFont.h +++ b/panda/src/text/staticTextFont.h @@ -55,7 +55,6 @@ private: typedef pmap Glyphs; Glyphs _glyphs; - PN_stdfloat _font_height; PT(PandaNode) _font; CoordinateSystem _cs; diff --git a/panda/src/text/textNode.h b/panda/src/text/textNode.h index 50266cbfd7..4e24b110b9 100644 --- a/panda/src/text/textNode.h +++ b/panda/src/text/textNode.h @@ -343,7 +343,6 @@ private: int _max_rows; GeomEnums::UsageHint _usage_hint; int _flatten_flags; - bool _dynamic_merge; PN_stdfloat _frame_width; PN_stdfloat _card_border_size; PN_stdfloat _card_border_uv_portion; diff --git a/panda/src/tinydisplay/store_pixel.h b/panda/src/tinydisplay/store_pixel.h index 8352e842a4..d6fb1540c6 100644 --- a/panda/src/tinydisplay/store_pixel.h +++ b/panda/src/tinydisplay/store_pixel.h @@ -26,8 +26,8 @@ FNAME(store_pixel) (ZBuffer *zb, PIXEL &result, int r, int g, int b, int a) { r = STORE_PIXEL_0(fr, ((unsigned int)r * OP_A(fr, r) >> 16) + ((unsigned int)fr * OP_B(fr, r) >> 16)); g = STORE_PIXEL_1(fg, ((unsigned int)g * OP_A(fg, g) >> 16) + ((unsigned int)fg * OP_B(fg, g) >> 16)); - b = STORE_PIXEL_2(fg, ((unsigned int)b * OP_A(fb, b) >> 16) + ((unsigned int)fb * OP_B(fb, b) >> 16)); - a = STORE_PIXEL_3(fg, ((unsigned int)a * OP_A(fa, a) >> 16) + ((unsigned int)fa * OP_B(fa, a) >> 16)); + b = STORE_PIXEL_2(fb, ((unsigned int)b * OP_A(fb, b) >> 16) + ((unsigned int)fb * OP_B(fb, b) >> 16)); + a = STORE_PIXEL_3(fa, ((unsigned int)a * OP_A(fa, a) >> 16) + ((unsigned int)fa * OP_B(fa, a) >> 16)); result = RGBA_TO_PIXEL(r, g, b, a); } @@ -43,8 +43,8 @@ FNAME_S(store_pixel) (ZBuffer *zb, PIXEL &result, int r, int g, int b, int a) { r = STORE_PIXEL_0(fr, ((unsigned int)r * OP_A(fr, r) >> 16) + ((unsigned int)fr * OP_B(fr, r) >> 16)); g = STORE_PIXEL_1(fg, ((unsigned int)g * OP_A(fg, g) >> 16) + ((unsigned int)fg * OP_B(fg, g) >> 16)); - b = STORE_PIXEL_2(fg, ((unsigned int)b * OP_A(fb, b) >> 16) + ((unsigned int)fb * OP_B(fb, b) >> 16)); - a = STORE_PIXEL_3(fg, ((unsigned int)a * OP_A(fa, a) >> 16) + ((unsigned int)fa * OP_B(fa, a) >> 16)); + b = STORE_PIXEL_2(fb, ((unsigned int)b * OP_A(fb, b) >> 16) + ((unsigned int)fb * OP_B(fb, b) >> 16)); + a = STORE_PIXEL_3(fa, ((unsigned int)a * OP_A(fa, a) >> 16) + ((unsigned int)fa * OP_B(fa, a) >> 16)); result = SRGBA_TO_PIXEL(r, g, b, a); } diff --git a/panda/src/tinydisplay/zfeatures.h b/panda/src/tinydisplay/zfeatures.h index 6092b87c24..73a61d95c5 100644 --- a/panda/src/tinydisplay/zfeatures.h +++ b/panda/src/tinydisplay/zfeatures.h @@ -39,4 +39,10 @@ /* Number of simultaneous texture stages supported (multitexture). */ #define MAX_TEXTURE_STAGES 3 +#ifdef __GNUC__ +#define UNUSED __attribute__((unused)) +#else +#define UNUSED +#endif + #endif /* _tgl_features_h_ */ diff --git a/panda/src/tinydisplay/ztriangle_two.h b/panda/src/tinydisplay/ztriangle_two.h index 6bb255ce01..647dcba605 100644 --- a/panda/src/tinydisplay/ztriangle_two.h +++ b/panda/src/tinydisplay/ztriangle_two.h @@ -187,7 +187,7 @@ FNAME(flat_textured) (ZBuffer *zb, zz=z >> ZB_POINT_Z_FRAC_BITS; \ if (ZCMP(pz[_a], zz)) { \ tmp = ZB_LOOKUP_TEXTURE(texture_def, s, t, mipmap_level, mipmap_dx); \ - int a = PALPHA_MULT(oa0, PIXEL_A(tmp)); \ + UNUSED int a = PALPHA_MULT(oa0, PIXEL_A(tmp)); \ if (ACMP(zb, a)) { \ STORE_PIX(pp[_a], \ RGBA_TO_PIXEL(PCOMPONENT_MULT(or0, PIXEL_R(tmp)), \ @@ -249,7 +249,7 @@ FNAME(smooth_textured) (ZBuffer *zb, zz=z >> ZB_POINT_Z_FRAC_BITS; \ if (ZCMP(pz[_a], zz)) { \ tmp = ZB_LOOKUP_TEXTURE(texture_def, s, t, mipmap_level, mipmap_dx); \ - int a = PALPHA_MULT(oa1, PIXEL_A(tmp)); \ + UNUSED int a = PALPHA_MULT(oa1, PIXEL_A(tmp)); \ if (ACMP(zb, a)) { \ STORE_PIX(pp[_a], \ RGBA_TO_PIXEL(PCOMPONENT_MULT(or1, PIXEL_R(tmp)), \ @@ -431,7 +431,7 @@ FNAME(flat_perspective) (ZBuffer *zb, zz=z >> ZB_POINT_Z_FRAC_BITS; \ if (ZCMP(pz[_a], zz)) { \ tmp = ZB_LOOKUP_TEXTURE(texture_def, s, t, mipmap_level, mipmap_dx); \ - int a = PALPHA_MULT(oa0, PIXEL_A(tmp)); \ + UNUSED int a = PALPHA_MULT(oa0, PIXEL_A(tmp)); \ if (ACMP(zb, a)) { \ STORE_PIX(pp[_a], \ RGBA_TO_PIXEL(PCOMPONENT_MULT(or0, PIXEL_R(tmp)), \ @@ -567,7 +567,7 @@ FNAME(smooth_perspective) (ZBuffer *zb, zz=z >> ZB_POINT_Z_FRAC_BITS; \ if (ZCMP(pz[_a], zz)) { \ tmp = ZB_LOOKUP_TEXTURE(texture_def, s, t, mipmap_level, mipmap_dx); \ - int a = PALPHA_MULT(oa1, PIXEL_A(tmp)); \ + UNUSED int a = PALPHA_MULT(oa1, PIXEL_A(tmp)); \ if (ACMP(zb, a)) { \ STORE_PIX(pp[_a], \ RGBA_TO_PIXEL(PCOMPONENT_MULT(or1, PIXEL_R(tmp)), \ @@ -695,9 +695,9 @@ FNAME(smooth_multitex2) (ZBuffer *zb, zz=z >> ZB_POINT_Z_FRAC_BITS; \ if (ZCMP(pz[_a], zz)) { \ tmp = ZB_LOOKUP_TEXTURE(&zb->current_textures[0], s, t, mipmap_level, mipmap_dx); \ - int a = PALPHA_MULT(oa1, PIXEL_A(tmp)); \ + UNUSED int a = PALPHA_MULT(oa1, PIXEL_A(tmp)); \ if (ACMP(zb, a)) { \ - int tmpa = ZB_LOOKUP_TEXTURE(&zb->current_textures[1], sa, ta, mipmap_levela, mipmap_dxa); \ + UNUSED int tmpa = ZB_LOOKUP_TEXTURE(&zb->current_textures[1], sa, ta, mipmap_levela, mipmap_dxa); \ STORE_PIX(pp[_a], \ RGBA_TO_PIXEL(PCOMPONENT_MULT3(or1, PIXEL_R(tmp), PIXEL_R(tmpa)), \ PCOMPONENT_MULT3(og1, PIXEL_G(tmp), PIXEL_G(tmpa)), \ @@ -853,10 +853,10 @@ FNAME(smooth_multitex3) (ZBuffer *zb, zz=z >> ZB_POINT_Z_FRAC_BITS; \ if (ZCMP(pz[_a], zz)) { \ tmp = ZB_LOOKUP_TEXTURE(&zb->current_textures[0], s, t, mipmap_level, mipmap_dx); \ - int a = PALPHA_MULT(oa1, PIXEL_A(tmp)); \ + UNUSED int a = PALPHA_MULT(oa1, PIXEL_A(tmp)); \ if (ACMP(zb, a)) { \ - int tmpa = ZB_LOOKUP_TEXTURE(&zb->current_textures[1], sa, ta, mipmap_levela, mipmap_dxa); \ - int tmpb = ZB_LOOKUP_TEXTURE(&zb->current_textures[2], sb, tb, mipmap_levelb, mipmap_dxb); \ + UNUSED int tmpa = ZB_LOOKUP_TEXTURE(&zb->current_textures[1], sa, ta, mipmap_levela, mipmap_dxa); \ + UNUSED int tmpb = ZB_LOOKUP_TEXTURE(&zb->current_textures[2], sb, tb, mipmap_levelb, mipmap_dxb); \ STORE_PIX(pp[_a], \ RGBA_TO_PIXEL(PCOMPONENT_MULT4(or1, PIXEL_R(tmp), PIXEL_R(tmpa), PIXEL_R(tmpb)), \ PCOMPONENT_MULT4(og1, PIXEL_G(tmp), PIXEL_G(tmpa), PIXEL_G(tmpb)), \ diff --git a/pandatool/src/egg-palettize/eggPalettize.h b/pandatool/src/egg-palettize/eggPalettize.h index a0c6208d31..8bb1c65774 100644 --- a/pandatool/src/egg-palettize/eggPalettize.h +++ b/pandatool/src/egg-palettize/eggPalettize.h @@ -62,7 +62,6 @@ private: bool _omitall; bool _redo_all; bool _redo_eggs; - bool _dont_lock_txa; bool _describe_input_file; bool _remove_eggs; diff --git a/pandatool/src/eggbase/eggWriter.h b/pandatool/src/eggbase/eggWriter.h index 7d08eab3a0..9ef09fffe6 100644 --- a/pandatool/src/eggbase/eggWriter.h +++ b/pandatool/src/eggbase/eggWriter.h @@ -40,7 +40,6 @@ protected: private: ofstream _output_stream; - ostream *_output_ptr; }; #endif diff --git a/pandatool/src/objegg/eggToObjConverter.h b/pandatool/src/objegg/eggToObjConverter.h index a36fa77500..df54648a72 100644 --- a/pandatool/src/objegg/eggToObjConverter.h +++ b/pandatool/src/objegg/eggToObjConverter.h @@ -67,8 +67,6 @@ private: const UniqueVertices &unique); private: - bool _triangulate_polygons; - UniqueVertices _unique_vert3, _unique_vert4, _unique_uv2, _unique_uv3, _unique_norm; VertexMap _vmap; EggGroupNode *_current_group; diff --git a/pandatool/src/palettizer/eggFile.h b/pandatool/src/palettizer/eggFile.h index 39f3b577df..696ec833e6 100644 --- a/pandatool/src/palettizer/eggFile.h +++ b/pandatool/src/palettizer/eggFile.h @@ -90,7 +90,6 @@ private: typedef pvector Textures; Textures _textures; - bool _noabs; bool _first_txa_match; PaletteGroups _explicitly_assigned_groups; PaletteGroup *_default_group; diff --git a/pandatool/src/palettizer/texturePlacement.h b/pandatool/src/palettizer/texturePlacement.h index be4d667a24..ca69f93ea0 100644 --- a/pandatool/src/palettizer/texturePlacement.h +++ b/pandatool/src/palettizer/texturePlacement.h @@ -127,7 +127,6 @@ private: // This value is only filled in while reading from the bam file; don't use // it otherwise. int _num_references; - int _margin_override; int _num_textureSwaps; public: diff --git a/pandatool/src/pfmprogs/pfmBba.h b/pandatool/src/pfmprogs/pfmBba.h index 518f5568d2..4d01ca647d 100644 --- a/pandatool/src/pfmprogs/pfmBba.h +++ b/pandatool/src/pfmprogs/pfmBba.h @@ -43,7 +43,6 @@ private: bool _got_zero_special; bool _got_output_filename; Filename _output_filename; - int _reorder_index; }; #endif From c17cb11dfaae8cd8b9d5a8fc32dda25ccc615839 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 30 May 2018 11:12:15 +0200 Subject: [PATCH 209/247] makepanda: enable more warnings by default --- makepanda/makepanda.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 6ba8974c8e..92ddeaebcb 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1354,6 +1354,9 @@ def CompileCxx(obj,src,opts): if (optlevel==3): cmd += " -O2" if (optlevel==4): cmd += " -O3 -DNDEBUG" + # Enable more warnings. + cmd += " -Wall -Wno-reorder -Wno-unused-function" + if src.endswith(".c"): cmd += ' ' + CFLAGS else: From 00e259d4dd82f62a10daa9397a57790e2a798985 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Tue, 29 May 2018 22:20:25 -0600 Subject: [PATCH 210/247] dtoolbase: Fixup NODEFAULT macro 1. Test for Clang before _MSC_VER (Clang defines this on Windows) 2. Use it in pdtoa.cxx --- dtool/src/dtoolbase/dtoolbase.h | 4 ++-- dtool/src/dtoolbase/pdtoa.cxx | 9 +-------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/dtool/src/dtoolbase/dtoolbase.h b/dtool/src/dtoolbase/dtoolbase.h index 4e7b73ba9a..1614d05cfd 100644 --- a/dtool/src/dtoolbase/dtoolbase.h +++ b/dtool/src/dtoolbase/dtoolbase.h @@ -73,10 +73,10 @@ // 'assume at least one of the cases is always true') #ifdef _DEBUG #define NODEFAULT default: assert(0); break; -#elif defined(_MSC_VER) -#define NODEFAULT default: __assume(0); // special VC keyword #elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || __has_builtin(__builtin_unreachable) #define NODEFAULT default: __builtin_unreachable(); +#elif defined(_MSC_VER) +#define NODEFAULT default: __assume(0); // special VC keyword #else #define NODEFAULT #endif diff --git a/dtool/src/dtoolbase/pdtoa.cxx b/dtool/src/dtoolbase/pdtoa.cxx index 47aa2db50a..2ef158f4ac 100644 --- a/dtool/src/dtoolbase/pdtoa.cxx +++ b/dtool/src/dtoolbase/pdtoa.cxx @@ -271,14 +271,7 @@ inline static void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, cha case 3: d = p1 / 100; p1 %= 100; break; case 2: d = p1 / 10; p1 %= 10; break; case 1: d = p1; p1 = 0; break; - default: -#if defined(_MSC_VER) - __assume(0); -#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) - __builtin_unreachable(); -#else - d = 0; -#endif + NODEFAULT } if (d || *len) buffer[(*len)++] = '0' + static_cast(d); From 1c6ae84cdce2772ffef9c4ff9197ba2ed29b6b25 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Wed, 30 May 2018 12:04:06 -0600 Subject: [PATCH 211/247] dtoolutil: Remove HAVE_OPEN_MASK Rationale: 1. Per standard, fstream::open takes 2 arguments. If platforms add a third, they're out of spec. 2. The only platform I could find that takes a file mask specifically as the third argument is IRIX, which Panda hasn't targeted in forever. 3. The mask being requested isn't even particularly interesting - falling back to a platform default is best. 4. When USE_PANDAFILESTREAM is defined, pfstream is implemented as PandaFileStream, which doesn't have a three-argument open() and breaks immediately. 5. makepanda doesn't ever define HAVE_OPEN_MASK 6. It's been broken for so long that, if it were important to anybody, it would have been fixed by now. --- dtool/src/dtoolutil/filename.cxx | 44 +++----------------------------- makepanda/makepanda.py | 1 - 2 files changed, 4 insertions(+), 41 deletions(-) diff --git a/dtool/src/dtoolutil/filename.cxx b/dtool/src/dtoolutil/filename.cxx index 42bdf12e2f..2df2647490 100644 --- a/dtool/src/dtoolutil/filename.cxx +++ b/dtool/src/dtoolutil/filename.cxx @@ -1921,15 +1921,10 @@ open_write(ofstream &stream, bool truncate) const { stream.clear(); #ifdef WIN32_VC wstring os_specific = to_os_specific_w(); - stream.open(os_specific.c_str(), open_mode); #else string os_specific = to_os_specific(); -#ifdef HAVE_OPEN_MASK - stream.open(os_specific.c_str(), open_mode, 0666); -#else - stream.open(os_specific.c_str(), open_mode); -#endif #endif // WIN32_VC + stream.open(os_specific.c_str(), open_mode); return (!stream.fail()); } @@ -1958,15 +1953,10 @@ open_append(ofstream &stream) const { stream.clear(); #ifdef WIN32_VC wstring os_specific = to_os_specific_w(); - stream.open(os_specific.c_str(), open_mode); #else string os_specific = to_os_specific(); -#ifdef HAVE_OPEN_MASK - stream.open(os_specific.c_str(), open_mode, 0666); -#else - stream.open(os_specific.c_str(), open_mode); -#endif #endif // WIN32_VC + stream.open(os_specific.c_str(), open_mode); return (!stream.fail()); } @@ -2005,15 +1995,10 @@ open_read_write(fstream &stream, bool truncate) const { stream.clear(); #ifdef WIN32_VC wstring os_specific = to_os_specific_w(); - stream.open(os_specific.c_str(), open_mode); #else string os_specific = to_os_specific(); -#ifdef HAVE_OPEN_MASK - stream.open(os_specific.c_str(), open_mode, 0666); -#else - stream.open(os_specific.c_str(), open_mode); -#endif #endif // WIN32_VC + stream.open(os_specific.c_str(), open_mode); return (!stream.fail()); } @@ -2042,15 +2027,10 @@ open_read_append(fstream &stream) const { stream.clear(); #ifdef WIN32_VC wstring os_specific = to_os_specific_w(); - stream.open(os_specific.c_str(), open_mode); #else string os_specific = to_os_specific(); -#ifdef HAVE_OPEN_MASK - stream.open(os_specific.c_str(), open_mode, 0666); -#else - stream.open(os_specific.c_str(), open_mode); -#endif #endif // WIN32_VC + stream.open(os_specific.c_str(), open_mode); return (!stream.fail()); } @@ -2125,11 +2105,7 @@ open_write(pofstream &stream, bool truncate) const { stream.clear(); string os_specific = to_os_specific(); -#ifdef HAVE_OPEN_MASK - stream.open(os_specific.c_str(), open_mode, 0666); -#else stream.open(os_specific.c_str(), open_mode); -#endif return (!stream.fail()); } @@ -2159,11 +2135,7 @@ open_append(pofstream &stream) const { stream.clear(); string os_specific = to_os_specific(); -#ifdef HAVE_OPEN_MASK - stream.open(os_specific.c_str(), open_mode, 0666); -#else stream.open(os_specific.c_str(), open_mode); -#endif return (!stream.fail()); } @@ -2203,11 +2175,7 @@ open_read_write(pfstream &stream, bool truncate) const { stream.clear(); string os_specific = to_os_specific(); -#ifdef HAVE_OPEN_MASK - stream.open(os_specific.c_str(), open_mode, 0666); -#else stream.open(os_specific.c_str(), open_mode); -#endif return (!stream.fail()); } @@ -2237,11 +2205,7 @@ open_read_append(pfstream &stream) const { stream.clear(); string os_specific = to_os_specific(); -#ifdef HAVE_OPEN_MASK - stream.open(os_specific.c_str(), open_mode, 0666); -#else stream.open(os_specific.c_str(), open_mode); -#endif return (!stream.fail()); } diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 92ddeaebcb..b46f8186ac 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2270,7 +2270,6 @@ DTOOL_CONFIG=[ ("DO_PIPELINING", '1', '1'), ("DEFAULT_PATHSEP", '";"', '":"'), ("WORDS_BIGENDIAN", 'UNDEF', 'UNDEF'), - ("HAVE_OPEN_MASK", 'UNDEF', 'UNDEF'), ("PHAVE_LOCKF", '1', '1'), ("HAVE_WCHAR_T", '1', '1'), ("HAVE_WSTRING", '1', '1'), From db5dd98d33028ffbf1a10693b0534cd3057cb83e Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 30 May 2018 22:49:49 +0200 Subject: [PATCH 212/247] general: further warning fixes, use -Wno-unused-variable if NDEBUG Disabling unused variable checking is needed in NDEBUG builds because of the heavy use of temporary variables in asserts. --- dtool/src/cppparser/cppFunctionType.cxx | 6 ++-- dtool/src/cppparser/cppPreprocessor.cxx | 5 +--- dtool/src/dconfig/dconfig.I | 2 +- dtool/src/dtoolutil/executionEnvironment.cxx | 4 +-- dtool/src/dtoolutil/string_utils.I | 2 +- dtool/src/interrogate/functionRemap.cxx | 18 +++++------ .../interfaceMakerPythonNative.cxx | 4 +-- dtool/src/interrogatedb/dtool_super_base.cxx | 2 +- makepanda/makepanda.py | 7 +++++ panda/src/bullet/bulletConvexHullShape.cxx | 2 -- .../collide/collisionHandlerFluidPusher.cxx | 6 ++-- panda/src/egg2pg/eggSaver.cxx | 2 -- panda/src/express/datagram.I | 4 +-- panda/src/grutil/meshDrawer.h | 2 -- panda/src/grutil/pfmVizzer.cxx | 3 +- panda/src/mathutil/triangulator.cxx | 20 ++----------- panda/src/ode/odeTriMeshData.cxx | 2 +- panda/src/pgraph/fog.cxx | 1 - panda/src/pgui/pgScrollFrame.h | 2 -- panda/src/physics/baseIntegrator.cxx | 30 +++++++------------ panda/src/physics/physicsManager.I | 2 +- panda/src/physics/physicsManager.cxx | 2 +- panda/src/text/staticTextFont.cxx | 2 +- .../tinydisplay/tinyGraphicsStateGuardian.cxx | 1 - panda/src/tinydisplay/ztriangle.h | 4 +-- panda/src/tinydisplay/ztriangle_two.h | 2 +- pandatool/src/gtk-stats/gtkStatsLabel.cxx | 8 +++++ pandatool/src/gtk-stats/gtkStatsLabel.h | 1 + pandatool/src/objegg/objToEggConverter.cxx | 1 - 29 files changed, 62 insertions(+), 85 deletions(-) diff --git a/dtool/src/cppparser/cppFunctionType.cxx b/dtool/src/cppparser/cppFunctionType.cxx index 38eb3d98ba..497c46d4b9 100644 --- a/dtool/src/cppparser/cppFunctionType.cxx +++ b/dtool/src/cppparser/cppFunctionType.cxx @@ -71,17 +71,19 @@ operator = (const CPPFunctionType ©) { */ bool CPPFunctionType:: accepts_num_parameters(int num_parameters) { + assert(num_parameters >= 0); if (_parameters == NULL) { return (num_parameters == 0); } + size_t actual_num_parameters = _parameters->_parameters.size(); // If we passed too many parameters, it must have an ellipsis. - if (num_parameters > actual_num_parameters) { + if ((size_t)num_parameters > actual_num_parameters) { return _parameters->_includes_ellipsis; } // Make sure all superfluous parameters have a default value. - for (size_t i = num_parameters; i < actual_num_parameters; ++i) { + for (size_t i = (size_t)num_parameters; i < actual_num_parameters; ++i) { CPPInstance *param = _parameters->_parameters[i]; if (param->_initializer == NULL) { return false; diff --git a/dtool/src/cppparser/cppPreprocessor.cxx b/dtool/src/cppparser/cppPreprocessor.cxx index ecaecb98b6..899d1f076f 100644 --- a/dtool/src/cppparser/cppPreprocessor.cxx +++ b/dtool/src/cppparser/cppPreprocessor.cxx @@ -1579,7 +1579,6 @@ handle_if_directive(const string &args, const YYLTYPE &loc) { */ void CPPPreprocessor:: handle_include_directive(const string &args, const YYLTYPE &loc) { - bool okflag = false; Filename filename; Filename filename_as_referenced; bool angle_quotes = false; @@ -1599,7 +1598,6 @@ handle_include_directive(const string &args, const YYLTYPE &loc) { if (!expr.empty()) { if (expr[0] == '"' && expr[expr.size() - 1] == '"') { filename = expr.substr(1, expr.size() - 2); - okflag = true; if (_files.size() == 1) { // If we're currently processing a top-level file, record the include @@ -1614,7 +1612,6 @@ handle_include_directive(const string &args, const YYLTYPE &loc) { // same, as if they used quote marks. angle_quotes = true; } - okflag = true; if (_files.size() == 1) { // If we're currently processing a top-level file, record the include @@ -2552,7 +2549,7 @@ get_number(int c) { loc.last_column = get_col_number(); YYSTYPE result; - result.u.real = pstrtod(num.c_str(), (char **)NULL); + result.u.real = (long double)pstrtod(num.c_str(), (char **)NULL); return get_literal(REAL, loc, num, result); } diff --git a/dtool/src/dconfig/dconfig.I b/dtool/src/dconfig/dconfig.I index a49d57cd2c..0497ffc067 100644 --- a/dtool/src/dconfig/dconfig.I +++ b/dtool/src/dconfig/dconfig.I @@ -25,7 +25,7 @@ GetInt(const string &sym, int def) { float DConfig:: GetFloat(const string &sym, float def) { - ConfigVariableDouble var(sym, def, "DConfig", ConfigFlags::F_dconfig); + ConfigVariableDouble var(sym, (double)def, "DConfig", ConfigFlags::F_dconfig); return (float)var.get_value(); } diff --git a/dtool/src/dtoolutil/executionEnvironment.cxx b/dtool/src/dtoolutil/executionEnvironment.cxx index 9a2921efd2..2ede3b7253 100644 --- a/dtool/src/dtoolutil/executionEnvironment.cxx +++ b/dtool/src/dtoolutil/executionEnvironment.cxx @@ -755,10 +755,10 @@ read_args() { if (_binary_name.empty()) { _binary_name = buffer; } - int idx = strlen(buffer) + 1; + size_t idx = strlen(buffer) + 1; while (idx < bufsize) { _args.push_back((char*)(buffer + idx)); - int newidx = strlen(buffer + idx); + size_t newidx = strlen(buffer + idx); idx += newidx + 1; } } diff --git a/dtool/src/dtoolutil/string_utils.I b/dtool/src/dtoolutil/string_utils.I index e4e71766f8..f7878c3ba8 100644 --- a/dtool/src/dtoolutil/string_utils.I +++ b/dtool/src/dtoolutil/string_utils.I @@ -32,7 +32,7 @@ format_string(bool value) { INLINE string format_string(float value) { char buffer[32]; - pdtoa(value, buffer); + pdtoa((double)value, buffer); return string(buffer); } diff --git a/dtool/src/interrogate/functionRemap.cxx b/dtool/src/interrogate/functionRemap.cxx index 42a420644f..7299d9b5f8 100644 --- a/dtool/src/interrogate/functionRemap.cxx +++ b/dtool/src/interrogate/functionRemap.cxx @@ -767,12 +767,12 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak } // Check for a special meaning by name and signature. - int first_param = 0; + size_t first_param = 0; if (_has_this) { first_param = 1; } - if (_parameters.size() > (size_t)first_param && _parameters[first_param]._name == "self" && + if (_parameters.size() > first_param && _parameters[first_param]._name == "self" && TypeManager::is_pointer_to_PyObject(_parameters[first_param]._remap->get_orig_type())) { // Here's a special case. If the first parameter of a nonstatic method // is a PyObject * called "self", then we will automatically fill it in @@ -782,9 +782,9 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak _flags |= F_explicit_self; } - if ((int)_parameters.size() == first_param) { + if (_parameters.size() == first_param) { _args_type = InterfaceMaker::AT_no_args; - } else if ((int)_parameters.size() == first_param + 1 && + } else if (_parameters.size() == first_param + 1 && _parameters[first_param]._remap->get_default_value() == NULL) { _args_type = InterfaceMaker::AT_single_arg; } else { @@ -833,7 +833,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak } } else if (fname == "size" || fname == "__len__") { - if ((int)_parameters.size() == first_param && + if (_parameters.size() == first_param && TypeManager::is_integer(_return_type->get_new_type())) { // It receives no parameters, and returns an integer. _flags |= F_size; @@ -847,7 +847,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak } } else if (fname == "__iter__") { - if ((int)_parameters.size() == first_param && + if (_parameters.size() == first_param && TypeManager::is_pointer(_return_type->get_new_type())) { // It receives no parameters, and returns a pointer. _flags |= F_iter; @@ -870,7 +870,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak if (_args_type == InterfaceMaker::AT_varargs) { // Of course methods named "make" can still take kwargs, if they are // named. - for (int i = first_param; i < _parameters.size(); ++i) { + for (size_t i = first_param; i < _parameters.size(); ++i) { if (_parameters[i]._has_name) { _args_type = InterfaceMaker::AT_keyword_args; break; @@ -904,7 +904,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak if (_args_type == InterfaceMaker::AT_varargs) { // Every other method can take keyword arguments, if they take more // than one argument, and the arguments are named. - for (int i = first_param; i < _parameters.size(); ++i) { + for (size_t i = first_param; i < _parameters.size(); ++i) { if (_parameters[i]._has_name) { _args_type |= InterfaceMaker::AT_keyword_args; break; @@ -960,7 +960,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak // Constructors always take varargs, and possibly keyword args. _args_type = InterfaceMaker::AT_varargs; - for (int i = first_param; i < _parameters.size(); ++i) { + for (size_t i = first_param; i < _parameters.size(); ++i) { if (_parameters[i]._has_name) { _args_type = InterfaceMaker::AT_keyword_args; break; diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 3fd5d0245a..5d202167d4 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -3610,8 +3610,8 @@ write_function_for_name(ostream &out, Object *obj, std::set::iterator sii; for (sii = mii->second.begin(); sii != mii->second.end(); ++sii) { remap = (*sii); - int first_param = remap->_has_this ? 1 : 0; - for (int i = first_param; i < remap->_parameters.size(); ++i) { + size_t first_param = remap->_has_this ? 1u : 0u; + for (size_t i = first_param; i < remap->_parameters.size(); ++i) { if (remap->_parameters[i]._has_name) { strip_keyword_args = false; break; diff --git a/dtool/src/interrogatedb/dtool_super_base.cxx b/dtool/src/interrogatedb/dtool_super_base.cxx index 26b57a157d..610d89da8b 100644 --- a/dtool/src/interrogatedb/dtool_super_base.cxx +++ b/dtool/src/interrogatedb/dtool_super_base.cxx @@ -26,7 +26,7 @@ static PyObject *GetSuperBase(PyObject *self) { PyMethodDef Dtool_Methods_DTOOL_SUPER_BASE[] = { { "DtoolGetSuperBase", (PyCFunction) &GetSuperBase, METH_NOARGS, "Will Return SUPERbase Class"}, - { NULL, NULL } + { nullptr, nullptr, 0, nullptr } }; EXPCL_INTERROGATEDB void Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(PyObject *module) { diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index b46f8186ac..80b551c84f 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1357,6 +1357,13 @@ def CompileCxx(obj,src,opts): # Enable more warnings. cmd += " -Wall -Wno-reorder -Wno-unused-function" + if not src.endswith(".c"): + cmd += " -Wno-reorder" + + # Ignore unused variables in NDEBUG builds, often used in asserts. + if optlevel == 4: + cmd += " -Wno-unused-variable" + if src.endswith(".c"): cmd += ' ' + CFLAGS else: diff --git a/panda/src/bullet/bulletConvexHullShape.cxx b/panda/src/bullet/bulletConvexHullShape.cxx index 07d559c2fd..798aeda9e1 100644 --- a/panda/src/bullet/bulletConvexHullShape.cxx +++ b/panda/src/bullet/bulletConvexHullShape.cxx @@ -130,13 +130,11 @@ add_geom(const Geom *geom, const TransformState *ts) { #if BT_BULLET_VERSION >= 282 for (it = points.begin(); it != points.end(); ++it) { - LVecBase3 v = *it; _shape->addPoint(LVecBase3_to_btVector3(*it), false); } _shape->recalcLocalAabb(); #else for (it = points.begin(); it != points.end(); ++it) { - LVecBase3 v = *it; _shape->addPoint(LVecBase3_to_btVector3(*it)); } #endif diff --git a/panda/src/collide/collisionHandlerFluidPusher.cxx b/panda/src/collide/collisionHandlerFluidPusher.cxx index 476aacb82b..9e4e95f5b0 100644 --- a/panda/src/collide/collisionHandlerFluidPusher.cxx +++ b/panda/src/collide/collisionHandlerFluidPusher.cxx @@ -213,11 +213,11 @@ handle_entries() { prev_trans = prev_trans->set_pos(contact_pos); from_node_path.set_prev_transform(wrt_node, prev_trans); - { - //const LPoint3 new_pos(from_node_path.get_pos(wrt_node)); + /*{ + const LPoint3 new_pos(from_node_path.get_pos(wrt_node)); CPT(TransformState) new_prev_trans(from_node_path.get_prev_transform(wrt_node)); const LPoint3 new_prev_pos(new_prev_trans->get_pos()); - } + }*/ // recalculate the position delta N = from_node_path.get_pos_delta(wrt_node); diff --git a/panda/src/egg2pg/eggSaver.cxx b/panda/src/egg2pg/eggSaver.cxx index 43dcb06a5b..ab56a074dd 100644 --- a/panda/src/egg2pg/eggSaver.cxx +++ b/panda/src/egg2pg/eggSaver.cxx @@ -860,8 +860,6 @@ convert_primitive(const GeomVertexData *vertex_data, } } - LNormal normal; - LColor color; CPT(TransformBlendTable) transformBlendTable = vertex_data->get_transform_blend_table(); int num_primitives = primitive->get_num_primitives(); diff --git a/panda/src/express/datagram.I b/panda/src/express/datagram.I index 499bfab48b..cac87f1111 100644 --- a/panda/src/express/datagram.I +++ b/panda/src/express/datagram.I @@ -157,9 +157,9 @@ add_float64(PN_float64 value) { INLINE void Datagram:: add_stdfloat(PN_stdfloat value) { if (_stdfloat_double) { - add_float64(value); + add_float64((double)value); } else { - add_float32(value); + add_float32((float)value); } } diff --git a/panda/src/grutil/meshDrawer.h b/panda/src/grutil/meshDrawer.h index 1b391210f6..e959b37c24 100644 --- a/panda/src/grutil/meshDrawer.h +++ b/panda/src/grutil/meshDrawer.h @@ -107,8 +107,6 @@ private: GeomVertexRewriter *_color; // billboard vectors - LVector4 _colorv; - LVector3 _normalv; LVector3 _eyePos; LVector3 _b1, _b2, _b3, _b4; LVector3 _up, _right; diff --git a/panda/src/grutil/pfmVizzer.cxx b/panda/src/grutil/pfmVizzer.cxx index 9bd440a0c3..72a0cbf7a2 100644 --- a/panda/src/grutil/pfmVizzer.cxx +++ b/panda/src/grutil/pfmVizzer.cxx @@ -323,8 +323,7 @@ generate_vis_points() const { NodePath PfmVizzer:: generate_vis_mesh(MeshFace face) const { nassertr(_pfm.is_valid(), NodePath()); - bool check_aux_pfm = uses_aux_pfm(); - nassertr(!check_aux_pfm || (_aux_pfm != NULL && _aux_pfm->is_valid()), NodePath()); + nassertr(!uses_aux_pfm() || (_aux_pfm != NULL && _aux_pfm->is_valid()), NodePath()); nassertr(face != 0, NodePath()); if (_pfm.get_num_channels() == 1 && _vis_columns.empty()) { diff --git a/panda/src/mathutil/triangulator.cxx b/panda/src/mathutil/triangulator.cxx index a0c1ad9ad5..fabfe31147 100644 --- a/panda/src/mathutil/triangulator.cxx +++ b/panda/src/mathutil/triangulator.cxx @@ -867,7 +867,7 @@ add_segment(int segnum) { int tfirstr = 0, tlastr = 0, tfirstl = 0, tlastl = 0; int i1, i2, t, tn; // t1, t2, point_t tpt; - int tritop = 0, tribot = 0, is_swapped = 0; + int tribot = 0, is_swapped = 0; int tmptriseg; s = seg[segnum]; @@ -939,7 +939,6 @@ add_segment(int segnum) { else /* v0 already present */ { /* Get the topmost intersecting trapezoid */ tfirst = locate_endpoint(&s.v0, &s.v1, s.root0); - tritop = 1; } @@ -1294,16 +1293,13 @@ add_segment(int segnum) { // int tmpseg = tr[tr[t].d0].rseg; double y0, yt; point_t tmppt; - int tnext, i_d0, i_d1; + int tnext, i_d0; - i_d1 = false; i_d0 = false; if (FP_EQUAL(tr[t].lo.y, s.v0.y)) { if (tr[t].lo.x > s.v0.x) i_d0 = true; - else - i_d1 = true; } else { @@ -1314,8 +1310,6 @@ add_segment(int segnum) { if (_less_than(&tmppt, &tr[t].lo)) i_d0 = true; - else - i_d1 = true; } /* check continuity from the top so that the lower-neighbour */ @@ -1792,7 +1786,6 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { int mnew; int v0, v1; //, v0next, v1next; int retval = 0; //, tmp; - int do_switch = false; // printf("visited size = %d, visited[trnum] = %d\n", visited.size(), // visited[trnum]); @@ -1817,7 +1810,6 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { v1 = t->lseg; if (from == t->d1) { - do_switch = true; mnew = make_new_monotone_poly(mcur, v1, v0); traverse_polygon(mcur, t->d1, trnum, TR_FROM_UP); traverse_polygon(mnew, t->d0, trnum, TR_FROM_UP); @@ -1847,7 +1839,6 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { v1 = tr[t->u0].rseg; if (from == t->u1) { - do_switch = true; mnew = make_new_monotone_poly(mcur, v1, v0); traverse_polygon(mcur, t->u1, trnum, TR_FROM_DN); traverse_polygon(mnew, t->u0, trnum, TR_FROM_DN); @@ -1879,7 +1870,6 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { if (((dir == TR_FROM_DN) && (t->d1 == from)) || ((dir == TR_FROM_UP) && (t->u1 == from))) { - do_switch = true; mnew = make_new_monotone_poly(mcur, v1, v0); traverse_polygon(mcur, t->u1, trnum, TR_FROM_DN); traverse_polygon(mcur, t->d1, trnum, TR_FROM_UP); @@ -1905,7 +1895,6 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { retval = SP_2UP_LEFT; if ((dir == TR_FROM_UP) && (t->u0 == from)) { - do_switch = true; mnew = make_new_monotone_poly(mcur, v1, v0); traverse_polygon(mcur, t->u0, trnum, TR_FROM_DN); traverse_polygon(mnew, t->d0, trnum, TR_FROM_UP); @@ -1928,7 +1917,6 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { retval = SP_2UP_RIGHT; if ((dir == TR_FROM_UP) && (t->u1 == from)) { - do_switch = true; mnew = make_new_monotone_poly(mcur, v1, v0); traverse_polygon(mcur, t->u1, trnum, TR_FROM_DN); traverse_polygon(mnew, t->d1, trnum, TR_FROM_UP); @@ -1957,7 +1945,6 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { retval = SP_2DN_LEFT; if (!((dir == TR_FROM_DN) && (t->d0 == from))) { - do_switch = true; mnew = make_new_monotone_poly(mcur, v1, v0); traverse_polygon(mcur, t->u1, trnum, TR_FROM_DN); traverse_polygon(mcur, t->d1, trnum, TR_FROM_UP); @@ -1981,7 +1968,6 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { retval = SP_2DN_RIGHT; if ((dir == TR_FROM_DN) && (t->d1 == from)) { - do_switch = true; mnew = make_new_monotone_poly(mcur, v1, v0); traverse_polygon(mcur, t->d1, trnum, TR_FROM_UP); traverse_polygon(mnew, t->u1, trnum, TR_FROM_DN); @@ -2008,7 +1994,6 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { retval = SP_SIMPLE_LRDN; if (dir == TR_FROM_UP) { - do_switch = true; mnew = make_new_monotone_poly(mcur, v1, v0); traverse_polygon(mcur, t->u0, trnum, TR_FROM_DN); traverse_polygon(mcur, t->u1, trnum, TR_FROM_DN); @@ -2033,7 +2018,6 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { retval = SP_SIMPLE_LRUP; if (dir == TR_FROM_UP) { - do_switch = true; mnew = make_new_monotone_poly(mcur, v1, v0); traverse_polygon(mcur, t->u0, trnum, TR_FROM_DN); traverse_polygon(mcur, t->u1, trnum, TR_FROM_DN); diff --git a/panda/src/ode/odeTriMeshData.cxx b/panda/src/ode/odeTriMeshData.cxx index a87853c4bb..0c04196833 100644 --- a/panda/src/ode/odeTriMeshData.cxx +++ b/panda/src/ode/odeTriMeshData.cxx @@ -229,7 +229,7 @@ process_primitive(const GeomPrimitive *primitive, CPT(GeomVertexData) vData) { GeomVertexReader vReader(vData, "vertex"); GeomVertexReader nReader(vData, "normal"); - LVecBase3f vertex, normal; + LVecBase3f vertex; // CPT(GeomPrimitive) dPrimitive = primitive->decompose(); CPT(GeomPrimitive) dPrimitive = primitive; ostream &out = odetrimeshdata_cat.debug(); diff --git a/panda/src/pgraph/fog.cxx b/panda/src/pgraph/fog.cxx index 06c831f337..654c6fd613 100644 --- a/panda/src/pgraph/fog.cxx +++ b/panda/src/pgraph/fog.cxx @@ -136,7 +136,6 @@ void Fog:: adjust_to_camera(const TransformState *camera_transform) { LVector3 forward = LVector3::forward(); - LPoint3 onset_point, opaque_point; if (get_num_parents() != 0) { // Linear fog is relative to the fog's net transform in the scene graph. NodePath this_np(this); diff --git a/panda/src/pgui/pgScrollFrame.h b/panda/src/pgui/pgScrollFrame.h index 7dfae33d1b..c60a161a78 100644 --- a/panda/src/pgui/pgScrollFrame.h +++ b/panda/src/pgui/pgScrollFrame.h @@ -94,8 +94,6 @@ private: bool _needs_recompute_clip; bool _needs_recompute_canvas; - LVecBase4 _orig_clip_frame; - bool _has_virtual_frame; LVecBase4 _virtual_frame; diff --git a/panda/src/physics/baseIntegrator.cxx b/panda/src/physics/baseIntegrator.cxx index f0cbe93893..ca5ec4faad 100644 --- a/panda/src/physics/baseIntegrator.cxx +++ b/panda/src/physics/baseIntegrator.cxx @@ -40,16 +40,13 @@ precompute_linear_matrices(Physical *physical, const LinearForceVector &forces) { nassertv(physical); // make sure the physical's in the scene graph, somewhere. - PhysicalNode *physical_node = physical->get_physical_node(); - nassertv(physical_node); + nassertv(physical->get_physical_node() != nullptr); // by global forces, we mean forces not contained in the physical - int global_force_vec_size = forces.size(); + size_t global_force_vec_size = forces.size(); // by local forces, we mean members of the physical's force set. - int local_force_vec_size = physical->get_linear_forces().size(); - - ForceNode *force_node; + size_t local_force_vec_size = physical->get_linear_forces().size(); // prepare the vector _precomputed_linear_matrices.clear(); @@ -63,8 +60,7 @@ precompute_linear_matrices(Physical *physical, LinearForceVector::const_iterator fi; for (fi = forces.begin(); fi != forces.end(); ++fi) { // LinearForce *cur_force = *fi; - force_node = (*fi)->get_force_node(); - nassertv(force_node != (ForceNode *) NULL); + nassertv((*fi)->get_force_node() != nullptr); NodePath force_np = (*fi)->get_force_node_path(); _precomputed_linear_matrices.push_back( @@ -74,8 +70,7 @@ precompute_linear_matrices(Physical *physical, // tally the local xforms const LinearForceVector &force_vector = physical->get_linear_forces(); for (fi = force_vector.begin(); fi != force_vector.end(); ++fi) { - force_node = (*fi)->get_force_node(); - nassertv(force_node != (ForceNode *) NULL); + nassertv((*fi)->get_force_node() != nullptr); NodePath force_np = (*fi)->get_force_node_path(); _precomputed_linear_matrices.push_back( @@ -93,16 +88,13 @@ precompute_angular_matrices(Physical *physical, const AngularForceVector &forces) { nassertv(physical); // make sure the physical's in the scene graph, somewhere. - PhysicalNode *physical_node = physical->get_physical_node(); - nassertv(physical_node != NULL); + nassertv(physical->get_physical_node() != nullptr); // by global forces, we mean forces not contained in the physical - int global_force_vec_size = forces.size(); + size_t global_force_vec_size = forces.size(); // by local forces, we mean members of the physical's force set. - int local_force_vec_size = physical->get_angular_forces().size(); - - ForceNode *force_node; + size_t local_force_vec_size = physical->get_angular_forces().size(); // prepare the vector _precomputed_angular_matrices.clear(); @@ -115,8 +107,7 @@ precompute_angular_matrices(Physical *physical, // tally the global xforms AngularForceVector::const_iterator fi; for (fi = forces.begin(); fi != forces.end(); ++fi) { - force_node = (*fi)->get_force_node(); - nassertv(force_node != (ForceNode *) NULL); + nassertv((*fi)->get_force_node() != nullptr); NodePath force_np = (*fi)->get_force_node_path(); _precomputed_angular_matrices.push_back( @@ -126,8 +117,7 @@ precompute_angular_matrices(Physical *physical, // tally the local xforms const AngularForceVector &force_vector = physical->get_angular_forces(); for (fi = force_vector.begin(); fi != force_vector.end(); ++fi) { - force_node = (*fi)->get_force_node(); - nassertv(force_node != (ForceNode *) NULL); + nassertv((*fi)->get_force_node() != nullptr); NodePath force_np = (*fi)->get_force_node_path(); _precomputed_angular_matrices.push_back( diff --git a/panda/src/physics/physicsManager.I b/panda/src/physics/physicsManager.I index e9c128c641..6b2c94c94c 100644 --- a/panda/src/physics/physicsManager.I +++ b/panda/src/physics/physicsManager.I @@ -57,7 +57,7 @@ attach_physicalnode(PhysicalNode *p) { INLINE void PhysicsManager:: attach_physical_node(PhysicalNode *p) { nassertv(p); - for (int i = 0; i < p->get_num_physicals(); ++i) { + for (size_t i = 0; i < p->get_num_physicals(); ++i) { attach_physical(p->get_physical(i)); } } diff --git a/panda/src/physics/physicsManager.cxx b/panda/src/physics/physicsManager.cxx index 60d237d167..7bd75bec33 100644 --- a/panda/src/physics/physicsManager.cxx +++ b/panda/src/physics/physicsManager.cxx @@ -110,7 +110,7 @@ remove_physical(Physical *p) { void PhysicsManager:: remove_physical_node(PhysicalNode *p) { nassertv(p); - for (int i = 0; i < p->get_num_physicals(); ++i) { + for (size_t i = 0; i < p->get_num_physicals(); ++i) { remove_physical(p->get_physical(i)); } } diff --git a/panda/src/text/staticTextFont.cxx b/panda/src/text/staticTextFont.cxx index 88f4186ad7..2a06033f2f 100644 --- a/panda/src/text/staticTextFont.cxx +++ b/panda/src/text/staticTextFont.cxx @@ -248,7 +248,7 @@ find_character_gsets(PandaNode *root, CPT(Geom) &ch, CPT(Geom) &dot, const Geom *geom = geode->get_geom(i); bool found_points = false; - for (int j = 0; j < geom->get_num_primitives() && !found_points; j++) { + for (size_t j = 0; j < geom->get_num_primitives() && !found_points; ++j) { const GeomPrimitive *primitive = geom->get_primitive(j); if (primitive->is_of_type(GeomPoints::get_class_type())) { dot = geom; diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index a9c6b113a2..07f7ad4e6b 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -697,7 +697,6 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, // Texture coordinates. for (int si = 0; si < max_stage_index; ++si) { - LTexCoord d; (*texgen_func[si])(v->tex_coord[si], tcdata[si]); } diff --git a/panda/src/tinydisplay/ztriangle.h b/panda/src/tinydisplay/ztriangle.h index c8fdfc4c53..9b2db10f2d 100644 --- a/panda/src/tinydisplay/ztriangle.h +++ b/panda/src/tinydisplay/ztriangle.h @@ -348,10 +348,10 @@ int n; #ifdef INTERP_Z ZPOINT *pz; - unsigned int z,zz; + UNUSED unsigned int z,zz; #endif #ifdef INTERP_RGB - unsigned int or1,og1,ob1,oa1; + UNUSED unsigned int or1,og1,ob1,oa1; #endif #ifdef INTERP_ST unsigned int s,t; diff --git a/panda/src/tinydisplay/ztriangle_two.h b/panda/src/tinydisplay/ztriangle_two.h index 647dcba605..b8baba23c2 100644 --- a/panda/src/tinydisplay/ztriangle_two.h +++ b/panda/src/tinydisplay/ztriangle_two.h @@ -31,7 +31,7 @@ static void FNAME(flat_untextured) (ZBuffer *zb, ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2) { - int color; + UNUSED int color; int or0, og0, ob0, oa0; #define INTERP_Z diff --git a/pandatool/src/gtk-stats/gtkStatsLabel.cxx b/pandatool/src/gtk-stats/gtkStatsLabel.cxx index 846aeb8a15..e5a81afbfe 100644 --- a/pandatool/src/gtk-stats/gtkStatsLabel.cxx +++ b/pandatool/src/gtk-stats/gtkStatsLabel.cxx @@ -117,6 +117,14 @@ get_collector_index() const { return _collector_index; } +/** + * Returns the thread index. + */ +int GtkStatsLabel:: +get_thread_index() const { + return _thread_index; +} + /** * Enables or disables the visual highlight for this label. */ diff --git a/pandatool/src/gtk-stats/gtkStatsLabel.h b/pandatool/src/gtk-stats/gtkStatsLabel.h index 80f697dc4f..bf4834985e 100644 --- a/pandatool/src/gtk-stats/gtkStatsLabel.h +++ b/pandatool/src/gtk-stats/gtkStatsLabel.h @@ -36,6 +36,7 @@ public: int get_height() const; int get_collector_index() const; + int get_thread_index() const; void set_highlight(bool highlight); bool get_highlight() const; diff --git a/pandatool/src/objegg/objToEggConverter.cxx b/pandatool/src/objegg/objToEggConverter.cxx index c6df68710c..5444463a79 100644 --- a/pandatool/src/objegg/objToEggConverter.cxx +++ b/pandatool/src/objegg/objToEggConverter.cxx @@ -270,7 +270,6 @@ process_ref_plane_res(const string &line) { } bool okflag = true; - LPoint3d pos; okflag &= string_to_double(words[1], _ref_plane_res[0]); okflag &= string_to_double(words[2], _ref_plane_res[1]); From aa1b06f132c55f76e7bbb25670f556cc2c4d8507 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 30 May 2018 23:04:43 +0200 Subject: [PATCH 213/247] putil: make BitMask et al literal types --- panda/src/putil/bitMask.I | 14 ++---------- panda/src/putil/bitMask.cxx | 7 ++++++ panda/src/putil/bitMask.h | 6 ++--- panda/src/putil/doubleBitMask.I | 38 ------------------------------- panda/src/putil/doubleBitMask.cxx | 6 +++++ panda/src/putil/doubleBitMask.h | 6 +---- 6 files changed, 19 insertions(+), 58 deletions(-) diff --git a/panda/src/putil/bitMask.I b/panda/src/putil/bitMask.I index fa1073ad4b..39d3a7742d 100644 --- a/panda/src/putil/bitMask.I +++ b/panda/src/putil/bitMask.I @@ -18,17 +18,7 @@ TypeHandle BitMask::_type_handle; * */ template -INLINE BitMask:: -BitMask() : - _word(0) -{ -} - -/** - * - */ -template -INLINE BitMask:: +constexpr BitMask:: BitMask(WordType init_value) : _word(init_value) { @@ -170,7 +160,7 @@ is_zero() const { template INLINE bool BitMask:: is_all_on() const { - return (~_word == 0); + return _word == (WordType)~0; } /** diff --git a/panda/src/putil/bitMask.cxx b/panda/src/putil/bitMask.cxx index 8e51315eb2..ba81e204c7 100644 --- a/panda/src/putil/bitMask.cxx +++ b/panda/src/putil/bitMask.cxx @@ -12,7 +12,14 @@ */ #include "bitMask.h" +#include template class BitMask; template class BitMask; template class BitMask; + +#ifndef CPPPARSER +static_assert(std::is_literal_type::value, "BitMask16 is not a literal type"); +static_assert(std::is_literal_type::value, "BitMask32 is not a literal type"); +static_assert(std::is_literal_type::value, "BitMask64 is not a literal type"); +#endif diff --git a/panda/src/putil/bitMask.h b/panda/src/putil/bitMask.h index 3d73089b50..8eb73a2440 100644 --- a/panda/src/putil/bitMask.h +++ b/panda/src/putil/bitMask.h @@ -36,8 +36,8 @@ public: PUBLISHED: enum { num_bits = nbits }; - INLINE BitMask(); - INLINE BitMask(WordType init_value); + constexpr BitMask() = default; + constexpr BitMask(WordType init_value); INLINE static BitMask all_on(); INLINE static BitMask all_off(); @@ -131,7 +131,7 @@ public: INLINE void generate_hash(ChecksumHashGenerator &hashgen) const; private: - WordType _word; + WordType _word = 0u; public: static TypeHandle get_class_type() { diff --git a/panda/src/putil/doubleBitMask.I b/panda/src/putil/doubleBitMask.I index 0768263afe..001dec7eb3 100644 --- a/panda/src/putil/doubleBitMask.I +++ b/panda/src/putil/doubleBitMask.I @@ -14,36 +14,6 @@ template TypeHandle DoubleBitMask::_type_handle; -/** - * - */ -template -INLINE DoubleBitMask:: -DoubleBitMask() { -} - -/** - * - */ -template -INLINE DoubleBitMask:: -DoubleBitMask(const DoubleBitMask ©) : - _lo(copy._lo), - _hi(copy._hi) -{ -} - -/** - * - */ -template -INLINE DoubleBitMask &DoubleBitMask:: -operator = (const DoubleBitMask ©) { - _lo = copy._lo; - _hi = copy._hi; - return *this; -} - /** * Returns a DoubleBitMask whose bits are all on. */ @@ -111,14 +81,6 @@ range(int low_bit, int size) { return result; } -/** - * - */ -template -INLINE DoubleBitMask:: -~DoubleBitMask() { -} - /** * Returns the number of bits available to set in the doubleBitMask. */ diff --git a/panda/src/putil/doubleBitMask.cxx b/panda/src/putil/doubleBitMask.cxx index c35d11613a..a69d6b0eb0 100644 --- a/panda/src/putil/doubleBitMask.cxx +++ b/panda/src/putil/doubleBitMask.cxx @@ -12,6 +12,12 @@ */ #include "doubleBitMask.h" +#include template class DoubleBitMask; template class DoubleBitMask; + +#ifndef CPPPARSER +static_assert(std::is_literal_type::value, "DoubleBitMaskNative is not a literal type"); +static_assert(std::is_literal_type::value, "QuadBitMaskNative is not a literal type"); +#endif diff --git a/panda/src/putil/doubleBitMask.h b/panda/src/putil/doubleBitMask.h index 6c32cd0122..de17e6091b 100644 --- a/panda/src/putil/doubleBitMask.h +++ b/panda/src/putil/doubleBitMask.h @@ -37,9 +37,7 @@ PUBLISHED: num_bits = BMType::num_bits * 2, }; - INLINE DoubleBitMask(); - INLINE DoubleBitMask(const DoubleBitMask ©); - INLINE DoubleBitMask &operator = (const DoubleBitMask ©); + constexpr DoubleBitMask() = default; INLINE static DoubleBitMask all_on(); INLINE static DoubleBitMask all_off(); @@ -47,8 +45,6 @@ PUBLISHED: INLINE static DoubleBitMask bit(int index); INLINE static DoubleBitMask range(int low_bit, int size); - INLINE ~DoubleBitMask(); - constexpr static bool has_max_num_bits() {return true;} constexpr static int get_max_num_bits() {return num_bits;} From 4f55e26e6179e6fd399a54dc906ea3887f2e1c6c Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 30 May 2018 23:06:24 +0200 Subject: [PATCH 214/247] tests: add tests for BitMask*.is_all_on() --- tests/putil/test_bitmask.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/putil/test_bitmask.py diff --git a/tests/putil/test_bitmask.py b/tests/putil/test_bitmask.py new file mode 100644 index 0000000000..e87984cac1 --- /dev/null +++ b/tests/putil/test_bitmask.py @@ -0,0 +1,10 @@ +from panda3d import core + + +def test_bitmask_allon(): + assert core.BitMask16.all_on().is_all_on() + assert core.BitMask32.all_on().is_all_on() + assert core.BitMask64.all_on().is_all_on() + assert core.DoubleBitMaskNative.all_on().is_all_on() + assert core.QuadBitMaskNative.all_on().is_all_on() + assert core.BitArray.all_on().is_all_on() From 190c553c57c197651e0ddfdc7f0e3addafd093a8 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 30 May 2018 23:14:30 +0200 Subject: [PATCH 215/247] dtool_config.h: remove some macros for ancient C++ compilers --- dtool/src/dtoolbase/dtoolbase_cc.h | 15 --------------- dtool/src/dtoolutil/lineStreamBuf.cxx | 5 ----- dtool/src/prc/encryptStreamBuf.cxx | 5 ----- makepanda/makepanda.py | 3 --- panda/src/downloader/bioStreamBuf.cxx | 5 ----- panda/src/downloader/chunkedStreamBuf.cxx | 5 ----- panda/src/downloader/identityStreamBuf.cxx | 5 ----- panda/src/downloader/multiplexStreamBuf.cxx | 5 ----- panda/src/express/subStreamBuf.cxx | 5 ----- pandatool/src/progbase/wordWrapStreamBuf.cxx | 5 ----- 10 files changed, 58 deletions(-) diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index 98bf992cf9..fc47f057d1 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -83,21 +83,6 @@ using namespace std; #define TYPENAME typename -#ifndef HAVE_WCHAR_T -// Some C++ libraries (os x 3.1) don't define this. -typedef unsigned short wchar_t; -#endif - -#ifndef HAVE_WSTRING -// Some C++ libraries (gcc 2.95) don't define this. -typedef basic_string wstring; -#endif - -#ifndef HAVE_STREAMSIZE -// Some C++ libraries (Irix) don't define this. -typedef long streamsize; -#endif - #ifndef HAVE_IOS_TYPEDEFS typedef int ios_openmode; typedef int ios_fmtflags; diff --git a/dtool/src/dtoolutil/lineStreamBuf.cxx b/dtool/src/dtoolutil/lineStreamBuf.cxx index f2a795dab5..561772ddcb 100644 --- a/dtool/src/dtoolutil/lineStreamBuf.cxx +++ b/dtool/src/dtoolutil/lineStreamBuf.cxx @@ -13,11 +13,6 @@ #include "lineStreamBuf.h" -#ifndef HAVE_STREAMSIZE -// Some compilers--notably SGI--don't define this for us. -typedef int streamsize; -#endif - /** * */ diff --git a/dtool/src/prc/encryptStreamBuf.cxx b/dtool/src/prc/encryptStreamBuf.cxx index dc38ac5894..a939235743 100644 --- a/dtool/src/prc/encryptStreamBuf.cxx +++ b/dtool/src/prc/encryptStreamBuf.cxx @@ -23,11 +23,6 @@ #include "openssl/rand.h" #include "openssl/evp.h" -#ifndef HAVE_STREAMSIZE -// Some compilers (notably SGI) don't define this for us -typedef int streamsize; -#endif /* HAVE_STREAMSIZE */ - // The iteration count is scaled by this factor for writing to the stream. static const int iteration_count_factor = 1000; diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 80b551c84f..67ca6e4a13 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2278,8 +2278,6 @@ DTOOL_CONFIG=[ ("DEFAULT_PATHSEP", '";"', '":"'), ("WORDS_BIGENDIAN", 'UNDEF', 'UNDEF'), ("PHAVE_LOCKF", '1', '1'), - ("HAVE_WCHAR_T", '1', '1'), - ("HAVE_WSTRING", '1', '1'), ("SIMPLE_STRUCT_POINTERS", '1', 'UNDEF'), ("HAVE_DINKUM", 'UNDEF', 'UNDEF'), ("HAVE_STL_HASH", 'UNDEF', 'UNDEF'), @@ -2289,7 +2287,6 @@ DTOOL_CONFIG=[ ("PHAVE_GETOPT_H", 'UNDEF', '1'), ("PHAVE_LINUX_INPUT_H", 'UNDEF', '1'), ("IOCTL_TERMINAL_WIDTH", 'UNDEF', '1'), - ("HAVE_STREAMSIZE", '1', '1'), ("HAVE_IOS_TYPEDEFS", '1', '1'), ("HAVE_IOS_BINARY", '1', '1'), ("STATIC_INIT_GETENV", '1', 'UNDEF'), diff --git a/panda/src/downloader/bioStreamBuf.cxx b/panda/src/downloader/bioStreamBuf.cxx index d0bd04e027..65dd28c5ba 100644 --- a/panda/src/downloader/bioStreamBuf.cxx +++ b/panda/src/downloader/bioStreamBuf.cxx @@ -24,11 +24,6 @@ #undef X509_NAME #endif // WIN32_VC -#ifndef HAVE_STREAMSIZE -// Some compilers (notably SGI) don't define this for us -typedef int streamsize; -#endif /* HAVE_STREAMSIZE */ - /** * */ diff --git a/panda/src/downloader/chunkedStreamBuf.cxx b/panda/src/downloader/chunkedStreamBuf.cxx index 9464a9c730..a20b8425ed 100644 --- a/panda/src/downloader/chunkedStreamBuf.cxx +++ b/panda/src/downloader/chunkedStreamBuf.cxx @@ -18,11 +18,6 @@ // This module is not compiled if OpenSSL is not available. #ifdef HAVE_OPENSSL -#ifndef HAVE_STREAMSIZE -// Some compilers (notably SGI) don't define this for us -typedef int streamsize; -#endif /* HAVE_STREAMSIZE */ - /** * */ diff --git a/panda/src/downloader/identityStreamBuf.cxx b/panda/src/downloader/identityStreamBuf.cxx index a11f1cfda3..4d98540423 100644 --- a/panda/src/downloader/identityStreamBuf.cxx +++ b/panda/src/downloader/identityStreamBuf.cxx @@ -17,11 +17,6 @@ #ifdef HAVE_OPENSSL #include "httpChannel.h" -#ifndef HAVE_STREAMSIZE -// Some compilers (notably SGI) don't define this for us -typedef int streamsize; -#endif /* HAVE_STREAMSIZE */ - /** * */ diff --git a/panda/src/downloader/multiplexStreamBuf.cxx b/panda/src/downloader/multiplexStreamBuf.cxx index 783558f587..8d290a2d6d 100644 --- a/panda/src/downloader/multiplexStreamBuf.cxx +++ b/panda/src/downloader/multiplexStreamBuf.cxx @@ -24,11 +24,6 @@ // recursion. #include -#ifndef HAVE_STREAMSIZE -// Some compilers--notably SGI--don't define this for us. -typedef int streamsize; -#endif - /** * Closes or deletes the relevant pointers, if _owns_obj is true. */ diff --git a/panda/src/express/subStreamBuf.cxx b/panda/src/express/subStreamBuf.cxx index 61a349b215..22d3515767 100644 --- a/panda/src/express/subStreamBuf.cxx +++ b/panda/src/express/subStreamBuf.cxx @@ -15,11 +15,6 @@ #include "pnotify.h" #include "memoryHook.h" -#ifndef HAVE_STREAMSIZE -// Some compilers (notably SGI) don't define this for us -typedef int streamsize; -#endif /* HAVE_STREAMSIZE */ - static const size_t substream_buffer_size = 4096; /** diff --git a/pandatool/src/progbase/wordWrapStreamBuf.cxx b/pandatool/src/progbase/wordWrapStreamBuf.cxx index 4280a3d394..f8f4dced30 100644 --- a/pandatool/src/progbase/wordWrapStreamBuf.cxx +++ b/pandatool/src/progbase/wordWrapStreamBuf.cxx @@ -17,11 +17,6 @@ #include "pnotify.h" -#ifndef HAVE_STREAMSIZE -// Some compilers--notably SGI--don't define this for us. -typedef int streamsize; -#endif - /** * */ From 283d43f98839b00e662677a04360544c9f8bf028 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 30 May 2018 23:29:05 +0200 Subject: [PATCH 216/247] putil: workaround macOS 10.6 compile error until #300 is fixed [skip ci] --- panda/src/putil/bitMask.cxx | 5 +++-- panda/src/putil/doubleBitMask.cxx | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/panda/src/putil/bitMask.cxx b/panda/src/putil/bitMask.cxx index ba81e204c7..cd200ab565 100644 --- a/panda/src/putil/bitMask.cxx +++ b/panda/src/putil/bitMask.cxx @@ -12,13 +12,14 @@ */ #include "bitMask.h" -#include template class BitMask; template class BitMask; template class BitMask; -#ifndef CPPPARSER +#if !defined(CPPPARSER) && !defined(__APPLE__) +#include + static_assert(std::is_literal_type::value, "BitMask16 is not a literal type"); static_assert(std::is_literal_type::value, "BitMask32 is not a literal type"); static_assert(std::is_literal_type::value, "BitMask64 is not a literal type"); diff --git a/panda/src/putil/doubleBitMask.cxx b/panda/src/putil/doubleBitMask.cxx index a69d6b0eb0..ff651eea61 100644 --- a/panda/src/putil/doubleBitMask.cxx +++ b/panda/src/putil/doubleBitMask.cxx @@ -12,12 +12,13 @@ */ #include "doubleBitMask.h" -#include template class DoubleBitMask; template class DoubleBitMask; -#ifndef CPPPARSER +#if !defined(CPPPARSER) && !defined(__APPLE__) +#include + static_assert(std::is_literal_type::value, "DoubleBitMaskNative is not a literal type"); static_assert(std::is_literal_type::value, "QuadBitMaskNative is not a literal type"); #endif From 94c7fa30e218400c055bfdbc5ed50d21b29af9d9 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Wed, 30 May 2018 17:27:58 -0600 Subject: [PATCH 217/247] makepanda: Remove a couple of unused config macros --- makepanda/makepanda.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 67ca6e4a13..40fa055bce 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2319,7 +2319,6 @@ DTOOL_CONFIG=[ ("PHAVE_UTIME_H", 'UNDEF', '1'), ("PHAVE_GLOB_H", 'UNDEF', '1'), ("PHAVE_DIRENT_H", 'UNDEF', '1'), - ("PHAVE_SYS_SOUNDCARD_H", 'UNDEF', '1'), ("PHAVE_UCONTEXT_H", 'UNDEF', '1'), ("PHAVE_STDINT_H", '1', '1'), ("HAVE_RTTI", '1', '1'), @@ -2332,7 +2331,6 @@ DTOOL_CONFIG=[ ("HAVE_ZLIB", 'UNDEF', 'UNDEF'), ("HAVE_PNG", 'UNDEF', 'UNDEF'), ("HAVE_JPEG", 'UNDEF', 'UNDEF'), - ("PHAVE_JPEGINT_H", '1', '1'), ("HAVE_VIDEO4LINUX", 'UNDEF', '1'), ("HAVE_TIFF", 'UNDEF', 'UNDEF'), ("HAVE_OPENEXR", 'UNDEF', 'UNDEF'), From 159b43e5639b7afb2611573efcea71000bf93be5 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 31 May 2018 19:05:25 -0600 Subject: [PATCH 218/247] general: Address a few more compiler warnings --- dtool/src/dtoolbase/pdtoa.cxx | 2 +- panda/src/express/error_utils.cxx | 2 +- panda/src/express/windowsRegistry.cxx | 2 -- panda/src/glstuff/glGraphicsStateGuardian_src.h | 2 +- panda/src/pnmimagetypes/config_pnmimagetypes.cxx | 1 + panda/src/text/textAssembler.cxx | 2 +- panda/src/wgldisplay/wglGraphicsStateGuardian.cxx | 2 -- panda/src/wgldisplay/wglGraphicsWindow.cxx | 2 +- panda/src/windisplay/winGraphicsPipe.cxx | 4 ++-- panda/src/windisplay/winGraphicsWindow.cxx | 7 +++---- 10 files changed, 11 insertions(+), 15 deletions(-) diff --git a/dtool/src/dtoolbase/pdtoa.cxx b/dtool/src/dtoolbase/pdtoa.cxx index 2ef158f4ac..bc50d6ff92 100644 --- a/dtool/src/dtoolbase/pdtoa.cxx +++ b/dtool/src/dtoolbase/pdtoa.cxx @@ -259,7 +259,7 @@ inline static void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, cha *len = 0; while (kappa > 0) { - uint32_t d; + uint32_t d = 0; switch (kappa) { case 10: d = p1 / 1000000000; p1 %= 1000000000; break; case 9: d = p1 / 100000000; p1 %= 100000000; break; diff --git a/panda/src/express/error_utils.cxx b/panda/src/express/error_utils.cxx index bae1da4a31..8a1ec79331 100644 --- a/panda/src/express/error_utils.cxx +++ b/panda/src/express/error_utils.cxx @@ -191,7 +191,7 @@ string handle_socket_error() { return string(strerror(errno)); #else int err = WSAGetLastError(); - char *errmsg; + const char *errmsg; switch (err) { case 10022: errmsg = "An invalid argument was supplied"; diff --git a/panda/src/express/windowsRegistry.cxx b/panda/src/express/windowsRegistry.cxx index 183a3a9c0d..a803234a6c 100644 --- a/panda/src/express/windowsRegistry.cxx +++ b/panda/src/express/windowsRegistry.cxx @@ -34,8 +34,6 @@ set_string_value(const string &key, const string &name, const string &value, TextEncoder encoder; wstring wvalue = encoder.decode_text(value); - bool okflag = true; - // Now convert the string to Windows' idea of the correct wide-char // encoding, so we can store it in the registry. This might well be the // same string we just decoded from, but it might not. diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index ab1d27a2a4..15ecebe439 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -269,7 +269,7 @@ public: virtual int get_driver_shader_version_major(); virtual int get_driver_shader_version_minor(); - static void debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam); + static void APIENTRY debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam); virtual void reset(); diff --git a/panda/src/pnmimagetypes/config_pnmimagetypes.cxx b/panda/src/pnmimagetypes/config_pnmimagetypes.cxx index b115aa5213..7661696980 100644 --- a/panda/src/pnmimagetypes/config_pnmimagetypes.cxx +++ b/panda/src/pnmimagetypes/config_pnmimagetypes.cxx @@ -269,6 +269,7 @@ init_libpnmimagetypes() { // And register with the PandaSystem. PandaSystem *ps = PandaSystem::get_global_ptr(); + (void)ps; // Suppress unused variable warning #ifdef HAVE_JPEG ps->add_system("libjpeg"); diff --git a/panda/src/text/textAssembler.cxx b/panda/src/text/textAssembler.cxx index 6abe29d7a0..86fb8c8434 100644 --- a/panda/src/text/textAssembler.cxx +++ b/panda/src/text/textAssembler.cxx @@ -1412,9 +1412,9 @@ assemble_row(TextAssembler::TextRow &row, bool underscore = false; PN_stdfloat underscore_start = 0.0f; const TextProperties *underscore_properties = nullptr; - const ComputedProperties *prev_cprops = nullptr; #ifdef HAVE_HARFBUZZ + const ComputedProperties *prev_cprops = nullptr; hb_buffer_t *harfbuff = nullptr; #endif diff --git a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx index 9d916129a4..aca8f44577 100644 --- a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx +++ b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx @@ -123,7 +123,6 @@ get_properties(FrameBufferProperties &properties, HDC hdc, int pfnum) { pfd.cBlueBits, pfd.cAlphaBits); } - int mode = 0; if (pfd.dwFlags & PFD_DOUBLEBUFFER) { properties.set_back_buffers(1); } @@ -193,7 +192,6 @@ get_properties_advanced(FrameBufferProperties &properties, properties.clear(); properties.set_all_specified(); - int frame_buffer_mode = 0; if (ivalue_list[acceleration_i] == WGL_NO_ACCELERATION_ARB) { properties.set_force_software(true); } else { diff --git a/panda/src/wgldisplay/wglGraphicsWindow.cxx b/panda/src/wgldisplay/wglGraphicsWindow.cxx index 06fc3d3ed4..a2aad595c7 100644 --- a/panda/src/wgldisplay/wglGraphicsWindow.cxx +++ b/panda/src/wgldisplay/wglGraphicsWindow.cxx @@ -358,7 +358,7 @@ setup_colormap(const PIXELFORMATDESCRIPTOR &pixelformat) { #ifdef NOTIFY_DEBUG // typedef enum {Software, MCD, ICD} OGLDriverType; -static char *OGLDrvStrings[3] = {"Software","MCD","ICD"}; +static const char *OGLDrvStrings[3] = {"Software","MCD","ICD"}; /** * Reports information about the selected pixel format descriptor, along with diff --git a/panda/src/windisplay/winGraphicsPipe.cxx b/panda/src/windisplay/winGraphicsPipe.cxx index cf76e06296..1861c7d303 100644 --- a/panda/src/windisplay/winGraphicsPipe.cxx +++ b/panda/src/windisplay/winGraphicsPipe.cxx @@ -261,7 +261,7 @@ WinGraphicsPipe() { windisplay_cat.debug() << "Using EnumDisplaySettings to fetch display information.\n"; } pvector display_modes; - DEVMODE dm = {0}; + DEVMODE dm{}; dm.dmSize = sizeof(dm); for (int i = 0; EnumDisplaySettings(NULL, i, &dm) != 0; ++i) { DisplayMode mode; @@ -293,7 +293,7 @@ WinGraphicsPipe() { version_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (GetVersionEx(&version_info)) { if (windisplay_cat.is_info()) { - sprintf(string, "OS version: %d.%d.%d.%d\n", version_info.dwMajorVersion, version_info.dwMinorVersion, version_info.dwPlatformId, version_info.dwBuildNumber); + sprintf(string, "OS version: %lu.%lu.%lu.%lu\n", version_info.dwMajorVersion, version_info.dwMinorVersion, version_info.dwPlatformId, version_info.dwBuildNumber); windisplay_cat.info() << string; windisplay_cat.info() << " " << version_info.szCSDVersion << "\n"; } diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index f8fa283020..767dd9a4eb 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -69,9 +69,9 @@ static const char * const errorbox_title = "Panda3D Error"; // These static variables contain pointers to the touch input functions, which // are dynamically extracted from USER32.DLL -typedef WINUSERAPI BOOL (WINAPI *PFN_REGISTERTOUCHWINDOW)(IN HWND hWnd, IN ULONG ulFlags); -typedef WINUSERAPI BOOL (WINAPI *PFN_GETTOUCHINPUTINFO)(IN HTOUCHINPUT hTouchInput, IN UINT cInputs, OUT PTOUCHINPUT pInputs, IN int cbSize); -typedef WINUSERAPI BOOL (WINAPI *PFN_CLOSETOUCHINPUTHANDLE)(IN HTOUCHINPUT hTouchInput); +typedef BOOL (WINAPI *PFN_REGISTERTOUCHWINDOW)(IN HWND hWnd, IN ULONG ulFlags); +typedef BOOL (WINAPI *PFN_GETTOUCHINPUTINFO)(IN HTOUCHINPUT hTouchInput, IN UINT cInputs, OUT PTOUCHINPUT pInputs, IN int cbSize); +typedef BOOL (WINAPI *PFN_CLOSETOUCHINPUTHANDLE)(IN HTOUCHINPUT hTouchInput); static PFN_REGISTERTOUCHWINDOW pRegisterTouchWindow = 0; static PFN_GETTOUCHINPUTINFO pGetTouchInputInfo = 0; @@ -1292,7 +1292,6 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { << msg << ", " << wparam << ", " << lparam << ")\n"; } WindowProperties properties; - int button = -1; switch (msg) { case WM_MOUSEMOVE: From 213ae6b0290f3bfe56a1006c51e5d205d5f9801e Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 1 Jun 2018 20:44:30 +0200 Subject: [PATCH 219/247] Change some .T files to new docstring style that were missed --- panda/src/express/dcast.T | 79 +++++++-------- panda/src/express/ordered_vector.T | 151 ++++++++++++----------------- pandatool/src/maya/maya_funcs.T | 46 ++++----- 3 files changed, 115 insertions(+), 161 deletions(-) diff --git a/panda/src/express/dcast.T b/panda/src/express/dcast.T index 251f278dce..b457984ec4 100644 --- a/panda/src/express/dcast.T +++ b/panda/src/express/dcast.T @@ -1,24 +1,20 @@ -// Filename: dcast.T -// Created by: drose (06Aug01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcast.T + * @author drose + * @date 2001-08-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: _dcast_get_typehandle -// Description: Returns the TypeHandle associated with the type of -// the parameter, if it can be determined. This is a -// support function for _dcast, below. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TypeHandle associated with the type of the parameter, if it can + * be determined. This is a support function for _dcast, below. + */ template INLINE TypeHandle _dcast_get_typehandle(WantType *) { @@ -38,16 +34,13 @@ _dcast_get_typehandle(WantType *) { return handle; } - -//////////////////////////////////////////////////////////////////// -// Function: _dcast -// Description: The implementation of the DCAST macro, this checks -// the actual type of the pointer before performing a -// downcast operation. In NDEBUG mode, it simply -// downcasts. -// -// This flavor of _dcast works on non-const pointers. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of the DCAST macro, this checks the actual type of the + * pointer before performing a downcast operation. In NDEBUG mode, it simply + * downcasts. + * + * This flavor of _dcast works on non-const pointers. + */ template INLINE WantType * _dcast(WantType *, TypedObject *ptr) { @@ -61,15 +54,13 @@ _dcast(WantType *, TypedObject *ptr) { return (WantType *)ptr; } -//////////////////////////////////////////////////////////////////// -// Function: _dcast -// Description: The implementation of the DCAST macro, this checks -// the actual type of the pointer before performing a -// downcast operation. In NDEBUG mode, it simply -// downcasts. -// -// This flavor of _dcast works on const pointers. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of the DCAST macro, this checks the actual type of the + * pointer before performing a downcast operation. In NDEBUG mode, it simply + * downcasts. + * + * This flavor of _dcast works on const pointers. + */ template INLINE const WantType * _dcast(WantType *, const TypedObject *ptr) { @@ -83,12 +74,10 @@ _dcast(WantType *, const TypedObject *ptr) { return (const WantType *)ptr; } -//////////////////////////////////////////////////////////////////// -// Function: _dcast_ref -// Description: Similar to the above, with a pointer reference as the -// first parameter. Just for fiddly compiler reasons; -// the reference isn't used. -//////////////////////////////////////////////////////////////////// +/** + * Similar to the above, with a pointer reference as the first parameter. + * Just for fiddly compiler reasons; the reference isn't used. +*/ template INLINE WantType * _dcast_ref(WantType *&, TypedObject *ptr) { diff --git a/panda/src/express/ordered_vector.T b/panda/src/express/ordered_vector.T index 7ea866e52f..e43226a9ee 100644 --- a/panda/src/express/ordered_vector.T +++ b/panda/src/express/ordered_vector.T @@ -1,32 +1,26 @@ -// Filename: ordered_vector.T -// Created by: drose (20Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ordered_vector.T + * @author drose + * @date 2002-02-02 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::insert_unique -// Access: Public -// Description: Inserts the indicated key into the ordered vector. -// The iterator is a hint to the expected position; if -// this is correct, the insert operation is likely to be -// faster. The return value is the iterator referencing -// the new element. -// -// This flavor of insert does not allow multiple copies -// of the same key to be inserted. If the key is -// already present, it is not inserted, and the iterator -// referencing the original value is returned. -//////////////////////////////////////////////////////////////////// +/** + * Inserts the indicated key into the ordered vector. The iterator is a hint + * to the expected position; if this is correct, the insert operation is + * likely to be faster. The return value is the iterator referencing the new + * element. + * + * This flavor of insert does not allow multiple copies of the same key to be + * inserted. If the key is already present, it is not inserted, and the + * iterator referencing the original value is returned. + */ template TYPENAME ordered_vector::ITERATOR ordered_vector:: insert_unique(TYPENAME ordered_vector::ITERATOR position, @@ -62,18 +56,16 @@ insert_unique(TYPENAME ordered_vector::ITERATOR position, return result; } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::insert_nonunique -// Access: Public -// Description: Inserts the indicated key into the ordered vector. -// The iterator is a hint to the expected position; if -// this is correct, the insert operation is likely to be -// faster. The return value is the iterator referencing -// the new element. -// -// This flavor of insert allows multiple copies of the -// same key to be inserted. -//////////////////////////////////////////////////////////////////// + +/** + * Inserts the indicated key into the ordered vector. The iterator is a hint + * to the expected position; if this is correct, the insert operation is + * likely to be faster. The return value is the iterator referencing the new + * element. + * + * This flavor of insert allows multiple copies of the + * same key to be inserted. + */ template TYPENAME ordered_vector::ITERATOR ordered_vector:: insert_nonunique(TYPENAME ordered_vector::ITERATOR position, @@ -100,13 +92,10 @@ insert_nonunique(TYPENAME ordered_vector::ITERATOR positio return result; } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::verify_list_unique -// Access: Public -// Description: Ensures that the indicated range of elements is -// sorted correctly. Returns true if this is the case; -// otherwise, returns false. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the indicated range of elements is sorted correctly. Returns + * true if this is the case; otherwise, returns false. + */ template bool ordered_vector:: verify_list_unique() const { @@ -127,13 +116,10 @@ verify_list_unique() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::verify_list_nonunique -// Access: Public -// Description: Ensures that the indicated range of elements is -// sorted correctly. Returns true if this is the case; -// otherwise, returns false. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the indicated range of elements is sorted correctly. Returns + * true if this is the case; otherwise, returns false. + */ template bool ordered_vector:: verify_list_nonunique() const { @@ -155,12 +141,9 @@ verify_list_nonunique() const { } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::r_find_insert_position -// Access: Private -// Description: The recursive implementation of -// find_insert_position(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of find_insert_position(). + */ template TYPENAME ordered_vector::ITERATOR ordered_vector:: r_find_insert_position(TYPENAME ordered_vector::ITERATOR first, @@ -184,11 +167,9 @@ r_find_insert_position(TYPENAME ordered_vector::ITERATOR f } } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::r_find -// Access: Private -// Description: The recursive implementation of find(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of find(). + */ template TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: r_find(TYPENAME ordered_vector::CONST_ITERATOR first, @@ -217,11 +198,9 @@ r_find(TYPENAME ordered_vector::CONST_ITERATOR first, } } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::r_find_particular -// Access: Private -// Description: The recursive implementation of find_particular(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of find_particular(). + */ template TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: r_find_particular(TYPENAME ordered_vector::CONST_ITERATOR first, @@ -270,11 +249,9 @@ r_find_particular(TYPENAME ordered_vector::CONST_ITERATOR } } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::r_count -// Access: Private -// Description: The recursive implementation of count(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of count(). + */ template TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: r_count(TYPENAME ordered_vector::CONST_ITERATOR first, @@ -305,11 +282,9 @@ r_count(TYPENAME ordered_vector::CONST_ITERATOR first, } } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::r_lower_bound -// Access: Private -// Description: The recursive implementation of lower_bound(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of lower_bound(). + */ template TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: r_lower_bound(TYPENAME ordered_vector::CONST_ITERATOR first, @@ -338,11 +313,9 @@ r_lower_bound(TYPENAME ordered_vector::CONST_ITERATOR firs } } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::r_upper_bound -// Access: Private -// Description: The recursive implementation of upper_bound(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of upper_bound(). + */ template TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: r_upper_bound(TYPENAME ordered_vector::CONST_ITERATOR first, @@ -371,11 +344,9 @@ r_upper_bound(TYPENAME ordered_vector::CONST_ITERATOR firs } } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::r_equal_range -// Access: Private -// Description: The recursive implementation of equal_range(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of equal_range(). + */ template pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> ordered_vector:: r_equal_range(TYPENAME ordered_vector::CONST_ITERATOR first, diff --git a/pandatool/src/maya/maya_funcs.T b/pandatool/src/maya/maya_funcs.T index 04ecfab83f..80d8803d3f 100644 --- a/pandatool/src/maya/maya_funcs.T +++ b/pandatool/src/maya/maya_funcs.T @@ -1,24 +1,20 @@ -// Filename: maya_funcs.I -// Created by: drose (16Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file maya_funcs.T + * @author drose + * @date 2000-02-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: get_maya_attribute -// Description: A generic function to extract an attribute of some -// type from an MObject. This is used to implement -// get_bool_attribute(), etc. -//////////////////////////////////////////////////////////////////// +/** + * A generic function to extract an attribute of some type from an MObject. + * This is used to implement get_bool_attribute(), etc. + */ template bool get_maya_attribute(MObject &node, const string &attribute_name, @@ -33,12 +29,10 @@ get_maya_attribute(MObject &node, const string &attribute_name, return status; } -//////////////////////////////////////////////////////////////////// -// Function: set_maya_attribute -// Description: A generic function to set an attribute of some -// type on an MObject. This is used to implement -// set_bool_attribute(), etc. -//////////////////////////////////////////////////////////////////// +/** + * A generic function to set an attribute of some type on an MObject. This is + * used to implement set_bool_attribute(), etc. + */ template bool set_maya_attribute(MObject &node, const string &attribute_name, From 21d8c2964587d03f9561fc281fdf7eac16567ffc Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 1 Jun 2018 21:49:26 +0200 Subject: [PATCH 220/247] More warning fixes --- contrib/src/ai/obstacleAvoidance.cxx | 1 - dtool/src/interrogatedb/py_wrappers.cxx | 14 +++++++------- makepanda/makepanda.py | 2 +- panda/src/cocoadisplay/cocoaGraphicsPipe.mm | 2 +- panda/src/cocoadisplay/cocoaGraphicsWindow.mm | 2 +- panda/src/egldisplay/eglGraphicsBuffer.h | 1 - panda/src/glstuff/glCgShaderContext_src.cxx | 1 - panda/src/pgraphnodes/shaderGenerator.cxx | 2 -- panda/src/vision/openCVTexture.cxx | 2 +- panda/src/vision/openCVTexture.h | 2 +- 10 files changed, 12 insertions(+), 17 deletions(-) diff --git a/contrib/src/ai/obstacleAvoidance.cxx b/contrib/src/ai/obstacleAvoidance.cxx index faf8a1ff05..87ce79026b 100644 --- a/contrib/src/ai/obstacleAvoidance.cxx +++ b/contrib/src/ai/obstacleAvoidance.cxx @@ -36,7 +36,6 @@ obstacle_detection() { double distance = 0x7fff ; double expanded_radius = 0; LVecBase3 to_obstacle; - LVecBase3 prev_avoidance; for(unsigned int i = 0; i < _ai_char->_world->_obstacles.size(); ++i) { PT(BoundingVolume) bounds = _ai_char->_world->_obstacles[i].get_bounds(); CPT(BoundingSphere) bsphere = bounds->as_bounding_sphere(); diff --git a/dtool/src/interrogatedb/py_wrappers.cxx b/dtool/src/interrogatedb/py_wrappers.cxx index 4d56eee41a..3e8f61cb39 100644 --- a/dtool/src/interrogatedb/py_wrappers.cxx +++ b/dtool/src/interrogatedb/py_wrappers.cxx @@ -517,7 +517,7 @@ static PyObject *Dtool_MappingWrapper_keys(PyObject *self, PyObject *) { _register_collection((PyTypeObject *)&Dtool_MappingWrapper_Keys_Type, "MappingView"); } - PyObject_INIT(keys, &Dtool_MappingWrapper_Keys_Type); + (void)PyObject_INIT(keys, &Dtool_MappingWrapper_Keys_Type); Py_XINCREF(wrap->_base._self); keys->_base._self = wrap->_base._self; keys->_base._name = wrap->_base._name; @@ -552,7 +552,7 @@ static PyObject *Dtool_MappingWrapper_values(PyObject *self, PyObject *) { _register_collection((PyTypeObject *)&Dtool_MappingWrapper_Values_Type, "ValuesView"); } - PyObject_INIT(values, &Dtool_MappingWrapper_Values_Type); + (void)PyObject_INIT(values, &Dtool_MappingWrapper_Values_Type); Py_XINCREF(wrap->_base._self); values->_base._self = wrap->_base._self; values->_base._name = wrap->_base._name; @@ -588,7 +588,7 @@ static PyObject *Dtool_MappingWrapper_items(PyObject *self, PyObject *) { _register_collection((PyTypeObject *)&Dtool_MappingWrapper_Items_Type, "MappingView"); } - PyObject_INIT(items, &Dtool_MappingWrapper_Items_Type); + (void)PyObject_INIT(items, &Dtool_MappingWrapper_Items_Type); Py_XINCREF(wrap->_base._self); items->_base._self = wrap->_base._self; items->_base._name = wrap->_base._name; @@ -1557,7 +1557,7 @@ Dtool_SequenceWrapper *Dtool_NewSequenceWrapper(PyObject *self, const char *name _register_collection((PyTypeObject *)&Dtool_MutableSequenceWrapper_Type, "Sequence"); } - PyObject_INIT(wrap, &Dtool_SequenceWrapper_Type); + (void)PyObject_INIT(wrap, &Dtool_SequenceWrapper_Type); Py_XINCREF(self); wrap->_base._self = self; wrap->_base._name = name; @@ -1582,7 +1582,7 @@ Dtool_MutableSequenceWrapper *Dtool_NewMutableSequenceWrapper(PyObject *self, co _register_collection((PyTypeObject *)&Dtool_MutableSequenceWrapper_Type, "MutableSequence"); } - PyObject_INIT(wrap, &Dtool_MutableSequenceWrapper_Type); + (void)PyObject_INIT(wrap, &Dtool_MutableSequenceWrapper_Type); Py_XINCREF(self); wrap->_base._self = self; wrap->_base._name = name; @@ -1609,7 +1609,7 @@ Dtool_MappingWrapper *Dtool_NewMappingWrapper(PyObject *self, const char *name) _register_collection((PyTypeObject *)&Dtool_MappingWrapper_Type, "Mapping"); } - PyObject_INIT(wrap, &Dtool_MappingWrapper_Type); + (void)PyObject_INIT(wrap, &Dtool_MappingWrapper_Type); Py_XINCREF(self); wrap->_base._self = self; wrap->_base._name = name; @@ -1636,7 +1636,7 @@ Dtool_MappingWrapper *Dtool_NewMutableMappingWrapper(PyObject *self, const char _register_collection((PyTypeObject *)&Dtool_MutableMappingWrapper_Type, "MutableMapping"); } - PyObject_INIT(wrap, &Dtool_MutableMappingWrapper_Type); + (void)PyObject_INIT(wrap, &Dtool_MutableMappingWrapper_Type); Py_XINCREF(self); wrap->_base._self = self; wrap->_base._name = name; diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 40fa055bce..4a369a6f72 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1355,7 +1355,7 @@ def CompileCxx(obj,src,opts): if (optlevel==4): cmd += " -O3 -DNDEBUG" # Enable more warnings. - cmd += " -Wall -Wno-reorder -Wno-unused-function" + cmd += " -Wall -Wno-unused-function" if not src.endswith(".c"): cmd += " -Wno-reorder" diff --git a/panda/src/cocoadisplay/cocoaGraphicsPipe.mm b/panda/src/cocoadisplay/cocoaGraphicsPipe.mm index 5430373c55..dd554e2a77 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsPipe.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsPipe.mm @@ -37,7 +37,7 @@ CocoaGraphicsPipe(CGDirectDisplayID display) : _display(display) { _supported_types = OT_window | OT_buffer | OT_texture_buffer; _is_valid = true; - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [[NSAutoreleasePool alloc] init]; // Put Cocoa into thread-safe mode by spawning a thread which immediately // exits. diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index 72c9d57c0f..35f71f6614 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm @@ -405,7 +405,7 @@ open_window() { cocoadisplay_cat.info() << "os_handle type " << os_handle->get_type() << "\n"; - void *ptr_handle; + void *ptr_handle = nullptr; // Depending on whether the window handle comes from a Carbon or a Cocoa // application, it could be either a HIViewRef or an NSView or NSWindow. diff --git a/panda/src/egldisplay/eglGraphicsBuffer.h b/panda/src/egldisplay/eglGraphicsBuffer.h index 0d5d473d36..7bed62cb83 100644 --- a/panda/src/egldisplay/eglGraphicsBuffer.h +++ b/panda/src/egldisplay/eglGraphicsBuffer.h @@ -41,7 +41,6 @@ protected: virtual bool open_buffer(); private: - X11_Display *_display; EGLSurface _pbuffer; EGLDisplay _egl_display; diff --git a/panda/src/glstuff/glCgShaderContext_src.cxx b/panda/src/glstuff/glCgShaderContext_src.cxx index 23efd27d9a..574648300b 100644 --- a/panda/src/glstuff/glCgShaderContext_src.cxx +++ b/panda/src/glstuff/glCgShaderContext_src.cxx @@ -1079,7 +1079,6 @@ update_shader_texture_bindings(ShaderContext *prev) { for (int i = 0; i < (int)_shader->_tex_spec.size(); ++i) { Shader::ShaderTexSpec &spec = _shader->_tex_spec[i]; - const InternalName *id = spec._name; CGparameter p = _cg_parameter_map[spec._id._seqno]; if (p == 0) { diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index 372bd89e1d..3dea5f7134 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -288,8 +288,6 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { } } - bool normal_mapping = key._lighting && shader_attrib->auto_normal_on(); - // See if there is a normal map, height map, gloss map, or glow map. Also // check if anything has TexGen. diff --git a/panda/src/vision/openCVTexture.cxx b/panda/src/vision/openCVTexture.cxx index 5990e77321..e0262d01ba 100644 --- a/panda/src/vision/openCVTexture.cxx +++ b/panda/src/vision/openCVTexture.cxx @@ -92,7 +92,7 @@ consider_update() { * independently of the original. */ PT(Texture) OpenCVTexture:: -make_copy_impl() { +make_copy_impl() const { Texture::CDReader cdata_tex(Texture::_cycler); PT(OpenCVTexture) copy = new OpenCVTexture(get_name()); Texture::CDWriter cdata_copy_tex(copy->Texture::_cycler, true); diff --git a/panda/src/vision/openCVTexture.h b/panda/src/vision/openCVTexture.h index 7226202a7f..ce4d279456 100644 --- a/panda/src/vision/openCVTexture.h +++ b/panda/src/vision/openCVTexture.h @@ -41,7 +41,7 @@ public: protected: virtual void consider_update(); - virtual PT(Texture) make_copy_impl(); + virtual PT(Texture) make_copy_impl() const; void do_assign(Texture::CData *cdata_tex, const OpenCVTexture *copy, const Texture::CData *cdata_copy_tex); From 298147bb397e0878ba8c47a36b2ca3a9ffeddd84 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 1 Jun 2018 21:56:38 +0200 Subject: [PATCH 221/247] Give several additional classes constexpr constructors This is useful because these types are created at static init time, and giving them a constexpr constructor and trivial destructor lets them be created during constant initialization, which helps to prevent static init ordering issues. --- panda/src/display/frameBufferProperties.I | 15 ------------- panda/src/display/frameBufferProperties.cxx | 22 ------------------ panda/src/display/frameBufferProperties.h | 14 +++++------- panda/src/egg/eggParameters.cxx | 23 ------------------- panda/src/egg/eggParameters.h | 13 +++++------ panda/src/pgraph/cacheStats.I | 2 +- panda/src/pgraph/cacheStats.cxx | 5 +---- panda/src/pgraph/cacheStats.h | 21 ++++++++--------- panda/src/pgraph/nodePath.I | 4 ++-- panda/src/putil/loaderOptions.I | 25 +-------------------- panda/src/putil/loaderOptions.h | 4 +--- 11 files changed, 29 insertions(+), 119 deletions(-) diff --git a/panda/src/display/frameBufferProperties.I b/panda/src/display/frameBufferProperties.I index 6f2d3257ee..70c809c64b 100644 --- a/panda/src/display/frameBufferProperties.I +++ b/panda/src/display/frameBufferProperties.I @@ -11,21 +11,6 @@ * @date 2003-01-27 */ -/** - * - */ -INLINE FrameBufferProperties:: -FrameBufferProperties(const FrameBufferProperties ©) { - (*this) = copy; -} - -/** - * - */ -INLINE FrameBufferProperties:: -~FrameBufferProperties() { -} - /** * */ diff --git a/panda/src/display/frameBufferProperties.cxx b/panda/src/display/frameBufferProperties.cxx index ea37cc4381..81d12a98ba 100644 --- a/panda/src/display/frameBufferProperties.cxx +++ b/panda/src/display/frameBufferProperties.cxx @@ -17,28 +17,6 @@ #include "config_display.h" #include "texture.h" -/** - * - */ -FrameBufferProperties:: -FrameBufferProperties() { - clear(); -} - -/** - * - */ -void FrameBufferProperties:: -operator = (const FrameBufferProperties ©) { - _flags_specified = copy._flags_specified; - _flags = copy._flags; - _specified = copy._specified; - - for (int i = 0; i < FBP_COUNT; ++i) { - _property[i] = copy._property[i]; - } -} - /** * Returns true if this set of properties makes strictly greater or equal * demands of the framebuffer than the other set of framebuffer properties. diff --git a/panda/src/display/frameBufferProperties.h b/panda/src/display/frameBufferProperties.h index 9ac6c015ea..67e0c50d1e 100644 --- a/panda/src/display/frameBufferProperties.h +++ b/panda/src/display/frameBufferProperties.h @@ -63,11 +63,11 @@ private: FBF_all = 0x100-1, }; - int _property[FBP_COUNT]; - int _specified; + int _property[FBP_COUNT] = {0}; + int _specified = 0; - int _flags; - int _flags_specified; + int _flags = 0; + int _flags_specified = 0; PUBLISHED: @@ -145,10 +145,8 @@ PUBLISHED: // Other. - FrameBufferProperties(); - INLINE FrameBufferProperties(const FrameBufferProperties ©); - INLINE ~FrameBufferProperties(); - void operator = (const FrameBufferProperties ©); + constexpr FrameBufferProperties() = default; + static const FrameBufferProperties &get_default(); bool operator == (const FrameBufferProperties &other) const; INLINE bool operator != (const FrameBufferProperties &other) const; diff --git a/panda/src/egg/eggParameters.cxx b/panda/src/egg/eggParameters.cxx index 14b63ba8ea..b9fc709fcd 100644 --- a/panda/src/egg/eggParameters.cxx +++ b/panda/src/egg/eggParameters.cxx @@ -17,26 +17,3 @@ static EggParameters default_egg_parameters; EggParameters *egg_parameters = &default_egg_parameters; - - -/** - * Initializes all the parameters with default values. - */ -EggParameters:: -EggParameters() { - _pos_threshold = 0.0001; - _normal_threshold = 0.0001; - _uv_threshold = 0.0001; - _color_threshold = 1.0/256.0; - - _table_threshold = 0.0001; -} - - -/** - * - */ -EggParameters:: -EggParameters(const EggParameters &other) { - memcpy(this, &other, sizeof(EggParameters)); -} diff --git a/panda/src/egg/eggParameters.h b/panda/src/egg/eggParameters.h index 36bd1e48f6..93b1aff8b0 100644 --- a/panda/src/egg/eggParameters.h +++ b/panda/src/egg/eggParameters.h @@ -31,28 +31,27 @@ */ class EXPCL_PANDAEGG EggParameters { public: - EggParameters(); - EggParameters(const EggParameters ©); + constexpr EggParameters() = default; // The per-component difference below which two vertices are deemed to be at // the same position. - double _pos_threshold; + double _pos_threshold = 0.0001; // The per-component difference below which two vertices are deemed to have // the same normal. - double _normal_threshold; + double _normal_threshold = 0.0001; // The per-component difference below which two vertices are deemed to have // the same texture coordinates. - double _uv_threshold; + double _uv_threshold = 0.0001; // The per-component difference below which two vertices are deemed to have // the same color. - PN_stdfloat _color_threshold; + PN_stdfloat _color_threshold = 1.0/256.0; // The per-component difference below which two anim table values are deemed // to be equivalent. - double _table_threshold; + double _table_threshold = 0.0001; }; extern EXPCL_PANDAEGG EggParameters *egg_parameters; diff --git a/panda/src/pgraph/cacheStats.I b/panda/src/pgraph/cacheStats.I index a83e480757..e84ff83878 100644 --- a/panda/src/pgraph/cacheStats.I +++ b/panda/src/pgraph/cacheStats.I @@ -17,7 +17,7 @@ INLINE void CacheStats:: maybe_report(const char *name) { #ifndef NDEBUG - if (_cache_report) { + if (UNLIKELY(_cache_report)) { double now = ClockObject::get_global_clock()->get_real_time(); if (now - _last_reset < _cache_report_interval) { return; diff --git a/panda/src/pgraph/cacheStats.cxx b/panda/src/pgraph/cacheStats.cxx index 88a5498384..e16c14801e 100644 --- a/panda/src/pgraph/cacheStats.cxx +++ b/panda/src/pgraph/cacheStats.cxx @@ -22,10 +22,7 @@ void CacheStats:: init() { #ifndef NDEBUG // Let's not use the clock at static init time. - reset(0.0); - // reset(ClockObject::get_global_clock()->get_real_time()); - _total_cache_size = 0; - _num_states = 0; + //reset(ClockObject::get_global_clock()->get_real_time()); _cache_report = ConfigVariableBool("cache-report", false); _cache_report_interval = ConfigVariableDouble("cache-report-interval", 5.0); diff --git a/panda/src/pgraph/cacheStats.h b/panda/src/pgraph/cacheStats.h index 45fb1e6043..12707c4bf0 100644 --- a/panda/src/pgraph/cacheStats.h +++ b/panda/src/pgraph/cacheStats.h @@ -24,6 +24,7 @@ */ class EXPCL_PANDA_PGRAPH CacheStats { public: + constexpr CacheStats() = default; void init(); void reset(double now); void write(ostream &out, const char *name) const; @@ -38,17 +39,17 @@ public: private: #ifndef NDEBUG - int _cache_hits; - int _cache_misses; - int _cache_adds; - int _cache_new_adds; - int _cache_dels; - int _total_cache_size; - int _num_states; - double _last_reset; + int _cache_hits = 0; + int _cache_misses = 0; + int _cache_adds = 0; + int _cache_new_adds = 0; + int _cache_dels = 0; + int _total_cache_size = 0; + int _num_states = 0; + double _last_reset = 0.0; - bool _cache_report; - double _cache_report_interval; + bool _cache_report = false; + double _cache_report_interval = 0.0; #endif // NDEBUG }; diff --git a/panda/src/pgraph/nodePath.I b/panda/src/pgraph/nodePath.I index 8860fff331..74bcc01bd9 100644 --- a/panda/src/pgraph/nodePath.I +++ b/panda/src/pgraph/nodePath.I @@ -16,9 +16,9 @@ */ INLINE NodePath:: NodePath() : - _error_type(ET_ok) + _error_type(ET_ok), + _backup_key(0) { - _backup_key = 0; } /** diff --git a/panda/src/putil/loaderOptions.I b/panda/src/putil/loaderOptions.I index b15780c847..6e407e7840 100644 --- a/panda/src/putil/loaderOptions.I +++ b/panda/src/putil/loaderOptions.I @@ -14,7 +14,7 @@ /** * */ -INLINE LoaderOptions:: +constexpr LoaderOptions:: LoaderOptions(int flags, int texture_flags) : _flags(flags), _texture_flags(texture_flags), @@ -23,29 +23,6 @@ LoaderOptions(int flags, int texture_flags) : { } -/** - * - */ -INLINE LoaderOptions:: -LoaderOptions(const LoaderOptions ©) : - _flags(copy._flags), - _texture_flags(copy._texture_flags), - _texture_num_views(copy._texture_num_views), - _auto_texture_scale(copy._auto_texture_scale) -{ -} - -/** - * - */ -INLINE void LoaderOptions:: -operator = (const LoaderOptions ©) { - _flags = copy._flags; - _texture_flags = copy._texture_flags; - _texture_num_views = copy._texture_num_views; - _auto_texture_scale = copy._auto_texture_scale; -} - /** * */ diff --git a/panda/src/putil/loaderOptions.h b/panda/src/putil/loaderOptions.h index 50c73f983e..971353e723 100644 --- a/panda/src/putil/loaderOptions.h +++ b/panda/src/putil/loaderOptions.h @@ -49,9 +49,7 @@ PUBLISHED: }; LoaderOptions(int flags = LF_search | LF_report_errors); - INLINE LoaderOptions(int flags, int texture_flags); - INLINE LoaderOptions(const LoaderOptions ©); - INLINE void operator = (const LoaderOptions ©); + constexpr LoaderOptions(int flags, int texture_flags); INLINE void set_flags(int flags); INLINE int get_flags() const; From e0245d2777f096fd4cb1c1ea852dd7d3ef34c197 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 3 Jun 2018 12:24:31 -0400 Subject: [PATCH 222/247] First step towards eliminating `using namespace std;` (#335) --- contrib/src/ai/aiPathFinder.h | 8 ++-- contrib/src/ai/aiWorld.h | 2 +- contrib/src/ai/pathFind.cxx | 6 +-- contrib/src/ai/pathFind.h | 4 +- contrib/src/rplight/gpuCommandList.h | 2 +- contrib/src/rplight/pointerSlotStorage.h | 1 + contrib/src/rplight/pssmCameraRig.h | 6 +-- direct/src/dcparser/dcbase.h | 16 +++---- direct/src/directdServer/directdClient.cxx | 4 +- direct/src/interval/cMetaInterval.cxx | 2 +- dtool/src/cppparser/cppBison.cxx.prebuilt | 6 +-- dtool/src/cppparser/cppBison.yxx | 6 +-- dtool/src/cppparser/cppClosureType.h | 2 +- dtool/src/cppparser/cppCommentBlock.h | 2 +- dtool/src/cppparser/cppPreprocessor.cxx | 4 +- dtool/src/dtoolbase/dtoolbase_cc.h | 43 +++++++++++++++---- dtool/src/dtoolbase/fakestringstream.h | 2 - dtool/src/dtoolbase/memoryHook.h | 2 +- dtool/src/dtoolbase/neverFreeMemory.h | 2 +- dtool/src/dtoolbase/pallocator.h | 6 ++- dtool/src/dtoolbase/pdeque.h | 4 +- dtool/src/dtoolbase/pdtoa.cxx | 2 +- dtool/src/dtoolbase/plist.h | 4 +- dtool/src/dtoolbase/pmap.h | 7 ++- dtool/src/dtoolbase/pset.h | 11 +++-- dtool/src/dtoolbase/pvector.h | 4 +- dtool/src/dtoolbase/stl_compares.h | 4 ++ dtool/src/dtoolbase/typeRegistry.h | 6 +-- dtool/src/dtoolbase/typeRegistryNode.h | 4 +- dtool/src/dtoolutil/dSearchPath.cxx | 8 ++-- dtool/src/dtoolutil/filename.cxx | 10 ++--- dtool/src/dtoolutil/filename.h | 10 ++--- dtool/src/interrogate/functionRemap.h | 2 +- dtool/src/interrogate/interfaceMaker.cxx | 2 +- dtool/src/interrogate/interfaceMaker.h | 20 ++++----- dtool/src/interrogate/interrogateBuilder.cxx | 14 +++--- dtool/src/interrogate/interrogateBuilder.h | 16 +++---- dtool/src/interrogate/interrogate_module.cxx | 12 +++--- dtool/src/interrogate/parse_file.cxx | 2 +- dtool/src/interrogatedb/indexRemapper.cxx | 2 +- dtool/src/interrogatedb/indexRemapper.h | 2 +- .../src/interrogatedb/interrogateComponent.h | 2 +- dtool/src/interrogatedb/interrogateDatabase.h | 28 ++++++------ dtool/src/interrogatedb/interrogateFunction.h | 4 +- .../interrogateFunctionWrapper.h | 2 +- dtool/src/interrogatedb/interrogateType.h | 12 +++--- .../src/interrogatedb/interrogate_datafile.I | 6 +-- .../src/interrogatedb/interrogate_datafile.h | 4 +- dtool/src/interrogatedb/py_panda.I | 2 +- dtool/src/interrogatedb/py_panda.h | 2 +- dtool/src/parser-inc/vector | 4 ++ dtool/src/prc/configDeclaration.h | 2 +- dtool/src/prc/configPage.h | 2 +- dtool/src/prc/configPageManager.h | 6 +-- dtool/src/prc/configVariableCore.h | 2 +- dtool/src/prc/configVariableManager.h | 6 +-- dtool/src/prc/notify.cxx | 4 +- dtool/src/prc/notifyCategory.h | 2 +- dtool/src/prc/pnotify.h | 2 +- dtool/src/prc/prcKeyRegistry.h | 2 +- panda/src/chan/partGroup.cxx | 2 +- panda/src/collide/collisionTraverser.cxx | 6 +-- panda/src/cull/cullBinFixed.cxx | 2 +- panda/src/display/graphicsOutput.cxx | 4 +- panda/src/display/graphicsWindow_ext.cxx | 4 +- panda/src/display/subprocessWindowBuffer.cxx | 1 - panda/src/display/subprocessWindowBuffer.h | 1 - panda/src/downloader/httpChannel.cxx | 6 +-- panda/src/downloadertools/multify.cxx | 4 +- panda/src/downloadertools/pdecrypt.cxx | 2 +- panda/src/downloadertools/pencrypt.cxx | 2 +- panda/src/egg/eggData.cxx | 2 +- panda/src/egg/eggPrimitive.I | 2 +- panda/src/egg/eggPrimitive.cxx | 4 +- panda/src/egg/eggUtilities.I | 2 +- panda/src/egg/eggVertexPool.cxx | 4 +- panda/src/egg/lexer.cxx.prebuilt | 10 ++--- panda/src/egg/lexer.lxx | 10 ++--- panda/src/egg/parser.cxx.prebuilt | 8 ++-- panda/src/egg/parser.yxx | 8 ++-- panda/src/event/asyncFuture.I | 2 +- panda/src/event/asyncFuture.h | 2 +- panda/src/event/eventParameter.h | 2 +- panda/src/express/hashVal.cxx | 2 +- panda/src/express/make_ca_bundle.cxx | 2 +- panda/src/express/memoryUsage.h | 4 +- panda/src/express/multifile.cxx | 2 +- panda/src/express/ordered_vector.I | 2 +- panda/src/express/profileTimer.cxx | 14 +++--- panda/src/express/virtualFile.cxx | 4 +- panda/src/express/virtualFileMountSystem.cxx | 2 +- panda/src/express/weakReferenceList.cxx | 2 +- panda/src/glstuff/glShaderContext_src.cxx | 2 +- panda/src/gobj/geomTriangles.cxx | 2 + panda/src/gobj/geomTristrips.cxx | 2 + panda/src/gobj/internalName_ext.cxx | 2 +- panda/src/gobj/shader.cxx | 6 +-- panda/src/net/datagram_ui.cxx | 8 ++-- panda/src/net/test_raw_server.cxx | 2 +- panda/src/pgraph/clipPlaneAttrib.cxx | 8 ++-- panda/src/pgraph/cullableObject.cxx | 2 +- panda/src/pgraph/lightAttrib.cxx | 4 +- panda/src/pgraph/renderAttrib.h | 2 +- panda/src/pgraph/renderAttribRegistry.cxx | 4 +- panda/src/pgraph/renderEffects.cxx | 12 +++--- panda/src/pgraph/renderState.h | 2 +- panda/src/pgraph/textureStageCollection.cxx | 4 +- panda/src/pgraph/transformState.h | 2 +- panda/src/pipeline/test_diners.cxx | 2 +- panda/src/pipeline/test_threaddata.cxx | 2 +- panda/src/pnmimage/pnmImage.cxx | 2 +- panda/src/pstatclient/pStatFrameData.cxx | 2 +- panda/src/putil/datagramInputFile.I | 2 +- panda/src/putil/datagramOutputFile.I | 2 +- panda/src/putil/simpleHashMap.h | 10 ++--- panda/src/speedtree/speedTreeNode.cxx | 2 +- panda/src/speedtree/stBasicTerrain.cxx | 2 +- panda/src/windisplay/winGraphicsWindow.cxx | 2 +- pandatool/src/bam/ptsToBam.cxx | 4 +- pandatool/src/cvscopy/cvsCopy.cxx | 14 +++--- pandatool/src/cvscopy/cvsSourceTree.cxx | 8 ++-- pandatool/src/dxf/dxfFile.cxx | 2 +- pandatool/src/egg-palettize/eggPalettize.cxx | 2 +- pandatool/src/egg-qtess/qtessInputFile.cxx | 4 +- pandatool/src/eggbase/eggMultiFilter.cxx | 4 +- pandatool/src/eggbase/eggWriter.h | 2 +- pandatool/src/flt/fltHeader.cxx | 2 +- pandatool/src/flt/fltTexture.cxx | 4 +- pandatool/src/mayaegg/mayaToEggConverter.cxx | 2 +- pandatool/src/mayaprogs/blend_test.cxx | 2 +- pandatool/src/mayaprogs/normal_test.cxx | 2 +- pandatool/src/miscprogs/binToC.cxx | 4 +- pandatool/src/palettizer/textureImage.cxx | 2 +- pandatool/src/progbase/programBase.cxx | 2 +- pandatool/src/progbase/withOutputFile.h | 4 +- pandatool/src/softegg/soft2Egg.c | 7 ++- pandatool/src/softegg/softToEggConverter.cxx | 2 +- pandatool/src/softprogs/softCVS.cxx | 8 ++-- pandatool/src/text-stats/textStats.cxx | 2 +- pandatool/src/vrml/vrmlParser.cxx.prebuilt | 6 +-- pandatool/src/vrml/vrmlParser.yxx | 6 +-- pandatool/src/xfile/xFile.cxx | 2 +- 142 files changed, 363 insertions(+), 316 deletions(-) diff --git a/contrib/src/ai/aiPathFinder.h b/contrib/src/ai/aiPathFinder.h index 1595cb2777..4b2e2c976a 100644 --- a/contrib/src/ai/aiPathFinder.h +++ b/contrib/src/ai/aiPathFinder.h @@ -18,8 +18,8 @@ #include "cmath.h" #include "lineSegs.h" -typedef vector NodeArray; -typedef vector NavMesh; +typedef std::vector NodeArray; +typedef std::vector NavMesh; Node* find_in_mesh(NavMesh nav_mesh, LVecBase3 pos, int grid_size); @@ -32,8 +32,8 @@ class EXPCL_PANDAAI PathFinder { public: Node *_src_node; Node *_dest_node; - vector _open_list; - vector _closed_list; + std::vector _open_list; + std::vector _closed_list; NavMesh _grid; diff --git a/contrib/src/ai/aiWorld.h b/contrib/src/ai/aiWorld.h index 64cecefc2d..3848e054dc 100644 --- a/contrib/src/ai/aiWorld.h +++ b/contrib/src/ai/aiWorld.h @@ -34,7 +34,7 @@ class EXPCL_PANDAAI AIWorld { AICharPool _ai_char_pool; NodePath _render; public: - vector _obstacles; + std::vector _obstacles; typedef std::vector FlockPool; FlockPool _flock_pool; void remove_ai_char_from_flock(string name); diff --git a/contrib/src/ai/pathFind.cxx b/contrib/src/ai/pathFind.cxx index 39093da197..aca7745229 100644 --- a/contrib/src/ai/pathFind.cxx +++ b/contrib/src/ai/pathFind.cxx @@ -46,7 +46,7 @@ void PathFind::create_nav_mesh(const char* navmesh_filename) { string fields[10]; // Open data file for reading. - ifstream nav_mesh_file (navmesh_filename); + std::ifstream nav_mesh_file (navmesh_filename); if(nav_mesh_file.is_open()) { // Capture the grid size from the file. @@ -56,7 +56,7 @@ void PathFind::create_nav_mesh(const char* navmesh_filename) { // Initialize the stage mesh with NULL nodes. for(int r = 0; r < _grid_size; ++r) { - _nav_mesh.push_back(vector()); + _nav_mesh.push_back(std::vector()); for(int c = 0; c < _grid_size; ++c) { _nav_mesh[r].push_back(NULL); } @@ -111,7 +111,7 @@ void PathFind::create_nav_mesh(const char* navmesh_filename) { * _nav_mesh. */ void PathFind::assign_neighbor_nodes(const char* navmesh_filename){ - ifstream nav_mesh_file (navmesh_filename); + std::ifstream nav_mesh_file (navmesh_filename); // Stage variables. int gd_x, gd_y, gd_xn, gd_yn; diff --git a/contrib/src/ai/pathFind.h b/contrib/src/ai/pathFind.h index eb82f9ff99..ffeb50abf0 100644 --- a/contrib/src/ai/pathFind.h +++ b/contrib/src/ai/pathFind.h @@ -40,9 +40,9 @@ public: LVecBase3 _prev_position; PT(GeomNode) _parent; LineSegs *_pen; - vector _previous_obstacles; + std::vector _previous_obstacles; bool _dynamic_avoid; - vector _dynamic_obstacle; + std::vector _dynamic_obstacle; PathFind(AICharacter *ai_ch); ~PathFind(); diff --git a/contrib/src/rplight/gpuCommandList.h b/contrib/src/rplight/gpuCommandList.h index f2ec280116..1551afe630 100644 --- a/contrib/src/rplight/gpuCommandList.h +++ b/contrib/src/rplight/gpuCommandList.h @@ -48,7 +48,7 @@ PUBLISHED: MAKE_PROPERTY(num_commands, get_num_commands); protected: - queue _commands; + std::queue _commands; }; #endif // GPUCOMMANDLIST_H diff --git a/contrib/src/rplight/pointerSlotStorage.h b/contrib/src/rplight/pointerSlotStorage.h index 2d908c5795..401e133b81 100644 --- a/contrib/src/rplight/pointerSlotStorage.h +++ b/contrib/src/rplight/pointerSlotStorage.h @@ -45,6 +45,7 @@ class PointerSlotStorage {}; using std::tr1::array; #else #include +using std::array; #endif /** diff --git a/contrib/src/rplight/pssmCameraRig.h b/contrib/src/rplight/pssmCameraRig.h index ce0567bbbf..33cefe6dc1 100644 --- a/contrib/src/rplight/pssmCameraRig.h +++ b/contrib/src/rplight/pssmCameraRig.h @@ -96,9 +96,9 @@ protected: inline LPoint3 get_interpolated_point(CoordinateOrigin origin, float depth); LVecBase3 get_snap_offset(const LMatrix4& mat, size_t resolution); - vector _cam_nodes; - vector _cameras; - vector _max_film_sizes; + std::vector _cam_nodes; + std::vector _cameras; + std::vector _max_film_sizes; // Current near and far points // Order: UL, UR, LL, LR (See CoordinateOrigin) diff --git a/direct/src/dcparser/dcbase.h b/direct/src/dcparser/dcbase.h index 6d65f16524..6cf146d848 100644 --- a/direct/src/dcparser/dcbase.h +++ b/direct/src/dcparser/dcbase.h @@ -60,8 +60,6 @@ #include #endif -using namespace std; - #define INLINE inline #define TYPENAME typename @@ -82,7 +80,7 @@ using namespace std; // Panda defines a special Filename class. We'll use an ordinary string // instead. -typedef string Filename; +typedef std::string Filename; // Panda defines WORDS_BIGENDIAN on a bigendian machine; otherwise, the // machine is assumed to be littleendian. Outside of Panda, you're @@ -92,15 +90,15 @@ typedef string Filename; #include #include #include -#define pvector vector -#define pmap map -#define pset set +#define pvector std::vector +#define pmap std::map +#define pset std::set #include -typedef ifstream pifstream; -typedef ofstream pofstream; -typedef fstream pfstream; +typedef std::ifstream pifstream; +typedef std::ofstream pofstream; +typedef std::fstream pfstream; #endif // WITHIN_PANDA diff --git a/direct/src/directdServer/directdClient.cxx b/direct/src/directdServer/directdClient.cxx index 550c3f2862..91059ed384 100644 --- a/direct/src/directdServer/directdClient.cxx +++ b/direct/src/directdServer/directdClient.cxx @@ -24,7 +24,7 @@ DirectDClient::cli_command(const string& cmd) { cerr<<"command "<> code; string host; @@ -49,7 +49,7 @@ DirectDClient::run_client(const string& host, int port) { connect_to(host, port); while (!cin.fail() && _connections.size()!=0) { - cout << "directd send: " << flush; + cout << "directd send: " << std::flush; string d; cin >> d; cli_command(d); diff --git a/direct/src/interval/cMetaInterval.cxx b/direct/src/interval/cMetaInterval.cxx index dd5f1386f2..a4b914c7ed 100644 --- a/direct/src/interval/cMetaInterval.cxx +++ b/direct/src/interval/cMetaInterval.cxx @@ -756,7 +756,7 @@ do_recompute() { // We do a stable_sort() to guarantee ordering of events that have the same // start time. These must be invoked in the order in which they appear. - stable_sort(_events.begin(), _events.end(), IndirectLess()); + std::stable_sort(_events.begin(), _events.end(), IndirectLess()); _duration = int_to_double_time(_end_time); } diff --git a/dtool/src/cppparser/cppBison.cxx.prebuilt b/dtool/src/cppparser/cppBison.cxx.prebuilt index 6ee30a3510..f1985d488e 100644 --- a/dtool/src/cppparser/cppBison.cxx.prebuilt +++ b/dtool/src/cppparser/cppBison.cxx.prebuilt @@ -114,9 +114,9 @@ static int publish_nest_level = 0; static CPPVisibility publish_previous; static YYLTYPE publish_loc; -static vector last_scopes; -static vector last_storage_classes; -static vector last_structs; +static std::vector last_scopes; +static std::vector last_storage_classes; +static std::vector last_structs; int yyparse(); diff --git a/dtool/src/cppparser/cppBison.yxx b/dtool/src/cppparser/cppBison.yxx index 64fc1cf4f1..3750399ccc 100644 --- a/dtool/src/cppparser/cppBison.yxx +++ b/dtool/src/cppparser/cppBison.yxx @@ -49,9 +49,9 @@ static int publish_nest_level = 0; static CPPVisibility publish_previous; static YYLTYPE publish_loc; -static vector last_scopes; -static vector last_storage_classes; -static vector last_structs; +static std::vector last_scopes; +static std::vector last_storage_classes; +static std::vector last_structs; int yyparse(); diff --git a/dtool/src/cppparser/cppClosureType.h b/dtool/src/cppparser/cppClosureType.h index 9c3533ad4a..85b392ba85 100644 --- a/dtool/src/cppparser/cppClosureType.h +++ b/dtool/src/cppparser/cppClosureType.h @@ -39,7 +39,7 @@ public: CaptureType _type; CPPExpression *_initializer; }; - typedef vector Captures; + typedef std::vector Captures; Captures _captures; CaptureType _default_capture; diff --git a/dtool/src/cppparser/cppCommentBlock.h b/dtool/src/cppparser/cppCommentBlock.h index d3e8ef0a02..614012ce61 100644 --- a/dtool/src/cppparser/cppCommentBlock.h +++ b/dtool/src/cppparser/cppCommentBlock.h @@ -36,6 +36,6 @@ public: string _comment; }; -typedef list CPPComments; +typedef std::list CPPComments; #endif diff --git a/dtool/src/cppparser/cppPreprocessor.cxx b/dtool/src/cppparser/cppPreprocessor.cxx index 899d1f076f..c41441fd75 100644 --- a/dtool/src/cppparser/cppPreprocessor.cxx +++ b/dtool/src/cppparser/cppPreprocessor.cxx @@ -567,12 +567,12 @@ show_line(const YYLTYPE &loc) { } // Seek to the offending line in the file. - ifstream stream; + std::ifstream stream; if (loc.file._filename.open_read(stream)) { int l = 0; string linestr; while (l < loc.first_line) { - getline(stream, linestr); + std::getline(stream, linestr); ++l; } diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index fc47f057d1..8c44ec4429 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -35,8 +35,6 @@ #include #include -using namespace std; - #define INLINE inline #define ALWAYS_INLINE inline #define TYPENAME typename @@ -78,8 +76,7 @@ typedef int ios_seekdir; #include #include - -using namespace std; +#include #define TYPENAME typename @@ -90,10 +87,10 @@ typedef int ios_iostate; // Old iostream libraries used ios::seek_dir instead of ios::seekdir. typedef ios::seek_dir ios_seekdir; #else -typedef ios::openmode ios_openmode; -typedef ios::fmtflags ios_fmtflags; -typedef ios::iostate ios_iostate; -typedef ios::seekdir ios_seekdir; +typedef std::ios::openmode ios_openmode; +typedef std::ios::fmtflags ios_fmtflags; +typedef std::ios::iostate ios_iostate; +typedef std::ios::seekdir ios_seekdir; #endif // Apple has an outdated libstdc++. Not all is lost, though, as we can fill @@ -161,6 +158,36 @@ namespace std { #endif // CPPPARSER +// This was previously `using namespace std`, but we don't want to pull in the +// entire namespace, so we enumerate the things we are using without std:: +// prefix in the Panda headers. It is intended that this list will shrink. +using std::cerr; +using std::cin; +using std::cout; +using std::dec; +using std::endl; +using std::hex; +using std::ios; +using std::iostream; +using std::istream; +using std::istringstream; +using std::max; +using std::min; +using std::move; +using std::ostream; +using std::ostringstream; +using std::pair; +using std::setfill; +using std::setw; +using std::streambuf; +using std::streamoff; +using std::streampos; +using std::streamsize; +using std::string; +using std::stringstream; +using std::swap; +using std::wstring; + // The ReferenceCount class is defined later, within Panda, but we need to // pass around forward references to it here at the very low level. class ReferenceCount; diff --git a/dtool/src/dtoolbase/fakestringstream.h b/dtool/src/dtoolbase/fakestringstream.h index 4ff2a971f0..7132d6280e 100644 --- a/dtool/src/dtoolbase/fakestringstream.h +++ b/dtool/src/dtoolbase/fakestringstream.h @@ -18,8 +18,6 @@ #include #include -using namespace std; - class fake_istream_buffer { public: fake_istream_buffer() { diff --git a/dtool/src/dtoolbase/memoryHook.h b/dtool/src/dtoolbase/memoryHook.h index bb30e7f03d..11d83439d3 100644 --- a/dtool/src/dtoolbase/memoryHook.h +++ b/dtool/src/dtoolbase/memoryHook.h @@ -84,7 +84,7 @@ protected: private: size_t _page_size; - typedef map DeletedChains; + typedef std::map DeletedChains; DeletedChains _deleted_chains; mutable MutexImpl _lock; diff --git a/dtool/src/dtoolbase/neverFreeMemory.h b/dtool/src/dtoolbase/neverFreeMemory.h index d3f0cf51a1..8396313015 100644 --- a/dtool/src/dtoolbase/neverFreeMemory.h +++ b/dtool/src/dtoolbase/neverFreeMemory.h @@ -57,7 +57,7 @@ private: size_t _remaining; }; - typedef set Pages; + typedef std::set Pages; Pages _pages; size_t _total_alloc; diff --git a/dtool/src/dtoolbase/pallocator.h b/dtool/src/dtoolbase/pallocator.h index 8dfbb8178d..9c27191aa0 100644 --- a/dtool/src/dtoolbase/pallocator.h +++ b/dtool/src/dtoolbase/pallocator.h @@ -20,6 +20,8 @@ #include "deletedChain.h" #include "typeHandle.h" +using std::allocator; + /** * This is our own Panda specialization on the default STL allocator. Its * main purpose is to call the hooks for MemoryUsage to properly track STL- @@ -36,8 +38,8 @@ // If we're not trying to make custom allocators (either we don't know what // kind of syntax this STL library wants, or we're compiling with OPTIMIZE 4), // then simply use the standard allocator. -#define pallocator_single allocator -#define pallocator_array allocator +#define pallocator_single std::allocator +#define pallocator_array std::allocator #else diff --git a/dtool/src/dtoolbase/pdeque.h b/dtool/src/dtoolbase/pdeque.h index 96cf319e77..e3bc33d521 100644 --- a/dtool/src/dtoolbase/pdeque.h +++ b/dtool/src/dtoolbase/pdeque.h @@ -22,10 +22,12 @@ #if !defined(USE_STL_ALLOCATOR) || defined(CPPPARSER) // If we're not using custom allocators, just use the standard class // definition. -#define pdeque deque +#define pdeque std::deque #else +using std::deque; + /** * This is our own Panda specialization on the default STL deque. Its main * purpose is to call the hooks for MemoryUsage to properly track STL- diff --git a/dtool/src/dtoolbase/pdtoa.cxx b/dtool/src/dtoolbase/pdtoa.cxx index bc50d6ff92..2b508654ba 100644 --- a/dtool/src/dtoolbase/pdtoa.cxx +++ b/dtool/src/dtoolbase/pdtoa.cxx @@ -397,7 +397,7 @@ void pdtoa(double value, char *buffer) { #ifdef _MSC_VER if (copysign(1.0, value) < 0) { #else - if (signbit(value)) { + if (std::signbit(value)) { #endif *buffer++ = '-'; value = -value; diff --git a/dtool/src/dtoolbase/plist.h b/dtool/src/dtoolbase/plist.h index bbb9e55089..978f91cd49 100644 --- a/dtool/src/dtoolbase/plist.h +++ b/dtool/src/dtoolbase/plist.h @@ -22,10 +22,12 @@ #if !defined(USE_STL_ALLOCATOR) || defined(CPPPARSER) // If we're not using custom allocators, just use the standard class // definition. -#define plist list +#define plist std::list #else +using std::list; + /** * This is our own Panda specialization on the default STL list. Its main * purpose is to call the hooks for MemoryUsage to properly track STL- diff --git a/dtool/src/dtoolbase/pmap.h b/dtool/src/dtoolbase/pmap.h index e115191b45..8ac5be6134 100644 --- a/dtool/src/dtoolbase/pmap.h +++ b/dtool/src/dtoolbase/pmap.h @@ -27,8 +27,8 @@ #if !defined(USE_STL_ALLOCATOR) || defined(CPPPARSER) // If we're not using custom allocators, just use the standard class // definition. -#define pmap map -#define pmultimap multimap +#define pmap std::map +#define pmultimap std::multimap #ifdef HAVE_STL_HASH #define phash_map stdext::hash_map @@ -40,6 +40,9 @@ #else // USE_STL_ALLOCATOR +using std::map; +using std::multimap; + /** * This is our own Panda specialization on the default STL map. Its main * purpose is to call the hooks for MemoryUsage to properly track STL- diff --git a/dtool/src/dtoolbase/pset.h b/dtool/src/dtoolbase/pset.h index b7990ad671..142c5b3149 100644 --- a/dtool/src/dtoolbase/pset.h +++ b/dtool/src/dtoolbase/pset.h @@ -27,19 +27,22 @@ #if !defined(USE_STL_ALLOCATOR) || defined(CPPPARSER) // If we're not using custom allocators, just use the standard class // definition. -#define pset set -#define pmultiset multiset +#define pset std::set +#define pmultiset std::multiset #ifdef HAVE_STL_HASH #define phash_set stdext::hash_set #define phash_multiset stdext::hash_multiset #else // HAVE_STL_HASH -#define phash_set set -#define phash_multiset multiset +#define phash_set std::set +#define phash_multiset std::multiset #endif // HAVE_STL_HASH #else // USE_STL_ALLOCATOR +using std::set; +using std::multiset; + /** * This is our own Panda specialization on the default STL set. Its main * purpose is to call the hooks for MemoryUsage to properly track STL- diff --git a/dtool/src/dtoolbase/pvector.h b/dtool/src/dtoolbase/pvector.h index 8da0e88b85..8baf3c49c1 100644 --- a/dtool/src/dtoolbase/pvector.h +++ b/dtool/src/dtoolbase/pvector.h @@ -28,11 +28,13 @@ #elif defined(CPPPARSER) // Simplified definition to speed up Interrogate parsing. template -class pvector : public vector { +class pvector : public std::vector { }; #else +using std::vector; + /** * This is our own Panda specialization on the default STL vector. Its main * purpose is to call the hooks for MemoryUsage to properly track STL- diff --git a/dtool/src/dtoolbase/stl_compares.h b/dtool/src/dtoolbase/stl_compares.h index 57d989337a..0afffbf9a2 100644 --- a/dtool/src/dtoolbase/stl_compares.h +++ b/dtool/src/dtoolbase/stl_compares.h @@ -24,6 +24,8 @@ #ifdef HAVE_STL_HASH #include // for hash_compare +using std::less; + template > class stl_hash_compare : public stdext::hash_compare { public: @@ -36,6 +38,8 @@ public: #include // for less +using std::less; + // This is declared for the cases in which we don't have STL_HASH available. template > class stl_hash_compare : public Compare { diff --git a/dtool/src/dtoolbase/typeRegistry.h b/dtool/src/dtoolbase/typeRegistry.h index 5c5c09ad4c..2227782862 100644 --- a/dtool/src/dtoolbase/typeRegistry.h +++ b/dtool/src/dtoolbase/typeRegistry.h @@ -100,13 +100,13 @@ private: static INLINE void init_lock(); - typedef vector HandleRegistry; + typedef std::vector HandleRegistry; HandleRegistry _handle_registry; - typedef map NameRegistry; + typedef std::map NameRegistry; NameRegistry _name_registry; - typedef vector RootClasses; + typedef std::vector RootClasses; RootClasses _root_classes; bool _derivations_fresh; diff --git a/dtool/src/dtoolbase/typeRegistryNode.h b/dtool/src/dtoolbase/typeRegistryNode.h index a8df5c339e..c459d64805 100644 --- a/dtool/src/dtoolbase/typeRegistryNode.h +++ b/dtool/src/dtoolbase/typeRegistryNode.h @@ -43,7 +43,7 @@ public: TypeHandle _handle; string _name; TypeHandle &_ref; - typedef vector Classes; + typedef std::vector Classes; Classes _parent_classes; Classes _child_classes; @@ -72,7 +72,7 @@ private: SubtreeMaskType _mask; SubtreeMaskType _bits; }; - typedef vector TopInheritance; + typedef std::vector TopInheritance; void r_build_subtrees(TypeRegistryNode *top, int bit_count, SubtreeMaskType bits); diff --git a/dtool/src/dtoolutil/dSearchPath.cxx b/dtool/src/dtoolutil/dSearchPath.cxx index d0aec4c3ad..f30f2156fc 100644 --- a/dtool/src/dtoolutil/dSearchPath.cxx +++ b/dtool/src/dtoolutil/dSearchPath.cxx @@ -220,8 +220,8 @@ append_path(const string &path, const string &separator) { */ void DSearchPath:: append_path(const DSearchPath &path) { - copy(path._directories.begin(), path._directories.end(), - back_inserter(_directories)); + std::copy(path._directories.begin(), path._directories.end(), + std::back_inserter(_directories)); } /** @@ -232,8 +232,8 @@ void DSearchPath:: prepend_path(const DSearchPath &path) { if (!path._directories.empty()) { Directories new_directories = path._directories; - copy(_directories.begin(), _directories.end(), - back_inserter(new_directories)); + std::copy(_directories.begin(), _directories.end(), + std::back_inserter(new_directories)); _directories.swap(new_directories); } } diff --git a/dtool/src/dtoolutil/filename.cxx b/dtool/src/dtoolutil/filename.cxx index 2df2647490..036707f47d 100644 --- a/dtool/src/dtoolutil/filename.cxx +++ b/dtool/src/dtoolutil/filename.cxx @@ -1855,7 +1855,7 @@ scan_directory(vector_string &contents) const { * or set_binary(). */ bool Filename:: -open_read(ifstream &stream) const { +open_read(std::ifstream &stream) const { assert(!get_pattern()); assert(is_binary_or_text()); @@ -1891,7 +1891,7 @@ open_read(ifstream &stream) const { * if it already exists. Otherwise, the file is kept at its original length. */ bool Filename:: -open_write(ofstream &stream, bool truncate) const { +open_write(std::ofstream &stream, bool truncate) const { assert(!get_pattern()); assert(is_binary_or_text()); @@ -1937,7 +1937,7 @@ open_write(ofstream &stream, bool truncate) const { * or set_binary(). */ bool Filename:: -open_append(ofstream &stream) const { +open_append(std::ofstream &stream) const { assert(!get_pattern()); assert(is_binary_or_text()); @@ -1969,7 +1969,7 @@ open_append(ofstream &stream) const { * one of set_text() or set_binary(). */ bool Filename:: -open_read_write(fstream &stream, bool truncate) const { +open_read_write(std::fstream &stream, bool truncate) const { assert(!get_pattern()); assert(is_binary_or_text()); @@ -2011,7 +2011,7 @@ open_read_write(fstream &stream, bool truncate) const { * open_read() without first calling one of set_text() or set_binary(). */ bool Filename:: -open_read_append(fstream &stream) const { +open_read_append(std::fstream &stream) const { assert(!get_pattern()); assert(is_binary_or_text()); diff --git a/dtool/src/dtoolutil/filename.h b/dtool/src/dtoolutil/filename.h index 07927a846c..01297dfbee 100644 --- a/dtool/src/dtoolutil/filename.h +++ b/dtool/src/dtoolutil/filename.h @@ -203,11 +203,11 @@ PUBLISHED: EXTENSION(PyObject *scan_directory() const); #endif - bool open_read(ifstream &stream) const; - bool open_write(ofstream &stream, bool truncate = true) const; - bool open_append(ofstream &stream) const; - bool open_read_write(fstream &stream, bool truncate = false) const; - bool open_read_append(fstream &stream) const; + bool open_read(std::ifstream &stream) const; + bool open_write(std::ofstream &stream, bool truncate = true) const; + bool open_append(std::ofstream &stream) const; + bool open_read_write(std::fstream &stream, bool truncate = false) const; + bool open_read_append(std::fstream &stream) const; #ifdef USE_PANDAFILESTREAM bool open_read(pifstream &stream) const; diff --git a/dtool/src/interrogate/functionRemap.h b/dtool/src/interrogate/functionRemap.h index b4b8aea6dd..7c12f65c3d 100644 --- a/dtool/src/interrogate/functionRemap.h +++ b/dtool/src/interrogate/functionRemap.h @@ -103,7 +103,7 @@ public: F_explicit_args = 0x8000, }; - typedef vector Parameters; + typedef std::vector Parameters; Parameters _parameters; ParameterRemap *_return_type; diff --git a/dtool/src/interrogate/interfaceMaker.cxx b/dtool/src/interrogate/interfaceMaker.cxx index 218affd565..2b04f8477a 100644 --- a/dtool/src/interrogate/interfaceMaker.cxx +++ b/dtool/src/interrogate/interfaceMaker.cxx @@ -460,7 +460,7 @@ wrap_global_functions() { * added to the end. */ void InterfaceMaker:: -get_function_remaps(vector &remaps) { +get_function_remaps(std::vector &remaps) { FunctionsByIndex::iterator fi; for (fi = _functions.begin(); fi != _functions.end(); ++fi) { Function *func = (*fi).second; diff --git a/dtool/src/interrogate/interfaceMaker.h b/dtool/src/interrogate/interfaceMaker.h index f6b4730609..620f42d275 100644 --- a/dtool/src/interrogate/interfaceMaker.h +++ b/dtool/src/interrogate/interfaceMaker.h @@ -64,7 +64,7 @@ public: virtual bool separate_overloading(); virtual bool wrap_global_functions(); - void get_function_remaps(vector &remaps); + void get_function_remaps(std::vector &remaps); static ostream &indent(ostream &out, int indent_level); @@ -100,14 +100,14 @@ public: string _name; const InterrogateType &_itype; const InterrogateFunction &_ifunc; - typedef vector Remaps; + typedef std::vector Remaps; Remaps _remaps; bool _has_this; int _flags; ArgsType _args_type; }; - typedef map FunctionsByIndex; - typedef vector Functions; + typedef std::map FunctionsByIndex; + typedef std::vector Functions; FunctionsByIndex _functions; class MakeSeq { @@ -119,15 +119,15 @@ public: Function *_length_getter; Function *_element_getter; }; - typedef vector MakeSeqs; + typedef std::vector MakeSeqs; class Property { public: Property(const InterrogateElement &ielement); const InterrogateElement &_ielement; - vector _getter_remaps; - vector _setter_remaps; + std::vector _getter_remaps; + std::vector _setter_remaps; Function *_length_function; Function *_has_function; Function *_clear_function; @@ -136,7 +136,7 @@ public: Function *_getkey_function; bool _has_this; }; - typedef vector Properties; + typedef std::vector Properties; class Object { public: @@ -162,10 +162,10 @@ public: }; int _protocol_types; }; - typedef map Objects; + typedef std::map Objects; Objects _objects; - typedef map WrappersByHash; + typedef std::map WrappersByHash; WrappersByHash _wrappers_by_hash; virtual FunctionRemap * diff --git a/dtool/src/interrogate/interrogateBuilder.cxx b/dtool/src/interrogate/interrogateBuilder.cxx index 63d579c68f..5c9dc651ad 100644 --- a/dtool/src/interrogate/interrogateBuilder.cxx +++ b/dtool/src/interrogate/interrogateBuilder.cxx @@ -74,7 +74,7 @@ add_source_file(const string &filename) { void InterrogateBuilder:: read_command_file(istream &in) { string line; - getline(in, line); + std::getline(in, line); while (!in.fail() && !in.eof()) { // Strip out the comment. size_t hash = line.find('#'); @@ -110,7 +110,7 @@ read_command_file(istream &in) { do_command(command, params); } - getline(in, line); + std::getline(in, line); } } @@ -323,7 +323,7 @@ build() { */ void InterrogateBuilder:: write_code(ostream &out_code,ostream * out_include, InterrogateModuleDef *def) { - typedef vector InterfaceMakers; + typedef std::vector InterfaceMakers; InterfaceMakers makers; if (build_c_wrappers) { @@ -443,7 +443,7 @@ write_code(ostream &out_code,ostream * out_include, InterrogateModuleDef *def) { } // Now collect all the function wrappers. - vector remaps; + std::vector remaps; for (mi = makers.begin(); mi != makers.end(); ++mi) { (*mi)->get_function_remaps(remaps); } @@ -457,7 +457,7 @@ write_code(ostream &out_code,ostream * out_include, InterrogateModuleDef *def) { int num_wrappers = 0; map wrappers_by_index; - vector::iterator ri; + std::vector::iterator ri; for (ri = remaps.begin(); ri != remaps.end(); ++ri) { FunctionRemap *remap = (*ri); wrappers_by_index[remap->_wrapper_index] = remap; @@ -960,7 +960,7 @@ is_inherited_published(CPPInstance *function, CPPStructType *struct_type) { * purpose of this function. */ void InterrogateBuilder:: -remap_indices(vector &remaps) { +remap_indices(std::vector &remaps) { IndexRemapper index_remap; InterrogateDatabase::get_ptr()->remap_indices(1, index_remap); @@ -976,7 +976,7 @@ remap_indices(vector &remaps) { (*fi).second = index_remap.map_from((*fi).second); } - vector::iterator ri; + std::vector::iterator ri; for (ri = remaps.begin(); ri != remaps.end(); ++ri) { FunctionRemap *remap = (*ri); remap->_wrapper_index = index_remap.map_from(remap->_wrapper_index); diff --git a/dtool/src/interrogate/interrogateBuilder.h b/dtool/src/interrogate/interrogateBuilder.h index 41096a6f6a..68bcb4b131 100644 --- a/dtool/src/interrogate/interrogateBuilder.h +++ b/dtool/src/interrogate/interrogateBuilder.h @@ -68,8 +68,8 @@ public: TypeIndex get_type(CPPType *type, bool global); public: - typedef set Commands; - typedef map CommandParams; + typedef std::set Commands; + typedef std::map CommandParams; void insert_param_list(InterrogateBuilder::Commands &commands, const string ¶ms); @@ -86,7 +86,7 @@ public: bool is_inherited_published(CPPInstance *function, CPPStructType *struct_type); - void remap_indices(vector &remaps); + void remap_indices(std::vector &remaps); void scan_function(CPPFunctionGroup *fgroup); void scan_function(CPPInstance *function); void scan_struct_type(CPPStructType *type); @@ -135,17 +135,17 @@ public: static string trim_blanks(const string &str); - typedef map TypesByName; - typedef map FunctionsByName; - typedef map MakeSeqsByName; - typedef map PropertiesByName; + typedef std::map TypesByName; + typedef std::map FunctionsByName; + typedef std::map MakeSeqsByName; + typedef std::map PropertiesByName; TypesByName _types_by_name; FunctionsByName _functions_by_name; MakeSeqsByName _make_seqs_by_name; PropertiesByName _properties_by_name; - typedef map IncludeFiles; + typedef std::map IncludeFiles; IncludeFiles _include_files; Commands _forcetype; diff --git a/dtool/src/interrogate/interrogate_module.cxx b/dtool/src/interrogate/interrogate_module.cxx index 8c843e9da1..0cb7703fd0 100644 --- a/dtool/src/interrogate/interrogate_module.cxx +++ b/dtool/src/interrogate/interrogate_module.cxx @@ -80,10 +80,10 @@ upcase_string(const string &str) { * Finds a dependency cycle between the given dependency mapping, starting at * the node that is already placed in the given cycle vector. */ -static bool find_dependency_cycle(vector_string &cycle, map > &dependencies) { +static bool find_dependency_cycle(vector_string &cycle, std::map > &dependencies) { assert(!cycle.empty()); - const set &deps = dependencies[cycle.back()]; + const std::set &deps = dependencies[cycle.back()]; for (auto it = deps.begin(); it != deps.end(); ++it) { auto it2 = std::find(cycle.begin(), cycle.end(), *it); if (it2 != cycle.end()) { @@ -156,7 +156,7 @@ int write_python_table_native(ostream &out) { int count = 0; - map > dependencies; + std::map > dependencies; // out << "extern \"C\" {\n"; @@ -182,7 +182,7 @@ int write_python_table_native(ostream &out) { if (interrogate_type_has_module_name(thetype) && module_name == interrogate_type_module_name(thetype)) { if (interrogate_type_has_library_name(thetype)) { string library_name = interrogate_type_library_name(thetype); - set &deps = dependencies[library_name]; + std::set &deps = dependencies[library_name]; // Get the dependencies for this library. int num_derivations = interrogate_type_number_of_derivations(thetype); @@ -219,7 +219,7 @@ int write_python_table_native(ostream &out) { for (auto it = dependencies.begin(); it != dependencies.end(); ++it) { const string &library_name = it->first; - set &deps = dependencies[library_name]; + std::set &deps = dependencies[library_name]; // Remove the dependencies that have already been added from the deps. if (!deps.empty()) { @@ -243,7 +243,7 @@ int write_python_table_native(ostream &out) { cerr << "Circular dependency between libraries detected:\n"; for (auto it = dependencies.begin(); it != dependencies.end(); ++it) { const string &library_name = it->first; - set &deps = dependencies[library_name]; + std::set &deps = dependencies[library_name]; if (deps.empty()) { continue; } diff --git a/dtool/src/interrogate/parse_file.cxx b/dtool/src/interrogate/parse_file.cxx index 6670bcbe44..f20986022a 100644 --- a/dtool/src/interrogate/parse_file.cxx +++ b/dtool/src/interrogate/parse_file.cxx @@ -276,7 +276,7 @@ main(int argc, char **argv) { while (cin) { string str; cout << "Enter an expression or type name:\n"; - getline(cin, str); + std::getline(std::cin, str); if (!str.empty()) { size_t space = str.find(' '); diff --git a/dtool/src/interrogatedb/indexRemapper.cxx b/dtool/src/interrogatedb/indexRemapper.cxx index eee236cf08..7c606bec06 100644 --- a/dtool/src/interrogatedb/indexRemapper.cxx +++ b/dtool/src/interrogatedb/indexRemapper.cxx @@ -59,7 +59,7 @@ in_map(int from) const { */ int IndexRemapper:: map_from(int from) const { - map::const_iterator mi; + std::map::const_iterator mi; mi = _map_int.find(from); if (mi == _map_int.end()) { return from; diff --git a/dtool/src/interrogatedb/indexRemapper.h b/dtool/src/interrogatedb/indexRemapper.h index 9318777c94..c89a7a2988 100644 --- a/dtool/src/interrogatedb/indexRemapper.h +++ b/dtool/src/interrogatedb/indexRemapper.h @@ -38,7 +38,7 @@ public: int map_from(int from) const; private: - map _map_int; + std::map _map_int; }; #endif diff --git a/dtool/src/interrogatedb/interrogateComponent.h b/dtool/src/interrogatedb/interrogateComponent.h index c69dc26886..77b4388d7e 100644 --- a/dtool/src/interrogatedb/interrogateComponent.h +++ b/dtool/src/interrogatedb/interrogateComponent.h @@ -55,7 +55,7 @@ private: InterrogateModuleDef *_def; string _name; - typedef vector Strings; + typedef std::vector Strings; Strings _alt_names; friend class InterrogateBuilder; diff --git a/dtool/src/interrogatedb/interrogateDatabase.h b/dtool/src/interrogatedb/interrogateDatabase.h index 84fc55fbab..182e35798f 100644 --- a/dtool/src/interrogatedb/interrogateDatabase.h +++ b/dtool/src/interrogatedb/interrogateDatabase.h @@ -124,41 +124,41 @@ private: const string &wrapper_hash_name); // This data is loaded from the various database files. - typedef map TypeMap; + typedef std::map TypeMap; TypeMap _type_map; - typedef map FunctionMap; + typedef std::map FunctionMap; FunctionMap _function_map; - typedef map FunctionWrapperMap; + typedef std::map FunctionWrapperMap; FunctionWrapperMap _wrapper_map; - typedef map ManifestMap; + typedef std::map ManifestMap; ManifestMap _manifest_map; - typedef map ElementMap; + typedef std::map ElementMap; ElementMap _element_map; - typedef map MakeSeqMap; + typedef std::map MakeSeqMap; MakeSeqMap _make_seq_map; - typedef vector GlobalTypes; + typedef std::vector GlobalTypes; GlobalTypes _global_types; GlobalTypes _all_types; - typedef vector GlobalFunctions; + typedef std::vector GlobalFunctions; GlobalFunctions _global_functions; GlobalFunctions _all_functions; - typedef vector GlobalManifests; + typedef std::vector GlobalManifests; GlobalManifests _global_manifests; - typedef vector GlobalElements; + typedef std::vector GlobalElements; GlobalElements _global_elements; // This data is compiled in directly to the shared libraries that we link // with. - typedef vector Modules; + typedef std::vector Modules; Modules _modules; - typedef map ModulesByHash; + typedef std::map ModulesByHash; ModulesByHash _modules_by_hash; // This records the set of database files that are still to be loaded. - typedef vector Requests; + typedef std::vector Requests; Requests _requests; bool _error_flag; @@ -174,7 +174,7 @@ private: }; int _lookups_fresh; - typedef map Lookup; + typedef std::map Lookup; Lookup _types_by_name; Lookup _types_by_scoped_name; Lookup _types_by_true_name; diff --git a/dtool/src/interrogatedb/interrogateFunction.h b/dtool/src/interrogatedb/interrogateFunction.h index 312f69a97e..eac57642f8 100644 --- a/dtool/src/interrogatedb/interrogateFunction.h +++ b/dtool/src/interrogatedb/interrogateFunction.h @@ -78,7 +78,7 @@ private: string _prototype; TypeIndex _class; - typedef vector Wrappers; + typedef std::vector Wrappers; Wrappers _c_wrappers; Wrappers _python_wrappers; @@ -92,7 +92,7 @@ public: // This must be a pointer, rather than a concrete map, so we don't risk // trying to create a map in one DLL and access it in another. Silly // Windows. - typedef map Instances; + typedef std::map Instances; Instances *_instances; string _expression; diff --git a/dtool/src/interrogatedb/interrogateFunctionWrapper.h b/dtool/src/interrogatedb/interrogateFunctionWrapper.h index 511e8c6263..a49edb90ad 100644 --- a/dtool/src/interrogatedb/interrogateFunctionWrapper.h +++ b/dtool/src/interrogatedb/interrogateFunctionWrapper.h @@ -90,7 +90,7 @@ public: }; private: - typedef vector Parameters; + typedef std::vector Parameters; Parameters _parameters; friend class InterrogateBuilder; diff --git a/dtool/src/interrogatedb/interrogateType.h b/dtool/src/interrogatedb/interrogateType.h index 176efb4fb9..e852007b6b 100644 --- a/dtool/src/interrogatedb/interrogateType.h +++ b/dtool/src/interrogatedb/interrogateType.h @@ -154,16 +154,16 @@ public: TypeIndex _wrapped_type; int _array_size; - typedef vector Functions; + typedef std::vector Functions; Functions _constructors; FunctionIndex _destructor; - typedef vector Elements; + typedef std::vector Elements; Elements _elements; Functions _methods; Functions _casts; - typedef vector MakeSeqs; + typedef std::vector MakeSeqs; MakeSeqs _make_seqs; enum DerivationFlags { @@ -188,7 +188,7 @@ public: }; private: - typedef vector Derivations; + typedef std::vector Derivations; Derivations _derivations; public: @@ -205,10 +205,10 @@ public: }; private: - typedef vector EnumValues; + typedef std::vector EnumValues; EnumValues _enum_values; - typedef vector Types; + typedef std::vector Types; Types _nested_types; public: diff --git a/dtool/src/interrogatedb/interrogate_datafile.I b/dtool/src/interrogatedb/interrogate_datafile.I index 9111260237..1e9d0f17e2 100644 --- a/dtool/src/interrogatedb/interrogate_datafile.I +++ b/dtool/src/interrogatedb/interrogate_datafile.I @@ -17,9 +17,9 @@ */ template void -idf_output_vector(ostream &out, const vector &vec) { +idf_output_vector(ostream &out, const std::vector &vec) { out << vec.size() << " "; - TYPENAME vector::const_iterator vi; + TYPENAME std::vector::const_iterator vi; for (vi = vec.begin(); vi != vec.end(); ++vi) { out << (*vi) << " "; } @@ -33,7 +33,7 @@ idf_output_vector(ostream &out, const vector &vec) { */ template void -idf_input_vector(istream &in, vector &vec) { +idf_input_vector(istream &in, std::vector &vec) { int length; in >> length; if (in.fail()) { diff --git a/dtool/src/interrogatedb/interrogate_datafile.h b/dtool/src/interrogatedb/interrogate_datafile.h index ecd2acbce0..7442d8ce81 100644 --- a/dtool/src/interrogatedb/interrogate_datafile.h +++ b/dtool/src/interrogatedb/interrogate_datafile.h @@ -27,10 +27,10 @@ void idf_output_string(ostream &out, const char *str, char whitespace = ' '); void idf_input_string(istream &in, const char *&str); template -void idf_output_vector(ostream &out, const vector &vec); +void idf_output_vector(ostream &out, const std::vector &vec); template -void idf_input_vector(istream &in, vector &vec); +void idf_input_vector(istream &in, std::vector &vec); #include "interrogate_datafile.I" diff --git a/dtool/src/interrogatedb/py_panda.I b/dtool/src/interrogatedb/py_panda.I index 1986a128c5..24c038df94 100644 --- a/dtool/src/interrogatedb/py_panda.I +++ b/dtool/src/interrogatedb/py_panda.I @@ -247,7 +247,7 @@ ALWAYS_INLINE PyObject *Dtool_WrapValue(wchar_t value) { return PyUnicode_FromWideChar(&value, 1); } -ALWAYS_INLINE PyObject *Dtool_WrapValue(nullptr_t) { +ALWAYS_INLINE PyObject *Dtool_WrapValue(std::nullptr_t) { Py_INCREF(Py_None); return Py_None; } diff --git a/dtool/src/interrogatedb/py_panda.h b/dtool/src/interrogatedb/py_panda.h index f4edc8f4ad..f84d5cd3ba 100644 --- a/dtool/src/interrogatedb/py_panda.h +++ b/dtool/src/interrogatedb/py_panda.h @@ -393,7 +393,7 @@ ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::string *value); ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::wstring *value); ALWAYS_INLINE PyObject *Dtool_WrapValue(char value); ALWAYS_INLINE PyObject *Dtool_WrapValue(wchar_t value); -ALWAYS_INLINE PyObject *Dtool_WrapValue(nullptr_t); +ALWAYS_INLINE PyObject *Dtool_WrapValue(std::nullptr_t); ALWAYS_INLINE PyObject *Dtool_WrapValue(PyObject *value); ALWAYS_INLINE PyObject *Dtool_WrapValue(const vector_uchar &value); diff --git a/dtool/src/parser-inc/vector b/dtool/src/parser-inc/vector index fb27a78c0d..e83a5ff911 100644 --- a/dtool/src/parser-inc/vector +++ b/dtool/src/parser-inc/vector @@ -22,6 +22,8 @@ #include +inline namespace std { + template class vector { public: @@ -40,4 +42,6 @@ public: typedef size_t size_type; }; +} + #endif diff --git a/dtool/src/prc/configDeclaration.h b/dtool/src/prc/configDeclaration.h index 9a74acd8d2..1e6c50ee12 100644 --- a/dtool/src/prc/configDeclaration.h +++ b/dtool/src/prc/configDeclaration.h @@ -111,7 +111,7 @@ private: short _flags; }; - typedef vector Words; + typedef std::vector Words; Words _words; bool _got_words; diff --git a/dtool/src/prc/configPage.h b/dtool/src/prc/configPage.h index 72659fe096..e6cdb9ed0d 100644 --- a/dtool/src/prc/configPage.h +++ b/dtool/src/prc/configPage.h @@ -92,7 +92,7 @@ private: int _next_decl_seq; int _trust_level; - typedef vector Declarations; + typedef std::vector Declarations; Declarations _declarations; string _signature; diff --git a/dtool/src/prc/configPageManager.h b/dtool/src/prc/configPageManager.h index 1ad8f6c3bd..dd6acc3f99 100644 --- a/dtool/src/prc/configPageManager.h +++ b/dtool/src/prc/configPageManager.h @@ -76,7 +76,7 @@ private: void config_initialized(); - typedef vector Pages; + typedef std::vector Pages; Pages _implicit_pages; Pages _explicit_pages; bool _pages_sorted; @@ -87,7 +87,7 @@ private: DSearchPath _search_path; - typedef vector Globs; + typedef std::vector Globs; Globs _prc_patterns; Globs _prc_encrypted_patterns; Globs _prc_executable_patterns; @@ -105,7 +105,7 @@ private: int _file_flags; Filename _filename; }; - typedef vector ConfigFiles; + typedef std::vector ConfigFiles; static ConfigPageManager *_global_ptr; }; diff --git a/dtool/src/prc/configVariableCore.h b/dtool/src/prc/configVariableCore.h index 19e03436d2..6e8ce7ace9 100644 --- a/dtool/src/prc/configVariableCore.h +++ b/dtool/src/prc/configVariableCore.h @@ -110,7 +110,7 @@ private: ConfigDeclaration *_default_value; ConfigDeclaration *_local_value; - typedef vector Declarations; + typedef std::vector Declarations; Declarations _declarations; Declarations _trusted_declarations; Declarations _untrusted_declarations; diff --git a/dtool/src/prc/configVariableManager.h b/dtool/src/prc/configVariableManager.h index 713e1bc5d2..818c5a8f3d 100644 --- a/dtool/src/prc/configVariableManager.h +++ b/dtool/src/prc/configVariableManager.h @@ -67,13 +67,13 @@ private: // We have to avoid pmap and pvector, due to the very low-level nature of // this stuff. - typedef vector Variables; + typedef std::vector Variables; Variables _variables; - typedef map VariablesByName; + typedef std::map VariablesByName; VariablesByName _variables_by_name; - typedef map VariableTemplates; + typedef std::map VariableTemplates; VariableTemplates _variable_templates; static ConfigVariableManager *_global_ptr; diff --git a/dtool/src/prc/notify.cxx b/dtool/src/prc/notify.cxx index f74f55e596..dc48aace3c 100644 --- a/dtool/src/prc/notify.cxx +++ b/dtool/src/prc/notify.cxx @@ -36,9 +36,9 @@ Notify *Notify::_global_ptr = (Notify *)NULL; */ Notify:: Notify() { - _ostream_ptr = &cerr; + _ostream_ptr = &std::cerr; _owns_ostream_ptr = false; - _null_ostream_ptr = new fstream; + _null_ostream_ptr = new std::fstream; _assert_handler = (AssertHandler *)NULL; _assert_failed = false; diff --git a/dtool/src/prc/notifyCategory.h b/dtool/src/prc/notifyCategory.h index ee25b56268..5ef3712208 100644 --- a/dtool/src/prc/notifyCategory.h +++ b/dtool/src/prc/notifyCategory.h @@ -88,7 +88,7 @@ private: string _basename; NotifyCategory *_parent; ConfigVariableEnum _severity; - typedef vector Children; + typedef std::vector Children; Children _children; static long _server_delta; // not a time_t because server delta may be signed. diff --git a/dtool/src/prc/pnotify.h b/dtool/src/prc/pnotify.h index 27a346d0d9..90cdb24a5d 100644 --- a/dtool/src/prc/pnotify.h +++ b/dtool/src/prc/pnotify.h @@ -85,7 +85,7 @@ private: // This shouldn't be a pmap, since it might be invoked before we initialize // the global malloc pointers. - typedef map Categories; + typedef std::map Categories; Categories _categories; static Notify *_global_ptr; diff --git a/dtool/src/prc/prcKeyRegistry.h b/dtool/src/prc/prcKeyRegistry.h index 0a21d182ad..c05e69a445 100644 --- a/dtool/src/prc/prcKeyRegistry.h +++ b/dtool/src/prc/prcKeyRegistry.h @@ -63,7 +63,7 @@ private: time_t _generated_time; }; - typedef vector Keys; + typedef std::vector Keys; Keys _keys; static PrcKeyRegistry *_global_ptr; diff --git a/panda/src/chan/partGroup.cxx b/panda/src/chan/partGroup.cxx index 20fe582ae9..e1503e93b3 100644 --- a/panda/src/chan/partGroup.cxx +++ b/panda/src/chan/partGroup.cxx @@ -163,7 +163,7 @@ public: */ void PartGroup:: sort_descendants() { - stable_sort(_children.begin(), _children.end(), PartGroupAlphabeticalOrder()); + std::stable_sort(_children.begin(), _children.end(), PartGroupAlphabeticalOrder()); Children::iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { diff --git a/panda/src/collide/collisionTraverser.cxx b/panda/src/collide/collisionTraverser.cxx index 74973d6764..27ec4a99c1 100644 --- a/panda/src/collide/collisionTraverser.cxx +++ b/panda/src/collide/collisionTraverser.cxx @@ -495,7 +495,7 @@ prepare_colliders_single(CollisionTraverser::LevelStatesSingle &level_states, for (i = 0; i < num_colliders; ++i) { indirect[i] = i; } - sort(indirect, indirect + num_colliders, SortByColliderSort(*this)); + std::sort(indirect, indirect + num_colliders, SortByColliderSort(*this)); int num_remaining_colliders = num_colliders; for (i = 0; i < num_colliders; ++i) { @@ -706,7 +706,7 @@ prepare_colliders_double(CollisionTraverser::LevelStatesDouble &level_states, for (i = 0; i < num_colliders; ++i) { indirect[i] = i; } - sort(indirect, indirect + num_colliders, SortByColliderSort(*this)); + std::sort(indirect, indirect + num_colliders, SortByColliderSort(*this)); int num_remaining_colliders = num_colliders; for (i = 0; i < num_colliders; ++i) { @@ -917,7 +917,7 @@ prepare_colliders_quad(CollisionTraverser::LevelStatesQuad &level_states, for (i = 0; i < num_colliders; ++i) { indirect[i] = i; } - sort(indirect, indirect + num_colliders, SortByColliderSort(*this)); + std::sort(indirect, indirect + num_colliders, SortByColliderSort(*this)); int num_remaining_colliders = num_colliders; for (i = 0; i < num_colliders; ++i) { diff --git a/panda/src/cull/cullBinFixed.cxx b/panda/src/cull/cullBinFixed.cxx index 212bc4f320..e3e5637ad9 100644 --- a/panda/src/cull/cullBinFixed.cxx +++ b/panda/src/cull/cullBinFixed.cxx @@ -61,7 +61,7 @@ add_object(CullableObject *object, Thread *current_thread) { void CullBinFixed:: finish_cull(SceneSetup *, Thread *current_thread) { PStatTimer timer(_cull_this_pcollector, current_thread); - stable_sort(_objects.begin(), _objects.end()); + std::stable_sort(_objects.begin(), _objects.end()); } /** diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index cb2f69ff6c..0583602189 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -1540,7 +1540,9 @@ do_determine_display_regions(GraphicsOutput::CData *cdata) { } } - stable_sort(cdata->_active_display_regions.begin(), cdata->_active_display_regions.end(), IndirectLess()); + std::stable_sort(cdata->_active_display_regions.begin(), + cdata->_active_display_regions.end(), + IndirectLess()); } /** diff --git a/panda/src/display/graphicsWindow_ext.cxx b/panda/src/display/graphicsWindow_ext.cxx index 06260b4c83..ac06b3565a 100644 --- a/panda/src/display/graphicsWindow_ext.cxx +++ b/panda/src/display/graphicsWindow_ext.cxx @@ -30,7 +30,7 @@ add_python_event_handler(PyObject* handler, PyObject* name){ */ void Extension:: remove_python_event_handler(PyObject* name){ - list toRemove; + std::list toRemove; GraphicsWindow::PythonWinProcClasses::iterator iter; for (iter = _this->_python_window_proc_classes.begin(); iter != _this->_python_window_proc_classes.end(); ++iter) { PythonGraphicsWindowProc* pgwp = (PythonGraphicsWindowProc*)*iter; @@ -43,7 +43,7 @@ remove_python_event_handler(PyObject* name){ } #endif } - list::iterator iter2; + std::list::iterator iter2; for (iter2 = toRemove.begin(); iter2 != toRemove.end(); ++iter2) { PythonGraphicsWindowProc* pgwp = *iter2; _this->remove_window_proc(pgwp); diff --git a/panda/src/display/subprocessWindowBuffer.cxx b/panda/src/display/subprocessWindowBuffer.cxx index 36eec2def3..daae50b523 100644 --- a/panda/src/display/subprocessWindowBuffer.cxx +++ b/panda/src/display/subprocessWindowBuffer.cxx @@ -18,7 +18,6 @@ #include #include -using namespace std; const char SubprocessWindowBuffer:: _magic_number[SubprocessWindowBuffer::magic_number_length] = "pNdaSWB"; diff --git a/panda/src/display/subprocessWindowBuffer.h b/panda/src/display/subprocessWindowBuffer.h index 2fecbcadbc..e0d52a7f4a 100644 --- a/panda/src/display/subprocessWindowBuffer.h +++ b/panda/src/display/subprocessWindowBuffer.h @@ -17,7 +17,6 @@ #include // perror #include #include -using namespace std; /** * This is a special class that is designed to faciliate SubprocessWindow. diff --git a/panda/src/downloader/httpChannel.cxx b/panda/src/downloader/httpChannel.cxx index 93e04f1432..30d1b3c7bf 100644 --- a/panda/src/downloader/httpChannel.cxx +++ b/panda/src/downloader/httpChannel.cxx @@ -1637,7 +1637,7 @@ run_ssl_handshake() { if (downloader_cat.is_spam()) { downloader_cat.spam() << _NOTIFY_HTTP_CHANNEL_ID - << "Received certificate from server:\n" << flush; + << "Received certificate from server:\n" << std::flush; X509_print_fp(stderr, cert); fflush(stderr); } @@ -2144,14 +2144,14 @@ run_reading_body() { } string line; - getline(*_body_stream, line); + std::getline(*_body_stream, line); while (!_body_stream->fail() && !_body_stream->eof()) { if (downloader_cat.is_spam()) { downloader_cat.spam() << _NOTIFY_HTTP_CHANNEL_ID << "skip: " << line << "\n"; } - getline(*_body_stream, line); + std::getline(*_body_stream, line); } if (!_body_stream->is_closed()) { diff --git a/panda/src/downloadertools/multify.cxx b/panda/src/downloadertools/multify.cxx index 8f3df9ce14..b26de65ab1 100644 --- a/panda/src/downloadertools/multify.cxx +++ b/panda/src/downloadertools/multify.cxx @@ -245,7 +245,7 @@ const string & get_password() { if (!got_password) { cerr << "Enter password: "; - getline(cin, password); + std::getline(std::cin, password); got_password = true; } @@ -650,7 +650,7 @@ list_files(const vector_string ¶ms) { int i; if (verbose) { - cout << num_subfiles << " subfiles:\n" << flush; + cout << num_subfiles << " subfiles:\n" << std::flush; for (i = 0; i < num_subfiles; i++) { string subfile_name = multifile->get_subfile_name(i); if (is_named(subfile_name, params)) { diff --git a/panda/src/downloadertools/pdecrypt.cxx b/panda/src/downloadertools/pdecrypt.cxx index 73a242fda1..9ce3445bf0 100644 --- a/panda/src/downloadertools/pdecrypt.cxx +++ b/panda/src/downloadertools/pdecrypt.cxx @@ -122,7 +122,7 @@ main(int argc, char **argv) { // Prompt for password. if (!got_password) { cerr << "Enter password: "; - getline(cin, password); + std::getline(std::cin, password); got_password = true; } diff --git a/panda/src/downloadertools/pencrypt.cxx b/panda/src/downloadertools/pencrypt.cxx index 5f8774c4d9..3d61651348 100644 --- a/panda/src/downloadertools/pencrypt.cxx +++ b/panda/src/downloadertools/pencrypt.cxx @@ -181,7 +181,7 @@ main(int argc, char **argv) { // Prompt for password. if (!got_password) { cerr << "Enter password: "; - getline(cin, password); + std::getline(std::cin, password); got_password = true; } diff --git a/panda/src/egg/eggData.cxx b/panda/src/egg/eggData.cxx index 69eb4eb6e6..b91f660b68 100644 --- a/panda/src/egg/eggData.cxx +++ b/panda/src/egg/eggData.cxx @@ -276,7 +276,7 @@ write(ostream &out, int indent_level) const { PT(EggCoordinateSystem) ecs = new EggCoordinateSystem(_coordsys); ecs->write(out, indent_level); EggGroupNode::write(out, indent_level); - out << flush; + out << std::flush; } diff --git a/panda/src/egg/eggPrimitive.I b/panda/src/egg/eggPrimitive.I index 8ae8a1eecf..a52449443d 100644 --- a/panda/src/egg/eggPrimitive.I +++ b/panda/src/egg/eggPrimitive.I @@ -136,7 +136,7 @@ has_texture() const { INLINE bool EggPrimitive:: has_texture(EggTexture *texture) const { PT_EggTexture t = texture; - return (::find(_textures.begin(), _textures.end(), t) != _textures.end()); + return (std::find(_textures.begin(), _textures.end(), t) != _textures.end()); } /** diff --git a/panda/src/egg/eggPrimitive.cxx b/panda/src/egg/eggPrimitive.cxx index e3eb0b16d7..90cd4942ca 100644 --- a/panda/src/egg/eggPrimitive.cxx +++ b/panda/src/egg/eggPrimitive.cxx @@ -644,7 +644,7 @@ erase(iterator first, iterator last) { EggPrimitive::iterator EggPrimitive:: find(EggVertex *vertex) { PT_EggVertex vpt = vertex; - return ::find(begin(), end(), vpt); + return std::find(begin(), end(), vpt); } @@ -670,7 +670,7 @@ add_vertex(EggVertex *vertex) { EggVertex *EggPrimitive:: remove_vertex(EggVertex *vertex) { PT_EggVertex vpt = vertex; - iterator i = ::find(begin(), end(), vpt); + iterator i = std::find(begin(), end(), vpt); if (i == end()) { return PT_EggVertex(); } else { diff --git a/panda/src/egg/eggUtilities.I b/panda/src/egg/eggUtilities.I index 04430db8f5..4ad2d6b1c7 100644 --- a/panda/src/egg/eggUtilities.I +++ b/panda/src/egg/eggUtilities.I @@ -57,7 +57,7 @@ split_vertex(EggVertex *vert, const FunctionObject &sequence) { typedef pvector Prims; Prims prims; prims.reserve(vert->pref_size()); - copy(vert->pref_begin(), vert->pref_end(), back_inserter(prims)); + std::copy(vert->pref_begin(), vert->pref_end(), std::back_inserter(prims)); // Now walk through the list of primitives that reference this vertex. Prims::const_iterator pri; diff --git a/panda/src/egg/eggVertexPool.cxx b/panda/src/egg/eggVertexPool.cxx index f1783d8158..e35cee0079 100644 --- a/panda/src/egg/eggVertexPool.cxx +++ b/panda/src/egg/eggVertexPool.cxx @@ -675,7 +675,7 @@ transform(const LMatrix4d &mat) { typedef pvector Verts; Verts verts; verts.reserve(size()); - copy(begin(), end(), back_inserter(verts)); + std::copy(begin(), end(), std::back_inserter(verts)); Verts::const_iterator vi; for (vi = verts.begin(); vi != verts.end(); ++vi) { @@ -742,7 +742,7 @@ sort_by_external_index() { sorted_vertices.push_back(*i); } - ::sort(sorted_vertices.begin(), sorted_vertices.end(), SortByExternalIndex()); + std::sort(sorted_vertices.begin(), sorted_vertices.end(), SortByExternalIndex()); // Now reassign the indices, and copy them into a new index map. IndexVertices new_index_vertices; diff --git a/panda/src/egg/lexer.cxx.prebuilt b/panda/src/egg/lexer.cxx.prebuilt index 6f6e8bd56a..ef8160d2c2 100644 --- a/panda/src/egg/lexer.cxx.prebuilt +++ b/panda/src/egg/lexer.cxx.prebuilt @@ -1062,11 +1062,11 @@ eggyyerror(const string &msg) { } out << " at line " << line_number << ", column " << col_number << ":\n" - << setiosflags(Notify::get_literal_flag()) + << std::setiosflags(Notify::get_literal_flag()) << current_line << "\n"; indent(out, col_number-1) << "^\n" << msg << "\n\n" - << resetiosflags(Notify::get_literal_flag()) << flush; + << std::resetiosflags(Notify::get_literal_flag()) << std::flush; } error_count++; } @@ -1088,11 +1088,11 @@ eggyywarning(const string &msg) { } out << " at line " << line_number << ", column " << col_number << ":\n" - << setiosflags(Notify::get_literal_flag()) + << std::setiosflags(Notify::get_literal_flag()) << current_line << "\n"; indent(out, col_number-1) << "^\n" << msg << "\n\n" - << resetiosflags(Notify::get_literal_flag()) << flush; + << std::resetiosflags(Notify::get_literal_flag()) << std::flush; } warning_count++; } @@ -1215,7 +1215,7 @@ eat_c_comment() { ostringstream errmsg; errmsg << "This comment contains a nested /* symbol at line " << line << ", column " << col-1 << "--possibly unclosed?" - << ends; + << std::ends; eggyywarning(errmsg); } last_c = c; diff --git a/panda/src/egg/lexer.lxx b/panda/src/egg/lexer.lxx index 1ce4a0006e..c1294a8ec7 100644 --- a/panda/src/egg/lexer.lxx +++ b/panda/src/egg/lexer.lxx @@ -117,11 +117,11 @@ eggyyerror(const string &msg) { } out << " at line " << line_number << ", column " << col_number << ":\n" - << setiosflags(Notify::get_literal_flag()) + << std::setiosflags(Notify::get_literal_flag()) << current_line << "\n"; indent(out, col_number-1) << "^\n" << msg << "\n\n" - << resetiosflags(Notify::get_literal_flag()) << flush; + << std::resetiosflags(Notify::get_literal_flag()) << std::flush; } error_count++; } @@ -143,11 +143,11 @@ eggyywarning(const string &msg) { } out << " at line " << line_number << ", column " << col_number << ":\n" - << setiosflags(Notify::get_literal_flag()) + << std::setiosflags(Notify::get_literal_flag()) << current_line << "\n"; indent(out, col_number-1) << "^\n" << msg << "\n\n" - << resetiosflags(Notify::get_literal_flag()) << flush; + << std::resetiosflags(Notify::get_literal_flag()) << std::flush; } warning_count++; } @@ -270,7 +270,7 @@ eat_c_comment() { ostringstream errmsg; errmsg << "This comment contains a nested /* symbol at line " << line << ", column " << col-1 << "--possibly unclosed?" - << ends; + << std::ends; eggyywarning(errmsg); } last_c = c; diff --git a/panda/src/egg/parser.cxx.prebuilt b/panda/src/egg/parser.cxx.prebuilt index 7791e8de4a..b25f0abf32 100644 --- a/panda/src/egg/parser.cxx.prebuilt +++ b/panda/src/egg/parser.cxx.prebuilt @@ -3137,14 +3137,14 @@ yyreduce: if (vertex_index < 0) { ostringstream errmsg; errmsg << "Ignoring invalid vertex index " << vertex_index - << " in vertex pool " << pool->get_name() << ends; + << " in vertex pool " << pool->get_name() << std::ends; eggyywarning(errmsg); vertex_index = -1; } else if (pool->has_vertex(vertex_index)) { ostringstream errmsg; errmsg << "Ignoring duplicate vertex index " << vertex_index - << " in vertex pool " << pool->get_name() << ends; + << " in vertex pool " << pool->get_name() << std::ends; eggyywarning(errmsg); vertex_index = -1; } @@ -4055,7 +4055,7 @@ yyreduce: if (vertex == NULL) { ostringstream errmsg; errmsg << "No vertex " << index << " in pool " << pool->get_name() - << ends; + << std::ends; eggyyerror(errmsg); } else { group->ref_vertex(vertex, membership); @@ -4659,7 +4659,7 @@ yyreduce: if (vertex == NULL) { ostringstream errmsg; errmsg << "No vertex " << index << " in pool " << pool->get_name() - << ends; + << std::ends; eggyyerror(errmsg); } else { prim->add_vertex(vertex); diff --git a/panda/src/egg/parser.yxx b/panda/src/egg/parser.yxx index 02e83f18ec..ab864d92d6 100644 --- a/panda/src/egg/parser.yxx +++ b/panda/src/egg/parser.yxx @@ -971,14 +971,14 @@ vertex: if (vertex_index < 0) { ostringstream errmsg; errmsg << "Ignoring invalid vertex index " << vertex_index - << " in vertex pool " << pool->get_name() << ends; + << " in vertex pool " << pool->get_name() << std::ends; eggyywarning(errmsg); vertex_index = -1; } else if (pool->has_vertex(vertex_index)) { ostringstream errmsg; errmsg << "Ignoring duplicate vertex index " << vertex_index - << " in vertex pool " << pool->get_name() << ends; + << " in vertex pool " << pool->get_name() << std::ends; eggyywarning(errmsg); vertex_index = -1; } @@ -1797,7 +1797,7 @@ group_vertex_ref: if (vertex == NULL) { ostringstream errmsg; errmsg << "No vertex " << index << " in pool " << pool->get_name() - << ends; + << std::ends; eggyyerror(errmsg); } else { group->ref_vertex(vertex, membership); @@ -2477,7 +2477,7 @@ primitive_vertex_ref: if (vertex == NULL) { ostringstream errmsg; errmsg << "No vertex " << index << " in pool " << pool->get_name() - << ends; + << std::ends; eggyyerror(errmsg); } else { prim->add_vertex(vertex); diff --git a/panda/src/event/asyncFuture.I b/panda/src/event/asyncFuture.I index 44fb0a8247..960ce56b49 100644 --- a/panda/src/event/asyncFuture.I +++ b/panda/src/event/asyncFuture.I @@ -89,7 +89,7 @@ get_result(TypedObject *&ptr, ReferenceCount *&ref_ptr) const { * Sets this future's result. Can only be called if done() returns false. */ INLINE void AsyncFuture:: -set_result(nullptr_t) { +set_result(std::nullptr_t) { set_result(nullptr, nullptr); } diff --git a/panda/src/event/asyncFuture.h b/panda/src/event/asyncFuture.h index 18d5b773f1..5349ced637 100644 --- a/panda/src/event/asyncFuture.h +++ b/panda/src/event/asyncFuture.h @@ -83,7 +83,7 @@ PUBLISHED: BLOCKING void wait(); BLOCKING void wait(double timeout); - INLINE void set_result(nullptr_t); + INLINE void set_result(std::nullptr_t); INLINE void set_result(TypedObject *result); INLINE void set_result(TypedReferenceCount *result); INLINE void set_result(TypedWritableReferenceCount *result); diff --git a/panda/src/event/eventParameter.h b/panda/src/event/eventParameter.h index 24ea3ec1e2..8519c3c4d6 100644 --- a/panda/src/event/eventParameter.h +++ b/panda/src/event/eventParameter.h @@ -35,7 +35,7 @@ class EXPCL_PANDA_EVENT EventParameter { PUBLISHED: INLINE EventParameter() = default; - INLINE EventParameter(nullptr_t) {}; + INLINE EventParameter(std::nullptr_t) {}; INLINE EventParameter(const TypedWritableReferenceCount *ptr); INLINE EventParameter(const TypedReferenceCount *ptr); INLINE EventParameter(int value); diff --git a/panda/src/express/hashVal.cxx b/panda/src/express/hashVal.cxx index aa08714668..02065e1a5b 100644 --- a/panda/src/express/hashVal.cxx +++ b/panda/src/express/hashVal.cxx @@ -39,7 +39,7 @@ output_hex(ostream &out) const { */ void HashVal:: input_hex(istream &in) { - in >> ws; + in >> std::ws; char buffer[32]; size_t i = 0; int ch = in.get(); diff --git a/panda/src/express/make_ca_bundle.cxx b/panda/src/express/make_ca_bundle.cxx index 0794312de1..bc57eb97d8 100644 --- a/panda/src/express/make_ca_bundle.cxx +++ b/panda/src/express/make_ca_bundle.cxx @@ -70,7 +70,7 @@ main(int argc, char *argv[]) { // Now write the data to the .c file, in a compilable form, similar to // bin2c. - ofstream out; + std::ofstream out; Filename target = Filename::text_filename(string(target_filename)); if (!target.open_write(out)) { cerr << "Couldn't open " << target_filename << " for writing.\n"; diff --git a/panda/src/express/memoryUsage.h b/panda/src/express/memoryUsage.h index 9742348cac..cd72581704 100644 --- a/panda/src/express/memoryUsage.h +++ b/panda/src/express/memoryUsage.h @@ -156,12 +156,12 @@ private: * one pointer or the other. We don't store an entry for an object's * TypedObject pointer. */ - typedef map Table; + typedef std::map Table; Table _table; // This table indexes the individual MemoryInfo objects, for unique // iteration. - typedef set InfoSet; + typedef std::set InfoSet; InfoSet _info_set; bool _info_set_dirty; diff --git a/panda/src/express/multifile.cxx b/panda/src/express/multifile.cxx index 0bedba8909..2ae60892d4 100644 --- a/panda/src/express/multifile.cxx +++ b/panda/src/express/multifile.cxx @@ -1296,7 +1296,7 @@ repack() { } _removed_subfiles.clear(); _new_subfiles.clear(); - copy(_subfiles.begin(), _subfiles.end(), back_inserter(_new_subfiles)); + std::copy(_subfiles.begin(), _subfiles.end(), std::back_inserter(_new_subfiles)); _next_index = 0; _last_index = 0; _last_data_byte = 0; diff --git a/panda/src/express/ordered_vector.I b/panda/src/express/ordered_vector.I index 287998b85c..4f0d5082f0 100644 --- a/panda/src/express/ordered_vector.I +++ b/panda/src/express/ordered_vector.I @@ -601,7 +601,7 @@ template INLINE void ordered_vector:: sort_nonunique() { TAU_PROFILE("ordered_vector::sort_nonunique()", " ", TAU_USER); - stable_sort(begin(), end(), _compare); + std::stable_sort(begin(), end(), _compare); } /** diff --git a/panda/src/express/profileTimer.cxx b/panda/src/express/profileTimer.cxx index 41d1ac8f89..ef571fc929 100644 --- a/panda/src/express/profileTimer.cxx +++ b/panda/src/express/profileTimer.cxx @@ -13,8 +13,6 @@ #include "pmap.h" -using namespace std; - // See ProfileTimer.h for documentation. @@ -120,13 +118,13 @@ consolidateTo(ostream &out) const { { pmap::const_iterator i=entries.begin(); for (;i!=entries.end(); ++i) { - out << " " << setw(50) << i->first << ": " - << setiosflags(ios::fixed) << setprecision(6) << setw(10) << i->second << "\n"; + out << " " << std::setw(50) << i->first << ": " + << std::setiosflags(std::ios::fixed) << std::setprecision(6) << std::setw(10) << i->second << "\n"; total+=i->second; } } out << "\n [Total Time: " - << setiosflags(ios::fixed) << setprecision(6) << total + << std::setiosflags(std::ios::fixed) << std::setprecision(6) << total << " seconds]\n" << "-------------------------------------------------------------------\n"; out << endl; @@ -150,12 +148,12 @@ printTo(ostream &out) const { int i; for (i=0; i<_entryCount; ++i) { TimerEntry& te=_entries[i]; - out << " " << setw(50) << te._tag << ": " - << setiosflags(ios::fixed) << setprecision(6) << setw(10) << te._time << "\n"; + out << " " << std::setw(50) << te._tag << ": " + << std::setiosflags(std::ios::fixed) << std::setprecision(6) << std::setw(10) << te._time << "\n"; total+=te._time; } out << "\n [Total Time: " - << setiosflags(ios::fixed) << setprecision(6) << total + << std::setiosflags(std::ios::fixed) << std::setprecision(6) << total << " seconds]\n" << "-------------------------------------------------------------------\n"; out << endl; diff --git a/panda/src/express/virtualFile.cxx b/panda/src/express/virtualFile.cxx index 1d12b7f250..eb010f2806 100644 --- a/panda/src/express/virtualFile.cxx +++ b/panda/src/express/virtualFile.cxx @@ -108,8 +108,8 @@ scan_directory() const { // Copy the set of nested mount points to a sorted list so we can search it // quickly. ov_set mount_points; - copy(mount_points_flat.begin(), mount_points_flat.end(), - back_inserter(mount_points)); + std::copy(mount_points_flat.begin(), mount_points_flat.end(), + std::back_inserter(mount_points)); mount_points.sort(); diff --git a/panda/src/express/virtualFileMountSystem.cxx b/panda/src/express/virtualFileMountSystem.cxx index ce201712b2..ef9c4dcaf5 100644 --- a/panda/src/express/virtualFileMountSystem.cxx +++ b/panda/src/express/virtualFileMountSystem.cxx @@ -49,7 +49,7 @@ bool VirtualFileMountSystem:: create_file(const Filename &file) { Filename pathname(_physical_filename, file); pathname.set_binary(); - ofstream stream; + std::ofstream stream; return pathname.open_write(stream, false); } diff --git a/panda/src/express/weakReferenceList.cxx b/panda/src/express/weakReferenceList.cxx index f9e92d6009..0534556d7a 100644 --- a/panda/src/express/weakReferenceList.cxx +++ b/panda/src/express/weakReferenceList.cxx @@ -47,7 +47,7 @@ add_callback(WeakPointerCallback *callback, void *data) { // have been deleted in the meantime. bool deleted = was_deleted(); if (!deleted) { - _callbacks.insert(make_pair(callback, data)); + _callbacks.insert(std::make_pair(callback, data)); } _lock.unlock(); diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index 27fabc899e..6c756631e2 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -2801,7 +2801,7 @@ glsl_report_shader_errors(GLuint shader, Shader::ShaderType type, bool fatal) { // instead of source indices. istringstream log(info_log); string line; - while (getline(log, line)) { + while (std::getline(log, line)) { int fileno, lineno, colno; int prefixlen = 0; diff --git a/panda/src/gobj/geomTriangles.cxx b/panda/src/gobj/geomTriangles.cxx index a6e3b9480f..fa24ce761a 100644 --- a/panda/src/gobj/geomTriangles.cxx +++ b/panda/src/gobj/geomTriangles.cxx @@ -73,6 +73,8 @@ get_primitive_type() const { */ CPT(GeomPrimitive) GeomTriangles:: make_adjacency() const { + using std::make_pair; + Thread *current_thread = Thread::get_current_thread(); PT(GeomTrianglesAdjacency) adj = new GeomTrianglesAdjacency(get_usage_hint()); diff --git a/panda/src/gobj/geomTristrips.cxx b/panda/src/gobj/geomTristrips.cxx index ae7bf0bc25..01f97e8bee 100644 --- a/panda/src/gobj/geomTristrips.cxx +++ b/panda/src/gobj/geomTristrips.cxx @@ -87,6 +87,8 @@ get_geom_rendering() const { */ CPT(GeomPrimitive) GeomTristrips:: make_adjacency() const { + using std::make_pair; + Thread *current_thread = Thread::get_current_thread(); PT(GeomTristripsAdjacency) adj = new GeomTristripsAdjacency(get_usage_hint()); CPTA_int ends = get_ends(); diff --git a/panda/src/gobj/internalName_ext.cxx b/panda/src/gobj/internalName_ext.cxx index b98bcd9c12..0c157f2541 100644 --- a/panda/src/gobj/internalName_ext.cxx +++ b/panda/src/gobj/internalName_ext.cxx @@ -73,7 +73,7 @@ make(PyStringObject *str) { Py_INCREF(str); iname->ref(); - InternalName::_py_intern_table.insert(make_pair((PyObject *)str, iname.p())); + InternalName::_py_intern_table.insert(std::make_pair((PyObject *)str, iname.p())); return iname.p(); } diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index 94c90c644d..834757a4d1 100644 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -2575,7 +2575,7 @@ r_preprocess_source(ostream &out, const Filename &fn, int ext_google_line = 0; bool had_include = false; int lineno = 0; - while (getline(*source, line)) { + while (std::getline(*source, line)) { ++lineno; if (line.empty()) { @@ -2589,7 +2589,7 @@ r_preprocess_source(ostream &out, const Filename &fn, line.resize(line.size() - 1); string line2; - if (getline(*source, line2)) { + if (std::getline(*source, line2)) { line += line2; out.put('\n'); ++lineno; @@ -2618,7 +2618,7 @@ r_preprocess_source(ostream &out, const Filename &fn, size_t block_end = line2.find("*/"); while (block_end == string::npos) { // Didn't find it - look in the next line. - if (getline(*source, line2)) { + if (std::getline(*source, line2)) { out.put('\n'); ++lineno; block_end = line2.find("*/"); diff --git a/panda/src/net/datagram_ui.cxx b/panda/src/net/datagram_ui.cxx index fb5fc1a958..fa9879bf86 100644 --- a/panda/src/net/datagram_ui.cxx +++ b/panda/src/net/datagram_ui.cxx @@ -31,8 +31,8 @@ operator >> (istream &in, NetDatagram &datagram) { datagram.clear(); // First, read a line of text. - string line; - getline(in, line); + std::string line; + std::getline(in, line); // Now parse the text. size_t p = 0; @@ -74,7 +74,7 @@ operator >> (istream &in, NetDatagram &datagram) { while (p < line.length() && line[p] != '"') { p++; } - string str = line.substr(start, p - start); + std::string str = line.substr(start, p - start); datagram.add_int8(DE_string); datagram.add_string(str); p++; @@ -85,7 +85,7 @@ operator >> (istream &in, NetDatagram &datagram) { while (p < line.length() && !isspace(line[p])) { p++; } - string str = line.substr(start, p - start); + std::string str = line.substr(start, p - start); datagram.add_int8(DE_string); datagram.add_string(str); } diff --git a/panda/src/net/test_raw_server.cxx b/panda/src/net/test_raw_server.cxx index 7811fdd446..aeec9b0aee 100644 --- a/panda/src/net/test_raw_server.cxx +++ b/panda/src/net/test_raw_server.cxx @@ -84,7 +84,7 @@ main(int argc, char *argv[]) { if (reader.get_data(datagram)) { string data = datagram.get_message(); nout.write(data.data(), data.length()); - nout << flush; + nout << std::flush; Clients::iterator ci; for (ci = clients.begin(); ci != clients.end(); ++ci) { diff --git a/panda/src/pgraph/clipPlaneAttrib.cxx b/panda/src/pgraph/clipPlaneAttrib.cxx index 726b5472b7..0e37f618a5 100644 --- a/panda/src/pgraph/clipPlaneAttrib.cxx +++ b/panda/src/pgraph/clipPlaneAttrib.cxx @@ -505,8 +505,8 @@ compose_off(const RenderAttrib *other) const { // Create a new ClipPlaneAttrib that will hold the result. ClipPlaneAttrib *new_attrib = new ClipPlaneAttrib; - back_insert_iterator result = - back_inserter(new_attrib->_on_planes); + std::back_insert_iterator result = + std::back_inserter(new_attrib->_on_planes); while (ai != _off_planes.end() && bi != ta->_off_planes.end()) { @@ -717,8 +717,8 @@ compose_impl(const RenderAttrib *other) const { // Create a new ClipPlaneAttrib that will hold the result. ClipPlaneAttrib *new_attrib = new ClipPlaneAttrib; - back_insert_iterator result = - back_inserter(new_attrib->_on_planes); + std::back_insert_iterator result = + std::back_inserter(new_attrib->_on_planes); while (ai != _on_planes.end() && bi != ta->_on_planes.end() && diff --git a/panda/src/pgraph/cullableObject.cxx b/panda/src/pgraph/cullableObject.cxx index 8c8b24f1c0..31ebfb2484 100644 --- a/panda/src/pgraph/cullableObject.cxx +++ b/panda/src/pgraph/cullableObject.cxx @@ -545,7 +545,7 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { // Now sort the points in order from back-to-front so they will render // properly with transparency, at least with each other. - sort(vertices, vertices_end, SortPoints(points)); + std::sort(vertices, vertices_end, SortPoints(points)); // Go through the points, now in sorted order, and generate a pair of // triangles for each one. We generate indexed triangles instead of diff --git a/panda/src/pgraph/lightAttrib.cxx b/panda/src/pgraph/lightAttrib.cxx index 40014c53ee..fea2094a23 100644 --- a/panda/src/pgraph/lightAttrib.cxx +++ b/panda/src/pgraph/lightAttrib.cxx @@ -734,8 +734,8 @@ compose_impl(const RenderAttrib *other) const { // Create a new LightAttrib that will hold the result. LightAttrib *new_attrib = new LightAttrib; - back_insert_iterator result = - back_inserter(new_attrib->_on_lights); + std::back_insert_iterator result = + std::back_inserter(new_attrib->_on_lights); while (ai != _on_lights.end() && bi != ta->_on_lights.end() && diff --git a/panda/src/pgraph/renderAttrib.h b/panda/src/pgraph/renderAttrib.h index b506d64841..514a90b7d4 100644 --- a/panda/src/pgraph/renderAttrib.h +++ b/panda/src/pgraph/renderAttrib.h @@ -185,7 +185,7 @@ public: private: // This mutex protects _attribs. static LightReMutex *_attribs_lock; - typedef SimpleHashMap > Attribs; + typedef SimpleHashMap > Attribs; static Attribs *_attribs; int _saved_entry; diff --git a/panda/src/pgraph/renderAttribRegistry.cxx b/panda/src/pgraph/renderAttribRegistry.cxx index 4c27e4c0a7..ba3cc9a3b6 100644 --- a/panda/src/pgraph/renderAttribRegistry.cxx +++ b/panda/src/pgraph/renderAttribRegistry.cxx @@ -105,7 +105,7 @@ register_slot(TypeHandle type_handle, int sort, RenderAttrib *default_attrib) { _registry.push_back(RegistryNode(type_handle, sort, default_attrib)); _sorted_slots.push_back(slot); - ::sort(_sorted_slots.begin(), _sorted_slots.end(), SortSlots(this)); + std::sort(_sorted_slots.begin(), _sorted_slots.end(), SortSlots(this)); return slot; } @@ -123,7 +123,7 @@ set_slot_sort(int slot, int sort) { for (int i = 1; i < (int)_registry.size(); ++i) { _sorted_slots.push_back(i); } - ::sort(_sorted_slots.begin(), _sorted_slots.end(), SortSlots(this)); + std::sort(_sorted_slots.begin(), _sorted_slots.end(), SortSlots(this)); } /** diff --git a/panda/src/pgraph/renderEffects.cxx b/panda/src/pgraph/renderEffects.cxx index aaa81773ce..139eb9e00f 100644 --- a/panda/src/pgraph/renderEffects.cxx +++ b/panda/src/pgraph/renderEffects.cxx @@ -123,8 +123,8 @@ xform(const LMatrix4 &mat) const { } RenderEffects *new_state = new RenderEffects; - back_insert_iterator result = - back_inserter(new_state->_effects); + std::back_insert_iterator result = + std::back_inserter(new_state->_effects); Effects::const_iterator ai; for (ai = _effects.begin(); ai != _effects.end(); ++ai) { @@ -251,8 +251,8 @@ make(const RenderEffect *effect1, CPT(RenderEffects) RenderEffects:: add_effect(const RenderEffect *effect) const { RenderEffects *new_state = new RenderEffects; - back_insert_iterator result = - back_inserter(new_state->_effects); + std::back_insert_iterator result = + std::back_inserter(new_state->_effects); Effect new_effect(effect); Effects::const_iterator ai = _effects.begin(); @@ -288,8 +288,8 @@ add_effect(const RenderEffect *effect) const { CPT(RenderEffects) RenderEffects:: remove_effect(TypeHandle type) const { RenderEffects *new_state = new RenderEffects; - back_insert_iterator result = - back_inserter(new_state->_effects); + std::back_insert_iterator result = + std::back_inserter(new_state->_effects); Effects::const_iterator ai = _effects.begin(); diff --git a/panda/src/pgraph/renderState.h b/panda/src/pgraph/renderState.h index 433582fd2c..053f8cc365 100644 --- a/panda/src/pgraph/renderState.h +++ b/panda/src/pgraph/renderState.h @@ -227,7 +227,7 @@ private: // cache, which is encoded in _composition_cache and // _invert_composition_cache. static LightReMutex *_states_lock; - typedef SimpleHashMap > States; + typedef SimpleHashMap > States; static States *_states; static const RenderState *_empty_state; diff --git a/panda/src/pgraph/textureStageCollection.cxx b/panda/src/pgraph/textureStageCollection.cxx index 4f707efe63..42d6320b33 100644 --- a/panda/src/pgraph/textureStageCollection.cxx +++ b/panda/src/pgraph/textureStageCollection.cxx @@ -231,8 +231,8 @@ size() const { */ void TextureStageCollection:: sort() { - ::sort(_texture_stages.begin(), _texture_stages.end(), - CompareTextureStageSort()); + std::sort(_texture_stages.begin(), _texture_stages.end(), + CompareTextureStageSort()); } /** diff --git a/panda/src/pgraph/transformState.h b/panda/src/pgraph/transformState.h index 5edd8985d6..e204402489 100644 --- a/panda/src/pgraph/transformState.h +++ b/panda/src/pgraph/transformState.h @@ -252,7 +252,7 @@ private: // cache, which is encoded in _composition_cache and // _invert_composition_cache. static LightReMutex *_states_lock; - typedef SimpleHashMap > States; + typedef SimpleHashMap > States; static States *_states; static CPT(TransformState) _identity_state; static CPT(TransformState) _invalid_state; diff --git a/panda/src/pipeline/test_diners.cxx b/panda/src/pipeline/test_diners.cxx index 0a8f01e484..27976e3ea5 100644 --- a/panda/src/pipeline/test_diners.cxx +++ b/panda/src/pipeline/test_diners.cxx @@ -42,7 +42,7 @@ static double random_f(double max) return max * (double)i / (double)RAND_MAX; } -#define PRINTMSG(x) { MutexHolder l(Mutex::_notify_mutex); x << flush; } +#define PRINTMSG(x) { MutexHolder l(Mutex::_notify_mutex); x << std::flush; } // n philosophers sharing n chopsticks. Philosophers are poor folk and can't // afford luxuries like 2 chopsticks per person. diff --git a/panda/src/pipeline/test_threaddata.cxx b/panda/src/pipeline/test_threaddata.cxx index ebf6698216..2a397ac5c5 100644 --- a/panda/src/pipeline/test_threaddata.cxx +++ b/panda/src/pipeline/test_threaddata.cxx @@ -48,7 +48,7 @@ thread_main() { MutexHolder holder(cout_mutex); cout << "Running thread " << get_name() << " with parameter " << _parameter - << ", i = " << i << "\n" << flush; + << ", i = " << i << "\n" << std::flush; Thread *thread = get_current_thread(); nassertv(thread == this); } diff --git a/panda/src/pnmimage/pnmImage.cxx b/panda/src/pnmimage/pnmImage.cxx index d4fed72b3c..6f9daaf000 100644 --- a/panda/src/pnmimage/pnmImage.cxx +++ b/panda/src/pnmimage/pnmImage.cxx @@ -1918,7 +1918,7 @@ make_histogram(PNMImage::Histogram &histogram) { pixels.push_back(PixelSpecCount((*hi).first, (*hi).second)); } } - ::sort(pixels.begin(), pixels.end()); + std::sort(pixels.begin(), pixels.end()); histogram.swap(pixels, hist_map); } diff --git a/panda/src/pstatclient/pStatFrameData.cxx b/panda/src/pstatclient/pStatFrameData.cxx index f15f6bc61e..9c58f8d29d 100644 --- a/panda/src/pstatclient/pStatFrameData.cxx +++ b/panda/src/pstatclient/pStatFrameData.cxx @@ -25,7 +25,7 @@ */ void PStatFrameData:: sort_time() { - stable_sort(_time_data.begin(), _time_data.end()); + std::stable_sort(_time_data.begin(), _time_data.end()); } /** diff --git a/panda/src/putil/datagramInputFile.I b/panda/src/putil/datagramInputFile.I index c956fef4ac..152aa3505e 100644 --- a/panda/src/putil/datagramInputFile.I +++ b/panda/src/putil/datagramInputFile.I @@ -45,7 +45,7 @@ open(const Filename &filename) { */ INLINE istream &DatagramInputFile:: get_stream() { - static ifstream null_stream; + static std::ifstream null_stream; nassertr(_in != NULL, null_stream); return *_in; } diff --git a/panda/src/putil/datagramOutputFile.I b/panda/src/putil/datagramOutputFile.I index b3dbe95c9c..54167ae967 100644 --- a/panda/src/putil/datagramOutputFile.I +++ b/panda/src/putil/datagramOutputFile.I @@ -44,7 +44,7 @@ open(const Filename &filename) { */ INLINE ostream &DatagramOutputFile:: get_stream() { - static ofstream null_stream; + static std::ofstream null_stream; nassertr(_out != NULL, null_stream); return *_out; } diff --git a/panda/src/putil/simpleHashMap.h b/panda/src/putil/simpleHashMap.h index 6d08de5554..cd759f6cbd 100644 --- a/panda/src/putil/simpleHashMap.h +++ b/panda/src/putil/simpleHashMap.h @@ -52,16 +52,16 @@ private: * values. This allows effectively using SimpleHashMap as a set. */ template -class SimpleKeyValuePair { +class SimpleKeyValuePair { public: - INLINE SimpleKeyValuePair(const Key &key, nullptr_t data) : + INLINE SimpleKeyValuePair(const Key &key, std::nullptr_t data) : _key(key) {} Key _key; - ALWAYS_INLINE constexpr static nullptr_t get_data() { return nullptr; } - ALWAYS_INLINE constexpr static nullptr_t modify_data() { return nullptr; } - ALWAYS_INLINE static void set_data(nullptr_t) {} + ALWAYS_INLINE constexpr static std::nullptr_t get_data() { return nullptr; } + ALWAYS_INLINE constexpr static std::nullptr_t modify_data() { return nullptr; } + ALWAYS_INLINE static void set_data(std::nullptr_t) {} }; /** diff --git a/panda/src/speedtree/speedTreeNode.cxx b/panda/src/speedtree/speedTreeNode.cxx index c455e848f5..f3b9eb469d 100644 --- a/panda/src/speedtree/speedTreeNode.cxx +++ b/panda/src/speedtree/speedTreeNode.cxx @@ -505,7 +505,7 @@ add_from_stf(istream &in, const Filename &pathname, } // Consume any whitespace at the end of the file. - in >> ws; + in >> std::ws; if (!in.eof()) { // If we didn't read all the way to end-of-file, there was an error. diff --git a/panda/src/speedtree/stBasicTerrain.cxx b/panda/src/speedtree/stBasicTerrain.cxx index 5ee746dcbf..9b84e86ee8 100644 --- a/panda/src/speedtree/stBasicTerrain.cxx +++ b/panda/src/speedtree/stBasicTerrain.cxx @@ -191,7 +191,7 @@ setup_terrain(istream &in, const Filename &pathname) { } // Consume any whitespace at the end of the file. - in >> ws; + in >> std::ws; if (!in.eof()) { // If we didn't read all the way to end-of-file, there was an error. diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index 767dd9a4eb..d215d0e1aa 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -2825,7 +2825,7 @@ static HCURSOR get_cursor(const Filename &filename); const WinGraphicsWindow::WindowClass &WinGraphicsWindow:: register_window_class(const WindowProperties &props) { WindowClass wcreg(props); - wostringstream wclass_name; + std::wostringstream wclass_name; wclass_name << L"WinGraphicsWindow" << _window_class_index; wcreg._name = wclass_name.str(); diff --git a/pandatool/src/bam/ptsToBam.cxx b/pandatool/src/bam/ptsToBam.cxx index 4db96663ca..941b291105 100644 --- a/pandatool/src/bam/ptsToBam.cxx +++ b/pandatool/src/bam/ptsToBam.cxx @@ -77,7 +77,7 @@ run() { _decimated_point_number = 0.0; _num_vdatas = 0; string line; - while (getline(pts, line)) { + while (std::getline(pts, line)) { process_line(line); } close_vertex_data(); @@ -132,7 +132,7 @@ process_line(const string &line) { _line_number++; if (_line_number % 1000000 == 0) { - cerr << "." << flush; + std::cerr << "." << std::flush; } if (line.empty() || !isdigit(line[0])) { diff --git a/pandatool/src/cvscopy/cvsCopy.cxx b/pandatool/src/cvscopy/cvsCopy.cxx index 1b8b43449a..fdb1d6b85e 100644 --- a/pandatool/src/cvscopy/cvsCopy.cxx +++ b/pandatool/src/cvscopy/cvsCopy.cxx @@ -264,7 +264,7 @@ verify_binary_file(Filename source, Filename dest) { source.set_binary(); dest.set_binary(); - ifstream s, d; + std::ifstream s, d; if (!source.open_read(s)) { return false; } @@ -313,8 +313,8 @@ copy_binary_file(Filename source, Filename dest) { source.set_binary(); dest.set_binary(); - ifstream in; - ofstream out; + std::ifstream in; + std::ofstream out; if (!source.open_read(in)) { nout << "Cannot read " << source << "\n"; return false; @@ -475,11 +475,11 @@ scan_for_root(const string &dirname) { */ string CVSCopy:: prompt(const string &message) { - nout << flush; + nout << std::flush; while (true) { - cerr << message << flush; - string response; - getline(cin, response); + std::cerr << message << std::flush; + std::string response; + std::getline(std::cin, response); // Remove leading and trailing whitespace. size_t p = 0; diff --git a/pandatool/src/cvscopy/cvsSourceTree.cxx b/pandatool/src/cvscopy/cvsSourceTree.cxx index 5fea69e430..333c4991ad 100644 --- a/pandatool/src/cvscopy/cvsSourceTree.cxx +++ b/pandatool/src/cvscopy/cvsSourceTree.cxx @@ -438,11 +438,11 @@ ask_any(const string &basename, */ string CVSSourceTree:: prompt(const string &message) { - nout << flush; + nout << std::flush; while (true) { - cerr << message << flush; - string response; - getline(cin, response); + cerr << message << std::flush; + std::string response; + std::getline(std::cin, response); // Remove leading and trailing whitespace. size_t p = 0; diff --git a/pandatool/src/dxf/dxfFile.cxx b/pandatool/src/dxf/dxfFile.cxx index b716ea11ba..35772c625f 100644 --- a/pandatool/src/dxf/dxfFile.cxx +++ b/pandatool/src/dxf/dxfFile.cxx @@ -552,7 +552,7 @@ get_group() { in.get(); } - getline(in, _string); + std::getline(in, _string); _string = trim_right(_string); if (!in) { diff --git a/pandatool/src/egg-palettize/eggPalettize.cxx b/pandatool/src/egg-palettize/eggPalettize.cxx index 200b62e798..d01087a9ac 100644 --- a/pandatool/src/egg-palettize/eggPalettize.cxx +++ b/pandatool/src/egg-palettize/eggPalettize.cxx @@ -701,7 +701,7 @@ run() { } else { _txa_filename.set_text(); - ifstream txa_file; + std::ifstream txa_file; if (!_txa_filename.open_read(txa_file)) { nout << "Unable to open " << _txa_filename << "\n"; exit(1); diff --git a/pandatool/src/egg-qtess/qtessInputFile.cxx b/pandatool/src/egg-qtess/qtessInputFile.cxx index 647f0b8471..850ad638f9 100644 --- a/pandatool/src/egg-qtess/qtessInputFile.cxx +++ b/pandatool/src/egg-qtess/qtessInputFile.cxx @@ -30,7 +30,7 @@ read(const Filename &filename) { _filename = Filename::text_filename(filename); _entries.clear(); - ifstream input; + std::ifstream input; if (!_filename.open_read(input)) { qtess_cat.error() << "Unable to open input file " << _filename << "\n"; @@ -41,7 +41,7 @@ read(const Filename &filename) { int line_number = 0; string line; - while (getline(input, line)) { + while (std::getline(input, line)) { line_number++; // Eliminate comments. We have to scan the line repeatedly until we find diff --git a/pandatool/src/eggbase/eggMultiFilter.cxx b/pandatool/src/eggbase/eggMultiFilter.cxx index 8b8fd61a15..1191d55dea 100644 --- a/pandatool/src/eggbase/eggMultiFilter.cxx +++ b/pandatool/src/eggbase/eggMultiFilter.cxx @@ -76,14 +76,14 @@ handle_args(ProgramBase::Args &args) { nout << "Populating args from input file: " << _input_filename << "\n"; // Makes sure the file is set is_text _filename = Filename::text_filename(_input_filename); - ifstream input; + std::ifstream input; if (!_filename.open_read(input)) { nout << "Error opening file: " << _input_filename << "\n"; return false; } string line; // File should be a space-delimited list of egg files - while (getline(input, line, ' ')) { + while (std::getline(input, line, ' ')) { args.push_back(line); } } diff --git a/pandatool/src/eggbase/eggWriter.h b/pandatool/src/eggbase/eggWriter.h index 9ef09fffe6..9037fe7e54 100644 --- a/pandatool/src/eggbase/eggWriter.h +++ b/pandatool/src/eggbase/eggWriter.h @@ -39,7 +39,7 @@ protected: virtual bool post_command_line(); private: - ofstream _output_stream; + std::ofstream _output_stream; }; #endif diff --git a/pandatool/src/flt/fltHeader.cxx b/pandatool/src/flt/fltHeader.cxx index 062afe15fa..3b689fb0fe 100644 --- a/pandatool/src/flt/fltHeader.cxx +++ b/pandatool/src/flt/fltHeader.cxx @@ -237,7 +237,7 @@ FltError FltHeader:: write_flt(Filename filename) { filename.set_binary(); - ofstream out; + std::ofstream out; if (!filename.open_write(out)) { assert(!flt_error_abort); return FE_could_not_open; diff --git a/pandatool/src/flt/fltTexture.cxx b/pandatool/src/flt/fltTexture.cxx index c3c61cf130..ee56205c6f 100644 --- a/pandatool/src/flt/fltTexture.cxx +++ b/pandatool/src/flt/fltTexture.cxx @@ -136,7 +136,7 @@ FltError FltTexture:: read_attr_data() { Filename attr_filename = get_attr_filename(); - ifstream attr; + std::ifstream attr; if (!attr_filename.open_read(attr)) { return FE_could_not_open; } @@ -184,7 +184,7 @@ write_attr_data(Filename attr_filename) const { } attr_filename.set_binary(); - ofstream attr; + std::ofstream attr; if (!attr_filename.open_write(attr)) { return FE_could_not_open; } diff --git a/pandatool/src/mayaegg/mayaToEggConverter.cxx b/pandatool/src/mayaegg/mayaToEggConverter.cxx index d661af583b..ed2a22552b 100644 --- a/pandatool/src/mayaegg/mayaToEggConverter.cxx +++ b/pandatool/src/mayaegg/mayaToEggConverter.cxx @@ -675,7 +675,7 @@ convert_char_chan(double start_frame, double end_frame, double frame_inc, } else { // We have to write to cerr instead of mayaegg_cat to allow flushing // without writing a newline. - cerr << "." << flush; + std::cerr << "." << std::flush; } MGlobal::viewFrame(frame); diff --git a/pandatool/src/mayaprogs/blend_test.cxx b/pandatool/src/mayaprogs/blend_test.cxx index cf7e880731..5cbd6d413e 100644 --- a/pandatool/src/mayaprogs/blend_test.cxx +++ b/pandatool/src/mayaprogs/blend_test.cxx @@ -177,7 +177,7 @@ output_vertices(const char *filename, MFnMesh &mesh) { exit(1); } - ofstream file(filename, ios::out | ios::trunc); + std::ofstream file(filename, ios::out | ios::trunc); if (!file) { cerr << "Couldn't open " << filename << " for output.\n"; exit(1); diff --git a/pandatool/src/mayaprogs/normal_test.cxx b/pandatool/src/mayaprogs/normal_test.cxx index e1015f2759..ca1b4638eb 100644 --- a/pandatool/src/mayaprogs/normal_test.cxx +++ b/pandatool/src/mayaprogs/normal_test.cxx @@ -179,7 +179,7 @@ output_vertices(const char *filename, MFnMesh &mesh) { exit(1); } - ofstream file(filename, ios::out | ios::trunc); + std::ofstream file(filename, std::ios::out | std::ios::trunc); if (!file) { cerr << "Couldn't open " << filename << " for output.\n"; exit(1); diff --git a/pandatool/src/miscprogs/binToC.cxx b/pandatool/src/miscprogs/binToC.cxx index 8d1ee2dec8..ba41010a60 100644 --- a/pandatool/src/miscprogs/binToC.cxx +++ b/pandatool/src/miscprogs/binToC.cxx @@ -66,13 +66,13 @@ BinToC() : */ void BinToC:: run() { - ifstream in; + std::ifstream in; if (!_input_filename.open_read(in)) { nout << "Unable to read " << _input_filename << ".\n"; exit(1); } - ostream &out = get_output(); + std::ostream &out = get_output(); string static_keyword; if (_static_table) { static_keyword = "static "; diff --git a/pandatool/src/palettizer/textureImage.cxx b/pandatool/src/palettizer/textureImage.cxx index 54e213ed24..fca1307928 100644 --- a/pandatool/src/palettizer/textureImage.cxx +++ b/pandatool/src/palettizer/textureImage.cxx @@ -90,7 +90,7 @@ assign_groups() { if (_explicitly_assigned_groups.empty()) { // If we have no explicit group assignments, we must consider all the egg // files. - copy(_egg_files.begin(), _egg_files.end(), back_inserter(needed_eggs)); + std::copy(_egg_files.begin(), _egg_files.end(), std::back_inserter(needed_eggs)); } else { // Otherwise, we only need to consider the egg files that don't have any diff --git a/pandatool/src/progbase/programBase.cxx b/pandatool/src/progbase/programBase.cxx index 86a2c17c48..c5440d08f2 100644 --- a/pandatool/src/progbase/programBase.cxx +++ b/pandatool/src/progbase/programBase.cxx @@ -57,7 +57,7 @@ operator () (const Option *a, const Option *b) const { // properly flushed before we exit, if someone calls exit(). It's probably // not necessary, but why not be phobic about it? static void flush_nout() { - nout << flush; + nout << std::flush; } static ConfigVariableInt default_terminal_width diff --git a/pandatool/src/progbase/withOutputFile.h b/pandatool/src/progbase/withOutputFile.h index d77627ffa7..7c4c0f2af7 100644 --- a/pandatool/src/progbase/withOutputFile.h +++ b/pandatool/src/progbase/withOutputFile.h @@ -52,8 +52,8 @@ protected: Filename _output_filename; private: - ofstream _output_stream; - ostream *_output_ptr; + std::ofstream _output_stream; + std::ostream *_output_ptr; bool _owns_output_ptr; }; diff --git a/pandatool/src/softegg/soft2Egg.c b/pandatool/src/softegg/soft2Egg.c index aaad102fb4..9e744b8655 100644 --- a/pandatool/src/softegg/soft2Egg.c +++ b/pandatool/src/softegg/soft2Egg.c @@ -192,10 +192,9 @@ class soft2egg : public EggBase bool has_morph; bool make_pose; - ofstream eggFile; - ofstream animFile; - ofstream texFile; - + std::ofstream eggFile; + std::ofstream animFile; + std::ofstream texFile; }; diff --git a/pandatool/src/softegg/softToEggConverter.cxx b/pandatool/src/softegg/softToEggConverter.cxx index 64d5da3aed..41cd0b66b9 100644 --- a/pandatool/src/softegg/softToEggConverter.cxx +++ b/pandatool/src/softegg/softToEggConverter.cxx @@ -775,7 +775,7 @@ convert_char_chan() { // if (softegg_cat.is_debug()) { softegg_cat.debug(false) softegg_cat.info() << "frame " << time << "\n"; // } else { We have to write to cerr instead of softegg_cat to allow - // flushing without writing a newline. cerr << "." << flush; } + // flushing without writing a newline. std::cerr << "." << std::flush; } // MGlobal::viewFrame(frame); for (i = 0; i < num_nodes; i++) { diff --git a/pandatool/src/softprogs/softCVS.cxx b/pandatool/src/softprogs/softCVS.cxx index 22329eb8c5..a49e8ccde4 100644 --- a/pandatool/src/softprogs/softCVS.cxx +++ b/pandatool/src/softprogs/softCVS.cxx @@ -282,7 +282,7 @@ get_scenes() { Filename file(sf.get_dirname(), sf.get_filename()); file.set_text(); - ifstream in; + std::ifstream in; if (!file.open_read(in)) { nout << "Unable to read " << file << "\n"; } else { @@ -436,7 +436,7 @@ scan_cvs(const string &dirname, pset &cvs_elements) { return false; } - ifstream in; + std::ifstream in; cvs_entries.set_text(); if (!cvs_entries.open_read(in)) { nout << "Unable to read CVS directory.\n"; @@ -444,7 +444,7 @@ scan_cvs(const string &dirname, pset &cvs_elements) { } string line; - getline(in, line); + std::getline(in, line); while (!in.fail() && !in.eof()) { if (!line.empty() && line[0] == '/') { size_t slash = line.find('/', 1); @@ -461,7 +461,7 @@ scan_cvs(const string &dirname, pset &cvs_elements) { } } - getline(in, line); + std::getline(in, line); } return true; diff --git a/pandatool/src/text-stats/textStats.cxx b/pandatool/src/text-stats/textStats.cxx index cc1e2392c1..c5e3c5a11c 100644 --- a/pandatool/src/text-stats/textStats.cxx +++ b/pandatool/src/text-stats/textStats.cxx @@ -87,7 +87,7 @@ run() { nout << "Listening for connections.\n"; if (_got_outputFileName) { - _outFile = new ofstream(_outputFileName.c_str(), ios::out); + _outFile = new std::ofstream(_outputFileName.c_str(), std::ios::out); } else { _outFile = &(nout); } diff --git a/pandatool/src/vrml/vrmlParser.cxx.prebuilt b/pandatool/src/vrml/vrmlParser.cxx.prebuilt index fb95f8075f..6eaddbf170 100644 --- a/pandatool/src/vrml/vrmlParser.cxx.prebuilt +++ b/pandatool/src/vrml/vrmlParser.cxx.prebuilt @@ -106,7 +106,7 @@ // Currently-being-define proto. Prototypes may be nested, so a stack // is needed: -stack< VrmlNodeType*, plist > currentProtoStack; +std::stack > currentProtoStack; // This is used to keep track of which field in which type of node is being // parsed. Field are nested (nodes are contained inside MFNode/SFNode fields) @@ -117,12 +117,12 @@ typedef struct { const VrmlNodeType::NameTypeRec *typeRec; } FieldRec; -stack< FieldRec*, plist > currentField; +std::stack > currentField; // Similarly for the node entries (which contain the actual values for // the fields as they are encountered): -stack< VrmlNode*, plist > currentNode; +std::stack > currentNode; // This is used when the parser knows what kind of token it expects // to get next-- used when parsing field values (whose types are declared diff --git a/pandatool/src/vrml/vrmlParser.yxx b/pandatool/src/vrml/vrmlParser.yxx index 3404f8c3f8..f3984b47fc 100644 --- a/pandatool/src/vrml/vrmlParser.yxx +++ b/pandatool/src/vrml/vrmlParser.yxx @@ -49,7 +49,7 @@ // Currently-being-define proto. Prototypes may be nested, so a stack // is needed: -stack< VrmlNodeType*, plist > currentProtoStack; +std::stack > currentProtoStack; // This is used to keep track of which field in which type of node is being // parsed. Field are nested (nodes are contained inside MFNode/SFNode fields) @@ -60,12 +60,12 @@ typedef struct { const VrmlNodeType::NameTypeRec *typeRec; } FieldRec; -stack< FieldRec*, plist > currentField; +std::stack > currentField; // Similarly for the node entries (which contain the actual values for // the fields as they are encountered): -stack< VrmlNode*, plist > currentNode; +std::stack > currentNode; // This is used when the parser knows what kind of token it expects // to get next-- used when parsing field values (whose types are declared diff --git a/pandatool/src/xfile/xFile.cxx b/pandatool/src/xfile/xFile.cxx index 26791ed403..049fe26780 100644 --- a/pandatool/src/xfile/xFile.cxx +++ b/pandatool/src/xfile/xFile.cxx @@ -123,7 +123,7 @@ read(istream &in, const string &filename) { */ bool XFile:: write(Filename filename) const { - ofstream out; + std::ofstream out; // We actually open the file to write in binary mode, to avoid the MS-DOS // newline characters (since Windows seems to do this too). From c08339e8ce0cc3c49f01b2325b9e340129a2acaf Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 3 Jun 2018 22:30:15 +0200 Subject: [PATCH 223/247] ShaderGenerator: fix error with normal map and only ambient light Closes #331 --- panda/src/pgraphnodes/shaderGenerator.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index 3dea5f7134..a2a749729e 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -353,7 +353,7 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { if (parallax_mapping_samples == 0) { info._mode = TextureStage::M_normal; } else if (!shader_attrib->auto_normal_on() || - (!key._lighting && (key._outputs & AuxBitplaneAttrib::ABO_aux_normal) == 0)) { + (key._lights.empty() && (key._outputs & AuxBitplaneAttrib::ABO_aux_normal) == 0)) { info._mode = TextureStage::M_height; info._flags = ShaderKey::TF_has_alpha; } else { @@ -362,7 +362,7 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { break; case TextureStage::M_normal_gloss: - if (!shader_attrib->auto_gloss_on() || !key._lighting) { + if (!shader_attrib->auto_gloss_on() || key._lights.empty()) { info._mode = TextureStage::M_normal; } else if (!shader_attrib->auto_normal_on()) { info._mode = TextureStage::M_gloss; @@ -411,7 +411,7 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { switch (info._mode) { case TextureStage::M_normal: if (!shader_attrib->auto_normal_on() || - (!key._lighting && (key._outputs & AuxBitplaneAttrib::ABO_aux_normal) == 0)) { + (key._lights.empty() && (key._outputs & AuxBitplaneAttrib::ABO_aux_normal) == 0)) { skip = true; } else { info._flags = ShaderKey::TF_map_normal; @@ -425,7 +425,7 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) { } break; case TextureStage::M_gloss: - if (key._lighting && shader_attrib->auto_gloss_on()) { + if (!key._lights.empty() && shader_attrib->auto_gloss_on()) { info._flags = ShaderKey::TF_map_gloss; } else { skip = true; From d8bf9d4b559bcf6980a863b8305b40ff3d520784 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 3 Jun 2018 22:33:12 +0200 Subject: [PATCH 224/247] tests: skip display tests if pipe cannot create offscreen buffers --- tests/display/conftest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/display/conftest.py b/tests/display/conftest.py index 88a2b5f3c3..36d498b9a3 100644 --- a/tests/display/conftest.py +++ b/tests/display/conftest.py @@ -68,7 +68,9 @@ def gsg(graphics_pipe, graphics_engine): ) graphics_engine.open_windows() - assert buffer is not None + if buffer is None: + pytest.skip("GraphicsPipe cannot make offscreen buffers") + yield buffer.gsg if buffer is not None: From eb960669a5b03a1a9834622ca0ac367784c4f25c Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 3 Jun 2018 22:33:59 +0200 Subject: [PATCH 225/247] display: fix assert when window fails to open The assert is being triggered because the window is already being removed in open_windows. It does not really matter if it returns false anyway, as long as the window is removed one way or another. --- panda/src/display/graphicsEngine.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index b3f931e44b..e47597872e 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -445,8 +445,7 @@ make_output(GraphicsPipe *pipe, } // No good; delete the window and keep trying. - bool removed = remove_window(window); - nassertr(removed, NULL); + remove_window(window); } } From 57602d750f16e5b7029385fa5f5fcf52147f5f70 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 3 Jun 2018 22:35:16 +0200 Subject: [PATCH 226/247] cocoadisplay: don't crash if window/buffer fails to open --- panda/src/cocoadisplay/cocoaGraphicsBuffer.mm | 6 ++++++ panda/src/cocoadisplay/cocoaGraphicsWindow.mm | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/panda/src/cocoadisplay/cocoaGraphicsBuffer.mm b/panda/src/cocoadisplay/cocoaGraphicsBuffer.mm index ea6fb61e4e..07f44b6c94 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsBuffer.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsBuffer.mm @@ -105,6 +105,12 @@ open_buffer() { } } + if (cocoagsg->_context == nil) { + // Could not obtain a proper context. + _gsg.clear(); + return false; + } + FrameBufferProperties desired_props(_fb_properties); // Lock the context, so we can safely operate on it. diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index 35f71f6614..df12a69985 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm @@ -362,6 +362,13 @@ open_window() { } } + if (cocoagsg->_context == nil) { + // Could not obtain a proper context. + _gsg.clear(); + close_window(); + return false; + } + // Fill in the blanks. if (!_properties.has_origin()) { _properties.set_origin(-2, -2); From ebe1b0763f3b33073826593006829b4e3982e328 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 27 May 2018 17:31:49 -0600 Subject: [PATCH 227/247] express: Allow WeakPointer comparisons to nullptr This saves us from having to do casts like: if (foo == (const FooType *)nullptr) { ... } --- panda/src/express/weakPointerToBase.I | 54 +++++++++++++++++++++++++++ panda/src/express/weakPointerToBase.h | 7 ++++ 2 files changed, 61 insertions(+) diff --git a/panda/src/express/weakPointerToBase.I b/panda/src/express/weakPointerToBase.I index 1c831529a1..5ba737d507 100644 --- a/panda/src/express/weakPointerToBase.I +++ b/panda/src/express/weakPointerToBase.I @@ -292,6 +292,51 @@ operator >= (To *other) const { return (To *)_void_ptr >= other; } +/** + * + */ +template +INLINE bool WeakPointerToBase:: +operator == (nullptr_t) const { + return _void_ptr == nullptr; +} + +/** + * + */ +template +INLINE bool WeakPointerToBase:: +operator != (nullptr_t) const { + return _void_ptr != nullptr; +} + +/** + * + */ +template +INLINE bool WeakPointerToBase:: +operator > (nullptr_t) const { + return _void_ptr != nullptr; +} + +/** + * + */ +template +INLINE bool WeakPointerToBase:: +operator <= (nullptr_t) const { + return _void_ptr == nullptr; +} + +/** + * + */ +template +INLINE bool WeakPointerToBase:: +operator >= (nullptr_t) const { + return true; +} + /** * */ @@ -392,6 +437,15 @@ operator < (const To *other) const { return (To *)_void_ptr < other; } +/** + * + */ +template +INLINE bool WeakPointerToBase:: +operator < (nullptr_t) const { + return false; +} + /** * */ diff --git a/panda/src/express/weakPointerToBase.h b/panda/src/express/weakPointerToBase.h index 4870ef21d8..20505191e3 100644 --- a/panda/src/express/weakPointerToBase.h +++ b/panda/src/express/weakPointerToBase.h @@ -60,6 +60,12 @@ public: INLINE bool operator <= (To *other) const; INLINE bool operator >= (To *other) const; + INLINE bool operator == (nullptr_t) const; + INLINE bool operator != (nullptr_t) const; + INLINE bool operator > (nullptr_t) const; + INLINE bool operator <= (nullptr_t) const; + INLINE bool operator >= (nullptr_t) const; + INLINE bool operator == (const WeakPointerToBase &other) const; INLINE bool operator != (const WeakPointerToBase &other) const; INLINE bool operator > (const WeakPointerToBase &other) const; @@ -73,6 +79,7 @@ public: INLINE bool operator >= (const PointerToBase &other) const; #endif // WIN32_VC INLINE bool operator < (const To *other) const; + INLINE bool operator < (nullptr_t) const; INLINE bool operator < (const WeakPointerToBase &other) const; INLINE bool operator < (const PointerToBase &other) const; #endif // CPPPARSER From d422d74abbac431e16666a4c521a77e77c642c56 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Wed, 30 May 2018 13:52:36 -0600 Subject: [PATCH 228/247] general: Clean up asserts which were abusing NULL --- dtool/src/interrogate/interfaceMaker.cxx | 1 - dtool/src/interrogate/interrogateBuilder.cxx | 2 -- panda/src/express/nodeReferenceCount.I | 4 ---- panda/src/express/nodeReferenceCount.cxx | 2 -- panda/src/express/referenceCount.I | 4 ---- panda/src/express/referenceCount.cxx | 2 -- panda/src/express/weakPointerTo.I | 16 ++++++++-------- .../putil/cachedTypedWritableReferenceCount.I | 4 ---- .../putil/cachedTypedWritableReferenceCount.cxx | 2 -- panda/src/putil/nodeCachedReferenceCount.I | 4 ---- panda/src/putil/nodeCachedReferenceCount.cxx | 2 -- panda/src/speedtree/speedTreeNode.I | 4 +++- panda/src/speedtree/speedTreeNode.cxx | 6 ++++-- 13 files changed, 15 insertions(+), 38 deletions(-) diff --git a/dtool/src/interrogate/interfaceMaker.cxx b/dtool/src/interrogate/interfaceMaker.cxx index 2b04f8477a..ded4efacc5 100644 --- a/dtool/src/interrogate/interfaceMaker.cxx +++ b/dtool/src/interrogate/interfaceMaker.cxx @@ -665,7 +665,6 @@ record_object(TypeIndex type_index) { InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); const InterrogateType &itype = idb->get_type(type_index); - assert(&itype != NULL); Object *object = new Object(itype); bool inserted = _objects.insert(Objects::value_type(type_index, object)).second; diff --git a/dtool/src/interrogate/interrogateBuilder.cxx b/dtool/src/interrogate/interrogateBuilder.cxx index 5c9dc651ad..2ce5b4f512 100644 --- a/dtool/src/interrogate/interrogateBuilder.cxx +++ b/dtool/src/interrogate/interrogateBuilder.cxx @@ -1696,8 +1696,6 @@ get_function(CPPInstance *function, string description, InterrogateFunction &ifunction = InterrogateDatabase::get_ptr()->update_function(index); - nassertr(&ifunction != NULL, 0); - ifunction._flags |= flags; // Also, make sure this particular signature is defined. diff --git a/panda/src/express/nodeReferenceCount.I b/panda/src/express/nodeReferenceCount.I index 4273f0b78c..4f963476f7 100644 --- a/panda/src/express/nodeReferenceCount.I +++ b/panda/src/express/nodeReferenceCount.I @@ -52,8 +52,6 @@ NodeReferenceCount(const NodeReferenceCount ©) : ReferenceCount(copy) { */ INLINE void NodeReferenceCount:: operator = (const NodeReferenceCount ©) { - nassertv(this != NULL); - // If this assertion fails, our own pointer was recently deleted. Possibly // you used a real pointer instead of a PointerTo at some point, and the // object was deleted when the PointerTo went out of scope. Maybe you tried @@ -74,8 +72,6 @@ operator = (const NodeReferenceCount ©) { */ INLINE NodeReferenceCount:: ~NodeReferenceCount() { - nassertv(this != NULL); - // If this assertion fails, we're trying to delete an object that was just // deleted. Possibly you used a real pointer instead of a PointerTo at some // point, and the object was deleted when the PointerTo went out of scope. diff --git a/panda/src/express/nodeReferenceCount.cxx b/panda/src/express/nodeReferenceCount.cxx index 05c9b6d63f..f965f240a4 100644 --- a/panda/src/express/nodeReferenceCount.cxx +++ b/panda/src/express/nodeReferenceCount.cxx @@ -21,8 +21,6 @@ TypeHandle NodeReferenceCount::_type_handle; */ bool NodeReferenceCount:: do_test_ref_count_integrity() const { - nassertr(this != NULL, false); - // If this assertion fails, we're trying to delete an object that was just // deleted. Possibly you used a real pointer instead of a PointerTo at some // point, and the object was deleted when the PointerTo went out of scope. diff --git a/panda/src/express/referenceCount.I b/panda/src/express/referenceCount.I index f18c60a02c..00f9d44b8c 100644 --- a/panda/src/express/referenceCount.I +++ b/panda/src/express/referenceCount.I @@ -63,8 +63,6 @@ ReferenceCount(const ReferenceCount &) { */ INLINE void ReferenceCount:: operator = (const ReferenceCount &) { - nassertv(this != NULL); - // If this assertion fails, our own pointer was recently deleted. Possibly // you used a real pointer instead of a PointerTo at some point, and the // object was deleted when the PointerTo went out of scope. Maybe you tried @@ -80,8 +78,6 @@ operator = (const ReferenceCount &) { ReferenceCount:: ~ReferenceCount() { TAU_PROFILE("ReferenceCount::~ReferenceCount()", " ", TAU_USER); - nassertv(this != NULL); - // If this assertion fails, we're trying to delete an object that was just // deleted. Possibly you used a real pointer instead of a PointerTo at some // point, and the object was deleted when the PointerTo went out of scope. diff --git a/panda/src/express/referenceCount.cxx b/panda/src/express/referenceCount.cxx index f5d988cf8e..371f755673 100644 --- a/panda/src/express/referenceCount.cxx +++ b/panda/src/express/referenceCount.cxx @@ -23,8 +23,6 @@ TypeHandle ReferenceCount::_type_handle; */ bool ReferenceCount:: do_test_ref_count_integrity() const { - nassertr(this != NULL, false); - // If this assertion fails, we're trying to delete an object that was just // deleted. Possibly you used a real pointer instead of a PointerTo at some // point, and the object was deleted when the PointerTo went out of scope. diff --git a/panda/src/express/weakPointerTo.I b/panda/src/express/weakPointerTo.I index 60ac8a1917..969d2e7158 100644 --- a/panda/src/express/weakPointerTo.I +++ b/panda/src/express/weakPointerTo.I @@ -45,7 +45,7 @@ WeakPointerTo(const WeakPointerTo ©) : template INLINE TYPENAME WeakPointerTo::To &WeakPointerTo:: operator *() const { - nassertr(!this->was_deleted(), *((To *)NULL)); + assert(!this->was_deleted()); return *((To *)WeakPointerToBase::_void_ptr); } @@ -55,7 +55,7 @@ operator *() const { template INLINE TYPENAME WeakPointerTo::To *WeakPointerTo:: operator -> () const { - nassertr(!this->was_deleted(), (To *)NULL); + assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; } @@ -68,7 +68,7 @@ operator -> () const { template INLINE WeakPointerTo:: operator T * () const { - nassertr(!this->was_deleted(), (To *)NULL); + assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; } @@ -108,7 +108,7 @@ lock() const { template INLINE TYPENAME WeakPointerTo::To *WeakPointerTo:: p() const { - nassertr(!this->was_deleted(), (To *)NULL); + assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; } @@ -208,7 +208,7 @@ WeakConstPointerTo(const WeakConstPointerTo ©) : template INLINE const TYPENAME WeakConstPointerTo::To &WeakConstPointerTo:: operator *() const { - nassertr(!this->was_deleted(), *((To *)NULL)); + assert(!this->was_deleted()); return *((To *)WeakPointerToBase::_void_ptr); } @@ -218,7 +218,7 @@ operator *() const { template INLINE const TYPENAME WeakConstPointerTo::To *WeakConstPointerTo:: operator -> () const { - nassertr(!this->was_deleted(), (To *)NULL); + assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; } @@ -232,7 +232,7 @@ operator -> () const { template INLINE WeakConstPointerTo:: operator const T * () const { - nassertr(!this->was_deleted(), (To *)NULL); + assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; } @@ -269,7 +269,7 @@ lock() const { template INLINE const TYPENAME WeakConstPointerTo::To *WeakConstPointerTo:: p() const { - nassertr(!this->was_deleted(), (To *)NULL); + assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; } diff --git a/panda/src/putil/cachedTypedWritableReferenceCount.I b/panda/src/putil/cachedTypedWritableReferenceCount.I index 1d60f9a614..dae8502d4b 100644 --- a/panda/src/putil/cachedTypedWritableReferenceCount.I +++ b/panda/src/putil/cachedTypedWritableReferenceCount.I @@ -49,8 +49,6 @@ CachedTypedWritableReferenceCount(const CachedTypedWritableReferenceCount ©) */ INLINE void CachedTypedWritableReferenceCount:: operator = (const CachedTypedWritableReferenceCount ©) { - nassertv(this != NULL); - // If this assertion fails, our own pointer was recently deleted. Possibly // you used a real pointer instead of a PointerTo at some point, and the // object was deleted when the PointerTo went out of scope. Maybe you tried @@ -71,8 +69,6 @@ operator = (const CachedTypedWritableReferenceCount ©) { */ INLINE CachedTypedWritableReferenceCount:: ~CachedTypedWritableReferenceCount() { - nassertv(this != NULL); - // If this assertion fails, we're trying to delete an object that was just // deleted. Possibly you used a real pointer instead of a PointerTo at some // point, and the object was deleted when the PointerTo went out of scope. diff --git a/panda/src/putil/cachedTypedWritableReferenceCount.cxx b/panda/src/putil/cachedTypedWritableReferenceCount.cxx index 53e4fa355a..d7ee3ed74d 100644 --- a/panda/src/putil/cachedTypedWritableReferenceCount.cxx +++ b/panda/src/putil/cachedTypedWritableReferenceCount.cxx @@ -21,8 +21,6 @@ TypeHandle CachedTypedWritableReferenceCount::_type_handle; */ bool CachedTypedWritableReferenceCount:: do_test_ref_count_integrity() const { - nassertr(this != NULL, false); - // If this assertion fails, we're trying to delete an object that was just // deleted. Possibly you used a real pointer instead of a PointerTo at some // point, and the object was deleted when the PointerTo went out of scope. diff --git a/panda/src/putil/nodeCachedReferenceCount.I b/panda/src/putil/nodeCachedReferenceCount.I index c06016d523..92abe19ce3 100644 --- a/panda/src/putil/nodeCachedReferenceCount.I +++ b/panda/src/putil/nodeCachedReferenceCount.I @@ -49,8 +49,6 @@ NodeCachedReferenceCount(const NodeCachedReferenceCount ©) : CachedTypedWrit */ INLINE void NodeCachedReferenceCount:: operator = (const NodeCachedReferenceCount ©) { - nassertv(this != NULL); - // If this assertion fails, our own pointer was recently deleted. Possibly // you used a real pointer instead of a PointerTo at some point, and the // object was deleted when the PointerTo went out of scope. Maybe you tried @@ -71,8 +69,6 @@ operator = (const NodeCachedReferenceCount ©) { */ INLINE NodeCachedReferenceCount:: ~NodeCachedReferenceCount() { - nassertv(this != NULL); - // If this assertion fails, we're trying to delete an object that was just // deleted. Possibly you used a real pointer instead of a PointerTo at some // point, and the object was deleted when the PointerTo went out of scope. diff --git a/panda/src/putil/nodeCachedReferenceCount.cxx b/panda/src/putil/nodeCachedReferenceCount.cxx index 62249dcd42..f53ff22b96 100644 --- a/panda/src/putil/nodeCachedReferenceCount.cxx +++ b/panda/src/putil/nodeCachedReferenceCount.cxx @@ -21,8 +21,6 @@ TypeHandle NodeCachedReferenceCount::_type_handle; */ bool NodeCachedReferenceCount:: do_test_ref_count_integrity() const { - nassertr(this != NULL, false); - // If this assertion fails, we're trying to delete an object that was just // deleted. Possibly you used a real pointer instead of a PointerTo at some // point, and the object was deleted when the PointerTo went out of scope. diff --git a/panda/src/speedtree/speedTreeNode.I b/panda/src/speedtree/speedTreeNode.I index 400a26e12b..b095152ee9 100644 --- a/panda/src/speedtree/speedTreeNode.I +++ b/panda/src/speedtree/speedTreeNode.I @@ -47,7 +47,9 @@ get_tree(int n) const { */ INLINE const SpeedTreeNode::InstanceList &SpeedTreeNode:: get_instance_list(int n) const { - nassertr(n >= 0 && n < (int)_trees.size(), *(InstanceList *)NULL); + // TODO: This should be nassertr instead of assert, but there's nothing we + // can really return when the assert fails. + assert(n >= 0 && n < (int)_trees.size()); InstanceList *instance_list = _trees[n]; return *instance_list; } diff --git a/panda/src/speedtree/speedTreeNode.cxx b/panda/src/speedtree/speedTreeNode.cxx index f3b9eb469d..7cee51229b 100644 --- a/panda/src/speedtree/speedTreeNode.cxx +++ b/panda/src/speedtree/speedTreeNode.cxx @@ -145,8 +145,10 @@ count_total_instances() const { */ SpeedTreeNode::InstanceList &SpeedTreeNode:: add_tree(const STTree *tree) { - nassertr(is_valid(), *(InstanceList *)NULL); - nassertr(tree->is_valid(), *(InstanceList *)NULL); + // TODO: These should be nassertr instead of assert, but there's nothing we + // can really return when the assert fails. + assert(is_valid()); + assert(tree->is_valid()); InstanceList ilist(tree); Trees::iterator ti = _trees.find(&ilist); From 92d2f5e195b9b4c21b5cc43d1575c2e9782b089d Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 3 Jun 2018 16:31:01 -0600 Subject: [PATCH 229/247] general: Don't use NULL where not appropriate --- panda/src/dxgsg9/dxTextureContext9.cxx | 2 +- panda/src/express/virtualFileMountSystem.cxx | 4 +-- panda/src/gobj/vertexDataSaveFile.cxx | 2 +- panda/src/movies/microphoneAudioDS.cxx | 4 +-- .../wgldisplay/wglGraphicsStateGuardian.cxx | 4 +-- panda/src/windisplay/winGraphicsWindow.cxx | 32 +++++++++---------- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/panda/src/dxgsg9/dxTextureContext9.cxx b/panda/src/dxgsg9/dxTextureContext9.cxx index c089c26e8a..60f787f298 100644 --- a/panda/src/dxgsg9/dxTextureContext9.cxx +++ b/panda/src/dxgsg9/dxTextureContext9.cxx @@ -1935,7 +1935,7 @@ fill_d3d_texture_pixels(DXScreenData &scrn, bool compress_texture) { scaled *= 255; color = D3DCOLOR_RGBA((int)scaled[0], (int)scaled[1], (int)scaled[2], (int)scaled[3]); flags = D3DCLEAR_TARGET; - if (device -> Clear (NULL, NULL, flags, color, 0.0f, 0) == D3D_OK) { + if (device -> Clear (0, NULL, flags, color, 0.0f, 0) == D3D_OK) { } } diff --git a/panda/src/express/virtualFileMountSystem.cxx b/panda/src/express/virtualFileMountSystem.cxx index ef9c4dcaf5..cc6041b12c 100644 --- a/panda/src/express/virtualFileMountSystem.cxx +++ b/panda/src/express/virtualFileMountSystem.cxx @@ -385,7 +385,7 @@ atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents // First ensure that the file exists to validate its case. if (VirtualFileSystem::get_global_ptr()->vfs_case_sensitive) { if (!has_file(file)) { - return NULL; + return false; } } #endif // WIN32 @@ -402,7 +402,7 @@ atomic_read_contents(const Filename &file, string &contents) const { // First ensure that the file exists to validate its case. if (VirtualFileSystem::get_global_ptr()->vfs_case_sensitive) { if (!has_file(file)) { - return NULL; + return false; } } #endif // WIN32 diff --git a/panda/src/gobj/vertexDataSaveFile.cxx b/panda/src/gobj/vertexDataSaveFile.cxx index e602b51129..7fab0a9110 100644 --- a/panda/src/gobj/vertexDataSaveFile.cxx +++ b/panda/src/gobj/vertexDataSaveFile.cxx @@ -306,7 +306,7 @@ read_data(unsigned char *data, size_t size, VertexDataSaveBlock *block) { << "Error reading " << size << " bytes from save file, windows error code 0x" << hex << error << dec << ".\n"; - return NULL; + return false; } success = GetOverlappedResult(_handle, &overlapped, &bytes_read, false); } diff --git a/panda/src/movies/microphoneAudioDS.cxx b/panda/src/movies/microphoneAudioDS.cxx index 95412fb961..aa32f0c544 100644 --- a/panda/src/movies/microphoneAudioDS.cxx +++ b/panda/src/movies/microphoneAudioDS.cxx @@ -146,7 +146,7 @@ find_all_microphones_ds() { format.nBlockAlign = 2 * chan; format.wBitsPerSample = 16; format.cbSize = 0; - stat = waveInOpen(NULL, i, &format, NULL, NULL, WAVE_FORMAT_QUERY); + stat = waveInOpen(NULL, i, &format, 0, 0, WAVE_FORMAT_QUERY); if (stat == MMSYSERR_NOERROR) { PT(MicrophoneAudioDS) p = new MicrophoneAudioDS(); ostringstream name; @@ -248,7 +248,7 @@ open() { format.cbSize = 0; HWAVEIN hwav; - MMRESULT stat = waveInOpen(&hwav, _device_id, &format, NULL, NULL, CALLBACK_NULL); + MMRESULT stat = waveInOpen(&hwav, _device_id, &format, 0, 0, CALLBACK_NULL); if (stat != MMSYSERR_NOERROR) { delete_buffers(buffers); diff --git a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx index aca8f44577..c957fa7e9e 100644 --- a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx +++ b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx @@ -594,7 +594,7 @@ make_context(HDC hdc) { // what kind of OpenGL context we would like. int attrib_list[32]; int n = 0; - attrib_list[0] = NULL; + attrib_list[0] = 0; if (gl_version.get_num_words() > 0) { attrib_list[n++] = WGL_CONTEXT_MAJOR_VERSION_ARB; @@ -612,7 +612,7 @@ make_context(HDC hdc) { attrib_list[n++] = WGL_CONTEXT_PROFILE_MASK_ARB; attrib_list[n++] = WGL_CONTEXT_CORE_PROFILE_BIT_ARB; #endif - attrib_list[n] = NULL; + attrib_list[n] = 0; _context = _wglCreateContextAttribsARB(hdc, 0, attrib_list); } else { diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index d215d0e1aa..dac15d8c41 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -1870,7 +1870,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { lptstr = (char *) GlobalLock(hglb); if (lptstr != NULL) { char *pChar; - for (pChar=lptstr; *pChar!=NULL; pChar++) { + for (pChar=lptstr; *pChar; pChar++) { _input_devices[0].keystroke((uchar)*pChar); } GlobalUnlock(hglb); @@ -2159,12 +2159,12 @@ update_cursor_window(WinGraphicsWindow *to_window) { // We are leaving a graphics window; we should restore the Win2000 // effects. if (_got_saved_params) { - SystemParametersInfo(SPI_SETMOUSETRAILS, NULL, - (PVOID)_saved_mouse_trails, NULL); - SystemParametersInfo(SPI_SETCURSORSHADOW, NULL, - (PVOID)_saved_cursor_shadow, NULL); - SystemParametersInfo(SPI_SETMOUSEVANISH, NULL, - (PVOID)_saved_mouse_vanish, NULL); + SystemParametersInfo(SPI_SETMOUSETRAILS, 0, + (PVOID)_saved_mouse_trails, 0); + SystemParametersInfo(SPI_SETCURSORSHADOW, 0, + (PVOID)_saved_cursor_shadow, 0); + SystemParametersInfo(SPI_SETMOUSEVANISH, 0, + (PVOID)_saved_mouse_vanish, 0); _got_saved_params = false; } @@ -2178,17 +2178,17 @@ update_cursor_window(WinGraphicsWindow *to_window) { // These parameters are only defined for Win2000XP, but they should just // cause a silent error on earlier OS's, which is OK. if (!_got_saved_params) { - SystemParametersInfo(SPI_GETMOUSETRAILS, NULL, - &_saved_mouse_trails, NULL); - SystemParametersInfo(SPI_GETCURSORSHADOW, NULL, - &_saved_cursor_shadow, NULL); - SystemParametersInfo(SPI_GETMOUSEVANISH, NULL, - &_saved_mouse_vanish, NULL); + SystemParametersInfo(SPI_GETMOUSETRAILS, 0, + &_saved_mouse_trails, 0); + SystemParametersInfo(SPI_GETCURSORSHADOW, 0, + &_saved_cursor_shadow, 0); + SystemParametersInfo(SPI_GETMOUSEVANISH, 0, + &_saved_mouse_vanish, 0); _got_saved_params = true; - SystemParametersInfo(SPI_SETMOUSETRAILS, NULL, (PVOID)0, NULL); - SystemParametersInfo(SPI_SETCURSORSHADOW, NULL, (PVOID)false, NULL); - SystemParametersInfo(SPI_SETMOUSEVANISH, NULL, (PVOID)false, NULL); + SystemParametersInfo(SPI_SETMOUSETRAILS, 0, (PVOID)0, 0); + SystemParametersInfo(SPI_SETCURSORSHADOW, 0, (PVOID)false, 0); + SystemParametersInfo(SPI_SETMOUSEVANISH, 0, (PVOID)false, 0); } SetCursor(to_window->_cursor); From e2b4353800532b6396ffbf8348cf450aca28a2a6 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 28 May 2018 14:10:25 -0600 Subject: [PATCH 230/247] general: Replace NULL (and 0 as pointer) with C++11 nullptr Exceptions to this replacement are: - .c files - Headers included by a .c file - stb_image.h - dr_flac.h - Strings - Comments --- contrib/src/ai/aiBehaviors.cxx | 94 +-- contrib/src/ai/aiNode.cxx | 6 +- contrib/src/ai/aiPathFinder.cxx | 6 +- contrib/src/ai/aiWorld.cxx | 4 +- contrib/src/ai/arrival.cxx | 6 +- contrib/src/ai/meshNode.cxx | 6 +- contrib/src/ai/pathFind.cxx | 30 +- direct/src/dcparse/dcparse.cxx | 4 +- direct/src/dcparser/dcArrayParameter.cxx | 10 +- direct/src/dcparser/dcAtomicField.cxx | 8 +- direct/src/dcparser/dcClass.cxx | 88 +-- direct/src/dcparser/dcClassParameter.cxx | 4 +- direct/src/dcparser/dcDeclaration.cxx | 8 +- direct/src/dcparser/dcField.cxx | 44 +- direct/src/dcparser/dcFile.cxx | 24 +- direct/src/dcparser/dcKeywordList.cxx | 4 +- direct/src/dcparser/dcLexer.lxx | 10 +- direct/src/dcparser/dcMolecularField.cxx | 4 +- direct/src/dcparser/dcPackData.I | 8 +- direct/src/dcparser/dcPackData.cxx | 2 +- direct/src/dcparser/dcPacker.I | 80 +-- direct/src/dcparser/dcPacker.cxx | 148 ++-- direct/src/dcparser/dcPackerCatalog.cxx | 24 +- direct/src/dcparser/dcPackerInterface.cxx | 28 +- direct/src/dcparser/dcPackerInterface.h | 2 +- direct/src/dcparser/dcParameter.cxx | 18 +- direct/src/dcparser/dcParser.yxx | 114 ++-- direct/src/dcparser/dcSimpleParameter.cxx | 12 +- direct/src/dcparser/dcSwitch.cxx | 50 +- direct/src/dcparser/dcSwitchParameter.cxx | 6 +- direct/src/directd/directd.cxx | 6 +- .../src/distributed/cConnectionRepository.cxx | 78 +-- .../cDistributedSmoothNodeBase.cxx | 12 +- direct/src/interval/cIntervalManager.cxx | 22 +- direct/src/interval/cLerpNodePathInterval.cxx | 10 +- direct/src/interval/cMetaInterval.I | 4 +- direct/src/interval/cMetaInterval.cxx | 4 +- direct/src/motiontrail/cMotionTrail.cxx | 14 +- direct/src/plugin/binaryXml.cxx | 38 +- direct/src/plugin/fileSpec.cxx | 26 +- direct/src/plugin/find_root_dir.cxx | 28 +- direct/src/plugin/handleStreamBuf.cxx | 8 +- direct/src/plugin/load_plugin.cxx | 166 ++--- direct/src/plugin/mkdir_complete.cxx | 8 +- direct/src/plugin/p3dAuthSession.cxx | 30 +- direct/src/plugin/p3dCInstance.cxx | 2 +- direct/src/plugin/p3dCert.cxx | 96 +-- direct/src/plugin/p3dCert_wx.cxx | 74 +- direct/src/plugin/p3dConcreteSequence.cxx | 8 +- direct/src/plugin/p3dConcreteStruct.cxx | 10 +- direct/src/plugin/p3dConditionVar.cxx | 6 +- direct/src/plugin/p3dDownload.cxx | 6 +- direct/src/plugin/p3dFileParams.cxx | 6 +- direct/src/plugin/p3dHost.I | 2 +- direct/src/plugin/p3dHost.cxx | 94 +-- direct/src/plugin/p3dInstance.I | 8 +- direct/src/plugin/p3dInstance.cxx | 434 ++++++------ direct/src/plugin/p3dInstanceManager.cxx | 82 +-- direct/src/plugin/p3dMainObject.cxx | 54 +- direct/src/plugin/p3dMultifileReader.cxx | 16 +- direct/src/plugin/p3dObject.cxx | 28 +- direct/src/plugin/p3dOsxSplashWindow.I | 10 +- direct/src/plugin/p3dOsxSplashWindow.cxx | 78 +-- direct/src/plugin/p3dPackage.cxx | 116 ++-- direct/src/plugin/p3dPatchFinder.cxx | 48 +- direct/src/plugin/p3dPythonMain.cxx | 18 +- direct/src/plugin/p3dPythonObject.cxx | 42 +- direct/src/plugin/p3dPythonRun.cxx | 246 +++---- direct/src/plugin/p3dSession.cxx | 102 +-- direct/src/plugin/p3dSplashWindow.cxx | 6 +- direct/src/plugin/p3dWinSplashWindow.I | 2 +- direct/src/plugin/p3dWinSplashWindow.cxx | 92 +-- direct/src/plugin/p3dX11SplashWindow.cxx | 52 +- direct/src/plugin/p3d_lock.h | 10 +- direct/src/plugin/p3d_plugin.cxx | 66 +- direct/src/plugin/p3d_plugin.h | 2 +- direct/src/plugin/p3d_plugin_common.h | 2 +- direct/src/plugin/run_p3dpython.cxx | 2 +- direct/src/plugin/wstring_encode.cxx | 6 +- direct/src/plugin/xml_helpers.cxx | 2 +- direct/src/plugin_activex/PPDownloadRequest.h | 8 +- direct/src/plugin_npapi/npruntime.h | 4 +- direct/src/plugin_npapi/ppBrowserObject.cxx | 20 +- direct/src/plugin_npapi/ppInstance.I | 2 +- direct/src/plugin_npapi/ppInstance.cxx | 250 +++---- direct/src/plugin_npapi/ppPandaObject.I | 2 +- direct/src/plugin_npapi/ppPandaObject.cxx | 34 +- direct/src/plugin_npapi/ppToplevelObject.cxx | 12 +- direct/src/plugin_npapi/startup.cxx | 34 +- direct/src/plugin_standalone/p3dEmbed.cxx | 4 +- direct/src/plugin_standalone/panda3d.cxx | 42 +- direct/src/plugin_standalone/panda3dBase.cxx | 50 +- direct/src/plugin_standalone/panda3dMac.cxx | 4 +- dtool/src/cppparser/cppArrayType.cxx | 20 +- dtool/src/cppparser/cppBison.yxx | 232 +++---- .../cppparser/cppClassTemplateParameter.cxx | 10 +- .../src/cppparser/cppClassTemplateParameter.h | 2 +- dtool/src/cppparser/cppClosureType.cxx | 8 +- dtool/src/cppparser/cppClosureType.h | 2 +- dtool/src/cppparser/cppConstType.cxx | 6 +- dtool/src/cppparser/cppDeclaration.cxx | 60 +- dtool/src/cppparser/cppDeclaration.h | 4 +- dtool/src/cppparser/cppEnumType.cxx | 46 +- dtool/src/cppparser/cppExpression.cxx | 152 ++--- dtool/src/cppparser/cppExpression.h | 6 +- dtool/src/cppparser/cppExpressionParser.cxx | 4 +- dtool/src/cppparser/cppExtensionType.cxx | 24 +- dtool/src/cppparser/cppExtensionType.h | 2 +- dtool/src/cppparser/cppFunctionGroup.cxx | 4 +- dtool/src/cppparser/cppFunctionType.cxx | 34 +- dtool/src/cppparser/cppIdentifier.cxx | 88 +-- dtool/src/cppparser/cppIdentifier.h | 20 +- dtool/src/cppparser/cppInstance.cxx | 90 +-- dtool/src/cppparser/cppInstance.h | 6 +- dtool/src/cppparser/cppInstanceIdentifier.cxx | 26 +- dtool/src/cppparser/cppInstanceIdentifier.h | 4 +- dtool/src/cppparser/cppMakeProperty.cxx | 16 +- dtool/src/cppparser/cppMakeProperty.h | 2 +- dtool/src/cppparser/cppMakeSeq.h | 2 +- dtool/src/cppparser/cppManifest.cxx | 10 +- dtool/src/cppparser/cppNameComponent.cxx | 18 +- dtool/src/cppparser/cppNameComponent.h | 2 +- dtool/src/cppparser/cppNamespace.cxx | 10 +- dtool/src/cppparser/cppNamespace.h | 2 +- dtool/src/cppparser/cppParameterList.cxx | 2 +- dtool/src/cppparser/cppParameterList.h | 2 +- dtool/src/cppparser/cppParser.cxx | 4 +- dtool/src/cppparser/cppPointerType.cxx | 12 +- dtool/src/cppparser/cppPreprocessor.cxx | 80 +-- dtool/src/cppparser/cppReferenceType.cxx | 10 +- dtool/src/cppparser/cppScope.cxx | 190 +++--- dtool/src/cppparser/cppScope.h | 14 +- dtool/src/cppparser/cppSimpleType.cxx | 6 +- dtool/src/cppparser/cppStructType.cxx | 194 +++--- dtool/src/cppparser/cppStructType.h | 2 +- dtool/src/cppparser/cppTBDType.cxx | 10 +- dtool/src/cppparser/cppTBDType.h | 2 +- .../cppparser/cppTemplateParameterList.cxx | 10 +- .../src/cppparser/cppTemplateParameterList.h | 2 +- dtool/src/cppparser/cppTemplateScope.cxx | 24 +- dtool/src/cppparser/cppTemplateScope.h | 8 +- dtool/src/cppparser/cppToken.cxx | 2 +- dtool/src/cppparser/cppType.cxx | 22 +- dtool/src/cppparser/cppType.h | 4 +- dtool/src/cppparser/cppTypeDeclaration.cxx | 10 +- dtool/src/cppparser/cppTypeParser.cxx | 4 +- dtool/src/cppparser/cppTypeProxy.cxx | 70 +- dtool/src/cppparser/cppTypeProxy.h | 4 +- dtool/src/cppparser/cppTypedefType.cxx | 30 +- dtool/src/cppparser/cppTypedefType.h | 6 +- dtool/src/dtoolbase/deletedBufferChain.I | 2 +- dtool/src/dtoolbase/deletedBufferChain.cxx | 6 +- dtool/src/dtoolbase/deletedChain.h | 4 +- dtool/src/dtoolbase/dtoolbase.cxx | 2 +- dtool/src/dtoolbase/memoryHook.cxx | 14 +- dtool/src/dtoolbase/neverFreeMemory.I | 2 +- dtool/src/dtoolbase/neverFreeMemory.cxx | 6 +- dtool/src/dtoolbase/pstrtod.cxx | 6 +- dtool/src/dtoolbase/ptmalloc2_smp_src.cxx | 86 +-- dtool/src/dtoolbase/test_strtod.cxx | 2 +- dtool/src/dtoolbase/typeHandle.cxx | 24 +- dtool/src/dtoolbase/typeHandle.h | 10 +- dtool/src/dtoolbase/typeRegistry.I | 4 +- dtool/src/dtoolbase/typeRegistry.cxx | 70 +- dtool/src/dtoolbase/typeRegistryNode.I | 2 +- dtool/src/dtoolbase/typeRegistryNode.cxx | 6 +- dtool/src/dtoolutil/executionEnvironment.cxx | 52 +- dtool/src/dtoolutil/filename.I | 2 +- dtool/src/dtoolutil/filename.cxx | 84 +-- dtool/src/dtoolutil/filename_ext.cxx | 14 +- dtool/src/dtoolutil/lineStreamBuf.cxx | 4 +- dtool/src/dtoolutil/load_dso.cxx | 8 +- dtool/src/dtoolutil/pandaFileStreamBuf.cxx | 8 +- dtool/src/dtoolutil/pandaSystem.cxx | 4 +- dtool/src/dtoolutil/panda_getopt_impl.cxx | 42 +- dtool/src/dtoolutil/pfstreamBuf.cxx | 20 +- dtool/src/dtoolutil/stringDecoder.cxx | 10 +- dtool/src/dtoolutil/textEncoder.I | 14 +- dtool/src/dtoolutil/textEncoder.cxx | 6 +- dtool/src/dtoolutil/unicodeLatinMap.cxx | 2 +- dtool/src/dtoolutil/win32ArgParser.cxx | 8 +- dtool/src/interrogate/functionRemap.cxx | 42 +- dtool/src/interrogate/interfaceMaker.cxx | 28 +- .../interfaceMakerPythonNative.cxx | 154 ++--- .../interrogate/interfaceMakerPythonObj.cxx | 2 +- dtool/src/interrogate/interrogate.cxx | 64 +- dtool/src/interrogate/interrogateBuilder.cxx | 224 +++--- dtool/src/interrogate/interrogate_module.cxx | 24 +- dtool/src/interrogate/parameterRemap.I | 8 +- .../parameterRemapBasicStringPtrToString.cxx | 8 +- .../parameterRemapBasicStringRefToString.cxx | 8 +- .../parameterRemapBasicStringToString.cxx | 8 +- .../interrogate/parameterRemapPTToPointer.cxx | 8 +- .../interrogate/parameterRemapToString.cxx | 12 +- dtool/src/interrogate/parse_file.cxx | 28 +- dtool/src/interrogate/typeManager.cxx | 78 +-- dtool/src/interrogate/typeManager.h | 2 +- dtool/src/interrogatedb/dtool_super_base.cxx | 78 +-- .../src/interrogatedb/interrogateComponent.I | 12 +- .../src/interrogatedb/interrogateComponent.h | 2 +- .../src/interrogatedb/interrogateDatabase.cxx | 14 +- dtool/src/interrogatedb/interrogateElement.h | 2 +- .../src/interrogatedb/interrogateFunction.cxx | 2 +- dtool/src/interrogatedb/interrogateFunction.h | 2 +- .../interrogateFunctionWrapper.h | 2 +- dtool/src/interrogatedb/interrogateMakeSeq.h | 2 +- dtool/src/interrogatedb/interrogateManifest.h | 2 +- dtool/src/interrogatedb/interrogateType.cxx | 4 +- dtool/src/interrogatedb/interrogateType.h | 2 +- .../interrogatedb/interrogate_datafile.cxx | 2 +- .../interrogatedb/interrogate_interface.cxx | 2 +- dtool/src/interrogatedb/py_panda.I | 18 +- dtool/src/interrogatedb/py_panda.cxx | 122 ++-- dtool/src/interrogatedb/py_panda.h | 2 +- dtool/src/interrogatedb/py_wrappers.cxx | 636 +++++++++--------- dtool/src/prc/androidLogStream.cxx | 4 +- dtool/src/prc/configPage.cxx | 18 +- dtool/src/prc/configPageManager.I | 4 +- dtool/src/prc/configPageManager.cxx | 4 +- dtool/src/prc/configVariable.I | 4 +- dtool/src/prc/configVariableBase.I | 24 +- dtool/src/prc/configVariableBase.cxx | 4 +- dtool/src/prc/configVariableBool.I | 2 +- dtool/src/prc/configVariableCore.I | 8 +- dtool/src/prc/configVariableCore.cxx | 22 +- dtool/src/prc/configVariableDouble.I | 2 +- dtool/src/prc/configVariableEnum.I | 2 +- dtool/src/prc/configVariableFilename.I | 2 +- dtool/src/prc/configVariableFilename.cxx | 2 +- dtool/src/prc/configVariableInt.I | 2 +- dtool/src/prc/configVariableInt64.I | 2 +- dtool/src/prc/configVariableList.I | 14 +- dtool/src/prc/configVariableManager.I | 2 +- dtool/src/prc/configVariableManager.cxx | 16 +- dtool/src/prc/configVariableSearchPath.I | 8 +- dtool/src/prc/configVariableSearchPath.cxx | 2 +- dtool/src/prc/configVariableString.I | 2 +- dtool/src/prc/encryptStreamBuf.cxx | 68 +- dtool/src/prc/notify.cxx | 22 +- dtool/src/prc/notifyCategory.cxx | 16 +- dtool/src/prc/notifyCategoryProxy.I | 4 +- dtool/src/prc/prcKeyRegistry.cxx | 36 +- dtool/src/prc/streamReader_ext.cxx | 4 +- dtool/src/prckeys/makePrcKey.cxx | 14 +- dtool/src/prckeys/signPrcFile_src.cxx | 14 +- dtool/src/pystub/pystub.cxx | 50 +- .../src/test_interrogate/test_interrogate.cxx | 2 +- panda/src/android/config_android.cxx | 2 +- panda/src/android/jni_NativeIStream.cxx | 4 +- .../src/android/pnmFileTypeAndroidReader.cxx | 6 +- panda/src/android/pview.cxx | 2 +- .../androiddisplay/androidGraphicsPipe.cxx | 12 +- .../androidGraphicsStateGuardian.cxx | 10 +- .../androiddisplay/androidGraphicsWindow.cxx | 26 +- panda/src/audio/audioManager.cxx | 32 +- panda/src/audio/audioManager.h | 2 +- panda/src/audiotraits/fmodAudioManager.cxx | 16 +- panda/src/audiotraits/fmodAudioSound.cxx | 8 +- panda/src/audiotraits/globalMilesManager.cxx | 18 +- panda/src/audiotraits/milesAudioManager.cxx | 56 +- panda/src/audiotraits/milesAudioManager.h | 2 +- panda/src/audiotraits/milesAudioSample.cxx | 20 +- panda/src/audiotraits/milesAudioSequence.cxx | 10 +- panda/src/audiotraits/milesAudioSound.cxx | 2 +- panda/src/audiotraits/milesAudioStream.cxx | 14 +- panda/src/audiotraits/openalAudioManager.cxx | 68 +- panda/src/audiotraits/openalAudioSound.I | 4 +- panda/src/audiotraits/openalAudioSound.cxx | 4 +- panda/src/awesomium/WebBrowserTexture.cxx | 2 +- panda/src/awesomium/WebBrowserTexture.h | 2 +- panda/src/bullet/bulletAllHitsRayResult.cxx | 2 +- panda/src/bullet/bulletBodyNode.cxx | 10 +- .../src/bullet/bulletClosestHitRayResult.cxx | 2 +- .../bullet/bulletClosestHitSweepResult.cxx | 2 +- panda/src/bullet/bulletContactCallbacks.h | 2 +- panda/src/bullet/bulletContactResult.cxx | 16 +- panda/src/bullet/bulletConvexHullShape.cxx | 8 +- panda/src/bullet/bulletGhostNode.cxx | 4 +- panda/src/bullet/bulletHelper.I | 4 +- panda/src/bullet/bulletHelper.cxx | 6 +- panda/src/bullet/bulletHelper.h | 4 +- panda/src/bullet/bulletPersistentManifold.cxx | 6 +- panda/src/bullet/bulletPlaneShape.h | 2 +- panda/src/bullet/bulletSoftBodyNode.cxx | 20 +- panda/src/bullet/bulletSoftBodyNode.h | 4 +- panda/src/bullet/bulletSoftBodyShape.cxx | 2 +- panda/src/bullet/bulletSphereShape.h | 2 +- panda/src/bullet/bulletTriangleMesh.cxx | 4 +- panda/src/bullet/bulletTriangleMeshShape.I | 4 +- panda/src/bullet/bulletTriangleMeshShape.cxx | 18 +- panda/src/bullet/bulletVehicle.cxx | 4 +- panda/src/bullet/bulletWheel.cxx | 4 +- panda/src/bullet/bulletWorld.I | 2 +- panda/src/bullet/bulletWorld.cxx | 34 +- panda/src/chan/animBundle.cxx | 4 +- panda/src/chan/animBundleNode.cxx | 8 +- panda/src/chan/animChannelMatrixDynamic.cxx | 22 +- panda/src/chan/animChannelMatrixXfmTable.I | 4 +- panda/src/chan/animChannelMatrixXfmTable.cxx | 2 +- panda/src/chan/animChannelScalarDynamic.cxx | 10 +- panda/src/chan/animChannelScalarTable.I | 4 +- panda/src/chan/animControl.I | 2 +- panda/src/chan/animControl.cxx | 4 +- panda/src/chan/animControlCollection.I | 24 +- panda/src/chan/animControlCollection.cxx | 14 +- panda/src/chan/animGroup.cxx | 16 +- panda/src/chan/auto_bind.cxx | 8 +- panda/src/chan/bindAnimRequest.cxx | 4 +- panda/src/chan/movingPartBase.I | 4 +- panda/src/chan/movingPartBase.cxx | 36 +- panda/src/chan/movingPartMatrix.cxx | 18 +- panda/src/chan/movingPartScalar.cxx | 8 +- panda/src/chan/partBundle.I | 4 +- panda/src/chan/partBundle.cxx | 44 +- panda/src/chan/partBundleNode.I | 4 +- panda/src/chan/partBundleNode.cxx | 2 +- panda/src/chan/partGroup.cxx | 28 +- panda/src/char/character.cxx | 32 +- panda/src/char/characterJoint.cxx | 28 +- panda/src/char/characterJointBundle.cxx | 2 +- panda/src/collada/colladaBindMaterial.cxx | 10 +- panda/src/collada/colladaInput.cxx | 22 +- panda/src/collada/colladaLoader.cxx | 68 +- panda/src/collada/colladaPrimitive.cxx | 20 +- panda/src/collada/load_collada_file.cxx | 8 +- panda/src/collada/load_collada_file.h | 2 +- panda/src/collide/collisionBox.cxx | 46 +- panda/src/collide/collisionEntry.I | 8 +- panda/src/collide/collisionEntry.cxx | 2 +- panda/src/collide/collisionFloorMesh.cxx | 10 +- panda/src/collide/collisionHandlerEvent.cxx | 2 +- panda/src/collide/collisionHandlerFloor.cxx | 10 +- .../collide/collisionHandlerFluidPusher.cxx | 14 +- panda/src/collide/collisionHandlerGravity.cxx | 10 +- .../collide/collisionHandlerHighestEvent.cxx | 6 +- panda/src/collide/collisionHandlerPhysical.I | 2 +- .../src/collide/collisionHandlerPhysical.cxx | 2 +- panda/src/collide/collisionHandlerPhysical.h | 2 +- panda/src/collide/collisionHandlerPusher.cxx | 6 +- panda/src/collide/collisionHandlerQueue.cxx | 4 +- panda/src/collide/collisionInvSphere.cxx | 14 +- panda/src/collide/collisionLevelState.I | 8 +- panda/src/collide/collisionLevelStateBase.I | 12 +- panda/src/collide/collisionLevelStateBase.cxx | 2 +- panda/src/collide/collisionNode.cxx | 12 +- panda/src/collide/collisionPlane.cxx | 32 +- panda/src/collide/collisionPolygon.cxx | 110 +-- panda/src/collide/collisionRecorder.cxx | 4 +- panda/src/collide/collisionSolid.cxx | 78 +-- panda/src/collide/collisionSphere.cxx | 38 +- panda/src/collide/collisionTraverser.I | 4 +- panda/src/collide/collisionTraverser.cxx | 56 +- panda/src/collide/collisionTube.cxx | 26 +- panda/src/collide/collisionVisualizer.cxx | 6 +- panda/src/cull/cullBinBackToFront.cxx | 4 +- panda/src/cull/cullBinFrontToBack.cxx | 4 +- panda/src/cull/cullBinStateSorted.I | 4 +- panda/src/device/analogNode.I | 2 +- panda/src/device/analogNode.cxx | 6 +- panda/src/device/buttonNode.I | 2 +- panda/src/device/buttonNode.cxx | 8 +- panda/src/device/clientBase.cxx | 8 +- panda/src/device/dialNode.I | 2 +- panda/src/device/dialNode.cxx | 4 +- panda/src/device/trackerNode.I | 2 +- panda/src/device/trackerNode.cxx | 8 +- panda/src/dgraph/dataGraphTraverser.cxx | 2 +- panda/src/display/callbackGraphicsWindow.I | 6 +- panda/src/display/callbackGraphicsWindow.cxx | 14 +- panda/src/display/displayInformation.cxx | 8 +- panda/src/display/displayRegion.I | 8 +- panda/src/display/displayRegion.cxx | 44 +- .../display/displayRegionDrawCallbackData.cxx | 2 +- panda/src/display/graphicsEngine.I | 2 +- panda/src/display/graphicsEngine.cxx | 112 +-- panda/src/display/graphicsEngine.h | 6 +- panda/src/display/graphicsOutput.I | 4 +- panda/src/display/graphicsOutput.cxx | 48 +- panda/src/display/graphicsOutput.h | 4 +- panda/src/display/graphicsPipe.cxx | 26 +- panda/src/display/graphicsPipe.h | 2 +- panda/src/display/graphicsPipeSelection.I | 2 +- panda/src/display/graphicsPipeSelection.cxx | 28 +- panda/src/display/graphicsStateGuardian.I | 4 +- panda/src/display/graphicsStateGuardian.cxx | 152 ++--- panda/src/display/graphicsStateGuardian.h | 2 +- .../src/display/graphicsStateGuardian_ext.cxx | 4 +- panda/src/display/graphicsWindow.cxx | 14 +- .../src/display/graphicsWindowInputDevice.cxx | 6 +- panda/src/display/parasiteBuffer.cxx | 10 +- panda/src/display/standardMunger.cxx | 4 +- panda/src/display/subprocessWindow.cxx | 48 +- panda/src/display/subprocessWindowBuffer.cxx | 24 +- panda/src/display/windowHandle.cxx | 8 +- panda/src/display/windowProperties.I | 2 +- panda/src/display/windowProperties.cxx | 16 +- panda/src/display/windowProperties.h | 2 +- panda/src/distort/nonlinearImager.cxx | 46 +- panda/src/distort/projectionScreen.cxx | 28 +- panda/src/downloader/bioPtr.cxx | 24 +- panda/src/downloader/bioStreamBuf.cxx | 6 +- panda/src/downloader/bioStreamPtr.cxx | 4 +- panda/src/downloader/chunkedStream.cxx | 4 +- panda/src/downloader/chunkedStreamBuf.I | 2 +- panda/src/downloader/chunkedStreamBuf.cxx | 8 +- panda/src/downloader/decompressor.cxx | 22 +- panda/src/downloader/downloadDb.cxx | 2 +- panda/src/downloader/extractor.cxx | 12 +- panda/src/downloader/httpChannel.cxx | 104 +-- panda/src/downloader/httpClient.cxx | 62 +- panda/src/downloader/httpDate.I | 2 +- panda/src/downloader/httpDate.cxx | 4 +- .../downloader/httpDigestAuthorization.cxx | 2 +- panda/src/downloader/identityStream.cxx | 4 +- panda/src/downloader/identityStreamBuf.I | 2 +- panda/src/downloader/multiplexStream.I | 8 +- panda/src/downloader/multiplexStreamBuf.cxx | 8 +- panda/src/downloader/multiplexStreamBuf.h | 4 +- panda/src/downloader/patcher.cxx | 2 +- panda/src/downloader/socketStream.I | 2 +- panda/src/downloader/socketStream.cxx | 2 +- panda/src/downloader/stringStream_ext.cxx | 2 +- panda/src/downloader/virtualFileHTTP.cxx | 6 +- panda/src/downloader/virtualFileMountHTTP.cxx | 2 +- panda/src/downloadertools/multify.cxx | 4 +- panda/src/dxgsg9/dxGeomMunger9.I | 4 +- panda/src/dxgsg9/dxGeomMunger9.cxx | 22 +- panda/src/dxgsg9/dxGraphicsDevice9.cxx | 4 +- panda/src/dxgsg9/dxGraphicsStateGuardian9.I | 2 +- panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx | 232 +++---- panda/src/dxgsg9/dxGraphicsStateGuardian9.h | 2 +- panda/src/dxgsg9/dxIndexBufferContext9.cxx | 14 +- panda/src/dxgsg9/dxInput9.cxx | 22 +- panda/src/dxgsg9/dxOcclusionQueryContext9.cxx | 2 +- panda/src/dxgsg9/dxShaderContext9.cxx | 40 +- panda/src/dxgsg9/dxTextureContext9.cxx | 72 +- panda/src/dxgsg9/dxVertexBufferContext9.cxx | 6 +- panda/src/dxgsg9/dxgsg9base.h | 14 +- panda/src/dxgsg9/wdxGraphicsBuffer9.cxx | 38 +- panda/src/dxgsg9/wdxGraphicsPipe9.cxx | 38 +- panda/src/dxgsg9/wdxGraphicsWindow9.cxx | 40 +- panda/src/dxml/config_dxml.cxx | 4 +- panda/src/dxml/tinyxml.cpp | 166 ++--- panda/src/dxml/tinyxmlparser.cpp | 118 ++-- panda/src/egg/eggBinMaker.cxx | 6 +- panda/src/egg/eggCompositePrimitive.cxx | 8 +- panda/src/egg/eggData.cxx | 8 +- panda/src/egg/eggGroup.I | 4 +- panda/src/egg/eggGroup.cxx | 10 +- panda/src/egg/eggGroupNode.cxx | 28 +- panda/src/egg/eggGroupNode_ext.cxx | 4 +- panda/src/egg/eggMaterialCollection.cxx | 2 +- panda/src/egg/eggMesher.cxx | 14 +- panda/src/egg/eggMesherEdge.I | 2 +- panda/src/egg/eggMesherEdge.cxx | 2 +- panda/src/egg/eggMesherFanMaker.cxx | 10 +- panda/src/egg/eggMesherStrip.cxx | 26 +- panda/src/egg/eggNameUniquifier.cxx | 6 +- panda/src/egg/eggNameUniquifier.h | 2 +- panda/src/egg/eggNode.I | 16 +- panda/src/egg/eggNode.cxx | 48 +- panda/src/egg/eggObject.cxx | 4 +- panda/src/egg/eggPolygon.cxx | 2 +- panda/src/egg/eggPrimitive.I | 14 +- panda/src/egg/eggPrimitive.cxx | 36 +- panda/src/egg/eggTextureCollection.cxx | 6 +- panda/src/egg/eggTransform.I | 64 +- panda/src/egg/eggUtilities.I | 2 +- panda/src/egg/eggVertex.cxx | 32 +- panda/src/egg/eggVertexAux.cxx | 2 +- panda/src/egg/eggVertexPool.I | 2 +- panda/src/egg/eggVertexPool.cxx | 22 +- panda/src/egg/eggVertexUV.cxx | 2 +- panda/src/egg/eggXfmSAnim.cxx | 16 +- panda/src/egg/lexer.lxx | 12 +- panda/src/egg/parser.yxx | 22 +- panda/src/egg2pg/animBundleMaker.cxx | 8 +- panda/src/egg2pg/characterMaker.cxx | 74 +- panda/src/egg2pg/eggLoader.cxx | 104 +-- panda/src/egg2pg/eggRenderState.cxx | 36 +- panda/src/egg2pg/eggSaver.cxx | 38 +- panda/src/egg2pg/eggSaver.h | 4 +- panda/src/egg2pg/egg_parametrics.cxx | 12 +- panda/src/egg2pg/load_egg_file.cxx | 16 +- panda/src/egg2pg/load_egg_file.h | 2 +- panda/src/egldisplay/eglGraphicsBuffer.cxx | 8 +- panda/src/egldisplay/eglGraphicsPipe.cxx | 22 +- panda/src/egldisplay/eglGraphicsPixmap.cxx | 14 +- .../egldisplay/eglGraphicsStateGuardian.cxx | 12 +- panda/src/egldisplay/eglGraphicsWindow.cxx | 22 +- panda/src/event/asyncTask.cxx | 32 +- panda/src/event/asyncTaskChain.cxx | 22 +- panda/src/event/asyncTaskCollection.cxx | 4 +- panda/src/event/asyncTaskManager.I | 2 +- panda/src/event/asyncTaskManager.cxx | 16 +- panda/src/event/asyncTaskSequence.cxx | 22 +- panda/src/event/event.cxx | 4 +- panda/src/event/event.h | 2 +- panda/src/event/eventHandler.cxx | 4 +- panda/src/event/eventHandler.h | 2 +- panda/src/event/eventParameter.I | 4 +- panda/src/event/eventParameter.cxx | 2 +- panda/src/event/eventQueue.I | 2 +- panda/src/event/eventQueue.cxx | 2 +- panda/src/event/genericAsyncTask.cxx | 20 +- panda/src/event/pythonTask.cxx | 24 +- panda/src/express/compress_string.cxx | 8 +- panda/src/express/config_express.cxx | 12 +- panda/src/express/datagram.I | 6 +- panda/src/express/datagram.cxx | 4 +- panda/src/express/datagramGenerator.cxx | 6 +- panda/src/express/datagramIterator.I | 44 +- panda/src/express/datagramIterator.cxx | 14 +- panda/src/express/datagramSink.cxx | 4 +- panda/src/express/dcast.cxx | 2 +- panda/src/express/dcast.h | 4 +- panda/src/express/encrypt_string.cxx | 8 +- panda/src/express/hashVal.cxx | 2 +- panda/src/express/make_ca_bundle.cxx | 6 +- panda/src/express/memoryInfo.I | 6 +- panda/src/express/memoryInfo.cxx | 10 +- panda/src/express/memoryUsage.cxx | 36 +- panda/src/express/memoryUsagePointers_ext.cxx | 6 +- panda/src/express/multifile.I | 8 +- panda/src/express/multifile.cxx | 152 ++--- panda/src/express/nodePointerTo.h | 4 +- panda/src/express/nodePointerToBase.I | 16 +- panda/src/express/openSSLWrapper.cxx | 10 +- panda/src/express/patchfile.cxx | 66 +- panda/src/express/pointerToArray.I | 108 +-- panda/src/express/pointerToArrayBase.cxx | 2 +- panda/src/express/pointerToArray_ext.I | 64 +- panda/src/express/pointerToArray_ext.h | 2 +- panda/src/express/pointerToBase.I | 18 +- panda/src/express/profileTimer.cxx | 2 +- panda/src/express/ramfile_ext.cxx | 4 +- panda/src/express/referenceCount.I | 8 +- panda/src/express/referenceCount.cxx | 4 +- panda/src/express/subStream.I | 4 +- panda/src/express/subStreamBuf.cxx | 14 +- panda/src/express/subfileInfo.I | 4 +- panda/src/express/threadSafePointerTo.h | 4 +- panda/src/express/threadSafePointerToBase.I | 10 +- panda/src/express/trueClock.I | 2 +- panda/src/express/trueClock.cxx | 8 +- panda/src/express/virtualFile.cxx | 16 +- panda/src/express/virtualFileList.I | 4 +- panda/src/express/virtualFileMount.I | 2 +- panda/src/express/virtualFileMount.cxx | 18 +- .../express/virtualFileMountAndroidAsset.cxx | 12 +- .../src/express/virtualFileMountMultifile.cxx | 2 +- panda/src/express/virtualFileMountRamdisk.I | 2 +- panda/src/express/virtualFileMountRamdisk.cxx | 82 +-- panda/src/express/virtualFileMountSystem.cxx | 20 +- panda/src/express/virtualFileSystem.I | 20 +- panda/src/express/virtualFileSystem.cxx | 110 +-- panda/src/express/virtualFileSystem_ext.cxx | 4 +- panda/src/express/virtualFile_ext.cxx | 4 +- panda/src/express/weakPointerTo.h | 4 +- panda/src/express/weakPointerToBase.I | 2 +- panda/src/express/windowsRegistry.cxx | 10 +- panda/src/express/zStreamBuf.cxx | 18 +- panda/src/ffmpeg/ffmpegAudio.cxx | 4 +- panda/src/ffmpeg/ffmpegAudioCursor.cxx | 54 +- panda/src/ffmpeg/ffmpegVideo.cxx | 4 +- panda/src/ffmpeg/ffmpegVideoCursor.cxx | 96 +-- panda/src/ffmpeg/ffmpegVirtualFile.I | 2 +- panda/src/ffmpeg/ffmpegVirtualFile.cxx | 30 +- panda/src/framework/pandaFramework.I | 4 +- panda/src/framework/pandaFramework.cxx | 54 +- panda/src/framework/pandaFramework.h | 6 +- panda/src/framework/windowFramework.I | 6 +- panda/src/framework/windowFramework.cxx | 78 +-- panda/src/framework/windowFramework.h | 2 +- panda/src/glstuff/glCgShaderContext_src.cxx | 10 +- panda/src/glstuff/glGeomContext_src.cxx | 4 +- panda/src/glstuff/glGeomMunger_src.cxx | 26 +- panda/src/glstuff/glGraphicsBuffer_src.cxx | 34 +- .../glstuff/glGraphicsStateGuardian_src.cxx | 396 +++++------ .../src/glstuff/glImmediateModeSender_src.cxx | 24 +- panda/src/glstuff/glShaderContext_src.cxx | 98 +-- panda/src/glxdisplay/glxGraphicsBuffer.cxx | 12 +- panda/src/glxdisplay/glxGraphicsPipe.cxx | 44 +- panda/src/glxdisplay/glxGraphicsPixmap.cxx | 18 +- .../glxdisplay/glxGraphicsStateGuardian.cxx | 136 ++-- panda/src/glxdisplay/glxGraphicsWindow.cxx | 18 +- .../glxdisplay/posixGraphicsStateGuardian.cxx | 18 +- panda/src/gobj/adaptiveLru.I | 6 +- panda/src/gobj/adaptiveLru.cxx | 28 +- panda/src/gobj/bufferContext.I | 6 +- panda/src/gobj/bufferContext.cxx | 8 +- panda/src/gobj/bufferContextChain.cxx | 2 +- panda/src/gobj/bufferResidencyTracker.cxx | 2 +- panda/src/gobj/geom.I | 28 +- panda/src/gobj/geom.cxx | 14 +- panda/src/gobj/geomCacheEntry.I | 12 +- panda/src/gobj/geomCacheEntry.cxx | 6 +- panda/src/gobj/geomCacheManager.cxx | 4 +- panda/src/gobj/geomLines.cxx | 4 +- panda/src/gobj/geomLinestrips.cxx | 6 +- panda/src/gobj/geomMunger.I | 2 +- panda/src/gobj/geomMunger.cxx | 28 +- panda/src/gobj/geomPrimitive.I | 14 +- panda/src/gobj/geomPrimitive.cxx | 34 +- panda/src/gobj/geomTriangles.cxx | 6 +- panda/src/gobj/geomTrifans.cxx | 6 +- panda/src/gobj/geomTristrips.cxx | 16 +- panda/src/gobj/geomVertexArrayData.I | 6 +- panda/src/gobj/geomVertexArrayData.cxx | 24 +- panda/src/gobj/geomVertexArrayData_ext.cxx | 24 +- panda/src/gobj/geomVertexArrayFormat.I | 6 +- panda/src/gobj/geomVertexArrayFormat.cxx | 12 +- panda/src/gobj/geomVertexColumn.I | 6 +- panda/src/gobj/geomVertexColumn.cxx | 2 +- panda/src/gobj/geomVertexData.I | 28 +- panda/src/gobj/geomVertexData.cxx | 66 +- panda/src/gobj/geomVertexFormat.I | 36 +- panda/src/gobj/geomVertexFormat.cxx | 44 +- panda/src/gobj/geomVertexReader.I | 22 +- panda/src/gobj/geomVertexReader.cxx | 36 +- panda/src/gobj/geomVertexRewriter.I | 8 +- panda/src/gobj/geomVertexRewriter.cxx | 2 +- panda/src/gobj/geomVertexWriter.I | 20 +- panda/src/gobj/geomVertexWriter.cxx | 42 +- panda/src/gobj/internalName.I | 40 +- panda/src/gobj/internalName.cxx | 18 +- panda/src/gobj/internalName.h | 2 +- panda/src/gobj/internalName_ext.cxx | 4 +- panda/src/gobj/lens.cxx | 16 +- panda/src/gobj/materialPool.cxx | 4 +- panda/src/gobj/paramTexture.cxx | 4 +- panda/src/gobj/preparedGraphicsObjects.cxx | 42 +- panda/src/gobj/shader.I | 2 +- panda/src/gobj/shader.cxx | 134 ++-- panda/src/gobj/shader.h | 2 +- panda/src/gobj/shaderBuffer.I | 2 +- panda/src/gobj/shaderBuffer.cxx | 12 +- panda/src/gobj/simpleAllocator.I | 22 +- panda/src/gobj/simpleAllocator.cxx | 14 +- panda/src/gobj/simpleLru.I | 12 +- panda/src/gobj/simpleLru.cxx | 14 +- panda/src/gobj/sliderTable.I | 2 +- panda/src/gobj/texture.I | 2 +- panda/src/gobj/texture.cxx | 116 ++-- panda/src/gobj/texture.h | 4 +- panda/src/gobj/textureCollection.cxx | 6 +- panda/src/gobj/textureCollection_ext.cxx | 10 +- panda/src/gobj/texturePool.I | 2 +- panda/src/gobj/texturePool.cxx | 92 +-- panda/src/gobj/texturePoolFilter.cxx | 2 +- panda/src/gobj/textureReloadRequest.I | 4 +- panda/src/gobj/textureStage.I | 6 +- panda/src/gobj/textureStagePool.cxx | 6 +- panda/src/gobj/transformBlend.I | 2 +- panda/src/gobj/transformTable.I | 2 +- panda/src/gobj/transformTable.cxx | 2 +- panda/src/gobj/vertexDataBlock.I | 6 +- panda/src/gobj/vertexDataBook.cxx | 2 +- panda/src/gobj/vertexDataBuffer.I | 18 +- panda/src/gobj/vertexDataBuffer.cxx | 42 +- panda/src/gobj/vertexDataPage.I | 12 +- panda/src/gobj/vertexDataPage.cxx | 42 +- panda/src/gobj/vertexDataPage.h | 2 +- panda/src/gobj/vertexDataSaveFile.cxx | 18 +- panda/src/grutil/cardMaker.I | 2 +- panda/src/grutil/cardMaker.cxx | 4 +- panda/src/grutil/frameRateMeter.cxx | 10 +- panda/src/grutil/geoMipTerrain.cxx | 4 +- panda/src/grutil/geoMipTerrain.h | 4 +- panda/src/grutil/heightfieldTesselator.cxx | 16 +- panda/src/grutil/heightfieldTesselator.h | 2 +- panda/src/grutil/lineSegs.I | 2 +- panda/src/grutil/lineSegs.cxx | 8 +- panda/src/grutil/meshDrawer.I | 20 +- panda/src/grutil/meshDrawer.cxx | 20 +- panda/src/grutil/meshDrawer2D.I | 14 +- panda/src/grutil/meshDrawer2D.cxx | 12 +- panda/src/grutil/movieTexture.I | 4 +- panda/src/grutil/movieTexture.cxx | 42 +- panda/src/grutil/multitexReducer.cxx | 28 +- panda/src/grutil/nodeVertexTransform.cxx | 4 +- panda/src/grutil/nodeVertexTransform.h | 2 +- panda/src/grutil/pfmVizzer.I | 10 +- panda/src/grutil/pfmVizzer.cxx | 30 +- panda/src/grutil/pfmVizzer.h | 10 +- .../src/grutil/pipeOcclusionCullTraverser.cxx | 34 +- panda/src/grutil/rigidBodyCombiner.cxx | 6 +- panda/src/grutil/sceneGraphAnalyzerMeter.cxx | 6 +- panda/src/grutil/shaderTerrainMesh.I | 4 +- panda/src/grutil/shaderTerrainMesh.cxx | 20 +- .../src/gsgbase/graphicsStateGuardianBase.cxx | 26 +- panda/src/linmath/configVariableColor.I | 2 +- panda/src/linmath/lmatrix3_ext_src.I | 4 +- panda/src/linmath/lmatrix4_ext_src.I | 4 +- panda/src/linmath/lvecBase2_ext_src.I | 10 +- panda/src/linmath/lvecBase3_ext_src.I | 10 +- panda/src/linmath/lvecBase4_ext_src.I | 10 +- panda/src/mathutil/boundingSphere.cxx | 12 +- panda/src/mathutil/boundingVolume.cxx | 16 +- panda/src/mathutil/fftCompressor.cxx | 36 +- .../src/mathutil/intersectionBoundingVolume.I | 2 +- panda/src/mathutil/randomizer.I | 2 +- panda/src/mathutil/unionBoundingVolume.I | 2 +- panda/src/mathutil/unionBoundingVolume.cxx | 2 +- panda/src/movies/flacAudio.cxx | 8 +- panda/src/movies/flacAudioCursor.cxx | 12 +- panda/src/movies/microphoneAudio.cxx | 2 +- panda/src/movies/microphoneAudioDS.cxx | 10 +- panda/src/movies/movieTypeRegistry.I | 2 +- panda/src/movies/movieTypeRegistry.cxx | 8 +- panda/src/movies/movieVideo.cxx | 2 +- panda/src/movies/movieVideoCursor.cxx | 10 +- panda/src/movies/movieVideoCursor.h | 2 +- panda/src/movies/userDataAudio.cxx | 4 +- panda/src/movies/userDataAudioCursor.cxx | 2 +- panda/src/movies/vorbisAudio.cxx | 8 +- panda/src/movies/vorbisAudioCursor.cxx | 14 +- panda/src/movies/wavAudio.cxx | 8 +- panda/src/movies/wavAudioCursor.cxx | 4 +- panda/src/nativenet/membuffer.I | 8 +- panda/src/nativenet/socket_address.cxx | 12 +- panda/src/nativenet/socket_fdset.h | 14 +- panda/src/nativenet/socket_tcp_ssl.h | 20 +- panda/src/nativenet/time_accumulator.h | 18 +- panda/src/nativenet/time_clock.h | 16 +- panda/src/net/config_net.cxx | 20 +- panda/src/net/connection.cxx | 8 +- panda/src/net/connectionListener.cxx | 2 +- panda/src/net/connectionManager.cxx | 20 +- panda/src/net/connectionReader.cxx | 30 +- panda/src/net/connectionWriter.cxx | 8 +- panda/src/net/datagramSinkNet.cxx | 6 +- panda/src/ode/odeAMotorJoint.cxx | 2 +- panda/src/ode/odeBallJoint.cxx | 2 +- panda/src/ode/odeBody.cxx | 6 +- panda/src/ode/odeBoxGeom.cxx | 2 +- panda/src/ode/odeCappedCylinderGeom.cxx | 2 +- panda/src/ode/odeContactJoint.cxx | 2 +- panda/src/ode/odeConvexGeom.cxx | 2 +- panda/src/ode/odeCylinderGeom.cxx | 2 +- panda/src/ode/odeFixedJoint.cxx | 2 +- panda/src/ode/odeGeom.I | 2 +- panda/src/ode/odeGeom.cxx | 50 +- panda/src/ode/odeHashSpace.cxx | 2 +- panda/src/ode/odeHinge2Joint.cxx | 2 +- panda/src/ode/odeHingeJoint.cxx | 2 +- panda/src/ode/odeJoint.I | 4 +- panda/src/ode/odeJoint.cxx | 66 +- panda/src/ode/odeLMotorJoint.cxx | 2 +- panda/src/ode/odeNullJoint.cxx | 2 +- panda/src/ode/odePlane2dJoint.cxx | 2 +- panda/src/ode/odePlaneGeom.cxx | 4 +- panda/src/ode/odeQuadTreeSpace.cxx | 2 +- panda/src/ode/odeRayGeom.cxx | 2 +- panda/src/ode/odeSimpleSpace.cxx | 2 +- panda/src/ode/odeSliderJoint.cxx | 2 +- panda/src/ode/odeSpace.cxx | 26 +- panda/src/ode/odeSpace_ext.cxx | 8 +- panda/src/ode/odeSphereGeom.cxx | 2 +- panda/src/ode/odeTriMeshData.I | 2 +- panda/src/ode/odeTriMeshData.cxx | 28 +- panda/src/ode/odeTriMeshGeom.I | 2 +- panda/src/ode/odeTriMeshGeom.cxx | 6 +- panda/src/ode/odeUniversalJoint.cxx | 2 +- panda/src/ode/odeUtil_ext.cxx | 6 +- panda/src/ode/odeWorld.cxx | 2 +- panda/src/osxdisplay/osxGraphicsBuffer.cxx | 20 +- panda/src/osxdisplay/osxGraphicsPipe.cxx | 54 +- .../osxdisplay/osxGraphicsStateGuardian.cxx | 30 +- panda/src/parametrics/curveFitter.cxx | 6 +- panda/src/parametrics/nurbsCurveInterface.cxx | 2 +- panda/src/parametrics/parametricCurve.cxx | 4 +- .../parametrics/parametricCurveCollection.I | 2 +- .../parametrics/parametricCurveCollection.cxx | 50 +- panda/src/parametrics/piecewiseCurve.cxx | 6 +- panda/src/parametrics/ropeNode.cxx | 12 +- panda/src/parametrics/sheetNode.cxx | 10 +- .../colorInterpolationManager.I | 2 +- .../src/particlesystem/geomParticleRenderer.I | 2 +- .../particlesystem/geomParticleRenderer.cxx | 14 +- .../src/particlesystem/geomParticleRenderer.h | 2 +- .../particlesystem/spriteParticleRenderer.I | 14 +- .../particlesystem/spriteParticleRenderer.cxx | 4 +- .../particlesystem/spriteParticleRenderer.h | 2 +- panda/src/pgraph/accumulatedAttribs.cxx | 80 +-- panda/src/pgraph/attribNodeRegistry.I | 2 +- panda/src/pgraph/attribNodeRegistry.cxx | 6 +- panda/src/pgraph/audioVolumeAttrib.cxx | 2 +- panda/src/pgraph/auxBitplaneAttrib.cxx | 2 +- panda/src/pgraph/bamFile.I | 4 +- panda/src/pgraph/bamFile.cxx | 38 +- panda/src/pgraph/camera.cxx | 4 +- panda/src/pgraph/clipPlaneAttrib.cxx | 14 +- panda/src/pgraph/colorAttrib.cxx | 4 +- panda/src/pgraph/colorScaleAttrib.cxx | 2 +- panda/src/pgraph/cullBin.cxx | 2 +- panda/src/pgraph/cullBinManager.I | 2 +- panda/src/pgraph/cullBinManager.cxx | 10 +- panda/src/pgraph/cullPlanes.cxx | 22 +- panda/src/pgraph/cullResult.I | 2 +- panda/src/pgraph/cullResult.cxx | 50 +- panda/src/pgraph/cullTraverser.I | 2 +- panda/src/pgraph/cullTraverser.cxx | 28 +- panda/src/pgraph/cullTraverserData.I | 6 +- panda/src/pgraph/cullTraverserData.cxx | 24 +- panda/src/pgraph/cullableObject.I | 4 +- panda/src/pgraph/cullableObject.cxx | 18 +- panda/src/pgraph/depthOffsetAttrib.cxx | 4 +- panda/src/pgraph/findApproxLevelEntry.I | 4 +- panda/src/pgraph/findApproxLevelEntry.cxx | 4 +- panda/src/pgraph/fogAttrib.I | 2 +- panda/src/pgraph/fogAttrib.cxx | 2 +- panda/src/pgraph/geomNode.I | 14 +- panda/src/pgraph/geomNode.cxx | 20 +- panda/src/pgraph/geomTransformer.cxx | 46 +- panda/src/pgraph/internalNameCollection.cxx | 4 +- panda/src/pgraph/lensNode.I | 4 +- panda/src/pgraph/lensNode.cxx | 24 +- panda/src/pgraph/lensNode.h | 2 +- panda/src/pgraph/lightAttrib.cxx | 12 +- panda/src/pgraph/lightRampAttrib.cxx | 2 +- panda/src/pgraph/loader.I | 6 +- panda/src/pgraph/loader.cxx | 36 +- panda/src/pgraph/loaderFileType.cxx | 2 +- panda/src/pgraph/loaderFileTypeBam.cxx | 6 +- panda/src/pgraph/loaderFileTypeRegistry.cxx | 10 +- panda/src/pgraph/materialCollection.cxx | 6 +- panda/src/pgraph/modelPool.I | 2 +- panda/src/pgraph/modelPool.cxx | 18 +- panda/src/pgraph/nodePath.I | 22 +- panda/src/pgraph/nodePath.cxx | 402 +++++------ panda/src/pgraph/nodePath.h | 2 +- panda/src/pgraph/nodePathCollection.cxx | 2 +- panda/src/pgraph/nodePathCollection_ext.cxx | 12 +- panda/src/pgraph/nodePathComponent.I | 4 +- panda/src/pgraph/nodePathComponent.cxx | 12 +- panda/src/pgraph/nodePath_ext.cxx | 34 +- panda/src/pgraph/occluderEffect.cxx | 2 +- panda/src/pgraph/occluderNode.cxx | 12 +- panda/src/pgraph/pandaNode.I | 48 +- panda/src/pgraph/pandaNode.cxx | 76 +-- panda/src/pgraph/pandaNodeChain.I | 4 +- panda/src/pgraph/pandaNode_ext.cxx | 22 +- panda/src/pgraph/paramNodePath.cxx | 2 +- panda/src/pgraph/planeNode.I | 8 +- panda/src/pgraph/planeNode.cxx | 6 +- panda/src/pgraph/polylightNode.I | 2 +- panda/src/pgraph/portalClipper.cxx | 6 +- panda/src/pgraph/portalNode.cxx | 8 +- panda/src/pgraph/renderAttrib.cxx | 14 +- panda/src/pgraph/renderAttribRegistry.I | 2 +- panda/src/pgraph/renderAttribRegistry.cxx | 4 +- panda/src/pgraph/renderEffect.cxx | 8 +- panda/src/pgraph/renderEffects.I | 2 +- panda/src/pgraph/renderEffects.cxx | 20 +- panda/src/pgraph/renderState.I | 12 +- panda/src/pgraph/renderState.cxx | 122 ++-- panda/src/pgraph/renderState_ext.cxx | 10 +- panda/src/pgraph/sceneGraphReducer.I | 14 +- panda/src/pgraph/sceneGraphReducer.cxx | 18 +- panda/src/pgraph/sceneGraphReducer.h | 2 +- panda/src/pgraph/sceneSetup.I | 4 +- panda/src/pgraph/scissorAttrib.cxx | 2 +- panda/src/pgraph/scissorEffect.cxx | 16 +- panda/src/pgraph/shaderAttrib.I | 2 +- panda/src/pgraph/shaderAttrib.cxx | 30 +- panda/src/pgraph/shaderAttrib.h | 4 +- panda/src/pgraph/shaderInput.cxx | 2 +- panda/src/pgraph/shaderPool.I | 2 +- panda/src/pgraph/shaderPool.cxx | 8 +- panda/src/pgraph/texGenAttrib.cxx | 2 +- panda/src/pgraph/texMatrixAttrib.cxx | 6 +- panda/src/pgraph/texProjectorEffect.I | 2 +- panda/src/pgraph/texProjectorEffect.cxx | 12 +- panda/src/pgraph/textureAttrib.I | 10 +- panda/src/pgraph/textureAttrib.cxx | 16 +- panda/src/pgraph/textureStageCollection.cxx | 6 +- panda/src/pgraph/transformState.cxx | 86 +-- panda/src/pgraph/transformState_ext.cxx | 12 +- panda/src/pgraph/weakNodePath.I | 4 +- panda/src/pgraph/workingNodePath.I | 12 +- panda/src/pgraph/workingNodePath.cxx | 24 +- panda/src/pgraphnodes/callbackNode.I | 4 +- panda/src/pgraphnodes/callbackNode.cxx | 6 +- panda/src/pgraphnodes/computeNode.cxx | 2 +- panda/src/pgraphnodes/fadeLodNode.cxx | 20 +- panda/src/pgraphnodes/lightLensNode.I | 2 +- panda/src/pgraphnodes/lodNode.cxx | 6 +- .../src/pgraphnodes/nodeCullCallbackData.cxx | 4 +- panda/src/pgraphnodes/sceneGraphAnalyzer.cxx | 12 +- panda/src/pgraphnodes/shaderGenerator.cxx | 20 +- panda/src/pgraphnodes/spotlight.cxx | 6 +- panda/src/pgui/pgEntry.I | 6 +- panda/src/pgui/pgEntry.cxx | 14 +- panda/src/pgui/pgFrameStyle.cxx | 2 +- panda/src/pgui/pgItem.I | 6 +- panda/src/pgui/pgItem.cxx | 28 +- panda/src/pgui/pgItemNotify.cxx | 2 +- panda/src/pgui/pgMouseWatcherGroup.I | 2 +- panda/src/pgui/pgMouseWatcherGroup.cxx | 6 +- panda/src/pgui/pgMouseWatcherRegion.cxx | 18 +- panda/src/pgui/pgScrollFrame.I | 16 +- panda/src/pgui/pgScrollFrame.cxx | 30 +- panda/src/pgui/pgSliderBar.I | 26 +- panda/src/pgui/pgSliderBar.cxx | 58 +- panda/src/pgui/pgTop.I | 2 +- panda/src/pgui/pgTop.cxx | 16 +- panda/src/pgui/test_pgentry.cxx | 2 +- panda/src/physics/angularEulerIntegrator.cxx | 2 +- panda/src/physics/baseForce.cxx | 4 +- panda/src/physics/forceNode.I | 2 +- panda/src/physics/forceNode.cxx | 2 +- panda/src/physics/linearControlForce.I | 2 +- panda/src/physics/linearControlForce.cxx | 2 +- panda/src/physics/linearEulerIntegrator.cxx | 2 +- panda/src/physics/linearIntegrator.cxx | 2 +- panda/src/physics/linearUserDefinedForce.h | 2 +- panda/src/physics/physical.I | 4 +- panda/src/physics/physical.cxx | 6 +- panda/src/physics/physicalNode.I | 2 +- panda/src/physics/physicalNode.cxx | 2 +- panda/src/physics/physicsManager.I | 2 +- panda/src/physics/physicsManager.cxx | 4 +- panda/src/physx/physxActor.cxx | 24 +- panda/src/physx/physxBoxForceFieldShape.cxx | 2 +- panda/src/physx/physxBoxShape.cxx | 2 +- .../src/physx/physxCapsuleForceFieldShape.cxx | 2 +- panda/src/physx/physxCapsuleShape.cxx | 2 +- panda/src/physx/physxCcdSkeleton.cxx | 2 +- panda/src/physx/physxCcdSkeletonDesc.I | 8 +- panda/src/physx/physxCloth.cxx | 16 +- panda/src/physx/physxClothMesh.cxx | 2 +- panda/src/physx/physxClothMeshDesc.I | 10 +- panda/src/physx/physxClothNode.I | 2 +- panda/src/physx/physxContactPair.cxx | 8 +- panda/src/physx/physxController.cxx | 4 +- panda/src/physx/physxControllerReport.cxx | 4 +- panda/src/physx/physxControllerShapeHit.I | 4 +- panda/src/physx/physxControllersHit.I | 4 +- .../src/physx/physxConvexForceFieldShape.cxx | 2 +- panda/src/physx/physxConvexMesh.cxx | 2 +- panda/src/physx/physxConvexMeshDesc.I | 4 +- panda/src/physx/physxConvexShape.cxx | 2 +- panda/src/physx/physxCylindricalJoint.cxx | 2 +- panda/src/physx/physxD6Joint.cxx | 2 +- panda/src/physx/physxDistanceJoint.cxx | 2 +- panda/src/physx/physxFileStream.cxx | 2 +- panda/src/physx/physxFixedJoint.cxx | 2 +- panda/src/physx/physxForceField.cxx | 12 +- panda/src/physx/physxForceFieldShape.cxx | 10 +- panda/src/physx/physxForceFieldShapeGroup.cxx | 24 +- panda/src/physx/physxHeightField.cxx | 2 +- panda/src/physx/physxHeightFieldDesc.I | 4 +- panda/src/physx/physxHeightFieldShape.cxx | 2 +- panda/src/physx/physxJoint.cxx | 8 +- panda/src/physx/physxJointDesc.cxx | 6 +- panda/src/physx/physxKitchen.cxx | 40 +- panda/src/physx/physxManager.cxx | 44 +- panda/src/physx/physxMaterial.cxx | 6 +- panda/src/physx/physxMemoryWriteBuffer.cxx | 2 +- panda/src/physx/physxMeshPool.cxx | 32 +- panda/src/physx/physxObjectCollection.I | 4 +- panda/src/physx/physxOverlapReport.cxx | 4 +- panda/src/physx/physxPlaneShape.cxx | 2 +- panda/src/physx/physxPointInPlaneJoint.cxx | 2 +- panda/src/physx/physxPointOnLineJoint.cxx | 2 +- panda/src/physx/physxPrismaticJoint.cxx | 2 +- panda/src/physx/physxPulleyJoint.cxx | 2 +- panda/src/physx/physxRaycastHit.cxx | 4 +- panda/src/physx/physxRaycastReport.cxx | 4 +- panda/src/physx/physxRevoluteJoint.cxx | 6 +- panda/src/physx/physxScene.I | 2 +- panda/src/physx/physxScene.cxx | 152 ++--- panda/src/physx/physxScene.h | 12 +- panda/src/physx/physxShape.cxx | 6 +- panda/src/physx/physxSoftBody.cxx | 12 +- panda/src/physx/physxSoftBodyMesh.cxx | 2 +- panda/src/physx/physxSoftBodyMeshDesc.I | 8 +- .../src/physx/physxSphereForceFieldShape.cxx | 2 +- panda/src/physx/physxSphereShape.cxx | 2 +- panda/src/physx/physxSphericalJoint.cxx | 2 +- panda/src/physx/physxTriangleMesh.cxx | 2 +- panda/src/physx/physxTriangleMeshDesc.I | 12 +- panda/src/physx/physxTriangleMeshShape.cxx | 2 +- panda/src/physx/physxUtilLib.I | 2 +- panda/src/physx/physxWheelShape.cxx | 2 +- panda/src/pipeline/conditionVarDebug.cxx | 12 +- panda/src/pipeline/conditionVarFullDebug.cxx | 12 +- .../src/pipeline/conditionVarFullWin32Impl.I | 4 +- panda/src/pipeline/conditionVarPosixImpl.I | 2 +- panda/src/pipeline/conditionVarPosixImpl.cxx | 2 +- panda/src/pipeline/conditionVarWin32Impl.I | 2 +- panda/src/pipeline/cycleDataLockedReader.I | 24 +- .../src/pipeline/cycleDataLockedStageReader.I | 24 +- panda/src/pipeline/cycleDataStageWriter.I | 24 +- panda/src/pipeline/cycleDataWriter.I | 26 +- panda/src/pipeline/genericThread.cxx | 6 +- panda/src/pipeline/lightMutexHolder.I | 2 +- panda/src/pipeline/lightReMutexDirect.I | 2 +- panda/src/pipeline/lightReMutexHolder.I | 2 +- panda/src/pipeline/mutexDebug.I | 2 +- panda/src/pipeline/mutexDebug.cxx | 30 +- panda/src/pipeline/mutexHolder.I | 2 +- panda/src/pipeline/pipeline.I | 2 +- panda/src/pipeline/pipeline.cxx | 4 +- panda/src/pipeline/pipelineCyclerDummyImpl.I | 14 +- panda/src/pipeline/pipelineCyclerDummyImpl.h | 4 +- panda/src/pipeline/pipelineCyclerLinks.I | 20 +- .../src/pipeline/pipelineCyclerTrivialImpl.h | 4 +- panda/src/pipeline/pipelineCyclerTrueImpl.I | 26 +- panda/src/pipeline/pipelineCyclerTrueImpl.cxx | 16 +- panda/src/pipeline/pipelineCyclerTrueImpl.h | 2 +- panda/src/pipeline/pythonThread.cxx | 26 +- panda/src/pipeline/reMutexDirect.I | 2 +- panda/src/pipeline/reMutexDirect.cxx | 10 +- panda/src/pipeline/reMutexHolder.I | 2 +- panda/src/pipeline/test_threaddata.cxx | 2 +- panda/src/pipeline/thread.I | 6 +- panda/src/pipeline/thread.cxx | 26 +- panda/src/pipeline/threadDummyImpl.I | 2 +- panda/src/pipeline/threadPosixImpl.I | 2 +- panda/src/pipeline/threadPosixImpl.cxx | 10 +- panda/src/pipeline/threadSimpleImpl.cxx | 8 +- panda/src/pipeline/threadSimpleManager.cxx | 22 +- panda/src/pipeline/threadWin32Impl.cxx | 2 +- panda/src/pnmimage/pfmFile.cxx | 12 +- panda/src/pnmimage/pfmFile_ext.cxx | 10 +- panda/src/pnmimage/pnmFileType.cxx | 4 +- panda/src/pnmimage/pnmFileTypeRegistry.cxx | 10 +- panda/src/pnmimage/pnmImage.I | 26 +- panda/src/pnmimage/pnmImage.cxx | 74 +- panda/src/pnmimage/pnmImage.h | 14 +- panda/src/pnmimage/pnmImageHeader.I | 4 +- panda/src/pnmimage/pnmImageHeader.cxx | 58 +- panda/src/pnmimage/pnmImageHeader.h | 12 +- panda/src/pnmimage/pnmReader.cxx | 2 +- panda/src/pnmimage/pnmWriter.cxx | 2 +- panda/src/pnmimage/pnmbitio.cxx | 4 +- panda/src/pnmimage/ppmcmap.cxx | 30 +- .../pnmimagetypes/pnmFileTypeBMPReader.cxx | 4 +- .../pnmimagetypes/pnmFileTypeBMPWriter.cxx | 4 +- panda/src/pnmimagetypes/pnmFileTypeEXR.cxx | 6 +- .../pnmimagetypes/pnmFileTypeJPGReader.cxx | 4 +- .../pnmimagetypes/pnmFileTypeJPGWriter.cxx | 2 +- panda/src/pnmimagetypes/pnmFileTypePNG.cxx | 38 +- panda/src/pnmimagetypes/pnmFileTypePNM.cxx | 10 +- .../pnmimagetypes/pnmFileTypeSGIReader.cxx | 10 +- .../pnmimagetypes/pnmFileTypeSGIWriter.cxx | 6 +- .../src/pnmimagetypes/pnmFileTypeStbImage.cxx | 10 +- panda/src/pnmimagetypes/pnmFileTypeTGA.cxx | 26 +- panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx | 28 +- panda/src/pnmtext/freetypeFace.cxx | 10 +- panda/src/pnmtext/freetypeFont.I | 4 +- panda/src/pnmtext/freetypeFont.cxx | 6 +- panda/src/pnmtext/pnmTextMaker.cxx | 2 +- panda/src/pstatclient/pStatClient.I | 16 +- panda/src/pstatclient/pStatClient.cxx | 20 +- panda/src/pstatclient/pStatCollector.I | 18 +- panda/src/pstatclient/pStatCollector.h | 4 +- panda/src/pstatclient/pStatProperties.cxx | 10 +- panda/src/pstatclient/pStatThread.I | 4 +- panda/src/pstatclient/pStatThread.h | 2 +- panda/src/pstatclient/test_client.cxx | 10 +- panda/src/putil/bamCache.I | 8 +- panda/src/putil/bamCache.cxx | 64 +- panda/src/putil/bamCacheIndex.cxx | 10 +- panda/src/putil/bamCacheRecord.I | 14 +- panda/src/putil/bamCacheRecord.cxx | 18 +- panda/src/putil/bamReader.I | 28 +- panda/src/putil/bamReader.cxx | 104 +-- panda/src/putil/bamReader.h | 6 +- panda/src/putil/bamReader_ext.cxx | 16 +- panda/src/putil/bamWriter.I | 2 +- panda/src/putil/bamWriter.cxx | 16 +- panda/src/putil/bamWriter.h | 2 +- panda/src/putil/buttonRegistry.I | 6 +- panda/src/putil/buttonRegistry.cxx | 16 +- panda/src/putil/callbackObject_ext.I | 2 +- panda/src/putil/config_putil.cxx | 8 +- panda/src/putil/copyOnWriteObject.I | 4 +- panda/src/putil/copyOnWriteObject.cxx | 4 +- panda/src/putil/copyOnWritePointer.I | 46 +- panda/src/putil/copyOnWritePointer.cxx | 10 +- panda/src/putil/copyOnWritePointer.h | 4 +- panda/src/putil/datagramInputFile.I | 4 +- panda/src/putil/datagramInputFile.cxx | 22 +- panda/src/putil/datagramOutputFile.I | 4 +- panda/src/putil/datagramOutputFile.cxx | 24 +- panda/src/putil/factory.h | 2 +- panda/src/putil/factoryBase.I | 4 +- panda/src/putil/factoryBase.cxx | 28 +- panda/src/putil/factoryBase.h | 2 +- panda/src/putil/factoryParams.I | 6 +- panda/src/putil/factoryParams.cxx | 14 +- panda/src/putil/globalPointerRegistry.I | 2 +- panda/src/putil/globalPointerRegistry.cxx | 4 +- panda/src/putil/linkedListNode.I | 26 +- panda/src/putil/load_prc_file.cxx | 8 +- panda/src/putil/loaderOptions.cxx | 6 +- panda/src/putil/paramValue.I | 2 +- panda/src/putil/paramValue.cxx | 2 +- panda/src/putil/pythonCallbackObject.cxx | 4 +- panda/src/putil/test_bam.cxx | 12 +- panda/src/putil/test_bam.h | 2 +- panda/src/putil/typedWritable.I | 4 +- panda/src/putil/typedWritable.cxx | 38 +- panda/src/putil/typedWritable.h | 4 +- panda/src/putil/typedWritable_ext.cxx | 52 +- panda/src/putil/weakKeyHashMap.I | 10 +- panda/src/recorder/recorderController.I | 12 +- panda/src/recorder/recorderController.cxx | 36 +- panda/src/recorder/recorderFrame.cxx | 2 +- panda/src/recorder/recorderTable.I | 4 +- panda/src/recorder/recorderTable.cxx | 2 +- panda/src/recorder/socketStreamRecorder.I | 20 +- panda/src/recorder/socketStreamRecorder.cxx | 2 +- panda/src/rocket/rocketFileInterface.cxx | 24 +- panda/src/rocket/rocketFileInterface.h | 2 +- panda/src/rocket/rocketRegion.cxx | 12 +- panda/src/rocket/rocketRegion_ext.cxx | 2 +- panda/src/rocket/rocketRenderInterface.cxx | 18 +- panda/src/speedtree/config_speedtree.cxx | 2 +- panda/src/speedtree/loaderFileTypeSrt.cxx | 4 +- panda/src/speedtree/loaderFileTypeStf.cxx | 2 +- panda/src/speedtree/speedTreeNode.I | 8 +- panda/src/speedtree/speedTreeNode.cxx | 46 +- panda/src/speedtree/speedTreeNode.h | 2 +- panda/src/speedtree/stBasicTerrain.cxx | 2 +- panda/src/speedtree/stTerrain.cxx | 8 +- panda/src/testbed/pgrid.cxx | 10 +- panda/src/testbed/pview.cxx | 38 +- panda/src/testbed/test_lod.cxx | 4 +- panda/src/testbed/test_texmem.cxx | 2 +- panda/src/text/config_text.cxx | 8 +- panda/src/text/dynamicTextFont.cxx | 32 +- panda/src/text/dynamicTextGlyph.I | 2 +- panda/src/text/dynamicTextGlyph.cxx | 8 +- panda/src/text/dynamicTextPage.cxx | 6 +- panda/src/text/fontPool.I | 2 +- panda/src/text/fontPool.cxx | 12 +- panda/src/text/geomTextGlyph.cxx | 12 +- panda/src/text/staticTextFont.cxx | 10 +- panda/src/text/textAssembler.I | 8 +- panda/src/text/textAssembler.cxx | 80 +-- panda/src/text/textFont.cxx | 2 +- panda/src/text/textGlyph.I | 6 +- panda/src/text/textGlyph.cxx | 6 +- panda/src/text/textNode.I | 6 +- panda/src/text/textNode.cxx | 24 +- panda/src/text/textProperties.cxx | 6 +- panda/src/text/textPropertiesManager.cxx | 8 +- panda/src/tform/driveInterface.cxx | 2 +- panda/src/tform/mouseInterfaceNode.cxx | 4 +- panda/src/tform/mouseWatcher.I | 14 +- panda/src/tform/mouseWatcher.cxx | 76 +-- panda/src/tform/mouseWatcherBase.cxx | 6 +- panda/src/tform/transform2sg.cxx | 4 +- panda/src/tinydisplay/init.cxx | 4 +- panda/src/tinydisplay/specbuf.cxx | 2 +- panda/src/tinydisplay/td_light.cxx | 2 +- panda/src/tinydisplay/tinyGraphicsBuffer.cxx | 18 +- .../tinydisplay/tinyGraphicsStateGuardian.I | 6 +- .../tinydisplay/tinyGraphicsStateGuardian.cxx | 108 +-- .../tinydisplay/tinyOffscreenGraphicsPipe.cxx | 4 +- panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx | 34 +- panda/src/tinydisplay/tinySDLGraphicsPipe.cxx | 8 +- .../src/tinydisplay/tinySDLGraphicsWindow.cxx | 24 +- panda/src/tinydisplay/tinyTextureContext.I | 2 +- panda/src/tinydisplay/tinyTextureContext.cxx | 8 +- panda/src/tinydisplay/tinyWinGraphicsPipe.cxx | 12 +- .../src/tinydisplay/tinyWinGraphicsWindow.cxx | 24 +- panda/src/tinydisplay/tinyXGraphicsPipe.cxx | 8 +- panda/src/tinydisplay/tinyXGraphicsWindow.cxx | 56 +- panda/src/tinydisplay/zbuffer.cxx | 16 +- panda/src/vision/arToolKit.cxx | 2 +- panda/src/vision/openCVTexture.I | 2 +- panda/src/vision/openCVTexture.cxx | 16 +- panda/src/vision/webcamVideo.cxx | 2 +- panda/src/vision/webcamVideoCursorOpenCV.cxx | 14 +- panda/src/vision/webcamVideoCursorV4L.cxx | 24 +- panda/src/vision/webcamVideoDS.cxx | 84 +-- panda/src/vrpn/vrpnClient.cxx | 12 +- panda/src/wgldisplay/wglGraphicsBuffer.cxx | 30 +- panda/src/wgldisplay/wglGraphicsPipe.cxx | 32 +- .../wgldisplay/wglGraphicsStateGuardian.cxx | 82 +-- panda/src/wgldisplay/wglGraphicsWindow.cxx | 12 +- panda/src/windisplay/winDetectDx.h | 22 +- panda/src/windisplay/winGraphicsPipe.cxx | 16 +- panda/src/windisplay/winGraphicsWindow.I | 4 +- panda/src/windisplay/winGraphicsWindow.cxx | 104 +-- panda/src/x11display/x11GraphicsPipe.I | 6 +- panda/src/x11display/x11GraphicsPipe.cxx | 40 +- panda/src/x11display/x11GraphicsWindow.cxx | 74 +- pandatool/src/assimp/assimpLoader.cxx | 32 +- pandatool/src/assimp/loaderFileTypeAssimp.cxx | 4 +- pandatool/src/assimp/pandaIOSystem.cxx | 8 +- pandatool/src/assimp/pandaLogger.cxx | 4 +- pandatool/src/bam/bamInfo.cxx | 8 +- pandatool/src/bam/bamToEgg.cxx | 8 +- pandatool/src/bam/eggToBam.cxx | 14 +- pandatool/src/bam/ptsToBam.cxx | 10 +- .../src/converter/eggToSomethingConverter.I | 2 +- .../src/converter/eggToSomethingConverter.cxx | 4 +- .../src/converter/somethingToEggConverter.I | 2 +- .../src/converter/somethingToEggConverter.cxx | 6 +- pandatool/src/cvscopy/cvsCopy.cxx | 14 +- pandatool/src/cvscopy/cvsSourceDirectory.cxx | 26 +- pandatool/src/cvscopy/cvsSourceTree.cxx | 32 +- pandatool/src/cvscopy/testCopy.cxx | 2 +- pandatool/src/daeegg/daeCharacter.cxx | 18 +- pandatool/src/daeegg/daeCharacter.h | 2 +- pandatool/src/daeegg/daeMaterials.cxx | 20 +- pandatool/src/daeegg/daeToEggConverter.cxx | 110 +-- pandatool/src/daeegg/daeToEggConverter.h | 2 +- pandatool/src/daeprogs/eggToDAE.cxx | 14 +- pandatool/src/dxf/dxfFile.cxx | 8 +- pandatool/src/dxfegg/dxfToEggConverter.cxx | 6 +- pandatool/src/egg-mkfont/eggMakeFont.cxx | 36 +- pandatool/src/egg-optchar/eggOptchar.cxx | 58 +- pandatool/src/egg-palettize/eggPalettize.cxx | 4 +- pandatool/src/egg-palettize/txaFileFilter.cxx | 4 +- pandatool/src/egg-qtess/eggQtess.cxx | 10 +- pandatool/src/egg-qtess/qtessInputEntry.I | 10 +- pandatool/src/egg-qtess/qtessInputEntry.cxx | 4 +- pandatool/src/egg-qtess/qtessSurface.I | 2 +- pandatool/src/egg-qtess/qtessSurface.cxx | 24 +- pandatool/src/eggbase/eggBase.cxx | 10 +- pandatool/src/eggbase/eggMultiBase.cxx | 6 +- pandatool/src/eggbase/eggMultiFilter.cxx | 2 +- pandatool/src/eggbase/eggReader.cxx | 8 +- pandatool/src/eggbase/eggSingleBase.cxx | 4 +- pandatool/src/eggbase/eggToSomething.cxx | 4 +- pandatool/src/eggbase/somethingToEgg.cxx | 8 +- .../src/eggcharbase/eggCharacterCollection.I | 8 +- .../eggcharbase/eggCharacterCollection.cxx | 4 +- pandatool/src/eggcharbase/eggCharacterData.I | 10 +- .../src/eggcharbase/eggCharacterData.cxx | 6 +- .../src/eggcharbase/eggCharacterFilter.cxx | 6 +- pandatool/src/eggcharbase/eggComponentData.I | 4 +- .../src/eggcharbase/eggComponentData.cxx | 12 +- pandatool/src/eggcharbase/eggJointData.I | 4 +- pandatool/src/eggcharbase/eggJointData.cxx | 72 +- .../src/eggcharbase/eggJointNodePointer.cxx | 14 +- .../src/eggcharbase/eggMatrixTablePointer.cxx | 28 +- .../src/eggcharbase/eggScalarTablePointer.cxx | 6 +- pandatool/src/eggcharbase/eggSliderData.cxx | 8 +- pandatool/src/eggprogs/eggMakeTube.cxx | 24 +- pandatool/src/eggprogs/eggRename.cxx | 2 +- pandatool/src/eggprogs/eggRetargetAnim.cxx | 10 +- pandatool/src/eggprogs/eggTextureCards.cxx | 30 +- pandatool/src/eggprogs/eggToC.cxx | 8 +- pandatool/src/eggprogs/eggTopstrip.cxx | 16 +- pandatool/src/flt/fltBead.cxx | 8 +- pandatool/src/flt/fltGeometry.I | 4 +- pandatool/src/flt/fltHeader.cxx | 20 +- pandatool/src/flt/fltInstanceRef.cxx | 2 +- pandatool/src/flt/fltMesh.cxx | 2 +- pandatool/src/flt/fltRecord.cxx | 8 +- pandatool/src/flt/fltRecordReader.cxx | 10 +- pandatool/src/flt/fltRecordWriter.cxx | 2 +- pandatool/src/flt/fltVertexList.cxx | 2 +- pandatool/src/fltegg/fltToEggConverter.cxx | 8 +- pandatool/src/fltegg/fltToEggLevelState.I | 4 +- pandatool/src/fltegg/fltToEggLevelState.cxx | 12 +- pandatool/src/fltprogs/eggToFlt.cxx | 4 +- pandatool/src/gtk-stats/gtkStats.cxx | 8 +- pandatool/src/gtk-stats/gtkStatsChartMenu.cxx | 2 +- pandatool/src/gtk-stats/gtkStatsGraph.cxx | 36 +- pandatool/src/gtk-stats/gtkStatsLabel.cxx | 2 +- pandatool/src/gtk-stats/gtkStatsMonitor.I | 2 +- pandatool/src/gtk-stats/gtkStatsMonitor.cxx | 34 +- .../src/imageprogs/imageFixHiddenColor.cxx | 6 +- pandatool/src/imageprogs/imageInfo.cxx | 2 +- pandatool/src/imageprogs/imageResize.cxx | 6 +- pandatool/src/imageprogs/imageTrans.cxx | 2 +- .../src/imageprogs/imageTransformColors.cxx | 12 +- pandatool/src/lwo/iffInputFile.cxx | 20 +- pandatool/src/lwo/lwoGroupChunk.cxx | 6 +- pandatool/src/lwo/lwoPolygons.cxx | 2 +- pandatool/src/lwo/lwoSurfaceBlock.cxx | 2 +- pandatool/src/lwo/test_lwo.cxx | 2 +- pandatool/src/lwoegg/cLwoLayer.cxx | 2 +- pandatool/src/lwoegg/cLwoPolygons.I | 4 +- pandatool/src/lwoegg/cLwoPolygons.cxx | 24 +- pandatool/src/lwoegg/cLwoSurface.I | 2 +- pandatool/src/lwoegg/cLwoSurface.cxx | 26 +- pandatool/src/lwoegg/cLwoSurfaceBlock.cxx | 8 +- pandatool/src/lwoegg/lwoToEggConverter.cxx | 62 +- pandatool/src/lwoprogs/lwoScan.cxx | 4 +- pandatool/src/maxegg/maxEgg.cxx | 22 +- pandatool/src/maxegg/maxEgg.h | 2 +- pandatool/src/maxegg/maxEggLoader.cxx | 2 +- pandatool/src/maxegg/maxNodeDesc.cxx | 30 +- pandatool/src/maxegg/maxNodeDesc.h | 2 +- pandatool/src/maxegg/maxNodeTree.cxx | 28 +- pandatool/src/maxegg/maxOptionsDialog.cxx | 4 +- pandatool/src/maxegg/maxToEggConverter.cxx | 28 +- pandatool/src/maxegg/maxToEggConverter.h | 2 +- pandatool/src/maxprogs/maxEggImport.cxx | 6 +- pandatool/src/maya/mayaApi.cxx | 6 +- pandatool/src/maya/mayaShader.cxx | 2 +- pandatool/src/maya/mayaShaderColorDef.cxx | 12 +- pandatool/src/maya/mayaShaders.cxx | 8 +- pandatool/src/mayaegg/mayaBlendDesc.cxx | 4 +- pandatool/src/mayaegg/mayaEggLoader.cxx | 70 +- pandatool/src/mayaegg/mayaNodeDesc.cxx | 38 +- pandatool/src/mayaegg/mayaNodeDesc.h | 2 +- pandatool/src/mayaegg/mayaNodeTree.cxx | 48 +- pandatool/src/mayaegg/mayaToEggConverter.cxx | 50 +- pandatool/src/mayaegg/mayaToEggConverter.h | 2 +- pandatool/src/mayaprogs/mayaPview.cxx | 8 +- pandatool/src/mayaprogs/mayaSavePview.cxx | 2 +- pandatool/src/mayaprogs/mayaToEgg.cxx | 16 +- pandatool/src/mayaprogs/mayaToEgg_server.cxx | 16 +- pandatool/src/mayaprogs/mayapath.cxx | 16 +- pandatool/src/miscprogs/binToC.cxx | 2 +- pandatool/src/objegg/eggToObjConverter.cxx | 14 +- pandatool/src/objegg/objToEggConverter.cxx | 16 +- pandatool/src/palettizer/destTextureImage.cxx | 2 +- pandatool/src/palettizer/eggFile.cxx | 30 +- pandatool/src/palettizer/imageFile.cxx | 12 +- pandatool/src/palettizer/pal_string_utils.cxx | 8 +- pandatool/src/palettizer/paletteImage.cxx | 24 +- pandatool/src/palettizer/palettePage.cxx | 4 +- pandatool/src/palettizer/palettizer.cxx | 32 +- .../src/palettizer/sourceTextureImage.cxx | 2 +- pandatool/src/palettizer/textureImage.cxx | 40 +- .../src/palettizer/textureMemoryCounter.cxx | 6 +- pandatool/src/palettizer/texturePlacement.cxx | 30 +- .../src/palettizer/textureProperties.cxx | 20 +- pandatool/src/palettizer/textureReference.cxx | 40 +- pandatool/src/palettizer/txaLine.cxx | 16 +- pandatool/src/pfmprogs/pfmBba.cxx | 2 +- pandatool/src/pfmprogs/pfmTrans.cxx | 4 +- pandatool/src/progbase/programBase.cxx | 36 +- pandatool/src/progbase/programBase.h | 8 +- pandatool/src/progbase/test_prog.cxx | 4 +- pandatool/src/progbase/withOutputFile.cxx | 6 +- pandatool/src/pstatserver/pStatClientData.cxx | 16 +- pandatool/src/pstatserver/pStatListener.cxx | 2 +- pandatool/src/pstatserver/pStatReader.cxx | 2 +- pandatool/src/pstatserver/pStatServer.cxx | 2 +- pandatool/src/pstatserver/pStatServer.h | 2 +- pandatool/src/pstatserver/pStatThreadData.cxx | 36 +- pandatool/src/pstatserver/pStatView.cxx | 6 +- pandatool/src/pstatserver/pStatViewLevel.cxx | 2 +- .../src/ptloader/loaderFileTypePandatool.cxx | 22 +- .../src/ptloader/loaderFileTypePandatool.h | 2 +- pandatool/src/softegg/softNodeDesc.cxx | 88 +-- pandatool/src/softegg/softNodeDesc.h | 2 +- pandatool/src/softegg/softNodeTree.cxx | 42 +- pandatool/src/softegg/softToEggConverter.cxx | 100 +-- pandatool/src/softprogs/softCVS.cxx | 2 +- pandatool/src/text-stats/textStats.cxx | 6 +- pandatool/src/vrml/parse_vrml.cxx | 10 +- pandatool/src/vrml/vrmlLexer.lxx | 10 +- pandatool/src/vrml/vrmlNode.cxx | 2 +- pandatool/src/vrml/vrmlNodeType.cxx | 28 +- pandatool/src/vrml/vrmlNodeType.h | 8 +- pandatool/src/vrml/vrmlParser.yxx | 50 +- pandatool/src/vrmlegg/indexedFaceSet.cxx | 12 +- pandatool/src/vrmlegg/vrmlAppearance.cxx | 8 +- pandatool/src/vrmlegg/vrmlToEggConverter.cxx | 18 +- pandatool/src/vrmlprogs/vrmlTrans.cxx | 2 +- pandatool/src/win-stats/winStats.cxx | 14 +- pandatool/src/win-stats/winStatsGraph.cxx | 32 +- pandatool/src/win-stats/winStatsLabel.cxx | 16 +- .../src/win-stats/winStatsLabelStack.cxx | 10 +- pandatool/src/win-stats/winStatsMonitor.cxx | 20 +- pandatool/src/win-stats/winStatsPianoRoll.cxx | 14 +- .../src/win-stats/winStatsStripChart.cxx | 18 +- pandatool/src/xfile/xFile.cxx | 20 +- pandatool/src/xfile/xFileArrayDef.I | 6 +- pandatool/src/xfile/xFileArrayDef.cxx | 2 +- pandatool/src/xfile/xFileDataDef.cxx | 28 +- pandatool/src/xfile/xFileDataDef.h | 2 +- pandatool/src/xfile/xFileDataNodeTemplate.cxx | 4 +- pandatool/src/xfile/xFileDataObject.I | 8 +- pandatool/src/xfile/xFileDataObject.cxx | 12 +- pandatool/src/xfile/xFileDataObject.h | 2 +- pandatool/src/xfile/xFileDataObjectArray.cxx | 2 +- pandatool/src/xfile/xFileNode.I | 4 +- pandatool/src/xfile/xFileNode.cxx | 26 +- pandatool/src/xfile/xFileTemplate.I | 2 +- pandatool/src/xfile/xLexer.lxx | 6 +- pandatool/src/xfile/xParser.yxx | 24 +- pandatool/src/xfileegg/xFileAnimationSet.cxx | 6 +- pandatool/src/xfileegg/xFileMesh.cxx | 14 +- .../src/xfileegg/xFileToEggConverter.cxx | 12 +- pandatool/src/xfileprogs/xFileToEgg.cxx | 2 +- 1390 files changed, 12684 insertions(+), 12684 deletions(-) diff --git a/contrib/src/ai/aiBehaviors.cxx b/contrib/src/ai/aiBehaviors.cxx index 727e7e12f4..38d32b1026 100644 --- a/contrib/src/ai/aiBehaviors.cxx +++ b/contrib/src/ai/aiBehaviors.cxx @@ -21,16 +21,16 @@ AIBehaviors::AIBehaviors() { _previous_conflict = false; _conflict = false; - _seek_obj = NULL; - _flee_obj = NULL; - _pursue_obj = NULL; - _evade_obj = NULL; - _arrival_obj = NULL; - _wander_obj = NULL; - _flock_group = NULL; - _path_follow_obj = NULL; - _path_find_obj = NULL; - _obstacle_avoidance_obj = NULL; + _seek_obj = nullptr; + _flee_obj = nullptr; + _pursue_obj = nullptr; + _evade_obj = nullptr; + _arrival_obj = nullptr; + _wander_obj = nullptr; + _flock_group = nullptr; + _path_follow_obj = nullptr; + _path_find_obj = nullptr; + _obstacle_avoidance_obj = nullptr; turn_off("seek"); turn_off("flee"); @@ -267,7 +267,7 @@ LVecBase3 AIBehaviors::calculate_prioritized() { accumulate_force("obstacle_avoidance", force); } - if(_path_follow_obj!=NULL) { + if(_path_follow_obj!=nullptr) { if(_path_follow_obj->_start) { _path_follow_obj->do_follow(); } @@ -286,13 +286,13 @@ LVecBase3 AIBehaviors::calculate_prioritized() { } if(is_on(_arrival)) { - if(_seek_obj != NULL) { + if(_seek_obj != nullptr) { LVecBase3 dirn = _steering_force; dirn.normalize(); _steering_force = ((_steering_force.length() - _arrival_force.length()) * dirn); } - if(_pursue_obj != NULL) { + if(_pursue_obj != nullptr) { LVecBase3 dirn = _steering_force; dirn.normalize(); _steering_force = ((_steering_force.length() - _arrival_force.length()) * _arrival_obj->_arrival_direction); @@ -320,10 +320,10 @@ void AIBehaviors::remove_ai(string ai_type) { } case 1: { - if(_seek_obj != NULL) { + if(_seek_obj != nullptr) { turn_off("seek"); delete _seek_obj; - _seek_obj = NULL; + _seek_obj = nullptr; } break; } @@ -338,10 +338,10 @@ void AIBehaviors::remove_ai(string ai_type) { } case 3: { - if(_pursue_obj != NULL) { + if(_pursue_obj != nullptr) { turn_off("pursue"); delete _pursue_obj; - _pursue_obj = NULL; + _pursue_obj = nullptr; } break; } @@ -356,59 +356,59 @@ void AIBehaviors::remove_ai(string ai_type) { } case 5: { - if(_arrival_obj != NULL) { + if(_arrival_obj != nullptr) { turn_off("arrival"); turn_off("arrival_activate"); delete _arrival_obj; - _arrival_obj = NULL; + _arrival_obj = nullptr; } break; } case 6: { - if(_flock_group != NULL) { + if(_flock_group != nullptr) { turn_off("flock"); turn_off("flock_activate"); - _flock_group = NULL; + _flock_group = nullptr; } break; } case 7: { - if(_wander_obj != NULL) { + if(_wander_obj != nullptr) { turn_off("wander"); delete _wander_obj; - _wander_obj = NULL; + _wander_obj = nullptr; } break; } case 8: { - if(_obstacle_avoidance_obj !=NULL) { + if(_obstacle_avoidance_obj !=nullptr) { turn_off("obstacle_avoidance"); delete _obstacle_avoidance_obj; - _obstacle_avoidance_obj = NULL; + _obstacle_avoidance_obj = nullptr; } break; } case 9: { - if(_pursue_obj != NULL && _path_follow_obj != NULL) { + if(_pursue_obj != nullptr && _path_follow_obj != nullptr) { turn_off("pursue"); delete _pursue_obj; - _pursue_obj = NULL; + _pursue_obj = nullptr; delete _path_follow_obj; - _path_follow_obj = NULL; + _path_follow_obj = nullptr; } break; } case 16: { - if(_pursue_obj != NULL && _path_follow_obj != NULL) { + if(_pursue_obj != nullptr && _path_follow_obj != nullptr) { turn_off("pursue"); delete _pursue_obj; - _pursue_obj = NULL; + _pursue_obj = nullptr; delete _path_follow_obj; - _path_follow_obj = NULL; + _path_follow_obj = nullptr; } break; } @@ -436,7 +436,7 @@ void AIBehaviors::pause_ai(string ai_type) { } case 1: { - if(_seek_obj != NULL) { + if(_seek_obj != nullptr) { turn_off("seek"); } break; @@ -451,7 +451,7 @@ void AIBehaviors::pause_ai(string ai_type) { } case 3: { - if(_pursue_obj != NULL) { + if(_pursue_obj != nullptr) { turn_off("pursue"); } break; @@ -466,7 +466,7 @@ void AIBehaviors::pause_ai(string ai_type) { } case 5: { - if(_arrival_obj != NULL) { + if(_arrival_obj != nullptr) { turn_off("arrival"); turn_off("arrival_activate"); } @@ -474,7 +474,7 @@ void AIBehaviors::pause_ai(string ai_type) { } case 6: { - if(_flock_group != NULL) { + if(_flock_group != nullptr) { turn_off("flock"); turn_off("flock_activate"); } @@ -482,14 +482,14 @@ void AIBehaviors::pause_ai(string ai_type) { } case 7: { - if(_wander_obj != NULL) { + if(_wander_obj != nullptr) { turn_off("wander"); } break; } case 8: { - if(_obstacle_avoidance_obj != NULL) { + if(_obstacle_avoidance_obj != nullptr) { turn_off("obstacle_avoidance"); turn_off("obstacle_avoidance_activate"); } @@ -497,14 +497,14 @@ void AIBehaviors::pause_ai(string ai_type) { } case 9: { - if(_pursue_obj != NULL && _path_follow_obj != NULL) { + if(_pursue_obj != nullptr && _path_follow_obj != nullptr) { turn_off("pursue"); _path_follow_obj->_start = false; } break; } case 16: { - if(_pursue_obj != NULL && _path_follow_obj != NULL) { + if(_pursue_obj != nullptr && _path_follow_obj != nullptr) { turn_off("pursue"); _path_follow_obj->_start = false; } @@ -534,7 +534,7 @@ void AIBehaviors::resume_ai(string ai_type) { } case 1: { - if(_seek_obj != NULL) { + if(_seek_obj != nullptr) { turn_on("seek"); } break; @@ -548,7 +548,7 @@ void AIBehaviors::resume_ai(string ai_type) { } case 3: { - if(_pursue_obj != NULL) { + if(_pursue_obj != nullptr) { turn_on("pursue"); } break; @@ -562,42 +562,42 @@ void AIBehaviors::resume_ai(string ai_type) { } case 5: { - if(_arrival_obj != NULL) { + if(_arrival_obj != nullptr) { turn_on("arrival"); } break; } case 6: { - if(_flock_group != NULL) { + if(_flock_group != nullptr) { turn_on("flock"); } break; } case 7: { - if(_wander_obj != NULL) { + if(_wander_obj != nullptr) { turn_on("wander"); } break; } case 8: { - if(_obstacle_avoidance_obj != NULL) { + if(_obstacle_avoidance_obj != nullptr) { turn_on("obstacle_avoidance"); } break; } case 9: { - if(_pursue_obj != NULL && _path_follow_obj != NULL) { + if(_pursue_obj != nullptr && _path_follow_obj != nullptr) { turn_on("pursue"); _path_follow_obj->_start = true; } break; } case 16: { - if(_pursue_obj != NULL && _path_follow_obj != NULL) { + if(_pursue_obj != nullptr && _path_follow_obj != nullptr) { turn_off("pursue"); _path_follow_obj->_start = false; } diff --git a/contrib/src/ai/aiNode.cxx b/contrib/src/ai/aiNode.cxx index a37927ae63..1812cf6cc1 100644 --- a/contrib/src/ai/aiNode.cxx +++ b/contrib/src/ai/aiNode.cxx @@ -15,7 +15,7 @@ AINode::AINode(int grid_x, int grid_y, LVecBase3 pos, float w, float l, float h) { for (int i = 0; i < 8; ++i) { - _neighbours[i] = NULL; + _neighbours[i] = nullptr; } _position = pos; @@ -29,8 +29,8 @@ AINode::AINode(int grid_x, int grid_y, LVecBase3 pos, float w, float l, float h) _score = 0; _cost = 0; _heuristic = 0; - _next = NULL; - _prv_node = NULL; + _next = nullptr; + _prv_node = nullptr; } AINode::~AINode() { diff --git a/contrib/src/ai/aiPathFinder.cxx b/contrib/src/ai/aiPathFinder.cxx index 58f11bfc39..8167a6e42e 100644 --- a/contrib/src/ai/aiPathFinder.cxx +++ b/contrib/src/ai/aiPathFinder.cxx @@ -87,7 +87,7 @@ void PathFinder::identify_neighbors(Node *parent_node) { // while adding new nodes to the open list heap. remove_from_olist(); for(int i = 0; i < 8; ++i) { - if(parent_node->_neighbours[i] != NULL) { + if(parent_node->_neighbours[i] != nullptr) { if(parent_node->_neighbours[i]->_status == parent_node->_neighbours[i]->neutral && parent_node->_neighbours[i]->_type == true) { // Link the neighbor to the parent node. @@ -340,10 +340,10 @@ Node* find_in_mesh(NavMesh nav_mesh, LVecBase3 pos, int grid_size) { for(int i = 0; i < size; ++i) { for(int j = 0; j < size; ++j) { - if(nav_mesh[i][j] != NULL && nav_mesh[i][j]->contains(x, y)) { + if(nav_mesh[i][j] != nullptr && nav_mesh[i][j]->contains(x, y)) { return(nav_mesh[i][j]); } } } - return NULL; + return nullptr; } diff --git a/contrib/src/ai/aiWorld.cxx b/contrib/src/ai/aiWorld.cxx index 8210046497..bace5593ef 100644 --- a/contrib/src/ai/aiWorld.cxx +++ b/contrib/src/ai/aiWorld.cxx @@ -99,7 +99,7 @@ Flock AIWorld::get_flock(unsigned int flock_id) { return *_flock_pool[i]; } } - Flock *null_flock = NULL; + Flock *null_flock = nullptr; return *null_flock; } @@ -112,7 +112,7 @@ void AIWorld::remove_flock(unsigned int flock_id) { for(unsigned int j = 0; j < _flock_pool[i]->_ai_char_list.size(); ++j) { _flock_pool[i]->_ai_char_list[j]->get_ai_behaviors()->turn_off("flock_activate"); _flock_pool[i]->_ai_char_list[j]->get_ai_behaviors()->turn_off("flock"); - _flock_pool[i]->_ai_char_list[j]->get_ai_behaviors()->_flock_group = NULL; + _flock_pool[i]->_ai_char_list[j]->get_ai_behaviors()->_flock_group = nullptr; } _flock_pool.erase(_flock_pool.begin() + i); break; diff --git a/contrib/src/ai/arrival.cxx b/contrib/src/ai/arrival.cxx index f9fba9438a..af7400d170 100644 --- a/contrib/src/ai/arrival.cxx +++ b/contrib/src/ai/arrival.cxx @@ -48,7 +48,7 @@ LVecBase3 Arrival::do_arrival() { _ai_char->_steering->_steering_force = LVecBase3(0.0, 0.0, 0.0); _ai_char->_steering->_arrival_force = LVecBase3(0.0, 0.0, 0.0); - if(_ai_char->_steering->_seek_obj != NULL) { + if(_ai_char->_steering->_seek_obj != nullptr) { _ai_char->_steering->turn_off("arrival"); _ai_char->_steering->turn_on("arrival_activate"); } @@ -62,11 +62,11 @@ LVecBase3 Arrival::do_arrival() { double u = _ai_char->get_velocity().length(); LVecBase3 desired_force = ((u * u) / (2 * distance)) * _ai_char->get_mass(); - if(_ai_char->_steering->_seek_obj != NULL) { + if(_ai_char->_steering->_seek_obj != nullptr) { return(desired_force); } - if(_ai_char->_steering->_pursue_obj != NULL) { + if(_ai_char->_steering->_pursue_obj != nullptr) { if(distance > _arrival_distance) { _ai_char->_steering->turn_off("arrival"); diff --git a/contrib/src/ai/meshNode.cxx b/contrib/src/ai/meshNode.cxx index 043dc5b60c..26189f6bbf 100644 --- a/contrib/src/ai/meshNode.cxx +++ b/contrib/src/ai/meshNode.cxx @@ -3,7 +3,7 @@ Node::Node(int grid_x, int grid_y, LVecBase3 pos, float w, float l, float h) { for(int i = 0; i < 8; ++i) { - _neighbours[i] = NULL; + _neighbours[i] = nullptr; } _position = pos; @@ -17,8 +17,8 @@ Node::Node(int grid_x, int grid_y, LVecBase3 pos, float w, float l, float h) { _score = 0; _cost = 0; _heuristic = 0; - _next = NULL; - _prv_node = NULL; + _next = nullptr; + _prv_node = nullptr; } Node::~Node() { diff --git a/contrib/src/ai/pathFind.cxx b/contrib/src/ai/pathFind.cxx index aca7745229..c3f807a8e7 100644 --- a/contrib/src/ai/pathFind.cxx +++ b/contrib/src/ai/pathFind.cxx @@ -23,7 +23,7 @@ PathFind::PathFind(AICharacter *ai_ch) { _pen->set_color(1.0, 0.0, 0.0); _pen->set_thickness(2.0); - _path_finder_obj = NULL; + _path_finder_obj = nullptr; _dynamic_avoid = false; } @@ -58,7 +58,7 @@ void PathFind::create_nav_mesh(const char* navmesh_filename) { for(int r = 0; r < _grid_size; ++r) { _nav_mesh.push_back(std::vector()); for(int c = 0; c < _grid_size; ++c) { - _nav_mesh[r].push_back(NULL); + _nav_mesh[r].push_back(nullptr); } } @@ -150,7 +150,7 @@ void PathFind::assign_neighbor_nodes(const char* navmesh_filename){ } else if(fields_n[0] == "1" && fields_n[1] == "1") { // NULL neighbor. - _nav_mesh[gd_y][gd_x]->_neighbours[i] = NULL; + _nav_mesh[gd_y][gd_x]->_neighbours[i] = nullptr; } else { cout<<"Warning: Corrupt data!"<_ai_char_np.get_pos(_ai_char->_window_render), _grid_size); - if(src == NULL) { + if(src == nullptr) { cout<<"couldnt find source"<find_path(src, dst); trace_path(src); } @@ -248,22 +248,22 @@ void PathFind::path_find(NodePath target, string type) { Node* src = find_in_mesh(_nav_mesh, _ai_char->_ai_char_np.get_pos(_ai_char->_window_render), _grid_size); - if(src == NULL) { + if(src == nullptr) { cout<<"couldnt find source"<find_path(src, dst); trace_path(src); } - if(_ai_char->_steering->_path_follow_obj!=NULL) { + if(_ai_char->_steering->_path_follow_obj!=nullptr) { if(!_ai_char->_steering->_path_follow_obj->_start) { _ai_char->_steering->start_follow("pathfind"); } @@ -277,12 +277,12 @@ void PathFind::clear_path() { // Initialize to zero for(int i = 0; i < _grid_size; ++i) { for(int j = 0; j < _grid_size; ++j) { - if(_nav_mesh[i][j] != NULL) { + if(_nav_mesh[i][j] != nullptr) { _nav_mesh[i][j]->_status = _nav_mesh[i][j]->neutral; _nav_mesh[i][j]->_cost = 0; _nav_mesh[i][j]->_heuristic = 0; _nav_mesh[i][j]->_score = 0; - _nav_mesh[i][j]->_prv_node = NULL; + _nav_mesh[i][j]->_prv_node = nullptr; } } } @@ -333,7 +333,7 @@ void PathFind::add_obstacle_to_mesh(NodePath obstacle) { Node* temp = find_in_mesh(_nav_mesh, obstacle.get_pos(), _grid_size); - if(temp != NULL) { + if(temp != nullptr) { float left = temp->_position.get_x() - np_sphere->get_radius(); float right = temp->_position.get_x() + np_sphere->get_radius(); float top = temp->_position.get_y() + np_sphere->get_radius(); @@ -341,7 +341,7 @@ void PathFind::add_obstacle_to_mesh(NodePath obstacle) { for(int i = 0; i < _grid_size; ++i) { for(int j = 0; j < _grid_size; ++j) { - if(_nav_mesh[i][j] != NULL && _nav_mesh[i][j]->_type == true) { + if(_nav_mesh[i][j] != nullptr && _nav_mesh[i][j]->_type == true) { if(_nav_mesh[i][j]->_position.get_x() >= left && _nav_mesh[i][j]->_position.get_x() <= right && _nav_mesh[i][j]->_position.get_y() >= down && _nav_mesh[i][j]->_position.get_y() <= top) { _nav_mesh[i][j]->_type = false; diff --git a/direct/src/dcparse/dcparse.cxx b/direct/src/dcparse/dcparse.cxx index 3d02ef669c..9fbd4ef063 100644 --- a/direct/src/dcparse/dcparse.cxx +++ b/direct/src/dcparse/dcparse.cxx @@ -103,8 +103,8 @@ write_complete_field_list(const DCFile &file) { cout << field->get_class()->get_name() << "::"; } cout << field->get_name(); - if (field->as_atomic_field() != (DCAtomicField *)NULL || - field->as_molecular_field() != (DCMolecularField *)NULL) { + if (field->as_atomic_field() != nullptr || + field->as_molecular_field() != nullptr) { // It's a "method". cout << "()"; } diff --git a/direct/src/dcparser/dcArrayParameter.cxx b/direct/src/dcparser/dcArrayParameter.cxx index 7485a34a5d..b8101128bd 100644 --- a/direct/src/dcparser/dcArrayParameter.cxx +++ b/direct/src/dcparser/dcArrayParameter.cxx @@ -58,7 +58,7 @@ DCArrayParameter(DCParameter *element_type, const DCUnsignedIntRange &size) : _pack_type = PT_array; DCSimpleParameter *simple_type = _element_type->as_simple_parameter(); - if (simple_type != (DCSimpleParameter *)NULL) { + if (simple_type != nullptr) { if (simple_type->get_type() == ST_char) { // We make a special case for char[] arrays: these we format as a // string. (It will still accept an array of ints packed into it.) We @@ -148,7 +148,7 @@ get_array_size() const { */ DCParameter *DCArrayParameter:: append_array_specification(const DCUnsignedIntRange &size) { - if (get_typedef() != (DCTypedef *)NULL) { + if (get_typedef() != nullptr) { // If this was a typedef, wrap it directly. return new DCArrayParameter(this, size); } @@ -203,7 +203,7 @@ validate_num_nested_fields(int num_nested_fields) const { void DCArrayParameter:: output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const { - if (get_typedef() != (DCTypedef *)NULL) { + if (get_typedef() != nullptr) { output_typedef_name(out, brief, prename, name, postname); } else { @@ -236,7 +236,7 @@ pack_string(DCPackData &pack_data, const string &value, bool &pack_error, bool &range_error) const { // We can only pack a string if the array element type is char or int8. DCSimpleParameter *simple_type = _element_type->as_simple_parameter(); - if (simple_type == (DCSimpleParameter *)NULL) { + if (simple_type == nullptr) { pack_error = true; return; } @@ -306,7 +306,7 @@ unpack_string(const char *data, size_t length, size_t &p, string &value, bool &pack_error, bool &range_error) const { // We can only unpack a string if the array element type is char or int8. DCSimpleParameter *simple_type = _element_type->as_simple_parameter(); - if (simple_type == (DCSimpleParameter *)NULL) { + if (simple_type == nullptr) { pack_error = true; return; } diff --git a/direct/src/dcparser/dcAtomicField.cxx b/direct/src/dcparser/dcAtomicField.cxx index 0d2ace8f35..c3f0dc365b 100644 --- a/direct/src/dcparser/dcAtomicField.cxx +++ b/direct/src/dcparser/dcAtomicField.cxx @@ -73,7 +73,7 @@ get_num_elements() const { */ DCParameter *DCAtomicField:: get_element(int n) const { - nassertr(n >= 0 && n < (int)_elements.size(), NULL); + nassertr(n >= 0 && n < (int)_elements.size(), nullptr); return _elements[n]; } @@ -127,7 +127,7 @@ DCSubatomicType DCAtomicField:: get_element_type(int n) const { nassertr(n >= 0 && n < (int)_elements.size(), ST_invalid); DCSimpleParameter *simple_parameter = _elements[n]->as_simple_parameter(); - nassertr(simple_parameter != (DCSimpleParameter *)NULL, ST_invalid); + nassertr(simple_parameter != nullptr, ST_invalid); return simple_parameter->get_type(); } @@ -143,7 +143,7 @@ int DCAtomicField:: get_element_divisor(int n) const { nassertr(n >= 0 && n < (int)_elements.size(), 1); DCSimpleParameter *simple_parameter = _elements[n]->as_simple_parameter(); - nassertr(simple_parameter != (DCSimpleParameter *)NULL, 1); + nassertr(simple_parameter != nullptr, 1); return simple_parameter->get_divisor(); } @@ -207,7 +207,7 @@ generate_hash(HashGenerator &hashgen) const { */ DCPackerInterface *DCAtomicField:: get_nested_field(int n) const { - nassertr(n >= 0 && n < (int)_elements.size(), NULL); + nassertr(n >= 0 && n < (int)_elements.size(), nullptr); return _elements[n]; } diff --git a/direct/src/dcparser/dcClass.cxx b/direct/src/dcparser/dcClass.cxx index d11a116415..3d311e6506 100644 --- a/direct/src/dcparser/dcClass.cxx +++ b/direct/src/dcparser/dcClass.cxx @@ -80,11 +80,11 @@ DCClass(DCFile *dc_file, const string &name, bool is_struct, bool bogus_class) : _bogus_class(bogus_class) { _number = -1; - _constructor = NULL; + _constructor = nullptr; #ifdef HAVE_PYTHON - _class_def = NULL; - _owner_class_def = NULL; + _class_def = nullptr; + _owner_class_def = nullptr; #endif } @@ -93,7 +93,7 @@ DCClass(DCFile *dc_file, const string &name, bool is_struct, bool bogus_class) : */ DCClass:: ~DCClass() { - if (_constructor != (DCField *)NULL) { + if (_constructor != nullptr) { delete _constructor; } @@ -137,7 +137,7 @@ get_num_parents() const { */ DCClass *DCClass:: get_parent(int n) const { - nassertr(n >= 0 && n < (int)_parents.size(), NULL); + nassertr(n >= 0 && n < (int)_parents.size(), nullptr); return _parents[n]; } @@ -147,7 +147,7 @@ get_parent(int n) const { */ bool DCClass:: has_constructor() const { - return (_constructor != (DCField *)NULL); + return (_constructor != nullptr); } /** @@ -183,7 +183,7 @@ get_field(int n) const { // __asm { int 3 } } #endif //] - nassertr_always(n >= 0 && n < (int)_fields.size(), NULL); + nassertr_always(n >= 0 && n < (int)_fields.size(), nullptr); return _fields[n]; } @@ -205,13 +205,13 @@ get_field_by_name(const string &name) const { Parents::const_iterator pi; for (pi = _parents.begin(); pi != _parents.end(); ++pi) { DCField *result = (*pi)->get_field_by_name(name); - if (result != (DCField *)NULL) { + if (result != nullptr) { return result; } } // Nobody knew what this field is. - return (DCField *)NULL; + return nullptr; } /** @@ -232,7 +232,7 @@ get_field_by_index(int index_number) const { Parents::const_iterator pi; for (pi = _parents.begin(); pi != _parents.end(); ++pi) { DCField *result = (*pi)->get_field_by_index(index_number); - if (result != (DCField *)NULL) { + if (result != nullptr) { // Cache this result for future lookups. ((DCClass *)this)->_fields_by_index[index_number] = result; return result; @@ -240,7 +240,7 @@ get_field_by_index(int index_number) const { } // Nobody knew what this field is. - return (DCField *)NULL; + return nullptr; } /** @@ -250,7 +250,7 @@ get_field_by_index(int index_number) const { int DCClass:: get_num_inherited_fields() const { if (dc_multiple_inheritance && dc_virtual_inheritance && - _dc_file != (DCFile *)NULL) { + _dc_file != nullptr) { _dc_file->check_inherited_fields(); if (_inherited_fields.empty()) { ((DCClass *)this)->rebuild_inherited_fields(); @@ -283,12 +283,12 @@ get_num_inherited_fields() const { DCField *DCClass:: get_inherited_field(int n) const { if (dc_multiple_inheritance && dc_virtual_inheritance && - _dc_file != (DCFile *)NULL) { + _dc_file != nullptr) { _dc_file->check_inherited_fields(); if (_inherited_fields.empty()) { ((DCClass *)this)->rebuild_inherited_fields(); } - nassertr(n >= 0 && n < (int)_inherited_fields.size(), NULL); + nassertr(n >= 0 && n < (int)_inherited_fields.size(), nullptr); return _inherited_fields[n]; } else { @@ -349,7 +349,7 @@ output(ostream &out) const { */ bool DCClass:: has_class_def() const { - return (_class_def != NULL); + return (_class_def != nullptr); } #endif // HAVE_PYTHON @@ -373,7 +373,7 @@ set_class_def(PyObject *class_def) { */ PyObject *DCClass:: get_class_def() const { - if (_class_def == NULL) { + if (_class_def == nullptr) { Py_INCREF(Py_None); return Py_None; } @@ -390,7 +390,7 @@ get_class_def() const { */ bool DCClass:: has_owner_class_def() const { - return (_owner_class_def != NULL); + return (_owner_class_def != nullptr); } #endif // HAVE_PYTHON @@ -414,7 +414,7 @@ set_owner_class_def(PyObject *owner_class_def) { */ PyObject *DCClass:: get_owner_class_def() const { - if (_owner_class_def == NULL) { + if (_owner_class_def == nullptr) { Py_INCREF(Py_None); return Py_None; } @@ -441,7 +441,7 @@ receive_update(PyObject *distobj, DatagramIterator &di) const { int field_id = packer.raw_unpack_uint16(); DCField *field = get_field_by_index(field_id); - if (field == (DCField *)NULL) { + if (field == nullptr) { ostringstream strm; strm << "Received update for field " << field_id << ", not in class " @@ -478,7 +478,7 @@ receive_update_broadcast_required(PyObject *distobj, DatagramIterator &di) const int num_fields = get_num_inherited_fields(); for (int i = 0; i < num_fields && !PyErr_Occurred(); ++i) { DCField *field = get_inherited_field(i); - if (field->as_molecular_field() == (DCMolecularField *)NULL && + if (field->as_molecular_field() == nullptr && field->is_required() && field->is_broadcast()) { packer.begin_unpack(field); field->receive_update(packer, distobj); @@ -513,7 +513,7 @@ receive_update_broadcast_required_owner(PyObject *distobj, int num_fields = get_num_inherited_fields(); for (int i = 0; i < num_fields && !PyErr_Occurred(); ++i) { DCField *field = get_inherited_field(i); - if (field->as_molecular_field() == (DCMolecularField *)NULL && + if (field->as_molecular_field() == nullptr && field->is_required() && (field->is_ownrecv() || field->is_broadcast())) { packer.begin_unpack(field); field->receive_update(packer, distobj); @@ -546,7 +546,7 @@ receive_update_all_required(PyObject *distobj, DatagramIterator &di) const { int num_fields = get_num_inherited_fields(); for (int i = 0; i < num_fields && !PyErr_Occurred(); ++i) { DCField *field = get_inherited_field(i); - if (field->as_molecular_field() == (DCMolecularField *)NULL && + if (field->as_molecular_field() == nullptr && field->is_required()) { packer.begin_unpack(field); field->receive_update(packer, distobj); @@ -585,7 +585,7 @@ void DCClass:: direct_update(PyObject *distobj, const string &field_name, const string &value_blob) { DCField *field = get_field_by_name(field_name); - nassertv_always(field != NULL); + nassertv_always(field != nullptr); DCPacker packer; packer.set_unpack_data(value_blob); @@ -645,7 +645,7 @@ bool DCClass:: pack_required_field(DCPacker &packer, PyObject *distobj, const DCField *field) const { const DCParameter *parameter = field->as_parameter(); - if (parameter != (DCParameter *)NULL) { + if (parameter != nullptr) { // This is the easy case: to pack a parameter, we just look on the class // object for the data element. string field_name = field->get_name(); @@ -668,7 +668,7 @@ pack_required_field(DCPacker &packer, PyObject *distobj, } PyObject *result = PyObject_GetAttrString(distobj, (char *)field_name.c_str()); - nassertr(result != (PyObject *)NULL, false); + nassertr(result != nullptr, false); // Now pack the value into the datagram. bool pack_ok = parameter->pack_args(packer, result); @@ -677,7 +677,7 @@ pack_required_field(DCPacker &packer, PyObject *distobj, return pack_ok; } - if (field->as_molecular_field() != (DCMolecularField *)NULL) { + if (field->as_molecular_field() != nullptr) { ostringstream strm; strm << "Cannot pack molecular field " << field->get_name() << " for generate"; @@ -686,7 +686,7 @@ pack_required_field(DCPacker &packer, PyObject *distobj, } const DCAtomicField *atom = field->as_atomic_field(); - nassertr(atom != (DCAtomicField *)NULL, false); + nassertr(atom != nullptr, false); // We need to get the initial value of this field. There isn't a good, // robust way to get this; presently, we just mangle the "setFoo()" name of @@ -740,13 +740,13 @@ pack_required_field(DCPacker &packer, PyObject *distobj, } PyObject *func = PyObject_GetAttrString(distobj, (char *)getter_name.c_str()); - nassertr(func != (PyObject *)NULL, false); + nassertr(func != nullptr, false); PyObject *empty_args = PyTuple_New(0); PyObject *result = PyObject_CallObject(func, empty_args); Py_DECREF(empty_args); Py_DECREF(func); - if (result == (PyObject *)NULL) { + if (result == nullptr) { // We don't set this as an exception, since presumably the Python method // itself has already triggered a Python exception. cerr << "Error when calling " << getter_name << "\n"; @@ -789,7 +789,7 @@ Datagram DCClass:: client_format_update(const string &field_name, DOID_TYPE do_id, PyObject *args) const { DCField *field = get_field_by_name(field_name); - if (field == (DCField *)NULL) { + if (field == nullptr) { ostringstream strm; strm << "No field named " << field_name << " in class " << get_name() << "\n"; @@ -810,7 +810,7 @@ Datagram DCClass:: ai_format_update(const string &field_name, DOID_TYPE do_id, CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, PyObject *args) const { DCField *field = get_field_by_name(field_name); - if (field == (DCField *)NULL) { + if (field == nullptr) { ostringstream strm; strm << "No field named " << field_name << " in class " << get_name() << "\n"; @@ -832,7 +832,7 @@ Datagram DCClass:: ai_format_update_msg_type(const string &field_name, DOID_TYPE do_id, CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, int msg_type, PyObject *args) const { DCField *field = get_field_by_name(field_name); - if (field == (DCField *)NULL) { + if (field == nullptr) { ostringstream strm; strm << "No field named " << field_name << " in class " << get_name() << "\n"; @@ -871,7 +871,7 @@ client_format_generate_CMU(PyObject *distobj, DOID_TYPE do_id, int num_fields = get_num_inherited_fields(); for (int i = 0; i < num_fields; ++i) { DCField *field = get_inherited_field(i); - if (field->is_required() && field->as_molecular_field() == NULL) { + if (field->is_required() && field->as_molecular_field() == nullptr) { packer.begin_pack(field); if (!pack_required_field(packer, distobj, field)) { return Datagram(); @@ -897,7 +897,7 @@ client_format_generate_CMU(PyObject *distobj, DOID_TYPE do_id, Py_XDECREF(py_field_name); DCField *field = get_field_by_name(field_name); - if (field == (DCField *)NULL) { + if (field == nullptr) { ostringstream strm; strm << "No field named " << field_name << " in class " << get_name() << "\n"; @@ -956,7 +956,7 @@ ai_format_generate(PyObject *distobj, DOID_TYPE do_id, int num_fields = get_num_inherited_fields(); for (int i = 0; i < num_fields; ++i) { DCField *field = get_inherited_field(i); - if (field->is_required() && field->as_molecular_field() == NULL) { + if (field->is_required() && field->as_molecular_field() == nullptr) { packer.begin_pack(field); if (!pack_required_field(packer, distobj, field)) { return Datagram(); @@ -980,7 +980,7 @@ ai_format_generate(PyObject *distobj, DOID_TYPE do_id, Py_XDECREF(py_field_name); DCField *field = get_field_by_name(field_name); - if (field == (DCField *)NULL) { + if (field == nullptr) { ostringstream strm; strm << "No field named " << field_name << " in class " << get_name() << "\n"; @@ -1042,7 +1042,7 @@ write(ostream &out, bool brief, int indent_level) const { } out << "\n"; - if (_constructor != (DCField *)NULL) { + if (_constructor != nullptr) { _constructor->write(out, brief, indent_level + 2); } @@ -1098,7 +1098,7 @@ output_instance(ostream &out, bool brief, const string &prename, out << " {"; - if (_constructor != (DCField *)NULL) { + if (_constructor != nullptr) { _constructor->output(out, brief); out << "; "; } @@ -1134,7 +1134,7 @@ generate_hash(HashGenerator &hashgen) const { hashgen.add_int((*pi)->get_number()); } - if (_constructor != (DCField *)NULL) { + if (_constructor != nullptr) { _constructor->generate_hash(hashgen); } @@ -1247,20 +1247,20 @@ shadow_inherited_field(const string &name) { */ bool DCClass:: add_field(DCField *field) { - nassertr(field->get_class() == this || field->get_class() == NULL, false); + nassertr(field->get_class() == this || field->get_class() == nullptr, false); field->set_class(this); - if (_dc_file != (DCFile *)NULL) { + if (_dc_file != nullptr) { _dc_file->mark_inherited_fields_stale(); } if (!field->get_name().empty()) { if (field->get_name() == _name) { // This field is a constructor. - if (_constructor != (DCField *)NULL) { + if (_constructor != nullptr) { // We already have a constructor. return false; } - if (field->as_atomic_field() == (DCAtomicField *)NULL) { + if (field->as_atomic_field() == nullptr) { // The constructor must be an atomic field. return false; } @@ -1278,7 +1278,7 @@ add_field(DCField *field) { } } - if (_dc_file != (DCFile *)NULL && + if (_dc_file != nullptr && ((dc_virtual_inheritance && dc_sort_inheritance_by_file) || !is_struct())) { if (dc_multiple_inheritance) { _dc_file->set_new_index_number(field); diff --git a/direct/src/dcparser/dcClassParameter.cxx b/direct/src/dcparser/dcClassParameter.cxx index be5ca00283..379dbb5961 100644 --- a/direct/src/dcparser/dcClassParameter.cxx +++ b/direct/src/dcparser/dcClassParameter.cxx @@ -119,7 +119,7 @@ get_class() const { */ DCPackerInterface *DCClassParameter:: get_nested_field(int n) const { - nassertr(n >= 0 && n < (int)_nested_fields.size(), NULL); + nassertr(n >= 0 && n < (int)_nested_fields.size(), nullptr); return _nested_fields[n]; } @@ -130,7 +130,7 @@ get_nested_field(int n) const { void DCClassParameter:: output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const { - if (get_typedef() != (DCTypedef *)NULL) { + if (get_typedef() != nullptr) { output_typedef_name(out, brief, prename, name, postname); } else { diff --git a/direct/src/dcparser/dcDeclaration.cxx b/direct/src/dcparser/dcDeclaration.cxx index fd86238b4a..7da467a44a 100644 --- a/direct/src/dcparser/dcDeclaration.cxx +++ b/direct/src/dcparser/dcDeclaration.cxx @@ -26,7 +26,7 @@ DCDeclaration:: */ DCClass *DCDeclaration:: as_class() { - return (DCClass *)NULL; + return nullptr; } /** @@ -34,7 +34,7 @@ as_class() { */ const DCClass *DCDeclaration:: as_class() const { - return (DCClass *)NULL; + return nullptr; } /** @@ -42,7 +42,7 @@ as_class() const { */ DCSwitch *DCDeclaration:: as_switch() { - return (DCSwitch *)NULL; + return nullptr; } /** @@ -50,7 +50,7 @@ as_switch() { */ const DCSwitch *DCDeclaration:: as_switch() const { - return (DCSwitch *)NULL; + return nullptr; } /** diff --git a/direct/src/dcparser/dcField.cxx b/direct/src/dcparser/dcField.cxx index a44412638a..eeace485c6 100644 --- a/direct/src/dcparser/dcField.cxx +++ b/direct/src/dcparser/dcField.cxx @@ -31,7 +31,7 @@ */ DCField:: DCField() : - _dclass(NULL) + _dclass(nullptr) #ifdef WITHIN_PANDA , _field_update_pcollector("DCField") @@ -108,7 +108,7 @@ as_field() const { */ DCAtomicField *DCField:: as_atomic_field() { - return (DCAtomicField *)NULL; + return nullptr; } /** @@ -117,7 +117,7 @@ as_atomic_field() { */ const DCAtomicField *DCField:: as_atomic_field() const { - return (DCAtomicField *)NULL; + return nullptr; } /** @@ -126,7 +126,7 @@ as_atomic_field() const { */ DCMolecularField *DCField:: as_molecular_field() { - return (DCMolecularField *)NULL; + return nullptr; } /** @@ -135,7 +135,7 @@ as_molecular_field() { */ const DCMolecularField *DCField:: as_molecular_field() const { - return (DCMolecularField *)NULL; + return nullptr; } /** @@ -143,7 +143,7 @@ as_molecular_field() const { */ DCParameter *DCField:: as_parameter() { - return (DCParameter *)NULL; + return nullptr; } /** @@ -151,7 +151,7 @@ as_parameter() { */ const DCParameter *DCField:: as_parameter() const { - return (DCParameter *)NULL; + return nullptr; } /** @@ -235,7 +235,7 @@ pack_args(DCPacker &packer, PyObject *sequence) const { ostringstream strm; PyObject *exc_type = PyExc_Exception; - if (as_parameter() != (DCParameter *)NULL) { + if (as_parameter() != nullptr) { // If it's a parameter-type field, the value may or may not be a // sequence. if (packer.had_pack_error()) { @@ -251,7 +251,7 @@ pack_args(DCPacker &packer, PyObject *sequence) const { } else { // If it's a molecular or atomic field, the value should be a sequence. PyObject *tuple = PySequence_Tuple(sequence); - if (tuple == (PyObject *)NULL) { + if (tuple == nullptr) { strm << "Value for " << get_name() << " not a sequence: " \ << get_pystr(sequence); exc_type = PyExc_TypeError; @@ -287,8 +287,8 @@ pack_args(DCPacker &packer, PyObject *sequence) const { */ PyObject *DCField:: unpack_args(DCPacker &packer) const { - nassertr(!packer.had_error(), NULL); - nassertr(packer.get_current_field() == this, NULL); + nassertr(!packer.had_error(), nullptr); + nassertr(packer.get_current_field() == this, nullptr); size_t start_byte = packer.get_num_unpacked_bytes(); PyObject *object = packer.unpack_object(); @@ -329,7 +329,7 @@ unpack_args(DCPacker &packer) const { } Py_XDECREF(object); - return NULL; + return nullptr; } #endif // HAVE_PYTHON @@ -340,10 +340,10 @@ unpack_args(DCPacker &packer) const { */ void DCField:: receive_update(DCPacker &packer, PyObject *distobj) const { - if (as_parameter() != (DCParameter *)NULL) { + if (as_parameter() != nullptr) { // If it's a parameter-type field, just store a new value on the object. PyObject *value = unpack_args(packer); - if (value != (PyObject *)NULL) { + if (value != nullptr) { PyObject_SetAttrString(distobj, (char *)_name.c_str(), value); } Py_DECREF(value); @@ -362,9 +362,9 @@ receive_update(DCPacker &packer, PyObject *distobj) const { // method. PyObject *args = unpack_args(packer); - if (args != (PyObject *)NULL) { + if (args != nullptr) { PyObject *func = PyObject_GetAttrString(distobj, (char *)_name.c_str()); - nassertv(func != (PyObject *)NULL); + nassertv(func != nullptr); PyObject *result; { @@ -499,7 +499,7 @@ pack_default_value(DCPackData &pack_data, bool &) const { void DCField:: set_name(const string &name) { DCPackerInterface::set_name(name); - if (_dclass != (DCClass *)NULL) { + if (_dclass != nullptr) { _dclass->_dc_file->mark_inherited_fields_stale(); } } @@ -510,12 +510,12 @@ set_name(const string &name) { */ string DCField:: get_pystr(PyObject *value) { - if (value == NULL) { + if (value == nullptr) { return "(null)"; } PyObject *str = PyObject_Str(value); - if (str != NULL) { + if (str != nullptr) { #if PY_MAJOR_VERSION >= 3 string result = PyUnicode_AsUTF8(str); #else @@ -526,7 +526,7 @@ get_pystr(PyObject *value) { } PyObject *repr = PyObject_Repr(value); - if (repr != NULL) { + if (repr != nullptr) { #if PY_MAJOR_VERSION >= 3 string result = PyUnicode_AsUTF8(repr); #else @@ -536,9 +536,9 @@ get_pystr(PyObject *value) { return result; } - if (value->ob_type != NULL) { + if (value->ob_type != nullptr) { PyObject *typestr = PyObject_Str((PyObject *)(value->ob_type)); - if (typestr != NULL) { + if (typestr != nullptr) { #if PY_MAJOR_VERSION >= 3 string result = PyUnicode_AsUTF8(typestr); #else diff --git a/direct/src/dcparser/dcFile.cxx b/direct/src/dcparser/dcFile.cxx index 9dc7009dca..43301e4615 100644 --- a/direct/src/dcparser/dcFile.cxx +++ b/direct/src/dcparser/dcFile.cxx @@ -123,7 +123,7 @@ read(Filename filename) { filename.set_text(); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *in = vfs->open_read_file(filename, true); - if (in == (istream *)NULL) { + if (in == nullptr) { cerr << "Cannot open " << filename << " for reading.\n"; return false; } @@ -247,7 +247,7 @@ get_num_classes() const { */ DCClass *DCFile:: get_class(int n) const { - nassertr(n >= 0 && n < (int)_classes.size(), NULL); + nassertr(n >= 0 && n < (int)_classes.size(), nullptr); return _classes[n]; } @@ -263,7 +263,7 @@ get_class_by_name(const string &name) const { return (*ni).second->as_class(); } - return (DCClass *)NULL; + return nullptr; } /** @@ -278,7 +278,7 @@ get_switch_by_name(const string &name) const { return (*ni).second->as_switch(); } - return (DCSwitch *)NULL; + return nullptr; } /** @@ -291,13 +291,13 @@ get_switch_by_name(const string &name) const { */ DCField *DCFile:: get_field_by_index(int index_number) const { - nassertr(dc_multiple_inheritance, NULL); + nassertr(dc_multiple_inheritance, nullptr); if (index_number >= 0 && index_number < (int)_fields_by_index.size()) { return _fields_by_index[index_number]; } - return NULL; + return nullptr; } /** @@ -352,7 +352,7 @@ get_num_typedefs() const { */ DCTypedef *DCFile:: get_typedef(int n) const { - nassertr(n >= 0 && n < (int)_typedefs.size(), NULL); + nassertr(n >= 0 && n < (int)_typedefs.size(), nullptr); return _typedefs[n]; } @@ -368,7 +368,7 @@ get_typedef_by_name(const string &name) const { return (*ni).second; } - return NULL; + return nullptr; } /** @@ -394,9 +394,9 @@ get_keyword(int n) const { const DCKeyword *DCFile:: get_keyword_by_name(const string &name) const { const DCKeyword *keyword = _keywords.get_keyword_by_name(name); - if (keyword == (const DCKeyword *)NULL) { + if (keyword == nullptr) { keyword = _default_keywords.get_keyword_by_name(name); - if (keyword != (const DCKeyword *)NULL) { + if (keyword != nullptr) { // One of the historical default keywords was used, but wasn't defined. // Define it implicitly right now. ((DCFile *)this)->_keywords.add_keyword(keyword); @@ -612,11 +612,11 @@ setup_default_keywords() { { "clrecv", 0x0040 }, { "ownsend", 0x0080 }, { "airecv", 0x0100 }, - { NULL, 0 } + { nullptr, 0 } }; _default_keywords.clear_keywords(); - for (int i = 0; default_keywords[i].name != NULL; ++i) { + for (int i = 0; default_keywords[i].name != nullptr; ++i) { DCKeyword *keyword = new DCKeyword(default_keywords[i].name, default_keywords[i].flag); diff --git a/direct/src/dcparser/dcKeywordList.cxx b/direct/src/dcparser/dcKeywordList.cxx index d3f2d0347e..c2cba110b6 100644 --- a/direct/src/dcparser/dcKeywordList.cxx +++ b/direct/src/dcparser/dcKeywordList.cxx @@ -83,7 +83,7 @@ get_num_keywords() const { */ const DCKeyword *DCKeywordList:: get_keyword(int n) const { - nassertr(n >= 0 && n < (int)_keywords.size(), NULL); + nassertr(n >= 0 && n < (int)_keywords.size(), nullptr); return _keywords[n]; } @@ -99,7 +99,7 @@ get_keyword_by_name(const string &name) const { return (*ni).second; } - return NULL; + return nullptr; } /** diff --git a/direct/src/dcparser/dcLexer.lxx b/direct/src/dcparser/dcLexer.lxx index 4dbd18299d..b2d83dad47 100644 --- a/direct/src/dcparser/dcLexer.lxx +++ b/direct/src/dcparser/dcLexer.lxx @@ -35,7 +35,7 @@ static int error_count = 0; static int warning_count = 0; // This is the pointer to the current input stream. -static istream *input_p = NULL; +static istream *input_p = nullptr; // This is the name of the dc file we're parsing. We keep it so we // can print it out for error messages. @@ -129,7 +129,7 @@ dcyywarning(const string &msg) { // stdio FILE pointer. This is flex-specific. static void input_chars(char *buffer, int &result, int max_size) { - nassertv(input_p != NULL); + nassertv(input_p != nullptr); if (*input_p) { input_p->read(buffer, max_size); result = input_p->gcount(); @@ -150,7 +150,7 @@ input_chars(char *buffer, int &result, int max_size) { // Truncate it at the newline. char *end = strchr(current_line, '\n'); - if (end != NULL) { + if (end != nullptr) { *end = '\0'; } } @@ -733,9 +733,9 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) accept(); dcyylval.str = dcyytext; - if (dc_file != (DCFile *)NULL) { + if (dc_file != nullptr) { const DCKeyword *keyword = dc_file->get_keyword_by_name(dcyylval.str); - if (keyword != (DCKeyword *)NULL) { + if (keyword != nullptr) { dcyylval.u.keyword = keyword; return KEYWORD; } diff --git a/direct/src/dcparser/dcMolecularField.cxx b/direct/src/dcparser/dcMolecularField.cxx index 4bb0c3241f..178c86ad2e 100644 --- a/direct/src/dcparser/dcMolecularField.cxx +++ b/direct/src/dcparser/dcMolecularField.cxx @@ -59,7 +59,7 @@ get_num_atomics() const { */ DCAtomicField *DCMolecularField:: get_atomic(int n) const { - nassertr(n >= 0 && n < (int)_fields.size(), NULL); + nassertr(n >= 0 && n < (int)_fields.size(), nullptr); return _fields[n]; } @@ -161,7 +161,7 @@ generate_hash(HashGenerator &hashgen) const { */ DCPackerInterface *DCMolecularField:: get_nested_field(int n) const { - nassertr(n >= 0 && n < (int)_nested_fields.size(), NULL); + nassertr(n >= 0 && n < (int)_nested_fields.size(), nullptr); return _nested_fields[n]; } diff --git a/direct/src/dcparser/dcPackData.I b/direct/src/dcparser/dcPackData.I index 3766f64d2f..e1523f09ad 100644 --- a/direct/src/dcparser/dcPackData.I +++ b/direct/src/dcparser/dcPackData.I @@ -16,7 +16,7 @@ */ INLINE DCPackData:: DCPackData() { - _buffer = NULL; + _buffer = nullptr; _allocated_size = 0; _used_length = 0; } @@ -26,7 +26,7 @@ DCPackData() { */ INLINE DCPackData:: ~DCPackData() { - if (_buffer != (const char *)NULL) { + if (_buffer != nullptr) { delete[] _buffer; } } @@ -82,7 +82,7 @@ rewrite_data(size_t position, const char *buffer, size_t size) { */ INLINE char *DCPackData:: get_rewrite_pointer(size_t position, size_t size) { - nassertr(position + size <= _used_length, NULL); + nassertr(position + size <= _used_length, nullptr); return _buffer + position; } @@ -129,7 +129,7 @@ INLINE char *DCPackData:: take_data() { char *data = _buffer; - _buffer = NULL; + _buffer = nullptr; _allocated_size = 0; _used_length = 0; diff --git a/direct/src/dcparser/dcPackData.cxx b/direct/src/dcparser/dcPackData.cxx index 4276c735f4..2c0c19a61d 100644 --- a/direct/src/dcparser/dcPackData.cxx +++ b/direct/src/dcparser/dcPackData.cxx @@ -27,7 +27,7 @@ set_used_length(size_t size) { if (_used_length > 0) { memcpy(new_buf, _buffer, _used_length); } - if (_buffer != NULL) { + if (_buffer != nullptr) { delete[] _buffer; } _buffer = new_buf; diff --git a/direct/src/dcparser/dcPacker.I b/direct/src/dcparser/dcPacker.I index c159b0cb77..9bb4607dd6 100644 --- a/direct/src/dcparser/dcPacker.I +++ b/direct/src/dcparser/dcPacker.I @@ -24,7 +24,7 @@ clear_data() { delete[] _unpack_data; _owns_unpack_data = false; } - _unpack_data = NULL; + _unpack_data = nullptr; } /** @@ -35,7 +35,7 @@ clear_data() { */ INLINE bool DCPacker:: has_nested_fields() const { - if (_current_field == NULL) { + if (_current_field == nullptr) { return false; } else { return _current_field->has_nested_fields(); @@ -65,7 +65,7 @@ get_num_nested_fields() const { */ INLINE bool DCPacker:: more_nested_fields() const { - return (_current_field != (DCPackerInterface *)NULL && !_pack_error); + return (_current_field != nullptr && !_pack_error); } /** @@ -112,7 +112,7 @@ get_last_switch() const { */ INLINE DCPackType DCPacker:: get_pack_type() const { - if (_current_field == NULL) { + if (_current_field == nullptr) { return PT_invalid; } else { return _current_field->get_pack_type(); @@ -125,7 +125,7 @@ get_pack_type() const { */ INLINE string DCPacker:: get_current_field_name() const { - if (_current_field == NULL) { + if (_current_field == nullptr) { return string(); } else { return _current_field->get_name(); @@ -138,7 +138,7 @@ get_current_field_name() const { INLINE void DCPacker:: pack_double(double value) { nassertv(_mode == M_pack || _mode == M_repack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { _current_field->pack_double(_pack_data, value, _pack_error, _range_error); @@ -152,7 +152,7 @@ pack_double(double value) { INLINE void DCPacker:: pack_int(int value) { nassertv(_mode == M_pack || _mode == M_repack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { _current_field->pack_int(_pack_data, value, _pack_error, _range_error); @@ -166,7 +166,7 @@ pack_int(int value) { INLINE void DCPacker:: pack_uint(unsigned int value) { nassertv(_mode == M_pack || _mode == M_repack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { _current_field->pack_uint(_pack_data, value, _pack_error, _range_error); @@ -180,7 +180,7 @@ pack_uint(unsigned int value) { INLINE void DCPacker:: pack_int64(int64_t value) { nassertv(_mode == M_pack || _mode == M_repack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { _current_field->pack_int64(_pack_data, value, _pack_error, _range_error); @@ -194,7 +194,7 @@ pack_int64(int64_t value) { INLINE void DCPacker:: pack_uint64(uint64_t value) { nassertv(_mode == M_pack || _mode == M_repack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { _current_field->pack_uint64(_pack_data, value, _pack_error, _range_error); @@ -208,7 +208,7 @@ pack_uint64(uint64_t value) { INLINE void DCPacker:: pack_string(const string &value) { nassertv(_mode == M_pack || _mode == M_repack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { _current_field->pack_string(_pack_data, value, _pack_error, _range_error); @@ -223,7 +223,7 @@ pack_string(const string &value) { INLINE void DCPacker:: pack_literal_value(const string &value) { nassertv(_mode == M_pack || _mode == M_repack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { _pack_data.append_data(value.data(), value.length()); @@ -238,7 +238,7 @@ INLINE double DCPacker:: unpack_double() { double value = 0.0; nassertr(_mode == M_unpack, value); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -257,7 +257,7 @@ INLINE int DCPacker:: unpack_int() { int value = 0; nassertr(_mode == M_unpack, value); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -276,7 +276,7 @@ INLINE unsigned int DCPacker:: unpack_uint() { unsigned int value = 0; nassertr(_mode == M_unpack, value); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -295,7 +295,7 @@ INLINE int64_t DCPacker:: unpack_int64() { int64_t value = 0; nassertr(_mode == M_unpack, value); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -314,7 +314,7 @@ INLINE uint64_t DCPacker:: unpack_uint64() { uint64_t value = 0; nassertr(_mode == M_unpack, value); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -333,7 +333,7 @@ INLINE string DCPacker:: unpack_string() { string value; nassertr(_mode == M_unpack, value); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -363,7 +363,7 @@ unpack_literal_value() { INLINE void DCPacker:: unpack_double(double &value) { nassertv(_mode == M_unpack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -379,7 +379,7 @@ unpack_double(double &value) { INLINE void DCPacker:: unpack_int(int &value) { nassertv(_mode == M_unpack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -395,7 +395,7 @@ unpack_int(int &value) { INLINE void DCPacker:: unpack_uint(unsigned int &value) { nassertv(_mode == M_unpack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -411,7 +411,7 @@ unpack_uint(unsigned int &value) { INLINE void DCPacker:: unpack_int64(int64_t &value) { nassertv(_mode == M_unpack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -427,7 +427,7 @@ unpack_int64(int64_t &value) { INLINE void DCPacker:: unpack_uint64(uint64_t &value) { nassertv(_mode == M_unpack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -443,7 +443,7 @@ unpack_uint64(uint64_t &value) { INLINE void DCPacker:: unpack_string(string &value) { nassertv(_mode == M_unpack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -613,7 +613,7 @@ append_data(const char *buffer, size_t size) { */ INLINE char *DCPacker:: get_write_pointer(size_t size) { - nassertr(_mode == M_idle, NULL); + nassertr(_mode == M_idle, nullptr); return _pack_data.get_write_pointer(size); } @@ -773,7 +773,7 @@ raw_unpack_int64() { */ INLINE void DCPacker:: raw_unpack_int8(int &value) { - nassertv(_mode == M_idle && _unpack_data != NULL); + nassertv(_mode == M_idle && _unpack_data != nullptr); if (_unpack_p + 1 > _unpack_length) { _pack_error = true; return; @@ -787,7 +787,7 @@ raw_unpack_int8(int &value) { */ INLINE void DCPacker:: raw_unpack_int16(int &value) { - nassertv(_mode == M_idle && _unpack_data != NULL); + nassertv(_mode == M_idle && _unpack_data != nullptr); if (_unpack_p + 2 > _unpack_length) { _pack_error = true; return; @@ -801,7 +801,7 @@ raw_unpack_int16(int &value) { */ INLINE void DCPacker:: raw_unpack_int32(int &value) { - nassertv(_mode == M_idle && _unpack_data != NULL); + nassertv(_mode == M_idle && _unpack_data != nullptr); if (_unpack_p + 4 > _unpack_length) { _pack_error = true; return; @@ -875,7 +875,7 @@ raw_unpack_string() { */ INLINE void DCPacker:: raw_unpack_int64(int64_t &value) { - nassertv(_mode == M_idle && _unpack_data != NULL); + nassertv(_mode == M_idle && _unpack_data != nullptr); if (_unpack_p + 8 > _unpack_length) { _pack_error = true; return; @@ -889,7 +889,7 @@ raw_unpack_int64(int64_t &value) { */ INLINE void DCPacker:: raw_unpack_uint8(unsigned int &value) { - nassertv(_mode == M_idle && _unpack_data != NULL); + nassertv(_mode == M_idle && _unpack_data != nullptr); if (_unpack_p + 1 > _unpack_length) { _pack_error = true; return; @@ -903,7 +903,7 @@ raw_unpack_uint8(unsigned int &value) { */ INLINE void DCPacker:: raw_unpack_uint16(unsigned int &value) { - nassertv(_mode == M_idle && _unpack_data != NULL); + nassertv(_mode == M_idle && _unpack_data != nullptr); if (_unpack_p + 2 > _unpack_length) { _pack_error = true; return; @@ -917,7 +917,7 @@ raw_unpack_uint16(unsigned int &value) { */ INLINE void DCPacker:: raw_unpack_uint32(unsigned int &value) { - nassertv(_mode == M_idle && _unpack_data != NULL); + nassertv(_mode == M_idle && _unpack_data != nullptr); if (_unpack_p + 4 > _unpack_length) { _pack_error = true; return; @@ -931,7 +931,7 @@ raw_unpack_uint32(unsigned int &value) { */ INLINE void DCPacker:: raw_unpack_uint64(uint64_t &value) { - nassertv(_mode == M_idle && _unpack_data != NULL); + nassertv(_mode == M_idle && _unpack_data != nullptr); if (_unpack_p + 8 > _unpack_length) { _pack_error = true; return; @@ -945,7 +945,7 @@ raw_unpack_uint64(uint64_t &value) { */ INLINE void DCPacker:: raw_unpack_float64(double &value) { - nassertv(_mode == M_idle && _unpack_data != NULL); + nassertv(_mode == M_idle && _unpack_data != nullptr); if (_unpack_p + 8 > _unpack_length) { _pack_error = true; return; @@ -959,7 +959,7 @@ raw_unpack_float64(double &value) { */ INLINE void DCPacker:: raw_unpack_string(string &value) { - nassertv(_mode == M_idle && _unpack_data != NULL); + nassertv(_mode == M_idle && _unpack_data != nullptr); unsigned int string_length = raw_unpack_uint16(); if (_unpack_p + string_length > _unpack_length) { @@ -981,13 +981,13 @@ advance() { _current_field_index >= _num_nested_fields) { // Done with all the fields on this parent. The caller must now call // pop(). - _current_field = NULL; + _current_field = nullptr; // But if the parent is a switch record, we make a special case so we can // get the alternate fields. - if (_current_parent != (DCPackerInterface *)NULL) { + if (_current_parent != nullptr) { const DCSwitchParameter *switch_parameter = ((DCPackerInterface *)_current_parent)->as_switch_parameter(); - if (switch_parameter != (DCSwitchParameter *)NULL) { + if (switch_parameter != nullptr) { handle_switch(switch_parameter); } } @@ -995,7 +995,7 @@ advance() { } else if (_pop_marker != 0 && _unpack_p >= _pop_marker) { // Done with all the fields on this parent. The caller must now call // pop(). - _current_field = NULL; + _current_field = nullptr; } else { // We have another field to advance to. @@ -1009,7 +1009,7 @@ advance() { */ INLINE void *DCPacker::StackElement:: operator new(size_t size) { - if (_deleted_chain != (DCPacker::StackElement *)NULL) { + if (_deleted_chain != nullptr) { StackElement *obj = _deleted_chain; _deleted_chain = _deleted_chain->_next; return obj; diff --git a/direct/src/dcparser/dcPacker.cxx b/direct/src/dcparser/dcPacker.cxx index 794d5e1690..119add847e 100644 --- a/direct/src/dcparser/dcPacker.cxx +++ b/direct/src/dcparser/dcPacker.cxx @@ -23,7 +23,7 @@ #include "py_panda.h" #endif -DCPacker::StackElement *DCPacker::StackElement::_deleted_chain = NULL; +DCPacker::StackElement *DCPacker::StackElement::_deleted_chain = nullptr; int DCPacker::StackElement::_num_ever_allocated = 0; /** @@ -32,15 +32,15 @@ int DCPacker::StackElement::_num_ever_allocated = 0; DCPacker:: DCPacker() { _mode = M_idle; - _unpack_data = NULL; + _unpack_data = nullptr; _unpack_length = 0; _owns_unpack_data = false; _unpack_p = 0; - _live_catalog = NULL; + _live_catalog = nullptr; _parse_error = false; _pack_error = false; _range_error = false; - _stack = NULL; + _stack = nullptr; clear(); } @@ -73,11 +73,11 @@ begin_pack(const DCPackerInterface *root) { _range_error = false; _root = root; - _catalog = NULL; - _live_catalog = NULL; + _catalog = nullptr; + _live_catalog = nullptr; _current_field = root; - _current_parent = NULL; + _current_parent = nullptr; _current_field_index = 0; _num_nested_fields = 0; } @@ -94,7 +94,7 @@ end_pack() { _mode = M_idle; - if (_stack != NULL || _current_field != NULL || _current_parent != NULL) { + if (_stack != nullptr || _current_field != nullptr || _current_parent != nullptr) { _pack_error = true; } @@ -146,7 +146,7 @@ set_unpack_data(const char *unpack_data, size_t unpack_length, void DCPacker:: begin_unpack(const DCPackerInterface *root) { nassertv(_mode == M_idle); - nassertv(_unpack_data != NULL); + nassertv(_unpack_data != nullptr); _mode = M_unpack; _parse_error = false; @@ -154,11 +154,11 @@ begin_unpack(const DCPackerInterface *root) { _range_error = false; _root = root; - _catalog = NULL; - _live_catalog = NULL; + _catalog = nullptr; + _live_catalog = nullptr; _current_field = root; - _current_parent = NULL; + _current_parent = nullptr; _current_field_index = 0; _num_nested_fields = 0; } @@ -175,13 +175,13 @@ end_unpack() { _mode = M_idle; - if (_stack != NULL || _current_field != NULL || _current_parent != NULL) { + if (_stack != nullptr || _current_field != nullptr || _current_parent != nullptr) { // This happens if we have not unpacked all of the fields. However, this // is not an error if we have called seek() during the unpack session (in // which case the _catalog will be non-NULL). On the other hand, if the // catalog is still NULL, then we have never called seek() and it is an // error not to unpack all values. - if (_catalog == (DCPackerCatalog *)NULL) { + if (_catalog == nullptr) { _pack_error = true; } } @@ -206,7 +206,7 @@ end_unpack() { void DCPacker:: begin_repack(const DCPackerInterface *root) { nassertv(_mode == M_idle); - nassertv(_unpack_data != NULL); + nassertv(_unpack_data != nullptr); nassertv(_unpack_p == 0); _mode = M_repack; @@ -220,14 +220,14 @@ begin_repack(const DCPackerInterface *root) { _root = root; _catalog = _root->get_catalog(); _live_catalog = _catalog->get_live_catalog(_unpack_data, _unpack_length); - if (_live_catalog == NULL) { + if (_live_catalog == nullptr) { _pack_error = true; } // We don't begin at the first field in repack mode. Instead, you must // explicitly call seek(). - _current_field = NULL; - _current_parent = NULL; + _current_field = nullptr; + _current_parent = nullptr; _current_field_index = 0; _num_nested_fields = 0; } @@ -262,12 +262,12 @@ end_repack() { */ bool DCPacker:: seek(const string &field_name) { - if (_catalog == (DCPackerCatalog *)NULL) { + if (_catalog == nullptr) { _catalog = _root->get_catalog(); _live_catalog = _catalog->get_live_catalog(_unpack_data, _unpack_length); } - nassertr(_catalog != (DCPackerCatalog *)NULL, false); - if (_live_catalog == NULL) { + nassertr(_catalog != nullptr, false); + if (_live_catalog == nullptr) { _pack_error = true; return false; } @@ -292,12 +292,12 @@ seek(const string &field_name) { */ bool DCPacker:: seek(int seek_index) { - if (_catalog == (DCPackerCatalog *)NULL) { + if (_catalog == nullptr) { _catalog = _root->get_catalog(); _live_catalog = _catalog->get_live_catalog(_unpack_data, _unpack_length); } - nassertr(_catalog != (DCPackerCatalog *)NULL, false); - if (_live_catalog == NULL) { + nassertr(_catalog != nullptr, false); + if (_live_catalog == nullptr) { _pack_error = true; return false; } @@ -324,9 +324,9 @@ seek(int seek_index) { return true; } else if (_mode == M_repack) { - nassertr(_catalog != (DCPackerCatalog *)NULL, false); + nassertr(_catalog != nullptr, false); - if (_stack != NULL || _current_field != NULL) { + if (_stack != nullptr || _current_field != nullptr) { // It is an error to reseek while the stack is nonempty--that means we // haven't finished packing the current field. _pack_error = true; @@ -334,7 +334,7 @@ seek(int seek_index) { } const DCPackerCatalog::Entry &entry = _live_catalog->get_entry(seek_index); - if (entry._parent->as_switch_parameter() != (DCSwitchParameter *)NULL) { + if (entry._parent->as_switch_parameter() != nullptr) { // If the parent is a DCSwitch, that can only mean that the seeked field // is a switch parameter. We can't support seeking to a switch // parameter and modifying it directly--what would happen to all of the @@ -357,7 +357,7 @@ seek(int seek_index) { _catalog->release_live_catalog(_live_catalog); _live_catalog = _catalog->get_live_catalog(_unpack_data, _unpack_length); - if (_live_catalog == NULL) { + if (_live_catalog == nullptr) { _pack_error = true; return false; } @@ -470,7 +470,7 @@ push() { if (_num_nested_fields >= 0 && _current_field_index >= _num_nested_fields) { - _current_field = NULL; + _current_field = nullptr; } else { _current_field = _current_parent->get_nested_field(_current_field_index); @@ -487,7 +487,7 @@ push() { */ void DCPacker:: pop() { - if (_current_field != NULL && _num_nested_fields >= 0) { + if (_current_field != nullptr && _num_nested_fields >= 0) { // Oops, didn't pack or unpack enough values. _pack_error = true; @@ -497,7 +497,7 @@ pop() { _pack_error = true; } - if (_stack == NULL) { + if (_stack == nullptr) { // Unbalanced pop(). _pack_error = true; @@ -528,7 +528,7 @@ pop() { _current_field_index = _stack->_current_field_index; _push_marker = _stack->_push_marker; _pop_marker = _stack->_pop_marker; - _num_nested_fields = (_current_parent == NULL) ? 0 : _current_parent->get_num_nested_fields(); + _num_nested_fields = (_current_parent == nullptr) ? 0 : _current_parent->get_num_nested_fields(); StackElement *next = _stack->_next; delete _stack; @@ -545,7 +545,7 @@ pop() { void DCPacker:: pack_default_value() { nassertv(_mode == M_pack || _mode == M_repack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { if (_current_field->pack_default_value(_pack_data, _pack_error)) { @@ -571,7 +571,7 @@ pack_default_value() { void DCPacker:: unpack_validate() { nassertv(_mode == M_unpack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -597,7 +597,7 @@ unpack_validate() { void DCPacker:: unpack_skip() { nassertv(_mode == M_unpack); - if (_current_field == NULL) { + if (_current_field == nullptr) { _pack_error = true; } else { @@ -739,11 +739,11 @@ pack_object(PyObject *object) { (PyObject_HasAttrString(object, "__len__") != 0); bool is_instance = false; - const DCClass *dclass = NULL; + const DCClass *dclass = nullptr; const DCPackerInterface *current_field = get_current_field(); - if (current_field != (DCPackerInterface *)NULL) { + if (current_field != nullptr) { const DCClassParameter *class_param = get_current_field()->as_class_parameter(); - if (class_param != (DCClassParameter *)NULL) { + if (class_param != nullptr) { dclass = class_param->get_class(); if (dclass->has_class_def()) { @@ -771,7 +771,7 @@ pack_object(PyObject *object) { // (3) Otherwise, it is considered to be a class object. - if (dclass != (DCClass *)NULL && (is_instance || !is_sequence)) { + if (dclass != nullptr && (is_instance || !is_sequence)) { // The supplied object is either an instance of the expected class // object, or it is not a sequence--this is case (1) or (3). pack_class_object(dclass, object); @@ -782,7 +782,7 @@ pack_object(PyObject *object) { int size = PySequence_Size(object); for (int i = 0; i < size; ++i) { PyObject *element = PySequence_GetItem(object, i); - if (element != (PyObject *)NULL) { + if (element != nullptr) { pack_object(element); Py_DECREF(element); } else { @@ -812,7 +812,7 @@ pack_object(PyObject *object) { */ PyObject *DCPacker:: unpack_object() { - PyObject *object = NULL; + PyObject *object = nullptr; DCPackType pack_type = get_pack_type(); @@ -896,13 +896,13 @@ unpack_object() { case PT_class: { const DCClassParameter *class_param = get_current_field()->as_class_parameter(); - if (class_param != (DCClassParameter *)NULL) { + if (class_param != nullptr) { const DCClass *dclass = class_param->get_class(); if (dclass->has_class_def()) { // If we know what kind of class object this is and it has a valid // constructor, create the class object instead of just a tuple. object = unpack_class_object(dclass); - if (object == (PyObject *)NULL) { + if (object == nullptr) { cerr << "Unable to construct object of class " << dclass->get_name() << "\n"; } else { @@ -939,7 +939,7 @@ unpack_object() { break; } - nassertr(object != (PyObject *)NULL, NULL); + nassertr(object != nullptr, nullptr); return object; } #endif // HAVE_PYTHON @@ -995,10 +995,10 @@ unpack_and_format(ostream &out, bool show_field_names) { DCPackType pack_type = get_pack_type(); if (show_field_names && !get_current_field_name().empty()) { - nassertv(_current_field != (DCPackerInterface *)NULL); + nassertv(_current_field != nullptr); const DCField *field = _current_field->as_field(); - if (field != (DCField *)NULL && - field->as_parameter() != (DCParameter *)NULL) { + if (field != nullptr && + field->as_parameter() != nullptr) { out << field->get_name() << " = "; } } @@ -1135,7 +1135,7 @@ void DCPacker:: handle_switch(const DCSwitchParameter *switch_parameter) { // First, get the value from the key. This is either found in the unpack or // the pack data, depending on what mode we're in. - const DCPackerInterface *new_parent = NULL; + const DCPackerInterface *new_parent = nullptr; if (_mode == M_pack || _mode == M_repack) { const char *data = _pack_data.get_data(); @@ -1147,7 +1147,7 @@ handle_switch(const DCSwitchParameter *switch_parameter) { (_unpack_data + _push_marker, _unpack_p - _push_marker); } - if (new_parent == (DCPackerInterface *)NULL) { + if (new_parent == nullptr) { // This means an invalid value was packed for the key. _range_error = true; return; @@ -1173,20 +1173,20 @@ handle_switch(const DCSwitchParameter *switch_parameter) { void DCPacker:: clear() { clear_stack(); - _current_field = NULL; - _current_parent = NULL; + _current_field = nullptr; + _current_parent = nullptr; _current_field_index = 0; _num_nested_fields = 0; _push_marker = 0; _pop_marker = 0; - _last_switch = NULL; + _last_switch = nullptr; - if (_live_catalog != (DCPackerCatalog::LiveCatalog *)NULL) { + if (_live_catalog != nullptr) { _catalog->release_live_catalog(_live_catalog); - _live_catalog = NULL; + _live_catalog = nullptr; } - _catalog = NULL; - _root = NULL; + _catalog = nullptr; + _root = nullptr; } /** @@ -1194,7 +1194,7 @@ clear() { */ void DCPacker:: clear_stack() { - while (_stack != (StackElement *)NULL) { + while (_stack != nullptr) { StackElement *next = _stack->_next; delete _stack; _stack = next; @@ -1212,7 +1212,7 @@ pack_class_object(const DCClass *dclass, PyObject *object) { push(); while (more_nested_fields() && !_pack_error) { const DCField *field = get_current_field()->as_field(); - nassertv(field != (DCField *)NULL); + nassertv(field != nullptr); get_class_element(dclass, object, field); } pop(); @@ -1227,36 +1227,36 @@ pack_class_object(const DCClass *dclass, PyObject *object) { PyObject *DCPacker:: unpack_class_object(const DCClass *dclass) { PyObject *class_def = dclass->get_class_def(); - nassertr(class_def != (PyObject *)NULL, NULL); + nassertr(class_def != nullptr, nullptr); - PyObject *object = NULL; + PyObject *object = nullptr; if (!dclass->has_constructor()) { // If the class uses a default constructor, go ahead and create the Python // object for it now. - object = PyObject_CallObject(class_def, NULL); - if (object == (PyObject *)NULL) { - return NULL; + object = PyObject_CallObject(class_def, nullptr); + if (object == nullptr) { + return nullptr; } } push(); - if (object == (PyObject *)NULL && more_nested_fields()) { + if (object == nullptr && more_nested_fields()) { // The first nested field will be the constructor. const DCField *field = get_current_field()->as_field(); - nassertr(field != (DCField *)NULL, object); + nassertr(field != nullptr, object); nassertr(field == dclass->get_constructor(), object); set_class_element(class_def, object, field); // By now, the object should have been constructed. - if (object == (PyObject *)NULL) { - return NULL; + if (object == nullptr) { + return nullptr; } } while (more_nested_fields()) { const DCField *field = get_current_field()->as_field(); - nassertr(field != (DCField *)NULL, object); + nassertr(field != nullptr, object); set_class_element(class_def, object, field); } @@ -1287,8 +1287,8 @@ set_class_element(PyObject *class_def, PyObject *&object, push(); while (more_nested_fields()) { const DCField *field = get_current_field()->as_field(); - nassertv(field != (DCField *)NULL); - nassertv(object != (PyObject *)NULL); + nassertv(field != nullptr); + nassertv(object != nullptr); set_class_element(class_def, object, field); } pop(); @@ -1307,7 +1307,7 @@ set_class_element(PyObject *class_def, PyObject *&object, PyObject *element = unpack_object(); if (pack_type == PT_field) { - if (object == (PyObject *)NULL) { + if (object == nullptr) { // If the object hasn't been constructed yet, assume this is the // constructor. object = PyObject_CallObject(class_def, element); @@ -1315,7 +1315,7 @@ set_class_element(PyObject *class_def, PyObject *&object, } else { if (PyObject_HasAttrString(object, (char *)field_name.c_str())) { PyObject *func = PyObject_GetAttrString(object, (char *)field_name.c_str()); - if (func != (PyObject *)NULL) { + if (func != nullptr) { PyObject *result = PyObject_CallObject(func, element); Py_XDECREF(result); Py_DECREF(func); @@ -1324,7 +1324,7 @@ set_class_element(PyObject *class_def, PyObject *&object, } } else { - nassertv(object != (PyObject *)NULL); + nassertv(object != nullptr); PyObject_SetAttrString(object, (char *)field_name.c_str(), element); } @@ -1353,7 +1353,7 @@ get_class_element(const DCClass *dclass, PyObject *object, push(); while (more_nested_fields() && !_pack_error) { const DCField *field = get_current_field()->as_field(); - nassertv(field != (DCField *)NULL); + nassertv(field != nullptr); get_class_element(dclass, object, field); } pop(); diff --git a/direct/src/dcparser/dcPackerCatalog.cxx b/direct/src/dcparser/dcPackerCatalog.cxx index 0f13322009..0eda4197b6 100644 --- a/direct/src/dcparser/dcPackerCatalog.cxx +++ b/direct/src/dcparser/dcPackerCatalog.cxx @@ -21,7 +21,7 @@ */ DCPackerCatalog:: DCPackerCatalog(const DCPackerInterface *root) : _root(root) { - _live_catalog = NULL; + _live_catalog = nullptr; } /** @@ -34,7 +34,7 @@ DCPackerCatalog(const DCPackerCatalog ©) : _entries_by_name(copy._entries_by_name), _entries_by_field(copy._entries_by_field) { - _live_catalog = NULL; + _live_catalog = nullptr; } /** @@ -42,7 +42,7 @@ DCPackerCatalog(const DCPackerCatalog ©) : */ DCPackerCatalog:: ~DCPackerCatalog() { - if (_live_catalog != (LiveCatalog *)NULL) { + if (_live_catalog != nullptr) { delete _live_catalog; } @@ -92,7 +92,7 @@ find_entry_by_field(const DCPackerInterface *field) const { */ const DCPackerCatalog::LiveCatalog *DCPackerCatalog:: get_live_catalog(const char *data, size_t length) const { - if (_live_catalog != (LiveCatalog *)NULL) { + if (_live_catalog != nullptr) { // Return the previously-allocated live catalog; it will be the same as // this one since it's based on a fixed-length field. return _live_catalog; @@ -111,13 +111,13 @@ get_live_catalog(const char *data, size_t length) const { DCPacker packer; packer.set_unpack_data(data, length, false); packer.begin_unpack(_root); - const DCSwitchParameter *last_switch = NULL; + const DCSwitchParameter *last_switch = nullptr; r_fill_live_catalog(live_catalog, packer, last_switch); bool okflag = packer.end_unpack(); if (!okflag) { delete live_catalog; - return NULL; + return nullptr; } if (_root->has_fixed_structure()) { @@ -188,7 +188,7 @@ r_fill_catalog(const string &name_prefix, const DCPackerInterface *field, const DCPackerInterface *parent, int field_index) { string next_name_prefix = name_prefix; - if (parent != (const DCPackerInterface *)NULL && !field->get_name().empty()) { + if (parent != nullptr && !field->get_name().empty()) { // Record this entry in the catalog. next_name_prefix += field->get_name(); add_entry(next_name_prefix, field, parent, field_index); @@ -197,7 +197,7 @@ r_fill_catalog(const string &name_prefix, const DCPackerInterface *field, } const DCSwitchParameter *switch_parameter = field->as_switch_parameter(); - if (switch_parameter != (DCSwitchParameter *)NULL) { + if (switch_parameter != nullptr) { // If we come upon a DCSwitch while building the catalog, save the // name_prefix at this point so we'll have it again when we later // encounter the switch while unpacking a live record (and so we can @@ -211,7 +211,7 @@ r_fill_catalog(const string &name_prefix, const DCPackerInterface *field, // It's ok if num_nested is -1. for (int i = 0; i < num_nested; i++) { DCPackerInterface *nested = field->get_nested_field(i); - if (nested != (DCPackerInterface *)NULL) { + if (nested != nullptr) { r_fill_catalog(next_name_prefix, nested, field, i); } } @@ -255,10 +255,10 @@ r_fill_live_catalog(LiveCatalog *live_catalog, DCPacker &packer, last_switch = packer.get_last_switch(); const DCPackerInterface *switch_case = packer.get_current_parent(); - nassertv(switch_case != (DCPackerInterface *)NULL); + nassertv(switch_case != nullptr); const DCPackerCatalog *switch_catalog = live_catalog->_catalog->update_switch_fields(last_switch, switch_case); - nassertv(switch_catalog != (DCPackerCatalog *)NULL); + nassertv(switch_catalog != nullptr); live_catalog->_catalog = switch_catalog; // And we also have to expand the live catalog to hold the new entries. @@ -317,7 +317,7 @@ update_switch_fields(const DCSwitchParameter *switch_parameter, int num_nested = switch_case->get_num_nested_fields(); for (int i = 1; i < num_nested; i++) { DCPackerInterface *nested = switch_case->get_nested_field(i); - if (nested != (DCPackerInterface *)NULL) { + if (nested != nullptr) { switch_catalog->r_fill_catalog(name_prefix, nested, switch_case, i); } } diff --git a/direct/src/dcparser/dcPackerInterface.cxx b/direct/src/dcparser/dcPackerInterface.cxx index dc731a479a..dd6e4ae482 100644 --- a/direct/src/dcparser/dcPackerInterface.cxx +++ b/direct/src/dcparser/dcPackerInterface.cxx @@ -32,7 +32,7 @@ DCPackerInterface(const string &name) : _has_nested_fields = false; _num_nested_fields = -1; _pack_type = PT_invalid; - _catalog = NULL; + _catalog = nullptr; } /** @@ -50,7 +50,7 @@ DCPackerInterface(const DCPackerInterface ©) : _num_nested_fields(copy._num_nested_fields), _pack_type(copy._pack_type) { - _catalog = NULL; + _catalog = nullptr; } /** @@ -58,7 +58,7 @@ DCPackerInterface(const DCPackerInterface ©) : */ DCPackerInterface:: ~DCPackerInterface() { - if (_catalog != (DCPackerCatalog *)NULL) { + if (_catalog != nullptr) { delete _catalog; } } @@ -83,7 +83,7 @@ find_seek_index(const string &name) const { */ DCField *DCPackerInterface:: as_field() { - return (DCField *)NULL; + return nullptr; } /** @@ -91,7 +91,7 @@ as_field() { */ const DCField *DCPackerInterface:: as_field() const { - return (DCField *)NULL; + return nullptr; } /** @@ -99,7 +99,7 @@ as_field() const { */ DCSwitchParameter *DCPackerInterface:: as_switch_parameter() { - return (DCSwitchParameter *)NULL; + return nullptr; } /** @@ -107,7 +107,7 @@ as_switch_parameter() { */ const DCSwitchParameter *DCPackerInterface:: as_switch_parameter() const { - return (DCSwitchParameter *)NULL; + return nullptr; } /** @@ -115,7 +115,7 @@ as_switch_parameter() const { */ DCClassParameter *DCPackerInterface:: as_class_parameter() { - return (DCClassParameter *)NULL; + return nullptr; } /** @@ -123,7 +123,7 @@ as_class_parameter() { */ const DCClassParameter *DCPackerInterface:: as_class_parameter() const { - return (DCClassParameter *)NULL; + return nullptr; } /** @@ -145,7 +145,7 @@ check_match(const string &description, DCFile *dcfile) const { dc_cleanup_parser(); DCField *field = dc_get_parameter_description(); - if (field != NULL) { + if (field != nullptr) { match = check_match(field); delete field; } @@ -184,7 +184,7 @@ calc_num_nested_fields(size_t) const { */ DCPackerInterface *DCPackerInterface:: get_nested_field(int) const { - return NULL; + return nullptr; } /** @@ -367,7 +367,7 @@ unpack_skip(const char *data, size_t length, size_t &p, */ const DCPackerCatalog *DCPackerInterface:: get_catalog() const { - if (_catalog == (DCPackerCatalog *)NULL) { + if (_catalog == nullptr) { ((DCPackerInterface *)this)->make_catalog(); } return _catalog; @@ -432,8 +432,8 @@ do_check_match_molecular_field(const DCMolecularField *) const { */ void DCPackerInterface:: make_catalog() { - nassertv(_catalog == (DCPackerCatalog *)NULL); + nassertv(_catalog == nullptr); _catalog = new DCPackerCatalog(this); - _catalog->r_fill_catalog("", this, NULL, 0); + _catalog->r_fill_catalog("", this, nullptr, 0); } diff --git a/direct/src/dcparser/dcPackerInterface.h b/direct/src/dcparser/dcPackerInterface.h index 42284ac54f..0157d3c5ce 100644 --- a/direct/src/dcparser/dcPackerInterface.h +++ b/direct/src/dcparser/dcPackerInterface.h @@ -82,7 +82,7 @@ PUBLISHED: virtual const DCClassParameter *as_class_parameter() const; INLINE bool check_match(const DCPackerInterface *other) const; - bool check_match(const string &description, DCFile *dcfile = NULL) const; + bool check_match(const string &description, DCFile *dcfile = nullptr) const; public: virtual void set_name(const string &name); diff --git a/direct/src/dcparser/dcParameter.cxx b/direct/src/dcparser/dcParameter.cxx index a1fcfecca7..ef1c50997f 100644 --- a/direct/src/dcparser/dcParameter.cxx +++ b/direct/src/dcparser/dcParameter.cxx @@ -22,7 +22,7 @@ */ DCParameter:: DCParameter() { - _typedef = NULL; + _typedef = nullptr; _has_fixed_byte_size = false; _has_fixed_structure = false; _num_nested_fields = -1; @@ -66,7 +66,7 @@ as_parameter() const { */ DCSimpleParameter *DCParameter:: as_simple_parameter() { - return NULL; + return nullptr; } /** @@ -74,7 +74,7 @@ as_simple_parameter() { */ const DCSimpleParameter *DCParameter:: as_simple_parameter() const { - return NULL; + return nullptr; } /** @@ -82,7 +82,7 @@ as_simple_parameter() const { */ DCClassParameter *DCParameter:: as_class_parameter() { - return NULL; + return nullptr; } /** @@ -90,7 +90,7 @@ as_class_parameter() { */ const DCClassParameter *DCParameter:: as_class_parameter() const { - return NULL; + return nullptr; } /** @@ -98,7 +98,7 @@ as_class_parameter() const { */ DCSwitchParameter *DCParameter:: as_switch_parameter() { - return NULL; + return nullptr; } /** @@ -106,7 +106,7 @@ as_switch_parameter() { */ const DCSwitchParameter *DCParameter:: as_switch_parameter() const { - return NULL; + return nullptr; } /** @@ -114,7 +114,7 @@ as_switch_parameter() const { */ DCArrayParameter *DCParameter:: as_array_parameter() { - return NULL; + return nullptr; } /** @@ -122,7 +122,7 @@ as_array_parameter() { */ const DCArrayParameter *DCParameter:: as_array_parameter() const { - return NULL; + return nullptr; } /** diff --git a/direct/src/dcparser/dcParser.yxx b/direct/src/dcparser/dcParser.yxx index 5c39b398e4..8b9c7e40ad 100644 --- a/direct/src/dcparser/dcParser.yxx +++ b/direct/src/dcparser/dcParser.yxx @@ -29,18 +29,18 @@ #define YYINITDEPTH 1000 #define YYMAXDEPTH 1000 -DCFile *dc_file = (DCFile *)NULL; -static DCClass *current_class = (DCClass *)NULL; -static DCSwitch *current_switch = (DCSwitch *)NULL; -static DCAtomicField *current_atomic = (DCAtomicField *)NULL; -static DCMolecularField *current_molecular = (DCMolecularField *)NULL; -static DCParameter *current_parameter = (DCParameter *)NULL; +DCFile *dc_file = nullptr; +static DCClass *current_class = nullptr; +static DCSwitch *current_switch = nullptr; +static DCAtomicField *current_atomic = nullptr; +static DCMolecularField *current_molecular = nullptr; +static DCParameter *current_parameter = nullptr; static DCKeywordList current_keyword_list; static DCPacker default_packer; static DCPacker *current_packer; static DCDoubleRange double_range; static DCUnsignedIntRange uint_range; -static DCField *parameter_description = (DCField *)NULL; +static DCField *parameter_description = nullptr; //////////////////////////////////////////////////////////////////// // Defining the interface to the parser. @@ -55,7 +55,7 @@ dc_init_parser(istream &in, const string &filename, DCFile &file) { void dc_init_parser_parameter_value(istream &in, const string &filename, DCPacker &packer) { - dc_file = NULL; + dc_file = nullptr; current_packer = &packer; dc_init_lexer(in, filename); dc_start_parameter_value(); @@ -66,7 +66,7 @@ dc_init_parser_parameter_description(istream &in, const string &filename, DCFile *file) { dc_file = file; dc_init_lexer(in, filename); - parameter_description = NULL; + parameter_description = nullptr; dc_start_parameter_description(); } @@ -77,7 +77,7 @@ dc_get_parameter_description() { void dc_cleanup_parser() { - dc_file = (DCFile *)NULL; + dc_file = nullptr; } %} @@ -181,7 +181,7 @@ dc: { if (!dc_file->add_class($2)) { DCClass *old_class = dc_file->get_class_by_name($2->get_name()); - if (old_class != (DCClass *)NULL && old_class->is_bogus_class()) { + if (old_class != nullptr && old_class->is_bogus_class()) { yyerror("Base class defined after its first reference: " + $2->get_name()); } else { yyerror("Duplicate class name: " + $2->get_name()); @@ -249,7 +249,7 @@ import_symbol_list: typedef_decl: KW_TYPEDEF parameter_with_default { - if ($2 != (DCParameter *)NULL) { + if ($2 != nullptr) { DCTypedef *dtypedef = new DCTypedef($2); if (!dc_file->add_typedef(dtypedef)) { @@ -304,13 +304,13 @@ dclass: dclass_name: IDENTIFIER { - if (dc_file == (DCFile *)NULL) { + if (dc_file == nullptr) { yyerror("No DCFile available, so no class names are predefined."); - $$ = NULL; + $$ = nullptr; } else { DCClass *dclass = dc_file->get_class_by_name($1); - if (dclass == (DCClass *)NULL) { + if (dclass == nullptr) { // Create a bogus class as a forward reference. dclass = new DCClass(dc_file, $1, false, true); dc_file->add_class(dclass); @@ -332,7 +332,7 @@ dclass_derivation: dclass_base_list: dclass_name { - if ($1 != (DCClass *)NULL) { + if ($1 != nullptr) { current_class->add_parent($1); } } @@ -342,7 +342,7 @@ dclass_base_list: yyerror("Multiple inheritance is not supported without \"dc-multiple-inheritance 1\" in your Config.prc file."); } else { - if ($3 != (DCClass *)NULL) { + if ($3 != nullptr) { current_class->add_parent($3); } } @@ -354,7 +354,7 @@ dclass_fields: | dclass_fields ';' | dclass_fields dclass_field ';' { - if ($2 == (DCField *)NULL) { + if ($2 == nullptr) { // Pass this error up. } else if (!current_class->add_field($2)) { yyerror("Duplicate field name: " + $2->get_name()); @@ -367,7 +367,7 @@ dclass_fields: dclass_field: atomic_field keyword_list { - if ($1 != (DCField *)NULL) { + if ($1 != nullptr) { if ($1->get_name().empty()) { yyerror("Field name required."); } @@ -379,14 +379,14 @@ dclass_field: | unnamed_parameter_with_default keyword_list { yyerror("Unnamed parameters are not allowed on a dclass"); - if ($1 != (DCField *)NULL) { + if ($1 != nullptr) { $1->copy_keywords(current_keyword_list); } $$ = $1; } | named_parameter_with_default keyword_list { - if ($1 != (DCField *)NULL) { + if ($1 != nullptr) { $1->copy_keywords(current_keyword_list); } $$ = $1; @@ -408,13 +408,13 @@ struct: struct_name: IDENTIFIER { - if (dc_file == (DCFile *)NULL) { + if (dc_file == nullptr) { yyerror("No DCFile available, so no struct names are predefined."); - $$ = NULL; + $$ = nullptr; } else { DCClass *dstruct = dc_file->get_class_by_name($1); - if (dstruct == (DCClass *)NULL) { + if (dstruct == nullptr) { // Create a bogus class as a forward reference. dstruct = new DCClass(dc_file, $1, false, true); dc_file->add_class(dstruct); @@ -436,13 +436,13 @@ struct_derivation: struct_base_list: struct_name { - if ($1 != (DCClass *)NULL) { + if ($1 != nullptr) { current_class->add_parent($1); } } | struct_base_list ',' struct_name { - if ($3 != (DCClass *)NULL) { + if ($3 != nullptr) { current_class->add_parent($3); } } @@ -453,7 +453,7 @@ struct_fields: | struct_fields ';' | struct_fields struct_field ';' { - if ($2 == (DCField *)NULL) { + if ($2 == nullptr) { // Pass this error up. } else if (!current_class->add_field($2)) { yyerror("Duplicate field name: " + $2->get_name()); @@ -483,7 +483,7 @@ struct_field: atomic_field: optional_name '(' { - if (current_class == (DCClass *)NULL) { + if (current_class == nullptr) { yyerror("Cannot define a method outside of a struct or class."); DCClass *temp_class = new DCClass(dc_file, "temp", false, false); // memory leak. current_atomic = new DCAtomicField($1, temp_class, false); @@ -511,7 +511,7 @@ nonempty_parameter_list: atomic_element: parameter_with_default { - if ($1 != (DCParameter *)NULL) { + if ($1 != nullptr) { current_atomic->add_element($1); } } @@ -538,14 +538,14 @@ named_parameter_with_default: { current_packer = &default_packer; current_packer->clear_data(); - if ($1 != (DCField *)NULL) { + if ($1 != nullptr) { current_packer->begin_pack($1); } } parameter_value { bool is_valid = false; - if ($1 != (DCField *)NULL) { + if ($1 != nullptr) { is_valid = $1->is_valid(); } if (current_packer->end_pack()) { @@ -568,14 +568,14 @@ unnamed_parameter_with_default: { current_packer = &default_packer; current_packer->clear_data(); - if ($1 != (DCField *)NULL) { + if ($1 != nullptr) { current_packer->begin_pack($1); } } parameter_value { bool is_valid = false; - if ($1 != (DCField *)NULL) { + if ($1 != nullptr) { is_valid = $1->is_valid(); } if (current_packer->end_pack()) { @@ -636,7 +636,7 @@ simple_type_name: | simple_type_name '(' double_range ')' { DCSimpleParameter *simple_param = $1->as_simple_parameter(); - nassertr(simple_param != (DCSimpleParameter *)NULL, 0); + nassertr(simple_param != nullptr, 0); if (!simple_param->set_range(double_range)) { yyerror("Inappropriate range for type"); } @@ -645,7 +645,7 @@ simple_type_name: | simple_type_name '/' small_unsigned_integer { DCSimpleParameter *simple_param = $1->as_simple_parameter(); - nassertr(simple_param != (DCSimpleParameter *)NULL, 0); + nassertr(simple_param != nullptr, 0); if (!simple_param->is_numeric_type()) { yyerror("A divisor is only valid on a numeric type."); @@ -661,7 +661,7 @@ simple_type_name: | simple_type_name '%' number { DCSimpleParameter *simple_param = $1->as_simple_parameter(); - nassertr(simple_param != (DCSimpleParameter *)NULL, 0); + nassertr(simple_param != nullptr, 0); if (!simple_param->is_numeric_type()) { yyerror("A divisor is only valid on a numeric type."); @@ -676,22 +676,22 @@ type_name: simple_type_name | IDENTIFIER { - if (dc_file == (DCFile *)NULL) { + if (dc_file == nullptr) { yyerror("Invalid type."); - $$ = NULL; + $$ = nullptr; } else { DCTypedef *dtypedef = dc_file->get_typedef_by_name($1); - if (dtypedef == (DCTypedef *)NULL) { + if (dtypedef == nullptr) { // Maybe it's a class name. DCClass *dclass = dc_file->get_class_by_name($1); - if (dclass != (DCClass *)NULL) { + if (dclass != nullptr) { // Create an implicit typedef for this. dtypedef = new DCTypedef(new DCClassParameter(dclass), true); } else { // Maybe it's a switch name. DCSwitch *dswitch = dc_file->get_switch_by_name($1); - if (dswitch != (DCSwitch *)NULL) { + if (dswitch != nullptr) { // This also gets an implicit typedef. dtypedef = new DCTypedef(new DCSwitchParameter(dswitch), true); } else { @@ -709,10 +709,10 @@ type_name: | struct { // This is an inline struct definition. - if ($1 == (DCClass *)NULL) { - $$ = NULL; + if ($1 == nullptr) { + $$ = nullptr; } else { - if (dc_file != (DCFile *)NULL) { + if (dc_file != nullptr) { dc_file->add_thing_to_delete($1); } else { // This is a memory leak--this happens when we put an anonymous @@ -725,10 +725,10 @@ type_name: | switch { // This is an inline switch definition. - if ($1 == (DCSwitch *)NULL) { - $$ = NULL; + if ($1 == nullptr) { + $$ = nullptr; } else { - if (dc_file != (DCFile *)NULL) { + if (dc_file != nullptr) { dc_file->add_thing_to_delete($1); } else { // This is a memory leak--this happens when we put an anonymous @@ -840,8 +840,8 @@ type_definition: type_name | type_definition '[' uint_range ']' { - if ($1 == (DCParameter *)NULL) { - $$ = NULL; + if ($1 == nullptr) { + $$ = nullptr; } else { $$ = $1->append_array_specification(uint_range); } @@ -857,7 +857,7 @@ parameter_definition: | parameter_definition '/' small_unsigned_integer { DCSimpleParameter *simple_param = $1->as_simple_parameter(); - if (simple_param == NULL || simple_param->get_typedef() != (DCTypedef *)NULL) { + if (simple_param == nullptr || simple_param->get_typedef() != nullptr) { yyerror("A divisor is only allowed on a primitive type."); } else if (!simple_param->is_numeric_type()) { @@ -872,7 +872,7 @@ parameter_definition: | parameter_definition '%' number { DCSimpleParameter *simple_param = $1->as_simple_parameter(); - if (simple_param == NULL || simple_param->get_typedef() != (DCTypedef *)NULL) { + if (simple_param == nullptr || simple_param->get_typedef() != nullptr) { yyerror("A modulus is only allowed on a primitive type."); } else if (!simple_param->is_numeric_type()) { @@ -1184,8 +1184,8 @@ atomic_name: IDENTIFIER { DCField *field = current_class->get_field_by_name($1); - $$ = (DCAtomicField *)NULL; - if (field == (DCField *)NULL) { + $$ = nullptr; + if (field == nullptr) { // Maybe the field is unknown because the class is partially // bogus. In that case, allow it for now; create a bogus field as // a placeholder. @@ -1200,7 +1200,7 @@ atomic_name: } else { $$ = field->as_atomic_field(); - if ($$ == (DCAtomicField *)NULL) { + if ($$ == nullptr) { yyerror("Not an atomic field: " + $1); } } @@ -1210,13 +1210,13 @@ atomic_name: molecular_atom_list: atomic_name { - if ($1 != (DCAtomicField *)NULL) { + if ($1 != nullptr) { current_molecular->add_atomic($1); } } | molecular_atom_list ',' atomic_name { - if ($3 != (DCAtomicField *)NULL) { + if ($3 != nullptr) { current_molecular->add_atomic($3); if (!$3->is_bogus_field() && !current_molecular->compare_keywords(*$3)) { yyerror("Mismatched keywords in molecule between " + @@ -1258,7 +1258,7 @@ switch_fields: { if (!current_switch->is_field_valid()) { yyerror("case declaration required before first element"); - } else if ($2 != (DCField *)NULL) { + } else if ($2 != nullptr) { if (!current_switch->add_field($2)) { yyerror("Duplicate field name: " + $2->get_name()); } diff --git a/direct/src/dcparser/dcSimpleParameter.cxx b/direct/src/dcparser/dcSimpleParameter.cxx index bd1d6cd086..34f4e7e402 100644 --- a/direct/src/dcparser/dcSimpleParameter.cxx +++ b/direct/src/dcparser/dcSimpleParameter.cxx @@ -21,7 +21,7 @@ #include DCSimpleParameter::NestedFieldMap DCSimpleParameter::_nested_field_map; -DCClassParameter *DCSimpleParameter::_uint32uint8_type = NULL; +DCClassParameter *DCSimpleParameter::_uint32uint8_type = nullptr; /** * @@ -186,7 +186,7 @@ DCSimpleParameter(DCSubatomicType type, unsigned int divisor) : _nested_field = create_uint32uint8_type(); } else { - _nested_field = NULL; + _nested_field = nullptr; } } @@ -2173,7 +2173,7 @@ unpack_skip(const char *data, size_t length, size_t &p, void DCSimpleParameter:: output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const { - if (get_typedef() != (DCTypedef *)NULL) { + if (get_typedef() != nullptr) { output_typedef_name(out, brief, prename, name, postname); } else { @@ -2342,7 +2342,7 @@ do_check_match_array_parameter(const DCArrayParameter *other) const { // We cannot match a fixed-size array. return false; } - if (_nested_field == NULL) { + if (_nested_field == nullptr) { // Only an array-style simple parameter can match a DCArrayParameter. return false; } @@ -2374,8 +2374,8 @@ create_nested_field(DCSubatomicType type, unsigned int divisor) { */ DCPackerInterface *DCSimpleParameter:: create_uint32uint8_type() { - if (_uint32uint8_type == NULL) { - DCClass *dclass = new DCClass(NULL, "", true, false); + if (_uint32uint8_type == nullptr) { + DCClass *dclass = new DCClass(nullptr, "", true, false); dclass->add_field(new DCSimpleParameter(ST_uint32)); dclass->add_field(new DCSimpleParameter(ST_uint8)); _uint32uint8_type = new DCClassParameter(dclass); diff --git a/direct/src/dcparser/dcSwitch.cxx b/direct/src/dcparser/dcSwitch.cxx index 0215a9919c..ee3c70f7c5 100644 --- a/direct/src/dcparser/dcSwitch.cxx +++ b/direct/src/dcparser/dcSwitch.cxx @@ -27,7 +27,7 @@ DCSwitch(const string &name, DCField *key_parameter) : _name(name), _key_parameter(key_parameter) { - _default_case = NULL; + _default_case = nullptr; _fields_added = false; } @@ -36,7 +36,7 @@ DCSwitch(const string &name, DCField *key_parameter) : */ DCSwitch:: ~DCSwitch() { - nassertv(_key_parameter != (DCField *)NULL); + nassertv(_key_parameter != nullptr); delete _key_parameter; Cases::iterator ci; @@ -121,7 +121,7 @@ get_case_by_value(const string &case_value) const { */ DCPackerInterface *DCSwitch:: get_case(int n) const { - nassertr(n >= 0 && n < (int)_cases.size(), NULL); + nassertr(n >= 0 && n < (int)_cases.size(), nullptr); return _cases[n]->_fields; } @@ -157,8 +157,8 @@ get_num_fields(int case_index) const { */ DCField *DCSwitch:: get_field(int case_index, int n) const { - nassertr(case_index >= 0 && case_index < (int)_cases.size(), NULL); - nassertr(n >= 0 && n < (int)_cases[case_index]->_fields->_fields.size(), NULL); + nassertr(case_index >= 0 && case_index < (int)_cases.size(), nullptr); + nassertr(n >= 0 && n < (int)_cases[case_index]->_fields->_fields.size(), nullptr); return _cases[case_index]->_fields->_fields[n]; } @@ -168,7 +168,7 @@ get_field(int case_index, int n) const { */ DCField *DCSwitch:: get_field_by_name(int case_index, const string &name) const { - nassertr(case_index >= 0 && case_index < (int)_cases.size(), NULL); + nassertr(case_index >= 0 && case_index < (int)_cases.size(), nullptr); const FieldsByName &fields_by_name = _cases[case_index]->_fields->_fields_by_name; FieldsByName::const_iterator ni; @@ -177,7 +177,7 @@ get_field_by_name(int case_index, const string &name) const { return (*ni).second; } - return NULL; + return nullptr; } /** @@ -226,7 +226,7 @@ add_invalid_case() { */ bool DCSwitch:: add_default() { - if (_default_case != (SwitchFields *)NULL) { + if (_default_case != nullptr) { add_invalid_case(); return false; } @@ -286,12 +286,12 @@ apply_switch(const char *value_data, size_t length) const { } // Unexpected value--use the default. - if (_default_case != (SwitchFields *)NULL) { + if (_default_case != nullptr) { return _default_case; } // No default. - return NULL; + return nullptr; } /** @@ -326,26 +326,26 @@ output_instance(ostream &out, bool brief, const string &prename, _key_parameter->output(out, brief); out << ") {"; - const SwitchFields *last_fields = NULL; + const SwitchFields *last_fields = nullptr; Cases::const_iterator ci; for (ci = _cases.begin(); ci != _cases.end(); ++ci) { const SwitchCase *dcase = (*ci); - if (dcase->_fields != last_fields && last_fields != (SwitchFields *)NULL) { + if (dcase->_fields != last_fields && last_fields != nullptr) { last_fields->output(out, brief); } last_fields = dcase->_fields; out << "case " << _key_parameter->format_data(dcase->_value, false) << ": "; } - if (_default_case != (SwitchFields *)NULL) { - if (_default_case != last_fields && last_fields != (SwitchFields *)NULL) { + if (_default_case != nullptr) { + if (_default_case != last_fields && last_fields != nullptr) { last_fields->output(out, brief); } last_fields = _default_case; out << "default: "; } - if (last_fields != (SwitchFields *)NULL) { + if (last_fields != nullptr) { last_fields->output(out, brief); } @@ -372,12 +372,12 @@ write_instance(ostream &out, bool brief, int indent_level, _key_parameter->output(out, brief); out << ") {\n"; - const SwitchFields *last_fields = NULL; + const SwitchFields *last_fields = nullptr; Cases::const_iterator ci; for (ci = _cases.begin(); ci != _cases.end(); ++ci) { const SwitchCase *dcase = (*ci); - if (dcase->_fields != last_fields && last_fields != (SwitchFields *)NULL) { + if (dcase->_fields != last_fields && last_fields != nullptr) { last_fields->write(out, brief, indent_level + 2); } last_fields = dcase->_fields; @@ -385,15 +385,15 @@ write_instance(ostream &out, bool brief, int indent_level, << "case " << _key_parameter->format_data(dcase->_value, false) << ":\n"; } - if (_default_case != (SwitchFields *)NULL) { - if (_default_case != last_fields && last_fields != (SwitchFields *)NULL) { + if (_default_case != nullptr) { + if (_default_case != last_fields && last_fields != nullptr) { last_fields->write(out, brief, indent_level + 2); } last_fields = _default_case; indent(out, indent_level) << "default:\n"; } - if (last_fields != (SwitchFields *)NULL) { + if (last_fields != nullptr) { last_fields->write(out, brief, indent_level + 2); } @@ -428,7 +428,7 @@ generate_hash(HashGenerator &hashgen) const { } } - if (_default_case != (SwitchFields *)NULL) { + if (_default_case != nullptr) { const SwitchFields *fields = _default_case; hashgen.add_int(fields->_fields.size()); Fields::const_iterator fi; @@ -446,7 +446,7 @@ generate_hash(HashGenerator &hashgen) const { */ bool DCSwitch:: pack_default_value(DCPackData &pack_data, bool &pack_error) const { - SwitchFields *fields = NULL; + SwitchFields *fields = nullptr; DCPacker packer; packer.begin_pack(_key_parameter); if (!_cases.empty()) { @@ -466,7 +466,7 @@ pack_default_value(DCPackData &pack_data, bool &pack_error) const { pack_error = true; } - if (fields == (SwitchFields *)NULL) { + if (fields == nullptr) { pack_error = true; } else { @@ -528,7 +528,7 @@ do_check_match_switch(const DCSwitch *other) const { */ DCSwitch::SwitchFields *DCSwitch:: start_new_case() { - SwitchFields *fields = NULL; + SwitchFields *fields = nullptr; if (_current_fields.empty() || _fields_added) { // If we have recently encountered a break (which removes all of the @@ -587,7 +587,7 @@ DCSwitch::SwitchFields:: */ DCPackerInterface *DCSwitch::SwitchFields:: get_nested_field(int n) const { - nassertr(n >= 0 && n < (int)_fields.size(), NULL); + nassertr(n >= 0 && n < (int)_fields.size(), nullptr); return _fields[n]; } diff --git a/direct/src/dcparser/dcSwitchParameter.cxx b/direct/src/dcparser/dcSwitchParameter.cxx index 0dcc741861..8f3b7ccf00 100644 --- a/direct/src/dcparser/dcSwitchParameter.cxx +++ b/direct/src/dcparser/dcSwitchParameter.cxx @@ -66,7 +66,7 @@ DCSwitchParameter(const DCSwitch *dswitch) : // Also consider the default case, if there is one. const DCSwitch::SwitchFields *fields = (DCSwitch::SwitchFields *)_dswitch->get_default_case(); - if (fields != (DCSwitch::SwitchFields *)NULL) { + if (fields != nullptr) { if (!fields->has_fixed_byte_size() || fields->get_fixed_byte_size() != _fixed_byte_size) { _has_fixed_byte_size = false; @@ -155,7 +155,7 @@ apply_switch(const char *value_data, size_t length) const { void DCSwitchParameter:: output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const { - if (get_typedef() != (DCTypedef *)NULL) { + if (get_typedef() != nullptr) { output_typedef_name(out, brief, prename, name, postname); } else { @@ -171,7 +171,7 @@ void DCSwitchParameter:: write_instance(ostream &out, bool brief, int indent_level, const string &prename, const string &name, const string &postname) const { - if (get_typedef() != (DCTypedef *)NULL) { + if (get_typedef() != nullptr) { write_typedef_name(out, brief, indent_level, prename, name, postname); } else { diff --git a/direct/src/directd/directd.cxx b/direct/src/directd/directd.cxx index 1b4601fc41..027236579d 100644 --- a/direct/src/directd/directd.cxx +++ b/direct/src/directd/directd.cxx @@ -83,7 +83,7 @@ namespace { // If we can't open the process with PROCESS_TERMINATE rights, then we // give up immediately. hProc = OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, dwPID); - if(hProc == NULL) { + if(hProc == nullptr) { return TA_FAILED; } @@ -115,7 +115,7 @@ namespace { ZeroMemory(&si, sizeof(STARTUPINFO)); si.cb = sizeof(STARTUPINFO); ZeroMemory(&pi, sizeof(PROCESS_INFORMATION)); - if (CreateProcess(NULL, (char*)cmd.c_str(), + if (CreateProcess(nullptr, (char*)cmd.c_str(), 0, 0, 1, NORMAL_PRIORITY_CLASS, 0, 0, &si, &pi)) { pid=pi.dwProcessId; @@ -228,7 +228,7 @@ DirectD::start_app(const string& cmd) { ZeroMemory(&si, sizeof(STARTUPINFO)); si.cb = sizeof(STARTUPINFO); ZeroMemory(&pi, sizeof(PROCESS_INFORMATION)); - if (CreateProcess(NULL, (char*)cmd.c_str(), + if (CreateProcess(nullptr, (char*)cmd.c_str(), 0, 0, 1, NORMAL_PRIORITY_CLASS | CREATE_SUSPENDED, 0, 0, &si, &pi)) { // The process must be created with CREATE_SUSPENDED to give us a chance diff --git a/direct/src/distributed/cConnectionRepository.cxx b/direct/src/distributed/cConnectionRepository.cxx index 2ce5beb0c7..910edf7154 100644 --- a/direct/src/distributed/cConnectionRepository.cxx +++ b/direct/src/distributed/cConnectionRepository.cxx @@ -41,10 +41,10 @@ CConnectionRepository:: CConnectionRepository(bool has_owner_view, bool threaded_net) : _lock("CConnectionRepository::_lock"), #ifdef HAVE_PYTHON - _python_repository(NULL), + _python_repository(nullptr), #endif #ifdef HAVE_OPENSSL - _http_conn(NULL), + _http_conn(nullptr), #endif #ifdef HAVE_NET _cw(&_qcm, threaded_net ? 1 : 0), @@ -95,7 +95,7 @@ set_tcp_header_size(int tcp_header_size) { _tcp_header_size = tcp_header_size; #ifdef HAVE_OPENSSL - if (_http_conn != (SocketStream *)NULL) { + if (_http_conn != nullptr) { _http_conn->set_tcp_header_size(tcp_header_size); } #endif @@ -157,7 +157,7 @@ try_connect_net(const URLSpec &url) { _qcm.open_TCP_client_connection(url.get_server(), url.get_port(), game_server_timeout_ms); - if (_net_conn != (Connection *)NULL) { + if (_net_conn != nullptr) { _net_conn->set_no_delay(true); _qcr.add_connection(_net_conn); return true; @@ -209,7 +209,7 @@ start_delay(double min_delay, double max_delay) { _qcr.start_delay(min_delay, max_delay); #endif // HAVE_NET #ifdef HAVE_OPENSSL - if (_http_conn != (SocketStream *)NULL) { + if (_http_conn != nullptr) { _http_conn->start_delay(min_delay, max_delay); } #endif // HAVE_OPENSSL @@ -233,7 +233,7 @@ stop_delay() { _qcr.stop_delay(); #endif // HAVE_NET #ifdef HAVE_OPENSSL - if (_http_conn != (SocketStream *)NULL) { + if (_http_conn != nullptr) { _http_conn->stop_delay(); } #endif // HAVE_OPENSSL @@ -278,7 +278,7 @@ check_datagram() { #ifdef HAVE_PYTHON // For now, we need to stuff this field onto the Python structure, to // support legacy code that expects to find it there. - if (_python_repository != (PyObject *)NULL) { + if (_python_repository != nullptr) { #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) PyGILState_STATE gstate; gstate = PyGILState_Ensure(); @@ -353,7 +353,7 @@ is_connected() { _qcm.close_connection(reset_connection); if (reset_connection == _net_conn) { // Whoops, lost our connection. - _net_conn = NULL; + _net_conn = nullptr; return false; } } @@ -370,7 +370,7 @@ is_connected() { // Connection lost. delete _http_conn; - _http_conn = NULL; + _http_conn = nullptr; } #endif // HAVE_OPENSSL @@ -607,7 +607,7 @@ disconnect() { #ifdef HAVE_NET if (_net_conn) { _qcm.close_connection(_net_conn); - _net_conn = NULL; + _net_conn = nullptr; } #endif // HAVE_NET @@ -615,7 +615,7 @@ disconnect() { if (_http_conn) { _http_conn->close(); delete _http_conn; - _http_conn = NULL; + _http_conn = nullptr; } #endif // HAVE_OPENSSL @@ -684,11 +684,11 @@ handle_update_field() { PStatTimer timer(_update_pcollector); unsigned int do_id = _di.get_uint32(); - if (_python_repository != (PyObject *)NULL) + if (_python_repository != nullptr) { PyObject *doId2do = PyObject_GetAttrString(_python_repository, "doId2do"); - nassertr(doId2do != NULL, false); + nassertr(doId2do != nullptr, false); #ifdef USE_PYTHON_2_2_OR_EARLIER PyObject *doId = PyInt_FromLong(do_id); @@ -699,14 +699,14 @@ handle_update_field() { Py_DECREF(doId); Py_DECREF(doId2do); - if (distobj != NULL) { + if (distobj != nullptr) { PyObject *dclass_obj = PyObject_GetAttrString(distobj, "dclass"); - nassertr(dclass_obj != NULL, false); + nassertr(dclass_obj != nullptr, false); PyObject *dclass_this = PyObject_GetAttrString(dclass_obj, "this"); Py_DECREF(dclass_obj); - nassertr(dclass_this != NULL, false); + nassertr(dclass_this != nullptr, false); DCClass *dclass = (DCClass *)PyLong_AsVoidPtr(dclass_this); Py_DECREF(dclass_this); @@ -715,7 +715,7 @@ handle_update_field() { // 'neverDisable' attribute set to non-zero if (_in_quiet_zone) { PyObject *neverDisable = PyObject_GetAttrString(distobj, "neverDisable"); - nassertr(neverDisable != NULL, false); + nassertr(neverDisable != nullptr, false); unsigned int cNeverDisable = PyLong_AsLong(neverDisable); if (!cNeverDisable) { @@ -772,14 +772,14 @@ handle_update_field_owner() { PStatTimer timer(_update_pcollector); unsigned int do_id = _di.get_uint32(); - if (_python_repository != (PyObject *)NULL) { + if (_python_repository != nullptr) { PyObject *doId2do = PyObject_GetAttrString(_python_repository, "doId2do"); - nassertr(doId2do != NULL, false); + nassertr(doId2do != nullptr, false); PyObject *doId2ownerView = PyObject_GetAttrString(_python_repository, "doId2ownerView"); - nassertr(doId2ownerView != NULL, false); + nassertr(doId2ownerView != nullptr, false); #ifdef USE_PYTHON_2_2_OR_EARLIER PyObject *doId = PyInt_FromLong(do_id); @@ -791,13 +791,13 @@ handle_update_field_owner() { PyObject *distobjOV = PyDict_GetItem(doId2ownerView, doId); Py_DECREF(doId2ownerView); - if (distobjOV != NULL) { + if (distobjOV != nullptr) { PyObject *dclass_obj = PyObject_GetAttrString(distobjOV, "dclass"); - nassertr(dclass_obj != NULL, false); + nassertr(dclass_obj != nullptr, false); PyObject *dclass_this = PyObject_GetAttrString(dclass_obj, "this"); Py_DECREF(dclass_obj); - nassertr(dclass_this != NULL, false); + nassertr(dclass_this != nullptr, false); DCClass *dclass = (DCClass *)PyLong_AsVoidPtr(dclass_this); Py_DECREF(dclass_this); @@ -834,13 +834,13 @@ handle_update_field_owner() { Py_DECREF(doId); Py_DECREF(doId2do); - if (distobj != NULL) { + if (distobj != nullptr) { PyObject *dclass_obj = PyObject_GetAttrString(distobj, "dclass"); - nassertr(dclass_obj != NULL, false); + nassertr(dclass_obj != nullptr, false); PyObject *dclass_this = PyObject_GetAttrString(dclass_obj, "this"); Py_DECREF(dclass_obj); - nassertr(dclass_this != NULL, false); + nassertr(dclass_this != nullptr, false); DCClass *dclass = (DCClass *)PyLong_AsVoidPtr(dclass_this); Py_DECREF(dclass_this); @@ -915,19 +915,19 @@ describe_message(ostream &out, const string &prefix, string msgName; #ifdef HAVE_PYTHON - if (_python_repository != (PyObject *)NULL) { + if (_python_repository != nullptr) { PyObject *msgId = PyLong_FromLong(msg_type); - nassertv(msgId != NULL); + nassertv(msgId != nullptr); #if PY_MAJOR_VERSION >= 3 PyObject *methodName = PyUnicode_FromString("_getMsgName"); #else PyObject *methodName = PyString_FromString("_getMsgName"); #endif - nassertv(methodName != NULL); + nassertv(methodName != nullptr); PyObject *result = PyObject_CallMethodObjArgs(_python_repository, methodName, - msgId, NULL); - nassertv(result != NULL); + msgId, nullptr); + nassertv(result != nullptr); #if PY_MAJOR_VERSION >= 3 msgName += string(PyUnicode_AsUTF8(result)); @@ -952,13 +952,13 @@ describe_message(ostream &out, const string &prefix, // It's an update message. Figure out what dclass the object is based on // its doId, so we can decode the rest of the message. do_id = packer.raw_unpack_uint32(); - DCClass *dclass = NULL; + DCClass *dclass = nullptr; #ifdef HAVE_PYTHON - if (_python_repository != (PyObject *)NULL) { + if (_python_repository != nullptr) { PyObject *doId2do = PyObject_GetAttrString(_python_repository, "doId2do"); - nassertv(doId2do != NULL); + nassertv(doId2do != nullptr); #ifdef USE_PYTHON_2_2_OR_EARLIER PyObject *doId = PyInt_FromLong(do_id); @@ -969,13 +969,13 @@ describe_message(ostream &out, const string &prefix, Py_DECREF(doId); Py_DECREF(doId2do); - if (distobj != NULL) { + if (distobj != nullptr) { PyObject *dclass_obj = PyObject_GetAttrString(distobj, "dclass"); - nassertv(dclass_obj != NULL); + nassertv(dclass_obj != nullptr); PyObject *dclass_this = PyObject_GetAttrString(dclass_obj, "this"); Py_DECREF(dclass_obj); - nassertv(dclass_this != NULL); + nassertv(dclass_this != nullptr); dclass = (DCClass *)PyLong_AsVoidPtr(dclass_this); Py_DECREF(dclass_this); @@ -985,7 +985,7 @@ describe_message(ostream &out, const string &prefix, int field_id = packer.raw_unpack_uint16(); - if (dclass == (DCClass *)NULL) { + if (dclass == nullptr) { out << full_prefix << "update for unknown object " << do_id << ", field " << field_id << "\n"; @@ -993,7 +993,7 @@ describe_message(ostream &out, const string &prefix, out << full_prefix << ":" << dclass->get_name() << "(" << do_id << ")."; DCField *field = dclass->get_field_by_index(field_id); - if (field == (DCField *)NULL) { + if (field == nullptr) { out << "unknown field " << field_id << "\n"; } else { diff --git a/direct/src/distributed/cDistributedSmoothNodeBase.cxx b/direct/src/distributed/cDistributedSmoothNodeBase.cxx index 14a665d9b9..37c69daaca 100644 --- a/direct/src/distributed/cDistributedSmoothNodeBase.cxx +++ b/direct/src/distributed/cDistributedSmoothNodeBase.cxx @@ -26,12 +26,12 @@ static const double network_time_precision = 100.0; // Matches ClockDelta.py */ CDistributedSmoothNodeBase:: CDistributedSmoothNodeBase() { - _repository = NULL; + _repository = nullptr; _is_ai = false; _ai_id = 0; #ifdef HAVE_PYTHON - _clock_delta = NULL; + _clock_delta = nullptr; #endif _currL[0] = 0; @@ -270,7 +270,7 @@ broadcast_pos_hpr_xy() { void CDistributedSmoothNodeBase:: begin_send_update(DCPacker &packer, const string &field_name) { DCField *field = _dclass->get_field_by_name(field_name); - nassertv(field != (DCField *)NULL); + nassertv(field != nullptr); if (_is_ai) { @@ -298,9 +298,9 @@ begin_send_update(DCPacker &packer, const string &field_name) { void CDistributedSmoothNodeBase:: finish_send_update(DCPacker &packer) { #ifdef HAVE_PYTHON - nassertv(_clock_delta != NULL); + nassertv(_clock_delta != nullptr); PyObject *clock_delta = PyObject_GetAttrString(_clock_delta, "delta"); - nassertv(clock_delta != NULL); + nassertv(clock_delta != nullptr); double delta = PyFloat_AsDouble(clock_delta); Py_DECREF(clock_delta); #else @@ -319,7 +319,7 @@ finish_send_update(DCPacker &packer) { bool pack_ok = packer.end_pack(); if (pack_ok) { Datagram dg(packer.get_data(), packer.get_length()); - nassertv(_repository != NULL); + nassertv(_repository != nullptr); _repository->send_datagram(dg); } else { diff --git a/direct/src/interval/cIntervalManager.cxx b/direct/src/interval/cIntervalManager.cxx index bd6189b349..104c9e0953 100644 --- a/direct/src/interval/cIntervalManager.cxx +++ b/direct/src/interval/cIntervalManager.cxx @@ -125,7 +125,7 @@ CInterval *CIntervalManager:: get_c_interval(int index) const { MutexHolder holder(_lock); - nassertr(index >= 0 && index < (int)_intervals.size(), NULL); + nassertr(index >= 0 && index < (int)_intervals.size(), nullptr); return _intervals[index]._interval; } @@ -140,14 +140,14 @@ remove_c_interval(int index) { nassertv(index >= 0 && index < (int)_intervals.size()); IntervalDef &def = _intervals[index]; - nassertv(def._interval != (CInterval *)NULL); + nassertv(def._interval != nullptr); NameIndex::iterator ni = _name_index.find(def._interval->get_name()); nassertv(ni != _name_index.end()); nassertv((*ni).second == index); _name_index.erase(ni); - def._interval = (CInterval *)NULL; + def._interval = nullptr; def._next_slot = _first_slot; _first_slot = index; } @@ -171,7 +171,7 @@ interrupt() { while (ni != _name_index.end()) { int index = (*ni).second; const IntervalDef &def = _intervals[index]; - nassertr(def._interval != (CInterval *)NULL, num_paused); + nassertr(def._interval != nullptr, num_paused); if (def._interval->get_auto_pause() || def._interval->get_auto_finish()) { // This interval may be interrupted. if (def._interval->get_auto_pause()) { @@ -262,7 +262,7 @@ step() { while (ni != _name_index.end()) { int index = (*ni).second; const IntervalDef &def = _intervals[index]; - nassertv(def._interval != (CInterval *)NULL); + nassertv(def._interval != nullptr); if (!def._interval->step_play()) { // This interval is finished and wants to be removed from the active // list. @@ -299,7 +299,7 @@ get_next_event() { while (_next_event_index < (int)_intervals.size()) { IntervalDef &def = _intervals[_next_event_index]; - if (def._interval != (CInterval *)NULL) { + if (def._interval != nullptr) { if ((def._flags & F_external) != 0 && def._interval->check_t_callback()) { return _next_event_index; @@ -338,7 +338,7 @@ get_next_removal() { nassertr(index >= 0 && index < (int)_intervals.size(), -1); IntervalDef &def = _intervals[index]; - def._interval = (CInterval *)NULL; + def._interval = nullptr; def._next_slot = _first_slot; _first_slot = index; return index; @@ -373,7 +373,7 @@ write(ostream &out) const { int index = (*ni).second; nassertv(index >= 0 && index < (int)_intervals.size()); const IntervalDef &def = _intervals[index]; - nassertv(def._interval != (CInterval *)NULL); + nassertv(def._interval != nullptr); out << *def._interval << "\n"; } @@ -384,7 +384,7 @@ write(ostream &out) const { int index = (*ri); nassertv(index >= 0 && index < (int)_intervals.size()); const IntervalDef &def = _intervals[index]; - nassertv(def._interval != (CInterval *)NULL); + nassertv(def._interval != nullptr); out << "(R)" << *def._interval << "\n"; } } @@ -395,7 +395,7 @@ write(ostream &out) const { */ CIntervalManager *CIntervalManager:: get_global_ptr() { - if (_global_ptr == (CIntervalManager *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new CIntervalManager; } return _global_ptr; @@ -433,7 +433,7 @@ remove_index(int index) { if ((def._flags & F_external) != 0) { _removed.push_back(index); } else { - def._interval = (CInterval *)NULL; + def._interval = nullptr; def._next_slot = _first_slot; _first_slot = index; } diff --git a/direct/src/interval/cLerpNodePathInterval.cxx b/direct/src/interval/cLerpNodePathInterval.cxx index 8c9423106f..12286ce3d8 100644 --- a/direct/src/interval/cLerpNodePathInterval.cxx +++ b/direct/src/interval/cLerpNodePathInterval.cxx @@ -57,7 +57,7 @@ CLerpNodePathInterval(const string &name, double duration, _flags(0), _texture_stage(TextureStage::get_default()), _override(0), - _slerp(NULL) + _slerp(nullptr) { if (bake_in_start) { _flags |= F_bake_in_start; @@ -191,7 +191,7 @@ priv_step(double t) { _flags &= ~F_slerp_setup; } } - nassertv(_slerp != NULL); + nassertv(_slerp != nullptr); (this->*_slerp)(quat, d); } if ((_flags & F_end_scale) != 0) { @@ -404,7 +404,7 @@ priv_step(double t) { color.set(1.0f, 1.0f, 1.0f, 1.0f); const RenderAttrib *attrib = state->get_attrib(ColorAttrib::get_class_type()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ColorAttrib *ca = DCAST(ColorAttrib, attrib); if (ca->get_color_type() == ColorAttrib::T_flat) { color = ca->get_color(); @@ -428,7 +428,7 @@ priv_step(double t) { color_scale.set(1.0f, 1.0f, 1.0f, 1.0f); const RenderAttrib *attrib = state->get_attrib(ColorScaleAttrib::get_class_type()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attrib); color_scale = csa->get_scale(); } @@ -446,7 +446,7 @@ priv_step(double t) { const RenderAttrib *attrib = state->get_attrib(TexMatrixAttrib::get_class_type()); CPT(TexMatrixAttrib) tma; - if (attrib != (const TexMatrixAttrib *)NULL) { + if (attrib != nullptr) { tma = DCAST(TexMatrixAttrib, attrib); transform = tma->get_transform(_texture_stage); } else { diff --git a/direct/src/interval/cMetaInterval.I b/direct/src/interval/cMetaInterval.I index ae30cd9792..0140e6e019 100644 --- a/direct/src/interval/cMetaInterval.I +++ b/direct/src/interval/cMetaInterval.I @@ -58,8 +58,8 @@ get_def_type(int n) const { */ INLINE CInterval *CMetaInterval:: get_c_interval(int n) const { - nassertr(n >= 0 && n < (int)_defs.size(), NULL); - nassertr(_defs[n]._type == DT_c_interval, NULL); + nassertr(n >= 0 && n < (int)_defs.size(), nullptr); + nassertr(_defs[n]._type == DT_c_interval, nullptr); return _defs[n]._c_interval; } diff --git a/direct/src/interval/cMetaInterval.cxx b/direct/src/interval/cMetaInterval.cxx index a4b914c7ed..2b764187bc 100644 --- a/direct/src/interval/cMetaInterval.cxx +++ b/direct/src/interval/cMetaInterval.cxx @@ -66,7 +66,7 @@ clear_intervals() { Defs::iterator di; for (di = _defs.begin(); di != _defs.end(); ++di) { IntervalDef &def = (*di); - if (def._c_interval != (CInterval *)NULL) { + if (def._c_interval != nullptr) { CInterval::Parents::iterator pi = find(def._c_interval->_parents.begin(), def._c_interval->_parents.end(), @@ -122,7 +122,7 @@ int CMetaInterval:: add_c_interval(CInterval *c_interval, double rel_time, RelativeStart rel_to) { nassertr(_event_queue.empty() && !_processing_events, -1); - nassertr(c_interval != (CInterval *)NULL, -1); + nassertr(c_interval != nullptr, -1); c_interval->_parents.push_back(this); c_interval->_ival_pcollector = PStatCollector(_ival_pcollector, c_interval->_pname); diff --git a/direct/src/motiontrail/cMotionTrail.cxx b/direct/src/motiontrail/cMotionTrail.cxx index 988a59c5dc..e578ea2f63 100644 --- a/direct/src/motiontrail/cMotionTrail.cxx +++ b/direct/src/motiontrail/cMotionTrail.cxx @@ -55,14 +55,14 @@ CMotionTrail ( ) { _resolution_distance = 0.5f; // node path states - _geom_node = 0; + _geom_node = nullptr; // real-time data _vertex_index = 0; - _vertex_data = 0; - _triangles = 0; + _vertex_data = nullptr; + _triangles = nullptr; - _vertex_array = 0; + _vertex_array = nullptr; } /** @@ -298,7 +298,7 @@ add_geometry_quad (LVector4 &v0, LVector4 &v1, LVector4 &v2, LVector4 &v3, LVect */ void CMotionTrail::end_geometry ( ) { static CPT(RenderState) state; - if (state == (RenderState *)NULL) { + if (state == nullptr) { state = RenderState::make(ColorAttrib::make_vertex()); } @@ -674,7 +674,7 @@ update_motion_trail (PN_stdfloat current_time, LMatrix4 *transform) { } for (index = 0; index < total_vertices; index++) { - nurbs_curve_result_array [index] = 0; + nurbs_curve_result_array [index] = nullptr; } delete[] nurbs_curve_result_array; @@ -804,6 +804,6 @@ update_motion_trail (PN_stdfloat current_time, LMatrix4 *transform) { this -> end_geometry ( ); delete[] _vertex_array; - _vertex_array = 0; + _vertex_array = nullptr; } } diff --git a/direct/src/plugin/binaryXml.cxx b/direct/src/plugin/binaryXml.cxx index 6363f12d8e..4840a2c1e2 100644 --- a/direct/src/plugin/binaryXml.cxx +++ b/direct/src/plugin/binaryXml.cxx @@ -69,11 +69,11 @@ write_xml_node(ostream &out, TiXmlNode *xnode) { // Now write out the node type. NodeType type = NT_element; - if (xnode->ToDocument() != NULL) { + if (xnode->ToDocument() != nullptr) { type = NT_document; - } else if (xnode->ToElement() != NULL) { + } else if (xnode->ToElement() != nullptr) { type = NT_element; - } else if (xnode->ToText() != NULL) { + } else if (xnode->ToText() != nullptr) { type = NT_text; } else { type = NT_unknown; @@ -88,10 +88,10 @@ write_xml_node(ostream &out, TiXmlNode *xnode) { if (type == NT_element) { // Write the element attributes. TiXmlElement *xelement = xnode->ToElement(); - assert(xelement != NULL); + assert(xelement != nullptr); const TiXmlAttribute *xattrib = xelement->FirstAttribute(); - while (xattrib != NULL) { + while (xattrib != nullptr) { // We have an attribute. out.put((char)true); @@ -114,7 +114,7 @@ write_xml_node(ostream &out, TiXmlNode *xnode) { // Now write all of the children. TiXmlNode *xchild = xnode->FirstChild(); - while (xchild != NULL) { + while (xchild != nullptr) { // We have a child. out.put((char)true); write_xml_node(out, xchild); @@ -136,13 +136,13 @@ read_xml_node(istream &in, char *&buffer, xml_uint32 &buffer_length, xml_uint32 value_length; in.read((char *)&value_length, sizeof(value_length)); if (in.gcount() != sizeof(value_length)) { - return NULL; + return nullptr; } xml_uint32 value_proof_expect = (value_length + length_nonce1) * length_nonce2; xml_uint32 value_proof; in.read((char *)&value_proof, sizeof(value_proof)); if (in.gcount() != sizeof(value_proof)) { - return NULL; + return nullptr; } if (value_proof != value_proof_expect) { // Hey, we ran into garbage: the proof value didn't match our expected @@ -164,7 +164,7 @@ read_xml_node(istream &in, char *&buffer, xml_uint32 &buffer_length, } logfile << "\n"; logfile << "End garbage.\n"; - return NULL; + return nullptr; } if (value_length > buffer_length) { @@ -179,10 +179,10 @@ read_xml_node(istream &in, char *&buffer, xml_uint32 &buffer_length, // Read the node type. NodeType type = (NodeType)in.get(); if (type == NT_unknown) { - return NULL; + return nullptr; } - TiXmlNode *xnode = NULL; + TiXmlNode *xnode = nullptr; if (type == NT_element) { xnode = new TiXmlElement(value); } else if (type == NT_document) { @@ -196,7 +196,7 @@ read_xml_node(istream &in, char *&buffer, xml_uint32 &buffer_length, if (type == NT_element) { // Read the element attributes. TiXmlElement *xelement = xnode->ToElement(); - assert(xelement != NULL); + assert(xelement != nullptr); bool got_attrib = (bool)(in.get() != 0); while (got_attrib && in && !in.eof()) { @@ -205,7 +205,7 @@ read_xml_node(istream &in, char *&buffer, xml_uint32 &buffer_length, in.read((char *)&name_length, sizeof(name_length)); if (in.gcount() != sizeof(name_length)) { delete xnode; - return NULL; + return nullptr; } if (name_length > buffer_length) { @@ -221,7 +221,7 @@ read_xml_node(istream &in, char *&buffer, xml_uint32 &buffer_length, in.read((char *)&value_length, sizeof(value_length)); if (in.gcount() != sizeof(value_length)) { delete xnode; - return NULL; + return nullptr; } if (value_length > buffer_length) { @@ -245,7 +245,7 @@ read_xml_node(istream &in, char *&buffer, xml_uint32 &buffer_length, while (got_child && in && !in.eof()) { // We have a child. TiXmlNode *xchild = read_xml_node(in, buffer, buffer_length, logfile); - if (xchild != NULL) { + if (xchild != nullptr) { xnode->LinkEndChild(xchild); } @@ -317,12 +317,12 @@ read_xml(istream &in, ostream &logfile) { char *buffer = new char[buffer_length]; TiXmlNode *xnode = read_xml_node(in, buffer, buffer_length, logfile); delete[] buffer; - if (xnode == NULL) { - return NULL; + if (xnode == nullptr) { + return nullptr; } TiXmlDocument *doc = xnode->ToDocument(); - assert(doc != NULL); + assert(doc != nullptr); #else // standard ASCII read. @@ -330,7 +330,7 @@ read_xml(istream &in, ostream &logfile) { in >> *doc; if (in.fail() || in.eof()) { delete doc; - return NULL; + return nullptr; } #endif diff --git a/direct/src/plugin/fileSpec.cxx b/direct/src/plugin/fileSpec.cxx index 58194c10f2..29f22e9899 100644 --- a/direct/src/plugin/fileSpec.cxx +++ b/direct/src/plugin/fileSpec.cxx @@ -42,7 +42,7 @@ FileSpec() { _timestamp = 0; memset(_hash, 0, hash_size); _got_hash = false; - _actual_file = NULL; + _actual_file = nullptr; } /** @@ -56,7 +56,7 @@ FileSpec(const FileSpec ©) : _got_hash(copy._got_hash) { memcpy(_hash, copy._hash, hash_size); - _actual_file = NULL; + _actual_file = nullptr; } /** @@ -76,7 +76,7 @@ operator = (const FileSpec ©) { */ FileSpec:: ~FileSpec() { - if (_actual_file != NULL) { + if (_actual_file != nullptr) { delete _actual_file; } } @@ -87,25 +87,25 @@ FileSpec:: void FileSpec:: load_xml(TiXmlElement *xelement) { const char *filename = xelement->Attribute("filename"); - if (filename != NULL) { + if (filename != nullptr) { _filename = filename; } const char *size = xelement->Attribute("size"); - if (size != NULL) { + if (size != nullptr) { char *endptr; _size = strtoul(size, &endptr, 10); } const char *timestamp = xelement->Attribute("timestamp"); - if (timestamp != NULL) { + if (timestamp != nullptr) { char *endptr; _timestamp = strtoul(timestamp, &endptr, 10); } _got_hash = false; const char *hash = xelement->Attribute("hash"); - if (hash != NULL && strlen(hash) == (hash_size * 2)) { + if (hash != nullptr && strlen(hash) == (hash_size * 2)) { // Decode the hex hash string. _got_hash = decode_hex(_hash, hash, hash_size); } @@ -151,9 +151,9 @@ quick_verify(const string &package_dir) { */ bool FileSpec:: quick_verify_pathname(const string &pathname) { - if (_actual_file != NULL) { + if (_actual_file != nullptr) { delete _actual_file; - _actual_file = NULL; + _actual_file = nullptr; } int result = 1; @@ -221,9 +221,9 @@ quick_verify_pathname(const string &pathname) { */ bool FileSpec:: full_verify(const string &package_dir) { - if (_actual_file != NULL) { + if (_actual_file != nullptr) { delete _actual_file; - _actual_file = NULL; + _actual_file = nullptr; } string pathname = get_pathname(package_dir); @@ -281,7 +281,7 @@ full_verify(const string &package_dir) { */ const FileSpec *FileSpec:: force_get_actual_file(const string &pathname) { - if (_actual_file == NULL) { + if (_actual_file == nullptr) { #ifdef _WIN32 struct _stat st; wstring pathname_w; @@ -418,7 +418,7 @@ output_hash(ostream &out) const { bool FileSpec:: priv_check_hash(const string &pathname, void *stp) { const struct stat &st = *(const struct stat *)stp; - assert(_actual_file == NULL); + assert(_actual_file == nullptr); _actual_file = new FileSpec; _actual_file->_filename = pathname; _actual_file->_size = st.st_size; diff --git a/direct/src/plugin/find_root_dir.cxx b/direct/src/plugin/find_root_dir.cxx index 0cf4546a0e..d15362bfd0 100644 --- a/direct/src/plugin/find_root_dir.cxx +++ b/direct/src/plugin/find_root_dir.cxx @@ -46,7 +46,7 @@ static wstring get_csidl_dir_w(int csidl) { static const int buffer_size = MAX_PATH; wchar_t buffer[buffer_size]; - if (SHGetSpecialFolderPathW(NULL, buffer, csidl, true)) { + if (SHGetSpecialFolderPathW(nullptr, buffer, csidl, true)) { wstring root = buffer; root += wstring(L"/Panda3D"); @@ -73,10 +73,10 @@ find_root_dir_default_w() { wstring root; bool is_protected = false; HMODULE ieframe = LoadLibrary("ieframe.dll"); - if (ieframe != NULL) { + if (ieframe != nullptr) { typedef HRESULT STDAPICALLTYPE IEIsProtectedModeProcess(BOOL *pbResult); IEIsProtectedModeProcess *func = (IEIsProtectedModeProcess *)GetProcAddress(ieframe, "IEIsProtectedModeProcess"); - if (func != NULL) { + if (func != nullptr) { BOOL result = false; HRESULT hr = (*func)(&result); if (hr == S_OK) { @@ -101,12 +101,12 @@ find_root_dir_default_w() { // instead of hard-linking it. HMODULE shell32 = LoadLibrary("shell32.dll"); - if (shell32 != NULL) { + if (shell32 != nullptr) { typedef HRESULT STDAPICALLTYPE SHGetKnownFolderPath(REFGUID rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath); SHGetKnownFolderPath *func = (SHGetKnownFolderPath *)GetProcAddress(shell32, "SHGetKnownFolderPath"); - if (func != NULL) { - LPWSTR cache_path = NULL; - HRESULT hr = (*func)(FOLDERID_LocalAppDataLow, 0, NULL, &cache_path); + if (func != nullptr) { + LPWSTR cache_path = nullptr; + HRESULT hr = (*func)(FOLDERID_LocalAppDataLow, 0, nullptr, &cache_path); if (SUCCEEDED(hr)) { root = cache_path; @@ -128,8 +128,8 @@ find_root_dir_default_w() { // cache folder. typedef HRESULT STDAPICALLTYPE IEGetWriteableFolderPath(REFGUID clsidFolderID, LPWSTR* lppwstrPath); IEGetWriteableFolderPath *func = (IEGetWriteableFolderPath *)GetProcAddress(ieframe, "IEGetWriteableFolderPath"); - if (func != NULL) { - LPWSTR cache_path = NULL; + if (func != nullptr) { + LPWSTR cache_path = nullptr; // Since we're here, we'll start by asking for LocalAppDataLow, even // though I know it doesn't work. @@ -218,9 +218,9 @@ find_root_dir_default() { string root; const passwd *pwdata = getpwuid(getuid()); - if (pwdata == NULL) { + if (pwdata == nullptr) { char *home = getenv("HOME"); - if (home == NULL) { + if (home == nullptr) { // Beh. Let's hope it never gets to this point. return "."; } else { @@ -260,13 +260,13 @@ find_root_dir_actual() { } TiXmlElement *xconfig = doc.FirstChildElement("config"); - if (xconfig == NULL) { + if (xconfig == nullptr) { // No element within config.xml. return root; } const char *new_root = xconfig->Attribute("root_dir"); - if (new_root == NULL || *new_root == '\0') { + if (new_root == nullptr || *new_root == '\0') { // No root_dir specified. return root; } @@ -295,7 +295,7 @@ find_root_dir() { wstring root_w; string_to_wstring(root_w, root); - DWORD length = GetShortPathNameW(root_w.c_str(), NULL, 0); + DWORD length = GetShortPathNameW(root_w.c_str(), nullptr, 0); wchar_t *short_name = new wchar_t[length]; GetShortPathNameW(root_w.c_str(), short_name, length); diff --git a/direct/src/plugin/handleStreamBuf.cxx b/direct/src/plugin/handleStreamBuf.cxx index c3aa4dc76f..c2adbd2f62 100644 --- a/direct/src/plugin/handleStreamBuf.cxx +++ b/direct/src/plugin/handleStreamBuf.cxx @@ -120,10 +120,10 @@ close() { void HandleStreamBuf:: close_handle() { #ifdef _WIN32 - if (_handle != NULL) { + if (_handle != nullptr) { CloseHandle(_handle); } - _handle = NULL; + _handle = nullptr; #else if (_handle != -1) { ::close(_handle); @@ -256,7 +256,7 @@ read_chars(char *start, size_t length) { #ifdef _WIN32 // Windows case. DWORD bytes_read = 0; - BOOL success = ReadFile(_handle, start, length, &bytes_read, NULL); + BOOL success = ReadFile(_handle, start, length, &bytes_read, nullptr); if (!success) { DWORD error = GetLastError(); if (error != ERROR_HANDLE_EOF && error != ERROR_BROKEN_PIPE) { @@ -304,7 +304,7 @@ write_chars(const char *start, size_t length) { #ifdef _WIN32 // Windows case. DWORD bytes_written = 0; - BOOL success = WriteFile(_handle, start, length, &bytes_written, NULL); + BOOL success = WriteFile(_handle, start, length, &bytes_written, nullptr); if (!success) { assert(bytes_written <= length); DWORD error = GetLastError(); diff --git a/direct/src/plugin/load_plugin.cxx b/direct/src/plugin/load_plugin.cxx index f5a730eacb..f46cb7355d 100644 --- a/direct/src/plugin/load_plugin.cxx +++ b/direct/src/plugin/load_plugin.cxx @@ -75,9 +75,9 @@ P3D_instance_feed_url_stream_func *P3D_instance_feed_url_stream_ptr; P3D_instance_handle_event_func *P3D_instance_handle_event_ptr; #ifdef _WIN32 -static HMODULE module = NULL; +static HMODULE module = nullptr; #else -static void *module = NULL; +static void *module = nullptr; #endif static bool plugin_loaded = false; @@ -139,11 +139,11 @@ load_plugin(const string &p3d_plugin_filename, string filename = p3d_plugin_filename; #ifdef _WIN32 - assert(module == NULL); + assert(module == nullptr); if (filename.empty()) { // If no filename is supplied, look within our existing address space. - module = GetModuleHandle(NULL); + module = GetModuleHandle(nullptr); dso_needs_unload = false; } else { @@ -168,7 +168,7 @@ load_plugin(const string &p3d_plugin_filename, dso_needs_unload = true; } - if (module == NULL) { + if (module == nullptr) { // Couldn't load the DLL. logfile << "Couldn't load " << filename << ", error = " @@ -180,16 +180,16 @@ load_plugin(const string &p3d_plugin_filename, #else // _WIN32 // Posix case. - assert(module == NULL); + assert(module == nullptr); if (filename.empty()) { - module = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL); + module = dlopen(nullptr, RTLD_LAZY | RTLD_LOCAL); } else { module = dlopen(filename.c_str(), RTLD_LAZY | RTLD_LOCAL); } - if (module == NULL) { + if (module == nullptr) { // Couldn't load the .so. const char *message = dlerror(); - if (message == (char *)NULL) { + if (message == nullptr) { message = "No error"; } logfile << "Couldn't load " << filename << ": " << message << "\n"; @@ -276,45 +276,45 @@ init_plugin(const string &contents_filename, const string &host_url, const string &start_dir, ostream &logfile) { // Ensure that all of the function pointers have been found. - if (P3D_initialize_ptr == NULL || - P3D_finalize_ptr == NULL || - P3D_set_plugin_version_ptr == NULL || - P3D_set_super_mirror_ptr == NULL || - P3D_new_instance_ptr == NULL || - P3D_instance_start_ptr == NULL || - P3D_instance_start_stream_ptr == NULL || - P3D_instance_finish_ptr == NULL || - P3D_instance_setup_window_ptr == NULL || + if (P3D_initialize_ptr == nullptr || + P3D_finalize_ptr == nullptr || + P3D_set_plugin_version_ptr == nullptr || + P3D_set_super_mirror_ptr == nullptr || + P3D_new_instance_ptr == nullptr || + P3D_instance_start_ptr == nullptr || + P3D_instance_start_stream_ptr == nullptr || + P3D_instance_finish_ptr == nullptr || + P3D_instance_setup_window_ptr == nullptr || - P3D_object_get_type_ptr == NULL || - P3D_object_get_bool_ptr == NULL || - P3D_object_get_int_ptr == NULL || - P3D_object_get_float_ptr == NULL || - P3D_object_get_string_ptr == NULL || - P3D_object_get_repr_ptr == NULL || - P3D_object_get_property_ptr == NULL || - P3D_object_set_property_ptr == NULL || - P3D_object_has_method_ptr == NULL || - P3D_object_call_ptr == NULL || - P3D_object_eval_ptr == NULL || - P3D_object_incref_ptr == NULL || - P3D_object_decref_ptr == NULL || + P3D_object_get_type_ptr == nullptr || + P3D_object_get_bool_ptr == nullptr || + P3D_object_get_int_ptr == nullptr || + P3D_object_get_float_ptr == nullptr || + P3D_object_get_string_ptr == nullptr || + P3D_object_get_repr_ptr == nullptr || + P3D_object_get_property_ptr == nullptr || + P3D_object_set_property_ptr == nullptr || + P3D_object_has_method_ptr == nullptr || + P3D_object_call_ptr == nullptr || + P3D_object_eval_ptr == nullptr || + P3D_object_incref_ptr == nullptr || + P3D_object_decref_ptr == nullptr || - P3D_make_class_definition_ptr == NULL || - P3D_new_undefined_object_ptr == NULL || - P3D_new_none_object_ptr == NULL || - P3D_new_bool_object_ptr == NULL || - P3D_new_int_object_ptr == NULL || - P3D_new_float_object_ptr == NULL || - P3D_new_string_object_ptr == NULL || - P3D_instance_get_panda_script_object_ptr == NULL || - P3D_instance_set_browser_script_object_ptr == NULL || + P3D_make_class_definition_ptr == nullptr || + P3D_new_undefined_object_ptr == nullptr || + P3D_new_none_object_ptr == nullptr || + P3D_new_bool_object_ptr == nullptr || + P3D_new_int_object_ptr == nullptr || + P3D_new_float_object_ptr == nullptr || + P3D_new_string_object_ptr == nullptr || + P3D_instance_get_panda_script_object_ptr == nullptr || + P3D_instance_set_browser_script_object_ptr == nullptr || - P3D_instance_get_request_ptr == NULL || - P3D_check_request_ptr == NULL || - P3D_request_finish_ptr == NULL || - P3D_instance_feed_url_stream_ptr == NULL || - P3D_instance_handle_event_ptr == NULL) { + P3D_instance_get_request_ptr == nullptr || + P3D_check_request_ptr == nullptr || + P3D_request_finish_ptr == nullptr || + P3D_instance_feed_url_stream_ptr == nullptr || + P3D_instance_handle_event_ptr == nullptr) { logfile << "Some function pointers not found:" @@ -411,55 +411,55 @@ unload_plugin(ostream &logfile) { static void unload_dso() { if (dso_needs_unload) { - assert(module != NULL); + assert(module != nullptr); #ifdef _WIN32 FreeLibrary(module); #else dlclose(module); #endif - module = NULL; + module = nullptr; dso_needs_unload = false; } - P3D_initialize_ptr = NULL; - P3D_finalize_ptr = NULL; - P3D_set_plugin_version_ptr = NULL; - P3D_set_super_mirror_ptr = NULL; - P3D_new_instance_ptr = NULL; - P3D_instance_start_ptr = NULL; - P3D_instance_start_stream_ptr = NULL; - P3D_instance_finish_ptr = NULL; - P3D_instance_setup_window_ptr = NULL; + P3D_initialize_ptr = nullptr; + P3D_finalize_ptr = nullptr; + P3D_set_plugin_version_ptr = nullptr; + P3D_set_super_mirror_ptr = nullptr; + P3D_new_instance_ptr = nullptr; + P3D_instance_start_ptr = nullptr; + P3D_instance_start_stream_ptr = nullptr; + P3D_instance_finish_ptr = nullptr; + P3D_instance_setup_window_ptr = nullptr; - P3D_object_get_type_ptr = NULL; - P3D_object_get_bool_ptr = NULL; - P3D_object_get_int_ptr = NULL; - P3D_object_get_float_ptr = NULL; - P3D_object_get_string_ptr = NULL; - P3D_object_get_repr_ptr = NULL; - P3D_object_get_property_ptr = NULL; - P3D_object_set_property_ptr = NULL; - P3D_object_has_method_ptr = NULL; - P3D_object_call_ptr = NULL; - P3D_object_eval_ptr = NULL; - P3D_object_incref_ptr = NULL; - P3D_object_decref_ptr = NULL; + P3D_object_get_type_ptr = nullptr; + P3D_object_get_bool_ptr = nullptr; + P3D_object_get_int_ptr = nullptr; + P3D_object_get_float_ptr = nullptr; + P3D_object_get_string_ptr = nullptr; + P3D_object_get_repr_ptr = nullptr; + P3D_object_get_property_ptr = nullptr; + P3D_object_set_property_ptr = nullptr; + P3D_object_has_method_ptr = nullptr; + P3D_object_call_ptr = nullptr; + P3D_object_eval_ptr = nullptr; + P3D_object_incref_ptr = nullptr; + P3D_object_decref_ptr = nullptr; - P3D_make_class_definition_ptr = NULL; - P3D_new_undefined_object_ptr = NULL; - P3D_new_none_object_ptr = NULL; - P3D_new_bool_object_ptr = NULL; - P3D_new_int_object_ptr = NULL; - P3D_new_float_object_ptr = NULL; - P3D_new_string_object_ptr = NULL; - P3D_instance_get_panda_script_object_ptr = NULL; - P3D_instance_set_browser_script_object_ptr = NULL; + P3D_make_class_definition_ptr = nullptr; + P3D_new_undefined_object_ptr = nullptr; + P3D_new_none_object_ptr = nullptr; + P3D_new_bool_object_ptr = nullptr; + P3D_new_int_object_ptr = nullptr; + P3D_new_float_object_ptr = nullptr; + P3D_new_string_object_ptr = nullptr; + P3D_instance_get_panda_script_object_ptr = nullptr; + P3D_instance_set_browser_script_object_ptr = nullptr; - P3D_instance_get_request_ptr = NULL; - P3D_check_request_ptr = NULL; - P3D_request_finish_ptr = NULL; - P3D_instance_feed_url_stream_ptr = NULL; - P3D_instance_handle_event_ptr = NULL; + P3D_instance_get_request_ptr = nullptr; + P3D_check_request_ptr = nullptr; + P3D_request_finish_ptr = nullptr; + P3D_instance_feed_url_stream_ptr = nullptr; + P3D_instance_handle_event_ptr = nullptr; plugin_loaded = false; } diff --git a/direct/src/plugin/mkdir_complete.cxx b/direct/src/plugin/mkdir_complete.cxx index 9422ea2e32..8b721f1fa8 100644 --- a/direct/src/plugin/mkdir_complete.cxx +++ b/direct/src/plugin/mkdir_complete.cxx @@ -154,7 +154,7 @@ mkfile_complete(const string &filename, ostream &logfile) { */ bool mkdir_complete_w(const wstring &dirname, ostream &logfile) { - if (CreateDirectoryW(dirname.c_str(), NULL) != 0) { + if (CreateDirectoryW(dirname.c_str(), nullptr) != 0) { // Success! return true; } @@ -171,7 +171,7 @@ mkdir_complete_w(const wstring &dirname, ostream &logfile) { wstring parent = get_dirname_w(dirname); if (!parent.empty() && mkdir_complete_w(parent, logfile)) { // Parent successfully created. Try again to make the child. - if (CreateDirectoryW(dirname.c_str(), NULL) != 0) { + if (CreateDirectoryW(dirname.c_str(), nullptr) != 0) { // Got it! return true; } @@ -198,7 +198,7 @@ mkfile_complete_w(const wstring &filename, ostream &logfile) { HANDLE file = CreateFileW(filename.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (file == INVALID_HANDLE_VALUE) { // Try to make the parent directory first. wstring parent = get_dirname_w(filename); @@ -206,7 +206,7 @@ mkfile_complete_w(const wstring &filename, ostream &logfile) { // Parent successfully created. Try again to make the file. file = CreateFileW(filename.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); } if (file == INVALID_HANDLE_VALUE) { logfile diff --git a/direct/src/plugin/p3dAuthSession.cxx b/direct/src/plugin/p3dAuthSession.cxx index 46678c19ad..15363647f9 100644 --- a/direct/src/plugin/p3dAuthSession.cxx +++ b/direct/src/plugin/p3dAuthSession.cxx @@ -53,7 +53,7 @@ P3DAuthSession(P3DInstance *inst) : _cert_filename = new P3DTemporaryFile(".crt"); string filename = _cert_filename->get_filename(); FILE *fp = fopen(filename.c_str(), "w"); - if (fp == NULL) { + if (fp == nullptr) { nout << "Couldn't write temporary file\n"; return; } @@ -88,7 +88,7 @@ P3DAuthSession:: ~P3DAuthSession() { shutdown(false); - if (_cert_filename != NULL) { + if (_cert_filename != nullptr) { delete _cert_filename; } } @@ -101,7 +101,7 @@ shutdown(bool send_message) { if (!send_message) { // If we're not to send the instance the shutdown message as a result of // this, then clear the _inst pointer now. - _inst = NULL; + _inst = nullptr; } if (_p3dcert_running) { @@ -119,7 +119,7 @@ shutdown(bool send_message) { struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 100000; - select(0, NULL, NULL, NULL, &tv); + select(0, nullptr, nullptr, nullptr, &tv); int status; waitpid(_p3dcert_pid, &status, WNOHANG); #endif // _WIN32 @@ -133,7 +133,7 @@ shutdown(bool send_message) { join_wait_thread(); // We're no longer bound to any particular instance. - _inst = NULL; + _inst = nullptr; } /** @@ -146,7 +146,7 @@ start_p3dcert() { return; } - if (_inst->_p3dcert_package == NULL) { + if (_inst->_p3dcert_package == nullptr) { nout << "Couldn't start Python: no p3dcert package.\n"; return; } @@ -175,14 +175,14 @@ start_p3dcert() { const wchar_t *keep[] = { L"TMP", L"TEMP", L"HOME", L"USER", L"SYSTEMROOT", L"USERPROFILE", L"COMSPEC", - NULL + nullptr }; wstring env_w; - for (int ki = 0; keep[ki] != NULL; ++ki) { + for (int ki = 0; keep[ki] != nullptr; ++ki) { wchar_t *value = _wgetenv(keep[ki]); - if (value != NULL) { + if (value != nullptr) { env_w += keep[ki]; env_w += L"="; env_w += value; @@ -204,11 +204,11 @@ start_p3dcert() { #ifdef HAVE_X11 "DISPLAY", "XAUTHORITY", #endif - NULL + nullptr }; - for (int ki = 0; keep[ki] != NULL; ++ki) { + for (int ki = 0; keep[ki] != nullptr; ++ki) { char *value = getenv(keep[ki]); - if (value != NULL) { + if (value != nullptr) { _env += keep[ki]; _env += "="; _env += value; @@ -337,7 +337,7 @@ wt_thread_run() { // Notify the instance that we're done. P3DInstance *inst = _inst; - if (inst != NULL) { + if (inst != nullptr) { inst->auth_finished_sub_thread(); } @@ -388,7 +388,7 @@ win_create_process() { // anyway. PROCESS_INFORMATION process_info; BOOL result = CreateProcess - (_p3dcert_exe.c_str(), command_line, NULL, NULL, TRUE, + (_p3dcert_exe.c_str(), command_line, nullptr, nullptr, TRUE, 0, (void *)_env.c_str(), start_dir_cstr, &startup_info, &process_info); bool started_program = (result != 0); @@ -440,7 +440,7 @@ posix_create_process() { p = zero + 1; zero = _env.find('\0', p); } - ptrs.push_back((char *)NULL); + ptrs.push_back(nullptr); execle(_p3dcert_exe.c_str(), _p3dcert_exe.c_str(), _cert_filename->get_filename().c_str(), _cert_dir.c_str(), diff --git a/direct/src/plugin/p3dCInstance.cxx b/direct/src/plugin/p3dCInstance.cxx index d6ecf259f1..0f77925b22 100644 --- a/direct/src/plugin/p3dCInstance.cxx +++ b/direct/src/plugin/p3dCInstance.cxx @@ -19,7 +19,7 @@ */ P3DCInstance:: P3DCInstance(TiXmlElement *xinstance) : - _func(NULL) + _func(nullptr) { xinstance->Attribute("instance_id", &_instance_id); } diff --git a/direct/src/plugin/p3dCert.cxx b/direct/src/plugin/p3dCert.cxx index bae39a3c76..f47723d466 100644 --- a/direct/src/plugin/p3dCert.cxx +++ b/direct/src/plugin/p3dCert.cxx @@ -55,10 +55,10 @@ static LanguageIndex detect_language() { typedef BOOL (*GUPL)(DWORD, PULONG, PZZWSTR, PULONG); GUPL pGetUserPreferredUILanguages = (GUPL)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), TEXT("GetUserPreferredUILanguages")); - if (pGetUserPreferredUILanguages != NULL) { + if (pGetUserPreferredUILanguages != nullptr) { ULONG num_langs = 0; ULONG buffer_size = 0; - pGetUserPreferredUILanguages(8, &num_langs, NULL, &buffer_size); + pGetUserPreferredUILanguages(8, &num_langs, nullptr, &buffer_size); PZZWSTR buffer = (PZZWSTR)_alloca(buffer_size); if (pGetUserPreferredUILanguages(8, &num_langs, buffer, &buffer_size)) { for (ULONG i = 0; i < num_langs; ++i) { @@ -67,7 +67,7 @@ static LanguageIndex detect_language() { // It may be a two-letter code; match it in our list. for (int j = 0; j < LI_COUNT; ++j) { const char *lang_code = language_codes[j]; - if (lang_code != NULL && lang_code[0] == buffer[0] && + if (lang_code != nullptr && lang_code[0] == buffer[0] && lang_code[1] == buffer[1]) { return (LanguageIndex)j; } @@ -120,7 +120,7 @@ static LanguageIndex detect_language() { // See if we support this language. for (int j = 0; j < LI_COUNT; ++j) { const char *lang_code = language_codes[j]; - if (lang_code != NULL && strncasecmp(buffer, lang_code, 2) == 0) { + if (lang_code != nullptr && strncasecmp(buffer, lang_code, 2) == 0) { CFRelease(langs); return (LanguageIndex)j; } @@ -136,10 +136,10 @@ static LanguageIndex detect_language() { // First consult the LANGUAGE variable, which is a GNU extension that can // contain multiple languages in order of preference. const char *lang = getenv("LANGUAGE"); - while (lang != NULL && lang[0] != 0) { + while (lang != nullptr && lang[0] != 0) { size_t len; const char *next = strchr(lang, ':'); - if (next == NULL) { + if (next == nullptr) { len = strlen(lang); } else { len = (next - lang); @@ -150,7 +150,7 @@ static LanguageIndex detect_language() { // It may be a two-letter language code; match it in our list. for (int i = 0; i < LI_COUNT; ++i) { const char *lang_code = language_codes[i]; - if (lang_code != NULL && strncasecmp(lang, lang_code, 2) == 0) { + if (lang_code != nullptr && strncasecmp(lang, lang_code, 2) == 0) { return (LanguageIndex)i; } } @@ -161,14 +161,14 @@ static LanguageIndex detect_language() { // Fall back to the C locale functions. setlocale(LC_ALL, ""); - lang = setlocale(LC_MESSAGES, NULL); + lang = setlocale(LC_MESSAGES, nullptr); - if (lang == NULL || lang[0] == 0 || strcmp(lang, "C") == 0) { + if (lang == nullptr || lang[0] == 0 || strcmp(lang, "C") == 0) { // Try the LANG variable. lang = getenv("LANG"); } - if (lang == NULL || strlen(lang) < 2 || isalnum(lang[2])) { + if (lang == nullptr || strlen(lang) < 2 || isalnum(lang[2])) { // Couldn't extract a meaningful two-letter code. return LI_default; } @@ -176,7 +176,7 @@ static LanguageIndex detect_language() { // It may be a two-letter language code; match it in our list. for (int i = 0; i < LI_COUNT; ++i) { const char *lang_code = language_codes[i]; - if (lang_code != NULL && strncasecmp(lang, lang_code, 2) == 0) { + if (lang_code != nullptr && strncasecmp(lang, lang_code, 2) == 0) { return (LanguageIndex)i; } } @@ -192,7 +192,7 @@ wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdS LPWSTR *argv; int argc; argv = CommandLineToArgvW(pCmdLine, &argc); - if (argv == NULL || argc != 2) { + if (argv == nullptr || argc != 2) { cerr << "usage: p3dcert cert_filename cert_dir\n"; return 1; } @@ -243,10 +243,10 @@ AuthDialog(const string &cert_filename, const string &cert_dir) : Fl_Window(435, 242, new_application_title[li]), _cert_dir(cert_dir) { - _view_cert_dialog = NULL; + _view_cert_dialog = nullptr; - _cert = NULL; - _stack = NULL; + _cert = nullptr; + _stack = nullptr; _verify_result = -1; // Center the window on the screen. @@ -264,17 +264,17 @@ AuthDialog(const string &cert_filename, const string &cert_dir) : */ AuthDialog:: ~AuthDialog() { - if (_view_cert_dialog != NULL) { + if (_view_cert_dialog != nullptr) { _view_cert_dialog->hide(); } - if (_cert != NULL) { + if (_cert != nullptr) { X509_free(_cert); - _cert = NULL; + _cert = nullptr; } - if (_stack != NULL) { + if (_stack != nullptr) { sk_X509_free(_stack); - _stack = NULL; + _stack = nullptr; } } @@ -294,7 +294,7 @@ void AuthDialog:: view_cert_clicked(Fl_Widget *w, void *data) { AuthDialog *dlg = (AuthDialog *) data; - if (dlg->_view_cert_dialog != NULL) { + if (dlg->_view_cert_dialog != nullptr) { dlg->_view_cert_dialog->hide(); } dlg->hide(); @@ -317,7 +317,7 @@ cancel_clicked(Fl_Widget *w, void *data) { */ void AuthDialog:: approve_cert() { - assert(_cert != NULL); + assert(_cert != nullptr); // Make sure the directory exists. #ifdef _WIN32 @@ -332,7 +332,7 @@ approve_cert() { // Sure, there's a slight race condition right now: another process might // attempt to create the same filename. So what. - FILE *fp = NULL; + FILE *fp = nullptr; #ifdef _WIN32 wchar_t *buf = new wchar_t[buf_length]; @@ -366,7 +366,7 @@ approve_cert() { fp = fopen(buf, "w"); #endif // _WIN32 - if (fp != NULL) { + if (fp != nullptr) { PEM_write_X509(fp, _cert); fclose(fp); } @@ -386,14 +386,14 @@ void AuthDialog:: read_cert_file(const string &cert_filename) { #endif - FILE *fp = NULL; + FILE *fp = nullptr; #ifdef _WIN32 fp = _wfopen(cert_filename.c_str(), L"r"); #else // _WIN32 fp = fopen(cert_filename.c_str(), "r"); #endif // _WIN32 - if (fp == NULL) { + if (fp == nullptr) { #ifdef _WIN32 wcerr << L"Couldn't read " << cert_filename.c_str() << L"\n"; #else @@ -401,8 +401,8 @@ read_cert_file(const string &cert_filename) { #endif return; } - _cert = PEM_read_X509(fp, NULL, NULL, (void *)""); - if (_cert == NULL) { + _cert = PEM_read_X509(fp, nullptr, nullptr, (void *)""); + if (_cert == nullptr) { #ifdef _WIN32 wcerr << L"Could not read certificate in " << cert_filename.c_str() << L".\n"; #else @@ -413,11 +413,11 @@ read_cert_file(const string &cert_filename) { } // Build up a STACK of the remaining certificates in the file. - _stack = sk_X509_new(NULL); - X509 *c = PEM_read_X509(fp, NULL, NULL, (void *)""); - while (c != NULL) { + _stack = sk_X509_new(nullptr); + X509 *c = PEM_read_X509(fp, nullptr, nullptr, (void *)""); + while (c != nullptr) { sk_X509_push(_stack, c); - c = PEM_read_X509(fp, NULL, NULL, (void *)""); + c = PEM_read_X509(fp, nullptr, nullptr, (void *)""); } fclose(fp); @@ -429,7 +429,7 @@ read_cert_file(const string &cert_filename) { */ void AuthDialog:: get_friendly_name() { - if (_cert == NULL) { + if (_cert == nullptr) { _friendly_name.clear(); return; } @@ -447,15 +447,15 @@ get_friendly_name() { // A complex OpenSSL interface to extract out the name in utf-8. X509_NAME *xname = X509_get_subject_name(_cert); - if (xname != NULL) { + if (xname != nullptr) { int pos = X509_NAME_get_index_by_NID(xname, nid, -1); if (pos != -1) { // We just get the first common name. I guess it's possible to have // more than one; not sure what that means in this context. X509_NAME_ENTRY *xentry = X509_NAME_get_entry(xname, pos); - if (xentry != NULL) { + if (xentry != nullptr) { ASN1_STRING *data = X509_NAME_ENTRY_get_data(xentry); - if (data != NULL) { + if (data != nullptr) { // We use "print" to dump the output to a memory BIO. Is there an // easier way to decode the ASN1_STRING? Curse these incomplete // docs. @@ -480,7 +480,7 @@ get_friendly_name() { */ void AuthDialog:: verify_cert() { - if (_cert == NULL) { + if (_cert == nullptr) { _verify_result = -1; return; } @@ -535,11 +535,11 @@ load_certificates_from_der_ram(X509_STORE *store, bp = (unsigned char *)data; bp_end = bp + data_size; - X509 *x509 = d2i_X509(NULL, &bp, bp_end - bp); - while (x509 != NULL) { + X509 *x509 = d2i_X509(nullptr, &bp, bp_end - bp); + while (x509 != nullptr) { X509_STORE_add_cert(store, x509); ++count; - x509 = d2i_X509(NULL, &bp, bp_end - bp); + x509 = d2i_X509(nullptr, &bp, bp_end - bp); } return count; @@ -578,7 +578,7 @@ layout() { next_y += 180; short nbuttons = 1; - if (_cert != NULL) { + if (_cert != nullptr) { nbuttons++; if (_verify_result == 0) { nbuttons++; @@ -586,13 +586,13 @@ layout() { } short bx = (w() - nbuttons * BUTTON_WIDTH - (nbuttons - 1) * BUTTON_SPACE) / 2; - if (_verify_result == 0 && _cert != NULL) { + if (_verify_result == 0 && _cert != nullptr) { Fl_Return_Button *run_button = new Fl_Return_Button(bx, next_y, BUTTON_WIDTH, 25, run_title[li]); run_button->callback(this->run_clicked, this); bx += BUTTON_WIDTH + BUTTON_SPACE; } - if (_cert != NULL) { + if (_cert != nullptr) { Fl_Button *view_button = new Fl_Button(bx, next_y, BUTTON_WIDTH, 25, show_cert_title[li]); view_button->callback(this->view_cert_clicked, this); bx += BUTTON_WIDTH + BUTTON_SPACE; @@ -672,8 +672,8 @@ ViewCertDialog(AuthDialog *auth_dialog, X509 *cert) : */ ViewCertDialog:: ~ViewCertDialog() { - if (_auth_dialog != NULL) { - _auth_dialog->_view_cert_dialog = NULL; + if (_auth_dialog != nullptr) { + _auth_dialog->_view_cert_dialog = nullptr; } } @@ -683,7 +683,7 @@ ViewCertDialog:: void ViewCertDialog:: run_clicked(Fl_Widget *w, void *data) { ViewCertDialog *dlg = (ViewCertDialog *) data; - if (dlg->_auth_dialog != NULL){ + if (dlg->_auth_dialog != nullptr){ dlg->_auth_dialog->approve_cert(); } dlg->hide(); @@ -695,7 +695,7 @@ run_clicked(Fl_Widget *w, void *data) { void ViewCertDialog:: cancel_clicked(Fl_Widget *w, void *data) { ViewCertDialog *dlg = (ViewCertDialog *) data; - if (dlg->_auth_dialog != NULL){ + if (dlg->_auth_dialog != nullptr){ dlg->_auth_dialog->hide(); } dlg->hide(); @@ -707,7 +707,7 @@ cancel_clicked(Fl_Widget *w, void *data) { void ViewCertDialog:: layout() { // Format the certificate text for display in the dialog. - assert(_cert != NULL); + assert(_cert != nullptr); BIO *mbio = BIO_new(BIO_s_mem()); X509_print(mbio, _cert); diff --git a/direct/src/plugin/p3dCert_wx.cxx b/direct/src/plugin/p3dCert_wx.cxx index ae373bb5ba..d2e5a78801 100644 --- a/direct/src/plugin/p3dCert_wx.cxx +++ b/direct/src/plugin/p3dCert_wx.cxx @@ -136,14 +136,14 @@ AuthDialog(const string &cert_filename, const string &cert_dir) : // I hate stay-on-top dialogs, but if we don't set this flag, it doesn't // come to the foreground on OSX, and might be lost behind the browser // window. - wxDialog(NULL, wxID_ANY, _T("New Panda3D Application"), wxDefaultPosition, + wxDialog(nullptr, wxID_ANY, _T("New Panda3D Application"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP), _cert_dir(cert_dir) { - _view_cert_dialog = NULL; + _view_cert_dialog = nullptr; - _cert = NULL; - _stack = NULL; + _cert = nullptr; + _stack = nullptr; _verify_result = -1; read_cert_file(cert_filename); @@ -157,17 +157,17 @@ AuthDialog(const string &cert_filename, const string &cert_dir) : */ AuthDialog:: ~AuthDialog() { - if (_view_cert_dialog != NULL) { + if (_view_cert_dialog != nullptr) { _view_cert_dialog->Destroy(); } - if (_cert != NULL) { + if (_cert != nullptr) { X509_free(_cert); - _cert = NULL; + _cert = nullptr; } - if (_stack != NULL) { + if (_stack != nullptr) { sk_X509_free(_stack); - _stack = NULL; + _stack = nullptr; } } @@ -184,7 +184,7 @@ run_clicked(wxCommandEvent &event) { */ void AuthDialog:: view_cert_clicked(wxCommandEvent &event) { - if (_view_cert_dialog != NULL) { + if (_view_cert_dialog != nullptr) { _view_cert_dialog->Destroy(); } Hide(); @@ -206,7 +206,7 @@ cancel_clicked(wxCommandEvent &event) { */ void AuthDialog:: approve_cert() { - assert(_cert != NULL); + assert(_cert != nullptr); // Make sure the directory exists. mkdir_complete(_cert_dir, cerr); @@ -243,13 +243,13 @@ approve_cert() { // Sure, there's a slight race condition right now: another process might // attempt to create the same filename. So what. - FILE *fp = NULL; + FILE *fp = nullptr; #ifdef _WIN32 fp = _wfopen(buf_w.c_str(), L"w"); #else // _WIN32 fp = fopen(buf, "w"); #endif // _WIN32 - if (fp != NULL) { + if (fp != nullptr) { PEM_write_X509(fp, _cert); fclose(fp); } @@ -263,7 +263,7 @@ approve_cert() { */ void AuthDialog:: read_cert_file(const string &cert_filename) { - FILE *fp = NULL; + FILE *fp = nullptr; #ifdef _WIN32 wstring cert_filename_w; if (string_to_wstring(cert_filename_w, cert_filename)) { @@ -273,23 +273,23 @@ read_cert_file(const string &cert_filename) { fp = fopen(cert_filename.c_str(), "r"); #endif // _WIN32 - if (fp == NULL) { + if (fp == nullptr) { cerr << "Couldn't read " << cert_filename << "\n"; return; } - _cert = PEM_read_X509(fp, NULL, NULL, (void *)""); - if (_cert == NULL) { + _cert = PEM_read_X509(fp, nullptr, nullptr, (void *)""); + if (_cert == nullptr) { cerr << "Could not read certificate in " << cert_filename << ".\n"; fclose(fp); return; } // Build up a STACK of the remaining certificates in the file. - _stack = sk_X509_new(NULL); - X509 *c = PEM_read_X509(fp, NULL, NULL, (void *)""); - while (c != NULL) { + _stack = sk_X509_new(nullptr); + X509 *c = PEM_read_X509(fp, nullptr, nullptr, (void *)""); + while (c != nullptr) { sk_X509_push(_stack, c); - c = PEM_read_X509(fp, NULL, NULL, (void *)""); + c = PEM_read_X509(fp, nullptr, nullptr, (void *)""); } fclose(fp); @@ -301,7 +301,7 @@ read_cert_file(const string &cert_filename) { */ void AuthDialog:: get_friendly_name() { - if (_cert == NULL) { + if (_cert == nullptr) { _friendly_name.clear(); return; } @@ -319,15 +319,15 @@ get_friendly_name() { // A complex OpenSSL interface to extract out the name in utf-8. X509_NAME *xname = X509_get_subject_name(_cert); - if (xname != NULL) { + if (xname != nullptr) { int pos = X509_NAME_get_index_by_NID(xname, nid, -1); if (pos != -1) { // We just get the first common name. I guess it's possible to have // more than one; not sure what that means in this context. X509_NAME_ENTRY *xentry = X509_NAME_get_entry(xname, pos); - if (xentry != NULL) { + if (xentry != nullptr) { ASN1_STRING *data = X509_NAME_ENTRY_get_data(xentry); - if (data != NULL) { + if (data != nullptr) { // We use "print" to dump the output to a memory BIO. Is there an // easier way to decode the ASN1_STRING? Curse these incomplete // docs. @@ -352,7 +352,7 @@ get_friendly_name() { */ void AuthDialog:: verify_cert() { - if (_cert == NULL) { + if (_cert == nullptr) { _verify_result = -1; return; } @@ -407,11 +407,11 @@ load_certificates_from_der_ram(X509_STORE *store, bp = (unsigned char *)data; bp_end = bp + data_size; - X509 *x509 = d2i_X509(NULL, &bp, bp_end - bp); - while (x509 != NULL) { + X509 *x509 = d2i_X509(nullptr, &bp, bp_end - bp); + while (x509 != nullptr) { X509_STORE_add_cert(store, x509); ++count; - x509 = d2i_X509(NULL, &bp, bp_end - bp); + x509 = d2i_X509(nullptr, &bp, bp_end - bp); } return count; @@ -449,12 +449,12 @@ layout() { // Create the run cancel buttons. wxBoxSizer *bsizer = new wxBoxSizer(wxHORIZONTAL); - if (_verify_result == 0 && _cert != NULL) { + if (_verify_result == 0 && _cert != nullptr) { wxButton *run_button = new wxButton(panel, wxID_OK, _T("Run")); bsizer->Add(run_button, 0, wxALIGN_CENTER | wxALL, 5); } - if (_cert != NULL) { + if (_cert != nullptr) { wxButton *view_button = new wxButton(panel, VIEW_CERT_BUTTON, _T("View Certificate")); bsizer->Add(view_button, 0, wxALIGN_CENTER | wxALL, 5); } @@ -522,7 +522,7 @@ END_EVENT_TABLE() */ ViewCertDialog:: ViewCertDialog(AuthDialog *auth_dialog, X509 *cert) : -wxDialog(NULL, wxID_ANY, _T("View Certificate"), wxDefaultPosition, +wxDialog(nullptr, wxID_ANY, _T("View Certificate"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), _auth_dialog(auth_dialog), _cert(cert) @@ -535,8 +535,8 @@ wxDialog(NULL, wxID_ANY, _T("View Certificate"), wxDefaultPosition, */ ViewCertDialog:: ~ViewCertDialog() { - if (_auth_dialog != NULL) { - _auth_dialog->_view_cert_dialog = NULL; + if (_auth_dialog != nullptr) { + _auth_dialog->_view_cert_dialog = nullptr; } } @@ -545,7 +545,7 @@ ViewCertDialog:: */ void ViewCertDialog:: run_clicked(wxCommandEvent &event) { - if (_auth_dialog != NULL){ + if (_auth_dialog != nullptr){ _auth_dialog->approve_cert(); } Destroy(); @@ -556,7 +556,7 @@ run_clicked(wxCommandEvent &event) { */ void ViewCertDialog:: cancel_clicked(wxCommandEvent &event) { - if (_auth_dialog != NULL){ + if (_auth_dialog != nullptr){ _auth_dialog->Destroy(); } Destroy(); @@ -568,7 +568,7 @@ cancel_clicked(wxCommandEvent &event) { void ViewCertDialog:: layout() { // Format the certificate text for display in the dialog. - assert(_cert != NULL); + assert(_cert != nullptr); BIO *mbio = BIO_new(BIO_s_mem()); X509_print(mbio, _cert); diff --git a/direct/src/plugin/p3dConcreteSequence.cxx b/direct/src/plugin/p3dConcreteSequence.cxx index 946afd05cd..2dd6dbf29e 100644 --- a/direct/src/plugin/p3dConcreteSequence.cxx +++ b/direct/src/plugin/p3dConcreteSequence.cxx @@ -86,7 +86,7 @@ get_property(const string &property) { char *endptr; int index = strtoul(property.c_str(), &endptr, 10); if (*endptr != '\0') { - return NULL; + return nullptr; } return get_element(index); @@ -133,7 +133,7 @@ fill_xml(TiXmlElement *xvalue, P3DSession *session) { P3D_object **P3DConcreteSequence:: get_object_array() { if (_elements.empty()) { - return NULL; + return nullptr; } return &_elements[0]; } @@ -165,7 +165,7 @@ get_element(int n) const { return _elements[n]; } - return NULL; + return nullptr; } /** @@ -174,7 +174,7 @@ get_element(int n) const { */ bool P3DConcreteSequence:: set_element(int n, P3D_object *value) { - if (value == NULL) { + if (value == nullptr) { // Delete an element. if (n < 0 || n >= (int)_elements.size()) { // Invalid index. diff --git a/direct/src/plugin/p3dConcreteStruct.cxx b/direct/src/plugin/p3dConcreteStruct.cxx index f85119cd2d..753bcb2b83 100644 --- a/direct/src/plugin/p3dConcreteStruct.cxx +++ b/direct/src/plugin/p3dConcreteStruct.cxx @@ -82,7 +82,7 @@ get_property(const string &property) { return (*ei).second; } - return NULL; + return nullptr; } /** @@ -91,7 +91,7 @@ get_property(const string &property) { */ bool P3DConcreteStruct:: set_property(const string &property, P3D_object *value) { - if (value == NULL) { + if (value == nullptr) { // Delete an element. Elements::iterator ei = _elements.find(property); if (ei == _elements.end()) { @@ -139,7 +139,7 @@ has_method(const string &method_name) { P3D_object *P3DConcreteStruct:: call(const string &method_name, bool needs_response, P3D_object *params[], int num_params) { - P3D_object *result = NULL; + P3D_object *result = nullptr; if (method_name == "toString") { string value; @@ -147,9 +147,9 @@ call(const string &method_name, bool needs_response, result = P3D_new_string_object(value.data(), value.length()); } - if (result != NULL && !needs_response) { + if (result != nullptr && !needs_response) { P3D_OBJECT_DECREF(result); - result = NULL; + result = nullptr; } return result; diff --git a/direct/src/plugin/p3dConditionVar.cxx b/direct/src/plugin/p3dConditionVar.cxx index 341e8be905..22133c0781 100644 --- a/direct/src/plugin/p3dConditionVar.cxx +++ b/direct/src/plugin/p3dConditionVar.cxx @@ -28,7 +28,7 @@ P3DConditionVar() { InitializeCriticalSection(&_lock); // Create an auto-reset event. - _event_signal = CreateEvent(NULL, false, false, NULL); + _event_signal = CreateEvent(nullptr, false, false, nullptr); #else // _WIN32 pthread_mutexattr_t attr; @@ -38,7 +38,7 @@ P3DConditionVar() { pthread_mutexattr_destroy(&attr); assert(result == 0); - result = pthread_cond_init(&_cvar, NULL); + result = pthread_cond_init(&_cvar, nullptr); assert(result == 0); #endif // _WIN32 @@ -115,7 +115,7 @@ wait(double timeout) { #else // _WIN32 struct timeval now; - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); // Convert from timeval to timespec struct timespec ts; diff --git a/direct/src/plugin/p3dDownload.cxx b/direct/src/plugin/p3dDownload.cxx index 9b1af6ba7d..6423b4d9a7 100644 --- a/direct/src/plugin/p3dDownload.cxx +++ b/direct/src/plugin/p3dDownload.cxx @@ -27,7 +27,7 @@ P3DDownload() { _canceled = false; _download_id = 0; - _instance = NULL; + _instance = nullptr; } /** @@ -46,7 +46,7 @@ P3DDownload(const P3DDownload ©) : _canceled = false; _download_id = 0; - _instance = NULL; + _instance = nullptr; } /** @@ -162,7 +162,7 @@ receive_data(const unsigned char *this_data, size_t this_data_size) { */ void P3DDownload:: download_progress() { - time_t now = time(NULL); + time_t now = time(nullptr); if (now - _last_reported_time > 10) { _last_reported_time = now; nout << "Downloading " << get_url() << ": "; diff --git a/direct/src/plugin/p3dFileParams.cxx b/direct/src/plugin/p3dFileParams.cxx index 128520d993..1be229e3bb 100644 --- a/direct/src/plugin/p3dFileParams.cxx +++ b/direct/src/plugin/p3dFileParams.cxx @@ -90,13 +90,13 @@ set_tokens(const P3D_token tokens[], size_t num_tokens) { void P3DFileParams:: set_token(const char *keyword, const char *value) { Token token; - if (keyword != NULL) { + if (keyword != nullptr) { // Make the token lowercase, since HTML is case-insensitive but we're not. for (const char *p = keyword; *p; ++p) { token._keyword += tolower(*p); } } - if (value != NULL) { + if (value != nullptr) { token._value = value; } _tokens.push_back(token); @@ -111,7 +111,7 @@ set_args(int argc, const char *argv[]) { for (int i = 0; i < argc; ++i) { const char *arg = argv[i]; - if (arg == NULL) { + if (arg == nullptr) { arg = ""; } _args.push_back(arg); diff --git a/direct/src/plugin/p3dHost.I b/direct/src/plugin/p3dHost.I index f7e4640b66..27f3e2a8f8 100644 --- a/direct/src/plugin/p3dHost.I +++ b/direct/src/plugin/p3dHost.I @@ -79,7 +79,7 @@ get_descriptive_name() const { */ inline bool P3DHost:: has_contents_file() const { - return (_xcontents != NULL); + return (_xcontents != nullptr); } /** diff --git a/direct/src/plugin/p3dHost.cxx b/direct/src/plugin/p3dHost.cxx index 054dbe6166..028af6bef0 100644 --- a/direct/src/plugin/p3dHost.cxx +++ b/direct/src/plugin/p3dHost.cxx @@ -42,7 +42,7 @@ P3DHost(const string &host_url, const string &host_dir) : _descriptive_name = _host_url; - _xcontents = NULL; + _xcontents = nullptr; _contents_expiration = 0; _contents_iseq = 0; } @@ -52,7 +52,7 @@ P3DHost(const string &host_url, const string &host_dir) : */ P3DHost:: ~P3DHost() { - if (_xcontents != NULL) { + if (_xcontents != nullptr) { delete _xcontents; } @@ -94,7 +94,7 @@ P3DHost:: */ P3DHost *P3DHost:: get_alt_host(const string &alt_host) { - assert(_xcontents != NULL); + assert(_xcontents != nullptr); AltHosts::iterator hi; hi = _alt_hosts.find(alt_host); @@ -118,8 +118,8 @@ has_current_contents_file(P3DInstanceManager *inst_mgr) const { return has_contents_file(); } - time_t now = time(NULL); - return now < _contents_expiration && (_xcontents != NULL); + time_t now = time(nullptr); + return now < _contents_expiration && (_xcontents != nullptr); } /** @@ -153,11 +153,11 @@ read_contents_file(const string &contents_filename, bool fresh_download) { } TiXmlElement *xcontents = doc.FirstChildElement("contents"); - if (xcontents == NULL) { + if (xcontents == nullptr) { return false; } - if (_xcontents != NULL) { + if (_xcontents != nullptr) { delete _xcontents; } _xcontents = (TiXmlElement *)xcontents->Clone(); @@ -169,7 +169,7 @@ read_contents_file(const string &contents_filename, bool fresh_download) { // Get the latest possible expiration time, based on the max_age indication. // Any expiration time later than this is in error. - time_t now = time(NULL); + time_t now = time(nullptr); _contents_expiration = now + (time_t)max_age; if (fresh_download) { @@ -177,7 +177,7 @@ read_contents_file(const string &contents_filename, bool fresh_download) { // Update the XML with the new download information. TiXmlElement *xorig = xcontents->FirstChildElement("orig"); - while (xorig != NULL) { + while (xorig != nullptr) { xcontents->RemoveChild(xorig); xorig = xcontents->FirstChildElement("orig"); } @@ -192,7 +192,7 @@ read_contents_file(const string &contents_filename, bool fresh_download) { // Read the download hash and expiration time from the XML. int expiration = 0; TiXmlElement *xorig = xcontents->FirstChildElement("orig"); - if (xorig != NULL) { + if (xorig != nullptr) { _contents_spec.load_xml(xorig); xorig->Attribute("expiration", &expiration); } @@ -208,18 +208,18 @@ read_contents_file(const string &contents_filename, bool fresh_download) { << " s\n"; TiXmlElement *xhost = _xcontents->FirstChildElement("host"); - if (xhost != NULL) { + if (xhost != nullptr) { const char *url = xhost->Attribute("url"); - if (url != NULL && _host_url == string(url)) { + if (url != nullptr && _host_url == string(url)) { // We're the primary host. This is the normal case. read_xhost(xhost); // Build up the list of alternate hosts. TiXmlElement *xalthost = xhost->FirstChildElement("alt_host"); - while (xalthost != NULL) { + while (xalthost != nullptr) { const char *keyword = xalthost->Attribute("keyword"); const char *url = xalthost->Attribute("url"); - if (keyword != NULL && url != NULL) { + if (keyword != nullptr && url != nullptr) { _alt_hosts[keyword] = url; } xalthost = xalthost->NextSiblingElement("alt_host"); @@ -228,9 +228,9 @@ read_contents_file(const string &contents_filename, bool fresh_download) { } else { // We're not the primary host; perhaps we're an alternate host. TiXmlElement *xalthost = xhost->FirstChildElement("alt_host"); - while (xalthost != NULL) { + while (xalthost != nullptr) { const char *url = xalthost->Attribute("url"); - if (url != NULL && _host_url == string(url)) { + if (url != nullptr && _host_url == string(url)) { // Yep, we're this alternate host. read_xhost(xalthost); break; @@ -288,12 +288,12 @@ read_contents_file(const string &contents_filename, bool fresh_download) { void P3DHost:: read_xhost(TiXmlElement *xhost) { const char *descriptive_name = xhost->Attribute("descriptive_name"); - if (descriptive_name != NULL && _descriptive_name.empty()) { + if (descriptive_name != nullptr && _descriptive_name.empty()) { _descriptive_name = descriptive_name; } const char *host_dir_basename = xhost->Attribute("host_dir"); - if (host_dir_basename == NULL) { + if (host_dir_basename == nullptr) { host_dir_basename = ""; } if (_host_dir.empty()) { @@ -303,7 +303,7 @@ read_xhost(TiXmlElement *xhost) { // Get the "download" URL, which is the source from which we download // everything other than the contents.xml file. const char *download_url = xhost->Attribute("download_url"); - if (download_url != NULL) { + if (download_url != nullptr) { _download_url_prefix = download_url; } if (!_download_url_prefix.empty()) { @@ -315,9 +315,9 @@ read_xhost(TiXmlElement *xhost) { } TiXmlElement *xmirror = xhost->FirstChildElement("mirror"); - while (xmirror != NULL) { + while (xmirror != nullptr) { const char *url = xmirror->Attribute("url"); - if (url != NULL) { + if (url != nullptr) { add_mirror(url); } xmirror = xmirror->NextSiblingElement("mirror"); @@ -338,7 +338,7 @@ get_package(const string &package_name, const string &package_version, const string &package_platform, const string &package_seq, const string &alt_host) { if (!alt_host.empty()) { - if (_xcontents != NULL) { + if (_xcontents != nullptr) { // If we're asking for an alt host and we've already read our // contents.xml file, then we already know all of our hosts, and we can // start the package off with the correct host immediately. @@ -355,7 +355,7 @@ get_package(const string &package_name, const string &package_version, string key = package_name + "_" + package_version; PlatformPackages &ppackages = _packages[alt_host][key]; PlatformPackages::iterator ppi; - P3DPackage *package = NULL; + P3DPackage *package = nullptr; // First, look for an exact match of the platform. for (ppi = ppackages.begin(); ppi != ppackages.end(); ++ppi) { @@ -366,7 +366,7 @@ get_package(const string &package_name, const string &package_version, } // If an exact match isn't found, look for a generic platform. - if (package == NULL) { + if (package == nullptr) { for (ppi = ppackages.begin(); ppi != ppackages.end(); ++ppi) { if ((*ppi)->get_package_platform().empty()) { package = *ppi; @@ -375,18 +375,18 @@ get_package(const string &package_name, const string &package_version, } } - if (package != NULL) { + if (package != nullptr) { if (package->get_failed()) { // If the package has previously failed, move it aside and try again // (maybe it just failed because the user interrupted it). nout << "Package " << key << " has previously failed; trying again.\n"; _failed_packages.push_back(package); ppackages.erase(ppi); - package = NULL; + package = nullptr; } } - if (package == NULL) { + if (package == nullptr) { package = new P3DPackage(this, package_name, package_version, package_platform, alt_host); ppackages.push_back(package); @@ -428,7 +428,7 @@ choose_suitable_platform(string &selected_platform, const string &package_name, const string &package_version, const string &package_platform) { - if (_xcontents == NULL) { + if (_xcontents == nullptr) { return false; } @@ -443,17 +443,17 @@ choose_suitable_platform(string &selected_platform, for (int pi = 0; pi < num_supported_platforms; ++pi) { string supported_platform = inst_mgr->get_supported_platform(pi); xpackage = _xcontents->FirstChildElement("package"); - while (xpackage != NULL) { + while (xpackage != nullptr) { const char *name = xpackage->Attribute("name"); const char *platform = xpackage->Attribute("platform"); const char *version = xpackage->Attribute("version"); - if (platform == NULL) { + if (platform == nullptr) { platform = ""; } - if (version == NULL) { + if (version == nullptr) { version = ""; } - if (name != NULL && + if (name != nullptr && package_name == name && supported_platform == platform && package_version == version) { @@ -470,17 +470,17 @@ choose_suitable_platform(string &selected_platform, // Now, we look for an exact match for the expected platform. xpackage = _xcontents->FirstChildElement("package"); - while (xpackage != NULL) { + while (xpackage != nullptr) { const char *name = xpackage->Attribute("name"); const char *platform = xpackage->Attribute("platform"); const char *version = xpackage->Attribute("version"); - if (platform == NULL) { + if (platform == nullptr) { platform = ""; } - if (version == NULL) { + if (version == nullptr) { version = ""; } - if (name != NULL && + if (name != nullptr && package_name == name && package_platform == platform && package_version == version) { @@ -496,17 +496,17 @@ choose_suitable_platform(string &selected_platform, // Look one more time, this time looking for a non-platform-specific // version. xpackage = _xcontents->FirstChildElement("package"); - while (xpackage != NULL) { + while (xpackage != nullptr) { const char *name = xpackage->Attribute("name"); const char *platform = xpackage->Attribute("platform"); const char *version = xpackage->Attribute("version"); - if (platform == NULL) { + if (platform == nullptr) { platform = ""; } - if (version == NULL) { + if (version == nullptr) { version = ""; } - if (name != NULL && + if (name != nullptr && package_name == name && *platform == '\0' && package_version == version) { @@ -535,7 +535,7 @@ get_package_desc_file(FileSpec &desc_file, // out const string &package_name, // in const string &package_version, // in const string &package_platform) { // in - if (_xcontents == NULL) { + if (_xcontents == nullptr) { return false; } @@ -545,22 +545,22 @@ get_package_desc_file(FileSpec &desc_file, // out // platform precisely, because we previously called // choose_suitable_platform(). TiXmlElement *xpackage = _xcontents->FirstChildElement("package"); - while (xpackage != NULL) { + while (xpackage != nullptr) { const char *name = xpackage->Attribute("name"); const char *platform = xpackage->Attribute("platform"); const char *version = xpackage->Attribute("version"); const char *seq = xpackage->Attribute("seq"); const char *solo = xpackage->Attribute("solo"); - if (platform == NULL) { + if (platform == nullptr) { platform = ""; } - if (version == NULL) { + if (version == nullptr) { version = ""; } - if (seq == NULL) { + if (seq == nullptr) { seq = ""; } - if (name != NULL && platform != NULL && + if (name != nullptr && platform != nullptr && package_name == name && package_platform == platform && package_version == version) { @@ -568,7 +568,7 @@ get_package_desc_file(FileSpec &desc_file, // out desc_file.load_xml(xpackage); package_seq = seq; package_solo = false; - if (solo != NULL) { + if (solo != nullptr) { package_solo = (atoi(solo) != 0); } return true; diff --git a/direct/src/plugin/p3dInstance.I b/direct/src/plugin/p3dInstance.I index 4168f68ac8..13aacd8b6b 100644 --- a/direct/src/plugin/p3dInstance.I +++ b/direct/src/plugin/p3dInstance.I @@ -105,7 +105,7 @@ get_matches_script_origin() const { */ inline bool P3DInstance:: is_started() const { - return (_session != NULL); + return (_session != nullptr); } /** @@ -123,7 +123,7 @@ is_failed() const { inline P3DInstance::ImageFile:: ImageFile() { _use_standard_image = true; - _temp_filename = NULL; + _temp_filename = nullptr; _image_placement = P3DSplashWindow::IP_none; } @@ -140,8 +140,8 @@ inline P3DInstance::ImageFile:: */ inline void P3DInstance::ImageFile:: cleanup() { - if (_temp_filename != NULL) { + if (_temp_filename != nullptr) { delete _temp_filename; - _temp_filename = NULL; + _temp_filename = nullptr; } } diff --git a/direct/src/plugin/p3dInstance.cxx b/direct/src/plugin/p3dInstance.cxx index 0eabdaafd5..21e608d5a5 100644 --- a/direct/src/plugin/p3dInstance.cxx +++ b/direct/src/plugin/p3dInstance.cxx @@ -99,22 +99,22 @@ P3DInstance(P3D_request_ready_func *func, int argc, const char *argv[], void *user_data) : _func(func) { - _dom_object = NULL; + _dom_object = nullptr; _main_object = new P3DMainObject; _main_object->set_instance(this); _user_data = user_data; _request_pending = false; _total_time_reports = 0; - _temp_p3d_filename = NULL; - _image_package = NULL; + _temp_p3d_filename = nullptr; + _image_package = nullptr; _current_background_image = IT_none; _current_button_image = IT_none; _got_fparams = false; _got_wparams = false; _p3d_trusted = false; - _xpackage = NULL; - _certlist_package = NULL; - _p3dcert_package = NULL; + _xpackage = nullptr; + _certlist_package = nullptr; + _p3dcert_package = nullptr; _fparams.set_tokens(tokens, num_tokens); _fparams.set_args(argc, argv); @@ -141,10 +141,10 @@ P3DInstance(P3D_request_ready_func *func, } _auth_button_clicked = false; _failed = false; - _session = NULL; - _auth_session = NULL; - _panda3d_package = NULL; - _splash_window = NULL; + _session = nullptr; + _auth_session = nullptr; + _panda3d_package = nullptr; + _splash_window = nullptr; _instance_window_opened = false; _instance_window_attached = false; _stuff_to_download = false; @@ -163,18 +163,18 @@ P3DInstance(P3D_request_ready_func *func, #ifdef __APPLE__ _shared_fd = -1; _shared_mmap_size = 0; - _swbuffer = NULL; - _reversed_buffer = NULL; - _buffer_data = NULL; - _data_provider = NULL; - _buffer_color_space = NULL; - _buffer_image = NULL; + _swbuffer = nullptr; + _reversed_buffer = nullptr; + _buffer_data = nullptr; + _data_provider = nullptr; + _buffer_color_space = nullptr; + _buffer_image = nullptr; // We have to start with _mouse_active true; firefox doesn't send activate // events. _mouse_active = true; _modifiers = 0; - _frame_timer = NULL; + _frame_timer = nullptr; #endif // __APPLE__ // Set some initial properties. @@ -219,7 +219,7 @@ P3DInstance(P3D_request_ready_func *func, time_t timestamp = inst_mgr->get_coreapi_timestamp(); _main_object->set_int_property("coreapiTimestamp", (int)timestamp); const char *timestamp_string = ctime(×tamp); - if (timestamp_string == NULL) { + if (timestamp_string == nullptr) { timestamp_string = ""; } _main_object->set_string_property("coreapiTimestampString", timestamp_string); @@ -239,7 +239,7 @@ P3DInstance(P3D_request_ready_func *func, // contents. P3DHost *host = inst_mgr->get_host(inst_mgr->get_host_url()); _image_package = host->get_package("images", "", "", ""); - if (_image_package != NULL) { + if (_image_package != nullptr) { _image_package->add_instance(this); } @@ -261,27 +261,27 @@ P3DInstance(P3D_request_ready_func *func, */ P3DInstance:: ~P3DInstance() { - assert(_session == NULL); + assert(_session == nullptr); cleanup(); - if (_dom_object != NULL) { + if (_dom_object != nullptr) { P3D_OBJECT_DECREF(_dom_object); - _dom_object = NULL; + _dom_object = nullptr; } - if (_main_object != NULL) { + if (_main_object != nullptr) { nout << "panda_script_object ref = " << _main_object->_ref_count << "\n"; - _main_object->set_instance(NULL); + _main_object->set_instance(nullptr); P3D_OBJECT_DECREF(_main_object); - _main_object = NULL; + _main_object = nullptr; } Downloads::iterator di; for (di = _downloads.begin(); di != _downloads.end(); ++di) { P3DDownload *download = (*di).second; if (download->get_instance() == this) { - download->set_instance(NULL); + download->set_instance(nullptr); } p3d_unref_delete(download); } @@ -300,10 +300,10 @@ void P3DInstance:: cleanup() { _failed = true; - if (_auth_session != NULL) { + if (_auth_session != nullptr) { _auth_session->shutdown(false); p3d_unref_delete(_auth_session); - _auth_session = NULL; + _auth_session = nullptr; } for (int i = 0; i < (int)IT_num_image_types; ++i) { @@ -316,47 +316,47 @@ cleanup() { (*pi)->remove_instance(this); } _packages.clear(); - if (_image_package != NULL) { + if (_image_package != nullptr) { _image_package->remove_instance(this); - _image_package = NULL; + _image_package = nullptr; } - if (_certlist_package != NULL) { + if (_certlist_package != nullptr) { _certlist_package->remove_instance(this); - _certlist_package = NULL; + _certlist_package = nullptr; } - if (_p3dcert_package != NULL) { + if (_p3dcert_package != nullptr) { _p3dcert_package->remove_instance(this); - _p3dcert_package = NULL; + _p3dcert_package = nullptr; } - if (_splash_window != NULL) { + if (_splash_window != nullptr) { delete _splash_window; - _splash_window = NULL; + _splash_window = nullptr; } - if (_temp_p3d_filename != NULL) { + if (_temp_p3d_filename != nullptr) { delete _temp_p3d_filename; - _temp_p3d_filename = NULL; + _temp_p3d_filename = nullptr; } - if (_xpackage != NULL) { + if (_xpackage != nullptr) { delete _xpackage; - _xpackage = NULL; + _xpackage = nullptr; } #ifdef __APPLE__ - if (_frame_timer != NULL) { + if (_frame_timer != nullptr) { CFRunLoopTimerInvalidate(_frame_timer); CFRelease(_frame_timer); - _frame_timer = NULL; + _frame_timer = nullptr; } free_swbuffer(); #endif - TiXmlDocument *doc = NULL; + TiXmlDocument *doc = nullptr; ACQUIRE_LOCK(_request_lock); RawRequests::iterator ri; for (ri = _raw_requests.begin(); ri != _raw_requests.end(); ++ri) { @@ -404,7 +404,7 @@ set_p3d_url(const string &p3d_url) { determine_p3d_basename(p3d_url); // Make a temporary file to receive the instance data. - assert(_temp_p3d_filename == NULL); + assert(_temp_p3d_filename == nullptr); _temp_p3d_filename = new P3DTemporaryFile(".p3d"); _stuff_to_download = true; @@ -416,7 +416,7 @@ set_p3d_url(const string &p3d_url) { #ifdef _WIN32 _start_dl_tick = GetTickCount(); #else - gettimeofday(&_start_dl_timeval, NULL); + gettimeofday(&_start_dl_timeval, nullptr); #endif _show_dl_instance_progress = false; @@ -445,7 +445,7 @@ make_p3d_stream(const string &p3d_url) { determine_p3d_basename(p3d_url); // Make a temporary file to receive the instance data. - assert(_temp_p3d_filename == NULL); + assert(_temp_p3d_filename == nullptr); _temp_p3d_filename = new P3DTemporaryFile(".p3d"); _stuff_to_download = true; @@ -457,7 +457,7 @@ make_p3d_stream(const string &p3d_url) { #ifdef _WIN32 _start_dl_tick = GetTickCount(); #else - gettimeofday(&_start_dl_timeval, NULL); + gettimeofday(&_start_dl_timeval, nullptr); #endif _show_dl_instance_progress = false; @@ -505,7 +505,7 @@ set_wparams(const P3DWindowParams &wparams) { if (_wparams.get_window_type() != P3D_WT_hidden) { // Update or create the splash window. - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_wparams(_wparams); } else { make_splash_window(); @@ -526,13 +526,13 @@ set_wparams(const P3DWindowParams &wparams) { int x_size = _wparams.get_win_width(); int y_size = _wparams.get_win_height(); if (x_size != 0 && y_size != 0) { - if (_swbuffer == NULL || _swbuffer->get_x_size() != x_size || + if (_swbuffer == nullptr || _swbuffer->get_x_size() != x_size || _swbuffer->get_y_size() != y_size) { // We need to open a new shared buffer. alloc_swbuffer(); } - if (_swbuffer == NULL) { + if (_swbuffer == nullptr) { nout << "Could not open swbuffer\n"; } } @@ -540,7 +540,7 @@ set_wparams(const P3DWindowParams &wparams) { } // Update the instance in the sub-process. - if (_session != NULL) { + if (_session != nullptr) { TiXmlDocument *doc = new TiXmlDocument; TiXmlElement *xcommand = new TiXmlElement("command"); xcommand->SetAttribute("cmd", "setup_window"); @@ -582,11 +582,11 @@ set_browser_script_object(P3D_object *browser_script_object) { if (browser_script_object != _dom_object) { P3D_OBJECT_XDECREF(_dom_object); _dom_object = browser_script_object; - if (_dom_object != NULL) { + if (_dom_object != nullptr) { P3D_OBJECT_INCREF(_dom_object); } - if (_session != NULL) { + if (_session != nullptr) { send_browser_script_object(); } } @@ -596,12 +596,12 @@ set_browser_script_object(P3D_object *browser_script_object) { _origin_protocol.clear(); _origin_hostname.clear(); _origin_port.clear(); - if (_dom_object != NULL) { + if (_dom_object != nullptr) { P3D_object *location = P3D_OBJECT_GET_PROPERTY(_dom_object, "location"); - if (location != NULL) { + if (location != nullptr) { P3D_object *protocol = P3D_OBJECT_GET_PROPERTY(location, "protocol"); - if (protocol != NULL) { - int size = P3D_OBJECT_GET_STRING(protocol, NULL, 0); + if (protocol != nullptr) { + int size = P3D_OBJECT_GET_STRING(protocol, nullptr, 0); char *buffer = new char[size]; P3D_OBJECT_GET_STRING(protocol, buffer, size); _origin_protocol = string(buffer, size); @@ -610,8 +610,8 @@ set_browser_script_object(P3D_object *browser_script_object) { } P3D_object *hostname = P3D_OBJECT_GET_PROPERTY(location, "hostname"); - if (hostname != NULL) { - int size = P3D_OBJECT_GET_STRING(hostname, NULL, 0); + if (hostname != nullptr) { + int size = P3D_OBJECT_GET_STRING(hostname, nullptr, 0); char *buffer = new char[size]; P3D_OBJECT_GET_STRING(hostname, buffer, size); _origin_hostname = string(buffer, size); @@ -620,8 +620,8 @@ set_browser_script_object(P3D_object *browser_script_object) { } P3D_object *port = P3D_OBJECT_GET_PROPERTY(location, "port"); - if (port != NULL) { - int size = P3D_OBJECT_GET_STRING(port, NULL, 0); + if (port != nullptr) { + int size = P3D_OBJECT_GET_STRING(port, nullptr, 0); char *buffer = new char[size]; P3D_OBJECT_GET_STRING(port, buffer, size); _origin_port = string(buffer, size); @@ -676,14 +676,14 @@ get_request() { if (_baked_requests.empty()) { // No requests ready. _request_pending = false; - return NULL; + return nullptr; } P3D_request *request = _baked_requests.front(); _baked_requests.pop_front(); _request_pending = !_baked_requests.empty(); - if (request != NULL) { + if (request != nullptr) { switch (request->_request_type) { case P3D_RT_notify: { @@ -691,7 +691,7 @@ get_request() { string message = request->_request._notify._message; string expression = _fparams.lookup_token(message); nout << "notify: " << message << " " << expression << "\n"; - if (!expression.empty() && _dom_object != NULL) { + if (!expression.empty() && _dom_object != nullptr) { P3D_object *result = P3D_OBJECT_EVAL(_dom_object, expression.c_str()); P3D_OBJECT_XDECREF(result); } @@ -702,13 +702,13 @@ get_request() { { // We also send an implicit message when Python requests itself to // shutdown. - _main_object->set_pyobj(NULL); + _main_object->set_pyobj(nullptr); _main_object->set_string_property("status", "stopped"); string message = "onpythonstop"; string expression = _fparams.lookup_token(message); nout << "notify: " << message << " " << expression << "\n"; - if (!expression.empty() && _dom_object != NULL) { + if (!expression.empty() && _dom_object != nullptr) { P3D_object *result = P3D_OBJECT_EVAL(_dom_object, expression.c_str()); P3D_OBJECT_XDECREF(result); } @@ -730,13 +730,13 @@ get_request() { const char *host_url = request->_request._forget_package._host_url; const char *package_name = request->_request._forget_package._package_name; const char *package_version = request->_request._forget_package._package_version; - if (package_version == NULL) { + if (package_version == nullptr) { package_version = ""; } P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DHost *host = inst_mgr->get_host(host_url); - if (package_name != NULL) { + if (package_name != nullptr) { P3DPackage *package = host->get_package(package_name, package_version, _session_platform, ""); host->forget_package(package); } else { @@ -769,7 +769,7 @@ void P3DInstance:: bake_requests() { while (true) { // Get the latest request from the read thread. - TiXmlDocument *doc = NULL; + TiXmlDocument *doc = nullptr; ACQUIRE_LOCK(_request_lock); if (!_raw_requests.empty()) { doc = _raw_requests.front(); @@ -777,18 +777,18 @@ bake_requests() { } RELEASE_LOCK(_request_lock); - if (doc == NULL) { + if (doc == nullptr) { // No more requests to process right now. return; } // Now we've got a request in XML form; convert it to P3D_request form. TiXmlElement *xrequest = doc->FirstChildElement("request"); - assert(xrequest != (TiXmlElement *)NULL); + assert(xrequest != nullptr); P3D_request *request = make_p3d_request(xrequest); delete doc; - if (request != NULL) { + if (request != nullptr) { _baked_requests.push_back(request); } } @@ -812,7 +812,7 @@ add_raw_request(TiXmlDocument *doc) { // Tell the world we've got a new request. P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); inst_mgr->signal_request_ready(this); - if (_session != NULL) { + if (_session != nullptr) { _session->signal_request_ready(this); } } @@ -824,7 +824,7 @@ add_raw_request(TiXmlDocument *doc) { */ void P3DInstance:: add_baked_request(P3D_request *request) { - assert(request->_instance == NULL); + assert(request->_instance == nullptr); request->_instance = this; ref(); @@ -843,14 +843,14 @@ add_baked_request(P3D_request *request) { */ void P3DInstance:: finish_request(P3D_request *request, bool handled) { - assert(request != NULL); - if (request->_instance == NULL) { + assert(request != nullptr); + if (request->_instance == nullptr) { nout << "Ignoring empty request " << request << "\n"; return; } P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); - if (inst_mgr->validate_instance(request->_instance) == NULL) { + if (inst_mgr->validate_instance(request->_instance) == nullptr) { // nout << "Ignoring unknown request " << request << "\n"; return; } @@ -860,31 +860,31 @@ finish_request(P3D_request *request, bool handled) { break; case P3D_RT_get_url: - if (request->_request._get_url._url != NULL) { + if (request->_request._get_url._url != nullptr) { free((char *)request->_request._get_url._url); - request->_request._get_url._url = NULL; + request->_request._get_url._url = nullptr; } break; case P3D_RT_notify: - if (request->_request._notify._message != NULL) { + if (request->_request._notify._message != nullptr) { free((char *)request->_request._notify._message); - request->_request._notify._message = NULL; + request->_request._notify._message = nullptr; } break; case P3D_RT_forget_package: - if (request->_request._forget_package._host_url != NULL) { + if (request->_request._forget_package._host_url != nullptr) { free((char *)request->_request._forget_package._host_url); - request->_request._forget_package._host_url = NULL; + request->_request._forget_package._host_url = nullptr; } - if (request->_request._forget_package._package_name != NULL) { + if (request->_request._forget_package._package_name != nullptr) { free((char *)request->_request._forget_package._package_name); - request->_request._forget_package._package_name = NULL; + request->_request._forget_package._package_name = nullptr; } - if (request->_request._forget_package._package_version != NULL) { + if (request->_request._forget_package._package_version != nullptr) { free((char *)request->_request._forget_package._package_version); - request->_request._forget_package._package_version = NULL; + request->_request._forget_package._package_version = nullptr; } break; @@ -893,7 +893,7 @@ finish_request(P3D_request *request, bool handled) { } p3d_unref_delete(((P3DInstance *)request->_instance)); - request->_instance = NULL; + request->_instance = nullptr; delete request; } @@ -925,7 +925,7 @@ feed_url_stream(int unique_id, if (!download_ok || download->get_download_finished()) { // All done. if (download->get_instance() == this) { - download->set_instance(NULL); + download->set_instance(nullptr); } _downloads.erase(di); p3d_unref_delete(download); @@ -941,7 +941,7 @@ feed_url_stream(int unique_id, bool P3DInstance:: handle_event(const P3D_event_data &event) { bool retval = false; - if (_splash_window != NULL) { + if (_splash_window != nullptr) { if (_splash_window->handle_event(event)) { retval = true; } @@ -970,7 +970,7 @@ handle_event(const P3D_event_data &event) { */ const string &P3DInstance:: get_log_pathname() const { - if (_session != NULL) { + if (_session != nullptr) { return _session->_log_pathname; } return _log_pathname; @@ -1053,16 +1053,16 @@ remove_package(P3DPackage *package) { _downloading_packages.erase(pi); } if (package == _image_package) { - _image_package = NULL; + _image_package = nullptr; } if (package == _certlist_package) { - _certlist_package = NULL; + _certlist_package = nullptr; } if (package == _p3dcert_package) { - _p3dcert_package = NULL; + _p3dcert_package = nullptr; } if (package == _panda3d_package) { - _panda3d_package = NULL; + _panda3d_package = nullptr; } set_failed(); @@ -1170,7 +1170,7 @@ start_download(P3DDownload *download, bool add_request) { // is true in order to ask the plugin for the stream. if (add_request) { P3D_request *request = new P3D_request; - request->_instance = NULL; + request->_instance = nullptr; request->_request_type = P3D_RT_get_url; request->_request._get_url._url = strdup(download->get_url().c_str()); request->_request._get_url._unique_id = download_id; @@ -1227,7 +1227,7 @@ request_stop_main_thread() { if (add_request) { _requested_stop = true; P3D_request *request = new P3D_request; - request->_instance = NULL; + request->_instance = nullptr; request->_request_type = P3D_RT_stop; add_baked_request(request); } @@ -1240,7 +1240,7 @@ request_stop_main_thread() { void P3DInstance:: request_refresh() { P3D_request *request = new P3D_request; - request->_instance = NULL; + request->_instance = nullptr; request->_request_type = P3D_RT_refresh; add_baked_request(request); } @@ -1251,7 +1251,7 @@ request_refresh() { void P3DInstance:: request_callback(P3D_callback_func *func, void *data) { P3D_request *request = new P3D_request; - request->_instance = NULL; + request->_instance = nullptr; request->_request_type = P3D_RT_callback; request->_request._callback._func = func; request->_request._callback._data = data; @@ -1335,7 +1335,7 @@ splash_button_clicked_main_thread() { if (!_p3d_trusted) { auth_button_clicked(); - } else if (_session == NULL) { + } else if (_session == nullptr) { play_button_clicked(); } else { nout << "Ignoring click for already-started instance\n"; @@ -1349,10 +1349,10 @@ splash_button_clicked_main_thread() { void P3DInstance:: auth_button_clicked() { // Delete the previous session and create a new one. - if (_auth_session != NULL) { + if (_auth_session != nullptr) { _auth_session->shutdown(false); p3d_unref_delete(_auth_session); - _auth_session = NULL; + _auth_session = nullptr; } P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); @@ -1366,7 +1366,7 @@ auth_button_clicked() { */ void P3DInstance:: play_button_clicked() { - if (_session == NULL && _p3d_trusted) { + if (_session == nullptr && _p3d_trusted) { set_button_image(IT_none); if (!_download_started) { // Now we initiate the download. @@ -1754,12 +1754,12 @@ check_p3d_signature() { } // Check the list of pre-approved certificates. - if (_certlist_package == NULL) { + if (_certlist_package == nullptr) { // We have to go download this package. P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DHost *host = inst_mgr->get_host(inst_mgr->get_host_url()); _certlist_package = host->get_package("certlist", "", "", ""); - if (_certlist_package != NULL) { + if (_certlist_package != nullptr) { _certlist_package->add_instance(this); } @@ -1791,12 +1791,12 @@ mark_p3d_untrusted() { return; } - if (_p3dcert_package == NULL) { + if (_p3dcert_package == nullptr) { // We have to go download this package. P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DHost *host = inst_mgr->get_host(inst_mgr->get_host_url()); _p3dcert_package = host->get_package("p3dcert", "", "", ""); - if (_p3dcert_package != NULL) { + if (_p3dcert_package != nullptr) { _p3dcert_package->add_instance(this); } @@ -1883,14 +1883,14 @@ scan_app_desc_file(TiXmlDocument *doc) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); TiXmlElement *xpackage = doc->FirstChildElement("package"); - if (xpackage == NULL) { + if (xpackage == nullptr) { return; } - assert(_xpackage == NULL); + assert(_xpackage == nullptr); _xpackage = (TiXmlElement *)xpackage->Clone(); TiXmlElement *xconfig = _xpackage->FirstChildElement("config"); - if (xconfig != NULL) { + if (xconfig != nullptr) { int hidden = 0; if (xconfig->QueryIntAttribute("hidden", &hidden) == TIXML_SUCCESS) { if (hidden != 0) { @@ -1899,27 +1899,27 @@ scan_app_desc_file(TiXmlDocument *doc) { } const char *log_basename = xconfig->Attribute("log_basename"); - if (log_basename != NULL) { + if (log_basename != nullptr) { _log_basename = log_basename; } const char *prc_name = xconfig->Attribute("prc_name"); - if (prc_name != NULL) { + if (prc_name != nullptr) { _prc_name = prc_name; } const char *start_dir = xconfig->Attribute("start_dir"); - if (start_dir != NULL) { + if (start_dir != nullptr) { _start_dir = start_dir; } const char *run_origin = xconfig->Attribute("run_origin"); - if (run_origin != NULL) { + if (run_origin != nullptr) { _matches_run_origin = check_matches_origin(run_origin); } const char *script_origin = xconfig->Attribute("script_origin"); - if (script_origin != NULL) { + if (script_origin != nullptr) { _matches_script_origin = check_matches_origin(script_origin); } @@ -1987,24 +1987,24 @@ scan_app_desc_file(TiXmlDocument *doc) { void P3DInstance:: add_panda3d_package() { assert(!_packages_specified); - assert(_panda3d_package == NULL); - if (_xpackage == NULL) { + assert(_panda3d_package == nullptr); + if (_xpackage == nullptr) { return; } P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); TiXmlElement *xrequires = _xpackage->FirstChildElement("requires"); - while (xrequires != NULL) { + while (xrequires != nullptr) { const char *name = xrequires->Attribute("name"); const char *host_url = xrequires->Attribute("host"); - if (name != NULL && host_url != NULL && strcmp(name, "panda3d") == 0) { + if (name != nullptr && host_url != nullptr && strcmp(name, "panda3d") == 0) { const char *version = xrequires->Attribute("version"); - if (version == NULL) { + if (version == nullptr) { version = ""; } const char *seq = xrequires->Attribute("seq"); - if (seq == NULL) { + if (seq == nullptr) { seq = ""; } P3DHost *host = inst_mgr->get_host(host_url); @@ -2026,23 +2026,23 @@ add_panda3d_package() { void P3DInstance:: add_packages() { assert(!_packages_specified); - if (_xpackage == NULL) { + if (_xpackage == nullptr) { return; } P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); TiXmlElement *xrequires = _xpackage->FirstChildElement("requires"); - while (xrequires != NULL) { + while (xrequires != nullptr) { const char *name = xrequires->Attribute("name"); const char *host_url = xrequires->Attribute("host"); - if (name != NULL && host_url != NULL) { + if (name != nullptr && host_url != nullptr) { const char *version = xrequires->Attribute("version"); - if (version == NULL) { + if (version == nullptr) { version = ""; } const char *seq = xrequires->Attribute("seq"); - if (seq == NULL) { + if (seq == nullptr) { seq = ""; } P3DHost *host = inst_mgr->get_host(host_url); @@ -2074,17 +2074,17 @@ add_packages() { string P3DInstance:: find_alt_host_url(const string &host_url, const string &alt_host) { TiXmlElement *xhost = _xpackage->FirstChildElement("host"); - while (xhost != NULL) { + while (xhost != nullptr) { const char *url = xhost->Attribute("url"); - if (url != NULL && host_url == url) { + if (url != nullptr && host_url == url) { // This matches the host. Now do we have a matching alt_host keyword // for this host? TiXmlElement *xalt_host = xhost->FirstChildElement("alt_host"); - while (xalt_host != NULL) { + while (xalt_host != nullptr) { const char *keyword = xalt_host->Attribute("keyword"); - if (keyword != NULL && alt_host == keyword) { + if (keyword != nullptr && alt_host == keyword) { const char *alt_host_url = xalt_host->Attribute("url"); - if (alt_host_url != NULL) { + if (alt_host_url != nullptr) { return alt_host_url; } } @@ -2110,9 +2110,9 @@ get_host_info(P3DHost *host) { assert(!host->has_contents_file()); TiXmlElement *xhost = _xpackage->FirstChildElement("host"); - while (xhost != NULL) { + while (xhost != nullptr) { const char *url = xhost->Attribute("url"); - if (url != NULL && host->get_host_url() == url) { + if (url != nullptr && host->get_host_url() == url) { // Found the entry for this particular host. host->read_xhost(xhost); return; @@ -2168,7 +2168,7 @@ send_browser_script_object() { TiXmlElement *xcommand = new TiXmlElement("command"); xcommand->SetAttribute("cmd", "pyobj"); xcommand->SetAttribute("op", "set_browser_script_object"); - if (_dom_object != NULL) { + if (_dom_object != nullptr) { xcommand->LinkEndChild(_session->p3dobj_to_xml(_dom_object)); } @@ -2184,16 +2184,16 @@ send_browser_script_object() { P3D_request *P3DInstance:: make_p3d_request(TiXmlElement *xrequest) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); - P3D_request *request = NULL; + P3D_request *request = nullptr; const char *rtype = xrequest->Attribute("rtype"); - if (rtype != NULL) { + if (rtype != nullptr) { if (strcmp(rtype, "notify") == 0) { const char *message = xrequest->Attribute("message"); - if (message != NULL) { + if (message != nullptr) { // A notify message from Python code. request = new P3D_request; - request->_instance = NULL; + request->_instance = nullptr; request->_request_type = P3D_RT_notify; request->_request._notify._message = strdup(message); handle_notify_request(message); @@ -2210,19 +2210,19 @@ make_p3d_request(TiXmlElement *xrequest) { int unique_id = 0; xrequest->Attribute("unique_id", &unique_id); - P3D_object *value = NULL; + P3D_object *value = nullptr; TiXmlElement *xvalue = xrequest->FirstChildElement("value"); - if (xvalue != NULL) { + if (xvalue != nullptr) { value = _session->xml_to_p3dobj(xvalue); } - if (value == NULL) { + if (value == nullptr) { value = inst_mgr->new_none_object(); } - if (operation != NULL && xobject != NULL) { + if (operation != nullptr && xobject != nullptr) { P3D_object *object = _session->xml_to_p3dobj(xobject); - if (property_name == NULL) { + if (property_name == nullptr) { property_name = ""; } @@ -2242,25 +2242,25 @@ make_p3d_request(TiXmlElement *xrequest) { } else if (strcmp(rtype, "stop") == 0) { // A stop request from Python code. This is kind of weird, but OK. request = new P3D_request; - request->_instance = NULL; + request->_instance = nullptr; request->_request_type = P3D_RT_stop; } else if (strcmp(rtype, "forget_package") == 0) { const char *host_url = xrequest->Attribute("host_url"); - if (host_url != NULL) { + if (host_url != nullptr) { // A Python-level request to remove a package from the cache. request = new P3D_request; - request->_instance = NULL; + request->_instance = nullptr; request->_request_type = P3D_RT_forget_package; request->_request._forget_package._host_url = strdup(host_url); - request->_request._forget_package._package_name = NULL; - request->_request._forget_package._package_version = NULL; + request->_request._forget_package._package_name = nullptr; + request->_request._forget_package._package_version = nullptr; const char *package_name = xrequest->Attribute("package_name"); const char *package_version = xrequest->Attribute("package_version"); - if (package_name != NULL) { + if (package_name != nullptr) { request->_request._forget_package._package_name = strdup(package_name); - if (package_version != NULL) { + if (package_version != nullptr) { request->_request._forget_package._package_version = strdup(package_version); } } @@ -2271,8 +2271,8 @@ make_p3d_request(TiXmlElement *xrequest) { } } - if (request != NULL) { - assert(request->_instance == NULL); + if (request != nullptr) { + assert(request->_instance == nullptr); request->_instance = this; ref(); } @@ -2298,19 +2298,19 @@ handle_notify_request(const string &message) { doc->LinkEndChild(xcommand); TiXmlDocument *response = _session->command_and_response(doc); - P3D_object *result = NULL; - if (response != NULL) { + P3D_object *result = nullptr; + if (response != nullptr) { TiXmlElement *xresponse = response->FirstChildElement("response"); - if (xresponse != NULL) { + if (xresponse != nullptr) { TiXmlElement *xvalue = xresponse->FirstChildElement("value"); - if (xvalue != NULL) { + if (xvalue != nullptr) { result = _session->xml_to_p3dobj(xvalue); } } delete response; } - if (result != NULL) { + if (result != nullptr) { if (_matches_script_origin) { // We only actually merge the objects if this web page is allowed to // call our scripting functions. @@ -2329,7 +2329,7 @@ handle_notify_request(const string &message) { // The process told us that it just successfully opened its window, for // the first time. Hide the splash window. _instance_window_opened = true; - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_visible(false); } @@ -2352,7 +2352,7 @@ handle_notify_request(const string &message) { // window opening and the first frame being drawn. _instance_window_attached = true; #ifndef __APPLE__ - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_visible(false); } #endif // __APPLE__ @@ -2360,12 +2360,12 @@ handle_notify_request(const string &message) { #ifdef __APPLE__ // Start a timer to update the frame repeatedly. This seems to be // steadier than waiting for nullEvent. - if (_frame_timer == NULL) { + if (_frame_timer == nullptr) { CFRunLoopTimerContext timer_context; memset(&timer_context, 0, sizeof(timer_context)); timer_context.info = this; _frame_timer = CFRunLoopTimerCreate - (NULL, 0, 1.0 / 60.0, 0, 0, timer_callback, &timer_context); + (nullptr, 0, 1.0 / 60.0, 0, 0, timer_callback, &timer_context); CFRunLoopRef run_loop = CFRunLoopGetCurrent(); CFRunLoopAddTimer(run_loop, _frame_timer, kCFRunLoopCommonModes); } @@ -2377,16 +2377,16 @@ handle_notify_request(const string &message) { _instance_window_opened = true; _instance_window_attached = false; set_background_image(IT_active); - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_visible(true); } #ifdef __APPLE__ // Stop the frame timer; we don't need it any more. - if (_frame_timer != NULL) { + if (_frame_timer != nullptr) { CFRunLoopTimerInvalidate(_frame_timer); CFRelease(_frame_timer); - _frame_timer = NULL; + _frame_timer = nullptr; } #endif // __APPLE__ @@ -2403,7 +2403,7 @@ handle_notify_request(const string &message) { auth_finished_main_thread(); } else if (message == "keyboardfocus") { - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->request_keyboard_focus(); } } @@ -2430,7 +2430,7 @@ handle_script_request(const string &operation, P3D_object *object, // We've got the property value; feed it back down to the subprocess. - if (result != NULL) { + if (result != nullptr) { xcommand->LinkEndChild(_session->p3dobj_to_xml(result)); P3D_OBJECT_DECREF(result); } @@ -2445,7 +2445,7 @@ handle_script_request(const string &operation, P3D_object *object, xcommand->LinkEndChild(xvalue); } else if (operation == "del_property") { - bool result = P3D_OBJECT_SET_PROPERTY(object, property_name.c_str(), true, NULL); + bool result = P3D_OBJECT_SET_PROPERTY(object, property_name.c_str(), true, nullptr); TiXmlElement *xvalue = new TiXmlElement("value"); xvalue->SetAttribute("type", "bool"); @@ -2476,20 +2476,20 @@ handle_script_request(const string &operation, P3D_object *object, P3D_OBJECT_CALL(object, property_name.c_str(), needs_response, values, num_values); - if (result != NULL) { + if (result != nullptr) { xcommand->LinkEndChild(_session->p3dobj_to_xml(result)); P3D_OBJECT_DECREF(result); } } else if (operation == "eval") { P3D_object *result; - int size = P3D_OBJECT_GET_STRING(value, NULL, 0); + int size = P3D_OBJECT_GET_STRING(value, nullptr, 0); char *buffer = new char[size + 1]; P3D_OBJECT_GET_STRING(value, buffer, size + 1); result = P3D_OBJECT_EVAL(object, buffer); delete[] buffer; - if (result != NULL) { + if (result != nullptr) { xcommand->LinkEndChild(_session->p3dobj_to_xml(result)); P3D_OBJECT_DECREF(result); } @@ -2544,7 +2544,7 @@ make_splash_window() { make_visible = true; } - if (_splash_window != NULL) { + if (_splash_window != nullptr) { // Already got one. _splash_window->set_visible(make_visible); return; @@ -2704,7 +2704,7 @@ make_splash_window() { _image_files[i]._filename.clear(); // Make a temporary file to receive the splash image. - assert(_image_files[i]._temp_filename == NULL); + assert(_image_files[i]._temp_filename == nullptr); _image_files[i]._temp_filename = new P3DTemporaryFile(".jpg"); // Start downloading the requested image. @@ -2753,7 +2753,7 @@ set_background_image(ImageType image_type) { } // Update the splash window. - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_image_filename(_image_files[_current_background_image]._filename, P3DSplashWindow::IP_background); } } @@ -2790,7 +2790,7 @@ set_button_image(ImageType image_type) { } // Update the splash window. - if (_splash_window != NULL) { + if (_splash_window != nullptr) { if (_current_button_image != IT_none) { _splash_window->set_image_filename(_image_files[_current_button_image]._filename, P3DSplashWindow::IP_button_ready); _splash_window->set_image_filename(_image_files[_current_button_image + 1]._filename, P3DSplashWindow::IP_button_rollover); @@ -2804,7 +2804,7 @@ set_button_image(ImageType image_type) { } else { // We're not changing the button graphic, but we might be re-activating // it. - if (_splash_window != NULL) { + if (_splash_window != nullptr) { if (_current_button_image != IT_none) { _splash_window->set_button_active(true); } else { @@ -2829,7 +2829,7 @@ report_package_info_ready(P3DPackage *package) { // If we're downloading one of the two cert packages, though, put up a // progress bar. make_splash_window(); - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_install_progress(0.0, true, 0); } if (package == _certlist_package) { @@ -2926,7 +2926,7 @@ ready_to_install() { #ifdef _WIN32 _start_dl_tick = GetTickCount(); #else - gettimeofday(&_start_dl_timeval, NULL); + gettimeofday(&_start_dl_timeval, nullptr); #endif nout << "Beginning install of " << _downloading_packages.size() @@ -2956,7 +2956,7 @@ ready_to_install() { _main_object->set_float_property("downloadProgress", progress); } - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_install_progress(progress, true, 0); } @@ -3030,7 +3030,7 @@ mark_download_complete() { } // Take down the download progress bar. - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_install_progress(0.0, true, 0); } set_install_label(""); @@ -3090,7 +3090,7 @@ report_instance_progress(double progress, bool is_progress_known, double elapsed = (double)(now - _start_dl_tick) * 0.001; #else struct timeval now; - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); double elapsed = (double)(now.tv_sec - _start_dl_timeval.tv_sec) + (double)(now.tv_usec - _start_dl_timeval.tv_usec) / 1000000.0; #endif @@ -3108,7 +3108,7 @@ report_instance_progress(double progress, bool is_progress_known, } } - if (_splash_window != NULL && _show_dl_instance_progress) { + if (_splash_window != nullptr && _show_dl_instance_progress) { _splash_window->set_install_progress(progress, is_progress_known, received_data); } _main_object->set_float_property("instanceDownloadProgress", progress); @@ -3125,7 +3125,7 @@ report_package_progress(P3DPackage *package, double progress) { } if (package == _certlist_package || package == _p3dcert_package) { // This gets its own progress bar. - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_install_progress(progress, true, 0); } return; @@ -3141,7 +3141,7 @@ report_package_progress(P3DPackage *package, double progress) { progress = (progress * package->get_download_size() + _total_downloaded + _prev_downloaded) / (_total_download_size + _prev_downloaded); progress = min(progress, 1.0); - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_install_progress(progress, true, 0); } _main_object->set_float_property("downloadProgress", progress); @@ -3155,7 +3155,7 @@ report_package_progress(P3DPackage *package, double progress) { double elapsed = (double)(now - _start_dl_tick) * 0.001; #else struct timeval now; - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); double elapsed = (double)(now.tv_sec - _start_dl_timeval.tv_sec) + (double)(now.tv_usec - _start_dl_timeval.tv_usec) / 1000000.0; #endif @@ -3213,7 +3213,7 @@ report_package_done(P3DPackage *package, bool success) { // files out of it and point them to the splash window. string package_dir = package->get_package_dir(); const TiXmlElement *xconfig = package->get_xconfig(); - if (xconfig == NULL) { + if (xconfig == nullptr) { nout << "No entry in image package\n"; return; } @@ -3225,7 +3225,7 @@ report_package_done(P3DPackage *package, bool success) { // filename. string token = string(_image_type_names[i]) + "_img"; const string *basename = xconfig->Attribute(token); - if (basename == NULL) { + if (basename == nullptr) { nout << "No entry in image package for " << token << "\n"; } else { string image_filename = package_dir + "/" + *basename; @@ -3233,7 +3233,7 @@ report_package_done(P3DPackage *package, bool success) { // If the image should be on the window now, and the window still // exists, put it up. - if (_splash_window != NULL && + if (_splash_window != nullptr && _image_files[i]._image_placement != P3DSplashWindow::IP_none) { P3DSplashWindow::ImagePlacement image_placement = _image_files[i]._image_placement; _splash_window->set_image_filename(image_filename, image_placement); @@ -3252,7 +3252,7 @@ report_package_done(P3DPackage *package, bool success) { package->mark_used(); // Take down the download progress. - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_install_progress(0.0, true, 0); } set_install_label(""); @@ -3270,7 +3270,7 @@ report_package_done(P3DPackage *package, bool success) { package->mark_used(); // Take down the download progress. - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_install_progress(0.0, true, 0); } set_install_label(""); @@ -3294,7 +3294,7 @@ report_package_done(P3DPackage *package, bool success) { void P3DInstance:: set_install_label(const string &install_label) { _install_label = install_label; - if (_splash_window != NULL) { + if (_splash_window != nullptr) { _splash_window->set_install_label(_install_label); } } @@ -3330,7 +3330,7 @@ paint_window() { */ bool P3DInstance:: get_framebuffer_osx_port() { - if (_swbuffer == NULL || !_instance_window_attached) { + if (_swbuffer == nullptr || !_instance_window_attached) { // We don't have a Panda3D window yet. return false; } @@ -3382,7 +3382,7 @@ get_framebuffer_osx_port() { _swbuffer->close_read_framebuffer(); - if (_splash_window != NULL && _splash_window->get_visible()) { + if (_splash_window != nullptr && _splash_window->get_visible()) { // If the splash window is up, time to hide it. We've just rendered a // real frame. _splash_window->set_visible(false); @@ -3404,7 +3404,7 @@ get_framebuffer_osx_port() { */ bool P3DInstance:: get_framebuffer_osx_cgcontext() { - if (_swbuffer == NULL || !_instance_window_attached) { + if (_swbuffer == nullptr || !_instance_window_attached) { // We don't have a Panda3D window yet. return false; } @@ -3420,7 +3420,7 @@ get_framebuffer_osx_cgcontext() { memcpy(_reversed_buffer, framebuffer, y_size * rowsize); _swbuffer->close_read_framebuffer(); - if (_splash_window != NULL && _splash_window->get_visible()) { + if (_splash_window != nullptr && _splash_window->get_visible()) { // If the splash window is up, time to hide it. We've just rendered a // real frame. _splash_window->set_visible(false); @@ -3466,7 +3466,7 @@ paint_window_osx_port() { const P3D_window_handle &handle = _wparams.get_parent_window(); assert(handle._window_handle_type == P3D_WHT_osx_port); GrafPtr out_port = handle._handle._osx_port._port; - GrafPtr port_save = NULL; + GrafPtr port_save = nullptr; Boolean port_changed = QDSwapPort(out_port, &port_save); // Make sure the clipping rectangle isn't in the way. Is there a better way @@ -3479,7 +3479,7 @@ paint_window_osx_port() { &src_rect, &ddrc_rect, srcCopy, 0); if (port_changed) { - QDSwapPort(port_save, NULL); + QDSwapPort(port_save, nullptr); } DisposeGWorld(pGWorld); @@ -3501,7 +3501,7 @@ paint_window_osx_cgcontext(CGContextRef context) { int x_size = min(_wparams.get_win_width(), _swbuffer->get_x_size()); int y_size = min(_wparams.get_win_height(), _swbuffer->get_y_size()); - if (_buffer_image != NULL) { + if (_buffer_image != nullptr) { CGRect region = { { 0, 0 }, { (CGFloat)x_size, (CGFloat)y_size } }; CGContextDrawImage(context, region, _buffer_image); } @@ -3526,20 +3526,20 @@ handle_event_osx_event_record(const P3D_event_data &event) { const P3D_window_handle &handle = _wparams.get_parent_window(); if (handle._window_handle_type == P3D_WHT_osx_port) { GrafPtr out_port = handle._handle._osx_port._port; - GrafPtr port_save = NULL; + GrafPtr port_save = nullptr; Boolean port_changed = QDSwapPort(out_port, &port_save); GlobalToLocal(&pt); if (port_changed) { - QDSwapPort(port_save, NULL); + QDSwapPort(port_save, nullptr); } } else { // First, convert the coordinates from screen coordinates to browser // window coordinates. WindowRef window = handle._handle._osx_cgcontext._window; CGPoint cgpt = { (CGFloat)pt.h, (CGFloat)pt.v }; - HIPointConvert(&cgpt, kHICoordSpaceScreenPixel, NULL, + HIPointConvert(&cgpt, kHICoordSpaceScreenPixel, nullptr, kHICoordSpaceWindow, window); // Then convert to plugin coordinates. @@ -3572,7 +3572,7 @@ handle_event_osx_event_record(const P3D_event_data &event) { case keyDown: case keyUp: case autoKey: - if (_swbuffer != NULL) { + if (_swbuffer != nullptr) { swb_event._source = SubprocessWindowBuffer::ES_keyboard; swb_event._code = er->message; if (er->what == keyUp) { @@ -3614,7 +3614,7 @@ handle_event_osx_event_record(const P3D_event_data &event) { } } - if (_swbuffer != NULL) { + if (_swbuffer != nullptr) { _swbuffer->add_event(swb_event); } #endif // __APPLE__ @@ -3709,7 +3709,7 @@ handle_event_osx_cocoa(const P3D_event_data &event) { swb_event._flags |= SubprocessWindowBuffer::EF_has_mouse; } - if (_swbuffer != NULL) { + if (_swbuffer != nullptr) { _swbuffer->add_event(swb_event); } #endif // __APPLE__ @@ -3773,7 +3773,7 @@ void P3DInstance:: send_notify(const string &message) { nout << "send_notify(" << message << ")\n"; P3D_request *request = new P3D_request; - request->_instance = NULL; + request->_instance = nullptr; request->_request_type = P3D_RT_notify; request->_request._notify._message = strdup(message.c_str()); add_baked_request(request); @@ -3793,12 +3793,12 @@ alloc_swbuffer() { _swbuffer = SubprocessWindowBuffer::new_buffer (_shared_fd, _shared_mmap_size, _shared_filename, x_size, y_size); - if (_swbuffer != NULL) { + if (_swbuffer != nullptr) { _reversed_buffer = new char[_swbuffer->get_framebuffer_size()]; memset(_reversed_buffer, 0, _swbuffer->get_row_size()); size_t rowsize = _swbuffer->get_row_size(); - _buffer_data = CFDataCreateWithBytesNoCopy(NULL, (const UInt8 *)_reversed_buffer, + _buffer_data = CFDataCreateWithBytesNoCopy(nullptr, (const UInt8 *)_reversed_buffer, y_size * rowsize, kCFAllocatorNull); _data_provider = CGDataProviderCreateWithCFData(_buffer_data); @@ -3806,7 +3806,7 @@ alloc_swbuffer() { _buffer_image = CGImageCreate(x_size, y_size, 8, 32, rowsize, _buffer_color_space, kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, - _data_provider, NULL, false, kCGRenderingIntentDefault); + _data_provider, nullptr, false, kCGRenderingIntentDefault); } } @@ -3819,26 +3819,26 @@ alloc_swbuffer() { */ void P3DInstance:: free_swbuffer() { - if (_swbuffer != NULL) { + if (_swbuffer != nullptr) { SubprocessWindowBuffer::destroy_buffer(_shared_fd, _shared_mmap_size, _shared_filename, _swbuffer); - _swbuffer = NULL; + _swbuffer = nullptr; } - if (_reversed_buffer != NULL) { + if (_reversed_buffer != nullptr) { delete[] _reversed_buffer; - _reversed_buffer = NULL; + _reversed_buffer = nullptr; } - if (_buffer_image != NULL) { + if (_buffer_image != nullptr) { CGImageRelease(_buffer_image); CGColorSpaceRelease(_buffer_color_space); CGDataProviderRelease(_data_provider); CFRelease(_buffer_data); - _buffer_data = NULL; - _data_provider = NULL; - _buffer_color_space = NULL; - _buffer_image = NULL; + _buffer_data = nullptr; + _data_provider = nullptr; + _buffer_color_space = nullptr; + _buffer_image = nullptr; } } #endif // __APPLE__ @@ -3881,7 +3881,7 @@ download_finished(bool success) { // Put it onscreen if it's supposed to be onscreen now, and our splash // window still exists. - if (_inst->_splash_window != NULL && + if (_inst->_splash_window != nullptr && _inst->_image_files[_index]._image_placement != P3DSplashWindow::IP_none) { P3DSplashWindow::ImagePlacement image_placement = _inst->_image_files[_index]._image_placement; _inst->_splash_window->set_image_filename(get_filename(), image_placement); diff --git a/direct/src/plugin/p3dInstanceManager.cxx b/direct/src/plugin/p3dInstanceManager.cxx index 46a194e289..3b8c52ba15 100644 --- a/direct/src/plugin/p3dInstanceManager.cxx +++ b/direct/src/plugin/p3dInstanceManager.cxx @@ -86,11 +86,11 @@ P3DInstanceManager() { _true_object = new P3DBoolObject(true); _false_object = new P3DBoolObject(false); - _auth_session = NULL; + _auth_session = nullptr; // Seed the lame random number generator in rand(); we use it to select a // mirror for downloading. - srand((unsigned int)time(NULL)); + srand((unsigned int)time(nullptr)); #ifdef _WIN32 // Ensure the appropriate Windows common controls are available to this @@ -127,7 +127,7 @@ P3DInstanceManager:: #ifndef _WIN32 // Restore the original SIGPIPE handler. - sigaction(SIGPIPE, &_old_sigpipe, NULL); + sigaction(SIGPIPE, &_old_sigpipe, nullptr); #endif // _WIN32 // force-finish any remaining instances. @@ -139,9 +139,9 @@ P3DInstanceManager:: assert(_sessions.empty()); assert(_instances.empty()); - if (_auth_session != NULL) { + if (_auth_session != nullptr) { p3d_unref_delete(_auth_session); - _auth_session = NULL; + _auth_session = nullptr; } Hosts::iterator hi; @@ -239,7 +239,7 @@ initialize(int api_version, const string &contents_filename, int mib[2] = { CTL_HW, HW_MACHINE }; char machine[512]; size_t len = 511; - if (sysctl(mib, 2, (void *)machine, &len, NULL, 0) == 0) { + if (sysctl(mib, 2, (void *)machine, &len, nullptr, 0) == 0) { if (strcmp(machine, "x86_64") == 0) { _supported_platforms.push_back("osx_amd64"); } @@ -400,7 +400,7 @@ set_plugin_version(int major, int minor, int sequence, nout << "Core API version: " << _coreapi_set_ver << "\n"; const char *timestamp_string = ctime(&_coreapi_timestamp); - if (timestamp_string == NULL) { + if (timestamp_string == nullptr) { timestamp_string = ""; } nout << "Core API date: " << timestamp_string << "\n"; @@ -541,12 +541,12 @@ finish_instance(P3DInstance *inst) { */ P3DAuthSession *P3DInstanceManager:: authorize_instance(P3DInstance *inst) { - if (_auth_session != NULL) { + if (_auth_session != nullptr) { // We only want one auth_session window open at a time, to minimize user // confusion, so close any previous window. _auth_session->shutdown(true); p3d_unref_delete(_auth_session); - _auth_session = NULL; + _auth_session = nullptr; } _auth_session = new P3DAuthSession(inst); @@ -566,7 +566,7 @@ validate_instance(P3D_instance *instance) { return (*ii); } - return NULL; + return nullptr; } /** @@ -583,7 +583,7 @@ check_request() { } } - return NULL; + return nullptr; } /** @@ -600,7 +600,7 @@ wait_request(double timeout) { int stop_tick = int(GetTickCount() + timeout * 1000.0); #else struct timeval stop_time; - gettimeofday(&stop_time, NULL); + gettimeofday(&stop_time, nullptr); int seconds = (int)floor(timeout); stop_time.tv_sec += seconds; @@ -612,7 +612,7 @@ wait_request(double timeout) { #endif _request_ready.acquire(); - if (check_request() != (P3DInstance *)NULL) { + if (check_request() != nullptr) { _request_ready.release(); return; } @@ -633,7 +633,7 @@ wait_request(double timeout) { timeout = remaining_ticks * 0.001; #else struct timeval now; - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); struct timeval remaining; remaining.tv_sec = stop_time.tv_sec - now.tv_sec; @@ -649,7 +649,7 @@ wait_request(double timeout) { timeout = remaining.tv_sec + remaining.tv_usec * 0.001; #endif - if (check_request() != (P3DInstance *)NULL) { + if (check_request() != nullptr) { _request_ready.release(); return; } @@ -713,7 +713,7 @@ get_unique_id() { */ void P3DInstanceManager:: signal_request_ready(P3DInstance *inst) { - if (inst->get_request_ready_func() != NULL) { + if (inst->get_request_ready_func() != nullptr) { // This instance requires asynchronous notifications of requests. Thus, // we should tell the notify thread to wake up and make the callback. _notify_ready.acquire(); @@ -765,7 +765,7 @@ make_temp_filename(const string &extension) { if (tid == 0) { tid = 1; } - int hash = ((clock() + _next_temp_filename_counter) * ((time(NULL) * tid) >> 8)) & 0xffffff; + int hash = ((clock() + _next_temp_filename_counter) * ((time(nullptr) * tid) >> 8)) & 0xffffff; ++_next_temp_filename_counter; char hex_code[10]; sprintf(hex_code, "%06x", hash); @@ -847,8 +847,8 @@ find_cert(X509 *cert) { vector::iterator si; for (si = contents.begin(); si != contents.end(); ++si) { string filename = this_cert_dir + "/" + (*si); - X509 *x509 = NULL; - FILE *fp = NULL; + X509 *x509 = nullptr; + FILE *fp = nullptr; #ifdef _WIN32 wstring filename_w; if (string_to_wstring(filename_w, filename)) { @@ -857,12 +857,12 @@ find_cert(X509 *cert) { #else // _WIN32 fp = fopen(filename.c_str(), "r"); #endif // _WIN32 - if (fp != NULL) { - x509 = PEM_read_X509(fp, NULL, NULL, (void *)""); + if (fp != nullptr) { + x509 = PEM_read_X509(fp, nullptr, nullptr, (void *)""); fclose(fp); } - if (x509 != NULL) { + if (x509 != nullptr) { string der2 = cert_to_der(x509); // We might as well save this cert in the table for next time, even if // it's not the one we're looking for right now. @@ -896,8 +896,8 @@ read_certlist(P3DPackage *package) { string suffix = basename.substr(basename.length() - 4); if (suffix == ".pem" || suffix == ".crt") { string filename = package->get_package_dir() + "/" + basename; - X509 *x509 = NULL; - FILE *fp = NULL; + X509 *x509 = nullptr; + FILE *fp = nullptr; #ifdef _WIN32 wstring filename_w; if (string_to_wstring(filename_w, filename)) { @@ -906,12 +906,12 @@ read_certlist(P3DPackage *package) { #else // _WIN32 fp = fopen(filename.c_str(), "r"); #endif // _WIN32 - if (fp != NULL) { - x509 = PEM_read_X509(fp, NULL, NULL, (void *)""); + if (fp != nullptr) { + x509 = PEM_read_X509(fp, nullptr, nullptr, (void *)""); fclose(fp); } - if (x509 != NULL) { + if (x509 != nullptr) { string der2 = cert_to_der(x509); _approved_certs.insert(der2); } @@ -952,7 +952,7 @@ get_cert_dir(X509 *cert) { */ string P3DInstanceManager:: cert_to_der(X509 *cert) { - int buffer_size = i2d_X509(cert, NULL); + int buffer_size = i2d_X509(cert, nullptr); unsigned char *buffer = new unsigned char[buffer_size]; unsigned char *p = buffer; i2d_X509(cert, &p); @@ -1001,7 +1001,7 @@ uninstall_all() { */ P3DInstanceManager *P3DInstanceManager:: get_global_ptr() { - if (_global_ptr == NULL) { + if (_global_ptr == nullptr) { _global_ptr = new P3DInstanceManager; } return _global_ptr; @@ -1013,9 +1013,9 @@ get_global_ptr() { */ void P3DInstanceManager:: delete_global_ptr() { - if (_global_ptr != NULL) { + if (_global_ptr != nullptr) { delete _global_ptr; - _global_ptr = NULL; + _global_ptr = nullptr; } } @@ -1072,13 +1072,13 @@ scan_directory(const string &dirname, vector &contents) { size_t orig_size = contents.size(); DIR *root = opendir(dirname.c_str()); - if (root == (DIR *)NULL) { + if (root == nullptr) { return false; } struct dirent *d; d = readdir(root); - while (d != (struct dirent *)NULL) { + while (d != nullptr) { if (d->d_name[0] != '.') { contents.push_back(d->d_name); } @@ -1347,13 +1347,13 @@ create_runtime_environment() { // $TEMP or $TMP being defined specifically, and if they are, we'll use // GetTempPath(); otherwise, we'll fall back to SHGetSpecialFolderPath(). - if (getenv("TEMP") != NULL || getenv("TMP") != NULL) { + if (getenv("TEMP") != nullptr || getenv("TMP") != nullptr) { if (GetTempPathW(MAX_PATH, buffer_1) != 0) { temp_directory_w = buffer_1; } } if (temp_directory_w.empty()) { - if (SHGetSpecialFolderPathW(NULL, buffer_1, CSIDL_INTERNET_CACHE, true)) { + if (SHGetSpecialFolderPathW(nullptr, buffer_1, CSIDL_INTERNET_CACHE, true)) { temp_directory_w = buffer_1; // That just *might* return a non-writable folder, if we're in Protected @@ -1379,9 +1379,9 @@ create_runtime_environment() { } // Also insist that the temp directory is fully specified. - size_t needs_size_2 = GetFullPathNameW(temp_directory_w.c_str(), 0, NULL, NULL); + size_t needs_size_2 = GetFullPathNameW(temp_directory_w.c_str(), 0, nullptr, nullptr); wchar_t *buffer_2 = new wchar_t[needs_size_2]; - if (GetFullPathNameW(temp_directory_w.c_str(), needs_size_2, buffer_2, NULL) != 0) { + if (GetFullPathNameW(temp_directory_w.c_str(), needs_size_2, buffer_2, nullptr) != 0) { temp_directory_w = buffer_2; } delete[] buffer_2; @@ -1428,7 +1428,7 @@ create_runtime_environment() { struct sigaction ignore; memset(&ignore, 0, sizeof(ignore)); ignore.sa_handler = SIG_IGN; - sigaction(SIGINT, &ignore, NULL); + sigaction(SIGINT, &ignore, nullptr); } #endif @@ -1482,9 +1482,9 @@ nt_thread_run() { for (ni = instances.begin(); ni != instances.end(); ++ni) { // TODO: a race condition here when instances are deleted. P3DInstance *inst = (*ni); - assert(inst != NULL); + assert(inst != nullptr); P3D_request_ready_func *func = inst->get_request_ready_func(); - if (func != NULL) { + if (func != nullptr) { (*func)(inst); } } @@ -1505,7 +1505,7 @@ supports_win64() { LPFN_ISWOW64PROCESS _IsWow64Process; _IsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process"); - if (_IsWow64Process != NULL) { + if (_IsWow64Process != nullptr) { if (!_IsWow64Process(GetCurrentProcess(), &is_win64)) { is_win64 = false; } diff --git a/direct/src/plugin/p3dMainObject.cxx b/direct/src/plugin/p3dMainObject.cxx index c905c8805b..adda6129d6 100644 --- a/direct/src/plugin/p3dMainObject.cxx +++ b/direct/src/plugin/p3dMainObject.cxx @@ -23,8 +23,8 @@ */ P3DMainObject:: P3DMainObject() : - _pyobj(NULL), - _inst(NULL), + _pyobj(nullptr), + _inst(nullptr), _unauth_play(false) { } @@ -34,7 +34,7 @@ P3DMainObject() : */ P3DMainObject:: ~P3DMainObject() { - set_pyobj(NULL); + set_pyobj(nullptr); // Clear the local properties. Properties::const_iterator pi; @@ -83,10 +83,10 @@ get_float() { */ void P3DMainObject:: make_string(string &value) { - if (_pyobj == NULL) { + if (_pyobj == nullptr) { value = "P3DMainObject"; } else { - int size = P3D_OBJECT_GET_STRING(_pyobj, NULL, 0); + int size = P3D_OBJECT_GET_STRING(_pyobj, nullptr, 0); char *buffer = new char[size]; P3D_OBJECT_GET_STRING(_pyobj, buffer, size); value = string(buffer, size); @@ -100,7 +100,7 @@ make_string(string &value) { */ P3D_object *P3DMainObject:: get_property(const string &property) { - if (_pyobj == NULL) { + if (_pyobj == nullptr) { // Without a pyobj, we just report whatever's been stored locally. Properties::const_iterator pi; pi = _properties.find(property); @@ -109,7 +109,7 @@ get_property(const string &property) { P3D_OBJECT_INCREF(result); return result; } - return NULL; + return nullptr; } // With a pyobj, we pass the query down to it. @@ -123,9 +123,9 @@ get_property(const string &property) { bool P3DMainObject:: set_property(const string &property, bool needs_response, P3D_object *value) { // First, we set the property locally. - if (value != NULL) { + if (value != nullptr) { Properties::iterator pi; - pi = _properties.insert(Properties::value_type(property, (P3D_object *)NULL)).first; + pi = _properties.insert(Properties::value_type(property, nullptr)).first; assert(pi != _properties.end()); P3D_object *orig_value = (*pi).second; if (orig_value != value) { @@ -144,7 +144,7 @@ set_property(const string &property, bool needs_response, P3D_object *value) { } } - if (_pyobj == NULL) { + if (_pyobj == nullptr) { // Without a pyobj, that's all we do. return true; } @@ -171,7 +171,7 @@ has_method(const string &method_name) { return true; } - if (_pyobj == NULL) { + if (_pyobj == nullptr) { // No methods until we get our pyobj. return false; } @@ -197,7 +197,7 @@ call(const string &method_name, bool needs_response, if (i != 0) { nout << ", "; } - int buffer_size = P3D_OBJECT_GET_REPR(params[i], NULL, 0); + int buffer_size = P3D_OBJECT_GET_REPR(params[i], nullptr, 0); char *buffer = new char[buffer_size]; P3D_OBJECT_GET_REPR(params[i], buffer, buffer_size); nout.write(buffer, buffer_size); @@ -217,9 +217,9 @@ call(const string &method_name, bool needs_response, return call_uninstall(params, num_params); } - if (_pyobj == NULL) { + if (_pyobj == nullptr) { // No methods until we get our pyobj. - return NULL; + return nullptr; } return P3D_OBJECT_CALL(_pyobj, method_name.c_str(), needs_response, @@ -251,9 +251,9 @@ set_pyobj(P3D_object *pyobj) { // actually need to set the reference; instead, we clear anything we had // set. nout << "application shares main object\n"; - pyobj = NULL; + pyobj = nullptr; - } else if (pyobj != NULL) { + } else if (pyobj != nullptr) { // In the alternate case, the application has its own, separate // appRunner.main object. Thus, we do need to set the pointer. nout << "application has its own main object\n"; @@ -262,7 +262,7 @@ set_pyobj(P3D_object *pyobj) { if (_pyobj != pyobj) { P3D_OBJECT_XDECREF(_pyobj); _pyobj = pyobj; - if (_pyobj != NULL) { + if (_pyobj != nullptr) { P3D_OBJECT_INCREF(_pyobj); // Now that we have a pyobj, we have to transfer down all of the @@ -288,7 +288,7 @@ get_pyobj() const { */ void P3DMainObject:: apply_properties(P3D_object *pyobj) { - P3DPythonObject *p3dpyobj = NULL; + P3DPythonObject *p3dpyobj = nullptr; if (pyobj->_class == &P3DObject::_object_class) { p3dpyobj = ((P3DObject *)pyobj)->as_python_object(); } @@ -297,7 +297,7 @@ apply_properties(P3D_object *pyobj) { for (pi = _properties.begin(); pi != _properties.end(); ++pi) { const string &property_name = (*pi).first; P3D_object *value = (*pi).second; - if (p3dpyobj != NULL && P3D_OBJECT_GET_TYPE(value) != P3D_OT_object) { + if (p3dpyobj != nullptr && P3D_OBJECT_GET_TYPE(value) != P3D_OT_object) { // If we know we have an actual P3DPythonObject (we really expect this), // then we can call set_property_insecure() directly, because we want to // allow setting the initial properties even if Javascript has no @@ -317,7 +317,7 @@ apply_properties(P3D_object *pyobj) { */ void P3DMainObject:: set_instance(P3DInstance *inst) { - if (_inst != NULL) { + if (_inst != nullptr) { // Save the game log filename of the instance just before it goes away, in // case JavaScript asks for it later. _game_log_pathname = _inst->get_log_pathname(); @@ -341,7 +341,7 @@ set_instance(P3DInstance *inst) { P3D_object *P3DMainObject:: call_play(P3D_object *params[], int num_params) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); - if (_inst == NULL) { + if (_inst == nullptr) { return inst_mgr->new_bool_object(false); } @@ -372,7 +372,7 @@ call_play(P3D_object *params[], int num_params) { */ P3D_object *P3DMainObject:: call_read_game_log(P3D_object *params[], int num_params) { - if (_inst != NULL) { + if (_inst != nullptr) { string log_pathname = _inst->get_log_pathname(); return read_log(log_pathname, params, num_params); } @@ -413,7 +413,7 @@ call_read_log(P3D_object *params[], int num_params) { return inst_mgr->new_undefined_object(); } - int size = P3D_OBJECT_GET_STRING(params[0], NULL, 0); + int size = P3D_OBJECT_GET_STRING(params[0], nullptr, 0); char *buffer = new char[size]; P3D_OBJECT_GET_STRING(params[0], buffer, size); string log_filename = string(buffer, size); @@ -599,7 +599,7 @@ read_log_file(const string &log_pathname, size_t buffer_bytes = max(max(full_bytes, head_bytes), tail_bytes) + 1; nout << "allocating " << buffer_bytes << " bytes to read at a time from file of size " << file_size << ".\n"; char *buffer = new char[buffer_bytes]; - if (buffer == NULL) { + if (buffer == nullptr) { log_data << "== PandaLog-" << "Error allocating buffer"; log_data << " " << "(" << log_leafname << ")" << "\n"; return; @@ -659,7 +659,7 @@ read_log_file(const string &log_pathname, // cleanup delete[] buffer; - buffer = NULL; + buffer = nullptr; } /** @@ -673,7 +673,7 @@ call_uninstall(P3D_object *params[], int num_params) { // Get the first parameter, the uninstall mode. string mode; if (num_params > 0) { - int size = P3D_OBJECT_GET_STRING(params[0], NULL, 0); + int size = P3D_OBJECT_GET_STRING(params[0], nullptr, 0); char *buffer = new char[size]; P3D_OBJECT_GET_STRING(params[0], buffer, size); mode = string(buffer, size); @@ -686,7 +686,7 @@ call_uninstall(P3D_object *params[], int num_params) { return inst_mgr->new_bool_object(true); } - if (_inst != NULL) { + if (_inst != nullptr) { nout << "uninstall " << mode << " for " << _inst << "\n"; bool success = false; if (mode == "host") { diff --git a/direct/src/plugin/p3dMultifileReader.cxx b/direct/src/plugin/p3dMultifileReader.cxx index 2ab529f887..dfaf4d8a2d 100644 --- a/direct/src/plugin/p3dMultifileReader.cxx +++ b/direct/src/plugin/p3dMultifileReader.cxx @@ -88,7 +88,7 @@ extract_all(const string &to_dir, P3DPackage *package, for (si = _subfiles.begin(); si != _subfiles.end(); ++si) { const Subfile &s = (*si); FileSpec file; - if (package != NULL && !package->is_extractable(file, s._filename)) { + if (package != nullptr && !package->is_extractable(file, s._filename)) { continue; } @@ -127,7 +127,7 @@ extract_all(const string &to_dir, P3DPackage *package, // or something. chmod(output_pathname.c_str(), 0555); - if (step != NULL && package != NULL) { + if (step != nullptr && package != nullptr) { step->thread_add_bytes_done(s._data_length); } } @@ -409,7 +409,7 @@ check_signatures() { // Now convert each of the certificates to an X509 object, and store it in // our CertChain. CertChain chain; - EVP_PKEY *pkey = NULL; + EVP_PKEY *pkey = nullptr; if (buffer_size > 0) { #if OPENSSL_VERSION_NUMBER >= 0x00908000L // Beginning in 0.9.8, d2i_X509() accepted a const unsigned char **. @@ -420,13 +420,13 @@ check_signatures() { #endif bp = (unsigned char *)&buffer[0]; bp_end = bp + buffer_size; - X509 *x509 = d2i_X509(NULL, &bp, bp_end - bp); - while (num_certs > 0 && x509 != NULL) { + X509 *x509 = d2i_X509(nullptr, &bp, bp_end - bp); + while (num_certs > 0 && x509 != nullptr) { chain.push_back(CertRecord(x509)); --num_certs; - x509 = d2i_X509(NULL, &bp, bp_end - bp); + x509 = d2i_X509(nullptr, &bp, bp_end - bp); } - if (num_certs != 0 || x509 != NULL) { + if (num_certs != 0 || x509 != nullptr) { nout << "Extra data in signature record.\n"; } } @@ -437,7 +437,7 @@ check_signatures() { pkey = X509_get_pubkey(chain[0]._cert); } - if (pkey != NULL) { + if (pkey != nullptr) { EVP_MD_CTX *md_ctx; #if OPENSSL_VERSION_NUMBER >= 0x00907000L md_ctx = EVP_MD_CTX_create(); diff --git a/direct/src/plugin/p3dObject.cxx b/direct/src/plugin/p3dObject.cxx index 5f17ee3e2e..a8393a6c11 100644 --- a/direct/src/plugin/p3dObject.cxx +++ b/direct/src/plugin/p3dObject.cxx @@ -77,7 +77,7 @@ static P3D_object * object_call(P3D_object *object, const char *method_name, bool needs_response, P3D_object *params[], int num_params) { - if (method_name == NULL) { + if (method_name == nullptr) { method_name = ""; } return ((P3DObject *)object)->call(method_name, needs_response, params, num_params); @@ -147,7 +147,7 @@ generic_get_repr(P3D_object *object, char *buffer, int buffer_length) { static P3D_object * generic_get_property(P3D_object *object, const char *property) { - return NULL; + return nullptr; } static bool @@ -164,12 +164,12 @@ generic_has_method(P3D_object *object, const char *method_name) { static P3D_object * generic_call(P3D_object *object, const char *method_name, bool needs_response, P3D_object *params[], int num_params) { - return NULL; + return nullptr; } static P3D_object * generic_eval(P3D_object *object, const char *expression) { - return NULL; + return nullptr; } P3D_class_definition P3DObject::_generic_class = { @@ -244,7 +244,7 @@ get_repr(char *buffer, int buffer_length) { */ P3D_object *P3DObject:: get_property(const string &property) { - return NULL; + return nullptr; } /** @@ -275,7 +275,7 @@ has_method(const string &method_name) { P3D_object *P3DObject:: call(const string &method_name, bool needs_response, P3D_object *params[], int num_params) { - return NULL; + return nullptr; } /** @@ -284,7 +284,7 @@ call(const string &method_name, bool needs_response, */ P3D_object *P3DObject:: eval(const string &expression) { - return NULL; + return nullptr; } /** @@ -317,7 +317,7 @@ fill_xml(TiXmlElement *xvalue, P3DSession *session) { */ P3D_object **P3DObject:: get_object_array() { - return NULL; + return nullptr; } /** @@ -335,7 +335,7 @@ get_object_array_size() { */ P3DPythonObject *P3DObject:: as_python_object() { - return NULL; + return nullptr; } /** @@ -345,7 +345,7 @@ as_python_object() { bool P3DObject:: get_bool_property(const string &property) { P3D_object *result = get_property(property); - if (result == NULL) { + if (result == nullptr) { return 0; } bool bresult = P3D_OBJECT_GET_BOOL(result); @@ -370,7 +370,7 @@ set_bool_property(const string &property, bool value) { int P3DObject:: get_int_property(const string &property) { P3D_object *result = get_property(property); - if (result == NULL) { + if (result == nullptr) { return 0; } int iresult = P3D_OBJECT_GET_INT(result); @@ -395,7 +395,7 @@ set_int_property(const string &property, int value) { double P3DObject:: get_float_property(const string &property) { P3D_object *result = get_property(property); - if (result == NULL) { + if (result == nullptr) { return 0.0; } double fresult = P3D_OBJECT_GET_FLOAT(result); @@ -421,11 +421,11 @@ set_float_property(const string &property, double value) { string P3DObject:: get_string_property(const string &property) { P3D_object *result = get_property(property); - if (result == NULL) { + if (result == nullptr) { return string(); } - int size = P3D_OBJECT_GET_STRING(result, NULL, 0); + int size = P3D_OBJECT_GET_STRING(result, nullptr, 0); char *buffer = new char[size]; P3D_OBJECT_GET_STRING(result, buffer, size); string sresult(buffer, size); diff --git a/direct/src/plugin/p3dOsxSplashWindow.I b/direct/src/plugin/p3dOsxSplashWindow.I index 4778fd40cc..a9573dafa4 100644 --- a/direct/src/plugin/p3dOsxSplashWindow.I +++ b/direct/src/plugin/p3dOsxSplashWindow.I @@ -16,11 +16,11 @@ */ inline P3DOsxSplashWindow::OsxImageData:: OsxImageData() { - _raw_data = NULL; - _image = NULL; - _color_space = NULL; - _provider = NULL; - _data = NULL; + _raw_data = nullptr; + _image = nullptr; + _color_space = nullptr; + _provider = nullptr; + _data = nullptr; } /** diff --git a/direct/src/plugin/p3dOsxSplashWindow.cxx b/direct/src/plugin/p3dOsxSplashWindow.cxx index c8fc969679..d504d58671 100644 --- a/direct/src/plugin/p3dOsxSplashWindow.cxx +++ b/direct/src/plugin/p3dOsxSplashWindow.cxx @@ -33,7 +33,7 @@ P3DOsxSplashWindow:: P3DOsxSplashWindow(P3DInstance *inst, bool make_visible) : P3DSplashWindow(inst, make_visible) { - _font_attribs = NULL; + _font_attribs = nullptr; _install_progress = 0; _progress_known = true; _received_data = 0; @@ -41,7 +41,7 @@ P3DOsxSplashWindow(P3DInstance *inst, bool make_visible) : // We have to start with _mouse_active true; firefox doesn't send activate // events. _mouse_active = true; - _toplevel_window = NULL; + _toplevel_window = nullptr; } /** @@ -49,13 +49,13 @@ P3DOsxSplashWindow(P3DInstance *inst, bool make_visible) : */ P3DOsxSplashWindow:: ~P3DOsxSplashWindow() { - if (_toplevel_window != NULL) { + if (_toplevel_window != nullptr) { SetWRefCon(_toplevel_window, 0); HideWindow(_toplevel_window); DisposeWindow(_toplevel_window); - _toplevel_window = NULL; + _toplevel_window = nullptr; } - if (_font_attribs != NULL) { + if (_font_attribs != nullptr) { CFRelease(_font_attribs); } } @@ -72,7 +72,7 @@ set_wparams(const P3DWindowParams &wparams) { if (_wparams.get_window_type() == P3D_WT_toplevel || _wparams.get_window_type() == P3D_WT_fullscreen) { // Creating a toplevel splash window. - if (_toplevel_window == NULL) { + if (_toplevel_window == nullptr) { Rect r; r.top = _wparams.get_win_y(); r.left = _wparams.get_win_x(); @@ -134,7 +134,7 @@ set_wparams(const P3DWindowParams &wparams) { CFTypeRef traits_values[1] = { symbolic_ref }; CFDictionaryRef traits = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&traits_keys, (const void **)&traits_values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - CFStringRef family = CFStringCreateWithCString(NULL, _font_family.c_str(), kCFStringEncodingUTF8); + CFStringRef family = CFStringCreateWithCString(nullptr, _font_family.c_str(), kCFStringEncodingUTF8); CFStringRef attribs_keys[2] = { kCTFontFamilyNameAttribute, kCTFontTraitsAttribute }; CFTypeRef attribs_values[2] = { family, traits }; @@ -142,7 +142,7 @@ set_wparams(const P3DWindowParams &wparams) { // Create the font object. CTFontDescriptorRef font_desc = CTFontDescriptorCreateWithAttributes(attribs); - CTFontRef font = CTFontCreateWithFontDescriptor(font_desc, _font_size, NULL); + CTFontRef font = CTFontCreateWithFontDescriptor(font_desc, _font_size, nullptr); CFStringRef keys[1] = { kCTFontAttributeName }; CFTypeRef values[1] = { font }; @@ -164,7 +164,7 @@ void P3DOsxSplashWindow:: set_visible(bool visible) { P3DSplashWindow::set_visible(visible); - if (_toplevel_window != NULL) { + if (_toplevel_window != nullptr) { if (_visible) { ShowWindow(_toplevel_window); } else { @@ -266,7 +266,7 @@ refresh() { if (!_visible) { return; } - if (_toplevel_window != NULL) { + if (_toplevel_window != nullptr) { Rect r = { 0, 0, (short)_win_height, (short)_win_width }; InvalWindowRect(_toplevel_window, &r); @@ -284,13 +284,13 @@ paint_window() { return; } - if (_toplevel_window != NULL || + if (_toplevel_window != nullptr || _wparams.get_parent_window()._window_handle_type == P3D_WHT_osx_port) { // The old QuickDraw-style window handle. We use CreateCGContextForPort() // to map this to the new CoreGraphics-style. - GrafPtr out_port = NULL; - if (_toplevel_window != NULL) { + GrafPtr out_port = nullptr; + if (_toplevel_window != nullptr) { GetPort(&out_port); } else { @@ -394,13 +394,13 @@ handle_event_osx_event_record(const P3D_event_data &event) { const P3D_window_handle &handle = _wparams.get_parent_window(); if (handle._window_handle_type == P3D_WHT_osx_port) { GrafPtr out_port = handle._handle._osx_port._port; - GrafPtr port_save = NULL; + GrafPtr port_save = nullptr; Boolean port_changed = QDSwapPort(out_port, &port_save); GlobalToLocal(&pt); if (port_changed) { - QDSwapPort(port_save, NULL); + QDSwapPort(port_save, nullptr); } } else if (handle._window_handle_type == P3D_WHT_osx_cgcontext) { @@ -408,7 +408,7 @@ handle_event_osx_event_record(const P3D_event_data &event) { // window coordinates. WindowRef window = handle._handle._osx_cgcontext._window; CGPoint cgpt = { (CGFloat)pt.h, (CGFloat)pt.v }; - HIPointConvert(&cgpt, kHICoordSpaceScreenPixel, NULL, + HIPointConvert(&cgpt, kHICoordSpaceScreenPixel, nullptr, kHICoordSpaceWindow, window); // Then convert to plugin coordinates. @@ -536,7 +536,7 @@ load_image(OsxImageData &image, const string &image_filename) { } image._data = - CFDataCreateWithBytesNoCopy(NULL, (const UInt8 *)image._raw_data, + CFDataCreateWithBytesNoCopy(nullptr, (const UInt8 *)image._raw_data, image._height * new_row_stride, kCFAllocatorNull); image._provider = CGDataProviderCreateWithCFData(image._data); image._color_space = CGColorSpaceCreateDeviceRGB(); @@ -545,7 +545,7 @@ load_image(OsxImageData &image, const string &image_filename) { CGImageCreate(image._width, image._height, 8, 32, new_row_stride, image._color_space, kCGImageAlphaFirst | kCGBitmapByteOrder32Little, - image._provider, NULL, false, kCGRenderingIntentDefault); + image._provider, nullptr, false, kCGRenderingIntentDefault); } /** @@ -554,7 +554,7 @@ load_image(OsxImageData &image, const string &image_filename) { */ bool P3DOsxSplashWindow:: paint_image(CGContextRef context, const OsxImageData &image) { - if (image._image == NULL) { + if (image._image == nullptr) { return false; } @@ -675,8 +675,8 @@ paint_progress_bar(CGContextRef context) { CGContextSetTextMatrix(context, text_xform); // Now draw the install_label right above it. - CFStringRef string = CFStringCreateWithCString(NULL, _install_label.c_str(), kCFStringEncodingUTF8); - CFAttributedStringRef attr_string = CFAttributedStringCreate(NULL, string, _font_attribs); + CFStringRef string = CFStringCreateWithCString(nullptr, _install_label.c_str(), kCFStringEncodingUTF8); + CFAttributedStringRef attr_string = CFAttributedStringCreate(nullptr, string, _font_attribs); CTLineRef line = CTLineCreateWithAttributedString(attr_string); // Determine the placement based on the size of the text. @@ -716,11 +716,11 @@ OSStatus P3DOsxSplashWindow:: event_callback(EventHandlerCallRef my_handler, EventRef event) { OSStatus result = eventNotHandledErr; - WindowRef window = NULL; + WindowRef window = nullptr; UInt32 the_class = GetEventClass(event); UInt32 kind = GetEventKind(event); - GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL, - sizeof(WindowRef), NULL, (void*) &window); + GetEventParameter(event, kEventParamWindowRef, typeWindowRef, nullptr, + sizeof(WindowRef), nullptr, (void*) &window); switch (the_class) { case kEventClassWindow: switch (kind) { @@ -773,17 +773,17 @@ event_callback(EventHandlerCallRef my_handler, EventRef event) { case kEventMouseDragged: { Point point; - GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, - sizeof(Point), NULL, (void *)&point); + GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, nullptr, + sizeof(Point), nullptr, (void *)&point); GrafPtr port; - assert(_toplevel_window != NULL); + assert(_toplevel_window != nullptr); port = GetWindowPort(_toplevel_window); - GrafPtr port_save = NULL; + GrafPtr port_save = nullptr; Boolean port_changed = QDSwapPort(port, &port_save); GlobalToLocal(&point); if (port_changed) { - QDSwapPort(port_save, NULL); + QDSwapPort(port_save, nullptr); } set_mouse_data(point.h, point.v, _mouse_down); @@ -800,25 +800,25 @@ event_callback(EventHandlerCallRef my_handler, EventRef event) { */ void P3DOsxSplashWindow::OsxImageData:: dump_image() { - if (_image != NULL) { + if (_image != nullptr) { CGImageRelease(_image); - _image = NULL; + _image = nullptr; } - if (_color_space != NULL) { + if (_color_space != nullptr) { CGColorSpaceRelease(_color_space); - _color_space = NULL; + _color_space = nullptr; } - if (_provider != NULL) { + if (_provider != nullptr) { CGDataProviderRelease(_provider); - _provider = NULL; + _provider = nullptr; } - if (_data != NULL) { + if (_data != nullptr) { CFRelease(_data); - _data = NULL; + _data = nullptr; } - if (_raw_data != NULL) { + if (_raw_data != nullptr) { delete[] _raw_data; - _raw_data = NULL; + _raw_data = nullptr; } } diff --git a/direct/src/plugin/p3dPackage.cxx b/direct/src/plugin/p3dPackage.cxx index 0560c0f6da..1efead479b 100644 --- a/direct/src/plugin/p3dPackage.cxx +++ b/direct/src/plugin/p3dPackage.cxx @@ -59,16 +59,16 @@ P3DPackage(P3DHost *host, const string &package_name, _host_contents_iseq = 0; - _xconfig = NULL; - _temp_contents_file = NULL; + _xconfig = nullptr; + _temp_contents_file = nullptr; _computed_plan_size = false; _info_ready = false; _allow_data_download = false; _ready = false; _failed = false; - _active_download = NULL; - _saved_download = NULL; + _active_download = nullptr; + _saved_download = nullptr; _updated = false; } @@ -89,24 +89,24 @@ P3DPackage:: } _instances.clear(); - if (_xconfig != NULL) { + if (_xconfig != nullptr) { delete _xconfig; - _xconfig = NULL; + _xconfig = nullptr; } // Cancel any pending download. - if (_active_download != NULL) { + if (_active_download != nullptr) { _active_download->cancel(); - set_active_download(NULL); + set_active_download(nullptr); } - if (_saved_download != NULL) { + if (_saved_download != nullptr) { _saved_download->cancel(); - set_saved_download(NULL); + set_saved_download(nullptr); } - if (_temp_contents_file != NULL) { + if (_temp_contents_file != nullptr) { delete _temp_contents_file; - _temp_contents_file = NULL; + _temp_contents_file = nullptr; } } @@ -192,9 +192,9 @@ remove_instance(P3DInstance *inst) { if (inst == _instances[0]) { // This was the primary instance. Cancel any pending download and move to // the next instance. - if (_active_download != NULL) { + if (_active_download != nullptr) { _active_download->cancel(); - set_active_download(NULL); + set_active_download(nullptr); } } @@ -226,12 +226,12 @@ mark_used() { } TiXmlElement *xusage = doc.FirstChildElement("usage"); - if (xusage == NULL) { + if (xusage == nullptr) { xusage = new TiXmlElement("usage"); doc.LinkEndChild(xusage); } - time_t now = time(NULL); + time_t now = time(nullptr); int count = 0; xusage->Attribute("count_runtime", &count); if (count == 0) { @@ -292,7 +292,7 @@ uninstall() { for (ii = _instances.begin(); ii != _instances.end(); ++ii) { P3DInstance *inst = (*ii); P3DSession *session = inst->get_session(); - if (session != NULL) { + if (session != nullptr) { nout << "Stopping session " << session << "\n"; session->shutdown(); } @@ -350,7 +350,7 @@ begin_info_download() { return; } - if (_active_download != NULL) { + if (_active_download != nullptr) { // In the middle of downloading. return; } @@ -387,9 +387,9 @@ download_contents_file() { // Download contents.xml to a temporary filename first, in case multiple // packages are downloading it simultaneously. - if (_temp_contents_file != NULL) { + if (_temp_contents_file != nullptr) { delete _temp_contents_file; - _temp_contents_file = NULL; + _temp_contents_file = nullptr; } _temp_contents_file = new P3DTemporaryFile(".xml"); @@ -404,7 +404,7 @@ void P3DPackage:: contents_file_download_finished(bool success) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); if (!_host->has_current_contents_file(inst_mgr)) { - if (!success || _temp_contents_file == NULL || + if (!success || _temp_contents_file == nullptr || !_host->read_contents_file(_temp_contents_file->get_filename(), true)) { if (_temp_contents_file) { @@ -429,7 +429,7 @@ contents_file_download_finished(bool success) { report_done(false); if (_temp_contents_file) { delete _temp_contents_file; - _temp_contents_file = NULL; + _temp_contents_file = nullptr; } return; } @@ -439,7 +439,7 @@ contents_file_download_finished(bool success) { // The file is correctly installed by now; we can remove the temporary file. if (_temp_contents_file) { delete _temp_contents_file; - _temp_contents_file = NULL; + _temp_contents_file = nullptr; } host_got_contents_file(); @@ -460,8 +460,8 @@ contents_file_download_finished(bool success) { */ void P3DPackage:: redownload_contents_file(P3DPackage::Download *download) { - assert(_active_download == NULL); - assert(_saved_download == NULL); + assert(_active_download == nullptr); + assert(_saved_download == nullptr); if (_host->get_contents_iseq() != _host_contents_iseq) { // If the contents_iseq number has changed, we don't even need to download @@ -479,9 +479,9 @@ redownload_contents_file(P3DPackage::Download *download) { set_saved_download(download); // Download contents.xml to a temporary filename first. - if (_temp_contents_file != NULL) { + if (_temp_contents_file != nullptr) { delete _temp_contents_file; - _temp_contents_file = NULL; + _temp_contents_file = nullptr; } _temp_contents_file = new P3DTemporaryFile(".xml"); @@ -521,14 +521,14 @@ contents_file_redownload_finished(bool success) { // We no longer need the temporary file. if (_temp_contents_file) { delete _temp_contents_file; - _temp_contents_file = NULL; + _temp_contents_file = nullptr; } if (contents_changed) { // OK, the contents.xml has changed; this means we have to restart the // whole download process from the beginning. nout << "Redownloading contents.xml made a difference.\n"; - set_saved_download(NULL); + set_saved_download(nullptr); host_got_contents_file(); } else { @@ -536,8 +536,8 @@ contents_file_redownload_finished(bool success) { // you to our regularly scheduled download. nout << "Redownloading contents.xml didn't help.\n"; Download *download = _saved_download; - _saved_download = NULL; - if (download == NULL) { + _saved_download = nullptr; + if (download == nullptr) { // But, if _saved_download was NULL (meaning NULL was passed to // redownload_contents_file(), above), it means that we were called from // download_desc_file(), and there's nothing more to do. We're just @@ -639,7 +639,7 @@ download_desc_file() { nout << "Couldn't find package " << _package_fullname << ", platform \"" << _package_platform << "\" in contents file.\n"; - redownload_contents_file(NULL); + redownload_contents_file(nullptr); return; } @@ -730,7 +730,7 @@ desc_file_download_finished(bool success) { void P3DPackage:: got_desc_file(TiXmlDocument *doc, bool freshly_downloaded) { TiXmlElement *xpackage = doc->FirstChildElement("package"); - if (xpackage == NULL) { + if (xpackage == nullptr) { nout << _package_name << " desc file contains no \n"; if (!freshly_downloaded) { download_desc_file(); @@ -752,9 +752,9 @@ got_desc_file(TiXmlDocument *doc, bool freshly_downloaded) { xpackage->Attribute("patch_version", &_patch_version); TiXmlElement *xconfig = xpackage->FirstChildElement("config"); - if (xconfig != NULL) { + if (xconfig != nullptr) { const char *display_name_cstr = xconfig->Attribute("display_name"); - if (display_name_cstr != NULL) { + if (display_name_cstr != nullptr) { _package_display_name = display_name_cstr; } @@ -767,7 +767,7 @@ got_desc_file(TiXmlDocument *doc, bool freshly_downloaded) { TiXmlElement *xcompressed_archive = xpackage->FirstChildElement("compressed_archive"); - if (xuncompressed_archive == NULL || xcompressed_archive == NULL) { + if (xuncompressed_archive == nullptr || xcompressed_archive == nullptr) { // The desc file didn't include the archive file itself, weird. if (!freshly_downloaded) { download_desc_file(); @@ -784,7 +784,7 @@ got_desc_file(TiXmlDocument *doc, bool freshly_downloaded) { _unpack_size = 0; _extracts.clear(); TiXmlElement *xextract = xpackage->FirstChildElement("extract"); - while (xextract != NULL) { + while (xextract != nullptr) { FileSpec file; file.load_xml(xextract); _extracts.push_back(file); @@ -797,16 +797,16 @@ got_desc_file(TiXmlDocument *doc, bool freshly_downloaded) { // Get the required packages. _requires.clear(); TiXmlElement *xrequires = xpackage->FirstChildElement("requires"); - while (xrequires != NULL) { + while (xrequires != nullptr) { const char *package_name = xrequires->Attribute("name"); const char *host_url = xrequires->Attribute("host"); - if (package_name != NULL && host_url != NULL) { + if (package_name != nullptr && host_url != nullptr) { const char *version = xrequires->Attribute("version"); - if (version == NULL) { + if (version == nullptr) { version = ""; } const char *seq = xrequires->Attribute("seq"); - if (seq == NULL) { + if (seq == nullptr) { seq = ""; } P3DHost *host = inst_mgr->get_host(host_url); @@ -969,14 +969,14 @@ build_install_plans(TiXmlDocument *doc) { // Maybe we've already read the md5 hash and we have it stored here. const FileSpec *on_disk_ptr = _uncompressed_archive.get_actual_file(); FileSpec on_disk; - if (on_disk_ptr == NULL) { + if (on_disk_ptr == nullptr) { // If not, we have to go read it now. if (on_disk.read_hash(_uncompressed_archive.get_pathname(_package_dir))) { on_disk_ptr = &on_disk; } } - if (on_disk_ptr != NULL) { + if (on_disk_ptr != nullptr) { P3DPatchFinder patch_finder; P3DPatchFinder::Patchfiles chain; if (patch_finder.get_patch_chain_to_current(chain, doc, *on_disk_ptr)) { @@ -1218,7 +1218,7 @@ P3DPackage::Download *P3DPackage:: start_download(P3DPackage::DownloadType dtype, const string &urlbase, const string &pathname, const FileSpec &file_spec) { // Only one download should be active at a time - assert(_active_download == NULL); + assert(_active_download == nullptr); // This can't happen! If verify_contents is set to P3D_VC_never, we're not // allowed to download anything, so we shouldn't get here P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); @@ -1249,7 +1249,7 @@ start_download(P3DPackage::DownloadType dtype, const string &urlbase, } else { strm << _host->get_download_url_prefix(); } - strm << urlbase << "?" << time(NULL); + strm << urlbase << "?" << time(nullptr); string url = strm.str(); download->_try_urls.push_back(url); @@ -1315,11 +1315,11 @@ start_download(P3DPackage::DownloadType dtype, const string &urlbase, void P3DPackage:: set_active_download(Download *download) { if (_active_download != download) { - if (_active_download != NULL) { + if (_active_download != nullptr) { p3d_unref_delete(_active_download); } _active_download = download; - if (_active_download != NULL) { + if (_active_download != nullptr) { _active_download->ref(); } } @@ -1332,11 +1332,11 @@ set_active_download(Download *download) { void P3DPackage:: set_saved_download(Download *download) { if (_saved_download != download) { - if (_saved_download != NULL) { + if (_saved_download != nullptr) { p3d_unref_delete(_saved_download); } _saved_download = download; - if (_saved_download != NULL) { + if (_saved_download != nullptr) { _saved_download->ref(); } } @@ -1456,11 +1456,11 @@ download_finished(bool success) { if (get_ref_count() == 1) { // No one cares anymore. nout << "No one cares about " << get_url() << "\n"; - _package->set_active_download(NULL); + _package->set_active_download(nullptr); return; } - _package->set_active_download(NULL); + _package->set_active_download(nullptr); assert(get_ref_count() > 0); if (success && !_file_spec.get_filename().empty()) { @@ -1471,7 +1471,7 @@ download_finished(bool success) { nout << "expected: "; _file_spec.output_hash(nout); nout << "\n"; - if (_file_spec.get_actual_file() != (FileSpec *)NULL) { + if (_file_spec.get_actual_file() != nullptr) { nout << " got: "; _file_spec.get_actual_file()->output_hash(nout); nout << "\n"; @@ -1578,7 +1578,7 @@ InstallStepDownloadFile(P3DPackage *package, const FileSpec &file) : _pathname = _package->get_package_dir() + "/" + _file.get_filename(); - _download = NULL; + _download = nullptr; } /** @@ -1586,7 +1586,7 @@ InstallStepDownloadFile(P3DPackage *package, const FileSpec &file) : */ P3DPackage::InstallStepDownloadFile:: ~InstallStepDownloadFile() { - if (_download != NULL) { + if (_download != nullptr) { p3d_unref_delete(_download); } } @@ -1596,13 +1596,13 @@ P3DPackage::InstallStepDownloadFile:: */ P3DPackage::InstallToken P3DPackage::InstallStepDownloadFile:: do_step(bool download_finished) { - if (_download == NULL) { + if (_download == nullptr) { // First, we have to start the download going. - assert(_package->_active_download == NULL); + assert(_package->_active_download == nullptr); _download = _package->start_download(DT_install_step, _urlbase, _pathname, _file); - assert(_download != NULL); + assert(_download != nullptr); _download->ref(); } @@ -1632,7 +1632,7 @@ do_step(bool download_finished) { nout << "Restarting download of " << _urlbase << " on new instance\n"; p3d_unref_delete(_download); - _download = NULL; + _download = nullptr; return IT_continue; } else { diff --git a/direct/src/plugin/p3dPatchFinder.cxx b/direct/src/plugin/p3dPatchFinder.cxx index c3e5b80c86..044953b3af 100644 --- a/direct/src/plugin/p3dPatchFinder.cxx +++ b/direct/src/plugin/p3dPatchFinder.cxx @@ -24,8 +24,8 @@ PackageVersion(const PackageVersionKey &key) : _host_url(key._host_url), _file(key._file) { - _package_current = NULL; - _package_base = NULL; + _package_current = nullptr; + _package_base = nullptr; } /** @@ -58,7 +58,7 @@ get_patch_chain(Patchfiles &chain, PackageVersion *start_pv, for (pi = _from_patches.begin(); pi != _from_patches.end(); ++pi) { Patchfile *patchfile = (*pi); PackageVersion *from_pv = patchfile->_from_pv; - assert(from_pv != NULL); + assert(from_pv != nullptr); Patchfiles this_chain; if (from_pv->get_patch_chain(this_chain, start_pv, already_visited)) { // There's a path through this patchfile. @@ -129,8 +129,8 @@ output(ostream &out) const { P3DPatchFinder::Patchfile:: Patchfile(Package *package) : _package(package), - _from_pv(NULL), - _to_pv(NULL) + _from_pv(nullptr), + _to_pv(nullptr) { _package_name = package->_package_name; _platform = package->_platform; @@ -161,30 +161,30 @@ get_target_key() const { void P3DPatchFinder::Patchfile:: load_xml(TiXmlElement *xpatch) { const char *package_name_cstr = xpatch->Attribute("name"); - if (package_name_cstr != NULL && *package_name_cstr) { + if (package_name_cstr != nullptr && *package_name_cstr) { _package_name = package_name_cstr; } const char *platform_cstr = xpatch->Attribute("platform"); - if (platform_cstr != NULL && *platform_cstr) { + if (platform_cstr != nullptr && *platform_cstr) { _platform = platform_cstr; } const char *version_cstr = xpatch->Attribute("version"); - if (version_cstr != NULL && *version_cstr) { + if (version_cstr != nullptr && *version_cstr) { _version = version_cstr; } const char *host_url_cstr = xpatch->Attribute("host"); - if (host_url_cstr != NULL && *host_url_cstr) { + if (host_url_cstr != nullptr && *host_url_cstr) { _host_url = host_url_cstr; } _file.load_xml(xpatch); TiXmlElement *xsource = xpatch->FirstChildElement("source"); - if (xsource != NULL) { + if (xsource != nullptr) { _source_file.load_xml(xsource); } TiXmlElement *xtarget = xpatch->FirstChildElement("target"); - if (xtarget != NULL) { + if (xtarget != nullptr) { _target_file.load_xml(xtarget); } } @@ -194,8 +194,8 @@ load_xml(TiXmlElement *xpatch) { */ P3DPatchFinder::Package:: Package() { - _current_pv = NULL; - _base_pv = NULL; + _current_pv = nullptr; + _base_pv = nullptr; _got_base_file = false; } @@ -230,43 +230,43 @@ get_generic_key(const FileSpec &file) const { bool P3DPatchFinder::Package:: read_desc_file(TiXmlDocument *doc) { TiXmlElement *xpackage = doc->FirstChildElement("package"); - if (xpackage == NULL) { + if (xpackage == nullptr) { return false; } const char *package_name_cstr = xpackage->Attribute("name"); - if (package_name_cstr != NULL && *package_name_cstr) { + if (package_name_cstr != nullptr && *package_name_cstr) { _package_name = package_name_cstr; } const char *platform_cstr = xpackage->Attribute("platform"); - if (platform_cstr != NULL && *platform_cstr) { + if (platform_cstr != nullptr && *platform_cstr) { _platform = platform_cstr; } const char *version_cstr = xpackage->Attribute("version"); - if (version_cstr != NULL && *version_cstr) { + if (version_cstr != nullptr && *version_cstr) { _version = version_cstr; } const char *host_url_cstr = xpackage->Attribute("host"); - if (host_url_cstr != NULL && *host_url_cstr) { + if (host_url_cstr != nullptr && *host_url_cstr) { _host_url = host_url_cstr; } // Get the current version. TiXmlElement *xarchive = xpackage->FirstChildElement("uncompressed_archive"); - if (xarchive != NULL) { + if (xarchive != nullptr) { _current_file.load_xml(xarchive); } // Get the base_version--the bottom (oldest) of the patch chain. xarchive = xpackage->FirstChildElement("base_version"); - if (xarchive != NULL) { + if (xarchive != nullptr) { _base_file.load_xml(xarchive); _got_base_file = true; } _patches.clear(); TiXmlElement *xpatch = xpackage->FirstChildElement("patch"); - while (xpatch != NULL) { + while (xpatch != nullptr) { Patchfile *patchfile = new Patchfile(this); patchfile->load_xml(xpatch); _patches.push_back(patchfile); @@ -301,7 +301,7 @@ get_patch_chain_to_current(Patchfiles &chain, TiXmlDocument *doc, const FileSpec &file) { chain.clear(); Package *package = read_package_desc_file(doc); - if (package == NULL) { + if (package == nullptr) { return false; } @@ -309,7 +309,7 @@ get_patch_chain_to_current(Patchfiles &chain, TiXmlDocument *doc, PackageVersion *from_pv = get_package_version(package->get_generic_key(file)); PackageVersion *to_pv = package->_current_pv; - if (to_pv != NULL && from_pv != NULL) { + if (to_pv != nullptr && from_pv != nullptr) { return to_pv->get_patch_chain(chain, from_pv, PackageVersionsList()); } @@ -326,7 +326,7 @@ read_package_desc_file(TiXmlDocument *doc) { Package *package = new Package; if (!package->read_desc_file(doc)) { delete package; - return NULL; + return nullptr; } _packages.push_back(package); diff --git a/direct/src/plugin/p3dPythonMain.cxx b/direct/src/plugin/p3dPythonMain.cxx index 76cf92c7e4..3d8bbdc9e8 100644 --- a/direct/src/plugin/p3dPythonMain.cxx +++ b/direct/src/plugin/p3dPythonMain.cxx @@ -94,10 +94,10 @@ WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { int main(int argc, char *argv[]) { const char *program_name = argv[0]; - const char *archive_file = NULL; - const char *input_handle_str = NULL; - const char *output_handle_str = NULL; - const char *interactive_console_str = NULL; + const char *archive_file = nullptr; + const char *input_handle_str = nullptr; + const char *output_handle_str = nullptr; + const char *interactive_console_str = nullptr; if (argc > 1) { archive_file = argv[1]; @@ -112,13 +112,13 @@ main(int argc, char *argv[]) { interactive_console_str = argv[4]; } - if (archive_file == NULL || *archive_file == '\0') { + if (archive_file == nullptr || *archive_file == '\0') { cerr << "No archive filename specified on command line.\n"; return 1; } FHandle input_handle = invalid_fhandle; - if (input_handle_str != NULL && *input_handle_str) { + if (input_handle_str != nullptr && *input_handle_str) { stringstream stream(input_handle_str); stream >> input_handle; if (!stream) { @@ -127,7 +127,7 @@ main(int argc, char *argv[]) { } FHandle output_handle = invalid_fhandle; - if (output_handle_str != NULL && *output_handle_str) { + if (output_handle_str != nullptr && *output_handle_str) { stringstream stream(output_handle_str); stream >> output_handle; if (!stream) { @@ -136,7 +136,7 @@ main(int argc, char *argv[]) { } bool interactive_console = false; - if (interactive_console_str != NULL && *interactive_console_str) { + if (interactive_console_str != nullptr && *interactive_console_str) { stringstream stream(interactive_console_str); int flag; stream >> flag; @@ -146,7 +146,7 @@ main(int argc, char *argv[]) { } int status = run_p3dpython(program_name, archive_file, input_handle, - output_handle, NULL, interactive_console); + output_handle, nullptr, interactive_console); if (status != 0) { cerr << "Failure on startup.\n"; } diff --git a/direct/src/plugin/p3dPythonObject.cxx b/direct/src/plugin/p3dPythonObject.cxx index 3a771dbf72..fb52163b71 100644 --- a/direct/src/plugin/p3dPythonObject.cxx +++ b/direct/src/plugin/p3dPythonObject.cxx @@ -51,8 +51,8 @@ bool P3DPythonObject:: get_bool() { bool bresult = 0; - P3D_object *result = call("__bool__", true, NULL, 0); - if (result != NULL) { + P3D_object *result = call("__bool__", true, nullptr, 0); + if (result != nullptr) { bresult = P3D_OBJECT_GET_BOOL(result); P3D_OBJECT_DECREF(result); } @@ -67,8 +67,8 @@ int P3DPythonObject:: get_int() { int iresult = 0; - P3D_object *result = call("__int__", true, NULL, 0); - if (result != NULL) { + P3D_object *result = call("__int__", true, nullptr, 0); + if (result != nullptr) { iresult = P3D_OBJECT_GET_INT(result); P3D_OBJECT_DECREF(result); } @@ -83,8 +83,8 @@ double P3DPythonObject:: get_float() { double fresult = 0.0; - P3D_object *result = call("__float__", true, NULL, 0); - if (result != NULL) { + P3D_object *result = call("__float__", true, nullptr, 0); + if (result != nullptr) { fresult = P3D_OBJECT_GET_FLOAT(result); P3D_OBJECT_DECREF(result); } @@ -98,9 +98,9 @@ get_float() { */ void P3DPythonObject:: make_string(string &value) { - P3D_object *result = call("__str__", true, NULL, 0); - if (result != NULL) { - int size = P3D_OBJECT_GET_STRING(result, NULL, 0); + P3D_object *result = call("__str__", true, nullptr, 0); + if (result != nullptr) { + int size = P3D_OBJECT_GET_STRING(result, nullptr, 0); char *buffer = new char[size]; P3D_OBJECT_GET_STRING(result, buffer, size); value = string(buffer, size); @@ -150,9 +150,9 @@ set_property_insecure(const string &property, bool needs_response, P3D_object *params[2]; params[0] = new P3DStringObject(property); - P3D_object *result = NULL; + P3D_object *result = nullptr; - if (value == NULL) { + if (value == nullptr) { // Delete an attribute. result = call_insecure("__del_property__", needs_response, params, 1); @@ -164,7 +164,7 @@ set_property_insecure(const string &property, bool needs_response, P3D_OBJECT_DECREF(params[0]); - if (result != NULL) { + if (result != nullptr) { bresult = P3D_OBJECT_GET_BOOL(result); P3D_OBJECT_DECREF(result); } @@ -193,7 +193,7 @@ has_method(const string &method_name) { P3D_object *result = call("__has_method__", true, params, 1); P3D_OBJECT_DECREF(params[0]); - if (result != NULL) { + if (result != nullptr) { bresult = P3D_OBJECT_GET_BOOL(result); P3D_OBJECT_DECREF(result); } @@ -219,7 +219,7 @@ call(const string &method_name, bool needs_response, P3D_object *params[], int num_params) { if (!_session->get_matches_script_origin()) { // If you can't be scripting us, you can't be calling methods. - return NULL; + return nullptr; } return call_insecure(method_name, needs_response, params, num_params); @@ -255,18 +255,18 @@ call_insecure(const string &method_name, bool needs_response, // NULL. if (!needs_response) { _session->send_command(doc); - return NULL; + return nullptr; } // If a response is requested, we have to send the command and wait for it. TiXmlDocument *response = _session->command_and_response(doc); - P3D_object *result = NULL; - if (response != NULL) { + P3D_object *result = nullptr; + if (response != nullptr) { TiXmlElement *xresponse = response->FirstChildElement("response"); - if (xresponse != NULL) { + if (xresponse != nullptr) { TiXmlElement *xvalue = xresponse->FirstChildElement("value"); - if (xvalue != NULL) { + if (xvalue != nullptr) { result = _session->xml_to_p3dobj(xvalue); } } @@ -282,9 +282,9 @@ call_insecure(const string &method_name, bool needs_response, */ void P3DPythonObject:: output(ostream &out) { - P3D_object *result = call("__repr__", true, NULL, 0); + P3D_object *result = call("__repr__", true, nullptr, 0); out << "Python " << _object_id; - if (result != NULL) { + if (result != nullptr) { out << ": " << *result; P3D_OBJECT_DECREF(result); } diff --git a/direct/src/plugin/p3dPythonRun.cxx b/direct/src/plugin/p3dPythonRun.cxx index 542c47acb8..3d657597fe 100644 --- a/direct/src/plugin/p3dPythonRun.cxx +++ b/direct/src/plugin/p3dPythonRun.cxx @@ -28,7 +28,7 @@ extern "C" { // There is only one P3DPythonRun object in any given process space. Makes // the statics easier to deal with, and we don't need multiple instances of // this thing. -P3DPythonRun *P3DPythonRun::_global_ptr = NULL; +P3DPythonRun *P3DPythonRun::_global_ptr = nullptr; TypeHandle P3DPythonRun::P3DWindowHandle::_type_handle; @@ -45,7 +45,7 @@ P3DPythonRun(const char *program_name, const char *archive_file, _read_thread_continue = false; _program_continue = true; _session_terminated = false; - _taskMgr = NULL; + _taskMgr = nullptr; INIT_LOCK(_commands_lock); INIT_THREAD(_read_thread); @@ -55,7 +55,7 @@ P3DPythonRun(const char *program_name, const char *archive_file, _interactive_console = interactive_console; - if (program_name != NULL) { + if (program_name != nullptr) { #if PY_MAJOR_VERSION >= 3 // Python 3 case: we have to convert it to a wstring. TextEncoder enc; @@ -66,7 +66,7 @@ P3DPythonRun(const char *program_name, const char *archive_file, _program_name = program_name; #endif } - if (archive_file != NULL) { + if (archive_file != nullptr) { _archive_file = Filename::from_os_specific(archive_file); } @@ -76,7 +76,7 @@ P3DPythonRun(const char *program_name, const char *archive_file, #else _py_argv[0] = (char *)_program_name.c_str(); #endif - _py_argv[1] = NULL; + _py_argv[1] = nullptr; #ifdef NDEBUG // In OPTIMIZE 4 compilation mode, run Python in optimized mode too. @@ -113,7 +113,7 @@ P3DPythonRun(const char *program_name, const char *archive_file, PySys_SetArgvEx(_py_argc, _py_argv, 0); // Open the error output before we do too much more. - if (log_pathname != NULL && *log_pathname != '\0') { + if (log_pathname != nullptr && *log_pathname != '\0') { Filename f = Filename::from_os_specific(log_pathname); f.set_text(); if (f.open_write(_error_log)) { @@ -178,7 +178,7 @@ run_python() { // We could simply freeze it, but Python has a bug setting __path__ of // frozen modules properly. PyObject *panda3d_module = PyImport_AddModule("panda3d"); - if (panda3d_module == NULL) { + if (panda3d_module == nullptr) { nout << "Failed to add panda3d module:\n"; PyErr_Print(); return 1; @@ -192,7 +192,7 @@ run_python() { // Import the VFSImporter module that was frozen in. PyObject *vfsimporter_module = PyImport_ImportModule("direct.showbase.VFSImporter"); - if (vfsimporter_module == NULL) { + if (vfsimporter_module == nullptr) { nout << "Failed to import VFSImporter:\n"; PyErr_Print(); return 1; @@ -203,14 +203,14 @@ run_python() { // such that we can still find the other direct modules. Filename direct_dir(dir, "direct"); PyObject *direct_module = PyImport_AddModule("direct"); - if (direct_module != NULL) { + if (direct_module != nullptr) { dir_str = direct_dir.to_os_specific(); PyModule_AddObject(direct_module, "__path__", Py_BuildValue("[s#]", dir_str.data(), dir_str.length())); PyModule_AddStringConstant(direct_module, "__package__", "direct"); } PyObject *showbase_module = PyImport_AddModule("direct.showbase"); - if (showbase_module != NULL) { + if (showbase_module != nullptr) { Filename showbase_dir(direct_dir, "showbase"); dir_str = showbase_dir.to_os_specific(); PyModule_AddObject(showbase_module, "__path__", Py_BuildValue("[s#]", dir_str.data(), dir_str.length())); @@ -218,7 +218,7 @@ run_python() { } PyObject *stdpy_module = PyImport_AddModule("direct.stdpy"); - if (stdpy_module != NULL) { + if (stdpy_module != nullptr) { Filename stdpy_dir(direct_dir, "stdpy"); dir_str = stdpy_dir.to_os_specific(); PyModule_AddObject(stdpy_module, "__path__", Py_BuildValue("[s#]", dir_str.data(), dir_str.length())); @@ -229,7 +229,7 @@ run_python() { // bunch of encodings modules as part of the frozen bundle. Filename encodings_dir(dir, "encodings"); PyObject *encodings_module = PyImport_AddModule("encodings"); - if (encodings_module != NULL) { + if (encodings_module != nullptr) { dir_str = encodings_dir.to_os_specific(); PyModule_AddObject(encodings_module, "__path__", Py_BuildValue("[s#]", dir_str.data(), dir_str.length())); PyModule_AddStringConstant(encodings_module, "__package__", "encodings"); @@ -237,7 +237,7 @@ run_python() { // And register the VFSImporter. PyObject *result = PyObject_CallMethod(vfsimporter_module, (char *)"register", (char *)""); - if (result == NULL) { + if (result == nullptr) { nout << "Failed to call VFSImporter.register():\n"; PyErr_Print(); return 1; @@ -261,7 +261,7 @@ run_python() { // And finally, we can import the startup module. PyObject *app_runner_module = PyImport_ImportModule("direct.p3d.AppRunner"); - if (app_runner_module == NULL) { + if (app_runner_module == nullptr) { nout << "Failed to import direct.p3d.AppRunner\n"; PyErr_Print(); return 1; @@ -269,7 +269,7 @@ run_python() { // Get the pointers to the objects needed within the module. PyObject *app_runner_class = PyObject_GetAttrString(app_runner_module, "AppRunner"); - if (app_runner_class == NULL) { + if (app_runner_class == nullptr) { nout << "Failed to get AppRunner class\n"; PyErr_Print(); return 1; @@ -277,7 +277,7 @@ run_python() { // Construct an instance of AppRunner. _runner = PyObject_CallFunction(app_runner_class, (char *)""); - if (_runner == NULL) { + if (_runner == nullptr) { nout << "Failed to construct AppRunner instance\n"; PyErr_Print(); return 1; @@ -286,7 +286,7 @@ run_python() { // Import the JavaScript module. PyObject *javascript_module = PyImport_ImportModule("direct.p3d.JavaScript"); - if (javascript_module == NULL) { + if (javascript_module == nullptr) { nout << "Failed to import direct.p3d.JavaScript\n"; PyErr_Print(); return false; @@ -294,35 +294,35 @@ run_python() { // Get the UndefinedObject class. _undefined_object_class = PyObject_GetAttrString(javascript_module, "UndefinedObject"); - if (_undefined_object_class == NULL) { + if (_undefined_object_class == nullptr) { PyErr_Print(); return 1; } // And the "Undefined" instance. _undefined = PyObject_GetAttrString(javascript_module, "Undefined"); - if (_undefined == NULL) { + if (_undefined == nullptr) { PyErr_Print(); return 1; } // Get the ConcreteStruct class. _concrete_struct_class = PyObject_GetAttrString(javascript_module, "ConcreteStruct"); - if (_concrete_struct_class == NULL) { + if (_concrete_struct_class == nullptr) { PyErr_Print(); return 1; } // Get the BrowserObject class. _browser_object_class = PyObject_GetAttrString(javascript_module, "BrowserObject"); - if (_browser_object_class == NULL) { + if (_browser_object_class == nullptr) { PyErr_Print(); return 1; } // Get the global TaskManager. _taskMgr = PyObject_GetAttrString(app_runner_module, "taskMgr"); - if (_taskMgr == NULL) { + if (_taskMgr == nullptr) { PyErr_Print(); return 1; } @@ -337,28 +337,28 @@ run_python() { "Poll for communications from the parent process" }, { "request_func", P3DPythonRun::st_request_func, METH_VARARGS, "Send an asynchronous request to the plugin host" }, - { NULL, NULL, 0, NULL } /* Sentinel */ + { nullptr, nullptr, 0, nullptr } /* Sentinel */ }; #if PY_MAJOR_VERSION >= 3 static PyModuleDef p3dpython_module = { PyModuleDef_HEAD_INIT, "p3dpython", - NULL, + nullptr, -1, p3dpython_methods, - NULL, NULL, NULL, NULL + nullptr, nullptr, nullptr, nullptr }; PyObject *p3dpython = PyModule_Create(&p3dpython_module); #else PyObject *p3dpython = Py_InitModule("p3dpython", p3dpython_methods); #endif - if (p3dpython == NULL) { + if (p3dpython == nullptr) { PyErr_Print(); return 1; } PyObject *request_func = PyObject_GetAttrString(p3dpython, "request_func"); - if (request_func == NULL) { + if (request_func == nullptr) { PyErr_Print(); return 1; } @@ -366,7 +366,7 @@ run_python() { // Now pass that func pointer back to our AppRunner instance, so it can call // up to us. result = PyObject_CallMethod(_runner, (char *)"setRequestFunc", (char *)"N", request_func); - if (result == NULL) { + if (result == nullptr) { PyErr_Print(); return 1; } @@ -384,7 +384,7 @@ run_python() { chain->set_thread_priority(TP_low); PyObject *check_comm = PyObject_GetAttrString(p3dpython, "check_comm"); - if (check_comm == NULL) { + if (check_comm == nullptr) { PyErr_Print(); return 1; } @@ -392,7 +392,7 @@ run_python() { // Add it to the task manager. We do this instead of constructing a // PythonTask because linking p3dpython with core.pyd is problematic. result = PyObject_CallMethod(_taskMgr, (char *)"add", (char *)"Ns", check_comm, "check_comm"); - if (result == NULL) { + if (result == nullptr) { PyErr_Print(); return 1; } @@ -401,7 +401,7 @@ run_python() { // Finally, get lost in AppRunner.run() (which is really a call to // taskMgr.run()). PyObject *done = PyObject_CallMethod(_runner, (char *)"run", (char *)""); - if (done == NULL) { + if (done == nullptr) { int status = 1; // An uncaught application exception, and not handled by @@ -409,10 +409,10 @@ run_python() { // status that we should return. if (PyErr_ExceptionMatches(PyExc_SystemExit)) { PyObject *ptype, *ptraceback; - PyObject *value = NULL; + PyObject *value = nullptr; PyErr_Fetch(&ptype, &value, &ptraceback); - if (value != NULL && PyExceptionInstance_Check(value)) { + if (value != nullptr && PyExceptionInstance_Check(value)) { PyObject *code = PyObject_GetAttrString(value, "code"); if (code) { Py_DECREF(value); @@ -420,7 +420,7 @@ run_python() { } } - if (value == NULL || value == Py_None) { + if (value == nullptr || value == Py_None) { status = 0; #if PY_MAJOR_VERSION >= 3 } else if (PyLong_Check(value)) { @@ -510,13 +510,13 @@ void P3DPythonRun:: run_interactive_console() { #ifdef _WIN32 // Make sure that control-C support is enabled for the interpreter. - SetConsoleCtrlHandler(NULL, false); + SetConsoleCtrlHandler(nullptr, false); #endif // The "readline" module makes the Python prompt friendlier, with command // history and everything. Simply importing it is sufficient. PyObject *readline_module = PyImport_ImportModule("readline"); - if (readline_module == NULL) { + if (readline_module == nullptr) { // But, the module might not exist on certain platforms. If not, no // sweat. PyErr_Clear(); @@ -536,7 +536,7 @@ run_interactive_console() { void P3DPythonRun:: handle_command(TiXmlDocument *doc) { TiXmlElement *xcommand = doc->FirstChildElement("command"); - if (xcommand != NULL) { + if (xcommand != nullptr) { bool needs_response = false; int want_response_id; if (xcommand->QueryIntAttribute("want_response_id", &want_response_id) == TIXML_SUCCESS) { @@ -545,7 +545,7 @@ handle_command(TiXmlDocument *doc) { } const char *cmd = xcommand->Attribute("cmd"); - if (cmd != NULL) { + if (cmd != nullptr) { if (strcmp(cmd, "init") == 0) { assert(!needs_response); @@ -565,7 +565,7 @@ handle_command(TiXmlDocument *doc) { } else if (strcmp(cmd, "start_instance") == 0) { assert(!needs_response); TiXmlElement *xinstance = xcommand->FirstChildElement("instance"); - if (xinstance != (TiXmlElement *)NULL) { + if (xinstance != nullptr) { P3DCInstance *inst = new P3DCInstance(xinstance); start_instance(inst, xinstance); } @@ -581,7 +581,7 @@ handle_command(TiXmlDocument *doc) { assert(!needs_response); int instance_id; TiXmlElement *xwparams = xcommand->FirstChildElement("wparams"); - if (xwparams != (TiXmlElement *)NULL && + if (xwparams != nullptr && xcommand->QueryIntAttribute("instance_id", &instance_id) == TIXML_SUCCESS) { setup_window(instance_id, xwparams); } @@ -657,11 +657,11 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, doc.LinkEndChild(xresponse); const char *op = xcommand->Attribute("op"); - if (op != NULL && !PyErr_Occurred()) { + if (op != nullptr && !PyErr_Occurred()) { if (strcmp(op, "get_panda_script_object") == 0) { // Get Panda's toplevel Python object. PyObject *obj = PyObject_CallMethod(_runner, (char*)"getPandaScriptObject", (char *)""); - if (obj != NULL) { + if (obj != nullptr) { xresponse->LinkEndChild(pyobj_to_xml(obj)); Py_DECREF(obj); } @@ -670,7 +670,7 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, // Set the Browser's toplevel window object. PyObject *obj; TiXmlElement *xvalue = xcommand->FirstChildElement("value"); - if (xvalue != NULL) { + if (xvalue != nullptr) { obj = xml_to_pyobj(xvalue); } else { obj = Py_None; @@ -684,7 +684,7 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, // Call the named method on the indicated object, or the object itself // if method_name isn't given. TiXmlElement *xobject = xcommand->FirstChildElement("object"); - if (xobject != NULL) { + if (xobject != nullptr) { PyObject *obj = xml_to_pyobj(xobject); const char *method_name = xcommand->Attribute("method_name"); @@ -693,7 +693,7 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, PyObject *list = PyList_New(0); TiXmlElement *xchild = xcommand->FirstChildElement("value"); - while (xchild != NULL) { + while (xchild != nullptr) { PyObject *child = xml_to_pyobj(xchild); PyList_Append(list, child); Py_DECREF(child); @@ -705,8 +705,8 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, Py_DECREF(list); // Now call the method. - PyObject *result = NULL; - if (method_name == NULL) { + PyObject *result = nullptr; + if (method_name == nullptr) { // No method name; call the object directly. result = PyObject_CallObject(obj, params); @@ -811,7 +811,7 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, if (PyObject_HasAttrString(obj, property_name)) { result = PyObject_GetAttrString(obj, property_name); - if (result != NULL) { + if (result != nullptr) { success = true; } else { PyErr_Clear(); @@ -821,7 +821,7 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, if (!success) { if (PyMapping_HasKeyString(obj, property_name)) { result = PyMapping_GetItemString(obj, property_name); - if (result != NULL) { + if (result != nullptr) { success = true; } else { PyErr_Clear(); @@ -830,7 +830,7 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, } if (!success) { - result = NULL; + result = nullptr; } } @@ -859,7 +859,7 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, } else { // Not a special-case name. Call the named method. PyObject *method = PyObject_GetAttrString(obj, (char *)method_name); - if (method != NULL) { + if (method != nullptr) { result = PyObject_CallObject(method, params); Py_DECREF(method); } @@ -867,7 +867,7 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, Py_DECREF(params); // Feed the return value back through the XML pipe to the caller. - if (result != NULL) { + if (result != nullptr) { xresponse->LinkEndChild(pyobj_to_xml(result)); Py_DECREF(result); } else { @@ -948,10 +948,10 @@ wait_script_response(int response_id) { TiXmlDocument *doc = (*ci); TiXmlElement *xcommand = doc->FirstChildElement("command"); - if (xcommand != NULL) { + if (xcommand != nullptr) { const char *cmd = xcommand->Attribute("cmd"); - if ((cmd != NULL && strcmp(cmd, "script_response") == 0) || - xcommand->Attribute("want_response_id") != NULL) { + if ((cmd != nullptr && strcmp(cmd, "script_response") == 0) || + xcommand->Attribute("want_response_id") != nullptr) { // This is either a response, or it's a command that will want a // response itself. In either case we should handle it right away. @@ -960,7 +960,7 @@ wait_script_response(int response_id) { RELEASE_LOCK(_commands_lock); handle_command(doc); if (_session_terminated) { - return NULL; + return nullptr; } ACQUIRE_LOCK(_commands_lock); break; @@ -976,9 +976,9 @@ wait_script_response(int response_id) { TiXmlDocument *doc = (*ci); TiXmlElement *xcommand = doc->FirstChildElement("command"); - assert(xcommand != NULL); + assert(xcommand != nullptr); const char *cmd = xcommand->Attribute("cmd"); - assert(cmd != NULL && strcmp(cmd, "script_response") == 0); + assert(cmd != nullptr && strcmp(cmd, "script_response") == 0); int unique_id; if (xcommand->QueryIntAttribute("unique_id", &unique_id) == TIXML_SUCCESS) { @@ -995,7 +995,7 @@ wait_script_response(int response_id) { if (!_program_continue) { terminate_session(); - return NULL; + return nullptr; } #ifdef _WIN32 @@ -1005,7 +1005,7 @@ wait_script_response(int response_id) { // We appear to be best off with just a single PeekMessage() call here; // the full message pump seems to cause problems. MSG msg; - PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE | PM_NOYIELD); + PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE | PM_NOYIELD); #endif // _WIN32 // nout << "."; @@ -1027,7 +1027,7 @@ py_request_func(PyObject *args) { const char *request_type; PyObject *extra_args; if (!PyArg_ParseTuple(args, "isO", &instance_id, &request_type, &extra_args)) { - return NULL; + return nullptr; } if (strcmp(request_type, "wait_script_response") == 0) { @@ -1035,20 +1035,20 @@ py_request_func(PyObject *args) { // means to wait for a particular script_response to come in on the wire. int response_id; if (!PyArg_ParseTuple(extra_args, "i", &response_id)) { - return NULL; + return nullptr; } TiXmlDocument *doc = wait_script_response(response_id); if (_session_terminated) { return Py_BuildValue(""); } - assert(doc != NULL); + assert(doc != nullptr); TiXmlElement *xcommand = doc->FirstChildElement("command"); - assert(xcommand != NULL); + assert(xcommand != nullptr); TiXmlElement *xvalue = xcommand->FirstChildElement("value"); - PyObject *value = NULL; - if (xvalue != NULL) { + PyObject *value = nullptr; + if (xvalue != nullptr) { value = xml_to_pyobj(xvalue); } else { // An absence of a element is an exception. We will return NULL @@ -1070,7 +1070,7 @@ py_request_func(PyObject *args) { // A general notification to be sent directly to the instance. const char *message; if (!PyArg_ParseTuple(extra_args, "s", &message)) { - return NULL; + return nullptr; } xrequest->SetAttribute("message", message); @@ -1087,7 +1087,7 @@ py_request_func(PyObject *args) { if (!PyArg_ParseTuple(extra_args, "sOsOii", &operation, &object, &property_name, &value, &needs_response, &unique_id)) { - return NULL; + return nullptr; } xrequest->SetAttribute("operation", operation); @@ -1106,7 +1106,7 @@ py_request_func(PyObject *args) { // Release a particular P3D_object that we were holding a reference to. int object_id; if (!PyArg_ParseTuple(extra_args, "i", &object_id)) { - return NULL; + return nullptr; } xrequest->SetAttribute("object_id", object_id); @@ -1119,7 +1119,7 @@ py_request_func(PyObject *args) { const char *package_name; const char *package_version; if (!PyArg_ParseTuple(extra_args, "sss", &host_url, &package_name, &package_version)) { - return NULL; + return nullptr; } xrequest->SetAttribute("host_url", host_url); @@ -1134,7 +1134,7 @@ py_request_func(PyObject *args) { } else { string message = string("Unsupported request type: ") + string(request_type); PyErr_SetString(PyExc_ValueError, message.c_str()); - return NULL; + return nullptr; } return Py_BuildValue(""); @@ -1185,18 +1185,18 @@ start_instance(P3DCInstance *inst, TiXmlElement *xinstance) { set_instance_info(inst, xinstance); TiXmlElement *xpackage = xinstance->FirstChildElement("package"); - while (xpackage != (TiXmlElement *)NULL) { + while (xpackage != nullptr) { add_package_info(inst, xpackage); xpackage = xpackage->NextSiblingElement("package"); } TiXmlElement *xfparams = xinstance->FirstChildElement("fparams"); - if (xfparams != (TiXmlElement *)NULL) { + if (xfparams != nullptr) { set_p3d_filename(inst, xfparams); } TiXmlElement *xwparams = xinstance->FirstChildElement("wparams"); - if (xwparams != (TiXmlElement *)NULL) { + if (xwparams != nullptr) { setup_window(inst, xwparams); } } @@ -1228,12 +1228,12 @@ terminate_instance(int id) { void P3DPythonRun:: set_instance_info(P3DCInstance *inst, TiXmlElement *xinstance) { const char *root_dir = xinstance->Attribute("root_dir"); - if (root_dir == NULL) { + if (root_dir == nullptr) { root_dir = ""; } const char *log_directory = xinstance->Attribute("log_directory"); - if (log_directory == NULL) { + if (log_directory == nullptr) { log_directory = ""; } @@ -1241,14 +1241,14 @@ set_instance_info(P3DCInstance *inst, TiXmlElement *xinstance) { xinstance->Attribute("verify_contents", &verify_contents); const char *super_mirror = xinstance->Attribute("super_mirror"); - if (super_mirror == NULL) { + if (super_mirror == nullptr) { super_mirror = ""; } // Get the initial "main" object, if specified. PyObject *main; TiXmlElement *xmain = xinstance->FirstChildElement("main"); - if (xmain != NULL) { + if (xmain != nullptr) { main = xml_to_pyobj(xmain); } else { main = Py_None; @@ -1262,7 +1262,7 @@ set_instance_info(P3DCInstance *inst, TiXmlElement *xinstance) { (_runner, (char *)"setInstanceInfo", (char *)"sssiNi", root_dir, log_directory, super_mirror, verify_contents, main, respect_per_platform); - if (result == NULL) { + if (result == nullptr) { PyErr_Print(); if (_interactive_console) { run_interactive_console(); @@ -1282,16 +1282,16 @@ add_package_info(P3DCInstance *inst, TiXmlElement *xpackage) { const char *version = xpackage->Attribute("version"); const char *host = xpackage->Attribute("host"); const char *host_dir = xpackage->Attribute("host_dir"); - if (name == NULL || host == NULL) { + if (name == nullptr || host == nullptr) { return; } - if (version == NULL) { + if (version == nullptr) { version = ""; } - if (platform == NULL) { + if (platform == nullptr) { platform = ""; } - if (host_dir == NULL) { + if (host_dir == nullptr) { host_dir = ""; } @@ -1299,7 +1299,7 @@ add_package_info(P3DCInstance *inst, TiXmlElement *xpackage) { (_runner, (char *)"addPackageInfo", (char *)"sssss", name, platform, version, host, host_dir); - if (result == NULL) { + if (result == nullptr) { PyErr_Print(); if (_interactive_console) { run_interactive_console(); @@ -1317,7 +1317,7 @@ void P3DPythonRun:: set_p3d_filename(P3DCInstance *inst, TiXmlElement *xfparams) { string p3d_filename; const char *p3d_filename_c = xfparams->Attribute("p3d_filename"); - if (p3d_filename_c != NULL) { + if (p3d_filename_c != nullptr) { p3d_filename = p3d_filename_c; } @@ -1326,21 +1326,21 @@ set_p3d_filename(P3DCInstance *inst, TiXmlElement *xfparams) { string p3d_url; const char *p3d_url_c = xfparams->Attribute("p3d_url"); - if (p3d_url_c != NULL) { + if (p3d_url_c != nullptr) { p3d_url = p3d_url_c; } PyObject *token_list = PyList_New(0); TiXmlElement *xtoken = xfparams->FirstChildElement("token"); - while (xtoken != NULL) { + while (xtoken != nullptr) { string keyword, value; const char *keyword_c = xtoken->Attribute("keyword"); - if (keyword_c != NULL) { + if (keyword_c != nullptr) { keyword = keyword_c; } const char *value_c = xtoken->Attribute("value"); - if (value_c != NULL) { + if (value_c != nullptr) { value = value_c; } @@ -1354,10 +1354,10 @@ set_p3d_filename(P3DCInstance *inst, TiXmlElement *xfparams) { PyObject *arg_list = PyList_New(0); TiXmlElement *xarg = xfparams->FirstChildElement("arg"); - while (xarg != NULL) { + while (xarg != nullptr) { string value; const char *value_c = xarg->Attribute("value"); - if (value_c != NULL) { + if (value_c != nullptr) { value = value_c; } @@ -1373,7 +1373,7 @@ set_p3d_filename(P3DCInstance *inst, TiXmlElement *xfparams) { token_list, arg_list, inst->get_instance_id(), _interactive_console, p3d_offset, p3d_url.c_str()); - if (result == NULL) { + if (result == nullptr) { PyErr_Print(); if (_interactive_console) { run_interactive_console(); @@ -1405,7 +1405,7 @@ void P3DPythonRun:: setup_window(P3DCInstance *inst, TiXmlElement *xwparams) { string window_type; const char *window_type_c = xwparams->Attribute("window_type"); - if (window_type_c != NULL) { + if (window_type_c != nullptr) { window_type = window_type_c; } @@ -1429,7 +1429,7 @@ setup_window(P3DCInstance *inst, TiXmlElement *xwparams) { // to go through this subprocess-window nonsense. const char *subprocess_window = xwparams->Attribute("subprocess_window"); - if (subprocess_window != NULL) { + if (subprocess_window != nullptr) { Filename filename = Filename::from_os_specific(subprocess_window); parent_window_handle = NativeWindowHandle::make_subprocess(filename); } @@ -1437,7 +1437,7 @@ setup_window(P3DCInstance *inst, TiXmlElement *xwparams) { #elif defined(HAVE_X11) // Use stringstream to decode the "long" attribute. const char *parent_cstr = xwparams->Attribute("parent_xwindow"); - if (parent_cstr != NULL) { + if (parent_cstr != nullptr) { long window; istringstream strm(parent_cstr); strm >> window; @@ -1446,7 +1446,7 @@ setup_window(P3DCInstance *inst, TiXmlElement *xwparams) { #endif PyObject *py_handle = Py_None; - if (parent_window_handle != NULL) { + if (parent_window_handle != nullptr) { // We have a valid parent WindowHandle, but replace it with a // P3DWindowHandle so we can get the callbacks. @@ -1467,7 +1467,7 @@ setup_window(P3DCInstance *inst, TiXmlElement *xwparams) { (_runner, (char *)"setupWindow", (char *)"siiiiN", window_type.c_str(), win_x, win_y, win_width, win_height, py_handle); - if (result == NULL) { + if (result == nullptr) { PyErr_Print(); if (_interactive_console) { run_interactive_console(); @@ -1489,7 +1489,7 @@ send_windows_message(int id, unsigned int msg, int wparam, int lparam) { } P3DCInstance *inst = (*ii).second; - if (inst->_parent_window_handle != (WindowHandle *)NULL) { + if (inst->_parent_window_handle != nullptr) { inst->_parent_window_handle->send_windows_message(msg, wparam, lparam); } } @@ -1507,9 +1507,9 @@ terminate_session() { _instances.clear(); if (!_session_terminated) { - if (_taskMgr != NULL) { + if (_taskMgr != nullptr) { PyObject *result = PyObject_CallMethod(_taskMgr, (char *)"stop", (char *)""); - if (result == NULL) { + if (result == nullptr) { PyErr_Print(); } else { Py_DECREF(result); @@ -1573,13 +1573,13 @@ pyobj_to_xml(PyObject *value) { // function for getting the UTF-8 encoded version. Py_ssize_t length = 0; char *buffer = PyUnicode_AsUTF8AndSize(value, &length); - if (buffer != NULL) { + if (buffer != nullptr) { string str(buffer, length); xvalue->SetAttribute("value", str); } #else PyObject *as_str = PyUnicode_AsUTF8String(value); - if (as_str != NULL) { + if (as_str != nullptr) { char *buffer; Py_ssize_t length; if (PyString_AsStringAndSize(as_str, &buffer, &length) != -1) { @@ -1594,13 +1594,13 @@ pyobj_to_xml(PyObject *value) { // using the standard encoding, then re-encoding it. xvalue->SetAttribute("type", "string"); - PyObject *ustr = PyUnicode_FromEncodedObject(value, NULL, NULL); - if (ustr == NULL) { + PyObject *ustr = PyUnicode_FromEncodedObject(value, nullptr, nullptr); + if (ustr == nullptr) { PyErr_Print(); return xvalue; } else { PyObject *as_str = PyUnicode_AsUTF8String(ustr); - if (as_str != NULL) { + if (as_str != nullptr) { char *buffer; Py_ssize_t length; if (PyString_AsStringAndSize(as_str, &buffer, &length) != -1) { @@ -1620,7 +1620,7 @@ pyobj_to_xml(PyObject *value) { Py_ssize_t length = PySequence_Length(value); for (Py_ssize_t i = 0; i < length; ++i) { PyObject *item = PySequence_GetItem(value, i); - if (item != NULL) { + if (item != nullptr) { xvalue->LinkEndChild(pyobj_to_xml(item)); Py_DECREF(item); } @@ -1631,7 +1631,7 @@ pyobj_to_xml(PyObject *value) { xvalue->SetAttribute("type", "concrete_struct"); PyObject *items = PyObject_CallMethod(value, (char *)"getConcreteProperties", (char *)""); - if (items == NULL) { + if (items == nullptr) { PyErr_Print(); return xvalue; } @@ -1639,11 +1639,11 @@ pyobj_to_xml(PyObject *value) { Py_ssize_t length = PySequence_Length(items); for (Py_ssize_t i = 0; i < length; ++i) { PyObject *item = PySequence_GetItem(items, i); - if (item != NULL) { + if (item != nullptr) { PyObject *a = PySequence_GetItem(item, 0); - if (a != NULL) { + if (a != nullptr) { PyObject *b = PySequence_GetItem(item, 1); - if (b != NULL) { + if (b != nullptr) { TiXmlElement *xitem = pyobj_to_xml(b); Py_DECREF(b); @@ -1664,7 +1664,7 @@ pyobj_to_xml(PyObject *value) { Py_ssize_t length; #if PY_MAJOR_VERSION >= 3 buffer = PyUnicode_AsUTF8AndSize(as_str, &length); - if (buffer != NULL) { + if (buffer != nullptr) { #else if (PyString_AsStringAndSize(as_str, &buffer, &length) != -1) { #endif @@ -1694,7 +1694,7 @@ pyobj_to_xml(PyObject *value) { // This is a BrowserObject, a reference to an object that actually exists // in the host namespace. So, pass up the appropriate object ID. PyObject *objectId = PyObject_GetAttrString(value, (char *)"_BrowserObject__objectId"); - if (objectId != NULL) { + if (objectId != nullptr) { int object_id = PyInt_AsLong(objectId); xvalue->SetAttribute("type", "browser"); xvalue->SetAttribute("object_id", object_id); @@ -1764,8 +1764,8 @@ xml_to_pyobj(TiXmlElement *xvalue) { // Using the string form here instead of the char * form, so we don't get // tripped up on embedded null characters. const string *value = xvalue->Attribute(string("value")); - if (value != NULL) { - return PyUnicode_DecodeUTF8(value->data(), value->length(), NULL); + if (value != nullptr) { + return PyUnicode_DecodeUTF8(value->data(), value->length(), nullptr); } } else if (strcmp(type, "undefined") == 0) { @@ -1785,9 +1785,9 @@ xml_to_pyobj(TiXmlElement *xvalue) { PyObject *list = PyList_New(0); TiXmlElement *xitem = xvalue->FirstChildElement("value"); - while (xitem != NULL) { + while (xitem != nullptr) { PyObject *item = xml_to_pyobj(xitem); - if (item != NULL) { + if (item != nullptr) { PyList_Append(list, item); Py_DECREF(item); } @@ -1802,13 +1802,13 @@ xml_to_pyobj(TiXmlElement *xvalue) { // Receive a concrete struct as a new ConcreteStruct instance. PyObject *obj = PyObject_CallFunction(_concrete_struct_class, (char *)""); - if (obj != NULL) { + if (obj != nullptr) { TiXmlElement *xitem = xvalue->FirstChildElement("value"); - while (xitem != NULL) { + while (xitem != nullptr) { const char *key = xitem->Attribute("key"); - if (key != NULL) { + if (key != nullptr) { PyObject *item = xml_to_pyobj(xitem); - if (item != NULL) { + if (item != nullptr) { PyObject_SetAttrString(obj, (char *)key, item); Py_DECREF(item); } @@ -1847,7 +1847,7 @@ void P3DPythonRun:: rt_thread_run() { while (_read_thread_continue) { TiXmlDocument *doc = read_xml(_pipe_read, nout); - if (doc == NULL) { + if (doc == nullptr) { // Some error on reading. Abort. _program_continue = false; return; @@ -1858,9 +1858,9 @@ rt_thread_run() { // Check for one special case: the "exit" command means we shut down the // read thread along with everything else. TiXmlElement *xcommand = doc->FirstChildElement("command"); - if (xcommand != NULL) { + if (xcommand != nullptr) { const char *cmd = xcommand->Attribute("cmd"); - if (cmd != NULL) { + if (cmd != nullptr) { if (strcmp(cmd, "exit") == 0) { _read_thread_continue = false; } diff --git a/direct/src/plugin/p3dSession.cxx b/direct/src/plugin/p3dSession.cxx index 522936f61a..cb0fb58d78 100644 --- a/direct/src/plugin/p3dSession.cxx +++ b/direct/src/plugin/p3dSession.cxx @@ -143,7 +143,7 @@ shutdown() { #else // _WIN32 // Wait for a certain amount of time for the process to stop by itself. struct timeval start; - gettimeofday(&start, NULL); + gettimeofday(&start, nullptr); int start_ms = start.tv_sec * 1000 + start.tv_usec / 1000; int status; @@ -155,7 +155,7 @@ shutdown() { } struct timeval now; - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); int now_ms = now.tv_sec * 1000 + now.tv_usec / 1000; int elapsed = now_ms - start_ms; @@ -171,7 +171,7 @@ shutdown() { struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 1; - select(0, NULL, NULL, NULL, &tv); + select(0, nullptr, nullptr, nullptr, &tv); result = waitpid(_p3dpython_pid, &status, WNOHANG); } _p3dpython_pid = -1; @@ -227,7 +227,7 @@ shutdown() { */ void P3DSession:: start_instance(P3DInstance *inst) { - assert(inst->_session == NULL); + assert(inst->_session == nullptr); assert(inst->get_session_key() == _session_key); if (_failed) { inst->set_failed(); @@ -279,7 +279,7 @@ terminate_instance(P3DInstance *inst) { if (inst->_session == this) { nout << "Assigning " << inst << "->log_pathname = " << _log_pathname << "\n"; inst->_log_pathname = _log_pathname; - inst->_session = NULL; + inst->_session = nullptr; _instances.erase(inst->get_instance_id()); } RELEASE_LOCK(_instances_lock); @@ -319,7 +319,7 @@ send_command(TiXmlDocument *command) { TiXmlDocument *P3DSession:: command_and_response(TiXmlDocument *command) { if (!_p3dpython_started) { - return NULL; + return nullptr; } P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); @@ -328,7 +328,7 @@ command_and_response(TiXmlDocument *command) { // Add the "want_response_id" attribute to the toplevel command, so the sub- // process knows we'll be waiting for its response. TiXmlElement *xcommand = command->FirstChildElement("command"); - assert(xcommand != NULL); + assert(xcommand != nullptr); xcommand->SetAttribute("want_response_id", response_id); write_xml(_pipe_write, command, nout); @@ -341,7 +341,7 @@ command_and_response(TiXmlDocument *command) { if (!_p3dpython_running) { // Hmm, looks like Python has gone away. _response_ready.release(); - return NULL; + return nullptr; } // Make sure we bake requests while we are waiting, to process recursive @@ -380,7 +380,7 @@ command_and_response(TiXmlDocument *command) { // coming and will block waiting for them. MSG msg; - PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE | PM_NOYIELD); + PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE | PM_NOYIELD); // We wait with a timeout, so we can go back and spin the event loop some // more. On Windows, the timeout needs to be small, so we continue to @@ -444,16 +444,16 @@ xml_to_p3dobj(const TiXmlElement *xvalue) { // Using the string form here instead of the char * form, so we don't get // tripped up on embedded null characters. const string *value = xvalue->Attribute(string("value")); - if (value != NULL) { + if (value != nullptr) { return new P3DStringObject(*value); } } else if (strcmp(type, "concrete_sequence") == 0) { P3DConcreteSequence *obj = new P3DConcreteSequence; const TiXmlElement *xitem = xvalue->FirstChildElement("value"); - while (xitem != NULL) { + while (xitem != nullptr) { P3D_object *item = xml_to_p3dobj(xitem); - if (item != NULL) { + if (item != nullptr) { obj->append(item); P3D_OBJECT_DECREF(item); } @@ -464,11 +464,11 @@ xml_to_p3dobj(const TiXmlElement *xvalue) { } else if (strcmp(type, "concrete_struct") == 0) { P3DConcreteStruct *obj = new P3DConcreteStruct; const TiXmlElement *xitem = xvalue->FirstChildElement("value"); - while (xitem != NULL) { + while (xitem != nullptr) { const char *key = xitem->Attribute("key"); - if (key != NULL) { + if (key != nullptr) { P3D_object *item = xml_to_p3dobj(xitem); - if (item != NULL) { + if (item != nullptr) { obj->set_property(key, item); P3D_OBJECT_DECREF(item); } @@ -539,7 +539,7 @@ p3dobj_to_xml(P3D_object *obj) { case P3D_OT_string: { xvalue->SetAttribute("type", "string"); - int size = P3D_OBJECT_GET_STRING(obj, NULL, 0); + int size = P3D_OBJECT_GET_STRING(obj, nullptr, 0); char *buffer = new char[size]; P3D_OBJECT_GET_STRING(obj, buffer, size); xvalue->SetAttribute("value", string(buffer, size)); @@ -548,12 +548,12 @@ p3dobj_to_xml(P3D_object *obj) { break; case P3D_OT_object: - P3DObject *p3dobj = NULL; + P3DObject *p3dobj = nullptr; if (obj->_class == &P3DObject::_object_class) { p3dobj = (P3DObject *)obj; } - if (p3dobj != NULL && p3dobj->fill_xml(xvalue, this)) { + if (p3dobj != nullptr && p3dobj->fill_xml(xvalue, this)) { // This object has a specialized XML representation, valid for this // particular session. It has already been filled into xvalue. @@ -666,7 +666,7 @@ start_p3dpython(P3DInstance *inst) { return; } - if (inst->_panda3d_package == NULL) { + if (inst->_panda3d_package == nullptr) { nout << "Couldn't start Python: no panda3d dependency.\n"; set_failed(); return; @@ -787,22 +787,22 @@ start_p3dpython(P3DInstance *inst) { string p3dpythonw_exe = _p3dpython_exe + "w"; if (_p3dpython_exe.empty()) { // Allow package to override the name of the p3dpython executables. - const char *p3dpython_name_xconfig = NULL; - const char *p3dpythonw_name_xconfig = NULL; + const char *p3dpython_name_xconfig = nullptr; + const char *p3dpythonw_name_xconfig = nullptr; const TiXmlElement *panda3d_xconfig = inst->_panda3d_package->get_xconfig(); - if (panda3d_xconfig != NULL) { + if (panda3d_xconfig != nullptr) { p3dpython_name_xconfig = panda3d_xconfig->Attribute("p3dpython_name"); p3dpythonw_name_xconfig = panda3d_xconfig->Attribute("p3dpythonw_name"); } string p3dpython_name = "p3dpython"; - if (p3dpython_name_xconfig != NULL) { + if (p3dpython_name_xconfig != nullptr) { nout << "p3dpython_name from panda3d xconfig: " << p3dpython_name_xconfig << "\n"; p3dpython_name = p3dpython_name_xconfig; } string p3dpythonw_name = p3dpython_name + "w"; - if (p3dpythonw_name_xconfig != NULL) { + if (p3dpythonw_name_xconfig != nullptr) { nout << "p3dpythonw_name from panda3d xconfig: " << p3dpythonw_name_xconfig << "\n"; p3dpythonw_name = p3dpythonw_name_xconfig; } @@ -848,9 +848,9 @@ start_p3dpython(P3DInstance *inst) { #ifdef HAVE_X11 "DISPLAY", "XAUTHORITY", #endif - NULL + nullptr }; - for (int ki = 0; keep[ki] != NULL; ++ki) { + for (int ki = 0; keep[ki] != nullptr; ++ki) { string value; if (get_env(value, keep[ki])) { _env += keep[ki]; @@ -867,7 +867,7 @@ start_p3dpython(P3DInstance *inst) { "PATH", "LD_LIBRARY_PATH", "DYLD_LIBRARY_PATH", "PYTHONPATH", "PYTHONHOME", "PRC_PATH", "PANDA_PRC_PATH", "TEMP", "CTPROJS", - NULL + nullptr }; #ifdef _WIN32 @@ -886,14 +886,14 @@ start_p3dpython(P3DInstance *inst) { #endif // _WIN32 char **ep; - for (ep = global_environ; *ep != NULL; ++ep) { + for (ep = global_environ; *ep != nullptr; ++ep) { string env = *ep; size_t equals = env.find('='); if (equals != string::npos) { string var = env.substr(0, equals); const char *varc = var.c_str(); bool found = false; - for (int i = 0; dont_keep[i] != NULL && !found; ++i) { + for (int i = 0; dont_keep[i] != nullptr && !found; ++i) { #ifdef _WIN32 found = (_stricmp(dont_keep[i], varc) == 0); #else @@ -1088,9 +1088,9 @@ start_p3dpython(P3DInstance *inst) { #else tzset(); #endif - time_t log_time_seconds = time(NULL); + time_t log_time_seconds = time(nullptr); struct tm *log_time_local_p = localtime(&log_time_seconds); - if (log_time_local_p != NULL) { + if (log_time_local_p != nullptr) { struct tm log_time_local = *log_time_local_p; static const size_t buffer_size = 16; char buffer[buffer_size]; @@ -1121,7 +1121,7 @@ start_p3dpython(P3DInstance *inst) { HANDLE r_to, w_to, r_from, w_from; // Create the pipe to the process. - if (!CreatePipe(&r_to, &w_to, NULL, 0)) { + if (!CreatePipe(&r_to, &w_to, nullptr, 0)) { nout << "failed to create pipe\n"; set_failed(); } else { @@ -1131,7 +1131,7 @@ start_p3dpython(P3DInstance *inst) { } // Create the pipe from the process. - if (!CreatePipe(&r_from, &w_from, NULL, 0)) { + if (!CreatePipe(&r_from, &w_from, nullptr, 0)) { nout << "failed to create pipe\n"; set_failed(); } else { @@ -1311,7 +1311,7 @@ void P3DSession:: rt_thread_run() { while (_read_thread_continue) { TiXmlDocument *doc = read_xml(_pipe_read, nout); - if (doc == NULL) { + if (doc == nullptr) { // Some error on reading. Abort. rt_terminate(); _p3dpython_running = false; @@ -1335,7 +1335,7 @@ rt_thread_run() { void P3DSession:: rt_handle_request(TiXmlDocument *doc) { TiXmlElement *xresponse = doc->FirstChildElement("response"); - if (xresponse != (TiXmlElement *)NULL) { + if (xresponse != nullptr) { int response_id; if (xresponse->QueryIntAttribute("response_id", &response_id) == TIXML_SUCCESS) { // This is a response to a previous command-and-response. Send it to @@ -1350,7 +1350,7 @@ rt_handle_request(TiXmlDocument *doc) { } TiXmlElement *xrequest = doc->FirstChildElement("request"); - if (xrequest != (TiXmlElement *)NULL) { + if (xrequest != nullptr) { int instance_id; if (xrequest->QueryIntAttribute("instance_id", &instance_id) == TIXML_SUCCESS) { // Look up the particular instance this is related to. @@ -1360,13 +1360,13 @@ rt_handle_request(TiXmlDocument *doc) { if (ii != _instances.end()) { P3DInstance *inst = (*ii).second; inst->add_raw_request(doc); - doc = NULL; + doc = nullptr; } RELEASE_LOCK(_instances_lock); } } - if (doc != NULL) { + if (doc != nullptr) { delete doc; } } @@ -1418,7 +1418,7 @@ win_create_process() { HANDLE handle = CreateFileW (log_pathname_w.c_str(), GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, CREATE_ALWAYS, 0, NULL); + nullptr, CREATE_ALWAYS, 0, nullptr); if (handle != INVALID_HANDLE_VALUE) { error_handle = handle; SetHandleInformation(error_handle, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT); @@ -1447,7 +1447,7 @@ win_create_process() { const wchar_t *start_dir_cstr; wstring start_dir_w; if (_keep_user_env) { - start_dir_cstr = NULL; + start_dir_cstr = nullptr; nout << "Not changing working directory.\n"; } else { string_to_wstring(start_dir_w, _start_dir); @@ -1479,7 +1479,7 @@ win_create_process() { PROCESS_INFORMATION process_info; BOOL result = CreateProcessW - (p3dpython_exe_w.c_str(), command_line, NULL, NULL, TRUE, + (p3dpython_exe_w.c_str(), command_line, nullptr, nullptr, TRUE, CREATE_UNICODE_ENVIRONMENT, (void *)env_w.c_str(), start_dir_cstr, &startup_info, &process_info); bool started_program = (result != 0); @@ -1577,7 +1577,7 @@ posix_create_process() { p = zero + 1; zero = _env.find('\0', p); } - ptrs.push_back((char *)NULL); + ptrs.push_back(nullptr); stringstream input_handle_stream; input_handle_stream << _input_handle; @@ -1605,7 +1605,7 @@ posix_create_process() { // program" message. Maybe I'll put in the more reliable test later. struct timeval start; - gettimeofday(&start, NULL); + gettimeofday(&start, nullptr); int start_ms = start.tv_sec * 1000 + start.tv_usec / 1000; int status; @@ -1617,7 +1617,7 @@ posix_create_process() { } struct timeval now; - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); int now_ms = now.tv_sec * 1000 + now.tv_usec / 1000; int elapsed = now_ms - start_ms; if (elapsed > 100) { @@ -1631,7 +1631,7 @@ posix_create_process() { struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 1; - select(0, NULL, NULL, NULL, &tv); + select(0, nullptr, nullptr, nullptr, &tv); result = waitpid(child, &status, WNOHANG); } @@ -1684,7 +1684,7 @@ p3dpython_thread_run() { _putenv(start); #else const char *equals = strchr(start, '='); - if (equals != NULL) { + if (equals != nullptr) { string variable(start, equals - start); setenv(variable.c_str(), equals + 1, true); } @@ -1703,7 +1703,7 @@ p3dpython_thread_run() { #endif SetErrorMode(0); HMODULE module = LoadLibrary(libp3dpython.c_str()); - if (module == NULL) { + if (module == nullptr) { // Couldn't load the DLL. nout << "Couldn't load " << libp3dpython << "\n"; return; @@ -1719,7 +1719,7 @@ p3dpython_thread_run() { libp3dpython += ".so"; #endif void *module = dlopen(libp3dpython.c_str(), RTLD_LAZY | RTLD_LOCAL); - if (module == NULL) { + if (module == nullptr) { // Couldn't load the .so. nout << "Couldn't load " << libp3dpython << "\n"; return; @@ -1730,7 +1730,7 @@ p3dpython_thread_run() { #endif // _WIN32 run_p3dpython_func *run_p3dpython = (run_p3dpython_func *)get_func(module, "run_p3dpython"); - if (run_p3dpython == NULL) { + if (run_p3dpython == nullptr) { nout << "Couldn't find run_p3dpython\n"; return; } @@ -1755,14 +1755,14 @@ get_env(string &value, const string &varname) { wstring varname_w; string_to_wstring(varname_w, varname); const wchar_t *vc = _wgetenv(varname_w.c_str()); - if (vc == NULL) { + if (vc == nullptr) { return false; } wstring_to_string(value, vc); return true; #else // _WIN32 const char *vc = getenv(varname.c_str()); - if (vc == NULL) { + if (vc == nullptr) { return false; } value = vc; diff --git a/direct/src/plugin/p3dSplashWindow.cxx b/direct/src/plugin/p3dSplashWindow.cxx index dc17b5c95a..2660cb2b3e 100644 --- a/direct/src/plugin/p3dSplashWindow.cxx +++ b/direct/src/plugin/p3dSplashWindow.cxx @@ -348,10 +348,10 @@ read_image_data(ImageData &image, string &data, unsigned char *imgdata = stbi_load(image_filename.c_str(), &image._width, &image._height, &image._num_channels, 0); - if (imgdata == NULL) { + if (imgdata == nullptr) { nout << "Couldn't read splash file image: " << image_filename << "\n"; const char *reason = stbi_failure_reason(); - if (reason != NULL) { + if (reason != nullptr) { nout << "stbi_failure_reason: " << reason << "\n"; } return false; @@ -492,7 +492,7 @@ set_mouse_data(int mouse_x, int mouse_y, bool mouse_down) { */ void P3DSplashWindow:: button_click_detected() { - assert(_inst != NULL); + assert(_inst != nullptr); nout << "Play button clicked by user\n"; _inst->splash_button_clicked_sub_thread(); } diff --git a/direct/src/plugin/p3dWinSplashWindow.I b/direct/src/plugin/p3dWinSplashWindow.I index 20cafcc1bf..bae5fb0680 100644 --- a/direct/src/plugin/p3dWinSplashWindow.I +++ b/direct/src/plugin/p3dWinSplashWindow.I @@ -17,7 +17,7 @@ inline P3DWinSplashWindow::WinImageData:: WinImageData() { _filename_changed = false; - _bitmap = NULL; + _bitmap = nullptr; } /** diff --git a/direct/src/plugin/p3dWinSplashWindow.cxx b/direct/src/plugin/p3dWinSplashWindow.cxx index eb4d242430..5cc189b31c 100644 --- a/direct/src/plugin/p3dWinSplashWindow.cxx +++ b/direct/src/plugin/p3dWinSplashWindow.cxx @@ -28,14 +28,14 @@ P3DWinSplashWindow:: P3DWinSplashWindow(P3DInstance *inst, bool make_visible) : P3DSplashWindow(inst, make_visible) { - _thread = NULL; + _thread = nullptr; _thread_id = 0; - _hwnd = NULL; - _font = NULL; - _fg_brush = NULL; - _bg_brush = NULL; - _bar_brush = NULL; - _bar_bg_brush = NULL; + _hwnd = nullptr; + _font = nullptr; + _fg_brush = nullptr; + _bg_brush = nullptr; + _bar_brush = nullptr; + _bar_bg_brush = nullptr; _thread_running = false; _install_progress = 0.0; _progress_known = true; @@ -97,7 +97,7 @@ set_visible(bool visible) { void P3DWinSplashWindow:: set_image_filename(const string &image_filename, ImagePlacement image_placement) { nout << "image_filename = " << image_filename << ", thread_id = " << _thread_id << "\n"; - WinImageData *image = NULL; + WinImageData *image = nullptr; switch (image_placement) { case IP_background: image = &_background_image; @@ -116,7 +116,7 @@ set_image_filename(const string &image_filename, ImagePlacement image_placement) image = &_button_click_image; break; } - if (image != NULL) { + if (image != nullptr) { ACQUIRE_LOCK(_install_lock); if (image->_filename != image_filename) { image->_filename = image_filename; @@ -211,13 +211,13 @@ request_keyboard_focus() { void P3DWinSplashWindow:: register_window_class() { if (!_registered_window_class) { - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); WNDCLASS wc; ZeroMemory(&wc, sizeof(WNDCLASS)); wc.lpfnWndProc = (WNDPROC)st_window_proc; wc.hInstance = application; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hCursor = LoadCursor(nullptr, IDC_ARROW); wc.lpszClassName = "panda3d_splash"; if (!RegisterClass(&wc)) { @@ -234,7 +234,7 @@ register_window_class() { void P3DWinSplashWindow:: unregister_window_class() { if (_registered_window_class) { - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); if (!UnregisterClass("panda3d_splash", application)) { nout << "Could not unregister window class panda3d_splash\n"; @@ -261,8 +261,8 @@ void P3DWinSplashWindow:: start_thread() { _thread_continue = true; _thread_running = true; - _thread = CreateThread(NULL, 0, &win_thread_run, this, 0, &_thread_id); - if (_thread == NULL) { + _thread = CreateThread(nullptr, 0, &win_thread_run, this, 0, &_thread_id); + if (_thread == nullptr) { // Thread never got started. _thread_running = false; } @@ -280,17 +280,17 @@ stop_thread() { PostThreadMessage(_thread_id, WM_USER, 0, 0); } - if (_thread != NULL){ + if (_thread != nullptr){ // If the thread doesn't close right away, call PeekMessage() to check for // Windows messages that the thread might be waiting for. while (WaitForSingleObject(_thread, 200) == WAIT_TIMEOUT) { MSG msg; - PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE | PM_NOYIELD); + PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE | PM_NOYIELD); nout << "Waiting for thread\n"; } CloseHandle(_thread); - _thread = NULL; + _thread = nullptr; // Now that the thread has exited, we can safely close its window. (We // couldn't close the window in the thread, because that would cause a @@ -310,7 +310,7 @@ thread_run() { int last_focus_seq = 0; MSG msg; int retval; - retval = GetMessage(&msg, NULL, 0, 0); + retval = GetMessage(&msg, nullptr, 0, 0); while (retval != 0 && _thread_continue) { if (retval == -1) { nout << "Error processing message queue.\n"; @@ -329,7 +329,7 @@ thread_run() { if (_drawn_label != _install_label) { // The label has changed. Redraw. _drawn_label = _install_label; - InvalidateRect(_hwnd, NULL, TRUE); + InvalidateRect(_hwnd, nullptr, TRUE); } // Also redraw when the progress bar changes. @@ -349,25 +349,25 @@ thread_run() { _drawn_progress = _install_progress; _drawn_progress_known = _progress_known; _drawn_received_data = _received_data; - InvalidateRect(_hwnd, NULL, TRUE); + InvalidateRect(_hwnd, nullptr, TRUE); } if (_drawn_bstate != _bstate) { // The button has changed state. Redraw it. _drawn_bstate = _bstate; - InvalidateRect(_hwnd, NULL, TRUE); + InvalidateRect(_hwnd, nullptr, TRUE); } if (_focus_seq != last_focus_seq) { last_focus_seq = _focus_seq; - if (SetFocus(_hwnd) == NULL && GetLastError() != 0) { + if (SetFocus(_hwnd) == nullptr && GetLastError() != 0) { nout << "SetFocus(" << _hwnd << ") failed: " << GetLastError() << "\n"; } } RELEASE_LOCK(_install_lock); - retval = GetMessage(&msg, NULL, 0, 0); + retval = GetMessage(&msg, nullptr, 0, 0); } // Tell our parent thread that we're done. @@ -392,7 +392,7 @@ win_thread_run(LPVOID data) { void P3DWinSplashWindow:: make_window() { register_window_class(); - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); int width = 320; int height = 240; @@ -420,7 +420,7 @@ make_window() { _hwnd = CreateWindow("panda3d_splash", "Panda3D", window_style, x, y, width, height, - parent_hwnd, NULL, application, 0); + parent_hwnd, nullptr, application, 0); if (!_hwnd) { nout << "Could not create embedded window!\n"; @@ -442,7 +442,7 @@ make_window() { x, y, win_rect.right - win_rect.left, win_rect.bottom - win_rect.top, - NULL, NULL, application, 0); + nullptr, nullptr, application, 0); if (!_hwnd) { nout << "Could not create toplevel window!\n"; return; @@ -463,7 +463,7 @@ make_window() { ANSI_CHARSET, OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, VARIABLE_PITCH, _font_family.c_str()); - if (_font == NULL) { + if (_font == nullptr) { nout << "CreateFont failed: " << GetLastError() << "\n"; _font = (HFONT)GetStockObject(ANSI_VAR_FONT); } @@ -490,7 +490,7 @@ update_image(WinImageData &image) { image.dump_image(); // Since we'll be displaying a new image, we need to refresh the window. - InvalidateRect(_hwnd, NULL, TRUE); + InvalidateRect(_hwnd, nullptr, TRUE); // Go read the image. string data; @@ -583,27 +583,27 @@ update_image(WinImageData &image) { */ void P3DWinSplashWindow:: close_window() { - if (_hwnd != NULL) { + if (_hwnd != nullptr) { ShowWindow(_hwnd, SW_HIDE); CloseWindow(_hwnd); - _hwnd = NULL; + _hwnd = nullptr; } - if (_fg_brush != NULL) { + if (_fg_brush != nullptr) { DeleteObject(_fg_brush); - _fg_brush = NULL; + _fg_brush = nullptr; } - if (_bg_brush != NULL) { + if (_bg_brush != nullptr) { DeleteObject(_bg_brush); - _bg_brush = NULL; + _bg_brush = nullptr; } - if (_bar_brush != NULL) { + if (_bar_brush != nullptr) { DeleteObject(_bar_brush); - _bar_brush = NULL; + _bar_brush = nullptr; } - if (_bar_bg_brush != NULL) { + if (_bar_bg_brush != nullptr) { DeleteObject(_bar_bg_brush); - _bar_bg_brush = NULL; + _bar_bg_brush = nullptr; } _background_image.dump_image(); @@ -677,7 +677,7 @@ paint_window(HDC dc) { */ bool P3DWinSplashWindow:: paint_image(HDC dc, const WinImageData &image, bool use_alpha) { - if (image._bitmap == NULL) { + if (image._bitmap == nullptr) { return false; } @@ -738,7 +738,7 @@ paint_image(HDC dc, const WinImageData &image, bool use_alpha) { } } - SelectObject(mem_dc, NULL); + SelectObject(mem_dc, nullptr); DeleteDC(mem_dc); return true; @@ -831,7 +831,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { break; case WM_SIZE: - InvalidateRect(hwnd, NULL, FALSE); + InvalidateRect(hwnd, nullptr, FALSE); break; case WM_ERASEBKGND: @@ -869,7 +869,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { { int elapsed = GetTickCount() - _request_focus_tick; if (elapsed < 200) { - if (SetFocus(_hwnd) == NULL && GetLastError() != 0) { + if (SetFocus(_hwnd) == nullptr && GetLastError() != 0) { nout << "Secondary SetFocus failed: " << GetLastError() << "\n"; } } @@ -889,7 +889,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { case WM_KEYDOWN: case WM_SYSKEYUP: case WM_KEYUP: - if (_inst->get_session() != NULL) { + if (_inst->get_session() != nullptr) { _inst->get_session()->send_windows_message(_inst, msg, wparam, lparam); } break; @@ -904,7 +904,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { LRESULT P3DWinSplashWindow:: st_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { LONG_PTR self = GetWindowLongPtr(hwnd, GWLP_USERDATA); - if (self == NULL) { + if (self == nullptr) { // We haven't assigned the pointer yet. return DefWindowProc(hwnd, msg, wparam, lparam); } @@ -917,9 +917,9 @@ st_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { */ void P3DWinSplashWindow::WinImageData:: dump_image() { - if (_bitmap != NULL) { + if (_bitmap != nullptr) { DeleteObject(_bitmap); - _bitmap = NULL; + _bitmap = nullptr; } } diff --git a/direct/src/plugin/p3dX11SplashWindow.cxx b/direct/src/plugin/p3dX11SplashWindow.cxx index 8be0edb050..2e1bbcb66e 100644 --- a/direct/src/plugin/p3dX11SplashWindow.cxx +++ b/direct/src/plugin/p3dX11SplashWindow.cxx @@ -39,12 +39,12 @@ P3DX11SplashWindow(P3DInstance *inst, bool make_visible) : INIT_THREAD(_read_thread); // Init for subprocess - _composite_image = NULL; + _composite_image = nullptr; _needs_new_composite = false; _display = None; _window = None; _screen = 0; - _font = NULL; + _font = nullptr; _graphics_context = None; _bar_context = None; _bar_bg_context = None; @@ -285,7 +285,7 @@ stop_subprocess() { // Wait for a certain amount of time for the process to stop by itself. struct timeval start; - gettimeofday(&start, NULL); + gettimeofday(&start, nullptr); int start_ms = start.tv_sec * 1000 + start.tv_usec / 1000; int status; @@ -297,7 +297,7 @@ stop_subprocess() { } struct timeval now; - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); int now_ms = now.tv_sec * 1000 + now.tv_usec / 1000; int elapsed = now_ms - start_ms; @@ -313,7 +313,7 @@ stop_subprocess() { struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 1; - select(0, NULL, NULL, NULL, &tv); + select(0, nullptr, nullptr, nullptr, &tv); result = waitpid(_subprocess_pid, &status, WNOHANG); } @@ -406,7 +406,7 @@ void P3DX11SplashWindow:: rt_thread_run() { while (true) { TiXmlDocument *doc = read_xml(_pipe_read, nout); - if (doc == NULL) { + if (doc == nullptr) { // Some error on reading. The splash window must have gone away, e.g. // because the user explicitly closed it; tell the instance to exit. _inst->request_stop_sub_thread(); @@ -648,7 +648,7 @@ subprocess_run() { tv.tv_sec = 0; tv.tv_usec = 1000; // 1 usec is not enough. - int result = select(read_fd + 1, &fds, NULL, NULL, &tv); + int result = select(read_fd + 1, &fds, nullptr, nullptr, &tv); if (result > 0) { // There is some noise on the pipe, so read it. input_ready = true; @@ -668,7 +668,7 @@ subprocess_run() { struct timespec req; req.tv_sec = 0; req.tv_nsec = 50000000; // 50 ms - nanosleep(&req, NULL); + nanosleep(&req, nullptr); } close_window(); @@ -680,22 +680,22 @@ subprocess_run() { void P3DX11SplashWindow:: receive_command() { TiXmlDocument *doc = read_xml(_pipe_read, nout); - if (doc == NULL) { + if (doc == nullptr) { // Pipe closed or something. _subprocess_continue = false; return; } TiXmlElement *xcommand = doc->FirstChildElement("command"); - if (xcommand != NULL) { + if (xcommand != nullptr) { const char *cmd = xcommand->Attribute("cmd"); - if (cmd != NULL) { + if (cmd != nullptr) { if (strcmp(cmd, "exit") == 0) { _subprocess_continue = false; } else if (strcmp(cmd, "set_visible") == 0) { int visible = 0; - if (xcommand->Attribute("visible", &visible) != NULL) { + if (xcommand->Attribute("visible", &visible) != nullptr) { _visible = visible; if (_visible) { XMapWindow(_display, _window); @@ -707,10 +707,10 @@ receive_command() { } else if (strcmp(cmd, "set_image_filename") == 0) { const string *image_filename = xcommand->Attribute(string("image_filename")); int image_placement; - if (image_filename != NULL && + if (image_filename != nullptr && xcommand->QueryIntAttribute("image_placement", &image_placement) == TIXML_SUCCESS) { - X11ImageData *image = NULL; + X11ImageData *image = nullptr; switch ((ImagePlacement)image_placement) { case IP_background: image = &_background_image; @@ -732,7 +732,7 @@ receive_command() { case IP_none: break; } - if (image != NULL) { + if (image != nullptr) { if (image->_filename != *image_filename) { image->_filename = *image_filename; image->_filename_changed = true; @@ -742,7 +742,7 @@ receive_command() { } else if (strcmp(cmd, "set_install_label") == 0) { const char *str = xcommand->Attribute("install_label"); - if (str != NULL) { + if (str != nullptr) { if (_install_label != string(str)) { _install_label = str; } @@ -775,7 +775,7 @@ receive_command() { */ void P3DX11SplashWindow:: redraw() { - if (_composite_image == NULL) { + if (_composite_image == nullptr) { // Clear the whole window, if there's no image. XClearWindow(_display, _window); @@ -823,10 +823,10 @@ make_window() { // _display = (X11_Display*) _wparams.get_parent_window()._xdisplay; // _own_display = false; if (_display == 0) { - _display = XOpenDisplay(NULL); + _display = XOpenDisplay(nullptr); _own_display = true; // } - assert(_display != NULL); + assert(_display != nullptr); _screen = DefaultScreen(_display); int x = _wparams.get_win_x(); @@ -972,7 +972,7 @@ setup_gc() { _font_family.c_str(), weight_name, style, _font_size); _font = XLoadQueryFont(_display, font_name); - if (_font != NULL) { + if (_font != nullptr) { break; } nout << "Font " << font_name << " unavailable.\n"; @@ -984,14 +984,14 @@ setup_gc() { _font_family.c_str(), weight_name, style2, _font_size); _font = XLoadQueryFont(_display, font_name); - if (_font != NULL) { + if (_font != nullptr) { break; } nout << "Font " << font_name << " unavailable.\n"; } } - if (_font != NULL) { + if (_font != nullptr) { nout << "Loaded font " << font_name << "\n"; } else { nout << "Using fallback font 6x13.\n"; @@ -1054,9 +1054,9 @@ setup_gc() { */ void P3DX11SplashWindow:: close_window() { - if (_composite_image != NULL) { + if (_composite_image != nullptr) { XDestroyImage(_composite_image); - _composite_image = NULL; + _composite_image = nullptr; } if (_bar_context != None) { @@ -1136,9 +1136,9 @@ update_image(X11ImageData &image) { */ void P3DX11SplashWindow:: compose_image() { - if (_composite_image != NULL) { + if (_composite_image != nullptr) { XDestroyImage(_composite_image); - _composite_image = NULL; + _composite_image = nullptr; } _needs_new_composite = false; diff --git a/direct/src/plugin/p3d_lock.h b/direct/src/plugin/p3d_lock.h index ed923de304..7c11ca5bb4 100644 --- a/direct/src/plugin/p3d_lock.h +++ b/direct/src/plugin/p3d_lock.h @@ -44,15 +44,15 @@ public: // Threads. #define THREAD HANDLE -#define INIT_THREAD(thread) (thread) = NULL; +#define INIT_THREAD(thread) (thread) = nullptr; #define SPAWN_THREAD(thread, callback_function, this) \ - (thread) = CreateThread(NULL, 0, &win_ ## callback_function, (this), 0, NULL) + (thread) = CreateThread(nullptr, 0, &win_ ## callback_function, (this), 0, nullptr) #define JOIN_THREAD(thread) \ { \ - assert((thread) != NULL); \ + assert((thread) != nullptr); \ WaitForSingleObject((thread), INFINITE); \ CloseHandle((thread)); \ - (thread) = NULL; \ + (thread) = nullptr; \ } // Declare this macro within your class declaration. This implements the @@ -115,7 +115,7 @@ public: static void * \ posix_ ## callback_function(void *data) { \ ((class *)data)->callback_function(); \ - return NULL; \ + return nullptr; \ } #endif // _WIN32 diff --git a/direct/src/plugin/p3d_plugin.cxx b/direct/src/plugin/p3d_plugin.cxx index 8fc91c881e..5cddf55b31 100644 --- a/direct/src/plugin/p3d_plugin.cxx +++ b/direct/src/plugin/p3d_plugin.cxx @@ -61,35 +61,35 @@ P3D_initialize(int api_version, const char *contents_filename, } ACQUIRE_LOCK(_api_lock); - if (contents_filename == NULL){ + if (contents_filename == nullptr){ contents_filename = ""; } - if (host_url == NULL){ + if (host_url == nullptr){ host_url = ""; } - if (platform == NULL) { + if (platform == nullptr) { platform = ""; } - if (log_directory == NULL) { + if (log_directory == nullptr) { log_directory = ""; } - if (log_basename == NULL) { + if (log_basename == nullptr) { log_basename = ""; } - if (api_version < 12 || root_dir == NULL) { + if (api_version < 12 || root_dir == nullptr) { root_dir = ""; } - if (api_version < 16 || host_dir == NULL) { + if (api_version < 16 || host_dir == nullptr) { host_dir = ""; } - if (api_version < 17 || start_dir == NULL) { + if (api_version < 17 || start_dir == nullptr) { start_dir = ""; } @@ -116,10 +116,10 @@ P3D_set_plugin_version(int major, int minor, int sequence, const char *coreapi_timestamp_str, const char *coreapi_set_ver) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); - if (distributor == NULL) { + if (distributor == nullptr) { distributor = ""; } - if (coreapi_host_url == NULL) { + if (coreapi_host_url == nullptr) { coreapi_host_url = ""; } @@ -133,10 +133,10 @@ P3D_set_plugin_version(int major, int minor, int sequence, } else { // Passing a time_t causes problems with disagreements about word size, so // since version 15 we pass it as a string. - coreapi_timestamp = strtoul(coreapi_timestamp_str, NULL, 10); + coreapi_timestamp = strtoul(coreapi_timestamp_str, nullptr, 10); } - if (inst_mgr->get_api_version() < 14 || coreapi_set_ver == NULL) { + if (inst_mgr->get_api_version() < 14 || coreapi_set_ver == nullptr) { // Prior to version 14 this parameter was absent. coreapi_set_ver = ""; } @@ -150,7 +150,7 @@ P3D_set_plugin_version(int major, int minor, int sequence, void P3D_set_super_mirror(const char *super_mirror_url) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); - if (super_mirror_url == NULL) { + if (super_mirror_url == nullptr) { super_mirror_url = ""; } @@ -177,7 +177,7 @@ bool P3D_instance_start(P3D_instance *instance, bool is_local, const char *p3d_filename, int p3d_offset) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); - if (p3d_filename == NULL) { + if (p3d_filename == nullptr) { p3d_filename = ""; } ACQUIRE_LOCK(_api_lock); @@ -190,7 +190,7 @@ P3D_instance_start(P3D_instance *instance, bool is_local, P3DInstance *inst = inst_mgr->validate_instance(instance); bool result = false; - if (inst != NULL) { + if (inst != nullptr) { // We don't actually start it immediately; the instance will have to // download the p3d url and read it, reading the python version, before it // can start. @@ -204,14 +204,14 @@ P3D_instance_start(P3D_instance *instance, bool is_local, int P3D_instance_start_stream(P3D_instance *instance, const char *p3d_url) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); - if (p3d_url == NULL) { + if (p3d_url == nullptr) { p3d_url = ""; } ACQUIRE_LOCK(_api_lock); P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DInstance *inst = inst_mgr->validate_instance(instance); int result = -1; - if (inst != NULL) { + if (inst != nullptr) { result = inst_mgr->make_p3d_stream(inst, p3d_url); } RELEASE_LOCK(_api_lock); @@ -224,7 +224,7 @@ P3D_instance_finish(P3D_instance *instance) { ACQUIRE_LOCK(_api_lock); P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DInstance *inst = inst_mgr->validate_instance(instance); - if (inst != NULL) { + if (inst != nullptr) { inst_mgr->finish_instance(inst); } RELEASE_LOCK(_api_lock); @@ -243,7 +243,7 @@ P3D_instance_setup_window(P3D_instance *instance, ACQUIRE_LOCK(_api_lock); P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DInstance *inst = inst_mgr->validate_instance(instance); - if (inst != NULL) { + if (inst != nullptr) { inst->set_wparams(wparams); } RELEASE_LOCK(_api_lock); @@ -356,7 +356,7 @@ P3D_object_eval(P3D_object *object, const char *expression) { void P3D_object_incref(P3D_object *object) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); - if (object != NULL) { + if (object != nullptr) { ACQUIRE_LOCK(_api_lock); P3D_OBJECT_INCREF(object); RELEASE_LOCK(_api_lock); @@ -366,7 +366,7 @@ P3D_object_incref(P3D_object *object) { void P3D_object_decref(P3D_object *object) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); - if (object != NULL) { + if (object != nullptr) { ACQUIRE_LOCK(_api_lock); P3D_OBJECT_DECREF(object); RELEASE_LOCK(_api_lock); @@ -461,8 +461,8 @@ P3D_instance_get_panda_script_object(P3D_instance *instance) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DInstance *inst = inst_mgr->validate_instance(instance); - P3D_object *result = NULL; - if (inst != NULL) { + P3D_object *result = nullptr; + if (inst != nullptr) { result = inst->get_panda_script_object(); } @@ -478,7 +478,7 @@ P3D_instance_set_browser_script_object(P3D_instance *instance, P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DInstance *inst = inst_mgr->validate_instance(instance); - if (inst != NULL) { + if (inst != nullptr) { inst->set_browser_script_object(object); } @@ -493,8 +493,8 @@ P3D_instance_get_request(P3D_instance *instance) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DInstance *inst = inst_mgr->validate_instance(instance); - P3D_request *result = NULL; - if (inst != NULL) { + P3D_request *result = nullptr; + if (inst != nullptr) { result = inst->get_request(); } @@ -509,7 +509,7 @@ P3D_check_request(double timeout) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3D_instance *inst = inst_mgr->check_request(); - if (inst != NULL || timeout <= 0.0) { + if (inst != nullptr || timeout <= 0.0) { RELEASE_LOCK(_api_lock); return inst; } @@ -518,7 +518,7 @@ P3D_check_request(double timeout) { int stop_tick = int(GetTickCount() + timeout * 1000.0); #else struct timeval stop_time; - gettimeofday(&stop_time, NULL); + gettimeofday(&stop_time, nullptr); int seconds = (int)floor(timeout); stop_time.tv_sec += seconds; @@ -535,7 +535,7 @@ P3D_check_request(double timeout) { ACQUIRE_LOCK(_api_lock); inst = inst_mgr->check_request(); - while (inst == NULL && inst_mgr->get_num_instances() != 0) { + while (inst == nullptr && inst_mgr->get_num_instances() != 0) { #ifdef _WIN32 int remaining_ticks = stop_tick - GetTickCount(); if (remaining_ticks <= 0) { @@ -544,7 +544,7 @@ P3D_check_request(double timeout) { timeout = remaining_ticks * 0.001; #else struct timeval now; - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); struct timeval remaining; remaining.tv_sec = stop_time.tv_sec - now.tv_sec; @@ -574,7 +574,7 @@ void P3D_request_finish(P3D_request *request, bool handled) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); ACQUIRE_LOCK(_api_lock); - if (request != (P3D_request *)NULL) { + if (request != nullptr) { P3DInstance::finish_request(request, handled); } RELEASE_LOCK(_api_lock); @@ -593,7 +593,7 @@ P3D_instance_feed_url_stream(P3D_instance *instance, int unique_id, P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DInstance *inst = inst_mgr->validate_instance(instance); bool result = false; - if (inst != NULL) { + if (inst != nullptr) { result = inst-> feed_url_stream(unique_id, result_code, http_status_code, total_expected_data, @@ -613,7 +613,7 @@ P3D_instance_handle_event(P3D_instance *instance, P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DInstance *inst = inst_mgr->validate_instance(instance); bool result = false; - if (inst != NULL) { + if (inst != nullptr) { result = inst->handle_event(*event); } diff --git a/direct/src/plugin/p3d_plugin.h b/direct/src/plugin/p3d_plugin.h index 6df6e281fc..1d7866e05c 100644 --- a/direct/src/plugin/p3d_plugin.h +++ b/direct/src/plugin/p3d_plugin.h @@ -633,7 +633,7 @@ struct _P3D_object { #define P3D_OBJECT_INCREF(object) (++(object)->_ref_count) #define P3D_OBJECT_DECREF(object) { if (--(object)->_ref_count <= 0) { (object)->_class->_finish((object)); } } -#define P3D_OBJECT_XDECREF(object) { if ((object) != (P3D_object *)NULL) { P3D_OBJECT_DECREF(object); } } +#define P3D_OBJECT_XDECREF(object) { if ((object) != nullptr) { P3D_OBJECT_DECREF(object); } } /* End of method pointer definitions. The following function types are once again meant to define actual function pointers to be found diff --git a/direct/src/plugin/p3d_plugin_common.h b/direct/src/plugin/p3d_plugin_common.h index 244ac70925..538f69f466 100644 --- a/direct/src/plugin/p3d_plugin_common.h +++ b/direct/src/plugin/p3d_plugin_common.h @@ -46,7 +46,7 @@ extern LOCK _api_lock; // A convenience function for formatting a generic P3D_object to an ostream. inline ostream & operator << (ostream &out, P3D_object &value) { - int size = P3D_OBJECT_GET_REPR(&value, NULL, 0); + int size = P3D_OBJECT_GET_REPR(&value, nullptr, 0); char *buffer = new char[size]; P3D_OBJECT_GET_REPR(&value, buffer, size); out.write(buffer, size); diff --git a/direct/src/plugin/run_p3dpython.cxx b/direct/src/plugin/run_p3dpython.cxx index abbaa92730..1a0432a2d4 100644 --- a/direct/src/plugin/run_p3dpython.cxx +++ b/direct/src/plugin/run_p3dpython.cxx @@ -28,6 +28,6 @@ run_p3dpython(const char *program_name, const char *archive_file, log_pathname, interactive_console); int result = P3DPythonRun::_global_ptr->run_python(); delete P3DPythonRun::_global_ptr; - P3DPythonRun::_global_ptr = NULL; + P3DPythonRun::_global_ptr = nullptr; return result; } diff --git a/direct/src/plugin/wstring_encode.cxx b/direct/src/plugin/wstring_encode.cxx index bda90a4270..3766e7dc10 100644 --- a/direct/src/plugin/wstring_encode.cxx +++ b/direct/src/plugin/wstring_encode.cxx @@ -30,11 +30,11 @@ bool wstring_to_string(string &result, const wstring &source) { bool success = false; int size = WideCharToMultiByte(CP_UTF8, 0, source.data(), source.length(), - NULL, 0, NULL, NULL); + nullptr, 0, nullptr, nullptr); if (size > 0) { char *buffer = new char[size]; int rc = WideCharToMultiByte(CP_UTF8, 0, source.data(), source.length(), - buffer, size, NULL, NULL); + buffer, size, nullptr, nullptr); if (rc != 0) { result.assign(buffer, size); success = true; @@ -54,7 +54,7 @@ bool string_to_wstring(wstring &result, const string &source) { bool success = false; int size = MultiByteToWideChar(CP_UTF8, 0, source.data(), source.length(), - NULL, 0); + nullptr, 0); if (size > 0) { wchar_t *buffer = new wchar_t[size]; int rc = MultiByteToWideChar(CP_UTF8, 0, source.data(), source.length(), diff --git a/direct/src/plugin/xml_helpers.cxx b/direct/src/plugin/xml_helpers.cxx index e08511f07a..20da4ce7ca 100644 --- a/direct/src/plugin/xml_helpers.cxx +++ b/direct/src/plugin/xml_helpers.cxx @@ -24,7 +24,7 @@ bool parse_bool_attrib(TiXmlElement *xelem, const string &attrib, bool default_value) { const char *value = xelem->Attribute(attrib.c_str()); - if (value == NULL || *value == '\0') { + if (value == nullptr || *value == '\0') { return default_value; } diff --git a/direct/src/plugin_activex/PPDownloadRequest.h b/direct/src/plugin_activex/PPDownloadRequest.h index a9ad8f3b2d..26d5081fc7 100644 --- a/direct/src/plugin_activex/PPDownloadRequest.h +++ b/direct/src/plugin_activex/PPDownloadRequest.h @@ -30,19 +30,19 @@ public: }; PPDownloadRequest( PPInstance& instance, P3D_request* p3dRequest ) : - m_instance( instance ), m_p3dRequest( p3dRequest ), m_data( NULL ), + m_instance( instance ), m_p3dRequest( p3dRequest ), m_data( nullptr ), m_requestType( RequestType::P3DObject ), m_hFile( INVALID_HANDLE_VALUE ) { } PPDownloadRequest( PPInstance& instance, const std::string& fileName ) : - m_instance( instance ), m_p3dRequest( NULL ), m_fileName( fileName ), - m_data( NULL ), m_requestType( RequestType::File ), m_hFile( INVALID_HANDLE_VALUE ) + m_instance( instance ), m_p3dRequest( nullptr ), m_fileName( fileName ), + m_data( nullptr ), m_requestType( RequestType::File ), m_hFile( INVALID_HANDLE_VALUE ) { } PPDownloadRequest( PPInstance& instance, std::strstream* data ) : - m_instance( instance ), m_p3dRequest ( NULL ), m_data( data ), + m_instance( instance ), m_p3dRequest ( nullptr ), m_data( data ), m_requestType( RequestType::Data ), m_hFile( INVALID_HANDLE_VALUE ) { } diff --git a/direct/src/plugin_npapi/npruntime.h b/direct/src/plugin_npapi/npruntime.h index 6e89165045..2039225cbe 100644 --- a/direct/src/plugin_npapi/npruntime.h +++ b/direct/src/plugin_npapi/npruntime.h @@ -137,13 +137,13 @@ void NPN_ReleaseVariantValue(NPVariant *variant); #define VOID_TO_NPVARIANT(_v) \ NP_BEGIN_MACRO \ (_v).type = NPVariantType_Void; \ - (_v).value.objectValue = NULL; \ + (_v).value.objectValue = nullptr; \ NP_END_MACRO #define NULL_TO_NPVARIANT(_v) \ NP_BEGIN_MACRO \ (_v).type = NPVariantType_Null; \ - (_v).value.objectValue = NULL; \ + (_v).value.objectValue = nullptr; \ NP_END_MACRO #define BOOLEAN_TO_NPVARIANT(_val, _v) \ diff --git a/direct/src/plugin_npapi/ppBrowserObject.cxx b/direct/src/plugin_npapi/ppBrowserObject.cxx index 822f1f5657..9655295141 100644 --- a/direct/src/plugin_npapi/ppBrowserObject.cxx +++ b/direct/src/plugin_npapi/ppBrowserObject.cxx @@ -44,7 +44,7 @@ static P3D_object * object_call(P3D_object *object, const char *method_name, bool needs_response, P3D_object *params[], int num_params) { - if (method_name == NULL) { + if (method_name == nullptr) { method_name = ""; } P3D_object *response = ((const PPBrowserObject *)object)->call(method_name, params, num_params); @@ -52,7 +52,7 @@ object_call(P3D_object *object, const char *method_name, // No response was expected. Throw away the response we received, so we // can be consistent with defined semantics. P3D_OBJECT_XDECREF(response); - response = NULL; + response = nullptr; } return response; } @@ -123,14 +123,14 @@ get_property(const string &property) const { if (!browser->hasproperty(_instance->get_npp_instance(), _npobj, property_name)) { // No such property. - return NULL; + return nullptr; } NPVariant result; if (!browser->getproperty(_instance->get_npp_instance(), _npobj, property_name, &result)) { // Failed to retrieve property. - return NULL; + return nullptr; } P3D_object *object = _instance->variant_to_p3dobj(&result); @@ -146,7 +146,7 @@ bool PPBrowserObject:: set_property(const string &property, bool needs_response, P3D_object *value) { NPIdentifier property_name = browser->getstringidentifier(property.c_str()); bool result; - if (value != NULL) { + if (value != nullptr) { // Set the property. NPVariant npvalue; _instance->p3dobj_to_variant(&npvalue, value); @@ -183,7 +183,7 @@ call(const string &method_name, P3D_object *params[], int num_params) const { npparams, num_params, &result)) { // Failed to invoke. delete[] npparams; - return NULL; + return nullptr; } } else { // Call the named method. @@ -193,7 +193,7 @@ call(const string &method_name, P3D_object *params[], int num_params) const { npparams, num_params, &result)) { // Failed to invoke. delete[] npparams; - return NULL; + return nullptr; } } @@ -215,7 +215,7 @@ eval(const string &expression) const { if (!browser->evaluate(_instance->get_npp_instance(), _npobj, &npexpr, &result)) { // Failed to eval. - return NULL; + return nullptr; } P3D_object *object = _instance->variant_to_p3dobj(&result); @@ -229,7 +229,7 @@ eval(const string &expression) const { */ void PPBrowserObject:: clear_class_definition() { - _browser_object_class = NULL; + _browser_object_class = nullptr; } /** @@ -238,7 +238,7 @@ clear_class_definition() { */ P3D_class_definition *PPBrowserObject:: get_class_definition() { - if (_browser_object_class == NULL) { + if (_browser_object_class == nullptr) { // Create a default class_definition object, and fill in the appropriate // pointers. _browser_object_class = P3D_make_class_definition_ptr(); diff --git a/direct/src/plugin_npapi/ppInstance.I b/direct/src/plugin_npapi/ppInstance.I index 122b396912..1c929d849b 100644 --- a/direct/src/plugin_npapi/ppInstance.I +++ b/direct/src/plugin_npapi/ppInstance.I @@ -27,5 +27,5 @@ get_window() const { if (_got_window) { return &_window; } - return NULL; + return nullptr; } diff --git a/direct/src/plugin_npapi/ppInstance.cxx b/direct/src/plugin_npapi/ppInstance.cxx index 47aa5b3cd0..8e3281c405 100644 --- a/direct/src/plugin_npapi/ppInstance.cxx +++ b/direct/src/plugin_npapi/ppInstance.cxx @@ -54,13 +54,13 @@ PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char *argn[], char *argv[], NPSavedData *saved, P3D_window_handle_type window_handle_type, P3D_event_type event_type) { - _p3d_inst = NULL; + _p3d_inst = nullptr; _npp_instance = instance; _npp_mode = mode; _window_handle_type = window_handle_type; _event_type = event_type; - _script_object = NULL; + _script_object = nullptr; _contents_expiration = 0; _failed = false; _started = false; @@ -68,9 +68,9 @@ PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode, // Copy the tokens and save them within this object. _tokens.reserve(argc); for (int i = 0; i < argc; ++i) { - if (argn[i] != NULL) { + if (argn[i] != nullptr) { const char *v = argv[i]; - if (v == NULL) { + if (v == nullptr) { // Firefox might give us a NULL argv[i] in some cases. v = ""; } @@ -130,13 +130,13 @@ PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode, #ifdef HAVE_X11 _twirl_subprocess_pid = -1; #ifdef HAVE_GTK - _plug = NULL; + _plug = nullptr; #endif // HAVE_GTK #endif // HAVE_X11 #ifdef _WIN32 - _hwnd = NULL; - _bg_brush = NULL; + _hwnd = nullptr; + _bg_brush = nullptr; #endif // _WIN32 #ifndef _WIN32 @@ -144,7 +144,7 @@ PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode, // use this to measure elapsed time from the window parameters having been // received. struct timeval tv; - gettimeofday(&tv, (struct timezone *)NULL); + gettimeofday(&tv, nullptr); _init_sec = tv.tv_sec; _init_usec = tv.tv_usec; #endif // !_WIN32 @@ -155,16 +155,16 @@ PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode, // thread.) _run_loop_main = CFRunLoopGetCurrent(); CFRetain(_run_loop_main); - _request_timer = NULL; + _request_timer = nullptr; INIT_LOCK(_timer_lock); // Also set up a timer to twirl the icon until the instance loads. - _twirl_timer = NULL; + _twirl_timer = nullptr; CFRunLoopTimerContext timer_context; memset(&timer_context, 0, sizeof(timer_context)); timer_context.info = this; _twirl_timer = CFRunLoopTimerCreate - (NULL, 0, 0.1, 0, 0, st_twirl_timer_callback, &timer_context); + (nullptr, 0, 0.1, 0, 0, st_twirl_timer_callback, &timer_context); CFRunLoopAddTimer(_run_loop_main, _twirl_timer, kCFRunLoopCommonModes); #endif // __APPLE__ @@ -181,15 +181,15 @@ PPInstance:: cleanup_window(); #ifdef __APPLE__ - if (_twirl_timer != NULL) { + if (_twirl_timer != nullptr) { CFRunLoopTimerInvalidate(_twirl_timer); CFRelease(_twirl_timer); - _twirl_timer = NULL; + _twirl_timer = nullptr; } - if (_request_timer != NULL) { + if (_request_timer != nullptr) { CFRunLoopTimerInvalidate(_request_timer); CFRelease(_request_timer); - _request_timer = NULL; + _request_timer = nullptr; } _run_loop_main = CFRunLoopGetCurrent(); CFRelease(_run_loop_main); @@ -200,15 +200,15 @@ PPInstance:: osx_release_twirl_images(); #endif // MACOSX_HAS_EVENT_MODELS - if (_p3d_inst != NULL) { + if (_p3d_inst != nullptr) { P3D_instance_finish_ptr(_p3d_inst); - _p3d_inst = NULL; + _p3d_inst = nullptr; } assert(_streams.empty()); assert(_file_datas.empty()); - if (_script_object != NULL) { + if (_script_object != nullptr) { browser->releaseobject(_script_object); } @@ -259,7 +259,7 @@ begin() { string contents_filename = _root_dir + "/contents.xml"; if (read_contents_file(contents_filename, false)) { - if (time(NULL) < _contents_expiration) { + if (time(nullptr) < _contents_expiration) { // Got the file, and it's good. get_core_api(); success = true; @@ -276,7 +276,7 @@ begin() { // Append a uniquifying query string to the URL to force the download to // go all the way through any caches. We use the time in seconds; // that's unique enough. - strm << "?" << time(NULL); + strm << "?" << time(nullptr); url = strm.str(); PPDownloadRequest *req = new PPDownloadRequest(PPDownloadRequest::RT_contents_file); @@ -308,7 +308,7 @@ set_window(NPWindow *window) { if (!_got_window) { #ifdef _WIN32 - _orig_window_proc = NULL; + _orig_window_proc = nullptr; if (window->type == NPWindowTypeWindow) { // Save the window handle. _hwnd = (HWND)window->window; @@ -330,7 +330,7 @@ set_window(NPWindow *window) { // twirling icon, and also to catch events in case something slips // through. _init_time = GetTickCount(); - SetTimer(_hwnd, 1, 100, NULL); + SetTimer(_hwnd, 1, 100, nullptr); } #endif // _WIN32 #ifdef MACOSX_HAS_EVENT_MODELS @@ -342,9 +342,9 @@ set_window(NPWindow *window) { if (_use_xembed) { if (!_got_window || _window.window != window->window) { // The window has changed. Destroy the old GtkPlug. - if (_plug != NULL) { + if (_plug != nullptr) { gtk_widget_destroy(_plug); - _plug = NULL; + _plug = nullptr; } // Create a new GtkPlug to bind to the XEmbed socket. @@ -367,7 +367,7 @@ set_window(NPWindow *window) { #endif // HAVE_X11 if (!_failed) { - if (_p3d_inst == NULL) { + if (_p3d_inst == nullptr) { create_instance(); } else { send_window(); @@ -385,16 +385,16 @@ new_stream(NPMIMEType type, NPStream *stream, bool seekable, uint16_t *stype) { return NPERR_GENERIC_ERROR; } - if (stream->notifyData == NULL) { + if (stream->notifyData == nullptr) { // This is an unsolicited stream. Assume the first unsolicited stream we // receive is the instance data; any other unsolicited stream is an error. - if (!_got_instance_url && stream->url != NULL) { + if (!_got_instance_url && stream->url != nullptr) { _got_instance_url = true; _instance_url = stream->url; stream->notifyData = new PPDownloadRequest(PPDownloadRequest::RT_instance_data); - if (_p3d_inst != NULL) { + if (_p3d_inst != nullptr) { // If we already have an instance by the time we get this stream, // start sending the data to the instance (instead of having to mess // around with a temporary file). @@ -488,7 +488,7 @@ write_ready(NPStream *stream) { */ int PPInstance:: write_stream(NPStream *stream, int offset, int len, void *buffer) { - if (stream->notifyData == NULL) { + if (stream->notifyData == nullptr) { nout << "Unexpected write_stream on " << stream->url << "\n"; browser->destroystream(_npp_instance, stream, NPRES_USER_BREAK); return 0; @@ -523,7 +523,7 @@ write_stream(NPStream *stream, int offset, int len, void *buffer) { // Nowadays we solve this problem by writing the data to a temporary file // until the instance is ready for it. - if (_p3d_inst == NULL) { + if (_p3d_inst == nullptr) { // The instance isn't ready, so stuff it in a temporary file. if (!_p3d_temp_file.feed(stream->end, buffer, len)) { set_failed(); @@ -575,7 +575,7 @@ destroy_stream(NPStream *stream, NPReason reason) { _streams.erase(si); } - if (stream->notifyData == NULL) { + if (stream->notifyData == nullptr) { nout << "Unexpected destroy_stream on " << stream->url << "\n"; return NPERR_NO_ERROR; } @@ -595,14 +595,14 @@ destroy_stream(NPStream *stream, NPReason reason) { case PPDownloadRequest::RT_user: if (!req->_notified_done) { P3D_instance_feed_url_stream_ptr(_p3d_inst, req->_user_id, - result_code, 0, stream->end, NULL, 0); + result_code, 0, stream->end, nullptr, 0); req->_notified_done = true; } break; case PPDownloadRequest::RT_instance_data: if (!req->_notified_done) { - if (_p3d_inst == NULL) { + if (_p3d_inst == nullptr) { // The instance still isn't ready; just mark the data done. We'll // send the entire file to the instance when it is ready. _p3d_temp_file.finish(); @@ -614,7 +614,7 @@ destroy_stream(NPStream *stream, NPReason reason) { // The instance has (only just) been created. Tell it we've sent it // all the data it will get. P3D_instance_feed_url_stream_ptr(_p3d_inst, _p3d_instance_id, - result_code, 0, stream->end, NULL, 0); + result_code, 0, stream->end, nullptr, 0); } req->_notified_done = true; } @@ -655,7 +655,7 @@ destroy_stream(NPStream *stream, NPReason reason) { */ void PPInstance:: url_notify(const char *url, NPReason reason, void *notifyData) { - if (notifyData == NULL) { + if (notifyData == nullptr) { return; } @@ -675,7 +675,7 @@ url_notify(const char *url, NPReason reason, void *notifyData) { assert(reason != NPRES_DONE); P3D_instance_feed_url_stream_ptr(_p3d_inst, req->_user_id, - P3D_RC_generic_error, 0, 0, NULL, 0); + P3D_RC_generic_error, 0, 0, nullptr, 0); req->_notified_done = true; } break; @@ -739,7 +739,7 @@ url_notify(const char *url, NPReason reason, void *notifyData) { */ void PPInstance:: stream_as_file(NPStream *stream, const char *fname) { - if (stream->notifyData == NULL) { + if (stream->notifyData == nullptr) { nout << "Unexpected stream_as_file on " << stream->url << "\n"; return; } @@ -772,7 +772,7 @@ stream_as_file(NPStream *stream, const char *fname) { // the file that Safari tells us about appears to be a temporary file // that Safari's about to delete. In order to protect ourselves from // this, we need to temporarily copy the file somewhere else. - char *name = tempnam(NULL, "p3d_"); + char *name = tempnam(nullptr, "p3d_"); // We prefer just making a hard link; it's quick and easy. if (link(filename.c_str(), name) != 0) { @@ -802,7 +802,7 @@ stream_as_file(NPStream *stream, const char *fname) { */ bool PPInstance:: handle_request(P3D_request *request) { - if (_p3d_inst == NULL || _failed) { + if (_p3d_inst == nullptr || _failed) { return false; } assert(request->_instance == _p3d_inst); @@ -811,9 +811,9 @@ handle_request(P3D_request *request) { switch (request->_request_type) { case P3D_RT_stop: - if (_p3d_inst != NULL) { + if (_p3d_inst != nullptr) { P3D_instance_finish_ptr(_p3d_inst); - _p3d_inst = NULL; + _p3d_inst = nullptr; } cleanup_window(); // Guess the browser doesn't really care. @@ -911,7 +911,7 @@ handle_event(void *event) { #endif // MACOSX_HAS_EVENT_MODELS } - if (_p3d_inst != NULL) { + if (_p3d_inst != nullptr) { if (P3D_instance_handle_event_ptr(_p3d_inst, &edata)) { retval = true; } @@ -926,15 +926,15 @@ handle_event(void *event) { */ NPObject *PPInstance:: get_panda_script_object() { - if (_script_object != NULL) { + if (_script_object != nullptr) { // NPRuntime "steals" a reference to this object. browser->retainobject(_script_object); return _script_object; } - P3D_object *main = NULL; + P3D_object *main = nullptr; - if (_p3d_inst != NULL) { + if (_p3d_inst != nullptr) { main = P3D_instance_get_panda_script_object_ptr(_p3d_inst); } nout << "get_panda_script_object, main = " << main << "\n"; @@ -985,7 +985,7 @@ p3dobj_to_variant(NPVariant *result, P3D_object *object) { case P3D_OT_string: { - int size = P3D_OBJECT_GET_STRING(object, NULL, 0); + int size = P3D_OBJECT_GET_STRING(object, nullptr, 0); char *buffer = (char *)browser->memalloc(size); P3D_OBJECT_GET_STRING(object, buffer, size); STRINGN_TO_NPVARIANT(buffer, size, *result); @@ -1071,9 +1071,9 @@ void PPInstance:: find_host(TiXmlElement *xcontents) { string host_url = PANDA_PACKAGE_HOST_URL; TiXmlElement *xhost = xcontents->FirstChildElement("host"); - if (xhost != NULL) { + if (xhost != nullptr) { const char *url = xhost->Attribute("url"); - if (url != NULL && host_url == string(url)) { + if (url != nullptr && host_url == string(url)) { // We're the primary host. This is the normal case. read_xhost(xhost); return; @@ -1081,9 +1081,9 @@ find_host(TiXmlElement *xcontents) { } else { // We're not the primary host; perhaps we're an alternate host. TiXmlElement *xalthost = xhost->FirstChildElement("alt_host"); - while (xalthost != NULL) { + while (xalthost != nullptr) { const char *url = xalthost->Attribute("url"); - if (url != NULL && host_url == string(url)) { + if (url != nullptr && host_url == string(url)) { // Yep, we're this alternate host. read_xhost(xhost); return; @@ -1107,7 +1107,7 @@ read_xhost(TiXmlElement *xhost) { // Get the "download" URL, which is the source from which we download // everything other than the contents.xml file. const char *download_url = xhost->Attribute("download_url"); - if (download_url != NULL) { + if (download_url != nullptr) { _download_url_prefix = download_url; } else { _download_url_prefix = PANDA_PACKAGE_HOST_URL; @@ -1119,9 +1119,9 @@ read_xhost(TiXmlElement *xhost) { } TiXmlElement *xmirror = xhost->FirstChildElement("mirror"); - while (xmirror != NULL) { + while (xmirror != nullptr) { const char *url = xmirror->Attribute("url"); - if (url != NULL) { + if (url != nullptr) { add_mirror(url); } xmirror = xmirror->NextSiblingElement("mirror"); @@ -1175,15 +1175,15 @@ choose_random_mirrors(vector &result, int num_mirrors) { void PPInstance:: request_ready(P3D_instance *instance) { PPInstance *inst = (PPInstance *)(instance->_user_data); - assert(inst != NULL); + assert(inst != nullptr); if (has_plugin_thread_async_call) { #ifdef HAS_PLUGIN_THREAD_ASYNC_CALL // Since we are running at least Gecko 1.9, and we have this very useful // function, let's use it to ask the browser to call us back in the main // thread. - assert((void *)browser->pluginthreadasynccall != (void *)NULL); - browser->pluginthreadasynccall(inst->_npp_instance, browser_sync_callback, NULL); + assert((void *)browser->pluginthreadasynccall != nullptr); + browser->pluginthreadasynccall(inst->_npp_instance, browser_sync_callback, nullptr); #endif // HAS_PLUGIN_THREAD_ASYNC_CALL } else { @@ -1195,7 +1195,7 @@ request_ready(P3D_instance *instance) { // Get the window handle for the window associated with this instance. const NPWindow *win = inst->get_window(); - if (win != NULL && win->type == NPWindowTypeWindow) { + if (win != nullptr && win->type == NPWindowTypeWindow) { PostMessage((HWND)(win->window), WM_USER, 0, 0); } #endif // _WIN32 @@ -1205,12 +1205,12 @@ request_ready(P3D_instance *instance) { // Only set a new timer if we don't have one already started. ACQUIRE_LOCK(inst->_timer_lock); - if (inst->_request_timer == NULL) { + if (inst->_request_timer == nullptr) { CFRunLoopTimerContext timer_context; memset(&timer_context, 0, sizeof(timer_context)); timer_context.info = inst; inst->_request_timer = CFRunLoopTimerCreate - (NULL, 0, 0, 0, 0, timer_callback, &timer_context); + (nullptr, 0, 0, 0, 0, timer_callback, &timer_context); CFRunLoopAddTimer(inst->_run_loop_main, inst->_request_timer, kCFRunLoopCommonModes); } RELEASE_LOCK(inst->_timer_lock); @@ -1232,7 +1232,7 @@ start_download(const string &url, PPDownloadRequest *req) { delete req; } else { // Otherwise, ask the browser to download it. - browser->geturlnotify(_npp_instance, url.c_str(), NULL, req); + browser->geturlnotify(_npp_instance, url.c_str(), nullptr, req); } } @@ -1283,19 +1283,19 @@ read_contents_file(const string &contents_filename, bool fresh_download) { bool found_core_package = false; TiXmlElement *xcontents = doc.FirstChildElement("contents"); - if (xcontents != NULL) { + if (xcontents != nullptr) { int max_age = P3D_CONTENTS_DEFAULT_MAX_AGE; xcontents->Attribute("max_age", &max_age); // Get the latest possible expiration time, based on the max_age // indication. Any expiration time later than this is in error. - time_t now = time(NULL); + time_t now = time(nullptr); _contents_expiration = now + (time_t)max_age; if (fresh_download) { // Update the XML with the new download information. TiXmlElement *xorig = xcontents->FirstChildElement("orig"); - while (xorig != NULL) { + while (xorig != nullptr) { xcontents->RemoveChild(xorig); xorig = xcontents->FirstChildElement("orig"); } @@ -1309,7 +1309,7 @@ read_contents_file(const string &contents_filename, bool fresh_download) { // Read the expiration time from the XML. int expiration = 0; TiXmlElement *xorig = xcontents->FirstChildElement("orig"); - if (xorig != NULL) { + if (xorig != nullptr) { xorig->Attribute("expiration", &expiration); } @@ -1327,14 +1327,14 @@ read_contents_file(const string &contents_filename, bool fresh_download) { // Now look for the core API package. _coreapi_set_ver = ""; TiXmlElement *xpackage = xcontents->FirstChildElement("package"); - while (xpackage != NULL) { + while (xpackage != nullptr) { const char *name = xpackage->Attribute("name"); - if (name != NULL && strcmp(name, "coreapi") == 0) { + if (name != nullptr && strcmp(name, "coreapi") == 0) { const char *platform = xpackage->Attribute("platform"); - if (platform != NULL && strcmp(platform, DTOOL_PLATFORM) == 0) { + if (platform != nullptr && strcmp(platform, DTOOL_PLATFORM) == 0) { _coreapi_dll.load_xml(xpackage); const char *set_ver = xpackage->Attribute("set_ver"); - if (set_ver != NULL) { + if (set_ver != nullptr) { _coreapi_set_ver = set_ver; } found_core_package = true; @@ -1491,7 +1491,7 @@ send_p3d_temp_file_data() { // If we'd already finished the stream earlier, tell the plugin. P3D_instance_feed_url_stream_ptr(_p3d_inst, _p3d_instance_id, P3D_RC_done, 0, _p3d_temp_file._total_size, - NULL, 0); + nullptr, 0); } _p3d_temp_file.cleanup(); } @@ -1515,7 +1515,7 @@ get_core_api() { // uniquifier, to break through any caches. ostringstream strm; strm << _download_url_prefix << _coreapi_dll.get_filename() - << "?" << time(NULL); + << "?" << time(nullptr); url = strm.str(); _core_urls.push_back(url); @@ -1566,7 +1566,7 @@ downloaded_plugin(const string &filename) { nout << "Expected:\n"; _coreapi_dll.write(nout); const FileSpec *actual = _coreapi_dll.force_get_actual_file(filename); - if (actual != NULL) { + if (actual != nullptr) { nout << "Found:\n"; actual->write(nout); } @@ -1671,10 +1671,10 @@ create_instance() { #ifdef __APPLE__ // We no longer need to twirl the icon. Stop the timer. - if (_twirl_timer != NULL) { + if (_twirl_timer != nullptr) { CFRunLoopTimerInvalidate(_twirl_timer); CFRelease(_twirl_timer); - _twirl_timer = NULL; + _twirl_timer = nullptr; } #endif // __APPLE__ @@ -1685,21 +1685,21 @@ create_instance() { // In the Windows case, we let the timer keep running, because it also // checks for wayward messages. - P3D_token *tokens = NULL; + P3D_token *tokens = nullptr; if (!_tokens.empty()) { tokens = &_tokens[0]; } _started = true; _p3d_inst = P3D_new_instance_ptr(request_ready, tokens, _tokens.size(), - 0, NULL, this); - if (_p3d_inst == NULL) { + 0, nullptr, this); + if (_p3d_inst == nullptr) { set_failed(); return; } // Now get the browser's toplevel DOM object (called the "window" object in // JavaScript), to pass to the plugin. - NPObject *window_object = NULL; + NPObject *window_object = nullptr; if (browser->getvalue(_npp_instance, NPNVWindowNPObject, &window_object) == NPERR_NO_ERROR) { PPBrowserObject *pobj = new PPBrowserObject(this, window_object); @@ -1709,7 +1709,7 @@ create_instance() { nout << "Couldn't get window_object\n"; } - if (_script_object != NULL) { + if (_script_object != nullptr) { // Now that we have a true instance, initialize our script_object with the // proper P3D_object pointer. P3D_object *main = P3D_instance_get_panda_script_object_ptr(_p3d_inst); @@ -1740,7 +1740,7 @@ create_instance() { */ void PPInstance:: send_window() { - assert(_p3d_inst != NULL); + assert(_p3d_inst != nullptr); int x = _window.x; int y = _window.y; @@ -1770,7 +1770,7 @@ send_window() { #endif } else if (_window_handle_type == P3D_WHT_osx_cgcontext) { NP_CGContext *context = (NP_CGContext *)_window.window; - if (context != NULL) { + if (context != nullptr) { parent_window._handle._osx_cgcontext._context = context->context; parent_window._handle._osx_cgcontext._window = (WindowRef)context->window; } @@ -1784,7 +1784,7 @@ send_window() { // If we're using XEmbed, pass the X11 Window pointer of our plug down // to Panda. (Hmm, it would be nice to pass the XID object and use this // system in general within Panda, but that's for the future, I think.) - assert(_plug != NULL); + assert(_plug != nullptr); parent_window._window_handle_type = P3D_WHT_x11_window; parent_window._handle._x11_window._xwindow = GDK_DRAWABLE_XID(_plug->window); #endif // HAVE_GTK @@ -1818,7 +1818,7 @@ send_window() { #endif } else if (_window_handle_type == P3D_WHT_osx_cgcontext) { NP_CGContext *context = (NP_CGContext *)_window.window; - if (context != NULL) { + if (context != nullptr) { parent_window._handle._osx_cgcontext._context = context->context; parent_window._handle._osx_cgcontext._window = (WindowRef)context->window; } @@ -1845,7 +1845,7 @@ send_window() { #endif P3D_window_type window_type = P3D_WT_embedded; - if (_window.window == NULL && _event_type != P3D_ET_osx_cocoa) { + if (_window.window == nullptr && _event_type != P3D_ET_osx_cocoa) { // No parent window: it must be a hidden window. window_type = P3D_WT_hidden; } else if (_window.width == 0 || _window.height == 0) { @@ -1870,16 +1870,16 @@ cleanup_window() { // Restore the parent window to its own window handler. HWND hwnd = (HWND)_window.window; SetWindowLongPtr(hwnd, GWLP_WNDPROC, _orig_window_proc); - InvalidateRect(hwnd, NULL, true); + InvalidateRect(hwnd, nullptr, true); - if (_bg_brush != NULL) { + if (_bg_brush != nullptr) { DeleteObject(_bg_brush); - _bg_brush = NULL; + _bg_brush = nullptr; } for (int step = 0; step < twirl_num_steps + 1; ++step) { - if (_twirl_bitmaps[step] != NULL) { + if (_twirl_bitmaps[step] != nullptr) { DeleteObject(_twirl_bitmaps[step]); - _twirl_bitmaps[step] = NULL; + _twirl_bitmaps[step] = nullptr; } } #endif // _WIN32 @@ -1888,9 +1888,9 @@ cleanup_window() { x11_stop_twirl_subprocess(); #ifdef HAVE_GTK - if (_plug != NULL) { + if (_plug != nullptr) { gtk_widget_destroy(_plug); - _plug = NULL; + _plug = nullptr; } #endif // HAVE_GTK #endif // HAVE_X11 @@ -2037,7 +2037,7 @@ set_failed() { if (!expression.empty()) { // Now attempt to evaluate the expression. - NPObject *window_object = NULL; + NPObject *window_object = nullptr; if (browser->getvalue(_npp_instance, NPNVWindowNPObject, &window_object) == NPERR_NO_ERROR) { NPString npexpr = { expression.c_str(), (uint32_t)expression.length() }; @@ -2054,9 +2054,9 @@ set_failed() { } } - if (_p3d_inst != NULL) { + if (_p3d_inst != nullptr) { P3D_instance_finish_ptr(_p3d_inst); - _p3d_inst = NULL; + _p3d_inst = nullptr; } cleanup_window(); } @@ -2073,11 +2073,11 @@ handle_request_loop() { } P3D_instance *p3d_inst = P3D_check_request_ptr(0.0); - while (p3d_inst != (P3D_instance *)NULL) { + while (p3d_inst != nullptr) { P3D_request *request = P3D_instance_get_request_ptr(p3d_inst); - if (request != (P3D_request *)NULL) { + if (request != nullptr) { PPInstance *inst = (PPInstance *)(p3d_inst->_user_data); - assert(inst != NULL); + assert(inst != nullptr); if (!inst->handle_request(request)) { // If handling the request is meant to yield control temporarily to // JavaScript (e.g. P3D_RT_callback), then do so now. @@ -2130,7 +2130,7 @@ browser_sync_callback(void *) { LONG PPInstance:: st_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { LONG_PTR self = GetWindowLongPtr(hwnd, GWLP_USERDATA); - if (self == NULL) { + if (self == nullptr) { // We haven't assigned the pointer yet (!?) return DefWindowProc(hwnd, msg, wparam, lparam); } @@ -2174,7 +2174,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { case WM_TIMER: if (!_started) { - InvalidateRect(_hwnd, NULL, FALSE); + InvalidateRect(_hwnd, nullptr, FALSE); } break; @@ -2286,7 +2286,7 @@ win_paint_twirl(HWND hwnd, HDC dc) { BitBlt(bdc, left, top, twirl_width, twirl_height, mem_dc, 0, 0, SRCCOPY); - SelectObject(mem_dc, NULL); + SelectObject(mem_dc, nullptr); DeleteDC(mem_dc); } } @@ -2414,7 +2414,7 @@ const wchar_t *PPInstance:: make_ansi_string(wstring &result, NPNSString *ns_string) { result.clear(); - if (ns_string != NULL) { + if (ns_string != nullptr) { // An NPNSString is really just an NSString, which is itself just a // CFString. CFStringRef cfstr = (CFStringRef)ns_string; @@ -2492,7 +2492,7 @@ osx_get_twirl_images() { image._raw_data = new_data; image._data = - CFDataCreateWithBytesNoCopy(NULL, (const UInt8 *)image._raw_data, + CFDataCreateWithBytesNoCopy(nullptr, (const UInt8 *)image._raw_data, twirl_size * 4, kCFAllocatorNull); image._provider = CGDataProviderCreateWithCFData(image._data); image._color_space = CGColorSpaceCreateDeviceRGB(); @@ -2501,7 +2501,7 @@ osx_get_twirl_images() { CGImageCreate(twirl_width, twirl_height, 8, 32, twirl_width * 4, image._color_space, kCGImageAlphaFirst | kCGBitmapByteOrder32Little, - image._provider, NULL, false, kCGRenderingIntentDefault); + image._provider, nullptr, false, kCGRenderingIntentDefault); } } #endif // MACOSX_HAS_EVENT_MODELS @@ -2520,25 +2520,25 @@ osx_release_twirl_images() { for (int step = 0; step < twirl_num_steps + 1; ++step) { OsxImageData &image = _twirl_images[step]; - if (image._image != NULL) { + if (image._image != nullptr) { CGImageRelease(image._image); - image._image = NULL; + image._image = nullptr; } - if (image._color_space != NULL) { + if (image._color_space != nullptr) { CGColorSpaceRelease(image._color_space); - image._color_space = NULL; + image._color_space = nullptr; } - if (image._provider != NULL) { + if (image._provider != nullptr) { CGDataProviderRelease(image._provider); - image._provider = NULL; + image._provider = nullptr; } - if (image._data != NULL) { + if (image._data != nullptr) { CFRelease(image._data); - image._data = NULL; + image._data = nullptr; } - if (image._raw_data != NULL) { + if (image._raw_data != nullptr) { delete[] image._raw_data; - image._raw_data = NULL; + image._raw_data = nullptr; } } } @@ -2571,7 +2571,7 @@ paint_twirl_osx_cgcontext(CGContextRef context) { } else { struct timeval tv; - gettimeofday(&tv, (struct timezone *)NULL); + gettimeofday(&tv, nullptr); double now = (double)(tv.tv_sec - _init_sec) + (double)(tv.tv_usec - _init_usec) / 1000000.0; // Don't draw the twirling icon until at least half a second has passed, @@ -2591,7 +2591,7 @@ paint_twirl_osx_cgcontext(CGContextRef context) { */ bool PPInstance:: osx_paint_image(CGContextRef context, const OsxImageData &image) { - if (image._image == NULL) { + if (image._image == nullptr) { return false; } @@ -2627,10 +2627,10 @@ void PPInstance:: timer_callback(CFRunLoopTimerRef timer, void *info) { PPInstance *self = (PPInstance *)info; ACQUIRE_LOCK(self->_timer_lock); - if (self->_request_timer != NULL) { + if (self->_request_timer != nullptr) { CFRunLoopTimerInvalidate(self->_request_timer); CFRelease(self->_request_timer); - self->_request_timer = NULL; + self->_request_timer = nullptr; } RELEASE_LOCK(self->_timer_lock); @@ -2744,14 +2744,14 @@ x11_twirl_subprocess_run() { struct timespec req; req.tv_sec = 0; req.tv_nsec = 500000000; // 500 ms - nanosleep(&req, NULL); + nanosleep(&req, nullptr); // We haven't been killed yet, so the plugin is still loading. Start // twirling. // First, embed a window. - X11_Display *display = XOpenDisplay(NULL); - assert(display != NULL); + X11_Display *display = XOpenDisplay(nullptr); + assert(display != nullptr); int screen = DefaultScreen(display); int depth = DefaultDepth(display, screen); @@ -2796,7 +2796,7 @@ x11_twirl_subprocess_run() { X11_Window parent = 0; if (_use_xembed) { #ifdef HAVE_GTK - assert(_plug != NULL); + assert(_plug != nullptr); parent = GDK_DRAWABLE_XID(_plug->window); #endif // HAVE_GTK } else { @@ -2874,7 +2874,7 @@ x11_twirl_subprocess_run() { // What step are we on now? struct timeval tv; - gettimeofday(&tv, (struct timezone *)NULL); + gettimeofday(&tv, nullptr); double now = (double)(tv.tv_sec - _init_sec) + (double)(tv.tv_usec - _init_usec) / 1000000.0; int step = ((int)(now * 10.0)) % twirl_num_steps; if (step != last_step) { @@ -2896,7 +2896,7 @@ x11_twirl_subprocess_run() { struct timespec req; req.tv_sec = 0; req.tv_nsec = 100000000; // 100 ms - nanosleep(&req, NULL); + nanosleep(&req, nullptr); } } #endif // HAVE_X11 @@ -2990,7 +2990,7 @@ thread_run() { struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 10000; - select(0, NULL, NULL, NULL, &tv); + select(0, nullptr, nullptr, nullptr, &tv); #endif } @@ -3002,7 +3002,7 @@ thread_run() { } P3D_instance_feed_url_stream_ptr - (_p3d_inst, _user_id, result, 0, _total_count, NULL, 0); + (_p3d_inst, _user_id, result, 0, _total_count, nullptr, 0); // All done. _thread_done = true; @@ -3041,7 +3041,7 @@ open() { _current_size = 0; _total_size = 0; - char *name = tempnam(NULL, "p3d_"); + char *name = tempnam(nullptr, "p3d_"); _filename = name; free(name); diff --git a/direct/src/plugin_npapi/ppPandaObject.I b/direct/src/plugin_npapi/ppPandaObject.I index 1f50908246..eafcfbd83c 100644 --- a/direct/src/plugin_npapi/ppPandaObject.I +++ b/direct/src/plugin_npapi/ppPandaObject.I @@ -18,7 +18,7 @@ */ inline P3D_object *PPPandaObject:: get_p3d_object() const { - if (_p3d_object != NULL) { + if (_p3d_object != nullptr) { P3D_OBJECT_INCREF(_p3d_object); } return _p3d_object; diff --git a/direct/src/plugin_npapi/ppPandaObject.cxx b/direct/src/plugin_npapi/ppPandaObject.cxx index c403868a41..f85ef43407 100644 --- a/direct/src/plugin_npapi/ppPandaObject.cxx +++ b/direct/src/plugin_npapi/ppPandaObject.cxx @@ -52,7 +52,7 @@ make_new(PPInstance *inst, P3D_object *p3d_object) { */ void PPPandaObject:: set_p3d_object(P3D_object *p3d_object) { - if (p3d_object != NULL) { + if (p3d_object != nullptr) { P3D_OBJECT_INCREF(p3d_object); } P3D_OBJECT_XDECREF(_p3d_object); @@ -67,7 +67,7 @@ set_p3d_object(P3D_object *p3d_object) { void PPPandaObject:: construct(PPInstance *inst, P3D_object *p3d_object) { _instance = inst; - _p3d_object = NULL; + _p3d_object = nullptr; set_p3d_object(p3d_object); } @@ -76,8 +76,8 @@ construct(PPInstance *inst, P3D_object *p3d_object) { */ void PPPandaObject:: invalidate() { - _instance = NULL; - set_p3d_object(NULL); + _instance = nullptr; + set_p3d_object(nullptr); } /** @@ -87,7 +87,7 @@ bool PPPandaObject:: has_method(NPIdentifier name) { string method_name = identifier_to_string(name); // nout << this << ".has_method(" << method_name << ")\n"; - if (_p3d_object == NULL) { + if (_p3d_object == nullptr) { // Not powered up yet. return false; } @@ -114,7 +114,7 @@ invoke(NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result) { string method_name = identifier_to_string(name); // nout << this << ".invoke(" << method_name << ")\n"; - if (_p3d_object == NULL) { + if (_p3d_object == nullptr) { // Not powered up yet. return false; } @@ -132,7 +132,7 @@ invoke(NPIdentifier name, const NPVariant *args, uint32_t argCount, } delete[] p3dargs; - if (value == NULL) { + if (value == nullptr) { // No such method, or some problem with the parameters. return false; } @@ -151,7 +151,7 @@ bool PPPandaObject:: invoke_default(const NPVariant *args, uint32_t argCount, NPVariant *result) { // nout << this << ".invoke_default()\n"; - if (_p3d_object == NULL) { + if (_p3d_object == nullptr) { // Not powered up yet. return false; } @@ -169,7 +169,7 @@ invoke_default(const NPVariant *args, uint32_t argCount, } delete[] p3dargs; - if (value == NULL) { + if (value == nullptr) { // No such method, or some problem with the parameters. return false; } @@ -187,7 +187,7 @@ bool PPPandaObject:: has_property(NPIdentifier name) { string property_name = identifier_to_string(name); // nout << this << ".has_property(" << property_name << ")\n"; - if (_p3d_object == NULL) { + if (_p3d_object == nullptr) { // Not powered up yet. return false; } @@ -215,14 +215,14 @@ get_property(NPIdentifier name, NPVariant *result) { string property_name = identifier_to_string(name); // nout << this << ".get_property(" << property_name << ")\n"; - if (_p3d_object == NULL) { + if (_p3d_object == nullptr) { // Not powered up yet. VOID_TO_NPVARIANT(*result); return true; } P3D_object *value = P3D_OBJECT_GET_PROPERTY(_p3d_object, property_name.c_str()); - if (value == NULL) { + if (value == nullptr) { // No such property. VOID_TO_NPVARIANT(*result); return true; @@ -242,7 +242,7 @@ bool PPPandaObject:: set_property(NPIdentifier name, const NPVariant *value) { string property_name = identifier_to_string(name); // nout << this << ".set_property(" << property_name << ")\n"; - if (_p3d_object == NULL) { + if (_p3d_object == nullptr) { // Not powered up yet. return false; } @@ -262,13 +262,13 @@ bool PPPandaObject:: remove_property(NPIdentifier name) { string property_name = identifier_to_string(name); // nout << this << ".remove_property(" << property_name << ")\n"; - if (_p3d_object == NULL) { + if (_p3d_object == nullptr) { // Not powered up yet. return false; } bool result = P3D_OBJECT_SET_PROPERTY(_p3d_object, property_name.c_str(), - true, NULL); + true, nullptr); return result; } @@ -281,7 +281,7 @@ enumerate(NPIdentifier **value, uint32_t *count) { // nout << this << ".enumerate()\n"; TODO: Not implemented yet. // Note that the array of values must be allocated here with NPN_MemAlloc(). - *value = NULL; + *value = nullptr; *count = 0; return false; } @@ -294,7 +294,7 @@ string PPPandaObject:: identifier_to_string(NPIdentifier ident) { if (browser->identifierisstring(ident)) { NPUTF8 *result = browser->utf8fromidentifier(ident); - if (result != NULL) { + if (result != nullptr) { string strval(result); browser->memfree(result); return strval; diff --git a/direct/src/plugin_npapi/ppToplevelObject.cxx b/direct/src/plugin_npapi/ppToplevelObject.cxx index a7f9c879e3..a3790d5039 100644 --- a/direct/src/plugin_npapi/ppToplevelObject.cxx +++ b/direct/src/plugin_npapi/ppToplevelObject.cxx @@ -52,7 +52,7 @@ make_new(PPInstance *inst) { */ void PPToplevelObject:: set_main(P3D_object *p3d_object) { - if (p3d_object != NULL) { + if (p3d_object != nullptr) { P3D_OBJECT_INCREF(p3d_object); } P3D_OBJECT_XDECREF(_main); @@ -67,7 +67,7 @@ set_main(P3D_object *p3d_object) { void PPToplevelObject:: construct(PPInstance *inst) { _instance = inst; - _main = NULL; + _main = nullptr; // Get our one property name as an identifier, so we can look for it. _main_id = browser->getstringidentifier("main"); @@ -78,8 +78,8 @@ construct(PPInstance *inst) { */ void PPToplevelObject:: invalidate() { - _instance = NULL; - set_main(NULL); + _instance = nullptr; + set_main(nullptr); } /** @@ -87,7 +87,7 @@ invalidate() { */ bool PPToplevelObject:: has_property(NPIdentifier name) { - if (_main == NULL) { + if (_main == nullptr) { // Not powered up yet. return false; } @@ -105,7 +105,7 @@ has_property(NPIdentifier name) { */ bool PPToplevelObject:: get_property(NPIdentifier name, NPVariant *result) { - if (_main == NULL) { + if (_main == nullptr) { // Not powered up yet. return false; } diff --git a/direct/src/plugin_npapi/startup.cxx b/direct/src/plugin_npapi/startup.cxx index 8d64c71dc7..0c6a99c258 100644 --- a/direct/src/plugin_npapi/startup.cxx +++ b/direct/src/plugin_npapi/startup.cxx @@ -127,7 +127,7 @@ NP_GetMIMEDescription(void) { */ NPError NP_GetValue(void*, NPPVariable variable, void* value) { - if (value == NULL) { + if (value == nullptr) { return NPERR_INVALID_PARAM; } @@ -175,7 +175,7 @@ NP_Initialize(NPNetscapeFuncs *browserFuncs, // On Unix, we have to use the pluginFuncs argument to pass our entry // points. #if !defined(_WIN32) && !defined(__APPLE__) - if (pluginFuncs != NULL) { + if (pluginFuncs != nullptr) { NP_GetEntryPoints(pluginFuncs); } #endif @@ -194,7 +194,7 @@ NP_Initialize(NPNetscapeFuncs *browserFuncs, #ifdef HAS_PLUGIN_THREAD_ASYNC_CALL // Check if the browser offers this very useful call. if (browser_major > 0 || browser_minor >= NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL) { - if ((void *)browser->pluginthreadasynccall == (void *)NULL) { + if ((void *)browser->pluginthreadasynccall == nullptr) { nout << "Browser should have PLUGIN_THREAD_ASYNC_CALL, but the pointer is NULL.\n"; has_plugin_thread_async_call = false; } else { @@ -205,7 +205,7 @@ NP_Initialize(NPNetscapeFuncs *browserFuncs, // Seed the lame random number generator in rand(); we use it to select a // mirror for downloading. - srand((unsigned int)time(NULL)); + srand((unsigned int)time(nullptr)); return NPERR_NO_ERROR; } @@ -370,11 +370,11 @@ NPP_Destroy(NPP instance, NPSavedData **save) { nout << "save = " << (void *)save << "\n"; // (*save) = NULL; PPInstance *inst = (PPInstance *)(instance->pdata); - assert(inst != NULL); + assert(inst != nullptr); inst->stop_outstanding_streams(); delete inst; - instance->pdata = NULL; + instance->pdata = nullptr; return NPERR_NO_ERROR; } @@ -392,7 +392,7 @@ NPP_SetWindow(NPP instance, NPWindow *window) { << "\n"; PPInstance *inst = (PPInstance *)(instance->pdata); - assert(inst != NULL); + assert(inst != nullptr); inst->set_window(window); return NPERR_NO_ERROR; @@ -414,7 +414,7 @@ NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream, << ", " << (PPInstance *)(instance->pdata) << "\n"; PPInstance::generic_browser_call(); PPInstance *inst = (PPInstance *)(instance->pdata); - assert(inst != NULL); + assert(inst != nullptr); return inst->new_stream(type, stream, seekable != 0, stype); } @@ -432,7 +432,7 @@ NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason) { PPInstance::generic_browser_call(); PPInstance *inst = (PPInstance *)(instance->pdata); - assert(inst != NULL); + assert(inst != nullptr); return inst->destroy_stream(stream, reason); } @@ -446,7 +446,7 @@ NPP_WriteReady_x(NPP instance, NPStream *stream) { // (PPInstance *)(instance->pdata) << "\n"; PPInstance::generic_browser_call(); PPInstance *inst = (PPInstance *)(instance->pdata); - assert(inst != NULL); + assert(inst != nullptr); return inst->write_ready(stream); } @@ -462,7 +462,7 @@ NPP_Write_x(NPP instance, NPStream *stream, int32_t offset, // " << instance << ", " << (PPInstance *)(instance->pdata) << "\n"; PPInstance::generic_browser_call(); PPInstance *inst = (PPInstance *)(instance->pdata); - assert(inst != NULL); + assert(inst != nullptr); return inst->write_stream(stream, offset, len, buffer); } @@ -481,7 +481,7 @@ NPP_StreamAsFile(NPP instance, NPStream *stream, const char *fname) { PPInstance::generic_browser_call(); PPInstance *inst = (PPInstance *)(instance->pdata); - assert(inst != NULL); + assert(inst != nullptr); inst->stream_as_file(stream, fname); } @@ -504,7 +504,7 @@ NPP_HandleEvent(NPP instance, void *event) { PPInstance::generic_browser_call(); PPInstance *inst = (PPInstance *)(instance->pdata); - assert(inst != NULL); + assert(inst != nullptr); return inst->handle_event(event); } @@ -522,7 +522,7 @@ NPP_URLNotify(NPP instance, const char *url, PPInstance::generic_browser_call(); PPInstance *inst = (PPInstance *)(instance->pdata); - assert(inst != NULL); + assert(inst != nullptr); inst->url_notify(url, reason, notifyData); } @@ -535,11 +535,11 @@ NPP_GetValue(NPP instance, NPPVariable variable, void *value) { nout << "GetValue " << variable << "\n"; PPInstance::generic_browser_call(); PPInstance *inst = (PPInstance *)(instance->pdata); - assert(inst != NULL); + assert(inst != nullptr); if (variable == NPPVpluginScriptableNPObject) { NPObject *obj = inst->get_panda_script_object(); - if (obj != NULL) { + if (obj != nullptr) { *(NPObject **)value = obj; return NPERR_NO_ERROR; } @@ -571,7 +571,7 @@ NPP_GetValue(NPP instance, NPPVariable variable, void *value) { return NPERR_NO_ERROR; } else { - return NP_GetValue(NULL, variable, value); + return NP_GetValue(nullptr, variable, value); } return NPERR_GENERIC_ERROR; diff --git a/direct/src/plugin_standalone/p3dEmbed.cxx b/direct/src/plugin_standalone/p3dEmbed.cxx index 87918f66f4..14903aa600 100644 --- a/direct/src/plugin_standalone/p3dEmbed.cxx +++ b/direct/src/plugin_standalone/p3dEmbed.cxx @@ -76,8 +76,8 @@ run_embedded(streampos read_offset, int argc, char *argv[]) { string curstr; bool havenull = false; P3D_token token; - token._keyword = NULL; - token._value = NULL; + token._keyword = nullptr; + token._value = nullptr; string keyword; string value; string root_dir; diff --git a/direct/src/plugin_standalone/panda3d.cxx b/direct/src/plugin_standalone/panda3d.cxx index 10876d2e64..8710d92696 100644 --- a/direct/src/plugin_standalone/panda3d.cxx +++ b/direct/src/plugin_standalone/panda3d.cxx @@ -144,12 +144,12 @@ run_command_line(int argc, char *argv[]) { // will be delivered to the subordinate Python process and return to a // command shell, and won't just kill the panda3d process. #ifdef _WIN32 - SetConsoleCtrlHandler(NULL, true); + SetConsoleCtrlHandler(nullptr, true); #else struct sigaction ignore; memset(&ignore, 0, sizeof(ignore)); ignore.sa_handler = SIG_IGN; - sigaction(SIGINT, &ignore, NULL); + sigaction(SIGINT, &ignore, nullptr); #endif // _WIN32 } break; @@ -348,7 +348,7 @@ get_plugin() { Filename contents_filename = Filename(Filename::from_os_specific(_root_dir), "contents.xml"); if (_verify_contents != P3D_VC_force) { if (read_contents_file(contents_filename, false)) { - if (_verify_contents == P3D_VC_none || time(NULL) < _contents_expiration) { + if (_verify_contents == P3D_VC_none || time(nullptr) < _contents_expiration) { // Got the file, and it's good. success = true; } @@ -415,7 +415,7 @@ download_contents_file(const Filename &contents_filename) { // Append a uniquifying query string to the URL to force the download to // go all the way through any caches. We use the time in seconds; that's // unique enough. - strm << "?" << time(NULL); + strm << "?" << time(nullptr); string url = strm.str(); // We might as well explicitly request the cache to be disabled too, since @@ -468,19 +468,19 @@ read_contents_file(const Filename &contents_filename, bool fresh_download) { bool found_core_package = false; TiXmlElement *xcontents = doc.FirstChildElement("contents"); - if (xcontents != NULL) { + if (xcontents != nullptr) { int max_age = P3D_CONTENTS_DEFAULT_MAX_AGE; xcontents->Attribute("max_age", &max_age); // Get the latest possible expiration time, based on the max_age // indication. Any expiration time later than this is in error. - time_t now = time(NULL); + time_t now = time(nullptr); _contents_expiration = now + (time_t)max_age; if (fresh_download) { // Update the XML with the new download information. TiXmlElement *xorig = xcontents->FirstChildElement("orig"); - while (xorig != NULL) { + while (xorig != nullptr) { xcontents->RemoveChild(xorig); xorig = xcontents->FirstChildElement("orig"); } @@ -494,7 +494,7 @@ read_contents_file(const Filename &contents_filename, bool fresh_download) { // Read the expiration time from the XML. int expiration = 0; TiXmlElement *xorig = xcontents->FirstChildElement("orig"); - if (xorig != NULL) { + if (xorig != nullptr) { xorig->Attribute("expiration", &expiration); } @@ -508,14 +508,14 @@ read_contents_file(const Filename &contents_filename, bool fresh_download) { // Now look for the core API package. _coreapi_set_ver = ""; TiXmlElement *xpackage = xcontents->FirstChildElement("package"); - while (xpackage != NULL) { + while (xpackage != nullptr) { const char *name = xpackage->Attribute("name"); - if (name != NULL && strcmp(name, "coreapi") == 0) { + if (name != nullptr && strcmp(name, "coreapi") == 0) { const char *platform = xpackage->Attribute("platform"); - if (platform != NULL && _coreapi_platform == string(platform)) { + if (platform != nullptr && _coreapi_platform == string(platform)) { _coreapi_dll.load_xml(xpackage); const char *set_ver = xpackage->Attribute("set_ver"); - if (set_ver != NULL) { + if (set_ver != nullptr) { _coreapi_set_ver = set_ver; } found_core_package = true; @@ -583,9 +583,9 @@ read_contents_file(const Filename &contents_filename, bool fresh_download) { void Panda3D:: find_host(TiXmlElement *xcontents) { TiXmlElement *xhost = xcontents->FirstChildElement("host"); - if (xhost != NULL) { + if (xhost != nullptr) { const char *url = xhost->Attribute("url"); - if (url != NULL && _host_url == string(url)) { + if (url != nullptr && _host_url == string(url)) { // We're the primary host. This is the normal case. read_xhost(xhost); return; @@ -593,9 +593,9 @@ find_host(TiXmlElement *xcontents) { } else { // We're not the primary host; perhaps we're an alternate host. TiXmlElement *xalthost = xhost->FirstChildElement("alt_host"); - while (xalthost != NULL) { + while (xalthost != nullptr) { const char *url = xalthost->Attribute("url"); - if (url != NULL && _host_url == string(url)) { + if (url != nullptr && _host_url == string(url)) { // Yep, we're this alternate host. read_xhost(xhost); return; @@ -619,11 +619,11 @@ read_xhost(TiXmlElement *xhost) { // Get the "download" URL, which is the source from which we download // everything other than the contents.xml file. const char *download_url = xhost->Attribute("download_url"); - if (download_url == NULL) { + if (download_url == nullptr) { download_url = xhost->Attribute("url"); } - if (download_url != NULL) { + if (download_url != nullptr) { _download_url_prefix = download_url; } else { _download_url_prefix = _host_url_prefix; @@ -635,9 +635,9 @@ read_xhost(TiXmlElement *xhost) { } TiXmlElement *xmirror = xhost->FirstChildElement("mirror"); - while (xmirror != NULL) { + while (xmirror != nullptr) { const char *url = xmirror->Attribute("url"); - if (url != NULL) { + if (url != nullptr) { add_mirror(url); } xmirror = xmirror->NextSiblingElement("mirror"); @@ -767,7 +767,7 @@ download_core_api() { // uniquifier, to break through any caches. ostringstream strm; strm << _download_url_prefix << _coreapi_dll.get_filename() - << "?" << time(NULL); + << "?" << time(nullptr); url = strm.str(); core_urls.push_back(url); diff --git a/direct/src/plugin_standalone/panda3dBase.cxx b/direct/src/plugin_standalone/panda3dBase.cxx index 0b3884f17c..07f86fb18a 100644 --- a/direct/src/plugin_standalone/panda3dBase.cxx +++ b/direct/src/plugin_standalone/panda3dBase.cxx @@ -74,7 +74,7 @@ Panda3DBase(bool console_environment) { // Seed the lame random number generator in rand(); we use it to select a // mirror for downloading. - srand((unsigned int)time(NULL)); + srand((unsigned int)time(nullptr)); _prepend_filename_to_args = true; } @@ -90,7 +90,7 @@ run_main_loop() { // Wait for new messages from Windows, and new requests from the plugin. MSG msg; int retval; - retval = GetMessage(&msg, NULL, 0, 0); + retval = GetMessage(&msg, nullptr, 0, 0); while (retval != 0 && !time_to_exit()) { if (retval == -1) { cerr << "Error processing message queue.\n"; @@ -101,20 +101,20 @@ run_main_loop() { // Check for new requests from the Panda3D plugin. P3D_instance *inst = P3D_check_request_ptr(wait_cycle); - while (inst != (P3D_instance *)NULL) { + while (inst != nullptr) { P3D_request *request = P3D_instance_get_request_ptr(inst); - if (request != (P3D_request *)NULL) { + if (request != nullptr) { handle_request(request); } inst = P3D_check_request_ptr(wait_cycle); } while (!_url_getters.empty() && - !PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { + !PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE)) { // If there are no Windows messages, check the download tasks. run_getters(); } - retval = GetMessage(&msg, NULL, 0, 0); + retval = GetMessage(&msg, nullptr, 0, 0); } // WM_QUIT has been received. Terminate all instances, and fall through. @@ -128,9 +128,9 @@ run_main_loop() { // Windows events. Instead, just wait for requests. while (!time_to_exit()) { P3D_instance *inst = P3D_check_request_ptr(wait_cycle); - if (inst != (P3D_instance *)NULL) { + if (inst != nullptr) { P3D_request *request = P3D_instance_get_request_ptr(inst); - if (request != (P3D_request *)NULL) { + if (request != nullptr) { handle_request(request); } } @@ -162,9 +162,9 @@ run_main_loop() { // Now wait while we process pending requests. while (!time_to_exit()) { P3D_instance *inst = P3D_check_request_ptr(wait_cycle); - if (inst != (P3D_instance *)NULL) { + if (inst != nullptr) { P3D_request *request = P3D_instance_get_request_ptr(inst); - if (request != (P3D_request *)NULL) { + if (request != nullptr) { handle_request(request); } } @@ -207,7 +207,7 @@ handle_request(P3D_request *request) { delete_instance(request->_instance); #ifdef _WIN32 // Post a silly message to spin the event loop. - PostMessage(NULL, WM_USER, 0, 0); + PostMessage(nullptr, WM_USER, 0, 0); #endif handled = true; break; @@ -267,7 +267,7 @@ void Panda3DBase:: make_parent_window() { WNDCLASS wc; - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); ZeroMemory(&wc, sizeof(WNDCLASS)); wc.lpfnWndProc = (WNDPROC)window_proc; wc.hInstance = application; @@ -287,7 +287,7 @@ make_parent_window() { HWND toplevel_window = CreateWindow("panda3d", "Panda3D", window_style, CW_USEDEFAULT, CW_USEDEFAULT, _win_width, _win_height, - NULL, NULL, application, 0); + nullptr, nullptr, application, 0); if (!toplevel_window) { cerr << "Could not create toplevel window!\n"; exit(1); @@ -364,7 +364,7 @@ create_instance(const string &p3d, bool start_instance, token._value = "1"; tokens.push_back(token); - P3D_token *tokens_p = NULL; + P3D_token *tokens_p = nullptr; size_t num_tokens = tokens.size(); if (!tokens.empty()) { tokens_p = &tokens[0]; @@ -379,10 +379,10 @@ create_instance(const string &p3d, bool start_instance, argv.push_back(args[i]); } - P3D_instance *inst = P3D_new_instance_ptr(NULL, tokens_p, num_tokens, - argv.size(), &argv[0], NULL); + P3D_instance *inst = P3D_new_instance_ptr(nullptr, tokens_p, num_tokens, + argv.size(), &argv[0], nullptr); - if (inst != NULL) { + if (inst != nullptr) { if (start_instance) { // We call start() first, to give the core API a chance to notice the // "hidden" attrib before we set the window parameters. @@ -443,11 +443,11 @@ read_p3d_info(const Filename &p3d_filename, int p3d_offset) { return false; } TiXmlElement *xpackage = doc.FirstChildElement("package"); - if (xpackage == NULL) { + if (xpackage == nullptr) { return false; } TiXmlElement *xconfig = xpackage->FirstChildElement("config"); - if (xconfig == NULL) { + if (xconfig == nullptr) { return false; } @@ -473,7 +473,7 @@ read_p3d_info(const Filename &p3d_filename, int p3d_offset) { bool Panda3DBase:: parse_token(const char *arg) { const char *equals = strchr(arg, '='); - if (equals == NULL) { + if (equals == nullptr) { return false; } @@ -624,12 +624,12 @@ report_downloading_package(P3D_instance *instance) { P3D_object *obj = P3D_instance_get_panda_script_object_ptr(instance); P3D_object *display_name = P3D_object_get_property_ptr(obj, "downloadPackageDisplayName"); - if (display_name == NULL) { + if (display_name == nullptr) { cerr << "Installing package.\n"; return; } - int name_length = P3D_object_get_string_ptr(display_name, NULL, 0); + int name_length = P3D_object_get_string_ptr(display_name, nullptr, 0); char *name = new char[name_length + 1]; P3D_object_get_string_ptr(display_name, name, name_length + 1); @@ -670,9 +670,9 @@ void Panda3DBase:: timer_callback(EventLoopTimerRef timer) { // Check for new requests from the Panda3D plugin. P3D_instance *inst = P3D_check_request_ptr(0.0); - while (inst != (P3D_instance *)NULL) { + while (inst != nullptr) { P3D_request *request = P3D_instance_get_request_ptr(inst); - if (request != (P3D_request *)NULL) { + if (request != nullptr) { handle_request(request); } inst = P3D_check_request_ptr(0.0); @@ -758,6 +758,6 @@ run() { P3D_instance_feed_url_stream_ptr (_instance, _unique_id, status, _channel->get_status_code(), - _bytes_sent, NULL, 0); + _bytes_sent, nullptr, 0); return false; } diff --git a/direct/src/plugin_standalone/panda3dMac.cxx b/direct/src/plugin_standalone/panda3dMac.cxx index 2b7ab47e8c..06877b9af0 100644 --- a/direct/src/plugin_standalone/panda3dMac.cxx +++ b/direct/src/plugin_standalone/panda3dMac.cxx @@ -53,7 +53,7 @@ open_p3d_file(FSRef *ref) { } // Create an instance. - create_instance((char *)filename, true, NULL, 0); + create_instance((char *)filename, true, nullptr, 0); } static pascal OSErr @@ -74,7 +74,7 @@ open_documents_handler(const AppleEvent *theAppleEvent, AppleEvent *reply, for (index = 1; index <= count; index++) { err = AEGetNthPtr(&docList, index, typeFSRef, - NULL, NULL, &theFSRef, sizeof(FSRef), NULL);// 5 + nullptr, nullptr, &theFSRef, sizeof(FSRef), nullptr);// 5 require_noerr(err, CantGetDocDescPtr); // Here's the file, do something with it. diff --git a/dtool/src/cppparser/cppArrayType.cxx b/dtool/src/cppparser/cppArrayType.cxx index ce861c1d69..0226420aaf 100644 --- a/dtool/src/cppparser/cppArrayType.cxx +++ b/dtool/src/cppparser/cppArrayType.cxx @@ -85,7 +85,7 @@ is_trivial() const { */ bool CPPArrayType:: is_default_constructible() const { - return _bounds != NULL && _element_type->is_default_constructible(); + return _bounds != nullptr && _element_type->is_default_constructible(); } /** @@ -105,7 +105,7 @@ is_copy_constructible() const { bool CPPArrayType:: is_equivalent(const CPPType &other) const { const CPPArrayType *ot = ((CPPType *)&other)->as_array_type(); - if (ot == (CPPArrayType *)NULL) { + if (ot == nullptr) { return CPPType::is_equivalent(other); } @@ -128,7 +128,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, _element_type->substitute_decl(subst, current_scope, global_scope) ->as_type(); - if (_bounds != NULL) { + if (_bounds != nullptr) { rep->_bounds = _bounds->substitute_decl(subst, current_scope, global_scope) ->as_expression(); @@ -171,7 +171,7 @@ output_instance(ostream &out, int indent_level, CPPScope *scope, const string &name) const { ostringstream brackets; brackets << "["; - if (_bounds != NULL) { + if (_bounds != nullptr) { brackets << *_bounds; } brackets << "]"; @@ -204,13 +204,13 @@ as_array_type() { bool CPPArrayType:: is_equal(const CPPDeclaration *other) const { const CPPArrayType *ot = ((CPPDeclaration *)other)->as_array_type(); - assert(ot != NULL); + assert(ot != nullptr); - if (_bounds != NULL && ot->_bounds != NULL) { + if (_bounds != nullptr && ot->_bounds != nullptr) { if (*_bounds != *ot->_bounds) { return false; } - } else if ((_bounds == NULL) != (ot->_bounds == NULL)) { + } else if ((_bounds == nullptr) != (ot->_bounds == nullptr)) { return false; } @@ -225,13 +225,13 @@ is_equal(const CPPDeclaration *other) const { bool CPPArrayType:: is_less(const CPPDeclaration *other) const { const CPPArrayType *ot = ((CPPDeclaration *)other)->as_array_type(); - assert(ot != NULL); + assert(ot != nullptr); - if (_bounds != NULL && ot->_bounds != NULL) { + if (_bounds != nullptr && ot->_bounds != nullptr) { if (*_bounds != *ot->_bounds) { return *_bounds < *ot->_bounds; } - } else if ((_bounds == NULL) != (ot->_bounds == NULL)) { + } else if ((_bounds == nullptr) != (ot->_bounds == nullptr)) { return _bounds < ot->_bounds; } diff --git a/dtool/src/cppparser/cppBison.yxx b/dtool/src/cppparser/cppBison.yxx index 3750399ccc..d132677763 100644 --- a/dtool/src/cppparser/cppBison.yxx +++ b/dtool/src/cppparser/cppBison.yxx @@ -36,15 +36,15 @@ // Defining the interface to the parser. //////////////////////////////////////////////////////////////////// -CPPScope *current_scope = NULL; -CPPScope *global_scope = NULL; -CPPPreprocessor *current_lexer = NULL; +CPPScope *current_scope = nullptr; +CPPScope *global_scope = nullptr; +CPPPreprocessor *current_lexer = nullptr; -static CPPStructType *current_struct = NULL; -static CPPEnumType *current_enum = NULL; +static CPPStructType *current_struct = nullptr; +static CPPEnumType *current_enum = nullptr; static int current_storage_class = 0; -static CPPType *current_type = NULL; -static CPPExpression *current_expr = NULL; +static CPPType *current_type = nullptr; +static CPPExpression *current_expr = nullptr; static int publish_nest_level = 0; static CPPVisibility publish_previous; static YYLTYPE publish_loc; @@ -118,7 +118,7 @@ parse_const_expr(CPPPreprocessor *pp, CPPScope *new_current_scope, current_scope = new_current_scope; global_scope = new_global_scope; - current_expr = (CPPExpression *)NULL; + current_expr = nullptr; current_lexer = pp; yyparse(); @@ -142,7 +142,7 @@ parse_type(CPPPreprocessor *pp, CPPScope *new_current_scope, current_scope = new_current_scope; global_scope = new_global_scope; - current_type = (CPPType *)NULL; + current_type = nullptr; current_lexer = pp; yyparse(); @@ -159,7 +159,7 @@ parse_type(CPPPreprocessor *pp, CPPScope *new_current_scope, static void push_scope(CPPScope *new_scope) { last_scopes.push_back(current_scope); - if (new_scope != NULL) { + if (new_scope != nullptr) { current_scope = new_scope; } } @@ -652,7 +652,7 @@ declaration: CPPDeclaration *length_getter = $5->find_symbol(current_scope, global_scope, current_lexer); if (length_getter == nullptr || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { yyerror("reference to non-existent or invalid length method: " + $5->get_fully_scoped_name(), @5); - length_getter = NULL; + length_getter = nullptr; } CPPDeclaration *getter = $7->find_symbol(current_scope, global_scope, current_lexer); @@ -688,7 +688,7 @@ declaration: CPPDeclaration *length_getter = $5->find_symbol(current_scope, global_scope, current_lexer); if (length_getter == nullptr || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { yyerror("reference to non-existent or invalid length method: " + $5->get_fully_scoped_name(), @5); - length_getter = NULL; + length_getter = nullptr; } CPPDeclaration *getter = $7->find_symbol(current_scope, global_scope, current_lexer); @@ -890,18 +890,18 @@ declaration: | KW_MAKE_SEQ '(' name ',' IDENTIFIER ',' IDENTIFIER ')' ';' { CPPDeclaration *length_getter = $5->find_symbol(current_scope, global_scope, current_lexer); - if (length_getter == (CPPDeclaration *)NULL || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { + if (length_getter == nullptr || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { yyerror("reference to non-existent or invalid length method: " + $5->get_fully_scoped_name(), @5); - length_getter = NULL; + length_getter = nullptr; } CPPDeclaration *element_getter = $7->find_symbol(current_scope, global_scope, current_lexer); - if (element_getter == (CPPDeclaration *)NULL || element_getter->get_subtype() != CPPDeclaration::ST_function_group) { + if (element_getter == nullptr || element_getter->get_subtype() != CPPDeclaration::ST_function_group) { yyerror("reference to non-existent or invalid element method: " + $7->get_fully_scoped_name(), @5); - element_getter = NULL; + element_getter = nullptr; } - if (length_getter != (CPPDeclaration *)NULL && element_getter != (CPPDeclaration *)NULL) { + if (length_getter != nullptr && element_getter != nullptr) { CPPMakeSeq *make_seq = new CPPMakeSeq($3, length_getter->as_function_group(), element_getter->as_function_group(), @@ -1070,7 +1070,7 @@ type_like_declaration: } | storage_class constructor_prototype { - if ($2 != (CPPInstance *)NULL) { + if ($2 != nullptr) { // Push the scope so that the initializers can make use of things defined // in the class body. push_scope($2->get_scope(current_scope, global_scope)); @@ -1079,7 +1079,7 @@ type_like_declaration: } maybe_initialize_or_constructor_body { - if ($2 != (CPPInstance *)NULL) { + if ($2 != nullptr) { pop_scope(); current_scope->add_declaration($2, global_scope, current_lexer, @2); $2->set_initializer($4); @@ -1087,7 +1087,7 @@ type_like_declaration: } | storage_class function_prototype maybe_initialize_or_function_body { - if ($2 != (CPPInstance *)NULL) { + if ($2 != nullptr) { $2->_storage_class |= (current_storage_class | $1); current_scope->add_declaration($2, global_scope, current_lexer, @2); $2->set_initializer($3); @@ -1144,9 +1144,9 @@ typedef_declaration: } | storage_class function_prototype maybe_initialize_or_function_body { - if ($2 != (CPPDeclaration *)NULL) { + if ($2 != nullptr) { CPPInstance *inst = $2->as_instance(); - if (inst != (CPPInstance *)NULL) { + if (inst != nullptr) { inst->_storage_class |= (current_storage_class | $1); current_scope->add_declaration(inst, global_scope, current_lexer, @2); CPPTypedefType *typedef_type = new CPPTypedefType(inst->_type, inst->_ident, current_scope); @@ -1269,10 +1269,10 @@ function_prototype: { pop_scope(); CPPType *type = $1->find_type(current_scope, global_scope, false, current_lexer); - if (type == NULL) { + if (type == nullptr) { yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1); } - assert(type != NULL); + assert(type != nullptr); CPPInstanceIdentifier *ii = $4; ii->add_modifier(IIT_pointer); @@ -1287,10 +1287,10 @@ function_prototype: { pop_scope(); CPPType *type = $1->find_type(current_scope, global_scope, false, current_lexer); - if (type == NULL) { + if (type == nullptr) { yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1); } - assert(type != NULL); + assert(type != nullptr); CPPInstanceIdentifier *ii = $5; ii->add_scoped_pointer_modifier($3); @@ -1301,13 +1301,13 @@ function_prototype: /* Typecast operators */ | KW_OPERATOR type not_paren_formal_parameter_identifier '(' { - if ($1 != NULL) { + if ($1 != nullptr) { push_scope($1->get_scope(current_scope, global_scope)); } } function_parameter_list ')' function_post { - if ($1 != NULL) { + if ($1 != nullptr) { pop_scope(); } @@ -1322,7 +1322,7 @@ function_prototype: // the method's return type to determine the full type description. string name = "operator typecast " + $2->get_simple_name(); CPPIdentifier *ident = $1; - if (ident == NULL) { + if (ident == nullptr) { ident = new CPPIdentifier(name, @2); } else { ident->add_name(name); @@ -1332,18 +1332,18 @@ function_prototype: } | KW_OPERATOR KW_CONST type not_paren_formal_parameter_identifier '(' { - if ($1 != NULL) { + if ($1 != nullptr) { push_scope($1->get_scope(current_scope, global_scope)); } } function_parameter_list ')' function_post { - if ($1 != NULL) { + if ($1 != nullptr) { pop_scope(); } CPPIdentifier *ident = $1; - if (ident == NULL) { + if (ident == nullptr) { ident = new CPPIdentifier("operator typecast", @4); } else { ident->add_name("operator typecast"); @@ -1360,10 +1360,10 @@ function_prototype: { CPPDeclaration *decl = $1->find_symbol(current_scope, global_scope, current_lexer); - if (decl != (CPPDeclaration *)NULL) { + if (decl != nullptr) { $$ = decl->as_instance(); } else { - $$ = (CPPInstance *)NULL; + $$ = nullptr; } } ; @@ -1626,13 +1626,13 @@ template_nonempty_formal_parameters: template_formal_parameter { CPPTemplateScope *ts = current_scope->as_template_scope(); - assert(ts != NULL); + assert(ts != nullptr); ts->add_template_parameter($1); } | template_nonempty_formal_parameters ',' template_formal_parameter { CPPTemplateScope *ts = current_scope->as_template_scope(); - assert(ts != NULL); + assert(ts != nullptr); ts->add_template_parameter($3); } ; @@ -1645,7 +1645,7 @@ typename_keyword: template_formal_parameter: typename_keyword { - $$ = CPPType::new_type(new CPPClassTemplateParameter((CPPIdentifier *)NULL)); + $$ = CPPType::new_type(new CPPClassTemplateParameter(nullptr)); } | typename_keyword name { @@ -1657,7 +1657,7 @@ template_formal_parameter: } | typename_keyword ELLIPSIS { - CPPClassTemplateParameter *ctp = new CPPClassTemplateParameter((CPPIdentifier *)NULL); + CPPClassTemplateParameter *ctp = new CPPClassTemplateParameter(nullptr); ctp->_packed = true; $$ = CPPType::new_type(ctp); } @@ -1706,18 +1706,18 @@ template_formal_parameter_type: | TYPENAME_IDENTIFIER { $$ = $1->find_type(current_scope, global_scope, false, current_lexer); - if ($$ == NULL) { + if ($$ == nullptr) { yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1); } - assert($$ != NULL); + assert($$ != nullptr); } | TYPEPACK_IDENTIFIER { $$ = $1->find_type(current_scope, global_scope, false, current_lexer); - if ($$ == NULL) { + if ($$ == nullptr) { yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1); } - assert($$ != NULL); + assert($$ != nullptr); } ; @@ -1733,7 +1733,7 @@ instance_identifier: // ficticious name for the function; in other respects it's just // like a regular function. CPPIdentifier *ident = $1; - if (ident == NULL) { + if (ident == nullptr) { ident = new CPPIdentifier("operator "+$2, @2); } else { ident->_names.push_back("operator "+$2); @@ -1748,7 +1748,7 @@ instance_identifier: yyerror("expected empty string", @2); } CPPIdentifier *ident = $1; - if (ident == NULL) { + if (ident == nullptr) { ident = new CPPIdentifier("operator \"\" "+$3->get_simple_name(), @3); } else { ident->_names.push_back("operator \"\" "+$3->get_simple_name()); @@ -1832,7 +1832,7 @@ instance_identifier_and_maybe_trailing_return_type: // This is handled a bit awkwardly right now. Ideally it'd be wrapped // up in the instance_identifier rule, but then more needs to happen in // order to avoid shift/reduce conflicts. - if ($2 != NULL) { + if ($2 != nullptr) { $1->add_trailing_return_type($2); } $$ = $1; @@ -1849,7 +1849,7 @@ instance_identifier_and_maybe_trailing_return_type: maybe_trailing_return_type: empty { - $$ = NULL; + $$ = nullptr; } | POINTSAT predefined_type empty_instance_identifier { @@ -1866,7 +1866,7 @@ maybe_trailing_return_type: maybe_comma_identifier: empty { - $$ = NULL; + $$ = nullptr; } | ',' IDENTIFIER { @@ -1956,7 +1956,7 @@ formal_parameters: template_parameter_maybe_initialize: empty { - $$ = (CPPExpression *)NULL; + $$ = nullptr; } | '=' no_angle_bracket_const_expr { @@ -1967,7 +1967,7 @@ template_parameter_maybe_initialize: maybe_initialize: empty { - $$ = (CPPExpression *)NULL; + $$ = nullptr; } | '=' const_expr { @@ -1978,15 +1978,15 @@ maybe_initialize: maybe_initialize_or_constructor_body: ';' { - $$ = (CPPExpression *)NULL; + $$ = nullptr; } | '{' code '}' { - $$ = (CPPExpression *)NULL; + $$ = nullptr; } | ':' constructor_inits '{' code '}' { - $$ = (CPPExpression *)NULL; + $$ = nullptr; } | '=' KW_DEFAULT ';' { @@ -2001,11 +2001,11 @@ maybe_initialize_or_constructor_body: maybe_initialize_or_function_body: ';' { - $$ = (CPPExpression *)NULL; + $$ = nullptr; } | '{' code '}' { - $$ = (CPPExpression *)NULL; + $$ = nullptr; } | '=' const_expr ';' { @@ -2021,7 +2021,7 @@ maybe_initialize_or_function_body: } | '=' '{' structure_init '}' { - $$ = (CPPExpression *)NULL; + $$ = nullptr; } ; @@ -2106,7 +2106,7 @@ formal_parameter: not_paren_formal_parameter_identifier: empty { - $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + $$ = new CPPInstanceIdentifier(nullptr); } | name_no_final { @@ -2152,7 +2152,7 @@ not_paren_formal_parameter_identifier: formal_parameter_identifier: empty { - $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + $$ = new CPPInstanceIdentifier(nullptr); } | name_no_final { @@ -2209,7 +2209,7 @@ formal_parameter_identifier: parameter_pack_identifier: ELLIPSIS { - $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + $$ = new CPPInstanceIdentifier(nullptr); $$->_packed = true; } | ELLIPSIS name @@ -2268,11 +2268,11 @@ parameter_pack_identifier: not_paren_empty_instance_identifier: empty { - $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + $$ = new CPPInstanceIdentifier(nullptr); } | ELLIPSIS { - $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + $$ = new CPPInstanceIdentifier(nullptr); $$->_packed = true; } | ELLIPSIS name @@ -2320,11 +2320,11 @@ not_paren_empty_instance_identifier: empty_instance_identifier: empty { - $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + $$ = new CPPInstanceIdentifier(nullptr); } | ELLIPSIS { - $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + $$ = new CPPInstanceIdentifier(nullptr); $$->_packed = true; } | ELLIPSIS name @@ -2369,7 +2369,7 @@ empty_instance_identifier: } | '(' function_parameter_list ')' function_post maybe_trailing_return_type { - $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + $$ = new CPPInstanceIdentifier(nullptr); $$->add_modifier(IIT_paren); $$->add_func_modifier($2, $4, $5); } @@ -2404,10 +2404,10 @@ type: | TYPENAME_IDENTIFIER { $$ = $1->find_type(current_scope, global_scope, false, current_lexer); - if ($$ == NULL) { + if ($$ == nullptr) { yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1); } - assert($$ != NULL); + assert($$ != nullptr); } | KW_TYPENAME name { @@ -2428,14 +2428,14 @@ type: | struct_keyword struct_attributes name { CPPType *type = $3->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { $$ = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType($1, $3, current_scope, @1.file)) ->as_extension_type(); CPPScope *scope = $3->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } $$ = et; @@ -2444,14 +2444,14 @@ type: | enum_keyword name_no_final ':' enum_element_type { CPPType *type = $2->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { $$ = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType($1, $2, current_scope, @1.file)) ->as_extension_type(); CPPScope *scope = $2->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } $$ = et; @@ -2460,7 +2460,7 @@ type: | KW_DECLTYPE '(' const_expr ')' { $$ = $3->determine_type(); - if ($$ == (CPPType *)NULL) { + if ($$ == nullptr) { stringstream str; str << *$3; yyerror("could not determine type of " + str.str(), @3); @@ -2473,7 +2473,7 @@ type: | KW_UNDERLYING_TYPE '(' full_type ')' { CPPEnumType *enum_type = $3->as_enum_type(); - if (enum_type == NULL) { + if (enum_type == nullptr) { yyerror("an enumeration type is required", @3); $$ = $3; } else { @@ -2490,10 +2490,10 @@ type_pack: TYPEPACK_IDENTIFIER { $$ = $1->find_type(current_scope, global_scope, false, current_lexer); - if ($$ == NULL) { + if ($$ == nullptr) { yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1); } - assert($$ != NULL); + assert($$ != nullptr); } ; @@ -2505,10 +2505,10 @@ type_decl: | TYPENAME_IDENTIFIER { $$ = $1->find_type(current_scope, global_scope, false, current_lexer); - if ($$ == NULL) { + if ($$ == nullptr) { yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1); } - assert($$ != NULL); + assert($$ != nullptr); } | KW_TYPENAME name { @@ -2529,14 +2529,14 @@ type_decl: | struct_keyword struct_attributes name { CPPType *type = $3->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { $$ = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType($1, $3, current_scope, @1.file)) ->as_extension_type(); CPPScope *scope = $3->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } $$ = et; @@ -2545,14 +2545,14 @@ type_decl: | enum_keyword name_no_final ':' enum_element_type { CPPType *type = $2->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { $$ = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType($1, $2, current_scope, @1.file)) ->as_extension_type(); CPPScope *scope = $2->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } $$ = et; @@ -2563,14 +2563,14 @@ type_decl: yywarning(string("C++ does not permit forward declaration of untyped enum ") + $2->get_fully_scoped_name(), @1); CPPType *type = $2->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { $$ = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType($1, $2, current_scope, @1.file)) ->as_extension_type(); CPPScope *scope = $2->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } $$ = et; @@ -2579,7 +2579,7 @@ type_decl: | KW_DECLTYPE '(' const_expr ')' { $$ = $3->determine_type(); - if ($$ == (CPPType *)NULL) { + if ($$ == nullptr) { stringstream str; str << *$3; yyerror("could not determine type of " + str.str(), @3); @@ -2592,7 +2592,7 @@ type_decl: | KW_UNDERLYING_TYPE '(' full_type ')' { CPPEnumType *enum_type = $3->as_enum_type(); - if (enum_type == NULL) { + if (enum_type == nullptr) { yyerror("an enumeration type is required", @3); $$ = $3; } else { @@ -2613,10 +2613,10 @@ predefined_type: | TYPENAME_IDENTIFIER { $$ = $1->find_type(current_scope, global_scope, false, current_lexer); - if ($$ == NULL) { + if ($$ == nullptr) { yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1); } - assert($$ != NULL); + assert($$ != nullptr); } | KW_TYPENAME name { @@ -2625,14 +2625,14 @@ predefined_type: | struct_keyword struct_attributes name { CPPType *type = $3->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { $$ = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType($1, $3, current_scope, @1.file)) ->as_extension_type(); CPPScope *scope = $3->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } $$ = et; @@ -2641,14 +2641,14 @@ predefined_type: | enum_keyword name { CPPType *type = $2->find_type(current_scope, global_scope, false, current_lexer); - if (type != NULL) { + if (type != nullptr) { $$ = type; } else { CPPExtensionType *et = CPPType::new_type(new CPPExtensionType($1, $2, current_scope, @1.file)) ->as_extension_type(); CPPScope *scope = $2->get_scope(current_scope, global_scope); - if (scope != NULL) { + if (scope != nullptr) { scope->define_extension_type(et); } $$ = et; @@ -2657,7 +2657,7 @@ predefined_type: | KW_DECLTYPE '(' const_expr ')' { $$ = $3->determine_type(); - if ($$ == (CPPType *)NULL) { + if ($$ == nullptr) { stringstream str; str << *$3; yyerror("could not determine type of " + str.str(), @3); @@ -2666,7 +2666,7 @@ predefined_type: | KW_UNDERLYING_TYPE '(' full_type ')' { CPPEnumType *enum_type = $3->as_enum_type(); - if (enum_type == NULL) { + if (enum_type == nullptr) { yyerror("an enumeration type is required", @3); $$ = $3; } else { @@ -2727,7 +2727,7 @@ anonymous_struct: CPPScope *new_scope = new CPPScope(current_scope, CPPNameComponent("anon"), starting_vis); - CPPStructType *st = new CPPStructType($1, NULL, current_scope, + CPPStructType *st = new CPPStructType($1, nullptr, current_scope, new_scope, @1.file); new_scope->set_struct_type(st); @@ -2750,7 +2750,7 @@ named_struct: ($1 == CPPExtensionType::T_class) ? V_private : V_public; CPPScope *scope = $3->get_scope(current_scope, global_scope, current_lexer); - if (scope == NULL) { + if (scope == nullptr) { scope = current_scope; } CPPScope *new_scope = new CPPScope(scope, $3->_names.back(), @@ -2838,18 +2838,18 @@ enum: enum_decl '{' enum_body '}' { $$ = current_enum; - current_enum = NULL; + current_enum = nullptr; } ; enum_decl: enum_keyword ':' enum_element_type { - current_enum = new CPPEnumType($1, NULL, $3, current_scope, NULL, @1.file); + current_enum = new CPPEnumType($1, nullptr, $3, current_scope, nullptr, @1.file); } | enum_keyword { - current_enum = new CPPEnumType($1, NULL, current_scope, NULL, @1.file); + current_enum = new CPPEnumType($1, nullptr, current_scope, nullptr, @1.file); } | enum_keyword name_no_final ':' enum_element_type { @@ -2878,12 +2878,12 @@ enum_body_trailing_comma: empty | enum_body_trailing_comma name ',' { - assert(current_enum != NULL); - current_enum->add_element($2->get_simple_name(), NULL, current_lexer, @2); + assert(current_enum != nullptr); + current_enum->add_element($2->get_simple_name(), nullptr, current_lexer, @2); } | enum_body_trailing_comma name '=' const_expr ',' { - assert(current_enum != NULL); + assert(current_enum != nullptr); current_enum->add_element($2->get_simple_name(), $4, current_lexer, @2); }; @@ -2891,12 +2891,12 @@ enum_body: enum_body_trailing_comma | enum_body_trailing_comma name { - assert(current_enum != NULL); - current_enum->add_element($2->get_simple_name(), NULL, current_lexer, @2); + assert(current_enum != nullptr); + current_enum->add_element($2->get_simple_name(), nullptr, current_lexer, @2); } | enum_body_trailing_comma name '=' const_expr { - assert(current_enum != NULL); + assert(current_enum != nullptr); current_enum->add_element($2->get_simple_name(), $4, current_lexer, @2); } ; @@ -2935,11 +2935,11 @@ namespace_declaration: KW_NAMESPACE name '{' { CPPScope *scope = $2->find_scope(current_scope, global_scope, current_lexer); - if (scope == NULL) { + if (scope == nullptr) { // This must be a new namespace declaration. CPPScope *parent_scope = $2->get_scope(current_scope, global_scope, current_lexer); - if (parent_scope == NULL) { + if (parent_scope == nullptr) { parent_scope = current_scope; } scope = new CPPScope(parent_scope, $2->_names.back(), V_public); @@ -2957,11 +2957,11 @@ namespace_declaration: | KW_INLINE KW_NAMESPACE name '{' { CPPScope *scope = $3->find_scope(current_scope, global_scope, current_lexer); - if (scope == NULL) { + if (scope == nullptr) { // This must be a new namespace declaration. CPPScope *parent_scope = $3->get_scope(current_scope, global_scope, current_lexer); - if (parent_scope == NULL) { + if (parent_scope == nullptr) { parent_scope = current_scope; } scope = new CPPScope(parent_scope, $3->_names.back(), V_public); @@ -3165,7 +3165,7 @@ element: optional_const_expr: empty { - $$ = (CPPExpression *)NULL; + $$ = nullptr; } | const_expr { @@ -3176,7 +3176,7 @@ optional_const_expr: optional_const_expr_comma: empty { - $$ = (CPPExpression *)NULL; + $$ = nullptr; } | const_expr_comma { @@ -3227,7 +3227,7 @@ no_angle_bracket_const_expr: | KW_SIZEOF '(' IDENTIFIER ')' %prec UNARY { CPPDeclaration *arg = $3->find_symbol(current_scope, global_scope, current_lexer); - if (arg == (CPPDeclaration *)NULL) { + if (arg == nullptr) { yyerror("undefined sizeof argument: " + $3->get_fully_scoped_name(), @3); } else if (arg->get_subtype() == CPPDeclaration::ST_instance) { CPPInstance *inst = arg->as_instance(); @@ -3392,20 +3392,20 @@ const_expr: { // A constructor call. CPPType *type = $1->find_type(current_scope, global_scope, false, current_lexer); - if (type == NULL) { + if (type == nullptr) { yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1); } - assert(type != NULL); + assert(type != nullptr); $$ = new CPPExpression(CPPExpression::construct_op(type, $3)); } | TYPENAME_IDENTIFIER '{' optional_const_expr_comma '}' { // Aggregate initialization. CPPType *type = $1->find_type(current_scope, global_scope, false, current_lexer); - if (type == NULL) { + if (type == nullptr) { yyerror(string("internal error resolving type ") + $1->get_fully_scoped_name(), @1); } - assert(type != NULL); + assert(type != nullptr); $$ = new CPPExpression(CPPExpression::aggregate_init_op(type, $3)); } | KW_INT '(' optional_const_expr_comma ')' @@ -3491,7 +3491,7 @@ const_expr: | KW_SIZEOF '(' IDENTIFIER ')' %prec UNARY { CPPDeclaration *arg = $3->find_symbol(current_scope, global_scope, current_lexer); - if (arg == (CPPDeclaration *)NULL) { + if (arg == nullptr) { yyerror("undefined sizeof argument: " + $3->get_fully_scoped_name(), @3); } else if (arg->get_subtype() == CPPDeclaration::ST_instance) { CPPInstance *inst = arg->as_instance(); @@ -3835,7 +3835,7 @@ formal_const_expr: | KW_SIZEOF '(' IDENTIFIER ')' %prec UNARY { CPPDeclaration *arg = $3->find_symbol(current_scope, global_scope, current_lexer); - if (arg == (CPPDeclaration *)NULL) { + if (arg == nullptr) { yyerror("undefined sizeof argument: " + $3->get_fully_scoped_name(), @3); } else if (arg->get_subtype() == CPPDeclaration::ST_instance) { CPPInstance *inst = arg->as_instance(); @@ -4123,7 +4123,7 @@ class_derivation_name: name { CPPType *type = $1->find_type(current_scope, global_scope, true); - if (type == NULL) { + if (type == nullptr) { type = CPPType::new_type(new CPPTBDType($1)); } $$ = type; diff --git a/dtool/src/cppparser/cppClassTemplateParameter.cxx b/dtool/src/cppparser/cppClassTemplateParameter.cxx index 7ed9a94faf..46fb525b8b 100644 --- a/dtool/src/cppparser/cppClassTemplateParameter.cxx +++ b/dtool/src/cppparser/cppClassTemplateParameter.cxx @@ -46,7 +46,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (_packed) { out << "..."; } - if (_ident != NULL) { + if (_ident != nullptr) { out << " "; _ident->output(out, scope); } @@ -83,7 +83,7 @@ as_class_template_parameter() { bool CPPClassTemplateParameter:: is_equal(const CPPDeclaration *other) const { const CPPClassTemplateParameter *ot = ((CPPDeclaration *)other)->as_class_template_parameter(); - assert(ot != NULL); + assert(ot != nullptr); if (_default_type != ot->_default_type) { return false; @@ -93,7 +93,7 @@ is_equal(const CPPDeclaration *other) const { return false; } - if (_ident == NULL || ot->_ident == NULL) { + if (_ident == nullptr || ot->_ident == nullptr) { return _ident == ot->_ident; } @@ -108,7 +108,7 @@ is_equal(const CPPDeclaration *other) const { bool CPPClassTemplateParameter:: is_less(const CPPDeclaration *other) const { const CPPClassTemplateParameter *ot = ((CPPDeclaration *)other)->as_class_template_parameter(); - assert(ot != NULL); + assert(ot != nullptr); if (_default_type != ot->_default_type) { return _default_type < ot->_default_type; @@ -118,7 +118,7 @@ is_less(const CPPDeclaration *other) const { return _packed < ot->_packed; } - if (_ident == NULL || ot->_ident == NULL) { + if (_ident == nullptr || ot->_ident == nullptr) { return _ident < ot->_ident; } diff --git a/dtool/src/cppparser/cppClassTemplateParameter.h b/dtool/src/cppparser/cppClassTemplateParameter.h index d936ca01ea..5192619ed2 100644 --- a/dtool/src/cppparser/cppClassTemplateParameter.h +++ b/dtool/src/cppparser/cppClassTemplateParameter.h @@ -26,7 +26,7 @@ class CPPIdentifier; class CPPClassTemplateParameter : public CPPType { public: CPPClassTemplateParameter(CPPIdentifier *ident, - CPPType *default_type = NULL); + CPPType *default_type = nullptr); virtual bool is_fully_specified() const; virtual void output(ostream &out, int indent_level, CPPScope *scope, diff --git a/dtool/src/cppparser/cppClosureType.cxx b/dtool/src/cppparser/cppClosureType.cxx index 30197057a6..974742e5df 100644 --- a/dtool/src/cppparser/cppClosureType.cxx +++ b/dtool/src/cppparser/cppClosureType.cxx @@ -20,7 +20,7 @@ */ CPPClosureType:: CPPClosureType(CaptureType default_capture) : - CPPFunctionType(NULL, NULL, 0), + CPPFunctionType(nullptr, nullptr, 0), _default_capture(default_capture) { } @@ -134,7 +134,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { } out << capture._name; - if (capture._initializer != NULL) { + if (capture._initializer != nullptr) { out << " = " << *capture._initializer; } @@ -142,7 +142,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { } out.put(']'); - if (_parameters != NULL) { + if (_parameters != nullptr) { out.put('('); _parameters->output(out, scope, true, -1); out.put(')'); @@ -152,7 +152,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { out << " noexcept"; } - if (_return_type != NULL) { + if (_return_type != nullptr) { out << " -> "; _return_type->output(out, indent_level, scope, false); } diff --git a/dtool/src/cppparser/cppClosureType.h b/dtool/src/cppparser/cppClosureType.h index 85b392ba85..96ac38ed17 100644 --- a/dtool/src/cppparser/cppClosureType.h +++ b/dtool/src/cppparser/cppClosureType.h @@ -44,7 +44,7 @@ public: CaptureType _default_capture; - void add_capture(string name, CaptureType type, CPPExpression *initializer = NULL); + void add_capture(string name, CaptureType type, CPPExpression *initializer = nullptr); virtual bool is_fully_specified() const; diff --git a/dtool/src/cppparser/cppConstType.cxx b/dtool/src/cppparser/cppConstType.cxx index f1851b5233..f7eb198782 100644 --- a/dtool/src/cppparser/cppConstType.cxx +++ b/dtool/src/cppparser/cppConstType.cxx @@ -160,7 +160,7 @@ is_convertible_to(const CPPType *other) const { bool CPPConstType:: is_equivalent(const CPPType &other) const { const CPPConstType *ot = ((CPPType *)&other)->as_const_type(); - if (ot == (CPPConstType *)NULL) { + if (ot == nullptr) { return CPPType::is_equivalent(other); } @@ -213,7 +213,7 @@ as_const_type() { bool CPPConstType:: is_equal(const CPPDeclaration *other) const { const CPPConstType *ot = ((CPPDeclaration *)other)->as_const_type(); - assert(ot != NULL); + assert(ot != nullptr); return _wrapped_around == ot->_wrapped_around; } @@ -226,7 +226,7 @@ is_equal(const CPPDeclaration *other) const { bool CPPConstType:: is_less(const CPPDeclaration *other) const { const CPPConstType *ot = ((CPPDeclaration *)other)->as_const_type(); - assert(ot != NULL); + assert(ot != nullptr); return _wrapped_around < ot->_wrapped_around; } diff --git a/dtool/src/cppparser/cppDeclaration.cxx b/dtool/src/cppparser/cppDeclaration.cxx index 3d2e5e68f5..444801ceea 100644 --- a/dtool/src/cppparser/cppDeclaration.cxx +++ b/dtool/src/cppparser/cppDeclaration.cxx @@ -22,8 +22,8 @@ CPPDeclaration(const CPPFile &file) : _file(file) { _vis = V_unknown; - _template_scope = NULL; - _leading_comment = (CPPCommentBlock *)NULL; + _template_scope = nullptr; + _leading_comment = nullptr; } /** @@ -86,7 +86,7 @@ operator < (const CPPDeclaration &other) const { */ bool CPPDeclaration:: is_template() const { - return _template_scope != NULL; + return _template_scope != nullptr; } /** @@ -116,7 +116,7 @@ CPPDeclaration *CPPDeclaration:: instantiate(const CPPTemplateParameterList *, CPPScope *, CPPScope *, CPPPreprocessor *error_sink) const { - if (error_sink != NULL) { + if (error_sink != nullptr) { error_sink->warning("Ignoring template parameters"); } return (CPPDeclaration *)this; @@ -129,7 +129,7 @@ CPPDeclaration *CPPDeclaration:: substitute_decl(SubstDecl &subst, CPPScope *, CPPScope *) { SubstDecl::const_iterator si = subst.find(this); if (si != subst.end()) { - assert((*si).second != NULL); + assert((*si).second != nullptr); return (*si).second; } return this; @@ -140,7 +140,7 @@ substitute_decl(SubstDecl &subst, CPPScope *, CPPScope *) { */ CPPInstance *CPPDeclaration:: as_instance() { - return (CPPInstance *)NULL; + return nullptr; } /** @@ -148,7 +148,7 @@ as_instance() { */ CPPClassTemplateParameter *CPPDeclaration:: as_class_template_parameter() { - return (CPPClassTemplateParameter *)NULL; + return nullptr; } /** @@ -156,7 +156,7 @@ as_class_template_parameter() { */ CPPTypedefType *CPPDeclaration:: as_typedef_type() { - return (CPPTypedefType *)NULL; + return nullptr; } /** @@ -164,7 +164,7 @@ as_typedef_type() { */ CPPTypeDeclaration *CPPDeclaration:: as_type_declaration() { - return (CPPTypeDeclaration *)NULL; + return nullptr; } /** @@ -172,7 +172,7 @@ as_type_declaration() { */ CPPExpression *CPPDeclaration:: as_expression() { - return (CPPExpression *)NULL; + return nullptr; } /** @@ -180,7 +180,7 @@ as_expression() { */ CPPType *CPPDeclaration:: as_type() { - return (CPPType *)NULL; + return nullptr; } /** @@ -188,7 +188,7 @@ as_type() { */ CPPNamespace *CPPDeclaration:: as_namespace() { - return (CPPNamespace *)NULL; + return nullptr; } /** @@ -196,7 +196,7 @@ as_namespace() { */ CPPUsing *CPPDeclaration:: as_using() { - return (CPPUsing *)NULL; + return nullptr; } /** @@ -204,7 +204,7 @@ as_using() { */ CPPSimpleType *CPPDeclaration:: as_simple_type() { - return (CPPSimpleType *)NULL; + return nullptr; } /** @@ -212,7 +212,7 @@ as_simple_type() { */ CPPPointerType *CPPDeclaration:: as_pointer_type() { - return (CPPPointerType *)NULL; + return nullptr; } /** @@ -220,7 +220,7 @@ as_pointer_type() { */ CPPReferenceType *CPPDeclaration:: as_reference_type() { - return (CPPReferenceType *)NULL; + return nullptr; } /** @@ -228,7 +228,7 @@ as_reference_type() { */ CPPArrayType *CPPDeclaration:: as_array_type() { - return (CPPArrayType *)NULL; + return nullptr; } /** @@ -236,7 +236,7 @@ as_array_type() { */ CPPConstType *CPPDeclaration:: as_const_type() { - return (CPPConstType *)NULL; + return nullptr; } /** @@ -244,7 +244,7 @@ as_const_type() { */ CPPFunctionType *CPPDeclaration:: as_function_type() { - return (CPPFunctionType *)NULL; + return nullptr; } /** @@ -252,7 +252,7 @@ as_function_type() { */ CPPFunctionGroup *CPPDeclaration:: as_function_group() { - return (CPPFunctionGroup *)NULL; + return nullptr; } /** @@ -260,7 +260,7 @@ as_function_group() { */ CPPExtensionType *CPPDeclaration:: as_extension_type() { - return (CPPExtensionType *)NULL; + return nullptr; } /** @@ -268,7 +268,7 @@ as_extension_type() { */ CPPStructType *CPPDeclaration:: as_struct_type() { - return (CPPStructType *)NULL; + return nullptr; } /** @@ -276,7 +276,7 @@ as_struct_type() { */ CPPEnumType *CPPDeclaration:: as_enum_type() { - return (CPPEnumType *)NULL; + return nullptr; } /** @@ -284,7 +284,7 @@ as_enum_type() { */ CPPTBDType *CPPDeclaration:: as_tbd_type() { - return (CPPTBDType *)NULL; + return nullptr; } /** @@ -292,7 +292,7 @@ as_tbd_type() { */ CPPTypeProxy *CPPDeclaration:: as_type_proxy() { - return (CPPTypeProxy *)NULL; + return nullptr; } /** @@ -300,7 +300,7 @@ as_type_proxy() { */ CPPMakeProperty *CPPDeclaration:: as_make_property() { - return (CPPMakeProperty *)NULL; + return nullptr; } /** @@ -308,7 +308,7 @@ as_make_property() { */ CPPMakeSeq *CPPDeclaration:: as_make_seq() { - return (CPPMakeSeq *)NULL; + return nullptr; } /** @@ -316,7 +316,7 @@ as_make_seq() { */ CPPClosureType *CPPDeclaration:: as_closure_type() { - return (CPPClosureType *)NULL; + return nullptr; } /** @@ -343,13 +343,13 @@ operator << (ostream &out, const CPPDeclaration::SubstDecl &subst) { CPPDeclaration::SubstDecl::const_iterator it; for (it = subst.begin(); it != subst.end(); ++it) { out << " "; - if (it->first == NULL) { + if (it->first == nullptr) { out << "(null)"; } else { out << *(it->first); } out << " -> "; - if (it->second == NULL) { + if (it->second == nullptr) { out << "(null)"; } else { out << *(it->second); diff --git a/dtool/src/cppparser/cppDeclaration.h b/dtool/src/cppparser/cppDeclaration.h index 8acaf6e50c..f590f435fa 100644 --- a/dtool/src/cppparser/cppDeclaration.h +++ b/dtool/src/cppparser/cppDeclaration.h @@ -105,7 +105,7 @@ public: virtual CPPDeclaration * instantiate(const CPPTemplateParameterList *actual_params, CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; typedef map SubstDecl; virtual CPPDeclaration *substitute_decl(SubstDecl &subst, @@ -226,7 +226,7 @@ protected: inline ostream & operator << (ostream &out, const CPPDeclaration &decl) { - decl.output(out, 0, (CPPScope *)NULL, false); + decl.output(out, 0, nullptr, false); return out; } diff --git a/dtool/src/cppparser/cppEnumType.cxx b/dtool/src/cppparser/cppEnumType.cxx index fbc3a7df53..ffbce64a7d 100644 --- a/dtool/src/cppparser/cppEnumType.cxx +++ b/dtool/src/cppparser/cppEnumType.cxx @@ -29,12 +29,12 @@ CPPEnumType(Type type, CPPIdentifier *ident, CPPScope *current_scope, CPPScope *scope, const CPPFile &file) : CPPExtensionType(type, ident, current_scope, file), _scope(scope), - _element_type(NULL), - _last_value(NULL) + _element_type(nullptr), + _last_value(nullptr) { _parent_scope = (type == T_enum) ? current_scope : scope; - if (ident != NULL) { + if (ident != nullptr) { ident->_native_scope = current_scope; } } @@ -48,10 +48,10 @@ CPPEnumType(Type type, CPPIdentifier *ident, CPPType *element_type, CPPExtensionType(type, ident, current_scope, file), _scope(scope), _element_type(element_type), - _last_value(NULL) + _last_value(nullptr) { _parent_scope = (type == T_enum) ? current_scope : scope; - if (ident != NULL) { + if (ident != nullptr) { ident->_native_scope = current_scope; } } @@ -69,11 +69,11 @@ is_scoped() const { */ CPPType *CPPEnumType:: get_underlying_type() { - if (_element_type == NULL) { + if (_element_type == nullptr) { // This enum is untyped. Use a suitable default, ie. 'int'. In the // future, we might want to check whether it fits in an int. - static CPPType *default_element_type = NULL; - if (default_element_type == NULL) { + static CPPType *default_element_type = nullptr; + if (default_element_type == nullptr) { default_element_type = CPPType::new_type(new CPPConstType(new CPPSimpleType(CPPSimpleType::T_int, 0))); } @@ -104,8 +104,8 @@ add_element(const string &name, CPPExpression *value, CPPPreprocessor *preproces inst->_storage_class |= CPPInstance::SC_constexpr; _elements.push_back(inst); - if (value == (CPPExpression *)NULL) { - if (_last_value == (CPPExpression *)NULL) { + if (value == nullptr) { + if (_last_value == nullptr) { // This is the first value, and should therefore be 0. static CPPExpression *const zero = new CPPExpression(0); value = zero; @@ -123,17 +123,17 @@ add_element(const string &name, CPPExpression *value, CPPPreprocessor *preproces inst->_initializer = value; _last_value = value; - if (preprocessor != (CPPPreprocessor *)NULL) { + if (preprocessor != nullptr) { // Same-line comment? CPPCommentBlock *comment = preprocessor->get_comment_on(pos.first_line, pos.file); - if (comment == (CPPCommentBlock *)NULL) { + if (comment == nullptr) { // Nope. Check for a comment before this line. comment = preprocessor->get_comment_before(pos.first_line, pos.file); - if (comment != NULL) { + if (comment != nullptr) { // This is a bit of a hack, but it prevents us from picking up a same- // line comment from the previous line. if (comment->_line_number != pos.first_line - 1 || @@ -148,12 +148,12 @@ add_element(const string &name, CPPExpression *value, CPPPreprocessor *preproces } // Add the value to the enum scope (as per C++11), assuming it's not anonymous. - if (_scope != NULL) { + if (_scope != nullptr) { _scope->add_enum_value(inst); } // Now add it to the containing scope as well if it's not an "enum class". - if (!is_scoped() && _parent_scope != NULL) { + if (!is_scoped() && _parent_scope != nullptr) { _parent_scope->add_enum_value(inst); } @@ -179,11 +179,11 @@ is_fully_specified() const { return false; } - if (_ident != NULL && !_ident->is_fully_specified()) { + if (_ident != nullptr && !_ident->is_fully_specified()) { return false; } - if (_element_type != NULL && !_element_type->is_fully_specified()) { + if (_element_type != nullptr && !_element_type->is_fully_specified()) { return false; } @@ -210,12 +210,12 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, CPPEnumType *rep = new CPPEnumType(*this); - if (_ident != NULL) { + if (_ident != nullptr) { rep->_ident = _ident->substitute_decl(subst, current_scope, global_scope); } - if (_element_type != NULL) { + if (_element_type != nullptr) { rep->_element_type = _element_type->substitute_decl(subst, current_scope, global_scope) ->as_type(); @@ -263,7 +263,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, */ void CPPEnumType:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { - if (!complete && _ident != NULL) { + if (!complete && _ident != nullptr) { // If we have a name, use it. if (cppparser_output_class_keyword) { out << _type << " "; @@ -272,10 +272,10 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { } else { out << _type; - if (_ident != NULL) { + if (_ident != nullptr) { out << " " << _ident->get_local_name(scope); } - if (_element_type != NULL) { + if (_element_type != nullptr) { out << " : " << _element_type->get_local_name(scope); } @@ -283,7 +283,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { Elements::const_iterator ei; for (ei = _elements.begin(); ei != _elements.end(); ++ei) { indent(out, indent_level + 2) << (*ei)->get_local_name(); - if ((*ei)->_initializer != NULL) { + if ((*ei)->_initializer != nullptr) { out << " = " << *(*ei)->_initializer; } out << ",\n"; diff --git a/dtool/src/cppparser/cppExpression.cxx b/dtool/src/cppparser/cppExpression.cxx index 139ac72d1b..ed36275af9 100644 --- a/dtool/src/cppparser/cppExpression.cxx +++ b/dtool/src/cppparser/cppExpression.cxx @@ -131,7 +131,7 @@ as_pointer() const { default: cerr << "Invalid type\n"; assert(false); - return (void *)NULL; + return nullptr; } } @@ -148,7 +148,7 @@ as_boolean() const { return (_u._real != 0.0); case RT_pointer: - return (_u._pointer != NULL); + return (_u._pointer != nullptr); default: cerr << "Invalid type\n"; @@ -250,15 +250,15 @@ CPPExpression(CPPIdentifier *ident, CPPScope *current_scope, CPPDeclaration *decl = ident->find_symbol(current_scope, global_scope); - if (decl != NULL) { + if (decl != nullptr) { CPPInstance *inst = decl->as_instance(); - if (inst != NULL) { + if (inst != nullptr) { _type = T_variable; _u._variable = inst; return; } CPPFunctionGroup *fgroup = decl->as_function_group(); - if (fgroup != NULL) { + if (fgroup != nullptr) { _type = T_function; _u._fgroup = fgroup; return; @@ -280,8 +280,8 @@ CPPExpression(int unary_operator, CPPExpression *op1) : _type = T_unary_operation; _u._op._operator = unary_operator; _u._op._op1 = op1; - _u._op._op2 = NULL; - _u._op._op3 = NULL; + _u._op._op2 = nullptr; + _u._op._op3 = nullptr; } /** @@ -295,7 +295,7 @@ CPPExpression(int binary_operator, CPPExpression *op1, CPPExpression *op2) : _u._op._operator = binary_operator; _u._op._op1 = op1; _u._op._op2 = op2; - _u._op._op3 = NULL; + _u._op._op3 = nullptr; } /** @@ -332,11 +332,11 @@ typecast_op(CPPType *type, CPPExpression *op1, Type cast_type) { CPPExpression CPPExpression:: construct_op(CPPType *type, CPPExpression *op1) { CPPExpression expr(0); - if (op1 == NULL) { + if (op1 == nullptr) { // A default constructor call--no parameters. expr._type = T_default_construct; expr._u._typecast._to = type; - expr._u._typecast._op1 = NULL; + expr._u._typecast._op1 = nullptr; } else { // A normal constructor call, with parameters. expr._type = T_construct; @@ -352,7 +352,7 @@ construct_op(CPPType *type, CPPExpression *op1) { CPPExpression CPPExpression:: aggregate_init_op(CPPType *type, CPPExpression *op1) { CPPExpression expr(0); - if (op1 == NULL) { + if (op1 == nullptr) { expr._type = T_empty_aggregate_init; } else { expr._type = T_aggregate_init; @@ -368,11 +368,11 @@ aggregate_init_op(CPPType *type, CPPExpression *op1) { CPPExpression CPPExpression:: new_op(CPPType *type, CPPExpression *op1) { CPPExpression expr(0); - if (op1 == NULL) { + if (op1 == nullptr) { // A default new operation--no parameters. expr._type = T_default_new; expr._u._typecast._to = type; - expr._u._typecast._op1 = NULL; + expr._u._typecast._op1 = nullptr; } else { // A normal new operation, with parameters. expr._type = T_new; @@ -427,7 +427,7 @@ sizeof_func(CPPType *type) { CPPExpression expr(0); expr._type = T_sizeof; expr._u._typecast._to = type; - expr._u._typecast._op1 = NULL; + expr._u._typecast._op1 = nullptr; return expr; } @@ -450,7 +450,7 @@ alignof_func(CPPType *type) { CPPExpression expr(0); expr._type = T_alignof; expr._u._typecast._to = type; - expr._u._typecast._op1 = NULL; + expr._u._typecast._op1 = nullptr; return expr; } @@ -509,7 +509,7 @@ raw_literal(const string &raw, CPPInstance *lit_op) { CPPExpression expr(0); expr._type = T_raw_literal; expr._str = raw; - expr._u._literal._value = (CPPExpression *)NULL; + expr._u._literal._value = nullptr; expr._u._literal._operator = lit_op; return expr; } @@ -553,7 +553,7 @@ evaluate() const { switch (_type) { case T_nullptr: - return Result((void *)0); + return Result(nullptr); case T_boolean: return Result((int)_u._boolean); @@ -572,15 +572,15 @@ evaluate() const { return Result(); case T_variable: - if (_u._variable->_type != NULL && - _u._variable->_initializer != NULL) { + if (_u._variable->_type != nullptr && + _u._variable->_initializer != nullptr) { // A constexpr variable, which is treated as const. if (_u._variable->_storage_class & CPPInstance::SC_constexpr) { return _u._variable->_initializer->evaluate(); } // A const variable. Fetch its assigned value. CPPConstType *const_type = _u._variable->_type->as_const_type(); - if (const_type != NULL) { + if (const_type != nullptr) { return _u._variable->_initializer->evaluate(); } } @@ -597,11 +597,11 @@ evaluate() const { case T_dynamic_cast: case T_const_cast: case T_reinterpret_cast: - assert(_u._typecast._op1 != NULL); + assert(_u._typecast._op1 != nullptr); r1 = _u._typecast._op1->evaluate(); if (r1._type != RT_error) { CPPSimpleType *stype = _u._typecast._to->as_simple_type(); - if (stype != NULL) { + if (stype != nullptr) { if (stype->_type == CPPSimpleType::T_bool) { return Result(r1.as_boolean()); @@ -630,18 +630,18 @@ evaluate() const { return Result(); case T_alignof: - if (_u._typecast._to != NULL) { + if (_u._typecast._to != nullptr) { // Check if the type is defined with an alignas. TODO: this should // probably be moved to a virtual getter on CPPType. CPPExtensionType *etype = _u._typecast._to->as_extension_type(); - if (etype != NULL && etype->_alignment != NULL) { + if (etype != nullptr && etype->_alignment != nullptr) { return etype->_alignment->evaluate(); } } return Result(); case T_binary_operation: - assert(_u._op._op2 != NULL); + assert(_u._op._op2 != nullptr); r2 = _u._op._op2->evaluate(); // The operators && and || are special cases: these are shirt-circuiting @@ -666,7 +666,7 @@ evaluate() const { // Fall through case T_unary_operation: - assert(_u._op._op1 != NULL); + assert(_u._op._op1 != nullptr); r1 = _u._op._op1->evaluate(); if (r1._type == RT_error) { // Here's one more special case: if the first operand is invalid, it @@ -854,39 +854,39 @@ evaluate() const { case KW_HAS_VIRTUAL_DESTRUCTOR: { CPPStructType *struct_type = _u._type_trait._type->as_struct_type(); - return Result(struct_type != NULL && struct_type->has_virtual_destructor()); + return Result(struct_type != nullptr && struct_type->has_virtual_destructor()); } case KW_IS_ABSTRACT: { CPPStructType *struct_type = _u._type_trait._type->as_struct_type(); - return Result(struct_type != NULL && struct_type->is_abstract()); + return Result(struct_type != nullptr && struct_type->is_abstract()); } case KW_IS_BASE_OF: { CPPStructType *struct_type1 = _u._type_trait._type->as_struct_type(); CPPStructType *struct_type2 = _u._type_trait._arg->as_struct_type(); - return Result(struct_type1 != NULL && struct_type2 != NULL && struct_type1->is_base_of(struct_type2)); + return Result(struct_type1 != nullptr && struct_type2 != nullptr && struct_type1->is_base_of(struct_type2)); } case KW_IS_CLASS: { CPPExtensionType *ext_type = _u._type_trait._type->as_extension_type(); - return Result(ext_type != NULL && ( + return Result(ext_type != nullptr && ( ext_type->_type == CPPExtensionType::T_class || ext_type->_type == CPPExtensionType::T_struct)); } case KW_IS_CONSTRUCTIBLE: - if (_u._type_trait._arg == NULL) { + if (_u._type_trait._arg == nullptr) { return Result(_u._type_trait._type->is_default_constructible()); } else { return Result(_u._type_trait._type->is_constructible(_u._type_trait._arg)); } case KW_IS_CONVERTIBLE_TO: - assert(_u._type_trait._arg != NULL); + assert(_u._type_trait._arg != nullptr); return Result(_u._type_trait._type->is_convertible_to(_u._type_trait._arg)); case KW_IS_DESTRUCTIBLE: @@ -895,7 +895,7 @@ evaluate() const { case KW_IS_EMPTY: { CPPStructType *struct_type = _u._type_trait._type->as_struct_type(); - return Result(struct_type != NULL && struct_type->is_empty()); + return Result(struct_type != nullptr && struct_type->is_empty()); } case KW_IS_ENUM: @@ -904,7 +904,7 @@ evaluate() const { case KW_IS_FINAL: { CPPStructType *struct_type = _u._type_trait._type->as_struct_type(); - return Result(struct_type != NULL && struct_type->is_final()); + return Result(struct_type != nullptr && struct_type->is_final()); } case KW_IS_FUNDAMENTAL: @@ -917,7 +917,7 @@ evaluate() const { case KW_IS_POLYMORPHIC: { CPPStructType *struct_type = _u._type_trait._type->as_struct_type(); - return Result(struct_type != NULL && struct_type->is_polymorphic()); + return Result(struct_type != nullptr && struct_type->is_polymorphic()); } case KW_IS_STANDARD_LAYOUT: @@ -929,7 +929,7 @@ evaluate() const { case KW_IS_UNION: { CPPExtensionType *ext_type = _u._type_trait._type->as_extension_type(); - return Result(ext_type != NULL && + return Result(ext_type != nullptr && ext_type->_type == CPPExtensionType::T_union); } @@ -952,8 +952,8 @@ evaluate() const { */ CPPType *CPPExpression:: determine_type() const { - CPPType *t1 = (CPPType *)NULL; - CPPType *t2 = (CPPType *)NULL; + CPPType *t1 = nullptr; + CPPType *t2 = nullptr; static CPPType *nullptr_type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_nullptr)); @@ -1028,16 +1028,16 @@ determine_type() const { return _u._variable->_type; case T_function: - if (_u._fgroup->get_return_type() == (CPPType *)NULL) { + if (_u._fgroup->get_return_type() == nullptr) { // There are multiple functions by this name that have different return // types. We could attempt to differentiate them based on the parameter // list, but that's a lot of work. Let's just give up. - return (CPPType *)NULL; + return nullptr; } return _u._fgroup->_instances.front()->_type; case T_unknown_ident: - return (CPPType *)NULL; + return nullptr; case T_typecast: case T_static_cast: @@ -1064,12 +1064,12 @@ determine_type() const { case T_binary_operation: case T_trinary_operation: - assert(_u._op._op2 != NULL); + assert(_u._op._op2 != nullptr); t2 = _u._op._op2->determine_type(); // Fall through case T_unary_operation: - assert(_u._op._op1 != NULL); + assert(_u._op._op1 != nullptr); t1 = _u._op._op1->determine_type(); switch (_u._op._operator) { @@ -1081,7 +1081,7 @@ determine_type() const { case UNARY_MINUS: case UNARY_PLUS: - if (t1 != NULL) { + if (t1 != nullptr) { switch (t1->get_subtype()) { case CPPDeclaration::ST_array: // Decay into pointer. @@ -1107,11 +1107,11 @@ determine_type() const { return t1; } } - return NULL; + return nullptr; case UNARY_STAR: case '[': // Array element reference - if (t1 != NULL) { + if (t1 != nullptr) { if (t1->as_pointer_type()) { return t1->as_pointer_type()->_pointing_at; } @@ -1119,7 +1119,7 @@ determine_type() const { return t1->as_array_type()->_element_type; } } - return NULL; + return nullptr; case UNARY_REF: return t1; @@ -1128,9 +1128,9 @@ determine_type() const { case '/': case '+': case '-': - if (t1 == NULL) { + if (t1 == nullptr) { return t2; - } else if (t2 == NULL) { + } else if (t2 == nullptr) { return t1; } else if (t1->as_pointer_type()) { if (t2->as_pointer_type()) { @@ -1162,25 +1162,25 @@ determine_type() const { case '.': case POINTSAT: - return NULL; + return nullptr; case 'f': // Function evaluation - if (t1 != NULL) { + if (t1 != nullptr) { // Easy case, function with only a single overload. CPPFunctionType *ftype = t1->as_function_type(); - if (ftype != (CPPFunctionType *)NULL) { + if (ftype != nullptr) { return ftype->_return_type; } } else if (_u._op._op1->_type == T_function) { CPPFunctionGroup *fgroup = _u._op._op1->_u._fgroup; - if (_u._op._op2 == NULL) { + if (_u._op._op2 == nullptr) { // If we are passing no args, look for an overload that has takes no // args. for (auto it = fgroup->_instances.begin(); it != fgroup->_instances.end(); ++it) { CPPInstance *inst = *it; - if (inst != NULL && inst->_type != NULL) { + if (inst != nullptr && inst->_type != nullptr) { CPPFunctionType *type = inst->_type->as_function_type(); - if (type != NULL && type->accepts_num_parameters(0)) { + if (type != nullptr && type->accepts_num_parameters(0)) { return type->_return_type; } } @@ -1189,7 +1189,7 @@ determine_type() const { //TODO } } - return NULL; + return nullptr; case ',': return t2; @@ -1201,15 +1201,15 @@ determine_type() const { case T_literal: case T_raw_literal: - if (_u._literal._operator != NULL) { + if (_u._literal._operator != nullptr) { CPPType *type = _u._literal._operator->_type; CPPFunctionType *ftype = type->as_function_type(); - if (ftype != (CPPFunctionType *)NULL) { + if (ftype != nullptr) { return ftype->_return_type; } } - return NULL; + return nullptr; case T_typeid_type: case T_typeid_expr: @@ -1226,7 +1226,7 @@ determine_type() const { abort(); } - return NULL; // Compiler kludge; can't get here. + return nullptr; // Compiler kludge; can't get here. } /** @@ -1361,9 +1361,9 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, // See if we can define it now. decl = rep->_u._ident->find_symbol(current_scope, global_scope, subst); - if (decl != NULL) { + if (decl != nullptr) { CPPInstance *inst = decl->as_instance(); - if (inst != NULL) { + if (inst != nullptr) { rep->_type = T_variable; rep->_u._variable = inst; any_changed = true; @@ -1384,7 +1384,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, break; } CPPFunctionGroup *fgroup = decl->as_function_group(); - if (fgroup != NULL) { + if (fgroup != nullptr) { rep->_type = T_function; rep->_u._fgroup = fgroup; any_changed = true; @@ -1481,13 +1481,13 @@ bool CPPExpression:: is_tbd() const { switch (_type) { case T_variable: - if (_u._variable->_type != NULL && - _u._variable->_initializer != NULL) { + if (_u._variable->_type != nullptr && + _u._variable->_initializer != nullptr) { if (_u._variable->_storage_class & CPPInstance::SC_constexpr) { return false; } CPPConstType *const_type = _u._variable->_type->as_const_type(); - if (const_type != NULL) { + if (const_type != nullptr) { return false; } } @@ -1643,13 +1643,13 @@ output(ostream &out, int indent_level, CPPScope *scope, bool) const { // We can just refer to the variable by name, except if it's a private // constant, in which case we have to compute the value, since we may have // to use it in generated code. - if (_u._variable->_type != NULL && - _u._variable->_initializer != NULL && + if (_u._variable->_type != nullptr && + _u._variable->_initializer != nullptr && _u._variable->_vis > V_public) { // A constexpr or const variable. Fetch its assigned value. CPPConstType *const_type = _u._variable->_type->as_const_type(); if ((_u._variable->_storage_class & CPPInstance::SC_constexpr) != 0 || - const_type != NULL) { + const_type != nullptr) { _u._variable->_initializer->output(out, indent_level, scope, false); break; } @@ -1659,7 +1659,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool) const { case T_function: // Pick any instance; they all have the same name anyway. - if (!_u._fgroup->_instances.empty() && _u._fgroup->_instances[0]->_ident != NULL) { + if (!_u._fgroup->_instances.empty() && _u._fgroup->_instances[0]->_ident != nullptr) { _u._fgroup->_instances[0]->_ident->output(out, scope); } else { out << _u._fgroup->_name; @@ -1936,7 +1936,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool) const { case T_literal: _u._literal._value->output(out, indent_level, scope, false); - if (_u._literal._operator != NULL) { + if (_u._literal._operator != nullptr) { string name = _u._literal._operator->get_simple_name(); assert(name.substr(0, 12) == "operator \"\" "); out << name.substr(12); @@ -1945,7 +1945,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool) const { case T_raw_literal: out << _str; - if (_u._literal._operator != NULL) { + if (_u._literal._operator != nullptr) { string name = _u._literal._operator->get_simple_name(); assert(name.substr(0, 12) == "operator \"\" "); out << name.substr(12); @@ -2064,9 +2064,9 @@ elevate_type(CPPType *t1, CPPType *t2) { CPPSimpleType *st1 = t1->as_simple_type(); CPPSimpleType *st2 = t2->as_simple_type(); - if (st1 == NULL || st2 == NULL) { + if (st1 == nullptr || st2 == nullptr) { // Nothing we can do about this. Who knows? - return NULL; + return nullptr; } if (st1->_type == st2->_type) { @@ -2113,7 +2113,7 @@ elevate_type(CPPType *t1, CPPType *t2) { bool CPPExpression:: is_equal(const CPPDeclaration *other) const { const CPPExpression *ot = ((CPPDeclaration *)other)->as_expression(); - assert(ot != NULL); + assert(ot != nullptr); if (_type != ot->_type) { return false; @@ -2213,7 +2213,7 @@ is_equal(const CPPDeclaration *other) const { bool CPPExpression:: is_less(const CPPDeclaration *other) const { const CPPExpression *ot = ((CPPDeclaration *)other)->as_expression(); - assert(ot != NULL); + assert(ot != nullptr); if (_type != ot->_type) { return (int)_type < (int)ot->_type; diff --git a/dtool/src/cppparser/cppExpression.h b/dtool/src/cppparser/cppExpression.h index 3178d4d178..0f9bc880e4 100644 --- a/dtool/src/cppparser/cppExpression.h +++ b/dtool/src/cppparser/cppExpression.h @@ -76,7 +76,7 @@ public: CPPExpression(const string &value); CPPExpression(long double value); CPPExpression(CPPIdentifier *ident, CPPScope *current_scope, - CPPScope *global_scope, CPPPreprocessor *error_sink = NULL); + CPPScope *global_scope, CPPPreprocessor *error_sink = nullptr); CPPExpression(int unary_operator, CPPExpression *op1); CPPExpression(int binary_operator, CPPExpression *op1, CPPExpression *op2); CPPExpression(int trinary_operator, CPPExpression *op1, CPPExpression *op2, CPPExpression *op3); @@ -84,10 +84,10 @@ public: static CPPExpression typecast_op(CPPType *type, CPPExpression *op1, Type cast_type = T_typecast); static CPPExpression construct_op(CPPType *type, CPPExpression *op1); static CPPExpression aggregate_init_op(CPPType *type, CPPExpression *op1); - static CPPExpression new_op(CPPType *type, CPPExpression *op1 = NULL); + static CPPExpression new_op(CPPType *type, CPPExpression *op1 = nullptr); static CPPExpression typeid_op(CPPType *type, CPPType *std_type_info); static CPPExpression typeid_op(CPPExpression *op1, CPPType *std_type_info); - static CPPExpression type_trait(int trait, CPPType *type, CPPType *arg = NULL); + static CPPExpression type_trait(int trait, CPPType *type, CPPType *arg = nullptr); static CPPExpression sizeof_func(CPPType *type); static CPPExpression sizeof_ellipsis_func(CPPIdentifier *ident); static CPPExpression alignof_func(CPPType *type); diff --git a/dtool/src/cppparser/cppExpressionParser.cxx b/dtool/src/cppparser/cppExpressionParser.cxx index 2ab7b30771..c0821712fc 100644 --- a/dtool/src/cppparser/cppExpressionParser.cxx +++ b/dtool/src/cppparser/cppExpressionParser.cxx @@ -22,7 +22,7 @@ CPPExpressionParser(CPPScope *current_scope, CPPScope *global_scope) : _current_scope(current_scope), _global_scope(global_scope) { - _expr = NULL; + _expr = nullptr; } /** @@ -69,7 +69,7 @@ parse_expr(const string &expr, const CPPPreprocessor &filepos) { */ void CPPExpressionParser:: output(ostream &out) const { - if (_expr == NULL) { + if (_expr == nullptr) { out << "(null expr)"; } else { out << *_expr; diff --git a/dtool/src/cppparser/cppExtensionType.cxx b/dtool/src/cppparser/cppExtensionType.cxx index eba135eb64..ef5168334b 100644 --- a/dtool/src/cppparser/cppExtensionType.cxx +++ b/dtool/src/cppparser/cppExtensionType.cxx @@ -26,9 +26,9 @@ CPPExtensionType(CPPExtensionType::Type type, const CPPFile &file) : CPPType(file), _type(type), _ident(ident), - _alignment(NULL) + _alignment(nullptr) { - if (_ident != NULL) { + if (_ident != nullptr) { _ident->_native_scope = current_scope; } } @@ -38,7 +38,7 @@ CPPExtensionType(CPPExtensionType::Type type, */ string CPPExtensionType:: get_simple_name() const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } return _ident->get_simple_name(); @@ -49,7 +49,7 @@ get_simple_name() const { */ string CPPExtensionType:: get_local_name(CPPScope *scope) const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } return _ident->get_local_name(scope); @@ -60,7 +60,7 @@ get_local_name(CPPScope *scope) const { */ string CPPExtensionType:: get_fully_scoped_name() const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } return _ident->get_fully_scoped_name(); @@ -81,7 +81,7 @@ is_incomplete() const { */ bool CPPExtensionType:: is_tbd() const { - if (_ident != (CPPIdentifier *)NULL) { + if (_ident != nullptr) { return _ident->is_tbd(); } return false; @@ -110,7 +110,7 @@ bool CPPExtensionType:: is_constructible(const CPPType *given_type) const { if (_type == T_enum || _type == T_enum_class || _type == T_enum_struct) { const CPPExtensionType *other = ((CPPType *)given_type)->remove_reference()->remove_const()->as_extension_type(); - return other != NULL && is_equal(other); + return other != nullptr && is_equal(other); } return false; } @@ -151,7 +151,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, } CPPExtensionType *rep = new CPPExtensionType(*this); - if (_ident != NULL) { + if (_ident != nullptr) { rep->_ident = _ident->substitute_decl(subst, current_scope, global_scope); } @@ -172,7 +172,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, */ CPPType *CPPExtensionType:: resolve_type(CPPScope *current_scope, CPPScope *global_scope) { - if (_ident == NULL) { + if (_ident == nullptr) { // We can't resolve anonymous types. But that's OK, since they can't be // forward declared anyway. return this; @@ -180,7 +180,7 @@ resolve_type(CPPScope *current_scope, CPPScope *global_scope) { // Maybe it has been defined by now. CPPType *type = _ident->find_type(current_scope, global_scope); - if (type != NULL) { + if (type != nullptr) { return type; } return this; @@ -195,7 +195,7 @@ resolve_type(CPPScope *current_scope, CPPScope *global_scope) { bool CPPExtensionType:: is_equivalent(const CPPType &other) const { const CPPExtensionType *ot = ((CPPType *)&other)->as_extension_type(); - if (ot == (CPPExtensionType *)NULL) { + if (ot == nullptr) { return CPPType::is_equivalent(other); } @@ -210,7 +210,7 @@ is_equivalent(const CPPType &other) const { */ void CPPExtensionType:: output(ostream &out, int, CPPScope *scope, bool complete) const { - if (_ident != NULL) { + if (_ident != nullptr) { // If we have a name, use it. if (complete || cppparser_output_class_keyword) { out << _type << " "; diff --git a/dtool/src/cppparser/cppExtensionType.h b/dtool/src/cppparser/cppExtensionType.h index dca9cf8cb3..5a44788af2 100644 --- a/dtool/src/cppparser/cppExtensionType.h +++ b/dtool/src/cppparser/cppExtensionType.h @@ -42,7 +42,7 @@ public: const CPPFile &file); virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = NULL) const; + virtual string get_local_name(CPPScope *scope = nullptr) const; virtual string get_fully_scoped_name() const; virtual bool is_incomplete() const; diff --git a/dtool/src/cppparser/cppFunctionGroup.cxx b/dtool/src/cppparser/cppFunctionGroup.cxx index 2243d14708..fdec00184d 100644 --- a/dtool/src/cppparser/cppFunctionGroup.cxx +++ b/dtool/src/cppparser/cppFunctionGroup.cxx @@ -40,7 +40,7 @@ CPPFunctionGroup:: */ CPPType *CPPFunctionGroup:: get_return_type() const { - CPPType *return_type = NULL; + CPPType *return_type = nullptr; if (!_instances.empty()) { Instances::const_iterator ii = _instances.begin(); @@ -48,7 +48,7 @@ get_return_type() const { ++ii; while (ii != _instances.end()) { if ((*ii)->_type->as_function_type()->_return_type != return_type) { - return (CPPType *)NULL; + return nullptr; } ++ii; } diff --git a/dtool/src/cppparser/cppFunctionType.cxx b/dtool/src/cppparser/cppFunctionType.cxx index 497c46d4b9..221297061d 100644 --- a/dtool/src/cppparser/cppFunctionType.cxx +++ b/dtool/src/cppparser/cppFunctionType.cxx @@ -27,16 +27,16 @@ CPPFunctionType(CPPType *return_type, CPPParameterList *parameters, _parameters(parameters), _flags(flags) { - _class_owner = NULL; + _class_owner = nullptr; // If the parameter list contains just the token "void", it means no // parameters. - if (_parameters != NULL && + if (_parameters != nullptr && _parameters->_parameters.size() == 1 && - _parameters->_parameters.front()->_type->as_simple_type() != NULL && + _parameters->_parameters.front()->_type->as_simple_type() != nullptr && _parameters->_parameters.front()->_type->as_simple_type()->_type == CPPSimpleType::T_void && - _parameters->_parameters.front()->_ident == NULL) { + _parameters->_parameters.front()->_ident == nullptr) { _parameters->_parameters.clear(); } } @@ -72,7 +72,7 @@ operator = (const CPPFunctionType ©) { bool CPPFunctionType:: accepts_num_parameters(int num_parameters) { assert(num_parameters >= 0); - if (_parameters == NULL) { + if (_parameters == nullptr) { return (num_parameters == 0); } @@ -85,7 +85,7 @@ accepts_num_parameters(int num_parameters) { // Make sure all superfluous parameters have a default value. for (size_t i = (size_t)num_parameters; i < actual_num_parameters; ++i) { CPPInstance *param = _parameters->_parameters[i]; - if (param->_initializer == NULL) { + if (param->_initializer == nullptr) { return false; } } @@ -117,13 +117,13 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, } CPPFunctionType *rep = new CPPFunctionType(*this); - if (_return_type != NULL) { + if (_return_type != nullptr) { rep->_return_type = _return_type->substitute_decl(subst, current_scope, global_scope) ->as_type(); } - if (_parameters != NULL) { + if (_parameters != nullptr) { rep->_parameters = _parameters->substitute_decl(subst, current_scope, global_scope); } @@ -148,8 +148,8 @@ CPPType *CPPFunctionType:: resolve_type(CPPScope *current_scope, CPPScope *global_scope) { CPPType *rtype = _return_type->resolve_type(current_scope, global_scope); CPPParameterList *params; - if (_parameters == NULL) { - params = NULL; + if (_parameters == nullptr) { + params = nullptr; } else { params = _parameters->resolve_type(current_scope, global_scope); } @@ -173,7 +173,7 @@ is_tbd() const { if (_return_type->is_tbd()) { return true; } - return _parameters == NULL || _parameters->is_tbd(); + return _parameters == nullptr || _parameters->is_tbd(); } /** @@ -328,7 +328,7 @@ get_num_default_parameters() const { // The trick is just to count, beginning from the end and working towards // the front, the number of parameters that have some initializer. - if (_parameters == NULL) { + if (_parameters == nullptr) { return 0; } @@ -336,7 +336,7 @@ get_num_default_parameters() const { CPPParameterList::Parameters::const_reverse_iterator pi; int count = 0; for (pi = params.rbegin(); - pi != params.rend() && (*pi)->_initializer != (CPPExpression *)NULL; + pi != params.rend() && (*pi)->_initializer != nullptr; ++pi) { count++; } @@ -392,7 +392,7 @@ match_virtual_override(const CPPFunctionType &other) const { bool CPPFunctionType:: is_equal(const CPPDeclaration *other) const { const CPPFunctionType *ot = ((CPPDeclaration *)other)->as_function_type(); - assert(ot != NULL); + assert(ot != nullptr); if (_return_type != ot->_return_type) { return false; @@ -403,7 +403,7 @@ is_equal(const CPPDeclaration *other) const { if (_parameters == ot->_parameters) { return true; } - if (_parameters == NULL || ot->_parameters == NULL || + if (_parameters == nullptr || ot->_parameters == nullptr || *_parameters != *ot->_parameters) { return false; } @@ -418,7 +418,7 @@ is_equal(const CPPDeclaration *other) const { bool CPPFunctionType:: is_less(const CPPDeclaration *other) const { const CPPFunctionType *ot = ((CPPDeclaration *)other)->as_function_type(); - assert(ot != NULL); + assert(ot != nullptr); if (_return_type != ot->_return_type) { return _return_type < ot->_return_type; @@ -429,7 +429,7 @@ is_less(const CPPDeclaration *other) const { if (_parameters == ot->_parameters) { return 0; } - if (_parameters == NULL || ot->_parameters == NULL) { + if (_parameters == nullptr || ot->_parameters == nullptr) { return _parameters < ot->_parameters; } return *_parameters < *ot->_parameters; diff --git a/dtool/src/cppparser/cppIdentifier.cxx b/dtool/src/cppparser/cppIdentifier.cxx index 940b2a5daf..8ffb6cefd8 100644 --- a/dtool/src/cppparser/cppIdentifier.cxx +++ b/dtool/src/cppparser/cppIdentifier.cxx @@ -26,7 +26,7 @@ CPPIdentifier:: CPPIdentifier(const string &name, const CPPFile &file) { _names.push_back(CPPNameComponent(name)); - _native_scope = (CPPScope *)NULL; + _native_scope = nullptr; _loc.first_line = 0; _loc.first_column = 0; _loc.last_line = 0; @@ -40,7 +40,7 @@ CPPIdentifier(const string &name, const CPPFile &file) { CPPIdentifier:: CPPIdentifier(const CPPNameComponent &name, const CPPFile &file) { _names.push_back(name); - _native_scope = (CPPScope *)NULL; + _native_scope = nullptr; _loc.first_line = 0; _loc.first_column = 0; _loc.last_line = 0; @@ -54,7 +54,7 @@ CPPIdentifier(const CPPNameComponent &name, const CPPFile &file) { CPPIdentifier:: CPPIdentifier(const string &name, const cppyyltype &loc) : _loc(loc) { _names.push_back(CPPNameComponent(name)); - _native_scope = (CPPScope *)NULL; + _native_scope = nullptr; } /** @@ -63,7 +63,7 @@ CPPIdentifier(const string &name, const cppyyltype &loc) : _loc(loc) { CPPIdentifier:: CPPIdentifier(const CPPNameComponent &name, const cppyyltype &loc) : _loc(loc) { _names.push_back(name); - _native_scope = (CPPScope *)NULL; + _native_scope = nullptr; } /** @@ -150,7 +150,7 @@ get_local_name(CPPScope *scope) const { string result; - if (scope == NULL || (_native_scope == NULL && _names.size() == 1)) { + if (scope == nullptr || (_native_scope == nullptr && _names.size() == 1)) { result = _names.back().get_name_with_templ(scope); } else if (_names.front().empty()) { @@ -159,15 +159,15 @@ get_local_name(CPPScope *scope) const { } else { // Determine the scope of everything up until but not including the last // name. - CPPScope *my_scope = get_scope(scope, NULL); + CPPScope *my_scope = get_scope(scope, nullptr); // Strip off template scopes, since they don't add anything particularly // meaningful to the local name. - while (my_scope != NULL && my_scope->as_template_scope() != NULL) { + while (my_scope != nullptr && my_scope->as_template_scope() != nullptr) { my_scope = my_scope->get_parent_scope(); } - if (my_scope == NULL) { + if (my_scope == nullptr) { result = get_fully_scoped_name(); } else if (my_scope == scope) { return _names.back().get_name_with_templ(scope); @@ -240,7 +240,7 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, assert(!_names.empty()); CPPScope *scope = _native_scope; - if (scope == (CPPScope *)NULL) { + if (scope == nullptr) { scope = current_scope; } int i = 0; @@ -251,16 +251,16 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, i++; } - while (i + 1 < (int)_names.size() && scope != NULL) { + while (i + 1 < (int)_names.size() && scope != nullptr) { CPPScope *next_scope = scope->find_scope(_names[i].get_name()); - if (next_scope == (CPPScope *)NULL) { - if (error_sink != NULL) { + if (next_scope == nullptr) { + if (error_sink != nullptr) { error_sink->error("Symbol " + _names[i].get_name() + " is not a known scope in " + scope->get_fully_scoped_name(), _loc); } - return (CPPScope *)NULL; + return nullptr; } if (_names[i].has_templ()) { next_scope = next_scope->instantiate(_names[i].get_templ(), @@ -283,7 +283,7 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, assert(!_names.empty()); CPPScope *scope = _native_scope; - if (scope == (CPPScope *)NULL) { + if (scope == nullptr) { scope = current_scope; } int i = 0; @@ -294,17 +294,17 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, i++; } - while (i + 1 < (int)_names.size() && scope != NULL) { + while (i + 1 < (int)_names.size() && scope != nullptr) { CPPScope *next_scope = scope->find_scope(_names[i].get_name(), subst, global_scope); - if (next_scope == (CPPScope *)NULL) { - if (error_sink != NULL) { + if (next_scope == nullptr) { + if (error_sink != nullptr) { error_sink->error("Symbol " + _names[i].get_name() + " is not a known scope in " + scope->get_fully_scoped_name(), _loc); } - return (CPPScope *)NULL; + return nullptr; } if (_names[i].has_templ()) { next_scope = next_scope->instantiate(_names[i].get_templ(), @@ -330,11 +330,11 @@ find_type(CPPScope *current_scope, CPPScope *global_scope, bool force_instantiate, CPPPreprocessor *error_sink) const { CPPScope *scope = get_scope(current_scope, global_scope, error_sink); - if (scope == NULL) { - return NULL; + if (scope == nullptr) { + return nullptr; } - CPPType *type = NULL; + CPPType *type = nullptr; if (!_names.back().has_templ()) { type = scope->find_type(get_simple_name()); @@ -374,12 +374,12 @@ find_type(CPPScope *current_scope, CPPScope *global_scope, CPPDeclaration::SubstDecl &subst, CPPPreprocessor *error_sink) const { CPPScope *scope = get_scope(current_scope, global_scope, subst, error_sink); - if (scope == NULL) { - return NULL; + if (scope == nullptr) { + return nullptr; } CPPType *type = scope->find_type(get_simple_name(), subst, global_scope); - if (type != NULL && _names.back().has_templ()) { + if (type != nullptr && _names.back().has_templ()) { // This is a template type. if (is_fully_specified()) { @@ -388,9 +388,9 @@ find_type(CPPScope *current_scope, CPPScope *global_scope, type->instantiate(_names.back().get_templ(), current_scope, global_scope, error_sink); - assert(decl != NULL); + assert(decl != nullptr); CPPType *new_type = decl->as_type(); - assert(new_type != NULL); + assert(new_type != nullptr); if (new_type == type) { type = CPPType::new_type(new CPPTBDType((CPPIdentifier *)this)); } else { @@ -413,8 +413,8 @@ CPPDeclaration *CPPIdentifier:: find_symbol(CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink) const { CPPScope *scope = get_scope(current_scope, global_scope, error_sink); - if (scope == NULL) { - return NULL; + if (scope == nullptr) { + return nullptr; } CPPDeclaration *sym; @@ -430,9 +430,9 @@ find_symbol(CPPScope *current_scope, CPPScope *global_scope, } else { sym = scope->find_template(get_simple_name()); - if (sym != NULL) { + if (sym != nullptr) { CPPType *type = sym->as_type(); - if (type != NULL && type->is_incomplete()) { + if (type != nullptr && type->is_incomplete()) { // We can't instantiate an incomplete type. sym = CPPType::new_type(new CPPTBDType((CPPIdentifier *)this)); } else { @@ -454,8 +454,8 @@ find_symbol(CPPScope *current_scope, CPPScope *global_scope, CPPDeclaration::SubstDecl &subst, CPPPreprocessor *error_sink) const { CPPScope *scope = get_scope(current_scope, global_scope, subst, error_sink); - if (scope == NULL) { - return NULL; + if (scope == nullptr) { + return nullptr; } CPPDeclaration *sym; @@ -472,9 +472,9 @@ find_symbol(CPPScope *current_scope, CPPScope *global_scope, } else { sym = scope->find_template(get_simple_name()); - if (sym != NULL) { + if (sym != nullptr) { CPPType *type = sym->as_type(); - if (type != NULL && type->is_incomplete()) { + if (type != nullptr && type->is_incomplete()) { // We can't instantiate an incomplete type. sym = CPPType::new_type(new CPPTBDType((CPPIdentifier *)this)); } else { @@ -495,8 +495,8 @@ CPPDeclaration *CPPIdentifier:: find_template(CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink) const { CPPScope *scope = get_scope(current_scope, global_scope, error_sink); - if (scope == NULL) { - return NULL; + if (scope == nullptr) { + return nullptr; } return scope->find_template(get_simple_name()); } @@ -508,8 +508,8 @@ CPPScope *CPPIdentifier:: find_scope(CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink) const { CPPScope *scope = get_scope(current_scope, global_scope, error_sink); - if (scope == NULL) { - return NULL; + if (scope == nullptr) { + return nullptr; } return scope->find_scope(get_simple_name()); } @@ -547,7 +547,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, */ void CPPIdentifier:: output(ostream &out, CPPScope *scope) const { - if (scope == NULL) { + if (scope == nullptr) { output_fully_scoped_name(out); } else { output_local_name(out, scope); @@ -562,16 +562,16 @@ void CPPIdentifier:: output_local_name(ostream &out, CPPScope *scope) const { assert(!_names.empty()); - if (scope == NULL || (_native_scope == NULL && _names.size() == 1)) { + if (scope == nullptr || (_native_scope == nullptr && _names.size() == 1)) { out << _names.back(); } else if (_names.front().empty()) { output_fully_scoped_name(out); } else { // Determine the scope of everything up until but not including the last // name. - CPPScope *my_scope = get_scope(scope, NULL); + CPPScope *my_scope = get_scope(scope, nullptr); - if (my_scope == NULL) { + if (my_scope == nullptr) { output_fully_scoped_name(out); } else { out << my_scope->get_local_name(scope) << "::" << _names.back(); @@ -584,8 +584,8 @@ output_local_name(ostream &out, CPPScope *scope) const { */ void CPPIdentifier:: output_fully_scoped_name(ostream &out) const { - if (_native_scope != NULL) { - _native_scope->output(out, (CPPScope *)NULL); + if (_native_scope != nullptr) { + _native_scope->output(out, nullptr); out << "::"; } Names::const_iterator ni = _names.begin(); diff --git a/dtool/src/cppparser/cppIdentifier.h b/dtool/src/cppparser/cppIdentifier.h index abb6405fc6..57daf3b469 100644 --- a/dtool/src/cppparser/cppIdentifier.h +++ b/dtool/src/cppparser/cppIdentifier.h @@ -48,7 +48,7 @@ public: bool is_scoped() const; string get_simple_name() const; - string get_local_name(CPPScope *scope = NULL) const; + string get_local_name(CPPScope *scope = nullptr) const; string get_fully_scoped_name() const; bool is_fully_specified() const; @@ -56,30 +56,30 @@ public: CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope, CPPDeclaration::SubstDecl &subst, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; CPPType *find_type(CPPScope *current_scope, CPPScope *global_scope, bool force_instantiate = false, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; CPPType *find_type(CPPScope *current_scope, CPPScope *global_scope, CPPDeclaration::SubstDecl &subst, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; CPPDeclaration *find_symbol(CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; CPPDeclaration *find_symbol(CPPScope *current_scope, CPPScope *global_scope, CPPDeclaration::SubstDecl &subst, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; CPPDeclaration *find_template(CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; CPPScope *find_scope(CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; CPPIdentifier *substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, @@ -96,7 +96,7 @@ public: }; inline ostream &operator << (ostream &out, const CPPIdentifier &identifier) { - identifier.output(out, (CPPScope *)NULL); + identifier.output(out, nullptr); return out; } diff --git a/dtool/src/cppparser/cppInstance.cxx b/dtool/src/cppparser/cppInstance.cxx index 0bfdcabde1..eb71e47315 100644 --- a/dtool/src/cppparser/cppInstance.cxx +++ b/dtool/src/cppparser/cppInstance.cxx @@ -35,10 +35,10 @@ CPPInstance(CPPType *type, const string &name, int storage_class) : _type(type), _ident(new CPPIdentifier(name)), _storage_class(storage_class), - _alignment(NULL), + _alignment(nullptr), _bit_width(-1) { - _initializer = NULL; + _initializer = nullptr; } /** @@ -50,10 +50,10 @@ CPPInstance(CPPType *type, CPPIdentifier *ident, int storage_class) : _type(type), _ident(ident), _storage_class(storage_class), - _alignment(NULL), + _alignment(nullptr), _bit_width(-1) { - _initializer = NULL; + _initializer = nullptr; } /** @@ -65,17 +65,17 @@ CPPInstance:: CPPInstance(CPPType *type, CPPInstanceIdentifier *ii, int storage_class, const CPPFile &file) : CPPDeclaration(file), - _alignment(NULL) + _alignment(nullptr) { _type = ii->unroll_type(type); _ident = ii->_ident; - ii->_ident = NULL; + ii->_ident = nullptr; _storage_class = storage_class; - _initializer = NULL; + _initializer = nullptr; _bit_width = ii->_bit_width; CPPParameterList *params = ii->get_initializer(); - if (params != (CPPParameterList *)NULL) { + if (params != nullptr) { // In this case, the instance has a parameter-list initializer, e.g.: int // foo(0); We really should save this initializer in the instance object. // But we don't for now, since no one really cares about initializers @@ -102,7 +102,7 @@ CPPInstance(const CPPInstance ©) : _alignment(copy._alignment), _bit_width(copy._bit_width) { - assert(_type != NULL); + assert(_type != nullptr); } /** @@ -150,17 +150,17 @@ operator == (const CPPInstance &other) const { // We *do* care about the identifier. We need to differentiate types of // function variables, among possibly other things, based on the identifier. - if ((_ident == NULL && other._ident != NULL) || - (_ident != NULL && other._ident == NULL) || - (_ident != NULL && other._ident != NULL && *_ident != *other._ident)) + if ((_ident == nullptr && other._ident != nullptr) || + (_ident != nullptr && other._ident == nullptr) || + (_ident != nullptr && other._ident != nullptr && *_ident != *other._ident)) { return false; } // We similarly care about the initializer. - if ((_initializer == NULL && other._initializer != NULL) || - (_initializer != NULL && other._initializer == NULL) || - (_initializer != NULL && other._initializer != NULL && + if ((_initializer == nullptr && other._initializer != nullptr) || + (_initializer != nullptr && other._initializer == nullptr) || + (_initializer != nullptr && other._initializer != nullptr && *_initializer != *other._initializer)) { return false; @@ -194,23 +194,23 @@ operator < (const CPPInstance &other) const { // We *do* care about the identifier. We need to differentiate types of // function variables, among possibly other things, based on the identifier. - if ((_ident == NULL && other._ident != NULL) || - (_ident != NULL && other._ident == NULL) || - (_ident != NULL && other._ident != NULL && *_ident != *other._ident)) + if ((_ident == nullptr && other._ident != nullptr) || + (_ident != nullptr && other._ident == nullptr) || + (_ident != nullptr && other._ident != nullptr && *_ident != *other._ident)) { - if (_ident == NULL || other._ident == NULL) { + if (_ident == nullptr || other._ident == nullptr) { return _ident < other._ident; } return *_ident < *other._ident; } // We similarly care about the initializer. - if ((_initializer == NULL && other._initializer != NULL) || - (_initializer != NULL && other._initializer == NULL) || - (_initializer != NULL && other._initializer != NULL && + if ((_initializer == nullptr && other._initializer != nullptr) || + (_initializer != nullptr && other._initializer == nullptr) || + (_initializer != nullptr && other._initializer != nullptr && *_initializer != *other._initializer)) { - if (_initializer == NULL || other._initializer == NULL) { + if (_initializer == nullptr || other._initializer == nullptr) { return _initializer < other._initializer; } return *_initializer < *other._initializer; @@ -226,12 +226,12 @@ operator < (const CPPInstance &other) const { */ void CPPInstance:: set_initializer(CPPExpression *initializer) { - if (_type->as_function_type() != (CPPFunctionType *)NULL) { + if (_type->as_function_type() != nullptr) { // This is a function declaration. _storage_class &= ~(SC_pure_virtual | SC_defaulted | SC_deleted); - _initializer = (CPPExpression *)NULL; + _initializer = nullptr; - if (initializer != (CPPExpression *)NULL) { + if (initializer != nullptr) { if (initializer->_type == CPPExpression::T_integer) { // = 0 _storage_class |= SC_pure_virtual; @@ -270,7 +270,7 @@ set_alignment(CPPExpression *const_expr) { */ bool CPPInstance:: is_scoped() const { - if (_ident == NULL) { + if (_ident == nullptr) { return false; } else { return _ident->is_scoped(); @@ -283,7 +283,7 @@ is_scoped() const { CPPScope *CPPInstance:: get_scope(CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink) const { - if (_ident == NULL) { + if (_ident == nullptr) { return current_scope; } else { return _ident->get_scope(current_scope, global_scope, error_sink); @@ -295,7 +295,7 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, */ string CPPInstance:: get_simple_name() const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } else { return _ident->get_simple_name(); @@ -307,7 +307,7 @@ get_simple_name() const { */ string CPPInstance:: get_local_name(CPPScope *scope) const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } else { return _ident->get_local_name(scope); @@ -319,7 +319,7 @@ get_local_name(CPPScope *scope) const { */ string CPPInstance:: get_fully_scoped_name() const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } else { return _ident->get_fully_scoped_name(); @@ -334,12 +334,12 @@ get_fully_scoped_name() const { void CPPInstance:: check_for_constructor(CPPScope *current_scope, CPPScope *global_scope) { CPPScope *scope = get_scope(current_scope, global_scope); - if (scope == NULL) { + if (scope == nullptr) { scope = current_scope; } CPPFunctionType *func = _type->as_function_type(); - if (func != NULL) { + if (func != nullptr) { string method_name = get_local_name(scope); string class_name = scope->get_local_name(); @@ -359,7 +359,7 @@ check_for_constructor(CPPScope *current_scope, CPPScope *global_scope) { CPPType *param_type = params->_parameters[0]->_type; CPPReferenceType *ref_type = param_type->as_reference_type(); - if (ref_type != NULL) { + if (ref_type != nullptr) { param_type = ref_type->_pointing_at->remove_cv(); if (class_name == param_type->get_simple_name()) { @@ -404,7 +404,7 @@ instantiate(const CPPTemplateParameterList *actual_params, CPPPreprocessor *error_sink) const { if (!is_template()) { - if (error_sink != NULL) { + if (error_sink != nullptr) { error_sink->warning("Ignoring template parameters for instance " + _ident->get_local_name()); } @@ -434,7 +434,7 @@ instantiate(const CPPTemplateParameterList *actual_params, // change the name. inst = new CPPInstance(*this); } - assert(inst != NULL); + assert(inst != nullptr); inst->_ident = inst->_ident->substitute_decl(subst, current_scope, global_scope); if (inst->_ident == _ident) { inst->_ident = new CPPIdentifier(*inst->_ident); @@ -442,7 +442,7 @@ instantiate(const CPPTemplateParameterList *actual_params, inst->_ident->_names.back().set_templ (new CPPTemplateParameterList(*actual_params)); - inst->_template_scope = NULL; + inst->_template_scope = nullptr; ((CPPInstance *)this)->_instantiations.insert(Instantiations::value_type(actual_params, inst)); return inst; @@ -455,10 +455,10 @@ instantiate(const CPPTemplateParameterList *actual_params, */ bool CPPInstance:: is_fully_specified() const { - if (_ident != NULL && !_ident->is_fully_specified()) { + if (_ident != nullptr && !_ident->is_fully_specified()) { return false; } - if (_initializer != NULL && !_initializer->is_fully_specified()) { + if (_initializer != nullptr && !_initializer->is_fully_specified()) { return false; } return CPPDeclaration::is_fully_specified() && @@ -482,11 +482,11 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, _type->substitute_decl(subst, current_scope, global_scope); rep->_type = new_type->as_type(); - if (rep->_type == NULL) { + if (rep->_type == nullptr) { rep->_type = _type; } - if (_initializer != NULL) { + if (_initializer != nullptr) { rep->_initializer = _initializer->substitute_decl(subst, current_scope, global_scope) ->as_expression(); @@ -517,7 +517,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { void CPPInstance:: output(ostream &out, int indent_level, CPPScope *scope, bool complete, int num_default_parameters) const { - assert(_type != NULL); + assert(_type != nullptr); if (_type->is_parameter_expr()) { // In this case, the whole thing is really an expression, and not an @@ -532,7 +532,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete, indent(out, indent_level); } - if (_alignment != NULL) { + if (_alignment != nullptr) { out << "alignas(" << *_alignment << ") "; } @@ -571,7 +571,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete, } string name; - if (_ident != NULL) { + if (_ident != nullptr) { name = _ident->get_local_name(scope); } if (_storage_class & SC_parameter_pack) { @@ -600,7 +600,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete, if (_storage_class & SC_deleted) { out << " = delete"; } - if (_initializer != NULL) { + if (_initializer != nullptr) { out << " = " << *_initializer; } } diff --git a/dtool/src/cppparser/cppInstance.h b/dtool/src/cppparser/cppInstance.h index 675ba83507..137bbe56b7 100644 --- a/dtool/src/cppparser/cppInstance.h +++ b/dtool/src/cppparser/cppInstance.h @@ -94,10 +94,10 @@ public: bool is_scoped() const; CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; string get_simple_name() const; - string get_local_name(CPPScope *scope = NULL) const; + string get_local_name(CPPScope *scope = nullptr) const; string get_fully_scoped_name() const; void check_for_constructor(CPPScope *current_scope, CPPScope *global_scope); @@ -105,7 +105,7 @@ public: virtual CPPDeclaration * instantiate(const CPPTemplateParameterList *actual_params, CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; virtual bool is_fully_specified() const; virtual CPPDeclaration *substitute_decl(SubstDecl &subst, diff --git a/dtool/src/cppparser/cppInstanceIdentifier.cxx b/dtool/src/cppparser/cppInstanceIdentifier.cxx index fe723f552d..b75dfc6424 100644 --- a/dtool/src/cppparser/cppInstanceIdentifier.cxx +++ b/dtool/src/cppparser/cppInstanceIdentifier.cxx @@ -27,10 +27,10 @@ CPPInstanceIdentifier::Modifier:: Modifier(CPPInstanceIdentifierType type) : _type(type), - _func_params(NULL), + _func_params(nullptr), _func_flags(0), - _scoping(NULL), - _expr(NULL) { + _scoping(nullptr), + _expr(nullptr) { } /** @@ -116,7 +116,7 @@ add_func_modifier(CPPParameterList *params, int flags, CPPType *trailing_return_ // check if the parameter list is empty. If it is, this is really a unary // operator, so set the unary_op flag. Operators () and [] are never // considered unary operators. - if (_ident != NULL && + if (_ident != nullptr && _ident->get_simple_name().substr(0, 9) == "operator ") { if (_ident->get_simple_name() != string("operator ()") && @@ -129,7 +129,7 @@ add_func_modifier(CPPParameterList *params, int flags, CPPType *trailing_return_ flags |= CPPFunctionType::F_operator; } - if (trailing_return_type != NULL) { + if (trailing_return_type != nullptr) { // Remember whether trailing return type notation was used. flags |= CPPFunctionType::F_trailing_return_type; } @@ -153,7 +153,7 @@ add_array_modifier(CPPExpression *expr) { // Special case for operator new[] and delete[]. We're not really adding an // array modifier to them, but appending [] to the identifier. This is to // work around a parser ambiguity. - if (_ident != NULL && (_ident->get_simple_name() == "operator delete" || + if (_ident != nullptr && (_ident->get_simple_name() == "operator delete" || _ident->get_simple_name() == "operator new")) { _ident->_names.back().append_name("[]"); @@ -206,7 +206,7 @@ get_initializer() const { } } - return NULL; + return nullptr; } /** @@ -215,7 +215,7 @@ get_initializer() const { CPPScope *CPPInstanceIdentifier:: get_scope(CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink) const { - if (_ident == NULL) { + if (_ident == nullptr) { return current_scope; } else { return _ident->get_scope(current_scope, global_scope, error_sink); @@ -228,7 +228,7 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, CPPType *CPPInstanceIdentifier:: r_unroll_type(CPPType *start_type, CPPInstanceIdentifier::Modifiers::const_iterator mi) { - assert(start_type != NULL); + assert(start_type != nullptr); start_type = CPPType::new_type(start_type); @@ -239,7 +239,7 @@ r_unroll_type(CPPType *start_type, const Modifier &mod = (*mi); ++mi; - CPPType *result = NULL; + CPPType *result = nullptr; switch (mod._type) { case IIT_pointer: @@ -260,7 +260,7 @@ r_unroll_type(CPPType *start_type, { CPPType *type = r_unroll_type(start_type, mi); CPPFunctionType *ftype = type->as_function_type(); - if (ftype != NULL) { + if (ftype != nullptr) { ftype = new CPPFunctionType(*ftype); ftype->_class_owner = mod._scoping; ftype->_flags |= CPPFunctionType::F_method_pointer; @@ -291,9 +291,9 @@ r_unroll_type(CPPType *start_type, case IIT_func: { CPPType *return_type = r_unroll_type(start_type, mi); - if (mod._trailing_return_type != (CPPType *)NULL) { + if (mod._trailing_return_type != nullptr) { CPPSimpleType *simple_type = return_type->as_simple_type(); - if (simple_type != NULL && simple_type->_type == CPPSimpleType::T_auto) { + if (simple_type != nullptr && simple_type->_type == CPPSimpleType::T_auto) { return_type = mod._trailing_return_type; } else { cerr << "function with trailing return type needs auto\n"; diff --git a/dtool/src/cppparser/cppInstanceIdentifier.h b/dtool/src/cppparser/cppInstanceIdentifier.h index 8433b30313..582e149e2c 100644 --- a/dtool/src/cppparser/cppInstanceIdentifier.h +++ b/dtool/src/cppparser/cppInstanceIdentifier.h @@ -55,7 +55,7 @@ public: void add_modifier(CPPInstanceIdentifierType type); void add_func_modifier(CPPParameterList *params, int flags, - CPPType *trailing_return_type = NULL); + CPPType *trailing_return_type = nullptr); void add_scoped_pointer_modifier(CPPIdentifier *scoping); void add_array_modifier(CPPExpression *expr); void add_initializer_modifier(CPPParameterList *params); @@ -65,7 +65,7 @@ public: CPPParameterList *get_initializer() const; CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; CPPIdentifier *_ident; diff --git a/dtool/src/cppparser/cppMakeProperty.cxx b/dtool/src/cppparser/cppMakeProperty.cxx index 02e4f21c60..e75cfb5676 100644 --- a/dtool/src/cppparser/cppMakeProperty.cxx +++ b/dtool/src/cppparser/cppMakeProperty.cxx @@ -64,41 +64,41 @@ get_fully_scoped_name() const { */ void CPPMakeProperty:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { - if (_length_function != NULL) { + if (_length_function != nullptr) { out << "__make_seq_property"; } else { out << "__make_property"; } - if (_has_function != NULL) { + if (_has_function != nullptr) { out.put('2'); } out << "(" << _ident->get_local_name(scope); - if (_length_function != NULL) { + if (_length_function != nullptr) { out << ", " << _length_function->_name; } - if (_has_function != NULL) { + if (_has_function != nullptr) { out << ", " << _has_function->_name; } out << ", " << _get_function->_name; - if (_set_function != NULL) { + if (_set_function != nullptr) { out << ", " << _set_function->_name; } - if (_clear_function != NULL) { + if (_clear_function != nullptr) { out << ", " << _clear_function->_name; } - if (_del_function != NULL) { + if (_del_function != nullptr) { out << ", " << _del_function->_name; } - if (_insert_function != NULL) { + if (_insert_function != nullptr) { out << ", " << _insert_function->_name; } diff --git a/dtool/src/cppparser/cppMakeProperty.h b/dtool/src/cppparser/cppMakeProperty.h index cd364b30ec..d97369fc7d 100644 --- a/dtool/src/cppparser/cppMakeProperty.h +++ b/dtool/src/cppparser/cppMakeProperty.h @@ -92,7 +92,7 @@ public: CPPScope *current_scope, const CPPFile &file); virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = NULL) const; + virtual string get_local_name(CPPScope *scope = nullptr) const; virtual string get_fully_scoped_name() const; virtual void output(ostream &out, int indent_level, CPPScope *scope, diff --git a/dtool/src/cppparser/cppMakeSeq.h b/dtool/src/cppparser/cppMakeSeq.h index 0e48dd0ef4..9d4eae4261 100644 --- a/dtool/src/cppparser/cppMakeSeq.h +++ b/dtool/src/cppparser/cppMakeSeq.h @@ -33,7 +33,7 @@ public: CPPScope *current_scope, const CPPFile &file); virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = NULL) const; + virtual string get_local_name(CPPScope *scope = nullptr) const; virtual string get_fully_scoped_name() const; virtual void output(ostream &out, int indent_level, CPPScope *scope, diff --git a/dtool/src/cppparser/cppManifest.cxx b/dtool/src/cppparser/cppManifest.cxx index bb8f315c39..faaaced2d8 100644 --- a/dtool/src/cppparser/cppManifest.cxx +++ b/dtool/src/cppparser/cppManifest.cxx @@ -41,7 +41,7 @@ CPPManifest:: CPPManifest(const string &args, const cppyyltype &loc) : _variadic_param(-1), _loc(loc), - _expr((CPPExpression *)NULL), + _expr(nullptr), _vis(V_public) { assert(!args.empty()); @@ -84,7 +84,7 @@ CPPManifest(const string &args, const cppyyltype &loc) : CPPManifest:: CPPManifest(const string ¯o, const string &definition) : _variadic_param(-1), - _expr((CPPExpression *)NULL), + _expr(nullptr), _vis(V_public) { _loc.first_line = 0; @@ -125,7 +125,7 @@ CPPManifest(const string ¯o, const string &definition) : */ CPPManifest:: ~CPPManifest() { - if (_expr != (CPPExpression *)NULL) { + if (_expr != nullptr) { delete _expr; } } @@ -242,10 +242,10 @@ expand(const vector_string &args) const { */ CPPType *CPPManifest:: determine_type() const { - if (_expr != (CPPExpression *)NULL) { + if (_expr != nullptr) { return _expr->determine_type(); } - return (CPPType *)NULL; + return nullptr; } /** diff --git a/dtool/src/cppparser/cppNameComponent.cxx b/dtool/src/cppparser/cppNameComponent.cxx index 9287aaa89b..b5c7f825aa 100644 --- a/dtool/src/cppparser/cppNameComponent.cxx +++ b/dtool/src/cppparser/cppNameComponent.cxx @@ -21,7 +21,7 @@ CPPNameComponent:: CPPNameComponent(const string &name) : _name(name) { - _templ = (CPPTemplateParameterList *)NULL; + _templ = nullptr; } /** @@ -32,10 +32,10 @@ operator == (const CPPNameComponent &other) const { if (_name != other._name) { return false; } - if (_templ == NULL && other._templ == NULL) { + if (_templ == nullptr && other._templ == nullptr) { return true; } - if (_templ == NULL || other._templ == NULL) { + if (_templ == nullptr || other._templ == nullptr) { return false; } if (*_templ != *other._templ) { @@ -61,10 +61,10 @@ operator < (const CPPNameComponent &other) const { if (_name != other._name) { return _name < other._name; } - if (_templ == NULL && other._templ == NULL) { + if (_templ == nullptr && other._templ == nullptr) { return false; } - if (_templ == NULL || other._templ == NULL) { + if (_templ == nullptr || other._templ == nullptr) { return _templ < other._templ; } return (*_templ) < (*other._templ); @@ -85,7 +85,7 @@ string CPPNameComponent:: get_name_with_templ(CPPScope *scope) const { ostringstream strm; strm << _name; - if (_templ != NULL) { + if (_templ != nullptr) { strm << "< "; _templ->output(strm, scope); strm << " >"; @@ -114,7 +114,7 @@ empty() const { */ bool CPPNameComponent:: has_templ() const { - return _templ != (CPPTemplateParameterList *)NULL; + return _templ != nullptr; } /** @@ -123,7 +123,7 @@ has_templ() const { */ bool CPPNameComponent:: is_tbd() const { - if (_templ != (CPPTemplateParameterList *)NULL) { + if (_templ != nullptr) { return _templ->is_tbd(); } return false; @@ -159,7 +159,7 @@ set_templ(CPPTemplateParameterList *templ) { void CPPNameComponent:: output(ostream &out) const { out << _name; - if (_templ != NULL) { + if (_templ != nullptr) { out << "< " << *_templ << " >"; } } diff --git a/dtool/src/cppparser/cppNameComponent.h b/dtool/src/cppparser/cppNameComponent.h index e8f4a94ce4..9e6981e3d8 100644 --- a/dtool/src/cppparser/cppNameComponent.h +++ b/dtool/src/cppparser/cppNameComponent.h @@ -32,7 +32,7 @@ public: bool operator < (const CPPNameComponent &other) const; string get_name() const; - string get_name_with_templ(CPPScope *scope = (CPPScope *)NULL) const; + string get_name_with_templ(CPPScope *scope = nullptr) const; CPPTemplateParameterList *get_templ() const; bool empty() const; bool has_templ() const; diff --git a/dtool/src/cppparser/cppNamespace.cxx b/dtool/src/cppparser/cppNamespace.cxx index 36bad0a932..c8e84a3725 100644 --- a/dtool/src/cppparser/cppNamespace.cxx +++ b/dtool/src/cppparser/cppNamespace.cxx @@ -33,7 +33,7 @@ CPPNamespace(CPPIdentifier *ident, CPPScope *scope, const CPPFile &file) : */ string CPPNamespace:: get_simple_name() const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } return _ident->get_simple_name(); @@ -44,7 +44,7 @@ get_simple_name() const { */ string CPPNamespace:: get_local_name(CPPScope *scope) const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } return _ident->get_local_name(scope); @@ -55,7 +55,7 @@ get_local_name(CPPScope *scope) const { */ string CPPNamespace:: get_fully_scoped_name() const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } return _ident->get_fully_scoped_name(); @@ -77,12 +77,12 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (_is_inline) { out << "inline "; } - if (!complete && _ident != NULL) { + if (!complete && _ident != nullptr) { // If we have a name, use it. out << "namespace " << _ident->get_local_name(scope); } else { - if (_ident != NULL) { + if (_ident != nullptr) { out << "namespace " << _ident->get_local_name(scope) << " {\n"; } else { out << "namespace {\n"; diff --git a/dtool/src/cppparser/cppNamespace.h b/dtool/src/cppparser/cppNamespace.h index 81002b475f..c0dd98132e 100644 --- a/dtool/src/cppparser/cppNamespace.h +++ b/dtool/src/cppparser/cppNamespace.h @@ -30,7 +30,7 @@ public: const CPPFile &file); string get_simple_name() const; - string get_local_name(CPPScope *scope = NULL) const; + string get_local_name(CPPScope *scope = nullptr) const; string get_fully_scoped_name() const; CPPScope *get_scope() const; diff --git a/dtool/src/cppparser/cppParameterList.cxx b/dtool/src/cppparser/cppParameterList.cxx index 1d3c2b986d..6ecdbc665d 100644 --- a/dtool/src/cppparser/cppParameterList.cxx +++ b/dtool/src/cppparser/cppParameterList.cxx @@ -213,7 +213,7 @@ output(ostream &out, CPPScope *scope, bool parameter_names, if (num_default_parameters >= 0 && i < (int)_parameters.size() - num_default_parameters) { // Don't show the default value for this parameter. - _parameters[i]->_initializer = (CPPExpression *)NULL; + _parameters[i]->_initializer = nullptr; } if (parameter_names) { diff --git a/dtool/src/cppparser/cppParameterList.h b/dtool/src/cppparser/cppParameterList.h index 93e00a822e..77c7b2b889 100644 --- a/dtool/src/cppparser/cppParameterList.h +++ b/dtool/src/cppparser/cppParameterList.h @@ -59,7 +59,7 @@ public: inline ostream & operator << (ostream &out, const CPPParameterList &plist) { - plist.output(out, (CPPScope *)NULL, true); + plist.output(out, nullptr, true); return out; } diff --git a/dtool/src/cppparser/cppParser.cxx b/dtool/src/cppparser/cppParser.cxx index 4b27a87d6d..6b13d95dec 100644 --- a/dtool/src/cppparser/cppParser.cxx +++ b/dtool/src/cppparser/cppParser.cxx @@ -25,7 +25,7 @@ bool cppparser_output_class_keyword = false; * */ CPPParser:: -CPPParser() : CPPScope((CPPScope *)NULL, CPPNameComponent(""), V_public) { +CPPParser() : CPPScope(nullptr, CPPNameComponent(""), V_public) { } /** @@ -88,6 +88,6 @@ parse_type(const string &type) { if (ep.parse_type(type, *this)) { return ep._type; } else { - return (CPPType *)NULL; + return nullptr; } } diff --git a/dtool/src/cppparser/cppPointerType.cxx b/dtool/src/cppparser/cppPointerType.cxx index 4ae396e22d..9185455350 100644 --- a/dtool/src/cppparser/cppPointerType.cxx +++ b/dtool/src/cppparser/cppPointerType.cxx @@ -147,14 +147,14 @@ is_constructible(const CPPType *given_type) const { // Can initialize void pointer with any pointer. const CPPSimpleType *simple_type = a->as_simple_type(); - if (simple_type != NULL) { + if (simple_type != nullptr) { return simple_type->_type == CPPSimpleType::T_void; } // Can initialize from derived class pointer. const CPPStructType *a_struct = a->as_struct_type(); const CPPStructType *b_struct = b->as_struct_type(); - if (a_struct != NULL && b_struct != NULL) { + if (a_struct != nullptr && b_struct != nullptr) { return a_struct->is_base_of(b_struct); } @@ -194,7 +194,7 @@ is_copy_assignable() const { bool CPPPointerType:: is_equivalent(const CPPType &other) const { const CPPPointerType *ot = ((CPPType *)&other)->as_pointer_type(); - if (ot == (CPPPointerType *)NULL) { + if (ot == nullptr) { return CPPType::is_equivalent(other); } @@ -241,7 +241,7 @@ output_instance(ostream &out, int indent_level, CPPScope *scope, string star = "*"; CPPFunctionType *ftype = _pointing_at->as_function_type(); - if (ftype != NULL && + if (ftype != nullptr && ((ftype->_flags & CPPFunctionType::F_method_pointer) != 0)) { // We have to output pointers-to-method with a scoping before the '*'. star = ftype->_class_owner->get_fully_scoped_name() + "::*"; @@ -275,7 +275,7 @@ as_pointer_type() { bool CPPPointerType:: is_equal(const CPPDeclaration *other) const { const CPPPointerType *ot = ((CPPDeclaration *)other)->as_pointer_type(); - assert(ot != NULL); + assert(ot != nullptr); return _pointing_at == ot->_pointing_at; } @@ -288,7 +288,7 @@ is_equal(const CPPDeclaration *other) const { bool CPPPointerType:: is_less(const CPPDeclaration *other) const { const CPPPointerType *ot = ((CPPDeclaration *)other)->as_pointer_type(); - assert(ot != NULL); + assert(ot != nullptr); return _pointing_at < ot->_pointing_at; } diff --git a/dtool/src/cppparser/cppPreprocessor.cxx b/dtool/src/cppparser/cppPreprocessor.cxx index c41441fd75..2a6c3270bc 100644 --- a/dtool/src/cppparser/cppPreprocessor.cxx +++ b/dtool/src/cppparser/cppPreprocessor.cxx @@ -87,8 +87,8 @@ trim_blanks(const string &str) { */ CPPPreprocessor::InputFile:: InputFile() { - _in = NULL; - _ignore_manifest = NULL; + _in = nullptr; + _ignore_manifest = nullptr; _line_number = 0; _col_number = 0; _next_line_number = 1; @@ -101,7 +101,7 @@ InputFile() { */ CPPPreprocessor::InputFile:: ~InputFile() { - if (_in != NULL) { + if (_in != nullptr) { // For some reason--compiler bug in gcc 3.2?--explicitly deleting the // stream pointer does not call the appropriate global delete function; // instead apparently calling the system delete function. So we call the @@ -120,7 +120,7 @@ CPPPreprocessor::InputFile:: */ bool CPPPreprocessor::InputFile:: open(const CPPFile &file) { - assert(_in == NULL); + assert(_in == nullptr); _file = file; pifstream *in = new pifstream; @@ -134,7 +134,7 @@ open(const CPPFile &file) { */ bool CPPPreprocessor::InputFile:: connect_input(const string &input) { - assert(_in == NULL); + assert(_in == nullptr); _input = input; _in = new istringstream(_input); @@ -146,7 +146,7 @@ connect_input(const string &input) { */ int CPPPreprocessor::InputFile:: get() { - assert(_in != NULL); + assert(_in != nullptr); if (!_lock_position) { _line_number = _next_line_number; @@ -186,7 +186,7 @@ get() { */ int CPPPreprocessor::InputFile:: peek() { - assert(_in != NULL); + assert(_in != nullptr); int c = _in->peek(); @@ -344,7 +344,7 @@ get_next_token0() { // instantiation and call yacc recursively to parse the template // parameters. CPPDeclaration *decl = ident->find_template(current_scope, global_scope); - if (decl != NULL) { + if (decl != nullptr) { ident->_names.back().set_templ (nested_parse_template_instantiation(decl->get_template_scope())); token = internal_get_next_token(); @@ -402,7 +402,7 @@ get_next_token0() { // parameters. CPPDeclaration *decl = ident->find_template(current_scope, global_scope); - if (decl != NULL) { + if (decl != nullptr) { ident->_names.back().set_templ (nested_parse_template_instantiation(decl->get_template_scope())); token = internal_get_next_token(); @@ -417,7 +417,7 @@ get_next_token0() { int token_type = IDENTIFIER; CPPDeclaration *decl = ident->find_symbol(current_scope, global_scope); - if (decl != NULL && decl->as_type() != NULL) { + if (decl != nullptr && decl->as_type() != nullptr) { // We need to see type pack template parameters as a different type of // identifier to resolve a parser ambiguity. CPPClassTemplateParameter *ctp = decl->as_class_template_parameter(); @@ -642,19 +642,19 @@ get_comment_before(int line, CPPFile file) { } if (comment->_last_line < line) { - return (CPPCommentBlock *)NULL; + return nullptr; } } else { wrong_file_count++; if (wrong_file_count > 10) { - return (CPPCommentBlock *)NULL; + return nullptr; } } ++ci; } - return (CPPCommentBlock *)NULL; + return nullptr; } /** @@ -672,14 +672,14 @@ get_comment_on(int line, CPPFile file) { if (comment->_line_number == line) { return comment; } else if (comment->_line_number < line) { - return (CPPCommentBlock *)NULL; + return nullptr; } } ++ci; } - return (CPPCommentBlock *)NULL; + return nullptr; } /** @@ -887,7 +887,7 @@ parse_expr(const string &input_expr, CPPScope *current_scope, if (ep.parse_expr(expr, *this)) { return ep._expr; } else { - return (CPPExpression *)NULL; + return nullptr; } } @@ -1674,7 +1674,7 @@ handle_pragma_directive(const string &args, const YYLTYPE &loc) { if (mi != _manifests.end()) { _manifest_stack[macro].push_back(mi->second); } else { - _manifest_stack[macro].push_back(NULL); + _manifest_stack[macro].push_back(nullptr); } } else if (sscanf(args.c_str(), "pop_macro ( \"%63[^\"]\" )", macro) == 1) { @@ -1683,7 +1683,7 @@ handle_pragma_directive(const string &args, const YYLTYPE &loc) { CPPManifest *manifest = stack.back(); stack.pop_back(); Manifests::iterator mi = _manifests.find(macro); - if (manifest == NULL) { + if (manifest == nullptr) { // It was undefined when it was pushed, so make it undefined again. if (mi != _manifests.end()) { _manifests.erase(mi); @@ -1966,7 +1966,7 @@ get_identifier(int c) { if (kw != 0) { YYSTYPE result; - result.u.identifier = (CPPIdentifier *)NULL; + result.u.identifier = nullptr; return CPPToken(kw, loc, name, result); } @@ -2019,24 +2019,24 @@ get_literal(int token, YYLTYPE loc, const string &str, const YYSTYPE &value) { CPPIdentifier *ident = new CPPIdentifier("operator \"\" " + suffix); CPPDeclaration *decl = ident->find_symbol(current_scope, global_scope, this); - if (decl == NULL || decl->get_subtype() != CPPDeclaration::ST_function_group) { + if (decl == nullptr || decl->get_subtype() != CPPDeclaration::ST_function_group) { error("unknown literal suffix " + suffix, loc); return CPPToken(token, loc, str, value); } // Find the overload with the appropriate signature. - CPPExpression *expr = NULL; - CPPInstance *instance = NULL; - CPPInstance *raw_instance = NULL; + CPPExpression *expr = nullptr; + CPPInstance *instance = nullptr; + CPPInstance *raw_instance = nullptr; CPPFunctionGroup *fgroup = decl->as_function_group(); CPPFunctionGroup::Instances::iterator it; for (it = fgroup->_instances.begin(); it != fgroup->_instances.end(); ++it) { - if ((*it)->_type == NULL) { + if ((*it)->_type == nullptr) { continue; } CPPFunctionType *ftype = (*it)->_type->as_function_type(); - if (ftype == NULL || ftype->_parameters == NULL) { + if (ftype == nullptr || ftype->_parameters == nullptr) { continue; } @@ -2049,7 +2049,7 @@ get_literal(int token, YYLTYPE loc, const string &str, const YYSTYPE &value) { } CPPInstance *param = params[0]; - if (param == NULL || param->_type == NULL) { + if (param == nullptr || param->_type == nullptr) { continue; } @@ -2083,11 +2083,11 @@ get_literal(int token, YYLTYPE loc, const string &str, const YYSTYPE &value) { } else if (type->get_subtype() == CPPDeclaration::ST_pointer) { // Must be a const pointer. Unwrap it. type = type->as_pointer_type()->_pointing_at; - if (type == NULL || type->get_subtype() != CPPDeclaration::ST_const) { + if (type == nullptr || type->get_subtype() != CPPDeclaration::ST_const) { continue; } type = type->as_const_type()->_wrapped_around; - if (type == NULL || type->get_subtype() != CPPDeclaration::ST_simple) { + if (type == nullptr || type->get_subtype() != CPPDeclaration::ST_simple) { continue; } @@ -2120,19 +2120,19 @@ get_literal(int token, YYLTYPE loc, const string &str, const YYSTYPE &value) { } YYSTYPE result; - if (instance != NULL) { + if (instance != nullptr) { result.u.expr = new CPPExpression(CPPExpression::literal(expr, instance)); return CPPToken(CUSTOM_LITERAL, loc, str, result); } - if ((token == REAL || token == INTEGER) && raw_instance != NULL) { + if ((token == REAL || token == INTEGER) && raw_instance != nullptr) { // For numeric constants, we can fall back to a raw literal operator. result.u.expr = new CPPExpression(CPPExpression::raw_literal(str, instance)); return CPPToken(CUSTOM_LITERAL, loc, str, result); } error(fgroup->_name + " has no suitable overload for literal of this type", loc); - result.u.expr = NULL; + result.u.expr = nullptr; return CPPToken(CUSTOM_LITERAL, loc, str, result); } @@ -2489,7 +2489,7 @@ get_number(int c) { loc.last_column = get_col_number(); YYSTYPE result; - result.u.integer = strtol(num.c_str(), (char **)NULL, 16); + result.u.integer = strtol(num.c_str(), nullptr, 16); return get_literal(INTEGER, loc, num, result); @@ -2508,7 +2508,7 @@ get_number(int c) { loc.last_column = get_col_number(); YYSTYPE result; - result.u.integer = strtol(bin.c_str(), (char **)NULL, 2); + result.u.integer = strtol(bin.c_str(), nullptr, 2); return get_literal(INTEGER, loc, bin, result); } @@ -2549,7 +2549,7 @@ get_number(int c) { loc.last_column = get_col_number(); YYSTYPE result; - result.u.real = (long double)pstrtod(num.c_str(), (char **)NULL); + result.u.real = (long double)pstrtod(num.c_str(), nullptr); return get_literal(REAL, loc, num, result); } @@ -2565,11 +2565,11 @@ get_number(int c) { // A leading zero implies an octal number. strtol() is supposed to be // able to make this distinction by itself, but we'll do it explicitly // just to be sure. - result.u.integer = strtol(num.c_str(), (char **)NULL, 8); + result.u.integer = strtol(num.c_str(), nullptr, 8); } else { // A decimal (base 10) integer. - result.u.integer = strtol(num.c_str(), (char **)NULL, 10); + result.u.integer = strtol(num.c_str(), nullptr, 10); } return get_literal(INTEGER, loc, num, result); @@ -2859,7 +2859,7 @@ bool CPPPreprocessor:: should_ignore_preprocessor() const { Files::const_iterator fi; for (fi = _files.begin(); fi != _files.end(); ++fi) { - if ((*fi)._ignore_manifest != NULL) { + if ((*fi)._ignore_manifest != nullptr) { return true; } } @@ -2957,7 +2957,7 @@ nested_parse_template_instantiation(CPPTemplateScope *scope) { indent(cerr, _files.size() * 2) << "Beginning nested parse\n"; #endif - assert(scope != NULL); + assert(scope != nullptr); State old_state = _state; int old_nesting = _paren_nesting; @@ -2991,7 +2991,7 @@ nested_parse_template_instantiation(CPPTemplateScope *scope) { // Parse a typename template parameter. _saved_tokens.push_back(CPPToken(START_TYPE)); CPPType *type = ::parse_type(this, current_scope, global_scope); - if (type == NULL) { + if (type == nullptr) { loc.last_line = get_line_number(); loc.last_column = get_col_number() - 1; warning("invalid type", loc); @@ -3008,7 +3008,7 @@ nested_parse_template_instantiation(CPPTemplateScope *scope) { // Parse a constant expression template parameter. _saved_tokens.push_back(CPPToken(START_CONST_EXPR)); CPPExpression *expr = parse_const_expr(this, current_scope, global_scope); - if (expr == NULL) { + if (expr == nullptr) { loc.last_line = get_line_number(); loc.last_column = get_col_number() - 1; warning("invalid expression", loc); diff --git a/dtool/src/cppparser/cppReferenceType.cxx b/dtool/src/cppparser/cppReferenceType.cxx index bbb1f1a50e..0b351c830e 100644 --- a/dtool/src/cppparser/cppReferenceType.cxx +++ b/dtool/src/cppparser/cppReferenceType.cxx @@ -114,7 +114,7 @@ is_constructible(const CPPType *given_type) const { const CPPType *b; CPPReferenceType *ref_type = ((CPPType *)given_type)->as_reference_type(); - if (ref_type != NULL) { + if (ref_type != nullptr) { if (ref_type->_value_category == VC_rvalue) { return is_constructible(ref_type->_pointing_at); } @@ -159,7 +159,7 @@ is_constructible(const CPPType *given_type) const { // Can initialize from derived class pointer. const CPPStructType *a_struct = a->as_struct_type(); const CPPStructType *b_struct = b->as_struct_type(); - if (a_struct != NULL && b_struct != NULL) { + if (a_struct != nullptr && b_struct != nullptr) { return a_struct->is_base_of(b_struct); } @@ -199,7 +199,7 @@ is_destructible() const { bool CPPReferenceType:: is_equivalent(const CPPType &other) const { const CPPReferenceType *ot = ((CPPType *)&other)->as_reference_type(); - if (ot == (CPPReferenceType *)NULL) { + if (ot == nullptr) { return CPPType::is_equivalent(other); } @@ -261,7 +261,7 @@ as_reference_type() { bool CPPReferenceType:: is_equal(const CPPDeclaration *other) const { const CPPReferenceType *ot = ((CPPDeclaration *)other)->as_reference_type(); - assert(ot != NULL); + assert(ot != nullptr); return (_pointing_at == ot->_pointing_at) && (_value_category == ot->_value_category); @@ -275,7 +275,7 @@ is_equal(const CPPDeclaration *other) const { bool CPPReferenceType:: is_less(const CPPDeclaration *other) const { const CPPReferenceType *ot = ((CPPDeclaration *)other)->as_reference_type(); - assert(ot != NULL); + assert(ot != nullptr); if (_value_category != ot->_value_category) { return (_value_category < ot->_value_category); diff --git a/dtool/src/cppparser/cppScope.cxx b/dtool/src/cppparser/cppScope.cxx index a873cfa3cf..34f2d47c7f 100644 --- a/dtool/src/cppparser/cppScope.cxx +++ b/dtool/src/cppparser/cppScope.cxx @@ -43,7 +43,7 @@ CPPScope(CPPScope *parent_scope, _parent_scope(parent_scope), _current_vis(starting_vis) { - _struct_type = NULL; + _struct_type = nullptr; _is_fully_specified = false; _fully_specified_known = false; _is_fully_specified_recursive_protect = false; @@ -111,7 +111,7 @@ add_declaration(CPPDeclaration *decl, CPPScope *global_scope, // that appeared preceding this particular declaration; they might be // relevant to the declaration. - if (decl->_leading_comment == (CPPCommentBlock *)NULL) { + if (decl->_leading_comment == nullptr) { decl->_leading_comment = preprocessor->get_comment_before(pos.first_line, pos.file); } @@ -151,13 +151,13 @@ define_typedef_type(CPPTypedefType *type, CPPPreprocessor *error_sink) { // We don't do redefinitions of typedefs. But we don't complain as long // as this is actually a typedef to the previous definition. if (other_type != type->_type && - (other_td == NULL || !other_td->_type->is_equivalent(*type->_type))) { + (other_td == nullptr || !other_td->_type->is_equivalent(*type->_type))) { - if (error_sink != NULL) { + if (error_sink != nullptr) { ostringstream errstr; - type->output(errstr, 0, NULL, false); + type->output(errstr, 0, nullptr, false); errstr << " has conflicting declaration as "; - other_type->output(errstr, 0, NULL, true); + other_type->output(errstr, 0, nullptr, true); error_sink->error(errstr.str(), type->_ident->_loc); error_sink->error("previous definition is here", other_td->_ident->_loc); @@ -185,7 +185,7 @@ define_typedef_type(CPPTypedefType *type, CPPPreprocessor *error_sink) { // incomplete, replace it. CPPDeclaration *old_templ = (*result.first).second; CPPType *old_templ_type = old_templ->as_type(); - if (old_templ_type == NULL || old_templ_type->is_incomplete()) { + if (old_templ_type == nullptr || old_templ_type->is_incomplete()) { // The previous template definition was incomplete, maybe a forward // reference; replace it with the good one. (*result.first).second = type; @@ -199,7 +199,7 @@ define_typedef_type(CPPTypedefType *type, CPPPreprocessor *error_sink) { */ void CPPScope:: define_extension_type(CPPExtensionType *type, CPPPreprocessor *error_sink) { - assert(type != NULL); + assert(type != nullptr); string name = type->get_local_name(this); if (name.empty()) { return; @@ -239,13 +239,13 @@ define_extension_type(CPPExtensionType *type, CPPPreprocessor *error_sink) { CPPExtensionType *other_ext = other_type->as_extension_type(); if (other_ext->_type != type->_type) { - if (error_sink != NULL) { + if (error_sink != nullptr) { ostringstream errstr; errstr << type->_type << " " << type->get_fully_scoped_name() << " was previously declared as " << other_ext->_type; error_sink->error(errstr.str(), type->_ident->_loc); - if (other_ext->_ident != NULL) { + if (other_ext->_ident != nullptr) { error_sink->error("previous declaration is here", other_ext->_ident->_loc); } @@ -258,20 +258,20 @@ define_extension_type(CPPExtensionType *type, CPPPreprocessor *error_sink) { // Error out if the declaration is different than the previous one. if (other_type != type && - (other_td == NULL || other_td->_type != type)) { + (other_td == nullptr || other_td->_type != type)) { - if (error_sink != NULL) { + if (error_sink != nullptr) { ostringstream errstr; if (!cppparser_output_class_keyword) { errstr << type->_type << " "; } - type->output(errstr, 0, NULL, false); + type->output(errstr, 0, nullptr, false); errstr << " has conflicting definition as "; - other_type->output(errstr, 0, NULL, true); + other_type->output(errstr, 0, nullptr, true); error_sink->error(errstr.str(), type->_ident->_loc); CPPExtensionType *other_ext = other_type->as_extension_type(); - if (other_ext != NULL && other_ext->_ident != NULL) { + if (other_ext != nullptr && other_ext->_ident != nullptr) { error_sink->error("previous definition is here", other_ext->_ident->_loc); } @@ -297,7 +297,7 @@ define_extension_type(CPPExtensionType *type, CPPPreprocessor *error_sink) { // incomplete, replace it. CPPDeclaration *old_templ = (*result.first).second; CPPType *old_templ_type = old_templ->as_type(); - if (old_templ_type == NULL || old_templ_type->is_incomplete()) { + if (old_templ_type == nullptr || old_templ_type->is_incomplete()) { // The previous template definition was incomplete, maybe a forward // reference; replace it with the good one. (*result.first).second = type; @@ -330,19 +330,19 @@ add_using(CPPUsing *using_decl, CPPScope *global_scope, if (using_decl->_full_namespace) { CPPScope *scope = using_decl->_ident->find_scope(this, global_scope); - if (scope != NULL) { + if (scope != nullptr) { _using.insert(scope); } else { - if (error_sink != NULL) { + if (error_sink != nullptr) { error_sink->warning("Attempt to use undefined namespace: " + using_decl->_ident->get_fully_scoped_name(), using_decl->_ident->_loc); } } } else { CPPDeclaration *decl = using_decl->_ident->find_symbol(this, global_scope); - if (decl != NULL) { + if (decl != nullptr) { handle_declaration(decl, global_scope, error_sink); } else { - if (error_sink != NULL) { + if (error_sink != nullptr) { error_sink->warning("Attempt to use unknown symbol: " + using_decl->_ident->get_fully_scoped_name(), using_decl->_ident->_loc); } } @@ -368,7 +368,7 @@ is_fully_specified() const { bool specified = true; - if (_parent_scope != NULL && !_parent_scope->is_fully_specified()) { + if (_parent_scope != nullptr && !_parent_scope->is_fully_specified()) { specified = false; } @@ -397,9 +397,9 @@ instantiate(const CPPTemplateParameterList *actual_params, CPPPreprocessor *error_sink) const { CPPScope *this_scope = (CPPScope *)this; - if (_parent_scope == NULL || - _parent_scope->as_template_scope() == NULL) { - if (error_sink != NULL) { + if (_parent_scope == nullptr || + _parent_scope->as_template_scope() == nullptr) { + if (error_sink != nullptr) { error_sink->warning("Ignoring template parameters for scope " + get_local_name()); } @@ -448,7 +448,7 @@ instantiate(const CPPTemplateParameterList *actual_params, ++pi) { CPPDeclaration *decl = (*pi); CPPClassTemplateParameter *ctp = decl->as_class_template_parameter(); - if (ctp != NULL) { + if (ctp != nullptr) { // CPPTypedefType *td = new CPPTypedefType(ctp, ctp->_ident); // scope->_typedefs.insert(Typedefs::value_type // (ctp->_ident->get_local_name(), td)); @@ -487,8 +487,8 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *rep = new CPPScope(current_scope, _name, V_public); bool anything_changed; - if (_parent_scope != NULL && - _parent_scope->as_template_scope() != NULL) { + if (_parent_scope != nullptr && + _parent_scope->as_template_scope() != nullptr) { // If the parent of this scope is a template scope--e.g. this scope has // template parameters--then we must first remove any of the template // parameters from the subst list. These will later get substituted @@ -529,31 +529,31 @@ find_type(const string &name, bool recurse) const { Using::const_iterator ui; for (ui = _using.begin(); ui != _using.end(); ++ui) { CPPType *type = (*ui)->find_type(name, false); - if (type != NULL) { + if (type != nullptr) { return type; } } - if (_struct_type != NULL) { + if (_struct_type != nullptr) { CPPStructType::Derivation::const_iterator di; for (di = _struct_type->_derivation.begin(); di != _struct_type->_derivation.end(); ++di) { CPPStructType *st = (*di)._base->as_struct_type(); - if (st != NULL) { + if (st != nullptr) { CPPType *type = st->_scope->find_type(name, false); - if (type != NULL) { + if (type != nullptr) { return type; } } } } - if (recurse && _parent_scope != NULL) { + if (recurse && _parent_scope != nullptr) { return _parent_scope->find_type(name); } - return NULL; + return nullptr; } /** @@ -573,32 +573,32 @@ find_type(const string &name, CPPDeclaration::SubstDecl &subst, Using::const_iterator ui; for (ui = _using.begin(); ui != _using.end(); ++ui) { CPPType *type = (*ui)->find_type(name, subst, global_scope, false); - if (type != NULL) { + if (type != nullptr) { return type; } } - if (_struct_type != NULL) { + if (_struct_type != nullptr) { CPPStructType::Derivation::const_iterator di; for (di = _struct_type->_derivation.begin(); di != _struct_type->_derivation.end(); ++di) { CPPStructType *st = (*di)._base->as_struct_type(); - if (st != NULL) { + if (st != nullptr) { CPPType *type = st->_scope->find_type(name, subst, global_scope, false); - if (type != NULL) { + if (type != nullptr) { return type; } } } } - if (recurse && _parent_scope != NULL) { + if (recurse && _parent_scope != nullptr) { return _parent_scope->find_type(name, subst, global_scope); } - return NULL; + return nullptr; } /** @@ -611,7 +611,7 @@ find_scope(const string &name, bool recurse) const { return (*ni).second->get_scope(); } - CPPType *type = (CPPType *)NULL; + CPPType *type = nullptr; Types::const_iterator ti; ti = _types.find(name); @@ -620,33 +620,33 @@ find_scope(const string &name, bool recurse) const { // Resolve if this is a typedef or const. while (type->get_subtype() == CPPDeclaration::ST_const || type->get_subtype() == CPPDeclaration::ST_typedef) { - if (type->as_typedef_type() != (CPPType *)NULL) { + if (type->as_typedef_type() != nullptr) { type = type->as_typedef_type()->_type; } else { type = type->as_const_type()->_wrapped_around; } } - } else if (_struct_type != NULL) { + } else if (_struct_type != nullptr) { CPPStructType::Derivation::const_iterator di; for (di = _struct_type->_derivation.begin(); di != _struct_type->_derivation.end(); ++di) { CPPStructType *st = (*di)._base->as_struct_type(); - if (st != NULL) { + if (st != nullptr) { type = st->_scope->find_type(name, false); } } } - if (type != NULL) { + if (type != nullptr) { CPPStructType *st = type->as_struct_type(); - if (st != NULL) { + if (st != nullptr) { return st->_scope; } CPPEnumType *et = type->as_enum_type(); - if (et != NULL) { + if (et != nullptr) { return et->_scope; } } @@ -654,16 +654,16 @@ find_scope(const string &name, bool recurse) const { Using::const_iterator ui; for (ui = _using.begin(); ui != _using.end(); ++ui) { CPPScope *scope = (*ui)->find_scope(name, false); - if (scope != NULL) { + if (scope != nullptr) { return scope; } } - if (recurse && _parent_scope != NULL) { + if (recurse && _parent_scope != nullptr) { return _parent_scope->find_scope(name); } - return (CPPScope *)NULL; + return nullptr; } /** @@ -673,14 +673,14 @@ CPPScope *CPPScope:: find_scope(const string &name, CPPDeclaration::SubstDecl &subst, CPPScope *global_scope, bool recurse) const { CPPType *type = find_type(name, subst, global_scope, recurse); - if (type == NULL) { - return NULL; + if (type == nullptr) { + return nullptr; } // Resolve if this is a typedef or const. while (type->get_subtype() == CPPDeclaration::ST_const || type->get_subtype() == CPPDeclaration::ST_typedef) { - if (type->as_typedef_type() != (CPPType *)NULL) { + if (type->as_typedef_type() != nullptr) { type = type->as_typedef_type()->_type; } else { type = type->as_const_type()->_wrapped_around; @@ -688,16 +688,16 @@ find_scope(const string &name, CPPDeclaration::SubstDecl &subst, } CPPStructType *st = type->as_struct_type(); - if (st != NULL) { + if (st != nullptr) { return st->_scope; } CPPEnumType *et = type->as_enum_type(); - if (et != NULL) { + if (et != nullptr) { return et->_scope; } - return NULL; + return nullptr; } /** @@ -705,7 +705,7 @@ find_scope(const string &name, CPPDeclaration::SubstDecl &subst, */ CPPDeclaration *CPPScope:: find_symbol(const string &name, bool recurse) const { - if (_struct_type != NULL && name == get_simple_name()) { + if (_struct_type != nullptr && name == get_simple_name()) { return _struct_type; } @@ -735,31 +735,31 @@ find_symbol(const string &name, bool recurse) const { Using::const_iterator ui; for (ui = _using.begin(); ui != _using.end(); ++ui) { CPPDeclaration *decl = (*ui)->find_symbol(name, false); - if (decl != NULL) { + if (decl != nullptr) { return decl; } } - if (_struct_type != NULL) { + if (_struct_type != nullptr) { CPPStructType::Derivation::const_iterator di; for (di = _struct_type->_derivation.begin(); di != _struct_type->_derivation.end(); ++di) { CPPStructType *st = (*di)._base->as_struct_type(); - if (st != NULL) { + if (st != nullptr) { CPPDeclaration *decl = st->_scope->find_symbol(name, false); - if (decl != NULL) { + if (decl != nullptr) { return decl; } } } } - if (recurse && _parent_scope != NULL) { + if (recurse && _parent_scope != nullptr) { return _parent_scope->find_symbol(name); } - return NULL; + return nullptr; } /** @@ -776,31 +776,31 @@ find_template(const string &name, bool recurse) const { Using::const_iterator ui; for (ui = _using.begin(); ui != _using.end(); ++ui) { CPPDeclaration *decl = (*ui)->find_template(name, false); - if (decl != NULL) { + if (decl != nullptr) { return decl; } } - if (_struct_type != NULL) { + if (_struct_type != nullptr) { CPPStructType::Derivation::const_iterator di; for (di = _struct_type->_derivation.begin(); di != _struct_type->_derivation.end(); ++di) { CPPStructType *st = (*di)._base->as_struct_type(); - if (st != NULL) { + if (st != nullptr) { CPPDeclaration *decl = st->_scope->find_template(name, false); - if (decl != NULL) { + if (decl != nullptr) { return decl; } } } } - if (recurse && _parent_scope != NULL) { + if (recurse && _parent_scope != nullptr) { return _parent_scope->find_template(name); } - return NULL; + return nullptr; } /** @@ -827,7 +827,7 @@ get_local_name(CPPScope *scope) const { } */ - if (scope != NULL && _parent_scope != NULL/* && _parent_scope != scope*/) { + if (scope != nullptr && _parent_scope != nullptr/* && _parent_scope != scope*/) { string parent_scope_name = _parent_scope->get_local_name(scope); if (parent_scope_name.empty()) { return _name.get_name_with_templ(); @@ -851,7 +851,7 @@ get_fully_scoped_name() const { } */ - if (_parent_scope != NULL) { + if (_parent_scope != nullptr) { return _parent_scope->get_fully_scoped_name() + "::" + _name.get_name_with_templ(); } else { @@ -865,7 +865,7 @@ get_fully_scoped_name() const { void CPPScope:: output(ostream &out, CPPScope *scope) const { // out << get_local_name(scope); - if (_parent_scope != NULL && _parent_scope != scope) { + if (_parent_scope != nullptr && _parent_scope != scope) { _parent_scope->output(out, scope); out << "::"; } @@ -887,7 +887,7 @@ write(ostream &out, int indent_level, CPPScope *scope) const { } bool complete = false; - if (cd->as_type() != NULL || cd->as_namespace() != NULL) { + if (cd->as_type() != nullptr || cd->as_namespace() != nullptr) { complete = true; } @@ -906,10 +906,10 @@ get_template_scope() { if (as_template_scope()) { return as_template_scope(); } - if (_parent_scope != NULL) { + if (_parent_scope != nullptr) { return _parent_scope->get_template_scope(); } - return (CPPTemplateScope *)NULL; + return nullptr; } /** @@ -917,7 +917,7 @@ get_template_scope() { */ CPPTemplateScope *CPPScope:: as_template_scope() { - return (CPPTemplateScope *)NULL; + return nullptr; } /** @@ -933,9 +933,9 @@ copy_substitute_decl(CPPScope *to_scope, CPPDeclaration::SubstDecl &subst, CPPScope *global_scope) const { bool anything_changed = false; - if (_struct_type != NULL) { - CPPScope *native_scope = (CPPScope *)NULL; - if (_struct_type->_ident != (CPPIdentifier *)NULL) { + if (_struct_type != nullptr) { + CPPScope *native_scope = nullptr; + if (_struct_type->_ident != nullptr) { native_scope = _struct_type->_ident->_native_scope; } to_scope->_struct_type = @@ -975,9 +975,9 @@ copy_substitute_decl(CPPScope *to_scope, CPPDeclaration::SubstDecl &subst, CPPType *source_type = (*ei).second; CPPDeclaration *decl = source_type->substitute_decl(subst, to_scope, global_scope); - assert(decl != NULL); + assert(decl != nullptr); CPPType *new_type = decl->as_type(); - assert(new_type != NULL); + assert(new_type != nullptr); to_scope->_structs.insert(ExtensionTypes::value_type(name, new_type)); if (new_type != source_type) { anything_changed = true; @@ -988,9 +988,9 @@ copy_substitute_decl(CPPScope *to_scope, CPPDeclaration::SubstDecl &subst, CPPType *source_type = (*ei).second; CPPDeclaration *decl = source_type->substitute_decl(subst, to_scope, global_scope); - assert(decl != NULL); + assert(decl != nullptr); CPPType *new_type = decl->as_type(); - assert(new_type != NULL); + assert(new_type != nullptr); to_scope->_classes.insert(ExtensionTypes::value_type(name, new_type)); if (new_type != source_type) { anything_changed = true; @@ -1001,9 +1001,9 @@ copy_substitute_decl(CPPScope *to_scope, CPPDeclaration::SubstDecl &subst, CPPType *source_type = (*ei).second; CPPDeclaration *decl = source_type->substitute_decl(subst, to_scope, global_scope); - assert(decl != NULL); + assert(decl != nullptr); CPPType *new_type = decl->as_type(); - assert(new_type != NULL); + assert(new_type != nullptr); to_scope->_unions.insert(ExtensionTypes::value_type(name, new_type)); if (new_type != source_type) { anything_changed = true; @@ -1014,9 +1014,9 @@ copy_substitute_decl(CPPScope *to_scope, CPPDeclaration::SubstDecl &subst, CPPType *source_type = (*ei).second; CPPDeclaration *decl = source_type->substitute_decl(subst, to_scope, global_scope); - assert(decl != NULL); + assert(decl != nullptr); CPPType *new_type = decl->as_type(); - assert(new_type != NULL); + assert(new_type != nullptr); to_scope->_enums.insert(ExtensionTypes::value_type(name, new_type)); if (new_type != source_type) { anything_changed = true; @@ -1028,7 +1028,7 @@ copy_substitute_decl(CPPScope *to_scope, CPPDeclaration::SubstDecl &subst, string name = fgroup->_name; CPPFunctionGroup *&to_fgroup = to_scope->_functions[name]; - if (to_fgroup == (CPPFunctionGroup *)NULL) { + if (to_fgroup == nullptr) { to_fgroup = new CPPFunctionGroup(name); } @@ -1095,30 +1095,30 @@ void CPPScope:: handle_declaration(CPPDeclaration *decl, CPPScope *global_scope, CPPPreprocessor *error_sink) { CPPTypedefType *def = decl->as_typedef_type(); - if (def != NULL) { + if (def != nullptr) { define_typedef_type(def, error_sink); CPPExtensionType *et = def->_type->as_extension_type(); - if (et != NULL) { + if (et != nullptr) { define_extension_type(et, error_sink); } return; } CPPTypeDeclaration *typedecl = decl->as_type_declaration(); - if (typedecl != (CPPTypeDeclaration *)NULL) { + if (typedecl != nullptr) { CPPExtensionType *et = typedecl->_type->as_extension_type(); - if (et != NULL) { + if (et != nullptr) { define_extension_type(et, error_sink); } return; } CPPInstance *inst = decl->as_instance(); - if (inst != NULL) { + if (inst != nullptr) { inst->check_for_constructor(this, global_scope); - if (inst->_ident != NULL) { + if (inst->_ident != nullptr) { // Not sure if this is the best place to assign this. However, this // fixes a bug with variables in expressions not having the proper // scoping prefix. ~rdb @@ -1153,7 +1153,7 @@ handle_declaration(CPPDeclaration *decl, CPPScope *global_scope, // Don't add a new template definition if we already had one by the // same name in another scope. - if (find_template(name) == NULL) { + if (find_template(name) == nullptr) { _templates.insert(Templates::value_type(name, inst)); } @@ -1170,7 +1170,7 @@ handle_declaration(CPPDeclaration *decl, CPPScope *global_scope, } CPPExtensionType *et = decl->as_extension_type(); - if (et != NULL) { + if (et != nullptr) { define_extension_type(et, error_sink); } } diff --git a/dtool/src/cppparser/cppScope.h b/dtool/src/cppparser/cppScope.h index dc8c7e0295..76539bff3b 100644 --- a/dtool/src/cppparser/cppScope.h +++ b/dtool/src/cppparser/cppScope.h @@ -63,19 +63,19 @@ public: const cppyyltype &pos); virtual void add_enum_value(CPPInstance *inst); virtual void define_typedef_type(CPPTypedefType *type, - CPPPreprocessor *error_sink = NULL); + CPPPreprocessor *error_sink = nullptr); virtual void define_extension_type(CPPExtensionType *type, - CPPPreprocessor *error_sink = NULL); + CPPPreprocessor *error_sink = nullptr); virtual void define_namespace(CPPNamespace *scope); virtual void add_using(CPPUsing *using_decl, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL); + CPPPreprocessor *error_sink = nullptr); virtual bool is_fully_specified() const; CPPScope * instantiate(const CPPTemplateParameterList *actual_params, CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; CPPScope * substitute_decl(CPPDeclaration::SubstDecl &subst, @@ -98,7 +98,7 @@ public: bool recurse = true) const; virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = NULL) const; + virtual string get_local_name(CPPScope *scope = nullptr) const; virtual string get_fully_scoped_name() const; virtual void output(ostream &out, CPPScope *scope) const; @@ -113,7 +113,7 @@ private: CPPScope *global_scope) const; void handle_declaration(CPPDeclaration *decl, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL); + CPPPreprocessor *error_sink = nullptr); public: typedef vector Declarations; @@ -159,7 +159,7 @@ private: inline ostream & operator << (ostream &out, const CPPScope &scope) { - scope.output(out, (CPPScope *)NULL); + scope.output(out, nullptr); return out; } diff --git a/dtool/src/cppparser/cppSimpleType.cxx b/dtool/src/cppparser/cppSimpleType.cxx index 8107e7ee24..321e76c3cd 100644 --- a/dtool/src/cppparser/cppSimpleType.cxx +++ b/dtool/src/cppparser/cppSimpleType.cxx @@ -74,7 +74,7 @@ is_constructible(const CPPType *given_type) const { given_type = ((CPPType *)given_type)->remove_reference()->remove_cv(); const CPPSimpleType *simple_type = given_type->as_simple_type(); - if (simple_type == NULL) { + if (simple_type == nullptr) { return given_type->is_enum() && is_arithmetic(); } else if (_type == T_nullptr) { return simple_type->_type == T_nullptr; @@ -250,7 +250,7 @@ as_simple_type() { bool CPPSimpleType:: is_equal(const CPPDeclaration *other) const { const CPPSimpleType *ot = ((CPPDeclaration *)other)->as_simple_type(); - assert(ot != NULL); + assert(ot != nullptr); return _type == ot->_type && _flags == ot->_flags; } @@ -263,7 +263,7 @@ is_equal(const CPPDeclaration *other) const { bool CPPSimpleType:: is_less(const CPPDeclaration *other) const { const CPPSimpleType *ot = ((CPPDeclaration *)other)->as_simple_type(); - assert(ot != NULL); + assert(ot != nullptr); if (_type != ot->_type) { return _type < ot->_type; diff --git a/dtool/src/cppparser/cppStructType.cxx b/dtool/src/cppparser/cppStructType.cxx index fda8feaa2b..25337642a0 100644 --- a/dtool/src/cppparser/cppStructType.cxx +++ b/dtool/src/cppparser/cppStructType.cxx @@ -82,15 +82,15 @@ operator = (const CPPStructType ©) { */ void CPPStructType:: append_derivation(CPPType *base, CPPVisibility vis, bool is_virtual) { - if (base != NULL) { + if (base != nullptr) { // Unwrap any typedefs, since we can't inherit from a typedef. CPPTypedefType *def = base->as_typedef_type(); - while (def != NULL) { + while (def != nullptr) { base = def->_type; def = base->as_typedef_type(); } - if (vis == V_unknown && base->as_extension_type() != NULL) { + if (vis == V_unknown && base->as_extension_type() != nullptr) { // Default visibility. if (base->as_extension_type()->_type == T_class) { vis = V_private; @@ -139,7 +139,7 @@ is_base_of(const CPPStructType *other) const { Derivation::const_iterator di; for (di = other->_derivation.begin(); di != other->_derivation.end(); ++di) { const CPPStructType *base = (*di)._base->as_struct_type(); - if (base != NULL && is_base_of(base)) { + if (base != nullptr && is_base_of(base)) { return true; } } @@ -165,7 +165,7 @@ is_empty() const { Derivation::const_iterator di; for (di = _derivation.begin(); di != _derivation.end(); ++di) { CPPStructType *base = (*di)._base->as_struct_type(); - if ((*di)._is_virtual || (base != NULL && !base->is_empty())) { + if ((*di)._is_virtual || (base != nullptr && !base->is_empty())) { return false; } } @@ -174,7 +174,7 @@ is_empty() const { CPPScope::Variables::const_iterator vi; for (vi = _scope->_variables.begin(); vi != _scope->_variables.end(); ++vi) { CPPInstance *instance = (*vi).second; - assert(instance != NULL); + assert(instance != nullptr); if (instance->_storage_class & CPPInstance::SC_static) { // Static members don't count. @@ -206,7 +206,7 @@ is_polymorphic() const { */ bool CPPStructType:: is_standard_layout() const { - assert(_scope != NULL); + assert(_scope != nullptr); CPPVisibility member_vis = V_unknown; @@ -214,7 +214,7 @@ is_standard_layout() const { CPPScope::Variables::const_iterator vi; for (vi = _scope->_variables.begin(); vi != _scope->_variables.end(); ++vi) { CPPInstance *instance = (*vi).second; - assert(instance != NULL); + assert(instance != nullptr); if (instance->_storage_class & CPPInstance::SC_static) { // Static members don't count. @@ -222,7 +222,7 @@ is_standard_layout() const { } // Finally, check if the data member itself is standard layout. - assert(instance->_type != NULL); + assert(instance->_type != nullptr); if (!instance->_type->is_standard_layout()) { return false; } @@ -230,7 +230,7 @@ is_standard_layout() const { if (member_vis == V_unknown) { // The first non-static data member may not be a base class. CPPStructType *struct_type = instance->_type->remove_cv()->as_struct_type(); - if (struct_type != NULL && struct_type->is_base_of(this)) { + if (struct_type != nullptr && struct_type->is_base_of(this)) { return false; } member_vis = instance->_vis; @@ -274,32 +274,32 @@ is_trivial() const { Derivation::const_iterator di; for (di = _derivation.begin(); di != _derivation.end(); ++di) { CPPStructType *base = (*di)._base->as_struct_type(); - if ((*di)._is_virtual || (base != NULL && !base->is_trivial())) { + if ((*di)._is_virtual || (base != nullptr && !base->is_trivial())) { return false; } } - assert(_scope != NULL); + assert(_scope != nullptr); // Make sure all members are trivial. CPPScope::Variables::const_iterator vi; for (vi = _scope->_variables.begin(); vi != _scope->_variables.end(); ++vi) { CPPInstance *instance = (*vi).second; - assert(instance != NULL); + assert(instance != nullptr); if (instance->_storage_class & CPPInstance::SC_static) { // Static members don't count. continue; } - if (instance->_initializer != NULL) { + if (instance->_initializer != nullptr) { // A member with an initializer means the default constructor would // assign a value. This means the type can't be trivial. return false; } // Finally, check if the data member itself is non-trivial. - assert(instance->_type != NULL); + assert(instance->_type != nullptr); if (!instance->_type->is_trivial()) { return false; } @@ -325,9 +325,9 @@ is_trivial() const { continue; } - assert(inst->_type != (CPPType *)NULL); + assert(inst->_type != nullptr); CPPFunctionType *ftype = inst->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); if (ftype->_flags & (CPPFunctionType::F_destructor | CPPFunctionType::F_move_constructor | @@ -370,7 +370,7 @@ is_constructible(const CPPType *given_type) const { CPPType *base_type = ((CPPType *)given_type)->remove_reference(); if (is_equivalent(*base_type->remove_cv())) { const CPPReferenceType *ref_type = given_type->as_reference_type(); - if (ref_type == NULL || + if (ref_type == nullptr || ref_type->_value_category == CPPReferenceType::VC_rvalue) { return is_move_constructible(V_public); } else { @@ -384,16 +384,16 @@ is_constructible(const CPPType *given_type) const { // Check for a different constructor. CPPFunctionGroup *fgroup = get_constructor(); - if (fgroup != (CPPFunctionGroup *)NULL) { + if (fgroup != nullptr) { CPPFunctionGroup::Instances::const_iterator ii; for (ii = fgroup->_instances.begin(); ii != fgroup->_instances.end(); ++ii) { CPPInstance *inst = (*ii); - assert(inst->_type != (CPPType *)NULL); + assert(inst->_type != nullptr); CPPFunctionType *ftype = inst->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); CPPParameterList *params = ftype->_parameters; if (params->_parameters.size() == 1 && !params->_includes_ellipsis) { @@ -464,7 +464,7 @@ is_default_constructible(CPPVisibility min_vis) const { } CPPInstance *constructor = get_default_constructor(); - if (constructor != (CPPInstance *)NULL) { + if (constructor != nullptr) { // It has a default constructor. if (constructor->_vis > min_vis) { // Inaccessible default constructor. @@ -480,7 +480,7 @@ is_default_constructible(CPPVisibility min_vis) const { } // Does it have constructors at all? If so, no implicit one is generated. - if (get_constructor() != (CPPFunctionGroup *)NULL) { + if (get_constructor() != nullptr) { return false; } @@ -489,7 +489,7 @@ is_default_constructible(CPPVisibility min_vis) const { Derivation::const_iterator di; for (di = _derivation.begin(); di != _derivation.end(); ++di) { CPPStructType *base = (*di)._base->as_struct_type(); - if (base != NULL) { + if (base != nullptr) { if (!base->is_default_constructible(V_protected)) { return false; } @@ -500,14 +500,14 @@ is_default_constructible(CPPVisibility min_vis) const { CPPScope::Variables::const_iterator vi; for (vi = _scope->_variables.begin(); vi != _scope->_variables.end(); ++vi) { CPPInstance *instance = (*vi).second; - assert(instance != NULL); + assert(instance != nullptr); if (instance->_storage_class & CPPInstance::SC_static) { // Static members don't count. continue; } - if (instance->_initializer != (CPPExpression *)NULL) { + if (instance->_initializer != nullptr) { // It has a default value. continue; } @@ -530,7 +530,7 @@ is_copy_constructible(CPPVisibility min_vis) const { } CPPInstance *constructor = get_copy_constructor(); - if (constructor != (CPPInstance *)NULL) { + if (constructor != nullptr) { // It has a copy constructor. if (constructor->_vis > min_vis) { // Inaccessible copy constructor. @@ -546,7 +546,7 @@ is_copy_constructible(CPPVisibility min_vis) const { } CPPInstance *destructor = get_destructor(); - if (destructor != (CPPInstance *)NULL) { + if (destructor != nullptr) { if (destructor->_vis > min_vis) { // Inaccessible destructor. return false; @@ -563,7 +563,7 @@ is_copy_constructible(CPPVisibility min_vis) const { Derivation::const_iterator di; for (di = _derivation.begin(); di != _derivation.end(); ++di) { CPPStructType *base = (*di)._base->as_struct_type(); - if (base != NULL) { + if (base != nullptr) { if (!base->is_copy_constructible(V_protected)) { return false; } @@ -574,7 +574,7 @@ is_copy_constructible(CPPVisibility min_vis) const { CPPScope::Variables::const_iterator vi; for (vi = _scope->_variables.begin(); vi != _scope->_variables.end(); ++vi) { CPPInstance *instance = (*vi).second; - assert(instance != NULL); + assert(instance != nullptr); if (instance->_storage_class & CPPInstance::SC_static) { // Static members don't count. @@ -595,7 +595,7 @@ is_copy_constructible(CPPVisibility min_vis) const { bool CPPStructType:: is_move_constructible(CPPVisibility min_vis) const { CPPInstance *constructor = get_move_constructor(); - if (constructor != (CPPInstance *)NULL) { + if (constructor != nullptr) { // It has a user-declared move constructor. if (constructor->_vis > min_vis) { // Inaccessible move constructor. @@ -624,7 +624,7 @@ is_move_constructible(CPPVisibility min_vis) const { bool CPPStructType:: is_copy_assignable(CPPVisibility min_vis) const { CPPInstance *assignment_operator = get_copy_assignment_operator(); - if (assignment_operator != (CPPInstance *)NULL) { + if (assignment_operator != nullptr) { // It has a copy assignment operator. if (assignment_operator->_vis > min_vis) { // Inaccessible copy assignment operator. @@ -653,7 +653,7 @@ is_copy_assignable(CPPVisibility min_vis) const { Derivation::const_iterator di; for (di = _derivation.begin(); di != _derivation.end(); ++di) { CPPStructType *base = (*di)._base->as_struct_type(); - if (base != NULL) { + if (base != nullptr) { if (!base->is_copy_assignable(V_protected)) { return false; } @@ -664,7 +664,7 @@ is_copy_assignable(CPPVisibility min_vis) const { CPPScope::Variables::const_iterator vi; for (vi = _scope->_variables.begin(); vi != _scope->_variables.end(); ++vi) { CPPInstance *instance = (*vi).second; - assert(instance != NULL); + assert(instance != nullptr); if (instance->_storage_class & CPPInstance::SC_static) { // Static members don't count. @@ -686,7 +686,7 @@ is_copy_assignable(CPPVisibility min_vis) const { bool CPPStructType:: is_move_assignable(CPPVisibility min_vis) const { CPPInstance *assignment_operator = get_move_assignment_operator(); - if (assignment_operator != (CPPInstance *)NULL) { + if (assignment_operator != nullptr) { // It has a user-declared move assignment_operator. if (assignment_operator->_vis > min_vis) { // Inaccessible move assignment_operator. @@ -715,7 +715,7 @@ bool CPPStructType:: is_destructible(CPPVisibility min_vis) const { // Do we have an explicit destructor? CPPInstance *destructor = get_destructor(); - if (destructor != (CPPInstance *)NULL) { + if (destructor != nullptr) { if (destructor->_vis > min_vis) { // Yes, but it's inaccessible. return false; @@ -733,18 +733,18 @@ is_destructible(CPPVisibility min_vis) const { Derivation::const_iterator di; for (di = _derivation.begin(); di != _derivation.end(); ++di) { CPPStructType *base = (*di)._base->as_struct_type(); - if (base != NULL && !base->is_destructible(V_protected)) { + if (base != nullptr && !base->is_destructible(V_protected)) { return false; } } - assert(_scope != NULL); + assert(_scope != nullptr); // Make sure all members are destructible. CPPScope::Variables::const_iterator vi; for (vi = _scope->_variables.begin(); vi != _scope->_variables.end(); ++vi) { CPPInstance *instance = (*vi).second; - assert(instance != NULL); + assert(instance != nullptr); if (instance->_storage_class & CPPInstance::SC_static) { // Static members don't count. @@ -752,7 +752,7 @@ is_destructible(CPPVisibility min_vis) const { } // If the data member is not destructible, no go. - assert(instance->_type != NULL); + assert(instance->_type != nullptr); if (!instance->_type->is_destructible()) { return false; } @@ -791,11 +791,11 @@ is_convertible_to(const CPPType *other) const { continue; } - assert(inst->_type != (CPPType *)NULL); + assert(inst->_type != nullptr); CPPFunctionType *ftype = inst->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); - if (ftype->_return_type != NULL && + if (ftype->_return_type != nullptr && (ftype->_flags & CPPFunctionType::F_operator_typecast) != 0) { // Yes, this is a typecast operator. Test using the return type. if (ftype->_return_type->is_convertible_to(other)) { @@ -809,7 +809,7 @@ is_convertible_to(const CPPType *other) const { Derivation::const_iterator di; for (di = _derivation.begin(); di != _derivation.end(); ++di) { CPPStructType *base = (*di)._base->as_struct_type(); - if (base != NULL && (*di)._vis <= V_public && !base->is_convertible_to(other)) { + if (base != nullptr && (*di)._vis <= V_public && !base->is_convertible_to(other)) { return true; } } @@ -845,7 +845,7 @@ check_virtual() const { bool CPPStructType:: has_virtual_destructor() const { CPPInstance *destructor = get_destructor(); - if (destructor != NULL) { + if (destructor != nullptr) { if (destructor->_storage_class & CPPInstance::SC_virtual) { return true; } @@ -854,7 +854,7 @@ has_virtual_destructor() const { Derivation::const_iterator di; for (di = _derivation.begin(); di != _derivation.end(); ++di) { CPPStructType *base = (*di)._base->as_struct_type(); - if (base != NULL && base->has_virtual_destructor()) { + if (base != nullptr && base->has_virtual_destructor()) { return true; } } @@ -869,7 +869,7 @@ has_virtual_destructor() const { */ bool CPPStructType:: is_fully_specified() const { - if (_scope != NULL && !_scope->is_fully_specified()) { + if (_scope != nullptr && !_scope->is_fully_specified()) { return false; } return CPPType::is_fully_specified(); @@ -895,7 +895,7 @@ get_constructor() const { if (fi != _scope->_functions.end()) { return fi->second; } else { - return (CPPFunctionGroup *)NULL; + return nullptr; } } @@ -906,8 +906,8 @@ get_constructor() const { CPPInstance *CPPStructType:: get_default_constructor() const { CPPFunctionGroup *fgroup = get_constructor(); - if (fgroup == (CPPFunctionGroup *)NULL) { - return (CPPInstance *)NULL; + if (fgroup == nullptr) { + return nullptr; } CPPFunctionGroup::Instances::const_iterator ii; @@ -915,19 +915,19 @@ get_default_constructor() const { ii != fgroup->_instances.end(); ++ii) { CPPInstance *inst = (*ii); - assert(inst->_type != (CPPType *)NULL); + assert(inst->_type != nullptr); CPPFunctionType *ftype = inst->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); if (ftype->_parameters->_parameters.size() == 0 || - ftype->_parameters->_parameters.front()->_initializer != NULL) { + ftype->_parameters->_parameters.front()->_initializer != nullptr) { // It takes 0 parameters (or all parameters have default values). return inst; } } - return (CPPInstance *)NULL; + return nullptr; } /** @@ -937,8 +937,8 @@ get_default_constructor() const { CPPInstance *CPPStructType:: get_copy_constructor() const { CPPFunctionGroup *fgroup = get_constructor(); - if (fgroup == (CPPFunctionGroup *)NULL) { - return (CPPInstance *)NULL; + if (fgroup == nullptr) { + return nullptr; } CPPFunctionGroup::Instances::const_iterator ii; @@ -946,17 +946,17 @@ get_copy_constructor() const { ii != fgroup->_instances.end(); ++ii) { CPPInstance *inst = (*ii); - assert(inst->_type != (CPPType *)NULL); + assert(inst->_type != nullptr); CPPFunctionType *ftype = inst->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); if ((ftype->_flags & CPPFunctionType::F_copy_constructor) != 0) { return inst; } } - return (CPPInstance *)NULL; + return nullptr; } /** @@ -966,8 +966,8 @@ get_copy_constructor() const { CPPInstance *CPPStructType:: get_move_constructor() const { CPPFunctionGroup *fgroup = get_constructor(); - if (fgroup == (CPPFunctionGroup *)NULL) { - return (CPPInstance *)NULL; + if (fgroup == nullptr) { + return nullptr; } CPPFunctionGroup::Instances::const_iterator ii; @@ -975,17 +975,17 @@ get_move_constructor() const { ii != fgroup->_instances.end(); ++ii) { CPPInstance *inst = (*ii); - assert(inst->_type != (CPPType *)NULL); + assert(inst->_type != nullptr); CPPFunctionType *ftype = inst->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); if ((ftype->_flags & CPPFunctionType::F_move_constructor) != 0) { return inst; } } - return (CPPInstance *)NULL; + return nullptr; } /** @@ -1000,7 +1000,7 @@ get_assignment_operator() const { if (fi != _scope->_functions.end()) { return fi->second; } else { - return (CPPFunctionGroup *)NULL; + return nullptr; } } @@ -1011,8 +1011,8 @@ get_assignment_operator() const { CPPInstance *CPPStructType:: get_copy_assignment_operator() const { CPPFunctionGroup *fgroup = get_assignment_operator(); - if (fgroup == (CPPFunctionGroup *)NULL) { - return (CPPInstance *)NULL; + if (fgroup == nullptr) { + return nullptr; } CPPFunctionGroup::Instances::const_iterator ii; @@ -1020,17 +1020,17 @@ get_copy_assignment_operator() const { ii != fgroup->_instances.end(); ++ii) { CPPInstance *inst = (*ii); - assert(inst->_type != (CPPType *)NULL); + assert(inst->_type != nullptr); CPPFunctionType *ftype = inst->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); if ((ftype->_flags & CPPFunctionType::F_copy_assignment_operator) != 0) { return inst; } } - return (CPPInstance *)NULL; + return nullptr; } /** @@ -1040,8 +1040,8 @@ get_copy_assignment_operator() const { CPPInstance *CPPStructType:: get_move_assignment_operator() const { CPPFunctionGroup *fgroup = get_assignment_operator(); - if (fgroup == (CPPFunctionGroup *)NULL) { - return (CPPInstance *)NULL; + if (fgroup == nullptr) { + return nullptr; } CPPFunctionGroup::Instances::const_iterator ii; @@ -1049,17 +1049,17 @@ get_move_assignment_operator() const { ii != fgroup->_instances.end(); ++ii) { CPPInstance *inst = (*ii); - assert(inst->_type != (CPPType *)NULL); + assert(inst->_type != nullptr); CPPFunctionType *ftype = inst->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); if ((ftype->_flags & CPPFunctionType::F_move_assignment_operator) != 0) { return inst; } } - return (CPPInstance *)NULL; + return nullptr; } /** @@ -1082,10 +1082,10 @@ get_destructor() const { ii != fgroup->_instances.end(); ++ii) { CPPInstance *inst = (*ii); - assert(inst->_type != (CPPType *)NULL); + assert(inst->_type != nullptr); CPPFunctionType *ftype = inst->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); if ((ftype->_flags & CPPFunctionType::F_destructor) != 0) { return inst; @@ -1094,7 +1094,7 @@ get_destructor() const { ++fi; } - return (CPPInstance *)NULL; + return nullptr; } /** @@ -1108,8 +1108,8 @@ instantiate(const CPPTemplateParameterList *actual_params, // I *think* this assertion is no longer valid. Who knows. // assert(!_incomplete); - if (_scope == NULL) { - if (error_sink != NULL) { + if (_scope == nullptr) { + if (error_sink != nullptr) { error_sink->warning("Ignoring template parameters for class " + get_local_name()); } @@ -1149,7 +1149,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { SubstDecl::const_iterator si = subst.find(this); if (si != subst.end()) { - assert((*si).second != NULL); + assert((*si).second != nullptr); return (*si).second; } @@ -1163,19 +1163,19 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, // type which we'll define later. CPPTypeProxy *proxy = new CPPTypeProxy; _proxies.push_back(proxy); - assert(proxy != NULL); + assert(proxy != nullptr); return proxy; } _subst_decl_recursive_protect = true; CPPStructType *rep = new CPPStructType(*this); - if (_ident != NULL) { + if (_ident != nullptr) { rep->_ident = _ident->substitute_decl(subst, current_scope, global_scope); } - if (_scope != NULL) { + if (_scope != nullptr) { rep->_scope = _scope->substitute_decl(subst, current_scope, global_scope); if (rep->_scope != _scope) { @@ -1185,14 +1185,14 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, // parameters into our identifier. CPPScope *pscope = rep->_scope->get_parent_scope(); - if (pscope != (CPPScope *)NULL && + if (pscope != nullptr && pscope->_name.has_templ()) { // If the struct name didn't have an explicit template reference // before, now it does. - if (_ident != NULL && !_ident->_names.empty() && !_ident->_names.back().has_templ()) { + if (_ident != nullptr && !_ident->_names.empty() && !_ident->_names.back().has_templ()) { if (rep->is_template()) { - rep->_template_scope = (CPPTemplateScope *)NULL; + rep->_template_scope = nullptr; CPPNameComponent nc(get_simple_name()); nc.set_templ(pscope->_name.get_templ()); rep->_ident = new CPPIdentifier(nc, _file); @@ -1227,9 +1227,9 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, (*pi)->_actual_type = rep; } - assert(rep != NULL); + assert(rep != nullptr); rep = CPPType::new_type(rep)->as_struct_type(); - assert(rep != NULL); + assert(rep != nullptr); if (rep != this) { _instantiations.insert(rep); } @@ -1241,7 +1241,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, */ void CPPStructType:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { - if (!complete && _ident != NULL) { + if (!complete && _ident != nullptr) { // If we have a name, use it. if (cppparser_output_class_keyword) { out << _type << " "; @@ -1258,7 +1258,7 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { get_template_scope()->_parameters.write_formal(out, scope); indent(out, indent_level); } - if (_ident != NULL) { + if (_ident != nullptr) { out << _type << " " << _ident->get_local_name(scope); } else { out << _type; @@ -1316,7 +1316,7 @@ get_virtual_funcs(VFunctions &funcs) const { for (di = _derivation.begin(); di != _derivation.end(); ++di) { VFunctions vf; CPPStructType *base = (*di)._base->as_struct_type(); - if (base != NULL) { + if (base != nullptr) { base->get_virtual_funcs(vf); funcs.splice(funcs.end(), vf); } @@ -1331,9 +1331,9 @@ get_virtual_funcs(VFunctions &funcs) const { ++vfnext; CPPInstance *inst = (*vfi); - assert(inst->_type != (CPPType *)NULL); + assert(inst->_type != nullptr); CPPFunctionType *base_ftype = inst->_type->as_function_type(); - assert(base_ftype != (CPPFunctionType *)NULL); + assert(base_ftype != nullptr); if (inst->_storage_class & CPPInstance::SC_deleted) { // Ignore deleted functions. @@ -1342,7 +1342,7 @@ get_virtual_funcs(VFunctions &funcs) const { // Match destructor-for-destructor; don't try to match destructors up by // name. CPPInstance *destructor = get_destructor(); - if (destructor != (CPPInstance *)NULL) { + if (destructor != nullptr) { // It's a match! This destructor is virtual. funcs.erase(vfi); destructor->_storage_class |= @@ -1365,10 +1365,10 @@ get_virtual_funcs(VFunctions &funcs) const { ii != fgroup->_instances.end() && !match_found; ++ii) { CPPInstance *new_inst = (*ii); - assert(new_inst->_type != (CPPType *)NULL); + assert(new_inst->_type != nullptr); CPPFunctionType *new_ftype = new_inst->_type->as_function_type(); - assert(new_ftype != (CPPFunctionType *)NULL); + assert(new_ftype != nullptr); if (new_ftype->match_virtual_override(*base_ftype)) { // It's a match! We now know it's virtual. Erase this function diff --git a/dtool/src/cppparser/cppStructType.h b/dtool/src/cppparser/cppStructType.h index 9da8777a6c..fc8a9e45b2 100644 --- a/dtool/src/cppparser/cppStructType.h +++ b/dtool/src/cppparser/cppStructType.h @@ -80,7 +80,7 @@ public: virtual CPPDeclaration * instantiate(const CPPTemplateParameterList *actual_params, CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; virtual CPPDeclaration *substitute_decl(SubstDecl &subst, CPPScope *current_scope, diff --git a/dtool/src/cppparser/cppTBDType.cxx b/dtool/src/cppparser/cppTBDType.cxx index 0b01c86817..664787cbe6 100644 --- a/dtool/src/cppparser/cppTBDType.cxx +++ b/dtool/src/cppparser/cppTBDType.cxx @@ -35,7 +35,7 @@ CPPTBDType(CPPIdentifier *ident) : CPPType *CPPTBDType:: resolve_type(CPPScope *current_scope, CPPScope *global_scope) { CPPType *type = _ident->find_type(current_scope, global_scope); - if (type != NULL) { + if (type != nullptr) { return type; } return this; @@ -108,13 +108,13 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, } rep = CPPType::new_type(rep)->as_tbd_type(); - assert(rep != NULL); + assert(rep != nullptr); CPPType *result = rep; // Can we now define it as a real type? CPPType *type = rep->_ident->find_type(current_scope, global_scope, subst); - if (type != NULL) { + if (type != nullptr) { result = type; } @@ -156,7 +156,7 @@ as_tbd_type() { bool CPPTBDType:: is_equal(const CPPDeclaration *other) const { const CPPTBDType *ot = ((CPPDeclaration *)other)->as_tbd_type(); - assert(ot != NULL); + assert(ot != nullptr); return (*_ident) == (*ot->_ident); } @@ -169,7 +169,7 @@ is_equal(const CPPDeclaration *other) const { bool CPPTBDType:: is_less(const CPPDeclaration *other) const { const CPPTBDType *ot = ((CPPDeclaration *)other)->as_tbd_type(); - assert(ot != NULL); + assert(ot != nullptr); return (*_ident) < (*ot->_ident); } diff --git a/dtool/src/cppparser/cppTBDType.h b/dtool/src/cppparser/cppTBDType.h index 6d35f053f4..f72833e3ff 100644 --- a/dtool/src/cppparser/cppTBDType.h +++ b/dtool/src/cppparser/cppTBDType.h @@ -36,7 +36,7 @@ public: virtual bool is_tbd() const; virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = NULL) const; + virtual string get_local_name(CPPScope *scope = nullptr) const; virtual string get_fully_scoped_name() const; virtual CPPDeclaration *substitute_decl(SubstDecl &subst, diff --git a/dtool/src/cppparser/cppTemplateParameterList.cxx b/dtool/src/cppparser/cppTemplateParameterList.cxx index 54d4ae544c..24ee70e9e4 100644 --- a/dtool/src/cppparser/cppTemplateParameterList.cxx +++ b/dtool/src/cppparser/cppTemplateParameterList.cxx @@ -65,7 +65,7 @@ build_subst_decl(const CPPTemplateParameterList &formal_params, if (decl->as_instance()) { // A value template parameter. Its default is an expression. CPPInstance *inst = decl->as_instance(); - if (inst->_initializer != NULL) { + if (inst->_initializer != nullptr) { CPPDeclaration *decl = inst->_initializer->substitute_decl(subst, current_scope, global_scope); @@ -77,7 +77,7 @@ build_subst_decl(const CPPTemplateParameterList &formal_params, } else if (decl->as_class_template_parameter()) { // A class template parameter. CPPClassTemplateParameter *cparam = decl->as_class_template_parameter(); - if (cparam->_default_type != NULL) { + if (cparam->_default_type != nullptr) { CPPDeclaration *decl = cparam->_default_type->substitute_decl(subst, current_scope, global_scope); @@ -116,12 +116,12 @@ bool CPPTemplateParameterList:: is_tbd() const { for (int i = 0; i < (int)_parameters.size(); ++i) { CPPType *type = _parameters[i]->as_type(); - if (type != (CPPType *)NULL && - (type->is_tbd() || type->as_class_template_parameter() != NULL)) { + if (type != nullptr && + (type->is_tbd() || type->as_class_template_parameter() != nullptr)) { return true; } CPPExpression *expr = _parameters[i]->as_expression(); - if (expr != NULL && expr->is_tbd()) { + if (expr != nullptr && expr->is_tbd()) { return true; } } diff --git a/dtool/src/cppparser/cppTemplateParameterList.h b/dtool/src/cppparser/cppTemplateParameterList.h index 712dd227cd..50b97247ea 100644 --- a/dtool/src/cppparser/cppTemplateParameterList.h +++ b/dtool/src/cppparser/cppTemplateParameterList.h @@ -58,7 +58,7 @@ public: inline ostream & operator << (ostream &out, const CPPTemplateParameterList &plist) { - plist.output(out, (CPPScope *)NULL); + plist.output(out, nullptr); return out; } diff --git a/dtool/src/cppparser/cppTemplateScope.cxx b/dtool/src/cppparser/cppTemplateScope.cxx index 2960718205..34482ad64b 100644 --- a/dtool/src/cppparser/cppTemplateScope.cxx +++ b/dtool/src/cppparser/cppTemplateScope.cxx @@ -35,7 +35,7 @@ add_declaration(CPPDeclaration *decl, CPPScope *global_scope, CPPPreprocessor *preprocessor, const cppyyltype &pos) { decl->_template_scope = this; - assert(_parent_scope != NULL); + assert(_parent_scope != nullptr); _parent_scope->add_declaration(decl, global_scope, preprocessor, pos); } @@ -45,7 +45,7 @@ add_declaration(CPPDeclaration *decl, CPPScope *global_scope, void CPPTemplateScope:: add_enum_value(CPPInstance *inst) { inst->_template_scope = this; - assert(_parent_scope != NULL); + assert(_parent_scope != nullptr); _parent_scope->add_enum_value(inst); } @@ -55,7 +55,7 @@ add_enum_value(CPPInstance *inst) { void CPPTemplateScope:: define_typedef_type(CPPTypedefType *type, CPPPreprocessor *error_sink) { type->_template_scope = this; - assert(_parent_scope != NULL); + assert(_parent_scope != nullptr); _parent_scope->define_typedef_type(type, error_sink); } @@ -65,7 +65,7 @@ define_typedef_type(CPPTypedefType *type, CPPPreprocessor *error_sink) { void CPPTemplateScope:: define_extension_type(CPPExtensionType *type, CPPPreprocessor *error_sink) { type->_template_scope = this; - assert(_parent_scope != NULL); + assert(_parent_scope != nullptr); _parent_scope->define_extension_type(type, error_sink); } @@ -74,7 +74,7 @@ define_extension_type(CPPExtensionType *type, CPPPreprocessor *error_sink) { */ void CPPTemplateScope:: define_namespace(CPPNamespace *scope) { - assert(_parent_scope != NULL); + assert(_parent_scope != nullptr); _parent_scope->define_namespace(scope); } @@ -84,7 +84,7 @@ define_namespace(CPPNamespace *scope) { void CPPTemplateScope:: add_using(CPPUsing *using_decl, CPPScope *global_scope, CPPPreprocessor *error_sink) { - assert(_parent_scope != NULL); + assert(_parent_scope != nullptr); _parent_scope->add_using(using_decl, global_scope, error_sink); } @@ -95,16 +95,16 @@ void CPPTemplateScope:: add_template_parameter(CPPDeclaration *param) { _parameters._parameters.push_back(param); CPPClassTemplateParameter *cl = param->as_class_template_parameter(); - if (cl != NULL) { + if (cl != nullptr) { // Create an implicit typedef for this class parameter. - if (cl->_ident != NULL) { + if (cl->_ident != nullptr) { string name = cl->_ident->get_local_name(); _types[name] = cl; } } CPPInstance *inst = param->as_instance(); - if (inst != NULL) { + if (inst != nullptr) { // Register the variable for this value parameter. string name = inst->get_local_name(); if (!name.empty()) { @@ -128,7 +128,7 @@ is_fully_specified() const { */ string CPPTemplateScope:: get_simple_name() const { - assert(_parent_scope != NULL); + assert(_parent_scope != nullptr); return _parent_scope->get_simple_name(); } @@ -137,7 +137,7 @@ get_simple_name() const { */ string CPPTemplateScope:: get_local_name(CPPScope *scope) const { - assert(_parent_scope != NULL); + assert(_parent_scope != nullptr); return _parent_scope->get_local_name(scope); } @@ -146,7 +146,7 @@ get_local_name(CPPScope *scope) const { */ string CPPTemplateScope:: get_fully_scoped_name() const { - assert(_parent_scope != NULL); + assert(_parent_scope != nullptr); return _parent_scope->get_fully_scoped_name(); } diff --git a/dtool/src/cppparser/cppTemplateScope.h b/dtool/src/cppparser/cppTemplateScope.h index 91235ff0fe..0cd987145e 100644 --- a/dtool/src/cppparser/cppTemplateScope.h +++ b/dtool/src/cppparser/cppTemplateScope.h @@ -35,17 +35,17 @@ public: const cppyyltype &pos); virtual void add_enum_value(CPPInstance *inst); virtual void define_typedef_type(CPPTypedefType *type, - CPPPreprocessor *error_sink = NULL); + CPPPreprocessor *error_sink = nullptr); virtual void define_extension_type(CPPExtensionType *type, - CPPPreprocessor *error_sink = NULL); + CPPPreprocessor *error_sink = nullptr); virtual void define_namespace(CPPNamespace *scope); virtual void add_using(CPPUsing *using_decl, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL); + CPPPreprocessor *error_sink = nullptr); virtual bool is_fully_specified() const; virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = NULL) const; + virtual string get_local_name(CPPScope *scope = nullptr) const; virtual string get_fully_scoped_name() const; virtual void output(ostream &out, CPPScope *scope) const; diff --git a/dtool/src/cppparser/cppToken.cxx b/dtool/src/cppparser/cppToken.cxx index d2e00982dc..8504150bbd 100644 --- a/dtool/src/cppparser/cppToken.cxx +++ b/dtool/src/cppparser/cppToken.cxx @@ -357,7 +357,7 @@ output(ostream &out) const { break; case KW_OPERATOR: - if (_lval.u.identifier != NULL) { + if (_lval.u.identifier != nullptr) { out << *_lval.u.identifier << "::"; } out << "KW_OPERATOR"; diff --git a/dtool/src/cppparser/cppType.cxx b/dtool/src/cppparser/cppType.cxx index af3f511da4..26581c7205 100644 --- a/dtool/src/cppparser/cppType.cxx +++ b/dtool/src/cppparser/cppType.cxx @@ -36,7 +36,7 @@ CPPType:: CPPType(const CPPFile &file) : CPPDeclaration(file) { - _declaration = (CPPTypeDeclaration *)NULL; + _declaration = nullptr; // This is set true by interrogate when the "forcetype" keyword is used. _forcetype = false; @@ -143,11 +143,11 @@ is_parameter_expr() const { bool CPPType:: is_enum() const { const CPPTypedefType *td_type = as_typedef_type(); - if (td_type != NULL) { + if (td_type != nullptr) { return td_type->_type->is_enum(); } const CPPExtensionType *ext_type = as_extension_type(); - if (ext_type != NULL) { + if (ext_type != nullptr) { return ext_type->_type == CPPExtensionType::T_enum || ext_type->_type == CPPExtensionType::T_enum_struct || ext_type->_type == CPPExtensionType::T_enum_class; @@ -161,7 +161,7 @@ is_enum() const { bool CPPType:: is_const() const { const CPPTypedefType *td_type = as_typedef_type(); - if (td_type != NULL) { + if (td_type != nullptr) { return td_type->_type->is_const(); } return get_subtype() == ST_const; @@ -173,7 +173,7 @@ is_const() const { bool CPPType:: is_reference() const { const CPPTypedefType *td_type = as_typedef_type(); - if (td_type != NULL) { + if (td_type != nullptr) { return td_type->_type->is_reference(); } return get_subtype() == ST_reference; @@ -186,11 +186,11 @@ is_reference() const { bool CPPType:: is_pointer() const { const CPPTypedefType *td_type = as_typedef_type(); - if (td_type != NULL) { + if (td_type != nullptr) { return td_type->_type->is_pointer(); } const CPPConstType *const_type = as_const_type(); - if (const_type != NULL) { + if (const_type != nullptr) { return const_type->_wrapped_around->is_pointer(); } return get_subtype() == ST_pointer; @@ -203,7 +203,7 @@ is_pointer() const { CPPType *CPPType:: remove_const() { const CPPTypedefType *td_type = as_typedef_type(); - if (td_type != NULL) { + if (td_type != nullptr) { CPPType *unwrapped = td_type->_type->remove_const(); if (unwrapped != td_type->_type) { return unwrapped; @@ -212,7 +212,7 @@ remove_const() { } } const CPPConstType *const_type = as_const_type(); - if (const_type != NULL) { + if (const_type != nullptr) { return const_type->_wrapped_around->remove_const(); } return this; @@ -224,7 +224,7 @@ remove_const() { CPPType *CPPType:: remove_reference() { const CPPTypedefType *td_type = as_typedef_type(); - if (td_type != NULL) { + if (td_type != nullptr) { CPPType *unwrapped = td_type->_type->remove_reference(); if (unwrapped != td_type->_type) { return unwrapped; @@ -233,7 +233,7 @@ remove_reference() { } } const CPPReferenceType *ref_type = as_reference_type(); - if (ref_type != NULL) { + if (ref_type != nullptr) { return ref_type->_pointing_at; } return this; diff --git a/dtool/src/cppparser/cppType.h b/dtool/src/cppparser/cppType.h index a312f45d33..1bf89db2f5 100644 --- a/dtool/src/cppparser/cppType.h +++ b/dtool/src/cppparser/cppType.h @@ -68,10 +68,10 @@ public: CPPType *remove_pointer(); bool has_typedef_name() const; - string get_typedef_name(CPPScope *scope = NULL) const; + string get_typedef_name(CPPScope *scope = nullptr) const; virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = NULL) const; + virtual string get_local_name(CPPScope *scope = nullptr) const; virtual string get_fully_scoped_name() const; virtual string get_preferred_name() const; int get_num_alt_names() const; diff --git a/dtool/src/cppparser/cppTypeDeclaration.cxx b/dtool/src/cppparser/cppTypeDeclaration.cxx index 88509911b4..23c72cd2d0 100644 --- a/dtool/src/cppparser/cppTypeDeclaration.cxx +++ b/dtool/src/cppparser/cppTypeDeclaration.cxx @@ -18,10 +18,10 @@ */ CPPTypeDeclaration:: CPPTypeDeclaration(CPPType *type) : - CPPInstance(type, (CPPIdentifier *)NULL) + CPPInstance(type, nullptr) { - assert(_type != NULL); - if (_type->_declaration == (CPPTypeDeclaration *)NULL) { + assert(_type != nullptr); + if (_type->_declaration == nullptr) { _type->_declaration = this; } } @@ -34,11 +34,11 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { CPPDeclaration *decl = CPPInstance::substitute_decl(subst, current_scope, global_scope); - assert(decl != NULL); + assert(decl != nullptr); if (decl->as_type_declaration()) { return decl; } - assert(decl->as_instance() != NULL); + assert(decl->as_instance() != nullptr); return new CPPTypeDeclaration(decl->as_instance()->_type); } diff --git a/dtool/src/cppparser/cppTypeParser.cxx b/dtool/src/cppparser/cppTypeParser.cxx index 815875dcf9..b88a1a079d 100644 --- a/dtool/src/cppparser/cppTypeParser.cxx +++ b/dtool/src/cppparser/cppTypeParser.cxx @@ -22,7 +22,7 @@ CPPTypeParser(CPPScope *current_scope, CPPScope *global_scope) : _current_scope(current_scope), _global_scope(global_scope) { - _type = NULL; + _type = nullptr; } /** @@ -69,7 +69,7 @@ parse_type(const string &type, const CPPPreprocessor &filepos) { */ void CPPTypeParser:: output(ostream &out) const { - if (_type == NULL) { + if (_type == nullptr) { out << "(null type)"; } else { out << *_type; diff --git a/dtool/src/cppparser/cppTypeProxy.cxx b/dtool/src/cppparser/cppTypeProxy.cxx index 239ef04828..fe6bfb7c05 100644 --- a/dtool/src/cppparser/cppTypeProxy.cxx +++ b/dtool/src/cppparser/cppTypeProxy.cxx @@ -21,7 +21,7 @@ CPPTypeProxy:: CPPTypeProxy() : CPPType(CPPFile()) { - _actual_type = (CPPType *)NULL; + _actual_type = nullptr; } /** @@ -31,7 +31,7 @@ CPPTypeProxy() : */ CPPType *CPPTypeProxy:: resolve_type(CPPScope *, CPPScope *) { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { return this; } return _actual_type; @@ -44,7 +44,7 @@ resolve_type(CPPScope *, CPPScope *) { */ bool CPPTypeProxy:: is_tbd() const { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { return false; } return _actual_type->is_tbd(); @@ -57,7 +57,7 @@ is_tbd() const { */ bool CPPTypeProxy:: has_typedef_name() const { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { return false; } return _actual_type->has_typedef_name(); @@ -69,7 +69,7 @@ has_typedef_name() const { */ string CPPTypeProxy:: get_typedef_name(CPPScope *) const { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { return string(); } return _actual_type->get_typedef_name(); @@ -83,7 +83,7 @@ get_typedef_name(CPPScope *) const { */ string CPPTypeProxy:: get_simple_name() const { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { return "unknown"; } return _actual_type->get_simple_name(); @@ -95,7 +95,7 @@ get_simple_name() const { */ string CPPTypeProxy:: get_local_name(CPPScope *scope) const { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { return "unknown"; } return _actual_type->get_local_name(scope); @@ -107,7 +107,7 @@ get_local_name(CPPScope *scope) const { */ string CPPTypeProxy:: get_fully_scoped_name() const { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { return "unknown"; } return _actual_type->get_fully_scoped_name(); @@ -121,7 +121,7 @@ get_fully_scoped_name() const { */ string CPPTypeProxy:: get_preferred_name() const { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { return "unknown"; } return _actual_type->get_preferred_name(); @@ -132,7 +132,7 @@ get_preferred_name() const { */ bool CPPTypeProxy:: is_incomplete() const { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { return true; } return _actual_type->is_incomplete(); @@ -147,7 +147,7 @@ void CPPTypeProxy:: output_instance(ostream &out, int indent_level, CPPScope *scope, bool complete, const string &prename, const string &name) const { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { out << "unknown " << prename << name; return; } @@ -160,7 +160,7 @@ output_instance(ostream &out, int indent_level, CPPScope *scope, */ void CPPTypeProxy:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { out << "unknown"; return; } @@ -181,7 +181,7 @@ get_subtype() const { */ CPPType *CPPTypeProxy:: as_type() { - if (_actual_type == (CPPType *)NULL) { + if (_actual_type == nullptr) { return this; } return _actual_type; @@ -192,8 +192,8 @@ as_type() { */ CPPSimpleType *CPPTypeProxy:: as_simple_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPSimpleType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_simple_type(); } @@ -203,8 +203,8 @@ as_simple_type() { */ CPPPointerType *CPPTypeProxy:: as_pointer_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPPointerType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_pointer_type(); } @@ -214,8 +214,8 @@ as_pointer_type() { */ CPPReferenceType *CPPTypeProxy:: as_reference_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPReferenceType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_reference_type(); } @@ -225,8 +225,8 @@ as_reference_type() { */ CPPArrayType *CPPTypeProxy:: as_array_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPArrayType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_array_type(); } @@ -236,8 +236,8 @@ as_array_type() { */ CPPConstType *CPPTypeProxy:: as_const_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPConstType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_const_type(); } @@ -247,8 +247,8 @@ as_const_type() { */ CPPFunctionType *CPPTypeProxy:: as_function_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPFunctionType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_function_type(); } @@ -258,8 +258,8 @@ as_function_type() { */ CPPExtensionType *CPPTypeProxy:: as_extension_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPExtensionType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_extension_type(); } @@ -269,8 +269,8 @@ as_extension_type() { */ CPPStructType *CPPTypeProxy:: as_struct_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPStructType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_struct_type(); } @@ -280,8 +280,8 @@ as_struct_type() { */ CPPEnumType *CPPTypeProxy:: as_enum_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPEnumType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_enum_type(); } @@ -291,8 +291,8 @@ as_enum_type() { */ CPPTBDType *CPPTypeProxy:: as_tbd_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPTBDType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_tbd_type(); } @@ -302,8 +302,8 @@ as_tbd_type() { */ CPPTypedefType *CPPTypeProxy:: as_typedef_type() { - if (_actual_type == (CPPType *)NULL) { - return (CPPTypedefType *)NULL; + if (_actual_type == nullptr) { + return nullptr; } return _actual_type->as_typedef_type(); } diff --git a/dtool/src/cppparser/cppTypeProxy.h b/dtool/src/cppparser/cppTypeProxy.h index da87e99ca6..fcd2ebe178 100644 --- a/dtool/src/cppparser/cppTypeProxy.h +++ b/dtool/src/cppparser/cppTypeProxy.h @@ -33,10 +33,10 @@ public: virtual bool is_tbd() const; bool has_typedef_name() const; - string get_typedef_name(CPPScope *scope = NULL) const; + string get_typedef_name(CPPScope *scope = nullptr) const; virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = NULL) const; + virtual string get_local_name(CPPScope *scope = nullptr) const; virtual string get_fully_scoped_name() const; virtual string get_preferred_name() const; diff --git a/dtool/src/cppparser/cppTypedefType.cxx b/dtool/src/cppparser/cppTypedefType.cxx index d965d5db48..32d4c55865 100644 --- a/dtool/src/cppparser/cppTypedefType.cxx +++ b/dtool/src/cppparser/cppTypedefType.cxx @@ -27,7 +27,7 @@ CPPTypedefType(CPPType *type, const string &name, CPPScope *current_scope) : _ident(new CPPIdentifier(name)), _using(false) { - if (_ident != NULL) { + if (_ident != nullptr) { _ident->_native_scope = current_scope; } @@ -47,7 +47,7 @@ CPPTypedefType(CPPType *type, CPPIdentifier *ident, CPPScope *current_scope) : _ident(ident), _using(false) { - if (_ident != NULL) { + if (_ident != nullptr) { _ident->_native_scope = current_scope; } _subst_decl_recursive_protect = false; @@ -64,13 +64,13 @@ CPPTypedefType(CPPType *type, CPPInstanceIdentifier *ii, CPPType(file), _using(false) { - assert(ii != NULL); + assert(ii != nullptr); _type = ii->unroll_type(type); _ident = ii->_ident; - ii->_ident = NULL; + ii->_ident = nullptr; delete ii; - if (_ident != NULL) { + if (_ident != nullptr) { _ident->_native_scope = current_scope; } @@ -82,7 +82,7 @@ CPPTypedefType(CPPType *type, CPPInstanceIdentifier *ii, */ bool CPPTypedefType:: is_scoped() const { - if (_ident == NULL) { + if (_ident == nullptr) { return false; } else { return _ident->is_scoped(); @@ -95,7 +95,7 @@ is_scoped() const { CPPScope *CPPTypedefType:: get_scope(CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink) const { - if (_ident == NULL) { + if (_ident == nullptr) { return current_scope; } else { return _ident->get_scope(current_scope, global_scope, error_sink); @@ -107,7 +107,7 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, */ string CPPTypedefType:: get_simple_name() const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } return _ident->get_simple_name(); @@ -118,7 +118,7 @@ get_simple_name() const { */ string CPPTypedefType:: get_local_name(CPPScope *scope) const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } return _ident->get_local_name(scope); @@ -129,7 +129,7 @@ get_local_name(CPPScope *scope) const { */ string CPPTypedefType:: get_fully_scoped_name() const { - if (_ident == NULL) { + if (_ident == nullptr) { return ""; } return _ident->get_fully_scoped_name(); @@ -151,7 +151,7 @@ is_incomplete() const { */ bool CPPTypedefType:: is_tbd() const { - if (_ident != NULL && _ident->is_tbd()) { + if (_ident != nullptr && _ident->is_tbd()) { return true; } return _type->is_tbd(); @@ -228,7 +228,7 @@ is_destructible() const { */ bool CPPTypedefType:: is_fully_specified() const { - if (_ident != NULL && !_ident->is_fully_specified()) { + if (_ident != nullptr && !_ident->is_fully_specified()) { return false; } return CPPDeclaration::is_fully_specified() && @@ -253,7 +253,7 @@ CPPDeclaration *CPPTypedefType:: substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { - if (_ident != NULL && _ident->get_scope(current_scope, global_scope) == global_scope) { + if (_ident != nullptr && _ident->get_scope(current_scope, global_scope) == global_scope) { // Hack... I know that size_t etc is supposed to work fine, so preserve // these top-level typedefs. CPPDeclaration *top = @@ -375,7 +375,7 @@ is_equivalent(const CPPType &other) const { void CPPTypedefType:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { string name; - if (_ident != NULL) { + if (_ident != nullptr) { name = _ident->get_local_name(scope); } @@ -420,7 +420,7 @@ as_typedef_type() { bool CPPTypedefType:: is_equal(const CPPDeclaration *other) const { const CPPTypedefType *ot = ((CPPDeclaration *)other)->as_typedef_type(); - assert(ot != NULL); + assert(ot != nullptr); return (*_type == *ot->_type) && (*_ident == *ot->_ident) && (_using == ot->_using); } diff --git a/dtool/src/cppparser/cppTypedefType.h b/dtool/src/cppparser/cppTypedefType.h index 04a9b05995..d3a3ea3245 100644 --- a/dtool/src/cppparser/cppTypedefType.h +++ b/dtool/src/cppparser/cppTypedefType.h @@ -34,10 +34,10 @@ public: bool is_scoped() const; CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = NULL) const; + virtual string get_local_name(CPPScope *scope = nullptr) const; virtual string get_fully_scoped_name() const; virtual bool is_incomplete() const; @@ -56,7 +56,7 @@ public: virtual CPPDeclaration * instantiate(const CPPTemplateParameterList *actual_params, CPPScope *current_scope, CPPScope *global_scope, - CPPPreprocessor *error_sink = NULL) const; + CPPPreprocessor *error_sink = nullptr) const; virtual CPPDeclaration *substitute_decl(SubstDecl &subst, CPPScope *current_scope, diff --git a/dtool/src/dtoolbase/deletedBufferChain.I b/dtool/src/dtoolbase/deletedBufferChain.I index 7f6a003f64..9eb17bd4fb 100644 --- a/dtool/src/dtoolbase/deletedBufferChain.I +++ b/dtool/src/dtoolbase/deletedBufferChain.I @@ -21,7 +21,7 @@ INLINE bool DeletedBufferChain:: validate(void *ptr) { TAU_PROFILE("bool DeletedBufferChain::validate(void *)", " ", TAU_USER); - if (ptr == (void *)NULL) { + if (ptr == nullptr) { return false; } diff --git a/dtool/src/dtoolbase/deletedBufferChain.cxx b/dtool/src/dtoolbase/deletedBufferChain.cxx index 71756f3e25..303c9f1223 100644 --- a/dtool/src/dtoolbase/deletedBufferChain.cxx +++ b/dtool/src/dtoolbase/deletedBufferChain.cxx @@ -20,7 +20,7 @@ */ DeletedBufferChain:: DeletedBufferChain(size_t buffer_size) { - _deleted_chain = NULL; + _deleted_chain = nullptr; _buffer_size = buffer_size; // We must allocate at least this much space for bookkeeping reasons. @@ -44,7 +44,7 @@ allocate(size_t size, TypeHandle type_handle) { ObjectNode *obj; _lock.lock(); - if (_deleted_chain != (ObjectNode *)NULL) { + if (_deleted_chain != nullptr) { obj = _deleted_chain; _deleted_chain = _deleted_chain->_next; _lock.unlock(); @@ -103,7 +103,7 @@ deallocate(void *ptr, TypeHandle type_handle) { #ifdef USE_DELETED_CHAIN // TAU_PROFILE("void DeletedBufferChain::deallocate(void *, TypeHandle)", " // ", TAU_USER); - assert(ptr != (void *)NULL); + assert(ptr != nullptr); #ifdef DO_MEMORY_USAGE const size_t alloc_size = _buffer_size + flag_reserved_bytes + MEMORY_HOOK_ALIGNMENT - 1; diff --git a/dtool/src/dtoolbase/deletedChain.h b/dtool/src/dtoolbase/deletedChain.h index a25be5d429..1915223450 100644 --- a/dtool/src/dtoolbase/deletedChain.h +++ b/dtool/src/dtoolbase/deletedChain.h @@ -122,11 +122,11 @@ public: #define ALLOC_DELETED_CHAIN(Type) \ inline static bool validate_ptr(const void *ptr) { \ - return (ptr != NULL); \ + return (ptr != nullptr); \ } #define ALLOC_DELETED_CHAIN_DECL(Type) \ inline static bool validate_ptr(const void *ptr) { \ - return (ptr != NULL); \ + return (ptr != nullptr); \ } #define ALLOC_DELETED_CHAIN_DEF(Type) diff --git a/dtool/src/dtoolbase/dtoolbase.cxx b/dtool/src/dtoolbase/dtoolbase.cxx index 64b7425057..10d1790ccf 100644 --- a/dtool/src/dtoolbase/dtoolbase.cxx +++ b/dtool/src/dtoolbase/dtoolbase.cxx @@ -36,7 +36,7 @@ MemoryHook *memory_hook; */ void init_memory_hook() { - if (memory_hook == NULL) { + if (memory_hook == nullptr) { memory_hook = new MemoryHook; } } diff --git a/dtool/src/dtoolbase/memoryHook.cxx b/dtool/src/dtoolbase/memoryHook.cxx index 30b53769e2..82ee8dc037 100644 --- a/dtool/src/dtoolbase/memoryHook.cxx +++ b/dtool/src/dtoolbase/memoryHook.cxx @@ -256,7 +256,7 @@ heap_alloc_single(size_t size) { void *alloc = call_malloc(inflated_size); #endif - while (alloc == (void *)NULL) { + while (alloc == nullptr) { alloc_fail(inflated_size); #ifdef MEMORY_HOOK_MALLOC_LOCK _lock.lock(); @@ -333,7 +333,7 @@ heap_alloc_array(size_t size) { void *alloc = call_malloc(inflated_size); #endif - while (alloc == (void *)NULL) { + while (alloc == nullptr) { alloc_fail(inflated_size); #ifdef MEMORY_HOOK_MALLOC_LOCK _lock.lock(); @@ -387,7 +387,7 @@ heap_realloc_array(void *ptr, size_t size) { alloc1 = call_realloc(alloc1, inflated_size); #endif - while (alloc1 == (void *)NULL) { + while (alloc1 == nullptr) { alloc_fail(inflated_size); // Recover the original pointer. @@ -517,16 +517,16 @@ mmap_alloc(size_t size, bool allow_exec) { #ifdef WIN32 // Windows case. - void *ptr = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, + void *ptr = VirtualAlloc(nullptr, size, MEM_COMMIT | MEM_RESERVE, allow_exec ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE); - if (ptr == (void *)NULL) { + if (ptr == nullptr) { DWORD err = GetLastError(); cerr << "Couldn't allocate memory page of size " << size << ": "; PVOID buffer; DWORD length = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, err, 0, (LPTSTR)&buffer, 0, NULL); + nullptr, err, 0, (LPTSTR)&buffer, 0, nullptr); if (length != 0) { cerr << (char *)buffer << "\n"; } else { @@ -545,7 +545,7 @@ mmap_alloc(size_t size, bool allow_exec) { if (allow_exec) { prot |= PROT_EXEC; } - void *ptr = mmap(NULL, size, prot, MAP_PRIVATE | MAP_ANON, -1, 0); + void *ptr = mmap(nullptr, size, prot, MAP_PRIVATE | MAP_ANON, -1, 0); if (ptr == (void *)-1) { perror("mmap"); abort(); diff --git a/dtool/src/dtoolbase/neverFreeMemory.I b/dtool/src/dtoolbase/neverFreeMemory.I index f34bdae28d..6e5216e993 100644 --- a/dtool/src/dtoolbase/neverFreeMemory.I +++ b/dtool/src/dtoolbase/neverFreeMemory.I @@ -59,7 +59,7 @@ get_total_unused() { */ INLINE NeverFreeMemory *NeverFreeMemory:: get_global_ptr() { - if (_global_ptr == (NeverFreeMemory *)NULL) { + if (_global_ptr == nullptr) { make_global_ptr(); } return _global_ptr; diff --git a/dtool/src/dtoolbase/neverFreeMemory.cxx b/dtool/src/dtoolbase/neverFreeMemory.cxx index a1f720cfba..b933007dd5 100644 --- a/dtool/src/dtoolbase/neverFreeMemory.cxx +++ b/dtool/src/dtoolbase/neverFreeMemory.cxx @@ -46,7 +46,7 @@ ns_alloc(size_t size) { // Look for a page that has sufficient space remaining. - Pages::iterator pi = _pages.lower_bound(Page(NULL, size)); + Pages::iterator pi = _pages.lower_bound(Page(nullptr, size)); if (pi != _pages.end()) { // Here's a page with enough remaining space. Page page = (*pi); @@ -82,8 +82,8 @@ void NeverFreeMemory:: make_global_ptr() { NeverFreeMemory *ptr = new NeverFreeMemory; void *result = AtomicAdjust::compare_and_exchange_ptr - ((void * TVOLATILE &)_global_ptr, (void *)NULL, (void *)ptr); - if (result != NULL) { + ((void * TVOLATILE &)_global_ptr, nullptr, (void *)ptr); + if (result != nullptr) { // Someone else got there first. delete ptr; } diff --git a/dtool/src/dtoolbase/pstrtod.cxx b/dtool/src/dtoolbase/pstrtod.cxx index 5a27ab6212..933d342f2c 100644 --- a/dtool/src/dtoolbase/pstrtod.cxx +++ b/dtool/src/dtoolbase/pstrtod.cxx @@ -104,7 +104,7 @@ pstrtod(const char *nptr, char **endptr) { if (!found_digits) { // Not a valid float. - if (endptr != NULL) { + if (endptr != nullptr) { *endptr = (char *)nptr; } return 0.0; @@ -139,7 +139,7 @@ pstrtod(const char *nptr, char **endptr) { value = -value; } - if (endptr != NULL) { + if (endptr != nullptr) { *endptr = (char *)p; } return value; @@ -154,5 +154,5 @@ pstrtod(const char *nptr, char **endptr) { */ double patof(const char *str) { - return pstrtod(str, (char **)NULL); + return pstrtod(str, nullptr); } diff --git a/dtool/src/dtoolbase/ptmalloc2_smp_src.cxx b/dtool/src/dtoolbase/ptmalloc2_smp_src.cxx index 7ecfde41f1..8cb0c882c5 100644 --- a/dtool/src/dtoolbase/ptmalloc2_smp_src.cxx +++ b/dtool/src/dtoolbase/ptmalloc2_smp_src.cxx @@ -259,20 +259,20 @@ typedef pthread_mutex_t mutex_t; pthread_mutex_t is at least one int wide. */ #define mutex_init(m) \ - (__pthread_mutex_init != NULL \ - ? __pthread_mutex_init (m, NULL) : (*(int *)(m) = 0)) + (__pthread_mutex_init != nullptr \ + ? __pthread_mutex_init (m, nullptr) : (*(int *)(m) = 0)) #define mutex_lock(m) \ - (__pthread_mutex_lock != NULL \ + (__pthread_mutex_lock != nullptr \ ? __pthread_mutex_lock (m) : ((*(int *)(m) = 1), 0)) #define mutex_trylock(m) \ - (__pthread_mutex_trylock != NULL \ + (__pthread_mutex_trylock != nullptr \ ? __pthread_mutex_trylock (m) : (*(int *)(m) ? 1 : ((*(int *)(m) = 1), 0))) #define mutex_unlock(m) \ - (__pthread_mutex_unlock != NULL \ + (__pthread_mutex_unlock != nullptr \ ? __pthread_mutex_unlock (m) : (*(int*)(m) = 0)) #define thread_atfork(prepare, parent, child) \ - (__pthread_atfork != NULL ? __pthread_atfork(prepare, parent, child) : 0) + (__pthread_atfork != nullptr ? __pthread_atfork(prepare, parent, child) : 0) #elif defined(MUTEX_INITIALIZER) /* Assume hurd, with cthreads */ @@ -360,7 +360,7 @@ static inline int mutex_lock(mutex_t *m) { } else { tm.tv_sec = 0; tm.tv_nsec = 2000001; - nanosleep(&tm, NULL); + nanosleep(&tm, nullptr); cnt = 0; } } @@ -392,7 +392,7 @@ static inline int mutex_unlock(mutex_t *m) { typedef pthread_mutex_t mutex_t; #define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER -#define mutex_init(m) pthread_mutex_init(m, NULL) +#define mutex_init(m) pthread_mutex_init(m, nullptr) #define mutex_lock(m) pthread_mutex_lock(m) #define mutex_trylock(m) pthread_mutex_trylock(m) #define mutex_unlock(m) pthread_mutex_unlock(m) @@ -438,7 +438,7 @@ typedef pthread_key_t tsd_key_t; typedef thread_t thread_id; #define MUTEX_INITIALIZER { 0 } -#define mutex_init(m) mutex_init(m, USYNC_THREAD, NULL) +#define mutex_init(m) mutex_init(m, USYNC_THREAD, nullptr) /* * Hack for thread-specific data on Solaris. We can't use thr_setspecific @@ -2040,7 +2040,7 @@ extern __malloc_ptr_t _int_memalign __MALLOC_P ((mstate __m, size_t __alignment, #define BOUNDED_N(ptr, sz) (ptr) #endif #ifndef RETURN_ADDRESS -#define RETURN_ADDRESS(X_) (NULL) +#define RETURN_ADDRESS(X_) (nullptr) #endif /* On some platforms we can compile internal, not exported functions better. @@ -3026,7 +3026,7 @@ int __malloc_initialized = -1; in the new arena. */ #define arena_get(ptr, size) do { \ - Void_t *vptr = NULL; \ + Void_t *vptr = nullptr; \ ptr = (mstate)tsd_getspecific(arena_key, vptr); \ if(ptr && !mutex_trylock(&ptr->mutex)) { \ THREAD_STAT(++(ptr->stat_lock_direct)); \ @@ -3088,7 +3088,7 @@ static Void_t* save_arena; static Void_t* malloc_atfork(size_t sz, const Void_t *caller) { - Void_t *vptr = NULL; + Void_t *vptr = nullptr; Void_t *victim; tsd_getspecific(arena_key, vptr); @@ -3115,7 +3115,7 @@ malloc_atfork(size_t sz, const Void_t *caller) static void free_atfork(Void_t* mem, const Void_t *caller) { - Void_t *vptr = NULL; + Void_t *vptr = nullptr; mstate ar_ptr; mchunkptr p; /* chunk corresponding to mem */ @@ -3232,9 +3232,9 @@ internal_function next_env_entry (char ***position) { char **current = *position; - char *result = NULL; + char *result = nullptr; - while (*current != NULL) + while (*current != nullptr) { if (__builtin_expect ((*current)[0] == 'M', 0) && (*current)[1] == 'A' @@ -3288,7 +3288,7 @@ ptmalloc_init __MALLOC_P((void)) __free_hook = free_starter; #ifdef _LIBC /* Initialize the pthreads interface. */ - if (__pthread_initialize != NULL) + if (__pthread_initialize != nullptr) __pthread_initialize(); #endif #endif /* !defined NO_THREADS */ @@ -3296,7 +3296,7 @@ ptmalloc_init __MALLOC_P((void)) main_arena.next = &main_arena; mutex_init(&list_lock); - tsd_key_create(&arena_key, NULL); + tsd_key_create(&arena_key, nullptr); tsd_setspecific(arena_key, (Void_t *)&main_arena); thread_atfork(ptmalloc_lock_all, ptmalloc_unlock_all, ptmalloc_unlock_all2); #ifndef NO_THREADS @@ -3305,12 +3305,12 @@ ptmalloc_init __MALLOC_P((void)) #endif #ifdef _LIBC secure = __libc_enable_secure; - s = NULL; + s = nullptr; { char **runp = _environ; char *envline; - while (__builtin_expect ((envline = next_env_entry (&runp)) != NULL, + while (__builtin_expect ((envline = next_env_entry (&runp)) != nullptr, 0)) { size_t len = strcspn (envline, "="); @@ -3367,7 +3367,7 @@ ptmalloc_init __MALLOC_P((void)) if(s[0]) mALLOPt(M_CHECK_ACTION, (int)(s[0] - '0')); __malloc_check_init(); } - if(__malloc_initialize_hook != NULL) + if(__malloc_initialize_hook != nullptr) (*__malloc_initialize_hook)(); __malloc_initialized = 1; } @@ -4103,7 +4103,7 @@ malloc_hook_ini(sz, caller) size_t sz; const __malloc_ptr_t caller; #endif { - __malloc_hook = NULL; + __malloc_hook = nullptr; ptmalloc_init(); return public_mALLOc(sz); } @@ -4116,8 +4116,8 @@ realloc_hook_ini(ptr, sz, caller) Void_t* ptr; size_t sz; const __malloc_ptr_t caller; #endif { - __malloc_hook = NULL; - __realloc_hook = NULL; + __malloc_hook = nullptr; + __realloc_hook = nullptr; ptmalloc_init(); return public_rEALLOc(ptr, sz); } @@ -4130,14 +4130,14 @@ memalign_hook_ini(alignment, sz, caller) size_t alignment; size_t sz; const __malloc_ptr_t caller; #endif { - __memalign_hook = NULL; + __memalign_hook = nullptr; ptmalloc_init(); return public_mEMALIGn(alignment, sz); } -void weak_variable (*__malloc_initialize_hook) __MALLOC_P ((void)) = NULL; +void weak_variable (*__malloc_initialize_hook) __MALLOC_P ((void)) = nullptr; void weak_variable (*__free_hook) __MALLOC_P ((__malloc_ptr_t __ptr, - const __malloc_ptr_t)) = NULL; + const __malloc_ptr_t)) = nullptr; __malloc_ptr_t weak_variable (*__malloc_hook) __MALLOC_P ((size_t __size, const __malloc_ptr_t)) = malloc_hook_ini; __malloc_ptr_t weak_variable (*__realloc_hook) @@ -4146,7 +4146,7 @@ __malloc_ptr_t weak_variable (*__realloc_hook) __malloc_ptr_t weak_variable (*__memalign_hook) __MALLOC_P ((size_t __alignment, size_t __size, const __malloc_ptr_t)) = memalign_hook_ini; -void weak_variable (*__after_morecore_hook) __MALLOC_P ((void)) = NULL; +void weak_variable (*__after_morecore_hook) __MALLOC_P ((void)) = nullptr; static int check_action = DEFAULT_CHECK_ACTION; @@ -4240,7 +4240,7 @@ mem2chunk_check(mem) Void_t* mem; unsigned char magic; p = mem2chunk(mem); - if(!aligned_OK(p)) return NULL; + if(!aligned_OK(p)) return nullptr; if( (char*)p>=mp_.sbrk_base && (char*)p<(mp_.sbrk_base+main_arena.system_mem) ) { /* Must be a chunk in conventional heap memory. */ @@ -4251,10 +4251,10 @@ mem2chunk_check(mem) Void_t* mem; ( !prev_inuse(p) && (p->prev_size&MALLOC_ALIGN_MASK || (long)prev_chunk(p)<(long)mp_.sbrk_base || next_chunk(prev_chunk(p))!=p) )) - return NULL; + return nullptr; magic = MAGICBYTE(p); for(sz += SIZE_SZ-1; (c = ((unsigned char*)p)[sz]) != magic; sz -= c) { - if(c<=0 || sz<(c+2*SIZE_SZ)) return NULL; + if(c<=0 || sz<(c+2*SIZE_SZ)) return nullptr; } ((unsigned char*)p)[sz] ^= 0xFF; } else { @@ -4271,10 +4271,10 @@ mem2chunk_check(mem) Void_t* mem; !chunk_is_mmapped(p) || (p->size & PREV_INUSE) || ( (((unsigned long)p - p->prev_size) & page_mask) != 0 ) || ( (sz = chunksize(p)), ((p->prev_size + sz) & page_mask) != 0 ) ) - return NULL; + return nullptr; magic = MAGICBYTE(p); for(sz -= 1; (c = ((unsigned char*)p)[sz]) != magic; sz -= c) { - if(c<=0 || sz<(c+2*SIZE_SZ)) return NULL; + if(c<=0 || sz<(c+2*SIZE_SZ)) return nullptr; } ((unsigned char*)p)[sz] ^= 0xFF; } @@ -4336,7 +4336,7 @@ malloc_check(sz, caller) size_t sz; const Void_t *caller; Void_t *victim; (void)mutex_lock(&main_arena.mutex); - victim = (top_check() >= 0) ? _int_malloc(&main_arena, sz+1) : NULL; + victim = (top_check() >= 0) ? _int_malloc(&main_arena, sz+1) : nullptr; (void)mutex_unlock(&main_arena.mutex); return mem2mem_check(victim, sz); } @@ -4387,7 +4387,7 @@ realloc_check(oldmem, bytes, caller) INTERNAL_SIZE_T nb, oldsize; Void_t* newmem = 0; - if (oldmem == 0) return malloc_check(bytes, NULL); + if (oldmem == 0) return malloc_check(bytes, nullptr); (void)mutex_lock(&main_arena.mutex); oldp = mem2chunk_check(oldmem); (void)mutex_unlock(&main_arena.mutex); @@ -4396,7 +4396,7 @@ realloc_check(oldmem, bytes, caller) fprintf(stderr, "realloc(): invalid pointer %p!\n", oldmem); if(check_action & 2) abort(); - return malloc_check(bytes, NULL); + return malloc_check(bytes, nullptr); } oldsize = chunksize(oldp); @@ -4460,13 +4460,13 @@ memalign_check(alignment, bytes, caller) INTERNAL_SIZE_T nb; Void_t* mem; - if (alignment <= MALLOC_ALIGNMENT) return malloc_check(bytes, NULL); + if (alignment <= MALLOC_ALIGNMENT) return malloc_check(bytes, nullptr); if (alignment < MINSIZE) alignment = MINSIZE; checked_request2size(bytes+1, nb); (void)mutex_lock(&main_arena.mutex); mem = (top_check() >= 0) ? _int_memalign(&main_arena, alignment, bytes+1) : - NULL; + nullptr; (void)mutex_unlock(&main_arena.mutex); return mem2mem_check(mem, bytes); } @@ -5367,7 +5367,7 @@ public_mALLOc(size_t bytes) __malloc_ptr_t (*hook) __MALLOC_P ((size_t, __const __malloc_ptr_t)) = __malloc_hook; - if (hook != NULL) + if (hook != nullptr) return (*hook)(bytes, RETURN_ADDRESS (0)); arena_get(ar_ptr, bytes); @@ -5407,7 +5407,7 @@ public_fREe(Void_t* mem) void (*hook) __MALLOC_P ((__malloc_ptr_t, __const __malloc_ptr_t)) = __free_hook; - if (hook != NULL) { + if (hook != nullptr) { (*hook)(mem, RETURN_ADDRESS (0)); return; } @@ -5454,11 +5454,11 @@ public_rEALLOc(Void_t* oldmem, size_t bytes) __malloc_ptr_t (*hook) __MALLOC_P ((__malloc_ptr_t, size_t, __const __malloc_ptr_t)) = __realloc_hook; - if (hook != NULL) + if (hook != nullptr) return (*hook)(oldmem, bytes, RETURN_ADDRESS (0)); #if REALLOC_ZERO_BYTES_FREES - if (bytes == 0 && oldmem != NULL) { public_fREe(oldmem); return 0; } + if (bytes == 0 && oldmem != nullptr) { public_fREe(oldmem); return 0; } #endif /* realloc of null is supposed to be same as malloc */ @@ -5523,7 +5523,7 @@ public_mEMALIGn(size_t alignment, size_t bytes) __malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, size_t, __const __malloc_ptr_t)) = __memalign_hook; - if (hook != NULL) + if (hook != nullptr) return (*hook)(alignment, bytes, RETURN_ADDRESS (0)); /* If need less alignment than we give anyway, just relay to malloc */ @@ -5602,7 +5602,7 @@ public_cALLOc(size_t n, size_t elem_size) __malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, __const __malloc_ptr_t)) = __malloc_hook; - if (hook != NULL) { + if (hook != nullptr) { sz = n * elem_size; mem = (*hook)(sz, RETURN_ADDRESS (0)); if(mem == 0) diff --git a/dtool/src/dtoolbase/test_strtod.cxx b/dtool/src/dtoolbase/test_strtod.cxx index e2c10de958..169e90bfcf 100644 --- a/dtool/src/dtoolbase/test_strtod.cxx +++ b/dtool/src/dtoolbase/test_strtod.cxx @@ -24,7 +24,7 @@ main(int argc, char *argv[]) { #endif for (int i = 1; i < argc; ++i) { - char *endptr = NULL; + char *endptr = nullptr; double result = pstrtod(argv[i], &endptr); cerr << "pstrtod - " << argv[i] << " : " << result << " : " << endptr << "\n"; result = strtod(argv[i], &endptr); diff --git a/dtool/src/dtoolbase/typeHandle.cxx b/dtool/src/dtoolbase/typeHandle.cxx index ed85da8d03..c3cad42e8c 100644 --- a/dtool/src/dtoolbase/typeHandle.cxx +++ b/dtool/src/dtoolbase/typeHandle.cxx @@ -30,8 +30,8 @@ get_memory_usage(MemoryClass memory_class) const { if ((*this) == TypeHandle::none()) { return 0; } else { - TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, NULL); - assert(rnode != (TypeRegistryNode *)NULL); + TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, nullptr); + assert(rnode != nullptr); return (size_t)AtomicAdjust::get(rnode->_memory_usage[memory_class]); } #endif // DO_MEMORY_USAGE @@ -49,8 +49,8 @@ inc_memory_usage(MemoryClass memory_class, size_t size) { assert((int)memory_class >= 0 && (int)memory_class < (int)MC_limit); #endif if ((*this) != TypeHandle::none()) { - TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, NULL); - assert(rnode != (TypeRegistryNode *)NULL); + TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, nullptr); + assert(rnode != nullptr); AtomicAdjust::add(rnode->_memory_usage[memory_class], (AtomicAdjust::Integer)size); // cerr << *this << ".inc(" << memory_class << ", " << size << ") -> " << // rnode->_memory_usage[memory_class] << "\n"; @@ -73,8 +73,8 @@ dec_memory_usage(MemoryClass memory_class, size_t size) { assert((int)memory_class >= 0 && (int)memory_class < (int)MC_limit); #endif if ((*this) != TypeHandle::none()) { - TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, NULL); - assert(rnode != (TypeRegistryNode *)NULL); + TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, nullptr); + assert(rnode != nullptr); AtomicAdjust::add(rnode->_memory_usage[memory_class], -(AtomicAdjust::Integer)size); // cerr << *this << ".dec(" << memory_class << ", " << size << ") -> " << // rnode->_memory_usage[memory_class] << "\n"; @@ -98,8 +98,8 @@ allocate_array(size_t size) { #ifdef _DEBUG assert(size <= alloc_size); #endif - TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, NULL); - assert(rnode != (TypeRegistryNode *)NULL); + TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, nullptr); + assert(rnode != nullptr); AtomicAdjust::add(rnode->_memory_usage[MC_array], (AtomicAdjust::Integer)alloc_size); if (rnode->_memory_usage[MC_array] < 0) { cerr << "Memory usage overflow for type " << rnode->_name << ".\n"; @@ -125,8 +125,8 @@ reallocate_array(void *old_ptr, size_t size) { if ((*this) != TypeHandle::none()) { size_t new_size = MemoryHook::get_ptr_size(new_ptr); - TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, NULL); - assert(rnode != (TypeRegistryNode *)NULL); + TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, nullptr); + assert(rnode != nullptr); AtomicAdjust::add(rnode->_memory_usage[MC_array], (AtomicAdjust::Integer)new_size - (AtomicAdjust::Integer)old_size); assert(rnode->_memory_usage[MC_array] >= 0); } @@ -147,8 +147,8 @@ deallocate_array(void *ptr) { #ifdef DO_MEMORY_USAGE size_t alloc_size = MemoryHook::get_ptr_size(ptr); if ((*this) != TypeHandle::none()) { - TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, NULL); - assert(rnode != (TypeRegistryNode *)NULL); + TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, nullptr); + assert(rnode != nullptr); AtomicAdjust::add(rnode->_memory_usage[MC_array], -(AtomicAdjust::Integer)alloc_size); assert(rnode->_memory_usage[MC_array] >= 0); } diff --git a/dtool/src/dtoolbase/typeHandle.h b/dtool/src/dtoolbase/typeHandle.h index b1b99c4ae0..03d0cd269c 100644 --- a/dtool/src/dtoolbase/typeHandle.h +++ b/dtool/src/dtoolbase/typeHandle.h @@ -108,18 +108,18 @@ PUBLISHED: INLINE int compare_to(const TypeHandle &other) const; INLINE size_t get_hash() const; - INLINE string get_name(TypedObject *object = (TypedObject *)NULL) const; + INLINE string get_name(TypedObject *object = nullptr) const; INLINE bool is_derived_from(TypeHandle parent, - TypedObject *object = (TypedObject *)NULL) const; + TypedObject *object = nullptr) const; - INLINE int get_num_parent_classes(TypedObject *object = (TypedObject *)NULL) const; + INLINE int get_num_parent_classes(TypedObject *object = nullptr) const; INLINE TypeHandle get_parent_class(int index) const; - INLINE int get_num_child_classes(TypedObject *object = (TypedObject *)NULL) const; + INLINE int get_num_child_classes(TypedObject *object = nullptr) const; INLINE TypeHandle get_child_class(int index) const; INLINE TypeHandle get_parent_towards(TypeHandle ancestor, - TypedObject *object = (TypedObject *)NULL) const; + TypedObject *object = nullptr) const; int get_best_parent_from_Set(const std::set< int > &legal_vals) const; diff --git a/dtool/src/dtoolbase/typeRegistry.I b/dtool/src/dtoolbase/typeRegistry.I index e35f37c207..7d47c7f7f7 100644 --- a/dtool/src/dtoolbase/typeRegistry.I +++ b/dtool/src/dtoolbase/typeRegistry.I @@ -30,7 +30,7 @@ INLINE TypeRegistry *TypeRegistry:: ptr() { // It's OK that we don't acquire the lock, because we guarantee that this is // called at static init time. - if (_global_pointer == NULL) { + if (_global_pointer == nullptr) { init_global_pointer(); } return _global_pointer; @@ -41,7 +41,7 @@ ptr() { */ INLINE void TypeRegistry:: init_lock() { - if (_lock == (MutexImpl *)NULL) { + if (_lock == nullptr) { _lock = new MutexImpl; } } diff --git a/dtool/src/dtoolbase/typeRegistry.cxx b/dtool/src/dtoolbase/typeRegistry.cxx index 7935f3221a..d7077727e1 100644 --- a/dtool/src/dtoolbase/typeRegistry.cxx +++ b/dtool/src/dtoolbase/typeRegistry.cxx @@ -20,8 +20,8 @@ #include -MutexImpl *TypeRegistry::_lock = NULL; -TypeRegistry *TypeRegistry::_global_pointer = NULL; +MutexImpl *TypeRegistry::_lock = nullptr; +TypeRegistry *TypeRegistry::_global_pointer = nullptr; /** * Creates a new Type of the given name and assigns a unique value to the @@ -37,7 +37,7 @@ register_type(TypeHandle &type_handle, const string &name) { if (type_handle != TypeHandle::none()) { // Here's a type that was already registered. Just make sure everything's // still kosher. - TypeRegistryNode *rnode = look_up(type_handle, NULL); + TypeRegistryNode *rnode = look_up(type_handle, nullptr); if (&type_handle == &rnode->_ref) { // No problem. _lock->unlock(); @@ -154,10 +154,10 @@ void TypeRegistry:: record_derivation(TypeHandle child, TypeHandle parent) { _lock->lock(); - TypeRegistryNode *cnode = look_up(child, NULL); - assert(cnode != (TypeRegistryNode *)NULL); - TypeRegistryNode *pnode = look_up(parent, NULL); - assert(pnode != (TypeRegistryNode *)NULL); + TypeRegistryNode *cnode = look_up(child, nullptr); + assert(cnode != nullptr); + TypeRegistryNode *pnode = look_up(parent, nullptr); + assert(pnode != nullptr); // First, we'll just run through the list to make sure we hadn't already // made this connection. @@ -184,8 +184,8 @@ void TypeRegistry:: record_alternate_name(TypeHandle type, const string &name) { _lock->lock(); - TypeRegistryNode *rnode = look_up(type, (TypedObject *)NULL); - if (rnode != (TypeRegistryNode *)NULL) { + TypeRegistryNode *rnode = look_up(type, nullptr); + if (rnode != nullptr) { NameRegistry::iterator ri = _name_registry.insert(NameRegistry::value_type(name, rnode)).first; @@ -250,7 +250,7 @@ string TypeRegistry:: get_name(TypeHandle type, TypedObject *object) const { _lock->lock(); TypeRegistryNode *rnode = look_up(type, object); - assert(rnode != (TypeRegistryNode *)NULL); + assert(rnode != nullptr); string name = rnode->_name; _lock->unlock(); @@ -276,10 +276,10 @@ is_derived_from(TypeHandle child, TypeHandle base, _lock->lock(); const TypeRegistryNode *child_node = look_up(child, child_object); - const TypeRegistryNode *base_node = look_up(base, (TypedObject *)NULL); + const TypeRegistryNode *base_node = look_up(base, nullptr); - assert(child_node != (TypeRegistryNode *)NULL); - assert(base_node != (TypeRegistryNode *)NULL); + assert(child_node != nullptr); + assert(base_node != nullptr); freshen_derivations(); @@ -305,13 +305,13 @@ get_num_typehandles() { TypeHandle TypeRegistry:: get_typehandle(int n) { _lock->lock(); - TypeRegistryNode *rnode = NULL; + TypeRegistryNode *rnode = nullptr; if (n >= 0 && n < (int)_handle_registry.size()) { rnode = _handle_registry[n]; } _lock->unlock(); - if (rnode != (TypeRegistryNode *)NULL) { + if (rnode != nullptr) { return rnode->_handle; } @@ -364,7 +364,7 @@ int TypeRegistry:: get_num_parent_classes(TypeHandle child, TypedObject *child_object) const { _lock->lock(); TypeRegistryNode *rnode = look_up(child, child_object); - assert(rnode != (TypeRegistryNode *)NULL); + assert(rnode != nullptr); int num_parents = (int)rnode->_parent_classes.size(); _lock->unlock(); return num_parents; @@ -378,8 +378,8 @@ TypeHandle TypeRegistry:: get_parent_class(TypeHandle child, int index) const { _lock->lock(); TypeHandle handle; - TypeRegistryNode *rnode = look_up(child, (TypedObject *)NULL); - assert(rnode != (TypeRegistryNode *)NULL); + TypeRegistryNode *rnode = look_up(child, nullptr); + assert(rnode != nullptr); if (index >= 0 && index < (int)rnode->_parent_classes.size()) { handle = rnode->_parent_classes[index]->_handle; } else { @@ -401,7 +401,7 @@ int TypeRegistry:: get_num_child_classes(TypeHandle child, TypedObject *child_object) const { _lock->lock(); TypeRegistryNode *rnode = look_up(child, child_object); - assert(rnode != (TypeRegistryNode *)NULL); + assert(rnode != nullptr); int num_children = (int)rnode->_child_classes.size(); _lock->unlock(); return num_children; @@ -415,8 +415,8 @@ TypeHandle TypeRegistry:: get_child_class(TypeHandle child, int index) const { _lock->lock(); TypeHandle handle; - TypeRegistryNode *rnode = look_up(child, (TypedObject *)NULL); - assert(rnode != (TypeRegistryNode *)NULL); + TypeRegistryNode *rnode = look_up(child, nullptr); + assert(rnode != nullptr); if (index >= 0 && index < (int)rnode->_child_classes.size()) { handle = rnode->_child_classes[index]->_handle; } else { @@ -442,9 +442,9 @@ get_parent_towards(TypeHandle child, TypeHandle base, _lock->lock(); TypeHandle handle; const TypeRegistryNode *child_node = look_up(child, child_object); - const TypeRegistryNode *base_node = look_up(base, NULL); - assert(child_node != (TypeRegistryNode *)NULL && - base_node != (TypeRegistryNode *)NULL); + const TypeRegistryNode *base_node = look_up(base, nullptr); + assert(child_node != nullptr && + base_node != nullptr); freshen_derivations(); handle = TypeRegistryNode::get_parent_towards(child_node, base_node); _lock->unlock(); @@ -469,7 +469,7 @@ reregister_types() { ri != reg->_handle_registry.end(); ++ri) { TypeRegistryNode *rnode = (*ri); - if (rnode != NULL && rnode->_handle != rnode->_ref) { + if (rnode != nullptr && rnode->_handle != rnode->_ref) { cerr << "Reregistering " << rnode->_name << "\n"; } } @@ -496,7 +496,7 @@ TypeRegistry() { // We'll start out our handle_registry with a default entry for the // TypeHandles whose index number is zero, and are therefore (probably) // uninitialized. - _handle_registry.push_back(NULL); + _handle_registry.push_back(nullptr); _derivations_fresh = false; @@ -537,7 +537,7 @@ rebuild_derivations() { hi != _handle_registry.end(); ++hi) { TypeRegistryNode *node = *hi; - if (node != (TypeRegistryNode *)NULL) { + if (node != nullptr) { node->clear_subtree(); } } @@ -548,7 +548,7 @@ rebuild_derivations() { hi != _handle_registry.end(); ++hi) { TypeRegistryNode *node = *hi; - if (node != NULL && node->_parent_classes.empty()) { + if (node != nullptr && node->_parent_classes.empty()) { _root_classes.push_back(node); // Also, for each root class, define a subtree. @@ -570,7 +570,7 @@ do_write(ostream &out) const { hi != _handle_registry.end(); ++hi) { const TypeRegistryNode *root = *hi; - if (root != NULL && root->_parent_classes.empty()) { + if (root != nullptr && root->_parent_classes.empty()) { write_node(out, 2, root); } } @@ -609,7 +609,7 @@ look_up_invalid(TypeHandle handle, TypedObject *object) const { if (handle._index == 0) { // The TypeHandle is unregistered. This is an error condition. - if (object != NULL) { + if (object != nullptr) { // But we're lucky enough to have a TypedObject pointer handy! Maybe we // can use it to resolve the error. We have to drop the lock while we // do this, so we don't get a recursive lock. @@ -621,7 +621,7 @@ look_up_invalid(TypeHandle handle, TypedObject *object) const { // Strange. cerr << "Unable to force_init_type() on unregistered TypeHandle.\n"; - return NULL; + return nullptr; } // Now get the name for printing. We can't use TypeHandle:: get_name() @@ -629,7 +629,7 @@ look_up_invalid(TypeHandle handle, TypedObject *object) const { ostringstream name; if (handle._index > 0 && handle._index < (int)_handle_registry.size()) { TypeRegistryNode *rnode = _handle_registry[handle._index]; - if (rnode != (TypeRegistryNode *)NULL) { + if (rnode != nullptr) { name << rnode->_name; name << " (index " << handle._index << ")"; } else { @@ -650,7 +650,7 @@ look_up_invalid(TypeHandle handle, TypedObject *object) const { << "Attempt to reference unregistered TypeHandle. Type is of some\n" << "class derived from type " << name.str() << " that doesn't define\n" << "a good force_init_type() method.\n"; - return NULL; + return nullptr; } } else { @@ -660,7 +660,7 @@ look_up_invalid(TypeHandle handle, TypedObject *object) const { << "Attempt to reference unregistered TypeHandle!\n" << "Registered TypeHandles are:\n"; do_write(cerr); - return NULL; + return nullptr; } } @@ -669,7 +669,7 @@ look_up_invalid(TypeHandle handle, TypedObject *object) const { cerr << "Invalid TypeHandle index " << handle._index << "! Is memory corrupt?\n"; - return NULL; + return nullptr; } #endif // NDEBUG diff --git a/dtool/src/dtoolbase/typeRegistryNode.I b/dtool/src/dtoolbase/typeRegistryNode.I index c9298aae27..4328a47d79 100644 --- a/dtool/src/dtoolbase/typeRegistryNode.I +++ b/dtool/src/dtoolbase/typeRegistryNode.I @@ -16,7 +16,7 @@ */ INLINE TypeRegistryNode::Inherit:: Inherit() { - _top = (TypeRegistryNode *)NULL; + _top = nullptr; _mask = 0; _bits = 0; } diff --git a/dtool/src/dtoolbase/typeRegistryNode.cxx b/dtool/src/dtoolbase/typeRegistryNode.cxx index a88533a769..6d8d85ffc5 100644 --- a/dtool/src/dtoolbase/typeRegistryNode.cxx +++ b/dtool/src/dtoolbase/typeRegistryNode.cxx @@ -45,7 +45,7 @@ is_derived_from(const TypeRegistryNode *child, const TypeRegistryNode *base) { // additional work. (See r_build_subtrees()). if (child->_inherit._top == base->_inherit._top) { - assert(child->_inherit._top != (TypeRegistryNode *)NULL); + assert(child->_inherit._top != nullptr); bool derives = Inherit::is_derived_from(child->_inherit, base->_inherit); @@ -255,7 +255,7 @@ r_build_subtrees(TypeRegistryNode *top, int bit_count, if (_visit_count == (int)_parent_classes.size()) { // This is the last time we'll visit this node, so continue the // recursion now. - assert(_inherit._top == (TypeRegistryNode *)NULL); + assert(_inherit._top == nullptr); sort(_top_inheritance.begin(), _top_inheritance.end()); define_subtree(); } @@ -263,7 +263,7 @@ r_build_subtrees(TypeRegistryNode *top, int bit_count, } else { // This class singly inherits, so this had better be the only time this // function is called on it since clear_subtree(). - assert(_inherit._top == (TypeRegistryNode *)NULL); + assert(_inherit._top == nullptr); assert(bit_count < (int)(sizeof(SubtreeMaskType) * 8)); diff --git a/dtool/src/dtoolutil/executionEnvironment.cxx b/dtool/src/dtoolutil/executionEnvironment.cxx index 2ede3b7253..a2baf28343 100644 --- a/dtool/src/dtoolutil/executionEnvironment.cxx +++ b/dtool/src/dtoolutil/executionEnvironment.cxx @@ -86,7 +86,7 @@ extern int GLOBAL_ARGC; // safely access them at stat init time--at least, not in libc5. (It does seem // to work with glibc2, however.) -ExecutionEnvironment *ExecutionEnvironment::_global_ptr = NULL; +ExecutionEnvironment *ExecutionEnvironment::_global_ptr = nullptr; /** * You shouldn't need to construct one of these; there's only one and it @@ -162,13 +162,13 @@ get_cwd() { #ifdef WIN32_VC // getcwd() requires us to allocate a dynamic buffer and grow it on demand. static size_t bufsize = 1024; - static wchar_t *buffer = NULL; + static wchar_t *buffer = nullptr; - if (buffer == (wchar_t *)NULL) { + if (buffer == nullptr) { buffer = new wchar_t[bufsize]; } - while (_wgetcwd(buffer, bufsize) == (wchar_t *)NULL) { + while (_wgetcwd(buffer, bufsize) == nullptr) { if (errno != ERANGE) { perror("getcwd"); return string(); @@ -176,7 +176,7 @@ get_cwd() { delete[] buffer; bufsize = bufsize * 2; buffer = new wchar_t[bufsize]; - assert(buffer != (wchar_t *)NULL); + assert(buffer != nullptr); } Filename cwd = Filename::from_os_specific_w(buffer); @@ -185,13 +185,13 @@ get_cwd() { #else // WIN32_VC // getcwd() requires us to allocate a dynamic buffer and grow it on demand. static size_t bufsize = 1024; - static char *buffer = NULL; + static char *buffer = nullptr; - if (buffer == (char *)NULL) { + if (buffer == nullptr) { buffer = new char[bufsize]; } - while (getcwd(buffer, bufsize) == (char *)NULL) { + while (getcwd(buffer, bufsize) == nullptr) { if (errno != ERANGE) { perror("getcwd"); return string(); @@ -199,7 +199,7 @@ get_cwd() { delete[] buffer; bufsize = bufsize * 2; buffer = new char[bufsize]; - assert(buffer != (char *)NULL); + assert(buffer != nullptr); } Filename cwd = Filename::from_os_specific(buffer); @@ -217,7 +217,7 @@ ns_has_environment_variable(const string &var) const { #ifdef PREREAD_ENVIRONMENT return _variables.count(var) != 0; #else - return getenv(var.c_str()) != (char *)NULL; + return getenv(var.c_str()) != nullptr; #endif } @@ -257,7 +257,7 @@ ns_get_environment_variable(const string &var) const { #ifndef PREREAD_ENVIRONMENT const char *def = getenv(var.c_str()); - if (def != (char *)NULL) { + if (def != nullptr) { return def; } #endif @@ -327,13 +327,13 @@ ns_get_environment_variable(const string &var) const { { CSIDL_SYSTEMX86, "SYSTEMX86" }, { CSIDL_TEMPLATES, "TEMPLATES" }, { CSIDL_WINDOWS, "WINDOWS" }, - { 0, NULL }, + { 0, nullptr }, }; - for (int i = 0; csidl_table[i].name != NULL; ++i) { + for (int i = 0; csidl_table[i].name != nullptr; ++i) { if (strcmp(var.c_str(), csidl_table[i].name) == 0) { wchar_t buffer[MAX_PATH]; - if (SHGetSpecialFolderPathW(NULL, buffer, csidl_table[i].id, true)) { + if (SHGetSpecialFolderPathW(nullptr, buffer, csidl_table[i].id, true)) { Filename pathname = Filename::from_os_specific_w(buffer); return pathname.to_os_specific(); } @@ -399,7 +399,7 @@ ns_clear_shadow(const string &var) { #ifdef PREREAD_ENVIRONMENT // Now we have to replace the value in the table. const char *def = getenv(var.c_str()); - if (def != (char *)NULL) { + if (def != nullptr) { (*vi).second = def; } else { _variables.erase(vi); @@ -457,7 +457,7 @@ ns_get_dtool_name() const { */ ExecutionEnvironment *ExecutionEnvironment:: get_ptr() { - if (_global_ptr == (ExecutionEnvironment *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new ExecutionEnvironment; } return _global_ptr; @@ -584,13 +584,13 @@ read_args() { if (_dtool_name.empty()) { void *dtool_handle = dlopen("libp3dtool.so." PANDA_ABI_VERSION_STR, RTLD_NOW | RTLD_NOLOAD); - if (dtool_handle != NULL && dlinfo(dtool_handle, RTLD_DI_ORIGIN, origin) != -1) { + if (dtool_handle != nullptr && dlinfo(dtool_handle, RTLD_DI_ORIGIN, origin) != -1) { _dtool_name = origin; _dtool_name += "/libp3dtool.so." PANDA_ABI_VERSION_STR; } else { // Try the version of libp3dtool.so without ABI suffix. dtool_handle = dlopen("libp3dtool.so", RTLD_NOW | RTLD_NOLOAD); - if (dtool_handle != NULL && dlinfo(dtool_handle, RTLD_DI_ORIGIN, origin) != -1) { + if (dtool_handle != nullptr && dlinfo(dtool_handle, RTLD_DI_ORIGIN, origin) != -1) { _dtool_name = origin; _dtool_name += "/libp3dtool.so"; } @@ -609,7 +609,7 @@ read_args() { #endif dlinfo(self, RTLD_DI_LINKMAP, &map); - while (map != NULL) { + while (map != nullptr) { const char *tail = strrchr(map->l_name, '/'); const char *head = strchr(map->l_name, '/'); if (tail && head && (strcmp(tail, "/libp3dtool.so." PANDA_ABI_VERSION_STR) == 0 @@ -652,7 +652,7 @@ read_args() { if (_binary_name.empty()) { static const DWORD buffer_size = 1024; wchar_t buffer[buffer_size]; - DWORD size = GetModuleFileNameW(NULL, buffer, buffer_size); + DWORD size = GetModuleFileNameW(nullptr, buffer, buffer_size); if (size != 0) { Filename tmp = Filename::from_os_specific_w(wstring(buffer, size)); tmp.make_true_case(); @@ -681,7 +681,7 @@ read_args() { char buffer[4096]; int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; mib[3] = getpid(); - if (sysctl(mib, 4, (void*) buffer, &bufsize, NULL, 0) == -1) { + if (sysctl(mib, 4, (void*) buffer, &bufsize, nullptr, 0) == -1) { perror("sysctl"); } else { _binary_name = buffer; @@ -719,7 +719,7 @@ read_args() { int argc = 0; LPWSTR *wargv = CommandLineToArgvW(cmdline, &argc); - if (wargv == NULL) { + if (wargv == nullptr) { cerr << "CommandLineToArgvW failed; command-line arguments unavailable to config.\n"; } else { @@ -749,7 +749,7 @@ read_args() { char buffer[4096]; int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_ARGS, 0}; mib[3] = getpid(); - if (sysctl(mib, 4, (void*) buffer, &bufsize, NULL, 0) == -1) { + if (sysctl(mib, 4, (void*) buffer, &bufsize, nullptr, 0) == -1) { perror("sysctl"); } else { if (_binary_name.empty()) { @@ -768,7 +768,7 @@ read_args() { // On Windows, __argv can be NULL when the main entry point is compiled in // Unicode mode (as is the case with Python 3) - if (GLOBAL_ARGV != NULL) { + if (GLOBAL_ARGV != nullptr) { if (_binary_name.empty() && argc > 0) { _binary_name = GLOBAL_ARGV[0]; // This really needs to be resolved against PATH. @@ -823,14 +823,14 @@ read_args() { if (!_binary_name.empty()) { char newpath [PATH_MAX + 1]; - if (realpath(_binary_name.c_str(), newpath) != NULL) { + if (realpath(_binary_name.c_str(), newpath) != nullptr) { _binary_name = newpath; } } if (!_dtool_name.empty()) { char newpath [PATH_MAX + 1]; - if (realpath(_dtool_name.c_str(), newpath) != NULL) { + if (realpath(_dtool_name.c_str(), newpath) != nullptr) { _dtool_name = newpath; } } diff --git a/dtool/src/dtoolutil/filename.I b/dtool/src/dtoolutil/filename.I index 2f099548e3..989d77df98 100644 --- a/dtool/src/dtoolutil/filename.I +++ b/dtool/src/dtoolutil/filename.I @@ -192,7 +192,7 @@ operator = (const wstring &filename) { */ INLINE Filename &Filename:: operator = (const char *filename) { - assert(filename != NULL); + assert(filename != nullptr); return (*this) = string(filename); } diff --git a/dtool/src/dtoolutil/filename.cxx b/dtool/src/dtoolutil/filename.cxx index 036707f47d..61816e7a44 100644 --- a/dtool/src/dtoolutil/filename.cxx +++ b/dtool/src/dtoolutil/filename.cxx @@ -145,12 +145,12 @@ back_to_front_slash(const string &str) { static const string & get_panda_root() { - static string *panda_root = NULL; + static string *panda_root = nullptr; - if (panda_root == NULL) { + if (panda_root == nullptr) { panda_root = new string; const char *envvar = getenv("PANDA_ROOT"); - if (envvar != (const char *)NULL) { + if (envvar != nullptr) { (*panda_root) = front_to_back_slash(envvar); } @@ -430,7 +430,7 @@ temporary(const string &dirname, const string &prefix, const string &suffix, if (fdirname.empty()) { // If we are not given a dirname, use the system tempnam() function to // create a system-defined temporary filename. - char *name = tempnam(NULL, prefix.c_str()); + char *name = tempnam(nullptr, prefix.c_str()); Filename result = Filename::from_os_specific(name); free(name); result.set_type(type); @@ -446,7 +446,7 @@ temporary(const string &dirname, const string &prefix, const string &suffix, // We take the time of day and multiply it by the process time. This will // give us a very large number, of which we take the bottom 24 bits and // generate a 6-character hex code. - int hash = (clock() * time(NULL)) & 0xffffff; + int hash = (clock() * time(nullptr)) & 0xffffff; char hex_code[10]; #ifdef _WIN32 sprintf_s(hex_code, 10, "%06x", hash); @@ -467,12 +467,12 @@ temporary(const string &dirname, const string &prefix, const string &suffix, */ const Filename &Filename:: get_home_directory() { - if (AtomicAdjust::get_ptr(_home_directory) == NULL) { + if (AtomicAdjust::get_ptr(_home_directory) == nullptr) { Filename home_directory; // In all environments, check $HOME first. char *home = getenv("HOME"); - if (home != (char *)NULL) { + if (home != nullptr) { Filename dirname = from_os_specific(home); if (dirname.is_directory()) { if (dirname.make_canonical()) { @@ -486,7 +486,7 @@ get_home_directory() { wchar_t buffer[MAX_PATH]; // On Windows, fall back to the "My Documents" folder. - if (SHGetSpecialFolderPathW(NULL, buffer, CSIDL_PERSONAL, true)) { + if (SHGetSpecialFolderPathW(nullptr, buffer, CSIDL_PERSONAL, true)) { Filename dirname = from_os_specific_w(buffer); if (dirname.is_directory()) { if (dirname.make_canonical()) { @@ -517,9 +517,9 @@ get_home_directory() { } Filename *newdir = new Filename(home_directory); - if (AtomicAdjust::compare_and_exchange_ptr(_home_directory, NULL, newdir) != NULL) { + if (AtomicAdjust::compare_and_exchange_ptr(_home_directory, nullptr, newdir) != nullptr) { // Didn't store it. Must have been stored by someone else. - assert(_home_directory != NULL); + assert(_home_directory != nullptr); delete newdir; } } @@ -532,7 +532,7 @@ get_home_directory() { */ const Filename &Filename:: get_temp_directory() { - if (AtomicAdjust::get_ptr(_temp_directory) == NULL) { + if (AtomicAdjust::get_ptr(_temp_directory) == nullptr) { Filename temp_directory; #ifdef WIN32 @@ -565,9 +565,9 @@ get_temp_directory() { } Filename *newdir = new Filename(temp_directory); - if (AtomicAdjust::compare_and_exchange_ptr(_temp_directory, NULL, newdir) != NULL) { + if (AtomicAdjust::compare_and_exchange_ptr(_temp_directory, nullptr, newdir) != nullptr) { // Didn't store it. Must have been stored by someone else. - assert(_temp_directory != NULL); + assert(_temp_directory != nullptr); delete newdir; } } @@ -582,13 +582,13 @@ get_temp_directory() { */ const Filename &Filename:: get_user_appdata_directory() { - if (AtomicAdjust::get_ptr(_user_appdata_directory) == NULL) { + if (AtomicAdjust::get_ptr(_user_appdata_directory) == nullptr) { Filename user_appdata_directory; #ifdef WIN32 wchar_t buffer[MAX_PATH]; - if (SHGetSpecialFolderPathW(NULL, buffer, CSIDL_LOCAL_APPDATA, true)) { + if (SHGetSpecialFolderPathW(nullptr, buffer, CSIDL_LOCAL_APPDATA, true)) { Filename dirname = from_os_specific_w(buffer); if (dirname.is_directory()) { if (dirname.make_canonical()) { @@ -622,9 +622,9 @@ get_user_appdata_directory() { } Filename *newdir = new Filename(user_appdata_directory); - if (AtomicAdjust::compare_and_exchange_ptr(_user_appdata_directory, NULL, newdir) != NULL) { + if (AtomicAdjust::compare_and_exchange_ptr(_user_appdata_directory, nullptr, newdir) != nullptr) { // Didn't store it. Must have been stored by someone else. - assert(_user_appdata_directory != NULL); + assert(_user_appdata_directory != nullptr); delete newdir; } } @@ -638,13 +638,13 @@ get_user_appdata_directory() { */ const Filename &Filename:: get_common_appdata_directory() { - if (AtomicAdjust::get_ptr(_common_appdata_directory) == NULL) { + if (AtomicAdjust::get_ptr(_common_appdata_directory) == nullptr) { Filename common_appdata_directory; #ifdef WIN32 wchar_t buffer[MAX_PATH]; - if (SHGetSpecialFolderPathW(NULL, buffer, CSIDL_COMMON_APPDATA, true)) { + if (SHGetSpecialFolderPathW(nullptr, buffer, CSIDL_COMMON_APPDATA, true)) { Filename dirname = from_os_specific_w(buffer); if (dirname.is_directory()) { if (dirname.make_canonical()) { @@ -672,9 +672,9 @@ get_common_appdata_directory() { } Filename *newdir = new Filename(common_appdata_directory); - if (AtomicAdjust::compare_and_exchange_ptr(_common_appdata_directory, NULL, newdir) != NULL) { + if (AtomicAdjust::compare_and_exchange_ptr(_common_appdata_directory, nullptr, newdir) != nullptr) { // Didn't store it. Must have been stored by someone else. - assert(_common_appdata_directory != NULL); + assert(_common_appdata_directory != nullptr); delete newdir; } } @@ -1017,7 +1017,7 @@ make_canonical() { #ifndef WIN32 // Use realpath in order to resolve symlinks properly char newpath [PATH_MAX + 1]; - if (realpath(c_str(), newpath) != NULL) { + if (realpath(c_str(), newpath) != nullptr) { Filename newpath_fn(newpath); newpath_fn._flags = _flags; (*this) = newpath_fn; @@ -1764,7 +1764,7 @@ scan_directory(vector_string &contents) const { dirname = _filename; } DIR *root = opendir(dirname.c_str()); - if (root == (DIR *)NULL) { + if (root == nullptr) { if (errno != ENOTDIR) { perror(dirname.c_str()); } @@ -1773,7 +1773,7 @@ scan_directory(vector_string &contents) const { struct dirent *d; d = readdir(root); - while (d != (struct dirent *)NULL) { + while (d != nullptr) { thread_consider_yield(); if (d->d_name[0] != '.') { contents.push_back(d->d_name); @@ -1814,7 +1814,7 @@ scan_directory(vector_string &contents) const { glob_t globbuf; - int r = glob(dirname.c_str(), GLOB_ERR, NULL, &globbuf); + int r = glob(dirname.c_str(), GLOB_ERR, nullptr, &globbuf); if (r != 0) { // Some error processing the match string. If our version of glob.h @@ -1834,7 +1834,7 @@ scan_directory(vector_string &contents) const { size_t offset = dirname.size() - 1; - for (int i = 0; globbuf.gl_pathv[i] != NULL; i++) { + for (int i = 0; globbuf.gl_pathv[i] != nullptr; i++) { contents.push_back(globbuf.gl_pathv[i] + offset); } globfree(&globbuf); @@ -2226,7 +2226,7 @@ touch() const { wstring os_specific = to_os_specific_w(); HANDLE fhandle; fhandle = CreateFileW(os_specific.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE, - NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (fhandle == INVALID_HANDLE_VALUE) { return false; } @@ -2240,7 +2240,7 @@ touch() const { return false; } - if (!SetFileTime(fhandle, NULL, NULL, &ftnow)) { + if (!SetFileTime(fhandle, nullptr, nullptr, &ftnow)) { CloseHandle(fhandle); return false; } @@ -2264,7 +2264,7 @@ touch() const { os_specific = result; } #endif // HAVE_CYGWIN - int result = utime(os_specific.c_str(), NULL); + int result = utime(os_specific.c_str(), nullptr); if (result < 0) { if (errno == ENOENT) { // So the file doesn't already exist; create it. @@ -2640,16 +2640,16 @@ atomic_compare_and_exchange_contents(string &orig_contents, #ifdef WIN32_VC wstring os_specific = to_os_specific_w(); HANDLE hfile = CreateFileW(os_specific.c_str(), GENERIC_READ | GENERIC_WRITE, - 0, NULL, OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, NULL); + 0, nullptr, OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL, nullptr); while (hfile == INVALID_HANDLE_VALUE) { DWORD error = GetLastError(); if (error == ERROR_SHARING_VIOLATION) { // If the file is locked by another process, yield and try again. Sleep(0); hfile = CreateFileW(os_specific.c_str(), GENERIC_READ | GENERIC_WRITE, - 0, NULL, OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, NULL); + 0, nullptr, OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL, nullptr); } else { cerr << "Couldn't open file: " << os_specific << ", error " << error << "\n"; @@ -2669,7 +2669,7 @@ atomic_compare_and_exchange_contents(string &orig_contents, orig_contents = string(); DWORD bytes_read; - if (!ReadFile(hfile, buf, buf_size, &bytes_read, NULL)) { + if (!ReadFile(hfile, buf, buf_size, &bytes_read, nullptr)) { cerr << "Error reading file: " << os_specific << ", error " << GetLastError() << "\n"; CloseHandle(hfile); @@ -2678,7 +2678,7 @@ atomic_compare_and_exchange_contents(string &orig_contents, while (bytes_read > 0) { orig_contents += string(buf, bytes_read); - if (!ReadFile(hfile, buf, buf_size, &bytes_read, NULL)) { + if (!ReadFile(hfile, buf, buf_size, &bytes_read, nullptr)) { cerr << "Error reading file: " << os_specific << ", error " << GetLastError() << "\n"; CloseHandle(hfile); @@ -2692,7 +2692,7 @@ atomic_compare_and_exchange_contents(string &orig_contents, SetFilePointer(hfile, 0, 0, FILE_BEGIN); DWORD bytes_written; if (!WriteFile(hfile, new_contents.data(), new_contents.size(), - &bytes_written, NULL)) { + &bytes_written, nullptr)) { cerr << "Error writing file: " << os_specific << ", error " << GetLastError() << "\n"; CloseHandle(hfile); @@ -2776,16 +2776,16 @@ atomic_read_contents(string &contents) const { #ifdef WIN32_VC wstring os_specific = to_os_specific_w(); HANDLE hfile = CreateFileW(os_specific.c_str(), GENERIC_READ, - FILE_SHARE_READ, NULL, OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, NULL); + FILE_SHARE_READ, nullptr, OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL, nullptr); while (hfile == INVALID_HANDLE_VALUE) { DWORD error = GetLastError(); if (error == ERROR_SHARING_VIOLATION) { // If the file is locked by another process, yield and try again. Sleep(0); hfile = CreateFileW(os_specific.c_str(), GENERIC_READ, - FILE_SHARE_READ, NULL, OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, NULL); + FILE_SHARE_READ, nullptr, OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL, nullptr); } else { cerr << "Couldn't open file: " << os_specific << ", error " << error << "\n"; @@ -2799,7 +2799,7 @@ atomic_read_contents(string &contents) const { contents = string(); DWORD bytes_read; - if (!ReadFile(hfile, buf, buf_size, &bytes_read, NULL)) { + if (!ReadFile(hfile, buf, buf_size, &bytes_read, nullptr)) { cerr << "Error reading file: " << os_specific << ", error " << GetLastError() << "\n"; CloseHandle(hfile); @@ -2808,7 +2808,7 @@ atomic_read_contents(string &contents) const { while (bytes_read > 0) { contents += string(buf, bytes_read); - if (!ReadFile(hfile, buf, buf_size, &bytes_read, NULL)) { + if (!ReadFile(hfile, buf, buf_size, &bytes_read, nullptr)) { cerr << "Error reading file: " << os_specific << ", error " << GetLastError() << "\n"; CloseHandle(hfile); diff --git a/dtool/src/dtoolutil/filename_ext.cxx b/dtool/src/dtoolutil/filename_ext.cxx index 3d71317786..196492d23f 100644 --- a/dtool/src/dtoolutil/filename_ext.cxx +++ b/dtool/src/dtoolutil/filename_ext.cxx @@ -24,8 +24,8 @@ extern Dtool_PyTypedObject Dtool_Filename; */ void Extension:: __init__(PyObject *path) { - nassertv(path != NULL); - nassertv(_this != NULL); + nassertv(path != nullptr); + nassertv(_this != nullptr); Py_ssize_t length; @@ -64,12 +64,12 @@ __init__(PyObject *path) { #if PY_VERSION_HEX >= 0x03060000 // It must be an os.PathLike object. Check for an __fspath__ method. PyObject *fspath = PyObject_GetAttrString((PyObject *)Py_TYPE(path), "__fspath__"); - if (fspath == NULL) { + if (fspath == nullptr) { PyErr_Format(PyExc_TypeError, "expected str, bytes or os.PathLike object, not %s", Py_TYPE(path)->tp_name); return; } - path_str = PyObject_CallFunctionObjArgs(fspath, path, NULL); + path_str = PyObject_CallFunctionObjArgs(fspath, path, nullptr); Py_DECREF(fspath); #else // There is no standard path protocol before Python 3.6, but let's try and @@ -89,7 +89,7 @@ __init__(PyObject *path) { } #endif - if (path_str == NULL) { + if (path_str == nullptr) { return; } @@ -133,8 +133,8 @@ __reduce__(PyObject *self) const { // object whose constructor we should call (e.g. this), and the arguments // necessary to reconstruct this object. PyTypeObject *this_class = Py_TYPE(self); - if (this_class == NULL) { - return NULL; + if (this_class == nullptr) { + return nullptr; } PyObject *result = Py_BuildValue("(O(s))", this_class, _this->c_str()); diff --git a/dtool/src/dtoolutil/lineStreamBuf.cxx b/dtool/src/dtoolutil/lineStreamBuf.cxx index 561772ddcb..4e9f990540 100644 --- a/dtool/src/dtoolutil/lineStreamBuf.cxx +++ b/dtool/src/dtoolutil/lineStreamBuf.cxx @@ -24,8 +24,8 @@ LineStreamBuf() { // characters one at a time, since they're just getting stuffed into a // string. (Although the code is written portably enough to use a buffer // correctly, if we had one.) - setg(0, 0, 0); - setp(0, 0); + setg(nullptr, nullptr, nullptr); + setp(nullptr, nullptr); } /** diff --git a/dtool/src/dtoolutil/load_dso.cxx b/dtool/src/dtoolutil/load_dso.cxx index ba63eee044..a54763afb1 100644 --- a/dtool/src/dtoolutil/load_dso.cxx +++ b/dtool/src/dtoolutil/load_dso.cxx @@ -45,7 +45,7 @@ void * load_dso(const DSearchPath &path, const Filename &filename) { Filename abspath = resolve_dso(path, filename); if (!abspath.is_regular_file()) { - return NULL; + return nullptr; } wstring os_specific_w = abspath.to_os_specific_w(); @@ -56,7 +56,7 @@ load_dso(const DSearchPath &path, const Filename &filename) { if (hLib) { pLoadLibraryEx = (tLoadLibraryEx)GetProcAddress(hLib, "LoadLibraryExW"); if (pLoadLibraryEx) { - return pLoadLibraryEx(os_specific_w.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + return pLoadLibraryEx(os_specific_w.c_str(), nullptr, LOAD_WITH_ALTERED_SEARCH_PATH); } } @@ -130,7 +130,7 @@ void * load_dso(const DSearchPath &path, const Filename &filename) { Filename abspath = resolve_dso(path, filename); if (!abspath.is_regular_file()) { - return NULL; + return nullptr; } string os_specific = abspath.to_os_specific(); return dlopen(os_specific.c_str(), RTLD_NOW | RTLD_GLOBAL); @@ -144,7 +144,7 @@ unload_dso(void *dso_handle) { string load_dso_error() { const char *message = dlerror(); - if (message != (const char *)NULL) { + if (message != nullptr) { return std::string(message); } return "No error."; diff --git a/dtool/src/dtoolutil/pandaFileStreamBuf.cxx b/dtool/src/dtoolutil/pandaFileStreamBuf.cxx index 037d421469..2e2c0ec035 100644 --- a/dtool/src/dtoolutil/pandaFileStreamBuf.cxx +++ b/dtool/src/dtoolutil/pandaFileStreamBuf.cxx @@ -41,7 +41,7 @@ PandaFileStreamBuf() { #ifdef _WIN32 // Windows case. - _handle = NULL; + _handle = nullptr; #else _fd = -1; #endif // _WIN32 @@ -132,7 +132,7 @@ open(const char *filename, ios::openmode mode) { encoder.set_text(_filename); wstring wfilename = encoder.get_wtext(); _handle = CreateFileW(wfilename.c_str(), access, share_mode, - NULL, creation_disposition, flags, NULL); + nullptr, creation_disposition, flags, nullptr); if (_handle != INVALID_HANDLE_VALUE) { // The file was successfully opened and locked. _is_open = true; @@ -251,10 +251,10 @@ close() { sync(); #ifdef _WIN32 - if (_handle != NULL) { + if (_handle != nullptr) { CloseHandle(_handle); } - _handle = NULL; + _handle = nullptr; #else if (_fd != -1) { ::close(_fd); diff --git a/dtool/src/dtoolutil/pandaSystem.cxx b/dtool/src/dtoolutil/pandaSystem.cxx index 79e5aa7762..5e7cc4b913 100644 --- a/dtool/src/dtoolutil/pandaSystem.cxx +++ b/dtool/src/dtoolutil/pandaSystem.cxx @@ -15,7 +15,7 @@ #include "pandaVersion.h" #include "dtool_platform.h" -PandaSystem *PandaSystem::_global_ptr = NULL; +PandaSystem *PandaSystem::_global_ptr = nullptr; TypeHandle PandaSystem::_type_handle; /** @@ -432,7 +432,7 @@ write(ostream &out) const { */ PandaSystem *PandaSystem:: get_global_ptr() { - if (_global_ptr == (PandaSystem *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new PandaSystem; } diff --git a/dtool/src/dtoolutil/panda_getopt_impl.cxx b/dtool/src/dtoolutil/panda_getopt_impl.cxx index fe1d630a32..9a216bbda0 100644 --- a/dtool/src/dtoolutil/panda_getopt_impl.cxx +++ b/dtool/src/dtoolutil/panda_getopt_impl.cxx @@ -23,7 +23,7 @@ // ahead and provide it instead. -char *optarg = NULL; +char *optarg = nullptr; int optind = 0; int opterr = 1; int optopt = 0; @@ -72,7 +72,7 @@ private: class Param { public: Param(size_t opt_index, size_t argv_index, - char short_option, char *argument = NULL); + char short_option, char *argument = nullptr); size_t _opt_index; size_t _argv_index; @@ -121,7 +121,7 @@ private: // This global pointer is used to differentiate between getopt() being called // the first time, vs. subsequent times. -static PandaGetopt *pgetopt = NULL; +static PandaGetopt *pgetopt = nullptr; /** * @@ -129,7 +129,7 @@ static PandaGetopt *pgetopt = NULL; PandaGetopt:: PandaGetopt(int argc, char *const argv[], const char *optstring, const struct option *longopts, bool allow_one_hyphen_long) { - assert(optstring != NULL); + assert(optstring != nullptr); _return_in_order = false; _require_order = false; @@ -154,7 +154,7 @@ PandaGetopt(int argc, char *const argv[], const char *optstring, ++optstring; _require_order = true; - } else if (getenv("POSIXLY_CORRECT") != NULL) { + } else if (getenv("POSIXLY_CORRECT") != nullptr) { // REQUIRE_ORDER. _require_order = true; @@ -210,13 +210,13 @@ process(int opterr, int *longindex, char *&optarg, int &optind, int &optopt) { optarg = param._argument; optind = (int)param._argv_index; - if (longindex != NULL) { + if (longindex != nullptr) { *longindex = option._longopts_index; } - if (option._option != NULL) { + if (option._option != nullptr) { // This was a long option. Check the special longopt handling parameters. - if (option._option->flag == NULL) { + if (option._option->flag == nullptr) { return option._option->val; } *(option._option->flag) = option._option->val; @@ -298,9 +298,9 @@ scan_options(const char *optstring, const struct option *longopts) { _options.push_back(Option(short_option, has_arg)); } - if (longopts != NULL) { + if (longopts != nullptr) { int longopts_index = 0; - while (longopts[longopts_index].name != NULL) { + while (longopts[longopts_index].name != nullptr) { _options.push_back(Option(longopts, longopts_index)); ++longopts_index; } @@ -317,7 +317,7 @@ scan_args(int argc, char *const argv[]) { bool end_of_processing = false; while ((int)ai < argc) { - assert(argv[ai] != NULL); + assert(argv[ai] != nullptr); if (argv[ai][0] != '-' || end_of_processing) { // This is a non-option argument. @@ -342,8 +342,8 @@ scan_args(int argc, char *const argv[]) { } else { // An option argument. - char *option = NULL; - char *argument = NULL; + char *option = nullptr; + char *argument = nullptr; size_t opt_index = 0; bool is_long_option = false; bool has_argument = false; @@ -387,7 +387,7 @@ scan_args(int argc, char *const argv[]) { if (is_long_option) { char *equals = strchr(option, '='); - if (equals != NULL) { + if (equals != nullptr) { argument = equals + 1; has_argument = true; } @@ -416,7 +416,7 @@ scan_args(int argc, char *const argv[]) { // Now record the non-option arguments that followed the option arguments. while ((int)ai < argc) { - assert(argv[ai] != NULL); + assert(argv[ai] != nullptr); _arguments.push_back(argv[ai]); ++ai; } @@ -430,7 +430,7 @@ PandaGetopt::Option:: Option(char short_option, int has_arg) : _short_option(short_option), _has_arg(has_arg), - _option(NULL), + _option(nullptr), _longopts_index(-1) { } @@ -463,17 +463,17 @@ Param(size_t opt_index, size_t argv_index, char short_option, char *argument) : int getopt(int argc, char *const argv[], const char *optstring) { - if (pgetopt == NULL) { - pgetopt = new PandaGetopt(argc, argv, optstring, NULL, false); + if (pgetopt == nullptr) { + pgetopt = new PandaGetopt(argc, argv, optstring, nullptr, false); pgetopt->permute(argc, (char **)argv); } - return pgetopt->process(opterr, NULL, optarg, optind, optopt); + return pgetopt->process(opterr, nullptr, optarg, optind, optopt); } int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex) { - if (pgetopt == NULL) { + if (pgetopt == nullptr) { pgetopt = new PandaGetopt(argc, argv, optstring, longopts, false); pgetopt->permute(argc, (char **)argv); } @@ -483,7 +483,7 @@ getopt_long(int argc, char *const argv[], const char *optstring, int getopt_long_only(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex) { - if (pgetopt == NULL) { + if (pgetopt == nullptr) { pgetopt = new PandaGetopt(argc, argv, optstring, longopts, true); pgetopt->permute(argc, (char **)argv); } diff --git a/dtool/src/dtoolutil/pfstreamBuf.cxx b/dtool/src/dtoolutil/pfstreamBuf.cxx index a23d2f64df..591d2847e0 100644 --- a/dtool/src/dtoolutil/pfstreamBuf.cxx +++ b/dtool/src/dtoolutil/pfstreamBuf.cxx @@ -89,8 +89,8 @@ int PipeStreamBuf::sync(void) { int PipeStreamBuf::underflow(void) { assert(_dir == Input); - if ((eback() == (char*)0L) || (gptr() == (char*)0L) || - (egptr() == (char*)0L)) { + if ((eback() == nullptr) || (gptr() == nullptr) || + (egptr() == nullptr)) { // must be new-style iostream library char* buf = new char[4096]; char* ebuf = &(buf[4096]); @@ -162,7 +162,7 @@ void PipeStreamBuf::write_chars(const char* start, int length, bool flush) { */ void PipeStreamBuf:: init_pipe() { - _pipe = NULL; + _pipe = nullptr; } /** @@ -170,7 +170,7 @@ init_pipe() { */ bool PipeStreamBuf:: is_open() const { - return _pipe != NULL; + return _pipe != nullptr; } /** @@ -179,7 +179,7 @@ is_open() const { */ bool PipeStreamBuf:: eof_pipe() const { - return (_pipe == NULL) && feof(_pipe); + return (_pipe == nullptr) && feof(_pipe); } /** @@ -193,7 +193,7 @@ bool PipeStreamBuf:: open_pipe(const string &cmd) { const char *typ = (_dir == Output)?"w":"r"; _pipe = popen(cmd.c_str(), typ); - return (_pipe != NULL); + return (_pipe != nullptr); } /** @@ -201,9 +201,9 @@ open_pipe(const string &cmd) { */ void PipeStreamBuf:: close_pipe() { - if (_pipe != NULL) { + if (_pipe != nullptr) { fclose(_pipe); - _pipe = NULL; + _pipe = nullptr; } } @@ -289,7 +289,7 @@ open_pipe(const string &cmd) { SECURITY_ATTRIBUTES saAttr; saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.bInheritHandle = TRUE; - saAttr.lpSecurityDescriptor = NULL; + saAttr.lpSecurityDescriptor = nullptr; if (!CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0)) { #ifndef NDEBUG cerr << "Unable to create output pipe\n"; @@ -391,7 +391,7 @@ read_pipe(char *data, size_t len) { return 0; } DWORD dwRead; - if (!ReadFile(_child_out, data, len, &dwRead, NULL)) { + if (!ReadFile(_child_out, data, len, &dwRead, nullptr)) { close_pipe(); return 0; } diff --git a/dtool/src/dtoolutil/stringDecoder.cxx b/dtool/src/dtoolutil/stringDecoder.cxx index ce73120543..847d8559bd 100644 --- a/dtool/src/dtoolutil/stringDecoder.cxx +++ b/dtool/src/dtoolutil/stringDecoder.cxx @@ -95,7 +95,7 @@ get_next_character() { // First byte of two. unsigned int two = 0; if (test_eof()) { - if (_notify_ptr != NULL) { + if (_notify_ptr != nullptr) { (*_notify_ptr) << "utf-8 encoded string '" << _input << "' ends abruptly.\n"; } @@ -108,7 +108,7 @@ get_next_character() { } else if ((result & 0xf0) == 0xe0) { // First byte of three. if (test_eof()) { - if (_notify_ptr != NULL) { + if (_notify_ptr != nullptr) { (*_notify_ptr) << "utf-8 encoded string '" << _input << "' ends abruptly.\n"; } @@ -116,7 +116,7 @@ get_next_character() { } unsigned int two = (unsigned char)_input[_p++]; if (test_eof()) { - if (_notify_ptr != NULL) { + if (_notify_ptr != nullptr) { (*_notify_ptr) << "utf-8 encoded string '" << _input << "' ends abruptly.\n"; } @@ -129,7 +129,7 @@ get_next_character() { // Otherwise--the high bit is set but it is not one of the introductory // utf-8 bytes--we have an error. - if (_notify_ptr != NULL) { + if (_notify_ptr != nullptr) { (*_notify_ptr) << "Non utf-8 byte in string: 0x" << hex << result << dec << ", string is '" << _input << "'\n"; @@ -152,7 +152,7 @@ get_next_character() { unsigned int high = (unsigned char)_input[_p++]; if (test_eof()) { - if (_notify_ptr != NULL) { + if (_notify_ptr != nullptr) { (*_notify_ptr) << "Unicode-encoded string has odd number of bytes.\n"; } diff --git a/dtool/src/dtoolutil/textEncoder.I b/dtool/src/dtoolutil/textEncoder.I index fb84aa316d..c46c03c0de 100644 --- a/dtool/src/dtoolutil/textEncoder.I +++ b/dtool/src/dtoolutil/textEncoder.I @@ -259,7 +259,7 @@ reencode_text(const string &text, TextEncoder::Encoding from, INLINE bool TextEncoder:: unicode_isalpha(int character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); - if (entry == (const UnicodeLatinMap::Entry *)NULL) { + if (entry == nullptr) { return false; } return entry->_char_type == UnicodeLatinMap::CT_upper || @@ -273,7 +273,7 @@ unicode_isalpha(int character) { INLINE bool TextEncoder:: unicode_isdigit(int character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); - if (entry == (const UnicodeLatinMap::Entry *)NULL) { + if (entry == nullptr) { // The digits aren't actually listed in the map. return (character >= '0' && character <= '9'); } @@ -288,7 +288,7 @@ unicode_isdigit(int character) { INLINE bool TextEncoder:: unicode_ispunct(int character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); - if (entry == (const UnicodeLatinMap::Entry *)NULL) { + if (entry == nullptr) { // Some punctuation marks aren't listed in the map. return (character >= 0 && character < 128 && ispunct(character)); } @@ -302,7 +302,7 @@ unicode_ispunct(int character) { INLINE bool TextEncoder:: unicode_isupper(int character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); - if (entry == (const UnicodeLatinMap::Entry *)NULL) { + if (entry == nullptr) { return false; } return entry->_char_type == UnicodeLatinMap::CT_upper; @@ -332,7 +332,7 @@ unicode_isspace(int character) { INLINE bool TextEncoder:: unicode_islower(int character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); - if (entry == (const UnicodeLatinMap::Entry *)NULL) { + if (entry == nullptr) { return false; } return entry->_char_type == UnicodeLatinMap::CT_lower; @@ -345,7 +345,7 @@ unicode_islower(int character) { INLINE int TextEncoder:: unicode_toupper(int character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); - if (entry == (const UnicodeLatinMap::Entry *)NULL) { + if (entry == nullptr) { return character; } return entry->_toupper_character; @@ -358,7 +358,7 @@ unicode_toupper(int character) { INLINE int TextEncoder:: unicode_tolower(int character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); - if (entry == (const UnicodeLatinMap::Entry *)NULL) { + if (entry == nullptr) { return character; } return entry->_tolower_character; diff --git a/dtool/src/dtoolutil/textEncoder.cxx b/dtool/src/dtoolutil/textEncoder.cxx index f4f788845e..90ce30d395 100644 --- a/dtool/src/dtoolutil/textEncoder.cxx +++ b/dtool/src/dtoolutil/textEncoder.cxx @@ -69,7 +69,7 @@ get_wtext_as_ascii() const { const UnicodeLatinMap::Entry *map_entry = UnicodeLatinMap::look_up(character); - if (map_entry != NULL && map_entry->_ascii_equiv != 0) { + if (map_entry != nullptr && map_entry->_ascii_equiv != 0) { result += (wchar_t)map_entry->_ascii_equiv; if (map_entry->_ascii_additional != 0) { result += (wchar_t)map_entry->_ascii_additional; @@ -117,7 +117,7 @@ encode_wchar(wchar_t ch, TextEncoder::Encoding encoding) { // an unusual accent mark). const UnicodeLatinMap::Entry *map_entry = UnicodeLatinMap::look_up(ch); - if (map_entry != NULL && map_entry->_ascii_equiv != 0) { + if (map_entry != nullptr && map_entry->_ascii_equiv != 0) { // Yes, it has an ascii equivalent. if (map_entry->_ascii_additional != 0) { // In fact, it has two of them. @@ -345,7 +345,7 @@ operator >> (istream &in, TextEncoder::Encoding &encoding) { encoding = TextEncoder::E_unicode; } else { ostream *notify_ptr = StringDecoder::get_notify_ptr(); - if (notify_ptr != (ostream *)NULL) { + if (notify_ptr != nullptr) { (*notify_ptr) << "Invalid TextEncoder::Encoding: " << word << "\n"; } diff --git a/dtool/src/dtoolutil/unicodeLatinMap.cxx b/dtool/src/dtoolutil/unicodeLatinMap.cxx index 3fc1e3cb1c..87c9cb5a7d 100644 --- a/dtool/src/dtoolutil/unicodeLatinMap.cxx +++ b/dtool/src/dtoolutil/unicodeLatinMap.cxx @@ -1392,7 +1392,7 @@ look_up(wchar_t character) { if (ci != _by_character->end()) { return (*ci).second; } - return NULL; + return nullptr; } } diff --git a/dtool/src/dtoolutil/win32ArgParser.cxx b/dtool/src/dtoolutil/win32ArgParser.cxx index 84ddb785a6..231b4af12b 100644 --- a/dtool/src/dtoolutil/win32ArgParser.cxx +++ b/dtool/src/dtoolutil/win32ArgParser.cxx @@ -29,7 +29,7 @@ */ Win32ArgParser:: Win32ArgParser() : - _argv(NULL), + _argv(nullptr), _argc(0) { } @@ -50,12 +50,12 @@ void Win32ArgParser:: clear() { assert(_argc == (int)_args.size()); - if (_argv != NULL) { + if (_argv != nullptr) { for (int i = 0; i < _argc; ++i) { PANDA_FREE_ARRAY(_argv[i]); } PANDA_FREE_ARRAY(_argv); - _argv = NULL; + _argv = nullptr; } _argc = 0; @@ -80,7 +80,7 @@ set_command_line(const string &command_line) { } } - assert(_argc == 0 && _argv == NULL); + assert(_argc == 0 && _argv == nullptr); _argc = (int)_args.size(); _argv = (char **)PANDA_MALLOC_ARRAY(_argc * sizeof(char *)); for (int i = 0; i < _argc; ++i) { diff --git a/dtool/src/interrogate/functionRemap.cxx b/dtool/src/interrogate/functionRemap.cxx index 7299d9b5f8..745d084b72 100644 --- a/dtool/src/interrogate/functionRemap.cxx +++ b/dtool/src/interrogate/functionRemap.cxx @@ -39,7 +39,7 @@ FunctionRemap:: FunctionRemap(const InterrogateType &itype, const InterrogateFunction &ifunc, CPPInstance *cppfunc, int num_default_parameters, InterfaceMaker *interface_maker) { - _return_type = (ParameterRemap *)NULL; + _return_type = nullptr; _void_return = true; _ForcedVoidReturn = false; _has_this = false; @@ -117,7 +117,7 @@ call_function(ostream &out, int indent_level, bool convert_result, if (_type == T_destructor) { // A destructor wrapper is just a wrapper around the delete operator. assert(!container.empty()); - assert(_cpptype != (CPPType *)NULL); + assert(_cpptype != nullptr); if (TypeManager::is_reference_count(_cpptype)) { // Except for a reference-count type object, in which case the @@ -279,7 +279,7 @@ call_function(ostream &out, int indent_level, bool convert_result, void FunctionRemap:: write_orig_prototype(ostream &out, int indent_level, bool local, int num_default_args) const { if (local) { - _cppfunc->output(out, indent_level, NULL, false, num_default_args); + _cppfunc->output(out, indent_level, nullptr, false, num_default_args); } else { _cppfunc->output(out, indent_level, &parser, false, num_default_args); } @@ -299,7 +299,7 @@ make_wrapper_entry(FunctionIndex function_index) { iwrapper._name = _wrapper_name; iwrapper._unique_name = _unique_name; - if (_cppfunc->_leading_comment != (CPPCommentBlock *)NULL) { + if (_cppfunc->_leading_comment != nullptr) { iwrapper._comment = InterrogateBuilder::trim_blanks(_cppfunc->_leading_comment->_comment); } @@ -395,7 +395,7 @@ get_call_str(const string &container, const vector_string &pexprs) const { // It's not possible to assign arrays in C++, we have to copy them. CPPArrayType *array_type = _parameters[_first_true_parameter]._remap->get_orig_type()->as_array_type(); - if (array_type != NULL) { + if (array_type != nullptr) { call << "std::copy(" << expr << ", " << expr << " + " << *array_type->_bounds << ", "; } else { call << expr << " = "; @@ -404,7 +404,7 @@ get_call_str(const string &container, const vector_string &pexprs) const { _parameters[_first_true_parameter]._remap->pass_parameter(call, get_parameter_expr(_first_true_parameter, pexprs)); - if (array_type != NULL) { + if (array_type != nullptr) { call << ')'; } @@ -490,7 +490,7 @@ get_min_num_args() const { } for (; pi != _parameters.end(); ++pi) { ParameterRemap *param = (*pi)._remap; - if (param->get_default_value() != (CPPExpression *)NULL) { + if (param->get_default_value() != nullptr) { // We've reached the first parameter that takes a default value. break; } else { @@ -567,7 +567,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak string fname = _cppfunc->get_simple_name(); CPPType *rtype = _ftype->_return_type->resolve_type(&parser, _cppscope); - if (_cpptype != (CPPType *)NULL && + if (_cpptype != nullptr && ((_cppfunc->_storage_class & CPPInstance::SC_static) == 0) && _type != T_constructor) { @@ -609,10 +609,10 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak fname == "operator >>=") { _type = T_assignment_method; - } else if (fname == "operator []" && !_const_method && rtype != NULL) { + } else if (fname == "operator []" && !_const_method && rtype != nullptr) { // Check if this is an item-assignment operator. CPPReferenceType *reftype = rtype->as_reference_type(); - if (reftype != NULL && reftype->_pointing_at->as_const_type() == NULL) { + if (reftype != nullptr && reftype->_pointing_at->as_const_type() == nullptr) { // It returns a mutable reference. _type = T_item_assignment_operator; } @@ -638,7 +638,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak } param._remap = interface_maker->remap_parameter(_cpptype, type); - if (param._remap == (ParameterRemap *)NULL) { + if (param._remap == nullptr) { // If we can't handle one of the parameter types, we can't call the // function. if (fname == "__traverse__") { @@ -666,13 +666,13 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak // by the parser, but we know they actually return a new concrete // instance. - if (_cpptype == (CPPType *)NULL) { + if (_cpptype == nullptr) { nout << "Method " << *_cppfunc << " has no struct type\n"; return false; } _return_type = interface_maker->remap_parameter(_cpptype, _cpptype); - if (_return_type != (ParameterRemap *)NULL) { + if (_return_type != nullptr) { _void_return = false; } @@ -681,13 +681,13 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak // return *this, which is a semi-standard C++ convention anyway. We just // enforce it. - if (_cpptype == (CPPType *)NULL) { + if (_cpptype == nullptr) { nout << "Method " << *_cppfunc << " has no struct type\n"; return false; } else { CPPType *ref_type = CPPType::new_type(new CPPReferenceType(_cpptype)); _return_type = interface_maker->remap_parameter(_cpptype, ref_type); - if (_return_type != (ParameterRemap *)NULL) { + if (_return_type != nullptr) { _void_return = false; } } @@ -697,7 +697,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak // scripting languages, so we use this to denote item-access operators // that return a non-const reference. - if (_cpptype == (CPPType *)NULL) { + if (_cpptype == nullptr) { nout << "Method " << *_cppfunc << " has no struct type\n"; return false; } else { @@ -711,7 +711,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak param._name = "assign_val"; param._remap = interface_maker->remap_parameter(_cpptype, ref_type); - if (param._remap == NULL || !param._remap->is_valid()) { + if (param._remap == nullptr || !param._remap->is_valid()) { nout << "Invalid remap for assignment type of method " << *_cppfunc << "\n"; return false; } @@ -726,12 +726,12 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak } else { // The normal case. _return_type = interface_maker->remap_parameter(_cpptype, rtype); - if (_return_type != (ParameterRemap *)NULL) { + if (_return_type != nullptr) { _void_return = TypeManager::is_void(rtype); } } - if (_return_type == (ParameterRemap *)NULL || + if (_return_type == nullptr || !_return_type->is_valid()) { // If our return type isn't something we can deal with, treat the function // as if it returns NULL. @@ -739,7 +739,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak _ForcedVoidReturn = true; CPPType *void_type = TypeManager::get_void_type(); _return_type = interface_maker->remap_parameter(_cpptype, void_type); - assert(_return_type != (ParameterRemap *)NULL); + assert(_return_type != nullptr); } // Do we need to manage the return value? @@ -785,7 +785,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak if (_parameters.size() == first_param) { _args_type = InterfaceMaker::AT_no_args; } else if (_parameters.size() == first_param + 1 && - _parameters[first_param]._remap->get_default_value() == NULL) { + _parameters[first_param]._remap->get_default_value() == nullptr) { _args_type = InterfaceMaker::AT_single_arg; } else { _args_type = InterfaceMaker::AT_varargs; diff --git a/dtool/src/interrogate/interfaceMaker.cxx b/dtool/src/interrogate/interfaceMaker.cxx index ded4efacc5..172b8c1375 100644 --- a/dtool/src/interrogate/interfaceMaker.cxx +++ b/dtool/src/interrogate/interfaceMaker.cxx @@ -315,7 +315,7 @@ write_module(ostream &, ostream *out_h, InterrogateModuleDef *) { */ ParameterRemap *InterfaceMaker:: remap_parameter(CPPType *struct_type, CPPType *param_type) { - nassertr(param_type != NULL, NULL); + nassertr(param_type != nullptr, nullptr); if (convert_strings) { if (TypeManager::is_char_pointer(param_type)) { @@ -328,7 +328,7 @@ remap_parameter(CPPType *struct_type, CPPType *param_type) { // If we're exporting a method of basic_string itself, don't convert // basic_string's to atomic strings. - if (struct_type == (CPPType *)NULL || + if (struct_type == nullptr || !(TypeManager::is_basic_string_char(struct_type) || TypeManager::is_basic_string_wchar(struct_type))) { if (TypeManager::is_basic_string_char(param_type)) { @@ -359,11 +359,11 @@ remap_parameter(CPPType *struct_type, CPPType *param_type) { CPPType *pt_type = TypeManager::unwrap(param_type); if (TypeManager::is_basic_string_char(pt_type) || TypeManager::is_basic_string_wchar(pt_type)) { - return (ParameterRemap *)NULL; + return nullptr; } } } - if (struct_type == (CPPType *)NULL || + if (struct_type == nullptr || !TypeManager::is_vector_unsigned_char(struct_type)) { if (TypeManager::is_vector_unsigned_char(param_type)) { if (TypeManager::is_reference(param_type)) { @@ -385,7 +385,7 @@ remap_parameter(CPPType *struct_type, CPPType *param_type) { // Don't convert PointerTo<>'s to pointers for methods of the PointerTo // itself! - if (struct_type == (CPPType *)NULL || + if (struct_type == nullptr || !(pt_type->get_local_name(&parser) == struct_type->get_local_name(&parser))) { return new ParameterRemapPTToPointer(param_type); } @@ -417,7 +417,7 @@ remap_parameter(CPPType *struct_type, CPPType *param_type) { } else { // Here's something we have a problem with. - return (ParameterRemap *)NULL; + return nullptr; } } @@ -512,7 +512,7 @@ make_function_remap(const InterrogateType &itype, // No such FunctionRemap is valid. Return NULL. delete remap; - return (FunctionRemap *)NULL; + return nullptr; } /** @@ -576,7 +576,7 @@ record_function(const InterrogateType &itype, FunctionIndex func_index) { // printf(" Function Name = %s\n", ifunc.get_name().c_str()); // Now get all the valid FunctionRemaps for the function. - if (ifunc._instances != (InterrogateFunction::Instances *)NULL) { + if (ifunc._instances != nullptr) { InterrogateFunction::Instances::const_iterator ii; for (ii = ifunc._instances->begin(); ii != ifunc._instances->end(); ++ii) { CPPInstance *cppfunc = (*ii).second; @@ -591,7 +591,7 @@ record_function(const InterrogateType &itype, FunctionIndex func_index) { pi != parameters->_parameters.rend(); ++pi) { CPPInstance *param = (*pi); - if (param->_initializer != (CPPExpression *)NULL) { + if (param->_initializer != nullptr) { // This parameter has a default value. max_default_parameters++; } else { @@ -610,7 +610,7 @@ record_function(const InterrogateType &itype, FunctionIndex func_index) { num_default_parameters++) { FunctionRemap *remap = make_function_remap(itype, ifunc, cppfunc, num_default_parameters); - if (remap != (FunctionRemap *)NULL) { + if (remap != nullptr) { func->_remaps.push_back(remap); @@ -654,7 +654,7 @@ InterfaceMaker::Object *InterfaceMaker:: record_object(TypeIndex type_index) { if (type_index == 0) { // An invalid type. - return (Object *)NULL; + return nullptr; } Objects::iterator oi = _objects.find(type_index); @@ -884,7 +884,7 @@ hash_function_signature(FunctionRemap *remap) { return; } - if ((*hi).second != (FunctionRemap *)NULL && + if ((*hi).second != nullptr && (*hi).second->_function_signature == remap->_function_signature) { // The same function signature has already appeared. This shouldn't // happen. @@ -896,9 +896,9 @@ hash_function_signature(FunctionRemap *remap) { } // We have a conflict. Extend both strings to resolve the ambiguity. - if ((*hi).second != (FunctionRemap *)NULL) { + if ((*hi).second != nullptr) { FunctionRemap *other_remap = (*hi).second; - (*hi).second = (FunctionRemap *)NULL; + (*hi).second = nullptr; other_remap->_hash += InterrogateBuilder::hash_string(other_remap->_function_signature, 11); bool inserted = _wrappers_by_hash.insert diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 5d202167d4..13ee124698 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -100,12 +100,12 @@ RenameSet methodRenameDictionary[] = { { "__deepcopy__" , "__deepcopy__", 0 }, { "print" , "Cprint", 0 }, { "CInterval.set_t", "_priv__cSetT", 0 }, - { NULL, NULL, -1 } + { nullptr, nullptr, -1 } }; RenameSet classRenameDictionary[] = { // No longer used, now empty. - { NULL, NULL, -1 } + { nullptr, nullptr, -1 } }; const char *pythonKeywords[] = { @@ -141,12 +141,12 @@ const char *pythonKeywords[] = { "while", "with", "yield", - NULL + nullptr }; std::string checkKeyword(std::string &cppName) { - for (int x = 0; pythonKeywords[x] != NULL; x++) { + for (int x = 0; pythonKeywords[x] != nullptr; x++) { if (cppName == pythonKeywords[x]) { return std::string("_") + cppName; } @@ -193,7 +193,7 @@ classNameFromCppName(const std::string &cppName, bool mangle) { } } - for (int x = 0; classRenameDictionary[x]._from != NULL; x++) { + for (int x = 0; classRenameDictionary[x]._from != nullptr; x++) { if (cppName == classRenameDictionary[x]._from) { className = classRenameDictionary[x]._to; } @@ -247,7 +247,7 @@ methodNameFromCppName(const std::string &cppName, const std::string &className, } } - for (int x = 0; methodRenameDictionary[x]._from != NULL; x++) { + for (int x = 0; methodRenameDictionary[x]._from != nullptr; x++) { if (origName == methodRenameDictionary[x]._from) { methodName = methodRenameDictionary[x]._to; } @@ -255,7 +255,7 @@ methodNameFromCppName(const std::string &cppName, const std::string &className, if (className.size() > 0) { string lookup_name = className + '.' + cppName; - for (int x = 0; classRenameDictionary[x]._from != NULL; x++) { + for (int x = 0; classRenameDictionary[x]._from != nullptr; x++) { if (lookup_name == methodRenameDictionary[x]._from) { methodName = methodRenameDictionary[x]._to; } @@ -296,7 +296,7 @@ std::string methodNameFromCppName(FunctionRemap *remap, const std::string &class bool InterfaceMakerPythonNative:: get_slotted_function_def(Object *obj, Function *func, FunctionRemap *remap, SlottedFunctionDef &def) { - if (obj == NULL) { + if (obj == nullptr) { // Only methods may be slotted. return false; } @@ -679,7 +679,7 @@ write_function_slot(ostream &out, int indent_level, const SlottedFunctions &slot void InterfaceMakerPythonNative:: get_valid_child_classes(std::map &answer, CPPStructType *inclass, const std::string &upcast_seed, bool can_downcast) { - if (inclass == NULL) { + if (inclass == nullptr) { return; } @@ -691,7 +691,7 @@ get_valid_child_classes(std::map &answer, CPPStructTyp const CPPStructType::Base &base = (*bi); // if (base._vis <= V_public) can_downcast = false; CPPStructType *base_type = TypeManager::resolve_type(base._base)->as_struct_type(); - if (base_type != NULL) { + if (base_type != nullptr) { std::string scoped_name = base_type->get_local_name(&parser); if (answer.find(scoped_name) == answer.end()) { @@ -806,7 +806,7 @@ void InterfaceMakerPythonNative:: write_prototypes(ostream &out_code, ostream *out_h) { Functions::iterator fi; - if (out_h != NULL) { + if (out_h != nullptr) { *out_h << "#include \"py_panda.h\"\n\n"; } @@ -966,7 +966,7 @@ write_functions(ostream &out) { for (fi = _functions.begin(); fi != _functions.end(); ++fi) { Function *func = (*fi).second; if (!func->_itype.is_global() && is_function_legal(func)) { - write_function_for_top(out, NULL, func); + write_function_for_top(out, nullptr, func); } } @@ -1187,7 +1187,7 @@ write_class_declarations(ostream &out, ostream *out_h, Object *obj) { out << "\n"; - if (out_h != NULL) { + if (out_h != nullptr) { *out_h << "extern \"C\" " << EXPORT_IMPORT_PREFIX << " struct Dtool_PyTypedObject Dtool_" << class_name << ";\n"; } } @@ -1465,7 +1465,7 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { out << " {NULL, NULL, 0, NULL}\n" << "};\n\n"; out << "struct LibraryDef " << def->library_name << "_moddef = {python_simple_funcs};\n"; - if (out_h != NULL) { + if (out_h != nullptr) { *out_h << "extern struct LibraryDef " << def->library_name << "_moddef;\n"; } } @@ -1546,7 +1546,7 @@ write_module_class(ostream &out, Object *obj) { } Object *nested_obj = _objects[nested_index]; - assert(nested_obj != (Object *)NULL); + assert(nested_obj != nullptr); if (nested_obj->_itype.is_class() || nested_obj->_itype.is_struct()) { write_module_class(out, nested_obj); @@ -2190,8 +2190,8 @@ write_module_class(ostream &out, Object *obj) { vector_string params_const(1); vector_string params_nonconst(1); - FunctionRemap *remap_const = NULL; - FunctionRemap *remap_nonconst = NULL; + FunctionRemap *remap_const = nullptr; + FunctionRemap *remap_nonconst = nullptr; // Iterate through the remaps to find the one that matches our // parameters. @@ -2219,20 +2219,20 @@ write_module_class(ostream &out, Object *obj) { // because the function may depend on it to decide whether to // provide a writable buffer or a readonly buffer. const string const_this = "(const " + cClassName + " *)local_this"; - if (remap_const != NULL && remap_nonconst != NULL) { + if (remap_const != nullptr && remap_nonconst != nullptr) { out << " if (!DtoolInstance_IS_CONST(self)) {\n"; out << " return " << remap_nonconst->call_function(out, 4, false, "local_this", params_nonconst) << ";\n"; out << " } else {\n"; out << " return " << remap_const->call_function(out, 4, false, const_this, params_const) << ";\n"; out << " }\n"; - } else if (remap_nonconst != NULL) { + } else if (remap_nonconst != nullptr) { out << " if (!DtoolInstance_IS_CONST(self)) {\n"; out << " return " << remap_nonconst->call_function(out, 4, false, "local_this", params_nonconst) << ";\n"; out << " } else {\n"; out << " Dtool_Raise_TypeError(\"Cannot call " << ClassName << ".__getbuffer__() on a const object.\");\n"; out << " return -1;\n"; out << " }\n"; - } else if (remap_const != NULL) { + } else if (remap_const != nullptr) { out << " return " << remap_const->call_function(out, 4, false, const_this, params_const) << ";\n"; } else { nout << ClassName << "::__getbuffer__ does not match the required signature.\n"; @@ -2259,8 +2259,8 @@ write_module_class(ostream &out, Object *obj) { vector_string params_const(1); vector_string params_nonconst(1); - FunctionRemap *remap_const = NULL; - FunctionRemap *remap_nonconst = NULL; + FunctionRemap *remap_const = nullptr; + FunctionRemap *remap_nonconst = nullptr; // Iterate through the remaps to find the one that matches our // parameters. @@ -2284,7 +2284,7 @@ write_module_class(ostream &out, Object *obj) { string return_expr; const string const_this = "(const " + cClassName + " *)local_this"; - if (remap_const != NULL && remap_nonconst != NULL) { + if (remap_const != nullptr && remap_nonconst != nullptr) { out << " if (!DtoolInstance_IS_CONST(self)) {\n"; return_expr = remap_nonconst->call_function(out, 4, false, "local_this", params_nonconst); if (!return_expr.empty()) { @@ -2298,7 +2298,7 @@ write_module_class(ostream &out, Object *obj) { } out << " }\n"; - } else if (remap_nonconst != NULL) { + } else if (remap_nonconst != nullptr) { // Doesn't matter if there's no const version. We *have* to call // it or else we could leak memory. return_expr = remap_nonconst->call_function(out, 2, false, "local_this", params_nonconst); @@ -2306,7 +2306,7 @@ write_module_class(ostream &out, Object *obj) { out << " " << return_expr << ";\n"; } - } else if (remap_const != NULL) { + } else if (remap_const != nullptr) { return_expr = remap_const->call_function(out, 2, false, const_this, params_const); if (!return_expr.empty()) { out << " " << return_expr << ";\n"; @@ -3093,7 +3093,7 @@ write_module_class(ostream &out, Object *obj) { continue; } Object *nested_obj = _objects[nested_index]; - assert(nested_obj != (Object *)NULL); + assert(nested_obj != nullptr); if (nested_obj->_itype.is_class() || nested_obj->_itype.is_struct()) { num_dict_items += 2; @@ -3125,7 +3125,7 @@ write_module_class(ostream &out, Object *obj) { } Object *nested_obj = _objects[nested_index]; - assert(nested_obj != (Object *)NULL); + assert(nested_obj != nullptr); if (nested_obj->_itype.is_class() || nested_obj->_itype.is_struct()) { std::string ClassName1 = make_safe_name(nested_obj->_itype.get_scoped_name()); @@ -3462,7 +3462,7 @@ write_function_for_name(ostream &out, Object *obj, bool has_this = false; Function::Remaps::const_iterator ri; - FunctionRemap *remap = NULL; + FunctionRemap *remap = nullptr; int max_required_args = 0; bool all_nonconst = true; bool has_keywords = false; @@ -4239,8 +4239,8 @@ int get_type_sort(CPPType *type) { // The Core sort function for remap calling orders.. bool RemapCompareLess(FunctionRemap *in1, FunctionRemap *in2) { - assert(in1 != NULL); - assert(in2 != NULL); + assert(in1 != nullptr); + assert(in2 != nullptr); if (in1->_const_method != in2->_const_method) { // Non-const methods should come first. @@ -4324,7 +4324,7 @@ write_function_forset(ostream &out, return; } - FunctionRemap *remap = NULL; + FunctionRemap *remap = nullptr; std::set::iterator sii; bool all_nonconst = false; @@ -5287,23 +5287,23 @@ write_function_instance(ostream &out, FunctionRemap *remap, // Unravel the type to determine its properties. int array_len = -1; bool is_const = true; - CPPSimpleType *simple = NULL; + CPPSimpleType *simple = nullptr; CPPType *unwrap = TypeManager::unwrap_const_reference(type); - if (unwrap != NULL) { + if (unwrap != nullptr) { CPPArrayType *array_type = unwrap->as_array_type(); CPPPointerType *pointer_type = unwrap->as_pointer_type(); - if (array_type != NULL) { - if (array_type->_bounds != NULL) { + if (array_type != nullptr) { + if (array_type->_bounds != nullptr) { array_len = array_type->_bounds->evaluate().as_integer(); } unwrap = array_type->_element_type; - } else if (pointer_type != NULL) { + } else if (pointer_type != nullptr) { unwrap = pointer_type->_pointing_at; } CPPConstType *const_type = unwrap->as_const_type(); - if (const_type != NULL) { + if (const_type != nullptr) { unwrap = const_type->_wrapped_around; } else { is_const = false; @@ -6545,7 +6545,7 @@ write_getset(ostream &out, Object *obj, Property *property) { out << " }\n"; out << " if (arg == (PyObject *)NULL) {\n"; - if (property->_deleter != NULL) { + if (property->_deleter != nullptr) { if (property->_deleter->_has_this) { out << " local_this->" << property->_deleter->_ifunc.get_name() << "(index);\n"; } else { @@ -6558,7 +6558,7 @@ write_getset(ostream &out, Object *obj, Property *property) { } out << " }\n"; - if (property->_clear_function != NULL) { + if (property->_clear_function != nullptr) { out << " if (arg == Py_None) {\n"; if (property->_clear_function->_has_this) { out << " local_this->" << property->_clear_function->_ifunc.get_name() << "(index);\n"; @@ -6659,7 +6659,7 @@ write_getset(ostream &out, Object *obj, Property *property) { " }\n"; } - if (property->_has_function != NULL) { + if (property->_has_function != nullptr) { std::set remaps; remaps.insert(property->_has_function->_remaps.begin(), property->_has_function->_remaps.end()); @@ -6717,10 +6717,10 @@ write_getset(ostream &out, Object *obj, Property *property) { } out << " if (value == (PyObject *)NULL) {\n"; - if (property->_deleter != NULL) { + if (property->_deleter != nullptr) { out << " PyObject *arg = key;\n"; - if (property->_has_function != NULL) { + if (property->_has_function != nullptr) { std::set remaps; remaps.insert(property->_has_function->_remaps.begin(), property->_has_function->_remaps.end()); @@ -6747,7 +6747,7 @@ write_getset(ostream &out, Object *obj, Property *property) { } out << " }\n"; - if (property->_clear_function != NULL) { + if (property->_clear_function != nullptr) { out << " if (value == Py_None) {\n" << " local_this->" << property->_clear_function->_ifunc.get_name() << "(key);\n" << " return 0;\n" @@ -6910,7 +6910,7 @@ write_getset(ostream &out, Object *obj, Property *property) { out << " }\n\n"; } - if (property->_has_function != NULL) { + if (property->_has_function != nullptr) { if (remap->_has_this) { out << " if (!local_this->" << property->_has_function->_ifunc.get_name() << "()) {\n"; } else { @@ -6942,10 +6942,10 @@ write_getset(ostream &out, Object *obj, Property *property) { } out << " if (arg == (PyObject *)NULL) {\n"; - if (property->_deleter != NULL && remap->_has_this) { + if (property->_deleter != nullptr && remap->_has_this) { out << " local_this->" << property->_deleter->_ifunc.get_name() << "();\n" << " return 0;\n"; - } else if (property->_deleter != NULL) { + } else if (property->_deleter != nullptr) { out << " " << cClassName << "::" << property->_deleter->_ifunc.get_name() << "();\n" << " return 0;\n"; } else { @@ -6954,7 +6954,7 @@ write_getset(ostream &out, Object *obj, Property *property) { } out << " }\n"; - if (property->_clear_function != NULL) { + if (property->_clear_function != nullptr) { out << " if (arg == Py_None) {\n"; if (remap->_has_this) { out << " local_this->" << property->_clear_function->_ifunc.get_name() << "();\n"; @@ -7003,7 +7003,7 @@ write_getset(ostream &out, Object *obj, Property *property) { InterfaceMaker::Object *InterfaceMakerPythonNative:: record_object(TypeIndex type_index) { if (type_index == 0) { - return (Object *)NULL; + return nullptr; } Objects::iterator oi = _objects.find(type_index); @@ -7015,7 +7015,7 @@ record_object(TypeIndex type_index) { const InterrogateType &itype = idb->get_type(type_index); if (!is_cpp_type_legal(itype._cpptype)) { - return (Object *)NULL; + return nullptr; } Object *object = new Object(itype); @@ -7287,7 +7287,7 @@ generate_wrappers() { */ bool InterfaceMakerPythonNative:: is_cpp_type_legal(CPPType *in_ctype) { - if (in_ctype == NULL) { + if (in_ctype == nullptr) { return false; } @@ -7357,7 +7357,7 @@ isExportThisRun(CPPType *ctype) { */ bool InterfaceMakerPythonNative:: isExportThisRun(Function *func) { - if (func == NULL || !is_function_legal(func)) { + if (func == nullptr || !is_function_legal(func)) { return false; } @@ -7375,7 +7375,7 @@ isExportThisRun(Function *func) { */ bool InterfaceMakerPythonNative:: is_remap_legal(FunctionRemap *remap) { - if (remap == NULL) { + if (remap == nullptr) { return false; } @@ -7402,7 +7402,7 @@ is_remap_legal(FunctionRemap *remap) { for (size_t pn = 0; pn < remap->_parameters.size(); pn++) { ParameterRemap *param = remap->_parameters[pn]._remap; CPPType *orig_type = param->get_orig_type(); - if (param->get_default_value() == NULL && !is_cpp_type_legal(orig_type)) { + if (param->get_default_value() == nullptr && !is_cpp_type_legal(orig_type)) { return false; } } @@ -7416,7 +7416,7 @@ is_remap_legal(FunctionRemap *remap) { */ int InterfaceMakerPythonNative:: has_coerce_constructor(CPPStructType *type) { - if (type == NULL) { + if (type == nullptr) { return 0; } @@ -7429,7 +7429,7 @@ has_coerce_constructor(CPPStructType *type) { } CPPScope *scope = type->get_scope(); - if (scope == NULL) { + if (scope == nullptr) { return 0; } @@ -7443,7 +7443,7 @@ has_coerce_constructor(CPPStructType *type) { for (ii = fgroup->_instances.begin(); ii != fgroup->_instances.end(); ++ii) { CPPInstance *inst = (*ii); CPPFunctionType *ftype = inst->_type->as_function_type(); - if (ftype == NULL) { + if (ftype == nullptr) { continue; } if (inst->_storage_class & CPPInstance::SC_explicit) { @@ -7489,7 +7489,7 @@ has_coerce_constructor(CPPStructType *type) { */ bool InterfaceMakerPythonNative:: is_remap_coercion_possible(FunctionRemap *remap) { - if (remap == NULL) { + if (remap == nullptr) { return false; } @@ -7565,7 +7565,7 @@ IsRunTimeTyped(const InterrogateType &itype) { */ bool InterfaceMakerPythonNative:: DoesInheritFromIsClass(const CPPStructType *inclass, const std::string &name) { - if (inclass == NULL) { + if (inclass == nullptr) { return false; } @@ -7582,7 +7582,7 @@ DoesInheritFromIsClass(const CPPStructType *inclass, const std::string &name) { const CPPStructType::Base &base = (*bi); CPPStructType *base_type = TypeManager::resolve_type(base._base)->as_struct_type(); - if (base_type != NULL) { + if (base_type != nullptr) { if (DoesInheritFromIsClass(base_type, name)) { return true; } @@ -7601,7 +7601,7 @@ has_get_class_type_function(CPPType *type) { } CPPStructType *struct_type = type->as_struct_type(); - if (struct_type == NULL) { + if (struct_type == nullptr) { return false; } @@ -7620,7 +7620,7 @@ has_init_type_function(CPPType *type) { } CPPStructType *struct_type = type->as_struct_type(); - if (struct_type == NULL) { + if (struct_type == nullptr) { return false; } @@ -7636,8 +7636,8 @@ has_init_type_function(CPPType *type) { const CPPInstance *cppinst = *ii; const CPPFunctionType *cppfunc = cppinst->_type->as_function_type(); - if (cppfunc != NULL && - cppfunc->_parameters != NULL && + if (cppfunc != nullptr && + cppfunc->_parameters != nullptr && cppfunc->_parameters->_parameters.size() == 0 && (cppinst->_storage_class & CPPInstance::SC_static) != 0) { return true; @@ -7669,7 +7669,7 @@ NeedsAStrFunction(const InterrogateType &itype_class) { FunctionIndex func_index = itype_class.get_method(mi); const InterrogateFunction &ifunc = idb->get_function(func_index); if (ifunc.get_name() == "write") { - if (ifunc._instances != (InterrogateFunction::Instances *)NULL) { + if (ifunc._instances != nullptr) { InterrogateFunction::Instances::const_iterator ii; for (ii = ifunc._instances->begin(); ii != ifunc._instances->end(); @@ -7677,9 +7677,9 @@ NeedsAStrFunction(const InterrogateType &itype_class) { CPPInstance *cppinst = (*ii).second; CPPFunctionType *cppfunc = cppinst->_type->as_function_type(); - if (cppfunc != NULL) { - if (cppfunc->_parameters != NULL && - cppfunc->_return_type != NULL && + if (cppfunc != nullptr) { + if (cppfunc->_parameters != nullptr && + cppfunc->_return_type != nullptr && TypeManager::is_void(cppfunc->_return_type)) { if (cppfunc->_parameters->_parameters.size() == 1) { CPPInstance *inst1 = cppfunc->_parameters->_parameters[0]; @@ -7693,7 +7693,7 @@ NeedsAStrFunction(const InterrogateType &itype_class) { CPPInstance *inst1 = cppfunc->_parameters->_parameters[0]; if (TypeManager::is_pointer_to_ostream(inst1->_type)) { inst1 = cppfunc->_parameters->_parameters[1]; - if (inst1->_initializer != NULL) { + if (inst1->_initializer != nullptr) { // write(ostream, int = 0) return 1; } @@ -7739,7 +7739,7 @@ NeedsAReprFunction(const InterrogateType &itype_class) { FunctionIndex func_index = itype_class.get_method(mi); const InterrogateFunction &ifunc = idb->get_function(func_index); if (ifunc.get_name() == "python_repr") { - if (ifunc._instances != (InterrogateFunction::Instances *)NULL) { + if (ifunc._instances != nullptr) { InterrogateFunction::Instances::const_iterator ii; for (ii = ifunc._instances->begin(); ii != ifunc._instances->end(); @@ -7747,9 +7747,9 @@ NeedsAReprFunction(const InterrogateType &itype_class) { CPPInstance *cppinst = (*ii).second; CPPFunctionType *cppfunc = cppinst->_type->as_function_type(); - if (cppfunc != NULL) { - if (cppfunc->_parameters != NULL && - cppfunc->_return_type != NULL && + if (cppfunc != nullptr) { + if (cppfunc->_parameters != nullptr && + cppfunc->_return_type != nullptr && TypeManager::is_void(cppfunc->_return_type)) { if (cppfunc->_parameters->_parameters.size() == 2) { CPPInstance *inst1 = cppfunc->_parameters->_parameters[0]; @@ -7777,7 +7777,7 @@ NeedsAReprFunction(const InterrogateType &itype_class) { FunctionIndex func_index = itype_class.get_method(mi); const InterrogateFunction &ifunc = idb->get_function(func_index); if (ifunc.get_name() == "output") { - if (ifunc._instances != (InterrogateFunction::Instances *)NULL) { + if (ifunc._instances != nullptr) { InterrogateFunction::Instances::const_iterator ii; for (ii = ifunc._instances->begin(); ii != ifunc._instances->end(); @@ -7785,9 +7785,9 @@ NeedsAReprFunction(const InterrogateType &itype_class) { CPPInstance *cppinst = (*ii).second; CPPFunctionType *cppfunc = cppinst->_type->as_function_type(); - if (cppfunc != NULL) { - if (cppfunc->_parameters != NULL && - cppfunc->_return_type != NULL && + if (cppfunc != nullptr) { + if (cppfunc->_parameters != nullptr && + cppfunc->_return_type != nullptr && TypeManager::is_void(cppfunc->_return_type)) { if (cppfunc->_parameters->_parameters.size() == 1) { CPPInstance *inst1 = cppfunc->_parameters->_parameters[0]; @@ -7801,7 +7801,7 @@ NeedsAReprFunction(const InterrogateType &itype_class) { CPPInstance *inst1 = cppfunc->_parameters->_parameters[0]; if (TypeManager::is_pointer_to_ostream(inst1->_type)) { inst1 = cppfunc->_parameters->_parameters[1]; - if (inst1->_initializer != NULL) { + if (inst1->_initializer != nullptr) { // output(ostream, foo = bar, ...) return 2; } diff --git a/dtool/src/interrogate/interfaceMakerPythonObj.cxx b/dtool/src/interrogate/interfaceMakerPythonObj.cxx index af48b2f016..1f76f0cb3b 100644 --- a/dtool/src/interrogate/interfaceMakerPythonObj.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonObj.cxx @@ -171,7 +171,7 @@ get_wrapper_prefix() { void InterfaceMakerPythonObj:: write_class_wrapper(ostream &out, InterfaceMaker::Object *object) { CPPType *struct_type = object->_itype._cpptype; - if (struct_type == (CPPType *)NULL) { + if (struct_type == nullptr) { return; } diff --git a/dtool/src/interrogate/interrogate.cxx b/dtool/src/interrogate/interrogate.cxx index 94175b9d2b..39b69e2c1d 100644 --- a/dtool/src/interrogate/interrogate.cxx +++ b/dtool/src/interrogate/interrogate.cxx @@ -83,32 +83,32 @@ enum CommandOptions { }; static struct option long_options[] = { - { "oc", required_argument, NULL, CO_oc }, - { "od", required_argument, NULL, CO_od }, - { "srcdir", required_argument, NULL, CO_srcdir }, - { "module", required_argument, NULL, CO_module }, - { "library", required_argument, NULL, CO_library }, - { "do-module", no_argument, NULL, CO_do_module }, - { "fptrs", no_argument, NULL, CO_fptrs }, - { "fnames", no_argument, NULL, CO_fnames }, - { "string", no_argument, NULL, CO_string }, - { "refcount", no_argument, NULL, CO_refcount }, - { "assert", no_argument, NULL, CO_assert }, - { "true-names", no_argument, NULL, CO_true_names }, - { "c", no_argument, NULL, CO_c }, - { "python", no_argument, NULL, CO_python }, - { "python-obj", no_argument, NULL, CO_python_obj }, - { "python-native", no_argument, NULL, CO_python_native }, - { "track-interpreter", no_argument, NULL, CO_track_interpreter }, - { "unique-names", no_argument, NULL, CO_unique_names }, - { "nodb", no_argument, NULL, CO_nodb }, - { "longlong", required_argument, NULL, CO_longlong }, - { "promiscuous", no_argument, NULL, CO_promiscuous }, - { "spam", no_argument, NULL, CO_spam }, - { "noangles", no_argument, NULL, CO_noangles }, - { "nomangle", no_argument, NULL, CO_nomangle }, - { "help", no_argument, NULL, CO_help }, - { NULL } + { "oc", required_argument, nullptr, CO_oc }, + { "od", required_argument, nullptr, CO_od }, + { "srcdir", required_argument, nullptr, CO_srcdir }, + { "module", required_argument, nullptr, CO_module }, + { "library", required_argument, nullptr, CO_library }, + { "do-module", no_argument, nullptr, CO_do_module }, + { "fptrs", no_argument, nullptr, CO_fptrs }, + { "fnames", no_argument, nullptr, CO_fnames }, + { "string", no_argument, nullptr, CO_string }, + { "refcount", no_argument, nullptr, CO_refcount }, + { "assert", no_argument, nullptr, CO_assert }, + { "true-names", no_argument, nullptr, CO_true_names }, + { "c", no_argument, nullptr, CO_c }, + { "python", no_argument, nullptr, CO_python }, + { "python-obj", no_argument, nullptr, CO_python_obj }, + { "python-native", no_argument, nullptr, CO_python_native }, + { "track-interpreter", no_argument, nullptr, CO_track_interpreter }, + { "unique-names", no_argument, nullptr, CO_unique_names }, + { "nodb", no_argument, nullptr, CO_nodb }, + { "longlong", required_argument, nullptr, CO_longlong }, + { "promiscuous", no_argument, nullptr, CO_promiscuous }, + { "spam", no_argument, nullptr, CO_spam }, + { "noangles", no_argument, nullptr, CO_noangles }, + { "nomangle", no_argument, nullptr, CO_nomangle }, + { "help", no_argument, nullptr, CO_help }, + { nullptr } }; void @@ -320,7 +320,7 @@ main(int argc, char **argv) { extern int optind; int flag; - flag = getopt_long_only(argc, argv, short_options, long_options, NULL); + flag = getopt_long_only(argc, argv, short_options, long_options, nullptr); while (flag != EOF) { switch (flag) { case 'I': @@ -458,7 +458,7 @@ main(int argc, char **argv) { default: exit(1); } - flag = getopt_long_only(argc, argv, short_options, long_options, NULL); + flag = getopt_long_only(argc, argv, short_options, long_options, nullptr); } argc -= (optind-1); @@ -541,10 +541,10 @@ main(int argc, char **argv) { // Make up a file identifier. This is just some bogus number that should be // the same in both the compiled-in code and in the database, so we can // check synchronicity at load time. - int file_identifier = time((time_t *)NULL); + int file_identifier = time(nullptr); InterrogateModuleDef *def = builder.make_module_def(file_identifier); - pofstream * the_output_include = NULL; + pofstream * the_output_include = nullptr; pofstream output_include; @@ -584,7 +584,7 @@ main(int argc, char **argv) { << " *\n" << " */\n\n"; - if(the_output_include != NULL) + if(the_output_include != nullptr) { output_code << "#include \""<resolve_type(&parser, &parser); @@ -132,7 +132,7 @@ do_command(const string &command, const string ¶ms) { } else if (command == "forcetype") { // forcetype explicitly exports the given type. CPPType *type = parser.parse_type(params); - if (type == (CPPType *)NULL) { + if (type == nullptr) { nout << "Unknown type: forcetype " << params << "\n"; } else { type = type->resolve_type(&parser, &parser); @@ -153,7 +153,7 @@ do_command(const string &command, const string ¶ms) { string new_name = params.substr(space + 1); CPPType *type = parser.parse_type(orig_name); - if (type == (CPPType *)NULL) { + if (type == nullptr) { nout << "Unknown type: renametype " << orig_name << "\n"; } else { type = type->resolve_type(&parser, &parser); @@ -164,7 +164,7 @@ do_command(const string &command, const string ¶ms) { } else if (command == "ignoretype") { // ignoretype explicitly ignores the given type. CPPType *type = parser.parse_type(params); - if (type == (CPPType *)NULL) { + if (type == nullptr) { nout << "Unknown type: ignoretype " << params << "\n"; } else { type = type->resolve_type(&parser, &parser); @@ -185,7 +185,7 @@ do_command(const string &command, const string ¶ms) { string constructor = params.substr(space + 1); CPPType *type = parser.parse_type(class_name); - if (type == (CPPType *)NULL) { + if (type == nullptr) { nout << "Unknown type: defconstruct " << class_name << "\n"; } else { type = type->resolve_type(&parser, &parser); @@ -254,10 +254,10 @@ build() { ci != _forcetype.end(); ++ci) { CPPType *type = parser.parse_type(*ci); - if (type == NULL) { + if (type == nullptr) { cerr << "Failure to parse forcetype " << *ci << "\n"; } - assert(type != (CPPType *)NULL); + assert(type != nullptr); get_type(type, true); } @@ -274,7 +274,7 @@ build() { scan_function(inst); } else { // Here's a data element declaration. - scan_element(inst, (CPPStructType *)NULL, &parser); + scan_element(inst, nullptr, &parser); } } else if ((*di)->get_subtype() == CPPDeclaration::ST_typedef) { @@ -511,7 +511,7 @@ write_code(ostream &out_code,ostream * out_include, InterrogateModuleDef *def) { << " \"" << def->library_name << "\", /* library_name */\n" << " \"" << def->library_hash_name << "\", /* library_hash_name */\n" << " \"" << def->module_name << "\", /* module_name */\n"; - if (def->database_filename != (const char *)NULL) { + if (def->database_filename != nullptr) { out_code << " \"" << def->database_filename << "\", /* database_filename */\n"; } else { @@ -921,17 +921,17 @@ bool InterrogateBuilder:: is_inherited_published(CPPInstance *function, CPPStructType *struct_type) { nassertr(struct_type->_derivation.size() == 1, false); CPPStructType *base = struct_type->_derivation[0]._base->as_struct_type(); - nassertr(base != (CPPStructType *)NULL, false); + nassertr(base != nullptr, false); CPPScope *base_scope = base->get_scope(); CPPDeclaration *symbol = base_scope->find_symbol(function->get_simple_name(), true); - if (symbol == (CPPDeclaration *)NULL) { + if (symbol == nullptr) { // Couldn't find the inherited function. return false; } CPPFunctionGroup *fgroup = symbol->as_function_group(); - if (fgroup == (CPPFunctionGroup *)NULL) { + if (fgroup == nullptr) { // Weird, it wasn't a function. return false; } @@ -1000,22 +1000,22 @@ scan_function(CPPFunctionGroup *fgroup) { */ void InterrogateBuilder:: scan_function(CPPInstance *function) { - assert(function != (CPPInstance *)NULL); - assert(function->_type != (CPPType *)NULL && function->_type->as_function_type() != (CPPFunctionType *)NULL); + assert(function != nullptr); + assert(function->_type != nullptr && function->_type->as_function_type() != nullptr); CPPFunctionType *ftype = function->_type->resolve_type(&parser, &parser)->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); CPPScope *scope = &parser; if (function->is_scoped()) { scope = function->get_scope(&parser, &parser); - if (scope == (CPPScope *)NULL) { + if (scope == nullptr) { // Invalid scope. nout << "Invalid scope: " << *function->_ident << "\n"; return; } - if (scope->get_struct_type() != (CPPStructType *)NULL) { + if (scope->get_struct_type() != nullptr) { // Wait, this is a method, not a function. This must be the declaration // for the method (since it's appearing out-of-scope). We don't need to // define a new method for it, but we'd like to update the comment, if @@ -1070,7 +1070,7 @@ scan_function(CPPInstance *function) { } get_function(function, "", - (CPPStructType *)NULL, scope, + nullptr, scope, InterrogateFunction::F_global); } @@ -1079,7 +1079,7 @@ scan_function(CPPInstance *function) { */ void InterrogateBuilder:: scan_struct_type(CPPStructType *type) { - if (type == (CPPStructType *)NULL) { + if (type == nullptr) { return; } @@ -1129,7 +1129,7 @@ scan_struct_type(CPPStructType *type) { */ void InterrogateBuilder:: scan_enum_type(CPPEnumType *type) { - if (type == (CPPEnumType *)NULL) { + if (type == nullptr) { return; } @@ -1163,7 +1163,7 @@ scan_enum_type(CPPEnumType *type) { */ void InterrogateBuilder:: scan_typedef_type(CPPTypedefType *type) { - if (type == (CPPTypedefType *)NULL) { + if (type == nullptr) { return; } @@ -1202,7 +1202,7 @@ scan_typedef_type(CPPTypedefType *type) { } CPPStructType *struct_type = wrapped_type->as_struct_type(); - if (struct_type == (CPPStructType *)NULL) { + if (struct_type == nullptr) { // We only export typedefs to structs, for now. return; } @@ -1247,7 +1247,7 @@ scan_typedef_type(CPPTypedefType *type) { */ void InterrogateBuilder:: scan_manifest(CPPManifest *manifest) { - if (manifest == (CPPManifest *)NULL) { + if (manifest == nullptr) { return; } @@ -1278,7 +1278,7 @@ scan_manifest(CPPManifest *manifest) { imanifest._definition = manifest->expand(); CPPType *type = manifest->determine_type(); - if (type != (CPPType *)NULL) { + if (type != nullptr) { imanifest._flags |= InterrogateManifest::F_has_type; imanifest._type = get_type(type, false); @@ -1292,8 +1292,8 @@ scan_manifest(CPPManifest *manifest) { } else { // We have a more complex expression. Generate a getter function. FunctionIndex getter = - get_getter(type, manifest->_name, (CPPStructType *)NULL, &parser, - (CPPInstance *)NULL); + get_getter(type, manifest->_name, nullptr, &parser, + nullptr); if (getter != 0) { imanifest._flags |= InterrogateManifest::F_has_getter; @@ -1313,7 +1313,7 @@ scan_manifest(CPPManifest *manifest) { ElementIndex InterrogateBuilder:: scan_element(CPPInstance *element, CPPStructType *struct_type, CPPScope *scope) { - if (element == (CPPInstance *)NULL) { + if (element == nullptr) { return 0; } @@ -1336,7 +1336,7 @@ scan_element(CPPInstance *element, CPPStructType *struct_type, return 0; } - if (struct_type == NULL && + if (struct_type == nullptr && (element->_file._source != CPPFile::S_local || in_ignorefile(element->_file._filename_as_referenced))) { // The element is defined in some other package or in an ignorable file. @@ -1368,7 +1368,7 @@ scan_element(CPPInstance *element, CPPStructType *struct_type, ielement._scoped_name = descope(element->get_local_name(&parser)); // See if there happens to be a comment before the element. - if (element->_leading_comment != (CPPCommentBlock *)NULL) { + if (element->_leading_comment != nullptr) { ielement._comment = trim_blanks(element->_leading_comment->_comment); } @@ -1382,7 +1382,7 @@ scan_element(CPPInstance *element, CPPStructType *struct_type, // We can only generate a getter and a setter if we can talk about the // type it is. - if (parameter_type->as_struct_type() != (CPPStructType *)NULL) { + if (parameter_type->as_struct_type() != nullptr) { // Wrap the type in a const reference. parameter_type = TypeManager::wrap_const_reference(parameter_type); } @@ -1407,7 +1407,7 @@ scan_element(CPPInstance *element, CPPStructType *struct_type, } } - if (struct_type == (CPPStructType *)NULL) { + if (struct_type == nullptr) { // This is a global data element: not a data member. ielement._flags |= InterrogateElement::F_global; } @@ -1432,9 +1432,9 @@ get_getter(CPPType *expr_type, string expression, // Unroll the "const" from the expr_type, since that doesn't matter for a // return type. - while (expr_type->as_const_type() != (CPPConstType *)NULL) { + while (expr_type->as_const_type() != nullptr) { expr_type = expr_type->as_const_type()->_wrapped_around; - assert(expr_type != (CPPType *)NULL); + assert(expr_type != nullptr); } // We can't return an array from a function, but we can decay it into a @@ -1453,10 +1453,10 @@ get_getter(CPPType *expr_type, string expression, int getter_flags = InterrogateFunction::F_getter; - if (struct_type != (CPPStructType *)NULL) { + if (struct_type != nullptr) { // This is a data member for some class. - assert(element != (CPPInstance *)NULL); - assert(scope != (CPPScope *)NULL); + assert(element != nullptr); + assert(scope != nullptr); if ((element->_storage_class & CPPInstance::SC_static) != 0) { // This is a static data member; therefore, the synthesized getter is @@ -1487,8 +1487,8 @@ get_getter(CPPType *expr_type, string expression, ostringstream desc; desc << "getter for "; - if (element != (CPPInstance *)NULL) { - element->_initializer = (CPPExpression *)NULL; + if (element != nullptr) { + element->_initializer = nullptr; element->output(desc, 0, &parser, false); desc << ";"; } else { @@ -1530,10 +1530,10 @@ get_setter(CPPType *expr_type, string expression, int setter_flags = InterrogateFunction::F_setter; - if (struct_type != (CPPStructType *)NULL) { + if (struct_type != nullptr) { // This is a data member for some class. - assert(element != (CPPInstance *)NULL); - assert(scope != (CPPScope *)NULL); + assert(element != nullptr); + assert(scope != nullptr); if ((element->_storage_class & CPPInstance::SC_static) != 0) { // This is a static data member; therefore, the synthesized setter is @@ -1560,8 +1560,8 @@ get_setter(CPPType *expr_type, string expression, ostringstream desc; desc << "setter for "; - if (element != (CPPInstance *)NULL) { - element->_initializer = (CPPExpression *)NULL; + if (element != nullptr) { + element->_initializer = nullptr; element->output(desc, 0, &parser, false); desc << ";"; } else { @@ -1590,7 +1590,7 @@ get_cast_function(CPPType *to_type, CPPType *from_type, CPPStructType *struct_type = from_type->as_struct_type(); CPPScope *scope = &parser; - if (struct_type != (CPPStructType *)NULL) { + if (struct_type != nullptr) { // We'll make this a method of the from type. scope = struct_type->get_scope(); @@ -1666,14 +1666,14 @@ get_function(CPPInstance *function, string description, function->_type = ftype; if ((ftype->_flags & CPPFunctionType::F_constructor) && - struct_type != (CPPStructType *)NULL && + struct_type != nullptr && struct_type->is_abstract()) { // This is a constructor for an abstract class; forget it. return 0; } TypeIndex class_index = 0; - if (struct_type != (CPPStructType *)NULL) { + if (struct_type != nullptr) { class_index = get_type(struct_type, false); } @@ -1714,7 +1714,7 @@ get_function(CPPInstance *function, string description, } // Also set the comment. - if (function->_leading_comment != (CPPCommentBlock *)NULL) { + if (function->_leading_comment != nullptr) { string comment = trim_blanks(function->_leading_comment->_comment); if (!ifunction._comment.empty()) { ifunction._comment += "\n\n"; @@ -1722,7 +1722,7 @@ get_function(CPPInstance *function, string description, ifunction._comment += comment; // And update the particular wrapper comment. - if ((*ii).second->_leading_comment == NULL || + if ((*ii).second->_leading_comment == nullptr || function->_leading_comment->_comment.length() > (*ii).second->_leading_comment->_comment.length()) { (*ii).second->_leading_comment = function->_leading_comment; @@ -1742,7 +1742,7 @@ get_function(CPPInstance *function, string description, ifunction->_scoped_name = descope(function->get_local_name(&parser)); ifunction->_instances = new InterrogateFunction::Instances; - if (function->_leading_comment != (CPPCommentBlock *)NULL) { + if (function->_leading_comment != nullptr) { ifunction->_comment = trim_blanks(function->_leading_comment->_comment); } @@ -1751,7 +1751,7 @@ get_function(CPPInstance *function, string description, prototype << ";"; ifunction->_prototype = prototype.str(); - if (struct_type != (CPPStructType *)NULL) { + if (struct_type != nullptr) { // The function is a method. ifunction->_flags |= InterrogateFunction::F_method; ifunction->_class = class_index; @@ -1844,19 +1844,19 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP } // Find the getter so we can get its return type. - CPPInstance *getter = NULL; - CPPType *return_type = NULL; + CPPInstance *getter = nullptr; + CPPType *return_type = nullptr; // How many arguments we expect the getter to have. size_t num_args = (size_t)(make_property->_type != CPPMakeProperty::T_normal); fgroup = make_property->_get_function; - if (fgroup != NULL) { + if (fgroup != nullptr) { CPPFunctionGroup::Instances::const_iterator fi; for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) { CPPInstance *function = (*fi); CPPFunctionType *ftype = function->_type->as_function_type(); - if (ftype == NULL) { + if (ftype == nullptr) { continue; } @@ -1879,7 +1879,7 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP // The getter must either take no arguments, or all defaults. if (params.size() == expected_num_args || (params.size() > expected_num_args && - params[expected_num_args]->_initializer != NULL)) { + params[expected_num_args]->_initializer != nullptr)) { // If this is a sequence getter, it must take an index argument. if (make_property->_type == CPPMakeProperty::T_sequence && !TypeManager::is_integer(params[index_arg]->_type)) { @@ -1897,7 +1897,7 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP } } - if (getter == NULL || return_type == NULL) { + if (getter == nullptr || return_type == nullptr) { cerr << "No instance of getter '" << fgroup->_name << "' is suitable!\n"; return 0; @@ -1905,10 +1905,10 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP } // Find the "hasser". - CPPInstance *hasser = NULL; + CPPInstance *hasser = nullptr; fgroup = make_property->_has_function; - if (fgroup != NULL) { + if (fgroup != nullptr) { CPPFunctionGroup::Instances::const_iterator fi; for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) { CPPInstance *function = (*fi); @@ -1929,10 +1929,10 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP } // And the "deleter". - CPPInstance *deleter = NULL; + CPPInstance *deleter = nullptr; fgroup = make_property->_del_function; - if (fgroup != NULL) { + if (fgroup != nullptr) { CPPFunctionGroup::Instances::const_iterator fi; for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) { CPPInstance *function = (*fi); @@ -2011,7 +2011,7 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP InterrogateElement &iproperty = idb->update_element(index); - if (return_type != NULL) { + if (return_type != nullptr) { TypeIndex return_index = get_type(TypeManager::unwrap_reference(return_type), false); if (iproperty._type != 0 && iproperty._type != return_index) { cerr << "Property " << property_name << " has inconsistent element type!\n"; @@ -2032,7 +2032,7 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP } if (make_property->_type == CPPMakeProperty::T_normal) { - if (getter != NULL) { + if (getter != nullptr) { iproperty._flags |= InterrogateElement::F_has_getter; iproperty._getter = get_function(getter, "", struct_type, struct_type->get_scope(), 0); @@ -2060,28 +2060,28 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP ifunction._instances->insert(InterrogateFunction::Instances::value_type(signature, getter)); } - if (hasser != NULL) { + if (hasser != nullptr) { iproperty._flags |= InterrogateElement::F_has_has_function; iproperty._has_function = get_function(hasser, "", struct_type, struct_type->get_scope(), 0); nassertr(iproperty._has_function, 0); } - if (deleter != NULL) { + if (deleter != nullptr) { iproperty._flags |= InterrogateElement::F_has_del_function; iproperty._del_function = get_function(deleter, "", struct_type, struct_type->get_scope(), 0); nassertr(iproperty._del_function, 0); } - if (inserter != NULL) { + if (inserter != nullptr) { iproperty._flags |= InterrogateElement::F_has_insert_function; iproperty._insert_function = get_function(inserter, "", struct_type, struct_type->get_scope(), 0); nassertr(iproperty._insert_function, 0); } - if (getkey_function != NULL) { + if (getkey_function != nullptr) { iproperty._flags |= InterrogateElement::F_has_getkey_function; iproperty._getkey_function = get_function(getkey_function, "", struct_type, struct_type->get_scope(), 0); @@ -2089,17 +2089,17 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP } // See if there happens to be a comment before the MAKE_PROPERTY macro. - if (make_property->_leading_comment != (CPPCommentBlock *)NULL) { + if (make_property->_leading_comment != nullptr) { iproperty._comment = trim_blanks(make_property->_leading_comment->_comment); - } else if (getter->_leading_comment != (CPPCommentBlock *)NULL) { + } else if (getter->_leading_comment != nullptr) { // Take the comment from the getter. iproperty._comment = trim_blanks(getter->_leading_comment->_comment); } // Now look for setters. fgroup = make_property->_set_function; - if (fgroup != NULL) { + if (fgroup != nullptr) { CPPFunctionGroup::Instances::const_iterator fi; for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) { CPPInstance *function = (*fi); @@ -2112,7 +2112,7 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP } fgroup = make_property->_clear_function; - if (fgroup != NULL) { + if (fgroup != nullptr) { CPPFunctionGroup::Instances::const_iterator fi; for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) { CPPInstance *function = (*fi); @@ -2148,12 +2148,12 @@ get_make_seq(CPPMakeSeq *make_seq, CPPStructType *struct_type) { CPPFunctionGroup::Instances::const_iterator fi; CPPFunctionGroup *fgroup = make_seq->_length_getter; - if (fgroup != NULL) { + if (fgroup != nullptr) { for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) { CPPInstance *function = (*fi); CPPFunctionType *ftype = function->_type->as_function_type(); - if (ftype != NULL) { + if (ftype != nullptr) { length_getter = get_function(function, "", struct_type, struct_type->get_scope(), 0); if (length_getter != 0) { @@ -2172,12 +2172,12 @@ get_make_seq(CPPMakeSeq *make_seq, CPPStructType *struct_type) { } fgroup = make_seq->_element_getter; - if (fgroup != NULL) { + if (fgroup != nullptr) { for (fi = fgroup->_instances.begin(); fi != fgroup->_instances.end(); ++fi) { CPPInstance *function = (*fi); CPPFunctionType *ftype = function->_type->as_function_type(); - if (ftype != NULL && ftype->_parameters->_parameters.size() >= 1 && + if (ftype != nullptr && ftype->_parameters->_parameters.size() >= 1 && TypeManager::is_integer(ftype->_parameters->_parameters[0]->_type)) { // It really doesn't matter whether we grab the const or non-const // version, since they should all return the same function anyway. @@ -2211,7 +2211,7 @@ get_make_seq(CPPMakeSeq *make_seq, CPPStructType *struct_type) { imake_seq._element_getter = element_getter; // See if there happens to be a comment before the MAKE_SEQ macro. - if (make_seq->_leading_comment != (CPPCommentBlock *)NULL) { + if (make_seq->_leading_comment != nullptr) { imake_seq._comment = trim_blanks(make_seq->_leading_comment->_comment); } @@ -2336,21 +2336,21 @@ get_type(CPPType *type, bool global) { itype._true_name = true_name; itype._cpptype = type; - if (type->_declaration != (CPPTypeDeclaration *)NULL) { + if (type->_declaration != nullptr) { // This type has a declaration; does the declaration have a comment? CPPTypeDeclaration *decl = type->_declaration; - if (decl->_leading_comment != (CPPCommentBlock *)NULL) { + if (decl->_leading_comment != nullptr) { itype._comment = trim_blanks(decl->_leading_comment->_comment); } } - CPPScope *scope = NULL; + CPPScope *scope = nullptr; // If it's an extension type or typedef, it might be scoped. if (CPPTypedefType *td_type = type->as_typedef_type()) { scope = td_type->_ident->get_scope(&parser, &parser); } else if (CPPExtensionType *ext_type = type->as_extension_type()) { - if (ext_type->_ident != (CPPIdentifier *)NULL) { + if (ext_type->_ident != nullptr) { scope = ext_type->_ident->get_scope(&parser, &parser); } else if (CPPEnumType *enum_type = ext_type->as_enum_type()) { @@ -2360,11 +2360,11 @@ get_type(CPPType *type, bool global) { } - if (scope != (CPPScope *)NULL) { - while (scope->as_template_scope() != (CPPTemplateScope *)NULL) { + if (scope != nullptr) { + while (scope->as_template_scope() != nullptr) { assert(scope->get_parent_scope() != scope); scope = scope->get_parent_scope(); - assert(scope != (CPPScope *)NULL); + assert(scope != nullptr); } itype._cppscope = scope; @@ -2374,7 +2374,7 @@ get_type(CPPType *type, bool global) { descope(scope->get_local_name(&parser) + "::" + itype._name); CPPStructType *struct_type = scope->get_struct_type(); - if (struct_type != (CPPStructType *)NULL) { + if (struct_type != nullptr) { itype._flags |= InterrogateType::F_nested; itype._outer_class = get_type(struct_type, false); } @@ -2384,28 +2384,28 @@ get_type(CPPType *type, bool global) { if (forced || !in_ignoretype(true_name)) { itype._flags |= InterrogateType::F_fully_defined; - if (type->as_simple_type() != (CPPSimpleType *)NULL) { + if (type->as_simple_type() != nullptr) { define_atomic_type(itype, type->as_simple_type()); - } else if (type->as_pointer_type() != (CPPPointerType *)NULL) { + } else if (type->as_pointer_type() != nullptr) { define_wrapped_type(itype, type->as_pointer_type()); - } else if (type->as_const_type() != (CPPConstType *)NULL) { + } else if (type->as_const_type() != nullptr) { define_wrapped_type(itype, type->as_const_type()); - } else if (type->as_struct_type() != (CPPStructType *)NULL) { + } else if (type->as_struct_type() != nullptr) { define_struct_type(itype, type->as_struct_type(), index, forced); - } else if (type->as_enum_type() != (CPPEnumType *)NULL) { + } else if (type->as_enum_type() != nullptr) { define_enum_type(itype, type->as_enum_type()); - } else if (type->as_extension_type() != (CPPExtensionType *)NULL) { + } else if (type->as_extension_type() != nullptr) { define_extension_type(itype, type->as_extension_type()); - } else if (type->as_typedef_type() != (CPPTypedefType *)NULL) { + } else if (type->as_typedef_type() != nullptr) { define_typedef_type(itype, type->as_typedef_type()); - } else if (type->as_array_type() != (CPPArrayType *)NULL) { + } else if (type->as_array_type() != nullptr) { define_array_type(itype, type->as_array_type()); } else { @@ -2532,7 +2532,7 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, } cpptype = TypeManager::resolve_type(cpptype)->as_struct_type(); - assert(cpptype != (CPPStructType *)NULL); + assert(cpptype != nullptr); bool has_virt_methods = cpptype->is_polymorphic(); switch (cpptype->_type) { @@ -2604,7 +2604,7 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, TypeIndex base_index = get_type(base_type, false); if (base_index == 0) { - if (base_type != NULL) { + if (base_type != nullptr) { nout << *cpptype << " reports a derivation from invalid type " << *base_type << ".\n"; } else { nout << *cpptype << " reports a derivation from an invalid type.\n"; @@ -2637,7 +2637,7 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, // (For many compilers, this does not require a pointer change.) generate_casts = true; - } else if (has_virt_methods && (base_type->as_struct_type() == (CPPStructType *)NULL || !base_type->as_struct_type()->is_polymorphic())) { + } else if (has_virt_methods && (base_type->as_struct_type() == nullptr || !base_type->as_struct_type()->is_polymorphic())) { // Finally, if this class has virtual methods, but its parent // doesn't, then we have to upcast (because this class will require // space for a virtual function table pointer, while the parent @@ -2686,17 +2686,17 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, CPPType *type = (*di)->as_type_declaration()->_type; if ((*di)->_vis <= min_vis || in_forcetype(type->get_local_name(&parser))) { - if (type->as_struct_type() != (CPPStructType *)NULL || - type->as_enum_type() != (CPPEnumType *)NULL) { + if (type->as_struct_type() != nullptr || + type->as_enum_type() != nullptr) { // Here's a nested class or enum definition. type->_vis = (*di)->_vis; CPPExtensionType *nested_type = type->as_extension_type(); - assert(nested_type != (CPPExtensionType *)NULL); + assert(nested_type != nullptr); // For now, we don't allow anonymous structs. - if (nested_type->_ident != (CPPIdentifier *)NULL || - nested_type->as_enum_type() != (CPPEnumType *)NULL) { + if (nested_type->_ident != nullptr || + nested_type->as_enum_type() != nullptr) { TypeIndex nested_index = get_type(nested_type, false); itype._nested_types.push_back(nested_index); } @@ -2722,7 +2722,7 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, } CPPStructType *struct_type = wrapped_type->as_struct_type(); - if (struct_type != (CPPStructType *)NULL) { + if (struct_type != nullptr) { // We only export typedefs to structs, for now. if (type->_vis <= min_vis) { @@ -2745,7 +2745,7 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, // See if we need to generate an implicit default constructor. CPPFunctionGroup *constructor = cpptype->get_constructor(); - if (constructor == (CPPFunctionGroup *)NULL && cpptype->is_default_constructible()) { + if (constructor == nullptr && cpptype->is_default_constructible()) { // Make a default constructor. CPPType *void_type = TypeManager::get_void_type(); CPPParameterList *params = new CPPParameterList; @@ -2765,11 +2765,11 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, // See if we need to generate an implicit copy constructor. CPPInstance *copy_constructor = cpptype->get_copy_constructor(); - if (copy_constructor == (CPPInstance *)NULL && + if (copy_constructor == nullptr && cpptype->is_copy_constructible()) { // Make an implicit copy constructor. CPPType *const_ref_type = TypeManager::wrap_const_reference(cpptype); - CPPInstance *param = new CPPInstance(const_ref_type, NULL); + CPPInstance *param = new CPPInstance(const_ref_type, nullptr); CPPType *void_type = TypeManager::get_void_type(); CPPParameterList *params = new CPPParameterList; @@ -2836,7 +2836,7 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, */ void InterrogateBuilder:: update_function_comment(CPPInstance *function, CPPScope *scope) { - if (function->_leading_comment == (CPPCommentBlock *)NULL) { + if (function->_leading_comment == nullptr) { // No comment anyway. Forget it. return; } @@ -2881,7 +2881,7 @@ update_function_comment(CPPInstance *function, CPPScope *scope) { InterrogateFunction::Instances::iterator ii = ifunction._instances->find(function_signature); if (ii != ifunction._instances->end()) { - if ((*ii).second->_leading_comment == NULL || + if ((*ii).second->_leading_comment == nullptr || function->_leading_comment->_comment.length() > (*ii).second->_leading_comment->_comment.length()) { (*ii).second->_leading_comment = function->_leading_comment; @@ -2910,9 +2910,9 @@ define_method(CPPFunctionGroup *fgroup, InterrogateType &itype, void InterrogateBuilder:: define_method(CPPInstance *function, InterrogateType &itype, CPPStructType *struct_type, CPPScope *scope) { - assert(function != (CPPInstance *)NULL); - assert(function->_type != (CPPType *)NULL && - function->_type->as_function_type() != (CPPFunctionType *)NULL); + assert(function != nullptr); + assert(function->_type != nullptr && + function->_type->as_function_type() != nullptr); CPPFunctionType *ftype = function->_type->resolve_type(scope, &parser)->as_function_type(); @@ -3033,7 +3033,7 @@ define_enum_type(InterrogateType &itype, CPPEnumType *cpptype) { itype._flags |= InterrogateType::F_enum; CPPScope *scope = cpptype->_parent_scope; - if (cpptype->_ident != (CPPIdentifier *)NULL) { + if (cpptype->_ident != nullptr) { scope = cpptype->_ident->get_scope(&parser, &parser); } @@ -3070,11 +3070,11 @@ define_enum_type(InterrogateType &itype, CPPEnumType *cpptype) { evalue._name = element->get_simple_name(); evalue._scoped_name = descope(element->get_local_name(&parser)); - if (element->_leading_comment != (CPPCommentBlock *)NULL) { + if (element->_leading_comment != nullptr) { evalue._comment = trim_blanks(element->_leading_comment->_comment); } - if (element->_initializer != (CPPExpression *)NULL) { + if (element->_initializer != nullptr) { CPPExpression::Result result = element->_initializer->evaluate(); if (result._type == CPPExpression::RT_error) { @@ -3110,7 +3110,7 @@ define_array_type(InterrogateType &itype, CPPArrayType *cpptype) { itype._flags |= InterrogateType::F_array; itype._wrapped_type = get_type(cpptype->_element_type, false); - if (cpptype->_bounds == NULL) { + if (cpptype->_bounds == nullptr) { // This indicates an unsized array. itype._array_size = -1; } else { diff --git a/dtool/src/interrogate/interrogate_module.cxx b/dtool/src/interrogate/interrogate_module.cxx index 0cb7703fd0..dfe8f3a1b5 100644 --- a/dtool/src/interrogate/interrogate_module.cxx +++ b/dtool/src/interrogate/interrogate_module.cxx @@ -52,15 +52,15 @@ enum CommandOptions { }; static struct option long_options[] = { - { "oc", required_argument, NULL, CO_oc }, - { "module", required_argument, NULL, CO_module }, - { "library", required_argument, NULL, CO_library }, - { "c", no_argument, NULL, CO_c }, - { "python", no_argument, NULL, CO_python }, - { "python-native", no_argument, NULL, CO_python_native }, - { "track-interpreter", no_argument, NULL, CO_track_interpreter }, - { "import", required_argument, NULL, CO_import }, - { NULL } + { "oc", required_argument, nullptr, CO_oc }, + { "module", required_argument, nullptr, CO_module }, + { "library", required_argument, nullptr, CO_library }, + { "c", no_argument, nullptr, CO_c }, + { "python", no_argument, nullptr, CO_python }, + { "python-native", no_argument, nullptr, CO_python_native }, + { "track-interpreter", no_argument, nullptr, CO_track_interpreter }, + { "import", required_argument, nullptr, CO_import }, + { nullptr } }; /* @@ -545,7 +545,7 @@ int main(int argc, char *argv[]) { pystub(); preprocess_argv(argc, argv); - flag = getopt_long_only(argc, argv, short_options, long_options, NULL); + flag = getopt_long_only(argc, argv, short_options, long_options, nullptr); while (flag != EOF) { switch (flag) { case CO_oc: @@ -583,7 +583,7 @@ int main(int argc, char *argv[]) { default: exit(1); } - flag = getopt_long_only(argc, argv, short_options, long_options, NULL); + flag = getopt_long_only(argc, argv, short_options, long_options, nullptr); } argc -= (optind-1); @@ -617,7 +617,7 @@ int main(int argc, char *argv[]) { pathname.set_type(Filename::T_dso); nout << "Loading " << pathname << "\n"; void *dl = load_dso(DSearchPath(), pathname); - if (dl == NULL) { + if (dl == nullptr) { nout << "Unable to load: " << load_dso_error() << "\n"; exit(1); } diff --git a/dtool/src/interrogate/parameterRemap.I b/dtool/src/interrogate/parameterRemap.I index 4b3040e514..dac104e87f 100644 --- a/dtool/src/interrogate/parameterRemap.I +++ b/dtool/src/interrogate/parameterRemap.I @@ -20,8 +20,8 @@ ParameterRemap(CPPType *orig_type) : _new_type(orig_type) { _is_valid = true; - _temporary_type = (CPPType *)NULL; - _default_value = (CPPExpression *)NULL; + _temporary_type = nullptr; + _default_value = nullptr; } /** @@ -57,7 +57,7 @@ get_new_type() const { */ INLINE CPPType *ParameterRemap:: get_temporary_type() const { - if (_temporary_type == (CPPType *)NULL) { + if (_temporary_type == nullptr) { return _new_type; } else { return _temporary_type; @@ -69,7 +69,7 @@ get_temporary_type() const { */ INLINE bool ParameterRemap:: has_default_value() const { - return (_default_value != (CPPExpression *)NULL); + return (_default_value != nullptr); } /** diff --git a/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx b/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx index 8c9c247ac7..d2ea916fff 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx +++ b/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx @@ -21,8 +21,8 @@ ParameterRemapBasicStringPtrToString:: ParameterRemapBasicStringPtrToString(CPPType *orig_type) : ParameterRemapToString(orig_type) { - static CPPType *const_char_star_type = (CPPType *)NULL; - if (const_char_star_type == (CPPType *)NULL) { + static CPPType *const_char_star_type = nullptr; + if (const_char_star_type == nullptr) { const_char_star_type = parser.parse_type("const char *"); } @@ -54,8 +54,8 @@ ParameterRemapBasicWStringPtrToWString:: ParameterRemapBasicWStringPtrToWString(CPPType *orig_type) : ParameterRemapToWString(orig_type) { - static CPPType *const_wchar_star_type = (CPPType *)NULL; - if (const_wchar_star_type == (CPPType *)NULL) { + static CPPType *const_wchar_star_type = nullptr; + if (const_wchar_star_type == nullptr) { const_wchar_star_type = parser.parse_type("const wchar_t *"); } diff --git a/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx b/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx index a94055f899..0e5bac31ff 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx +++ b/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx @@ -21,8 +21,8 @@ ParameterRemapBasicStringRefToString:: ParameterRemapBasicStringRefToString(CPPType *orig_type) : ParameterRemapToString(orig_type) { - static CPPType *const_char_star_type = (CPPType *)NULL; - if (const_char_star_type == (CPPType *)NULL) { + static CPPType *const_char_star_type = nullptr; + if (const_char_star_type == nullptr) { const_char_star_type = parser.parse_type("const char *"); } @@ -54,8 +54,8 @@ ParameterRemapBasicWStringRefToWString:: ParameterRemapBasicWStringRefToWString(CPPType *orig_type) : ParameterRemapToWString(orig_type) { - static CPPType *const_wchar_star_type = (CPPType *)NULL; - if (const_wchar_star_type == (CPPType *)NULL) { + static CPPType *const_wchar_star_type = nullptr; + if (const_wchar_star_type == nullptr) { const_wchar_star_type = parser.parse_type("const wchar_t *"); } diff --git a/dtool/src/interrogate/parameterRemapBasicStringToString.cxx b/dtool/src/interrogate/parameterRemapBasicStringToString.cxx index db031004c6..d2ed1f0406 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringToString.cxx +++ b/dtool/src/interrogate/parameterRemapBasicStringToString.cxx @@ -22,8 +22,8 @@ ParameterRemapBasicStringToString:: ParameterRemapBasicStringToString(CPPType *orig_type) : ParameterRemapToString(orig_type) { - static CPPType *const_char_star_type = (CPPType *)NULL; - if (const_char_star_type == (CPPType *)NULL) { + static CPPType *const_char_star_type = nullptr; + if (const_char_star_type == nullptr) { const_char_star_type = parser.parse_type("const char *"); } @@ -68,8 +68,8 @@ ParameterRemapBasicWStringToWString:: ParameterRemapBasicWStringToWString(CPPType *orig_type) : ParameterRemapToWString(orig_type) { - static CPPType *const_wchar_star_type = (CPPType *)NULL; - if (const_wchar_star_type == (CPPType *)NULL) { + static CPPType *const_wchar_star_type = nullptr; + if (const_wchar_star_type == nullptr) { const_wchar_star_type = parser.parse_type("const wchar_t *"); } diff --git a/dtool/src/interrogate/parameterRemapPTToPointer.cxx b/dtool/src/interrogate/parameterRemapPTToPointer.cxx index 44f6a0d036..d4aefb71d2 100644 --- a/dtool/src/interrogate/parameterRemapPTToPointer.cxx +++ b/dtool/src/interrogate/parameterRemapPTToPointer.cxx @@ -29,23 +29,23 @@ ParameterRemapPTToPointer(CPPType *orig_type) : ParameterRemap(orig_type) { CPPStructType *pt_type = TypeManager::unwrap(_orig_type)->as_struct_type(); - assert(pt_type != (CPPStructType *)NULL); + assert(pt_type != nullptr); // A horrible hack around a CPPParser bug. We don't trust the CPPStructType // pointer we were given; instead, we ask CPPParser to parse a new type of // the same name. This has a better chance of fully resolving templates. string name = pt_type->get_local_name(&parser); CPPType *new_type = parser.parse_type(name); - if (new_type == (CPPType *)NULL) { + if (new_type == nullptr) { nout << "Type " << name << " is unknown to parser.\n"; } else { new_type = new_type->resolve_type(&parser, &parser); pt_type = new_type->as_struct_type(); - assert(pt_type != (CPPStructType *)NULL); + assert(pt_type != nullptr); } _pointer_type = TypeManager::get_pointer_type(pt_type); - if (_pointer_type == (CPPType *)NULL) { + if (_pointer_type == nullptr) { // If we couldn't figure out the pointer type, forget it. nout << "Couldn't figure out pointer type for " << *pt_type << "\n"; _is_valid = false; diff --git a/dtool/src/interrogate/parameterRemapToString.cxx b/dtool/src/interrogate/parameterRemapToString.cxx index fe7c7a8253..0a3abe4559 100644 --- a/dtool/src/interrogate/parameterRemapToString.cxx +++ b/dtool/src/interrogate/parameterRemapToString.cxx @@ -22,13 +22,13 @@ ParameterRemapToString:: ParameterRemapToString(CPPType *orig_type) : ParameterRemap(orig_type) { - static CPPType *char_star_type = (CPPType *)NULL; - if (char_star_type == (CPPType *)NULL) { + static CPPType *char_star_type = nullptr; + if (char_star_type == nullptr) { char_star_type = parser.parse_type("char *"); } - static CPPType *const_char_star_type = (CPPType *)NULL; - if (const_char_star_type == (CPPType *)NULL) { + static CPPType *const_char_star_type = nullptr; + if (const_char_star_type == nullptr) { const_char_star_type = parser.parse_type("const char *"); } @@ -75,8 +75,8 @@ ParameterRemapToWString:: ParameterRemapToWString(CPPType *orig_type) : ParameterRemap(orig_type) { - static CPPType *char_star_type = (CPPType *)NULL; - if (char_star_type == (CPPType *)NULL) { + static CPPType *char_star_type = nullptr; + if (char_star_type == nullptr) { char_star_type = parser.parse_type("const wchar_t *"); } diff --git a/dtool/src/interrogate/parse_file.cxx b/dtool/src/interrogate/parse_file.cxx index f20986022a..f7341b306e 100644 --- a/dtool/src/interrogate/parse_file.cxx +++ b/dtool/src/interrogate/parse_file.cxx @@ -48,10 +48,10 @@ predefine_macro(CPPParser &parser, const string &option) { void show_type_or_expression(const string &str) { CPPExpression *expr = parser.parse_expr(str); - if (expr != NULL) { + if (expr != nullptr) { cout << "\nExpression: " << *expr << "\n"; CPPType *type = expr->determine_type(); - if (type == NULL) { + if (type == nullptr) { cout << "type is unknown\n"; } else { cout << "type is " << *type << "\n"; @@ -60,13 +60,13 @@ show_type_or_expression(const string &str) { } else { CPPType *type = parser.parse_type(str); - if (type != NULL) { + if (type != nullptr) { cout << "\nType: " << *type << "\n" << "Defined in: " << type->_file << "\n" << "Subtype code is: " << (int)type->get_subtype() << "\n\n"; CPPStructType *stype = type->as_struct_type(); - if (stype != (CPPStructType *)NULL) { + if (stype != nullptr) { stype->check_virtual(); } @@ -84,7 +84,7 @@ show_type_or_expression(const string &str) { << "get_preferred_name = " << type->get_preferred_name() << "\n" << "is_incomplete = " << type->is_incomplete() << "\n"; - if (stype != (CPPStructType *)NULL) { + if (stype != nullptr) { cout << "scope = " << stype->get_scope()->get_fully_scoped_name() << "\n"; bool is_abstract = stype->is_abstract(); cout << "is_abstract = " << is_abstract << "\n"; @@ -109,19 +109,19 @@ show_type_or_expression(const string &str) { void show_methods(const string &str) { CPPType *type = parser.parse_type(str); - if (type == NULL) { + if (type == nullptr) { cerr << "Invalid type: " << str << "\n"; return; } CPPStructType *stype = type->as_struct_type(); - if (stype == NULL) { + if (stype == nullptr) { cerr << "Type is not a structure or class.\n"; return; } CPPScope *scope = stype->get_scope(); - assert(scope != (CPPScope *)NULL); + assert(scope != nullptr); cerr << "Methods in " << *stype << ":\n"; @@ -142,19 +142,19 @@ show_methods(const string &str) { void show_data_members(const string &str) { CPPType *type = parser.parse_type(str); - if (type == NULL) { + if (type == nullptr) { cerr << "Invalid type: " << str << "\n"; return; } CPPStructType *stype = type->as_struct_type(); - if (stype == NULL) { + if (stype == nullptr) { cerr << "Type is not a structure or class.\n"; return; } CPPScope *scope = stype->get_scope(); - assert(scope != (CPPScope *)NULL); + assert(scope != nullptr); cerr << "Data members in " << *stype << ":\n"; @@ -168,19 +168,19 @@ show_data_members(const string &str) { void show_nested_types(const string &str) { CPPType *type = parser.parse_type(str); - if (type == NULL) { + if (type == nullptr) { cerr << "Invalid type: " << str << "\n"; return; } CPPStructType *stype = type->as_struct_type(); - if (stype == NULL) { + if (stype == nullptr) { cerr << "Type is not a structure or class.\n"; return; } CPPScope *scope = stype->get_scope(); - assert(scope != (CPPScope *)NULL); + assert(scope != nullptr); cerr << "Nested types in " << *stype << ":\n"; diff --git a/dtool/src/interrogate/typeManager.cxx b/dtool/src/interrogate/typeManager.cxx index 1485c785ca..d1d8b650b0 100644 --- a/dtool/src/interrogate/typeManager.cxx +++ b/dtool/src/interrogate/typeManager.cxx @@ -37,7 +37,7 @@ */ CPPType *TypeManager:: resolve_type(CPPType *type, CPPScope *scope) { - if (scope == (CPPScope *)NULL) { + if (scope == nullptr) { scope = &parser; } @@ -550,7 +550,7 @@ is_char(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return simple_type->_type == CPPSimpleType::T_char && simple_type->_flags == 0; @@ -581,7 +581,7 @@ is_unsigned_char(CPPType *type) { { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return (simple_type->_type == CPPSimpleType::T_char) && (simple_type->_flags & CPPSimpleType::F_unsigned) != 0; @@ -613,7 +613,7 @@ is_signed_char(CPPType *type) { { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return (simple_type->_type == CPPSimpleType::T_char) && (simple_type->_flags & CPPSimpleType::F_signed) != 0; @@ -717,7 +717,7 @@ is_const_unsigned_char_pointer(CPPType *type) { bool TypeManager:: is_basic_string_char(CPPType *type) { CPPType *string_type = get_basic_string_char_type(); - if (string_type != (CPPType *)NULL && + if (string_type != nullptr && string_type->get_local_name(&parser) == type->get_local_name(&parser)) { return true; } @@ -822,7 +822,7 @@ is_wchar(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return simple_type->_type == CPPSimpleType::T_wchar_t; } } @@ -865,7 +865,7 @@ is_wchar_pointer(CPPType *type) { bool TypeManager:: is_basic_string_wchar(CPPType *type) { CPPType *string_type = get_basic_string_wchar_type(); - if (string_type != (CPPType *)NULL && + if (string_type != nullptr && string_type->get_local_name(&parser) == type->get_local_name(&parser)) { return true; } @@ -1030,7 +1030,7 @@ is_bool(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return simple_type->_type == CPPSimpleType::T_bool; } @@ -1063,7 +1063,7 @@ is_integer(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return (simple_type->_type == CPPSimpleType::T_bool || simple_type->_type == CPPSimpleType::T_char || @@ -1098,7 +1098,7 @@ is_unsigned_integer(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return ((simple_type->_type == CPPSimpleType::T_bool || simple_type->_type == CPPSimpleType::T_char || @@ -1187,7 +1187,7 @@ is_long(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return (simple_type->_type == CPPSimpleType::T_int && (simple_type->_flags & CPPSimpleType::F_long) != 0); } @@ -1217,7 +1217,7 @@ is_short(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return (simple_type->_type == CPPSimpleType::T_int && (simple_type->_flags & CPPSimpleType::F_short) != 0); } @@ -1246,7 +1246,7 @@ is_unsigned_short(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return (simple_type->_type == CPPSimpleType::T_int && (simple_type->_flags & (CPPSimpleType::F_short | CPPSimpleType::F_unsigned)) == (CPPSimpleType::F_short | CPPSimpleType::F_unsigned)); } @@ -1276,7 +1276,7 @@ is_longlong(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return (simple_type->_type == CPPSimpleType::T_int && (simple_type->_flags & CPPSimpleType::F_longlong) != 0); } @@ -1306,7 +1306,7 @@ is_unsigned_longlong(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return (simple_type->_type == CPPSimpleType::T_int && (simple_type->_flags & (CPPSimpleType::F_longlong | CPPSimpleType::F_unsigned)) == (CPPSimpleType::F_longlong | CPPSimpleType::F_unsigned)); } @@ -1335,7 +1335,7 @@ is_double(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return (simple_type->_type == CPPSimpleType::T_double); } } @@ -1364,7 +1364,7 @@ is_float(CPPType *type) { case CPPDeclaration::ST_simple: { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return (simple_type->_type == CPPSimpleType::T_float || simple_type->_type == CPPSimpleType::T_double); @@ -1388,7 +1388,7 @@ is_float(CPPType *type) { bool TypeManager:: is_void(CPPType *type) { CPPSimpleType *simple_type = type->as_simple_type(); - if (simple_type != (CPPSimpleType *)NULL) { + if (simple_type != nullptr) { return simple_type->_type == CPPSimpleType::T_void && simple_type->_flags == 0; @@ -1404,7 +1404,7 @@ is_void(CPPType *type) { bool TypeManager:: is_reference_count(CPPType *type) { CPPType *refcount_type = get_reference_count_type(); - if (refcount_type != (CPPType *)NULL && + if (refcount_type != nullptr && refcount_type->get_local_name(&parser) == type->get_local_name(&parser)) { return true; } @@ -1859,7 +1859,7 @@ involves_unpublished(CPPType *type) { case CPPDeclaration::ST_struct: // A struct type is unpublished only if all of its members are // unpublished. - if (type->_declaration != (CPPTypeDeclaration *)NULL) { + if (type->_declaration != nullptr) { if (type->_declaration->_vis <= min_vis) { return false; } @@ -1881,7 +1881,7 @@ involves_unpublished(CPPType *type) { } case CPPDeclaration::ST_function: - if (type->_declaration != (CPPTypeDeclaration *)NULL) { + if (type->_declaration != nullptr) { if (type->_declaration->_vis <= min_vis) { return false; } @@ -1909,7 +1909,7 @@ involves_unpublished(CPPType *type) { return involves_unpublished(type->as_typedef_type()->_type); default: - if (type->_declaration != (CPPTypeDeclaration *)NULL) { + if (type->_declaration != nullptr) { return (type->_declaration->_vis > min_vis); } return false; @@ -1955,7 +1955,7 @@ involves_protected(CPPType *type) { return involves_protected(type->as_typedef_type()->_type); default: - if (type->_declaration != (CPPTypeDeclaration *)NULL) { + if (type->_declaration != nullptr) { return (type->_declaration->_vis > V_public); } return false; @@ -2073,7 +2073,7 @@ get_pointer_type(CPPStructType *pt_type) { ++ii) { CPPInstance *function = (*ii); CPPFunctionType *ftype = function->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); if (ftype->_parameters->_parameters.empty()) { // Here's the function p(). What's its return type? return resolve_type(ftype->_return_type); @@ -2081,7 +2081,7 @@ get_pointer_type(CPPStructType *pt_type) { } } - return (CPPType *)NULL; + return nullptr; } /** @@ -2106,15 +2106,15 @@ get_template_parameter_type(CPPType *source_type, int i) { } CPPStructType *type = source_type->as_struct_type(); - if (type == NULL) { - return NULL; + if (type == nullptr) { + return nullptr; } // I'm not sure how reliable this is, but I don't know if there is a more // proper way to access this. CPPTemplateParameterList *templ = type->_ident->_names.back().get_templ(); - if (templ == NULL || i >= (int)templ->_parameters.size()) { - return NULL; + if (templ == nullptr || i >= (int)templ->_parameters.size()) { + return nullptr; } CPPDeclaration *decl = templ->_parameters[i]; @@ -2134,7 +2134,7 @@ wrap_pointer(CPPType *source_type) { */ CPPType *TypeManager:: wrap_const_pointer(CPPType *source_type) { - if (source_type->as_const_type() != (CPPConstType *)NULL) { + if (source_type->as_const_type() != nullptr) { // It's already const. return CPPType::new_type(new CPPPointerType(source_type)); @@ -2149,7 +2149,7 @@ wrap_const_pointer(CPPType *source_type) { */ CPPType *TypeManager:: wrap_const_reference(CPPType *source_type) { - if (source_type->as_const_type() != (CPPConstType *)NULL) { + if (source_type->as_const_type() != nullptr) { // It's already const. return CPPType::new_type(new CPPReferenceType(source_type)); @@ -2166,7 +2166,7 @@ wrap_const_reference(CPPType *source_type) { CPPType *TypeManager:: get_basic_string_char_type() { static bool got_type = false; - static CPPType *type = (CPPType *)NULL; + static CPPType *type = nullptr; if (!got_type) { type = parser.parse_type("std::basic_string"); got_type = true; @@ -2181,7 +2181,7 @@ get_basic_string_char_type() { CPPType *TypeManager:: get_basic_string_wchar_type() { static bool got_type = false; - static CPPType *type = (CPPType *)NULL; + static CPPType *type = nullptr; if (!got_type) { type = parser.parse_type("std::basic_string"); got_type = true; @@ -2196,7 +2196,7 @@ get_basic_string_wchar_type() { CPPType *TypeManager:: get_reference_count_type() { static bool got_type = false; - static CPPType *type = (CPPType *)NULL; + static CPPType *type = nullptr; if (!got_type) { type = parser.parse_type("ReferenceCount"); got_type = true; @@ -2210,7 +2210,7 @@ get_reference_count_type() { CPPType *TypeManager:: get_void_type() { static bool got_type = false; - static CPPType *type = (CPPType *)NULL; + static CPPType *type = nullptr; if (!got_type) { type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_void)); got_type = true; @@ -2224,7 +2224,7 @@ get_void_type() { CPPType *TypeManager:: get_int_type() { static bool got_type = false; - static CPPType *type = (CPPType *)NULL; + static CPPType *type = nullptr; if (!got_type) { type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int)); got_type = true; @@ -2246,7 +2246,7 @@ string TypeManager:: get_function_signature(CPPInstance *function, int num_default_parameters) { CPPFunctionType *ftype = function->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); ostringstream out; @@ -2315,7 +2315,7 @@ get_function_name(CPPInstance *function) { bool TypeManager:: has_protected_destructor(CPPType *type) { CPPStructType *struct_type = type->as_struct_type(); - if (struct_type == (CPPStructType *)NULL) { + if (struct_type == nullptr) { // It's not even a struct type! return false; } @@ -2332,7 +2332,7 @@ has_protected_destructor(CPPType *type) { if (inst->_type->get_subtype() == CPPDeclaration::ST_function) { // Here's a function declaration. CPPFunctionType *ftype = inst->_type->as_function_type(); - assert(ftype != (CPPFunctionType *)NULL); + assert(ftype != nullptr); if ((ftype->_flags & CPPFunctionType::F_destructor) != 0) { // Here's the destructor! Is it protected? return (inst->_vis > V_public); diff --git a/dtool/src/interrogate/typeManager.h b/dtool/src/interrogate/typeManager.h index 65f192edf7..6d259b01ff 100644 --- a/dtool/src/interrogate/typeManager.h +++ b/dtool/src/interrogate/typeManager.h @@ -39,7 +39,7 @@ class CPPManifest; class TypeManager { public: - static CPPType *resolve_type(CPPType *type, CPPScope *scope = (CPPScope *)NULL); + static CPPType *resolve_type(CPPType *type, CPPScope *scope = nullptr); static bool is_assignable(CPPType *type); diff --git a/dtool/src/interrogatedb/dtool_super_base.cxx b/dtool/src/interrogatedb/dtool_super_base.cxx index 610d89da8b..d5197b3c76 100644 --- a/dtool/src/interrogatedb/dtool_super_base.cxx +++ b/dtool/src/interrogatedb/dtool_super_base.cxx @@ -46,89 +46,89 @@ EXPCL_INTERROGATEDB void Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(PyObject *modu PyDict_SetItemString(Dtool_DTOOL_SUPER_BASE._PyType.tp_dict, "DtoolGetSuperBase", PyCFunction_New(&Dtool_Methods_DTOOL_SUPER_BASE[0], (PyObject *)&Dtool_DTOOL_SUPER_BASE)); } - if (module != NULL) { + if (module != nullptr) { Py_INCREF((PyTypeObject *)&Dtool_DTOOL_SUPER_BASE); PyModule_AddObject(module, "DTOOL_SUPER_BASE", (PyObject *)&Dtool_DTOOL_SUPER_BASE); } } inline void *Dtool_DowncastInterface_DTOOL_SUPER_BASE(void *from_this, Dtool_PyTypedObject *from_type) { - return (void *) NULL; + return nullptr; } inline void *Dtool_UpcastInterface_DTOOL_SUPER_BASE(PyObject *self, Dtool_PyTypedObject *requested_type) { - return NULL; + return nullptr; } int Dtool_Init_DTOOL_SUPER_BASE(PyObject *self, PyObject *args, PyObject *kwds) { - assert(self != NULL); + assert(self != nullptr); PyErr_Format(PyExc_TypeError, "cannot init constant class %s", Py_TYPE(self)->tp_name); return -1; } EXPORT_THIS Dtool_PyTypedObject Dtool_DTOOL_SUPER_BASE = { { - PyVarObject_HEAD_INIT(NULL, 0) + PyVarObject_HEAD_INIT(nullptr, 0) "dtoolconfig.DTOOL_SUPER_BASE", sizeof(Dtool_PyInstDef), - 0, + 0, // tp_itemsize &Dtool_FreeInstance_DTOOL_SUPER_BASE, - 0, - 0, - 0, + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr #if PY_MAJOR_VERSION >= 3 - 0, + nullptr, // tp_compare #else &DTOOL_PyObject_ComparePointers, #endif - 0, - 0, - 0, - 0, + nullptr, // tp_repr + nullptr, // tp_as_number + nullptr, // tp_as_sequence + nullptr, // tp_as_mapping &DTOOL_PyObject_HashPointer, - 0, - 0, + nullptr, // tp_call + nullptr, // tp_str PyObject_GenericGetAttr, PyObject_GenericSetAttr, - 0, + nullptr, // tp_as_buffer (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES), - 0, - 0, - 0, + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear #if PY_MAJOR_VERSION >= 3 &DTOOL_PyObject_RichCompare, #else - 0, + nullptr, // tp_richcompare #endif - 0, - 0, - 0, + 0, // tp_weaklistoffset + nullptr, // tp_iter + nullptr, // tp_iternext Dtool_Methods_DTOOL_SUPER_BASE, standard_type_members, - 0, - 0, - 0, - 0, - 0, - 0, + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set + 0, // tp_dictoffset Dtool_Init_DTOOL_SUPER_BASE, PyType_GenericAlloc, Dtool_new_DTOOL_SUPER_BASE, PyObject_Del, - 0, - 0, - 0, - 0, - 0, - 0, - 0, + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del }, TypeHandle::none(), Dtool_PyModuleClassInit_DTOOL_SUPER_BASE, Dtool_UpcastInterface_DTOOL_SUPER_BASE, Dtool_DowncastInterface_DTOOL_SUPER_BASE, - NULL, - NULL, + nullptr, + nullptr, }; #endif // HAVE_PYTHON diff --git a/dtool/src/interrogatedb/interrogateComponent.I b/dtool/src/interrogatedb/interrogateComponent.I index 4617eee858..dc401c7945 100644 --- a/dtool/src/interrogatedb/interrogateComponent.I +++ b/dtool/src/interrogatedb/interrogateComponent.I @@ -46,7 +46,7 @@ operator = (const InterrogateComponent ©) { INLINE bool InterrogateComponent:: has_library_name() const { const char *name = get_library_name(); - return (name != (const char *)NULL && name[0] != '\0'); + return (name != nullptr && name[0] != '\0'); } /** @@ -57,10 +57,10 @@ has_library_name() const { */ INLINE const char *InterrogateComponent:: get_library_name() const { - if (_def != (InterrogateModuleDef *)NULL) { + if (_def != nullptr) { return _def->library_name; } - return (const char *)NULL; + return nullptr; } /** @@ -70,7 +70,7 @@ get_library_name() const { INLINE bool InterrogateComponent:: has_module_name() const { const char *name = get_module_name(); - return (name != (const char *)NULL && name[0] != '\0'); + return (name != nullptr && name[0] != '\0'); } /** @@ -81,10 +81,10 @@ has_module_name() const { */ INLINE const char *InterrogateComponent:: get_module_name() const { - if (_def != (InterrogateModuleDef *)NULL) { + if (_def != nullptr) { return _def->module_name; } - return (const char *)NULL; + return nullptr; } /** diff --git a/dtool/src/interrogatedb/interrogateComponent.h b/dtool/src/interrogatedb/interrogateComponent.h index 77b4388d7e..0d8a39595d 100644 --- a/dtool/src/interrogatedb/interrogateComponent.h +++ b/dtool/src/interrogatedb/interrogateComponent.h @@ -29,7 +29,7 @@ class IndexRemapper; */ class EXPCL_INTERROGATEDB InterrogateComponent { public: - INLINE InterrogateComponent(InterrogateModuleDef *def = NULL); + INLINE InterrogateComponent(InterrogateModuleDef *def = nullptr); INLINE InterrogateComponent(const InterrogateComponent ©); INLINE void operator = (const InterrogateComponent ©); diff --git a/dtool/src/interrogatedb/interrogateDatabase.cxx b/dtool/src/interrogatedb/interrogateDatabase.cxx index c11675d352..8781e5c2bd 100644 --- a/dtool/src/interrogatedb/interrogateDatabase.cxx +++ b/dtool/src/interrogatedb/interrogateDatabase.cxx @@ -16,7 +16,7 @@ #include "indexRemapper.h" #include "interrogate_datafile.h" -InterrogateDatabase *InterrogateDatabase::_global_ptr = NULL; +InterrogateDatabase *InterrogateDatabase::_global_ptr = nullptr; int InterrogateDatabase::_file_major_version = 0; int InterrogateDatabase::_file_minor_version = 0; int InterrogateDatabase::_current_major_version = 3; @@ -37,7 +37,7 @@ InterrogateDatabase() { */ InterrogateDatabase *InterrogateDatabase:: get_ptr() { - if (_global_ptr == (InterrogateDatabase *)NULL) { + if (_global_ptr == nullptr) { if (interrogatedb_cat->is_debug()) { interrogatedb_cat->debug() << "Creating interrogate database\n"; @@ -56,7 +56,7 @@ get_ptr() { void InterrogateDatabase:: request_module(InterrogateModuleDef *def) { if (interrogatedb_cat->is_debug()) { - if (def->library_name == (const char *)NULL) { + if (def->library_name == nullptr) { interrogatedb_cat->debug() << "Got interrogate data for anonymous module\n"; } else { @@ -78,13 +78,13 @@ request_module(InterrogateModuleDef *def) { _modules.push_back(def); } - if (def->num_unique_names > 0 && def->library_name != (const char *)NULL) { + if (def->num_unique_names > 0 && def->library_name != nullptr) { // Define a lookup by hash for this module, mainly so we can look up // functions by their unique names. _modules_by_hash[def->library_hash_name] = def; } - if (def->database_filename != (const char *)NULL) { + if (def->database_filename != nullptr) { _requests.push_back(def); } } @@ -361,7 +361,7 @@ get_fptr(FunctionWrapperIndex wrapper) { return def->fptrs[module_index]; } } - return (void *)NULL; + return nullptr; } /** @@ -830,7 +830,7 @@ load_latest() { for (ri = copy_requests.begin(); ri != copy_requests.end(); ++ri) { InterrogateModuleDef *def = (*ri); - if (def->database_filename != (char *)NULL) { + if (def->database_filename != nullptr) { Filename filename = def->database_filename; Filename pathname = filename; if (!pathname.empty() && pathname[0] != '/') { diff --git a/dtool/src/interrogatedb/interrogateElement.h b/dtool/src/interrogatedb/interrogateElement.h index f824b760cf..b3ba755fac 100644 --- a/dtool/src/interrogatedb/interrogateElement.h +++ b/dtool/src/interrogatedb/interrogateElement.h @@ -27,7 +27,7 @@ class CPPMakeProperty; */ class EXPCL_INTERROGATEDB InterrogateElement : public InterrogateComponent { public: - INLINE InterrogateElement(InterrogateModuleDef *def = NULL); + INLINE InterrogateElement(InterrogateModuleDef *def = nullptr); INLINE InterrogateElement(const InterrogateElement ©); INLINE void operator = (const InterrogateElement ©); diff --git a/dtool/src/interrogatedb/interrogateFunction.cxx b/dtool/src/interrogatedb/interrogateFunction.cxx index 6510f86fc9..a9a60264da 100644 --- a/dtool/src/interrogatedb/interrogateFunction.cxx +++ b/dtool/src/interrogatedb/interrogateFunction.cxx @@ -25,7 +25,7 @@ InterrogateFunction(InterrogateModuleDef *def) : { _flags = 0; _class = 0; - _instances = (Instances *)NULL; + _instances = nullptr; } /** diff --git a/dtool/src/interrogatedb/interrogateFunction.h b/dtool/src/interrogatedb/interrogateFunction.h index eac57642f8..cf92aa15dc 100644 --- a/dtool/src/interrogatedb/interrogateFunction.h +++ b/dtool/src/interrogatedb/interrogateFunction.h @@ -29,7 +29,7 @@ class CPPInstance; */ class EXPCL_INTERROGATEDB InterrogateFunction : public InterrogateComponent { public: - InterrogateFunction(InterrogateModuleDef *def = NULL); + InterrogateFunction(InterrogateModuleDef *def = nullptr); InterrogateFunction(const InterrogateFunction ©); void operator = (const InterrogateFunction ©); diff --git a/dtool/src/interrogatedb/interrogateFunctionWrapper.h b/dtool/src/interrogatedb/interrogateFunctionWrapper.h index a49edb90ad..ff80d930b9 100644 --- a/dtool/src/interrogatedb/interrogateFunctionWrapper.h +++ b/dtool/src/interrogatedb/interrogateFunctionWrapper.h @@ -27,7 +27,7 @@ class IndexRemapper; */ class EXPCL_INTERROGATEDB InterrogateFunctionWrapper : public InterrogateComponent { public: - INLINE InterrogateFunctionWrapper(InterrogateModuleDef *def = NULL); + INLINE InterrogateFunctionWrapper(InterrogateModuleDef *def = nullptr); INLINE InterrogateFunctionWrapper(const InterrogateFunctionWrapper ©); INLINE void operator = (const InterrogateFunctionWrapper ©); diff --git a/dtool/src/interrogatedb/interrogateMakeSeq.h b/dtool/src/interrogatedb/interrogateMakeSeq.h index 6883e81126..b65a32b27e 100644 --- a/dtool/src/interrogatedb/interrogateMakeSeq.h +++ b/dtool/src/interrogatedb/interrogateMakeSeq.h @@ -25,7 +25,7 @@ class IndexRemapper; */ class EXPCL_INTERROGATEDB InterrogateMakeSeq : public InterrogateComponent { public: - INLINE InterrogateMakeSeq(InterrogateModuleDef *def = NULL); + INLINE InterrogateMakeSeq(InterrogateModuleDef *def = nullptr); INLINE InterrogateMakeSeq(const InterrogateMakeSeq ©); INLINE void operator = (const InterrogateMakeSeq ©); diff --git a/dtool/src/interrogatedb/interrogateManifest.h b/dtool/src/interrogatedb/interrogateManifest.h index 49323a75c0..37ec3696b4 100644 --- a/dtool/src/interrogatedb/interrogateManifest.h +++ b/dtool/src/interrogatedb/interrogateManifest.h @@ -25,7 +25,7 @@ class IndexRemapper; */ class EXPCL_INTERROGATEDB InterrogateManifest : public InterrogateComponent { public: - INLINE InterrogateManifest(InterrogateModuleDef *def = NULL); + INLINE InterrogateManifest(InterrogateModuleDef *def = nullptr); INLINE InterrogateManifest(const InterrogateManifest ©); INLINE void operator = (const InterrogateManifest ©); diff --git a/dtool/src/interrogatedb/interrogateType.cxx b/dtool/src/interrogatedb/interrogateType.cxx index a6d6e45487..41839ffbf7 100644 --- a/dtool/src/interrogatedb/interrogateType.cxx +++ b/dtool/src/interrogatedb/interrogateType.cxx @@ -32,8 +32,8 @@ InterrogateType(InterrogateModuleDef *def) : _array_size = 1; _destructor = 0; - _cpptype = (CPPType *)NULL; - _cppscope = (CPPScope *)NULL; + _cpptype = nullptr; + _cppscope = nullptr; } /** diff --git a/dtool/src/interrogatedb/interrogateType.h b/dtool/src/interrogatedb/interrogateType.h index e852007b6b..f5b3b49065 100644 --- a/dtool/src/interrogatedb/interrogateType.h +++ b/dtool/src/interrogatedb/interrogateType.h @@ -29,7 +29,7 @@ class CPPScope; */ class EXPCL_INTERROGATEDB InterrogateType : public InterrogateComponent { public: - InterrogateType(InterrogateModuleDef *def = NULL); + InterrogateType(InterrogateModuleDef *def = nullptr); InterrogateType(const InterrogateType ©); void operator = (const InterrogateType ©); diff --git a/dtool/src/interrogatedb/interrogate_datafile.cxx b/dtool/src/interrogatedb/interrogate_datafile.cxx index eb5c0ca57f..65cc3f3fef 100644 --- a/dtool/src/interrogatedb/interrogate_datafile.cxx +++ b/dtool/src/interrogatedb/interrogate_datafile.cxx @@ -53,7 +53,7 @@ idf_input_string(istream &in, string &str) { */ void idf_output_string(ostream &out, const char *str, char whitespace) { - if (str == (const char *)NULL) { + if (str == nullptr) { out << "0 "; } else { out << strlen(str) << whitespace; diff --git a/dtool/src/interrogatedb/interrogate_interface.cxx b/dtool/src/interrogatedb/interrogate_interface.cxx index 6e948134d3..5f72f967e0 100644 --- a/dtool/src/interrogatedb/interrogate_interface.cxx +++ b/dtool/src/interrogatedb/interrogate_interface.cxx @@ -400,7 +400,7 @@ interrogate_wrapper_parameter_is_this(FunctionWrapperIndex wrapper, int n) { bool interrogate_wrapper_has_pointer(FunctionWrapperIndex wrapper) { // cerr << "interrogate_wrapper_has_pointer(" << wrapper << ")\n"; - return (InterrogateDatabase::get_ptr()->get_fptr(wrapper) != (void *)NULL); + return (InterrogateDatabase::get_ptr()->get_fptr(wrapper) != nullptr); } void * diff --git a/dtool/src/interrogatedb/py_panda.I b/dtool/src/interrogatedb/py_panda.I index 24c038df94..7ddf8bec9b 100644 --- a/dtool/src/interrogatedb/py_panda.I +++ b/dtool/src/interrogatedb/py_panda.I @@ -68,28 +68,28 @@ DtoolInstance_GetPointer(PyObject *self, T *&into, Dtool_PyTypedObject &target_c template INLINE PyObject * DTool_CreatePyInstance(const T *obj, bool memory_rules) { Dtool_PyTypedObject *known_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index()); - nassertr(known_class != NULL, NULL); + nassertr(known_class != nullptr, nullptr); return DTool_CreatePyInstance((void*) obj, *known_class, memory_rules, true); } template INLINE PyObject * DTool_CreatePyInstance(T *obj, bool memory_rules) { Dtool_PyTypedObject *known_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index()); - nassertr(known_class != NULL, NULL); + nassertr(known_class != nullptr, nullptr); return DTool_CreatePyInstance((void*) obj, *known_class, memory_rules, false); } template INLINE PyObject * DTool_CreatePyInstanceTyped(const T *obj, bool memory_rules) { Dtool_PyTypedObject *known_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index()); - nassertr(known_class != NULL, NULL); + nassertr(known_class != nullptr, nullptr); return DTool_CreatePyInstanceTyped((void*) obj, *known_class, memory_rules, true, obj->get_type().get_index()); } template INLINE PyObject * DTool_CreatePyInstanceTyped(T *obj, bool memory_rules) { Dtool_PyTypedObject *known_class = Dtool_RuntimeTypeDtoolType(get_type_handle(T).get_index()); - nassertr(known_class != NULL, NULL); + nassertr(known_class != nullptr, nullptr); return DTool_CreatePyInstanceTyped((void*) obj, *known_class, memory_rules, false, obj->get_type().get_index()); } @@ -180,7 +180,7 @@ ALWAYS_INLINE PyObject *Dtool_WrapValue(double value) { } ALWAYS_INLINE PyObject *Dtool_WrapValue(const char *value) { - if (value == (const char *)NULL) { + if (value == nullptr) { Py_INCREF(Py_None); return Py_None; } else { @@ -193,7 +193,7 @@ ALWAYS_INLINE PyObject *Dtool_WrapValue(const char *value) { } ALWAYS_INLINE PyObject *Dtool_WrapValue(const wchar_t *value) { - if (value == (const wchar_t *)NULL) { + if (value == nullptr) { Py_INCREF(Py_None); return Py_None; } else { @@ -214,7 +214,7 @@ ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::wstring &value) { } ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::string *value) { - if (value == (const std::string *)NULL) { + if (value == nullptr) { Py_INCREF(Py_None); return Py_None; } else { @@ -227,7 +227,7 @@ ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::string *value) { } ALWAYS_INLINE PyObject *Dtool_WrapValue(const std::wstring *value) { - if (value == (const std::wstring *)NULL) { + if (value == nullptr) { Py_INCREF(Py_None); return Py_None; } else { @@ -266,7 +266,7 @@ ALWAYS_INLINE PyObject *Dtool_WrapValue(const vector_uchar &value) { #if PY_MAJOR_VERSION >= 0x02060000 ALWAYS_INLINE PyObject *Dtool_WrapValue(Py_buffer *value) { - if (value == (Py_buffer *)NULL) { + if (value == nullptr) { return value; } else { return PyMemoryView_FromBuffer(value); diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index 362f5ec6ca..236c9a5197 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -24,7 +24,7 @@ PyMemberDef standard_type_members[] = { // {(char *)"this_signature", T_INT, offsetof(Dtool_PyInstDef, _signature), // READONLY, (char *)"A type check signature"}, {(char *)"this_metatype", T_OBJECT, offsetof(Dtool_PyInstDef, _My_Type), READONLY, (char *)"The dtool meta object"}, - {NULL} /* Sentinel */ + {nullptr} /* Sentinel */ }; static RuntimeTypeMap runtime_type_map; @@ -183,9 +183,9 @@ PyObject *Dtool_Raise_AssertionError() { PyObject *message = PyString_FromString(notify->get_assert_error_message().c_str()); #endif Py_INCREF(PyExc_AssertionError); - PyErr_Restore(PyExc_AssertionError, message, (PyObject *)NULL); + PyErr_Restore(PyExc_AssertionError, message, nullptr); notify->clear_assert_failed(); - return NULL; + return nullptr; } /** @@ -196,11 +196,11 @@ PyObject *Dtool_Raise_TypeError(const char *message) { // eventually anyway, so we might as well just get to the point. Py_INCREF(PyExc_TypeError); #if PY_MAJOR_VERSION >= 3 - PyErr_Restore(PyExc_TypeError, PyUnicode_FromString(message), (PyObject *)NULL); + PyErr_Restore(PyExc_TypeError, PyUnicode_FromString(message), nullptr); #else - PyErr_Restore(PyExc_TypeError, PyString_FromString(message), (PyObject *)NULL); + PyErr_Restore(PyExc_TypeError, PyString_FromString(message), nullptr); #endif - return NULL; + return nullptr; } /** @@ -221,8 +221,8 @@ PyObject *Dtool_Raise_ArgTypeError(PyObject *obj, int param, const char *functio Py_TYPE(obj)->tp_name); Py_INCREF(PyExc_TypeError); - PyErr_Restore(PyExc_TypeError, message, (PyObject *)NULL); - return NULL; + PyErr_Restore(PyExc_TypeError, message, nullptr); + return nullptr; } /** @@ -241,8 +241,8 @@ PyObject *Dtool_Raise_AttributeError(PyObject *obj, const char *attribute) { Py_TYPE(obj)->tp_name, attribute); Py_INCREF(PyExc_TypeError); - PyErr_Restore(PyExc_TypeError, message, (PyObject *)NULL); - return NULL; + PyErr_Restore(PyExc_TypeError, message, nullptr); + return nullptr; } /** @@ -265,7 +265,7 @@ PyObject *_Dtool_Raise_BadArgumentsError() { */ PyObject *_Dtool_Return_None() { if (UNLIKELY(_PyErr_OCCURRED())) { - return NULL; + return nullptr; } #ifndef NDEBUG if (UNLIKELY(Notify::ptr()->has_assert_failed())) { @@ -282,7 +282,7 @@ PyObject *_Dtool_Return_None() { */ PyObject *Dtool_Return_Bool(bool value) { if (UNLIKELY(_PyErr_OCCURRED())) { - return NULL; + return nullptr; } #ifndef NDEBUG if (UNLIKELY(Notify::ptr()->has_assert_failed())) { @@ -301,7 +301,7 @@ PyObject *Dtool_Return_Bool(bool value) { */ PyObject *_Dtool_Return(PyObject *value) { if (UNLIKELY(_PyErr_OCCURRED())) { - return NULL; + return nullptr; } #ifndef NDEBUG if (UNLIKELY(Notify::ptr()->has_assert_failed())) { @@ -315,22 +315,22 @@ PyObject *_Dtool_Return(PyObject *value) { * Creates a Python 3.4-style enum type. Steals reference to 'names'. */ PyObject *Dtool_EnumType_Create(const char *name, PyObject *names, const char *module) { - static PyObject *enum_class = NULL; - static PyObject *enum_meta = NULL; - static PyObject *enum_create = NULL; - if (enum_meta == NULL) { + static PyObject *enum_class = nullptr; + static PyObject *enum_meta = nullptr; + static PyObject *enum_create = nullptr; + if (enum_meta == nullptr) { PyObject *enum_module = PyImport_ImportModule("enum"); - nassertr_always(enum_module != NULL, NULL); + nassertr_always(enum_module != nullptr, nullptr); enum_class = PyObject_GetAttrString(enum_module, "Enum"); enum_meta = PyObject_GetAttrString(enum_module, "EnumMeta"); enum_create = PyObject_GetAttrString(enum_meta, "_create_"); - nassertr(enum_meta != NULL, NULL); + nassertr(enum_meta != nullptr, nullptr); } PyObject *result = PyObject_CallFunction(enum_create, (char *)"OsN", enum_class, name, names); - nassertr(result != NULL, NULL); - if (module != NULL) { + nassertr(result != nullptr, nullptr); + if (module != nullptr) { PyObject *modstr = PyUnicode_FromString(module); PyObject_SetAttrString(result, "__module__", modstr); Py_DECREF(modstr); @@ -346,19 +346,19 @@ PyObject *DTool_CreatePyInstanceTyped(void *local_this_in, Dtool_PyTypedObject & // caller will have to get the type index to pass to this function to begin // with. That code probably would have crashed by now if it was really NULL // for whatever reason. - nassertr(local_this_in != NULL, NULL); + nassertr(local_this_in != nullptr, nullptr); // IF the class is possibly a run time typed object if (type_index > 0) { // get best fit class... Dtool_PyTypedObject *target_class = Dtool_RuntimeTypeDtoolType(type_index); - if (target_class != NULL) { + if (target_class != nullptr) { // cast to the type... void *new_local_this = target_class->_Dtool_DowncastInterface(local_this_in, &known_class_type); - if (new_local_this != NULL) { + if (new_local_this != nullptr) { // ask class to allocate an instance.. - Dtool_PyInstDef *self = (Dtool_PyInstDef *) target_class->_PyType.tp_new(&target_class->_PyType, NULL, NULL); - if (self != NULL) { + Dtool_PyInstDef *self = (Dtool_PyInstDef *) target_class->_PyType.tp_new(&target_class->_PyType, nullptr, nullptr); + if (self != nullptr) { self->_ptr_to_object = new_local_this; self->_memory_rules = memory_rules; self->_is_const = is_const; @@ -372,8 +372,8 @@ PyObject *DTool_CreatePyInstanceTyped(void *local_this_in, Dtool_PyTypedObject & // if we get this far .. just wrap the thing in the known type ?? better // than aborting...I guess.... - Dtool_PyInstDef *self = (Dtool_PyInstDef *) known_class_type._PyType.tp_new(&known_class_type._PyType, NULL, NULL); - if (self != NULL) { + Dtool_PyInstDef *self = (Dtool_PyInstDef *) known_class_type._PyType.tp_new(&known_class_type._PyType, nullptr, nullptr); + if (self != nullptr) { self->_ptr_to_object = local_this_in; self->_memory_rules = memory_rules; self->_is_const = is_const; @@ -386,7 +386,7 @@ PyObject *DTool_CreatePyInstanceTyped(void *local_this_in, Dtool_PyTypedObject & // DTool_CreatePyInstance .. wrapper function to finalize the existance of a // general dtool py instance.. PyObject *DTool_CreatePyInstance(void *local_this, Dtool_PyTypedObject &in_classdef, bool memory_rules, bool is_const) { - if (local_this == NULL) { + if (local_this == nullptr) { // This is actually a very common case, so let's allow this, but return // Py_None consistently. This eliminates code in the wrappers. Py_INCREF(Py_None); @@ -394,8 +394,8 @@ PyObject *DTool_CreatePyInstance(void *local_this, Dtool_PyTypedObject &in_class } Dtool_PyTypedObject *classdef = &in_classdef; - Dtool_PyInstDef *self = (Dtool_PyInstDef *) classdef->_PyType.tp_new(&classdef->_PyType, NULL, NULL); - if (self != NULL) { + Dtool_PyInstDef *self = (Dtool_PyInstDef *) classdef->_PyType.tp_new(&classdef->_PyType, nullptr, nullptr); + if (self != nullptr) { self->_ptr_to_object = local_this; self->_memory_rules = memory_rules; self->_is_const = is_const; @@ -420,7 +420,7 @@ int DTool_PyInit_Finalize(PyObject *self, void *local_this, Dtool_PyTypedObject // done at code generation time because of multiple generation passes in // interrogate.. void Dtool_Accum_MethDefs(PyMethodDef in[], MethodDefmap &themap) { - for (; in->ml_name != NULL; in++) { + for (; in->ml_name != nullptr; in++) { if (themap.find(in->ml_name) == themap.end()) { themap[in->ml_name] = in; } @@ -492,7 +492,7 @@ LookupNamedClass(const string &name) { interrogatedb_cat.error() << "Attempt to use type " << name << " which has not yet been defined!\n"; - return NULL; + return nullptr; } else { return it->second; } @@ -506,7 +506,7 @@ LookupRuntimeTypedClass(TypeHandle handle) { if (it == runtime_type_map.end()) { interrogatedb_cat.error() << "Attempt to use type " << handle << " which has not yet been defined!\n"; - return NULL; + return nullptr; } else { return it->second; } @@ -523,7 +523,7 @@ Dtool_PyTypedObject *Dtool_RuntimeTypeDtoolType(int type) { return di->second; } } - return NULL; + return nullptr; } #if PY_MAJOR_VERSION >= 3 @@ -544,7 +544,7 @@ PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) { << "incompatible with Python " << version.substr(0, 3); string error = errs.str(); PyErr_SetString(PyExc_ImportError, error.c_str()); - return (PyObject *)NULL; + return nullptr; } // Initialize the types we define in py_panda. @@ -593,12 +593,12 @@ PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) { #endif // Initialize the base class of everything. - Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(NULL); + Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(nullptr); } // the module level function inits.... MethodDefmap functions; - for (int xx = 0; defs[xx] != NULL; xx++) { + for (int xx = 0; defs[xx] != nullptr; xx++) { Dtool_Accum_MethDefs(defs[xx]->_methods, functions); } @@ -608,9 +608,9 @@ PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) { for (mi = functions.begin(); mi != functions.end(); mi++, offset++) { newdef[offset] = *mi->second; } - newdef[offset].ml_doc = NULL; - newdef[offset].ml_name = NULL; - newdef[offset].ml_meth = NULL; + newdef[offset].ml_doc = nullptr; + newdef[offset].ml_name = nullptr; + newdef[offset].ml_meth = nullptr; newdef[offset].ml_flags = 0; #if PY_MAJOR_VERSION >= 3 @@ -620,7 +620,7 @@ PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) { PyObject *module = Py_InitModule((char *)modulename, newdef); #endif - if (module == NULL) { + if (module == nullptr) { #if PY_MAJOR_VERSION >= 3 return Dtool_Raise_TypeError("PyModule_Create returned NULL"); #else @@ -640,21 +640,21 @@ PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) { // Grab the __main__ module. PyObject *main_module = PyImport_ImportModule("__main__"); - if (main_module == NULL) { + if (main_module == nullptr) { interrogatedb_cat.warning() << "Unable to import __main__\n"; } // Extract the __file__ attribute, if present. Filename main_dir; PyObject *file_attr = PyObject_GetAttrString(main_module, "__file__"); - if (file_attr == NULL) { + if (file_attr == nullptr) { // Must be running in the interactive interpreter. Use the CWD. main_dir = ExecutionEnvironment::get_cwd(); } else { #if PY_MAJOR_VERSION >= 3 Py_ssize_t length; wchar_t *buffer = PyUnicode_AsWideCharString(file_attr, &length); - if (buffer != NULL) { + if (buffer != nullptr) { main_dir = Filename::from_os_specific_w(std::wstring(buffer, length)); main_dir.make_absolute(); main_dir = main_dir.get_dirname(); @@ -686,8 +686,8 @@ PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) { // grab the "THIS" pointer from an object and use it Required to support // historical inheritance in the form of "is this instance of".. PyObject *Dtool_BorrowThisReference(PyObject *self, PyObject *args) { - PyObject *from_in = NULL; - PyObject *to_in = NULL; + PyObject *from_in = nullptr; + PyObject *to_in = nullptr; if (PyArg_UnpackTuple(args, "Dtool_BorrowThisReference", 2, 2, &to_in, &from_in)) { if (DtoolInstance_Check(from_in) && DtoolInstance_Check(to_in)) { @@ -710,7 +710,7 @@ PyObject *Dtool_BorrowThisReference(PyObject *self, PyObject *args) { return Dtool_Raise_TypeError("One of these does not appear to be DTOOL Instance ??"); } } - return (PyObject *) NULL; + return nullptr; } // We do expose a dictionay for dtool classes .. this should be removed at @@ -721,14 +721,14 @@ PyObject *Dtool_AddToDictionary(PyObject *self1, PyObject *args) { PyObject *key; if (PyArg_ParseTuple(args, "OSO", &self, &key, &subject)) { PyObject *dict = ((PyTypeObject *)self)->tp_dict; - if (dict == NULL || !PyDict_Check(dict)) { + if (dict == nullptr || !PyDict_Check(dict)) { return Dtool_Raise_TypeError("No dictionary On Object"); } else { PyDict_SetItem(dict, key, subject); } } if (PyErr_Occurred()) { - return (PyObject *)NULL; + return nullptr; } Py_INCREF(Py_None); return Py_None; @@ -753,7 +753,7 @@ int DTOOL_PyObject_ComparePointers(PyObject *v1, PyObject *v2) { // try this compare void *v1_this = DTOOL_Call_GetPointerThis(v1); void *v2_this = DTOOL_Call_GetPointerThis(v2); - if (v1_this != NULL && v2_this != NULL) { // both are our types... + if (v1_this != nullptr && v2_this != nullptr) { // both are our types... if (v1_this < v2_this) { return -1; } @@ -776,23 +776,23 @@ int DTOOL_PyObject_ComparePointers(PyObject *v1, PyObject *v2) { int DTOOL_PyObject_Compare(PyObject *v1, PyObject *v2) { // First try compareTo function.. PyObject * func = PyObject_GetAttrString(v1, "compare_to"); - if (func == NULL) { + if (func == nullptr) { PyErr_Clear(); } else { #if PY_VERSION_HEX >= 0x03060000 PyObject *res = _PyObject_FastCall(func, &v2, 1); #else - PyObject *res = NULL; + PyObject *res = nullptr; PyObject *args = PyTuple_Pack(1, v2); - if (args != NULL) { - res = PyObject_Call(func, args, NULL); + if (args != nullptr) { + res = PyObject_Call(func, args, nullptr); Py_DECREF(args); } #endif Py_DECREF(func); PyErr_Clear(); // just in case the function threw an error // only use if the function returns an INT... hmm - if (res != NULL) { + if (res != nullptr) { if (PyLong_Check(res)) { long answer = PyLong_AsLong(res); Py_DECREF(res); @@ -861,8 +861,8 @@ PyObject *DTOOL_PyObject_RichCompare(PyObject *v1, PyObject *v2, int op) { */ PyObject *copy_from_make_copy(PyObject *self, PyObject *noargs) { PyObject *callable = PyObject_GetAttrString(self, "make_copy"); - if (callable == NULL) { - return NULL; + if (callable == nullptr) { + return nullptr; } PyObject *result = _PyObject_CallNoArg(callable); Py_DECREF(callable); @@ -880,7 +880,7 @@ PyObject *copy_from_copy_constructor(PyObject *self, PyObject *noargs) { PyObject *result = _PyObject_FastCall(callable, &self, 1); #else PyObject *args = PyTuple_Pack(1, self); - PyObject *result = PyObject_Call(callable, args, NULL); + PyObject *result = PyObject_Call(callable, args, nullptr); Py_DECREF(args); #endif return result; @@ -893,8 +893,8 @@ PyObject *copy_from_copy_constructor(PyObject *self, PyObject *noargs) { */ PyObject *map_deepcopy_to_copy(PyObject *self, PyObject *args) { PyObject *callable = PyObject_GetAttrString(self, "__copy__"); - if (callable == NULL) { - return NULL; + if (callable == nullptr) { + return nullptr; } PyObject *result = _PyObject_CallNoArg(callable); Py_DECREF(callable); diff --git a/dtool/src/interrogatedb/py_panda.h b/dtool/src/interrogatedb/py_panda.h index f84d5cd3ba..ffa6de94c8 100644 --- a/dtool/src/interrogatedb/py_panda.h +++ b/dtool/src/interrogatedb/py_panda.h @@ -247,7 +247,7 @@ EXPCL_INTERROGATEDB PyObject *_Dtool_Return(PyObject *value); * Wrapper around Python 3.4's enum library, which does not have a C API. */ EXPCL_INTERROGATEDB PyObject *Dtool_EnumType_Create(const char *name, PyObject *names, - const char *module = NULL); + const char *module = nullptr); /** diff --git a/dtool/src/interrogatedb/py_wrappers.cxx b/dtool/src/interrogatedb/py_wrappers.cxx index 3e8f61cb39..f03d727bd3 100644 --- a/dtool/src/interrogatedb/py_wrappers.cxx +++ b/dtool/src/interrogatedb/py_wrappers.cxx @@ -797,15 +797,15 @@ static PyObject *Dtool_MutableMappingWrapper_update(PyObject *self, PyObject *ar */ static PySequenceMethods Dtool_SequenceWrapper_SequenceMethods = { Dtool_SequenceWrapper_length, - 0, // sq_concat - 0, // sq_repeat + nullptr, // sq_concat + nullptr, // sq_repeat Dtool_SequenceWrapper_getitem, - 0, // sq_slice - 0, // sq_ass_item - 0, // sq_ass_slice + nullptr, // sq_slice + nullptr, // sq_ass_item + nullptr, // sq_ass_slice Dtool_SequenceWrapper_contains, - 0, // sq_inplace_concat - 0, // sq_inplace_repeat + nullptr, // sq_inplace_concat + nullptr, // sq_inplace_repeat }; static PyMethodDef Dtool_SequenceWrapper_Methods[] = { @@ -820,47 +820,47 @@ PyTypeObject Dtool_SequenceWrapper_Type = { sizeof(Dtool_SequenceWrapper), 0, // tp_itemsize Dtool_WrapperBase_dealloc, - 0, // tp_print - 0, // tp_getattr - 0, // tp_setattr - 0, // tp_compare + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare Dtool_SequenceWrapper_repr, - 0, // tp_as_number + nullptr, // tp_as_number &Dtool_SequenceWrapper_SequenceMethods, - 0, // tp_as_mapping - 0, // tp_hash - 0, // tp_call - 0, // tp_str + nullptr, // tp_as_mapping + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str PyObject_GenericGetAttr, PyObject_GenericSetAttr, - 0, // tp_as_buffer + nullptr, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - 0, // tp_doc - 0, // tp_traverse - 0, // tp_clear - 0, // tp_richcompare + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare 0, // tp_weaklistoffset PySeqIter_New, - 0, // tp_iternext + nullptr, // tp_iternext Dtool_SequenceWrapper_Methods, - 0, // tp_members - 0, // tp_getset - 0, // tp_base - 0, // tp_dict - 0, // tp_descr_get - 0, // tp_descr_set + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set 0, // tp_dictoffset - 0, // tp_init + nullptr, // tp_init PyType_GenericAlloc, - 0, // tp_new + nullptr, // tp_new PyObject_Del, - 0, // tp_is_gc - 0, // tp_bases - 0, // tp_mro - 0, // tp_cache - 0, // tp_subclasses - 0, // tp_weaklist - 0, // tp_del + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del }; /** @@ -868,15 +868,15 @@ PyTypeObject Dtool_SequenceWrapper_Type = { */ static PySequenceMethods Dtool_MutableSequenceWrapper_SequenceMethods = { Dtool_SequenceWrapper_length, - 0, // sq_concat - 0, // sq_repeat + nullptr, // sq_concat + nullptr, // sq_repeat Dtool_SequenceWrapper_getitem, - 0, // sq_slice + nullptr, // sq_slice Dtool_MutableSequenceWrapper_setitem, - 0, // sq_ass_slice + nullptr, // sq_ass_slice Dtool_SequenceWrapper_contains, Dtool_MutableSequenceWrapper_extend, - 0, // sq_inplace_repeat + nullptr, // sq_inplace_repeat }; static PyMethodDef Dtool_MutableSequenceWrapper_Methods[] = { @@ -897,47 +897,47 @@ PyTypeObject Dtool_MutableSequenceWrapper_Type = { sizeof(Dtool_MutableSequenceWrapper), 0, // tp_itemsize Dtool_WrapperBase_dealloc, - 0, // tp_print - 0, // tp_getattr - 0, // tp_setattr - 0, // tp_compare + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare Dtool_SequenceWrapper_repr, - 0, // tp_as_number + nullptr, // tp_as_number &Dtool_MutableSequenceWrapper_SequenceMethods, - 0, // tp_as_mapping - 0, // tp_hash - 0, // tp_call - 0, // tp_str + nullptr, // tp_as_mapping + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str PyObject_GenericGetAttr, PyObject_GenericSetAttr, - 0, // tp_as_buffer + nullptr, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - 0, // tp_doc - 0, // tp_traverse - 0, // tp_clear - 0, // tp_richcompare + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare 0, // tp_weaklistoffset PySeqIter_New, - 0, // tp_iternext + nullptr, // tp_iternext Dtool_MutableSequenceWrapper_Methods, - 0, // tp_members - 0, // tp_getset - 0, // tp_base - 0, // tp_dict - 0, // tp_descr_get - 0, // tp_descr_set + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set 0, // tp_dictoffset - 0, // tp_init + nullptr, // tp_init PyType_GenericAlloc, - 0, // tp_new + nullptr, // tp_new PyObject_Del, - 0, // tp_is_gc - 0, // tp_bases - 0, // tp_mro - 0, // tp_cache - 0, // tp_subclasses - 0, // tp_weaklist - 0, // tp_del + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del }; /** @@ -945,21 +945,21 @@ PyTypeObject Dtool_MutableSequenceWrapper_Type = { */ static PySequenceMethods Dtool_MappingWrapper_SequenceMethods = { Dtool_SequenceWrapper_length, - 0, // sq_concat - 0, // sq_repeat - 0, // sq_item - 0, // sq_slice - 0, // sq_ass_item - 0, // sq_ass_slice + nullptr, // sq_concat + nullptr, // sq_repeat + nullptr, // sq_item + nullptr, // sq_slice + nullptr, // sq_ass_item + nullptr, // sq_ass_slice Dtool_MappingWrapper_contains, - 0, // sq_inplace_concat - 0, // sq_inplace_repeat + nullptr, // sq_inplace_concat + nullptr, // sq_inplace_repeat }; static PyMappingMethods Dtool_MappingWrapper_MappingMethods = { Dtool_SequenceWrapper_length, Dtool_MappingWrapper_getitem, - 0, // mp_ass_subscript + nullptr, // mp_ass_subscript }; static PyMethodDef Dtool_MappingWrapper_Methods[] = { @@ -976,47 +976,47 @@ PyTypeObject Dtool_MappingWrapper_Type = { sizeof(Dtool_MappingWrapper), 0, // tp_itemsize Dtool_WrapperBase_dealloc, - 0, // tp_print - 0, // tp_getattr - 0, // tp_setattr - 0, // tp_compare + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare Dtool_WrapperBase_repr, - 0, // tp_as_number + nullptr, // tp_as_number &Dtool_MappingWrapper_SequenceMethods, &Dtool_MappingWrapper_MappingMethods, - 0, // tp_hash - 0, // tp_call - 0, // tp_str + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str PyObject_GenericGetAttr, PyObject_GenericSetAttr, - 0, // tp_as_buffer + nullptr, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - 0, // tp_doc - 0, // tp_traverse - 0, // tp_clear - 0, // tp_richcompare + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare 0, // tp_weaklistoffset Dtool_MappingWrapper_iter, - 0, // tp_iternext + nullptr, // tp_iternext Dtool_MappingWrapper_Methods, - 0, // tp_members - 0, // tp_getset - 0, // tp_base - 0, // tp_dict - 0, // tp_descr_get - 0, // tp_descr_set + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set 0, // tp_dictoffset - 0, // tp_init + nullptr, // tp_init PyType_GenericAlloc, - 0, // tp_new + nullptr, // tp_new PyObject_Del, - 0, // tp_is_gc - 0, // tp_bases - 0, // tp_mro - 0, // tp_cache - 0, // tp_subclasses - 0, // tp_weaklist - 0, // tp_del + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del }; /** @@ -1047,47 +1047,47 @@ PyTypeObject Dtool_MutableMappingWrapper_Type = { sizeof(Dtool_MappingWrapper), 0, // tp_itemsize Dtool_WrapperBase_dealloc, - 0, // tp_print - 0, // tp_getattr - 0, // tp_setattr - 0, // tp_compare + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare Dtool_WrapperBase_repr, - 0, // tp_as_number + nullptr, // tp_as_number &Dtool_MappingWrapper_SequenceMethods, &Dtool_MutableMappingWrapper_MappingMethods, - 0, // tp_hash - 0, // tp_call - 0, // tp_str + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str PyObject_GenericGetAttr, PyObject_GenericSetAttr, - 0, // tp_as_buffer + nullptr, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - 0, // tp_doc - 0, // tp_traverse - 0, // tp_clear - 0, // tp_richcompare + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare 0, // tp_weaklistoffset Dtool_MappingWrapper_iter, - 0, // tp_iternext + nullptr, // tp_iternext Dtool_MutableMappingWrapper_Methods, - 0, // tp_members - 0, // tp_getset - 0, // tp_base - 0, // tp_dict - 0, // tp_descr_get - 0, // tp_descr_set + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set 0, // tp_dictoffset - 0, // tp_init + nullptr, // tp_init PyType_GenericAlloc, - 0, // tp_new + nullptr, // tp_new PyObject_Del, - 0, // tp_is_gc - 0, // tp_bases - 0, // tp_mro - 0, // tp_cache - 0, // tp_subclasses - 0, // tp_weaklist - 0, // tp_del + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del }; /** @@ -1131,15 +1131,15 @@ static PyObject *Dtool_MappingWrapper_Items_getitem(PyObject *self, Py_ssize_t i static PySequenceMethods Dtool_MappingWrapper_Items_SequenceMethods = { Dtool_SequenceWrapper_length, - 0, // sq_concat - 0, // sq_repeat + nullptr, // sq_concat + nullptr, // sq_repeat Dtool_MappingWrapper_Items_getitem, - 0, // sq_slice - 0, // sq_ass_item - 0, // sq_ass_slice + nullptr, // sq_slice + nullptr, // sq_ass_item + nullptr, // sq_ass_slice Dtool_MappingWrapper_contains, - 0, // sq_inplace_concat - 0, // sq_inplace_repeat + nullptr, // sq_inplace_concat + nullptr, // sq_inplace_repeat }; PyTypeObject Dtool_MappingWrapper_Items_Type = { @@ -1148,47 +1148,47 @@ PyTypeObject Dtool_MappingWrapper_Items_Type = { sizeof(Dtool_MappingWrapper), 0, // tp_itemsize Dtool_WrapperBase_dealloc, - 0, // tp_print - 0, // tp_getattr - 0, // tp_setattr - 0, // tp_compare + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare Dtool_MappingWrapper_Items_repr, - 0, // tp_as_number + nullptr, // tp_as_number &Dtool_MappingWrapper_Items_SequenceMethods, - 0, // tp_as_mapping - 0, // tp_hash - 0, // tp_call - 0, // tp_str + nullptr, // tp_as_mapping + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str PyObject_GenericGetAttr, PyObject_GenericSetAttr, - 0, // tp_as_buffer + nullptr, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - 0, // tp_doc - 0, // tp_traverse - 0, // tp_clear - 0, // tp_richcompare + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare 0, // tp_weaklistoffset PySeqIter_New, - 0, // tp_iternext - 0, // tp_methods - 0, // tp_members - 0, // tp_getset - 0, // tp_base - 0, // tp_dict - 0, // tp_descr_get - 0, // tp_descr_set + nullptr, // tp_iternext + nullptr, // tp_methods + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set 0, // tp_dictoffset - 0, // tp_init + nullptr, // tp_init PyType_GenericAlloc, - 0, // tp_new + nullptr, // tp_new PyObject_Del, - 0, // tp_is_gc - 0, // tp_bases - 0, // tp_mro - 0, // tp_cache - 0, // tp_subclasses - 0, // tp_weaklist - 0, // tp_del + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del }; /** @@ -1211,15 +1211,15 @@ static PyObject *Dtool_MappingWrapper_Keys_repr(PyObject *self) { static PySequenceMethods Dtool_MappingWrapper_Keys_SequenceMethods = { Dtool_SequenceWrapper_length, - 0, // sq_concat - 0, // sq_repeat + nullptr, // sq_concat + nullptr, // sq_repeat Dtool_MappingWrapper_Items_getitem, - 0, // sq_slice - 0, // sq_ass_item - 0, // sq_ass_slice + nullptr, // sq_slice + nullptr, // sq_ass_item + nullptr, // sq_ass_slice Dtool_MappingWrapper_contains, - 0, // sq_inplace_concat - 0, // sq_inplace_repeat + nullptr, // sq_inplace_concat + nullptr, // sq_inplace_repeat }; PyTypeObject Dtool_MappingWrapper_Keys_Type = { @@ -1228,47 +1228,47 @@ PyTypeObject Dtool_MappingWrapper_Keys_Type = { sizeof(Dtool_SequenceWrapper), 0, // tp_itemsize Dtool_WrapperBase_dealloc, - 0, // tp_print - 0, // tp_getattr - 0, // tp_setattr - 0, // tp_compare + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare Dtool_MappingWrapper_Keys_repr, - 0, // tp_as_number + nullptr, // tp_as_number &Dtool_SequenceWrapper_SequenceMethods, - 0, // tp_as_mapping - 0, // tp_hash - 0, // tp_call - 0, // tp_str + nullptr, // tp_as_mapping + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str PyObject_GenericGetAttr, PyObject_GenericSetAttr, - 0, // tp_as_buffer + nullptr, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - 0, // tp_doc - 0, // tp_traverse - 0, // tp_clear - 0, // tp_richcompare + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare 0, // tp_weaklistoffset PySeqIter_New, - 0, // tp_iternext - 0, // tp_methods - 0, // tp_members - 0, // tp_getset - 0, // tp_base - 0, // tp_dict - 0, // tp_descr_get - 0, // tp_descr_set + nullptr, // tp_iternext + nullptr, // tp_methods + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set 0, // tp_dictoffset - 0, // tp_init + nullptr, // tp_init PyType_GenericAlloc, - 0, // tp_new + nullptr, // tp_new PyObject_Del, - 0, // tp_is_gc - 0, // tp_bases - 0, // tp_mro - 0, // tp_cache - 0, // tp_subclasses - 0, // tp_weaklist - 0, // tp_del + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del }; /** @@ -1305,15 +1305,15 @@ static PyObject *Dtool_MappingWrapper_Values_getitem(PyObject *self, Py_ssize_t static PySequenceMethods Dtool_MappingWrapper_Values_SequenceMethods = { Dtool_SequenceWrapper_length, - 0, // sq_concat - 0, // sq_repeat + nullptr, // sq_concat + nullptr, // sq_repeat Dtool_MappingWrapper_Values_getitem, - 0, // sq_slice - 0, // sq_ass_item - 0, // sq_ass_slice + nullptr, // sq_slice + nullptr, // sq_ass_item + nullptr, // sq_ass_slice Dtool_MappingWrapper_contains, - 0, // sq_inplace_concat - 0, // sq_inplace_repeat + nullptr, // sq_inplace_concat + nullptr, // sq_inplace_repeat }; PyTypeObject Dtool_MappingWrapper_Values_Type = { @@ -1322,47 +1322,47 @@ PyTypeObject Dtool_MappingWrapper_Values_Type = { sizeof(Dtool_MappingWrapper), 0, // tp_itemsize Dtool_WrapperBase_dealloc, - 0, // tp_print - 0, // tp_getattr - 0, // tp_setattr - 0, // tp_compare + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare Dtool_MappingWrapper_Values_repr, - 0, // tp_as_number + nullptr, // tp_as_number &Dtool_MappingWrapper_Values_SequenceMethods, - 0, // tp_as_mapping - 0, // tp_hash - 0, // tp_call - 0, // tp_str + nullptr, // tp_as_mapping + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str PyObject_GenericGetAttr, PyObject_GenericSetAttr, - 0, // tp_as_buffer + nullptr, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - 0, // tp_doc - 0, // tp_traverse - 0, // tp_clear - 0, // tp_richcompare + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare 0, // tp_weaklistoffset PySeqIter_New, - 0, // tp_iternext - 0, // tp_methods - 0, // tp_members - 0, // tp_getset - 0, // tp_base - 0, // tp_dict - 0, // tp_descr_get - 0, // tp_descr_set + nullptr, // tp_iternext + nullptr, // tp_methods + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set 0, // tp_dictoffset - 0, // tp_init + nullptr, // tp_init PyType_GenericAlloc, - 0, // tp_new + nullptr, // tp_new PyObject_Del, - 0, // tp_is_gc - 0, // tp_bases - 0, // tp_mro - 0, // tp_cache - 0, // tp_subclasses - 0, // tp_weaklist - 0, // tp_del + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del }; /** @@ -1381,47 +1381,47 @@ PyTypeObject Dtool_GeneratorWrapper_Type = { sizeof(Dtool_GeneratorWrapper), 0, // tp_itemsize Dtool_WrapperBase_dealloc, - 0, // tp_print - 0, // tp_getattr - 0, // tp_setattr - 0, // tp_compare - 0, // tp_repr - 0, // tp_as_number - 0, // tp_as_sequence - 0, // tp_as_mapping - 0, // tp_hash - 0, // tp_call - 0, // tp_str + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_compare + nullptr, // tp_repr + nullptr, // tp_as_number + nullptr, // tp_as_sequence + nullptr, // tp_as_mapping + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str PyObject_GenericGetAttr, PyObject_GenericSetAttr, - 0, // tp_as_buffer + nullptr, // tp_as_buffer Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, - 0, // tp_doc - 0, // tp_traverse - 0, // tp_clear - 0, // tp_richcompare + nullptr, // tp_doc + nullptr, // tp_traverse + nullptr, // tp_clear + nullptr, // tp_richcompare 0, // tp_weaklistoffset PyObject_SelfIter, Dtool_GeneratorWrapper_iternext, - 0, // tp_methods - 0, // tp_members - 0, // tp_getset - 0, // tp_base - 0, // tp_dict - 0, // tp_descr_get - 0, // tp_descr_set + nullptr, // tp_methods + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict + nullptr, // tp_descr_get + nullptr, // tp_descr_set 0, // tp_dictoffset - 0, // tp_init + nullptr, // tp_init PyType_GenericAlloc, - 0, // tp_new + nullptr, // tp_new PyObject_Del, - 0, // tp_is_gc - 0, // tp_bases - 0, // tp_mro - 0, // tp_cache - 0, // tp_subclasses - 0, // tp_weaklist - 0, // tp_del + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del }; /** @@ -1498,47 +1498,47 @@ PyTypeObject Dtool_StaticProperty_Type = { sizeof(PyGetSetDescrObject), 0, // tp_itemsize (destructor)Dtool_StaticProperty_dealloc, - 0, // tp_print - 0, // tp_getattr - 0, // tp_setattr - 0, // tp_reserved + nullptr, // tp_print + nullptr, // tp_getattr + nullptr, // tp_setattr + nullptr, // tp_reserved (reprfunc)Dtool_StaticProperty_repr, - 0, // tp_as_number - 0, // tp_as_sequence - 0, // tp_as_mapping - 0, // tp_hash - 0, // tp_call - 0, // tp_str + nullptr, // tp_as_number + nullptr, // tp_as_sequence + nullptr, // tp_as_mapping + nullptr, // tp_hash + nullptr, // tp_call + nullptr, // tp_str PyObject_GenericGetAttr, - 0, // tp_setattro - 0, // tp_as_buffer + nullptr, // tp_setattro + nullptr, // tp_as_buffer Py_TPFLAGS_DEFAULT, - 0, // tp_doc + nullptr, // tp_doc Dtool_StaticProperty_traverse, - 0, // tp_clear - 0, // tp_richcompare + nullptr, // tp_clear + nullptr, // tp_richcompare 0, // tp_weaklistoffset - 0, // tp_iter - 0, // tp_iternext - 0, // tp_methods - 0, // tp_members - 0, // tp_getset - 0, // tp_base - 0, // tp_dict + nullptr, // tp_iter + nullptr, // tp_iternext + nullptr, // tp_methods + nullptr, // tp_members + nullptr, // tp_getset + nullptr, // tp_base + nullptr, // tp_dict (descrgetfunc)Dtool_StaticProperty_get, (descrsetfunc)Dtool_StaticProperty_set, 0, // tp_dictoffset - 0, // tp_init - 0, // tp_alloc - 0, // tp_new - 0, // tp_del - 0, // tp_is_gc - 0, // tp_bases - 0, // tp_mro - 0, // tp_cache - 0, // tp_subclasses - 0, // tp_weaklist - 0, // tp_del + nullptr, // tp_init + nullptr, // tp_alloc + nullptr, // tp_new + nullptr, // tp_del + nullptr, // tp_is_gc + nullptr, // tp_bases + nullptr, // tp_mro + nullptr, // tp_cache + nullptr, // tp_subclasses + nullptr, // tp_weaklist + nullptr, // tp_del }; /** diff --git a/dtool/src/prc/androidLogStream.cxx b/dtool/src/prc/androidLogStream.cxx index 6427b9163a..2dd32f7c5b 100644 --- a/dtool/src/prc/androidLogStream.cxx +++ b/dtool/src/prc/androidLogStream.cxx @@ -124,9 +124,9 @@ AndroidLogStream:: */ ostream &AndroidLogStream:: out(NotifySeverity severity) { - static AndroidLogStream* streams[NS_fatal + 1] = {NULL}; + static AndroidLogStream* streams[NS_fatal + 1] = {nullptr}; - if (streams[severity] == NULL) { + if (streams[severity] == nullptr) { int priority = ANDROID_LOG_UNKNOWN; if (severity != NS_unspecified) { priority = ((int)severity) + 1; diff --git a/dtool/src/prc/configPage.cxx b/dtool/src/prc/configPage.cxx index 981caadf87..ce515529c2 100644 --- a/dtool/src/prc/configPage.cxx +++ b/dtool/src/prc/configPage.cxx @@ -25,8 +25,8 @@ #include "openssl/evp.h" #endif -ConfigPage *ConfigPage::_default_page = NULL; -ConfigPage *ConfigPage::_local_page = NULL; +ConfigPage *ConfigPage::_default_page = nullptr; +ConfigPage *ConfigPage::_local_page = nullptr; /** * The constructor is private because a ConfigPage should be constructed via @@ -58,7 +58,7 @@ ConfigPage:: */ ConfigPage *ConfigPage:: get_default_page() { - if (_default_page == (ConfigPage *)NULL) { + if (_default_page == nullptr) { _default_page = new ConfigPage("default", false, 0); } return _default_page; @@ -71,7 +71,7 @@ get_default_page() { */ ConfigPage *ConfigPage:: get_local_page() { - if (_local_page == (ConfigPage *)NULL) { + if (_local_page == nullptr) { _local_page = new ConfigPage("local", false, 0); } return _local_page; @@ -142,7 +142,7 @@ read_prc(istream &in) { // Look for the first line in the buffer.. char *newline = (char *)memchr((void *)buffer, '\n', count); - if (newline == (char *)NULL) { + if (newline == nullptr) { // The buffer was one long line. Huh. prev_line += string(buffer, count); @@ -154,7 +154,7 @@ read_prc(istream &in) { // Now look for the next line, etc. char *start = newline + 1; newline = (char *)memchr((void *)start, '\n', buffer_end - start); - while (newline != (char *)NULL) { + while (newline != nullptr) { length = newline - start; read_prc_line(string(start, length + 1)); start = newline + 1; @@ -189,7 +189,7 @@ read_prc(istream &in) { int num_keys = pkr->get_num_keys(); for (int i = 1; i < num_keys && _trust_level == 0; i++) { EVP_PKEY *pkey = pkr->get_key(i); - if (pkey != (EVP_PKEY *)NULL) { + if (pkey != nullptr) { int verify_result = EVP_VerifyFinal((EVP_MD_CTX *)_md_ctx, (unsigned char *)_signature.data(), @@ -283,7 +283,7 @@ get_num_declarations() const { */ const ConfigDeclaration *ConfigPage:: get_declaration(size_t n) const { - nassertr(n < _declarations.size(), (ConfigDeclaration *)NULL); + nassertr(n < _declarations.size(), nullptr); return _declarations[n]; } @@ -294,7 +294,7 @@ get_declaration(size_t n) const { */ ConfigDeclaration *ConfigPage:: modify_declaration(size_t n) { - nassertr(n < _declarations.size(), (ConfigDeclaration *)NULL); + nassertr(n < _declarations.size(), nullptr); return _declarations[n]; } diff --git a/dtool/src/prc/configPageManager.I b/dtool/src/prc/configPageManager.I index 16dbeb3e6c..cd95cce50f 100644 --- a/dtool/src/prc/configPageManager.I +++ b/dtool/src/prc/configPageManager.I @@ -123,7 +123,7 @@ get_num_implicit_pages() const { INLINE ConfigPage *ConfigPageManager:: get_implicit_page(size_t n) const { check_sort_pages(); - nassertr(n < _implicit_pages.size(), (ConfigPage *)NULL); + nassertr(n < _implicit_pages.size(), nullptr); return _implicit_pages[n]; } @@ -144,7 +144,7 @@ get_num_explicit_pages() const { INLINE ConfigPage *ConfigPageManager:: get_explicit_page(size_t n) const { check_sort_pages(); - nassertr(n < _explicit_pages.size(), (ConfigPage *)NULL); + nassertr(n < _explicit_pages.size(), nullptr); return _explicit_pages[n]; } diff --git a/dtool/src/prc/configPageManager.cxx b/dtool/src/prc/configPageManager.cxx index f7868aa394..8065ac3261 100644 --- a/dtool/src/prc/configPageManager.cxx +++ b/dtool/src/prc/configPageManager.cxx @@ -37,7 +37,7 @@ #include #include -ConfigPageManager *ConfigPageManager::_global_ptr = NULL; +ConfigPageManager *ConfigPageManager::_global_ptr = nullptr; /** * The constructor is private (actually, just protected, but only to avoid a @@ -500,7 +500,7 @@ write(ostream &out) const { */ ConfigPageManager *ConfigPageManager:: get_global_ptr() { - if (_global_ptr == (ConfigPageManager *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new ConfigPageManager; } return _global_ptr; diff --git a/dtool/src/prc/configVariable.I b/dtool/src/prc/configVariable.I index b46bc63529..92842ab0dd 100644 --- a/dtool/src/prc/configVariable.I +++ b/dtool/src/prc/configVariable.I @@ -57,7 +57,7 @@ INLINE ConfigVariable:: */ INLINE const ConfigDeclaration *ConfigVariable:: get_default_value() const { - nassertr(is_constructed(), (ConfigDeclaration *)NULL); + nassertr(is_constructed(), nullptr); return _core->get_default_value(); } @@ -273,7 +273,7 @@ set_double_word(size_t n, double value) { INLINE bool ConfigVariable:: is_constructed() const { #ifndef NDEBUG - if (_core == (ConfigVariableCore *)NULL) { + if (_core == nullptr) { report_unconstructed(); return false; } diff --git a/dtool/src/prc/configVariableBase.I b/dtool/src/prc/configVariableBase.I index 09db1c4088..29bf58f72a 100644 --- a/dtool/src/prc/configVariableBase.I +++ b/dtool/src/prc/configVariableBase.I @@ -37,7 +37,7 @@ INLINE ConfigVariableBase:: */ INLINE const string &ConfigVariableBase:: get_name() const { - nassertr(_core != (ConfigVariableCore *)NULL, *new string()); + nassertr(_core != nullptr, *new string()); return _core->get_name(); } @@ -47,7 +47,7 @@ get_name() const { */ INLINE ConfigVariableBase::ValueType ConfigVariableBase:: get_value_type() const { - nassertr(_core != (ConfigVariableCore *)NULL, VT_undefined); + nassertr(_core != nullptr, VT_undefined); return _core->get_value_type(); } @@ -56,7 +56,7 @@ get_value_type() const { */ INLINE const string &ConfigVariableBase:: get_description() const { - nassertr(_core != (ConfigVariableCore *)NULL, *new string()); + nassertr(_core != nullptr, *new string()); return _core->get_description(); } @@ -68,7 +68,7 @@ get_description() const { */ INLINE int ConfigVariableBase:: get_flags() const { - nassertr(_core != (ConfigVariableCore *)NULL, 0); + nassertr(_core != nullptr, 0); return _core->get_flags(); } @@ -83,7 +83,7 @@ get_flags() const { */ INLINE bool ConfigVariableBase:: is_closed() const { - nassertr(_core != (ConfigVariableCore *)NULL, false); + nassertr(_core != nullptr, false); return _core->is_closed(); } @@ -99,7 +99,7 @@ is_closed() const { */ INLINE int ConfigVariableBase:: get_trust_level() const { - nassertr(_core != (ConfigVariableCore *)NULL, 0); + nassertr(_core != nullptr, 0); return _core->get_trust_level(); } @@ -110,7 +110,7 @@ get_trust_level() const { */ INLINE bool ConfigVariableBase:: is_dynamic() const { - nassertr(_core != (ConfigVariableCore *)NULL, false); + nassertr(_core != nullptr, false); return _core->is_dynamic(); } @@ -123,7 +123,7 @@ is_dynamic() const { */ INLINE bool ConfigVariableBase:: clear_local_value() { - nassertr(_core != (ConfigVariableCore *)NULL, false); + nassertr(_core != nullptr, false); return _core->clear_local_value(); } @@ -133,7 +133,7 @@ clear_local_value() { */ INLINE bool ConfigVariableBase:: has_local_value() const { - nassertr(_core != (ConfigVariableCore *)NULL, false); + nassertr(_core != nullptr, false); return _core->has_local_value(); } @@ -143,7 +143,7 @@ has_local_value() const { */ INLINE bool ConfigVariableBase:: has_value() const { - nassertr(_core != (ConfigVariableCore *)NULL, false); + nassertr(_core != nullptr, false); return _core->has_value(); } @@ -152,7 +152,7 @@ has_value() const { */ INLINE void ConfigVariableBase:: output(ostream &out) const { - nassertv(_core != (ConfigVariableCore *)NULL); + nassertv(_core != nullptr); _core->output(out); } @@ -161,7 +161,7 @@ output(ostream &out) const { */ INLINE void ConfigVariableBase:: write(ostream &out) const { - nassertv(_core != (ConfigVariableCore *)NULL); + nassertv(_core != nullptr); _core->write(out); } diff --git a/dtool/src/prc/configVariableBase.cxx b/dtool/src/prc/configVariableBase.cxx index 52b113b79a..55643704b7 100644 --- a/dtool/src/prc/configVariableBase.cxx +++ b/dtool/src/prc/configVariableBase.cxx @@ -55,7 +55,7 @@ ConfigVariableBase(const string &name, void ConfigVariableBase:: record_unconstructed() const { #ifndef NDEBUG - if (_unconstructed == (Unconstructed *)NULL) { + if (_unconstructed == nullptr) { _unconstructed = new Unconstructed; } _unconstructed->insert(this); @@ -69,7 +69,7 @@ record_unconstructed() const { bool ConfigVariableBase:: was_unconstructed() const { #ifndef NDEBUG - if (_unconstructed != (Unconstructed *)NULL) { + if (_unconstructed != nullptr) { Unconstructed::const_iterator ui = _unconstructed->find(this); if (ui != _unconstructed->end()) { return true; diff --git a/dtool/src/prc/configVariableBool.I b/dtool/src/prc/configVariableBool.I index 7eba0820d0..25c9e833f1 100644 --- a/dtool/src/prc/configVariableBool.I +++ b/dtool/src/prc/configVariableBool.I @@ -115,7 +115,7 @@ get_value() const { INLINE bool ConfigVariableBool:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { return decl->get_bool_word(0); } return false; diff --git a/dtool/src/prc/configVariableCore.I b/dtool/src/prc/configVariableCore.I index 057beb0449..95f8829a2a 100644 --- a/dtool/src/prc/configVariableCore.I +++ b/dtool/src/prc/configVariableCore.I @@ -118,7 +118,7 @@ set_used() { */ INLINE bool ConfigVariableCore:: has_local_value() const { - return _local_value != (ConfigDeclaration *)NULL; + return _local_value != nullptr; } /** @@ -141,7 +141,7 @@ get_num_references() const { INLINE const ConfigDeclaration *ConfigVariableCore:: get_reference(size_t n) const { check_sort_declarations(); - nassertr(n < _declarations.size(), (ConfigDeclaration *)NULL); + nassertr(n < _declarations.size(), nullptr); return _declarations[n]; } @@ -167,7 +167,7 @@ get_num_trusted_references() const { INLINE const ConfigDeclaration *ConfigVariableCore:: get_trusted_reference(size_t n) const { check_sort_declarations(); - nassertr(n < _trusted_declarations.size(), (ConfigDeclaration *)NULL); + nassertr(n < _trusted_declarations.size(), nullptr); return _trusted_declarations[n]; } @@ -188,7 +188,7 @@ get_num_unique_references() const { INLINE const ConfigDeclaration *ConfigVariableCore:: get_unique_reference(size_t n) const { check_sort_declarations(); - nassertr(n < _unique_declarations.size(), (ConfigDeclaration *)NULL); + nassertr(n < _unique_declarations.size(), nullptr); return _unique_declarations[n]; } diff --git a/dtool/src/prc/configVariableCore.cxx b/dtool/src/prc/configVariableCore.cxx index 7bf355ba3c..b2ab7d277a 100644 --- a/dtool/src/prc/configVariableCore.cxx +++ b/dtool/src/prc/configVariableCore.cxx @@ -34,8 +34,8 @@ ConfigVariableCore(const string &name) : _is_used(false), _value_type(VT_undefined), _flags(0), - _default_value(NULL), - _local_value(NULL), + _default_value(nullptr), + _local_value(nullptr), _declarations_sorted(true), _value_queried(false) { @@ -56,12 +56,12 @@ ConfigVariableCore(const ConfigVariableCore &templ, const string &name) : _value_type(templ._value_type), _description(templ._description), _flags(templ._flags), - _default_value(NULL), - _local_value(NULL), + _default_value(nullptr), + _local_value(nullptr), _declarations_sorted(false), _value_queried(false) { - if (templ._default_value != (ConfigDeclaration *)NULL) { + if (templ._default_value != nullptr) { set_default_value(templ._default_value->get_string_value()); } } @@ -187,7 +187,7 @@ set_description(const string &description) { */ void ConfigVariableCore:: set_default_value(const string &default_value) { - if (_default_value == (ConfigDeclaration *)NULL) { + if (_default_value == nullptr) { // Defining the default value for the first time. ConfigPage *default_page = ConfigPage::get_default_page(); _default_value = default_page->make_declaration(this, default_value); @@ -228,7 +228,7 @@ set_default_value(const string &default_value) { */ ConfigDeclaration *ConfigVariableCore:: make_local_value() { - if (_local_value == (ConfigDeclaration *)NULL) { + if (_local_value == nullptr) { ConfigPage *local_page = ConfigPage::get_local_page(); string string_value = get_declaration(0)->get_string_value(); _local_value = local_page->make_declaration(this, string_value); @@ -253,9 +253,9 @@ make_local_value() { */ bool ConfigVariableCore:: clear_local_value() { - if (_local_value != (ConfigDeclaration *)NULL) { + if (_local_value != nullptr) { ConfigPage::get_local_page()->delete_declaration(_local_value); - _local_value = (ConfigDeclaration *)NULL; + _local_value = nullptr; invalidate_cache(); return true; } @@ -304,7 +304,7 @@ get_num_declarations() const { const ConfigDeclaration *ConfigVariableCore:: get_declaration(size_t n) const { ((ConfigVariableCore *)this)->_value_queried = true; - if (_default_value == (ConfigDeclaration *)NULL) { + if (_default_value == nullptr) { prc_cat->warning() << "value queried before default value set for " << get_name() << ".\n"; @@ -350,7 +350,7 @@ write(ostream &out) const { << " (from " << (*di)->get_page()->get_name() << ")\n"; } - if (_default_value != (ConfigDeclaration *)NULL) { + if (_default_value != nullptr) { out << " " << *_default_value << " (default value)\n"; } diff --git a/dtool/src/prc/configVariableDouble.I b/dtool/src/prc/configVariableDouble.I index 8cd2cd1e91..e93f39830e 100644 --- a/dtool/src/prc/configVariableDouble.I +++ b/dtool/src/prc/configVariableDouble.I @@ -116,7 +116,7 @@ get_value() const { INLINE double ConfigVariableDouble:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { return decl->get_double_word(0); } return 0.0; diff --git a/dtool/src/prc/configVariableEnum.I b/dtool/src/prc/configVariableEnum.I index 04464fcc41..6ae9327119 100644 --- a/dtool/src/prc/configVariableEnum.I +++ b/dtool/src/prc/configVariableEnum.I @@ -126,7 +126,7 @@ INLINE EnumType ConfigVariableEnum:: get_default_value() const { if (!_got_default_value) { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { ((ConfigVariableEnum *)this)->_default_value = (EnumType)parse_string(decl->get_string_value()); ((ConfigVariableEnum *)this)->_got_default_value = true; } diff --git a/dtool/src/prc/configVariableFilename.I b/dtool/src/prc/configVariableFilename.I index d84d92dcb0..8e6ca228b3 100644 --- a/dtool/src/prc/configVariableFilename.I +++ b/dtool/src/prc/configVariableFilename.I @@ -195,7 +195,7 @@ get_value() const { INLINE Filename ConfigVariableFilename:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { return Filename::expand_from(decl->get_string_value()); } return Filename(); diff --git a/dtool/src/prc/configVariableFilename.cxx b/dtool/src/prc/configVariableFilename.cxx index 1679082ef5..4c8941babd 100644 --- a/dtool/src/prc/configVariableFilename.cxx +++ b/dtool/src/prc/configVariableFilename.cxx @@ -28,7 +28,7 @@ reload_cache() { // We check again for cache validity since another thread may have beaten // us to the punch while we were waiting for the lock. if (!is_cache_valid(_local_modified)) { - nassertv(_core != (ConfigVariableCore *)NULL); + nassertv(_core != nullptr); const ConfigDeclaration *decl = _core->get_declaration(0); const ConfigPage *page = decl->get_page(); diff --git a/dtool/src/prc/configVariableInt.I b/dtool/src/prc/configVariableInt.I index 7c91ce1d6a..bdafa4b817 100644 --- a/dtool/src/prc/configVariableInt.I +++ b/dtool/src/prc/configVariableInt.I @@ -116,7 +116,7 @@ get_value() const { INLINE int ConfigVariableInt:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { return decl->get_int_word(0); } return 0; diff --git a/dtool/src/prc/configVariableInt64.I b/dtool/src/prc/configVariableInt64.I index f7c1c5d66b..534905b0e8 100644 --- a/dtool/src/prc/configVariableInt64.I +++ b/dtool/src/prc/configVariableInt64.I @@ -116,7 +116,7 @@ get_value() const { INLINE int64_t ConfigVariableInt64:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { return decl->get_int64_word(0); } return 0; diff --git a/dtool/src/prc/configVariableList.I b/dtool/src/prc/configVariableList.I index 4429e31fb9..a3e96c5a17 100644 --- a/dtool/src/prc/configVariableList.I +++ b/dtool/src/prc/configVariableList.I @@ -33,7 +33,7 @@ ConfigVariableList(const string &name, // A list variable implicitly defines a default value of the empty string. // This is just to prevent the core variable from complaining should anyone // ask for its solitary value. - if (_core->get_default_value() == (ConfigDeclaration *)NULL) { + if (_core->get_default_value() == nullptr) { _core->set_default_value(""); } _core->set_used(); @@ -44,7 +44,7 @@ ConfigVariableList(const string &name, */ INLINE size_t ConfigVariableList:: get_num_values() const { - nassertr(_core != (ConfigVariableCore *)NULL, 0); + nassertr(_core != nullptr, 0); return _core->get_num_trusted_references(); } @@ -53,9 +53,9 @@ get_num_values() const { */ INLINE string ConfigVariableList:: get_string_value(size_t n) const { - nassertr(_core != (ConfigVariableCore *)NULL, string()); + nassertr(_core != nullptr, string()); const ConfigDeclaration *decl = _core->get_trusted_reference(n); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { return decl->get_string_value(); } return string(); @@ -66,7 +66,7 @@ get_string_value(size_t n) const { */ INLINE size_t ConfigVariableList:: get_num_unique_values() const { - nassertr(_core != (ConfigVariableCore *)NULL, 0); + nassertr(_core != nullptr, 0); return _core->get_num_unique_references(); } @@ -75,9 +75,9 @@ get_num_unique_values() const { */ INLINE string ConfigVariableList:: get_unique_value(size_t n) const { - nassertr(_core != (ConfigVariableCore *)NULL, string()); + nassertr(_core != nullptr, string()); const ConfigDeclaration *decl = _core->get_unique_reference(n); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { return decl->get_string_value(); } return string(); diff --git a/dtool/src/prc/configVariableManager.I b/dtool/src/prc/configVariableManager.I index 4ca5363bde..6c92874e9c 100644 --- a/dtool/src/prc/configVariableManager.I +++ b/dtool/src/prc/configVariableManager.I @@ -24,7 +24,7 @@ get_num_variables() const { */ INLINE ConfigVariableCore *ConfigVariableManager:: get_variable(size_t n) const { - nassertr(n < _variables.size(), (ConfigVariableCore *)NULL); + nassertr(n < _variables.size(), nullptr); return _variables[n]; } diff --git a/dtool/src/prc/configVariableManager.cxx b/dtool/src/prc/configVariableManager.cxx index 4231abbbaa..52f7269f6b 100644 --- a/dtool/src/prc/configVariableManager.cxx +++ b/dtool/src/prc/configVariableManager.cxx @@ -17,7 +17,7 @@ #include "configPage.h" #include "config_prc.h" -ConfigVariableManager *ConfigVariableManager::_global_ptr = NULL; +ConfigVariableManager *ConfigVariableManager::_global_ptr = nullptr; /** * The constructor is private (actually, just protected, but only to avoid a @@ -52,12 +52,12 @@ make_variable(const string &name) { return (*ni).second; } - ConfigVariableCore *variable = NULL; + ConfigVariableCore *variable = nullptr; // See if there's a template that matches this name. VariableTemplates::const_iterator ti; for (ti = _variable_templates.begin(); - ti != _variable_templates.end() && variable == (ConfigVariableCore *)NULL; + ti != _variable_templates.end() && variable == nullptr; ++ti) { const GlobPattern &pattern = (*ti).first; ConfigVariableCore *templ = (*ti).second; @@ -66,7 +66,7 @@ make_variable(const string &name) { } } - if (variable == (ConfigVariableCore *)NULL) { + if (variable == nullptr) { variable = new ConfigVariableCore(name); } @@ -116,7 +116,7 @@ make_variable_template(const string &pattern, core->set_value_type(value_type); } if (!default_value.empty() || - core->get_default_value() == (ConfigDeclaration *)NULL) { + core->get_default_value() == nullptr) { core->set_default_value(default_value); } if (!description.empty()) { @@ -137,7 +137,7 @@ make_variable_template(const string &pattern, variable->set_value_type(value_type); } if (!default_value.empty() || - variable->get_default_value() == (ConfigDeclaration *)NULL) { + variable->get_default_value() == nullptr) { variable->set_default_value(default_value); } if (!description.empty()) { @@ -300,7 +300,7 @@ list_dynamic_variables() const { */ ConfigVariableManager *ConfigVariableManager:: get_global_ptr() { - if (_global_ptr == (ConfigVariableManager *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new ConfigVariableManager; } return _global_ptr; @@ -357,7 +357,7 @@ list_variable(const ConfigVariableCore *variable, } decl = variable->get_default_value(); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { nout << " default value = " << decl->get_string_value() << "\n"; } } diff --git a/dtool/src/prc/configVariableSearchPath.I b/dtool/src/prc/configVariableSearchPath.I index 9017d1cf0a..c9294f119e 100644 --- a/dtool/src/prc/configVariableSearchPath.I +++ b/dtool/src/prc/configVariableSearchPath.I @@ -28,7 +28,7 @@ ConfigVariableSearchPath(const string &name, // A SearchPath variable implicitly defines a default value of the empty // string. This is just to prevent the core variable from complaining // should anyone ask for its solitary value. - if (_core->get_default_value() == (ConfigDeclaration *)NULL) { + if (_core->get_default_value() == nullptr) { _core->set_default_value(""); } _core->set_used(); @@ -52,7 +52,7 @@ ConfigVariableSearchPath(const string &name, // A SearchPath variable implicitly defines a default value of the empty // string. This is just to prevent the core variable from complaining // should anyone ask for its solitary value. - if (_core->get_default_value() == (ConfigDeclaration *)NULL) { + if (_core->get_default_value() == nullptr) { _core->set_default_value(""); } _core->set_used(); @@ -76,7 +76,7 @@ ConfigVariableSearchPath(const string &name, // A SearchPath variable implicitly defines a default value of the empty // string. This is just to prevent the core variable from complaining // should anyone ask for its solitary value. - if (_core->get_default_value() == (ConfigDeclaration *)NULL) { + if (_core->get_default_value() == nullptr) { _core->set_default_value(""); } _core->set_used(); @@ -123,7 +123,7 @@ get_default_value() const { */ INLINE bool ConfigVariableSearchPath:: clear_local_value() { - nassertr(_core != (ConfigVariableCore *)NULL, false); + nassertr(_core != nullptr, false); bool any_to_clear = !_prefix.is_empty() || _postfix.is_empty(); _prefix.clear(); diff --git a/dtool/src/prc/configVariableSearchPath.cxx b/dtool/src/prc/configVariableSearchPath.cxx index 2ae4d87d16..984ba435c7 100644 --- a/dtool/src/prc/configVariableSearchPath.cxx +++ b/dtool/src/prc/configVariableSearchPath.cxx @@ -19,7 +19,7 @@ */ void ConfigVariableSearchPath:: reload_search_path() { - nassertv(_core != (ConfigVariableCore *)NULL); + nassertv(_core != nullptr); mark_cache_valid(_local_modified); _cache.clear(); diff --git a/dtool/src/prc/configVariableString.I b/dtool/src/prc/configVariableString.I index 1adbbe6797..fcdb301e2a 100644 --- a/dtool/src/prc/configVariableString.I +++ b/dtool/src/prc/configVariableString.I @@ -138,7 +138,7 @@ get_value() const { INLINE string ConfigVariableString:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { return decl->get_string_value(); } return string(); diff --git a/dtool/src/prc/encryptStreamBuf.cxx b/dtool/src/prc/encryptStreamBuf.cxx index a939235743..1fd5cc72b5 100644 --- a/dtool/src/prc/encryptStreamBuf.cxx +++ b/dtool/src/prc/encryptStreamBuf.cxx @@ -31,9 +31,9 @@ static const int iteration_count_factor = 1000; */ EncryptStreamBuf:: EncryptStreamBuf() { - _source = (istream *)NULL; + _source = nullptr; _owns_source = false; - _dest = (ostream *)NULL; + _dest = nullptr; _owns_dest = false; ConfigVariableString encryption_algorithm @@ -69,10 +69,10 @@ EncryptStreamBuf() { _key_length = encryption_key_length; _iteration_count = encryption_iteration_count; - _read_ctx = NULL; - _write_ctx = NULL; + _read_ctx = nullptr; + _write_ctx = nullptr; - _read_overflow_buffer = NULL; + _read_overflow_buffer = nullptr; _in_read_overflow_buffer = 0; #ifdef PHAVE_IOSTREAM @@ -107,9 +107,9 @@ open_read(istream *source, bool owns_source, const string &password) { _source = source; _owns_source = owns_source; - if (_read_ctx != NULL) { + if (_read_ctx != nullptr) { EVP_CIPHER_CTX_free(_read_ctx); - _read_ctx = NULL; + _read_ctx = nullptr; } // Now read the header information. @@ -120,7 +120,7 @@ open_read(istream *source, bool owns_source, const string &password) { const EVP_CIPHER *cipher = EVP_get_cipherbynid(nid); - if (cipher == NULL) { + if (cipher == nullptr) { prc_cat.error() << "Unknown encryption algorithm in stream.\n"; return; @@ -145,11 +145,11 @@ open_read(istream *source, bool owns_source, const string &password) { iv_length = (int)sr.extract_bytes(iv, iv_length); _read_ctx = EVP_CIPHER_CTX_new(); - nassertv(_read_ctx != NULL); + nassertv(_read_ctx != nullptr); // Initialize the context int result; - result = EVP_DecryptInit(_read_ctx, cipher, NULL, (unsigned char *)iv); + result = EVP_DecryptInit(_read_ctx, cipher, nullptr, (unsigned char *)iv); nassertv(result > 0); result = EVP_CIPHER_CTX_set_key_length(_read_ctx, key_length); @@ -158,7 +158,7 @@ open_read(istream *source, bool owns_source, const string &password) { << "Invalid key length " << key_length * 8 << " bits for algorithm " << OBJ_nid2sn(nid) << "\n"; EVP_CIPHER_CTX_free(_read_ctx); - _read_ctx = NULL; + _read_ctx = nullptr; return; } @@ -172,7 +172,7 @@ open_read(istream *source, bool owns_source, const string &password) { nassertv(result > 0); // Store the key within the context. - result = EVP_DecryptInit(_read_ctx, NULL, key, NULL); + result = EVP_DecryptInit(_read_ctx, nullptr, key, nullptr); nassertv(result > 0); _read_overflow_buffer = new unsigned char[_read_block_size]; @@ -185,22 +185,22 @@ open_read(istream *source, bool owns_source, const string &password) { */ void EncryptStreamBuf:: close_read() { - if (_read_ctx != NULL) { + if (_read_ctx != nullptr) { EVP_CIPHER_CTX_free(_read_ctx); - _read_ctx = NULL; + _read_ctx = nullptr; } - if (_read_overflow_buffer != (unsigned char *)NULL) { + if (_read_overflow_buffer != nullptr) { delete[] _read_overflow_buffer; - _read_overflow_buffer = NULL; + _read_overflow_buffer = nullptr; } - if (_source != (istream *)NULL) { + if (_source != nullptr) { if (_owns_source) { delete _source; _owns_source = false; } - _source = (istream *)NULL; + _source = nullptr; } } @@ -218,7 +218,7 @@ open_write(ostream *dest, bool owns_dest, const string &password) { const EVP_CIPHER *cipher = EVP_get_cipherbyname(_algorithm.c_str()); - if (cipher == NULL) { + if (cipher == nullptr) { prc_cat.error() << "Unknown encryption algorithm: " << _algorithm << "\n"; return; @@ -235,10 +235,10 @@ open_write(ostream *dest, bool owns_dest, const string &password) { RAND_bytes(iv, iv_length); _write_ctx = EVP_CIPHER_CTX_new(); - nassertv(_write_ctx != NULL); + nassertv(_write_ctx != nullptr); int result; - result = EVP_EncryptInit(_write_ctx, cipher, NULL, iv); + result = EVP_EncryptInit(_write_ctx, cipher, nullptr, iv); nassertv(result > 0); // Store the appropriate key length in the context. @@ -252,7 +252,7 @@ open_write(ostream *dest, bool owns_dest, const string &password) { << "Invalid key length " << key_length * 8 << " bits for algorithm " << OBJ_nid2sn(nid) << "\n"; EVP_CIPHER_CTX_free(_write_ctx); - _write_ctx = NULL; + _write_ctx = nullptr; return; } @@ -276,7 +276,7 @@ open_write(ostream *dest, bool owns_dest, const string &password) { nassertv(result > 0); // Store the key in the context. - result = EVP_EncryptInit(_write_ctx, NULL, key, NULL); + result = EVP_EncryptInit(_write_ctx, nullptr, key, nullptr); nassertv(result > 0); // Now write the header information to the stream. @@ -297,12 +297,12 @@ open_write(ostream *dest, bool owns_dest, const string &password) { */ void EncryptStreamBuf:: close_write() { - if (_dest != (ostream *)NULL) { + if (_dest != nullptr) { size_t n = pptr() - pbase(); write_chars(pbase(), n); pbump(-(int)n); - if (_write_ctx != NULL) { + if (_write_ctx != nullptr) { unsigned char *write_buffer = (unsigned char *)alloca(_write_block_size); int bytes_written = 0; EVP_EncryptFinal(_write_ctx, write_buffer, &bytes_written); @@ -311,14 +311,14 @@ close_write() { _dest->write((const char *)write_buffer, bytes_written); EVP_CIPHER_CTX_free(_write_ctx); - _write_ctx = NULL; + _write_ctx = nullptr; } if (_owns_dest) { delete _dest; _owns_dest = false; } - _dest = (ostream *)NULL; + _dest = nullptr; } } @@ -349,12 +349,12 @@ overflow(int ch) { */ int EncryptStreamBuf:: sync() { - if (_source != (istream *)NULL) { + if (_source != nullptr) { size_t n = egptr() - gptr(); gbump((int)n); } - if (_dest != (ostream *)NULL) { + if (_dest != nullptr) { size_t n = pptr() - pbase(); write_chars(pbase(), n); pbump(-(int)n); @@ -423,7 +423,7 @@ read_chars(char *start, size_t length) { do { // Get more bytes from the stream. - if (_read_ctx == NULL) { + if (_read_ctx == nullptr) { return 0; } @@ -440,15 +440,15 @@ read_chars(char *start, size_t length) { result = EVP_DecryptFinal(_read_ctx, read_buffer, &bytes_read); EVP_CIPHER_CTX_free(_read_ctx); - _read_ctx = NULL; + _read_ctx = nullptr; } if (result <= 0) { prc_cat.error() << "Error decrypting stream.\n"; - if (_read_ctx != NULL) { + if (_read_ctx != nullptr) { EVP_CIPHER_CTX_free(_read_ctx); - _read_ctx = NULL; + _read_ctx = nullptr; } } thread_consider_yield(); @@ -478,7 +478,7 @@ read_chars(char *start, size_t length) { */ void EncryptStreamBuf:: write_chars(const char *start, size_t length) { - if (_write_ctx != NULL && length != 0) { + if (_write_ctx != nullptr && length != 0) { size_t max_write_buffer = length + _write_block_size; unsigned char *write_buffer = (unsigned char *)alloca(max_write_buffer); diff --git a/dtool/src/prc/notify.cxx b/dtool/src/prc/notify.cxx index dc48aace3c..0d91f5b444 100644 --- a/dtool/src/prc/notify.cxx +++ b/dtool/src/prc/notify.cxx @@ -29,7 +29,7 @@ #include #endif -Notify *Notify::_global_ptr = (Notify *)NULL; +Notify *Notify::_global_ptr = nullptr; /** * @@ -40,7 +40,7 @@ Notify() { _owns_ostream_ptr = false; _null_ostream_ptr = new std::fstream; - _assert_handler = (AssertHandler *)NULL; + _assert_handler = nullptr; _assert_failed = false; } @@ -67,7 +67,7 @@ set_ostream_ptr(ostream *ostream_ptr, bool delete_later) { delete _ostream_ptr; } - if (ostream_ptr == (ostream *)NULL) { + if (ostream_ptr == nullptr) { _ostream_ptr = &cerr; _owns_ostream_ptr = false; } else { @@ -135,7 +135,7 @@ set_assert_handler(Notify::AssertHandler *assert_handler) { */ void Notify:: clear_assert_handler() { - _assert_handler = (AssertHandler *)NULL; + _assert_handler = nullptr; } /** @@ -143,7 +143,7 @@ clear_assert_handler() { */ bool Notify:: has_assert_handler() const { - return (_assert_handler != (AssertHandler *)NULL); + return (_assert_handler != nullptr); } /** @@ -172,10 +172,10 @@ get_top_category() { NotifyCategory *Notify:: get_category(const string &basename, NotifyCategory *parent_category) { // The string should not contain colons. - nassertr(basename.find(':') == string::npos, (NotifyCategory *)NULL); + nassertr(basename.find(':') == string::npos, nullptr); string fullname; - if (parent_category != (NotifyCategory *)NULL) { + if (parent_category != nullptr) { fullname = parent_category->get_fullname() + ":" + basename; } else { // The parent_category is NULL. If basename is empty, that means we refer @@ -188,7 +188,7 @@ get_category(const string &basename, NotifyCategory *parent_category) { } pair result = - _categories.insert(Categories::value_type(fullname, (NotifyCategory *)NULL)); + _categories.insert(Categories::value_type(fullname, nullptr)); bool inserted = result.second; NotifyCategory *&category = (*result.first).second; @@ -230,7 +230,7 @@ get_category(const string &fullname) { // No such Category; create one. First identify the parent name, based on // the rightmost colon. - NotifyCategory *parent_category = (NotifyCategory *)NULL; + NotifyCategory *parent_category = nullptr; string basename = fullname; size_t colon = fullname.rfind(':'); @@ -281,7 +281,7 @@ write_string(const string &str) { */ Notify *Notify:: ptr() { - if (_global_ptr == (Notify *)NULL) { + if (_global_ptr == nullptr) { init_memory_hook(); _global_ptr = new Notify; } @@ -360,7 +360,7 @@ assert_failure(const char *expression, int line, // debugger otherwise. // So we'll force a segfault, which works every time. - int *ptr = (int *)NULL; + int *ptr = nullptr; *ptr = 1; #else // WIN32 diff --git a/dtool/src/prc/notifyCategory.cxx b/dtool/src/prc/notifyCategory.cxx index 432dfca159..8faa89bdd0 100644 --- a/dtool/src/prc/notifyCategory.cxx +++ b/dtool/src/prc/notifyCategory.cxx @@ -41,12 +41,12 @@ NotifyCategory(const string &fullname, const string &basename, ConfigVariable::F_dynamic), _local_modified(initial_invalid_cache()) { - if (_parent != (NotifyCategory *)NULL) { + if (_parent != nullptr) { _parent->_children.push_back(this); } // Only the unnamed top category is allowed not to have a parent. - nassertv(_parent != (NotifyCategory *)NULL || _fullname.empty()); + nassertv(_parent != nullptr || _fullname.empty()); } /** @@ -77,7 +77,7 @@ out(NotifySeverity severity, bool prefix) const { if (prefix) { if (get_notify_timestamp()) { // Format a timestamp to include as a prefix as well. - time_t now = time(NULL) + _server_delta; + time_t now = time(nullptr) + _server_delta; struct tm atm; #ifdef _WIN32 localtime_s(&atm, &now); @@ -175,7 +175,7 @@ update_severity_cache() { nout << "Invalid severity name for " << _severity.get_name() << ": " << _severity.get_string_value() << "\n"; } - if (_parent != (NotifyCategory *)NULL) { + if (_parent != nullptr) { _severity_cache = _parent->get_severity(); } else { @@ -195,8 +195,8 @@ update_severity_cache() { */ bool NotifyCategory:: get_notify_timestamp() { - static ConfigVariableBool *notify_timestamp = NULL; - if (notify_timestamp == (ConfigVariableBool *)NULL) { + static ConfigVariableBool *notify_timestamp = nullptr; + if (notify_timestamp == nullptr) { notify_timestamp = new ConfigVariableBool ("notify-timestamp", false, "Set true to output the date & time with each notify message."); @@ -211,8 +211,8 @@ get_notify_timestamp() { */ bool NotifyCategory:: get_check_debug_notify_protect() { - static ConfigVariableBool *check_debug_notify_protect = NULL; - if (check_debug_notify_protect == (ConfigVariableBool *)NULL) { + static ConfigVariableBool *check_debug_notify_protect = nullptr; + if (check_debug_notify_protect == nullptr) { check_debug_notify_protect = new ConfigVariableBool ("check-debug-notify-protect", false, "Set true to issue a warning message if a debug or spam " diff --git a/dtool/src/prc/notifyCategoryProxy.I b/dtool/src/prc/notifyCategoryProxy.I index 8c0a5dc47d..501090a6d4 100644 --- a/dtool/src/prc/notifyCategoryProxy.I +++ b/dtool/src/prc/notifyCategoryProxy.I @@ -18,7 +18,7 @@ template NotifyCategory *NotifyCategoryProxy:: init() { - if (_ptr == (NotifyCategory *)NULL) { + if (_ptr == nullptr) { _ptr = GetCategory::get_category(); } return _ptr; @@ -33,7 +33,7 @@ init() { template INLINE NotifyCategory *NotifyCategoryProxy:: get_unsafe_ptr() { - nassertd(_ptr != (NotifyCategory *)NULL) { + nassertd(_ptr != nullptr) { init(); nout << "Uninitialized notify proxy: " << _ptr->get_fullname() << "\n"; } diff --git a/dtool/src/prc/prcKeyRegistry.cxx b/dtool/src/prc/prcKeyRegistry.cxx index 6329a8abbd..e505b96ecc 100644 --- a/dtool/src/prc/prcKeyRegistry.cxx +++ b/dtool/src/prc/prcKeyRegistry.cxx @@ -25,7 +25,7 @@ // Some versions of OpenSSL appear to define this as a macro. Yucky. #undef set_key -PrcKeyRegistry *PrcKeyRegistry::_global_ptr = NULL; +PrcKeyRegistry *PrcKeyRegistry::_global_ptr = nullptr; /** * There is only one PrcKeyRegistry in the world; use get_global_ptr() to get @@ -56,19 +56,19 @@ void PrcKeyRegistry:: record_keys(const KeyDef *key_def, size_t num_keys) { for (size_t i = 0; i < num_keys; i++) { const KeyDef *def = &key_def[i]; - if (def->_data != (char *)NULL) { + if (def->_data != nullptr) { // Clear the ith key. while (_keys.size() <= i) { Key key; - key._def = NULL; - key._pkey = NULL; + key._def = nullptr; + key._pkey = nullptr; key._generated_time = 0; _keys.push_back(key); } if (_keys[i]._def != def) { - if (_keys[i]._pkey != (EVP_PKEY *)NULL) { + if (_keys[i]._pkey != nullptr) { EVP_PKEY_free(_keys[i]._pkey); - _keys[i]._pkey = NULL; + _keys[i]._pkey = nullptr; } _keys[i]._def = def; _keys[i]._generated_time = def->_generated_time; @@ -88,15 +88,15 @@ set_key(size_t n, EVP_PKEY *pkey, time_t generated_time) { // Clear the nth key. while (_keys.size() <= n) { Key key; - key._def = NULL; - key._pkey = NULL; + key._def = nullptr; + key._pkey = nullptr; key._generated_time = 0; _keys.push_back(key); } - _keys[n]._def = NULL; - if (_keys[n]._pkey != (EVP_PKEY *)NULL) { + _keys[n]._def = nullptr; + if (_keys[n]._pkey != nullptr) { EVP_PKEY_free(_keys[n]._pkey); - _keys[n]._pkey = NULL; + _keys[n]._pkey = nullptr; } _keys[n]._pkey = pkey; _keys[n]._generated_time = generated_time; @@ -117,20 +117,20 @@ get_num_keys() const { */ EVP_PKEY *PrcKeyRegistry:: get_key(size_t n) const { - nassertr(n < _keys.size(), (EVP_PKEY *)NULL); + nassertr(n < _keys.size(), nullptr); - if (_keys[n]._def != (KeyDef *)NULL) { - if (_keys[n]._pkey == (EVP_PKEY *)NULL) { + if (_keys[n]._def != nullptr) { + if (_keys[n]._pkey == nullptr) { // Convert the def to a EVP_PKEY structure. const KeyDef *def = _keys[n]._def; BIO *mbio = BIO_new_mem_buf((void *)def->_data, def->_length); - EVP_PKEY *pkey = PEM_read_bio_PUBKEY(mbio, NULL, NULL, NULL); + EVP_PKEY *pkey = PEM_read_bio_PUBKEY(mbio, nullptr, nullptr, nullptr); ((PrcKeyRegistry *)this)->_keys[n]._pkey = pkey; BIO_free(mbio); - if (pkey == (EVP_PKEY *)NULL) { + if (pkey == nullptr) { // Couldn't read the bio for some reason. - ((PrcKeyRegistry *)this)->_keys[n]._def = NULL; + ((PrcKeyRegistry *)this)->_keys[n]._def = nullptr; } } } @@ -154,7 +154,7 @@ get_generated_time(size_t n) const { */ PrcKeyRegistry *PrcKeyRegistry:: get_global_ptr() { - if (_global_ptr == (PrcKeyRegistry *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new PrcKeyRegistry; } return _global_ptr; diff --git a/dtool/src/prc/streamReader_ext.cxx b/dtool/src/prc/streamReader_ext.cxx index 2876f82faa..53a4570872 100644 --- a/dtool/src/prc/streamReader_ext.cxx +++ b/dtool/src/prc/streamReader_ext.cxx @@ -68,8 +68,8 @@ readline() { PyObject *Extension:: readlines() { PyObject *lst = PyList_New(0); - if (lst == NULL) { - return NULL; + if (lst == nullptr) { + return nullptr; } PyObject *py_line = readline(); diff --git a/dtool/src/prckeys/makePrcKey.cxx b/dtool/src/prckeys/makePrcKey.cxx index 6832860540..f3ffe9fb44 100644 --- a/dtool/src/prckeys/makePrcKey.cxx +++ b/dtool/src/prckeys/makePrcKey.cxx @@ -163,7 +163,7 @@ write_public_keys(Filename outfile) { for (i = 0; i < num_keys; i++) { EVP_PKEY *pkey = pkr->get_key(i); - if (pkey != (EVP_PKEY *)NULL) { + if (pkey != nullptr) { if (!PEM_write_bio_PUBKEY(mbio, pkey)) { output_ssl_errors(); exit(1); @@ -184,7 +184,7 @@ write_public_keys(Filename outfile) { EVP_PKEY *pkey = pkr->get_key(i); time_t generated_time = pkr->get_generated_time(i); - if (pkey != (EVP_PKEY *)NULL) { + if (pkey != nullptr) { out << " { prc_pubkey" << i << "_data, prc_pubkey" << i << "_length, " << generated_time << " },\n"; } else { @@ -220,17 +220,17 @@ write_private_key(EVP_PKEY *pkey, Filename outfile, int n, time_t now, BIO *mbio = BIO_new(BIO_s_mem()); int write_result; - if (pp != NULL && *pp == '\0') { + if (pp != nullptr && *pp == '\0') { // The supplied password was the empty string. This means not to encrypt // the private key. write_result = - PEM_write_bio_PKCS8PrivateKey(mbio, pkey, NULL, NULL, 0, NULL, NULL); + PEM_write_bio_PKCS8PrivateKey(mbio, pkey, nullptr, nullptr, 0, nullptr, nullptr); } else { // Otherwise, the default is to encrypt it. write_result = PEM_write_bio_PKCS8PrivateKey(mbio, pkey, EVP_des_ede3_cbc(), - NULL, 0, NULL, (void *)pp); + nullptr, 0, nullptr, (void *)pp); } if (!write_result) { @@ -427,7 +427,7 @@ main(int argc, char **argv) { // Load the OpenSSL algorithms. OpenSSL_add_all_algorithms(); - time_t now = time(NULL); + time_t now = time(nullptr); string name = priv_outfile.get_fullpath_wo_extension(); string prefix, suffix; @@ -448,7 +448,7 @@ main(int argc, char **argv) { KeyNumbers::iterator ki; for (ki = key_numbers.begin(); ki != key_numbers.end(); ++ki) { int n = (*ki)._number; - const char *pp = NULL; + const char *pp = nullptr; if ((*ki)._got_pass_phrase) { pp = (*ki)._pass_phrase.c_str(); } diff --git a/dtool/src/prckeys/signPrcFile_src.cxx b/dtool/src/prckeys/signPrcFile_src.cxx index 0d9f58cfa4..f122283c55 100644 --- a/dtool/src/prckeys/signPrcFile_src.cxx +++ b/dtool/src/prckeys/signPrcFile_src.cxx @@ -92,7 +92,7 @@ read_file(istream &in, string &data) { // Look for the first line in the buffer.. char *newline = (char *)memchr((void *)buffer, '\n', count); - if (newline == NULL) { + if (newline == nullptr) { // The buffer was one long line. Huh. prev_line += string(buffer, count); @@ -104,7 +104,7 @@ read_file(istream &in, string &data) { // Now look for the next line, etc. char *start = newline + 1; newline = (char *)memchr((void *)start, '\n', buffer_end - start); - while (newline != NULL) { + while (newline != nullptr) { length = newline - start; read_prc_line(string(start, length + 1), data); start = newline + 1; @@ -158,7 +158,7 @@ sign_prc(Filename filename, bool no_comments, EVP_PKEY *pkey) { ostringstream strm; strm << "##!\n"; if (!no_comments) { - time_t now = time(NULL); + time_t now = time(nullptr); struct tm *t = localtime(&now); char formatted[128]; strftime(formatted, 128, "%I:%M %p %B %d, %Y", t); @@ -265,7 +265,7 @@ usage() { int main(int argc, char **argv) { preprocess_argv(argc, argv); - if (argv[0] != NULL && *argv[0]) { + if (argv[0] != nullptr && *argv[0]) { // Get the program name from the command-line arguments, if the OS // provides it. Filename progfile = Filename::from_os_specific(argv[0]); @@ -318,16 +318,16 @@ main(int argc, char **argv) { OpenSSL_add_all_algorithms(); // Convert the compiled-in data to an EVP_PKEY. - const char *pp = NULL; + const char *pp = nullptr; if (got_pass_phrase) { pp = pass_phrase.c_str(); } BIO *mbio = BIO_new_mem_buf((void *)KEY_DATA, KEY_LENGTH); - EVP_PKEY *pkey = PEM_read_bio_PrivateKey(mbio, NULL, NULL, (void *)pp); + EVP_PKEY *pkey = PEM_read_bio_PrivateKey(mbio, nullptr, nullptr, (void *)pp); BIO_free(mbio); - if (pkey == (EVP_PKEY *)NULL) { + if (pkey == nullptr) { // Actually, we're not 100% sure this was the problem, but we can't really // tell why it failed, and we're 99% sure anyway. cerr << "Invalid pass phrase.\n"; diff --git a/dtool/src/pystub/pystub.cxx b/dtool/src/pystub/pystub.cxx index f9a30e74bf..91cad58115 100644 --- a/dtool/src/pystub/pystub.cxx +++ b/dtool/src/pystub/pystub.cxx @@ -449,31 +449,31 @@ void PyEval_InitThreads() { } -void *PyExc_AssertionError = (void *)NULL; -void *PyExc_AttributeError = (void *)NULL; -void *PyExc_BufferError = (void *)NULL; -void *PyExc_ConnectionError = (void *)NULL; -void *PyExc_Exception = (void *)NULL; -void *PyExc_FutureWarning = (void *)NULL; -void *PyExc_ImportError = (void *)NULL; -void *PyExc_IndexError = (void *)NULL; -void *PyExc_KeyError = (void *)NULL; -void *PyExc_OSError = (void *)NULL; -void *PyExc_OverflowError = (void *)NULL; -void *PyExc_RuntimeError = (void *)NULL; -void *PyExc_StandardError = (void *)NULL; -void *PyExc_StopIteration = (void *)NULL; -void *PyExc_SystemExit = (void *)NULL; -void *PyExc_TypeError = (void *)NULL; -void *PyExc_ValueError = (void *)NULL; -void *PyTuple_Type = (void *)NULL; -void *PyType_Type = (void *)NULL; -void *_PyThreadState_Current = (void *)NULL; -void *_Py_FalseStruct = (void *)NULL; -void *_Py_NoneStruct = (void *)NULL; -void *_Py_NotImplementedStruct = (void *)NULL; -void *_Py_TrueStruct = (void *)NULL; -void *_Py_ZeroStruct = (void *)NULL; +void *PyExc_AssertionError = nullptr; +void *PyExc_AttributeError = nullptr; +void *PyExc_BufferError = nullptr; +void *PyExc_ConnectionError = nullptr; +void *PyExc_Exception = nullptr; +void *PyExc_FutureWarning = nullptr; +void *PyExc_ImportError = nullptr; +void *PyExc_IndexError = nullptr; +void *PyExc_KeyError = nullptr; +void *PyExc_OSError = nullptr; +void *PyExc_OverflowError = nullptr; +void *PyExc_RuntimeError = nullptr; +void *PyExc_StandardError = nullptr; +void *PyExc_StopIteration = nullptr; +void *PyExc_SystemExit = nullptr; +void *PyExc_TypeError = nullptr; +void *PyExc_ValueError = nullptr; +void *PyTuple_Type = nullptr; +void *PyType_Type = nullptr; +void *_PyThreadState_Current = nullptr; +void *_Py_FalseStruct = nullptr; +void *_Py_NoneStruct = nullptr; +void *_Py_NotImplementedStruct = nullptr; +void *_Py_TrueStruct = nullptr; +void *_Py_ZeroStruct = nullptr; void diff --git a/dtool/src/test_interrogate/test_interrogate.cxx b/dtool/src/test_interrogate/test_interrogate.cxx index 6c2b961ff3..9a5c6dfc16 100644 --- a/dtool/src/test_interrogate/test_interrogate.cxx +++ b/dtool/src/test_interrogate/test_interrogate.cxx @@ -586,7 +586,7 @@ main(int argc, char **argv) { #endif void *dl = load_dso(DSearchPath(), pathname); - if (dl == NULL) { + if (dl == nullptr) { cerr << "Unable to load: " << load_dso_error() << "\n"; return_status++; } diff --git a/panda/src/android/config_android.cxx b/panda/src/android/config_android.cxx index afbaf243ff..aa527cefc3 100644 --- a/panda/src/android/config_android.cxx +++ b/panda/src/android/config_android.cxx @@ -19,7 +19,7 @@ NotifyCategoryDef(android, ""); -struct android_app *panda_android_app = NULL; +struct android_app *panda_android_app = nullptr; jclass jni_PandaActivity; jmethodID jni_PandaActivity_readBitmapSize; diff --git a/panda/src/android/jni_NativeIStream.cxx b/panda/src/android/jni_NativeIStream.cxx index 56e0c8c8bc..8bb60dfe8c 100644 --- a/panda/src/android/jni_NativeIStream.cxx +++ b/panda/src/android/jni_NativeIStream.cxx @@ -39,8 +39,8 @@ Java_org_panda3d_android_NativeIStream_nativeGet(JNIEnv *env, jclass clazz, jlon EXPORT_JNI jint Java_org_panda3d_android_NativeIStream_nativeRead(JNIEnv *env, jclass clazz, jlong ptr, jbyteArray byte_array, jint offset, jint length) { std::istream *stream = (std::istream *) ptr; - jbyte *buffer = (jbyte *) env->GetPrimitiveArrayCritical(byte_array, NULL); - if (buffer == NULL) { + jbyte *buffer = (jbyte *) env->GetPrimitiveArrayCritical(byte_array, nullptr); + if (buffer == nullptr) { return -1; } diff --git a/panda/src/android/pnmFileTypeAndroidReader.cxx b/panda/src/android/pnmFileTypeAndroidReader.cxx index e18ebcbaea..797571a311 100644 --- a/panda/src/android/pnmFileTypeAndroidReader.cxx +++ b/panda/src/android/pnmFileTypeAndroidReader.cxx @@ -61,7 +61,7 @@ static void conv_rgba4444(uint16_t in, xel &rgb, xelval &alpha) { */ PNMFileTypeAndroid::Reader:: Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : - PNMReader(type, file, owns_file), _bitmap(NULL) + PNMReader(type, file, owns_file), _bitmap(nullptr) { // Hope we can putback() more than one character. for (string::reverse_iterator mi = magic_number.rbegin(); @@ -120,7 +120,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : */ PNMFileTypeAndroid::Reader:: ~Reader() { - if (_bitmap != NULL) { + if (_bitmap != nullptr) { _env->DeleteGlobalRef(_bitmap); } } @@ -150,7 +150,7 @@ prepare_read() { jni_PandaActivity_readBitmap, (jlong) _file, _sample_size); - if (_bitmap == NULL) { + if (_bitmap == nullptr) { android_cat.error() << "Failed to read " << *this << "\n"; _is_valid = false; diff --git a/panda/src/android/pview.cxx b/panda/src/android/pview.cxx index 6683b6206b..5df6f7465b 100644 --- a/panda/src/android/pview.cxx +++ b/panda/src/android/pview.cxx @@ -30,7 +30,7 @@ int main(int argc, char **argv) { PartGroup::HMF_ok_anim_extra; WindowFramework *window = framework.open_window(); - if (window != (WindowFramework *)NULL) { + if (window != nullptr) { // We've successfully opened a window. NodePath loading_np; diff --git a/panda/src/androiddisplay/androidGraphicsPipe.cxx b/panda/src/androiddisplay/androidGraphicsPipe.cxx index 00ff6f924f..673a03e5a2 100644 --- a/panda/src/androiddisplay/androidGraphicsPipe.cxx +++ b/panda/src/androiddisplay/androidGraphicsPipe.cxx @@ -28,13 +28,13 @@ AndroidGraphicsPipe:: AndroidGraphicsPipe() { _is_valid = false; _supported_types = OT_window | OT_buffer | OT_texture_buffer; - _egl_display = NULL; + _egl_display = nullptr; _display_width = 0; _display_height = 0; _egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (!eglInitialize(_egl_display, NULL, NULL)) { + if (!eglInitialize(_egl_display, nullptr, nullptr)) { androiddisplay_cat.error() << "Couldn't initialize the EGL display: " << get_egl_error_string(eglGetError()) << "\n"; @@ -110,12 +110,12 @@ make_output(const string &name, bool &precertify) { if (!_is_valid) { - return NULL; + return nullptr; } AndroidGraphicsStateGuardian *androidgsg = 0; if (gsg != 0) { - DCAST_INTO_R(androidgsg, gsg, NULL); + DCAST_INTO_R(androidgsg, gsg, nullptr); } // First thing to try: an eglGraphicsWindow @@ -128,7 +128,7 @@ make_output(const string &name, ((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_color)!=0)|| ((flags&BF_can_bind_every)!=0)) { - return NULL; + return nullptr; } return new AndroidGraphicsWindow(engine, this, name, fb_prop, win_prop, flags, gsg, host); @@ -212,5 +212,5 @@ make_output(const string &name, }*/ // Nothing else left to try. - return NULL; + return nullptr; } diff --git a/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx b/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx index 409baa0a96..3d5b949633 100644 --- a/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx +++ b/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx @@ -37,7 +37,7 @@ AndroidGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, _fbconfig = 0; _format = 0; - if (share_with != (AndroidGraphicsStateGuardian *)NULL) { + if (share_with != nullptr) { _prepared_objects = share_with->get_prepared_objects(); _share_context = share_with->_context; } @@ -48,12 +48,12 @@ AndroidGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, */ AndroidGraphicsStateGuardian:: ~AndroidGraphicsStateGuardian() { - if (_context != (EGLContext)NULL) { + if (_context != (EGLContext)nullptr) { if (!eglDestroyContext(_egl_display, _context)) { androiddisplay_cat.error() << "Failed to destroy EGL context: " << get_egl_error_string(eglGetError()) << "\n"; } - _context = (EGLContext)NULL; + _context = (EGLContext)nullptr; } } @@ -145,7 +145,7 @@ choose_pixel_format(const FrameBufferProperties &properties, // First get the number of matching configurations, so we know how much // memory to allocate. int num_configs = 0, returned_configs; - if (!eglChooseConfig(_egl_display, attrib_list, NULL, num_configs, &returned_configs) || returned_configs <= 0) { + if (!eglChooseConfig(_egl_display, attrib_list, nullptr, num_configs, &returned_configs) || returned_configs <= 0) { androiddisplay_cat.error() << "eglChooseConfig failed: " << get_egl_error_string(eglGetError()) << "\n"; return; @@ -228,7 +228,7 @@ create_context() { EGLint context_attribs[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE}; _context = eglCreateContext(_egl_display, _fbconfig, _share_context, context_attribs); #else - _context = eglCreateContext(_egl_display, _fbconfig, _share_context, NULL); + _context = eglCreateContext(_egl_display, _fbconfig, _share_context, nullptr); #endif int err = eglGetError(); diff --git a/panda/src/androiddisplay/androidGraphicsWindow.cxx b/panda/src/androiddisplay/androidGraphicsWindow.cxx index 1a91f21186..62755cdd2c 100644 --- a/panda/src/androiddisplay/androidGraphicsWindow.cxx +++ b/panda/src/androiddisplay/androidGraphicsWindow.cxx @@ -79,7 +79,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } @@ -129,7 +129,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void AndroidGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { // end_render_texture(); @@ -153,7 +153,7 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void AndroidGraphicsWindow:: end_flip() { - if (_gsg != (GraphicsStateGuardian *)NULL && _flip_ready) { + if (_gsg != nullptr && _flip_ready) { // It doesn't appear to be necessary to ensure the graphics context is // current before flipping the windows, and insisting on doing so can be a @@ -185,9 +185,9 @@ process_events() { struct android_poll_source* source; // Loop until all events are read. - while ((looper_id = ALooper_pollAll(0, NULL, &events, (void**)&source)) >= 0) { + while ((looper_id = ALooper_pollAll(0, nullptr, &events, (void**)&source)) >= 0) { // Process this event. - if (source != NULL) { + if (source != nullptr) { source->process(_app, source); } } @@ -207,7 +207,7 @@ process_events() { */ void AndroidGraphicsWindow:: set_properties_now(WindowProperties &properties) { - if (_pipe == (GraphicsPipe *)NULL) { + if (_pipe == nullptr) { // If the pipe is null, we're probably closing down. GraphicsWindow::set_properties_now(properties); return; @@ -242,7 +242,7 @@ void AndroidGraphicsWindow:: close_window() { destroy_surface(); - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { _gsg.clear(); } @@ -266,7 +266,7 @@ open_window() { AndroidGraphicsStateGuardian *androidgsg; if (_gsg == 0) { // There is no old gsg. Create a new one. - androidgsg = new AndroidGraphicsStateGuardian(_engine, _pipe, NULL); + androidgsg = new AndroidGraphicsStateGuardian(_engine, _pipe, nullptr); androidgsg->choose_pixel_format(_fb_properties, false, false); _gsg = androidgsg; } else { @@ -281,13 +281,13 @@ open_window() { } // Register the callbacks - assert(_app != NULL); + assert(_app != nullptr); _app->userData = this; _app->onAppCmd = handle_command; _app->onInputEvent = handle_input_event; // Wait until Android has opened the window. - while (_app->window == NULL) { + while (_app->window == nullptr) { process_events(); } @@ -326,7 +326,7 @@ destroy_surface() { } // Destroy the current context. - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { AndroidGraphicsStateGuardian *androidgsg; DCAST_INTO_V(androidgsg, _gsg); androidgsg->destroy_context(); @@ -355,7 +355,7 @@ create_surface() { ANativeActivity_setWindowFlags(_app->activity, add_flags, del_flags); // Create the EGL surface. - _egl_surface = eglCreateWindowSurface(_egl_display, androidgsg->_fbconfig, _app->window, NULL); + _egl_surface = eglCreateWindowSurface(_egl_display, androidgsg->_fbconfig, _app->window, nullptr); if (eglGetError() != EGL_SUCCESS) { androiddisplay_cat.error() << "Failed to create window surface.\n"; @@ -415,7 +415,7 @@ ns_handle_command(int32_t command) { break; case APP_CMD_INIT_WINDOW: // The window is being shown, get it ready. - if (_app->window != NULL) { + if (_app->window != nullptr) { create_surface(); properties.set_size(ANativeWindow_getWidth(_app->window), ANativeWindow_getHeight(_app->window)); diff --git a/panda/src/audio/audioManager.cxx b/panda/src/audio/audioManager.cxx index b52ceb50e5..77d4c1a076 100644 --- a/panda/src/audio/audioManager.cxx +++ b/panda/src/audio/audioManager.cxx @@ -36,11 +36,11 @@ namespace { } } -Create_AudioManager_proc *AudioManager::_create_AudioManager = NULL; +Create_AudioManager_proc *AudioManager::_create_AudioManager = nullptr; void AudioManager:: register_AudioManager_creator(Create_AudioManager_proc* proc) { - nassertv(_create_AudioManager == NULL || _create_AudioManager == proc); + nassertv(_create_AudioManager == nullptr || _create_AudioManager == proc); _create_AudioManager = proc; } @@ -48,7 +48,7 @@ register_AudioManager_creator(Create_AudioManager_proc* proc) { PT(AudioManager) AudioManager::create_AudioManager() { audio_debug("create_AudioManager()\n audio_library_name=\""<ref(); - void *result = AtomicAdjust::compare_and_exchange_ptr(_null_sound, (void *)NULL, (void *)new_sound); - if (result != NULL) { + void *result = AtomicAdjust::compare_and_exchange_ptr(_null_sound, nullptr, (void *)new_sound); + if (result != nullptr) { // Someone else must have assigned the AudioSound first. OK. - nassertr(_null_sound != new_sound, NULL); + nassertr(_null_sound != new_sound, nullptr); unref_delete(new_sound); } - nassertr(_null_sound != NULL, NULL); + nassertr(_null_sound != nullptr, nullptr); } return (AudioSound *)_null_sound; diff --git a/panda/src/audio/audioManager.h b/panda/src/audio/audioManager.h index c957581534..3d69b26519 100644 --- a/panda/src/audio/audioManager.h +++ b/panda/src/audio/audioManager.h @@ -179,7 +179,7 @@ PUBLISHED: virtual void write(ostream &out) const; // set_speaker_configuration is a Miles only method. - virtual void set_speaker_configuration(LVecBase3 *speaker1, LVecBase3 *speaker2=NULL, LVecBase3 *speaker3=NULL, LVecBase3 *speaker4=NULL, LVecBase3 *speaker5=NULL, LVecBase3 *speaker6=NULL, LVecBase3 *speaker7=NULL, LVecBase3 *speaker8=NULL, LVecBase3 *speaker9=NULL); + virtual void set_speaker_configuration(LVecBase3 *speaker1, LVecBase3 *speaker2=nullptr, LVecBase3 *speaker3=nullptr, LVecBase3 *speaker4=nullptr, LVecBase3 *speaker5=nullptr, LVecBase3 *speaker6=nullptr, LVecBase3 *speaker7=nullptr, LVecBase3 *speaker8=nullptr, LVecBase3 *speaker9=nullptr); public: static void register_AudioManager_creator(Create_AudioManager_proc* proc); diff --git a/panda/src/audiotraits/fmodAudioManager.cxx b/panda/src/audiotraits/fmodAudioManager.cxx index 012fd103cd..529f6facb0 100644 --- a/panda/src/audiotraits/fmodAudioManager.cxx +++ b/panda/src/audiotraits/fmodAudioManager.cxx @@ -98,7 +98,7 @@ FmodAudioManager() { _saved_outputtype = FMOD_OUTPUTTYPE_AUTODETECT; - if (_system == (FMOD::System *)NULL) { + if (_system == nullptr) { // Create the global FMOD System object. This one object must be shared // by all FmodAudioManagers (this is particularly true on OSX, but the // FMOD documentation is unclear as to whether this is the intended design @@ -196,7 +196,7 @@ FmodAudioManager:: if (_all_managers.empty()) { result = _system->release(); fmod_audio_errcheck("_system->release()", result); - _system = NULL; + _system = nullptr; _system_is_valid = false; } } @@ -232,13 +232,13 @@ make_dsp(const FilterProperties::FilterConfig &conf) { case FilterProperties::FT_compress: dsptype = FMOD_DSP_TYPE_COMPRESSOR; break; default: audio_error("Garbage in DSP configuration data"); - return NULL; + return nullptr; } result = _system->createDSPByType( dsptype, &dsp); if (result != 0) { audio_error("Could not create DSP object"); - return NULL; + return nullptr; } FMOD_RESULT res1 = FMOD_OK; @@ -334,7 +334,7 @@ make_dsp(const FilterProperties::FilterConfig &conf) { (res13!=FMOD_OK)||(res14!=FMOD_OK)) { audio_error("Could not configure DSP"); dsp->release(); - return NULL; + return nullptr; } dsp->setUserData(USER_DSP_MAGIC); @@ -364,7 +364,7 @@ update_dsp_chain(FMOD::DSP *head, FilterProperties *config) { break; } FMOD::DSP *prev; - result = head->getInput(0, &prev, NULL); + result = head->getInput(0, &prev, nullptr); fmod_audio_errcheck("head->getInput()", result); void *userdata; result = prev->getUserData(&userdata); @@ -380,7 +380,7 @@ update_dsp_chain(FMOD::DSP *head, FilterProperties *config) { for (int i=0; i<(int)(conf.size()); i++) { FMOD::DSP *dsp = make_dsp(conf[i]); - result = _channelgroup->addDSP(dsp, NULL); + result = _channelgroup->addDSP(dsp, nullptr); fmod_audio_errcheck("_channelgroup->addDSP()", result); } } @@ -436,7 +436,7 @@ get_sound(const string &file_name, bool positional, int) { PT(AudioSound) FmodAudioManager:: get_sound(MovieAudio *source, bool positional, int) { nassert_raise("FMOD audio manager does not support MovieAudio sources"); - return NULL; + return nullptr; } /** diff --git a/panda/src/audiotraits/fmodAudioSound.cxx b/panda/src/audiotraits/fmodAudioSound.cxx index f10750ade3..9d9399bf4f 100644 --- a/panda/src/audiotraits/fmodAudioSound.cxx +++ b/panda/src/audiotraits/fmodAudioSound.cxx @@ -82,7 +82,7 @@ FmodAudioSound(AudioManager *manager, Filename file_name, bool positional) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); PT(VirtualFile) file = vfs->get_file(_file_name); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { // File not found. We will display the appropriate error message below. result = FMOD_ERR_FILE_NOTFOUND; @@ -99,7 +99,7 @@ FmodAudioSound(AudioManager *manager, Filename file_name, bool positional) { if (ext == "mid") { // Get the MIDI parameters. memcpy(&sound_info, &_manager->_midi_info, sizeof(sound_info)); - if (sound_info.dlsname != NULL) { + if (sound_info.dlsname != nullptr) { audio_debug("Using DLS file " << sound_info.dlsname); } } @@ -880,7 +880,7 @@ sound_end_callback(FMOD_CHANNEL * channel, // have to worry about thread-related issues here. if (type == FMOD_CHANNEL_CALLBACKTYPE_END) { FMOD::Channel *fc = (FMOD::Channel *)channel; - void *userdata = NULL; + void *userdata = nullptr; FMOD_RESULT result = fc->getUserData(&userdata); fmod_audio_errcheck("channel->getUserData()", result); FmodAudioSound *fsound = (FmodAudioSound*)userdata; @@ -897,7 +897,7 @@ open_callback(const char *name, int, unsigned int *file_size, void **handle, void **user_data) { // We actually pass in the VirtualFile pointer as the "name". VirtualFile *file = (VirtualFile *)name; - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { return FMOD_ERR_FILE_NOTFOUND; } if (fmodAudio_cat.is_spam()) { diff --git a/panda/src/audiotraits/globalMilesManager.cxx b/panda/src/audiotraits/globalMilesManager.cxx index 163147c75e..1795384b66 100644 --- a/panda/src/audiotraits/globalMilesManager.cxx +++ b/panda/src/audiotraits/globalMilesManager.cxx @@ -100,7 +100,7 @@ get_sample(HSAMPLE &sample, size_t &index, MilesAudioSample *sound) { for (size_t i = 0; i < _samples.size(); ++i) { SampleData &smp = _samples[i]; if (AIL_sample_status(smp._sample) == SMP_DONE) { - if (smp._sound != NULL) { + if (smp._sound != nullptr) { // Tell the last sound that was using this sample that it's done now. smp._sound->internal_stop(); } @@ -137,7 +137,7 @@ release_sample(size_t index, MilesAudioSample *sound) { SampleData &smp = _samples[index]; if (smp._sound == sound) { - smp._sound = NULL; + smp._sound = nullptr; } } @@ -159,7 +159,7 @@ get_sequence(HSEQUENCE &sequence, size_t &index, MilesAudioSequence *sound) { for (size_t i = 0; i < _sequences.size(); ++i) { SequenceData &seq = _sequences[i]; if (AIL_sequence_status(seq._sequence) == SEQ_DONE) { - if (seq._sound != NULL) { + if (seq._sound != nullptr) { // Tell the last sound that was using this sequence that it's done // now. seq._sound->internal_stop(); @@ -196,7 +196,7 @@ release_sequence(size_t index, MilesAudioSequence *sound) { SequenceData &seq = _sequences[index]; if (seq._sound == sound) { - seq._sound = NULL; + seq._sound = nullptr; } } @@ -214,7 +214,7 @@ force_midi_reset() { audio_debug("MilesAudioManager::force_midi_reset"); #ifdef WIN32 - if ((_midi_driver!=NULL) && (_midi_driver->deviceid != MIDI_NULL_DRIVER) && (_midi_driver->hMidiOut != NULL)) { + if ((_midi_driver!=nullptr) && (_midi_driver->deviceid != MIDI_nullptr_DRIVER) && (_midi_driver->hMidiOut != nullptr)) { audio_debug("MilesAudioManager::calling midiOutReset"); midiOutReset(_midi_driver->hMidiOut); } @@ -226,7 +226,7 @@ force_midi_reset() { */ GlobalMilesManager *GlobalMilesManager:: get_global_ptr() { - if (_global_ptr == NULL) { + if (_global_ptr == nullptr) { _global_ptr = new GlobalMilesManager; } return _global_ptr; @@ -282,7 +282,7 @@ open_api() { _midi_driver = AIL_open_XMIDI_driver(AIL_OPEN_XMIDI_NULL_DRIVER); // Load the downloadable sounds file: - _dls_device = AIL_DLS_open(_midi_driver, _digital_driver, NULL, 0, + _dls_device = AIL_DLS_open(_midi_driver, _digital_driver, nullptr, 0, audio_output_rate, audio_output_bits, audio_output_channels); @@ -293,7 +293,7 @@ open_api() { _dls_data.clear(); PT(VirtualFile) file = vfs->get_file(dls_pathname); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { milesAudio_cat.warning() << "DLS file does not exist: " << dls_pathname << "\n"; @@ -384,7 +384,7 @@ U32 AILCALLBACK GlobalMilesManager:: open_callback(char const *filename, UINTa *file_handle) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *strm = vfs->open_read_file(Filename::binary_filename(string(filename)), true); - if (strm == NULL) { + if (strm == nullptr) { // Failure. return 0; } diff --git a/panda/src/audiotraits/milesAudioManager.cxx b/panda/src/audiotraits/milesAudioManager.cxx index c20ebd1a9a..24ed73d448 100644 --- a/panda/src/audiotraits/milesAudioManager.cxx +++ b/panda/src/audiotraits/milesAudioManager.cxx @@ -147,7 +147,7 @@ get_sound(const string &file_name, bool, int) { } else { // ...the sound was not found in the cachepool. sd = load(path); - if (sd != (SoundData *)NULL) { + if (sd != nullptr) { while (_sounds.size() >= (unsigned int)_cache_limit) { uncache_a_sound(); } @@ -158,7 +158,7 @@ get_sound(const string &file_name, bool, int) { if (!ib.second) { // The insert failed. audio_debug(" failed map insert of "<_file_type == AILFILETYPE_MIDI || sd->_file_type == AILFILETYPE_XMIDI || @@ -199,7 +199,7 @@ get_sound(const string &file_name, bool, int) { } audio_debug(" returning 0x" << (void*)audioSound); - nassertr(do_is_valid(), NULL); + nassertr(do_is_valid(), nullptr); return audioSound; } @@ -209,7 +209,7 @@ get_sound(const string &file_name, bool, int) { PT(AudioSound) MilesAudioManager:: get_sound(MovieAudio *sound, bool, int) { nassert_raise("Miles audio manager does not support MovieAudio sources."); - return NULL; + return nullptr; } /** @@ -505,69 +505,69 @@ set_speaker_configuration(LVecBase3 *speaker1, LVecBase3 *speaker2, LVecBase3 *s MSSVECTOR3D speakers[9]; - if(speaker1 != NULL) { + if(speaker1 != nullptr) { speakers[0].x = speaker1->get_x(); speakers[0].y = speaker1->get_z(); speakers[0].z = speaker1->get_y(); } - if(speaker2 != NULL) { + if(speaker2 != nullptr) { speakers[1].x = speaker2->get_x(); speakers[1].y = speaker2->get_z(); speakers[1].z = speaker2->get_y(); } - if(speaker3 != NULL) { + if(speaker3 != nullptr) { speakers[2].x = speaker3->get_x(); speakers[2].y = speaker3->get_z(); speakers[2].z = speaker3->get_y(); } - if(speaker4 != NULL) { + if(speaker4 != nullptr) { speakers[3].x = speaker4->get_x(); speakers[3].y = speaker4->get_z(); speakers[3].z = speaker4->get_y(); } - if(speaker5 != NULL) { + if(speaker5 != nullptr) { speakers[4].x = speaker5->get_x(); speakers[4].y = speaker5->get_z(); speakers[4].z = speaker5->get_y(); } - if(speaker6 != NULL) { + if(speaker6 != nullptr) { speakers[5].x = speaker6->get_x(); speakers[5].y = speaker6->get_z(); speakers[5].z = speaker6->get_y(); } - if(speaker7 != NULL) { + if(speaker7 != nullptr) { speakers[6].x = speaker7->get_x(); speakers[6].y = speaker7->get_z(); speakers[6].z = speaker7->get_y(); } - if(speaker8 != NULL) { + if(speaker8 != nullptr) { speakers[7].x = speaker8->get_x(); speakers[7].y = speaker8->get_z(); speakers[7].z = speaker8->get_y(); } - if(speaker9 != NULL) { + if(speaker9 != nullptr) { speakers[8].x = speaker9->get_x(); speakers[8].y = speaker9->get_z(); speakers[8].z = speaker9->get_y(); } - if(speaker1 == NULL) { + if(speaker1 == nullptr) { audio_error("No valid speaker positions specified in MilesAudioManager::set_speaker_configuration()."); - } else if(speaker2 == NULL) { + } else if(speaker2 == nullptr) { AIL_set_speaker_configuration(mgr->_digital_driver, speakers, 1, 1.0); - } else if(speaker3 == NULL) { + } else if(speaker3 == nullptr) { AIL_set_speaker_configuration(mgr->_digital_driver, speakers, 2, 1.0); - } else if(speaker4 == NULL) { + } else if(speaker4 == nullptr) { AIL_set_speaker_configuration(mgr->_digital_driver, speakers, 3, 1.0); - } else if(speaker5 == NULL) { + } else if(speaker5 == nullptr) { AIL_set_speaker_configuration(mgr->_digital_driver, speakers, 4, 1.0); - } else if(speaker6 == NULL) { + } else if(speaker6 == nullptr) { AIL_set_speaker_configuration(mgr->_digital_driver, speakers, 5, 1.0); - } else if(speaker7 == NULL) { + } else if(speaker7 == nullptr) { AIL_set_speaker_configuration(mgr->_digital_driver, speakers, 6, 1.0); - } else if(speaker8 == NULL) { + } else if(speaker8 == nullptr) { AIL_set_speaker_configuration(mgr->_digital_driver, speakers, 7, 1.0); - } else if(speaker9 == NULL) { + } else if(speaker9 == nullptr) { AIL_set_speaker_configuration(mgr->_digital_driver, speakers, 8, 1.0); } else { AIL_set_speaker_configuration(mgr->_digital_driver, speakers, 9, 1.0); @@ -878,16 +878,16 @@ load(const Filename &file_name) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); PT(VirtualFile) file = vfs->get_file(file_name); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { milesAudio_cat.warning() << "No such file: " << file_name << "\n"; - return NULL; + return nullptr; } if (file->get_file_size() == 0) { milesAudio_cat.warning() << "File " << file_name << " is empty\n"; - return NULL; + return nullptr; } sd->_basename = file_name.get_basename(); @@ -908,7 +908,7 @@ load(const Filename &file_name) { if (!file->read_file(sd->_raw_data, true)) { milesAudio_cat.warning() << "Unable to read " << file_name << "\n"; - return NULL; + return nullptr; } sd->_file_type = @@ -955,7 +955,7 @@ load(const Filename &file_name) { U32 wav_data_size; if (AIL_decompress_ASI(&sd->_raw_data[0], sd->_raw_data.size(), sd->_basename.c_str(), &wav_data, &wav_data_size, - NULL)) { + nullptr)) { audio_debug("expanded " << sd->_basename << " from " << sd->_raw_data.size() << " bytes to " << wav_data_size << " bytes."); diff --git a/panda/src/audiotraits/milesAudioManager.h b/panda/src/audiotraits/milesAudioManager.h index ead813b679..51fb16b527 100644 --- a/panda/src/audiotraits/milesAudioManager.h +++ b/panda/src/audiotraits/milesAudioManager.h @@ -81,7 +81,7 @@ public: virtual PN_stdfloat audio_3d_get_doppler_factor() const; virtual void audio_3d_set_drop_off_factor(PN_stdfloat factor); virtual PN_stdfloat audio_3d_get_drop_off_factor() const; - virtual void set_speaker_configuration(LVecBase3 *speaker1, LVecBase3 *speaker2=NULL, LVecBase3 *speaker3=NULL, LVecBase3 *speaker4=NULL, LVecBase3 *speaker5=NULL, LVecBase3 *speaker6=NULL, LVecBase3 *speaker7=NULL, LVecBase3 *speaker8=NULL, LVecBase3 *speaker9=NULL); + virtual void set_speaker_configuration(LVecBase3 *speaker1, LVecBase3 *speaker2=nullptr, LVecBase3 *speaker3=nullptr, LVecBase3 *speaker4=nullptr, LVecBase3 *speaker5=nullptr, LVecBase3 *speaker6=nullptr, LVecBase3 *speaker7=nullptr, LVecBase3 *speaker8=nullptr, LVecBase3 *speaker9=nullptr); virtual void output(ostream &out) const; virtual void write(ostream &out) const; diff --git a/panda/src/audiotraits/milesAudioSample.cxx b/panda/src/audiotraits/milesAudioSample.cxx index c89addb1a5..e953e77dad 100644 --- a/panda/src/audiotraits/milesAudioSample.cxx +++ b/panda/src/audiotraits/milesAudioSample.cxx @@ -38,7 +38,7 @@ MilesAudioSample(MilesAudioManager *manager, MilesAudioManager::SoundData *sd, MilesAudioSound(manager, file_name), _sd(sd) { - nassertv(sd != NULL); + nassertv(sd != nullptr); audio_debug("MilesAudioSample(manager=0x"<<(void*)&manager <<", sd=0x"<<(void*)sd<<", file_name="<release_sound(this); - _manager = NULL; + _manager = nullptr; } } @@ -325,7 +325,7 @@ void MilesAudioSample::set_3d_min_distance(PN_stdfloat dist) { // distances in a single operation. float max_dist; int auto_3D_wet_atten; - AIL_sample_3D_distances(_sample, &max_dist, NULL, &auto_3D_wet_atten); + AIL_sample_3D_distances(_sample, &max_dist, nullptr, &auto_3D_wet_atten); AIL_set_sample_3D_distances(_sample, max_dist, dist, auto_3D_wet_atten); } else { @@ -341,7 +341,7 @@ PN_stdfloat MilesAudioSample::get_3d_min_distance() const { if(_sample != 0) { float min_dist; - AIL_sample_3D_distances(_sample, NULL, &min_dist, NULL); + AIL_sample_3D_distances(_sample, nullptr, &min_dist, nullptr); return (PN_stdfloat)min_dist; } else { audio_warning("_sample == 0 in MilesAudioSample::get_3d_min_distance()."); @@ -362,7 +362,7 @@ void MilesAudioSample::set_3d_max_distance(PN_stdfloat dist) { // distances in a single operation. float min_dist; int auto_3D_wet_atten; - AIL_sample_3D_distances(_sample, NULL, &min_dist, &auto_3D_wet_atten); + AIL_sample_3D_distances(_sample, nullptr, &min_dist, &auto_3D_wet_atten); AIL_set_sample_3D_distances(_sample, dist, min_dist, auto_3D_wet_atten); } else { @@ -378,7 +378,7 @@ PN_stdfloat MilesAudioSample::get_3d_max_distance() const { if(_sample != 0) { float max_dist; - AIL_sample_3D_distances(_sample, &max_dist, NULL, NULL); + AIL_sample_3D_distances(_sample, &max_dist, nullptr, nullptr); return (PN_stdfloat)max_dist; } else { audio_warning("_sample == 0 in MilesAudioSample::get_3d_max_distance()."); @@ -500,7 +500,7 @@ finish_callback(HSAMPLE sample) { milesAudio_cat.debug() << "finished " << *self << "\n"; } - if (self->_manager == (MilesAudioManager *)NULL) { + if (self->_manager == nullptr) { return; } self->_manager->_sounds_finished = true; diff --git a/panda/src/audiotraits/milesAudioSequence.cxx b/panda/src/audiotraits/milesAudioSequence.cxx index 3b79099db8..9f16c0dd3d 100644 --- a/panda/src/audiotraits/milesAudioSequence.cxx +++ b/panda/src/audiotraits/milesAudioSequence.cxx @@ -38,7 +38,7 @@ MilesAudioSequence(MilesAudioManager *manager, MilesAudioManager::SoundData *sd, MilesAudioSound(manager, file_name), _sd(sd) { - nassertv(sd != NULL); + nassertv(sd != nullptr); audio_debug("MilesAudioSequence(manager=0x"<<(void*)&manager <<", sd=0x"<<(void*)sd<<", file_name="<_raw_data[0], 0); S32 length_ms; - AIL_sequence_ms_position(_sequence, &length_ms, NULL); + AIL_sequence_ms_position(_sequence, &length_ms, nullptr); PN_stdfloat time = (PN_stdfloat)length_ms * 0.001f; mgr->release_sequence(_sequence_index, this); _sequence = 0; diff --git a/panda/src/audiotraits/milesAudioSound.cxx b/panda/src/audiotraits/milesAudioSound.cxx index 0988eaf48e..de9d0edcff 100644 --- a/panda/src/audiotraits/milesAudioSound.cxx +++ b/panda/src/audiotraits/milesAudioSound.cxx @@ -130,7 +130,7 @@ set_time(PN_stdfloat time) { */ void MilesAudioSound:: set_active(bool active) { - if (_manager == (MilesAudioManager *)NULL) { + if (_manager == nullptr) { return; } diff --git a/panda/src/audiotraits/milesAudioStream.cxx b/panda/src/audiotraits/milesAudioStream.cxx index c8b9251cbd..debf8dd08a 100644 --- a/panda/src/audiotraits/milesAudioStream.cxx +++ b/panda/src/audiotraits/milesAudioStream.cxx @@ -118,7 +118,7 @@ play() { */ void MilesAudioStream:: stop() { - if (_manager == (MilesAudioManager *)NULL) { + if (_manager == nullptr) { return; } miles_audio_debug("stop()"); @@ -152,7 +152,7 @@ get_time() const { } S32 current_ms; - AIL_stream_ms_position(_stream, NULL, ¤t_ms); + AIL_stream_ms_position(_stream, nullptr, ¤t_ms); PN_stdfloat time = PN_stdfloat(current_ms * 0.001f); return time; @@ -226,7 +226,7 @@ length() const { } S32 length_ms; - AIL_stream_ms_position(_stream, &length_ms, NULL); + AIL_stream_ms_position(_stream, &length_ms, nullptr); _length = (PN_stdfloat)length_ms * 0.001f; _got_length = true; } @@ -266,9 +266,9 @@ cleanup() { set_active(false); nassertv(_stream == 0); - if (_manager != (MilesAudioManager *)NULL) { + if (_manager != nullptr) { _manager->release_sound(this); - _manager = NULL; + _manager = nullptr; } } @@ -283,7 +283,7 @@ finish_callback(HSTREAM stream) { milesAudio_cat.debug() << "finished " << *self << "\n"; } - if (self->_manager == (MilesAudioManager *)NULL) { + if (self->_manager == nullptr) { return; } self->_manager->_sounds_finished = true; @@ -300,7 +300,7 @@ do_set_time(PN_stdfloat time) { // Ensure we don't inadvertently run off the end of the sound. S32 length_ms; - AIL_stream_ms_position(_stream, &length_ms, NULL); + AIL_stream_ms_position(_stream, &length_ms, nullptr); time_ms = min(time_ms, length_ms); AIL_set_stream_ms_position(_stream, time_ms); diff --git a/panda/src/audiotraits/openalAudioManager.cxx b/panda/src/audiotraits/openalAudioManager.cxx index 1a91185ecf..f6b7caa22b 100644 --- a/panda/src/audiotraits/openalAudioManager.cxx +++ b/panda/src/audiotraits/openalAudioManager.cxx @@ -38,15 +38,15 @@ TypeHandle OpenALAudioManager::_type_handle; ReMutex OpenALAudioManager::_lock; int OpenALAudioManager::_active_managers = 0; bool OpenALAudioManager::_openal_active = false; -ALCdevice* OpenALAudioManager::_device = NULL; -ALCcontext* OpenALAudioManager::_context = NULL; +ALCdevice* OpenALAudioManager::_device = nullptr; +ALCcontext* OpenALAudioManager::_context = nullptr; // This is the list of all OpenALAudioManager objects in the world. It must // be a pointer rather than a concrete object, so it won't be destructed at // exit time before we're done removing things from it. -OpenALAudioManager::Managers *OpenALAudioManager::_managers = NULL; +OpenALAudioManager::Managers *OpenALAudioManager::_managers = nullptr; -OpenALAudioManager::SourceCache *OpenALAudioManager::_al_sources = NULL; +OpenALAudioManager::SourceCache *OpenALAudioManager::_al_sources = nullptr; // Central dispatcher for audio errors. @@ -79,7 +79,7 @@ AudioManager *Create_OpenALAudioManager() { OpenALAudioManager:: OpenALAudioManager() { ReMutexHolder holder(_lock); - if (_managers == (Managers *)NULL) { + if (_managers == nullptr) { _managers = new Managers; _al_sources = new SourceCache; } @@ -118,7 +118,7 @@ OpenALAudioManager() { // Initialization audio_cat.init(); if (_active_managers == 0 || !_openal_active) { - _device = NULL; + _device = nullptr; string dev_name = select_audio_device(); if (!dev_name.empty()) { @@ -126,7 +126,7 @@ OpenALAudioManager() { audio_cat.info() << "Using OpenAL device " << dev_name << "\n"; _device = alcOpenDevice(dev_name.c_str()); - if (_device == NULL) { + if (_device == nullptr) { audio_cat.error() << "Couldn't open OpenAL device \"" << dev_name << "\", falling back to default device\n"; } @@ -134,27 +134,27 @@ OpenALAudioManager() { audio_cat.info() << "Using default OpenAL device\n"; } - if (_device == NULL) { + if (_device == nullptr) { // Open the default device. - _device = alcOpenDevice(NULL); + _device = alcOpenDevice(nullptr); - if (_device == NULL && dev_name != "OpenAL Soft") { + if (_device == nullptr && dev_name != "OpenAL Soft") { // Try the OpenAL Soft driver instead, which is fairly reliable. _device = alcOpenDevice("OpenAL Soft"); - if (_device == NULL) { + if (_device == nullptr) { audio_cat.error() << "Couldn't open default OpenAL device\n"; } } } - if (_device != NULL) { + if (_device != nullptr) { // We managed to get a device open. alcGetError(_device); // clear errors - _context = alcCreateContext(_device, NULL); + _context = alcCreateContext(_device, nullptr); alc_audio_errcheck("alcCreateContext(_device, NULL)", _device); - if (_context != NULL) { + if (_context != nullptr) { _openal_active = true; } } @@ -197,7 +197,7 @@ OpenALAudioManager() { OpenALAudioManager:: ~OpenALAudioManager() { ReMutexHolder holder(_lock); - nassertv(_managers != (Managers *)NULL); + nassertv(_managers != nullptr); Managers::iterator mi = _managers->find(this); nassertv(mi != _managers->end()); _managers->erase(mi); @@ -213,7 +213,7 @@ OpenALAudioManager:: void OpenALAudioManager:: shutdown() { ReMutexHolder holder(_lock); - if (_managers != (Managers *)NULL) { + if (_managers != nullptr) { Managers::iterator mi; for (mi = _managers->begin(); mi != _managers->end(); ++mi) { (*mi)->cleanup(); @@ -241,12 +241,12 @@ string OpenALAudioManager:: select_audio_device() { string selected_device = openal_device; - const char *devices = NULL; + const char *devices = nullptr; // This extension gives us all audio paths on all drivers. - if (alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") == AL_TRUE) { - string default_device = alcGetString(NULL, ALC_DEFAULT_ALL_DEVICES_SPECIFIER); - devices = (const char *)alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER); + if (alcIsExtensionPresent(nullptr, "ALC_ENUMERATE_ALL_EXT") == AL_TRUE) { + string default_device = alcGetString(nullptr, ALC_DEFAULT_ALL_DEVICES_SPECIFIER); + devices = (const char *)alcGetString(nullptr, ALC_ALL_DEVICES_SPECIFIER); if (devices) { audio_cat.debug() << "All OpenAL devices:\n"; @@ -272,9 +272,9 @@ select_audio_device() { // This extension just gives us generic driver names, like "OpenAL Soft" and // "Generic Software", rather than individual outputs. - if (alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT") == AL_TRUE) { - string default_device = alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER); - devices = (const char *)alcGetString(NULL, ALC_DEVICE_SPECIFIER); + if (alcIsExtensionPresent(nullptr, "ALC_ENUMERATION_EXT") == AL_TRUE) { + string default_device = alcGetString(nullptr, ALC_DEFAULT_DEVICE_SPECIFIER); + devices = (const char *)alcGetString(nullptr, ALC_DEVICE_SPECIFIER); if (devices) { audio_cat.debug() << "OpenAL drivers:\n"; @@ -402,14 +402,14 @@ get_sound_data(MovieAudio *movie, int mode) { } PT(MovieAudioCursor) stream = movie->open(); - if (stream == 0) { + if (stream == nullptr) { audio_error("Cannot open file: "<_sample == 0) { audio_error("Could not create an OpenAL buffer object"); delete sd; - return NULL; + return nullptr; } int channels = stream->audio_channels(); int samples = (int)(stream->length() * stream->audio_rate()); @@ -448,7 +448,7 @@ get_sound_data(MovieAudio *movie, int mode) { if (err != AL_NO_ERROR) { audio_error("could not fill OpenAL buffer object with data"); delete sd; - return NULL; + return nullptr; } _sample_cache.insert(SampleCache::value_type(path, sd)); } else { @@ -498,7 +498,7 @@ get_sound(const string &file_name, bool positional, int mode) { if (path.empty()) { audio_error("get_sound - invalid filename"); - return NULL; + return nullptr; } PT(MovieAudio) mva = MovieAudio::get(path); @@ -1007,18 +1007,18 @@ cleanup() { // make sure that the context is not current when it is destroyed alcGetError(_device); // clear errors - alcMakeContextCurrent(NULL); + alcMakeContextCurrent(nullptr); alc_audio_errcheck("alcMakeContextCurrent(NULL)",_device); alcDestroyContext(_context); alc_audio_errcheck("alcDestroyContext(_context)",_device); - _context = NULL; + _context = nullptr; if (_device) { audio_debug("Going to try to close openAL"); alcCloseDevice(_device); // alc_audio_errcheck("alcCloseDevice(_device)",_device); - _device = NULL; + _device = nullptr; audio_debug("openAL Closed"); } @@ -1033,9 +1033,9 @@ cleanup() { */ OpenALAudioManager::SoundData:: SoundData() : - _manager(0), + _manager(nullptr), _sample(0), - _stream(NULL), + _stream(nullptr), _length(0.0), _rate(0), _channels(0), diff --git a/panda/src/audiotraits/openalAudioSound.I b/panda/src/audiotraits/openalAudioSound.I index 9a090adc3d..5bbf56e871 100644 --- a/panda/src/audiotraits/openalAudioSound.I +++ b/panda/src/audiotraits/openalAudioSound.I @@ -76,7 +76,7 @@ release_sound_data(bool force) { */ INLINE bool OpenALAudioSound:: is_valid() const { - return _manager != NULL; + return _manager != nullptr; } /** @@ -98,5 +98,5 @@ is_playing() const { */ INLINE bool OpenALAudioSound:: has_sound_data() const { - return _sd != NULL; + return _sd != nullptr; } diff --git a/panda/src/audiotraits/openalAudioSound.cxx b/panda/src/audiotraits/openalAudioSound.cxx index faa9df5717..2a697a642b 100644 --- a/panda/src/audiotraits/openalAudioSound.cxx +++ b/panda/src/audiotraits/openalAudioSound.cxx @@ -38,7 +38,7 @@ OpenALAudioSound(OpenALAudioManager* manager, bool positional, int mode) : _movie(movie), - _sd(NULL), + _sd(nullptr), _playing_loops(0), _playing_rate(0.0), _loops_completed(0), @@ -109,7 +109,7 @@ cleanup() { release_sound_data(true); } _manager->release_sound(this); - _manager = 0; + _manager = nullptr; } /** diff --git a/panda/src/awesomium/WebBrowserTexture.cxx b/panda/src/awesomium/WebBrowserTexture.cxx index 7872574b9d..04908f4abc 100644 --- a/panda/src/awesomium/WebBrowserTexture.cxx +++ b/panda/src/awesomium/WebBrowserTexture.cxx @@ -149,7 +149,7 @@ bool WebBrowserTexture::get_flip_texture_active() const { bool WebBrowserTexture::cull_callback(CullTraverser *trav, const CullTraverserData &data) const{ // see if we are in a state where udpates can happen. else just return if( !_update_active ) return true; - if( _aw_web_view == NULL ) return true; + if( _aw_web_view == nullptr ) return true; // do we even need to update? if( !_aw_web_view->is_dirty() ) return true; diff --git a/panda/src/awesomium/WebBrowserTexture.h b/panda/src/awesomium/WebBrowserTexture.h index e9ae392d10..112f8399da 100644 --- a/panda/src/awesomium/WebBrowserTexture.h +++ b/panda/src/awesomium/WebBrowserTexture.h @@ -37,7 +37,7 @@ protected: private: WebBrowserTexture(const WebBrowserTexture ©); PUBLISHED: - WebBrowserTexture(const string &name, AwWebView* aw_web_view = NULL); + WebBrowserTexture(const string &name, AwWebView* aw_web_view = nullptr); virtual ~WebBrowserTexture(); diff --git a/panda/src/bullet/bulletAllHitsRayResult.cxx b/panda/src/bullet/bulletAllHitsRayResult.cxx index 12c6abacc4..1b638efcf9 100644 --- a/panda/src/bullet/bulletAllHitsRayResult.cxx +++ b/panda/src/bullet/bulletAllHitsRayResult.cxx @@ -136,7 +136,7 @@ get_hit_fraction() const { PandaNode *BulletRayHit:: get_node() const { - return (_object) ? (PandaNode *)_object->getUserPointer() : NULL; + return (_object) ? (PandaNode *)_object->getUserPointer() : nullptr; } /** diff --git a/panda/src/bullet/bulletBodyNode.cxx b/panda/src/bullet/bulletBodyNode.cxx index 1b85a75779..565cfa35a2 100644 --- a/panda/src/bullet/bulletBodyNode.cxx +++ b/panda/src/bullet/bulletBodyNode.cxx @@ -310,7 +310,7 @@ BulletShape *BulletBodyNode:: get_shape(int idx) const { LightMutexHolder holder(BulletWorld::get_global_lock()); - nassertr(idx >= 0 && idx < (int)_shapes.size(), NULL); + nassertr(idx >= 0 && idx < (int)_shapes.size(), nullptr); return _shapes[idx]; } @@ -334,7 +334,7 @@ do_add_shape(BulletShape *bullet_shape, const TransformState *ts) { nassertv(ts); btCollisionShape *shape = bullet_shape->ptr(); - nassertv(shape != NULL); + nassertv(shape != nullptr); nassertv(!(shape->getShapeType() == CONVEX_HULL_SHAPE_PROXYTYPE && ((btConvexHullShape *)shape)->getNumVertices() == 0)); @@ -782,7 +782,7 @@ void BulletBodyNode:: add_shapes_from_collision_solids(CollisionNode *cnode) { LightMutexHolder holder(BulletWorld::get_global_lock()); - PT(BulletTriangleMesh) mesh = NULL; + PT(BulletTriangleMesh) mesh = nullptr; for (int j=0; jget_num_solids(); j++) { CPT(CollisionSolid) solid = cnode->get_solid(j); @@ -914,7 +914,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { } // Write NULL pointer to indicate the end of the list. - manager->write_pointer(dg, NULL); + manager->write_pointer(dg, nullptr); } /** @@ -927,7 +927,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { PT(BulletShape) shape = DCAST(BulletShape, p_list[pi++]); - while (shape != (BulletShape *)NULL) { + while (shape != nullptr) { const TransformState *trans = DCAST(TransformState, p_list[pi++]); add_shape(shape, trans); diff --git a/panda/src/bullet/bulletClosestHitRayResult.cxx b/panda/src/bullet/bulletClosestHitRayResult.cxx index 2e831c9308..094d404a6e 100644 --- a/panda/src/bullet/bulletClosestHitRayResult.cxx +++ b/panda/src/bullet/bulletClosestHitRayResult.cxx @@ -78,7 +78,7 @@ PandaNode *BulletClosestHitRayResult:: get_node() const { const btCollisionObject *objectPtr = m_collisionObject; - return (objectPtr) ? (PandaNode *)objectPtr->getUserPointer() : NULL; + return (objectPtr) ? (PandaNode *)objectPtr->getUserPointer() : nullptr; } /** diff --git a/panda/src/bullet/bulletClosestHitSweepResult.cxx b/panda/src/bullet/bulletClosestHitSweepResult.cxx index f86bc0456a..0e3d08ffc4 100644 --- a/panda/src/bullet/bulletClosestHitSweepResult.cxx +++ b/panda/src/bullet/bulletClosestHitSweepResult.cxx @@ -60,7 +60,7 @@ PandaNode *BulletClosestHitSweepResult:: get_node() const { const btCollisionObject *objectPtr = m_hitCollisionObject; - return (objectPtr) ? (PandaNode *)objectPtr->getUserPointer() : NULL; + return (objectPtr) ? (PandaNode *)objectPtr->getUserPointer() : nullptr; } /** diff --git a/panda/src/bullet/bulletContactCallbacks.h b/panda/src/bullet/bulletContactCallbacks.h index 27e8093e55..e368e6ee0c 100644 --- a/panda/src/bullet/bulletContactCallbacks.h +++ b/panda/src/bullet/bulletContactCallbacks.h @@ -51,7 +51,7 @@ contact_added_callback(btManifoldPoint &cp, int id1, int index1) { - if (cp.m_userPersistentData == NULL) { + if (cp.m_userPersistentData == nullptr) { #if BT_BULLET_VERSION >= 281 PT(PandaNode) node0 = (PandaNode *)wrap0->getCollisionObject()->getUserPointer(); diff --git a/panda/src/bullet/bulletContactResult.cxx b/panda/src/bullet/bulletContactResult.cxx index 4d9e2588bd..ad4e5b8801 100644 --- a/panda/src/bullet/bulletContactResult.cxx +++ b/panda/src/bullet/bulletContactResult.cxx @@ -22,8 +22,8 @@ BulletContact BulletContactResult::_empty; BulletContact:: BulletContact() : _mp(_empty) { - _node0 = NULL; - _node1 = NULL; + _node0 = nullptr; + _node1 = nullptr; } /** @@ -47,8 +47,8 @@ BulletContactResult:: BulletContactResult() : btCollisionWorld::ContactResultCallback() { #if BT_BULLET_VERSION >= 281 - _filter_cb = NULL; - _filter_proxy = NULL; + _filter_cb = nullptr; + _filter_proxy = nullptr; _filter_set = false; #endif } @@ -96,8 +96,8 @@ addSingleResult(btManifoldPoint &mp, BulletContact contact; contact._mp = BulletManifoldPoint(mp); - contact._node0 = obj0 ? (PandaNode *)obj0->getUserPointer() : NULL; - contact._node1 = obj1 ? (PandaNode *)obj1->getUserPointer() : NULL; + contact._node0 = obj0 ? (PandaNode *)obj0->getUserPointer() : nullptr; + contact._node1 = obj1 ? (PandaNode *)obj1->getUserPointer() : nullptr; contact._part_id0 = part_id0; contact._part_id1 = part_id1; contact._idx0 = idx0; @@ -119,8 +119,8 @@ addSingleResult(btManifoldPoint &mp, BulletContact contact; contact._mp = BulletManifoldPoint(mp); - contact._node0 = obj0 ? (PandaNode *)obj0->getUserPointer() : NULL; - contact._node1 = obj1 ? (PandaNode *)obj1->getUserPointer() : NULL; + contact._node0 = obj0 ? (PandaNode *)obj0->getUserPointer() : nullptr; + contact._node1 = obj1 ? (PandaNode *)obj1->getUserPointer() : nullptr; contact._part_id0 = part_id0; contact._part_id1 = part_id1; contact._idx0 = idx0; diff --git a/panda/src/bullet/bulletConvexHullShape.cxx b/panda/src/bullet/bulletConvexHullShape.cxx index 798aeda9e1..487219c7fd 100644 --- a/panda/src/bullet/bulletConvexHullShape.cxx +++ b/panda/src/bullet/bulletConvexHullShape.cxx @@ -25,7 +25,7 @@ TypeHandle BulletConvexHullShape::_type_handle; BulletConvexHullShape:: BulletConvexHullShape() { - _shape = new btConvexHullShape(NULL, 0); + _shape = new btConvexHullShape(nullptr, 0); _shape->setUserPointer(this); } @@ -36,7 +36,7 @@ BulletConvexHullShape:: BulletConvexHullShape(const BulletConvexHullShape ©) { LightMutexHolder holder(BulletWorld::get_global_lock()); - _shape = new btConvexHullShape(NULL, 0); + _shape = new btConvexHullShape(nullptr, 0); _shape->setUserPointer(this); #if BT_BULLET_VERSION >= 282 @@ -80,7 +80,7 @@ add_array(const PTA_LVecBase3 &points) { if (_shape) delete _shape; - _shape = new btConvexHullShape(NULL, 0); + _shape = new btConvexHullShape(nullptr, 0); _shape->setUserPointer(this); PTA_LVecBase3::const_iterator it; @@ -123,7 +123,7 @@ add_geom(const Geom *geom, const TransformState *ts) { delete _shape; // Create shape - _shape = new btConvexHullShape(NULL, 0); + _shape = new btConvexHullShape(nullptr, 0); _shape->setUserPointer(this); pvector::const_iterator it; diff --git a/panda/src/bullet/bulletGhostNode.cxx b/panda/src/bullet/bulletGhostNode.cxx index 14b693bda6..fad9e8141a 100644 --- a/panda/src/bullet/bulletGhostNode.cxx +++ b/panda/src/bullet/bulletGhostNode.cxx @@ -133,10 +133,10 @@ PandaNode *BulletGhostNode:: get_overlapping_node(int idx) const { LightMutexHolder holder(BulletWorld::get_global_lock()); - nassertr(idx >=0 && idx < _ghost->getNumOverlappingObjects(), NULL); + nassertr(idx >=0 && idx < _ghost->getNumOverlappingObjects(), nullptr); btCollisionObject *object = _ghost->getOverlappingObject(idx); - return (object) ? (PandaNode *)object->getUserPointer() : NULL; + return (object) ? (PandaNode *)object->getUserPointer() : nullptr; } /** diff --git a/panda/src/bullet/bulletHelper.I b/panda/src/bullet/bulletHelper.I index 51c4f4b830..85e168eb70 100644 --- a/panda/src/bullet/bulletHelper.I +++ b/panda/src/bullet/bulletHelper.I @@ -17,7 +17,7 @@ INLINE PT(InternalName) BulletHelper:: get_sb_index() { - if (_sb_index == (InternalName *)NULL) { + if (_sb_index == nullptr) { _sb_index = InternalName::make("sb_index"); } return _sb_index; @@ -29,7 +29,7 @@ get_sb_index() { INLINE PT(InternalName) BulletHelper:: get_sb_flip() { - if (_sb_flip == (InternalName *)NULL) { + if (_sb_flip == nullptr) { _sb_flip = InternalName::make("sb_flip"); } return _sb_flip; diff --git a/panda/src/bullet/bulletHelper.cxx b/panda/src/bullet/bulletHelper.cxx index a12a773740..d5e3f503b4 100644 --- a/panda/src/bullet/bulletHelper.cxx +++ b/panda/src/bullet/bulletHelper.cxx @@ -37,7 +37,7 @@ from_collision_solids(NodePath &np, bool clear) { NodePath cnp = npc.get_path(i); CollisionNode *cnode = DCAST(CollisionNode, cnp.node()); - PT(PandaNode) bnode = NULL; + PT(PandaNode) bnode = nullptr; // Create a either a new rigid body or a new ghost for each CollisionNode, // and add one shape per CollisionSolid contained in the CollisionNode @@ -179,8 +179,8 @@ make_geom(BulletSoftBodyNode *node, const GeomVertexFormat *format, bool two_sid CPT(GeomVertexFormat) fmt = (format) ? format : GeomVertexFormat::get_v3n3t2(); fmt = BulletHelper::add_sb_flip_column(fmt); - nassertr(fmt->has_column(InternalName::get_vertex()), NULL); - nassertr(fmt->has_column(InternalName::get_normal()), NULL); + nassertr(fmt->has_column(InternalName::get_vertex()), nullptr); + nassertr(fmt->has_column(InternalName::get_normal()), nullptr); btSoftBody::tNodeArray &nodes(body->m_nodes); diff --git a/panda/src/bullet/bulletHelper.h b/panda/src/bullet/bulletHelper.h index c63f70f111..f2195d4d92 100644 --- a/panda/src/bullet/bulletHelper.h +++ b/panda/src/bullet/bulletHelper.h @@ -43,11 +43,11 @@ PUBLISHED: // Geom utils static PT(Geom) make_geom_from_faces(BulletSoftBodyNode *node, - const GeomVertexFormat *format=NULL, + const GeomVertexFormat *format=nullptr, bool two_sided=false); static PT(Geom) make_geom_from_links(BulletSoftBodyNode *node, - const GeomVertexFormat *format=NULL); + const GeomVertexFormat *format=nullptr); static void make_texcoords_for_patch(Geom *geom, int resx, int resy); diff --git a/panda/src/bullet/bulletPersistentManifold.cxx b/panda/src/bullet/bulletPersistentManifold.cxx index e42ea3c6f8..67d760e8df 100644 --- a/panda/src/bullet/bulletPersistentManifold.cxx +++ b/panda/src/bullet/bulletPersistentManifold.cxx @@ -65,7 +65,7 @@ get_node0() { const btCollisionObject *obj = (btCollisionObject *)_manifold->getBody0(); #endif - return (obj) ? (PandaNode *)obj->getUserPointer(): NULL; + return (obj) ? (PandaNode *)obj->getUserPointer(): nullptr; } /** @@ -81,7 +81,7 @@ get_node1() { const btCollisionObject *obj = (btCollisionObject *)_manifold->getBody1(); #endif - return (obj) ? (PandaNode *)obj->getUserPointer(): NULL; + return (obj) ? (PandaNode *)obj->getUserPointer(): nullptr; } /** @@ -101,7 +101,7 @@ BulletManifoldPoint *BulletPersistentManifold:: get_manifold_point(int idx) const { LightMutexHolder holder(BulletWorld::get_global_lock()); - nassertr(idx < _manifold->getNumContacts(), NULL) + nassertr(idx < _manifold->getNumContacts(), nullptr) return new BulletManifoldPoint(_manifold->getContactPoint(idx)); } diff --git a/panda/src/bullet/bulletPlaneShape.h b/panda/src/bullet/bulletPlaneShape.h index dfee91f12c..95aa16d9ef 100644 --- a/panda/src/bullet/bulletPlaneShape.h +++ b/panda/src/bullet/bulletPlaneShape.h @@ -29,7 +29,7 @@ class EXPCL_PANDABULLET BulletPlaneShape : public BulletShape { private: // Only used by make_from_bam - INLINE BulletPlaneShape() : _shape(NULL) {}; + INLINE BulletPlaneShape() : _shape(nullptr) {}; PUBLISHED: explicit BulletPlaneShape(const LVector3 &normal, PN_stdfloat constant); diff --git a/panda/src/bullet/bulletSoftBodyNode.cxx b/panda/src/bullet/bulletSoftBodyNode.cxx index 8321c610f1..546a73f311 100644 --- a/panda/src/bullet/bulletSoftBodyNode.cxx +++ b/panda/src/bullet/bulletSoftBodyNode.cxx @@ -41,15 +41,15 @@ BulletSoftBodyNode(btSoftBody *body, const char *name) : BulletBodyNode(name) { // Shape btCollisionShape *shape_ptr = _soft->getCollisionShape(); - nassertv(shape_ptr != NULL); + nassertv(shape_ptr != nullptr); nassertv(shape_ptr->getShapeType() == SOFTBODY_SHAPE_PROXYTYPE); _shapes.push_back(new BulletSoftBodyShape((btSoftBodyCollisionShape *)shape_ptr)); // Rendering - _geom = NULL; - _curve = NULL; - _surface = NULL; + _geom = nullptr; + _curve = nullptr; + _surface = nullptr; } /** @@ -385,7 +385,7 @@ void BulletSoftBodyNode:: unlink_geom() { LightMutexHolder holder(BulletWorld::get_global_lock()); - _geom = NULL; + _geom = nullptr; } /** @@ -407,7 +407,7 @@ void BulletSoftBodyNode:: unlink_curve() { LightMutexHolder holder(BulletWorld::get_global_lock()); - _curve = NULL; + _curve = nullptr; } /** @@ -429,7 +429,7 @@ void BulletSoftBodyNode:: unlink_surface() { LightMutexHolder holder(BulletWorld::get_global_lock()); - _surface = NULL; + _surface = nullptr; } /** @@ -851,7 +851,7 @@ make_tri_mesh(BulletSoftBodyWorldInfo &info, PTA_LVecBase3 points, PTA_int indic num_triangles, randomizeConstraints); - nassertr(body, NULL); + nassertr(body, nullptr); delete[] vertices; delete[] triangles; @@ -873,7 +873,7 @@ make_tri_mesh(BulletSoftBodyWorldInfo &info, const Geom *geom, bool randomizeCon CPT(GeomVertexData) vdata = geom->get_vertex_data(); - nassertr(vdata->has_column(InternalName::get_vertex()), NULL); + nassertr(vdata->has_column(InternalName::get_vertex()), nullptr); GeomVertexReader vreader(vdata, InternalName::get_vertex()); @@ -953,7 +953,7 @@ make_tet_mesh(BulletSoftBodyWorldInfo &info, PTA_LVecBase3 points, PTA_int indic PT(BulletSoftBodyNode) BulletSoftBodyNode:: make_tet_mesh(BulletSoftBodyWorldInfo &info, const char *ele, const char *face, const char *node) { - nassertr(node && node[0], NULL); + nassertr(node && node[0], nullptr); // Nodes btAlignedObjectArray pos; diff --git a/panda/src/bullet/bulletSoftBodyNode.h b/panda/src/bullet/bulletSoftBodyNode.h index 600e185fac..26d7cc6fce 100644 --- a/panda/src/bullet/bulletSoftBodyNode.h +++ b/panda/src/bullet/bulletSoftBodyNode.h @@ -78,7 +78,7 @@ PUBLISHED: BulletSoftBodyConfig get_cfg(); BulletSoftBodyWorldInfo get_world_info(); - void generate_bending_constraints(int distance, BulletSoftBodyMaterial *material=NULL); + void generate_bending_constraints(int distance, BulletSoftBodyMaterial *material=nullptr); void randomize_constraints(); // Mass, volume, density @@ -146,7 +146,7 @@ PUBLISHED: PN_stdfloat erp=1.0, PN_stdfloat cfm=1.0, PN_stdfloat split=1.0, - BulletSoftBodyControl *control=NULL); + BulletSoftBodyControl *control=nullptr); // Materials int get_num_materials() const; diff --git a/panda/src/bullet/bulletSoftBodyShape.cxx b/panda/src/bullet/bulletSoftBodyShape.cxx index 9e6aa2929b..c6df128687 100644 --- a/panda/src/bullet/bulletSoftBodyShape.cxx +++ b/panda/src/bullet/bulletSoftBodyShape.cxx @@ -47,6 +47,6 @@ get_body() const { } else { - return NULL; + return nullptr; } } diff --git a/panda/src/bullet/bulletSphereShape.h b/panda/src/bullet/bulletSphereShape.h index aad49a145c..e0634d50c2 100644 --- a/panda/src/bullet/bulletSphereShape.h +++ b/panda/src/bullet/bulletSphereShape.h @@ -28,7 +28,7 @@ class EXPCL_PANDABULLET BulletSphereShape : public BulletShape { private: // Only used by make_from_bam - INLINE BulletSphereShape() : _shape(NULL) {}; + INLINE BulletSphereShape() : _shape(nullptr) {}; PUBLISHED: explicit BulletSphereShape(PN_stdfloat radius); diff --git a/panda/src/bullet/bulletTriangleMesh.cxx b/panda/src/bullet/bulletTriangleMesh.cxx index e2d3e0b242..9286a2d010 100644 --- a/panda/src/bullet/bulletTriangleMesh.cxx +++ b/panda/src/bullet/bulletTriangleMesh.cxx @@ -423,7 +423,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { // Add the vertices. const unsigned char *vptr = mesh.m_vertexBase; - nassertv(vptr != NULL || mesh.m_numVertices == 0); + nassertv(vptr != nullptr || mesh.m_numVertices == 0); for (int i = 0; i < mesh.m_numVertices; ++i) { const btVector3 &vertex = *((btVector3 *)vptr); @@ -435,7 +435,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { // Now add the triangle indices. const unsigned char *iptr = mesh.m_triangleIndexBase; - nassertv(iptr != NULL || mesh.m_numTriangles == 0); + nassertv(iptr != nullptr || mesh.m_numTriangles == 0); for (int i = 0; i < mesh.m_numTriangles; ++i) { int *triangle = (int *)iptr; diff --git a/panda/src/bullet/bulletTriangleMeshShape.I b/panda/src/bullet/bulletTriangleMeshShape.I index f178723ebc..f1263cbed6 100644 --- a/panda/src/bullet/bulletTriangleMeshShape.I +++ b/panda/src/bullet/bulletTriangleMeshShape.I @@ -32,7 +32,7 @@ INLINE BulletTriangleMeshShape:: INLINE bool BulletTriangleMeshShape:: is_static() const { - return (_bvh_shape != NULL); + return (_bvh_shape != nullptr); } /** @@ -41,5 +41,5 @@ is_static() const { INLINE bool BulletTriangleMeshShape:: is_dynamic() const { - return (_gimpact_shape != NULL); + return (_gimpact_shape != nullptr); } diff --git a/panda/src/bullet/bulletTriangleMeshShape.cxx b/panda/src/bullet/bulletTriangleMeshShape.cxx index ced374a3fc..ca9f7288cc 100644 --- a/panda/src/bullet/bulletTriangleMeshShape.cxx +++ b/panda/src/bullet/bulletTriangleMeshShape.cxx @@ -25,9 +25,9 @@ TypeHandle BulletTriangleMeshShape::_type_handle; */ BulletTriangleMeshShape:: BulletTriangleMeshShape() : - _mesh(NULL), - _gimpact_shape(NULL), - _bvh_shape(NULL), + _mesh(nullptr), + _gimpact_shape(nullptr), + _bvh_shape(nullptr), _dynamic(false), _compress(false), _bvh(false) { @@ -66,7 +66,7 @@ BulletTriangleMeshShape(BulletTriangleMesh *mesh, bool dynamic, bool compress, b _gimpact_shape->updateBound(); _gimpact_shape->setUserPointer(this); - _bvh_shape = NULL; + _bvh_shape = nullptr; } // Static will create a Bvh mesh shape @@ -75,7 +75,7 @@ BulletTriangleMeshShape(BulletTriangleMesh *mesh, bool dynamic, bool compress, b _bvh_shape = new btBvhTriangleMeshShape(mesh->ptr(), compress, bvh); _bvh_shape->setUserPointer(this); - _gimpact_shape = NULL; + _gimpact_shape = nullptr; } } @@ -95,11 +95,11 @@ BulletTriangleMeshShape(const BulletTriangleMeshShape ©) { _gimpact_shape = new btGImpactMeshShape(_mesh->ptr()); _gimpact_shape->updateBound(); _gimpact_shape->setUserPointer(this); - _bvh_shape = NULL; + _bvh_shape = nullptr; } else { _bvh_shape = new btBvhTriangleMeshShape(_mesh->ptr(), _compress, _bvh); _bvh_shape->setUserPointer(this); - _gimpact_shape = NULL; + _gimpact_shape = nullptr; } } @@ -117,7 +117,7 @@ ptr() const { return _gimpact_shape; } - return NULL; + return nullptr; } /** @@ -174,7 +174,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { _mesh = DCAST(BulletTriangleMesh, p_list[pi++]); btStridingMeshInterface *mesh_ptr = _mesh->ptr(); - nassertr(mesh_ptr != NULL, pi); + nassertr(mesh_ptr != nullptr, pi); if (_dynamic) { _gimpact_shape = new btGImpactMeshShape(mesh_ptr); diff --git a/panda/src/bullet/bulletVehicle.cxx b/panda/src/bullet/bulletVehicle.cxx index e2d74c131d..8d0f479dee 100644 --- a/panda/src/bullet/bulletVehicle.cxx +++ b/panda/src/bullet/bulletVehicle.cxx @@ -76,7 +76,7 @@ BulletRigidBodyNode *BulletVehicle:: do_get_chassis() { btRigidBody *bodyPtr = _vehicle->getRigidBody(); - return (bodyPtr) ? (BulletRigidBodyNode *)bodyPtr->getUserPointer() : NULL; + return (bodyPtr) ? (BulletRigidBodyNode *)bodyPtr->getUserPointer() : nullptr; } /** @@ -180,7 +180,7 @@ create_wheel() { btWheelInfo &info = _vehicle->addWheel(pos, direction, axle, suspension, radius, _tuning._, false); - info.m_clientInfo = NULL; + info.m_clientInfo = nullptr; return BulletWheel(info); } diff --git a/panda/src/bullet/bulletWheel.cxx b/panda/src/bullet/bulletWheel.cxx index 149dbd8bf5..c24369546b 100644 --- a/panda/src/bullet/bulletWheel.cxx +++ b/panda/src/bullet/bulletWheel.cxx @@ -517,7 +517,7 @@ PandaNode *BulletWheel:: get_node() const { LightMutexHolder holder(BulletWorld::get_global_lock()); - return (_info.m_clientInfo == NULL) ? NULL : (PandaNode *)_info.m_clientInfo; + return (_info.m_clientInfo == nullptr) ? nullptr : (PandaNode *)_info.m_clientInfo; } /** @@ -597,5 +597,5 @@ PandaNode *BulletWheelRaycastInfo:: get_ground_object() const { LightMutexHolder holder(BulletWorld::get_global_lock()); - return _info.m_groundObject ? (PandaNode *)_info.m_groundObject : NULL; + return _info.m_groundObject ? (PandaNode *)_info.m_groundObject : nullptr; } diff --git a/panda/src/bullet/bulletWorld.I b/panda/src/bullet/bulletWorld.I index 61893a1531..d79534c865 100644 --- a/panda/src/bullet/bulletWorld.I +++ b/panda/src/bullet/bulletWorld.I @@ -65,7 +65,7 @@ get_debug_node() const { INLINE bool BulletWorld:: has_debug_node() const { - return _debug != NULL; + return _debug != nullptr; } /** diff --git a/panda/src/bullet/bulletWorld.cxx b/panda/src/bullet/bulletWorld.cxx index 6098759581..6827140e93 100644 --- a/panda/src/bullet/bulletWorld.cxx +++ b/panda/src/bullet/bulletWorld.cxx @@ -95,13 +95,13 @@ BulletWorld() { break; default: bullet_cat.error() << "no proper filter algorithm!" << endl; - _filter_cb = NULL; + _filter_cb = nullptr; } _world->getPairCache()->setOverlapFilterCallback(_filter_cb); // Tick callback - _tick_callback_obj = NULL; + _tick_callback_obj = nullptr; // SoftBodyWorldInfo _info.m_dispatcher = _dispatcher; @@ -786,7 +786,7 @@ BulletRigidBodyNode *BulletWorld:: get_rigid_body(int idx) const { LightMutexHolder holder(get_global_lock()); - nassertr(idx >= 0 && idx < (int)_bodies.size(), NULL); + nassertr(idx >= 0 && idx < (int)_bodies.size(), nullptr); return _bodies[idx]; } @@ -807,7 +807,7 @@ BulletSoftBodyNode *BulletWorld:: get_soft_body(int idx) const { LightMutexHolder holder(get_global_lock()); - nassertr(idx >= 0 && idx < (int)_softbodies.size(), NULL); + nassertr(idx >= 0 && idx < (int)_softbodies.size(), nullptr); return _softbodies[idx]; } @@ -828,7 +828,7 @@ BulletGhostNode *BulletWorld:: get_ghost(int idx) const { LightMutexHolder holder(get_global_lock()); - nassertr(idx >= 0 && idx < (int)_ghosts.size(), NULL); + nassertr(idx >= 0 && idx < (int)_ghosts.size(), nullptr); return _ghosts[idx]; } @@ -849,7 +849,7 @@ BulletBaseCharacterControllerNode *BulletWorld:: get_character(int idx) const { LightMutexHolder holder(get_global_lock()); - nassertr(idx >= 0 && idx < (int)_characters.size(), NULL); + nassertr(idx >= 0 && idx < (int)_characters.size(), nullptr); return _characters[idx]; } @@ -870,7 +870,7 @@ BulletVehicle *BulletWorld:: get_vehicle(int idx) const { LightMutexHolder holder(get_global_lock()); - nassertr(idx >= 0 && idx < (int)_vehicles.size(), NULL); + nassertr(idx >= 0 && idx < (int)_vehicles.size(), nullptr); return _vehicles[idx]; } @@ -891,7 +891,7 @@ BulletConstraint *BulletWorld:: get_constraint(int idx) const { LightMutexHolder holder(get_global_lock()); - nassertr(idx >= 0 && idx < (int)_constraints.size(), NULL); + nassertr(idx >= 0 && idx < (int)_constraints.size(), nullptr); return _constraints[idx]; } @@ -1052,10 +1052,10 @@ BulletPersistentManifold *BulletWorld:: get_manifold(int idx) const { LightMutexHolder holder(get_global_lock()); - nassertr(idx < _dispatcher->getNumManifolds(), NULL); + nassertr(idx < _dispatcher->getNumManifolds(), nullptr); btPersistentManifold *ptr = _dispatcher->getManifoldByIndexInternal(idx); - return (ptr) ? new BulletPersistentManifold(ptr) : NULL; + return (ptr) ? new BulletPersistentManifold(ptr) : nullptr; } /** @@ -1077,7 +1077,7 @@ get_collision_object(PandaNode *node) { return ((BulletSoftBodyNode *)node)->get_object(); } - return NULL; + return nullptr; } /** @@ -1148,7 +1148,7 @@ clear_contact_added_callback() { _world->getSolverInfo().m_solverMode &= ~SOLVER_USE_2_FRICTION_DIRECTIONS; _world->getSolverInfo().m_solverMode &= ~SOLVER_ENABLE_FRICTION_DIRECTION_CACHING; - bullet_contact_added_callback = NULL; + bullet_contact_added_callback = nullptr; } /** @@ -1158,7 +1158,7 @@ void BulletWorld:: set_tick_callback(CallbackObject *obj, bool is_pretick) { LightMutexHolder holder(get_global_lock()); - nassertv(obj != NULL); + nassertv(obj != nullptr); _tick_callback_obj = obj; _world->setInternalTickCallback(&BulletWorld::tick_callback, this, is_pretick); } @@ -1170,8 +1170,8 @@ void BulletWorld:: clear_tick_callback() { LightMutexHolder holder(get_global_lock()); - _tick_callback_obj = NULL; - _world->setInternalTickCallback(NULL); + _tick_callback_obj = nullptr; + _world->setInternalTickCallback(nullptr); } /** @@ -1202,7 +1202,7 @@ void BulletWorld:: set_filter_callback(CallbackObject *obj) { LightMutexHolder holder(get_global_lock()); - nassertv(obj != NULL); + nassertv(obj != nullptr); if (_filter_algorithm != FA_callback) { bullet_cat.warning() << "filter algorithm is not 'callback'" << endl; @@ -1218,7 +1218,7 @@ void BulletWorld:: clear_filter_callback() { LightMutexHolder holder(get_global_lock()); - _filter_cb3._filter_callback_obj = NULL; + _filter_cb3._filter_callback_obj = nullptr; } /** diff --git a/panda/src/chan/animBundle.cxx b/panda/src/chan/animBundle.cxx index ad67124966..312483b3be 100644 --- a/panda/src/chan/animBundle.cxx +++ b/panda/src/chan/animBundle.cxx @@ -32,7 +32,7 @@ AnimBundle(AnimGroup *parent, const AnimBundle ©) : _fps(copy._fps), _num_frames(copy._num_frames) { - nassertv(_root == (AnimBundle *)NULL); + nassertv(_root == nullptr); _root = this; } @@ -43,7 +43,7 @@ AnimBundle(AnimGroup *parent, const AnimBundle ©) : */ PT(AnimBundle) AnimBundle:: copy_bundle() const { - PT(AnimGroup) group = copy_subtree((AnimGroup *)NULL); + PT(AnimGroup) group = copy_subtree(nullptr); return DCAST(AnimBundle, group.p()); } diff --git a/panda/src/chan/animBundleNode.cxx b/panda/src/chan/animBundleNode.cxx index b3e49ca6a7..f6fab7a110 100644 --- a/panda/src/chan/animBundleNode.cxx +++ b/panda/src/chan/animBundleNode.cxx @@ -46,12 +46,12 @@ safe_to_flatten() const { */ AnimBundle *AnimBundleNode:: find_anim_bundle(PandaNode *root) { - nassertr(root != (PandaNode *)NULL, NULL); + nassertr(root != nullptr, nullptr); if (root->is_of_type(AnimBundleNode::get_class_type())) { AnimBundleNode *anode = DCAST(AnimBundleNode, root); AnimBundle *anim = anode->get_bundle(); - if (anim != (AnimBundle *)NULL) { + if (anim != nullptr) { return anim; } } @@ -60,12 +60,12 @@ find_anim_bundle(PandaNode *root) { int num_children = cr.get_num_children(); for (int i = 0; i < num_children; i++) { AnimBundle *anim = find_anim_bundle(cr.get_child(i)); - if (anim != (AnimBundle *)NULL) { + if (anim != nullptr) { return anim; } } - return NULL; + return nullptr; } /** diff --git a/panda/src/chan/animChannelMatrixDynamic.cxx b/panda/src/chan/animChannelMatrixDynamic.cxx index fb60451bc3..1fa762e782 100644 --- a/panda/src/chan/animChannelMatrixDynamic.cxx +++ b/panda/src/chan/animChannelMatrixDynamic.cxx @@ -41,7 +41,7 @@ AnimChannelMatrixDynamic(AnimGroup *parent, const AnimChannelMatrixDynamic © AnimChannelMatrix(parent, copy), _value_node(copy._value_node), _value(copy._value), - _last_value(NULL) + _last_value(nullptr) { } @@ -53,7 +53,7 @@ AnimChannelMatrixDynamic(const string &name) : AnimChannelMatrix(name) { _value = TransformState::make_identity(); - _last_value = NULL; // This is impossible; thus, has_changed() will + _last_value = nullptr; // This is impossible; thus, has_changed() will // always return true the first time. } @@ -64,7 +64,7 @@ AnimChannelMatrixDynamic(const string &name) */ bool AnimChannelMatrixDynamic:: has_changed(int, double, int, double) { - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); } bool has_changed = (_value != _last_value); @@ -77,7 +77,7 @@ has_changed(int, double, int, double) { */ void AnimChannelMatrixDynamic:: get_value(int, LMatrix4 &mat) { - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); } mat = _value->get_mat(); @@ -89,7 +89,7 @@ get_value(int, LMatrix4 &mat) { */ void AnimChannelMatrixDynamic:: get_value_no_scale_shear(int, LMatrix4 &mat) { - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); } if (_value->has_scale() || _value->has_shear()) { @@ -105,7 +105,7 @@ get_value_no_scale_shear(int, LMatrix4 &mat) { */ void AnimChannelMatrixDynamic:: get_scale(int, LVecBase3 &scale) { - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); } scale = _value->get_scale(); @@ -117,7 +117,7 @@ get_scale(int, LVecBase3 &scale) { */ void AnimChannelMatrixDynamic:: get_hpr(int, LVecBase3 &hpr) { - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); } hpr = _value->get_hpr(); @@ -130,7 +130,7 @@ get_hpr(int, LVecBase3 &hpr) { */ void AnimChannelMatrixDynamic:: get_quat(int, LQuaternion &quat) { - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); } quat = _value->get_quat(); @@ -142,7 +142,7 @@ get_quat(int, LQuaternion &quat) { */ void AnimChannelMatrixDynamic:: get_pos(int, LVecBase3 &pos) { - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); } pos = _value->get_pos(); @@ -154,7 +154,7 @@ get_pos(int, LVecBase3 &pos) { */ void AnimChannelMatrixDynamic:: get_shear(int, LVecBase3 &shear) { - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); } shear = _value->get_shear(); @@ -186,7 +186,7 @@ set_value(const TransformState *value) { void AnimChannelMatrixDynamic:: set_value_node(PandaNode *value_node) { _value_node = value_node; - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); } } diff --git a/panda/src/chan/animChannelMatrixXfmTable.I b/panda/src/chan/animChannelMatrixXfmTable.I index 93fceb143c..e86bc56658 100644 --- a/panda/src/chan/animChannelMatrixXfmTable.I +++ b/panda/src/chan/animChannelMatrixXfmTable.I @@ -41,7 +41,7 @@ has_table(char table_id) const { if (table_index < 0) { return false; } - return !(_tables[table_index] == (const PN_stdfloat *)NULL); + return !(_tables[table_index] == nullptr); } /** @@ -51,7 +51,7 @@ INLINE void AnimChannelMatrixXfmTable:: clear_table(char table_id) { int table_index = get_table_index(table_id); if (table_index >= 0) { - _tables[table_index] = NULL; + _tables[table_index] = nullptr; } } diff --git a/panda/src/chan/animChannelMatrixXfmTable.cxx b/panda/src/chan/animChannelMatrixXfmTable.cxx index 6c404d06fe..ec9564ee88 100644 --- a/panda/src/chan/animChannelMatrixXfmTable.cxx +++ b/panda/src/chan/animChannelMatrixXfmTable.cxx @@ -377,7 +377,7 @@ write_datagram(BamWriter *manager, Datagram &me) { PN_stdfloat r = _tables[8].empty() ? 0.0f : _tables[8][i % _tables[8].size()]; hprs.push_back(LVecBase3(h, p, r)); } - const LVecBase3 *hprs_array = NULL; + const LVecBase3 *hprs_array = nullptr; if (hprs_length != 0) { hprs_array = &hprs[0]; } diff --git a/panda/src/chan/animChannelScalarDynamic.cxx b/panda/src/chan/animChannelScalarDynamic.cxx index ead0d539a6..a5597110ba 100644 --- a/panda/src/chan/animChannelScalarDynamic.cxx +++ b/panda/src/chan/animChannelScalarDynamic.cxx @@ -41,7 +41,7 @@ AnimChannelScalarDynamic(AnimGroup *parent, const AnimChannelScalarDynamic © AnimChannelScalar(parent, copy), _value_node(copy._value_node), _value(copy._value), - _last_value(NULL), + _last_value(nullptr), _value_changed(true), _float_value(copy._float_value) { @@ -66,7 +66,7 @@ AnimChannelScalarDynamic(const string &name) */ bool AnimChannelScalarDynamic:: has_changed(int, double, int, double) { - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); bool has_changed = (_value != _last_value); _last_value = _value; @@ -84,7 +84,7 @@ has_changed(int, double, int, double) { */ void AnimChannelScalarDynamic:: get_value(int, PN_stdfloat &value) { - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { value = _value->get_pos()[0]; } else { @@ -108,13 +108,13 @@ set_value(PN_stdfloat value) { */ void AnimChannelScalarDynamic:: set_value_node(PandaNode *value_node) { - if (_value_node == (PandaNode *)NULL) { + if (_value_node == nullptr) { _last_value = TransformState::make_pos(LVecBase3(_float_value, 0.0f, 0.0f)); } _value_node = value_node; - if (_value_node != (PandaNode *)NULL) { + if (_value_node != nullptr) { _value = _value_node->get_transform(); } } diff --git a/panda/src/chan/animChannelScalarTable.I b/panda/src/chan/animChannelScalarTable.I index 1a41648490..b9dda3154c 100644 --- a/panda/src/chan/animChannelScalarTable.I +++ b/panda/src/chan/animChannelScalarTable.I @@ -25,7 +25,7 @@ get_table() const { */ INLINE bool AnimChannelScalarTable:: has_table() const { - return _table != (const PN_stdfloat *)NULL; + return _table != nullptr; } @@ -34,5 +34,5 @@ has_table() const { */ INLINE void AnimChannelScalarTable:: clear_table() { - _table = NULL; + _table = nullptr; } diff --git a/panda/src/chan/animControl.I b/panda/src/chan/animControl.I index 3b79891fc4..4c493dd943 100644 --- a/panda/src/chan/animControl.I +++ b/panda/src/chan/animControl.I @@ -28,7 +28,7 @@ is_pending() const { */ INLINE bool AnimControl:: has_anim() const { - return (_anim != (AnimBundle *)NULL); + return (_anim != nullptr); } /** diff --git a/panda/src/chan/animControl.cxx b/panda/src/chan/animControl.cxx index 35e56374f7..34fd94646e 100644 --- a/panda/src/chan/animControl.cxx +++ b/panda/src/chan/animControl.cxx @@ -40,7 +40,7 @@ AnimControl(const string &name, PartBundle *part, _pending = true; _part = part; - _anim = NULL; + _anim = nullptr; _channel_index = -1; set_frame_rate(frame_rate); set_num_frames(num_frames); @@ -57,7 +57,7 @@ setup_anim(PartBundle *part, AnimBundle *anim, int channel_index, const BitArray &bound_joints) { MutexHolder holder(_pending_lock); nassertv(_pending && part == _part); - nassertv(_anim == (AnimBundle *)NULL); + nassertv(_anim == nullptr); _anim = anim; _channel_index = channel_index; _bound_joints = bound_joints; diff --git a/panda/src/chan/animControlCollection.I b/panda/src/chan/animControlCollection.I index fd4b7251b1..2492c3ad03 100644 --- a/panda/src/chan/animControlCollection.I +++ b/panda/src/chan/animControlCollection.I @@ -17,7 +17,7 @@ INLINE bool AnimControlCollection:: play(const string &anim_name) { AnimControl *control = find_anim(anim_name); - if (control == (AnimControl *)NULL) { + if (control == nullptr) { return false; } _last_started_control = control; @@ -31,7 +31,7 @@ play(const string &anim_name) { INLINE bool AnimControlCollection:: play(const string &anim_name, double from, double to) { AnimControl *control = find_anim(anim_name); - if (control == (AnimControl *)NULL) { + if (control == nullptr) { return false; } _last_started_control = control; @@ -45,7 +45,7 @@ play(const string &anim_name, double from, double to) { INLINE bool AnimControlCollection:: loop(const string &anim_name, bool restart) { AnimControl *control = find_anim(anim_name); - if (control == (AnimControl *)NULL) { + if (control == nullptr) { return false; } _last_started_control = control; @@ -59,7 +59,7 @@ loop(const string &anim_name, bool restart) { INLINE bool AnimControlCollection:: loop(const string &anim_name, bool restart, double from, double to) { AnimControl *control = find_anim(anim_name); - if (control == (AnimControl *)NULL) { + if (control == nullptr) { return false; } _last_started_control = control; @@ -73,7 +73,7 @@ loop(const string &anim_name, bool restart, double from, double to) { INLINE bool AnimControlCollection:: stop(const string &anim_name) { AnimControl *control = find_anim(anim_name); - if (control == (AnimControl *)NULL) { + if (control == nullptr) { return false; } control->stop(); @@ -87,7 +87,7 @@ stop(const string &anim_name) { INLINE bool AnimControlCollection:: pose(const string &anim_name, double frame) { AnimControl *control = find_anim(anim_name); - if (control == (AnimControl *)NULL) { + if (control == nullptr) { return false; } _last_started_control = control; @@ -102,7 +102,7 @@ pose(const string &anim_name, double frame) { INLINE int AnimControlCollection:: get_frame(const string &anim_name) const { AnimControl *control = find_anim(anim_name); - if (control == (AnimControl *)NULL) { + if (control == nullptr) { return 0; } return control->get_frame(); @@ -113,7 +113,7 @@ get_frame(const string &anim_name) const { */ INLINE int AnimControlCollection:: get_frame() const { - if (_last_started_control == (AnimControl *)NULL) { + if (_last_started_control == nullptr) { return 0; } return _last_started_control->get_frame(); @@ -125,7 +125,7 @@ get_frame() const { INLINE bool AnimControlCollection:: is_playing(const string &anim_name) const { AnimControl *control = find_anim(anim_name); - if (control == (AnimControl *)NULL) { + if (control == nullptr) { return false; } return control->is_playing(); @@ -137,7 +137,7 @@ is_playing(const string &anim_name) const { */ INLINE bool AnimControlCollection:: is_playing() const { - if (_last_started_control == (AnimControl *)NULL) { + if (_last_started_control == nullptr) { return false; } return _last_started_control->is_playing(); @@ -150,7 +150,7 @@ is_playing() const { INLINE int AnimControlCollection:: get_num_frames(const string &anim_name) const { AnimControl *control = find_anim(anim_name); - if (control == (AnimControl *)NULL) { + if (control == nullptr) { return 0; } return control->get_num_frames(); @@ -161,7 +161,7 @@ get_num_frames(const string &anim_name) const { */ INLINE int AnimControlCollection:: get_num_frames() const { - if (_last_started_control == (AnimControl *)NULL) { + if (_last_started_control == nullptr) { return 0; } return _last_started_control->get_num_frames(); diff --git a/panda/src/chan/animControlCollection.cxx b/panda/src/chan/animControlCollection.cxx index 2a46ebb88f..50783b5305 100644 --- a/panda/src/chan/animControlCollection.cxx +++ b/panda/src/chan/animControlCollection.cxx @@ -20,7 +20,7 @@ */ AnimControlCollection:: AnimControlCollection() { - _last_started_control = (AnimControl *)NULL; + _last_started_control = nullptr; } /** @@ -55,7 +55,7 @@ store_anim(AnimControl *control, const string &name) { nassertv(index < _controls.size()); nassertv(_controls[index]._name == name); if (_last_started_control == _controls[index]._control) { - _last_started_control = (AnimControl *)NULL; + _last_started_control = nullptr; } _controls[index]._control = control; } @@ -69,11 +69,11 @@ AnimControl *AnimControlCollection:: find_anim(const string &name) const { ControlsByName::const_iterator ci = _controls_by_name.find(name); if (ci == _controls_by_name.end()) { - return (AnimControl *)NULL; + return nullptr; } size_t index = (*ci).second; - nassertr(index < _controls.size(), NULL); - nassertr(_controls[index]._name == name, NULL); + nassertr(index < _controls.size(), nullptr); + nassertr(_controls[index]._name == name, nullptr); return _controls[index]._control; } @@ -93,7 +93,7 @@ unbind_anim(const string &name) { nassertr(_controls[index]._name == name, false); if (_last_started_control == _controls[index]._control) { - _last_started_control = (AnimControl *)NULL; + _last_started_control = nullptr; } _controls_by_name.erase(ci); @@ -124,7 +124,7 @@ get_num_anims() const { */ AnimControl *AnimControlCollection:: get_anim(int n) const { - nassertr(n >= 0 && n < (int)_controls.size(), NULL); + nassertr(n >= 0 && n < (int)_controls.size(), nullptr); return _controls[n]._control; } diff --git a/panda/src/chan/animGroup.cxx b/panda/src/chan/animGroup.cxx index 364da1bd58..4c23b36110 100644 --- a/panda/src/chan/animGroup.cxx +++ b/panda/src/chan/animGroup.cxx @@ -36,7 +36,7 @@ AnimGroup:: AnimGroup(const string &name) : Namable(name), _children(get_class_type()), - _root(NULL) + _root(nullptr) { } @@ -50,11 +50,11 @@ AnimGroup(AnimGroup *parent, const AnimGroup ©) : Namable(copy), _children(get_class_type()) { - if (parent != (AnimGroup *)NULL) { + if (parent != nullptr) { parent->_children.push_back(this); _root = parent->_root; } else { - _root = NULL; + _root = nullptr; } } @@ -67,7 +67,7 @@ AnimGroup(AnimGroup *parent, const string &name) : Namable(name), _children(get_class_type()) { - nassertv(parent != NULL); + nassertv(parent != nullptr); parent->_children.push_back(this); _root = parent->_root; @@ -95,7 +95,7 @@ get_num_children() const { */ AnimGroup *AnimGroup:: get_child(int n) const { - nassertr(n >= 0 && n < (int)_children.size(), NULL); + nassertr(n >= 0 && n < (int)_children.size(), nullptr); return _children[n]; } @@ -115,7 +115,7 @@ get_child_named(const string &name) const { } } - return (AnimGroup *)NULL; + return nullptr; } /** @@ -132,12 +132,12 @@ find_child(const string &name) const { return child; } AnimGroup *result = child->find_child(name); - if (result != (AnimGroup *)NULL) { + if (result != nullptr) { return result; } } - return (AnimGroup *)NULL; + return nullptr; } // An STL object to sort a list of children into alphabetical order. diff --git a/panda/src/chan/auto_bind.cxx b/panda/src/chan/auto_bind.cxx index 912b199ac8..e9e827b319 100644 --- a/panda/src/chan/auto_bind.cxx +++ b/panda/src/chan/auto_bind.cxx @@ -52,15 +52,15 @@ bind_anims(const PartBundles &parts, const AnimBundles &anims, if (name.empty()) { name = anim->get_name(); } - if (control != (AnimControl *)NULL) { - if (controls.find_anim(name) != (AnimControl *)NULL) { + if (control != nullptr) { + if (controls.find_anim(name) != nullptr) { // That name's already used; synthesize another one. int index = 0; string new_name; do { index++; new_name = name + '.' + format_string(index); - } while (controls.find_anim(new_name) != (AnimControl *)NULL); + } while (controls.find_anim(new_name) != nullptr); name = new_name; } @@ -68,7 +68,7 @@ bind_anims(const PartBundles &parts, const AnimBundles &anims, } if (chan_cat.is_info()) { - if (control == (AnimControl *)NULL) { + if (control == nullptr) { chan_cat.info() << "Bind failed.\n"; } else { diff --git a/panda/src/chan/bindAnimRequest.cxx b/panda/src/chan/bindAnimRequest.cxx index b1315044b9..c1b34038ff 100644 --- a/panda/src/chan/bindAnimRequest.cxx +++ b/panda/src/chan/bindAnimRequest.cxx @@ -51,7 +51,7 @@ do_task() { } PT(PandaNode) model = get_model(); - if (model == (PandaNode *)NULL) { + if (model == nullptr) { // Couldn't load the file. _control->fail_anim(part); return DS_done; @@ -59,7 +59,7 @@ do_task() { _control->set_anim_model(model); AnimBundle *anim = AnimBundleNode::find_anim_bundle(model); - if (anim == (AnimBundle *)NULL) { + if (anim == nullptr) { // No anim bundle. _control->fail_anim(part); return DS_done; diff --git a/panda/src/chan/movingPartBase.I b/panda/src/chan/movingPartBase.I index 2c18cb7584..182f597b67 100644 --- a/panda/src/chan/movingPartBase.I +++ b/panda/src/chan/movingPartBase.I @@ -18,7 +18,7 @@ INLINE MovingPartBase:: MovingPartBase(const MovingPartBase ©) : PartGroup(copy), _num_effective_channels(0), - _effective_control(NULL), + _effective_control(nullptr), _forced_channel(copy._forced_channel) { // We don't copy the bound channels. We do copy the forced_channel, though @@ -47,6 +47,6 @@ get_max_bound() const { */ INLINE AnimChannelBase *MovingPartBase:: get_bound(int n) const { - nassertr(n >= 0 && n < (int)_channels.size(), NULL); + nassertr(n >= 0 && n < (int)_channels.size(), nullptr); return _channels[n]; } diff --git a/panda/src/chan/movingPartBase.cxx b/panda/src/chan/movingPartBase.cxx index b623e7f689..cc60dabe3c 100644 --- a/panda/src/chan/movingPartBase.cxx +++ b/panda/src/chan/movingPartBase.cxx @@ -29,7 +29,7 @@ MovingPartBase:: MovingPartBase(PartGroup *parent, const string &name) : PartGroup(parent, name), _num_effective_channels(0), - _effective_control(NULL) + _effective_control(nullptr) { } @@ -39,7 +39,7 @@ MovingPartBase(PartGroup *parent, const string &name) : MovingPartBase:: MovingPartBase() : _num_effective_channels(0), - _effective_control(NULL) + _effective_control(nullptr) { } @@ -49,7 +49,7 @@ MovingPartBase() : */ bool MovingPartBase:: clear_forced_channel() { - if (_forced_channel != (AnimChannelBase *)NULL) { + if (_forced_channel != nullptr) { _forced_channel.clear(); return true; } @@ -117,10 +117,10 @@ do_update(PartBundle *root, const CycleData *root_cdata, PartGroup *parent, // See if any of the channel values have changed since last time. if (!needs_update) { - if (_forced_channel != (AnimChannelBase *)NULL) { + if (_forced_channel != nullptr) { needs_update = _forced_channel->has_changed(0, 0.0, 0, 0.0); - } else if (_effective_control != (AnimControl *)NULL) { + } else if (_effective_control != nullptr) { const PartBundle::CData *cdata = (const PartBundle::CData *)root_cdata; needs_update = _effective_control->channel_has_changed(_effective_channel, cdata->_frame_blend_flag); @@ -132,12 +132,12 @@ do_update(PartBundle *root, const CycleData *root_cdata, PartGroup *parent, ++bci) { AnimControl *control = (*bci).first; - AnimChannelBase *channel = NULL; + AnimChannelBase *channel = nullptr; int channel_index = control->get_channel_index(); if (channel_index >= 0 && channel_index < (int)_channels.size()) { channel = _channels[channel_index]; } - if (channel != (AnimChannelBase*)NULL) { + if (channel != nullptr) { needs_update = control->channel_has_changed(channel, cdata->_frame_blend_flag); } } @@ -199,7 +199,7 @@ pick_channel_index(plist &holes, int &next) const { int hole = (*ii); nassertv(hole >= 0 && hole < next); if (hole < (int)_channels.size() || - _channels[hole] != (AnimChannelBase *)NULL) { + _channels[hole] != nullptr) { // We can't accept this hole; we're using it! holes.erase(ii); } @@ -210,7 +210,7 @@ pick_channel_index(plist &holes, int &next) const { if (next < (int)_channels.size()) { int i; for (i = next; i < (int)_channels.size(); i++) { - if (_channels[i] == (AnimChannelBase*)NULL) { + if (_channels[i] == nullptr) { // Here's a hole we do have. holes.push_back(i); } @@ -238,7 +238,7 @@ bind_hierarchy(AnimGroup *anim, int channel_index, int &joint_index, } if (chan_cat.is_debug()) { - if (anim == (AnimGroup *)NULL) { + if (anim == nullptr) { chan_cat.debug() << "binding " << *this << " to NULL, is_included = " << is_included << "\n"; @@ -249,13 +249,13 @@ bind_hierarchy(AnimGroup *anim, int channel_index, int &joint_index, } } while ((int)_channels.size() <= channel_index) { - _channels.push_back((AnimChannelBase*)NULL); + _channels.push_back(nullptr); } - nassertv(_channels[channel_index] == (AnimChannelBase*)NULL); + nassertv(_channels[channel_index] == nullptr); if (is_included) { - if (anim == (AnimGroup*)NULL) { + if (anim == nullptr) { // If we're binding to the NULL anim, it means actually to create a // default AnimChannel that just returns the part's initial value. _channels[channel_index] = make_default_channel(); @@ -303,12 +303,12 @@ find_bound_joints(int &joint_index, bool is_included, BitArray &bound_joints, */ void MovingPartBase:: determine_effective_channels(const CycleData *root_cdata) { - _effective_control = NULL; - _effective_channel = NULL; + _effective_control = nullptr; + _effective_channel = nullptr; _num_effective_channels = 0; - AnimControl *effective_control = NULL; - AnimChannelBase *effective_channel = NULL; + AnimControl *effective_control = nullptr; + AnimChannelBase *effective_channel = nullptr; int num_effective_channels = 0; const PartBundle::CData *cdata = (const PartBundle::CData *)root_cdata; @@ -319,7 +319,7 @@ determine_effective_channels(const CycleData *root_cdata) { AnimControl *control = (*cbi).first; int channel_index = control->get_channel_index(); if (channel_index >= 0 && channel_index < (int)_channels.size()) { - if (_channels[channel_index] != (AnimChannelBase *)NULL) { + if (_channels[channel_index] != nullptr) { effective_control = control; effective_channel = _channels[channel_index]; ++num_effective_channels; diff --git a/panda/src/chan/movingPartMatrix.cxx b/panda/src/chan/movingPartMatrix.cxx index 6477728e0d..0c8c7bc7bd 100644 --- a/panda/src/chan/movingPartMatrix.cxx +++ b/panda/src/chan/movingPartMatrix.cxx @@ -53,7 +53,7 @@ get_blend_value(const PartBundle *root) { // If a forced channel is set on this particular joint, we always return // that value instead of performing the blend. Furthermore, the frame // number is always 0 for the forced channel. - if (_forced_channel != (AnimChannelBase *)NULL) { + if (_forced_channel != nullptr) { ChannelType *channel = DCAST(ChannelType, _forced_channel); channel->get_value(0, _value); return; @@ -67,7 +67,7 @@ get_blend_value(const PartBundle *root) { _value = _default_value; } - } else if (_effective_control != (AnimControl *)NULL && + } else if (_effective_control != nullptr && !cdata->_frame_blend_flag) { // A single value, the normal case. ChannelType *channel = DCAST(ChannelType, _effective_channel); @@ -93,7 +93,7 @@ get_blend_value(const PartBundle *root) { int channel_index = control->get_channel_index(); nassertv(channel_index >= 0 && channel_index < (int)_channels.size()); ChannelType *channel = DCAST(ChannelType, _channels[channel_index]); - if (channel != (ChannelType *)NULL) { + if (channel != nullptr) { ValueType v; channel->get_value(control->get_frame(), v); @@ -140,12 +140,12 @@ get_blend_value(const PartBundle *root) { PN_stdfloat effect = (*cbi).second; nassertv(effect != 0.0f); - ChannelType *channel = NULL; + ChannelType *channel = nullptr; int channel_index = control->get_channel_index(); if (channel_index >= 0 && channel_index < (int)_channels.size()) { channel = DCAST(ChannelType, _channels[channel_index]); } - if (channel != (ChannelType *)NULL) { + if (channel != nullptr) { int frame = control->get_frame(); ValueType v; LVecBase3 iscale, ishear; @@ -213,12 +213,12 @@ get_blend_value(const PartBundle *root) { PN_stdfloat effect = (*cbi).second; nassertv(effect != 0.0f); - ChannelType *channel = NULL; + ChannelType *channel = nullptr; int channel_index = control->get_channel_index(); if (channel_index >= 0 && channel_index < (int)_channels.size()) { channel = DCAST(ChannelType, _channels[channel_index]); } - if (channel != (ChannelType *)NULL) { + if (channel != nullptr) { int frame = control->get_frame(); LVecBase3 iscale, ihpr, ipos, ishear; channel->get_scale(frame, iscale); @@ -289,12 +289,12 @@ get_blend_value(const PartBundle *root) { PN_stdfloat effect = (*cbi).second; nassertv(effect != 0.0f); - ChannelType *channel = NULL; + ChannelType *channel = nullptr; int channel_index = control->get_channel_index(); if (channel_index >= 0 && channel_index < (int)_channels.size()) { channel = DCAST(ChannelType, _channels[channel_index]); } - if (channel != (ChannelType *)NULL) { + if (channel != nullptr) { int frame = control->get_frame(); LVecBase3 iscale, ipos, ishear; LQuaternion iquat; diff --git a/panda/src/chan/movingPartScalar.cxx b/panda/src/chan/movingPartScalar.cxx index abebb49a32..d0d03b4152 100644 --- a/panda/src/chan/movingPartScalar.cxx +++ b/panda/src/chan/movingPartScalar.cxx @@ -39,7 +39,7 @@ get_blend_value(const PartBundle *root) { // If a forced channel is set on this particular scalar, we always return // that value instead of performing the blend. Furthermore, the frame // number is always 0 for the forced channel. - if (_forced_channel != (AnimChannelBase *)NULL) { + if (_forced_channel != nullptr) { ChannelType *channel = DCAST(ChannelType, _forced_channel); channel->get_value(0, _value); return; @@ -53,7 +53,7 @@ get_blend_value(const PartBundle *root) { _value = _default_value; } - } else if (_effective_control != (AnimControl *)NULL && + } else if (_effective_control != nullptr && !cdata->_frame_blend_flag) { // A single value, the normal case. ChannelType *channel = DCAST(ChannelType, _effective_channel); @@ -70,12 +70,12 @@ get_blend_value(const PartBundle *root) { PN_stdfloat effect = (*cbi).second; nassertv(effect != 0.0f); - ChannelType *channel = NULL; + ChannelType *channel = nullptr; int channel_index = control->get_channel_index(); if (channel_index >= 0 && channel_index < (int)_channels.size()) { channel = DCAST(ChannelType, _channels[channel_index]); } - if (channel != NULL) { + if (channel != nullptr) { ValueType v; channel->get_value(control->get_frame(), v); diff --git a/panda/src/chan/partBundle.I b/panda/src/chan/partBundle.I index ca6ec4c7cf..ca4ffdaad4 100644 --- a/panda/src/chan/partBundle.I +++ b/panda/src/chan/partBundle.I @@ -43,7 +43,7 @@ set_anim_preload(AnimPreloadTable *anim_preload) { */ INLINE void PartBundle:: clear_anim_preload() { - _anim_preload = NULL; + _anim_preload = nullptr; } /** @@ -165,7 +165,7 @@ get_num_nodes() const { */ INLINE PartBundleNode *PartBundle:: get_node(int n) const { - nassertr(n >= 0 && n < (int)_nodes.size(), NULL); + nassertr(n >= 0 && n < (int)_nodes.size(), nullptr); return _nodes[n]; } diff --git a/panda/src/chan/partBundle.cxx b/panda/src/chan/partBundle.cxx index 3806f812a5..d2aa343774 100644 --- a/panda/src/chan/partBundle.cxx +++ b/panda/src/chan/partBundle.cxx @@ -85,13 +85,13 @@ make_copy() const { */ void PartBundle:: merge_anim_preloads(const PartBundle *other) { - if (other->_anim_preload == (AnimPreloadTable *)NULL || + if (other->_anim_preload == nullptr || _anim_preload == other->_anim_preload) { // No-op. return; } - if (_anim_preload == (AnimPreloadTable *)NULL) { + if (_anim_preload == nullptr) { // Trivial case. _anim_preload = other->_anim_preload; return; @@ -128,7 +128,7 @@ set_anim_blend_flag(bool anim_blend_flag) { // eliminate all the AnimControls other than the most-recently-added // one. - nassertv(cdataw->_last_control_set != NULL); + nassertv(cdataw->_last_control_set != nullptr); clear_and_stop_intersecting(cdataw->_last_control_set, cdataw); } @@ -247,7 +247,7 @@ bind_anim(AnimBundle *anim, int hierarchy_match_flags, return control; } - return NULL; + return nullptr; } /** @@ -275,7 +275,7 @@ PT(AnimControl) PartBundle:: load_bind_anim(Loader *loader, const Filename &filename, int hierarchy_match_flags, const PartSubset &subset, bool allow_async) { - nassertr(loader != (Loader *)NULL, NULL); + nassertr(loader != nullptr, nullptr); LoaderOptions anim_options(LoaderOptions::LF_search | LoaderOptions::LF_report_errors | @@ -284,7 +284,7 @@ load_bind_anim(Loader *loader, const Filename &filename, int anim_index = -1; CPT(AnimPreloadTable) anim_preload = _anim_preload.get_read_pointer(); - if (anim_preload != (AnimPreloadTable *)NULL) { + if (anim_preload != nullptr) { anim_index = anim_preload->find_anim(basename); } @@ -293,19 +293,19 @@ load_bind_anim(Loader *loader, const Filename &filename, // Therefore, perform an ordinary synchronous load-and-bind. PT(PandaNode) model = loader->load_sync(filename, anim_options); - if (model == (PandaNode *)NULL) { + if (model == nullptr) { // Couldn't load the file. - return NULL; + return nullptr; } AnimBundle *anim = AnimBundleNode::find_anim_bundle(model); - if (anim == (AnimBundle *)NULL) { + if (anim == nullptr) { // No anim bundle. - return NULL; + return nullptr; } PT(AnimControl) control = bind_anim(anim, hierarchy_match_flags, subset); - if (control == (AnimControl *)NULL) { + if (control == nullptr) { // Couldn't bind. - return NULL; + return nullptr; } control->set_anim_model(model); return control; @@ -366,7 +366,7 @@ wait_pending() { bool PartBundle:: freeze_joint(const string &joint_name, const TransformState *transform) { PartGroup *child = find_child(joint_name); - if (child == (PartGroup *)NULL) { + if (child == nullptr) { return false; } @@ -387,7 +387,7 @@ freeze_joint(const string &joint_name, const TransformState *transform) { bool PartBundle:: freeze_joint(const string &joint_name, const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale) { PartGroup *child = find_child(joint_name); - if (child == (PartGroup *)NULL) { + if (child == nullptr) { return false; } @@ -408,7 +408,7 @@ freeze_joint(const string &joint_name, const LVecBase3 &pos, const LVecBase3 &hp bool PartBundle:: freeze_joint(const string &joint_name, PN_stdfloat value) { PartGroup *child = find_child(joint_name); - if (child == (PartGroup *)NULL) { + if (child == nullptr) { return false; } @@ -430,7 +430,7 @@ freeze_joint(const string &joint_name, PN_stdfloat value) { bool PartBundle:: control_joint(const string &joint_name, PandaNode *node) { PartGroup *child = find_child(joint_name); - if (child == (PartGroup *)NULL) { + if (child == nullptr) { return false; } @@ -451,7 +451,7 @@ control_joint(const string &joint_name, PandaNode *node) { bool PartBundle:: release_joint(const string &joint_name) { PartGroup *child = find_child(joint_name); - if (child == (PartGroup *)NULL) { + if (child == nullptr) { return false; } @@ -479,7 +479,7 @@ update() { bool anim_changed = cdata->_anim_changed; bool frame_blend_flag = cdata->_frame_blend_flag; - any_changed = do_update(this, cdata, NULL, false, anim_changed, + any_changed = do_update(this, cdata, nullptr, false, anim_changed, current_thread); // Now update all the controls for next time. @@ -504,7 +504,7 @@ bool PartBundle:: force_update() { Thread *current_thread = Thread::get_current_thread(); CDWriter cdata(_cycler, false, current_thread); - bool any_changed = do_update(this, cdata, NULL, true, true, current_thread); + bool any_changed = do_update(this, cdata, nullptr, true, true, current_thread); // Now update all the controls for next time. ChannelBlend::const_iterator cbi; @@ -585,7 +585,7 @@ do_bind_anim(AnimControl *control, AnimBundle *anim, } } - if (!check_hierarchy(anim, NULL, hierarchy_match_flags)) { + if (!check_hierarchy(anim, nullptr, hierarchy_match_flags)) { return false; } @@ -747,7 +747,7 @@ void PartBundle:: finalize(BamReader *) { Thread *current_thread = Thread::get_current_thread(); CDWriter cdata(_cycler, true); - do_update(this, cdata, NULL, true, true, current_thread); + do_update(this, cdata, nullptr, true, true, current_thread); } /** @@ -827,7 +827,7 @@ CData() { _anim_blend_flag = false; _frame_blend_flag = interpolate_frames; _root_xform = LMatrix4::ident_mat(); - _last_control_set = NULL; + _last_control_set = nullptr; _net_blend = 0.0f; _anim_changed = false; _last_update = 0.0; diff --git a/panda/src/chan/partBundleNode.I b/panda/src/chan/partBundleNode.I index c1251b7eac..721e930bd9 100644 --- a/panda/src/chan/partBundleNode.I +++ b/panda/src/chan/partBundleNode.I @@ -54,7 +54,7 @@ get_num_bundles() const { */ INLINE PartBundle *PartBundleNode:: get_bundle(int n) const { - nassertr(n >= 0 && n < (int)_bundles.size(), NULL); + nassertr(n >= 0 && n < (int)_bundles.size(), nullptr); return _bundles[n]->get_bundle(); } @@ -65,6 +65,6 @@ get_bundle(int n) const { */ INLINE PartBundleHandle *PartBundleNode:: get_bundle_handle(int n) const { - nassertr(n >= 0 && n < (int)_bundles.size(), NULL); + nassertr(n >= 0 && n < (int)_bundles.size(), nullptr); return _bundles[n]; } diff --git a/panda/src/chan/partBundleNode.cxx b/panda/src/chan/partBundleNode.cxx index e0a726fd39..9fe5473fe0 100644 --- a/panda/src/chan/partBundleNode.cxx +++ b/panda/src/chan/partBundleNode.cxx @@ -192,6 +192,6 @@ fillin(DatagramIterator &scan, BamReader* manager) { // Remaining bundles. Push a new slot for each one. for (int i = 1; i < num_bundles; ++i) { manager->read_pointer(scan); - _bundles.push_back(NULL); + _bundles.push_back(nullptr); } } diff --git a/panda/src/chan/partGroup.cxx b/panda/src/chan/partGroup.cxx index e1503e93b3..ad501ca24c 100644 --- a/panda/src/chan/partGroup.cxx +++ b/panda/src/chan/partGroup.cxx @@ -36,7 +36,7 @@ PartGroup(PartGroup *parent, const string &name) : Namable(name), _children(get_class_type()) { - nassertv(parent != NULL); + nassertv(parent != nullptr); parent->_children.push_back(this); } @@ -102,7 +102,7 @@ get_num_children() const { */ PartGroup *PartGroup:: get_child(int n) const { - nassertr(n >= 0 && n < (int)_children.size(), NULL); + nassertr(n >= 0 && n < (int)_children.size(), nullptr); return _children[n]; } @@ -122,7 +122,7 @@ get_child_named(const string &name) const { } } - return (PartGroup *)NULL; + return nullptr; } /** @@ -139,12 +139,12 @@ find_child(const string &name) const { return child; } PartGroup *result = child->find_child(name); - if (result != (PartGroup *)NULL) { + if (result != nullptr) { return result; } } - return (PartGroup *)NULL; + return nullptr; } // An STL object to sort a list of children into alphabetical order. @@ -243,7 +243,7 @@ clear_forced_channel() { */ AnimChannelBase *PartGroup:: get_forced_channel() const { - return NULL; + return nullptr; } @@ -314,14 +314,14 @@ check_hierarchy(const AnimGroup *anim, const PartGroup *, // to differ meaninglessly here. Any differences here remain // unreported. if (anim->get_num_children() == get_num_children() + 1 && - anim->get_child_named("morph") != NULL && - get_child_named("morph") == NULL) { + anim->get_child_named("morph") != nullptr && + get_child_named("morph") == nullptr) { // Anim has "morph" and model does not, but there are no other // differences. } else if (get_num_children() == anim->get_num_children() + 1 && - get_child_named("morph") != NULL && - anim->get_child_named("morph") == NULL) { + get_child_named("morph") != nullptr && + anim->get_child_named("morph") == nullptr) { // Model has "morph" and anim does not, but there are no other // differences. @@ -562,7 +562,7 @@ bind_hierarchy(AnimGroup *anim, int channel_index, int &joint_index, int i = 0, j = 0; int part_num_children = get_num_children(); - int anim_num_children = (anim == NULL) ? 0 : anim->get_num_children(); + int anim_num_children = (anim == nullptr) ? 0 : anim->get_num_children(); while (i < part_num_children && j < anim_num_children) { PartGroup *pc = get_child(i); @@ -570,7 +570,7 @@ bind_hierarchy(AnimGroup *anim, int channel_index, int &joint_index, if (pc->get_name() < ac->get_name()) { // Here's a part, not in the anim. Bind it to the special NULL anim. - pc->bind_hierarchy(NULL, channel_index, joint_index, is_included, + pc->bind_hierarchy(nullptr, channel_index, joint_index, is_included, bound_joints, subset); i++; @@ -590,7 +590,7 @@ bind_hierarchy(AnimGroup *anim, int channel_index, int &joint_index, // Now pick up any more parts, not in the anim. while (i < part_num_children) { PartGroup *pc = get_child(i); - pc->bind_hierarchy(NULL, channel_index, joint_index, is_included, + pc->bind_hierarchy(nullptr, channel_index, joint_index, is_included, bound_joints, subset); i++; } @@ -652,7 +652,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _children.reserve(num_children); for (int i = 0; i < num_children; i++) { manager->read_pointer(scan); - _children.push_back(NULL); + _children.push_back(nullptr); } } diff --git a/panda/src/char/character.cxx b/panda/src/char/character.cxx index ed28ac491e..8b5bac116a 100644 --- a/panda/src/char/character.cxx +++ b/panda/src/char/character.cxx @@ -359,12 +359,12 @@ find_joint(const string &name) const { int num_bundles = get_num_bundles(); for (int i = 0; i < num_bundles; ++i) { PartGroup *part = get_bundle(i)->find_child(name); - if (part != (PartGroup *)NULL && part->is_character_joint()) { + if (part != nullptr && part->is_character_joint()) { return DCAST(CharacterJoint, part); } } - return NULL; + return nullptr; } /** @@ -377,13 +377,13 @@ find_slider(const string &name) const { int num_bundles = get_num_bundles(); for (int i = 0; i < num_bundles; ++i) { PartGroup *part = get_bundle(i)->find_child(name); - if (part != (PartGroup *)NULL && + if (part != nullptr && part->is_of_type(CharacterSlider::get_class_type())) { return DCAST(CharacterSlider, part); } } - return NULL; + return nullptr; } /** @@ -644,7 +644,7 @@ r_merge_bundles(Character::JointMap &joint_map, // Since the old_joint will be getting dropped, reset its character // reference. - old_joint->_character = NULL; + old_joint->_character = nullptr; // Copy any _net_transform and _local_transform operations to the new // joint. @@ -929,8 +929,8 @@ CPT(TransformTable) Character:: redirect_transform_table(const TransformTable *source, const Character::JointMap &joint_map, Character::GeomJointMap &gjmap) { - if (source == (TransformTable *)NULL) { - return NULL; + if (source == nullptr) { + return nullptr; } PT(TransformTable) dest = new TransformTable(*source); @@ -939,7 +939,7 @@ redirect_transform_table(const TransformTable *source, for (int i = 0; i < num_transforms; ++i) { const VertexTransform *vt = dest->get_transform(i); PT(JointVertexTransform) new_jvt = redirect_joint(vt, joint_map, gjmap); - if (new_jvt != (JointVertexTransform *)NULL) { + if (new_jvt != nullptr) { dest->set_transform(i, new_jvt); } } @@ -955,8 +955,8 @@ CPT(TransformBlendTable) Character:: redirect_transform_blend_table(const TransformBlendTable *source, const Character::JointMap &joint_map, Character::GeomJointMap &gjmap) { - if (source == (TransformBlendTable *)NULL) { - return NULL; + if (source == nullptr) { + return nullptr; } PT(TransformBlendTable) dest = new TransformBlendTable(*source); @@ -968,7 +968,7 @@ redirect_transform_blend_table(const TransformBlendTable *source, for (int j = 0; j < num_transforms; ++j) { const VertexTransform *vt = blend.get_transform(j); PT(JointVertexTransform) new_jvt = redirect_joint(vt, joint_map, gjmap); - if (new_jvt != (JointVertexTransform *)NULL) { + if (new_jvt != nullptr) { blend.set_transform(j, new_jvt); } } @@ -985,8 +985,8 @@ redirect_transform_blend_table(const TransformBlendTable *source, CPT(SliderTable) Character:: redirect_slider_table(const SliderTable *source, Character::GeomSliderMap &gsmap) { - if (source == (SliderTable *)NULL) { - return NULL; + if (source == nullptr) { + return nullptr; } PT(SliderTable) dest = new SliderTable(*source); @@ -995,7 +995,7 @@ redirect_slider_table(const SliderTable *source, for (int i = 0; i < num_sliders; ++i) { const VertexSlider *vs = dest->get_slider(i); PT(CharacterVertexSlider) new_cvs = redirect_slider(vs, gsmap); - if (new_cvs != (CharacterVertexSlider *)NULL) { + if (new_cvs != nullptr) { dest->set_slider(i, new_cvs); } } @@ -1057,7 +1057,7 @@ redirect_slider(const VertexSlider *vs, Character::GeomSliderMap &gsmap) { if (vs->is_of_type(CharacterVertexSlider::get_class_type())) { const CharacterVertexSlider *cvs = DCAST(CharacterVertexSlider, vs); CharacterSlider *slider = find_slider(cvs->get_char_slider()->get_name()); - if (slider != (CharacterSlider *)NULL) { + if (slider != nullptr) { new_cvs = new CharacterVertexSlider(slider); } } @@ -1081,7 +1081,7 @@ r_clear_joint_characters(PartGroup *part) { // listed within more than one Character node, but it can only point back // to one of them. if (joint->get_character() == this) { - joint->set_character(NULL); + joint->set_character(nullptr); } } diff --git a/panda/src/char/characterJoint.cxx b/panda/src/char/characterJoint.cxx index fee1a90f76..8a424d91c1 100644 --- a/panda/src/char/characterJoint.cxx +++ b/panda/src/char/characterJoint.cxx @@ -27,7 +27,7 @@ TypeHandle CharacterJoint::_type_handle; */ CharacterJoint:: CharacterJoint() : - _character(NULL) + _character(nullptr) { } @@ -37,7 +37,7 @@ CharacterJoint() : CharacterJoint:: CharacterJoint(const CharacterJoint ©) : MovingPartMatrix(copy), - _character(NULL), + _character(nullptr), _net_transform(copy._net_transform), _initial_net_transform_inverse(copy._initial_net_transform_inverse), _skinning_matrix(copy._skinning_matrix) @@ -75,7 +75,7 @@ CharacterJoint(Character *character, CharacterJoint:: ~CharacterJoint() { nassertv(_vertex_transforms.empty()); - nassertv(_character == (Character *)NULL); + nassertv(_character == nullptr); } /** @@ -110,7 +110,7 @@ make_copy() const { bool CharacterJoint:: update_internals(PartBundle *root, PartGroup *parent, bool self_changed, bool parent_changed, Thread *current_thread) { - nassertr(parent != (PartGroup *)NULL, false); + nassertr(parent != nullptr, false); bool net_changed = false; if (parent->is_character_joint()) { @@ -194,7 +194,7 @@ do_xform(const LMatrix4 &mat, const LMatrix4 &inv_mat) { */ bool CharacterJoint:: add_net_transform(PandaNode *node) { - if (_character != (Character *)NULL) { + if (_character != nullptr) { node->set_effect(CharacterJointEffect::make(_character)); } CPT(TransformState) t = TransformState::make_mat(_net_transform); @@ -213,7 +213,7 @@ add_net_transform(PandaNode *node) { bool CharacterJoint:: remove_net_transform(PandaNode *node) { CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); - if (effect != (RenderEffect *)NULL && + if (effect != nullptr && DCAST(CharacterJointEffect, effect)->matches_character(_character)) { node->clear_effect(CharacterJointEffect::get_class_type()); } @@ -243,7 +243,7 @@ clear_net_transforms() { PandaNode *node = *ai; CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); - if (effect != (RenderEffect *)NULL && + if (effect != nullptr && DCAST(CharacterJointEffect, effect)->matches_character(_character)) { node->clear_effect(CharacterJointEffect::get_class_type()); } @@ -286,7 +286,7 @@ get_net_transforms() { */ bool CharacterJoint:: add_local_transform(PandaNode *node) { - if (_character != (Character *)NULL) { + if (_character != nullptr) { node->set_effect(CharacterJointEffect::make(_character)); } CPT(TransformState) t = TransformState::make_mat(_value); @@ -305,7 +305,7 @@ add_local_transform(PandaNode *node) { bool CharacterJoint:: remove_local_transform(PandaNode *node) { CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); - if (effect != (RenderEffect *)NULL && + if (effect != nullptr && DCAST(CharacterJointEffect, effect)->matches_character(_character)) { node->clear_effect(CharacterJointEffect::get_class_type()); } @@ -335,7 +335,7 @@ clear_local_transforms() { PandaNode *node = *ai; CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); - if (effect != (RenderEffect *)NULL && + if (effect != nullptr && DCAST(CharacterJointEffect, effect)->matches_character(_character)) { node->clear_effect(CharacterJointEffect::get_class_type()); } @@ -401,7 +401,7 @@ void CharacterJoint:: set_character(Character *character) { if (character != _character) { - if (character != (Character *)NULL) { + if (character != nullptr) { // Change or set a _character pointer on each joint's exposed node. NodeList::iterator ai; for (ai = _net_transform_nodes.begin(); @@ -426,7 +426,7 @@ set_character(Character *character) { PandaNode *node = *ai; CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); - if (effect != (RenderEffect *)NULL && + if (effect != nullptr && DCAST(CharacterJointEffect, effect)->matches_character(_character)) { node->clear_effect(CharacterJointEffect::get_class_type()); } @@ -437,7 +437,7 @@ set_character(Character *character) { PandaNode *node = *ai; CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); - if (effect != (RenderEffect *)NULL && + if (effect != nullptr && DCAST(CharacterJointEffect, effect)->matches_character(_character)) { node->clear_effect(CharacterJointEffect::get_class_type()); } @@ -514,7 +514,7 @@ complete_pointers(TypedWritable **p_list, BamReader* manager) { if (manager->get_file_minor_ver() >= 4) { _character = DCAST(Character, p_list[pi++]); } else { - _character = NULL; + _character = nullptr; } int i; diff --git a/panda/src/char/characterJointBundle.cxx b/panda/src/char/characterJointBundle.cxx index e6bf4061a7..980e9058dc 100644 --- a/panda/src/char/characterJointBundle.cxx +++ b/panda/src/char/characterJointBundle.cxx @@ -78,7 +78,7 @@ remove_node(PartBundleNode *node) { */ void CharacterJointBundle:: r_set_character(PartGroup *group, Character *character) { - if (group == (PartGroup *)NULL) { + if (group == nullptr) { // This might happen if we are in the middle of reading the Character's // hierarchy from the bam file. return; diff --git a/panda/src/collada/colladaBindMaterial.cxx b/panda/src/collada/colladaBindMaterial.cxx index 768e31a46d..2ef46e4a99 100644 --- a/panda/src/collada/colladaBindMaterial.cxx +++ b/panda/src/collada/colladaBindMaterial.cxx @@ -37,8 +37,8 @@ */ CPT(RenderState) ColladaBindMaterial:: get_material(const ColladaPrimitive *prim) const { - if (prim == NULL || _states.count(prim->get_material()) == 0) { - return NULL; + if (prim == nullptr || _states.count(prim->get_material()) == 0) { + return nullptr; } return _states.find(prim->get_material())->second; } @@ -50,7 +50,7 @@ get_material(const ColladaPrimitive *prim) const { CPT(RenderState) ColladaBindMaterial:: get_material(const string &symbol) const { if (_states.count(symbol) == 0) { - return NULL; + return nullptr; } return _states.find(symbol)->second; } @@ -74,10 +74,10 @@ load_bind_material(domBind_material &bind_mat) { void ColladaBindMaterial:: load_instance_material(domInstance_material &inst) { domMaterialRef mat = daeSafeCast (inst.getTarget().getElement()); - nassertv(mat != NULL); + nassertv(mat != nullptr); domInstance_effectRef einst = mat->getInstance_effect(); - nassertv(einst != NULL); + nassertv(einst != nullptr); domInstance_effect::domSetparam_Array &setparams = einst->getSetparam_array(); diff --git a/panda/src/collada/colladaInput.cxx b/panda/src/collada/colladaInput.cxx index b0f77ccd4e..be6522b23f 100644 --- a/panda/src/collada/colladaInput.cxx +++ b/panda/src/collada/colladaInput.cxx @@ -38,7 +38,7 @@ */ ColladaInput:: ColladaInput(const string &semantic) : - _column_name (NULL), + _column_name (nullptr), _semantic (semantic), _offset (0), _have_set (false), @@ -70,7 +70,7 @@ ColladaInput(const string &semantic) : */ ColladaInput:: ColladaInput(const string &semantic, unsigned int set) : - _column_name (NULL), + _column_name (nullptr), _semantic (semantic), _offset (0), _have_set (true), @@ -107,7 +107,7 @@ ColladaInput(const string &semantic, unsigned int set) : ColladaInput *ColladaInput:: from_dom(domInput_local_offset &input) { // If we already loaded it before, use that. - if (input.getUserData() != NULL) { + if (input.getUserData() != nullptr) { return (ColladaInput *) input.getUserData(); } @@ -117,7 +117,7 @@ from_dom(domInput_local_offset &input) { // If this has the VERTEX semantic, it points to a element. if (new_input->is_vertex_source()) { domVertices *verts = daeSafeCast (input.getSource().getElement()); - nassertr(verts != NULL, NULL); + nassertr(verts != nullptr, nullptr); daeTArray &inputs = verts->getInput_array(); // Iterate over the elements in . @@ -127,7 +127,7 @@ from_dom(domInput_local_offset &input) { } } else { domSource *source = daeSafeCast (input.getSource().getElement()); - nassertr(source != NULL, NULL); + nassertr(source != nullptr, nullptr); new_input->read_data(*source); } @@ -141,17 +141,17 @@ from_dom(domInput_local_offset &input) { ColladaInput *ColladaInput:: from_dom(domInput_local &input) { // If we already loaded it before, use that. - if (input.getUserData() != NULL) { + if (input.getUserData() != nullptr) { return (ColladaInput *) input.getUserData(); } ColladaInput *new_input = new ColladaInput(input.getSemantic()); new_input->_offset = 0; - nassertr (!new_input->is_vertex_source(), NULL); + nassertr (!new_input->is_vertex_source(), nullptr); domSource *source = daeSafeCast (input.getSource().getElement()); - nassertr(source != NULL, NULL); + nassertr(source != nullptr, nullptr); new_input->read_data(*source); return new_input; @@ -174,7 +174,7 @@ make_vertex_columns(GeomVertexArrayFormat *format) const { return counter; } - nassertr(_column_name != NULL, 0); + nassertr(_column_name != nullptr, 0); format->add_column(_column_name, _num_bound_params, GeomEnums::NT_stdfloat, _column_contents); return 1; @@ -189,7 +189,7 @@ read_data(domSource &source) { // Get this, get that domFloat_array* float_array = source.getFloat_array(); - if (float_array == NULL) { + if (float_array == nullptr) { return false; } @@ -246,7 +246,7 @@ write_data(GeomVertexData *vdata, int start_row, domP &p, unsigned int stride) c */ void ColladaInput:: write_data(GeomVertexData *vdata, int start_row, domP &p, unsigned int stride, unsigned int offset) const { - nassertv(_column_name != NULL); + nassertv(_column_name != nullptr); GeomVertexWriter writer (vdata, _column_name); writer.set_row_unsafe(start_row); diff --git a/panda/src/collada/colladaLoader.cxx b/panda/src/collada/colladaLoader.cxx index 93749b30b6..7414af0a7f 100644 --- a/panda/src/collada/colladaLoader.cxx +++ b/panda/src/collada/colladaLoader.cxx @@ -45,18 +45,18 @@ #define domTargetable_floatRef domTargetableFloatRef #endif -#define TOSTRING(x) (x == NULL ? "" : x) +#define TOSTRING(x) (x == nullptr ? "" : x) /** * */ ColladaLoader:: ColladaLoader() : - _record (NULL), + _record (nullptr), _cs (CS_default), _error (false), - _root (NULL), - _collada (NULL) { + _root (nullptr), + _collada (nullptr) { _dae = new DAE; } @@ -87,7 +87,7 @@ read(const Filename &filename) { } _collada = _dae->openFromMemory(_filename.to_os_specific(), data.c_str()); - _error = (_collada == NULL); + _error = (_collada == nullptr); return !_error; } @@ -116,7 +116,7 @@ build_graph() { void ColladaLoader:: load_visual_scene(domVisual_scene& scene, PandaNode *parent) { // If we already loaded it before, instantiate the stored node. - if (scene.getUserData() != NULL) { + if (scene.getUserData() != nullptr) { parent->add_child((PandaNode *) scene.getUserData()); return; } @@ -156,7 +156,7 @@ load_visual_scene(domVisual_scene& scene, PandaNode *parent) { void ColladaLoader:: load_node(domNode& node, PandaNode *parent) { // If we already loaded it before, instantiate the stored node. - if (node.getUserData() != NULL) { + if (node.getUserData() != nullptr) { parent->add_child((PandaNode *) node.getUserData()); return; } @@ -243,7 +243,7 @@ load_node(domNode& node, PandaNode *parent) { for (size_t i = 0; i < ctrlinst.getCount(); ++i) { domController* target = daeSafeCast (ctrlinst[i]->getUrl().getElement()); // TODO: implement controllers. For now, let's just read the geometry - if (target->getSkin() != NULL) { + if (target->getSkin() != nullptr) { domGeometry* geom = daeSafeCast (target->getSkin()->getSource().getElement()); // TODO load_geometry(*geom, ctrlinst[i]->getBind_material(), pnode); } @@ -321,7 +321,7 @@ load_tags(domExtra &extra, PandaNode *node) { void ColladaLoader:: load_camera(domCamera &cam, PandaNode *parent) { // If we already loaded it before, instantiate the stored node. - if (cam.getUserData() != NULL) { + if (cam.getUserData() != nullptr) { parent->add_child((PandaNode *) cam.getUserData()); return; } @@ -335,13 +335,13 @@ load_camera(domCamera &cam, PandaNode *parent) { void ColladaLoader:: load_instance_geometry(domInstance_geometry &inst, PandaNode *parent) { // If we already loaded it before, instantiate the stored node. - if (inst.getUserData() != NULL) { + if (inst.getUserData() != nullptr) { parent->add_child((PandaNode *) inst.getUserData()); return; } domGeometry* geom = daeSafeCast (inst.getUrl().getElement()); - nassertv(geom != NULL); + nassertv(geom != nullptr); // Create the node. PT(GeomNode) gnode = new GeomNode(TOSTRING(geom->getName())); @@ -350,7 +350,7 @@ load_instance_geometry(domInstance_geometry &inst, PandaNode *parent) { domBind_materialRef bind_mat = inst.getBind_material(); ColladaBindMaterial cbm; - if (bind_mat != NULL) { + if (bind_mat != nullptr) { cbm.load_bind_material(*bind_mat); } @@ -370,7 +370,7 @@ load_instance_geometry(domInstance_geometry &inst, PandaNode *parent) { void ColladaLoader:: load_geometry(domGeometry &geom, GeomNode *gnode, ColladaBindMaterial &bind_mat) { domMesh* mesh = geom.getMesh(); - if (mesh == NULL) { + if (mesh == nullptr) { // TODO: support non-mesh geometry. return; } @@ -379,7 +379,7 @@ load_geometry(domGeometry &geom, GeomNode *gnode, ColladaBindMaterial &bind_mat) domLines_Array &lines_array = mesh->getLines_array(); for (size_t i = 0; i < lines_array.getCount(); ++i) { PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*lines_array[i]); - if (prim != NULL) { + if (prim != nullptr) { gnode->add_geom(prim->get_geom()); } } @@ -387,7 +387,7 @@ load_geometry(domGeometry &geom, GeomNode *gnode, ColladaBindMaterial &bind_mat) domLinestrips_Array &linestrips_array = mesh->getLinestrips_array(); for (size_t i = 0; i < linestrips_array.getCount(); ++i) { PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*linestrips_array[i]); - if (prim != NULL) { + if (prim != nullptr) { gnode->add_geom(prim->get_geom()); } } @@ -395,7 +395,7 @@ load_geometry(domGeometry &geom, GeomNode *gnode, ColladaBindMaterial &bind_mat) domPolygons_Array &polygons_array = mesh->getPolygons_array(); for (size_t i = 0; i < polygons_array.getCount(); ++i) { PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*polygons_array[i]); - if (prim != NULL) { + if (prim != nullptr) { gnode->add_geom(prim->get_geom()); } } @@ -403,7 +403,7 @@ load_geometry(domGeometry &geom, GeomNode *gnode, ColladaBindMaterial &bind_mat) domPolylist_Array &polylist_array = mesh->getPolylist_array(); for (size_t i = 0; i < polylist_array.getCount(); ++i) { PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*polylist_array[i]); - if (prim != NULL) { + if (prim != nullptr) { gnode->add_geom(prim->get_geom()); } } @@ -411,7 +411,7 @@ load_geometry(domGeometry &geom, GeomNode *gnode, ColladaBindMaterial &bind_mat) domTriangles_Array &triangles_array = mesh->getTriangles_array(); for (size_t i = 0; i < triangles_array.getCount(); ++i) { PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*triangles_array[i]); - if (prim != NULL) { + if (prim != nullptr) { gnode->add_geom(prim->get_geom()); } } @@ -419,7 +419,7 @@ load_geometry(domGeometry &geom, GeomNode *gnode, ColladaBindMaterial &bind_mat) domTrifans_Array &trifans_array = mesh->getTrifans_array(); for (size_t i = 0; i < trifans_array.getCount(); ++i) { PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*trifans_array[i]); - if (prim != NULL) { + if (prim != nullptr) { gnode->add_geom(prim->get_geom()); } } @@ -427,7 +427,7 @@ load_geometry(domGeometry &geom, GeomNode *gnode, ColladaBindMaterial &bind_mat) domTristrips_Array &tristrips_array = mesh->getTristrips_array(); for (size_t i = 0; i < tristrips_array.getCount(); ++i) { PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*tristrips_array[i]); - if (prim != NULL) { + if (prim != nullptr) { gnode->add_geom(prim->get_geom()); } } @@ -439,7 +439,7 @@ load_geometry(domGeometry &geom, GeomNode *gnode, ColladaBindMaterial &bind_mat) void ColladaLoader:: load_light(domLight &light, PandaNode *parent) { // If we already loaded it before, instantiate the stored node. - if (light.getUserData() != NULL) { + if (light.getUserData() != nullptr) { parent->add_child((PandaNode *) light.getUserData()); return; } @@ -449,7 +449,7 @@ load_light(domLight &light, PandaNode *parent) { // Check for an ambient light. domLight::domTechnique_common::domAmbientRef ambient = tc.getAmbient(); - if (ambient != NULL) { + if (ambient != nullptr) { PT(AmbientLight) alight = new AmbientLight(TOSTRING(light.getName())); lnode = DCAST(LightNode, alight); @@ -459,7 +459,7 @@ load_light(domLight &light, PandaNode *parent) { // Check for a directional light. domLight::domTechnique_common::domDirectionalRef directional = tc.getDirectional(); - if (directional != NULL) { + if (directional != nullptr) { PT(DirectionalLight) dlight = new DirectionalLight(TOSTRING(light.getName())); lnode = DCAST(LightNode, dlight); @@ -470,7 +470,7 @@ load_light(domLight &light, PandaNode *parent) { // Check for a point light. domLight::domTechnique_common::domPointRef point = tc.getPoint(); - if (point != NULL) { + if (point != nullptr) { PT(PointLight) plight = new PointLight(TOSTRING(light.getName())); lnode = DCAST(LightNode, plight); @@ -479,15 +479,15 @@ load_light(domLight &light, PandaNode *parent) { LVecBase3f atten (1.0f, 0.0f, 0.0f); domTargetable_floatRef fval = point->getConstant_attenuation(); - if (fval != NULL) { + if (fval != nullptr) { atten[0] = fval->getValue(); } fval = point->getLinear_attenuation(); - if (fval != NULL) { + if (fval != nullptr) { atten[1] = fval->getValue(); } fval = point->getQuadratic_attenuation(); - if (fval != NULL) { + if (fval != nullptr) { atten[2] = fval->getValue(); } @@ -496,7 +496,7 @@ load_light(domLight &light, PandaNode *parent) { // Check for a spot light. domLight::domTechnique_common::domSpotRef spot = tc.getSpot(); - if (spot != NULL) { + if (spot != nullptr) { PT(Spotlight) slight = new Spotlight(TOSTRING(light.getName())); lnode = DCAST(LightNode, slight); @@ -505,36 +505,36 @@ load_light(domLight &light, PandaNode *parent) { LVecBase3f atten (1.0f, 0.0f, 0.0f); domTargetable_floatRef fval = spot->getConstant_attenuation(); - if (fval != NULL) { + if (fval != nullptr) { atten[0] = fval->getValue(); } fval = spot->getLinear_attenuation(); - if (fval != NULL) { + if (fval != nullptr) { atten[1] = fval->getValue(); } fval = spot->getQuadratic_attenuation(); - if (fval != NULL) { + if (fval != nullptr) { atten[2] = fval->getValue(); } slight->set_attenuation(atten); fval = spot->getFalloff_angle(); - if (fval != NULL) { + if (fval != nullptr) { slight->get_lens()->set_fov(fval->getValue()); } else { slight->get_lens()->set_fov(180.0f); } fval = spot->getFalloff_exponent(); - if (fval != NULL) { + if (fval != nullptr) { slight->set_exponent(fval->getValue()); } else { slight->set_exponent(0.0f); } } - if (lnode == NULL) { + if (lnode == nullptr) { return; } parent->add_child(lnode); diff --git a/panda/src/collada/colladaPrimitive.cxx b/panda/src/collada/colladaPrimitive.cxx index f1c627cb00..04433b72e4 100644 --- a/panda/src/collada/colladaPrimitive.cxx +++ b/panda/src/collada/colladaPrimitive.cxx @@ -65,7 +65,7 @@ ColladaPrimitive(GeomPrimitive *prim, daeTArray &input ColladaPrimitive *ColladaPrimitive:: from_dom(domLines &prim) { // If we already loaded it before, use that. - if (prim.getUserData() != NULL) { + if (prim.getUserData() != nullptr) { return (ColladaPrimitive *) prim.getUserData(); } @@ -77,7 +77,7 @@ from_dom(domLines &prim) { prim.setUserData(new_prim); domPRef p = prim.getP(); - if (p != NULL) { + if (p != nullptr) { new_prim->load_primitive(*p); } @@ -91,7 +91,7 @@ from_dom(domLines &prim) { ColladaPrimitive *ColladaPrimitive:: from_dom(domLinestrips &prim) { // If we already loaded it before, use that. - if (prim.getUserData() != NULL) { + if (prim.getUserData() != nullptr) { return (ColladaPrimitive *) prim.getUserData(); } @@ -114,7 +114,7 @@ from_dom(domLinestrips &prim) { ColladaPrimitive *ColladaPrimitive:: from_dom(domPolygons &prim) { // If we already loaded it before, use that. - if (prim.getUserData() != NULL) { + if (prim.getUserData() != nullptr) { return (ColladaPrimitive *) prim.getUserData(); } @@ -145,7 +145,7 @@ from_dom(domPolygons &prim) { ColladaPrimitive *ColladaPrimitive:: from_dom(domPolylist &prim) { // If we already loaded it before, use that. - if (prim.getUserData() != NULL) { + if (prim.getUserData() != nullptr) { return (ColladaPrimitive *) prim.getUserData(); } @@ -162,7 +162,7 @@ from_dom(domPolylist &prim) { domPRef p = prim.getP(); domPolylist::domVcountRef vcounts = prim.getVcount(); - if (p == NULL || vcounts == NULL) { + if (p == nullptr || vcounts == nullptr) { return new_prim; } @@ -185,7 +185,7 @@ from_dom(domPolylist &prim) { ColladaPrimitive *ColladaPrimitive:: from_dom(domTriangles &prim) { // If we already loaded it before, use that. - if (prim.getUserData() != NULL) { + if (prim.getUserData() != nullptr) { return (ColladaPrimitive *) prim.getUserData(); } @@ -197,7 +197,7 @@ from_dom(domTriangles &prim) { prim.setUserData(new_prim); domPRef p = prim.getP(); - if (p != NULL) { + if (p != nullptr) { new_prim->load_primitive(*p); } @@ -211,7 +211,7 @@ from_dom(domTriangles &prim) { ColladaPrimitive *ColladaPrimitive:: from_dom(domTrifans &prim) { // If we already loaded it before, use that. - if (prim.getUserData() != NULL) { + if (prim.getUserData() != nullptr) { return (ColladaPrimitive *) prim.getUserData(); } @@ -234,7 +234,7 @@ from_dom(domTrifans &prim) { ColladaPrimitive *ColladaPrimitive:: from_dom(domTristrips &prim) { // If we already loaded it before, use that. - if (prim.getUserData() != NULL) { + if (prim.getUserData() != nullptr) { return (ColladaPrimitive *) prim.getUserData(); } diff --git a/panda/src/collada/load_collada_file.cxx b/panda/src/collada/load_collada_file.cxx index 1d849f0f79..2ebdd2c340 100644 --- a/panda/src/collada/load_collada_file.cxx +++ b/panda/src/collada/load_collada_file.cxx @@ -26,10 +26,10 @@ load_from_loader(ColladaLoader &loader) { if (loader._error && !collada_accept_errors) { collada_cat.error() << "Errors in collada file.\n"; - return NULL; + return nullptr; } - if (loader._root != NULL && collada_flatten) { + if (loader._root != nullptr && collada_flatten) { SceneGraphReducer gr; int combine_siblings_bits = 0; @@ -72,7 +72,7 @@ load_collada_file(const Filename &filename, CoordinateSystem cs, VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(filename); } @@ -85,7 +85,7 @@ load_collada_file(const Filename &filename, CoordinateSystem cs, << "Reading " << filename << "\n"; if (!loader.read(filename)) { - return NULL; + return nullptr; } return load_from_loader(loader); diff --git a/panda/src/collada/load_collada_file.h b/panda/src/collada/load_collada_file.h index 9dea0e72f9..8217b11063 100644 --- a/panda/src/collada/load_collada_file.h +++ b/panda/src/collada/load_collada_file.h @@ -30,7 +30,7 @@ BEGIN_PUBLISH */ EXPCL_COLLADA PT(PandaNode) load_collada_file(const Filename &filename, CoordinateSystem cs = CS_default, - BamCacheRecord *record = NULL); + BamCacheRecord *record = nullptr); END_PUBLISH #endif diff --git a/panda/src/collide/collisionBox.cxx b/panda/src/collide/collisionBox.cxx index b55988c352..ad025f8682 100644 --- a/panda/src/collide/collisionBox.cxx +++ b/panda/src/collide/collisionBox.cxx @@ -199,7 +199,7 @@ PT(CollisionEntry) CollisionBox:: test_intersection_from_sphere(const CollisionEntry &entry) const { const CollisionSphere *sphere; - DCAST_INTO_R(sphere, entry.get_from(), NULL); + DCAST_INTO_R(sphere, entry.get_from(), nullptr); CPT(TransformState) wrt_space = entry.get_wrt_space(); CPT(TransformState) wrt_prev_space = entry.get_wrt_prev_space(); @@ -310,7 +310,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PN_stdfloat edge_dist = 0.0f; const ClipPlaneAttrib *cpa = entry.get_into_clip_planes(); - if (cpa != (ClipPlaneAttrib *)NULL) { + if (cpa != nullptr) { // We have a clip plane; apply it. Points new_points; if (apply_clip_plane(new_points, cpa, entry.get_into_node_path().get_net_transform(),ip)) { @@ -361,7 +361,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { intersect = true; } if( !intersect ) - return NULL; + return nullptr; if (collide_cat.is_debug()) { collide_cat.debug() @@ -402,7 +402,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionBox:: test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; - DCAST_INTO_R(ray, entry.get_from(), NULL); + DCAST_INTO_R(ray, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); LPoint3 from_origin = ray->get_origin() * wrt_mat; @@ -453,7 +453,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { if(!intersect) { // No intersection with ANY of the box's planes has been detected - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -483,7 +483,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionBox:: test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *seg; - DCAST_INTO_R(seg, entry.get_from(), NULL); + DCAST_INTO_R(seg, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); LPoint3 from_origin = seg->get_point_a() * wrt_mat; @@ -535,7 +535,7 @@ test_intersection_from_segment(const CollisionEntry &entry) const { if(!intersect) { // No intersection with ANY of the box's planes has been detected - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -564,7 +564,7 @@ test_intersection_from_segment(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionBox:: test_intersection_from_box(const CollisionEntry &entry) const { const CollisionBox *box; - DCAST_INTO_R(box, entry.get_from(), NULL); + DCAST_INTO_R(box, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -603,7 +603,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { cabs(box_z[0] * from_extents[2]); pen = r1 + r2 - cabs(diff[0]); if (pen < 0) { - return NULL; + return nullptr; } min_pen = pen; @@ -613,7 +613,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { cabs(box_z[1] * from_extents[2]); pen = r1 + r2 - cabs(diff[1]); if (pen < 0) { - return NULL; + return nullptr; } if (pen < min_pen) { min_pen = pen; @@ -626,7 +626,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { cabs(box_z[2] * from_extents[2]); pen = r1 + r2 - cabs(diff[2]); if (pen < 0) { - return NULL; + return nullptr; } if (pen < min_pen) { min_pen = pen; @@ -640,7 +640,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { r2 = from_extents[0]; pen = r1 + r2 - cabs(diff.dot(box_x)); if (pen < 0) { - return NULL; + return nullptr; } if (pen < min_pen) { min_pen = pen; @@ -652,7 +652,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { r2 = from_extents[1]; pen = r1 + r2 - cabs(diff.dot(box_y)); if (pen < 0) { - return NULL; + return nullptr; } if (pen < min_pen) { min_pen = pen; @@ -664,7 +664,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { r2 = from_extents[2]; pen = r1 + r2 - cabs(diff.dot(box_z)); if (pen < 0) { - return NULL; + return nullptr; } if (pen < min_pen) { min_pen = pen; @@ -674,55 +674,55 @@ test_intersection_from_box(const CollisionEntry &entry) const { r1 = into_extents[1] * cabs(box_x[2]) + into_extents[2] * cabs(box_x[1]); r2 = from_extents[1] * cabs(box_z[0]) + from_extents[2] * cabs(box_y[0]); if (cabs(diff[2] * box_x[1] - diff[1] * box_x[2]) > r1 + r2) { - return NULL; + return nullptr; } r1 = into_extents[1] * cabs(box_y[2]) + into_extents[2] * cabs(box_y[1]); r2 = from_extents[0] * cabs(box_z[0]) + from_extents[2] * cabs(box_x[0]); if (cabs(diff[2] * box_y[1] - diff[1] * box_y[2]) > r1 + r2) { - return NULL; + return nullptr; } r1 = into_extents[1] * cabs(box_z[2]) + into_extents[2] * cabs(box_z[1]); r2 = from_extents[0] * cabs(box_y[0]) + from_extents[1] * cabs(box_x[0]); if (cabs(diff[2] * box_z[1] - diff[1] * box_z[2]) > r1 + r2) { - return NULL; + return nullptr; } r1 = into_extents[0] * cabs(box_x[2]) + into_extents[2] * cabs(box_x[0]); r2 = from_extents[1] * cabs(box_z[1]) + from_extents[2] * cabs(box_y[1]); if (cabs(diff[0] * box_x[2] - diff[2] * box_x[0]) > r1 + r2) { - return NULL; + return nullptr; } r1 = into_extents[0] * cabs(box_y[2]) + into_extents[2] * cabs(box_y[0]); r2 = from_extents[0] * cabs(box_z[1]) + from_extents[2] * cabs(box_x[1]); if (cabs(diff[0] * box_y[2] - diff[2] * box_y[0]) > r1 + r2) { - return NULL; + return nullptr; } r1 = into_extents[0] * cabs(box_z[2]) + into_extents[2] * cabs(box_z[0]); r2 = from_extents[0] * cabs(box_y[1]) + from_extents[1] * cabs(box_x[1]); if (cabs(diff[0] * box_z[2] - diff[2] * box_z[0]) > r1 + r2) { - return NULL; + return nullptr; } r1 = into_extents[0] * cabs(box_x[1]) + into_extents[1] * cabs(box_x[0]); r2 = from_extents[1] * cabs(box_z[2]) + from_extents[2] * cabs(box_y[2]); if (cabs(diff[1] * box_x[0] - diff[0] * box_x[1]) > r1 + r2) { - return NULL; + return nullptr; } r1 = into_extents[0] * cabs(box_y[1]) + into_extents[1] * cabs(box_y[0]); r2 = from_extents[0] * cabs(box_z[2]) + from_extents[2] * cabs(box_x[2]); if (cabs(diff[1] * box_y[0] - diff[0] * box_y[1]) > r1 + r2) { - return NULL; + return nullptr; } r1 = into_extents[0] * cabs(box_z[1]) + into_extents[1] * cabs(box_z[0]); r2 = from_extents[0] * cabs(box_y[2]) + from_extents[1] * cabs(box_x[2]); if (cabs(diff[1] * box_z[0] - diff[0] * box_z[1]) > r1 + r2) { - return NULL; + return nullptr; } if (collide_cat.is_debug()) { diff --git a/panda/src/collide/collisionEntry.I b/panda/src/collide/collisionEntry.I index 9b535d17ce..8187ca7a9c 100644 --- a/panda/src/collide/collisionEntry.I +++ b/panda/src/collide/collisionEntry.I @@ -38,7 +38,7 @@ get_from() const { */ INLINE bool CollisionEntry:: has_into() const { - return (_into != (CollisionSolid *)NULL); + return (_into != nullptr); } /** @@ -338,7 +338,7 @@ test_intersection(CollisionHandler *record, PT(CollisionEntry) result = get_from()->test_intersection(*this); #ifdef DO_COLLISION_RECORDING if (trav->has_recorder()) { - if (result != (CollisionEntry *)NULL) { + if (result != nullptr) { trav->get_recorder()->collision_tested(*result, true); } else { trav->get_recorder()->collision_tested(*this, false); @@ -351,11 +351,11 @@ test_intersection(CollisionHandler *record, // if there was no collision detected but the handler wants to know about // all potential collisions, create a "didn't collide" collision entry for // it - if (record->wants_all_potential_collidees() && result == (CollisionEntry *)NULL) { + if (record->wants_all_potential_collidees() && result == nullptr) { result = new CollisionEntry(*this); result->reset_collided(); } - if (result != (CollisionEntry *)NULL) { + if (result != nullptr) { record->add_entry(result); } } diff --git a/panda/src/collide/collisionEntry.cxx b/panda/src/collide/collisionEntry.cxx index 81814eea48..237c725579 100644 --- a/panda/src/collide/collisionEntry.cxx +++ b/panda/src/collide/collisionEntry.cxx @@ -239,7 +239,7 @@ write(ostream &out, int indent_level) const { out << "]"; const ClipPlaneAttrib *cpa = get_into_clip_planes(); - if (cpa != (ClipPlaneAttrib *)NULL) { + if (cpa != nullptr) { out << " (clipped)"; } out << "\n"; diff --git a/panda/src/collide/collisionFloorMesh.cxx b/panda/src/collide/collisionFloorMesh.cxx index d523875727..fa7ac93949 100644 --- a/panda/src/collide/collisionFloorMesh.cxx +++ b/panda/src/collide/collisionFloorMesh.cxx @@ -125,7 +125,7 @@ compute_internal_bounds() const { PT(CollisionEntry) CollisionFloorMesh:: test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; - DCAST_INTO_R(ray, entry.get_from(), NULL); + DCAST_INTO_R(ray, entry.get_from(), nullptr); LPoint3 from_origin = ray->get_origin() * entry.get_wrt_mat(); double fx = from_origin[0]; @@ -180,7 +180,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { new_entry->set_surface_point(LPoint3(fx, fy, finalz)); return new_entry; } - return NULL; + return nullptr; } @@ -190,7 +190,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionFloorMesh:: test_intersection_from_sphere(const CollisionEntry &entry) const { const CollisionSphere *sphere; - DCAST_INTO_R(sphere, entry.get_from(), NULL); + DCAST_INTO_R(sphere, entry.get_from(), nullptr); LPoint3 from_origin = sphere->get_center() * entry.get_wrt_mat(); double fx = from_origin[0]; @@ -243,14 +243,14 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PN_stdfloat finalz = p0z+vz+(((uz - vz) *u)/(u+v)); PN_stdfloat dz = fz - finalz; if(dz > rad) - return NULL; + return nullptr; PT(CollisionEntry) new_entry = new CollisionEntry(entry); new_entry->set_surface_normal(LPoint3(0, 0, 1)); new_entry->set_surface_point(LPoint3(fx, fy, finalz)); return new_entry; } - return NULL; + return nullptr; } diff --git a/panda/src/collide/collisionHandlerEvent.cxx b/panda/src/collide/collisionHandlerEvent.cxx index c43a3c2ee4..872044bb22 100644 --- a/panda/src/collide/collisionHandlerEvent.cxx +++ b/panda/src/collide/collisionHandlerEvent.cxx @@ -50,7 +50,7 @@ begin_group() { */ void CollisionHandlerEvent:: add_entry(CollisionEntry *entry) { - nassertv(entry != (CollisionEntry *)NULL); + nassertv(entry != nullptr); // Record this particular entry for later. This will keep track of all the // unique pairs of nodenode intersections. diff --git a/panda/src/collide/collisionHandlerFloor.cxx b/panda/src/collide/collisionHandlerFloor.cxx index e8f697fb5f..3c8c8e80bf 100644 --- a/panda/src/collide/collisionHandlerFloor.cxx +++ b/panda/src/collide/collisionHandlerFloor.cxx @@ -62,13 +62,13 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod bool got_min = false; PN_stdfloat max_height = 0.0f; PN_stdfloat min_height = 0.0f; - CollisionEntry *highest = NULL; - CollisionEntry *lowest = NULL; + CollisionEntry *highest = nullptr; + CollisionEntry *lowest = nullptr; Entries::const_iterator ei; for (ei = entries.begin(); ei != entries.end(); ++ei) { CollisionEntry *entry = (*ei); - nassertr(entry != (CollisionEntry *)NULL, 0.0f); + nassertr(entry != nullptr, 0.0f); nassertr(from_node_path == entry->get_from_node_path(), 0.0f); if (entry->has_surface_point()) { @@ -159,12 +159,12 @@ handle_entries() { // Get the maximum height for all collisions with this node. bool got_max = false; PN_stdfloat max_height = 0.0f; - CollisionEntry *max_entry = NULL; + CollisionEntry *max_entry = nullptr; Entries::const_iterator ei; for (ei = entries.begin(); ei != entries.end(); ++ei) { CollisionEntry *entry = (*ei); - nassertr(entry != (CollisionEntry *)NULL, false); + nassertr(entry != nullptr, false); nassertr(from_node_path == entry->get_from_node_path(), false); if (entry->has_surface_point()) { diff --git a/panda/src/collide/collisionHandlerFluidPusher.cxx b/panda/src/collide/collisionHandlerFluidPusher.cxx index 9e4e95f5b0..df15e8bacc 100644 --- a/panda/src/collide/collisionHandlerFluidPusher.cxx +++ b/panda/src/collide/collisionHandlerFluidPusher.cxx @@ -35,7 +35,7 @@ CollisionHandlerFluidPusher() { */ void CollisionHandlerFluidPusher:: add_entry(CollisionEntry *entry) { - nassertv(entry != (CollisionEntry *)NULL); + nassertv(entry != nullptr); // skip over CollisionHandlerPhysical::add_entry, since it filters out // collidees by orientation; our collider can change direction mid-frame, so // it may collide with something that would have been filtered out @@ -158,20 +158,20 @@ handle_entries() { // iterate until the mover runs out of movement or gets stuck while (true) { - const CollisionEntry *C = 0; + const CollisionEntry *C = nullptr; // find the first (earliest) collision Entries::const_iterator cei; for (cei = entries.begin(); cei != entries.end(); ++cei) { const CollisionEntry *entry = (*cei); - nassertr(entry != (CollisionEntry *)NULL, false); - if (entry->collided() && ((C == 0) || (entry->get_t() < C->get_t()))) { + nassertr(entry != nullptr, false); + if (entry->collided() && ((C == nullptr) || (entry->get_t() < C->get_t()))) { nassertr(from_node_path == entry->get_from_node_path(), false); C = entry; } } // if no collisions, we're done - if (C == 0) { + if (C == nullptr) { break; } @@ -227,13 +227,13 @@ handle_entries() { Entries new_entries; for (ei = entries.begin(); ei != entries.end(); ++ei) { CollisionEntry *entry = (*ei); - nassertr(entry != (CollisionEntry *)NULL, false); + nassertr(entry != nullptr, false); // skip the one we just collided against if (entry != C) { entry->_from_node_path = from_node_path; entry->reset_collided(); PT(CollisionEntry) result = entry->get_from()->test_intersection(**ei); - if (result != (CollisionEntry *)NULL && result != (CollisionEntry *)0) { + if (result != nullptr && result != nullptr) { new_entries.push_back(result); } } diff --git a/panda/src/collide/collisionHandlerGravity.cxx b/panda/src/collide/collisionHandlerGravity.cxx index a09b70a0a6..42a52a54b6 100644 --- a/panda/src/collide/collisionHandlerGravity.cxx +++ b/panda/src/collide/collisionHandlerGravity.cxx @@ -53,12 +53,12 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod // Get the maximum height for all collisions with this node. bool got_max = false; PN_stdfloat max_height = 0.0f; - CollisionEntry *highest = NULL; + CollisionEntry *highest = nullptr; Entries::const_iterator ei; for (ei = entries.begin(); ei != entries.end(); ++ei) { CollisionEntry *entry = (*ei); - nassertr(entry != (CollisionEntry *)NULL, 0.0f); + nassertr(entry != nullptr, 0.0f); nassertr(from_node_path == entry->get_from_node_path(), 0.0f); if (entry->has_surface_point()) { @@ -109,15 +109,15 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod bool got_min = false; PN_stdfloat max_height = 0.0f; PN_stdfloat min_height = 0.0f; - CollisionEntry *highest = NULL; - CollisionEntry *lowest = NULL; + CollisionEntry *highest = nullptr; + CollisionEntry *lowest = nullptr; pvector valid_entries; Entries::const_iterator ei; for (ei = entries.begin(); ei != entries.end(); ++ei) { CollisionEntry *entry = (*ei); - nassertr(entry != (CollisionEntry *)NULL, 0.0f); + nassertr(entry != nullptr, 0.0f); nassertr(from_node_path == entry->get_from_node_path(), 0.0f); if (entry->has_surface_point()) { diff --git a/panda/src/collide/collisionHandlerHighestEvent.cxx b/panda/src/collide/collisionHandlerHighestEvent.cxx index f72023153d..55eb58b221 100644 --- a/panda/src/collide/collisionHandlerHighestEvent.cxx +++ b/panda/src/collide/collisionHandlerHighestEvent.cxx @@ -46,7 +46,7 @@ begin_group() { } _current_colliding.clear(); _collider_distance = 0; - _closest_collider = NULL; + _closest_collider = nullptr; } /** @@ -55,12 +55,12 @@ begin_group() { */ void CollisionHandlerHighestEvent:: add_entry(CollisionEntry *entry) { - nassertv(entry != (CollisionEntry *)NULL); + nassertv(entry != nullptr); LVector3 vec = entry->get_surface_point(entry->get_from_node_path()) - entry->get_from()->get_collision_origin(); double dist = vec.length_squared(); - if (_closest_collider == NULL || dist < _collider_distance) { + if (_closest_collider == nullptr || dist < _collider_distance) { _collider_distance = dist; _closest_collider = entry; } diff --git a/panda/src/collide/collisionHandlerPhysical.I b/panda/src/collide/collisionHandlerPhysical.I index d0f45fd495..5000ec3f59 100644 --- a/panda/src/collide/collisionHandlerPhysical.I +++ b/panda/src/collide/collisionHandlerPhysical.I @@ -74,7 +74,7 @@ set_target(const NodePath &target, DriveInterface *drive_interface) { */ INLINE void CollisionHandlerPhysical::ColliderDef:: updated_transform() { - if (_drive_interface != (DriveInterface *)NULL) { + if (_drive_interface != nullptr) { _drive_interface->set_mat(_target.get_mat()); _drive_interface->force_dgraph(); } diff --git a/panda/src/collide/collisionHandlerPhysical.cxx b/panda/src/collide/collisionHandlerPhysical.cxx index 4b356235a3..3e65e41bfc 100644 --- a/panda/src/collide/collisionHandlerPhysical.cxx +++ b/panda/src/collide/collisionHandlerPhysical.cxx @@ -52,7 +52,7 @@ begin_group() { */ void CollisionHandlerPhysical:: add_entry(CollisionEntry *entry) { - nassertv(entry != (CollisionEntry *)NULL); + nassertv(entry != nullptr); CollisionHandlerEvent::add_entry(entry); if (entry->get_from()->is_tangible() && diff --git a/panda/src/collide/collisionHandlerPhysical.h b/panda/src/collide/collisionHandlerPhysical.h index cb3a340cdc..9a9225b6b8 100644 --- a/panda/src/collide/collisionHandlerPhysical.h +++ b/panda/src/collide/collisionHandlerPhysical.h @@ -62,7 +62,7 @@ protected: class ColliderDef { public: INLINE void set_target(const NodePath &target, - DriveInterface *drive_interface = NULL); + DriveInterface *drive_interface = nullptr); INLINE void updated_transform(); NodePath _target; diff --git a/panda/src/collide/collisionHandlerPusher.cxx b/panda/src/collide/collisionHandlerPusher.cxx index 4b1b60482a..5881b7e177 100644 --- a/panda/src/collide/collisionHandlerPusher.cxx +++ b/panda/src/collide/collisionHandlerPusher.cxx @@ -91,7 +91,7 @@ handle_entries() { Entries::const_iterator ei; for (ei = entries.begin(); ei != entries.end(); ++ei) { CollisionEntry *entry = (*ei); - nassertr(entry != (CollisionEntry *)NULL, false); + nassertr(entry != nullptr, false); nassertr(from_node_path == entry->get_from_node_path(), false); LPoint3 surface_point; @@ -171,8 +171,8 @@ handle_entries() { // concave). const CollisionSolid *s1 = sd._entry->get_into(); const CollisionSolid *s2 = sd2._entry->get_into(); - if (s1 != (CollisionSolid *)NULL && - s2 != (CollisionSolid *)NULL && + if (s1 != nullptr && + s2 != nullptr && s1->is_exact_type(CollisionPolygon::get_class_type()) && s2->is_exact_type(CollisionPolygon::get_class_type()) && sd._entry->get_into_node_path() == diff --git a/panda/src/collide/collisionHandlerQueue.cxx b/panda/src/collide/collisionHandlerQueue.cxx index 9c8909f3bc..7a2fefd271 100644 --- a/panda/src/collide/collisionHandlerQueue.cxx +++ b/panda/src/collide/collisionHandlerQueue.cxx @@ -58,7 +58,7 @@ begin_group() { */ void CollisionHandlerQueue:: add_entry(CollisionEntry *entry) { - nassertv(entry != (CollisionEntry *)NULL); + nassertv(entry != nullptr); _entries.push_back(entry); } @@ -118,7 +118,7 @@ get_num_entries() const { */ CollisionEntry *CollisionHandlerQueue:: get_entry(int n) const { - nassertr(n >= 0 && n < (int)_entries.size(), NULL); + nassertr(n >= 0 && n < (int)_entries.size(), nullptr); return _entries[n]; } diff --git a/panda/src/collide/collisionInvSphere.cxx b/panda/src/collide/collisionInvSphere.cxx index 35a73225dd..2074fb9522 100644 --- a/panda/src/collide/collisionInvSphere.cxx +++ b/panda/src/collide/collisionInvSphere.cxx @@ -47,7 +47,7 @@ make_copy() { PT(CollisionEntry) CollisionInvSphere:: test_intersection(const CollisionEntry &) const { report_undefined_from_intersection(get_type()); - return NULL; + return nullptr; } /** @@ -92,7 +92,7 @@ compute_internal_bounds() const { PT(CollisionEntry) CollisionInvSphere:: test_intersection_from_sphere(const CollisionEntry &entry) const { const CollisionSphere *sphere; - DCAST_INTO_R(sphere, entry.get_from(), NULL); + DCAST_INTO_R(sphere, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -108,7 +108,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PN_stdfloat dist2 = dot(vec, vec); if (dist2 < (into_radius - from_radius) * (into_radius - from_radius)) { // No intersection--the sphere is within the hollow. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -144,7 +144,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionInvSphere:: test_intersection_from_line(const CollisionEntry &entry) const { const CollisionLine *line; - DCAST_INTO_R(line, entry.get_from(), NULL); + DCAST_INTO_R(line, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -185,7 +185,7 @@ test_intersection_from_line(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionInvSphere:: test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; - DCAST_INTO_R(ray, entry.get_from(), NULL); + DCAST_INTO_R(ray, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -228,7 +228,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionInvSphere:: test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *segment; - DCAST_INTO_R(segment, entry.get_from(), NULL); + DCAST_INTO_R(segment, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -264,7 +264,7 @@ test_intersection_from_segment(const CollisionEntry &entry) const { // Neither edge of the segment intersects the shell. It follows that both // intersection points are within the hollow center of the sphere; // therefore, there is no intersection. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { diff --git a/panda/src/collide/collisionLevelState.I b/panda/src/collide/collisionLevelState.I index 5dc74aa691..db618f99e7 100644 --- a/panda/src/collide/collisionLevelState.I +++ b/panda/src/collide/collisionLevelState.I @@ -147,7 +147,7 @@ any_in_bounds() { is_in = true; // If there's no bounding volume, we're implicitly in. - if (col_gbv != (GeometricBoundingVolume *)NULL) { + if (col_gbv != nullptr) { is_in = (node_gbv->contains(col_gbv) != 0); _node_volume_pcollector.add_level(1); @@ -231,7 +231,7 @@ apply_transform() { int num_colliders = get_num_colliders(); new_bounds.reserve(num_colliders); for (int c = 0; c < num_colliders; c++) { - new_bounds.push_back((GeometricBoundingVolume *)NULL); + new_bounds.push_back(nullptr); } _local_bounds = new_bounds; @@ -257,8 +257,8 @@ apply_transform() { new_bounds.reserve(num_colliders); for (int c = 0; c < num_colliders; c++) { if (!has_collider(c) || - get_local_bound(c) == (GeometricBoundingVolume *)NULL) { - new_bounds.push_back((GeometricBoundingVolume *)NULL); + get_local_bound(c) == nullptr) { + new_bounds.push_back(nullptr); } else { const GeometricBoundingVolume *old_bound = get_local_bound(c); GeometricBoundingVolume *new_bound = diff --git a/panda/src/collide/collisionLevelStateBase.I b/panda/src/collide/collisionLevelStateBase.I index 2f2b366fb9..20923a9c22 100644 --- a/panda/src/collide/collisionLevelStateBase.I +++ b/panda/src/collide/collisionLevelStateBase.I @@ -88,7 +88,7 @@ get_num_colliders() const { */ INLINE const CollisionSolid *CollisionLevelStateBase:: get_collider(int n) const { - nassertr(n >= 0 && n < (int)_colliders.size(), NULL); + nassertr(n >= 0 && n < (int)_colliders.size(), nullptr); return _colliders[n]._collider; } @@ -98,7 +98,7 @@ get_collider(int n) const { */ INLINE CollisionNode *CollisionLevelStateBase:: get_collider_node(int n) const { - nassertr(n >= 0 && n < (int)_colliders.size(), NULL); + nassertr(n >= 0 && n < (int)_colliders.size(), nullptr); return _colliders[n]._node; } @@ -119,8 +119,8 @@ get_collider_node_path(int n) const { */ INLINE const GeometricBoundingVolume *CollisionLevelStateBase:: get_local_bound(int n) const { - nassertr(n >= 0 && n < (int)_colliders.size(), NULL); - nassertr(n >= 0 && n < (int)_local_bounds.size(), NULL); + nassertr(n >= 0 && n < (int)_colliders.size(), nullptr); + nassertr(n >= 0 && n < (int)_local_bounds.size(), nullptr); // For whatever reason, the Intel compiler can't figure this line out. // return _local_bounds[n]; @@ -137,8 +137,8 @@ get_local_bound(int n) const { */ INLINE const GeometricBoundingVolume *CollisionLevelStateBase:: get_parent_bound(int n) const { - nassertr(n >= 0 && n < (int)_colliders.size(), NULL); - nassertr(n >= 0 && n < (int)_parent_bounds.size(), NULL); + nassertr(n >= 0 && n < (int)_colliders.size(), nullptr); + nassertr(n >= 0 && n < (int)_parent_bounds.size(), nullptr); // But it can figure out this equivalent line. return *(_parent_bounds + n); diff --git a/panda/src/collide/collisionLevelStateBase.cxx b/panda/src/collide/collisionLevelStateBase.cxx index c66f58e8fc..02d7cc2fd2 100644 --- a/panda/src/collide/collisionLevelStateBase.cxx +++ b/panda/src/collide/collisionLevelStateBase.cxx @@ -52,7 +52,7 @@ prepare_collider(const ColliderDef &def, const NodePath &root) { const CollisionSolid *collider = def._collider; CPT(BoundingVolume) bv = collider->get_bounds(); if (!bv->is_of_type(GeometricBoundingVolume::get_class_type())) { - _local_bounds.push_back((GeometricBoundingVolume *)NULL); + _local_bounds.push_back(nullptr); } else { // We can use a plain pointer, rather than a PT() here, because we know we // are going to save the volume in the vector, below. diff --git a/panda/src/collide/collisionNode.cxx b/panda/src/collide/collisionNode.cxx index 9de94617b3..803a5f058d 100644 --- a/panda/src/collide/collisionNode.cxx +++ b/panda/src/collide/collisionNode.cxx @@ -142,7 +142,7 @@ combine_with(PandaNode *other) { } } - return NULL; + return nullptr; } /** @@ -184,7 +184,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { for (si = _solids.begin(); si != _solids.end(); ++si) { CPT(CollisionSolid) solid = (*si).get_read_pointer(); PT(PandaNode) node = solid->get_viz(trav, data, false); - if (node != (PandaNode *)NULL) { + if (node != nullptr) { CullTraverserData next_data(data, node); // We don't want to inherit the render state from above for these guys. @@ -206,7 +206,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { for (si = _solids.begin(); si != _solids.end(); ++si) { CPT(CollisionSolid) solid = (*si).get_read_pointer(); PT(PandaNode) node = solid->get_viz(trav, data, false); - if (node != (PandaNode *)NULL) { + if (node != nullptr) { CullTraverserData next_data(data, node); next_data._net_transform = @@ -331,8 +331,8 @@ CPT(RenderState) CollisionNode:: get_last_pos_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) state = (const RenderState *)NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make (ColorScaleAttrib::make(LVecBase4(1.0f, 1.0f, 1.0f, 0.5f)), TransparencyAttrib::make(TransparencyAttrib::M_alpha)); @@ -422,7 +422,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { for(int i = 0; i < num_solids; i++) { manager->read_pointer(scan); // Push back a NULL for each solid, for now. We'll fill them in later. - _solids.push_back((CollisionSolid *)NULL); + _solids.push_back(nullptr); } _from_collide_mask.set_word(scan.get_uint32()); diff --git a/panda/src/collide/collisionPlane.cxx b/panda/src/collide/collisionPlane.cxx index d722adde7b..f869f6c2d1 100644 --- a/panda/src/collide/collisionPlane.cxx +++ b/panda/src/collide/collisionPlane.cxx @@ -107,7 +107,7 @@ compute_internal_bounds() const { PT(CollisionEntry) CollisionPlane:: test_intersection_from_sphere(const CollisionEntry &entry) const { const CollisionSphere *sphere; - DCAST_INTO_R(sphere, entry.get_from(), NULL); + DCAST_INTO_R(sphere, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -119,7 +119,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PN_stdfloat dist = dist_to_plane(from_center); if (dist > from_radius) { // No intersection. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -146,7 +146,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPlane:: test_intersection_from_line(const CollisionEntry &entry) const { const CollisionLine *line; - DCAST_INTO_R(line, entry.get_from(), NULL); + DCAST_INTO_R(line, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -159,7 +159,7 @@ test_intersection_from_line(const CollisionEntry &entry) const { if (_plane.dist_to_plane(from_origin) > 0.0f) { // The line is entirely in front of the plane. - return NULL; + return nullptr; } // The line is entirely behind the plane. @@ -191,7 +191,7 @@ test_intersection_from_line(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPlane:: test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; - DCAST_INTO_R(ray, entry.get_from(), NULL); + DCAST_INTO_R(ray, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -208,13 +208,13 @@ test_intersection_from_ray(const CollisionEntry &entry) const { } else { if (!_plane.intersects_line(t, from_origin, from_direction)) { // No intersection. The ray is parallel to the plane. - return NULL; + return nullptr; } if (t < 0.0f) { // The intersection point is before the start of the ray, and so the ray // is entirely in front of the plane. - return NULL; + return nullptr; } } @@ -243,7 +243,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPlane:: test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *segment; - DCAST_INTO_R(segment, entry.get_from(), NULL); + DCAST_INTO_R(segment, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -255,7 +255,7 @@ test_intersection_from_segment(const CollisionEntry &entry) const { if (dist_a >= 0.0f && dist_b >= 0.0f) { // Entirely in front of the plane means no intersection. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -300,7 +300,7 @@ test_intersection_from_segment(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPlane:: test_intersection_from_tube(const CollisionEntry &entry) const { const CollisionTube *tube; - DCAST_INTO_R(tube, entry.get_from(), NULL); + DCAST_INTO_R(tube, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -315,7 +315,7 @@ test_intersection_from_tube(const CollisionEntry &entry) const { if (dist_a >= from_radius && dist_b >= from_radius) { // Entirely in front of the plane means no intersection. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -371,7 +371,7 @@ test_intersection_from_tube(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPlane:: test_intersection_from_parabola(const CollisionEntry &entry) const { const CollisionParabola *parabola; - DCAST_INTO_R(parabola, entry.get_from(), NULL); + DCAST_INTO_R(parabola, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -390,7 +390,7 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { if (!get_plane().intersects_parabola(t1, t2, local_p)) { // No intersection. The infinite parabola is entirely in front of the // plane. - return NULL; + return nullptr; } if (t1 >= parabola->get_t1() && t1 <= parabola->get_t2()) { @@ -409,7 +409,7 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { } else { // Neither intersection point is within our segment. - return NULL; + return nullptr; } } @@ -437,7 +437,7 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPlane:: test_intersection_from_box(const CollisionEntry &entry) const { const CollisionBox *box; - DCAST_INTO_R(box, entry.get_from(), NULL); + DCAST_INTO_R(box, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -459,7 +459,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { if (depth > 0) { // No collision. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { diff --git a/panda/src/collide/collisionPolygon.cxx b/panda/src/collide/collisionPolygon.cxx index 646a7b9439..2e907c0695 100644 --- a/panda/src/collide/collisionPolygon.cxx +++ b/panda/src/collide/collisionPolygon.cxx @@ -235,7 +235,7 @@ PT(PandaNode) CollisionPolygon:: get_viz(const CullTraverser *trav, const CullTraverserData &data, bool bounds_only) const { const ClipPlaneAttrib *cpa = DCAST(ClipPlaneAttrib, data._state->get_attrib(ClipPlaneAttrib::get_class_slot())); - if (cpa == (const ClipPlaneAttrib *)NULL) { + if (cpa == nullptr) { // Fortunately, the polygon is not clipped. This is the normal, easy // case. return CollisionSolid::get_viz(trav, data, bounds_only); @@ -259,7 +259,7 @@ get_viz(const CullTraverser *trav, const CullTraverserData &data, if (new_points.empty()) { // All points are in front of the clip plane; draw nothing. - return NULL; + return nullptr; } // Draw the clipped polygon. @@ -360,11 +360,11 @@ compute_internal_bounds() const { PT(CollisionEntry) CollisionPolygon:: test_intersection_from_sphere(const CollisionEntry &entry) const { if (_points.size() < 3) { - return NULL; + return nullptr; } const CollisionSphere *sphere; - DCAST_INTO_R(sphere, entry.get_from(), NULL); + DCAST_INTO_R(sphere, entry.get_from(), nullptr); CPT(TransformState) wrt_space = entry.get_wrt_space(); CPT(TransformState) wrt_prev_space = entry.get_wrt_prev_space(); @@ -395,7 +395,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { // in the same direction as the plane's normal. PN_stdfloat dot = delta.dot(get_normal()); if (dot > 0.1f) { - return NULL; + return nullptr; } if (IS_NEARLY_ZERO(dot)) { @@ -451,19 +451,19 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { if (!get_plane().intersects_line(dist, from_center, -get_normal())) { // No intersection with plane? This means the plane's effective normal // was within the plane itself. A useless polygon. - return NULL; + return nullptr; } if (dist > from_radius || dist < -from_radius) { // No intersection with the plane. - return NULL; + return nullptr; } LPoint2 p = to_2d(from_center - dist * get_normal()); PN_stdfloat edge_dist = 0.0f; const ClipPlaneAttrib *cpa = entry.get_into_clip_planes(); - if (cpa != (ClipPlaneAttrib *)NULL) { + if (cpa != nullptr) { // We have a clip plane; apply it. Points new_points; if (apply_clip_plane(new_points, cpa, entry.get_into_node_path().get_net_transform())) { @@ -472,7 +472,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { } else if (new_points.empty()) { // The polygon is completely clipped. - return NULL; + return nullptr; } else { // Test against the clipped polygon. @@ -489,7 +489,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { if (edge_dist > from_radius) { // No intersection; the circle is outside the polygon. - return NULL; + return nullptr; } // The sphere appears to intersect the polygon. If the edge is less than @@ -505,7 +505,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { if (dist > max_dist) { // There's no intersection: the sphere is hanging off the edge. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -541,11 +541,11 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPolygon:: test_intersection_from_line(const CollisionEntry &entry) const { if (_points.size() < 3) { - return NULL; + return nullptr; } const CollisionLine *line; - DCAST_INTO_R(line, entry.get_from(), NULL); + DCAST_INTO_R(line, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -555,35 +555,35 @@ test_intersection_from_line(const CollisionEntry &entry) const { PN_stdfloat t; if (!get_plane().intersects_line(t, from_origin, from_direction)) { // No intersection. - return NULL; + return nullptr; } LPoint3 plane_point = from_origin + t * from_direction; LPoint2 p = to_2d(plane_point); const ClipPlaneAttrib *cpa = entry.get_into_clip_planes(); - if (cpa != (ClipPlaneAttrib *)NULL) { + if (cpa != nullptr) { // We have a clip plane; apply it. Points new_points; if (apply_clip_plane(new_points, cpa, entry.get_into_node_path().get_net_transform())) { // All points are behind the clip plane. if (!point_is_inside(p, _points)) { - return NULL; + return nullptr; } } else { if (new_points.size() < 3) { - return NULL; + return nullptr; } if (!point_is_inside(p, new_points)) { - return NULL; + return nullptr; } } } else { // No clip plane is in effect. Do the default test. if (!point_is_inside(p, _points)) { - return NULL; + return nullptr; } } @@ -609,11 +609,11 @@ test_intersection_from_line(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPolygon:: test_intersection_from_ray(const CollisionEntry &entry) const { if (_points.size() < 3) { - return NULL; + return nullptr; } const CollisionRay *ray; - DCAST_INTO_R(ray, entry.get_from(), NULL); + DCAST_INTO_R(ray, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -623,40 +623,40 @@ test_intersection_from_ray(const CollisionEntry &entry) const { PN_stdfloat t; if (!get_plane().intersects_line(t, from_origin, from_direction)) { // No intersection. - return NULL; + return nullptr; } if (t < 0.0f) { // The intersection point is before the start of the ray. - return NULL; + return nullptr; } LPoint3 plane_point = from_origin + t * from_direction; LPoint2 p = to_2d(plane_point); const ClipPlaneAttrib *cpa = entry.get_into_clip_planes(); - if (cpa != (ClipPlaneAttrib *)NULL) { + if (cpa != nullptr) { // We have a clip plane; apply it. Points new_points; if (apply_clip_plane(new_points, cpa, entry.get_into_node_path().get_net_transform())) { // All points are behind the clip plane. if (!point_is_inside(p, _points)) { - return NULL; + return nullptr; } } else { if (new_points.size() < 3) { - return NULL; + return nullptr; } if (!point_is_inside(p, new_points)) { - return NULL; + return nullptr; } } } else { // No clip plane is in effect. Do the default test. if (!point_is_inside(p, _points)) { - return NULL; + return nullptr; } } @@ -682,11 +682,11 @@ test_intersection_from_ray(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPolygon:: test_intersection_from_segment(const CollisionEntry &entry) const { if (_points.size() < 3) { - return NULL; + return nullptr; } const CollisionSegment *segment; - DCAST_INTO_R(segment, entry.get_from(), NULL); + DCAST_INTO_R(segment, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -697,41 +697,41 @@ test_intersection_from_segment(const CollisionEntry &entry) const { PN_stdfloat t; if (!get_plane().intersects_line(t, from_a, from_direction)) { // No intersection. - return NULL; + return nullptr; } if (t < 0.0f || t > 1.0f) { // The intersection point is before the start of the segment or after the // end of the segment. - return NULL; + return nullptr; } LPoint3 plane_point = from_a + t * from_direction; LPoint2 p = to_2d(plane_point); const ClipPlaneAttrib *cpa = entry.get_into_clip_planes(); - if (cpa != (ClipPlaneAttrib *)NULL) { + if (cpa != nullptr) { // We have a clip plane; apply it. Points new_points; if (apply_clip_plane(new_points, cpa, entry.get_into_node_path().get_net_transform())) { // All points are behind the clip plane. if (!point_is_inside(p, _points)) { - return NULL; + return nullptr; } } else { if (new_points.size() < 3) { - return NULL; + return nullptr; } if (!point_is_inside(p, new_points)) { - return NULL; + return nullptr; } } } else { // No clip plane is in effect. Do the default test. if (!point_is_inside(p, _points)) { - return NULL; + return nullptr; } } @@ -757,11 +757,11 @@ test_intersection_from_segment(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPolygon:: test_intersection_from_parabola(const CollisionEntry &entry) const { if (_points.size() < 3) { - return NULL; + return nullptr; } const CollisionParabola *parabola; - DCAST_INTO_R(parabola, entry.get_from(), NULL); + DCAST_INTO_R(parabola, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -772,7 +772,7 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { PN_stdfloat t1, t2; if (!get_plane().intersects_parabola(t1, t2, local_p)) { // No intersection. - return NULL; + return nullptr; } PN_stdfloat t; @@ -792,35 +792,35 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { } else { // Neither intersection point is within our segment. - return NULL; + return nullptr; } LPoint3 plane_point = local_p.calc_point(t); LPoint2 p = to_2d(plane_point); const ClipPlaneAttrib *cpa = entry.get_into_clip_planes(); - if (cpa != (ClipPlaneAttrib *)NULL) { + if (cpa != nullptr) { // We have a clip plane; apply it. Points new_points; if (apply_clip_plane(new_points, cpa, entry.get_into_node_path().get_net_transform())) { // All points are behind the clip plane. if (!point_is_inside(p, _points)) { - return NULL; + return nullptr; } } else { if (new_points.size() < 3) { - return NULL; + return nullptr; } if (!point_is_inside(p, new_points)) { - return NULL; + return nullptr; } } } else { // No clip plane is in effect. Do the default test. if (!point_is_inside(p, _points)) { - return NULL; + return nullptr; } } @@ -846,7 +846,7 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionPolygon:: test_intersection_from_box(const CollisionEntry &entry) const { const CollisionBox *box; - DCAST_INTO_R(box, entry.get_from(), NULL); + DCAST_INTO_R(box, entry.get_from(), nullptr); // To make things easier, transform the box into the coordinate space of the // plane. @@ -864,7 +864,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { // Is there a separating axis between the plane and the box? if (cabs(from_center[1]) > cabs(box_x[1]) + cabs(box_y[1]) + cabs(box_z[1])) { // There is one. No collision. - return NULL; + return nullptr; } // Now do the same for each of the box' primary axes. @@ -873,19 +873,19 @@ test_intersection_from_box(const CollisionEntry &entry) const { r1 = cabs(box_x.dot(box_x)) + cabs(box_y.dot(box_x)) + cabs(box_z.dot(box_x)); project(box_x, center, r2); if (cabs(from_center.dot(box_x) - center) > r1 + r2) { - return NULL; + return nullptr; } r1 = cabs(box_x.dot(box_y)) + cabs(box_y.dot(box_y)) + cabs(box_z.dot(box_y)); project(box_y, center, r2); if (cabs(from_center.dot(box_y) - center) > r1 + r2) { - return NULL; + return nullptr; } r1 = cabs(box_x.dot(box_z)) + cabs(box_y.dot(box_z)) + cabs(box_z.dot(box_z)); project(box_z, center, r2); if (cabs(from_center.dot(box_z) - center) > r1 + r2) { - return NULL; + return nullptr; } // Now do the same check for the cross products between the box axes and the @@ -901,7 +901,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { r1 = cabs(box_x.dot(axis)) + cabs(box_y.dot(axis)) + cabs(box_z.dot(axis)); project(axis, center, r2); if (cabs(from_center.dot(axis) - center) > r1 + r2) { - return NULL; + return nullptr; } axis.set(-box_y[1] * pd._v[1], @@ -910,7 +910,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { r1 = cabs(box_x.dot(axis)) + cabs(box_y.dot(axis)) + cabs(box_z.dot(axis)); project(axis, center, r2); if (cabs(from_center.dot(axis) - center) > r1 + r2) { - return NULL; + return nullptr; } axis.set(-box_z[1] * pd._v[1], @@ -919,7 +919,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { r1 = cabs(box_x.dot(axis)) + cabs(box_y.dot(axis)) + cabs(box_z.dot(axis)); project(axis, center, r2); if (cabs(from_center.dot(axis) - center) > r1 + r2) { - return NULL; + return nullptr; } } @@ -958,7 +958,7 @@ fill_viz_geom() { collide_cat.debug() << "Recomputing viz for " << *this << "\n"; } - nassertv(_viz_geom != (GeomNode *)NULL && _bounds_viz_geom != (GeomNode *)NULL); + nassertv(_viz_geom != nullptr && _bounds_viz_geom != nullptr); draw_polygon(_viz_geom, _bounds_viz_geom, _points); } diff --git a/panda/src/collide/collisionRecorder.cxx b/panda/src/collide/collisionRecorder.cxx index 09d87a9971..45580e97f1 100644 --- a/panda/src/collide/collisionRecorder.cxx +++ b/panda/src/collide/collisionRecorder.cxx @@ -25,7 +25,7 @@ CollisionRecorder:: CollisionRecorder() { _num_missed = 0; _num_detected = 0; - _trav = (CollisionTraverser *)NULL; + _trav = nullptr; } /** @@ -33,7 +33,7 @@ CollisionRecorder() { */ CollisionRecorder:: ~CollisionRecorder() { - if (_trav != (CollisionTraverser *)NULL) { + if (_trav != nullptr) { _trav->clear_recorder(); } } diff --git a/panda/src/collide/collisionSolid.cxx b/panda/src/collide/collisionSolid.cxx index 5f27903b45..f812c836f2 100644 --- a/panda/src/collide/collisionSolid.cxx +++ b/panda/src/collide/collisionSolid.cxx @@ -108,7 +108,7 @@ set_bounds(const BoundingVolume &bounding_volume) { PT(CollisionEntry) CollisionSolid:: test_intersection(const CollisionEntry &) const { report_undefined_from_intersection(get_type()); - return NULL; + return nullptr; } /** @@ -134,7 +134,7 @@ PT(PandaNode) CollisionSolid:: get_viz(const CullTraverser *, const CullTraverserData &, bool bounds_only) const { LightMutexHolder holder(_lock); if ((_flags & F_viz_geom_stale) != 0) { - if (_viz_geom == (GeomNode *)NULL) { + if (_viz_geom == nullptr) { ((CollisionSolid *)this)->_viz_geom = new GeomNode("viz"); ((CollisionSolid *)this)->_bounds_viz_geom = new GeomNode("bounds_viz"); } else { @@ -202,7 +202,7 @@ PT(CollisionEntry) CollisionSolid:: test_intersection_from_sphere(const CollisionEntry &) const { report_undefined_intersection_test(CollisionSphere::get_class_type(), get_type()); - return NULL; + return nullptr; } /** @@ -213,7 +213,7 @@ PT(CollisionEntry) CollisionSolid:: test_intersection_from_line(const CollisionEntry &) const { report_undefined_intersection_test(CollisionLine::get_class_type(), get_type()); - return NULL; + return nullptr; } /** @@ -224,7 +224,7 @@ PT(CollisionEntry) CollisionSolid:: test_intersection_from_ray(const CollisionEntry &) const { report_undefined_intersection_test(CollisionRay::get_class_type(), get_type()); - return NULL; + return nullptr; } /** @@ -235,7 +235,7 @@ PT(CollisionEntry) CollisionSolid:: test_intersection_from_segment(const CollisionEntry &) const { report_undefined_intersection_test(CollisionSegment::get_class_type(), get_type()); - return NULL; + return nullptr; } /** @@ -246,7 +246,7 @@ PT(CollisionEntry) CollisionSolid:: test_intersection_from_tube(const CollisionEntry &) const { report_undefined_intersection_test(CollisionTube::get_class_type(), get_type()); - return NULL; + return nullptr; } /** @@ -257,7 +257,7 @@ PT(CollisionEntry) CollisionSolid:: test_intersection_from_parabola(const CollisionEntry &) const { report_undefined_intersection_test(CollisionParabola::get_class_type(), get_type()); - return NULL; + return nullptr; } /** @@ -268,7 +268,7 @@ PT(CollisionEntry) CollisionSolid:: test_intersection_from_box(const CollisionEntry &) const { report_undefined_intersection_test(CollisionBox::get_class_type(), get_type()); - return NULL; + return nullptr; } @@ -389,8 +389,8 @@ CPT(RenderState) CollisionSolid:: get_solid_viz_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) base_state = (const RenderState *)NULL; - if (base_state == (const RenderState *)NULL) { + static CPT(RenderState) base_state = nullptr; + if (base_state == nullptr) { base_state = RenderState::make (CullFaceAttrib::make(CullFaceAttrib::M_cull_clockwise), RenderModeAttrib::make(RenderModeAttrib::M_filled), @@ -398,24 +398,24 @@ get_solid_viz_state() { } if (!do_is_tangible()) { - static CPT(RenderState) intangible_state = (const RenderState *)NULL; - if (intangible_state == (const RenderState *)NULL) { + static CPT(RenderState) intangible_state = nullptr; + if (intangible_state == nullptr) { intangible_state = base_state->add_attrib (ColorAttrib::make_flat(LColor(1.0f, 0.3, 0.5f, 0.5f))); } return intangible_state; } else if (do_has_effective_normal()) { - static CPT(RenderState) fakenormal_state = (const RenderState *)NULL; - if (fakenormal_state == (const RenderState *)NULL) { + static CPT(RenderState) fakenormal_state = nullptr; + if (fakenormal_state == nullptr) { fakenormal_state = base_state->add_attrib (ColorAttrib::make_flat(LColor(0.5f, 0.5f, 1.0f, 0.5f))); } return fakenormal_state; } else { - static CPT(RenderState) tangible_state = (const RenderState *)NULL; - if (tangible_state == (const RenderState *)NULL) { + static CPT(RenderState) tangible_state = nullptr; + if (tangible_state == nullptr) { tangible_state = base_state->add_attrib (ColorAttrib::make_flat(LColor(1.0f, 1.0f, 1.0f, 0.5f))); } @@ -435,8 +435,8 @@ CPT(RenderState) CollisionSolid:: get_wireframe_viz_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) base_state = (const RenderState *)NULL; - if (base_state == (const RenderState *)NULL) { + static CPT(RenderState) base_state = nullptr; + if (base_state == nullptr) { base_state = RenderState::make (CullFaceAttrib::make(CullFaceAttrib::M_cull_none), RenderModeAttrib::make(RenderModeAttrib::M_wireframe), @@ -444,24 +444,24 @@ get_wireframe_viz_state() { } if (!do_is_tangible()) { - static CPT(RenderState) intangible_state = (const RenderState *)NULL; - if (intangible_state == (const RenderState *)NULL) { + static CPT(RenderState) intangible_state = nullptr; + if (intangible_state == nullptr) { intangible_state = base_state->add_attrib (ColorAttrib::make_flat(LColor(1.0f, 1.0f, 0.0f, 1.0f))); } return intangible_state; } else if (do_has_effective_normal()) { - static CPT(RenderState) fakenormal_state = (const RenderState *)NULL; - if (fakenormal_state == (const RenderState *)NULL) { + static CPT(RenderState) fakenormal_state = nullptr; + if (fakenormal_state == nullptr) { fakenormal_state = base_state->add_attrib (ColorAttrib::make_flat(LColor(0.0f, 0.0f, 1.0f, 1.0f))); } return fakenormal_state; } else { - static CPT(RenderState) tangible_state = (const RenderState *)NULL; - if (tangible_state == (const RenderState *)NULL) { + static CPT(RenderState) tangible_state = nullptr; + if (tangible_state == nullptr) { tangible_state = base_state->add_attrib (ColorAttrib::make_flat(LColor(0.0f, 0.0f, 1.0f, 1.0f))); } @@ -480,8 +480,8 @@ CPT(RenderState) CollisionSolid:: get_other_viz_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) base_state = (const RenderState *)NULL; - if (base_state == (const RenderState *)NULL) { + static CPT(RenderState) base_state = nullptr; + if (base_state == nullptr) { base_state = RenderState::make (CullFaceAttrib::make(CullFaceAttrib::M_cull_clockwise), RenderModeAttrib::make(RenderModeAttrib::M_filled), @@ -504,8 +504,8 @@ CPT(RenderState) CollisionSolid:: get_solid_bounds_viz_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) base_state = (const RenderState *)NULL; - if (base_state == (const RenderState *)NULL) { + static CPT(RenderState) base_state = nullptr; + if (base_state == nullptr) { base_state = RenderState::make (CullFaceAttrib::make(CullFaceAttrib::M_cull_clockwise), RenderModeAttrib::make(RenderModeAttrib::M_filled), @@ -513,24 +513,24 @@ get_solid_bounds_viz_state() { } if (!do_is_tangible()) { - static CPT(RenderState) intangible_state = (const RenderState *)NULL; - if (intangible_state == (const RenderState *)NULL) { + static CPT(RenderState) intangible_state = nullptr; + if (intangible_state == nullptr) { intangible_state = base_state->add_attrib (ColorAttrib::make_flat(LColor(1.0f, 1.0f, 0.5f, 0.3))); } return intangible_state; } else if (do_has_effective_normal()) { - static CPT(RenderState) fakenormal_state = (const RenderState *)NULL; - if (fakenormal_state == (const RenderState *)NULL) { + static CPT(RenderState) fakenormal_state = nullptr; + if (fakenormal_state == nullptr) { fakenormal_state = base_state->add_attrib (ColorAttrib::make_flat(LColor(0.5f, 0.5f, 1.0f, 0.3))); } return fakenormal_state; } else { - static CPT(RenderState) tangible_state = (const RenderState *)NULL; - if (tangible_state == (const RenderState *)NULL) { + static CPT(RenderState) tangible_state = nullptr; + if (tangible_state == nullptr) { tangible_state = base_state->add_attrib (ColorAttrib::make_flat(LColor(1.0f, 1.0f, 0.5f, 0.3))); } @@ -550,8 +550,8 @@ CPT(RenderState) CollisionSolid:: get_wireframe_bounds_viz_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) base_state = (const RenderState *)NULL; - if (base_state == (const RenderState *)NULL) { + static CPT(RenderState) base_state = nullptr; + if (base_state == nullptr) { base_state = RenderState::make (CullFaceAttrib::make(CullFaceAttrib::M_cull_none), RenderModeAttrib::make(RenderModeAttrib::M_wireframe), @@ -573,8 +573,8 @@ CPT(RenderState) CollisionSolid:: get_other_bounds_viz_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) base_state = (const RenderState *)NULL; - if (base_state == (const RenderState *)NULL) { + static CPT(RenderState) base_state = nullptr; + if (base_state == nullptr) { base_state = RenderState::make (CullFaceAttrib::make(CullFaceAttrib::M_cull_clockwise), RenderModeAttrib::make(RenderModeAttrib::M_filled), diff --git a/panda/src/collide/collisionSphere.cxx b/panda/src/collide/collisionSphere.cxx index 139a39a4b1..898fbd86c6 100644 --- a/panda/src/collide/collisionSphere.cxx +++ b/panda/src/collide/collisionSphere.cxx @@ -120,7 +120,7 @@ compute_internal_bounds() const { PT(CollisionEntry) CollisionSphere:: test_intersection_from_sphere(const CollisionEntry &entry) const { const CollisionSphere *sphere; - DCAST_INTO_R(sphere, entry.get_from(), NULL); + DCAST_INTO_R(sphere, entry.get_from(), nullptr); CPT(TransformState) wrt_space = entry.get_wrt_space(); @@ -152,13 +152,13 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { LVector3 from_direction = from_b - from_a; if (!intersects_line(t1, t2, from_a, from_direction, from_radius)) { // No intersection. - return NULL; + return nullptr; } if (t2 < 0.0 || t1 > 1.0) { // Both intersection points are before the start of the segment or // after the end of the segment. - return NULL; + return nullptr; } // doubles, not floats, to satisfy min and max templates. @@ -176,7 +176,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { } } else { // No delta, therefore no intersection. - return NULL; + return nullptr; } } @@ -231,7 +231,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionSphere:: test_intersection_from_line(const CollisionEntry &entry) const { const CollisionLine *line; - DCAST_INTO_R(line, entry.get_from(), NULL); + DCAST_INTO_R(line, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -241,7 +241,7 @@ test_intersection_from_line(const CollisionEntry &entry) const { double t1, t2; if (!intersects_line(t1, t2, from_origin, from_direction, 0.0f)) { // No intersection. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -271,7 +271,7 @@ test_intersection_from_line(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionSphere:: test_intersection_from_box(const CollisionEntry &entry) const { const CollisionBox *box; - DCAST_INTO_R(box, entry.get_from(), NULL); + DCAST_INTO_R(box, entry.get_from(), nullptr); // Instead of transforming the box into the sphere's coordinate space, we do // it the other way around. It's easier that way. @@ -315,7 +315,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { } if (d > radius_sq) { - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -347,7 +347,7 @@ test_intersection_from_box(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionSphere:: test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; - DCAST_INTO_R(ray, entry.get_from(), NULL); + DCAST_INTO_R(ray, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -357,12 +357,12 @@ test_intersection_from_ray(const CollisionEntry &entry) const { double t1, t2; if (!intersects_line(t1, t2, from_origin, from_direction, 0.0f)) { // No intersection. - return NULL; + return nullptr; } if (t2 < 0.0) { // Both intersection points are before the start of the ray. - return NULL; + return nullptr; } t1 = max(t1, 0.0); @@ -394,7 +394,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionSphere:: test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *segment; - DCAST_INTO_R(segment, entry.get_from(), NULL); + DCAST_INTO_R(segment, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -405,13 +405,13 @@ test_intersection_from_segment(const CollisionEntry &entry) const { double t1, t2; if (!intersects_line(t1, t2, from_a, from_direction, 0.0f)) { // No intersection. - return NULL; + return nullptr; } if (t2 < 0.0 || t1 > 1.0) { // Both intersection points are before the start of the segment or after // the end of the segment. - return NULL; + return nullptr; } t1 = max(t1, 0.0); @@ -443,7 +443,7 @@ test_intersection_from_segment(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionSphere:: test_intersection_from_tube(const CollisionEntry &entry) const { const CollisionTube *tube; - DCAST_INTO_R(tube, entry.get_from(), NULL); + DCAST_INTO_R(tube, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -458,13 +458,13 @@ test_intersection_from_tube(const CollisionEntry &entry) const { double t1, t2; if (!intersects_line(t1, t2, from_a, from_direction, from_radius)) { // No intersection. - return NULL; + return nullptr; } if (t2 < 0.0 || t1 > 1.0) { // Both intersection points are before the start of the tube or after // the end of the tube. - return NULL; + return nullptr; } PN_stdfloat t = (t1 + t2) * (PN_stdfloat)0.5; @@ -499,7 +499,7 @@ test_intersection_from_tube(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionSphere:: test_intersection_from_parabola(const CollisionEntry &entry) const { const CollisionParabola *parabola; - DCAST_INTO_R(parabola, entry.get_from(), NULL); + DCAST_INTO_R(parabola, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -512,7 +512,7 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { local_p.calc_point(parabola->get_t1()), local_p.calc_point(parabola->get_t2()))) { // No intersection. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { diff --git a/panda/src/collide/collisionTraverser.I b/panda/src/collide/collisionTraverser.I index 4f35be0a9e..dee53e3a53 100644 --- a/panda/src/collide/collisionTraverser.I +++ b/panda/src/collide/collisionTraverser.I @@ -40,7 +40,7 @@ get_respect_prev_transform() const { */ INLINE bool CollisionTraverser:: has_recorder() const { - return _recorder != (CollisionRecorder *)NULL; + return _recorder != nullptr; } /** @@ -58,7 +58,7 @@ get_recorder() const { */ INLINE void CollisionTraverser:: clear_recorder() { - set_recorder((CollisionRecorder *)NULL); + set_recorder(nullptr); } #endif // DO_COLLISION_RECORDING diff --git a/panda/src/collide/collisionTraverser.cxx b/panda/src/collide/collisionTraverser.cxx index 27ec4a99c1..65f33cba31 100644 --- a/panda/src/collide/collisionTraverser.cxx +++ b/panda/src/collide/collisionTraverser.cxx @@ -73,7 +73,7 @@ CollisionTraverser(const string &name) : { _respect_prev_transform = respect_prev_transform; #ifdef DO_COLLISION_RECORDING - _recorder = (CollisionRecorder *)NULL; + _recorder = nullptr; #endif } @@ -100,7 +100,7 @@ void CollisionTraverser:: add_collider(const NodePath &collider, CollisionHandler *handler) { nassertv(_ordered_colliders.size() == _colliders.size()); nassertv(!collider.is_empty() && collider.node()->is_collision_node()); - nassertv(handler != (CollisionHandler *)NULL); + nassertv(handler != nullptr); Colliders::iterator ci = _colliders.find(collider); if (ci != _colliders.end()) { @@ -231,7 +231,7 @@ get_handler(const NodePath &collider) const { if (ci != _colliders.end()) { return (*ci).second; } - return NULL; + return nullptr; } /** @@ -370,20 +370,20 @@ void CollisionTraverser:: set_recorder(CollisionRecorder *recorder) { if (recorder != _recorder) { // Remove the old recorder, if any. - if (_recorder != (CollisionRecorder *)NULL) { + if (_recorder != nullptr) { nassertv(_recorder->_trav == this); - _recorder->_trav = (CollisionTraverser *)NULL; + _recorder->_trav = nullptr; } _recorder = recorder; // Tell the new recorder about his new owner. - if (_recorder != (CollisionRecorder *)NULL) { + if (_recorder != nullptr) { nassertv(_recorder->_trav != this); - if (_recorder->_trav != (CollisionTraverser *)NULL) { + if (_recorder->_trav != nullptr) { _recorder->_trav->clear_recorder(); } - nassertv(_recorder->_trav == (CollisionTraverser *)NULL); + nassertv(_recorder->_trav == nullptr); _recorder->_trav = this; } } @@ -447,7 +447,7 @@ write(ostream &out, int indent_level) const { nassertv(ci != _colliders.end()); CollisionHandler *handler = (*ci).second; - nassertv(handler != (CollisionHandler *)NULL); + nassertv(handler != nullptr); indent(out, indent_level + 2) << cnode_path; @@ -561,7 +561,7 @@ r_traverse_single(CollisionLevelStateSingle &level_state, size_t pass) { CollisionNode *cnode; DCAST_INTO_V(cnode, node); CPT(BoundingVolume) node_bv = cnode->get_bounds(); - const GeometricBoundingVolume *node_gbv = NULL; + const GeometricBoundingVolume *node_gbv = nullptr; if (node_bv->is_of_type(GeometricBoundingVolume::get_class_type())) { DCAST_INTO_V(node_gbv, node_bv); } @@ -606,7 +606,7 @@ r_traverse_single(CollisionLevelStateSingle &level_state, size_t pass) { GeomNode *gnode; DCAST_INTO_V(gnode, node); CPT(BoundingVolume) node_bv = gnode->get_bounds(); - const GeometricBoundingVolume *node_gbv = NULL; + const GeometricBoundingVolume *node_gbv = nullptr; if (node_bv->is_of_type(GeometricBoundingVolume::get_class_type())) { DCAST_INTO_V(node_gbv, node_bv); } @@ -772,7 +772,7 @@ r_traverse_double(CollisionLevelStateDouble &level_state, size_t pass) { CollisionNode *cnode; DCAST_INTO_V(cnode, node); CPT(BoundingVolume) node_bv = cnode->get_bounds(); - const GeometricBoundingVolume *node_gbv = NULL; + const GeometricBoundingVolume *node_gbv = nullptr; if (node_bv->is_of_type(GeometricBoundingVolume::get_class_type())) { DCAST_INTO_V(node_gbv, node_bv); } @@ -817,7 +817,7 @@ r_traverse_double(CollisionLevelStateDouble &level_state, size_t pass) { GeomNode *gnode; DCAST_INTO_V(gnode, node); CPT(BoundingVolume) node_bv = gnode->get_bounds(); - const GeometricBoundingVolume *node_gbv = NULL; + const GeometricBoundingVolume *node_gbv = nullptr; if (node_bv->is_of_type(GeometricBoundingVolume::get_class_type())) { DCAST_INTO_V(node_gbv, node_bv); } @@ -983,7 +983,7 @@ r_traverse_quad(CollisionLevelStateQuad &level_state, size_t pass) { CollisionNode *cnode; DCAST_INTO_V(cnode, node); CPT(BoundingVolume) node_bv = cnode->get_bounds(); - const GeometricBoundingVolume *node_gbv = NULL; + const GeometricBoundingVolume *node_gbv = nullptr; if (node_bv->is_of_type(GeometricBoundingVolume::get_class_type())) { DCAST_INTO_V(node_gbv, node_bv); } @@ -1028,7 +1028,7 @@ r_traverse_quad(CollisionLevelStateQuad &level_state, size_t pass) { GeomNode *gnode; DCAST_INTO_V(gnode, node); CPT(BoundingVolume) node_bv = gnode->get_bounds(); - const GeometricBoundingVolume *node_gbv = NULL; + const GeometricBoundingVolume *node_gbv = nullptr; if (node_bv->is_of_type(GeometricBoundingVolume::get_class_type())) { DCAST_INTO_V(node_gbv, node_bv); } @@ -1110,8 +1110,8 @@ compare_collider_to_node(CollisionEntry &entry, const GeometricBoundingVolume *from_node_gbv, const GeometricBoundingVolume *into_node_gbv) { bool within_node_bounds = true; - if (from_parent_gbv != (GeometricBoundingVolume *)NULL && - into_node_gbv != (GeometricBoundingVolume *)NULL) { + if (from_parent_gbv != nullptr && + into_node_gbv != nullptr) { within_node_bounds = (into_node_gbv->contains(from_parent_gbv) != 0); _cnode_volume_pcollector.add_level(1); } @@ -1169,8 +1169,8 @@ compare_collider_to_geom_node(CollisionEntry &entry, const GeometricBoundingVolume *from_node_gbv, const GeometricBoundingVolume *into_node_gbv) { bool within_node_bounds = true; - if (from_parent_gbv != (GeometricBoundingVolume *)NULL && - into_node_gbv != (GeometricBoundingVolume *)NULL) { + if (from_parent_gbv != nullptr && + into_node_gbv != nullptr) { within_node_bounds = (into_node_gbv->contains(from_parent_gbv) != 0); _gnode_volume_pcollector.add_level(1); } @@ -1180,11 +1180,11 @@ compare_collider_to_geom_node(CollisionEntry &entry, DCAST_INTO_V(gnode, entry._into_node); int num_geoms = gnode->get_num_geoms(); for (int s = 0; s < num_geoms; ++s) { - entry._into = (CollisionSolid *)NULL; + entry._into = nullptr; const Geom *geom = DCAST(Geom, gnode->get_geom(s)); - if (geom != (Geom *)NULL) { + if (geom != nullptr) { CPT(BoundingVolume) geom_bv = geom->get_bounds(); - const GeometricBoundingVolume *geom_gbv = NULL; + const GeometricBoundingVolume *geom_gbv = nullptr; if (num_geoms > 1 && geom_bv->is_of_type(GeometricBoundingVolume::get_class_type())) { // Only bother to test against each geom's bounding volume if we @@ -1209,8 +1209,8 @@ compare_collider_to_solid(CollisionEntry &entry, const GeometricBoundingVolume *from_node_gbv, const GeometricBoundingVolume *solid_gbv) { bool within_solid_bounds = true; - if (from_node_gbv != (GeometricBoundingVolume *)NULL && - solid_gbv != (GeometricBoundingVolume *)NULL) { + if (from_node_gbv != nullptr && + solid_gbv != nullptr) { within_solid_bounds = (solid_gbv->contains(from_node_gbv) != 0); #ifdef DO_PSTATS ((CollisionSolid *)entry.get_into())->get_volume_pcollector().add_level(1); @@ -1240,8 +1240,8 @@ compare_collider_to_geom(CollisionEntry &entry, const Geom *geom, const GeometricBoundingVolume *from_node_gbv, const GeometricBoundingVolume *geom_gbv) { bool within_geom_bounds = true; - if (from_node_gbv != (GeometricBoundingVolume *)NULL && - geom_gbv != (GeometricBoundingVolume *)NULL) { + if (from_node_gbv != nullptr && + geom_gbv != nullptr) { within_geom_bounds = (geom_gbv->contains(from_node_gbv) != 0); _geom_volume_pcollector.add_level(1); } @@ -1278,7 +1278,7 @@ compare_collider_to_geom(CollisionEntry &entry, const Geom *geom, // in the Geom. if (CollisionPolygon::verify_points(v[0], v[1], v[2])) { bool within_solid_bounds = true; - if (from_node_gbv != (GeometricBoundingVolume *)NULL) { + if (from_node_gbv != nullptr) { PT(BoundingSphere) sphere = new BoundingSphere; sphere->around(v, v + 3); within_solid_bounds = (sphere->contains(from_node_gbv) != 0); @@ -1308,7 +1308,7 @@ compare_collider_to_geom(CollisionEntry &entry, const Geom *geom, // in the Geom. if (CollisionPolygon::verify_points(v[0], v[1], v[2])) { bool within_solid_bounds = true; - if (from_node_gbv != (GeometricBoundingVolume *)NULL) { + if (from_node_gbv != nullptr) { PT(BoundingSphere) sphere = new BoundingSphere; sphere->around(v, v + 3); within_solid_bounds = (sphere->contains(from_node_gbv) != 0); diff --git a/panda/src/collide/collisionTube.cxx b/panda/src/collide/collisionTube.cxx index 8e3b188aab..b84e308395 100644 --- a/panda/src/collide/collisionTube.cxx +++ b/panda/src/collide/collisionTube.cxx @@ -146,7 +146,7 @@ compute_internal_bounds() const { PT(CollisionEntry) CollisionTube:: test_intersection_from_sphere(const CollisionEntry &entry) const { const CollisionSphere *sphere; - DCAST_INTO_R(sphere, entry.get_from(), NULL); + DCAST_INTO_R(sphere, entry.get_from(), nullptr); CPT(TransformState) wrt_space = entry.get_wrt_space(); CPT(TransformState) wrt_prev_space = entry.get_wrt_prev_space(); @@ -173,13 +173,13 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { double t1, t2; if (!intersects_line(t1, t2, from_a, from_direction, from_radius)) { // No intersection. - return NULL; + return nullptr; } if (t2 < 0.0 || t1 > 1.0) { // Both intersection points are before the start of the segment or after // the end of the segment. - return NULL; + return nullptr; } // doubles, not floats, to satisfy min and max templates. @@ -224,7 +224,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionTube:: test_intersection_from_line(const CollisionEntry &entry) const { const CollisionLine *line; - DCAST_INTO_R(line, entry.get_from(), NULL); + DCAST_INTO_R(line, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -234,7 +234,7 @@ test_intersection_from_line(const CollisionEntry &entry) const { double t1, t2; if (!intersects_line(t1, t2, from_origin, from_direction, 0.0f)) { // No intersection. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -272,7 +272,7 @@ test_intersection_from_line(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionTube:: test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; - DCAST_INTO_R(ray, entry.get_from(), NULL); + DCAST_INTO_R(ray, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -282,12 +282,12 @@ test_intersection_from_ray(const CollisionEntry &entry) const { double t1, t2; if (!intersects_line(t1, t2, from_origin, from_direction, 0.0f)) { // No intersection. - return NULL; + return nullptr; } if (t2 < 0.0) { // Both intersection points are before the start of the ray. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -333,7 +333,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionTube:: test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *segment; - DCAST_INTO_R(segment, entry.get_from(), NULL); + DCAST_INTO_R(segment, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -344,13 +344,13 @@ test_intersection_from_segment(const CollisionEntry &entry) const { double t1, t2; if (!intersects_line(t1, t2, from_a, from_direction, 0.0f)) { // No intersection. - return NULL; + return nullptr; } if (t2 < 0.0 || t1 > 1.0) { // Both intersection points are before the start of the segment or after // the end of the segment. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { @@ -397,7 +397,7 @@ test_intersection_from_segment(const CollisionEntry &entry) const { PT(CollisionEntry) CollisionTube:: test_intersection_from_parabola(const CollisionEntry &entry) const { const CollisionParabola *parabola; - DCAST_INTO_R(parabola, entry.get_from(), NULL); + DCAST_INTO_R(parabola, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); @@ -410,7 +410,7 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { local_p.calc_point(parabola->get_t1()), local_p.calc_point(parabola->get_t2()))) { // No intersection. - return NULL; + return nullptr; } if (collide_cat.is_debug()) { diff --git a/panda/src/collide/collisionVisualizer.cxx b/panda/src/collide/collisionVisualizer.cxx index 204a39b6bd..0c7861b5eb 100644 --- a/panda/src/collide/collisionVisualizer.cxx +++ b/panda/src/collide/collisionVisualizer.cxx @@ -144,7 +144,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { const SolidInfo &solid_info = (*si).second; bool was_detected = (solid_info._detected_count > 0); PT(PandaNode) node = solid->get_viz(trav, xform_data, !was_detected); - if (node != (PandaNode *)NULL) { + if (node != nullptr) { CullTraverserData next_data(xform_data, node); // We don't want to inherit the render state from above for these @@ -321,8 +321,8 @@ CPT(RenderState) CollisionVisualizer:: get_viz_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) state = (const RenderState *)NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make (DepthOffsetAttrib::make()); } diff --git a/panda/src/cull/cullBinBackToFront.cxx b/panda/src/cull/cullBinBackToFront.cxx index a1a7264af0..99da6cf5ac 100644 --- a/panda/src/cull/cullBinBackToFront.cxx +++ b/panda/src/cull/cullBinBackToFront.cxx @@ -57,10 +57,10 @@ add_object(CullableObject *object, Thread *current_thread) { } const GeometricBoundingVolume *gbv = volume->as_geometric_bounding_volume(); - nassertv(gbv != NULL); + nassertv(gbv != nullptr); LPoint3 center = gbv->get_approx_center(); - nassertv(object->_internal_transform != (const TransformState *)NULL); + nassertv(object->_internal_transform != nullptr); center = center * object->_internal_transform->get_mat(); PN_stdfloat distance = _gsg->compute_distance_to(center); diff --git a/panda/src/cull/cullBinFrontToBack.cxx b/panda/src/cull/cullBinFrontToBack.cxx index 0fb05a68b5..4d297d1c94 100644 --- a/panda/src/cull/cullBinFrontToBack.cxx +++ b/panda/src/cull/cullBinFrontToBack.cxx @@ -57,10 +57,10 @@ add_object(CullableObject *object, Thread *current_thread) { } const GeometricBoundingVolume *gbv = volume->as_geometric_bounding_volume(); - nassertv(gbv != NULL); + nassertv(gbv != nullptr); LPoint3 center = gbv->get_approx_center(); - nassertv(object->_internal_transform != (const TransformState *)NULL); + nassertv(object->_internal_transform != nullptr); center = center * object->_internal_transform->get_mat(); PN_stdfloat distance = _gsg->compute_distance_to(center); diff --git a/panda/src/cull/cullBinStateSorted.I b/panda/src/cull/cullBinStateSorted.I index e035c433bb..1bdb99112f 100644 --- a/panda/src/cull/cullBinStateSorted.I +++ b/panda/src/cull/cullBinStateSorted.I @@ -29,8 +29,8 @@ INLINE CullBinStateSorted::ObjectData:: ObjectData(CullableObject *object) : _object(object) { - if (object->_munged_data == NULL) { - _format = NULL; + if (object->_munged_data == nullptr) { + _format = nullptr; } else { _format = object->_munged_data->get_format(); } diff --git a/panda/src/device/analogNode.I b/panda/src/device/analogNode.I index ec41944491..f02b638603 100644 --- a/panda/src/device/analogNode.I +++ b/panda/src/device/analogNode.I @@ -26,7 +26,7 @@ OutputData() { */ INLINE bool AnalogNode:: is_valid() const { - return (_analog != (ClientAnalogDevice *)NULL) && _analog->is_connected(); + return (_analog != nullptr) && _analog->is_connected(); } /** diff --git a/panda/src/device/analogNode.cxx b/panda/src/device/analogNode.cxx index d577496554..4f331c7bae 100644 --- a/panda/src/device/analogNode.cxx +++ b/panda/src/device/analogNode.cxx @@ -29,11 +29,11 @@ AnalogNode(ClientBase *client, const string &device_name) : _xy_output = define_output("xy", EventStoreVec2::get_class_type()); _xy = new EventStoreVec2(LPoint2(0.0f, 0.0f)); - nassertv(client != (ClientBase *)NULL); + nassertv(client != nullptr); PT(ClientDevice) device = client->get_device(ClientAnalogDevice::get_class_type(), device_name); - if (device == (ClientDevice *)NULL) { + if (device == nullptr) { device_cat.warning() << "Unable to open analog device " << device_name << "\n"; return; @@ -66,7 +66,7 @@ void AnalogNode:: write(ostream &out, int indent_level) const { DataNode::write(out, indent_level); - if (_analog != (ClientAnalogDevice *)NULL) { + if (_analog != nullptr) { _analog->acquire(); _analog->write_controls(out, indent_level + 2); _analog->unlock(); diff --git a/panda/src/device/buttonNode.I b/panda/src/device/buttonNode.I index 1fa5efd21b..c4ccc2c610 100644 --- a/panda/src/device/buttonNode.I +++ b/panda/src/device/buttonNode.I @@ -17,7 +17,7 @@ */ INLINE bool ButtonNode:: is_valid() const { - return (_button != (ClientButtonDevice *)NULL) && _button->is_connected(); + return (_button != nullptr) && _button->is_connected(); } /** diff --git a/panda/src/device/buttonNode.cxx b/panda/src/device/buttonNode.cxx index e3125a2db3..e2bb18eeee 100644 --- a/panda/src/device/buttonNode.cxx +++ b/panda/src/device/buttonNode.cxx @@ -29,11 +29,11 @@ ButtonNode(ClientBase *client, const string &device_name) : _button_events_output = define_output("button_events", ButtonEventList::get_class_type()); _button_events = new ButtonEventList; - nassertv(client != (ClientBase *)NULL); + nassertv(client != nullptr); PT(ClientDevice) device = client->get_device(ClientButtonDevice::get_class_type(), device_name); - if (device == (ClientDevice *)NULL) { + if (device == nullptr) { device_cat.warning() << "Unable to open button device " << device_name << "\n"; return; @@ -66,7 +66,7 @@ void ButtonNode:: output(ostream &out) const { DataNode::output(out); - if (_button != (ClientButtonDevice *)NULL) { + if (_button != nullptr) { out << " ("; _button->acquire(); _button->output_buttons(out); @@ -82,7 +82,7 @@ void ButtonNode:: write(ostream &out, int indent_level) const { DataNode::write(out, indent_level); - if (_button != (ClientButtonDevice *)NULL) { + if (_button != nullptr) { _button->acquire(); _button->write_buttons(out, indent_level + 2); _button->unlock(); diff --git a/panda/src/device/clientBase.cxx b/panda/src/device/clientBase.cxx index 8a061ce5f5..2ad270b81b 100644 --- a/panda/src/device/clientBase.cxx +++ b/panda/src/device/clientBase.cxx @@ -27,7 +27,7 @@ ClientBase() { _cs = CS_default; #ifdef OLD_HAVE_IPC - _client_thread = (thread *)NULL; + _client_thread = nullptr; _shutdown = false; #endif } @@ -126,7 +126,7 @@ get_device(TypeHandle device_type, const string &device_name) { // We need to create a new device for this name. PT(ClientDevice) device = make_device(device_type, device_name); - if (device != (ClientDevice *)NULL) { + if (device != nullptr) { dbn.insert(DevicesByName::value_type(device_name, device)); device->_is_connected = true; } @@ -185,9 +185,9 @@ do_poll() { */ void *ClientBase:: st_callback(void *arg) { - nassertr(arg != NULL, NULL); + nassertr(arg != nullptr, nullptr); ((ClientBase *)arg)->callback(); - return NULL; + return nullptr; } /** diff --git a/panda/src/device/dialNode.I b/panda/src/device/dialNode.I index c342eba997..1f6abdbc64 100644 --- a/panda/src/device/dialNode.I +++ b/panda/src/device/dialNode.I @@ -17,7 +17,7 @@ */ INLINE bool DialNode:: is_valid() const { - return (_dial != (ClientDialDevice *)NULL) && _dial->is_connected(); + return (_dial != nullptr) && _dial->is_connected(); } /** diff --git a/panda/src/device/dialNode.cxx b/panda/src/device/dialNode.cxx index b86305ac00..86fa011908 100644 --- a/panda/src/device/dialNode.cxx +++ b/panda/src/device/dialNode.cxx @@ -25,11 +25,11 @@ DialNode:: DialNode(ClientBase *client, const string &device_name) : DataNode(device_name) { - nassertv(client != (ClientBase *)NULL); + nassertv(client != nullptr); PT(ClientDevice) device = client->get_device(ClientDialDevice::get_class_type(), device_name); - if (device == (ClientDevice *)NULL) { + if (device == nullptr) { device_cat.warning() << "Unable to open dial device " << device_name << "\n"; return; diff --git a/panda/src/device/trackerNode.I b/panda/src/device/trackerNode.I index 75d91d1d82..99929d4af2 100644 --- a/panda/src/device/trackerNode.I +++ b/panda/src/device/trackerNode.I @@ -17,7 +17,7 @@ */ INLINE bool TrackerNode:: is_valid() const { - return (_tracker != (ClientTrackerDevice *)NULL) && _tracker->is_connected(); + return (_tracker != nullptr) && _tracker->is_connected(); } diff --git a/panda/src/device/trackerNode.cxx b/panda/src/device/trackerNode.cxx index e4c9356b13..cf4a8d0f01 100644 --- a/panda/src/device/trackerNode.cxx +++ b/panda/src/device/trackerNode.cxx @@ -28,14 +28,14 @@ TrackerNode(ClientBase *client, const string &device_name) : _transform = TransformState::make_identity(); - nassertv(client != (ClientBase *)NULL); + nassertv(client != nullptr); set_tracker_coordinate_system(client->get_coordinate_system()); set_graph_coordinate_system(CS_default); PT(ClientDevice) device = client->get_device(ClientTrackerDevice::get_class_type(), device_name); - if (device == (ClientDevice *)NULL) { + if (device == nullptr) { device_cat.warning() << "Unable to open tracker device " << device_name << "\n"; return; @@ -63,9 +63,9 @@ TrackerNode(ClientTrackerDevice *device) : _transform = TransformState::make_identity(); - nassertv(device != (ClientTrackerDevice *)NULL); + nassertv(device != nullptr); ClientBase *client = device->get_client(); - nassertv(client != (ClientBase *)NULL); + nassertv(client != nullptr); set_tracker_coordinate_system(client->get_coordinate_system()); set_graph_coordinate_system(CS_default); } diff --git a/panda/src/dgraph/dataGraphTraverser.cxx b/panda/src/dgraph/dataGraphTraverser.cxx index 3b3900d8ea..d0f695bc50 100644 --- a/panda/src/dgraph/dataGraphTraverser.cxx +++ b/panda/src/dgraph/dataGraphTraverser.cxx @@ -58,7 +58,7 @@ traverse(PandaNode *node) { // We must start the traversal at the root of the graph. nassertv(data_node->get_num_parents(_current_thread) == 0); - r_transmit(data_node, (DataNodeTransmit *)NULL); + r_transmit(data_node, nullptr); } else { traverse_below(node, DataNodeTransmit()); diff --git a/panda/src/display/callbackGraphicsWindow.I b/panda/src/display/callbackGraphicsWindow.I index 1a1f104a36..3a05f82fdd 100644 --- a/panda/src/display/callbackGraphicsWindow.I +++ b/panda/src/display/callbackGraphicsWindow.I @@ -32,7 +32,7 @@ set_events_callback(CallbackObject *object) { */ INLINE void CallbackGraphicsWindow:: clear_events_callback() { - set_events_callback(NULL); + set_events_callback(nullptr); } /** @@ -66,7 +66,7 @@ set_properties_callback(CallbackObject *object) { */ INLINE void CallbackGraphicsWindow:: clear_properties_callback() { - set_properties_callback(NULL); + set_properties_callback(nullptr); } /** @@ -96,7 +96,7 @@ set_render_callback(CallbackObject *object) { */ INLINE void CallbackGraphicsWindow:: clear_render_callback() { - set_render_callback(NULL); + set_render_callback(nullptr); } /** diff --git a/panda/src/display/callbackGraphicsWindow.cxx b/panda/src/display/callbackGraphicsWindow.cxx index f9c2362ed7..7774b149c2 100644 --- a/panda/src/display/callbackGraphicsWindow.cxx +++ b/panda/src/display/callbackGraphicsWindow.cxx @@ -29,7 +29,7 @@ CallbackGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const WindowProperties &win_prop, int flags, GraphicsStateGuardian *gsg) : - GraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, NULL) + GraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, nullptr) { #ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, this); @@ -80,7 +80,7 @@ create_input_device(const string &name) { bool CallbackGraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { bool result = false; - if (_render_callback != NULL) { + if (_render_callback != nullptr) { RenderCallbackData data(this, RCT_begin_frame, mode); _render_callback->do_callback(&data); result = data.get_render_flag(); @@ -105,7 +105,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { */ void CallbackGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { - if (_render_callback != NULL) { + if (_render_callback != nullptr) { // In case the callback or the application hosting the OpenGL context // wants to do more rendering, let's give it a blank slate. _gsg->set_state_and_transform(RenderState::make_empty(), _gsg->get_internal_transform()); @@ -138,7 +138,7 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void CallbackGraphicsWindow:: begin_flip() { - if (_render_callback != NULL) { + if (_render_callback != nullptr) { RenderCallbackData data(this, RCT_begin_flip, FM_render); _render_callback->do_callback(&data); } else { @@ -155,7 +155,7 @@ begin_flip() { */ void CallbackGraphicsWindow:: end_flip() { - if (_render_callback != NULL) { + if (_render_callback != nullptr) { RenderCallbackData data(this, RCT_end_flip, FM_render); _render_callback->do_callback(&data); } else { @@ -172,7 +172,7 @@ end_flip() { */ void CallbackGraphicsWindow:: process_events() { - if (_events_callback != NULL) { + if (_events_callback != nullptr) { EventsCallbackData data(this); _events_callback->do_callback(&data); } else { @@ -186,7 +186,7 @@ process_events() { */ void CallbackGraphicsWindow:: set_properties_now(WindowProperties &properties) { - if (_properties_callback != NULL) { + if (_properties_callback != nullptr) { PropertiesCallbackData data(this, properties); _properties_callback->do_callback(&data); } else { diff --git a/panda/src/display/displayInformation.cxx b/panda/src/display/displayInformation.cxx index d690544889..df1cec1420 100644 --- a/panda/src/display/displayInformation.cxx +++ b/panda/src/display/displayInformation.cxx @@ -64,7 +64,7 @@ output(ostream &out) const { */ DisplayInformation:: ~DisplayInformation() { - if (_display_mode_array != NULL) { + if (_display_mode_array != nullptr) { delete[] _display_mode_array; } } @@ -94,7 +94,7 @@ DisplayInformation() { window_height = 0; window_bits_per_pixel = 0; total_display_modes = 0; - display_mode_array = NULL; + display_mode_array = nullptr; video_memory = 0; texture_memory = 0; physical_memory = 0; @@ -148,8 +148,8 @@ DisplayInformation() { _num_cpu_cores = 0; _num_logical_cpus = 0; - _get_memory_information_function = 0; - _update_cpu_frequency_function = 0; + _get_memory_information_function = nullptr; + _update_cpu_frequency_function = nullptr; _os_version_major = -1; _os_version_minor = -1; diff --git a/panda/src/display/displayRegion.I b/panda/src/display/displayRegion.I index a1f55f5e7f..fa1c698c0a 100644 --- a/panda/src/display/displayRegion.I +++ b/panda/src/display/displayRegion.I @@ -306,7 +306,7 @@ set_cull_callback(CallbackObject *object) { */ INLINE void DisplayRegion:: clear_cull_callback() { - set_cull_callback(NULL); + set_cull_callback(nullptr); } /** @@ -354,7 +354,7 @@ set_draw_callback(CallbackObject *object) { */ INLINE void DisplayRegion:: clear_draw_callback() { - set_draw_callback(NULL); + set_draw_callback(nullptr); } /** @@ -581,8 +581,8 @@ INLINE DisplayRegionPipelineReader:: _object->_cycler.release_read(_cdata); #ifdef _DEBUG - _object = NULL; - _cdata = NULL; + _object = nullptr; + _cdata = nullptr; #endif // _DEBUG } diff --git a/panda/src/display/displayRegion.cxx b/panda/src/display/displayRegion.cxx index a84a8728e8..b1d99df839 100644 --- a/panda/src/display/displayRegion.cxx +++ b/panda/src/display/displayRegion.cxx @@ -56,7 +56,7 @@ DisplayRegion:: // The window pointer should already have been cleared by the time the // DisplayRegion destructs (since the GraphicsOutput class keeps a reference // count on the DisplayRegion). - nassertv(_window == (GraphicsOutput *)NULL); + nassertv(_window == nullptr); } /** @@ -107,7 +107,7 @@ set_dimensions(int i, const LVecBase4 &dimensions) { cdata->_regions[i]._dimensions = dimensions; - if (_window != (GraphicsOutput *)NULL && _window->has_size()) { + if (_window != nullptr && _window->has_size()) { do_compute_pixels(i, _window->get_fb_x_size(), _window->get_fb_y_size(), cdata); } } @@ -118,7 +118,7 @@ set_dimensions(int i, const LVecBase4 &dimensions) { */ GraphicsPipe *DisplayRegion:: get_pipe() const { - return (_window != (GraphicsOutput *)NULL) ? _window->get_pipe() : NULL; + return (_window != nullptr) ? _window->get_pipe() : nullptr; } /** @@ -144,7 +144,7 @@ void DisplayRegion:: set_camera(const NodePath &camera) { CDWriter cdata(_cycler, true); - Camera *camera_node = (Camera *)NULL; + Camera *camera_node = nullptr; if (!camera.is_empty()) { DCAST_INTO_V(camera_node, camera.node()); } @@ -153,12 +153,12 @@ set_camera(const NodePath &camera) { // Note that these operations on the DisplayRegion are not pipelined: they // operate across all pipeline stages. Since we have already asserted we // are running in pipeline stage 0, no problem. - if (cdata->_camera_node != (Camera *)NULL) { + if (cdata->_camera_node != nullptr) { // We need to tell the old camera we're not using him anymore. cdata->_camera_node->remove_display_region(this); } cdata->_camera_node = camera_node; - if (cdata->_camera_node != (Camera *)NULL) { + if (cdata->_camera_node != nullptr) { // Now tell the new camera we are using him. cdata->_camera_node->add_display_region(this); } @@ -307,7 +307,7 @@ set_cull_traverser(CullTraverser *trav) { */ CullTraverser *DisplayRegion:: get_cull_traverser() { - if (_trav == (CullTraverser *)NULL) { + if (_trav == nullptr) { _trav = new CullTraverser; } return _trav; @@ -356,7 +356,7 @@ output(ostream &out) const { */ Filename DisplayRegion:: make_screenshot_filename(const string &prefix) { - time_t now = time(NULL); + time_t now = time(nullptr); struct tm *ttm = localtime(&now); int frame_count = ClockObject::get_global_clock()->get_frame_count(); @@ -456,7 +456,7 @@ bool DisplayRegion:: get_screenshot(PNMImage &image) { PT(Texture) tex = get_screenshot(); - if (tex == NULL) { + if (tex == nullptr) { return false; } @@ -476,13 +476,13 @@ get_screenshot() { Thread *current_thread = Thread::get_current_thread(); GraphicsOutput *window = get_window(); - nassertr(window != (GraphicsOutput *)NULL, NULL); + nassertr(window != nullptr, nullptr); GraphicsStateGuardian *gsg = window->get_gsg(); - nassertr(gsg != (GraphicsStateGuardian *)NULL, NULL); + nassertr(gsg != nullptr, nullptr); if (!window->begin_frame(GraphicsOutput::FM_refresh, current_thread)) { - return NULL; + return nullptr; } { @@ -496,7 +496,7 @@ get_screenshot() { RenderBuffer buffer = gsg->get_render_buffer(get_screenshot_buffer_type(), _window->get_fb_properties()); if (!gsg->framebuffer_copy_to_ram(tex, 0, -1, this, buffer)) { - return NULL; + return nullptr; } window->end_frame(GraphicsOutput::FM_refresh, current_thread); @@ -522,8 +522,8 @@ get_screenshot() { PT(PandaNode) DisplayRegion:: make_cull_result_graph() { CullResult *cull_result = get_cull_result(Thread::get_current_thread()); - if (cull_result == (CullResult *)NULL) { - return NULL; + if (cull_result == nullptr) { + return nullptr; } return cull_result->make_result_graph(); } @@ -534,7 +534,7 @@ make_cull_result_graph() { */ void DisplayRegion:: compute_pixels() { - if (_window != (GraphicsOutput *)NULL) { + if (_window != nullptr) { CDWriter cdata(_cycler, false); for (size_t i = 0; i < cdata->_regions.size(); ++i) { do_compute_pixels(i, _window->get_fb_x_size(), _window->get_fb_y_size(), @@ -549,7 +549,7 @@ compute_pixels() { */ void DisplayRegion:: compute_pixels_all_stages() { - if (_window != (GraphicsOutput *)NULL) { + if (_window != nullptr) { OPEN_ITERATE_ALL_STAGES(_cycler) { CDStageWriter cdata(_cycler, pipeline_stage); for (size_t i = 0; i < cdata->_regions.size(); ++i) { @@ -602,7 +602,7 @@ compute_pixels_all_stages(int x_size, int y_size) { */ bool DisplayRegion:: supports_pixel_zoom() const { - if (_window != (GraphicsOutput *)NULL) { + if (_window != nullptr) { if (_window->supports_pixel_zoom()) { return get_clear_color_active() && get_clear_depth_active(); } @@ -617,7 +617,7 @@ supports_pixel_zoom() const { */ void DisplayRegion:: win_display_regions_changed() { - if (_window != (GraphicsOutput *)NULL) { + if (_window != nullptr) { _window->win_display_regions_changed(); } } @@ -640,7 +640,7 @@ do_compute_pixels(int i, int x_size, int y_size, CData *cdata) { region._pixels_i[0] = region._pixels[0]; region._pixels_i[1] = region._pixels[1]; - nassertv(_window != (GraphicsOutput *)NULL); + nassertv(_window != nullptr); if (_window->get_inverted()) { // The window is inverted; compute the DisplayRegion accordingly. region._pixels[2] = int(((1.0f - region._dimensions[3]) * y_size) + 0.5); @@ -694,7 +694,7 @@ do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, DisplayRegion::CData:: CData() : _lens_index(0), - _camera_node((Camera *)NULL), + _camera_node(nullptr), _active(true), _sort(0), _stereo_channel(Lens::SC_mono), @@ -745,5 +745,5 @@ make_copy() const { */ GraphicsPipe *DisplayRegionPipelineReader:: get_pipe() const { - return (_object->_window != (GraphicsOutput *)NULL) ? _object->_window->get_pipe() : NULL; + return (_object->_window != nullptr) ? _object->_window->get_pipe() : nullptr; } diff --git a/panda/src/display/displayRegionDrawCallbackData.cxx b/panda/src/display/displayRegionDrawCallbackData.cxx index e0ecfcbffb..194aa6bbef 100644 --- a/panda/src/display/displayRegionDrawCallbackData.cxx +++ b/panda/src/display/displayRegionDrawCallbackData.cxx @@ -57,7 +57,7 @@ upcall() { DisplayRegion *dr = _scene_setup->get_display_region(); GraphicsStateGuardian *gsg = dr->get_window()->get_gsg(); - if (_cull_result == NULL || _scene_setup == NULL) { + if (_cull_result == nullptr || _scene_setup == nullptr) { // Nothing to see here. } else if (dr->is_stereo()) { diff --git a/panda/src/display/graphicsEngine.I b/panda/src/display/graphicsEngine.I index eccf5cfee4..326d073a0c 100644 --- a/panda/src/display/graphicsEngine.I +++ b/panda/src/display/graphicsEngine.I @@ -144,7 +144,7 @@ make_buffer(GraphicsStateGuardian *gsg, const string &name, WindowProperties::size(x_size, y_size), GraphicsPipe::BF_refuse_window | GraphicsPipe::BF_fb_props_optional, - gsg, NULL); + gsg, nullptr); return result; } diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index e47597872e..b27eaa5c39 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -147,7 +147,7 @@ GraphicsEngine(Pipeline *pipeline) : _lock("GraphicsEngine::_lock"), _loaded_textures_lock("GraphicsEngine::_loaded_textures_lock") { - if (_pipeline == (Pipeline *)NULL) { + if (_pipeline == nullptr) { _pipeline = Pipeline::get_render_pipeline(); } @@ -288,7 +288,7 @@ make_output(GraphicsPipe *pipe, if ((x_size == 0)&&(y_size == 0)) { flags |= GraphicsPipe::BF_size_track_host; } - if (host != 0) { + if (host != nullptr) { host = host->get_host(); } @@ -296,28 +296,28 @@ make_output(GraphicsPipe *pipe, // call open_windows to get both ready. If that fails, give up on using the // supplied gsg and host. - if (host == (GraphicsOutput *)NULL) { - if (gsg != (GraphicsStateGuardian*)NULL) { + if (host == nullptr) { + if (gsg != nullptr) { if ((!gsg->is_valid())||(gsg->needs_reset())) { open_windows(); } if ((!gsg->is_valid())||(gsg->needs_reset())) { - gsg = NULL; + gsg = nullptr; } } } else { - if ((host->get_gsg()==0)|| + if ((host->get_gsg()==nullptr)|| (!host->is_valid())|| (!host->get_gsg()->is_valid())|| (host->get_gsg()->needs_reset())) { open_windows(); } - if ((host->get_gsg()==0)|| + if ((host->get_gsg()==nullptr)|| (!host->is_valid())|| (!host->get_gsg()->is_valid())|| (host->get_gsg()->needs_reset())) { - host = NULL; - gsg = NULL; + host = nullptr; + gsg = nullptr; } else { gsg = host->get_gsg(); } @@ -325,21 +325,21 @@ make_output(GraphicsPipe *pipe, // Sanity check everything. - nassertr(pipe != (GraphicsPipe *)NULL, NULL); - if (gsg != (GraphicsStateGuardian *)NULL) { - nassertr(pipe == gsg->get_pipe(), NULL); - nassertr(this == gsg->get_engine(), NULL); + nassertr(pipe != nullptr, nullptr); + if (gsg != nullptr) { + nassertr(pipe == gsg->get_pipe(), nullptr); + nassertr(this == gsg->get_engine(), nullptr); } // Are we really asking for a callback window? if ((flags & GraphicsPipe::BF_require_callback_window)!=0) { PT(GraphicsStateGuardian) this_gsg = gsg; - if (this_gsg == (GraphicsStateGuardian *)NULL) { + if (this_gsg == nullptr) { // If we don't already have a GSG, we have to ask the pipe to make a new // one, unencumbered by window dressing. this_gsg = pipe->make_callback_gsg(this); } - if (this_gsg != (GraphicsStateGuardian *)NULL) { + if (this_gsg != nullptr) { CallbackGraphicsWindow *window = new CallbackGraphicsWindow(this, pipe, name, fb_prop, win_prop, flags, this_gsg); window->_sort = sort; do_add_window(window); @@ -350,13 +350,13 @@ make_output(GraphicsPipe *pipe, // Couldn't make a callback window, because the pipe wouldn't make an // unencumbered GSG. - return NULL; + return nullptr; } // Determine if a parasite buffer meets the user's specs. bool can_use_parasite = false; - if ((host != 0)&& + if ((host != nullptr)&& ((flags&GraphicsPipe::BF_require_window)==0)&& ((flags&GraphicsPipe::BF_require_callback_window)==0)&& ((flags&GraphicsPipe::BF_refuse_parasite)==0)&& @@ -406,7 +406,7 @@ make_output(GraphicsPipe *pipe, bool precertify = false; PT(GraphicsOutput) window = pipe->make_output(name, fb_prop, win_prop, flags, this, gsg, host, retry, precertify); - if (window != (GraphicsOutput *)NULL) { + if (window != nullptr) { window->_sort = sort; if (precertify && gsg != nullptr && window->get_gsg() == gsg) { do_add_window(window); @@ -463,7 +463,7 @@ make_output(GraphicsPipe *pipe, // Could not create a window to the user's specs. - return NULL; + return nullptr; } /** @@ -511,7 +511,7 @@ add_window(GraphicsOutput *window, int sort) { */ bool GraphicsEngine:: remove_window(GraphicsOutput *window) { - nassertr(window != NULL, false); + nassertr(window != nullptr, false); Thread *current_thread = Thread::get_current_thread(); // First, make sure we know what this window is. @@ -543,9 +543,9 @@ remove_window(GraphicsOutput *window) { do_remove_window(window, current_thread); GraphicsStateGuardian *gsg = window->get_gsg(); - if (gsg != (GraphicsStateGuardian *)NULL) { + if (gsg != nullptr) { PreparedGraphicsObjects *pgo = gsg->get_prepared_objects(); - if (pgo != (PreparedGraphicsObjects *)NULL) { + if (pgo != nullptr) { // Check to see if any other still-active windows share this context. bool any_common = false; { @@ -553,7 +553,7 @@ remove_window(GraphicsOutput *window) { Windows::iterator wi; for (wi = _windows.begin(); wi != _windows.end() && !any_common; ++wi) { GraphicsStateGuardian *gsg2 = (*wi)->get_gsg(); - if (gsg2 != (GraphicsStateGuardian *)NULL && + if (gsg2 != nullptr && gsg2->get_prepared_objects() == pgo) { any_common = true; } @@ -593,10 +593,10 @@ remove_all_windows() { Windows::iterator wi; for (wi = old_windows.begin(); wi != old_windows.end(); ++wi) { GraphicsOutput *win = (*wi); - nassertv(win != NULL); + nassertv(win != nullptr); do_remove_window(win, current_thread); GraphicsStateGuardian *gsg = win->get_gsg(); - if (gsg != (GraphicsStateGuardian *)NULL) { + if (gsg != nullptr) { gsg->release_all(); } } @@ -669,7 +669,7 @@ get_num_windows() const { */ GraphicsOutput *GraphicsEngine:: get_window(int n) const { - nassertr(n >= 0 && n < (int)_windows.size(), NULL); + nassertr(n >= 0 && n < (int)_windows.size(), nullptr); if (!_windows_sorted) { ((GraphicsEngine *)this)->do_resort_windows(); @@ -730,7 +730,7 @@ render_frame() { Windows::iterator wi; for (wi = _windows.begin(); wi != _windows.end(); ++wi) { GraphicsOutput *win = (*wi); - nassertv(win != NULL); + nassertv(win != nullptr); if (win->get_delete_flag()) { do_remove_window(win, current_thread); @@ -745,7 +745,7 @@ render_frame() { int num_drs = win->get_num_active_display_regions(); for (int i = 0; i < num_drs; ++i) { DisplayRegion *dr = win->get_active_display_region(i); - if (dr != (DisplayRegion *)NULL) { + if (dr != nullptr) { NodePath camera_np = dr->get_camera(current_thread); if (!camera_np.is_empty()) { Camera *camera = DCAST(Camera, camera_np.node()); @@ -1165,7 +1165,7 @@ extract_texture_data(Texture *tex, GraphicsStateGuardian *gsg) { */ void GraphicsEngine:: dispatch_compute(const LVecBase3i &work_groups, const ShaderAttrib *sattr, GraphicsStateGuardian *gsg) { - nassertv(sattr->get_shader() != (Shader *)NULL); + nassertv(sattr->get_shader() != nullptr); nassertv(gsg != nullptr); ReMutexHolder holder(_lock); @@ -1219,7 +1219,7 @@ dispatch_compute(const LVecBase3i &work_groups, const ShaderAttrib *sattr, Graph */ GraphicsEngine *GraphicsEngine:: get_global_ptr() { - if (_global_ptr == NULL) { + if (_global_ptr == nullptr) { _global_ptr = new GraphicsEngine; PandaNode::set_scene_root_func(&scene_root_func); } @@ -1260,7 +1260,7 @@ do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, trav->set_cull_handler(cull_handler); trav->set_scene(scene_setup, gsg, dr->get_incomplete_render()); - trav->set_view_frustum(NULL); + trav->set_view_frustum(nullptr); if (view_frustum_cull) { // If we're to be performing view-frustum culling, determine the bounding // volume associated with the current viewing frustum. @@ -1269,8 +1269,8 @@ do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, // lens. PT(BoundingVolume) bv = scene_setup->get_cull_bounds(); - if (bv != (BoundingVolume *)NULL && !bv->is_infinite() && - bv->as_geometric_bounding_volume() != NULL) { + if (bv != nullptr && !bv->is_infinite() && + bv->as_geometric_bounding_volume() != nullptr) { // Transform it into the appropriate coordinate space. PT(GeometricBoundingVolume) local_frustum; local_frustum = bv->make_copy()->as_geometric_bounding_volume(); @@ -1314,7 +1314,7 @@ is_scene_root(const PandaNode *node) { int num_display_regions = win->get_num_active_display_regions(); for (int i = 0; i < num_display_regions; i++) { DisplayRegion *dr = win->get_active_display_region(i); - if (dr != (DisplayRegion *)NULL) { + if (dr != nullptr) { NodePath camera = dr->get_camera(); if (camera.is_empty()) { continue; @@ -1390,7 +1390,7 @@ cull_and_draw_together(GraphicsEngine::Windows wlist, int num_display_regions = win->get_num_active_display_regions(); for (int i = 0; i < num_display_regions; i++) { DisplayRegion *dr = win->get_active_display_region(i); - if (dr != (DisplayRegion *)NULL) { + if (dr != nullptr) { cull_and_draw_together(win, dr, current_thread); } } @@ -1420,7 +1420,7 @@ void GraphicsEngine:: cull_and_draw_together(GraphicsOutput *win, DisplayRegion *dr, Thread *current_thread) { GraphicsStateGuardian *gsg = win->get_gsg(); - nassertv(gsg != (GraphicsStateGuardian *)NULL); + nassertv(gsg != nullptr); PT(SceneSetup) scene_setup; @@ -1436,7 +1436,7 @@ cull_and_draw_together(GraphicsOutput *win, DisplayRegion *dr, scene_setup = setup_scene(gsg, &dr_reader); } - if (scene_setup == (SceneSetup *)NULL) { + if (scene_setup == nullptr) { // Never mind. } else if (dr->is_stereo()) { @@ -1451,7 +1451,7 @@ cull_and_draw_together(GraphicsOutput *win, DisplayRegion *dr, DrawCullHandler cull_handler(gsg); if (gsg->begin_scene()) { CallbackObject *cbobj = dr->get_cull_callback(); - if (cbobj != (CallbackObject *)NULL) { + if (cbobj != nullptr) { // Issue the cull callback on this DisplayRegion. DisplayRegionCullCallbackData cbdata(&cull_handler, scene_setup); cbobj->do_callback(&cbdata); @@ -1554,7 +1554,7 @@ cull_to_bins(GraphicsOutput *win, GraphicsStateGuardian *gsg, BinCullHandler cull_handler(cull_result); CallbackObject *cbobj = dr->get_cull_callback(); - if (cbobj != (CallbackObject *)NULL) { + if (cbobj != nullptr) { // Issue the cull callback on this DisplayRegion. DisplayRegionCullCallbackData cbdata(&cull_handler, scene_setup); cbobj->do_callback(&cbdata); @@ -1614,7 +1614,7 @@ draw_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) { int num_display_regions = win->get_num_active_display_regions(); for (int i = 0; i < num_display_regions; ++i) { DisplayRegion *dr = win->get_active_display_region(i); - if (dr != (DisplayRegion *)NULL) { + if (dr != nullptr) { do_draw(win, gsg, dr, current_thread); } } @@ -1847,28 +1847,28 @@ setup_scene(GraphicsStateGuardian *gsg, DisplayRegionPipelineReader *dr) { GraphicsOutput *window = dr->get_window(); // The window pointer shouldn't be NULL, since we presumably got to this // particular DisplayRegion by walking through a list on a window. - nassertr(window != (GraphicsOutput *)NULL, NULL); + nassertr(window != nullptr, nullptr); NodePath camera = dr->get_camera(); if (camera.is_empty()) { // No camera, no draw. - return NULL; + return nullptr; } Camera *camera_node; - DCAST_INTO_R(camera_node, camera.node(), NULL); + DCAST_INTO_R(camera_node, camera.node(), nullptr); if (!camera_node->is_active()) { // Camera inactive, no draw. - return NULL; + return nullptr; } camera_node->cleanup_aux_scene_data(current_thread); int lens_index = dr->get_lens_index(); Lens *lens = camera_node->get_lens(lens_index); - if (lens == (Lens *)NULL || !camera_node->get_lens_active(lens_index)) { + if (lens == nullptr || !camera_node->get_lens_active(lens_index)) { // No lens, no draw. - return NULL; + return nullptr; } NodePath scene_root = camera_node->get_scene(); @@ -1900,7 +1900,7 @@ setup_scene(GraphicsStateGuardian *gsg, DisplayRegionPipelineReader *dr) { << scene_root.get_scale(NodePath()) << "); cannot render.\n"; _singular_warning_this_frame = true; } - return NULL; + return nullptr; } if (world_transform->is_invalid()) { @@ -1911,7 +1911,7 @@ setup_scene(GraphicsStateGuardian *gsg, DisplayRegionPipelineReader *dr) { << camera.get_scale(NodePath()) << "); cannot render.\n"; } _singular_warning_this_frame = true; - return NULL; + return nullptr; } CPT(RenderState) initial_state = camera_node->get_initial_state(); @@ -1975,7 +1975,7 @@ do_draw(GraphicsOutput *win, GraphicsStateGuardian *gsg, DisplayRegion *dr, Thre cbobj = dr_reader.get_draw_callback(); } - if (cbobj != (CallbackObject *)NULL) { + if (cbobj != nullptr) { // Issue the draw callback on this DisplayRegion. // Set the GSG to the initial state. @@ -1992,7 +1992,7 @@ do_draw(GraphicsOutput *win, GraphicsStateGuardian *gsg, DisplayRegion *dr, Thre return; } - if (cull_result == NULL || scene_setup == NULL) { + if (cull_result == nullptr || scene_setup == nullptr) { // Nothing to see here. } else if (dr->is_stereo()) { @@ -2048,7 +2048,7 @@ do_add_window(GraphicsOutput *window) { */ void GraphicsEngine:: do_add_gsg(GraphicsStateGuardian *gsg, GraphicsPipe *pipe) { - nassertv(gsg != NULL); + nassertv(gsg != nullptr); ReMutexHolder holder(_lock); nassertv(gsg->get_pipe() == pipe && gsg->get_engine() == this); @@ -2073,7 +2073,7 @@ do_add_gsg(GraphicsStateGuardian *gsg, GraphicsPipe *pipe) { */ void GraphicsEngine:: do_remove_window(GraphicsOutput *window, Thread *current_thread) { - nassertv(window != NULL); + nassertv(window != nullptr); PT(GraphicsPipe) pipe = window->get_pipe(); window->clear_pipe(); @@ -2284,8 +2284,8 @@ const RenderState *GraphicsEngine:: get_invert_polygon_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) state = (const RenderState *)NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make(CullFaceAttrib::make_reverse()); } @@ -2302,7 +2302,7 @@ get_invert_polygon_state() { */ GraphicsEngine::WindowRenderer *GraphicsEngine:: get_window_renderer(const string &name, int pipeline_stage) { - nassertr(_lock.debug_is_locked(), NULL); + nassertr(_lock.debug_is_locked(), nullptr); if (name.empty()) { return &_app; @@ -2361,7 +2361,7 @@ add_window(Windows &wlist, GraphicsOutput *window) { */ void GraphicsEngine::WindowRenderer:: remove_window(GraphicsOutput *window) { - nassertv(window != NULL); + nassertv(window != nullptr); LightReMutexHolder holder(_wl_lock); PT(GraphicsOutput) ptwin = window; diff --git a/panda/src/display/graphicsEngine.h b/panda/src/display/graphicsEngine.h index c21bec1d73..867afdfb40 100644 --- a/panda/src/display/graphicsEngine.h +++ b/panda/src/display/graphicsEngine.h @@ -52,7 +52,7 @@ class Texture; */ class EXPCL_PANDA_DISPLAY GraphicsEngine : public ReferenceCount { PUBLISHED: - explicit GraphicsEngine(Pipeline *pipeline = NULL); + explicit GraphicsEngine(Pipeline *pipeline = nullptr); BLOCKING ~GraphicsEngine(); void set_threading_model(const GraphicsThreadingModel &threading_model); @@ -78,8 +78,8 @@ PUBLISHED: const string &name, int sort, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, - int flags, GraphicsStateGuardian *gsg = NULL, - GraphicsOutput *host = NULL); + int flags, GraphicsStateGuardian *gsg = nullptr, + GraphicsOutput *host = nullptr); // Syntactic shorthand versions of make_output INLINE GraphicsOutput *make_buffer(GraphicsOutput *host, diff --git a/panda/src/display/graphicsOutput.I b/panda/src/display/graphicsOutput.I index 393dbaadb5..bc0e866f7d 100644 --- a/panda/src/display/graphicsOutput.I +++ b/panda/src/display/graphicsOutput.I @@ -87,7 +87,7 @@ INLINE Texture *GraphicsOutput:: get_texture(int i) const { CDReader cdata(_cycler); if ((i < 0) || (i >= ((int)cdata->_textures.size()))) { - return (Texture *)NULL; + return nullptr; } return cdata->_textures[i]._texture; } @@ -734,7 +734,7 @@ end_frame_spam(FrameMode mode) { INLINE void GraphicsOutput:: clear_cube_map_selection() { _target_tex_page = -1; - _prev_page_dr = NULL; + _prev_page_dr = nullptr; } /** diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index 0583602189..1f3141e9fc 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -101,7 +101,7 @@ GraphicsOutput(GraphicsEngine *engine, GraphicsPipe *pipe, _is_valid = false; _flip_ready = false; _target_tex_page = -1; - _prev_page_dr = NULL; + _prev_page_dr = nullptr; _sort = 0; _child_sort = 0; _got_child_sort = false; @@ -168,7 +168,7 @@ GraphicsOutput:: nassertv(!is_valid()); // We shouldn't have a GraphicsPipe pointer anymore. - nassertv(_pipe == (GraphicsPipe *)NULL); + nassertv(_pipe == nullptr); // We don't have to destruct our child display regions explicitly, since // they are all reference-counted and will go away when their pointers do. @@ -177,11 +177,11 @@ GraphicsOutput:: for (dri = _total_display_regions.begin(); dri != _total_display_regions.end(); ++dri) { - (*dri)->_window = NULL; + (*dri)->_window = nullptr; } _total_display_regions.clear(); - _overlay_display_region = NULL; + _overlay_display_region = nullptr; } /** @@ -240,7 +240,7 @@ add_render_texture(Texture *tex, RenderTextureMode mode, LightMutexHolder holder(_lock); // Create texture if necessary. - if (tex == (Texture *)NULL) { + if (tex == nullptr) { tex = new Texture(get_name()); tex->set_wrap_u(SamplerState::WM_clamp); tex->set_wrap_v(SamplerState::WM_clamp); @@ -344,7 +344,7 @@ add_render_texture(Texture *tex, RenderTextureMode mode, } } - if (mode == RTM_bind_layered && _gsg != NULL && !_gsg->get_supports_geometry_shaders()) { + if (mode == RTM_bind_layered && _gsg != nullptr && !_gsg->get_supports_geometry_shaders()) { // Layered FBOs require a geometry shader to write to any but the first // layer. display_cat.warning() << @@ -555,8 +555,8 @@ get_delete_flag() const { void GraphicsOutput:: set_sort(int sort) { if (_sort != sort) { - if (_gsg != (GraphicsStateGuardian *)NULL && - _gsg->get_engine() != (GraphicsEngine *)NULL) { + if (_gsg != nullptr && + _gsg->get_engine() != nullptr) { _gsg->get_engine()->set_window_sort(this, sort); } } @@ -706,7 +706,7 @@ remove_all_display_regions() { if (display_region != _overlay_display_region) { // Let's aggressively clean up the display region too. display_region->cleanup(); - display_region->_window = NULL; + display_region->_window = nullptr; } } _total_display_regions.clear(); @@ -762,7 +762,7 @@ get_display_region(int n) const { if (n >= 0 && n < (int)_total_display_regions.size()) { result = _total_display_regions[n]; } else { - result = NULL; + result = nullptr; } } return result; @@ -793,7 +793,7 @@ get_active_display_region(int n) const { if (n >= 0 && n < (int)cdata->_active_display_regions.size()) { return cdata->_active_display_regions[n]; } - return NULL; + return nullptr; } /** @@ -830,7 +830,7 @@ make_texture_buffer(const string &name, int x_size, int y_size, props.set_alpha_bits(1); props.set_depth_bits(1); - if (fbp == NULL) { + if (fbp == nullptr) { fbp = &props; } @@ -838,7 +838,7 @@ make_texture_buffer(const string &name, int x_size, int y_size, if (textures_power_2 != ATS_none) { flags |= GraphicsPipe::BF_size_power_2; } - if (tex != (Texture *)NULL && + if (tex != nullptr && tex->get_texture_type() == Texture::TT_cube_map) { flags |= GraphicsPipe::BF_size_square; } @@ -849,8 +849,8 @@ make_texture_buffer(const string &name, int x_size, int y_size, *fbp, WindowProperties::size(x_size, y_size), flags, get_gsg(), get_host()); - if (buffer != (GraphicsOutput *)NULL) { - if (buffer->get_gsg() == (GraphicsStateGuardian *)NULL || + if (buffer != nullptr) { + if (buffer->get_gsg() == nullptr || buffer->get_gsg()->get_prepared_objects() != get_gsg()->get_prepared_objects()) { // If the newly-created buffer doesn't share texture objects with the // current GSG, then we will have to force the texture copy to go @@ -862,7 +862,7 @@ make_texture_buffer(const string &name, int x_size, int y_size, return buffer; } - return NULL; + return nullptr; } /** @@ -892,7 +892,7 @@ make_cube_map(const string &name, int size, NodePath &camera_rig, // The GSG doesn't support cube mapping; too bad for you. display_cat.warning() << "Cannot make dynamic cube map; GSG does not support cube maps.\n"; - return NULL; + return nullptr; } if (max_dimension > 0) { size = min(max_dimension, size); @@ -953,7 +953,7 @@ make_cube_map(const string &name, int size, NodePath &camera_rig, */ NodePath GraphicsOutput:: get_texture_card() { - if (_texture_card == NULL) { + if (_texture_card == nullptr) { PT(GeomVertexData) vdata = create_texture_card_vdata(get_x_size(), get_y_size()); PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_static); strip->set_shade_model(Geom::SM_uniform); @@ -1072,7 +1072,7 @@ reset_window(bool swapchain) { */ void GraphicsOutput:: clear_pipe() { - _pipe = (GraphicsPipe *)NULL; + _pipe = nullptr; } /** @@ -1097,7 +1097,7 @@ set_size_and_recalc(int x, int y) { (*dri)->compute_pixels_all_stages(fb_x_size, fb_y_size); } - if (_texture_card != NULL && _texture_card->get_num_geoms() > 0) { + if (_texture_card != nullptr && _texture_card->get_num_geoms() > 0) { _texture_card->modify_geom(0)->set_vertex_data(create_texture_card_vdata(x, y)); } } @@ -1118,7 +1118,7 @@ clear(Thread *current_thread) { << get_name() << " " << (void *)this << "\n"; } - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); DisplayRegionPipelineReader dr_reader(_overlay_display_region, current_thread); _gsg->prepare_display_region(&dr_reader); @@ -1182,7 +1182,7 @@ change_scenes(DisplayRegionPipelineReader *new_dr) { // In copy-to-texture mode, copy the just-rendered framebuffer to // the old texture page. - nassertv(old_page_dr != (DisplayRegion *)NULL); + nassertv(old_page_dr != nullptr); if (display_cat.is_debug()) { display_cat.debug() << "Copying texture for " << get_name() << " at scene change.\n"; @@ -1390,7 +1390,7 @@ copy_to_textures() { bool copied = false; DisplayRegion *dr = _overlay_display_region; - if (_prev_page_dr != (DisplayRegion *)NULL) { + if (_prev_page_dr != nullptr) { dr = _prev_page_dr; } @@ -1504,7 +1504,7 @@ do_remove_display_region(DisplayRegion *display_region) { // Let's aggressively clean up the display region too. CDWriter cdata(_cycler, true); display_region->cleanup(); - display_region->_window = NULL; + display_region->_window = nullptr; _total_display_regions.erase(dri); cdata->_active_display_regions_stale = true; diff --git a/panda/src/display/graphicsOutput.h b/panda/src/display/graphicsOutput.h index 93db287a74..c5ddb10ff0 100644 --- a/panda/src/display/graphicsOutput.h +++ b/panda/src/display/graphicsOutput.h @@ -225,11 +225,11 @@ PUBLISHED: GraphicsOutput *make_texture_buffer( const string &name, int x_size, int y_size, - Texture *tex = NULL, bool to_ram = false, FrameBufferProperties *fbp = NULL); + Texture *tex = nullptr, bool to_ram = false, FrameBufferProperties *fbp = nullptr); GraphicsOutput *make_cube_map(const string &name, int size, NodePath &camera_rig, DrawMask camera_mask = PandaNode::get_all_camera_mask(), - bool to_ram = false, FrameBufferProperties *fbp = NULL); + bool to_ram = false, FrameBufferProperties *fbp = nullptr); INLINE static Filename make_screenshot_filename( const string &prefix = "screenshot"); diff --git a/panda/src/display/graphicsPipe.cxx b/panda/src/display/graphicsPipe.cxx index ad5d1aea62..62a8ec5ad0 100644 --- a/panda/src/display/graphicsPipe.cxx +++ b/panda/src/display/graphicsPipe.cxx @@ -60,7 +60,7 @@ union cpuid_info { */ static inline uint32_t get_cpuid_max(uint32_t leaf) { #if defined(__GNUC__) && !defined(__APPLE__) - return __get_cpuid_max(leaf, 0); + return __get_cpuid_max(leaf, nullptr); #elif defined(_MSC_VER) uint32_t p[4] = {0}; __cpuid((int *)p, leaf); @@ -158,17 +158,17 @@ GraphicsPipe() : #if defined(IS_OSX) // macOS exposes a lot of useful information through sysctl. size_t len = sizeof(uint64_t); - sysctlbyname("hw.memsize", &_display_information->_physical_memory, &len, NULL, 0); + sysctlbyname("hw.memsize", &_display_information->_physical_memory, &len, nullptr, 0); len = sizeof(uint64_t); - sysctlbyname("hw.cpufrequency", &_display_information->_cpu_frequency, &len, NULL, 0); + sysctlbyname("hw.cpufrequency", &_display_information->_cpu_frequency, &len, nullptr, 0); len = sizeof(uint64_t); - sysctlbyname("hw.cpufrequency", &_display_information->_current_cpu_frequency, &len, NULL, 0); + sysctlbyname("hw.cpufrequency", &_display_information->_current_cpu_frequency, &len, nullptr, 0); len = sizeof(uint64_t); - sysctlbyname("hw.cpufrequency_max", &_display_information->_maximum_cpu_frequency, &len, NULL, 0); + sysctlbyname("hw.cpufrequency_max", &_display_information->_maximum_cpu_frequency, &len, nullptr, 0); len = sizeof(int); - sysctlbyname("hw.physicalcpu", &_display_information->_num_cpu_cores, &len, NULL, 0); + sysctlbyname("hw.physicalcpu", &_display_information->_num_cpu_cores, &len, nullptr, 0); len = sizeof(int); - sysctlbyname("hw.logicalcpu", &_display_information->_num_logical_cpus, &len, NULL, 0); + sysctlbyname("hw.logicalcpu", &_display_information->_num_logical_cpus, &len, nullptr, 0); #elif defined(IS_LINUX) _display_information->_get_memory_information_function = &update_memory_info; @@ -176,9 +176,9 @@ GraphicsPipe() : #elif defined(IS_FREEBSD) size_t len = sizeof(uint64_t); - sysctlbyname("hw.physmem", &_display_information->_physical_memory, &len, NULL, 0); + sysctlbyname("hw.physmem", &_display_information->_physical_memory, &len, nullptr, 0); len = sizeof(uint64_t); - sysctlbyname("vm.swap_total", &_display_information->_page_file_size, &len, NULL, 0); + sysctlbyname("vm.swap_total", &_display_information->_page_file_size, &len, nullptr, 0); #elif defined(_WIN32) MEMORYSTATUSEX status; @@ -228,7 +228,7 @@ GraphicsPipe::get_preferred_window_thread() const { */ PT(GraphicsStateGuardian) GraphicsPipe:: make_callback_gsg(GraphicsEngine *engine) { - return NULL; + return nullptr; } /** @@ -239,7 +239,7 @@ PT(GraphicsDevice) GraphicsPipe:: make_device(void *scrn) { display_cat.error() << "make_device() unimplemented by " << get_type() << "\n"; - return NULL; + return nullptr; } /** @@ -251,7 +251,7 @@ make_device(void *scrn) { */ void GraphicsPipe:: close_gsg(GraphicsStateGuardian *gsg) { - if (gsg != (GraphicsStateGuardian *)NULL) { + if (gsg != nullptr) { gsg->close_gsg(); } } @@ -271,7 +271,7 @@ make_output(const string &name, bool &precertify) { display_cat.error() << get_type() << " cannot create buffers or windows.\n"; - return NULL; + return nullptr; } /** diff --git a/panda/src/display/graphicsPipe.h b/panda/src/display/graphicsPipe.h index 501cc535be..032da4b1cd 100644 --- a/panda/src/display/graphicsPipe.h +++ b/panda/src/display/graphicsPipe.h @@ -110,7 +110,7 @@ public: virtual PreferredWindowThread get_preferred_window_thread() const; INLINE GraphicsDevice *get_device() const; - virtual PT(GraphicsDevice) make_device(void *scrn = NULL); + virtual PT(GraphicsDevice) make_device(void *scrn = nullptr); virtual PT(GraphicsStateGuardian) make_callback_gsg(GraphicsEngine *engine); diff --git a/panda/src/display/graphicsPipeSelection.I b/panda/src/display/graphicsPipeSelection.I index 100557bcc5..a3f68e0ec2 100644 --- a/panda/src/display/graphicsPipeSelection.I +++ b/panda/src/display/graphicsPipeSelection.I @@ -26,7 +26,7 @@ get_num_aux_modules() const { */ INLINE GraphicsPipeSelection *GraphicsPipeSelection:: get_global_ptr() { - if (_global_ptr == (GraphicsPipeSelection *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new GraphicsPipeSelection; } return _global_ptr; diff --git a/panda/src/display/graphicsPipeSelection.cxx b/panda/src/display/graphicsPipeSelection.cxx index 1134cc0553..d2b145da39 100644 --- a/panda/src/display/graphicsPipeSelection.cxx +++ b/panda/src/display/graphicsPipeSelection.cxx @@ -23,7 +23,7 @@ #include -GraphicsPipeSelection *GraphicsPipeSelection::_global_ptr = NULL; +GraphicsPipeSelection *GraphicsPipeSelection::_global_ptr = nullptr; /** * @@ -171,7 +171,7 @@ make_pipe(const string &type_name, const string &module_name) { } if (type == TypeHandle::none()) { - return NULL; + return nullptr; } return make_pipe(type); @@ -193,7 +193,7 @@ make_pipe(TypeHandle type) { if (ptype._type == type) { // Here's an exact match. PT(GraphicsPipe) pipe = (*ptype._constructor)(); - if (pipe != (GraphicsPipe *)NULL) { + if (pipe != nullptr) { return pipe; } } @@ -205,7 +205,7 @@ make_pipe(TypeHandle type) { if (ptype._type.is_derived_from(type)) { // Here's an approximate match. PT(GraphicsPipe) pipe = (*ptype._constructor)(); - if (pipe != (GraphicsPipe *)NULL) { + if (pipe != nullptr) { return pipe; } } @@ -218,14 +218,14 @@ make_pipe(TypeHandle type) { if (ptype._type.is_derived_from(type)) { // Here's an approximate match. PT(GraphicsPipe) pipe = (*ptype._constructor)(); - if (pipe != (GraphicsPipe *)NULL) { + if (pipe != nullptr) { return pipe; } } } // Couldn't find a matching pipe type. - return NULL; + return nullptr; } /** @@ -242,7 +242,7 @@ make_module_pipe(const string &module_name) { TypeHandle pipe_type = load_named_module(module_name); if (pipe_type == TypeHandle::none()) { - return NULL; + return nullptr; } return make_pipe(pipe_type); @@ -268,7 +268,7 @@ make_default_pipe() { if (cmp_nocase_uh(ptype._type.get_name(), _default_pipe_name) == 0) { // Here's an exact match. PT(GraphicsPipe) pipe = (*ptype._constructor)(); - if (pipe != (GraphicsPipe *)NULL) { + if (pipe != nullptr) { return pipe; } } @@ -282,7 +282,7 @@ make_default_pipe() { if (ptype_name.find(preferred_name) != string::npos) { // Here's a substring match. PT(GraphicsPipe) pipe = (*ptype._constructor)(); - if (pipe != (GraphicsPipe *)NULL) { + if (pipe != nullptr) { return pipe; } } @@ -293,13 +293,13 @@ make_default_pipe() { for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { const PipeType &ptype = (*ti); PT(GraphicsPipe) pipe = (*ptype._constructor)(); - if (pipe != (GraphicsPipe *)NULL) { + if (pipe != nullptr) { return pipe; } } // Nothing. Probably the list was empty. - return NULL; + return nullptr; } /** @@ -325,7 +325,7 @@ load_aux_modules() { */ bool GraphicsPipeSelection:: add_pipe_type(TypeHandle type, PipeConstructorFunc *func) { - nassertr(func != NULL, false); + nassertr(func != nullptr, false); if (!type.is_derived_from(GraphicsPipe::get_class_type())) { display_cat->warning() @@ -408,7 +408,7 @@ load_named_module(const string &name) { display_cat.info() << "loading display module: " << dlname.to_os_specific() << endl; void *handle = load_dso(get_plugin_path().get_value(), dlname); - if (handle == (void *)NULL) { + if (handle == nullptr) { display_cat.warning() << "Unable to load: " << load_dso_error() << endl; return TypeHandle::none(); @@ -425,7 +425,7 @@ load_named_module(const string &name) { TypeHandle pipe_type = TypeHandle::none(); - if (dso_symbol == (void *)NULL) { + if (dso_symbol == nullptr) { // Couldn't find the module function. display_cat.warning() << "Unable to find " << symbol_name << " in " << dlname.get_basename() diff --git a/panda/src/display/graphicsStateGuardian.I b/panda/src/display/graphicsStateGuardian.I index 94188b85be..9f36616a95 100644 --- a/panda/src/display/graphicsStateGuardian.I +++ b/panda/src/display/graphicsStateGuardian.I @@ -767,7 +767,7 @@ get_alpha_scale_via_texture() const { INLINE bool GraphicsStateGuardian:: get_alpha_scale_via_texture(const TextureAttrib *tex_attrib) const { return _alpha_scale_via_texture && - (tex_attrib == (const TextureAttrib *)NULL || + (tex_attrib == nullptr || tex_attrib->get_num_on_stages() < get_max_texture_stages()); } @@ -777,7 +777,7 @@ get_alpha_scale_via_texture(const TextureAttrib *tex_attrib) const { */ INLINE TextureStage *GraphicsStateGuardian:: get_alpha_scale_texture_stage() { - if (_alpha_scale_texture_stage == (TextureStage *)NULL) { + if (_alpha_scale_texture_stage == nullptr) { _alpha_scale_texture_stage = new TextureStage("alpha-scale"); _alpha_scale_texture_stage->set_sort(1000000000); } diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index e754b9bf4d..d0353717c9 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -134,7 +134,7 @@ PStatCollector GraphicsStateGuardian::_draw_set_state_stencil_pcollector("Draw:S PStatCollector GraphicsStateGuardian::_draw_set_state_fog_pcollector("Draw:Set State:Fog"); PStatCollector GraphicsStateGuardian::_draw_set_state_scissor_pcollector("Draw:Set State:Scissor"); -PT(TextureStage) GraphicsStateGuardian::_alpha_scale_texture_stage = NULL; +PT(TextureStage) GraphicsStateGuardian::_alpha_scale_texture_stage = nullptr; TypeHandle GraphicsStateGuardian::_type_handle; @@ -158,17 +158,17 @@ GraphicsStateGuardian(CoordinateSystem internal_coordinate_system, set_coordinate_system(get_default_coordinate_system()); - _data_reader = (GeomVertexDataPipelineReader *)NULL; - _current_display_region = (DisplayRegion*)NULL; + _data_reader = nullptr; + _current_display_region = nullptr; _current_stereo_channel = Lens::SC_mono; _current_tex_view_offset = 0; - _current_lens = (Lens *)NULL; + _current_lens = nullptr; _projection_mat = TransformState::make_identity(); _projection_mat_inv = TransformState::make_identity(); _needs_reset = true; _is_valid = false; - _current_properties = NULL; + _current_properties = nullptr; _closing_gsg = false; _active = true; _prepared_objects = new PreparedGraphicsObjects; @@ -317,7 +317,7 @@ GraphicsStateGuardian:: */ GraphicsEngine *GraphicsStateGuardian:: get_engine() const { - nassertr(_engine != (GraphicsEngine *)NULL, GraphicsEngine::get_global_ptr()); + nassertr(_engine != nullptr, GraphicsEngine::get_global_ptr()); return _engine; } @@ -493,7 +493,7 @@ set_flash_texture(Texture *tex) { */ void GraphicsStateGuardian:: clear_flash_texture() { - _flash_texture = NULL; + _flash_texture = nullptr; } #endif // NDEBUG @@ -518,14 +518,14 @@ bool GraphicsStateGuardian:: set_scene(SceneSetup *scene_setup) { _scene_setup = scene_setup; _current_lens = scene_setup->get_lens(); - if (_current_lens == (Lens *)NULL) { + if (_current_lens == nullptr) { return false; } set_coordinate_system(_current_lens->get_coordinate_system()); _projection_mat = calc_projection_mat(_current_lens); - if (_projection_mat == 0) { + if (_projection_mat == nullptr) { return false; } _projection_mat_inv = _projection_mat->get_inverse(); @@ -552,7 +552,7 @@ get_scene() const { */ TextureContext *GraphicsStateGuardian:: prepare_texture(Texture *, int view) { - return (TextureContext *)NULL; + return nullptr; } /** @@ -603,7 +603,7 @@ extract_texture_data(Texture *) { */ SamplerContext *GraphicsStateGuardian:: prepare_sampler(const SamplerState &sampler) { - return (SamplerContext *)NULL; + return nullptr; } /** @@ -622,7 +622,7 @@ release_sampler(SamplerContext *) { */ GeomContext *GraphicsStateGuardian:: prepare_geom(Geom *) { - return (GeomContext *)NULL; + return nullptr; } /** @@ -641,7 +641,7 @@ release_geom(GeomContext *) { */ ShaderContext *GraphicsStateGuardian:: prepare_shader(Shader *shader) { - return (ShaderContext *)NULL; + return nullptr; } /** @@ -656,7 +656,7 @@ release_shader(ShaderContext *sc) { */ VertexBufferContext *GraphicsStateGuardian:: prepare_vertex_buffer(GeomVertexArrayData *) { - return (VertexBufferContext *)NULL; + return nullptr; } /** @@ -672,7 +672,7 @@ release_vertex_buffer(VertexBufferContext *) { */ IndexBufferContext *GraphicsStateGuardian:: prepare_index_buffer(GeomPrimitive *) { - return (IndexBufferContext *)NULL; + return nullptr; } /** @@ -688,7 +688,7 @@ release_index_buffer(IndexBufferContext *) { */ BufferContext *GraphicsStateGuardian:: prepare_shader_buffer(ShaderBuffer *) { - return (BufferContext *)NULL; + return nullptr; } /** @@ -712,7 +712,7 @@ release_shader_buffer(BufferContext *) { */ void GraphicsStateGuardian:: begin_occlusion_query() { - nassertv(_current_occlusion_query == (OcclusionQueryContext *)NULL); + nassertv(_current_occlusion_query == nullptr); } /** @@ -723,9 +723,9 @@ begin_occlusion_query() { */ PT(OcclusionQueryContext) GraphicsStateGuardian:: end_occlusion_query() { - nassertr(_current_occlusion_query != (OcclusionQueryContext *)NULL, NULL); + nassertr(_current_occlusion_query != nullptr, nullptr); PT(OcclusionQueryContext) result = _current_occlusion_query; - _current_occlusion_query = NULL; + _current_occlusion_query = nullptr; return result; } @@ -735,7 +735,7 @@ end_occlusion_query() { */ PT(TimerQueryContext) GraphicsStateGuardian:: issue_timer_query(int pstats_index) { - return NULL; + return nullptr; } /** @@ -784,7 +784,7 @@ get_geom_munger(const RenderState *state, Thread *current_thread) { // Nothing in the map; create a new entry. PT(GeomMunger) munger = make_geom_munger(state, current_thread); - nassertr(munger != (GeomMunger *)NULL && munger->is_registered(), munger); + nassertr(munger != nullptr && munger->is_registered(), munger); nassertr(munger->is_of_type(StateMunger::get_class_type()), munger); state->_last_mi = mungers.store(_id, munger); @@ -800,7 +800,7 @@ make_geom_munger(const RenderState *state, Thread *current_thread) { // The default implementation returns no munger at all, but presumably, // every kind of GSG needs some special munging action, so real GSG's will // override this to return something more useful. - return NULL; + return nullptr; } /** @@ -940,7 +940,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, } case Shader::SMO_texpad_x: { Texture *tex = _target_shader->get_shader_input_texture(name); - nassertr(tex != 0, &LMatrix4::zeros_mat()); + nassertr(tex != nullptr, &LMatrix4::zeros_mat()); int sx = tex->get_x_size() - tex->get_pad_x_size(); int sy = tex->get_y_size() - tex->get_pad_y_size(); int sz = tex->get_z_size() - tex->get_pad_z_size(); @@ -952,7 +952,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, } case Shader::SMO_texpix_x: { Texture *tex = _target_shader->get_shader_input_texture(name); - nassertr(tex != 0, &LMatrix4::zeros_mat()); + nassertr(tex != nullptr, &LMatrix4::zeros_mat()); double px = 1.0 / tex->get_x_size(); double py = 1.0 / tex->get_y_size(); double pz = 1.0 / tex->get_z_size(); @@ -1015,7 +1015,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, const FogAttrib *target_fog = (const FogAttrib *) _target_rs->get_attrib_def(FogAttrib::get_class_slot()); Fog *fog = target_fog->get_fog(); - if (fog == (Fog*) NULL) { + if (fog == nullptr) { return &LMatrix4::ones_mat(); } PN_stdfloat start, end; @@ -1027,7 +1027,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, const FogAttrib *target_fog = (const FogAttrib *) _target_rs->get_attrib_def(FogAttrib::get_class_slot()); Fog *fog = target_fog->get_fog(); - if (fog == (Fog*) NULL) { + if (fog == nullptr) { return &LMatrix4::ones_mat(); } LVecBase4 c = fog->get_color(); @@ -1095,7 +1095,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, Spotlight *lt; DCAST_INTO_R(lt, np.node(), &LMatrix4::zeros_mat()); Lens *lens = lt->get_lens(); - nassertr(lens != (Lens *)NULL, &LMatrix4::zeros_mat()); + nassertr(lens != nullptr, &LMatrix4::zeros_mat()); LColor const &c = lt->get_color(); LColor const &s = lt->get_specular_color(); PN_stdfloat cutoff = ccos(deg_2_rad(lens->get_hfov() * 0.5f)); @@ -1517,28 +1517,28 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) static const CPT_InternalName IN_quadraticAttenuation("quadraticAttenuation"); static const CPT_InternalName IN_shadowViewMatrix("shadowViewMatrix"); - PandaNode *node = NULL; + PandaNode *node = nullptr; if (!np.is_empty()) { node = np.node(); } if (attrib == IN_color) { - if (node == (PandaNode *)NULL) { + if (node == nullptr) { return &LMatrix4::ident_mat(); } Light *light = node->as_light(); - nassertr(light != (Light *)NULL, &LMatrix4::ident_mat()); + nassertr(light != nullptr, &LMatrix4::ident_mat()); LColor c = light->get_color(); c.componentwise_mult(_light_color_scale); t.set_row(3, c); return &t; } else if (attrib == IN_ambient) { - if (node == (PandaNode *)NULL) { + if (node == nullptr) { return &LMatrix4::ident_mat(); } Light *light = node->as_light(); - nassertr(light != (Light *)NULL, &LMatrix4::ident_mat()); + nassertr(light != nullptr, &LMatrix4::ident_mat()); if (node->is_ambient_light()) { LColor c = light->get_color(); c.componentwise_mult(_light_color_scale); @@ -1550,11 +1550,11 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) return &t; } else if (attrib == IN_diffuse) { - if (node == (PandaNode *)NULL) { + if (node == nullptr) { return &LMatrix4::ident_mat(); } Light *light = node->as_light(); - nassertr(light != (Light *)NULL, &LMatrix4::ones_mat()); + nassertr(light != nullptr, &LMatrix4::ones_mat()); if (node->is_ambient_light()) { // Ambient light has no diffuse color. t.set_row(3, LColor(0.0f, 0.0f, 0.0f, 1.0f)); @@ -1566,11 +1566,11 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) return &t; } else if (attrib == IN_specular) { - if (node == (PandaNode *)NULL) { + if (node == nullptr) { return &LMatrix4::ident_mat(); } Light *light = node->as_light(); - nassertr(light != (Light *)NULL, &LMatrix4::ones_mat()); + nassertr(light != nullptr, &LMatrix4::ones_mat()); t.set_row(3, light->get_specular_color()); return &t; @@ -1595,7 +1595,7 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) LightLensNode *light; DCAST_INTO_R(light, node, &LMatrix4::ident_mat()); Lens *lens = light->get_lens(); - nassertr(lens != (Lens *)NULL, &LMatrix4::ident_mat()); + nassertr(lens != nullptr, &LMatrix4::ident_mat()); CPT(TransformState) transform = _scene_setup->get_cs_world_transform()->compose( @@ -1631,7 +1631,7 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) LightLensNode *light; DCAST_INTO_R(light, node, &LMatrix4::ident_mat()); Lens *lens = light->get_lens(); - nassertr(lens != (Lens *)NULL, &LMatrix4::ident_mat()); + nassertr(lens != nullptr, &LMatrix4::ident_mat()); CPT(TransformState) transform = _scene_setup->get_cs_world_transform()->compose( @@ -1647,7 +1647,7 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) } } else if (attrib == IN_spotDirection) { - if (node == (PandaNode *)NULL) { + if (node == nullptr) { t.set_row(3, LVector3(0.0f, 0.0f, -1.0f)); return &t; } else if (node->is_ambient_light()) { @@ -1658,7 +1658,7 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) LightLensNode *light; DCAST_INTO_R(light, node, &LMatrix4::ident_mat()); Lens *lens = light->get_lens(); - nassertr(lens != (Lens *)NULL, &LMatrix4::ident_mat()); + nassertr(lens != nullptr, &LMatrix4::ident_mat()); CPT(TransformState) transform = _scene_setup->get_cs_world_transform()->compose( @@ -1671,12 +1671,12 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) } } else if (attrib == IN_spotCutoff) { - if (node != (PandaNode *)NULL && + if (node != nullptr && node->is_of_type(Spotlight::get_class_type())) { LightLensNode *light; DCAST_INTO_R(light, node, &LMatrix4::ident_mat()); Lens *lens = light->get_lens(); - nassertr(lens != (Lens *)NULL, &LMatrix4::ident_mat()); + nassertr(lens != nullptr, &LMatrix4::ident_mat()); float cutoff = lens->get_hfov() * 0.5f; t.set_row(3, LVecBase4(cutoff)); @@ -1688,12 +1688,12 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) } } else if (attrib == IN_spotCosCutoff) { - if (node != (PandaNode *)NULL && + if (node != nullptr && node->is_of_type(Spotlight::get_class_type())) { LightLensNode *light; DCAST_INTO_R(light, node, &LMatrix4::ident_mat()); Lens *lens = light->get_lens(); - nassertr(lens != (Lens *)NULL, &LMatrix4::ident_mat()); + nassertr(lens != nullptr, &LMatrix4::ident_mat()); float cutoff = lens->get_hfov() * 0.5f; t.set_row(3, LVecBase4(ccos(deg_2_rad(cutoff)))); @@ -1705,19 +1705,19 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) } } else if (attrib == IN_spotExponent) { - if (node == (PandaNode *)NULL) { + if (node == nullptr) { return &LMatrix4::zeros_mat(); } Light *light = node->as_light(); - nassertr(light != (Light *)NULL, &LMatrix4::ident_mat()); + nassertr(light != nullptr, &LMatrix4::ident_mat()); t.set_row(3, LVecBase4(light->get_exponent())); return &t; } else if (attrib == IN_attenuation) { - if (node != (PandaNode *)NULL) { + if (node != nullptr) { Light *light = node->as_light(); - nassertr(light != (Light *)NULL, &LMatrix4::ones_mat()); + nassertr(light != nullptr, &LMatrix4::ones_mat()); t.set_row(3, LVecBase4(light->get_attenuation(), 0)); } else { @@ -1726,31 +1726,31 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) return &t; } else if (attrib == IN_constantAttenuation) { - if (node == (PandaNode *)NULL) { + if (node == nullptr) { return &LMatrix4::ones_mat(); } Light *light = node->as_light(); - nassertr(light != (Light *)NULL, &LMatrix4::ones_mat()); + nassertr(light != nullptr, &LMatrix4::ones_mat()); t.set_row(3, LVecBase4(light->get_attenuation()[0])); return &t; } else if (attrib == IN_linearAttenuation) { - if (node == (PandaNode *)NULL) { + if (node == nullptr) { return &LMatrix4::zeros_mat(); } Light *light = node->as_light(); - nassertr(light != (Light *)NULL, &LMatrix4::ident_mat()); + nassertr(light != nullptr, &LMatrix4::ident_mat()); t.set_row(3, LVecBase4(light->get_attenuation()[1])); return &t; } else if (attrib == IN_quadraticAttenuation) { - if (node == (PandaNode *)NULL) { + if (node == nullptr) { return &LMatrix4::zeros_mat(); } Light *light = node->as_light(); - nassertr(light != (Light *)NULL, &LMatrix4::ident_mat()); + nassertr(light != nullptr, &LMatrix4::ident_mat()); t.set_row(3, LVecBase4(light->get_attenuation()[2])); return &t; @@ -1761,7 +1761,7 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) 0.0f, 0.0f, 0.5f, 0.0f, 0.5f, 0.5f, 0.5f, 1.0f); - if (node == (PandaNode *)NULL) { + if (node == nullptr) { return &biasmat; } @@ -1808,7 +1808,7 @@ fetch_specified_texture(Shader::ShaderTexSpec &spec, SamplerState &sampler, if (basename == "shadowMap") { PT(Texture) tex = get_shadow_map(np); - if (tex != (Texture *)NULL) { + if (tex != nullptr) { sampler = tex->get_default_sampler(); } return tex; @@ -1884,11 +1884,11 @@ fetch_specified_texture(Shader::ShaderTexSpec &spec, SamplerState &sampler, break; default: - nassertr(false, NULL); + nassertr(false, nullptr); break; } - return NULL; + return nullptr; } /** @@ -1983,7 +1983,7 @@ clear_state_and_transform() { */ void GraphicsStateGuardian:: remove_window(GraphicsOutputBase *window) { - nassertv(_engine != (GraphicsEngine *)NULL); + nassertv(_engine != nullptr); GraphicsOutput *win; DCAST_INTO_V(win, window); _engine->remove_window(win); @@ -2009,12 +2009,12 @@ prepare_lens() { */ CPT(TransformState) GraphicsStateGuardian:: calc_projection_mat(const Lens *lens) { - if (lens == (Lens *)NULL) { - return NULL; + if (lens == nullptr) { + return nullptr; } if (!lens->is_linear()) { - return NULL; + return nullptr; } return TransformState::make_identity(); @@ -2295,7 +2295,7 @@ CPT(RenderState) GraphicsStateGuardian:: begin_decal_base_first() { // Turn off writing the depth buffer to render the base geometry. static CPT(RenderState) decal_base_first; - if (decal_base_first == (const RenderState *)NULL) { + if (decal_base_first == nullptr) { decal_base_first = RenderState::make (DepthWriteAttrib::make(DepthWriteAttrib::M_off), RenderState::get_max_priority()); @@ -2314,7 +2314,7 @@ begin_decal_nested() { // We should keep the depth buffer off during this operation, so that decals // on decals will render properly. static CPT(RenderState) decal_nested; - if (decal_nested == (const RenderState *)NULL) { + if (decal_nested == nullptr) { decal_nested = RenderState::make (DepthWriteAttrib::make(DepthWriteAttrib::M_off), RenderState::get_max_priority()); @@ -2338,7 +2338,7 @@ begin_decal_base_second() { // buffer to render the base geometry after the second pass. Also, turn off // texturing since there's no need for it now. static CPT(RenderState) decal_base_second; - if (decal_base_second == (const RenderState *)NULL) { + if (decal_base_second == nullptr) { decal_base_second = RenderState::make (ColorWriteAttrib::make(ColorWriteAttrib::C_off), // On reflection, we need to leave texturing on so the alpha test @@ -2469,7 +2469,7 @@ draw_points(const GeomPrimitivePipelineReader *, bool) { */ void GraphicsStateGuardian:: end_draw_primitives() { - _data_reader = NULL; + _data_reader = nullptr; } /** @@ -2481,7 +2481,7 @@ reset() { _is_valid = false; _state_rs = RenderState::make_empty(); - _target_rs = NULL; + _target_rs = nullptr; _state_mask.clear(); _internal_transform = _cs_transform; _scene_null = new SceneSetup; @@ -2597,7 +2597,7 @@ do_issue_clip_plane() { const ClipPlaneAttrib *target_clip_plane = (const ClipPlaneAttrib *) _target_rs->get_attrib_def(ClipPlaneAttrib::get_class_slot()); - if (target_clip_plane != (ClipPlaneAttrib *)NULL) { + if (target_clip_plane != nullptr) { CPT(ClipPlaneAttrib) new_plane = target_clip_plane->filter_to_max(_max_clip_planes); num_on_planes = new_plane->get_num_on_planes(); @@ -3053,8 +3053,8 @@ determine_target_texture() { const TexGenAttrib *target_tex_gen = (const TexGenAttrib *) _target_rs->get_attrib_def(TexGenAttrib::get_class_slot()); - nassertv(target_texture != (TextureAttrib *)NULL && - target_tex_gen != (TexGenAttrib *)NULL); + nassertv(target_texture != nullptr && + target_tex_gen != nullptr); _target_texture = target_texture; _target_tex_gen = target_tex_gen; @@ -3182,8 +3182,8 @@ determine_light_color_scale() { */ CPT(RenderState) GraphicsStateGuardian:: get_unlit_state() { - static CPT(RenderState) state = NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make(LightAttrib::make_all_off()); } return state; @@ -3194,8 +3194,8 @@ get_unlit_state() { */ CPT(RenderState) GraphicsStateGuardian:: get_unclipped_state() { - static CPT(RenderState) state = NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make(ClipPlaneAttrib::make_all_off()); } return state; @@ -3206,8 +3206,8 @@ get_unclipped_state() { */ CPT(RenderState) GraphicsStateGuardian:: get_untextured_state() { - static CPT(RenderState) state = NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make(TextureAttrib::make_off()); } return state; diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index 5a7bec86dd..8e0e8d8489 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -430,7 +430,7 @@ public: static void create_gamma_table (PN_stdfloat gamma, unsigned short *red_table, unsigned short *green_table, unsigned short *blue_table); - PT(Texture) get_shadow_map(const NodePath &light_np, GraphicsOutputBase *host=NULL); + PT(Texture) get_shadow_map(const NodePath &light_np, GraphicsOutputBase *host=nullptr); PT(Texture) get_dummy_shadow_map(Texture::TextureType texture_type) const; virtual GraphicsOutput *make_shadow_buffer(LightLensNode *light, Texture *tex, GraphicsOutput *host); diff --git a/panda/src/display/graphicsStateGuardian_ext.cxx b/panda/src/display/graphicsStateGuardian_ext.cxx index 0677741ac7..3738ef82b8 100644 --- a/panda/src/display/graphicsStateGuardian_ext.cxx +++ b/panda/src/display/graphicsStateGuardian_ext.cxx @@ -41,8 +41,8 @@ PyObject *Extension:: get_prepared_textures() const { PyObject *list = PyList_New(0); - if (list == NULL) { - return NULL; + if (list == nullptr) { + return nullptr; } _this->traverse_prepared_textures(&traverse_callback, (void *)list); diff --git a/panda/src/display/graphicsWindow.cxx b/panda/src/display/graphicsWindow.cxx index 88ee617f40..c3dadfa08c 100644 --- a/panda/src/display/graphicsWindow.cxx +++ b/panda/src/display/graphicsWindow.cxx @@ -294,7 +294,7 @@ has_keyboard(int device) const { */ ButtonMap *GraphicsWindow:: get_keyboard_map() const { - return NULL; + return nullptr; } /** @@ -432,8 +432,8 @@ get_pointer_events(int device) { PT(PointerEventList) result; { LightMutexHolder holder(_input_lock); - nassertr(device >= 0 && device < (int)_input_devices.size(), NULL); - nassertr(_input_devices[device].has_pointer_event(), NULL); + nassertr(device >= 0 && device < (int)_input_devices.size(), nullptr); + nassertr(_input_devices[device].has_pointer_event(), nullptr); result = _input_devices[device].get_pointer_events(); } return result; @@ -648,13 +648,13 @@ close_window() { << "Closing " << get_type() << "\n"; // Tell our parent window (if any) that we're no longer its child. - if (_window_handle != (WindowHandle *)NULL && - _parent_window_handle != (WindowHandle *)NULL) { + if (_window_handle != nullptr && + _parent_window_handle != nullptr) { _parent_window_handle->detach_child(_window_handle); } - _window_handle = NULL; - _parent_window_handle = NULL; + _window_handle = nullptr; + _parent_window_handle = nullptr; _is_valid = false; } diff --git a/panda/src/display/graphicsWindowInputDevice.cxx b/panda/src/display/graphicsWindowInputDevice.cxx index 89d6e9d5b4..f2af1e9df1 100644 --- a/panda/src/display/graphicsWindowInputDevice.cxx +++ b/panda/src/display/graphicsWindowInputDevice.cxx @@ -141,7 +141,7 @@ get_button_event() { bool GraphicsWindowInputDevice:: has_pointer_event() const { LightMutexHolder holder(_lock); - return (_pointer_events != 0); + return (_pointer_events != nullptr); } /** @@ -151,7 +151,7 @@ PT(PointerEventList) GraphicsWindowInputDevice:: get_pointer_events() { LightMutexHolder holder(_lock); PT(PointerEventList) result = _pointer_events; - _pointer_events = 0; + _pointer_events = nullptr; return result; } @@ -224,7 +224,7 @@ set_pointer(bool inwin, double x, double y, double time) { if (_enable_pointer_events) { int seq = _event_sequence++; - if (_pointer_events == 0) { + if (_pointer_events == nullptr) { _pointer_events = new PointerEventList(); } _pointer_events->add_event(_mouse_data._in_window, diff --git a/panda/src/display/parasiteBuffer.cxx b/panda/src/display/parasiteBuffer.cxx index ace66cfdbc..c03d799f4c 100644 --- a/panda/src/display/parasiteBuffer.cxx +++ b/panda/src/display/parasiteBuffer.cxx @@ -108,7 +108,7 @@ set_size_and_recalc(int x, int y) { */ bool ParasiteBuffer:: flip_ready() const { - nassertr(_host != NULL, false); + nassertr(_host != nullptr, false); return _host->flip_ready(); } @@ -125,7 +125,7 @@ flip_ready() const { */ void ParasiteBuffer:: begin_flip() { - nassertv(_host != NULL); + nassertv(_host != nullptr); _host->begin_flip(); } @@ -140,7 +140,7 @@ begin_flip() { */ void ParasiteBuffer:: ready_flip() { - nassertv(_host != NULL); + nassertv(_host != nullptr); _host->ready_flip(); } @@ -153,7 +153,7 @@ ready_flip() { */ void ParasiteBuffer:: end_flip() { - nassertv(_host != NULL); + nassertv(_host != nullptr); _host->end_flip(); _flip_ready = false; } @@ -198,7 +198,7 @@ void ParasiteBuffer:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); _host->end_frame(FM_parasite, current_thread); diff --git a/panda/src/display/standardMunger.cxx b/panda/src/display/standardMunger.cxx index cdc2f0bda3..5d2a3f5102 100644 --- a/panda/src/display/standardMunger.cxx +++ b/panda/src/display/standardMunger.cxx @@ -125,10 +125,10 @@ munge_data_impl(const GeomVertexData *data) { } else if (hardware_animated_vertices && animation.get_animation_type() == AT_panda && - new_data->get_slider_table() == (SliderTable *)NULL) { + new_data->get_slider_table() == nullptr) { // Maybe we can animate the vertices with hardware. const TransformBlendTable *table = new_data->get_transform_blend_table(); - if (table != (TransformBlendTable *)NULL && + if (table != nullptr && table->get_num_transforms() != 0 && table->get_max_simultaneous_transforms() <= get_gsg()->get_max_vertex_transforms()) { diff --git a/panda/src/display/subprocessWindow.cxx b/panda/src/display/subprocessWindow.cxx index d001f3b1f6..261c7f161a 100644 --- a/panda/src/display/subprocessWindow.cxx +++ b/panda/src/display/subprocessWindow.cxx @@ -41,7 +41,7 @@ SubprocessWindow(GraphicsEngine *engine, GraphicsPipe *pipe, // This will be an offscreen buffer that we use to render the actual // contents. - _buffer = NULL; + _buffer = nullptr; // Create a texture to receive the contents of the framebuffer from the // offscreen buffer. @@ -50,7 +50,7 @@ SubprocessWindow(GraphicsEngine *engine, GraphicsPipe *pipe, _fd = -1; _mmap_size = 0; _filename = string(); - _swbuffer = NULL; + _swbuffer = nullptr; _last_event_flags = 0; } @@ -59,8 +59,8 @@ SubprocessWindow(GraphicsEngine *engine, GraphicsPipe *pipe, */ SubprocessWindow:: ~SubprocessWindow() { - nassertv(_buffer == NULL); - nassertv(_swbuffer == NULL); + nassertv(_buffer == nullptr); + nassertv(_swbuffer == nullptr); } /** @@ -74,7 +74,7 @@ void SubprocessWindow:: process_events() { GraphicsWindow::process_events(); - if (_swbuffer != NULL) { + if (_swbuffer != nullptr) { SubprocessWindowBuffer::Event swb_event; while (_swbuffer->get_event(swb_event)) { // Deal with this event. @@ -129,7 +129,7 @@ process_events() { */ bool SubprocessWindow:: begin_frame(FrameMode mode, Thread *current_thread) { - if (_swbuffer == NULL || _buffer == NULL) { + if (_swbuffer == nullptr || _buffer == nullptr) { return false; } @@ -164,8 +164,8 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void SubprocessWindow:: begin_flip() { - nassertv(_buffer != (GraphicsBuffer *)NULL); - if (_swbuffer == NULL) { + nassertv(_buffer != nullptr); + if (_swbuffer == nullptr) { return; } @@ -225,9 +225,9 @@ void SubprocessWindow:: set_properties_now(WindowProperties &properties) { Filename filename; WindowHandle *window_handle = properties.get_parent_window(); - if (window_handle != NULL) { + if (window_handle != nullptr) { WindowHandle::OSHandle *os_handle = window_handle->get_os_handle(); - if (os_handle != NULL) { + if (os_handle != nullptr) { if (os_handle->is_of_type(NativeWindowHandle::SubprocessHandle::get_class_type())) { NativeWindowHandle::SubprocessHandle *subprocess_handle = DCAST(NativeWindowHandle::SubprocessHandle, os_handle); filename = subprocess_handle->get_filename(); @@ -299,30 +299,30 @@ open_window() { */ void SubprocessWindow:: internal_close_window() { - if (_swbuffer != NULL) { + if (_swbuffer != nullptr) { SubprocessWindowBuffer::close_buffer (_fd, _mmap_size, _filename.to_os_specific(), _swbuffer); _fd = -1; _filename = string(); - _swbuffer = NULL; + _swbuffer = nullptr; } - if (_buffer != NULL) { + if (_buffer != nullptr) { _buffer->request_close(); _buffer->process_events(); _engine->remove_window(_buffer); - _buffer = NULL; + _buffer = nullptr; } // Tell our parent window (if any) that we're no longer its child. - if (_window_handle != (WindowHandle *)NULL && - _parent_window_handle != (WindowHandle *)NULL) { + if (_window_handle != nullptr && + _parent_window_handle != nullptr) { _parent_window_handle->detach_child(_window_handle); } - _window_handle = NULL; - _parent_window_handle = NULL; + _window_handle = nullptr; + _parent_window_handle = nullptr; _is_valid = false; } @@ -332,7 +332,7 @@ internal_close_window() { */ bool SubprocessWindow:: internal_open_window() { - nassertr(_buffer == NULL, false); + nassertr(_buffer == nullptr, false); // Create a buffer with the same properties as the window. int flags = _creation_flags; @@ -342,7 +342,7 @@ internal_open_window() { GraphicsOutput *buffer = _engine->make_output(_pipe, _name, 0, _fb_properties, win_props, flags, _gsg, _host); - if (buffer != NULL) { + if (buffer != nullptr) { _buffer = DCAST(GraphicsBuffer, buffer); // However, the buffer is not itself intended to be rendered. We only // render it indirectly, via callbacks in here. @@ -363,9 +363,9 @@ internal_open_window() { _gsg = _buffer->get_gsg(); WindowHandle *window_handle = _properties.get_parent_window(); - if (window_handle != NULL) { + if (window_handle != nullptr) { WindowHandle::OSHandle *os_handle = window_handle->get_os_handle(); - if (os_handle != NULL) { + if (os_handle != nullptr) { if (os_handle->is_of_type(NativeWindowHandle::SubprocessHandle::get_class_type())) { NativeWindowHandle::SubprocessHandle *subprocess_handle = DCAST(NativeWindowHandle::SubprocessHandle, os_handle); _filename = subprocess_handle->get_filename(); @@ -384,7 +384,7 @@ internal_open_window() { _swbuffer = SubprocessWindowBuffer::open_buffer (_fd, _mmap_size, _filename.to_os_specific()); - if (_swbuffer == NULL) { + if (_swbuffer == nullptr) { close(_fd); _fd = -1; _filename = string(); @@ -404,7 +404,7 @@ internal_open_window() { _window_handle = NativeWindowHandle::make_subprocess(_filename); // And tell our parent window that we're now its child. - if (_parent_window_handle != (WindowHandle *)NULL) { + if (_parent_window_handle != nullptr) { _parent_window_handle->attach_child(_window_handle); } diff --git a/panda/src/display/subprocessWindowBuffer.cxx b/panda/src/display/subprocessWindowBuffer.cxx index daae50b523..f2f7eea2cb 100644 --- a/panda/src/display/subprocessWindowBuffer.cxx +++ b/panda/src/display/subprocessWindowBuffer.cxx @@ -94,12 +94,12 @@ new_buffer(int &fd, size_t &mmap_size, string &filename, mmap_size = 0; fd = -1; - filename = tmpnam(NULL); + filename = tmpnam(nullptr); fd = open(filename.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600); if (fd == -1) { perror(filename.c_str()); - return NULL; + return nullptr; } // Create a temporary object to determine the required size. @@ -114,14 +114,14 @@ new_buffer(int &fd, size_t &mmap_size, string &filename, write(fd, zero, zero_size); } - void *shared_mem = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, + void *shared_mem = mmap(nullptr, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (shared_mem == (void *)-1) { // Failure to map. close(fd); fd = -1; mmap_size = 0; - return NULL; + return nullptr; } // Now create the actual object in the shared-memory buffer. @@ -160,7 +160,7 @@ open_buffer(int &fd, size_t &mmap_size, const string &filename) { fd = open(filename.c_str(), O_RDWR); if (fd == -1) { perror(filename.c_str()); - return NULL; + return nullptr; } // Check that the disk file is large enough. @@ -169,19 +169,19 @@ open_buffer(int &fd, size_t &mmap_size, const string &filename) { cerr << filename << " not large enough.\n"; close(fd); fd = -1; - return NULL; + return nullptr; } // First, map enough memory to read the buffer object. size_t initial_size = sizeof(SubprocessWindowBuffer); - void *shared_mem = mmap(NULL, initial_size, PROT_READ, + void *shared_mem = mmap(nullptr, initial_size, PROT_READ, MAP_SHARED, fd, 0); if (shared_mem == (void *)-1) { perror("mmap"); cerr << "Couldn't map.\n"; close(fd); fd = -1; - return NULL; + return nullptr; } SubprocessWindowBuffer *temp = (SubprocessWindowBuffer *)shared_mem; @@ -190,7 +190,7 @@ open_buffer(int &fd, size_t &mmap_size, const string &filename) { munmap(shared_mem, initial_size); close(fd); fd = -1; - return NULL; + return nullptr; } @@ -203,15 +203,15 @@ open_buffer(int &fd, size_t &mmap_size, const string &filename) { cerr << filename << " not large enough.\n"; close(fd); fd = -1; - return NULL; + return nullptr; } - shared_mem = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, + shared_mem = mmap(nullptr, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (shared_mem == (void *)-1) { perror("mmap"); cerr << "Couldn't map 2.\n"; - return NULL; + return nullptr; } // Now that we've successfully opened and mapped the file, we can safely diff --git a/panda/src/display/windowHandle.cxx b/panda/src/display/windowHandle.cxx index ecc903595f..c114da8adf 100644 --- a/panda/src/display/windowHandle.cxx +++ b/panda/src/display/windowHandle.cxx @@ -31,7 +31,7 @@ WindowHandle:: */ void WindowHandle:: send_windows_message(unsigned int msg, int wparam, int lparam) { - if (_keyboard_window != NULL) { + if (_keyboard_window != nullptr) { _keyboard_window->receive_windows_message(msg, wparam, lparam); } } @@ -42,7 +42,7 @@ send_windows_message(unsigned int msg, int wparam, int lparam) { */ size_t WindowHandle:: get_int_handle() const { - if (_os_handle != NULL) { + if (_os_handle != nullptr) { return _os_handle->get_int_handle(); } return 0; @@ -53,7 +53,7 @@ get_int_handle() const { */ void WindowHandle:: output(ostream &out) const { - if (_os_handle == NULL) { + if (_os_handle == nullptr) { out << "(null)"; } else { out << *_os_handle; @@ -75,7 +75,7 @@ attach_child(WindowHandle *child) { void WindowHandle:: detach_child(WindowHandle *child) { if (_keyboard_window == child) { - _keyboard_window = NULL; + _keyboard_window = nullptr; } } diff --git a/panda/src/display/windowProperties.I b/panda/src/display/windowProperties.I index 9179124705..f9af047b54 100644 --- a/panda/src/display/windowProperties.I +++ b/panda/src/display/windowProperties.I @@ -726,7 +726,7 @@ has_parent_window() const { INLINE void WindowProperties:: clear_parent_window() { _specified &= ~S_parent_window; - _parent_window = NULL; + _parent_window = nullptr; } diff --git a/panda/src/display/windowProperties.cxx b/panda/src/display/windowProperties.cxx index 298bed4b45..fec24e4faf 100644 --- a/panda/src/display/windowProperties.cxx +++ b/panda/src/display/windowProperties.cxx @@ -15,7 +15,7 @@ #include "config_display.h" #include "nativeWindowHandle.h" -WindowProperties *WindowProperties::_default_properties = NULL; +WindowProperties *WindowProperties::_default_properties = nullptr; /** * @@ -93,7 +93,7 @@ get_config_properties() { */ WindowProperties WindowProperties:: get_default() { - if (_default_properties != NULL) { + if (_default_properties != nullptr) { return *_default_properties; } else { return get_config_properties(); @@ -110,7 +110,7 @@ get_default() { */ void WindowProperties:: set_default(const WindowProperties &default_properties) { - if (_default_properties == NULL) { + if (_default_properties == nullptr) { _default_properties = new WindowProperties; } (*_default_properties) = default_properties; @@ -122,9 +122,9 @@ set_default(const WindowProperties &default_properties) { */ void WindowProperties:: clear_default() { - if (_default_properties != NULL) { + if (_default_properties != nullptr) { delete _default_properties; - _default_properties = NULL; + _default_properties = nullptr; } } @@ -177,7 +177,7 @@ clear() { _z_order = Z_normal; _flags = 0; _mouse_mode = M_absolute; - _parent_window = NULL; + _parent_window = nullptr; } /** @@ -197,7 +197,7 @@ clear() { void WindowProperties:: set_parent_window(size_t parent) { if (parent == 0) { - set_parent_window((WindowHandle *)NULL); + set_parent_window(nullptr); } else { PT(WindowHandle) handle = NativeWindowHandle::make_int(parent); set_parent_window(handle); @@ -312,7 +312,7 @@ output(ostream &out) const { out << get_mouse_mode() << " "; } if (has_parent_window()) { - if (get_parent_window() == NULL) { + if (get_parent_window() == nullptr) { out << "parent:none "; } else { out << "parent:" << *get_parent_window() << " "; diff --git a/panda/src/display/windowProperties.h b/panda/src/display/windowProperties.h index 16a65c0096..dd6ba5185c 100644 --- a/panda/src/display/windowProperties.h +++ b/panda/src/display/windowProperties.h @@ -166,7 +166,7 @@ PUBLISHED: MAKE_PROPERTY2(z_order, has_z_order, get_z_order, set_z_order, clear_z_order); void set_parent_window(size_t parent); - INLINE void set_parent_window(WindowHandle *parent_window = NULL); + INLINE void set_parent_window(WindowHandle *parent_window = nullptr); INLINE WindowHandle *get_parent_window() const; INLINE bool has_parent_window() const; INLINE void clear_parent_window(); diff --git a/panda/src/distort/nonlinearImager.cxx b/panda/src/distort/nonlinearImager.cxx index fb264061c3..551caac4d1 100644 --- a/panda/src/distort/nonlinearImager.cxx +++ b/panda/src/distort/nonlinearImager.cxx @@ -28,7 +28,7 @@ */ NonlinearImager:: NonlinearImager() { - _engine = (GraphicsEngine *)NULL; + _engine = nullptr; _stale = true; } @@ -40,7 +40,7 @@ NonlinearImager:: remove_all_screens(); remove_all_viewers(); - if (_recompute_task != (AsyncTask *)NULL) { + if (_recompute_task != nullptr) { AsyncTaskManager *task_mgr = AsyncTaskManager::get_global_ptr(); task_mgr->remove(_recompute_task); } @@ -82,7 +82,7 @@ add_screen(const NodePath &screen, const string &name) { new_screen._screen = screen; new_screen._screen_node = screen_node; new_screen._name = name; - new_screen._buffer = (GraphicsOutput *)NULL; + new_screen._buffer = nullptr; new_screen._tex_width = 256; new_screen._tex_height = 256; new_screen._active = true; @@ -167,7 +167,7 @@ get_screen(int index) const { */ GraphicsOutput *NonlinearImager:: get_buffer(int index) const { - nassertr(index >= 0 && index < (int)_screens.size(), (GraphicsOutput *)NULL); + nassertr(index >= 0 && index < (int)_screens.size(), nullptr); return _screens[index]._buffer; } @@ -188,9 +188,9 @@ set_texture_size(int index, int width, int height) { screen._tex_width = width; screen._tex_height = height; - if (screen._buffer != (GraphicsOutput *)NULL) { + if (screen._buffer != nullptr) { bool removed = _engine->remove_window(screen._buffer); - screen._buffer = (GraphicsOutput *)NULL; + screen._buffer = nullptr; nassertv(removed); } @@ -230,9 +230,9 @@ set_screen_active(int index, bool active) { } // Also remove its buffer. - if (screen._buffer != (GraphicsOutput *)NULL) { + if (screen._buffer != nullptr) { bool removed = _engine->remove_window(screen._buffer); - screen._buffer = (GraphicsOutput *)NULL; + screen._buffer = nullptr; nassertv(removed); } @@ -276,20 +276,20 @@ get_screen_active(int index) const { int NonlinearImager:: add_viewer(DisplayRegion *dr) { GraphicsOutput *window = dr->get_window(); - nassertr(window != (GraphicsOutput *)NULL, -1); + nassertr(window != nullptr, -1); GraphicsStateGuardian *gsg = window->get_gsg(); - nassertr(gsg != (GraphicsStateGuardian *)NULL, -1); + nassertr(gsg != nullptr, -1); GraphicsEngine *engine = gsg->get_engine(); - nassertr(engine != (GraphicsEngine *)NULL, -1); + nassertr(engine != nullptr, -1); nassertr(_viewers.empty() || (engine == _engine), -1); - if (_engine == (GraphicsEngine *)NULL) { + if (_engine == nullptr) { _engine = engine; } - if (_recompute_task == (AsyncTask *)NULL) { + if (_recompute_task == nullptr) { _recompute_task = new GenericAsyncTask("nli_recompute", recompute_callback, (void *)this); AsyncTaskManager *task_mgr = AsyncTaskManager::get_global_ptr(); @@ -310,7 +310,7 @@ add_viewer(DisplayRegion *dr) { // Get the current camera off of the DisplayRegion, if any. viewer._viewer = dr->get_camera(); if (viewer._viewer.is_empty()) { - viewer._viewer_node = (LensNode *)NULL; + viewer._viewer_node = nullptr; } else { viewer._viewer_node = DCAST(LensNode, viewer._viewer.node()); } @@ -463,7 +463,7 @@ get_num_viewers() const { */ DisplayRegion *NonlinearImager:: get_viewer(int index) const { - nassertr(index >= 0 && index < (int)_viewers.size(), (DisplayRegion *)NULL); + nassertr(index >= 0 && index < (int)_viewers.size(), nullptr); return _viewers[index]._dr; } @@ -509,8 +509,8 @@ recompute() { } } - if (viewer._viewer_node != (LensNode *)NULL && - viewer._viewer_node->get_lens() != (Lens *)NULL) { + if (viewer._viewer_node != nullptr && + viewer._viewer_node->get_lens() != nullptr) { viewer._viewer_lens_change = viewer._viewer_node->get_lens()->get_last_change(); } @@ -540,7 +540,7 @@ recompute_if_stale() { size_t vi; for (vi = 0; vi < _viewers.size(); ++vi) { Viewer &viewer = _viewers[vi]; - if (viewer._viewer_node != (LensNode *)NULL) { + if (viewer._viewer_node != nullptr) { UpdateSeq lens_change = viewer._viewer_node->get_lens()->get_last_change(); if (lens_change != viewer._viewer_lens_change) { @@ -588,16 +588,16 @@ recompute_screen(NonlinearImager::Screen &screen, size_t vi) { Viewer &viewer = _viewers[vi]; PT(PandaNode) mesh = screen._screen_node->make_flat_mesh(screen._screen, viewer._viewer); - if (mesh != (PandaNode *)NULL) { + if (mesh != nullptr) { screen._meshes[vi]._mesh = viewer._internal_scene.attach_new_node(mesh); } - if (screen._buffer == (GraphicsOutput *)NULL) { + if (screen._buffer == nullptr) { GraphicsOutput *win = viewer._dr->get_window(); GraphicsOutput *buffer = win->make_texture_buffer - (screen._name, screen._tex_width, screen._tex_height, NULL, false); + (screen._name, screen._tex_width, screen._tex_height, nullptr, false); - if (buffer != (GraphicsOutput *)NULL) { + if (buffer != nullptr) { screen._buffer = buffer; DisplayRegion *dr = buffer->make_display_region(); dr->set_camera(screen._source_camera); @@ -607,7 +607,7 @@ recompute_screen(NonlinearImager::Screen &screen, size_t vi) { } } - if (screen._buffer != (GraphicsOutput *)NULL) { + if (screen._buffer != nullptr) { screen._meshes[vi]._mesh.set_texture(screen._buffer->get_texture()); // We don't really need to set the texture on the dark room screen, since diff --git a/panda/src/distort/projectionScreen.cxx b/panda/src/distort/projectionScreen.cxx index 1991bfc120..0ac8fd9edf 100644 --- a/panda/src/distort/projectionScreen.cxx +++ b/panda/src/distort/projectionScreen.cxx @@ -118,7 +118,7 @@ cull_callback(CullTraverser *, CullTraverserData &data) { */ void ProjectionScreen:: set_projector(const NodePath &projector) { - _projector_node = (LensNode *)NULL; + _projector_node = nullptr; _projector = projector; if (!projector.is_empty()) { nassertv(projector.node()->is_of_type(LensNode::get_class_type())); @@ -156,9 +156,9 @@ generate_screen(const NodePath &projector, const string &screen_name, PN_stdfloat fill_ratio) { nassertr(!projector.is_empty() && projector.node()->is_of_type(LensNode::get_class_type()), - NULL); + nullptr); LensNode *projector_node = DCAST(LensNode, projector.node()); - nassertr(projector_node->get_lens() != NULL, NULL); + nassertr(projector_node->get_lens() != nullptr, nullptr); // First, get the relative coordinate space of the projector. LMatrix4 rel_mat; @@ -204,7 +204,7 @@ generate_screen(const NodePath &projector, const string &screen_name, normal.add_data3(-normalize(norm * rel_mat)); } } - nassertr(vdata->get_num_rows() == num_verts, NULL); + nassertr(vdata->get_num_rows() == num_verts, nullptr); // Now synthesize a triangle mesh. We run triangle strips horizontally // across the grid. @@ -265,12 +265,12 @@ regenerate_screen(const NodePath &projector, const string &screen_name, */ PT(PandaNode) ProjectionScreen:: make_flat_mesh(const NodePath &this_np, const NodePath &camera) { - nassertr(!this_np.is_empty() && this_np.node() == this, NULL); + nassertr(!this_np.is_empty() && this_np.node() == this, nullptr); nassertr(!camera.is_empty() && camera.node()->is_of_type(LensNode::get_class_type()), - NULL); + nullptr); LensNode *camera_node = DCAST(LensNode, camera.node()); - nassertr(camera_node->get_lens() != (Lens *)NULL, NULL); + nassertr(camera_node->get_lens() != nullptr, nullptr); // First, ensure the UV's are up-to-date. recompute_if_stale(this_np); @@ -318,8 +318,8 @@ bool ProjectionScreen:: recompute_if_stale(const NodePath &this_np) { nassertr(!this_np.is_empty() && this_np.node() == this, false); - if (_projector_node != (LensNode *)NULL && - _projector_node->get_lens() != (Lens *)NULL) { + if (_projector_node != nullptr && + _projector_node->get_lens() != nullptr) { UpdateSeq lens_change = _projector_node->get_lens()->get_last_change(); if (_stale || lens_change != _projector_lens_change) { recompute(); @@ -346,8 +346,8 @@ recompute_if_stale(const NodePath &this_np) { */ void ProjectionScreen:: do_recompute(const NodePath &this_np) { - if (_projector_node != (LensNode *)NULL && - _projector_node->get_lens() != (Lens *)NULL) { + if (_projector_node != nullptr && + _projector_node->get_lens() != nullptr) { recompute_node(this_np, _rel_top_mat, _computed_rel_top_mat); // Make sure this flag is set to false for next time. @@ -479,7 +479,7 @@ recompute_geom(Geom *geom, const LMatrix4 &rel_mat) { Thread *current_thread = Thread::get_current_thread(); Lens *lens = _projector_node->get_lens(); - nassertv(lens != (Lens *)NULL); + nassertv(lens != nullptr); const LMatrix4 &to_uv = _invert_uvs ? lens_to_uv_inverted : lens_to_uv; @@ -620,7 +620,7 @@ make_mesh_children(PandaNode *new_node, const WorkingNodePath &np, rel_mat, computed_rel_mat); } - if (new_child != NULL) { + if (new_child != nullptr) { // Copy all of the render state (except TransformState) to the new arc. new_child->set_state(child->get_state()); } @@ -650,7 +650,7 @@ make_mesh_geom_node(const WorkingNodePath &np, const NodePath &camera, const Geom *geom = node->get_geom(i); PT(Geom) new_geom = make_mesh_geom(geom, lens_node->get_lens(), rel_mat); - if (new_geom != (Geom *)NULL) { + if (new_geom != nullptr) { new_node->add_geom(new_geom, node->get_geom_state(i)); } } diff --git a/panda/src/downloader/bioPtr.cxx b/panda/src/downloader/bioPtr.cxx index b86f37f816..8c5c76f636 100644 --- a/panda/src/downloader/bioPtr.cxx +++ b/panda/src/downloader/bioPtr.cxx @@ -36,7 +36,7 @@ static string format_error() { PVOID buffer; DWORD len; len = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, WSAGetLastError(), 0, (LPTSTR)&buffer, 0, NULL); + nullptr, WSAGetLastError(), 0, (LPTSTR)&buffer, 0, nullptr); if (len == 0) { return string("Unknown error message"); } @@ -88,17 +88,17 @@ BioPtr(const URLSpec &url) : _connecting(false) { // doesn't handle IPv6 properly. _server_name = url.get_server(); _port = url.get_port(); - _bio = NULL; + _bio = nullptr; // These hints tell getaddrinfo what kind of address to return. - struct addrinfo hints, *res = NULL; + struct addrinfo hints, *res = nullptr; memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG; hints.ai_family = support_ipv6 ? AF_UNSPEC : AF_INET; hints.ai_socktype = SOCK_STREAM; // Resolve the hostname or address string. - int result = getaddrinfo(_server_name.c_str(), NULL, &hints, &res); + int result = getaddrinfo(_server_name.c_str(), nullptr, &hints, &res); if (result != 0) { const char *errmsg; #ifndef _WIN32 @@ -113,14 +113,14 @@ BioPtr(const URLSpec &url) : _connecting(false) { << "Failed to resolve " << url.get_server() << ": " << errmsg << "\n"; return; } - nassertv(res != NULL && res->ai_addr != NULL); + nassertv(res != nullptr && res->ai_addr != nullptr); // Store the real resolved address. char buf[48]; buf[0] = 0; #ifdef _WIN32 DWORD bufsize = sizeof(buf); - WSAAddressToStringA(res->ai_addr, res->ai_addrlen, NULL, buf, &bufsize); + WSAAddressToStringA(res->ai_addr, res->ai_addrlen, nullptr, buf, &bufsize); #else if (res->ai_addr->sa_family == AF_INET) { inet_ntop(AF_INET, (char *)&((sockaddr_in *)res->ai_addr)->sin_addr, buf, sizeof(buf)); @@ -143,7 +143,7 @@ BioPtr(const URLSpec &url) : _connecting(false) { if (fd < 0) { downloader_cat.error() << "Failed to create socket: " << format_error() << "\n"; - _bio = NULL; + _bio = nullptr; freeaddrinfo(res); return; } @@ -170,7 +170,7 @@ BioPtr(const URLSpec &url) : _connecting(false) { */ void BioPtr:: set_nbio(bool nbio) { - if (_bio == NULL) { + if (_bio == nullptr) { return; } @@ -186,7 +186,7 @@ set_nbio(bool nbio) { */ bool BioPtr:: connect() { - if (_bio == NULL) { + if (_bio == nullptr) { return false; } @@ -226,7 +226,7 @@ connect() { */ bool BioPtr:: should_retry() const { - return (_bio != NULL) && BIO_should_retry(_bio); + return (_bio != nullptr) && BIO_should_retry(_bio); } /** @@ -234,14 +234,14 @@ should_retry() const { */ BioPtr:: ~BioPtr() { - if (_bio != (BIO *)NULL) { + if (_bio != nullptr) { if (downloader_cat.is_debug() && !_server_name.empty()) { downloader_cat.debug() << "Dropping connection to " << _server_name << " port " << _port << "\n"; } BIO_free_all(_bio); - _bio = (BIO *)NULL; + _bio = nullptr; } } diff --git a/panda/src/downloader/bioStreamBuf.cxx b/panda/src/downloader/bioStreamBuf.cxx index 65dd28c5ba..1598b15259 100644 --- a/panda/src/downloader/bioStreamBuf.cxx +++ b/panda/src/downloader/bioStreamBuf.cxx @@ -189,9 +189,9 @@ underflow() { << _source->get_port() << " (" << read_count << ").\n"; OpenSSLWrapper::get_global_ptr()->notify_ssl_errors(); - SSL *ssl = NULL; + SSL *ssl = nullptr; BIO_get_ssl(*_source, &ssl); - if (ssl != (SSL *)NULL) { + if (ssl != nullptr) { downloader_cat.warning() << "OpenSSL error code: " << SSL_get_error(ssl, read_count) << "\n"; @@ -271,7 +271,7 @@ write_chars(const char *start, size_t length) { fd_set wset; FD_ZERO(&wset); FD_SET(fd, &wset); - select(fd + 1, NULL, &wset, NULL, NULL); + select(fd + 1, nullptr, &wset, nullptr, nullptr); #endif // SIMPLE_THREADS } diff --git a/panda/src/downloader/bioStreamPtr.cxx b/panda/src/downloader/bioStreamPtr.cxx index 80d5e4838a..6444703b16 100644 --- a/panda/src/downloader/bioStreamPtr.cxx +++ b/panda/src/downloader/bioStreamPtr.cxx @@ -20,9 +20,9 @@ */ BioStreamPtr:: ~BioStreamPtr() { - if (_stream != (BioStream *)NULL) { + if (_stream != nullptr) { delete _stream; - _stream = (BioStream *)NULL; + _stream = nullptr; } } diff --git a/panda/src/downloader/chunkedStream.cxx b/panda/src/downloader/chunkedStream.cxx index 2b6f316c0b..279aed870d 100644 --- a/panda/src/downloader/chunkedStream.cxx +++ b/panda/src/downloader/chunkedStream.cxx @@ -21,9 +21,9 @@ */ IChunkedStream:: ~IChunkedStream() { - if (_channel != (HTTPChannel *)NULL) { + if (_channel != nullptr) { _channel->body_stream_destructs(this); - _channel = NULL; + _channel = nullptr; } } diff --git a/panda/src/downloader/chunkedStreamBuf.I b/panda/src/downloader/chunkedStreamBuf.I index b890d7349b..5942bb0f48 100644 --- a/panda/src/downloader/chunkedStreamBuf.I +++ b/panda/src/downloader/chunkedStreamBuf.I @@ -16,7 +16,7 @@ */ INLINE bool ChunkedStreamBuf:: is_closed() const { - return (_source == (BioStreamPtr *)NULL || (*_source)->is_closed()); + return (_source == nullptr || (*_source)->is_closed()); } /** diff --git a/panda/src/downloader/chunkedStreamBuf.cxx b/panda/src/downloader/chunkedStreamBuf.cxx index a20b8425ed..f6ddd39713 100644 --- a/panda/src/downloader/chunkedStreamBuf.cxx +++ b/panda/src/downloader/chunkedStreamBuf.cxx @@ -66,7 +66,7 @@ open_read(BioStreamPtr *source, HTTPChannel *doc) { _read_state = ISocketStream::RS_reading; _doc = doc; - if (_doc != (HTTPChannel *)NULL) { + if (_doc != nullptr) { _read_index = doc->_read_index; _doc->_transfer_file_size = 0; _doc->_got_transfer_file_size = true; @@ -176,7 +176,7 @@ read_chars(char *start, size_t length) { return 0; } - size_t chunk_size = (size_t)strtol(line.c_str(), NULL, 16); + size_t chunk_size = (size_t)strtol(line.c_str(), nullptr, 16); if (downloader_cat.is_spam()) { downloader_cat.spam() << "Got chunk of size " << chunk_size << " bytes.\n"; @@ -185,7 +185,7 @@ read_chars(char *start, size_t length) { if (chunk_size == 0) { // Last chunk; we're done. _done = true; - if (_doc != (HTTPChannel *)NULL && _read_index == _doc->_read_index) { + if (_doc != nullptr && _read_index == _doc->_read_index) { _doc->_file_size = _doc->_transfer_file_size; _doc->_got_file_size = true; } @@ -193,7 +193,7 @@ read_chars(char *start, size_t length) { return 0; } - if (_doc != (HTTPChannel *)NULL && _read_index == _doc->_read_index) { + if (_doc != nullptr && _read_index == _doc->_read_index) { _doc->_transfer_file_size += chunk_size; } diff --git a/panda/src/downloader/decompressor.cxx b/panda/src/downloader/decompressor.cxx index da78e19fa3..b6bc542e60 100644 --- a/panda/src/downloader/decompressor.cxx +++ b/panda/src/downloader/decompressor.cxx @@ -34,9 +34,9 @@ */ Decompressor:: Decompressor() { - _source = NULL; - _decompress = NULL; - _dest = NULL; + _source = nullptr; + _decompress = nullptr; + _dest = nullptr; } /** @@ -137,7 +137,7 @@ initiate(const Filename &source_file, const Filename &dest_file) { */ int Decompressor:: run() { - if (_decompress == (istream *)NULL) { + if (_decompress == nullptr) { // Hmm, we were already done. return EU_success; } @@ -222,7 +222,7 @@ decompress(Ramfile &source_and_dest_file) { */ PN_stdfloat Decompressor:: get_progress() const { - if (_decompress == (istream *)NULL) { + if (_decompress == nullptr) { // Hmm, we were already done. return 1.0f; } @@ -240,17 +240,17 @@ get_progress() const { */ void Decompressor:: cleanup() { - if (_source != (istream *)NULL) { + if (_source != nullptr) { delete _source; - _source = NULL; + _source = nullptr; } - if (_dest != (ostream *)NULL) { + if (_dest != nullptr) { delete _dest; - _dest = NULL; + _dest = nullptr; } - if (_decompress != (istream *)NULL) { + if (_decompress != nullptr) { delete _decompress; - _decompress = NULL; + _decompress = nullptr; } } diff --git a/panda/src/downloader/downloadDb.cxx b/panda/src/downloader/downloadDb.cxx index a210fba8bd..d532009e2b 100644 --- a/panda/src/downloader/downloadDb.cxx +++ b/panda/src/downloader/downloadDb.cxx @@ -253,7 +253,7 @@ read_db(Filename &file, bool want_server_info) { file.set_binary(); istream *read_stream = vfs->open_read_file(file, true); - if (read_stream == (istream *)NULL) { + if (read_stream == nullptr) { downloader_cat.error() << "failed to open input file: " << file << endl; diff --git a/panda/src/downloader/extractor.cxx b/panda/src/downloader/extractor.cxx index d387b51dd2..81568ae951 100644 --- a/panda/src/downloader/extractor.cxx +++ b/panda/src/downloader/extractor.cxx @@ -63,9 +63,9 @@ set_extract_dir(const Filename &extract_dir) { void Extractor:: reset() { if (_initiated) { - if (_read != (istream *)NULL) { + if (_read != nullptr) { Multifile::close_read_subfile(_read); - _read = (istream *)NULL; + _read = nullptr; } _write.close(); _initiated = false; @@ -125,7 +125,7 @@ step() { _subfile_pos = 0; _subfile_length = 0; _total_bytes_extracted = 0; - _read = (istream *)NULL; + _read = nullptr; _initiated = true; } @@ -134,7 +134,7 @@ step() { double finish = now + extractor_step_time; do { - if (_read == (istream *)NULL) { + if (_read == nullptr) { // Time to open the next subfile. if (_request_index >= (int)_requests.size()) { // All done! @@ -167,7 +167,7 @@ step() { _subfile_length = _multifile->get_subfile_length(_subfile_index); _subfile_pos = 0; _read = _multifile->open_read_subfile(_subfile_index); - if (_read == (istream *)NULL) { + if (_read == nullptr) { downloader_cat.error() << "Unable to read subfile " << _multifile->get_subfile_name(_subfile_index) << ".\n"; @@ -183,7 +183,7 @@ step() { << "Finished current subfile.\n"; } Multifile::close_read_subfile(_read); - _read = (istream *)NULL; + _read = nullptr; _write.close(); _request_index++; diff --git a/panda/src/downloader/httpChannel.cxx b/panda/src/downloader/httpChannel.cxx index 30d1b3c7bf..990c89d4e6 100644 --- a/panda/src/downloader/httpChannel.cxx +++ b/panda/src/downloader/httpChannel.cxx @@ -105,14 +105,14 @@ HTTPChannel(HTTPClient *client) : _done_state = S_new; _started_download = false; _sent_so_far = 0; - _body_stream = NULL; + _body_stream = nullptr; _owns_body_stream = false; - _sbio = NULL; + _sbio = nullptr; _cipher_list = _client->get_cipher_list(); _last_status_code = 0; _last_run_time = 0.0f; - _download_to_ramfile = NULL; - _download_to_stream = NULL; + _download_to_ramfile = nullptr; + _download_to_stream = nullptr; } /** @@ -549,7 +549,7 @@ open_read_body() { reset_body_stream(); if ((_state != S_read_header && _state != S_begin_body) || _source.is_null()) { - return NULL; + return nullptr; } string transfer_coding = downcase(get_header_value("Transfer-Encoding")); @@ -588,7 +588,7 @@ open_read_body() { */ void HTTPChannel:: close_read_body(istream *stream) const { - if (stream != (istream *)NULL) { + if (stream != nullptr) { // For some reason--compiler bug in gcc 3.2?--explicitly deleting the // stream pointer does not call the appropriate global delete function; // instead apparently calling the system delete function. So we call the @@ -677,7 +677,7 @@ download_to_file(const Filename &filename, bool subdocument_resumes) { */ bool HTTPChannel:: download_to_ram(Ramfile *ramfile, bool subdocument_resumes) { - nassertr(ramfile != (Ramfile *)NULL, false); + nassertr(ramfile != nullptr, false); reset_download_to(); ramfile->_pos = 0; _download_to_ramfile = ramfile; @@ -762,11 +762,11 @@ download_to_stream(ostream *strm, bool subdocument_resumes) { SocketStream *HTTPChannel:: get_connection() { if (!is_connection_ready()) { - return NULL; + return nullptr; } BioStream *stream = _source->get_stream(); - _source->set_stream(NULL); + _source->set_stream(nullptr); // We're now passing ownership of the connection to the caller. if (downloader_cat.is_debug()) { @@ -814,7 +814,7 @@ body_stream_destructs(ISocketStream *stream) { break; } } - _body_stream = NULL; + _body_stream = nullptr; _owns_body_stream = false; } } @@ -887,7 +887,7 @@ reached_done_state() { } else { // Oops, we have to download the body now. open_read_body(); - if (_body_stream == (ISocketStream *)NULL) { + if (_body_stream == nullptr) { if (downloader_cat.is_debug()) { downloader_cat.debug() << _NOTIFY_HTTP_CHANNEL_ID @@ -924,7 +924,7 @@ run_try_next_proxy() { // Now try the next proxy in sequence. _proxy = _proxies[_proxy_next_index]; - _proxy_auth = (HTTPAuthorization *)NULL; + _proxy_auth = nullptr; _proxy_next_index++; close_connection(); reconsider_proxy(); @@ -1023,7 +1023,7 @@ run_connecting_wait() { tv.tv_sec = 0; tv.tv_usec = 0; } - int errcode = select(fd + 1, NULL, &wset, NULL, &tv); + int errcode = select(fd + 1, nullptr, &wset, nullptr, &tv); if (errcode < 0) { downloader_cat.warning() << _NOTIFY_HTTP_CHANNEL_ID @@ -1138,7 +1138,7 @@ run_http_proxy_reading_header() { // 407: not authorized to proxy. Try to get the authorization. string authenticate_request = get_header_value("Proxy-Authenticate"); _proxy_auth = _client->generate_auth(_proxy, true, authenticate_request); - if (_proxy_auth != (HTTPAuthorization *)NULL) { + if (_proxy_auth != nullptr) { _proxy_realm = _proxy_auth->get_realm(); _proxy_username = _client->select_username(_proxy, true, _proxy_realm); if (!_proxy_username.empty()) { @@ -1447,9 +1447,9 @@ run_setup_ssl() { _sbio = BIO_new_ssl(_client->get_ssl_ctx(), true); BIO_push(_sbio, *_bio); - SSL *ssl = NULL; + SSL *ssl = nullptr; BIO_get_ssl(_sbio, &ssl); - nassertr(ssl != (SSL *)NULL, false); + nassertr(ssl != nullptr, false); // We only take one word at a time from the _cipher_list. If that // connection fails, then we take the next word. @@ -1511,7 +1511,7 @@ run_setup_ssl() { const char *name; int pri = 0; name = SSL_get_cipher_list(ssl, pri); - while (name != NULL) { + while (name != nullptr) { downloader_cat.spam() << _NOTIFY_HTTP_CHANNEL_ID << " " << pri + 1 << ". " << name << "\n"; @@ -1585,16 +1585,16 @@ run_ssl_handshake() { return false; } - SSL *ssl = NULL; + SSL *ssl = nullptr; BIO_get_ssl(_sbio, &ssl); - nassertr(ssl != (SSL *)NULL, false); + nassertr(ssl != nullptr, false); if (!_nonblocking) { SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY); } const SSL_CIPHER *cipher = SSL_get_current_cipher(ssl); - if (cipher == (const SSL_CIPHER *)NULL) { + if (cipher == nullptr) { downloader_cat.warning() << _NOTIFY_HTTP_CHANNEL_ID << "No current cipher on SSL connection.\n"; @@ -1609,10 +1609,10 @@ run_ssl_handshake() { // Now that we've made an SSL handshake, we can use the SSL bio to do all of // our communication henceforth. _bio->set_bio(_sbio); - _sbio = NULL; + _sbio = nullptr; X509 *cert = SSL_get_peer_certificate(ssl); - if (cert == (X509 *)NULL) { + if (cert == nullptr) { downloader_cat.info() << _NOTIFY_HTTP_CHANNEL_ID << "No certificate was presented by server.\n"; @@ -1925,7 +1925,7 @@ run_reading_header() { string authenticate_request = get_header_value("Proxy-Authenticate"); _proxy_auth = _client->generate_auth(_proxy, true, authenticate_request); - if (_proxy_auth != (HTTPAuthorization *)NULL) { + if (_proxy_auth != nullptr) { _proxy_realm = _proxy_auth->get_realm(); _proxy_username = _client->select_username(_proxy, true, _proxy_realm); if (!_proxy_username.empty()) { @@ -1942,7 +1942,7 @@ run_reading_header() { // 401: not authorized to remote server. Try to get the authorization. string authenticate_request = get_header_value("WWW-Authenticate"); _www_auth = _client->generate_auth(_request.get_url(), false, authenticate_request); - if (_www_auth != (HTTPAuthorization *)NULL) { + if (_www_auth != nullptr) { _www_realm = _www_auth->get_realm(); _www_username = _client->select_username(_request.get_url(), false, _www_realm); if (!_www_username.empty()) { @@ -2090,7 +2090,7 @@ run_begin_body() { } else { open_read_body(); - if (_body_stream == (ISocketStream *)NULL) { + if (_body_stream == nullptr) { if (downloader_cat.is_debug()) { downloader_cat.debug() << _NOTIFY_HTTP_CHANNEL_ID @@ -2132,7 +2132,7 @@ run_reading_body() { } // Skip the body we've already started. - if (_body_stream == NULL || !_owns_body_stream) { + if (_body_stream == nullptr || !_owns_body_stream) { // Whoops, we're not in skip-body mode. Better reset. if (downloader_cat.is_debug()) { downloader_cat.debug() @@ -2232,7 +2232,7 @@ run_read_trailer() { */ bool HTTPChannel:: run_download_to_file() { - nassertr(_body_stream != (ISocketStream *)NULL && _owns_body_stream, false); + nassertr(_body_stream != nullptr && _owns_body_stream, false); bool do_throttle = _wanted_nonblocking && _download_throttle; @@ -2293,8 +2293,8 @@ run_download_to_file() { */ bool HTTPChannel:: run_download_to_ram() { - nassertr(_body_stream != (ISocketStream *)NULL && _owns_body_stream, false); - nassertr(_download_to_ramfile != (Ramfile *)NULL, false); + nassertr(_body_stream != nullptr && _owns_body_stream, false); + nassertr(_download_to_ramfile != nullptr, false); bool do_throttle = _wanted_nonblocking && _download_throttle; @@ -2343,7 +2343,7 @@ run_download_to_ram() { */ bool HTTPChannel:: run_download_to_stream() { - nassertr(_body_stream != (ISocketStream *)NULL && _owns_body_stream, false); + nassertr(_body_stream != nullptr && _owns_body_stream, false); bool do_throttle = _wanted_nonblocking && _download_throttle; @@ -2448,7 +2448,7 @@ begin_request(HTTPEnum::Method method, const DocumentSpec &url, // Changing the proxy is grounds for dropping the old connection, if any. if (_proxy != new_proxy) { _proxy = new_proxy; - _proxy_auth = (HTTPAuthorization *)NULL; + _proxy_auth = nullptr; if (downloader_cat.is_debug()) { downloader_cat.debug() << _NOTIFY_HTTP_CHANNEL_ID @@ -2490,16 +2490,16 @@ begin_request(HTTPEnum::Method method, const DocumentSpec &url, // underneath this. reset_to_new(); _bio = new BioPtr(_request.get_url()); - if (_bio->get_bio() != NULL) { + if (_bio->get_bio() != nullptr) { // Successfully opened the file. _source = new BioStreamPtr(new BioStream(_bio)); _status_entry._status_code = 200; _state = S_start_direct_file_read; // Get the file size. - FILE *fp = NULL; + FILE *fp = nullptr; BIO_get_fp(_bio->get_bio(), &fp); - if (fp != NULL) { + if (fp != nullptr) { if (fseek(fp, 0, SEEK_END) == 0) { _file_size = ftell(fp); _got_file_size = true; @@ -2663,7 +2663,7 @@ open_download_file() { if (_download_dest == DD_file) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); _download_to_stream = vfs->open_write_file(_download_to_filename, false, !_subdocument_resumes); - if (_download_to_stream == NULL) { + if (_download_to_stream == nullptr) { downloader_cat.info() << _NOTIFY_HTTP_CHANNEL_ID << "Could not open " << _download_to_filename << " for writing.\n"; @@ -3339,8 +3339,8 @@ validate_server_name(X509 *cert) { // According to RFC 2818, we should check the DNS name(s) in the // subjectAltName extension first, if that extension exists. STACK_OF(GENERAL_NAME) *subject_alt_names = - (STACK_OF(GENERAL_NAME) *)X509_get_ext_d2i(cert, NID_subject_alt_name, NULL, NULL); - if (subject_alt_names != NULL) { + (STACK_OF(GENERAL_NAME) *)X509_get_ext_d2i(cert, NID_subject_alt_name, nullptr, nullptr); + if (subject_alt_names != nullptr) { int num_alts = sk_GENERAL_NAME_num(subject_alt_names); for (int i = 0; i < num_alts; ++i) { // Get the ith alt name. @@ -3348,13 +3348,13 @@ validate_server_name(X509 *cert) { sk_GENERAL_NAME_value(subject_alt_names, i); if (alt_name->type == GEN_DNS) { - char *buffer = NULL; + char *buffer = nullptr; int len = ASN1_STRING_to_UTF8((unsigned char**)&buffer, alt_name->d.ia5); if (len > 0) { cert_names.push_back(string(buffer, len)); } - if (buffer != NULL) { + if (buffer != nullptr) { OPENSSL_free(buffer); } } @@ -3365,7 +3365,7 @@ validate_server_name(X509 *cert) { // If there were no DNS names, use the common name instead. X509_NAME *xname = X509_get_subject_name(cert); - if (xname != NULL) { + if (xname != nullptr) { string common_name = get_x509_name_component(xname, NID_commonName); cert_names.push_back(common_name); } @@ -3444,7 +3444,7 @@ string HTTPChannel:: get_x509_name_component(X509_NAME *name, int nid) { ASN1_OBJECT *obj = OBJ_nid2obj(nid); - if (obj == NULL) { + if (obj == nullptr) { // Unknown nid. See opensslobjects.h. return string(); } @@ -3467,7 +3467,7 @@ void HTTPChannel:: make_header() { _proxy_auth = _client->select_auth(_proxy, true, _proxy_realm); _proxy_username = string(); - if (_proxy_auth != (HTTPAuthorization *)NULL) { + if (_proxy_auth != nullptr) { _proxy_realm = _proxy_auth->get_realm(); _proxy_username = _client->select_username(_proxy, true, _proxy_realm); } @@ -3482,7 +3482,7 @@ make_header() { _www_auth = _client->select_auth(_request.get_url(), false, _www_realm); _www_username = string(); - if (_www_auth != (HTTPAuthorization *)NULL) { + if (_www_auth != nullptr) { _www_realm = _www_auth->get_realm(); _www_username = _client->select_username(_request.get_url(), false, _www_realm); } @@ -3642,7 +3642,7 @@ void HTTPChannel:: make_proxy_request_text() { _proxy_request_text = _proxy_header; - if (_proxy_auth != (HTTPAuthorization *)NULL && !_proxy_username.empty()) { + if (_proxy_auth != nullptr && !_proxy_username.empty()) { _proxy_request_text += "Proxy-Authorization: "; _proxy_request_text += _proxy_auth->generate(HTTPEnum::M_connect, _request.get_url().get_server_and_port(), @@ -3662,14 +3662,14 @@ make_request_text() { _request_text = _header; if (_proxy_serves_document && - _proxy_auth != (HTTPAuthorization *)NULL && !_proxy_username.empty()) { + _proxy_auth != nullptr && !_proxy_username.empty()) { _request_text += "Proxy-Authorization: "; _request_text += _proxy_auth->generate(_method, _request.get_url().get_url(), _proxy_username, _body); _request_text += "\r\n"; } - if (_www_auth != (HTTPAuthorization *)NULL && !_www_username.empty()) { + if (_www_auth != nullptr && !_www_username.empty()) { string authorization = _request_text += "Authorization: "; _request_text += @@ -3767,14 +3767,14 @@ reset_download_to() { */ void HTTPChannel:: close_download_stream() { - if (_download_to_stream != NULL) { + if (_download_to_stream != nullptr) { _download_to_stream->flush(); if (_download_dest == DD_file) { VirtualFileSystem::close_write_file(_download_to_stream); } } - _download_to_ramfile = (Ramfile *)NULL; - _download_to_stream = NULL; + _download_to_ramfile = nullptr; + _download_to_stream = nullptr; } @@ -3799,12 +3799,12 @@ reset_to_new() { void HTTPChannel:: reset_body_stream() { if (_owns_body_stream) { - if (_body_stream != (ISocketStream *)NULL) { + if (_body_stream != nullptr) { close_read_body(_body_stream); - nassertv(_body_stream == (ISocketStream *)NULL && !_owns_body_stream); + nassertv(_body_stream == nullptr && !_owns_body_stream); } } else { - _body_stream = NULL; + _body_stream = nullptr; } } diff --git a/panda/src/downloader/httpClient.cxx b/panda/src/downloader/httpClient.cxx index 4770d6916d..7183b36ddf 100644 --- a/panda/src/downloader/httpClient.cxx +++ b/panda/src/downloader/httpClient.cxx @@ -216,7 +216,7 @@ HTTPClient() { _http_version = HTTPEnum::HV_11; _verify_ssl = verify_ssl ? VS_normal : VS_no_verify; - _ssl_ctx = (SSL_CTX *)NULL; + _ssl_ctx = nullptr; set_proxy_spec(http_proxy); set_direct_host_spec(http_direct_hosts); @@ -241,8 +241,8 @@ HTTPClient() { _client_certificate_passphrase = http_client_certificate_passphrase; _client_certificate_loaded = false; - _client_certificate_pub = NULL; - _client_certificate_priv = NULL; + _client_certificate_pub = nullptr; + _client_certificate_priv = nullptr; int num_server_certs = http_preapproved_server_certificate_filename.get_num_unique_values(); int si; @@ -271,7 +271,7 @@ HTTPClient() { */ HTTPClient:: HTTPClient(const HTTPClient ©) { - _ssl_ctx = (SSL_CTX *)NULL; + _ssl_ctx = nullptr; (*this) = copy; } @@ -295,12 +295,12 @@ operator = (const HTTPClient ©) { */ HTTPClient:: ~HTTPClient() { - if (_ssl_ctx != (SSL_CTX *)NULL) { + if (_ssl_ctx != nullptr) { #if OPENSSL_VERSION_NUMBER < 0x10100000 // Before we can free the context, we must remove the X509_STORE pointer // from it, so it won't be destroyed along with it (this object is shared // among all contexts). - _ssl_ctx->cert_store = NULL; + _ssl_ctx->cert_store = nullptr; #endif SSL_CTX_free(_ssl_ctx); } @@ -866,7 +866,7 @@ load_client_certificate() { ERR_clear_error(); _client_certificate_priv = - PEM_read_bio_PrivateKey(mbio, NULL, NULL, + PEM_read_bio_PrivateKey(mbio, nullptr, nullptr, (char *)_client_certificate_passphrase.c_str()); // Rewind the "file" to the beginning in order to read the public key @@ -875,7 +875,7 @@ load_client_certificate() { ERR_clear_error(); _client_certificate_pub = - PEM_read_bio_X509(mbio, NULL, NULL, NULL); + PEM_read_bio_X509(mbio, nullptr, nullptr, nullptr); BIO_free(mbio); @@ -891,18 +891,18 @@ load_client_certificate() { } if (downloader_cat.is_on(sev)) { - if (_client_certificate_priv != (EVP_PKEY *)NULL && - _client_certificate_pub != (X509 *)NULL) { + if (_client_certificate_priv != nullptr && + _client_certificate_pub != nullptr) { downloader_cat.out(sev) << "Read client certificate from " << source << "\n"; } else { - if (_client_certificate_priv == (EVP_PKEY *)NULL) { + if (_client_certificate_priv == nullptr) { downloader_cat.out(sev) << "Could not read private key from " << source << "\n"; } - if (_client_certificate_pub == (X509 *)NULL) { + if (_client_certificate_pub == nullptr) { downloader_cat.out(sev) << "Could not read public key from " << source << "\n"; } @@ -911,8 +911,8 @@ load_client_certificate() { } } - return (_client_certificate_priv != (EVP_PKEY *)NULL && - _client_certificate_pub != (X509 *)NULL); + return (_client_certificate_priv != nullptr && + _client_certificate_pub != nullptr); } /** @@ -961,10 +961,10 @@ add_preapproved_server_certificate_pem(const URLSpec &url, const string &pem) { BIO *mbio = BIO_new_mem_buf((void *)pem.data(), pem.length()); ERR_clear_error(); - X509 *cert = PEM_read_bio_X509(mbio, NULL, NULL, NULL); + X509 *cert = PEM_read_bio_X509(mbio, nullptr, nullptr, nullptr); BIO_free(mbio); - if (cert == NULL) { + if (cert == nullptr) { downloader_cat.warning() << "Could not parse PEM data\n"; return false; @@ -1003,7 +1003,7 @@ add_preapproved_server_certificate_pem(const URLSpec &url, const string &pem) { bool HTTPClient:: add_preapproved_server_certificate_name(const URLSpec &url, const string &name) { X509_NAME *cert_name = parse_x509_name(name); - if (cert_name == NULL) { + if (cert_name == nullptr) { downloader_cat.warning() << "Could not parse certificate name " << name << "\n"; return false; @@ -1156,7 +1156,7 @@ get_header(const URLSpec &url) { */ HTTPClient *HTTPClient:: get_global_ptr() { - if (_global_ptr == NULL) { + if (_global_ptr == nullptr) { _global_ptr = new HTTPClient; } return _global_ptr; @@ -1168,7 +1168,7 @@ get_global_ptr() { */ SSL_CTX *HTTPClient:: get_ssl_ctx() { - if (_ssl_ctx != (SSL_CTX *)NULL) { + if (_ssl_ctx != nullptr) { return _ssl_ctx; } @@ -1190,7 +1190,7 @@ get_ssl_ctx() { X509_STORE *store = sslw->get_x509_store(); #if OPENSSL_VERSION_NUMBER >= 0x10100000 - if (store != NULL) { + if (store != nullptr) { X509_STORE_up_ref(store); } #endif @@ -1419,7 +1419,7 @@ select_auth(const URLSpec &url, bool is_proxy, const string &last_realm) { } // No matching domains. - return NULL; + return nullptr; } /** @@ -1441,14 +1441,14 @@ generate_auth(const URLSpec &url, bool is_proxy, const string &challenge) { auth = new HTTPDigestAuthorization((*si).second, url, is_proxy); } - if (auth == (HTTPAuthorization *)NULL || !auth->is_valid()) { + if (auth == nullptr || !auth->is_valid()) { si = schemes.find("basic"); if (si != schemes.end()) { auth = new HTTPBasicAuthorization((*si).second, url, is_proxy); } } - if (auth == (HTTPAuthorization *)NULL || !auth->is_valid()) { + if (auth == nullptr || !auth->is_valid()) { downloader_cat.warning() << "Don't know how to use any of the server's available authorization schemes:\n"; for (si = schemes.begin(); si != schemes.end(); ++si) { @@ -1475,14 +1475,14 @@ generate_auth(const URLSpec &url, bool is_proxy, const string &challenge) { */ void HTTPClient:: unload_client_certificate() { - if (_client_certificate_priv != (EVP_PKEY *)NULL) { + if (_client_certificate_priv != nullptr) { EVP_PKEY_free(_client_certificate_priv); - _client_certificate_priv = NULL; + _client_certificate_priv = nullptr; } - if (_client_certificate_pub != (X509 *)NULL) { + if (_client_certificate_pub != nullptr) { X509_free(_client_certificate_pub); - _client_certificate_pub = NULL; + _client_certificate_pub = nullptr; } _client_certificate_loaded = false; @@ -1494,7 +1494,7 @@ unload_client_certificate() { */ X509_NAME *HTTPClient:: parse_x509_name(const string &source) { - X509_NAME *result = NULL; + X509_NAME *result = nullptr; result = X509_NAME_new(); bool added_any = false; @@ -1526,7 +1526,7 @@ parse_x509_name(const string &source) { << "Unknown type " << type << " in X509 name: " << source << "\n"; X509_NAME_free(result); - return NULL; + return nullptr; } string value; @@ -1556,7 +1556,7 @@ parse_x509_name(const string &source) { << "Unable to add " << type << "=" << value << " in X509 name: " << source << "\n"; X509_NAME_free(result); - return NULL; + return nullptr; } added_any = true; } @@ -1567,7 +1567,7 @@ parse_x509_name(const string &source) { downloader_cat.info() << "Invalid empty X509 name: " << source << "\n"; X509_NAME_free(result); - return NULL; + return nullptr; } return result; diff --git a/panda/src/downloader/httpDate.I b/panda/src/downloader/httpDate.I index 9b5adbefe4..67aefbccb3 100644 --- a/panda/src/downloader/httpDate.I +++ b/panda/src/downloader/httpDate.I @@ -45,7 +45,7 @@ operator = (const HTTPDate ©) { */ INLINE HTTPDate HTTPDate:: now() { - return HTTPDate(time(NULL)); + return HTTPDate(time(nullptr)); } /** diff --git a/panda/src/downloader/httpDate.cxx b/panda/src/downloader/httpDate.cxx index f3d156fc6a..f8877a65c8 100644 --- a/panda/src/downloader/httpDate.cxx +++ b/panda/src/downloader/httpDate.cxx @@ -182,7 +182,7 @@ HTTPDate(const string &format) { if (t.tm_year < 100) { // Two-digit year. Assume it's in the same century, unless that // assumption puts it more than 50 years in the future. - time_t now = time(NULL); + time_t now = time(nullptr); struct tm *tp = gmtime(&now); t.tm_year += 100 * (tp->tm_year / 100); if (t.tm_year - tp->tm_year > 50) { @@ -219,7 +219,7 @@ HTTPDate(const string &format) { if (_time != (time_t)-1) { // Unfortunately, mktime() assumes local time; convert this back to GMT. #if defined(IS_FREEBSD) - time_t now = time(NULL); + time_t now = time(nullptr); struct tm *tp = localtime(&now); _time -= tp->tm_gmtoff; #elif defined(_WIN32) diff --git a/panda/src/downloader/httpDigestAuthorization.cxx b/panda/src/downloader/httpDigestAuthorization.cxx index e8cddbb18b..8bb2804bcf 100644 --- a/panda/src/downloader/httpDigestAuthorization.cxx +++ b/panda/src/downloader/httpDigestAuthorization.cxx @@ -86,7 +86,7 @@ HTTPDigestAuthorization(const HTTPAuthorization::Tokens &tokens, // Compute an arbitrary client nonce. ostringstream strm; - strm << time(NULL) << ":" << clock() << ":" + strm << time(nullptr) << ":" << clock() << ":" << url.get_url() << ":Panda"; _cnonce = calc_md5(strm.str()); diff --git a/panda/src/downloader/identityStream.cxx b/panda/src/downloader/identityStream.cxx index f047ac1a6e..335cb9fd23 100644 --- a/panda/src/downloader/identityStream.cxx +++ b/panda/src/downloader/identityStream.cxx @@ -22,9 +22,9 @@ */ IIdentityStream:: ~IIdentityStream() { - if (_channel != (HTTPChannel *)NULL) { + if (_channel != nullptr) { _channel->body_stream_destructs(this); - _channel = NULL; + _channel = nullptr; } } diff --git a/panda/src/downloader/identityStreamBuf.I b/panda/src/downloader/identityStreamBuf.I index 6001a14fc0..b879886dd1 100644 --- a/panda/src/downloader/identityStreamBuf.I +++ b/panda/src/downloader/identityStreamBuf.I @@ -16,7 +16,7 @@ */ INLINE bool IdentityStreamBuf:: is_closed() const { - return (_source == (BioStreamPtr *)NULL || (*_source)->is_closed()); + return (_source == nullptr || (*_source)->is_closed()); } /** diff --git a/panda/src/downloader/multiplexStream.I b/panda/src/downloader/multiplexStream.I index 1da8528d0b..2a99a110d3 100644 --- a/panda/src/downloader/multiplexStream.I +++ b/panda/src/downloader/multiplexStream.I @@ -27,7 +27,7 @@ INLINE void MultiplexStream:: add_ostream(ostream *out, bool delete_later) { _msb.add_output(MultiplexStreamBuf::BT_none, MultiplexStreamBuf::OT_ostream, - out, NULL, delete_later); + out, nullptr, delete_later); } /** @@ -38,7 +38,7 @@ INLINE bool MultiplexStream:: add_stdio_file(FILE *fout, bool close_when_done) { _msb.add_output(MultiplexStreamBuf::BT_line, MultiplexStreamBuf::OT_ostream, - NULL, fout, close_when_done); + nullptr, fout, close_when_done); return true; } @@ -49,7 +49,7 @@ INLINE void MultiplexStream:: add_standard_output() { _msb.add_output(MultiplexStreamBuf::BT_none, MultiplexStreamBuf::OT_ostream, - &cout, NULL, false); + &cout, nullptr, false); } /** @@ -68,7 +68,7 @@ add_file(Filename file) { _msb.add_output(MultiplexStreamBuf::BT_line, MultiplexStreamBuf::OT_ostream, - out, NULL, true); + out, nullptr, true); return true; } diff --git a/panda/src/downloader/multiplexStreamBuf.cxx b/panda/src/downloader/multiplexStreamBuf.cxx index 8d290a2d6d..3b6b0a8b10 100644 --- a/panda/src/downloader/multiplexStreamBuf.cxx +++ b/panda/src/downloader/multiplexStreamBuf.cxx @@ -32,12 +32,12 @@ close() { if (_owns_obj) { switch (_output_type) { case OT_ostream: - assert(_out != (ostream *)NULL); + assert(_out != nullptr); delete _out; break; case OT_stdio: - assert(_fout != (FILE *)NULL); + assert(_fout != nullptr); fclose(_fout); break; @@ -54,13 +54,13 @@ void MultiplexStreamBuf::Output:: write_string(const string &str) { switch (_output_type) { case OT_ostream: - assert(_out != (ostream *)NULL); + assert(_out != nullptr); _out->write(str.data(), str.length()); _out->flush(); break; case OT_stdio: - assert(_fout != (FILE *)NULL); + assert(_fout != nullptr); fwrite(str.data(), str.length(), 1, _fout); fflush(_fout); break; diff --git a/panda/src/downloader/multiplexStreamBuf.h b/panda/src/downloader/multiplexStreamBuf.h index d869124116..0e440f6ab1 100644 --- a/panda/src/downloader/multiplexStreamBuf.h +++ b/panda/src/downloader/multiplexStreamBuf.h @@ -41,8 +41,8 @@ public: }; void add_output(BufferType buffer_type, OutputType output_type, - ostream *out = (ostream *)NULL, - FILE *fout = (FILE *)NULL, + ostream *out = nullptr, + FILE *fout = nullptr, bool owns_obj = false); void flush(); diff --git a/panda/src/downloader/patcher.cxx b/panda/src/downloader/patcher.cxx index 70d0f99ef2..c0b86f2c61 100644 --- a/panda/src/downloader/patcher.cxx +++ b/panda/src/downloader/patcher.cxx @@ -44,7 +44,7 @@ init(PT(Buffer) buffer) { nassertv(!buffer.is_null()); _buffer = buffer; - _patchfile = NULL; + _patchfile = nullptr; _patchfile = new Patchfile(_buffer); } diff --git a/panda/src/downloader/socketStream.I b/panda/src/downloader/socketStream.I index 21026ebdb4..8ac4914567 100644 --- a/panda/src/downloader/socketStream.I +++ b/panda/src/downloader/socketStream.I @@ -162,7 +162,7 @@ flush() { */ INLINE ISocketStream:: ISocketStream(streambuf *buf) : istream(buf), SSReader(this) { - _channel = NULL; + _channel = nullptr; } /** diff --git a/panda/src/downloader/socketStream.cxx b/panda/src/downloader/socketStream.cxx index 4e441f8f2b..4d52a82cb5 100644 --- a/panda/src/downloader/socketStream.cxx +++ b/panda/src/downloader/socketStream.cxx @@ -248,7 +248,7 @@ send_datagram(const Datagram &dg) { ISocketStream:: ~ISocketStream() { // This should already have been cleared by the subclass destructor. - nassertv(_channel == NULL); + nassertv(_channel == nullptr); } #endif // HAVE_OPENSSL diff --git a/panda/src/downloader/stringStream_ext.cxx b/panda/src/downloader/stringStream_ext.cxx index c9d66ca0a7..631c6f4a04 100644 --- a/panda/src/downloader/stringStream_ext.cxx +++ b/panda/src/downloader/stringStream_ext.cxx @@ -51,7 +51,7 @@ void Extension:: set_data(PyObject *data) { _this->_buf.clear(); - if (data == NULL) { + if (data == nullptr) { return; } diff --git a/panda/src/downloader/virtualFileHTTP.cxx b/panda/src/downloader/virtualFileHTTP.cxx index 03bfaa1737..27f33c644a 100644 --- a/panda/src/downloader/virtualFileHTTP.cxx +++ b/panda/src/downloader/virtualFileHTTP.cxx @@ -121,7 +121,7 @@ is_regular_file() const { istream *VirtualFileHTTP:: open_read_file(bool auto_unwrap) const { if (_status_only) { - return NULL; + return nullptr; } // We pre-download the file into a StringStream, then return a buffer to @@ -130,7 +130,7 @@ open_read_file(bool auto_unwrap) const { StringStream *strstream = new StringStream; if (!fetch_file(strstream)) { delete strstream; - return NULL; + return nullptr; } return return_file(strstream, auto_unwrap); @@ -178,7 +178,7 @@ return_file(istream *buffer_stream, bool auto_unwrap) const { istream *result = buffer_stream; #ifdef HAVE_ZLIB - if (result != (istream *)NULL && do_unwrap) { + if (result != nullptr && do_unwrap) { // We have to slip in a layer to decompress the file on the fly. IDecompressStream *wrapper = new IDecompressStream(result, true); result = wrapper; diff --git a/panda/src/downloader/virtualFileMountHTTP.cxx b/panda/src/downloader/virtualFileMountHTTP.cxx index 9ad783da87..c9cc4759a0 100644 --- a/panda/src/downloader/virtualFileMountHTTP.cxx +++ b/panda/src/downloader/virtualFileMountHTTP.cxx @@ -176,7 +176,7 @@ make_virtual_file(const Filename &local_filename, */ istream *VirtualFileMountHTTP:: open_read_file(const Filename &) const { - return NULL; + return nullptr; } /** diff --git a/panda/src/downloadertools/multify.cxx b/panda/src/downloadertools/multify.cxx index b26de65ab1..3b58ca0d23 100644 --- a/panda/src/downloadertools/multify.cxx +++ b/panda/src/downloadertools/multify.cxx @@ -610,7 +610,7 @@ format_timestamp(bool record_timestamp, time_t timestamp) { return " (no date) "; } - time_t now = time(NULL); + time_t now = time(nullptr); struct tm *tm_p = localtime(×tamp); if (timestamp > now || (now - timestamp > 86400 * 365)) { @@ -635,7 +635,7 @@ list_files(const vector_string ¶ms) { // So this is the only place where we accept a .pz/.gz compressed .mf. VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *istr = vfs->open_read_file(multifile_name, true); - if (istr == NULL) { + if (istr == nullptr) { cerr << "Unable to open " << multifile_name << " for reading.\n"; return false; } diff --git a/panda/src/dxgsg9/dxGeomMunger9.I b/panda/src/dxgsg9/dxGeomMunger9.I index 223e6478cb..596802b871 100644 --- a/panda/src/dxgsg9/dxGeomMunger9.I +++ b/panda/src/dxgsg9/dxGeomMunger9.I @@ -20,9 +20,9 @@ DXGeomMunger9(GraphicsStateGuardian *gsg, const RenderState *state) : _texture(DCAST(TextureAttrib, state->get_attrib(TextureAttrib::get_class_slot()))), _tex_gen(DCAST(TexGenAttrib, state->get_attrib(TexGenAttrib::get_class_slot()))) { - _filtered_texture = (TextureAttrib *)NULL; + _filtered_texture = nullptr; _reffed_filtered_texture = false; - if (_texture != (TextureAttrib *)NULL) { + if (_texture != nullptr) { _filtered_texture = _texture->filter_to_max(gsg->get_max_texture_stages()); if (_filtered_texture != _texture) { _filtered_texture->ref(); diff --git a/panda/src/dxgsg9/dxGeomMunger9.cxx b/panda/src/dxgsg9/dxGeomMunger9.cxx index e9b9ba498e..cce0f2e6f0 100644 --- a/panda/src/dxgsg9/dxGeomMunger9.cxx +++ b/panda/src/dxgsg9/dxGeomMunger9.cxx @@ -16,7 +16,7 @@ #include "geomVertexWriter.h" #include "config_dxgsg9.h" -GeomMunger *DXGeomMunger9::_deleted_chain = NULL; +GeomMunger *DXGeomMunger9::_deleted_chain = nullptr; TypeHandle DXGeomMunger9::_type_handle; /** @@ -72,7 +72,7 @@ munge_format_impl(const GeomVertexFormat *orig, const GeomVertexColumn *normal_type = orig->get_normal_column(); const GeomVertexColumn *color_type = orig->get_color_column(); - if (vertex_type != (const GeomVertexColumn *)NULL) { + if (vertex_type != nullptr) { new_array_format->add_column (InternalName::get_vertex(), 3, NT_float32, vertex_type->get_contents()); @@ -109,13 +109,13 @@ munge_format_impl(const GeomVertexFormat *orig, new_format->remove_column(InternalName::get_transform_blend()); } - if (normal_type != (const GeomVertexColumn *)NULL) { + if (normal_type != nullptr) { new_array_format->add_column (InternalName::get_normal(), 3, NT_float32, C_normal); new_format->remove_column(normal_type->get_name()); } - if (color_type != (const GeomVertexColumn *)NULL) { + if (color_type != nullptr) { new_array_format->add_column (InternalName::get_color(), 1, NT_packed_dabc, C_color); new_format->remove_column(color_type->get_name()); @@ -127,7 +127,7 @@ munge_format_impl(const GeomVertexFormat *orig, // Now set up each of the active texture coordinate stages--or at least // those for which we're not generating texture coordinates automatically. - if (_filtered_texture != (TextureAttrib *)NULL) { + if (_filtered_texture != nullptr) { int num_stages = _filtered_texture->get_num_on_ff_stages(); vector_int ff_tc_index(num_stages, 0); @@ -153,7 +153,7 @@ munge_format_impl(const GeomVertexFormat *orig, const GeomVertexColumn *texcoord_type = orig->get_column(name); - if (texcoord_type != (const GeomVertexColumn *)NULL) { + if (texcoord_type != nullptr) { new_array_format->add_column (name, texcoord_type->get_num_values(), NT_float32, C_texcoord); } else { @@ -201,7 +201,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { const GeomVertexColumn *normal_type = orig->get_normal_column(); const GeomVertexColumn *color_type = orig->get_color_column(); - if (vertex_type != (const GeomVertexColumn *)NULL) { + if (vertex_type != nullptr) { new_array_format->add_column (InternalName::get_vertex(), 3, NT_float32, vertex_type->get_contents()); @@ -212,13 +212,13 @@ premunge_format_impl(const GeomVertexFormat *orig) { return orig; } - if (normal_type != (const GeomVertexColumn *)NULL) { + if (normal_type != nullptr) { new_array_format->add_column (InternalName::get_normal(), 3, NT_float32, C_normal); new_format->remove_column(normal_type->get_name()); } - if (color_type != (const GeomVertexColumn *)NULL) { + if (color_type != nullptr) { new_array_format->add_column (InternalName::get_color(), 1, NT_packed_dabc, C_color); new_format->remove_column(color_type->get_name()); @@ -230,7 +230,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { // Now set up each of the active texture coordinate stages--or at least // those for which we're not generating texture coordinates automatically. - if (_filtered_texture != (TextureAttrib *)NULL) { + if (_filtered_texture != nullptr) { int num_stages = _filtered_texture->get_num_on_ff_stages(); vector_int ff_tc_index(num_stages, 0); @@ -256,7 +256,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { const GeomVertexColumn *texcoord_type = orig->get_column(name); - if (texcoord_type != (const GeomVertexColumn *)NULL) { + if (texcoord_type != nullptr) { new_array_format->add_column (name, texcoord_type->get_num_values(), NT_float32, C_texcoord); } else { diff --git a/panda/src/dxgsg9/dxGraphicsDevice9.cxx b/panda/src/dxgsg9/dxGraphicsDevice9.cxx index 6e79bb3c98..3b7f0abd82 100644 --- a/panda/src/dxgsg9/dxGraphicsDevice9.cxx +++ b/panda/src/dxgsg9/dxGraphicsDevice9.cxx @@ -23,8 +23,8 @@ DXGraphicsDevice9(wdxGraphicsPipe9 *pipe) : GraphicsDevice(pipe) { ZeroMemory(&_Scrn,sizeof(_Scrn)); - _d3d_device = NULL; - _swap_chain = NULL; + _d3d_device = nullptr; + _swap_chain = nullptr; } /** diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.I b/panda/src/dxgsg9/dxGraphicsStateGuardian9.I index 94e50a5f7d..51846fd33c 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.I +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.I @@ -121,7 +121,7 @@ get_tex_mat_sym(int stage_index) { */ INLINE unsigned char *DXGraphicsStateGuardian9:: get_safe_buffer_start() { - if (_temp_buffer == NULL) { + if (_temp_buffer == nullptr) { // Guarantee we get a buffer of size 0x10000 bytes that begins on an even // multiple of 0x10000. We do this by allocating double the required // buffer, and then pointing to the first multiple of 0x10000 within that diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index 8326068dc1..389baa4dca 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -81,11 +81,11 @@ TypeHandle DXGraphicsStateGuardian9::_type_handle; D3DMATRIX DXGraphicsStateGuardian9::_d3d_ident_mat; -unsigned char *DXGraphicsStateGuardian9::_temp_buffer = NULL; -unsigned char *DXGraphicsStateGuardian9::_safe_buffer_start = NULL; +unsigned char *DXGraphicsStateGuardian9::_temp_buffer = nullptr; +unsigned char *DXGraphicsStateGuardian9::_safe_buffer_start = nullptr; #ifdef HAVE_CG -LPDIRECT3DDEVICE9 DXGraphicsStateGuardian9::_cg_device = NULL; +LPDIRECT3DDEVICE9 DXGraphicsStateGuardian9::_cg_device = nullptr; #endif #define __D3DLIGHT_RANGE_MAX ((PN_stdfloat)sqrt(FLT_MAX)) //for some reason this is missing in dx9 hdrs @@ -108,8 +108,8 @@ DXGraphicsStateGuardian9(GraphicsEngine *engine, GraphicsPipe *pipe) : // tells us otherwise. _is_hardware = true; - _screen = NULL; - _d3d_device = NULL; + _screen = nullptr; + _d3d_device = nullptr; _dx_is_ready = false; _vertex_blending_enabled = false; @@ -117,7 +117,7 @@ DXGraphicsStateGuardian9(GraphicsEngine *engine, GraphicsPipe *pipe) : _tex_stats_retrieval_impossible = false; _supports_render_texture = false; - _active_ibuffer = NULL; + _active_ibuffer = nullptr; // This is a static member, but we initialize it here in the constructor // anyway. It won't hurt if it gets repeatedly initalized. @@ -168,7 +168,7 @@ DXGraphicsStateGuardian9:: } if (IS_VALID_PTR(_d3d_device)) { - _d3d_device->SetTexture(0, NULL); // this frees reference to the old texture + _d3d_device->SetTexture(0, nullptr); // this frees reference to the old texture } free_nondx_resources(); @@ -190,7 +190,7 @@ prepare_texture(Texture *tex, int view) { if (!get_supports_compressed_texture_format(tex->get_ram_image_compression())) { dxgsg9_cat.error() << *dtc->get_texture() << " is stored in an unsupported compressed format.\n"; - return NULL; + return nullptr; } return dtc; @@ -202,7 +202,7 @@ prepare_texture(Texture *tex, int view) { */ void DXGraphicsStateGuardian9:: apply_texture(int i, TextureContext *tc, const SamplerState &sampler) { - if (tc == (TextureContext *)NULL) { + if (tc == nullptr) { // The texture wasn't bound properly or something, so ensure texturing is // disabled and just return. set_texture_stage_state(i, D3DTSS_COLOROP, D3DTOP_DISABLE); @@ -387,7 +387,7 @@ extract_texture_data(Texture *tex) { int num_views = tex->get_num_views(); for (int view = 0; view < num_views; ++view) { TextureContext *tc = tex->prepare_now(view, get_prepared_objects(), this); - nassertr(tc != (TextureContext *)NULL, false); + nassertr(tc != nullptr, false); DXTextureContext9 *dtc = DCAST(DXTextureContext9, tc); if (!dtc->extract_texture_data(*_screen)) { @@ -409,7 +409,7 @@ prepare_shader(Shader *se) { case Shader::SL_GLSL: dxgsg9_cat.error() << "Tried to load GLSL shader, but GLSL shaders not supported by Direct3D 9.\n"; - return NULL; + return nullptr; case Shader::SL_Cg: #ifdef HAVE_CG @@ -418,21 +418,21 @@ prepare_shader(Shader *se) { } else { dxgsg9_cat.error() << "Tried to load Cg shader, but basic shaders not supported.\n"; - return NULL; + return nullptr; } #else dxgsg9_cat.error() << "Tried to load Cg shader, but Cg support not compiled in.\n"; - return NULL; + return nullptr; #endif default: dxgsg9_cat.error() << "Tried to load shader with unsupported shader language!\n"; - return NULL; + return nullptr; } - return NULL; + return nullptr; } /** @@ -476,7 +476,7 @@ prepare_vertex_buffer(GeomVertexArrayData *data) { int attempts = 0; do { - hr = _screen->_d3d_device->CreateVertexBuffer(num_bytes, usage, dvbc->_fvf, pool, &dvbc->_vbuffer, NULL); + hr = _screen->_d3d_device->CreateVertexBuffer(num_bytes, usage, dvbc->_fvf, pool, &dvbc->_vbuffer, nullptr); attempts++; } while (check_dx_allocation(hr, num_bytes, attempts)); @@ -496,10 +496,10 @@ prepare_vertex_buffer(GeomVertexArrayData *data) { dxgsg9_cat.error() << "CreateVertexBuffer failed" << D3DERRORSTRING(hr); - dvbc->_vbuffer = NULL; + dvbc->_vbuffer = nullptr; } - return NULL; + return nullptr; } /** @@ -524,7 +524,7 @@ apply_vertex_buffer(VertexBufferContext *vbc, if ( num_bytes != 0 ) { const unsigned char *client_pointer = reader->get_read_pointer(force); - if (client_pointer == NULL) { + if (client_pointer == nullptr) { return false; } @@ -582,7 +582,7 @@ release_vertex_buffer(VertexBufferContext *vbc) { #endif dvbc->_vbuffer->Release(); - dvbc->_vbuffer = NULL; + dvbc->_vbuffer = nullptr; delete dvbc; } @@ -607,7 +607,7 @@ setup_array_data(DXVertexBufferContext9*& dvbc, // Prepare the buffer object and bind it. VertexBufferContext* vbc = ((GeomVertexArrayData *)array_reader->get_object())->prepare_now(get_prepared_objects(), this); - nassertr(vbc != (VertexBufferContext *)NULL, false); + nassertr(vbc != nullptr, false); if (!apply_vertex_buffer(vbc, array_reader, force)) { return false; } @@ -640,11 +640,11 @@ apply_index_buffer(IndexBufferContext *ibc, const GeomPrimitivePipelineReader *reader, bool force) { DXIndexBufferContext9 *dibc = DCAST(DXIndexBufferContext9, ibc); - if (dibc->_ibuffer == NULL) { + if (dibc->_ibuffer == nullptr) { // Attempt to create a new index buffer. dibc->create_ibuffer(*_screen, reader); - if (dibc->_ibuffer != NULL) { + if (dibc->_ibuffer != nullptr) { if (!dibc->upload_data(reader, force)) { return false; } @@ -655,8 +655,8 @@ apply_index_buffer(IndexBufferContext *ibc, dibc->set_active(true); } else { - _d3d_device->SetIndices(NULL); - _active_ibuffer = NULL; + _d3d_device->SetIndices(nullptr); + _active_ibuffer = nullptr; } } else { @@ -671,7 +671,7 @@ apply_index_buffer(IndexBufferContext *ibc, } dibc->mark_loaded(reader); - _active_ibuffer = NULL; + _active_ibuffer = nullptr; } if (_active_ibuffer != dibc) { @@ -710,7 +710,7 @@ release_index_buffer(IndexBufferContext *ibc) { void DXGraphicsStateGuardian9:: begin_occlusion_query() { nassertv(_supports_occlusion_query); - nassertv(_current_occlusion_query == (OcclusionQueryContext *)NULL); + nassertv(_current_occlusion_query == nullptr); IDirect3DQuery9 *query; HRESULT hr = _d3d_device->CreateQuery(D3DQUERYTYPE_OCCLUSION, &query); @@ -739,8 +739,8 @@ begin_occlusion_query() { */ PT(OcclusionQueryContext) DXGraphicsStateGuardian9:: end_occlusion_query() { - if (_current_occlusion_query == (OcclusionQueryContext *)NULL) { - return NULL; + if (_current_occlusion_query == nullptr) { + return nullptr; } PT(OcclusionQueryContext) result = _current_occlusion_query; @@ -752,7 +752,7 @@ end_occlusion_query() { << "ending occlusion query " << query << "\n"; } - _current_occlusion_query = NULL; + _current_occlusion_query = nullptr; query->Issue(D3DISSUE_END); return result; @@ -808,19 +808,19 @@ clear(DrawableRegion *clearable) { } if ((main_flags | aux_flags) != 0) { - HRESULT hr = _d3d_device->Clear(0, NULL, main_flags | aux_flags, color_clear_value, + HRESULT hr = _d3d_device->Clear(0, nullptr, main_flags | aux_flags, color_clear_value, depth_clear_value, stencil_clear_value); if (FAILED(hr) && main_flags == D3DCLEAR_TARGET && aux_flags != 0) { // Maybe there's a problem with the one or more of the auxiliary // buffers. - hr = _d3d_device->Clear(0, NULL, D3DCLEAR_TARGET, color_clear_value, + hr = _d3d_device->Clear(0, nullptr, D3DCLEAR_TARGET, color_clear_value, depth_clear_value, stencil_clear_value); if (!FAILED(hr)) { // Yep, it worked without them. That's a problem. Which buffer poses // the problem? if (clearable->get_clear_depth_active()) { aux_flags |= D3DCLEAR_ZBUFFER; - HRESULT hr2 = _d3d_device->Clear(0, NULL, D3DCLEAR_ZBUFFER, color_clear_value, + HRESULT hr2 = _d3d_device->Clear(0, nullptr, D3DCLEAR_ZBUFFER, color_clear_value, depth_clear_value, stencil_clear_value); if (FAILED(hr2)) { dxgsg9_cat.error() @@ -831,7 +831,7 @@ clear(DrawableRegion *clearable) { } if (clearable->get_clear_stencil_active()) { aux_flags |= D3DCLEAR_STENCIL; - HRESULT hr2 = _d3d_device->Clear(0, NULL, D3DCLEAR_STENCIL, color_clear_value, + HRESULT hr2 = _d3d_device->Clear(0, nullptr, D3DCLEAR_STENCIL, color_clear_value, stencil_clear_value, stencil_clear_value); if (FAILED(hr2)) { dxgsg9_cat.error() @@ -856,7 +856,7 @@ clear(DrawableRegion *clearable) { */ void DXGraphicsStateGuardian9:: prepare_display_region(DisplayRegionPipelineReader *dr) { - nassertv(dr != (DisplayRegionPipelineReader *)NULL); + nassertv(dr != nullptr); GraphicsStateGuardian::prepare_display_region(dr); int l, u, w, h; @@ -903,12 +903,12 @@ prepare_display_region(DisplayRegionPipelineReader *dr) { */ CPT(TransformState) DXGraphicsStateGuardian9:: calc_projection_mat(const Lens *lens) { - if (lens == (Lens *)NULL) { - return NULL; + if (lens == nullptr) { + return nullptr; } if (!lens->is_linear()) { - return NULL; + return nullptr; } // DirectX also uses a Z range of 0 to 1, whereas the Panda convention is @@ -964,7 +964,7 @@ begin_frame(Thread *current_thread) { GraphicsStateGuardian::begin_frame(current_thread); - if (_d3d_device == NULL) { + if (_d3d_device == nullptr) { dxgsg9_cat.debug() << this << "::begin_frame(): no device.\n"; return false; @@ -1052,18 +1052,18 @@ end_scene() { if (_vertex_array_shader_context != 0) { _vertex_array_shader_context->disable_shader_vertex_arrays(this); - _vertex_array_shader = (Shader *)NULL; - _vertex_array_shader_context = (DXShaderContext9 *)NULL; + _vertex_array_shader = nullptr; + _vertex_array_shader_context = nullptr; } if (_texture_binding_shader_context != 0) { _texture_binding_shader_context->disable_shader_texture_bindings(this); - _texture_binding_shader = (Shader *)NULL; - _texture_binding_shader_context = (DXShaderContext9 *)NULL; + _texture_binding_shader = nullptr; + _texture_binding_shader_context = nullptr; } if (_current_shader_context != 0) { _current_shader_context->unbind(this); - _current_shader = (Shader *)NULL; - _current_shader_context = (DXShaderContext9 *)NULL; + _current_shader = nullptr; + _current_shader_context = nullptr; } _dlights.clear(); @@ -1146,7 +1146,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, if (!GraphicsStateGuardian::begin_draw_primitives(geom_reader, data_reader, force)) { return false; } - nassertr(_data_reader != (GeomVertexDataPipelineReader *)NULL, false); + nassertr(_data_reader != nullptr, false); const GeomVertexFormat *format = _data_reader->get_format(); @@ -1182,7 +1182,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, } const TransformTable *table = data_reader->get_transform_table(); - if (table != (TransformTable *)NULL) { + if (table != nullptr) { for (size_t i = 0; i < table->get_num_transforms(); ++i) { LMatrix4 mat; table->get_transform(i)->mult_matrix(mat, _internal_transform->get_mat()); @@ -1242,7 +1242,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, // Cg shader. if (_vertex_array_shader_context == 0) { disable_standard_vertex_arrays(); - if (!_current_shader_context->update_shader_vertex_arrays(NULL, this, force)) { + if (!_current_shader_context->update_shader_vertex_arrays(nullptr, this, force)) { return false; } } else { @@ -1274,7 +1274,7 @@ update_standard_vertex_arrays(bool force) { int number_of_arrays = _data_reader->get_num_arrays(); for ( int array_index = 0; array_index < number_of_arrays; ++array_index ) { const GeomVertexArrayDataHandle* array_reader = _data_reader->get_array_reader( array_index ); - if ( array_reader == NULL ) { + if ( array_reader == nullptr ) { dxgsg9_cat.error() << "Unable to get reader for array " << array_index << "\n"; return false; } @@ -1317,7 +1317,7 @@ void DXGraphicsStateGuardian9:: disable_standard_vertex_arrays() { for ( int array_index = 0; array_index < _num_bound_streams; ++array_index ) { - _d3d_device->SetStreamSource( array_index, NULL, 0, 0 ); + _d3d_device->SetStreamSource( array_index, nullptr, 0, 0 ); } _num_bound_streams = 0; } @@ -1338,7 +1338,7 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { // Indexed, vbuffers. IndexBufferContext *ibc = ((GeomPrimitive *)(reader->get_object()))->prepare_now(get_prepared_objects(), this); - nassertr(ibc != (IndexBufferContext *)NULL, false); + nassertr(ibc != nullptr, false); if (!apply_index_buffer(ibc, reader, force)) { return false; } @@ -1351,12 +1351,12 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { #if 0 // Indexed, client arrays. const unsigned char *index_pointer = reader->get_read_pointer(force); - if (index_pointer == NULL) { + if (index_pointer == nullptr) { return false; } D3DFORMAT index_type = get_index_type(reader->get_index_type()); const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } @@ -1375,7 +1375,7 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { #if 0 // Nonindexed, client arrays. const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } @@ -1408,7 +1408,7 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { // Indexed, vbuffers, one long triangle strip. IndexBufferContext *ibc = ((GeomPrimitive *)(reader->get_object()))->prepare_now(get_prepared_objects(), this); - nassertr(ibc != (IndexBufferContext *)NULL, false); + nassertr(ibc != nullptr, false); if (!apply_index_buffer(ibc, reader, force)) { return false; } @@ -1421,12 +1421,12 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { #if 0 // Indexed, client arrays, one long triangle strip. const unsigned char *index_pointer = reader->get_read_pointer(force); - if (index_pointer == NULL) { + if (index_pointer == nullptr) { return false; } D3DFORMAT index_type = get_index_type(reader->get_index_type()); const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } @@ -1446,7 +1446,7 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { #if 0 // Indexed, client arrays, one long triangle strip. const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } draw_primitive_up(D3DPT_TRIANGLESTRIP, @@ -1475,7 +1475,7 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { // Indexed, vbuffers, individual triangle strips. IndexBufferContext *ibc = ((GeomPrimitive *)(reader->get_object()))->prepare_now(get_prepared_objects(), this); - nassertr(ibc != (IndexBufferContext *)NULL, false); + nassertr(ibc != nullptr, false); if (!apply_index_buffer(ibc, reader, force)) { return false; } @@ -1496,12 +1496,12 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { // Indexed, client arrays, individual triangle strips. int stride = _data_reader->get_format()->get_array(0)->get_stride(); const unsigned char *index_pointer = reader->get_read_pointer(force); - if (index_pointer == NULL) { + if (index_pointer == nullptr) { return false; } D3DFORMAT index_type = get_index_type(reader->get_index_type()); const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } @@ -1536,7 +1536,7 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { #if 0 // Nonindexed, client arrays, individual triangle strips. const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } int stride = _data_reader->get_format()->get_array(0)->get_stride(); @@ -1582,7 +1582,7 @@ draw_trifans(const GeomPrimitivePipelineReader *reader, bool force) { // Indexed, vbuffers. IndexBufferContext *ibc = ((GeomPrimitive *)(reader->get_object()))->prepare_now(get_prepared_objects(), this); - nassertr(ibc != (IndexBufferContext *)NULL, false); + nassertr(ibc != nullptr, false); if (!apply_index_buffer(ibc, reader, force)) { return false; } @@ -1603,12 +1603,12 @@ draw_trifans(const GeomPrimitivePipelineReader *reader, bool force) { // Indexed, client arrays. int stride = _data_reader->get_format()->get_array(0)->get_stride(); const unsigned char *index_pointer = reader->get_read_pointer(force); - if (index_pointer == NULL) { + if (index_pointer == nullptr) { return false; } D3DFORMAT index_type = get_index_type(reader->get_index_type()); const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } @@ -1643,7 +1643,7 @@ draw_trifans(const GeomPrimitivePipelineReader *reader, bool force) { #if 0 // Nonindexed, client arrays. const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } int stride = _data_reader->get_format()->get_array(0)->get_stride(); @@ -1679,7 +1679,7 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { // Indexed, vbuffers. IndexBufferContext *ibc = ((GeomPrimitive *)(reader->get_object()))->prepare_now(get_prepared_objects(), this); - nassertr(ibc != (IndexBufferContext *)NULL, false); + nassertr(ibc != nullptr, false); if (!apply_index_buffer(ibc, reader, force)) { return false; } @@ -1692,12 +1692,12 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { #if 0 // Indexed, client arrays. const unsigned char *index_pointer = reader->get_read_pointer(force); - if (index_pointer == NULL) { + if (index_pointer == nullptr) { return false; } D3DFORMAT index_type = get_index_type(reader->get_index_type()); const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } @@ -1717,7 +1717,7 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { #if 0 // Nonindexed, client arrays. const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } draw_primitive_up(D3DPT_LINELIST, reader->get_num_primitives(), @@ -1759,7 +1759,7 @@ draw_points(const GeomPrimitivePipelineReader *reader, bool force) { #if 0 // Nonindexed, client arrays. const unsigned char *vertex_pointer = _data_reader->get_array_reader(0)->get_read_pointer(force); - if (vertex_pointer == NULL) { + if (vertex_pointer == nullptr) { return false; } draw_primitive_up(D3DPT_POINTLIST, reader->get_num_primitives(), @@ -1817,7 +1817,7 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, tex->set_render_to_texture(true); TextureContext *tc = tex->prepare_now(view, get_prepared_objects(), this); - if (tc == (TextureContext *)NULL) { + if (tc == nullptr) { return false; } DXTextureContext9 *dtc = DCAST(DXTextureContext9, tc); @@ -1833,7 +1833,7 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, // for now. return do_framebuffer_copy_to_ram(tex, view, z, dr, rb, true); } - nassertr(dtc->get_d3d_2d_texture() != NULL, false); + nassertr(dtc->get_d3d_2d_texture() != nullptr, false); IDirect3DSurface9 *tex_level_0; hr = dtc->get_d3d_2d_texture()->GetSurfaceLevel(0, &tex_level_0); @@ -1967,7 +1967,7 @@ do_framebuffer_copy_to_ram(Texture *tex, int view, int z, set_read_buffer(rb); RECT rect; - nassertr(tex != NULL && dr != NULL, false); + nassertr(tex != nullptr && dr != nullptr, false); int xo, yo, w, h; dr->get_region_pixels_i(xo, yo, w, h); @@ -2007,7 +2007,7 @@ do_framebuffer_copy_to_ram(Texture *tex, int view, int z, rect.bottom = yo + h; bool copy_inverted = false; - IDirect3DSurface9 *temp_surface = NULL; + IDirect3DSurface9 *temp_surface = nullptr; HRESULT hr; // Note if you try to grab the backbuffer and full-screen anti-aliasing is @@ -2015,7 +2015,7 @@ do_framebuffer_copy_to_ram(Texture *tex, int view, int z, // it's safer to get the front buffer. if (_cur_read_pixel_buffer & RenderBuffer::T_back) { DWORD render_target_index; - IDirect3DSurface9 *backbuffer = NULL; + IDirect3DSurface9 *backbuffer = nullptr; // GetRenderTarget() seems to be a little more reliable than // GetBackBuffer(). Might just be related to the swap_chain thing. @@ -2041,7 +2041,7 @@ do_framebuffer_copy_to_ram(Texture *tex, int view, int z, surface_description.Format, pool, &temp_surface, - NULL); + nullptr); if (FAILED(hr)) { dxgsg9_cat.error() << "CreateImageSurface failed in copy_pixel_buffer()" @@ -2085,7 +2085,7 @@ do_framebuffer_copy_to_ram(Texture *tex, int view, int z, // For GetFrontBuffer(), we need a temporary surface of type A8R8G8B8. // Unlike GetBackBuffer(), GetFrontBuffer() implicitly performs a copy. - hr = _d3d_device->CreateOffscreenPlainSurface(w, h, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &temp_surface, NULL); + hr = _d3d_device->CreateOffscreenPlainSurface(w, h, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &temp_surface, nullptr); if (FAILED(hr)) { dxgsg9_cat.error() << "CreateImageSurface failed in copy_pixel_buffer()" @@ -2219,9 +2219,9 @@ reset() { // TransformState::make_identity()); want gsg to pass all state settings // down so any non-matching defaults we set here get overwritten - nassertv(_screen->_d3d9 != NULL); + nassertv(_screen->_d3d9 != nullptr); - if (_d3d_device == NULL) { + if (_d3d_device == nullptr) { return; } @@ -2301,10 +2301,10 @@ reset() { const char *pixel_profile_str = cgGetProfileString(pixel_profile); - if (vertex_profile_str == NULL) { + if (vertex_profile_str == nullptr) { vertex_profile_str = "(null)"; } - if (pixel_profile_str == NULL) { + if (pixel_profile_str == nullptr) { pixel_profile_str = "(null)"; } @@ -2360,7 +2360,7 @@ reset() { _supports_gamma_calibration = ((d3d_caps.Caps2 & D3DCAPS2_CANCALIBRATEGAMMA) != 0); // Test for occlusion query support - hr = _d3d_device->CreateQuery(D3DQUERYTYPE_OCCLUSION, NULL); + hr = _d3d_device->CreateQuery(D3DQUERYTYPE_OCCLUSION, nullptr); _supports_occlusion_query = !FAILED(hr); if (dxgsg9_cat.is_error()) { @@ -2669,12 +2669,12 @@ reset() { // GF2Radeon8500, no on TNT) set_render_state(D3DRS_BLENDOP, D3DBLENDOP_ADD); - _current_shader = (Shader *)NULL; - _current_shader_context = (DXShaderContext9 *)NULL; - _vertex_array_shader = (Shader *)NULL; - _vertex_array_shader_context = (DXShaderContext9 *)NULL; - _texture_binding_shader = (Shader *)NULL; - _texture_binding_shader_context = (DXShaderContext9 *)NULL; + _current_shader = nullptr; + _current_shader_context = nullptr; + _vertex_array_shader = nullptr; + _vertex_array_shader_context = nullptr; + _texture_binding_shader = nullptr; + _texture_binding_shader_context = nullptr; PRINT_REFCNT(dxgsg9, _d3d_device); @@ -2991,7 +2991,7 @@ do_issue_fog() { if (!target_fog->is_off()) { set_render_state(D3DRS_FOGENABLE, TRUE); Fog *fog = target_fog->get_fog(); - nassertv(fog != (Fog *)NULL); + nassertv(fog != nullptr); apply_fog(fog); } else { set_render_state(D3DRS_FOGENABLE, FALSE); @@ -3364,7 +3364,7 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { void DXGraphicsStateGuardian9:: bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { Lens *lens = light_obj->get_lens(); - nassertv(lens != (Lens *)NULL); + nassertv(lens != nullptr); // Get the light in "world coordinates" (actually, view coordinates). This // means the light in the coordinate space of the camera, converted to DX's @@ -3513,7 +3513,7 @@ do_issue_texture() { update_standard_texture_bindings(); } else { disable_standard_texture_bindings(); - _current_shader_context->update_shader_texture_bindings(NULL,this); + _current_shader_context->update_shader_texture_bindings(nullptr,this); } } else { if (_current_shader_context==0) { @@ -3537,7 +3537,7 @@ disable_standard_texture_bindings() { for (int i = 0; i < _num_active_texture_stages; i++) { HRESULT hr; - hr = _d3d_device -> SetTexture (i, NULL); + hr = _d3d_device -> SetTexture (i, nullptr); if (FAILED (hr)) { dxgsg9_cat.error() << "SetTexture (" @@ -3560,7 +3560,7 @@ update_standard_texture_bindings() { int num_stages = _target_texture->get_num_on_ff_stages(); int num_old_stages = _max_texture_stages; - if (_state_texture != (TextureAttrib *)NULL) { + if (_state_texture != nullptr) { num_old_stages = _state_texture->get_num_on_ff_stages(); } @@ -3579,7 +3579,7 @@ update_standard_texture_bindings() { int texcoord_index = _target_texture->get_ff_tc_index(si); Texture *texture = _target_texture->get_on_texture(stage); - nassertv(texture != (Texture *)NULL); + nassertv(texture != nullptr); const SamplerState &sampler = _target_texture->get_on_sampler(stage); // We always reissue every stage in DX, just in case the texcoord index or @@ -3754,7 +3754,7 @@ update_standard_texture_bindings() { // Disable the texture stages that are no longer used. for (si = num_stages; si < _num_active_texture_stages; si++) { set_texture_stage_state(si, D3DTSS_COLOROP, D3DTOP_DISABLE); - _d3d_device->SetTexture(si, NULL); + _d3d_device->SetTexture(si, nullptr); } // Save the count of texture stages for next time. @@ -4007,16 +4007,16 @@ free_d3d_device() { _dx_is_ready = false; - if (_d3d_device != NULL) { + if (_d3d_device != nullptr) { for(int i = 0; i < D3D_MAXTEXTURESTAGES; i++) { // d3d should release this stuff internally anyway, but whatever - _d3d_device->SetTexture(i, NULL); + _d3d_device->SetTexture(i, nullptr); } } release_all(); - if (_d3d_device != NULL) { + if (_d3d_device != nullptr) { RELEASE(_d3d_device, dxgsg9, "d3dDevice", RELEASE_DOWN_TO_ZERO); } @@ -4252,7 +4252,7 @@ report_texmgr_stats() { */ void DXGraphicsStateGuardian9:: set_context(DXScreenData *new_context) { - nassertv(new_context != NULL); + nassertv(new_context != nullptr); _screen = new_context; _d3d_device = _screen->_d3d_device; //copy this one field for speed of deref _swap_chain = _screen->_swap_chain; //copy this one field for speed of deref @@ -4266,11 +4266,11 @@ set_context(DXScreenData *new_context) { */ void DXGraphicsStateGuardian9:: set_render_target() { - if (_d3d_device == NULL) { + if (_d3d_device == nullptr) { return; } - LPDIRECT3DSURFACE9 back = NULL, stencil = NULL; + LPDIRECT3DSURFACE9 back = nullptr, stencil = nullptr; UINT swap_chain; @@ -4479,7 +4479,7 @@ dx_cleanup() { // Do a safe check for releasing the D3DDEVICE. RefCount should be zero. if // we're called from exit(), _d3d_device may already have been released RELEASE(_d3d_device, dxgsg9, "d3dDevice", RELEASE_DOWN_TO_ZERO); - _screen->_d3d_device = NULL; + _screen->_d3d_device = nullptr; // Releasing pD3D is now the responsibility of the GraphicsPipe destructor } @@ -4574,7 +4574,7 @@ reset_d3d_device(D3DPRESENT_PARAMETERS *presentation_params, get_engine()->reset_all_windows(true);// reset with new swapchains by creating if (screen) { - *screen = NULL; + *screen = nullptr; } if (presentation_params != &_screen->_presentation_params) { @@ -4589,7 +4589,7 @@ reset_d3d_device(D3DPRESENT_PARAMETERS *presentation_params, _screen->_swap_chain->Release(); wdxdisplay9_cat.debug() << "swap chain " << _screen->_swap_chain << " is released\n"; - _screen->_swap_chain = NULL; + _screen->_swap_chain = nullptr; hr = _d3d_device->CreateAdditionalSwapChain(presentation_params, &_screen->_swap_chain); } if (SUCCEEDED(hr)) { @@ -4609,7 +4609,7 @@ reset_d3d_device(D3DPRESENT_PARAMETERS *presentation_params, bool DXGraphicsStateGuardian9:: check_cooperative_level() { bool bDoReactivateWindow = false; - if (_d3d_device == NULL) { + if (_d3d_device == nullptr) { return false; } @@ -4669,7 +4669,7 @@ check_cooperative_level() { */ void DXGraphicsStateGuardian9:: show_frame() { - if (_d3d_device == NULL) { + if (_d3d_device == nullptr) { return; } @@ -4679,9 +4679,9 @@ show_frame() { DWORD flags; flags = 0; - hr = _swap_chain->Present((CONST RECT*)NULL, (CONST RECT*)NULL, (HWND)NULL, NULL, flags); + hr = _swap_chain->Present(nullptr, nullptr, (HWND)nullptr, nullptr, flags); } else { - hr = _d3d_device->Present((CONST RECT*)NULL, (CONST RECT*)NULL, (HWND)NULL, NULL); + hr = _d3d_device->Present(nullptr, nullptr, (HWND)nullptr, nullptr); } if (FAILED(hr)) { @@ -5072,7 +5072,7 @@ do_issue_stencil() { const StencilAttrib *stencil = DCAST(StencilAttrib, _target_rs->get_attrib(StencilAttrib::get_class_slot())); - if (stencil != (const StencilAttrib *)NULL) { + if (stencil != nullptr) { // DEBUG if (false) { dxgsg9_cat.debug() << "STENCIL STATE CHANGE\n"; @@ -5135,7 +5135,7 @@ do_issue_stencil() { } if (stencil->get_render_state(StencilAttrib::SRS_clear)) { - _d3d_device->Clear(0, NULL, D3DCLEAR_STENCIL, 0, 0.0f, stencil->get_render_state(StencilAttrib::SRS_clear_value)); + _d3d_device->Clear(0, nullptr, D3DCLEAR_STENCIL, 0, 0.0f, stencil->get_render_state(StencilAttrib::SRS_clear_value)); } } else { @@ -5291,7 +5291,7 @@ get_gamma_table(void) { get = false; if (_gamma_table_initialized == false) { - HDC hdc = GetDC(NULL); + HDC hdc = GetDC(nullptr); if (hdc) { if (GetDeviceGammaRamp (hdc, (LPVOID) _orignial_gamma_table)) { @@ -5299,7 +5299,7 @@ get_gamma_table(void) { get = true; } - ReleaseDC (NULL, hdc); + ReleaseDC (nullptr, hdc); } } @@ -5312,7 +5312,7 @@ get_gamma_table(void) { bool DXGraphicsStateGuardian9:: static_set_gamma(bool restore, PN_stdfloat gamma) { bool set; - HDC hdc = GetDC(NULL); + HDC hdc = GetDC(nullptr); set = false; if (hdc) { @@ -5329,7 +5329,7 @@ static_set_gamma(bool restore, PN_stdfloat gamma) { set = true; } - ReleaseDC (NULL, hdc); + ReleaseDC (nullptr, hdc); } return set; @@ -5363,7 +5363,7 @@ restore_gamma() { */ void DXGraphicsStateGuardian9:: atexit_function(void) { - set_cg_device(NULL); + set_cg_device(nullptr); static_set_gamma(true, 1.0f); } diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h index fa31ac12fd..5a5c3b3359 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h @@ -227,7 +227,7 @@ protected: void dx_cleanup(); HRESULT reset_d3d_device(D3DPRESENT_PARAMETERS *p_presentation_params, - DXScreenData **screen = NULL); + DXScreenData **screen = nullptr); bool check_cooperative_level(); diff --git a/panda/src/dxgsg9/dxIndexBufferContext9.cxx b/panda/src/dxgsg9/dxIndexBufferContext9.cxx index a29dff17b3..ae5db21707 100644 --- a/panda/src/dxgsg9/dxIndexBufferContext9.cxx +++ b/panda/src/dxgsg9/dxIndexBufferContext9.cxx @@ -27,7 +27,7 @@ TypeHandle DXIndexBufferContext9::_type_handle; DXIndexBufferContext9:: DXIndexBufferContext9(PreparedGraphicsObjects *pgo, GeomPrimitive *data) : IndexBufferContext(pgo, data), - _ibuffer(NULL), + _ibuffer(nullptr), _managed(-1) { } @@ -62,7 +62,7 @@ evict_lru() { */ void DXIndexBufferContext9:: free_ibuffer(void) { - if (_ibuffer != NULL) { + if (_ibuffer != nullptr) { if (DEBUG_INDEX_BUFFER && dxgsg9_cat.is_debug()) { dxgsg9_cat.debug() << "deleting index buffer " << _ibuffer << "\n"; @@ -74,7 +74,7 @@ free_ibuffer(void) { _ibuffer->Release(); } - _ibuffer = NULL; + _ibuffer = nullptr; } } @@ -118,7 +118,7 @@ allocate_ibuffer(DXScreenData &scrn, do { hr = scrn._d3d_device->CreateIndexBuffer - (data_size, usage, index_type, pool, &_ibuffer, NULL); + (data_size, usage, index_type, pool, &_ibuffer, nullptr); attempts++; } while (scrn._dxgsg9 -> check_dx_allocation (hr, data_size, attempts)); @@ -126,7 +126,7 @@ allocate_ibuffer(DXScreenData &scrn, if (FAILED(hr)) { dxgsg9_cat.warning() << "CreateIndexBuffer failed" << D3DERRORSTRING(hr); - _ibuffer = NULL; + _ibuffer = nullptr; } else { if (DEBUG_INDEX_BUFFER && dxgsg9_cat.is_debug()) { dxgsg9_cat.debug() @@ -162,10 +162,10 @@ upload_data(const GeomPrimitivePipelineReader *reader, bool force) { nassertr(reader->get_object() == get_data(), false); Thread *current_thread = reader->get_current_thread(); - nassertr(_ibuffer != NULL, false); + nassertr(_ibuffer != nullptr, false); const unsigned char *data_pointer = reader->get_read_pointer(force); - if (data_pointer == NULL) { + if (data_pointer == nullptr) { return false; } size_t data_size = (size_t)reader->get_data_size_bytes(); diff --git a/panda/src/dxgsg9/dxInput9.cxx b/panda/src/dxgsg9/dxInput9.cxx index 24e3ea16f3..d0556d44c7 100644 --- a/panda/src/dxgsg9/dxInput9.cxx +++ b/panda/src/dxgsg9/dxInput9.cxx @@ -32,9 +32,9 @@ BOOL CALLBACK EnumGameCtrlsCallback( const DIDEVICEINSTANCE* pdidInstance, extern BOOL CALLBACK EnumObjectsCallbackJoystick(const DIDEVICEOBJECTINSTANCE* pdidoi,VOID* pContext); DInput9Info::DInput9Info() { - _pDInput9 = NULL; - _hDInputDLL = NULL; - _JoystickPollTimer = NULL; + _pDInput9 = nullptr; + _hDInputDLL = nullptr; + _JoystickPollTimer = nullptr; } DInput9Info::~DInput9Info() { @@ -48,7 +48,7 @@ DInput9Info::~DInput9Info() { SAFE_RELEASE(_pDInput9); if(_hDInputDLL) { FreeLibrary(_hDInputDLL); - _hDInputDLL=NULL; + _hDInputDLL=nullptr; } } @@ -70,15 +70,15 @@ bool DInput9Info::InitDirectInput() { LPDIRECTINPUT9CREATE pDInputCreate9; pDInputCreate9 = (LPDIRECTINPUT9CREATE) GetProcAddress(_hDInputDLL,DINPUTCREATE); - if(pDInputCreate9 == NULL) { + if(pDInputCreate9 == nullptr) { wdxdisplay_cat.fatal() << "GetProcAddr failed for " << DINPUTCREATE << endl; exit(1); } // Register with the DirectInput subsystem and get a pointer to a // IDirectInput interface we can use. Create a DInput object - if( FAILED( hr = (*pDInputCreate9)(GetModuleHandle(NULL), DIRECTINPUT_VERSION, - IID_IDirectInput9, (VOID**)&_pDInput9, NULL ) ) ) { + if( FAILED( hr = (*pDInputCreate9)(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, + IID_IDirectInput9, (VOID**)&_pDInput9, nullptr ) ) ) { wdxdisplay_cat.error() << DINPUTCREATE << "failed" << D3DERRORSTRING(hr); return false; } @@ -97,7 +97,7 @@ bool DInput9Info::InitDirectInput() { bool DInput9Info::CreateJoystickOrPad(HWND _window) { bool bFoundDev = false; UINT devnum=0; - char *errstr=NULL; + char *errstr=nullptr; // look through the list for the first joystick or gamepad for(;devnum<_DevInfos.size();devnum++) { @@ -116,13 +116,13 @@ bool DInput9Info::CreateJoystickOrPad(HWND _window) { LPDIRECTINPUTDEVICE9 pJoyDevice; // Obtain an interface to the enumerated joystick. - HRESULT hr = _pDInput9->CreateDevice(_DevInfos[devnum].guidInstance, &pJoyDevice, NULL ); + HRESULT hr = _pDInput9->CreateDevice(_DevInfos[devnum].guidInstance, &pJoyDevice, nullptr ); if(FAILED(hr)) { errstr="CreateDevice"; goto handle_error; } - assert(pJoyDevice!=NULL); + assert(pJoyDevice!=nullptr); _DeviceList.push_back(pJoyDevice); // Set the data format to "simple joystick" - a predefined data format A @@ -210,7 +210,7 @@ BOOL CALLBACK EnumObjectsCallbackJoystick( const DIDEVICEOBJECTINSTANCE* pdidoi, bool DInput9Info::ReadJoystick(int devnum, DIJOYSTATE2 &js) { LPDIRECTINPUTDEVICE9 pJoystick = _DeviceList[devnum]; - assert(pJoystick!=NULL); + assert(pJoystick!=nullptr); HRESULT hr; char *errstr; diff --git a/panda/src/dxgsg9/dxOcclusionQueryContext9.cxx b/panda/src/dxgsg9/dxOcclusionQueryContext9.cxx index 0999821080..89d584dffd 100644 --- a/panda/src/dxgsg9/dxOcclusionQueryContext9.cxx +++ b/panda/src/dxgsg9/dxOcclusionQueryContext9.cxx @@ -25,7 +25,7 @@ TypeHandle DXOcclusionQueryContext9::_type_handle; DXOcclusionQueryContext9:: ~DXOcclusionQueryContext9() { _query->Release(); - _query = NULL; + _query = nullptr; } /** diff --git a/panda/src/dxgsg9/dxShaderContext9.cxx b/panda/src/dxgsg9/dxShaderContext9.cxx index 9d151ac44a..e3992bea5d 100644 --- a/panda/src/dxgsg9/dxShaderContext9.cxx +++ b/panda/src/dxgsg9/dxShaderContext9.cxx @@ -35,8 +35,8 @@ TypeHandle DXShaderContext9::_type_handle; */ DXShaderContext9:: DXShaderContext9(Shader *s, GSG *gsg) : ShaderContext(s) { - _vertex_element_array = NULL; - _vertex_declaration = NULL; + _vertex_element_array = nullptr; + _vertex_declaration = nullptr; _num_bound_streams = 0; @@ -83,14 +83,14 @@ DXShaderContext9:: ~DXShaderContext9() { release_resources(); - if (_vertex_declaration != NULL) { + if (_vertex_declaration != nullptr) { _vertex_declaration->Release(); - _vertex_declaration = NULL; + _vertex_declaration = nullptr; } - if (_vertex_element_array != NULL) { + if (_vertex_element_array != nullptr) { delete _vertex_element_array; - _vertex_element_array = NULL; + _vertex_element_array = nullptr; } } @@ -200,7 +200,7 @@ issue_parameters(GSG *gsg, int altered) { if (altered & (spec._dep[0] | spec._dep[1])) { const Shader::ShaderPtrData *ptr_data = gsg->fetch_ptr_parameter(spec); - if (ptr_data == NULL) { //the input is not contained in ShaderPtrData + if (ptr_data == nullptr) { //the input is not contained in ShaderPtrData release_resources(); return; } @@ -237,7 +237,7 @@ issue_parameters(GSG *gsg, int altered) { if (altered & (spec._dep[0] | spec._dep[1])) { CGparameter p = _cg_parameter_map[spec._id._seqno]; - if (p == NULL) { + if (p == nullptr) { continue; } const LMatrix4 *val = gsg->fetch_specified_value(spec, altered); @@ -343,7 +343,7 @@ disable_shader_vertex_arrays(GSG *gsg) { LPDIRECT3DDEVICE9 device = gsg->_screen->_d3d_device; for (int array_index = 0; array_index < _num_bound_streams; ++array_index) { - device->SetStreamSource(array_index, NULL, 0, 0); + device->SetStreamSource(array_index, nullptr, 0, 0); } _num_bound_streams = 0; } @@ -377,7 +377,7 @@ update_shader_vertex_arrays(DXShaderContext9 *prev, GSG *gsg, bool force) { // Discard and recreate the VertexElementArray. This thrashes pretty // bad.... - if (_vertex_element_array != NULL) { + if (_vertex_element_array != nullptr) { delete _vertex_element_array; } _vertex_element_array = new VertexElementArray(nvarying + 2); @@ -394,14 +394,14 @@ update_shader_vertex_arrays(DXShaderContext9 *prev, GSG *gsg, bool force) { for (int array_index = 0; array_index < number_of_arrays; ++array_index) { const GeomVertexArrayDataHandle* array_reader = gsg->_data_reader->get_array_reader(array_index); - if (array_reader == NULL) { + if (array_reader == nullptr) { dxgsg9_cat.error() << "Unable to get reader for array " << array_index << "\n"; continue; } for (int var_index = 0; var_index < nvarying; ++var_index) { CGparameter p = _cg_parameter_map[_shader->_var_spec[var_index]._id._seqno]; - if (p == NULL) { + if (p == nullptr) { dxgsg9_cat.info() << "No parameter in map for parameter " << var_index << " (probably optimized away)\n"; @@ -444,7 +444,7 @@ update_shader_vertex_arrays(DXShaderContext9 *prev, GSG *gsg, bool force) { } const char *semantic = cgGetParameterSemantic(p); - if (semantic == NULL) { + if (semantic == nullptr) { dxgsg9_cat.error() << "Unable to retrieve semantic for parameter " << var_index << "\n"; continue; } @@ -564,7 +564,7 @@ update_shader_vertex_arrays(DXShaderContext9 *prev, GSG *gsg, bool force) { _num_bound_streams = number_of_arrays; - if (_vertex_element_array != NULL && + if (_vertex_element_array != nullptr && _vertex_element_array->add_end_vertex_element()) { if (dxgsg9_cat.is_debug()) { // Note that the currently generated vertex declaration works but @@ -580,9 +580,9 @@ update_shader_vertex_arrays(DXShaderContext9 *prev, GSG *gsg, bool force) { } // Discard the old VertexDeclaration. This thrashes pretty bad.... - if (_vertex_declaration != NULL) { + if (_vertex_declaration != nullptr) { _vertex_declaration->Release(); - _vertex_declaration = NULL; + _vertex_declaration = nullptr; } hr = device->CreateVertexDeclaration(_vertex_element_array->_vertex_element_array, @@ -613,14 +613,14 @@ disable_shader_texture_bindings(GSG *gsg) { if (_cg_program) { for (size_t i = 0; i < _shader->_tex_spec.size(); ++i) { CGparameter p = _cg_parameter_map[_shader->_tex_spec[i]._id._seqno]; - if (p == NULL) { + if (p == nullptr) { continue; } int texunit = cgGetParameterResourceIndex(p); HRESULT hr; - hr = gsg->_d3d_device->SetTexture(texunit, NULL); + hr = gsg->_d3d_device->SetTexture(texunit, nullptr); if (FAILED(hr)) { dxgsg9_cat.error() << "SetTexture(" << texunit << ", NULL) failed " @@ -649,7 +649,7 @@ update_shader_texture_bindings(DXShaderContext9 *prev, GSG *gsg) { for (size_t i = 0; i < _shader->_tex_spec.size(); ++i) { Shader::ShaderTexSpec &spec = _shader->_tex_spec[i]; CGparameter p = _cg_parameter_map[spec._id._seqno]; - if (p == NULL) { + if (p == nullptr) { continue; } @@ -671,7 +671,7 @@ update_shader_texture_bindings(DXShaderContext9 *prev, GSG *gsg) { } TextureContext *tc = tex->prepare_now(view, gsg->_prepared_objects, gsg); - if (tc == (TextureContext*)NULL) { + if (tc == nullptr) { continue; } diff --git a/panda/src/dxgsg9/dxTextureContext9.cxx b/panda/src/dxgsg9/dxTextureContext9.cxx index 60f787f298..12ad6dfdfe 100644 --- a/panda/src/dxgsg9/dxTextureContext9.cxx +++ b/panda/src/dxgsg9/dxTextureContext9.cxx @@ -40,10 +40,10 @@ DXTextureContext9(PreparedGraphicsObjects *pgo, Texture *tex, int view) : << "Creating DX texture [" << tex->get_name() << "], minfilter(" << tex->get_minfilter() << "), magfilter(" << tex->get_magfilter() << "), anisodeg(" << tex->get_anisotropic_degree() << ")\n"; } - _d3d_texture = NULL; - _d3d_2d_texture = NULL; - _d3d_volume_texture = NULL; - _d3d_cube_texture = NULL; + _d3d_texture = nullptr; + _d3d_2d_texture = nullptr; + _d3d_volume_texture = nullptr; + _d3d_cube_texture = nullptr; _has_mipmaps = false; _is_render_target = false; _managed = -1; @@ -992,21 +992,21 @@ create_texture(DXScreenData &scrn) { case Texture::TT_2d_texture: hr = scrn._d3d_device->CreateTexture (target_width, target_height, mip_level_count, usage, - target_pixel_format, pool, &_d3d_2d_texture, NULL); + target_pixel_format, pool, &_d3d_2d_texture, nullptr); _d3d_texture = _d3d_2d_texture; break; case Texture::TT_3d_texture: hr = scrn._d3d_device->CreateVolumeTexture (target_width, target_height, target_depth, mip_level_count, usage, - target_pixel_format, pool, &_d3d_volume_texture, NULL); + target_pixel_format, pool, &_d3d_volume_texture, nullptr); _d3d_texture = _d3d_volume_texture; break; case Texture::TT_cube_map: hr = scrn._d3d_device->CreateCubeTexture (target_width, mip_level_count, usage, - target_pixel_format, pool, &_d3d_cube_texture, NULL); + target_pixel_format, pool, &_d3d_cube_texture, nullptr); _d3d_texture = _d3d_cube_texture; target_height = target_width; @@ -1050,7 +1050,7 @@ create_texture(DXScreenData &scrn) { if (tex->has_ram_image()) { BamCache *cache = BamCache::get_global_ptr(); PT(BamCacheRecord) record = cache->lookup(tex->get_fullpath(), "txo"); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->set_data(tex, tex); cache->store(record); } @@ -1069,9 +1069,9 @@ create_texture(DXScreenData &scrn) { error_exit: RELEASE(_d3d_texture, dxgsg9, "texture", RELEASE_ONCE); - _d3d_2d_texture = NULL; - _d3d_volume_texture = NULL; - _d3d_cube_texture = NULL; + _d3d_2d_texture = nullptr; + _d3d_volume_texture = nullptr; + _d3d_cube_texture = nullptr; return false; } @@ -1101,7 +1101,7 @@ create_simple_texture(DXScreenData &scrn) { hr = scrn._d3d_device->CreateTexture (target_width, target_height, mip_level_count, usage, - target_pixel_format, pool, &_d3d_2d_texture, NULL); + target_pixel_format, pool, &_d3d_2d_texture, nullptr); _d3d_texture = _d3d_2d_texture; if (FAILED(hr)) { dxgsg9_cat.error() @@ -1124,7 +1124,7 @@ create_simple_texture(DXScreenData &scrn) { hr = -1; // hr = fill_d3d_texture_pixels(scrn); - IDirect3DSurface9 *surface = NULL; + IDirect3DSurface9 *surface = nullptr; _d3d_2d_texture->GetSurfaceLevel(0, &surface); RECT source_size; @@ -1135,8 +1135,8 @@ create_simple_texture(DXScreenData &scrn) { DWORD mip_filter = D3DX_FILTER_LINEAR; hr = D3DXLoadSurfaceFromMemory - (surface, (PALETTEENTRY*)NULL, (RECT*)NULL, (LPCVOID)image.p(), - target_pixel_format, target_width * 4, (PALETTEENTRY*)NULL, + (surface, nullptr, nullptr, (LPCVOID)image.p(), + target_pixel_format, target_width * 4, nullptr, &source_size, mip_filter, (D3DCOLOR)0x0); RELEASE(surface, dxgsg9, "create_simple_texture Surface", RELEASE_ONCE); @@ -1156,9 +1156,9 @@ create_simple_texture(DXScreenData &scrn) { error_exit: RELEASE(_d3d_texture, dxgsg9, "texture", RELEASE_ONCE); - _d3d_2d_texture = NULL; - _d3d_volume_texture = NULL; - _d3d_cube_texture = NULL; + _d3d_2d_texture = nullptr; + _d3d_volume_texture = nullptr; + _d3d_cube_texture = nullptr; return false; } @@ -1168,15 +1168,15 @@ create_simple_texture(DXScreenData &scrn) { void DXTextureContext9:: delete_texture() { - if (_d3d_texture == NULL) { + if (_d3d_texture == nullptr) { // don't bother printing the msg below, since we already released it. return; } RELEASE(_d3d_texture, dxgsg9, "texture", RELEASE_ONCE); - _d3d_2d_texture = NULL; - _d3d_volume_texture = NULL; - _d3d_cube_texture = NULL; + _d3d_2d_texture = nullptr; + _d3d_volume_texture = nullptr; + _d3d_cube_texture = nullptr; } /** @@ -1308,7 +1308,7 @@ extract_texture_data(DXScreenData &screen) { surface_description.Format, pool, &destination_surface, - NULL); + nullptr); if (hr == D3D_OK) { if (source_surface && destination_surface) { hr = screen._d3d_device -> GetRenderTargetData (source_surface, destination_surface); @@ -1316,7 +1316,7 @@ extract_texture_data(DXScreenData &screen) { D3DLOCKED_RECT rect; - hr = destination_surface -> LockRect (&rect, NULL, D3DLOCK_READONLY); + hr = destination_surface -> LockRect (&rect, nullptr, D3DLOCK_READONLY); if (hr == D3D_OK) { unsigned int y; @@ -1367,7 +1367,7 @@ extract_texture_data(DXScreenData &screen) { else { for (int n = 0; n < num_levels; ++n) { D3DLOCKED_RECT rect; - hr = _d3d_2d_texture->LockRect(n, &rect, NULL, D3DLOCK_READONLY); + hr = _d3d_2d_texture->LockRect(n, &rect, nullptr, D3DLOCK_READONLY); if (FAILED(hr)) { dxgsg9_cat.error() << "Texture::LockRect() failed! level = " << n << " " << D3DERRORSTRING(hr); @@ -1479,7 +1479,7 @@ d3d_surface_to_texture(RECT &source_rect, IDirect3DSurface9 *d3d_surface, return E_FAIL; } - hr = d3d_surface->LockRect(&locked_rect, (CONST RECT*)NULL, (D3DLOCK_READONLY | D3DLOCK_NO_DIRTY_UPDATE)); + hr = d3d_surface->LockRect(&locked_rect, nullptr, (D3DLOCK_READONLY | D3DLOCK_NO_DIRTY_UPDATE)); if (FAILED(hr)) { dxgsg9_cat.error() << "d3d_surface_to_texture LockRect() failed!" << D3DERRORSTRING(hr); @@ -1723,7 +1723,7 @@ HRESULT DXTextureContext9::fill_d3d_texture_mipmap_pixels(int mip_level, int dep { // This whole function was refactored out of fill_d3d_texture_pixels to make // the code more readable and to avoid code duplication. - IDirect3DSurface9 *mip_surface = NULL; + IDirect3DSurface9 *mip_surface = nullptr; bool using_temp_buffer = false; HRESULT hr = E_FAIL; CPTA_uchar image = get_texture()->get_ram_mipmap_image(mip_level); @@ -1849,8 +1849,8 @@ HRESULT DXTextureContext9::fill_d3d_texture_mipmap_pixels(int mip_level, int dep } else { hr = D3DXLoadSurfaceFromMemory - (mip_surface, (PALETTEENTRY*)NULL, (RECT*)NULL, (LPCVOID)pixels, - source_format, source_row_byte_length, (PALETTEENTRY*)NULL, + (mip_surface, nullptr, nullptr, (LPCVOID)pixels, + source_format, source_row_byte_length, nullptr, &source_size, mip_filter, (D3DCOLOR)0x0); if (FAILED(hr)) { dxgsg9_cat.error() @@ -1922,7 +1922,7 @@ fill_d3d_texture_pixels(DXScreenData &scrn, bool compress_texture) { // turn off depth stencil when clearing texture if it exists depth_stencil_surface = 0; if (device -> GetDepthStencilSurface (&depth_stencil_surface) == D3D_OK) { - if (device -> SetDepthStencilSurface (NULL) == D3D_OK) { + if (device -> SetDepthStencilSurface (nullptr) == D3D_OK) { } } @@ -1935,7 +1935,7 @@ fill_d3d_texture_pixels(DXScreenData &scrn, bool compress_texture) { scaled *= 255; color = D3DCOLOR_RGBA((int)scaled[0], (int)scaled[1], (int)scaled[2], (int)scaled[3]); flags = D3DCLEAR_TARGET; - if (device -> Clear (0, NULL, flags, color, 0.0f, 0) == D3D_OK) { + if (device -> Clear (0, nullptr, flags, color, 0.0f, 0) == D3D_OK) { } } @@ -2049,7 +2049,7 @@ fill_d3d_texture_pixels(DXScreenData &scrn, bool compress_texture) { } // mip_filter_flags |= D3DX_FILTER_DITHER; - hr = D3DXFilterTexture(_d3d_texture, (PALETTEENTRY*)NULL, 0, + hr = D3DXFilterTexture(_d3d_texture, nullptr, 0, mip_filter_flags); if (FAILED(hr)) { @@ -2118,7 +2118,7 @@ fill_d3d_volume_texture_pixels(DXScreenData &scrn) { size_t view_size = tex->get_ram_mipmap_view_size(0); image_pixels += view_size * get_view(); - IDirect3DVolume9 *mip_level_0 = NULL; + IDirect3DVolume9 *mip_level_0 = nullptr; bool using_temp_buffer = false; BYTE *pixels = image_pixels; @@ -2212,9 +2212,9 @@ fill_d3d_volume_texture_pixels(DXScreenData &scrn) { GraphicsStateGuardian::_data_transferred_pcollector.add_level(source_page_byte_length * orig_depth); #endif hr = D3DXLoadVolumeFromMemory - (mip_level_0, (PALETTEENTRY*)NULL, (D3DBOX*)NULL, (LPCVOID)pixels, + (mip_level_0, nullptr, nullptr, (LPCVOID)pixels, source_format, source_row_byte_length, source_page_byte_length, - (PALETTEENTRY*)NULL, + nullptr, &source_size, level_0_filter, (D3DCOLOR)0x0); if (FAILED(hr)) { dxgsg9_cat.error() @@ -2236,7 +2236,7 @@ fill_d3d_volume_texture_pixels(DXScreenData &scrn) { // mip_filter_flags| = D3DX_FILTER_DITHER; - hr = D3DXFilterTexture(_d3d_texture, (PALETTEENTRY*)NULL, 0, + hr = D3DXFilterTexture(_d3d_texture, nullptr, 0, mip_filter_flags); if (FAILED(hr)) { dxgsg9_cat.error() diff --git a/panda/src/dxgsg9/dxVertexBufferContext9.cxx b/panda/src/dxgsg9/dxVertexBufferContext9.cxx index 48eb65fc6e..43ef9d51c9 100644 --- a/panda/src/dxgsg9/dxVertexBufferContext9.cxx +++ b/panda/src/dxgsg9/dxVertexBufferContext9.cxx @@ -31,7 +31,7 @@ DXVertexBufferContext9(DXGraphicsStateGuardian9 *dxgsg, PreparedGraphicsObjects *pgo, GeomVertexArrayData *data) : VertexBufferContext(pgo, data), - _vbuffer(NULL) + _vbuffer(nullptr) { // Now fill in the FVF code. const GeomVertexArrayFormat *array_format = data->get_array_format(); @@ -174,9 +174,9 @@ void DXVertexBufferContext9:: evict_lru() { dequeue_lru(); - if ( _vbuffer != NULL ) { + if ( _vbuffer != nullptr ) { _vbuffer->Release(); - _vbuffer = NULL; + _vbuffer = nullptr; } update_data_size_bytes(0); diff --git a/panda/src/dxgsg9/dxgsg9base.h b/panda/src/dxgsg9/dxgsg9base.h index 1566a55ba5..359b9fa2a1 100644 --- a/panda/src/dxgsg9/dxgsg9base.h +++ b/panda/src/dxgsg9/dxgsg9base.h @@ -82,14 +82,14 @@ typedef DWORD DXShaderHandle; var.dwSize = sizeof(type); #define SAFE_DELSHADER(TYPE,HANDLE,PDEVICE) \ - if((HANDLE!=NULL)&&IS_VALID_PTR(PDEVICE)) { PDEVICE->Delete##TYPE##Shader(HANDLE); HANDLE=NULL; } + if((HANDLE!=nullptr)&&IS_VALID_PTR(PDEVICE)) { PDEVICE->Delete##TYPE##Shader(HANDLE); HANDLE=nullptr; } -#define SAFE_DELETE(p) { if(p) { assert(IS_VALID_PTR(p)); delete (p); (p)=NULL; } } -#define SAFE_DELETE_ARRAY(p) { if(p) { assert(IS_VALID_PTR(p)); delete [] (p); (p)=NULL; } } +#define SAFE_DELETE(p) { if(p) { assert(IS_VALID_PTR(p)); delete (p); (p)=nullptr; } } +#define SAFE_DELETE_ARRAY(p) { if(p) { assert(IS_VALID_PTR(p)); delete [] (p); (p)=nullptr; } } // for stuff outside a panda class -#define SAFE_RELEASE(p) { if(p) { assert(IS_VALID_PTR(p)); (p)->Release(); (p)=NULL; } } -#define SAFE_FREELIB(hDLL) { if(hDLL!=NULL) { FreeLibrary(hDLL);hDLL = NULL; } } +#define SAFE_RELEASE(p) { if(p) { assert(IS_VALID_PTR(p)); (p)->Release(); (p)=nullptr; } } +#define SAFE_FREELIB(hDLL) { if(hDLL!=nullptr) { FreeLibrary(hDLL);hDLL = nullptr; } } // this is bDoDownToZero argument to RELEASE() #define RELEASE_DOWN_TO_ZERO true @@ -110,7 +110,7 @@ typedef DWORD DXShaderHandle; refcnt = (OBJECT)->Release(); \ } while(refcnt>0); \ } \ - (OBJECT) = NULL; \ + (OBJECT) = nullptr; \ } else { \ MODULE##_cat.debug() << DBGSTR << " not released, ptr == NULL" << endl; \ }} @@ -129,7 +129,7 @@ typedef DWORD DXShaderHandle; refcnt = (OBJECT)->Release(); \ } while(refcnt>0); \ } \ - (OBJECT) = NULL; \ + (OBJECT) = nullptr; \ }} #define PRINT_REFCNT(MODULE,p) diff --git a/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx b/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx index 3cde32fc16..9ac420db2d 100644 --- a/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx @@ -37,10 +37,10 @@ wdxGraphicsBuffer9(GraphicsEngine *engine, GraphicsPipe *pipe, { // initialize all class members _cube_map_index = -1; - _saved_color_buffer = NULL; - _saved_depth_buffer = NULL; - _color_backing_store = NULL; - _depth_backing_store = NULL; + _saved_color_buffer = nullptr; + _saved_depth_buffer = nullptr; + _color_backing_store = nullptr; + _depth_backing_store = nullptr; // is this correct ??? Since the pbuffer never gets flipped, we get // screenshots from the same buffer we draw into. @@ -120,7 +120,7 @@ bool wdxGraphicsBuffer9:: begin_frame(FrameMode mode, Thread *current_thread) { begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } if (_dxgsg -> _d3d_device == 0) { @@ -151,7 +151,7 @@ void wdxGraphicsBuffer9:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { copy_to_textures(); @@ -225,7 +225,7 @@ restore_bitplanes() { // clear all render targets, except for the main render target for (int i = 1; i _d3d_device -> SetRenderTarget (i, NULL); + hr = _dxgsg -> _d3d_device -> SetRenderTarget (i, nullptr); if (!SUCCEEDED (hr)) { dxgsg9_cat.error ( ) << "SetRenderTarget " << i << " " << D3DERRORSTRING(hr) FL; } @@ -235,8 +235,8 @@ restore_bitplanes() { if (_saved_depth_buffer) { _saved_depth_buffer->Release(); } - _saved_color_buffer = NULL; - _saved_depth_buffer = NULL; + _saved_color_buffer = nullptr; + _saved_depth_buffer = nullptr; } @@ -335,7 +335,7 @@ rebuild_bitplanes() { if ((_color_backing_store)&& ((bitplane_x != _backing_sizex)||(bitplane_y != _backing_sizey))) { _color_backing_store->Release(); - _color_backing_store = NULL; + _color_backing_store = nullptr; } if (!_color_backing_store) { hr = _dxgsg->_d3d_device->CreateRenderTarget(bitplane_x, bitplane_y, @@ -344,7 +344,7 @@ rebuild_bitplanes() { _saved_color_desc.MultiSampleQuality, FALSE, &_color_backing_store, - NULL); + nullptr); if (!SUCCEEDED(hr)) { dxgsg9_cat.error ( ) << "CreateRenderTarget " << D3DERRORSTRING(hr) FL; } @@ -354,7 +354,7 @@ rebuild_bitplanes() { // Maintain the color texture. if (_color_backing_store) { _color_backing_store->Release(); - _color_backing_store = NULL; + _color_backing_store = nullptr; } color_tex = get_texture(color_tex_index); color_tex->set_size_padded(get_x_size(), get_y_size()); @@ -409,13 +409,13 @@ rebuild_bitplanes() { if ((_depth_backing_store)&& ((bitplane_x != _backing_sizex)||(bitplane_y != _backing_sizey))) { _depth_backing_store->Release(); - _depth_backing_store = NULL; + _depth_backing_store = nullptr; } if (!_depth_backing_store) { hr = _dxgsg -> _d3d_device -> CreateDepthStencilSurface (bitplane_x, bitplane_y, _saved_depth_desc.Format, _saved_depth_desc.MultiSampleType, _saved_depth_desc.MultiSampleQuality, - false, &_depth_backing_store, NULL); + false, &_depth_backing_store, nullptr); if (!SUCCEEDED(hr)) { dxgsg9_cat.error ( ) << "CreateDepthStencilSurface " << D3DERRORSTRING(hr) FL; } @@ -426,7 +426,7 @@ rebuild_bitplanes() { // Maintain the depth texture. if (_depth_backing_store) { _depth_backing_store->Release(); - _depth_backing_store = NULL; + _depth_backing_store = nullptr; } if (_shared_depth_buffer) { @@ -704,7 +704,7 @@ process_events() { // Handle all the messages on the queue in a row. Some of these might be // for another window, but they will get dispatched appropriately. - while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { + while (PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE)) { process_1_event(); } } @@ -717,11 +717,11 @@ close_buffer() { if (_color_backing_store) { _color_backing_store->Release(); - _color_backing_store = NULL; + _color_backing_store = nullptr; } if (_depth_backing_store) { _depth_backing_store->Release(); - _depth_backing_store = NULL; + _depth_backing_store = nullptr; } _cube_map_index = -1; @@ -784,7 +784,7 @@ void wdxGraphicsBuffer9:: process_1_event() { MSG msg; - if (!GetMessage(&msg, NULL, 0, 0)) { + if (!GetMessage(&msg, nullptr, 0, 0)) { // WM_QUIT received. We need a cleaner way to deal with this. // DestroyAllWindows(false); exit(msg.wParam); // this will invoke AtExitFn diff --git a/panda/src/dxgsg9/wdxGraphicsPipe9.cxx b/panda/src/dxgsg9/wdxGraphicsPipe9.cxx index c3c0ee0099..7ff6f28e5d 100644 --- a/panda/src/dxgsg9/wdxGraphicsPipe9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsPipe9.cxx @@ -21,7 +21,7 @@ TypeHandle wdxGraphicsPipe9::_type_handle; static bool MyGetProcAddr(HINSTANCE hDLL, FARPROC *pFn, const char *szExportedFnName) { *pFn = (FARPROC) GetProcAddress(hDLL, szExportedFnName); - if (*pFn == NULL) { + if (*pFn == nullptr) { wdxdisplay9_cat.error() << "GetProcAddr failed for " << szExportedFnName << ", error=" << GetLastError() < 0)|| (fb_prop.get_aux_rgba() > 0)|| (fb_prop.get_aux_float() > 0)) { - return NULL; + return nullptr; } } return new wdxGraphicsWindow9(engine, this, name, fb_prop, win_prop, @@ -130,7 +130,7 @@ make_output(const string &name, ((flags&BF_require_window)!=0)|| ((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_every)!=0)) { - return NULL; + return nullptr; } // Early failure - if we are sure that this buffer WONT meet specs, we can // bail out early. @@ -139,13 +139,13 @@ make_output(const string &name, (fb_prop.get_back_buffers() > 0)|| (fb_prop.get_accum_bits() > 0)|| (fb_prop.get_multisamples() > 0)) { - return NULL; + return nullptr; } } // Early success - if we are sure that this buffer WILL meet specs, we can // precertify it. This looks rather overly optimistic -- ie, buggy. - if ((wdxgsg != NULL) && wdxgsg->is_valid() && !wdxgsg->needs_reset() && + if ((wdxgsg != nullptr) && wdxgsg->is_valid() && !wdxgsg->needs_reset() && wdxgsg->get_supports_render_texture()) { precertify = true; } @@ -154,7 +154,7 @@ make_output(const string &name, } // Nothing else left to try. - return NULL; + return nullptr; } /** @@ -165,7 +165,7 @@ make_output(const string &name, bool wdxGraphicsPipe9:: init() { _hDDrawDLL = LoadLibrary("ddraw.dll"); - if (_hDDrawDLL == NULL) { + if (_hDDrawDLL == nullptr) { wdxdisplay9_cat.error() << "LoadLibrary failed for ddraw.dll, error=" << GetLastError() <show_frame(); } WinGraphicsWindow::end_flip(); @@ -234,11 +234,11 @@ close_window() { << "wdxGraphicsWindow9::close_window() " << this << "\n"; } - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { _gsg.clear(); } - DXGraphicsStateGuardian9::set_cg_device(NULL); + DXGraphicsStateGuardian9::set_cg_device(nullptr); _dxgsg->release_swap_chain(&_wcontext); WinGraphicsWindow::close_window(); @@ -291,7 +291,7 @@ open_window() { // case just create an additional swapchain for this window while (true) { - if (_dxgsg->get_pipe()->get_device() == NULL || discard_device) { + if (_dxgsg->get_pipe()->get_device() == nullptr || discard_device) { wdxdisplay9_cat.debug() << "device is null or fullscreen\n"; // If device exists, free it @@ -370,7 +370,7 @@ fullscreen_restored(WindowProperties &properties) { // as soon as the window is restored, even though BeginScene() says we can. // Instead, we have to wait until TestCooperativeLevel() lets us in. We // need to set a flag so we can handle this special case in begin_frame(). - if (_dxgsg != NULL) { + if (_dxgsg != nullptr) { _awaiting_restore = true; } } @@ -384,7 +384,7 @@ handle_reshape() { GdiFlush(); WinGraphicsWindow::handle_reshape(); - if (_dxgsg != NULL && _dxgsg->_d3d_device != NULL) { + if (_dxgsg != nullptr && _dxgsg->_d3d_device != nullptr) { // create the new resized rendertargets WindowProperties props = get_properties(); int x_size = props.get_x_size(); @@ -539,7 +539,7 @@ create_screen_buffers_and_device(DXScreenData &display, bool force_16bpp_zbuffer PRINT_REFCNT(wdxdisplay9, _d3d9); - nassertr(_d3d9 != NULL, false); + nassertr(_d3d9 != nullptr, false); nassertr(pD3DCaps->DevCaps & D3DDEVCAPS_HWRASTERIZATION, false); bool do_sync = sync_video; @@ -601,7 +601,7 @@ create_screen_buffers_and_device(DXScreenData &display, bool force_16bpp_zbuffer while (supported_multisamples > 1){ // need to check both rendertarget and zbuffer fmts hr = _d3d9->CheckDeviceMultiSampleType(adapter, D3DDEVTYPE_HAL, display._display_mode.Format, - is_fullscreen(), D3DMULTISAMPLE_TYPE(supported_multisamples), NULL); + is_fullscreen(), D3DMULTISAMPLE_TYPE(supported_multisamples), nullptr); if (FAILED(hr)) { supported_multisamples--; continue; @@ -609,7 +609,7 @@ create_screen_buffers_and_device(DXScreenData &display, bool force_16bpp_zbuffer if (display._presentation_params.EnableAutoDepthStencil) { hr = _d3d9->CheckDeviceMultiSampleType(adapter, D3DDEVTYPE_HAL, display._presentation_params.AutoDepthStencilFormat, - is_fullscreen(), D3DMULTISAMPLE_TYPE(supported_multisamples), NULL); + is_fullscreen(), D3DMULTISAMPLE_TYPE(supported_multisamples), nullptr); if (FAILED(hr)) { supported_multisamples--; continue; @@ -886,7 +886,7 @@ choose_device() { << " Revision: 0x" << adapter_info.Revision << dec << endl; HMONITOR _monitor = dxpipe->__d3d9->GetAdapterMonitor(i); - if (_monitor == NULL) { + if (_monitor == nullptr) { wdxdisplay9_cat.info() << "D3D9 Adapter[" << i << "]: seems to be disabled, skipping it\n"; continue; @@ -968,14 +968,14 @@ choose_device() { bool wdxGraphicsWindow9:: consider_device(wdxGraphicsPipe9 *dxpipe, DXDeviceInfo *device_info) { - nassertr(dxpipe != NULL, false); + nassertr(dxpipe != nullptr, false); WindowProperties properties = get_properties(); DWORD dwRenderWidth = properties.get_x_size(); DWORD dwRenderHeight = properties.get_y_size(); HRESULT hr; LPDIRECT3D9 _d3d9 = dxpipe->__d3d9; - nassertr(_dxgsg != NULL, false); + nassertr(_dxgsg != nullptr, false); _wcontext._d3d9 = _d3d9; _wcontext._is_dx9_1 = dxpipe->__is_dx9_1; _wcontext._card_id = device_info->cardID; // could this change by end? @@ -1123,7 +1123,7 @@ bool wdxGraphicsWindow9:: reset_device_resize_window(UINT new_xsize, UINT new_ysize) { bool retval = true; - DXScreenData *screen = NULL; + DXScreenData *screen = nullptr; D3DPRESENT_PARAMETERS d3dpp; memcpy(&d3dpp, &_wcontext._presentation_params, sizeof(D3DPRESENT_PARAMETERS)); _wcontext._presentation_params.BackBufferWidth = new_xsize; @@ -1184,7 +1184,7 @@ init_resized_window() { DWORD newHeight = _wcontext._presentation_params.BackBufferHeight; nassertv((newWidth != 0) && (newHeight != 0)); - nassertv(_wcontext._window != NULL); + nassertv(_wcontext._window != nullptr); if (_wcontext._presentation_params.Windowed) { POINT ul, lr; @@ -1207,7 +1207,7 @@ init_resized_window() { } // clear window to black ASAP - nassertv(_wcontext._window != NULL); + nassertv(_wcontext._window != nullptr); ClearToBlack(_wcontext._window, get_properties()); // clear textures and VB's out of video&AGP mem, so cache is reset @@ -1229,19 +1229,19 @@ init_resized_window() { flags = D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER; clear_color = 0x00000000; - hr = _wcontext._d3d_device-> Clear (0, NULL, flags, clear_color, 0.0f, 0); + hr = _wcontext._d3d_device-> Clear (0, nullptr, flags, clear_color, 0.0f, 0); if (FAILED(hr)) { wdxdisplay9_cat.error() << "Clear failed for device" << D3DERRORSTRING(hr); } - hr = _wcontext._d3d_device-> Present (NULL, NULL, NULL, NULL); + hr = _wcontext._d3d_device-> Present (nullptr, nullptr, nullptr, nullptr); if (FAILED(hr)) { wdxdisplay9_cat.error() << "Present failed for device" << D3DERRORSTRING(hr); } - hr = _wcontext._d3d_device-> Clear (0, NULL, flags, clear_color, 0.0f, 0); + hr = _wcontext._d3d_device-> Clear (0, nullptr, flags, clear_color, 0.0f, 0); if (FAILED(hr)) { wdxdisplay9_cat.error() << "Clear failed for device" diff --git a/panda/src/dxml/config_dxml.cxx b/panda/src/dxml/config_dxml.cxx index 7e25a58c3a..9c9a65533b 100644 --- a/panda/src/dxml/config_dxml.cxx +++ b/panda/src/dxml/config_dxml.cxx @@ -59,7 +59,7 @@ read_xml_stream(istream &in) { in >> *doc; if (in.fail() && !in.eof()) { delete doc; - return NULL; + return nullptr; } return doc; @@ -103,7 +103,7 @@ print_xml_to_file(const Filename &filename, TiXmlNode *xnode) { if (fopen_s(&file, os_name.c_str(), "w") != 0) { #else FILE *file = fopen(os_name.c_str(), "w"); - if (file == NULL) { + if (file == nullptr) { #endif dxml_cat.error() << "Failed to open " << filename << " for writing\n"; } diff --git a/panda/src/dxml/tinyxml.cpp b/panda/src/dxml/tinyxml.cpp index 05c2cc2af4..be84236496 100644 --- a/panda/src/dxml/tinyxml.cpp +++ b/panda/src/dxml/tinyxml.cpp @@ -42,7 +42,7 @@ bool TiXmlBase::condenseWhiteSpace = true; FILE* TiXmlFOpen( const char* filename, const char* mode ) { #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) - FILE* fp = 0; + FILE* fp = nullptr; /* Addition by drwr for Windows wide-character support */ //errno_t err = fopen_s( &fp, filename, mode ); @@ -65,7 +65,7 @@ FILE* TiXmlFOpen( const char* filename, const char* mode ) if ( !err && fp ) return fp; - return 0; + return nullptr; #else return fopen( filename, mode ); #endif @@ -157,19 +157,19 @@ void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString ) TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase() { - parent = 0; + parent = nullptr; type = _type; - firstChild = 0; - lastChild = 0; - prev = 0; - next = 0; + firstChild = nullptr; + lastChild = nullptr; + prev = nullptr; + next = nullptr; } TiXmlNode::~TiXmlNode() { TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; + TiXmlNode* temp = nullptr; while ( node ) { @@ -191,7 +191,7 @@ void TiXmlNode::CopyTo( TiXmlNode* target ) const void TiXmlNode::Clear() { TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; + TiXmlNode* temp = nullptr; while ( node ) { @@ -200,27 +200,27 @@ void TiXmlNode::Clear() delete temp; } - firstChild = 0; - lastChild = 0; + firstChild = nullptr; + lastChild = nullptr; } TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node ) { - assert( node->parent == 0 || node->parent == this ); - assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() ); + assert( node->parent == nullptr || node->parent == this ); + assert( node->GetDocument() == nullptr || node->GetDocument() == this->GetDocument() ); if ( node->Type() == TiXmlNode::TINYXML_DOCUMENT ) { delete node; - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); + return nullptr; } node->parent = this; node->prev = lastChild; - node->next = 0; + node->next = nullptr; if ( lastChild ) lastChild->next = node; @@ -236,12 +236,12 @@ TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) { if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); + return nullptr; } TiXmlNode* node = addThis.Clone(); if ( !node ) - return 0; + return nullptr; return LinkEndChild( node ); } @@ -250,17 +250,17 @@ TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ) { if ( !beforeThis || beforeThis->parent != this ) { - return 0; + return nullptr; } if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); + return nullptr; } TiXmlNode* node = addThis.Clone(); if ( !node ) - return 0; + return nullptr; node->parent = this; node->next = beforeThis; @@ -282,17 +282,17 @@ TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) { if ( !afterThis || afterThis->parent != this ) { - return 0; + return nullptr; } if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) { - if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); + return nullptr; } TiXmlNode* node = addThis.Clone(); if ( !node ) - return 0; + return nullptr; node->parent = this; node->prev = afterThis; @@ -314,22 +314,22 @@ TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& a TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) { if ( !replaceThis ) - return 0; + return nullptr; if ( replaceThis->parent != this ) - return 0; + return nullptr; if ( withThis.ToDocument() ) { // A document can never be a child. Thanks to Noam. TiXmlDocument* document = GetDocument(); if ( document ) - document->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; + document->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); + return nullptr; } TiXmlNode* node = withThis.Clone(); if ( !node ) - return 0; + return nullptr; node->next = replaceThis->next; node->prev = replaceThis->prev; @@ -384,7 +384,7 @@ const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const if ( strcmp( node->Value(), _value ) == 0 ) return node; } - return 0; + return nullptr; } @@ -396,7 +396,7 @@ const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const if ( strcmp( node->Value(), _value ) == 0 ) return node; } - return 0; + return nullptr; } @@ -436,7 +436,7 @@ const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const if ( strcmp( node->Value(), _value ) == 0 ) return node; } - return 0; + return nullptr; } @@ -448,7 +448,7 @@ const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const if ( strcmp( node->Value(), _value ) == 0 ) return node; } - return 0; + return nullptr; } @@ -478,7 +478,7 @@ const TiXmlElement* TiXmlNode::FirstChildElement() const if ( node->ToElement() ) return node->ToElement(); } - return 0; + return nullptr; } @@ -493,7 +493,7 @@ const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const if ( node->ToElement() ) return node->ToElement(); } - return 0; + return nullptr; } @@ -508,7 +508,7 @@ const TiXmlElement* TiXmlNode::NextSiblingElement() const if ( node->ToElement() ) return node->ToElement(); } - return 0; + return nullptr; } @@ -523,7 +523,7 @@ const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const if ( node->ToElement() ) return node->ToElement(); } - return 0; + return nullptr; } @@ -536,14 +536,14 @@ const TiXmlDocument* TiXmlNode::GetDocument() const if ( node->ToDocument() ) return node->ToDocument(); } - return 0; + return nullptr; } TiXmlElement::TiXmlElement (const char * _value) : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) { - firstChild = lastChild = 0; + firstChild = lastChild = nullptr; value = _value; } @@ -552,7 +552,7 @@ TiXmlElement::TiXmlElement (const char * _value) TiXmlElement::TiXmlElement( const std::string& _value ) : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) { - firstChild = lastChild = 0; + firstChild = lastChild = nullptr; value = _value; } #endif @@ -561,7 +561,7 @@ TiXmlElement::TiXmlElement( const std::string& _value ) TiXmlElement::TiXmlElement( const TiXmlElement& copy) : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) { - firstChild = lastChild = 0; + firstChild = lastChild = nullptr; copy.CopyTo( this ); } @@ -596,7 +596,7 @@ const char* TiXmlElement::Attribute( const char* name ) const const TiXmlAttribute* node = attributeSet.Find( name ); if ( node ) return node->Value(); - return 0; + return nullptr; } @@ -606,7 +606,7 @@ const std::string* TiXmlElement::Attribute( const std::string& name ) const const TiXmlAttribute* attrib = attributeSet.Find( name ); if ( attrib ) return &attrib->ValueStr(); - return 0; + return nullptr; } #endif @@ -614,7 +614,7 @@ const std::string* TiXmlElement::Attribute( const std::string& name ) const const char* TiXmlElement::Attribute( const char* name, int* i ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); - const char* result = 0; + const char* result = nullptr; if ( attrib ) { result = attrib->Value(); @@ -630,7 +630,7 @@ const char* TiXmlElement::Attribute( const char* name, int* i ) const const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); - const std::string* result = 0; + const std::string* result = nullptr; if ( attrib ) { result = &attrib->ValueStr(); @@ -646,7 +646,7 @@ const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) co const char* TiXmlElement::Attribute( const char* name, double* d ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); - const char* result = 0; + const char* result = nullptr; if ( attrib ) { result = attrib->Value(); @@ -662,7 +662,7 @@ const char* TiXmlElement::Attribute( const char* name, double* d ) const const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const { const TiXmlAttribute* attrib = attributeSet.Find( name ); - const std::string* result = 0; + const std::string* result = nullptr; if ( attrib ) { result = &attrib->ValueStr(); @@ -835,7 +835,7 @@ void TiXmlElement::CopyTo( TiXmlElement* target ) const // Element class: // Clone the attributes, then clone the children. - const TiXmlAttribute* attribute = 0; + const TiXmlAttribute* attribute = nullptr; for( attribute = attributeSet.First(); attribute; attribute = attribute->Next() ) @@ -843,7 +843,7 @@ void TiXmlElement::CopyTo( TiXmlElement* target ) const target->SetAttribute( attribute->Name(), attribute->Value() ); } - TiXmlNode* node = 0; + TiXmlNode* node = nullptr; for ( node = firstChild; node; node = node->NextSibling() ) { target->LinkEndChild( node->Clone() ); @@ -868,7 +868,7 @@ TiXmlNode* TiXmlElement::Clone() const { TiXmlElement* clone = new TiXmlElement( Value() ); if ( !clone ) - return 0; + return nullptr; CopyTo( clone ); return clone; @@ -884,7 +884,7 @@ const char* TiXmlElement::GetText() const return childText->Value(); } } - return 0; + return nullptr; } @@ -955,7 +955,7 @@ bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding ) } else { - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + SetError( TIXML_ERROR_OPENING_FILE, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return false; } } @@ -964,7 +964,7 @@ bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) { if ( !file ) { - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + SetError( TIXML_ERROR_OPENING_FILE, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return false; } @@ -981,7 +981,7 @@ bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) // Strange case, but good to handle up front. if ( length <= 0 ) { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + SetError( TIXML_ERROR_DOCUMENT_EMPTY, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return false; } @@ -1011,7 +1011,7 @@ bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) if ( fread( buf, length, 1, file ) != 1 ) { delete [] buf; - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + SetError( TIXML_ERROR_OPENING_FILE, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return false; } @@ -1051,7 +1051,7 @@ bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) assert( q <= (buf+length) ); *q = 0; - Parse( buf, 0, encoding ); + Parse( buf, nullptr, encoding ); delete [] buf; return !Error(); @@ -1100,7 +1100,7 @@ void TiXmlDocument::CopyTo( TiXmlDocument* target ) const target->errorLocation = errorLocation; target->useMicrosoftBOM = useMicrosoftBOM; - TiXmlNode* node = 0; + TiXmlNode* node = nullptr; for ( node = firstChild; node; node = node->NextSibling() ) { target->LinkEndChild( node->Clone() ); @@ -1112,7 +1112,7 @@ TiXmlNode* TiXmlDocument::Clone() const { TiXmlDocument* clone = new TiXmlDocument(); if ( !clone ) - return 0; + return nullptr; CopyTo( clone ); return clone; @@ -1149,7 +1149,7 @@ const TiXmlAttribute* TiXmlAttribute::Next() const // We are using knowledge of the sentinel. The sentinel // have a value or name. if ( next->value.empty() && next->name.empty() ) - return 0; + return nullptr; return next; } @@ -1169,7 +1169,7 @@ const TiXmlAttribute* TiXmlAttribute::Previous() const // We are using knowledge of the sentinel. The sentinel // have a value or name. if ( prev->value.empty() && prev->name.empty() ) - return 0; + return nullptr; return prev; } @@ -1298,7 +1298,7 @@ TiXmlNode* TiXmlComment::Clone() const TiXmlComment* clone = new TiXmlComment(); if ( !clone ) - return 0; + return nullptr; CopyTo( clone ); return clone; @@ -1341,11 +1341,11 @@ bool TiXmlText::Accept( TiXmlVisitor* visitor ) const TiXmlNode* TiXmlText::Clone() const { - TiXmlText* clone = 0; + TiXmlText* clone = nullptr; clone = new TiXmlText( "" ); if ( !clone ) - return 0; + return nullptr; CopyTo( clone ); return clone; @@ -1433,7 +1433,7 @@ TiXmlNode* TiXmlDeclaration::Clone() const TiXmlDeclaration* clone = new TiXmlDeclaration(); if ( !clone ) - return 0; + return nullptr; CopyTo( clone ); return clone; @@ -1465,7 +1465,7 @@ TiXmlNode* TiXmlUnknown::Clone() const TiXmlUnknown* clone = new TiXmlUnknown(); if ( !clone ) - return 0; + return nullptr; CopyTo( clone ); return clone; @@ -1511,8 +1511,8 @@ void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe ) { node->prev->next = node->next; node->next->prev = node->prev; - node->next = 0; - node->prev = 0; + node->next = nullptr; + node->prev = nullptr; return; } } @@ -1528,7 +1528,7 @@ TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const if ( node->name == name ) return node; } - return 0; + return nullptr; } TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const std::string& _name ) @@ -1551,7 +1551,7 @@ TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const if ( strcmp( node->name.c_str(), name ) == 0 ) return node; } - return 0; + return nullptr; } @@ -1574,7 +1574,7 @@ std::istream& operator>> (std::istream & in, TiXmlNode & base) tag.reserve( 8 * 1000 ); base.StreamIn( &in, &tag ); - base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING ); + base.Parse( tag.c_str(), nullptr, TIXML_DEFAULT_ENCODING ); return in; } #endif @@ -1612,7 +1612,7 @@ TiXmlHandle TiXmlHandle::FirstChild() const if ( child ) return TiXmlHandle( child ); } - return TiXmlHandle( 0 ); + return TiXmlHandle( nullptr ); } @@ -1624,7 +1624,7 @@ TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const if ( child ) return TiXmlHandle( child ); } - return TiXmlHandle( 0 ); + return TiXmlHandle( nullptr ); } @@ -1636,7 +1636,7 @@ TiXmlHandle TiXmlHandle::FirstChildElement() const if ( child ) return TiXmlHandle( child ); } - return TiXmlHandle( 0 ); + return TiXmlHandle( nullptr ); } @@ -1648,7 +1648,7 @@ TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const if ( child ) return TiXmlHandle( child ); } - return TiXmlHandle( 0 ); + return TiXmlHandle( nullptr ); } @@ -1667,7 +1667,7 @@ TiXmlHandle TiXmlHandle::Child( int count ) const if ( child ) return TiXmlHandle( child ); } - return TiXmlHandle( 0 ); + return TiXmlHandle( nullptr ); } @@ -1686,7 +1686,7 @@ TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const if ( child ) return TiXmlHandle( child ); } - return TiXmlHandle( 0 ); + return TiXmlHandle( nullptr ); } @@ -1705,7 +1705,7 @@ TiXmlHandle TiXmlHandle::ChildElement( int count ) const if ( child ) return TiXmlHandle( child ); } - return TiXmlHandle( 0 ); + return TiXmlHandle( nullptr ); } @@ -1724,7 +1724,7 @@ TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const if ( child ) return TiXmlHandle( child ); } - return TiXmlHandle( 0 ); + return TiXmlHandle( nullptr ); } @@ -1747,7 +1747,7 @@ bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) { buffer += " "; - attrib->Print( 0, 0, &buffer ); + attrib->Print( nullptr, 0, &buffer ); } if ( !element.FirstChild() ) @@ -1832,7 +1832,7 @@ bool TiXmlPrinter::Visit( const TiXmlText& text ) bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration ) { DoIndent(); - declaration.Print( 0, 0, &buffer ); + declaration.Print( nullptr, 0, &buffer ); DoLineBreak(); return true; } diff --git a/panda/src/dxml/tinyxmlparser.cpp b/panda/src/dxml/tinyxmlparser.cpp index 666a4f757c..edf757b761 100644 --- a/panda/src/dxml/tinyxmlparser.cpp +++ b/panda/src/dxml/tinyxmlparser.cpp @@ -315,7 +315,7 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding ) { if ( !p || !*p ) { - return 0; + return nullptr; } if ( encoding == TIXML_ENCODING_UTF8 ) { @@ -432,7 +432,7 @@ const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncodi } return p; } - return 0; + return nullptr; } const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding ) @@ -451,12 +451,12 @@ const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXml if ( *(p+2) == 'x' ) { // Hexadecimal. - if ( !*(p+3) ) return 0; + if ( !*(p+3) ) return nullptr; const char* q = p+3; q = strchr( q, ';' ); - if ( !q || !*q ) return 0; + if ( !q || !*q ) return nullptr; delta = q-p; --q; @@ -470,7 +470,7 @@ const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXml else if ( *q >= 'A' && *q <= 'F' ) ucs += mult * (*q - 'A' + 10 ); else - return 0; + return nullptr; mult *= 16; --q; } @@ -478,12 +478,12 @@ const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXml else { // Decimal. - if ( !*(p+2) ) return 0; + if ( !*(p+2) ) return nullptr; const char* q = p+2; q = strchr( q, ';' ); - if ( !q || !*q ) return 0; + if ( !q || !*q ) return nullptr; delta = q-p; --q; @@ -493,7 +493,7 @@ const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXml if ( *q >= '0' && *q <= '9' ) ucs += mult * (*q - '0'); else - return 0; + return nullptr; mult *= 10; --q; } @@ -649,7 +649,7 @@ void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) if ( !StreamTo( in, '<', tag ) ) { - SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + SetError( TIXML_ERROR_PARSING_EMPTY, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return; } @@ -661,7 +661,7 @@ void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) int c = in->get(); if ( c <= 0 ) { - SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + SetError( TIXML_ERROR_EMBEDDED_NULL, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); break; } (*tag) += (char) c; @@ -677,9 +677,9 @@ void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) if ( node ) { node->StreamIn( in, tag ); - bool isElement = node->ToElement() != 0; + bool isElement = node->ToElement() != nullptr; delete node; - node = 0; + node = nullptr; // If this is the root element, we're done. Parsing will be // done by the >> operator. @@ -690,13 +690,13 @@ void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) } else { - SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); + SetError( TIXML_ERROR, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return; } } } // We should have returned sooner. - SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); + SetError( TIXML_ERROR, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); } #endif @@ -710,8 +710,8 @@ const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiX // here is skipping white space. if ( !p || !*p ) { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; + SetError( TIXML_ERROR_DOCUMENT_EMPTY, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); + return nullptr; } // Note that, for a document, this needs to come @@ -747,8 +747,8 @@ const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiX p = SkipWhiteSpace( p, encoding ); if ( !p ) { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; + SetError( TIXML_ERROR_DOCUMENT_EMPTY, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); + return nullptr; } while ( p && *p ) @@ -787,8 +787,8 @@ const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiX // Was this empty? if ( !firstChild ) { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding ); - return 0; + SetError( TIXML_ERROR_DOCUMENT_EMPTY, nullptr, nullptr, encoding ); + return nullptr; } // All is well. @@ -817,19 +817,19 @@ void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* dat TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding ) { - TiXmlNode* returnNode = 0; + TiXmlNode* returnNode = nullptr; p = SkipWhiteSpace( p, encoding ); if( !p || !*p || *p != '<' ) { - return 0; + return nullptr; } p = SkipWhiteSpace( p, encoding ); if ( !p || !*p ) { - return 0; + return nullptr; } // What is this thing? @@ -911,7 +911,7 @@ void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag) { TiXmlDocument* document = GetDocument(); if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + document->SetError( TIXML_ERROR_EMBEDDED_NULL, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return; } (*tag) += (char) c ; @@ -973,7 +973,7 @@ void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag) { TiXmlDocument* document = GetDocument(); if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + document->SetError( TIXML_ERROR_EMBEDDED_NULL, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return; } @@ -1013,7 +1013,7 @@ void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag) { TiXmlDocument* document = GetDocument(); if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + document->SetError( TIXML_ERROR_EMBEDDED_NULL, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return; } assert( c == '>' ); @@ -1031,7 +1031,7 @@ void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag) return; node->StreamIn( in, tag ); delete node; - node = 0; + node = nullptr; // No return: go around from the beginning: text, closing tag, or node. } @@ -1047,8 +1047,8 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc if ( !p || !*p ) { - if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, 0, 0, encoding ); - return 0; + if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, nullptr, nullptr, encoding ); + return nullptr; } if ( data ) @@ -1060,7 +1060,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc if ( *p != '<' ) { if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, p, data, encoding ); - return 0; + return nullptr; } p = SkipWhiteSpace( p+1, encoding ); @@ -1072,7 +1072,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc if ( !p || !*p ) { if ( document ) document->SetError( TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, pErr, data, encoding ); - return 0; + return nullptr; } TIXML_STRING endTag ("SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); - return 0; + return nullptr; } if ( *p == '/' ) { @@ -1096,7 +1096,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc if ( *p != '>' ) { if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY, p, data, encoding ); - return 0; + return nullptr; } return (p+1); } @@ -1111,7 +1111,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc // We were looking for the end tag, but found nothing. // Fix for [ 1663758 ] Failure to report error on bad XML if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding ); - return 0; + return nullptr; } // We should find the end tag now @@ -1128,12 +1128,12 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc return p; } if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding ); - return 0; + return nullptr; } else { if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding ); - return 0; + return nullptr; } } else @@ -1142,7 +1142,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc TiXmlAttribute* attrib = new TiXmlAttribute(); if ( !attrib ) { - return 0; + return nullptr; } attrib->SetDocument( document ); @@ -1153,7 +1153,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc { if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding ); delete attrib; - return 0; + return nullptr; } // Handle the strange case of double attributes: @@ -1166,7 +1166,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc { if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding ); delete attrib; - return 0; + return nullptr; } attributeSet.Add( attrib ); @@ -1193,7 +1193,7 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm if ( !textNode ) { - return 0; + return nullptr; } if ( TiXmlBase::IsWhiteSpaceCondensed() ) @@ -1231,7 +1231,7 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm } else { - return 0; + return nullptr; } } } @@ -1241,7 +1241,7 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm if ( !p ) { - if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding ); + if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, nullptr, nullptr, encoding ); } return p; } @@ -1257,7 +1257,7 @@ void TiXmlUnknown::StreamIn( std::istream * in, TIXML_STRING * tag ) { TiXmlDocument* document = GetDocument(); if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + document->SetError( TIXML_ERROR_EMBEDDED_NULL, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return; } (*tag) += (char) c; @@ -1285,7 +1285,7 @@ const char* TiXmlUnknown::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc if ( !p || !*p || *p != '<' ) { if ( document ) document->SetError( TIXML_ERROR_PARSING_UNKNOWN, p, data, encoding ); - return 0; + return nullptr; } ++p; value = ""; @@ -1298,7 +1298,7 @@ const char* TiXmlUnknown::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc if ( !p ) { - if ( document ) document->SetError( TIXML_ERROR_PARSING_UNKNOWN, 0, 0, encoding ); + if ( document ) document->SetError( TIXML_ERROR_PARSING_UNKNOWN, nullptr, nullptr, encoding ); } if ( *p == '>' ) return p+1; @@ -1315,7 +1315,7 @@ void TiXmlComment::StreamIn( std::istream * in, TIXML_STRING * tag ) { TiXmlDocument* document = GetDocument(); if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + document->SetError( TIXML_ERROR_EMBEDDED_NULL, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return; } @@ -1351,7 +1351,7 @@ const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc if ( !StringEqual( p, startTag, false, encoding ) ) { document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding ); - return 0; + return nullptr; } p += strlen( startTag ); @@ -1390,7 +1390,7 @@ const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) { p = SkipWhiteSpace( p, encoding ); - if ( !p || !*p ) return 0; + if ( !p || !*p ) return nullptr; if ( data ) { @@ -1403,13 +1403,13 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlE if ( !p || !*p ) { if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); - return 0; + return nullptr; } p = SkipWhiteSpace( p, encoding ); if ( !p || !*p || *p != '=' ) { if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; + return nullptr; } ++p; // skip '=' @@ -1417,7 +1417,7 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlE if ( !p || !*p ) { if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; + return nullptr; } const char* end; @@ -1451,7 +1451,7 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlE // We did not have an opening quote but seem to have a // closing one. Give up and throw an error. if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; + return nullptr; } value += *p; ++p; @@ -1474,7 +1474,7 @@ void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag ) { TiXmlDocument* document = GetDocument(); if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + document->SetError( TIXML_ERROR_EMBEDDED_NULL, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return; } @@ -1513,7 +1513,7 @@ const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncodi if ( !StringEqual( p, startTag, false, encoding ) ) { document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding ); - return 0; + return nullptr; } p += strlen( startTag ); @@ -1538,7 +1538,7 @@ const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncodi p = ReadText( p, &value, ignoreWhite, end, false, encoding ); if ( p ) return p-1; // don't truncate the '<' - return 0; + return nullptr; } } @@ -1552,7 +1552,7 @@ void TiXmlDeclaration::StreamIn( std::istream * in, TIXML_STRING * tag ) { TiXmlDocument* document = GetDocument(); if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + document->SetError( TIXML_ERROR_EMBEDDED_NULL, nullptr, nullptr, TIXML_ENCODING_UNKNOWN ); return; } (*tag) += (char) c; @@ -1574,8 +1574,8 @@ const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXm TiXmlDocument* document = GetDocument(); if ( !p || !*p || !StringEqual( p, "SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding ); - return 0; + if ( document ) document->SetError( TIXML_ERROR_PARSING_DECLARATION, nullptr, nullptr, _encoding ); + return nullptr; } if ( data ) { @@ -1622,7 +1622,7 @@ const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXm ++p; } } - return 0; + return nullptr; } bool TiXmlText::Blank() const diff --git a/panda/src/egg/eggBinMaker.cxx b/panda/src/egg/eggBinMaker.cxx index 294c76de0d..9200afde6b 100644 --- a/panda/src/egg/eggBinMaker.cxx +++ b/panda/src/egg/eggBinMaker.cxx @@ -128,7 +128,7 @@ get_bin_name(int, const EggNode *) { */ PT(EggBin) EggBinMaker:: make_bin(int, const EggNode *, EggGroup *collapse_from) { - if (collapse_from == (EggGroup *)NULL) { + if (collapse_from == nullptr) { return new EggBin; } else { return new EggBin(*collapse_from); @@ -243,7 +243,7 @@ make_bins_for_group(EggGroupNode *group, const Bins &bins) { if (group->empty() && bins.size() == 1 && - group->get_parent() != NULL && + group->get_parent() != nullptr && group->is_of_type(EggGroup::get_class_type())) { const Nodes &nodes = bins.front(); nassertv(!nodes.empty()); @@ -268,7 +268,7 @@ make_bins_for_group(EggGroupNode *group, const Bins &bins) { const Nodes &nodes = (*bi); nassertv(!nodes.empty()); int bin_number = get_bin_number(nodes.front()); - PT(EggBin) bin = make_bin(bin_number, nodes.front(), NULL); + PT(EggBin) bin = make_bin(bin_number, nodes.front(), nullptr); setup_bin(bin, nodes); group->add_child(bin); diff --git a/panda/src/egg/eggCompositePrimitive.cxx b/panda/src/egg/eggCompositePrimitive.cxx index 65c7e338dd..b42cb080c9 100644 --- a/panda/src/egg/eggCompositePrimitive.cxx +++ b/panda/src/egg/eggCompositePrimitive.cxx @@ -100,7 +100,7 @@ get_shading() const { PT(EggCompositePrimitive) EggCompositePrimitive:: triangulate_in_place() { EggGroupNode *parent = get_parent(); - nassertr(parent != (EggGroupNode *)NULL, this); + nassertr(parent != nullptr, this); PT(EggCompositePrimitive) save_me = this; parent->remove_child(this); @@ -171,7 +171,7 @@ unify_attributes(EggPrimitive::Shading shading) { } EggVertexPool *vertex_pool = orig_vertex->get_pool(); - nassertv(vertex_pool != (EggVertexPool *)NULL); + nassertv(vertex_pool != nullptr); vertex = vertex_pool->create_unique_vertex(*vertex); vertex->copy_grefs_from(*orig_vertex); replace(pi, vertex); @@ -200,7 +200,7 @@ unify_attributes(EggPrimitive::Shading shading) { vertex->clear_color(); EggVertexPool *vertex_pool = orig_vertex->get_pool(); - nassertv(vertex_pool != (EggVertexPool *)NULL); + nassertv(vertex_pool != nullptr); vertex = vertex_pool->create_unique_vertex(*vertex); vertex->copy_grefs_from(*orig_vertex); replace(pi, vertex); @@ -248,7 +248,7 @@ unify_attributes(EggPrimitive::Shading shading) { } EggVertexPool *vertex_pool = orig_vertex->get_pool(); - nassertv(vertex_pool != (EggVertexPool *)NULL); + nassertv(vertex_pool != nullptr); vertex = vertex_pool->create_unique_vertex(*vertex); vertex->copy_grefs_from(*orig_vertex); replace(pi, vertex); diff --git a/panda/src/egg/eggData.cxx b/panda/src/egg/eggData.cxx index b91f660b68..84fe2cde3c 100644 --- a/panda/src/egg/eggData.cxx +++ b/panda/src/egg/eggData.cxx @@ -70,14 +70,14 @@ read(Filename filename, string display_name) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); PT(VirtualFile) vfile = vfs->get_file(filename); - if (vfile == NULL) { + if (vfile == nullptr) { egg_cat.error() << "Could not find " << display_name << "\n"; return false; } set_egg_timestamp(vfile->get_timestamp()); istream *file = vfile->open_read_file(true); - if (file == (istream *)NULL) { + if (file == nullptr) { egg_cat.error() << "Unable to open " << display_name << "\n"; return false; } @@ -158,7 +158,7 @@ merge(EggData &other) { bool EggData:: load_externals(const DSearchPath &searchpath) { return - r_load_externals(searchpath, get_coordinate_system(), NULL); + r_load_externals(searchpath, get_coordinate_system(), nullptr); } /** @@ -211,7 +211,7 @@ write_egg(Filename filename) { filename.set_text(); vfs->delete_file(filename); ostream *file = vfs->open_write_file(filename, true, true); - if (file == (ostream *)NULL) { + if (file == nullptr) { egg_cat.error() << "Unable to open " << filename << " for writing.\n"; return false; } diff --git a/panda/src/egg/eggGroup.I b/panda/src/egg/eggGroup.I index d66de55e0f..4575966733 100644 --- a/panda/src/egg/eggGroup.I +++ b/panda/src/egg/eggGroup.I @@ -686,7 +686,7 @@ set_lod(const EggSwitchCondition &lod) { */ INLINE void EggGroup:: clear_lod() { - _lod = NULL; + _lod = nullptr; } /** @@ -694,7 +694,7 @@ clear_lod() { */ INLINE bool EggGroup:: has_lod() const { - return (_lod != (EggSwitchCondition *)NULL); + return (_lod != nullptr); } /** diff --git a/panda/src/egg/eggGroup.cxx b/panda/src/egg/eggGroup.cxx index 2377006bab..b67d079cce 100644 --- a/panda/src/egg/eggGroup.cxx +++ b/panda/src/egg/eggGroup.cxx @@ -772,7 +772,7 @@ get_num_group_refs() const { */ EggGroup *EggGroup:: get_group_ref(int n) const { - nassertr(n >= 0 && n < (int)_group_refs.size(), NULL); + nassertr(n >= 0 && n < (int)_group_refs.size(), nullptr); return _group_refs[n]; } @@ -1069,7 +1069,7 @@ write_vertex_ref(ostream &out, int indent_level) const { indent(out, indent_level + 2) << " membership { " << membership << " }\n"; } - if (pool == (EggVertexPool *)NULL) { + if (pool == nullptr) { indent(out, indent_level + 2) << "// Invalid NULL vertex pool.\n"; } else { @@ -1121,7 +1121,7 @@ adjust_under() { _node_frame_inv = new MatrixFrame(mat); } else { - _node_frame_inv = NULL; + _node_frame_inv = nullptr; } _vertex_to_node = @@ -1144,8 +1144,8 @@ adjust_under() { // frame. _vertex_frame = _node_frame; _vertex_frame_inv = _node_frame_inv; - _vertex_to_node = NULL; - _node_to_vertex = NULL; + _vertex_to_node = nullptr; + _node_to_vertex = nullptr; } } diff --git a/panda/src/egg/eggGroupNode.cxx b/panda/src/egg/eggGroupNode.cxx index acf509274a..ef31289424 100644 --- a/panda/src/egg/eggGroupNode.cxx +++ b/panda/src/egg/eggGroupNode.cxx @@ -230,7 +230,7 @@ get_next_child() { if (_gnc_iterator != end()) { return *_gnc_iterator++; } - return NULL; + return nullptr; } /** @@ -241,7 +241,7 @@ EggNode *EggGroupNode:: add_child(EggNode *node) { test_ref_count_integrity(); PT(EggNode) ptnode = node; - if (node->_parent != NULL) { + if (node->_parent != nullptr) { node->_parent->remove_child(node); } prepare_add_child(node); @@ -300,7 +300,7 @@ find_child(const string &name) const { } } - return NULL; + return nullptr; } /** @@ -1177,7 +1177,7 @@ rebuild_vertex_pools(EggVertexPools &vertex_pools, unsigned int max_vertices, // vertex pools we've already created already have a copy of each one of // the vertices. bool found_pool = false; - EggVertexPool *best_pool = NULL; + EggVertexPool *best_pool = nullptr; int best_new_vertices = 0; Vertices new_vertices; @@ -1198,7 +1198,7 @@ rebuild_vertex_pools(EggVertexPools &vertex_pools, unsigned int max_vertices, EggVertex *vertex = (*vi); EggVertex *new_vertex = vertex_pool->find_matching_vertex(*vertex); new_vertices.push_back(new_vertex); - if (new_vertex == (EggVertex *)NULL) { + if (new_vertex == nullptr) { ++num_new_vertices; } } @@ -1212,7 +1212,7 @@ rebuild_vertex_pools(EggVertexPools &vertex_pools, unsigned int max_vertices, // We would have to add some vertices to this pool, so this vertex // pool qualifies only if the number of vertices we have to add // would still keep it within our limit. - if (best_pool == (EggVertexPool *)NULL || + if (best_pool == nullptr || num_new_vertices < best_new_vertices) { // This is currently our most favorable vertex pool. best_pool = vertex_pool; @@ -1222,7 +1222,7 @@ rebuild_vertex_pools(EggVertexPools &vertex_pools, unsigned int max_vertices, } if (!found_pool) { - if (best_pool == (EggVertexPool *)NULL) { + if (best_pool == nullptr) { // There was no vertex pool that qualified. We will have to create // a new vertex pool. best_pool = new EggVertexPool(""); @@ -1245,7 +1245,7 @@ rebuild_vertex_pools(EggVertexPools &vertex_pools, unsigned int max_vertices, nassertv(new_vertices.size() == vertices.size()); for (vi = new_vertices.begin(); vi != new_vertices.end(); ++vi) { EggVertex *new_vertex = (*vi); - nassertv(new_vertex != (EggVertex *)NULL); + nassertv(new_vertex != nullptr); prim->add_vertex(new_vertex); } @@ -1545,7 +1545,7 @@ r_load_externals(const DSearchPath &searchpath, CoordinateSystem coordsys, if (ext_data.read(filename)) { // The external file was read correctly. Add its contents into the // tree at this point. - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(filename); } @@ -1577,11 +1577,11 @@ r_load_externals(const DSearchPath &searchpath, CoordinateSystem coordsys, */ void EggGroupNode:: prepare_add_child(EggNode *node) { - nassertv(node != (EggNode *)NULL); + nassertv(node != nullptr); test_ref_count_integrity(); node->test_ref_count_integrity(); // Make sure the node is not already a child of some other group. - nassertv(node->get_parent() == NULL); + nassertv(node->get_parent() == nullptr); nassertv(node->get_depth() == 0); node->_parent = this; @@ -1599,11 +1599,11 @@ prepare_add_child(EggNode *node) { */ void EggGroupNode:: prepare_remove_child(EggNode *node) { - nassertv(node != (EggNode *)NULL); + nassertv(node != nullptr); // Make sure the node is in fact a child of this group. nassertv(node->get_parent() == this); nassertv(node->get_depth() == get_depth() + 1); - node->_parent = NULL; + node->_parent = nullptr; node->update_under(-(get_depth() + 1)); } @@ -1867,7 +1867,7 @@ do_compute_tangent_binormal(const TBNVertexValue &value, EggVertex new_vertex(*vertex); EggVertexUV *uv_obj = new_vertex.modify_uv_obj(value._uv_name); - nassertv(uv_obj != (EggVertexUV *)NULL); + nassertv(uv_obj != nullptr); uv_obj->set_tangent(tangent); uv_obj->set_binormal(binormal); diff --git a/panda/src/egg/eggGroupNode_ext.cxx b/panda/src/egg/eggGroupNode_ext.cxx index a0ac3fcb8e..9a42bb8cad 100644 --- a/panda/src/egg/eggGroupNode_ext.cxx +++ b/panda/src/egg/eggGroupNode_ext.cxx @@ -29,8 +29,8 @@ get_children() const { // Create the Python list object. EggGroupNode::size_type len = _this->size(); PyObject *lst = PyList_New(len); - if (lst == NULL) { - return NULL; + if (lst == nullptr) { + return nullptr; } // Fill in the list. diff --git a/panda/src/egg/eggMaterialCollection.cxx b/panda/src/egg/eggMaterialCollection.cxx index b89f3a1900..3ccc9c330f 100644 --- a/panda/src/egg/eggMaterialCollection.cxx +++ b/panda/src/egg/eggMaterialCollection.cxx @@ -395,5 +395,5 @@ find_mref(const string &mref_name) const { } } - return (EggMaterial *)NULL; + return nullptr; } diff --git a/panda/src/egg/eggMesher.cxx b/panda/src/egg/eggMesher.cxx index 98e583b3e0..89261d9855 100644 --- a/panda/src/egg/eggMesher.cxx +++ b/panda/src/egg/eggMesher.cxx @@ -30,7 +30,7 @@ */ EggMesher:: EggMesher() { - _vertex_pool = NULL; + _vertex_pool = nullptr; _strip_index = 0; } @@ -70,7 +70,7 @@ mesh(EggGroupNode *group, bool flat_shaded) { if (child->is_of_type(EggPolygon::get_class_type())) { EggPolygon *poly = DCAST(EggPolygon, child); - if (_vertex_pool == (EggVertexPool *)NULL) { + if (_vertex_pool == nullptr) { _vertex_pool = poly->get_pool(); add_polygon(poly, EggMesherStrip::MO_user); @@ -93,7 +93,7 @@ mesh(EggGroupNode *group, bool flat_shaded) { Strips::iterator si; for (si = _done.begin(); si != _done.end(); ++si) { PT(EggPrimitive) egg_prim = get_prim(*si); - if (egg_prim != (EggPrimitive *)NULL) { + if (egg_prim != nullptr) { output_children->add_child(egg_prim); } } @@ -164,7 +164,7 @@ clear() { _verts.clear(); _edges.clear(); _strip_index = 0; - _vertex_pool = NULL; + _vertex_pool = nullptr; _color_sheets.clear(); } @@ -197,7 +197,7 @@ add_polygon(const EggPolygon *egg_poly, EggMesherStrip::MesherOrigin origin) { this_poly = DCAST(EggPolygon, *ci); } - if (_vertex_pool == NULL) { + if (_vertex_pool == nullptr) { _vertex_pool = this_poly->get_pool(); } else { nassertr(_vertex_pool == this_poly->get_pool(), false); @@ -557,7 +557,7 @@ build_sheets() { int num_rows_b = 0; int first_row_id_b = first_row_id; double avg_length_b; - if (edge_b != NULL) { + if (edge_b != nullptr) { (*best).measure_sheet(edge_b, true, num_prims_b, num_rows_b, first_row_id_b, 0, 0); first_row_id += num_rows_b; @@ -565,7 +565,7 @@ build_sheets() { } // Which sheet is better? - if (edge_b != NULL && avg_length_b >= avg_length_a) { + if (edge_b != nullptr && avg_length_b >= avg_length_a) { // Sheet b. That's easy. (*best).cut_sheet(first_row_id_b, true, _vertex_pool); diff --git a/panda/src/egg/eggMesherEdge.I b/panda/src/egg/eggMesherEdge.I index 9d83e936e0..abad388cc0 100644 --- a/panda/src/egg/eggMesherEdge.I +++ b/panda/src/egg/eggMesherEdge.I @@ -17,7 +17,7 @@ */ INLINE EggMesherEdge:: EggMesherEdge(int vi_a, int vi_b) : _vi_a(vi_a), _vi_b(vi_b) { - _opposite = NULL; + _opposite = nullptr; } /** diff --git a/panda/src/egg/eggMesherEdge.cxx b/panda/src/egg/eggMesherEdge.cxx index a37d6785f7..1b24891b4e 100644 --- a/panda/src/egg/eggMesherEdge.cxx +++ b/panda/src/egg/eggMesherEdge.cxx @@ -61,7 +61,7 @@ output(ostream &out) const { out << " " << (*si)->_index; } - if (_opposite!=NULL) { + if (_opposite!=nullptr) { out << " opposite " << _opposite->_strips.size() << " strips:"; diff --git a/panda/src/egg/eggMesherFanMaker.cxx b/panda/src/egg/eggMesherFanMaker.cxx index efbfad25a2..51396dd32e 100644 --- a/panda/src/egg/eggMesherFanMaker.cxx +++ b/panda/src/egg/eggMesherFanMaker.cxx @@ -24,7 +24,7 @@ EggMesherFanMaker(int vertex, EggMesherStrip *tri, EggMesher *mesher) { _vertex = vertex; const EggMesherEdge *edge = tri->find_opposite_edge(vertex); - if (edge != (const EggMesherEdge *)NULL) { + if (edge != nullptr) { _edges.push_back(edge); } _strips.push_back(tri); @@ -73,8 +73,8 @@ join(EggMesherFanMaker &other) { const EggMesherEdge *my_back = _edges.back(); const EggMesherEdge *other_front = other._edges.front(); - nassertr(my_back != (EggMesherEdge *)NULL && - other_front != (EggMesherEdge *)NULL, false); + nassertr(my_back != nullptr && + other_front != nullptr, false); int my_back_b = my_back->_vi_b; int other_front_a = other_front->_vi_a; @@ -88,8 +88,8 @@ join(EggMesherFanMaker &other) { const EggMesherEdge *my_front = _edges.front(); const EggMesherEdge *other_back = other._edges.back(); - nassertr(my_front != (EggMesherEdge *)NULL && - other_back != (EggMesherEdge *)NULL, false); + nassertr(my_front != nullptr && + other_back != nullptr, false); int my_front_a = my_front->_vi_a; int other_back_b = other_back->_vi_b; diff --git a/panda/src/egg/eggMesherStrip.cxx b/panda/src/egg/eggMesherStrip.cxx index 5059105ceb..cec01dfe36 100644 --- a/panda/src/egg/eggMesherStrip.cxx +++ b/panda/src/egg/eggMesherStrip.cxx @@ -248,15 +248,15 @@ measure_sheet(const EggMesherEdge *edge, int new_row, int &num_prims, // the best. EggMesherEdge::Strips &strips = (*ei)->_strips; - EggMesherStrip *mate = NULL; + EggMesherStrip *mate = nullptr; for (si = strips.begin(); si != strips.end(); ++si) { if ((*si)->_row_id < first_row_id) { - if (mate == NULL || pick_sheet_mate(**si, *mate)) { + if (mate == nullptr || pick_sheet_mate(**si, *mate)) { mate = *si; } } } - if (mate!=NULL) { + if (mate!=nullptr) { mate->measure_sheet(*ei, secondary, num_prims, num_rows, first_row_id, this_row_id, this_row_distance + secondary); @@ -281,15 +281,15 @@ measure_sheet(const EggMesherEdge *edge, int new_row, int &num_prims, // Here's the edge. Same drill as above. EggMesherEdge::Strips &strips = (*ei)->_strips; - EggMesherStrip *mate = NULL; + EggMesherStrip *mate = nullptr; for (si = strips.begin(); si != strips.end(); ++si) { if ((*si)->_row_id < first_row_id) { - if (mate == NULL || pick_sheet_mate(**si, *mate)) { + if (mate == nullptr || pick_sheet_mate(**si, *mate)) { mate = *si; } } } - if (mate != NULL) { + if (mate != nullptr) { mate->measure_sheet(*ei, false, num_prims, num_rows, first_row_id, this_row_id, this_row_distance); } @@ -428,15 +428,15 @@ find_ideal_mate(EggMesherStrip *&mate, EggMesherEdge *&common_edge, const EggVertexPool *vertex_pool) { Edges::iterator ei; - mate = NULL; - common_edge = NULL; + mate = nullptr; + common_edge = nullptr; for (ei = _edges.begin(); ei != _edges.end(); ++ei) { EggMesherEdge::Strips &strips = (*ei)->_strips; EggMesherEdge::Strips::iterator si; for (si = strips.begin(); si != strips.end(); ++si) { if (*si != this) { - if (mate==NULL || pick_mate(**si, *mate, **ei, *common_edge, + if (mate==nullptr || pick_mate(**si, *mate, **ei, *common_edge, vertex_pool)) { mate = *si; common_edge = *ei; @@ -445,7 +445,7 @@ find_ideal_mate(EggMesherStrip *&mate, EggMesherEdge *&common_edge, } } - return (mate!=NULL); + return (mate!=nullptr); } @@ -898,7 +898,7 @@ find_opposite_edge(int vi) const { } } - return NULL; + return nullptr; } /** @@ -918,7 +918,7 @@ find_opposite_edge(const EggMesherEdge *edge) const { } } - return NULL; + return nullptr; } /** @@ -938,7 +938,7 @@ find_adjacent_edge(const EggMesherEdge *edge) const { } } - return NULL; + return nullptr; } /** diff --git a/panda/src/egg/eggNameUniquifier.cxx b/panda/src/egg/eggNameUniquifier.cxx index 0e50320d45..34a7123d48 100644 --- a/panda/src/egg/eggNameUniquifier.cxx +++ b/panda/src/egg/eggNameUniquifier.cxx @@ -89,7 +89,7 @@ uniquify(EggNode *node) { EggGroupNode::iterator ci; for (ci = group->begin(); ci != group->end(); ++ci) { EggNode *child = (*ci); - nassertv(child != (EggNode *)NULL); + nassertv(child != nullptr); uniquify(child); } } @@ -104,14 +104,14 @@ get_node(const string &category, const string &name) const { Categories::const_iterator ci; ci = _categories.find(category); if (ci == _categories.end()) { - return (EggNode *)NULL; + return nullptr; } const UsedNames &names = (*ci).second; UsedNames::const_iterator ni; ni = names.find(name); if (ni == names.end()) { - return (EggNode *)NULL; + return nullptr; } return (*ni).second; diff --git a/panda/src/egg/eggNameUniquifier.h b/panda/src/egg/eggNameUniquifier.h index d28457a97d..72a05698f6 100644 --- a/panda/src/egg/eggNameUniquifier.h +++ b/panda/src/egg/eggNameUniquifier.h @@ -68,7 +68,7 @@ PUBLISHED: EggNode *get_node(const string &category, const string &name) const; bool has_name(const string &category, const string &name) const; bool add_name(const string &category, const string &name, - EggNode *node = NULL); + EggNode *node = nullptr); virtual string get_category(EggNode *node)=0; virtual string filter_name(EggNode *node); diff --git a/panda/src/egg/eggNode.I b/panda/src/egg/eggNode.I index 08f2f8989b..596d61b826 100644 --- a/panda/src/egg/eggNode.I +++ b/panda/src/egg/eggNode.I @@ -16,7 +16,7 @@ */ INLINE EggNode:: EggNode(const string &name) : EggNamedObject(name) { - _parent = NULL; + _parent = nullptr; _depth = 0; _under_flags = 0; } @@ -26,7 +26,7 @@ EggNode(const string &name) : EggNamedObject(name) { */ INLINE EggNode:: EggNode(const EggNode ©) : EggNamedObject(copy) { - _parent = NULL; + _parent = nullptr; _depth = 0; _under_flags = 0; } @@ -106,7 +106,7 @@ is_local_coord() const { */ INLINE const LMatrix4d &EggNode:: get_vertex_frame() const { - if (_vertex_frame == (LMatrix4d *)NULL) { + if (_vertex_frame == nullptr) { return LMatrix4d::ident_mat(); } else { return *_vertex_frame; @@ -120,7 +120,7 @@ get_vertex_frame() const { */ INLINE const LMatrix4d &EggNode:: get_node_frame() const { - if (_node_frame == (LMatrix4d *)NULL) { + if (_node_frame == nullptr) { return LMatrix4d::ident_mat(); } else { return *_node_frame; @@ -133,7 +133,7 @@ get_node_frame() const { */ INLINE const LMatrix4d &EggNode:: get_vertex_frame_inv() const { - if (_vertex_frame_inv == (LMatrix4d *)NULL) { + if (_vertex_frame_inv == nullptr) { return LMatrix4d::ident_mat(); } else { return *_vertex_frame_inv; @@ -147,7 +147,7 @@ get_vertex_frame_inv() const { */ INLINE const LMatrix4d &EggNode:: get_node_frame_inv() const { - if (_node_frame_inv == (LMatrix4d *)NULL) { + if (_node_frame_inv == nullptr) { return LMatrix4d::ident_mat(); } else { return *_node_frame_inv; @@ -164,7 +164,7 @@ get_node_frame_inv() const { */ INLINE const LMatrix4d &EggNode:: get_vertex_to_node() const { - if (_vertex_to_node == (LMatrix4d *)NULL) { + if (_vertex_to_node == nullptr) { return LMatrix4d::ident_mat(); } else { return *_vertex_to_node; @@ -181,7 +181,7 @@ get_vertex_to_node() const { */ INLINE const LMatrix4d &EggNode:: get_node_to_vertex() const { - if (_node_to_vertex == (LMatrix4d *)NULL) { + if (_node_to_vertex == nullptr) { return LMatrix4d::ident_mat(); } else { return *_node_to_vertex; diff --git a/panda/src/egg/eggNode.cxx b/panda/src/egg/eggNode.cxx index 016ae01994..531f57f2c0 100644 --- a/panda/src/egg/eggNode.cxx +++ b/panda/src/egg/eggNode.cxx @@ -83,9 +83,9 @@ is_anim_matrix() const { */ EggRenderMode *EggNode:: determine_alpha_mode() { - if (_parent == (EggGroupNode *)NULL) { + if (_parent == nullptr) { // Too bad; we're done. - return (EggRenderMode *)NULL; + return nullptr; } return _parent->determine_alpha_mode(); } @@ -98,9 +98,9 @@ determine_alpha_mode() { */ EggRenderMode *EggNode:: determine_depth_write_mode() { - if (_parent == (EggGroupNode *)NULL) { + if (_parent == nullptr) { // Too bad; we're done. - return (EggRenderMode *)NULL; + return nullptr; } return _parent->determine_depth_write_mode(); } @@ -113,9 +113,9 @@ determine_depth_write_mode() { */ EggRenderMode *EggNode:: determine_depth_test_mode() { - if (_parent == (EggGroupNode *)NULL) { + if (_parent == nullptr) { // Too bad; we're done. - return (EggRenderMode *)NULL; + return nullptr; } return _parent->determine_depth_test_mode(); } @@ -128,9 +128,9 @@ determine_depth_test_mode() { */ EggRenderMode *EggNode:: determine_visibility_mode() { - if (_parent == (EggGroupNode *)NULL) { + if (_parent == nullptr) { // Too bad; we're done. - return (EggRenderMode *)NULL; + return nullptr; } return _parent->determine_visibility_mode(); } @@ -143,9 +143,9 @@ determine_visibility_mode() { */ EggRenderMode *EggNode:: determine_depth_offset() { - if (_parent == (EggGroupNode *)NULL) { + if (_parent == nullptr) { // Too bad; we're done. - return (EggRenderMode *)NULL; + return nullptr; } return _parent->determine_depth_offset(); } @@ -158,9 +158,9 @@ determine_depth_offset() { */ EggRenderMode *EggNode:: determine_draw_order() { - if (_parent == (EggGroupNode *)NULL) { + if (_parent == nullptr) { // Too bad; we're done. - return (EggRenderMode *)NULL; + return nullptr; } return _parent->determine_draw_order(); } @@ -172,9 +172,9 @@ determine_draw_order() { */ EggRenderMode *EggNode:: determine_bin() { - if (_parent == (EggGroupNode *)NULL) { + if (_parent == nullptr) { // Too bad; we're done. - return (EggRenderMode *)NULL; + return nullptr; } return _parent->determine_bin(); } @@ -189,7 +189,7 @@ determine_bin() { */ bool EggNode:: determine_indexed() { - if (_parent == (EggGroupNode *)NULL) { + if (_parent == nullptr) { // Too bad; we're done. return false; } @@ -206,7 +206,7 @@ determine_indexed() { */ bool EggNode:: determine_decal() { - if (_parent == (EggGroupNode *)NULL) { + if (_parent == nullptr) { // Too bad; we're done. return false; } @@ -252,7 +252,7 @@ parse_egg(const string &egg_syntax) { */ void EggNode:: test_under_integrity() const { - if (_parent == NULL) { + if (_parent == nullptr) { // If we have no parent, everything should be zero. nassertv(_depth == 0); nassertv(_under_flags == 0); @@ -303,15 +303,15 @@ egg_start_parse_body() { void EggNode:: update_under(int depth_offset) { int depth; - if (_parent == NULL) { + if (_parent == nullptr) { depth = 0; _under_flags = 0; - _vertex_frame = NULL; - _node_frame = NULL; - _vertex_frame_inv = NULL; - _node_frame_inv = NULL; - _vertex_to_node = NULL; - _node_to_vertex = NULL; + _vertex_frame = nullptr; + _node_frame = nullptr; + _vertex_frame_inv = nullptr; + _node_frame_inv = nullptr; + _vertex_to_node = nullptr; + _node_to_vertex = nullptr; } else { _parent->test_ref_count_integrity(); depth = _parent->_depth + 1; diff --git a/panda/src/egg/eggObject.cxx b/panda/src/egg/eggObject.cxx index b75d2ea64f..0d642ee356 100644 --- a/panda/src/egg/eggObject.cxx +++ b/panda/src/egg/eggObject.cxx @@ -96,7 +96,7 @@ get_user_data(TypeHandle type) const { if (ui != _user_data.end()) { return (*ui).second; } - return NULL; + return nullptr; } /** @@ -149,5 +149,5 @@ clear_user_data(TypeHandle type) { */ EggTransform *EggObject:: as_transform() { - return NULL; + return nullptr; } diff --git a/panda/src/egg/eggPolygon.cxx b/panda/src/egg/eggPolygon.cxx index 2d6a3378c7..cb783925e1 100644 --- a/panda/src/egg/eggPolygon.cxx +++ b/panda/src/egg/eggPolygon.cxx @@ -146,7 +146,7 @@ is_planar() const { PT(EggPolygon) EggPolygon:: triangulate_in_place(bool convex_also) { EggGroupNode *parent = get_parent(); - nassertr(parent != (EggGroupNode *)NULL, this); + nassertr(parent != nullptr, this); PT(EggPolygon) save_me = this; parent->remove_child(this); diff --git a/panda/src/egg/eggPrimitive.I b/panda/src/egg/eggPrimitive.I index a52449443d..c90c983001 100644 --- a/panda/src/egg/eggPrimitive.I +++ b/panda/src/egg/eggPrimitive.I @@ -148,7 +148,7 @@ has_texture(EggTexture *texture) const { */ INLINE EggTexture *EggPrimitive:: get_texture() const { - return has_texture() ? get_texture(0) : (EggTexture *)NULL; + return has_texture() ? get_texture(0) : nullptr; } /** @@ -184,7 +184,7 @@ get_num_textures() const { */ INLINE EggTexture *EggPrimitive:: get_texture(int n) const { - nassertr(n >= 0 && n < (int)_textures.size(), NULL); + nassertr(n >= 0 && n < (int)_textures.size(), nullptr); return _textures[n]; } @@ -202,7 +202,7 @@ set_material(EggMaterial *material) { */ INLINE void EggPrimitive:: clear_material() { - _material = (EggMaterial *)NULL; + _material = nullptr; } /** @@ -221,7 +221,7 @@ get_material() const { */ INLINE bool EggPrimitive:: has_material() const { - return _material != (EggMaterial *)NULL; + return _material != nullptr; } @@ -299,7 +299,7 @@ size() const { */ INLINE EggVertex *EggPrimitive:: operator [] (int index) const { - nassertr(index >= 0 && index < (int)size(), NULL); + nassertr(index >= 0 && index < (int)size(), nullptr); return *(begin() + index); } @@ -388,7 +388,7 @@ insert_vertex(size_t index, EggVertex *vertex) { */ INLINE EggVertex *EggPrimitive:: get_vertex(size_t index) const { - nassertr(index < size(), NULL); + nassertr(index < size(), nullptr); return *(begin() + index); } @@ -398,5 +398,5 @@ get_vertex(size_t index) const { */ INLINE EggVertexPool *EggPrimitive:: get_pool() const { - return empty() ? (EggVertexPool *)NULL : _vertices.front()->get_pool(); + return empty() ? nullptr : _vertices.front()->get_pool(); } diff --git a/panda/src/egg/eggPrimitive.cxx b/panda/src/egg/eggPrimitive.cxx index 90cd4942ca..ad0b464c30 100644 --- a/panda/src/egg/eggPrimitive.cxx +++ b/panda/src/egg/eggPrimitive.cxx @@ -37,9 +37,9 @@ determine_alpha_mode() { } EggRenderMode *result = EggNode::determine_alpha_mode(); - if (result == (EggRenderMode *)NULL) { + if (result == nullptr) { int num_textures = get_num_textures(); - for (int i = 0; i < num_textures && result == (EggRenderMode *)NULL; i++) { + for (int i = 0; i < num_textures && result == nullptr; i++) { EggTexture *egg_tex = get_texture(i); // We only want to consider the alpha mode on those textures that can @@ -70,9 +70,9 @@ determine_depth_write_mode() { } EggRenderMode *result = EggNode::determine_depth_write_mode(); - if (result == (EggRenderMode *)NULL) { + if (result == nullptr) { int num_textures = get_num_textures(); - for (int i = 0; i < num_textures && result == (EggRenderMode *)NULL; i++) { + for (int i = 0; i < num_textures && result == nullptr; i++) { if (get_texture(i)->get_depth_write_mode() != DWM_unspecified) { result = get_texture(i); } @@ -94,9 +94,9 @@ determine_depth_test_mode() { } EggRenderMode *result = EggNode::determine_depth_test_mode(); - if (result == (EggRenderMode *)NULL) { + if (result == nullptr) { int num_textures = get_num_textures(); - for (int i = 0; i < num_textures && result == (EggRenderMode *)NULL; i++) { + for (int i = 0; i < num_textures && result == nullptr; i++) { if (get_texture(i)->get_depth_test_mode() != DTM_unspecified) { result = get_texture(i); } @@ -118,9 +118,9 @@ determine_visibility_mode() { } EggRenderMode *result = EggNode::determine_visibility_mode(); - if (result == (EggRenderMode *)NULL) { + if (result == nullptr) { int num_textures = get_num_textures(); - for (int i = 0; i < num_textures && result == (EggRenderMode *)NULL; i++) { + for (int i = 0; i < num_textures && result == nullptr; i++) { if (get_texture(i)->get_visibility_mode() != VM_unspecified) { result = get_texture(i); } @@ -142,9 +142,9 @@ determine_depth_offset() { } EggRenderMode *result = EggNode::determine_depth_offset(); - if (result == (EggRenderMode *)NULL) { + if (result == nullptr) { int num_textures = get_num_textures(); - for (int i = 0; i < num_textures && result == (EggRenderMode *)NULL; i++) { + for (int i = 0; i < num_textures && result == nullptr; i++) { if (get_texture(i)->has_depth_offset()) { result = get_texture(i); } @@ -166,9 +166,9 @@ determine_draw_order() { } EggRenderMode *result = EggNode::determine_draw_order(); - if (result == (EggRenderMode *)NULL) { + if (result == nullptr) { int num_textures = get_num_textures(); - for (int i = 0; i < num_textures && result == (EggRenderMode *)NULL; i++) { + for (int i = 0; i < num_textures && result == nullptr; i++) { if (get_texture(i)->has_draw_order()) { result = get_texture(i); } @@ -190,9 +190,9 @@ determine_bin() { } EggRenderMode *result = EggNode::determine_bin(); - if (result == (EggRenderMode *)NULL) { + if (result == nullptr) { int num_textures = get_num_textures(); - for (int i = 0; i < num_textures && result == (EggRenderMode *)NULL; i++) { + for (int i = 0; i < num_textures && result == nullptr; i++) { if (get_texture(i)->has_bin()) { result = get_texture(i); } @@ -374,7 +374,7 @@ unify_attributes(EggPrimitive::Shading shading) { } EggVertexPool *vertex_pool = orig_vertex->get_pool(); - nassertv(vertex_pool != (EggVertexPool *)NULL); + nassertv(vertex_pool != nullptr); vertex = vertex_pool->create_unique_vertex(*vertex); vertex->copy_grefs_from(*orig_vertex); replace(pi, vertex); @@ -406,7 +406,7 @@ unify_attributes(EggPrimitive::Shading shading) { } EggVertexPool *vertex_pool = orig_vertex->get_pool(); - nassertv(vertex_pool != (EggVertexPool *)NULL); + nassertv(vertex_pool != nullptr); vertex = vertex_pool->create_unique_vertex(*vertex); vertex->copy_grefs_from(*orig_vertex); replace(pi, vertex); @@ -854,7 +854,7 @@ write_body(ostream &out, int indent_level) const { EggVertexPool *pool = get_pool(); // Make sure the vertices belong to some vertex pool. - nassertv(pool != NULL); + nassertv(pool != nullptr); // Make sure the vertex pool is named. nassertv(pool->has_name()); @@ -988,7 +988,7 @@ r_apply_texmats(EggTextureCollection &textures) { EggVertex *vertex = get_vertex(i); const EggVertexUV *uv_obj = vertex->get_uv_obj(uv_name); - if (uv_obj != (EggVertexUV *)NULL) { + if (uv_obj != nullptr) { EggVertex new_vertex(*vertex); PT(EggVertexUV) new_uv_obj = new EggVertexUV(*uv_obj); LTexCoord3d uvw = uv_obj->get_uvw() * mat; diff --git a/panda/src/egg/eggTextureCollection.cxx b/panda/src/egg/eggTextureCollection.cxx index f53c9d0ddc..38ee134048 100644 --- a/panda/src/egg/eggTextureCollection.cxx +++ b/panda/src/egg/eggTextureCollection.cxx @@ -99,7 +99,7 @@ get_num_textures() const { */ EggTexture *EggTextureCollection:: get_texture(int index) const { - nassertr(index >= 0 && index < (int)_ordered_textures.size(), NULL); + nassertr(index >= 0 && index < (int)_ordered_textures.size(), nullptr); return _ordered_textures[index]; } @@ -465,7 +465,7 @@ find_tref(const string &tref_name) const { } } - return (EggTexture *)NULL; + return nullptr; } /** @@ -485,5 +485,5 @@ find_filename(const Filename &filename) const { } } - return (EggTexture *)NULL; + return nullptr; } diff --git a/panda/src/egg/eggTransform.I b/panda/src/egg/eggTransform.I index bff92d6194..e6bccb6819 100644 --- a/panda/src/egg/eggTransform.I +++ b/panda/src/egg/eggTransform.I @@ -19,10 +19,10 @@ Component(EggTransform::ComponentType type, double number) : _type(type), _number(number) { - _vec2 = (LVecBase2d *)NULL; - _vec3 = (LVecBase3d *)NULL; - _mat3 = (LMatrix3d *)NULL; - _mat4 = (LMatrix4d *)NULL; + _vec2 = nullptr; + _vec3 = nullptr; + _mat3 = nullptr; + _mat4 = nullptr; } /** @@ -33,20 +33,20 @@ Component(const EggTransform::Component ©) : _type(copy._type), _number(copy._number) { - _vec2 = (LVecBase2d *)NULL; - _vec3 = (LVecBase3d *)NULL; - _mat3 = (LMatrix3d *)NULL; - _mat4 = (LMatrix4d *)NULL; - if (copy._vec2 != (LVecBase2d *)NULL) { + _vec2 = nullptr; + _vec3 = nullptr; + _mat3 = nullptr; + _mat4 = nullptr; + if (copy._vec2 != nullptr) { _vec2 = new LVector2d(*copy._vec2); } - if (copy._vec3 != (LVecBase3d *)NULL) { + if (copy._vec3 != nullptr) { _vec3 = new LVector3d(*copy._vec3); } - if (copy._mat3 != (LMatrix3d *)NULL) { + if (copy._mat3 != nullptr) { _mat3 = new LMatrix3d(*copy._mat3); } - if (copy._mat4 != (LMatrix4d *)NULL) { + if (copy._mat4 != nullptr) { _mat4 = new LMatrix4d(*copy._mat4); } } @@ -58,32 +58,32 @@ INLINE void EggTransform::Component:: operator = (const EggTransform::Component ©) { _type = copy._type; _number = copy._number; - if (_vec2 != (LVecBase2d *)NULL) { + if (_vec2 != nullptr) { delete _vec2; - _vec2 = (LVecBase2d *)NULL; + _vec2 = nullptr; } - if (_vec3 != (LVecBase3d *)NULL) { + if (_vec3 != nullptr) { delete _vec3; - _vec3 = (LVecBase3d *)NULL; + _vec3 = nullptr; } - if (_mat3 != (LMatrix3d *)NULL) { + if (_mat3 != nullptr) { delete _mat3; - _mat3 = (LMatrix3d *)NULL; + _mat3 = nullptr; } - if (_mat4 != (LMatrix4d *)NULL) { + if (_mat4 != nullptr) { delete _mat4; - _mat4 = (LMatrix4d *)NULL; + _mat4 = nullptr; } - if (copy._vec2 != (LVecBase2d *)NULL) { + if (copy._vec2 != nullptr) { _vec2 = new LVecBase2d(*copy._vec2); } - if (copy._vec3 != (LVecBase3d *)NULL) { + if (copy._vec3 != nullptr) { _vec3 = new LVecBase3d(*copy._vec3); } - if (copy._mat3 != (LMatrix3d *)NULL) { + if (copy._mat3 != nullptr) { _mat3 = new LMatrix3d(*copy._mat3); } - if (copy._mat4 != (LMatrix4d *)NULL) { + if (copy._mat4 != nullptr) { _mat4 = new LMatrix4d(*copy._mat4); } } @@ -93,16 +93,16 @@ operator = (const EggTransform::Component ©) { */ INLINE EggTransform::Component:: ~Component() { - if (_vec2 != (LVecBase2d *)NULL) { + if (_vec2 != nullptr) { delete _vec2; } - if (_vec3 != (LVecBase3d *)NULL) { + if (_vec3 != nullptr) { delete _vec3; } - if (_mat3 != (LMatrix3d *)NULL) { + if (_mat3 != nullptr) { delete _mat3; } - if (_mat4 != (LMatrix4d *)NULL) { + if (_mat4 != nullptr) { delete _mat4; } } @@ -259,7 +259,7 @@ get_component_number(int n) const { INLINE const LVecBase2d &EggTransform:: get_component_vec2(int n) const { nassertr(n >= 0 && n < (int)_components.size(), LVector2d::zero()); - nassertr(_components[n]._vec2 != (LVecBase2d *)NULL, LVector2d::zero()); + nassertr(_components[n]._vec2 != nullptr, LVector2d::zero()); return *_components[n]._vec2; } @@ -271,7 +271,7 @@ get_component_vec2(int n) const { INLINE const LVecBase3d &EggTransform:: get_component_vec3(int n) const { nassertr(n >= 0 && n < (int)_components.size(), LVector3d::zero()); - nassertr(_components[n]._vec3 != (LVecBase3d *)NULL, LVector3d::zero()); + nassertr(_components[n]._vec3 != nullptr, LVector3d::zero()); return *_components[n]._vec3; } @@ -282,7 +282,7 @@ get_component_vec3(int n) const { INLINE const LMatrix3d &EggTransform:: get_component_mat3(int n) const { nassertr(n >= 0 && n < (int)_components.size(), LMatrix3d::ident_mat()); - nassertr(_components[n]._mat3 != (LMatrix3d *)NULL, LMatrix3d::ident_mat()); + nassertr(_components[n]._mat3 != nullptr, LMatrix3d::ident_mat()); return *_components[n]._mat3; } @@ -293,7 +293,7 @@ get_component_mat3(int n) const { INLINE const LMatrix4d &EggTransform:: get_component_mat4(int n) const { nassertr(n >= 0 && n < (int)_components.size(), LMatrix4d::ident_mat()); - nassertr(_components[n]._mat4 != (LMatrix4d *)NULL, LMatrix4d::ident_mat()); + nassertr(_components[n]._mat4 != nullptr, LMatrix4d::ident_mat()); return *_components[n]._mat4; } diff --git a/panda/src/egg/eggUtilities.I b/panda/src/egg/eggUtilities.I index 4ad2d6b1c7..4efae4df81 100644 --- a/panda/src/egg/eggUtilities.I +++ b/panda/src/egg/eggUtilities.I @@ -69,7 +69,7 @@ split_vertex(EggVertex *vert, const FunctionObject &sequence) { if (seq != 0) { // Here's a new sequence number! Have we already defined it? - EggVertex *new_vert = NULL; + EggVertex *new_vert = nullptr; Sequences::const_iterator si = _sequences.find(seq); diff --git a/panda/src/egg/eggVertex.cxx b/panda/src/egg/eggVertex.cxx index 7663fd4eb3..5272a9f034 100644 --- a/panda/src/egg/eggVertex.cxx +++ b/panda/src/egg/eggVertex.cxx @@ -34,7 +34,7 @@ TypeHandle EggVertex::_type_handle; */ EggVertex:: EggVertex() { - _pool = NULL; + _pool = nullptr; _forward_reference = false; _index = -1; _external_index = -1; @@ -59,7 +59,7 @@ EggVertex(const EggVertex ©) _uv_map(copy._uv_map), _aux_map(copy._aux_map) { - _pool = NULL; + _pool = nullptr; _forward_reference = false; _index = -1; test_pref_integrity(); @@ -96,7 +96,7 @@ EggVertex:: ~EggVertex() { // We should never destruct a vertex while it still thinks it belongs to a // VertexPool. If we do, we've probably lost a reference count somewhere. - nassertv(_pool == NULL); + nassertv(_pool == nullptr); // Also, a vertex shouldn't be destructed while it's being referenced by a // group or a primitive, for the same reason. @@ -244,7 +244,7 @@ get_uv_obj(const string &name) const { if (ui != _uv_map.end()) { return (*ui).second; } - return NULL; + return nullptr; } /** @@ -259,7 +259,7 @@ get_aux_obj(const string &name) const { if (xi != _aux_map.end()) { return (*xi).second; } - return NULL; + return nullptr; } /** @@ -278,7 +278,7 @@ modify_uv_obj(const string &name) { return (*ui).second; } - return NULL; + return nullptr; } /** @@ -297,7 +297,7 @@ modify_aux_obj(const string &name) { return (*xi).second; } - return NULL; + return nullptr; } /** @@ -346,12 +346,12 @@ clear_aux(const string &name) { PT(EggVertex) EggVertex:: make_average(const EggVertex *first, const EggVertex *second) { PT(EggVertexPool) pool = first->get_pool(); - nassertr(pool == second->get_pool(), NULL); + nassertr(pool == second->get_pool(), nullptr); // If both vertices are in a pool, the new vertex will be part of the pool // as well. PT(EggVertex) middle; - if (pool == NULL) { + if (pool == nullptr) { middle = new EggVertex; } else { middle = pool->make_new_vertex(); @@ -375,7 +375,7 @@ make_average(const EggVertex *first, const EggVertex *second) { const EggVertexUV *first_uv = it->second; const EggVertexUV *second_uv = second->get_uv_obj(it->first); - if (first_uv != NULL && second_uv != NULL) { + if (first_uv != nullptr && second_uv != nullptr) { middle->set_uv_obj(EggVertexUV::make_average(first_uv, second_uv)); } } @@ -386,7 +386,7 @@ make_average(const EggVertex *first, const EggVertex *second) { const EggVertexAux *first_aux = ai->second; const EggVertexAux *second_aux = second->get_aux_obj(ai->first); - if (first_aux != NULL && second_aux != NULL) { + if (first_aux != nullptr && second_aux != nullptr) { middle->set_aux_obj(EggVertexAux::make_average(first_aux, second_aux)); } } @@ -755,7 +755,7 @@ copy_grefs_from(const EggVertex &other) { for (gri = other.gref_begin(); gri != other.gref_end(); ++gri) { EggGroup *group = *gri; - nassertv(group != NULL); + nassertv(group != nullptr); group->ref_vertex(this, group->get_vertex_membership(&other)); } @@ -771,7 +771,7 @@ clear_grefs() { GroupRef::const_iterator gri; for (gri = gref_copy.begin(); gri != gref_copy.end(); ++gri) { EggGroup *group = *gri; - nassertv(group != NULL); + nassertv(group != nullptr); group->unref_vertex(this); } @@ -836,7 +836,7 @@ test_gref_integrity() const { for (gri = gref_begin(); gri != gref_end(); ++gri) { EggGroup *group = *gri; - nassertv(group != NULL); + nassertv(group != nullptr); group->test_ref_count_integrity(); double membership = group->get_vertex_membership(this); @@ -856,7 +856,7 @@ test_pref_integrity() const { for (pri = pref_begin(); pri != pref_end(); ++pri) { EggPrimitive *prim = *pri; - nassertv(prim != NULL); + nassertv(prim != nullptr); prim->test_ref_count_integrity(); EggPrimitive::iterator vi; @@ -872,7 +872,7 @@ test_pref_integrity() const { */ void EggVertex:: output(ostream &out) const { - if (get_pool() == NULL) { + if (get_pool() == nullptr) { out << "(null):" << get_index(); } else { out << get_pool()->get_name() << ":" << get_index(); diff --git a/panda/src/egg/eggVertexAux.cxx b/panda/src/egg/eggVertexAux.cxx index ec6528e380..6b12ee538b 100644 --- a/panda/src/egg/eggVertexAux.cxx +++ b/panda/src/egg/eggVertexAux.cxx @@ -62,7 +62,7 @@ EggVertexAux:: */ PT(EggVertexAux) EggVertexAux:: make_average(const EggVertexAux *first, const EggVertexAux *second) { - nassertr(first->get_name() == second->get_name(), NULL); + nassertr(first->get_name() == second->get_name(), nullptr); LVecBase4d aux = (first->_aux + second->_aux) / 2; return new EggVertexAux(first->get_name(), aux); diff --git a/panda/src/egg/eggVertexPool.I b/panda/src/egg/eggVertexPool.I index 3a13278063..8e26c30fb7 100644 --- a/panda/src/egg/eggVertexPool.I +++ b/panda/src/egg/eggVertexPool.I @@ -17,7 +17,7 @@ */ INLINE bool EggVertexPool:: has_vertex(int index) const { - return get_vertex(index) != (EggVertex *)NULL; + return get_vertex(index) != nullptr; } /** diff --git a/panda/src/egg/eggVertexPool.cxx b/panda/src/egg/eggVertexPool.cxx index e35cee0079..e3b3cad248 100644 --- a/panda/src/egg/eggVertexPool.cxx +++ b/panda/src/egg/eggVertexPool.cxx @@ -63,7 +63,7 @@ EggVertexPool:: nassertv(vertex->_pool == this); nassertv(vertex->get_index() == index); - vertex->_pool = NULL; + vertex->_pool = nullptr; vertex->_index = -1; } @@ -114,11 +114,11 @@ get_vertex(int index) const { IndexVertices::const_iterator ivi = _index_vertices.find(index); if (ivi == _index_vertices.end()) { - return NULL; + return nullptr; } else { EggVertex *vertex = (*ivi).second; if (vertex->is_forward_reference()) { - return NULL; + return nullptr; } return vertex; } @@ -133,7 +133,7 @@ get_vertex(int index) const { */ EggVertex *EggVertexPool:: get_forward_vertex(int index) { - nassertr(index >= 0, NULL); + nassertr(index >= 0, nullptr); IndexVertices::const_iterator ivi = _index_vertices.find(index); @@ -421,13 +421,13 @@ add_vertex(EggVertex *vertex, int index) { PT(EggVertex) vertex_keep = vertex; // Don't try to add a vertex while it still belongs to another pool. - nassertr(vertex->_pool == NULL, NULL); + nassertr(vertex->_pool == nullptr, nullptr); if (index == -1) { index = get_highest_index() + 1; } // Always supply an index number >= 0. - nassertr(index >= 0, NULL); + nassertr(index >= 0, nullptr); // Check for a forward reference. IndexVertices::const_iterator ivi = _index_vertices.find(index); @@ -443,7 +443,7 @@ add_vertex(EggVertex *vertex, int index) { } // Oops, you duplicated a vertex index. - nassertr(false, NULL); + nassertr(false, nullptr); } _unique_vertices.insert(vertex); @@ -495,7 +495,7 @@ find_matching_vertex(const EggVertex ©) { } // No matching vertex. - return NULL; + return nullptr; } @@ -550,7 +550,7 @@ remove_vertex(EggVertex *vertex) { _unique_vertices.erase(uvi); - vertex->_pool = NULL; + vertex->_pool = nullptr; } /** @@ -572,7 +572,7 @@ remove_unused_vertices() { if (vertex->pref_size() == 0) { // This vertex is not used. Don't add it to the new lists. vertex->clear_grefs(); - vertex->_pool = NULL; + vertex->_pool = nullptr; num_removed++; } else { @@ -598,7 +598,7 @@ remove_unused_vertices() { orig_vertex->test_pref_integrity(); nassertr(vertex->pref_size() == 0, 0); vertex->clear_grefs(); - vertex->_pool = NULL; + vertex->_pool = nullptr; num_removed++; } else { diff --git a/panda/src/egg/eggVertexUV.cxx b/panda/src/egg/eggVertexUV.cxx index ded4e39dd0..4ba501d4c3 100644 --- a/panda/src/egg/eggVertexUV.cxx +++ b/panda/src/egg/eggVertexUV.cxx @@ -88,7 +88,7 @@ EggVertexUV:: */ PT(EggVertexUV) EggVertexUV:: make_average(const EggVertexUV *first, const EggVertexUV *second) { - nassertr(first->get_name() == second->get_name(), NULL); + nassertr(first->get_name() == second->get_name(), nullptr); int flags = first->_flags & second->_flags; LTexCoord3d uvw = (first->_uvw + second->_uvw) / 2; diff --git a/panda/src/egg/eggXfmSAnim.cxx b/panda/src/egg/eggXfmSAnim.cxx index 167cb531b7..c28d8c6c4e 100644 --- a/panda/src/egg/eggXfmSAnim.cxx +++ b/panda/src/egg/eggXfmSAnim.cxx @@ -73,7 +73,7 @@ optimize() { // default value. double value = sanim->get_value(0); double default_value; - if (sanim->has_name() && strchr("ijk", sanim->get_name()[0]) != NULL) { + if (sanim->has_name() && strchr("ijk", sanim->get_name()[0]) != nullptr) { default_value = 1.0; } else { default_value = 0.0; @@ -169,10 +169,10 @@ write(ostream &out, int indent_level) const { nassertv(sanim->get_name().length() == 1); char name = sanim->get_name()[0]; char *p = (char *)strchr(matrix_component_letters, name); - nassertv(p != (char *)NULL); - if (p != (char *)NULL) { + nassertv(p != nullptr); + if (p != nullptr) { int index = p - matrix_component_letters; - nassertv(tables[index] == (EggSAnimData *)NULL); + nassertv(tables[index] == nullptr); tables[index] = sanim; } } else { @@ -183,7 +183,7 @@ write(ostream &out, int indent_level) const { // Now write out the table children in our normal order. for (int i = 0; i < num_matrix_components; i++) { - if (tables[i] != (EggSAnimData *)NULL) { + if (tables[i] != nullptr) { tables[i]->write(out, indent_level + 2); } } @@ -400,7 +400,7 @@ set_value(int row, const LMatrix4d &mat) { for (int i = 0; i < num_matrix_components; i++) { string name(1, matrix_component_letters[i]); EggNode *child = find_child(name); - nassertr(child != (EggNode *)NULL && + nassertr(child != nullptr && child->is_of_type(EggSAnimData::get_class_type()), false); EggSAnimData *sanim = DCAST(EggSAnimData, child); @@ -495,7 +495,7 @@ add_data(const LMatrix4d &mat) { for (int i = 0; i < num_matrix_components; i++) { string name(1, matrix_component_letters[i]); EggNode *child = find_child(name); - nassertr(child != (EggNode *)NULL && + nassertr(child != nullptr && child->is_of_type(EggSAnimData::get_class_type()), false); EggSAnimData *sanim = DCAST(EggSAnimData, child); @@ -553,7 +553,7 @@ void EggXfmSAnim:: add_component_data(const string &component_name, double value) { EggNode *child = find_child(component_name); EggSAnimData *sanim; - if (child == (EggNode *)NULL) { + if (child == nullptr) { // We don't have this component yet; create it. sanim = new EggSAnimData(component_name); add_child(sanim); diff --git a/panda/src/egg/lexer.lxx b/panda/src/egg/lexer.lxx index c1294a8ec7..468a393418 100644 --- a/panda/src/egg/lexer.lxx +++ b/panda/src/egg/lexer.lxx @@ -44,7 +44,7 @@ static int error_count = 0; static int warning_count = 0; // This is the pointer to the current input stream. -static istream *input_p = NULL; +static istream *input_p = nullptr; // This is the name of the egg file we're parsing. We keep it so we // can print it out for error messages. @@ -162,7 +162,7 @@ eggyywarning(ostringstream &strm) { // stdio FILE pointer. This is flex-specific. static void input_chars(char *buffer, int &result, int max_size) { - nassertv(input_p != NULL); + nassertv(input_p != nullptr); if (*input_p) { input_p->read(buffer, max_size); result = input_p->gcount(); @@ -180,7 +180,7 @@ input_chars(char *buffer, int &result, int max_size) { // Truncate it at the newline. char *end = strchr(current_line, '\n'); - if (end != NULL) { + if (end != nullptr) { *end = '\0'; } } @@ -700,7 +700,7 @@ NUMERIC ([+-]?(([0-9]+[.]?)|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) {HEX} { // A hexadecimal integer number. accept(); - eggyylval._ulong = strtoul(yytext+2, NULL, 16); + eggyylval._ulong = strtoul(yytext+2, nullptr, 16); eggyylval._string = yytext; return EGG_ULONG; } @@ -708,7 +708,7 @@ NUMERIC ([+-]?(([0-9]+[.]?)|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) {BINARY} { // A binary integer number. accept(); - eggyylval._ulong = strtoul(yytext+2, NULL, 2); + eggyylval._ulong = strtoul(yytext+2, nullptr, 2); eggyylval._string = yytext; return EGG_ULONG; } @@ -717,7 +717,7 @@ NUMERIC ([+-]?(([0-9]+[.]?)|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) // not-a-number. These sometimes show up in egg files accidentally. accept(); memset(&eggyylval._number, 0, sizeof(eggyylval._number)); - *(unsigned long *)&eggyylval._number = strtoul(yytext+3, NULL, 0); + *(unsigned long *)&eggyylval._number = strtoul(yytext+3, nullptr, 0); eggyylval._string = yytext; return EGG_NUMBER; } diff --git a/panda/src/egg/parser.yxx b/panda/src/egg/parser.yxx index ab864d92d6..8bdd6ee39d 100644 --- a/panda/src/egg/parser.yxx +++ b/panda/src/egg/parser.yxx @@ -903,7 +903,7 @@ vertex_pool: VERTEXPOOL required_name { string name = $2; - EggVertexPool *pool = NULL; + EggVertexPool *pool = nullptr; VertexPools::const_iterator vpi = vertex_pools.find(name); if (vpi != vertex_pools.end()) { @@ -1545,7 +1545,7 @@ group_body: EggGroup *group = DCAST(EggGroup, egg_stack.back()); if (group->get_group_type() != EggGroup::GT_instance) { eggyyerror(" valid only within "); - } else if ($4 != (EggObject *)NULL) { + } else if ($4 != nullptr) { group->add_group_ref(DCAST(EggGroup, $4)); } } @@ -1785,7 +1785,7 @@ matrix4_body: group_vertex_ref: VERTEXREF '{' integer_list group_vertex_membership REF '{' vertex_pool_name '}' '}' { - if ($7 != (EggVertexPool *)NULL) { + if ($7 != nullptr) { EggVertexPool *pool = DCAST(EggVertexPool, $7); EggGroup *group = DCAST(EggGroup, egg_stack.back()); PTA_double nums = $3; @@ -1794,7 +1794,7 @@ group_vertex_ref: for (int i = 0; i < (int)nums.size(); i++) { int index = (int)nums[i]; EggVertex *vertex = pool->get_forward_vertex(index); - if (vertex == NULL) { + if (vertex == nullptr) { ostringstream errmsg; errmsg << "No vertex " << index << " in pool " << pool->get_name() << std::ends; @@ -2316,7 +2316,7 @@ nurbs_curve_body: primitive_tref_body: texture_name { - if ($1 != (EggTexture *)NULL) { + if ($1 != nullptr) { EggTexture *texture = DCAST(EggTexture, $1); DCAST(EggPrimitive, egg_stack.back())->add_texture(texture); } @@ -2333,7 +2333,7 @@ primitive_tref_body: primitive_texture_body: required_name { - EggTexture *texture = NULL; + EggTexture *texture = nullptr; // Defining a texture on-the-fly. Filename filename = $1; @@ -2345,7 +2345,7 @@ primitive_texture_body: texture = new EggTexture(tref_name, filename); textures[tref_name] = texture; - if (egg_top_node != NULL) { + if (egg_top_node != nullptr) { egg_top_node->add_child(texture); } @@ -2358,7 +2358,7 @@ primitive_texture_body: } } - nassertr(texture != NULL, 0); + nassertr(texture != nullptr, 0); DCAST(EggPrimitive, egg_stack.back())->add_texture(texture); } ; @@ -2373,7 +2373,7 @@ primitive_texture_body: primitive_material_body: material_name { - if ($1 != (EggMaterial *)NULL) { + if ($1 != nullptr) { EggMaterial *material = DCAST(EggMaterial, $1); DCAST(EggPrimitive, egg_stack.back())->set_material(material); } @@ -2466,7 +2466,7 @@ primitive_bface_body: primitive_vertex_ref: VERTEXREF '{' integer_list REF '{' vertex_pool_name '}' '}' { - if ($6 != (EggVertexPool *)NULL) { + if ($6 != nullptr) { EggVertexPool *pool = DCAST(EggVertexPool, $6); EggPrimitive *prim = DCAST(EggPrimitive, egg_stack.back()); PTA_double nums = $3; @@ -2474,7 +2474,7 @@ primitive_vertex_ref: for (int i = 0; i < (int)nums.size(); i++) { int index = (int)nums[i]; EggVertex *vertex = pool->get_forward_vertex(index); - if (vertex == NULL) { + if (vertex == nullptr) { ostringstream errmsg; errmsg << "No vertex " << index << " in pool " << pool->get_name() << std::ends; diff --git a/panda/src/egg2pg/animBundleMaker.cxx b/panda/src/egg2pg/animBundleMaker.cxx index 18e7447923..b32f6d79a5 100644 --- a/panda/src/egg2pg/animBundleMaker.cxx +++ b/panda/src/egg2pg/animBundleMaker.cxx @@ -167,7 +167,7 @@ inspect_tree(EggNode *egg_node) { */ void AnimBundleMaker:: build_hierarchy(EggTable *egg_table, AnimGroup *parent) { - AnimGroup *this_node = NULL; + AnimGroup *this_node = nullptr; // First, scan the children of egg_table for anim data tables. If any of // them is named "xform", it's a special case--this one stands for the @@ -176,7 +176,7 @@ build_hierarchy(EggTable *egg_table, AnimGroup *parent) { EggTable::const_iterator ci; for (ci = egg_table->begin(); ci != egg_table->end(); ++ci) { if ((*ci)->get_name() == "xform") { - if (this_node == NULL) { + if (this_node == nullptr) { this_node = create_xfm_channel((*ci), egg_table->get_name(), parent); } else { egg2pg_cat.warning() @@ -187,7 +187,7 @@ build_hierarchy(EggTable *egg_table, AnimGroup *parent) { } // If none of them were named "xform", just create a plain old AnimGroup. - if (this_node == NULL) { + if (this_node == nullptr) { this_node = new AnimGroup(parent, egg_table->get_name()); } @@ -251,7 +251,7 @@ create_xfm_channel(EggNode *egg_node, const string &name, egg2pg_cat.warning() << "Inappropriate node named xform under node " << name << "\n"; - return NULL; + return nullptr; } diff --git a/panda/src/egg2pg/characterMaker.cxx b/panda/src/egg2pg/characterMaker.cxx index 99bbf54f47..11c3a4e9b4 100644 --- a/panda/src/egg2pg/characterMaker.cxx +++ b/panda/src/egg2pg/characterMaker.cxx @@ -48,7 +48,7 @@ CharacterMaker(EggGroup *root, EggLoader &loader, bool structured) _character_node = new Character(_egg_root->get_name()); _bundle = _character_node->get_bundle(0); - _morph_root = (PartGroup *)NULL; + _morph_root = nullptr; _skeleton_root = new PartGroup(_bundle, ""); _structured = structured; } @@ -83,7 +83,7 @@ egg_to_part(EggNode *egg_node) const { // return the root of the character. return _bundle; } - nassertr(index < (int)_parts.size(), NULL); + nassertr(index < (int)_parts.size(), nullptr); return _parts[index]; } @@ -140,7 +140,7 @@ part_to_node(PartGroup *part, const string &name) const { if (part->is_character_joint()) { CharacterJoint *joint = DCAST(CharacterJoint, part); - if (joint->_geom_node != (PandaNode *)NULL) { + if (joint->_geom_node != nullptr) { node = joint->_geom_node; } } @@ -169,7 +169,7 @@ part_to_node(PartGroup *part, const string &name) const { */ int CharacterMaker:: create_slider(const string &name) { - if (_morph_root == (PartGroup *)NULL) { + if (_morph_root == nullptr) { _morph_root = new PartGroup(_bundle, "morph"); } CharacterSlider *slider = new CharacterSlider(_morph_root, name); @@ -238,7 +238,7 @@ build_joint_hierarchy(EggNode *egg_node, PartGroup *part, int index) { } PT(AnimPreloadTable) anim_preload = _bundle->modify_anim_preload(); - if (anim_preload == (AnimPreloadTable *)NULL) { + if (anim_preload == nullptr) { anim_preload = new AnimPreloadTable; _bundle->set_anim_preload(anim_preload); } @@ -313,7 +313,7 @@ parent_joint_nodes(PartGroup *part) { if (part->is_character_joint()) { CharacterJoint *joint = DCAST(CharacterJoint, part); PandaNode *joint_node = joint->_geom_node; - if (joint_node != NULL) { + if (joint_node != nullptr) { _character_node->add_child(joint_node); joint->add_net_transform(joint_node); joint_node->set_transform(TransformState::make_mat(joint->_net_transform)); @@ -341,7 +341,7 @@ make_geometry(EggNode *egg_node) { EggGroupNode *bin_home = determine_bin_home(egg_bin); bool is_dynamic; - if (bin_home == (EggGroupNode *)NULL) { + if (bin_home == nullptr) { // This is a dynamic polyset that lives under the character's root // node. bin_home = _egg_root; @@ -387,7 +387,7 @@ determine_primitive_home(EggPrimitive *egg_primitive) { // We need to keep track of the one joint we've encountered so far, to see // if all the vertices are referenced by the same joint. - EggGroupNode *home = NULL; + EggGroupNode *home = nullptr; EggPrimitive::const_iterator vi; for (vi = egg_primitive->begin(); @@ -397,7 +397,7 @@ determine_primitive_home(EggPrimitive *egg_primitive) { if (vertex->gref_size() > 1) { // This vertex is referenced by multiple joints; the primitive is // dynamic. - return NULL; + return nullptr; } if (!vertex->_dxyzs.empty() || @@ -405,14 +405,14 @@ determine_primitive_home(EggPrimitive *egg_primitive) { !vertex->_drgbas.empty()) { // This vertex has some morph slider definitions; therefore, the // primitive is dynamic. - return NULL; + return nullptr; } EggVertex::const_uv_iterator uvi; for (uvi = vertex->uv_begin(); uvi != vertex->uv_end(); ++uvi) { if (!(*uvi)->_duvs.empty()) { // Ditto: the vertex has some UV morphs; therefore the primitive is // dynamic. - return NULL; + return nullptr; } } @@ -423,15 +423,15 @@ determine_primitive_home(EggPrimitive *egg_primitive) { // where it is. vertex_home = egg_primitive->get_parent(); } else { - nassertr(vertex->gref_size() == 1, NULL); + nassertr(vertex->gref_size() == 1, nullptr); // This vertex is referenced exactly once. vertex_home = *vertex->gref_begin(); } - if (home != NULL && home != vertex_home) { + if (home != nullptr && home != vertex_home) { // Oops, two vertices are referenced by different joints! The primitive // is dynamic. - return NULL; + return nullptr; } home = vertex_home; @@ -439,35 +439,35 @@ determine_primitive_home(EggPrimitive *egg_primitive) { // This shouldn't be possible, unless there are no vertices--but we check // for that before calling this function. - nassertr(home != NULL, NULL); + nassertr(home != nullptr, nullptr); // So, all the vertices are assigned to the same group. This means the // polygon belongs entirely to one joint. // If the group is not, in fact, a joint then we return the first joint // above the group. - EggGroup *egg_group = (EggGroup *)NULL; + EggGroup *egg_group = nullptr; if (home->is_of_type(EggGroup::get_class_type())) { egg_group = DCAST(EggGroup, home); } - while (egg_group != (EggGroup *)NULL && + while (egg_group != nullptr && egg_group->get_group_type() != EggGroup::GT_joint && egg_group->get_dart_type() == EggGroup::DT_none) { - nassertr(egg_group->get_parent() != (EggGroupNode *)NULL, NULL); + nassertr(egg_group->get_parent() != nullptr, nullptr); home = egg_group->get_parent(); - egg_group = (EggGroup *)NULL; + egg_group = nullptr; if (home->is_of_type(EggGroup::get_class_type())) { egg_group = DCAST(EggGroup, home); } } - if (egg_group != (EggGroup *)NULL && + if (egg_group != nullptr && egg_group->get_group_type() == EggGroup::GT_joint && !egg_group->has_dcs_type()) { // If the home is a joint without a flag--this is the normal case-- // we'll move the polygon under the character node and animate it from // there explicitly. - return NULL; + return nullptr; } // Otherwise, if the joint *does* have a flag, we'll create static @@ -494,12 +494,12 @@ determine_bin_home(EggBin *egg_bin) { if (!egg_rigid_geometry) { // If we don't have egg-rigid-geometry enabled, then all geometry is // considered dynamic. - return NULL; + return nullptr; } // We need to keep track of the one joint we've encountered so far, to see // if all the vertices are referenced by the same joint. - EggGroupNode *home = NULL; + EggGroupNode *home = nullptr; EggGroupNode::const_iterator ci; for (ci = egg_bin->begin(); ci != egg_bin->end(); ++ci) { @@ -513,7 +513,7 @@ determine_bin_home(EggBin *egg_bin) { if (vertex->gref_size() > 1) { // This vertex is referenced by multiple joints; the primitive is // dynamic. - return NULL; + return nullptr; } if (!vertex->_dxyzs.empty() || @@ -521,14 +521,14 @@ determine_bin_home(EggBin *egg_bin) { !vertex->_drgbas.empty()) { // This vertex has some morph slider definitions; therefore, the // primitive is dynamic. - return NULL; + return nullptr; } EggVertex::const_uv_iterator uvi; for (uvi = vertex->uv_begin(); uvi != vertex->uv_end(); ++uvi) { if (!(*uvi)->_duvs.empty()) { // Ditto: the vertex has some UV morphs; therefore the primitive is // dynamic. - return NULL; + return nullptr; } } @@ -539,15 +539,15 @@ determine_bin_home(EggBin *egg_bin) { // where it is. vertex_home = egg_primitive->get_parent(); } else { - nassertr(vertex->gref_size() == 1, NULL); + nassertr(vertex->gref_size() == 1, nullptr); // This vertex is referenced exactly once. vertex_home = *vertex->gref_begin(); } - if (home != NULL && home != vertex_home) { + if (home != nullptr && home != vertex_home) { // Oops, two vertices are referenced by different joints! The // primitive is dynamic. - return NULL; + return nullptr; } home = vertex_home; @@ -557,29 +557,29 @@ determine_bin_home(EggBin *egg_bin) { // This shouldn't be possible, unless there are no vertices--but we // eliminate invalid primitives before we begin, so all primitives should // have vertices, and all bins should have primitives. - nassertr(home != NULL, NULL); + nassertr(home != nullptr, nullptr); // So, all the vertices are assigned to the same group. This means all the // primitives in the bin belong entirely to one joint. // If the group is not, in fact, a joint then we return the first joint // above the group. - EggGroup *egg_group = (EggGroup *)NULL; + EggGroup *egg_group = nullptr; if (home->is_of_type(EggGroup::get_class_type())) { egg_group = DCAST(EggGroup, home); } - while (egg_group != (EggGroup *)NULL && + while (egg_group != nullptr && egg_group->get_group_type() != EggGroup::GT_joint && egg_group->get_dart_type() == EggGroup::DT_none) { - nassertr(egg_group->get_parent() != (EggGroupNode *)NULL, NULL); + nassertr(egg_group->get_parent() != nullptr, nullptr); home = egg_group->get_parent(); - egg_group = (EggGroup *)NULL; + egg_group = nullptr; if (home->is_of_type(EggGroup::get_class_type())) { egg_group = DCAST(EggGroup, home); } } - if (egg_group != (EggGroup *)NULL && + if (egg_group != nullptr && egg_group->get_group_type() == EggGroup::GT_joint && !egg_group->has_dcs_type()) { // If we have rigid geometry that is assigned to a joint without a @@ -597,7 +597,7 @@ determine_bin_home(EggBin *egg_bin) { * and this may also break up the geometry into more individual pieces, which * is the biggest limiting factor on modern PC graphics cards. */ - return NULL; + return nullptr; } CharacterJoint *joint; @@ -618,7 +618,7 @@ determine_bin_home(EggBin *egg_bin) { */ VertexTransform *CharacterMaker:: get_identity_transform() { - if (_identity_transform == (VertexTransform *)NULL) { + if (_identity_transform == nullptr) { _identity_transform = new UserVertexTransform("root"); } return _identity_transform; diff --git a/panda/src/egg2pg/eggLoader.cxx b/panda/src/egg2pg/eggLoader.cxx index 6e07b82d26..ae2c30a8c3 100644 --- a/panda/src/egg2pg/eggLoader.cxx +++ b/panda/src/egg2pg/eggLoader.cxx @@ -115,7 +115,7 @@ public: LODInstance:: LODInstance(EggNode *egg_node) { - nassertv(egg_node != NULL); + nassertv(egg_node != nullptr); _egg_node = egg_node; // We expect this egg node to be an EggGroup with an LOD specification. @@ -139,7 +139,7 @@ EggLoader() { _data->set_coordinate_system(egg_coordinate_system); _error = false; _dynamic_override = false; - _dynamic_override_char_maker = NULL; + _dynamic_override_char_maker = nullptr; } /** @@ -151,7 +151,7 @@ EggLoader(const EggData *data) : { _error = false; _dynamic_override = false; - _dynamic_override_char_maker = NULL; + _dynamic_override_char_maker = nullptr; } @@ -224,7 +224,7 @@ reparent_decals() { ExtraNodes::const_iterator di; for (di = _decals.begin(); di != _decals.end(); ++di) { PandaNode *node = (*di); - nassertv(node != (PandaNode *)NULL); + nassertv(node != nullptr); // The NodePath interface is best for this. NodePath parent(node); @@ -307,7 +307,7 @@ make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, EggGroupNode::const_iterator ci = egg_bin->begin(); nassertv(ci != egg_bin->end()); CPT(EggPrimitive) first_prim = DCAST(EggPrimitive, (*ci)); - nassertv(first_prim != (EggPrimitive *)NULL); + nassertv(first_prim != nullptr); const EggRenderState *render_state; DCAST_INTO_V(render_state, first_prim->get_user_data(EggRenderState::get_class_type())); @@ -390,7 +390,7 @@ make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, if (!primitives.empty()) { LMatrix4d mat; - if (transform != NULL) { + if (transform != nullptr) { mat = (*transform); } else { mat = egg_bin->get_vertex_to_node(); @@ -400,7 +400,7 @@ make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, PT(GeomVertexData) vertex_data = make_vertex_data(render_state, vertex_pool, egg_bin, mat, blend_table, is_dynamic, character_maker, has_overall_color); - nassertv(vertex_data != (GeomVertexData *)NULL); + nassertv(vertex_data != nullptr); // And create a Geom to hold the primitives. PT(Geom) geom = new Geom(vertex_data); @@ -423,7 +423,7 @@ make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, // render_state->_state->write(cerr, 0); // Create a new GeomNode if we haven't already. - if (geom_node == (GeomNode *)NULL) { + if (geom_node == nullptr) { // Now, is our parent node a GeomNode, or just an ordinary PandaNode? // If it's a GeomNode, we can add the new Geom directly to our parent; // otherwise, we need to create a new node. @@ -453,7 +453,7 @@ make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, } } - if (geom_node != (GeomNode *)NULL && egg_show_normals) { + if (geom_node != nullptr && egg_show_normals) { // Create some more geometry to visualize each normal. for (vpi = vertex_pools.begin(); vpi != vertex_pools.end(); ++vpi) { EggVertexPool *vertex_pool = (*vpi); @@ -659,11 +659,11 @@ make_nurbs_curve(EggNurbsCurve *egg_curve, PandaNode *parent, return; } - assert(parent != NULL); + assert(parent != nullptr); assert(!parent->is_geom_node()); PT(NurbsCurveEvaluator) nurbs = ::make_nurbs_curve(egg_curve, mat); - if (nurbs == (NurbsCurveEvaluator *)NULL) { + if (nurbs == nullptr) { _error = true; return; } @@ -726,14 +726,14 @@ make_nurbs_curve(EggNurbsCurve *egg_curve, PandaNode *parent, void EggLoader:: make_old_nurbs_curve(EggNurbsCurve *egg_curve, PandaNode *parent, const LMatrix4d &mat) { - assert(parent != NULL); + assert(parent != nullptr); assert(!parent->is_geom_node()); PT(ParametricCurve) curve; curve = new NurbsCurve; NurbsCurveInterface *nurbs = curve->get_nurbs_interface(); - nassertv(nurbs != (NurbsCurveInterface *)NULL); + nassertv(nurbs != nullptr); if (egg_curve->get_order() < 1 || egg_curve->get_order() > 4) { egg2pg_cat.error() @@ -798,11 +798,11 @@ make_old_nurbs_curve(EggNurbsCurve *egg_curve, PandaNode *parent, void EggLoader:: make_nurbs_surface(EggNurbsSurface *egg_surface, PandaNode *parent, const LMatrix4d &mat) { - assert(parent != NULL); + assert(parent != nullptr); assert(!parent->is_geom_node()); PT(NurbsSurfaceEvaluator) nurbs = ::make_nurbs_surface(egg_surface, mat); - if (nurbs == (NurbsSurfaceEvaluator *)NULL) { + if (nurbs == nullptr) { _error = true; return; } @@ -915,7 +915,7 @@ load_texture(TextureDef &def, EggTexture *egg_tex) { // Since some properties of the textures are inferred from the texture files // themselves (if the properties are not explicitly specified in the egg // file), then we add the textures as dependents for the egg file. - if (_record != (BamCacheRecord *)NULL) { + if (_record != nullptr) { _record->add_dependent_file(egg_tex->get_fullpath()); if (egg_tex->has_alpha_filename() && wanted_alpha) { _record->add_dependent_file(egg_tex->get_alpha_fullpath()); @@ -987,7 +987,7 @@ load_texture(TextureDef &def, EggTexture *egg_tex) { break; } - if (tex == (Texture *)NULL) { + if (tex == nullptr) { return false; } @@ -1002,7 +1002,7 @@ load_texture(TextureDef &def, EggTexture *egg_tex) { // See if there is some egg data hanging on the texture. In particular, the // TxaFileFilter might have left that here for us. TypedReferenceCount *aux = tex->get_aux_data("egg"); - if (aux != (TypedReferenceCount *)NULL && + if (aux != nullptr && aux->is_of_type(EggTexture::get_class_type())) { EggTexture *aux_egg_tex = DCAST(EggTexture, aux); @@ -1686,7 +1686,7 @@ make_node(EggNode *egg_node, PandaNode *parent) { return make_node(DCAST(EggGroupNode, egg_node), parent); } - return (PandaNode *)NULL; + return nullptr; } /** @@ -1700,40 +1700,40 @@ make_node(EggBin *egg_bin, PandaNode *parent) { switch (egg_bin->get_bin_number()) { case EggBinner::BN_polyset: case EggBinner::BN_patches: - make_polyset(egg_bin, parent, NULL, _dynamic_override, _dynamic_override_char_maker); - return NULL; + make_polyset(egg_bin, parent, nullptr, _dynamic_override, _dynamic_override_char_maker); + return nullptr; case EggBinner::BN_lod: return make_lod(egg_bin, parent); case EggBinner::BN_nurbs_surface: { - nassertr(!egg_bin->empty(), NULL); + nassertr(!egg_bin->empty(), nullptr); EggNode *child = egg_bin->get_first_child(); EggNurbsSurface *egg_nurbs; - DCAST_INTO_R(egg_nurbs, child, NULL); + DCAST_INTO_R(egg_nurbs, child, nullptr); const LMatrix4d &mat = egg_nurbs->get_vertex_to_node(); make_nurbs_surface(egg_nurbs, parent, mat); } - return NULL; + return nullptr; case EggBinner::BN_nurbs_curve: { - nassertr(!egg_bin->empty(), NULL); + nassertr(!egg_bin->empty(), nullptr); EggNode *child = egg_bin->get_first_child(); EggNurbsCurve *egg_nurbs; - DCAST_INTO_R(egg_nurbs, child, NULL); + DCAST_INTO_R(egg_nurbs, child, nullptr); const LMatrix4d &mat = egg_nurbs->get_vertex_to_node(); make_nurbs_curve(egg_nurbs, parent, mat); } - return NULL; + return nullptr; case EggBinner::BN_none: break; } // Shouldn't get here. - return (PandaNode *)NULL; + return nullptr; } /** @@ -1769,7 +1769,7 @@ make_lod(EggBin *egg_bin, PandaNode *parent) { // All of the children should have the same center, because that's how we // binned them. nassertr(lod_node->get_center().almost_equal - (LCAST(PN_stdfloat, instance._d->_center), 0.01), NULL); + (LCAST(PN_stdfloat, instance._d->_center), 0.01), nullptr); // Tell the LOD node about this child's switching distances. lod_node->add_switch(instance._d->_switch_in, instance._d->_switch_out); @@ -1784,7 +1784,7 @@ make_lod(EggBin *egg_bin, PandaNode *parent) { */ PandaNode *EggLoader:: make_node(EggGroup *egg_group, PandaNode *parent) { - PT(PandaNode) node = NULL; + PT(PandaNode) node = nullptr; if (egg_group->get_dart_type() != EggGroup::DT_none) { // A group with the flag set means to create a character. @@ -1802,7 +1802,7 @@ make_node(EggGroup *egg_group, PandaNode *parent) { for (ci = egg_group->begin(); ci != egg_group->end(); ++ci) { make_node(*ci, node); } - _dynamic_override_char_maker = NULL; + _dynamic_override_char_maker = nullptr; _dynamic_override = false; } @@ -1956,8 +1956,8 @@ make_node(EggGroup *egg_group, PandaNode *parent) { } } - if (node == (PandaNode *)NULL) { - return NULL; + if (node == nullptr) { + return nullptr; } // Associate any instances with this node. @@ -2319,7 +2319,7 @@ make_vertex_data(const EggRenderState *render_state, vertex_data->reserve_num_rows(vertex_pool->size()); vertex_data->set_transform_blend_table(blend_table); - if (slider_table != (SliderTable *)NULL) { + if (slider_table != nullptr) { vertex_data->set_slider_table(SliderTable::register_table(slider_table)); } @@ -2477,7 +2477,7 @@ make_blend_table(EggVertexPool *vertex_pool, EggNode *primitive_home, // If the vertex has no explicit membership, it belongs right where it // is. PT(VertexTransform) vt = character_maker->egg_to_transform(primitive_home); - nassertr(vt != (VertexTransform *)NULL, NULL); + nassertr(vt != nullptr, nullptr); blend.add_transform(vt, 1.0f); } else { // If the vertex does have an explicit membership, ignore its parentage @@ -2492,7 +2492,7 @@ make_blend_table(EggVertexPool *vertex_pool, EggNode *primitive_home, } PT(VertexTransform) vt = character_maker->egg_to_transform(egg_joint); - nassertr(vt != (VertexTransform *)NULL, NULL); + nassertr(vt != nullptr, nullptr); blend.add_transform(vt, membership); } } @@ -2564,7 +2564,7 @@ make_primitive(const EggRenderState *render_state, EggPrimitive *egg_prim, primitive = new GeomPatches(num_vertices, Geom::UH_static); } - if (primitive == (GeomPrimitive *)NULL) { + if (primitive == nullptr) { // Don't know how to make this kind of primitive. egg2pg_cat.warning() << "Ignoring " << egg_prim->get_type() << "\n"; @@ -2633,7 +2633,7 @@ set_portal_polygon(EggGroup *egg_group, PortalNode *pnode) { pnode->clear_vertices(); PT(EggPolygon) poly = find_first_polygon(egg_group); - if (poly != (EggPolygon *)NULL) { + if (poly != nullptr) { LMatrix4d mat = poly->get_vertex_to_node(); EggPolygon::const_iterator vi; @@ -2650,7 +2650,7 @@ set_portal_polygon(EggGroup *egg_group, PortalNode *pnode) { void EggLoader:: set_occluder_polygon(EggGroup *egg_group, OccluderNode *pnode) { PT(EggPolygon) poly = find_first_polygon(egg_group); - if (poly != (EggPolygon *)NULL) { + if (poly != nullptr) { if (poly->size() != 4) { egg2pg_cat.error() << "Invalid number of vertices for " << egg_group->get_name() << "\n"; @@ -2693,14 +2693,14 @@ find_first_polygon(EggGroup *egg_group) { if ((*ci)->is_of_type(EggGroup::get_class_type())) { EggGroup *child_group = DCAST(EggGroup, *ci); PT(EggPolygon) found = find_first_polygon(child_group); - if (found != (EggPolygon *)NULL) { + if (found != nullptr) { return found; } } } // We got nothing. - return NULL; + return nullptr; } /** @@ -2712,7 +2712,7 @@ bool EggLoader:: make_sphere(EggGroup *egg_group, EggGroup::CollideFlags flags, LPoint3 ¢er, PN_stdfloat &radius, LColor &color) { EggGroup *geom_group = find_collision_geometry(egg_group, flags); - if (geom_group != (EggGroup *)NULL) { + if (geom_group != nullptr) { // Collect all of the vertices. pset vertices; @@ -2772,7 +2772,7 @@ bool EggLoader:: make_box(EggGroup *egg_group, EggGroup::CollideFlags flags, LPoint3 &min_p, LPoint3 &max_p, LColor &color) { EggGroup *geom_group = find_collision_geometry(egg_group, flags); - if (geom_group != (EggGroup *)NULL) { + if (geom_group != nullptr) { // Collect all of the vertices. pset vertices; @@ -2893,13 +2893,13 @@ void EggLoader:: make_collision_plane(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags) { EggGroup *geom_group = find_collision_geometry(egg_group, flags); - if (geom_group != (EggGroup *)NULL) { + if (geom_group != nullptr) { EggGroup::const_iterator ci; for (ci = geom_group->begin(); ci != geom_group->end(); ++ci) { if ((*ci)->is_of_type(EggPolygon::get_class_type())) { CollisionPlane *csplane = create_collision_plane(DCAST(EggPolygon, *ci), egg_group); - if (csplane != (CollisionPlane *)NULL) { + if (csplane != nullptr) { apply_collision_flags(csplane, flags); cnode->add_solid(csplane); return; @@ -2929,7 +2929,7 @@ make_collision_floor_mesh(EggGroup *egg_group, CollisionNode *cnode, EggGroup *geom_group = find_collision_geometry(egg_group, flags); - if (geom_group != (EggGroup *)NULL) { + if (geom_group != nullptr) { create_collision_floor_mesh(cnode, geom_group,flags); } } @@ -2943,7 +2943,7 @@ make_collision_polygon(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags) { EggGroup *geom_group = find_collision_geometry(egg_group, flags); - if (geom_group != (EggGroup *)NULL) { + if (geom_group != nullptr) { EggGroup::const_iterator ci; for (ci = geom_group->begin(); ci != geom_group->end(); ++ci) { if ((*ci)->is_of_type(EggPolygon::get_class_type())) { @@ -2970,7 +2970,7 @@ void EggLoader:: make_collision_polyset(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags) { EggGroup *geom_group = find_collision_geometry(egg_group, flags); - if (geom_group != (EggGroup *)NULL) { + if (geom_group != nullptr) { EggGroup::const_iterator ci; for (ci = geom_group->begin(); ci != geom_group->end(); ++ci) { if ((*ci)->is_of_type(EggPolygon::get_class_type())) { @@ -3049,7 +3049,7 @@ void EggLoader:: make_collision_tube(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags) { EggGroup *geom_group = find_collision_geometry(egg_group, flags); - if (geom_group != (EggGroup *)NULL) { + if (geom_group != nullptr) { // Collect all of the vertices. pset vertices; @@ -3284,7 +3284,7 @@ find_collision_geometry(EggGroup *egg_group, EggGroup::CollideFlags flags) { } // We got nothing. - return NULL; + return nullptr; } /** @@ -3296,7 +3296,7 @@ create_collision_plane(EggPolygon *egg_poly, EggGroup *parent_group) { egg2pg_cat.info() << "Ignoring degenerate collision plane in " << parent_group->get_name() << "\n"; - return NULL; + return nullptr; } if (!egg_poly->is_planar()) { @@ -3328,7 +3328,7 @@ create_collision_plane(EggPolygon *egg_poly, EggGroup *parent_group) { } if (vertices.size() < 3) { - return NULL; + return nullptr; } LPlane plane(vertices[0], vertices[1], vertices[2]); return new CollisionPlane(plane); diff --git a/panda/src/egg2pg/eggRenderState.cxx b/panda/src/egg2pg/eggRenderState.cxx index cb8a9681e3..5612826ec0 100644 --- a/panda/src/egg2pg/eggRenderState.cxx +++ b/panda/src/egg2pg/eggRenderState.cxx @@ -63,50 +63,50 @@ fill_state(EggPrimitive *egg_prim) { EggRenderMode *render_mode; render_mode = egg_prim->determine_alpha_mode(); - if (render_mode != (EggRenderMode *)NULL) { + if (render_mode != nullptr) { am = render_mode->get_alpha_mode(); } render_mode = egg_prim->determine_depth_write_mode(); - if (render_mode != (EggRenderMode *)NULL) { + if (render_mode != nullptr) { dwm = render_mode->get_depth_write_mode(); } render_mode = egg_prim->determine_depth_test_mode(); - if (render_mode != (EggRenderMode *)NULL) { + if (render_mode != nullptr) { dtm = render_mode->get_depth_test_mode(); } render_mode = egg_prim->determine_visibility_mode(); - if (render_mode != (EggRenderMode *)NULL) { + if (render_mode != nullptr) { vm = render_mode->get_visibility_mode(); } render_mode = egg_prim->determine_draw_order(); - if (render_mode != (EggRenderMode *)NULL) { + if (render_mode != nullptr) { has_draw_order = true; draw_order = render_mode->get_draw_order(); } render_mode = egg_prim->determine_depth_offset(); - if (render_mode != (EggRenderMode *)NULL) { + if (render_mode != nullptr) { has_depth_offset = true; depth_offset = render_mode->get_depth_offset(); } render_mode = egg_prim->determine_bin(); - if (render_mode != (EggRenderMode *)NULL) { + if (render_mode != nullptr) { has_bin = true; bin = render_mode->get_bin(); } // add_attrib(TextureAttrib::make_off()); int num_textures = egg_prim->get_num_textures(); - CPT(RenderAttrib) texture_attrib = NULL; - CPT(RenderAttrib) tex_gen_attrib = NULL; - CPT(RenderAttrib) tex_mat_attrib = NULL; + CPT(RenderAttrib) texture_attrib = nullptr; + CPT(RenderAttrib) tex_gen_attrib = nullptr; + CPT(RenderAttrib) tex_mat_attrib = nullptr; TexMats tex_mats; for (int i = 0; i < num_textures; i++) { PT_EggTexture egg_tex = egg_prim->get_texture(i); const TextureDef &def = _loader._textures[egg_tex]; - if (def._texture != (const RenderAttrib *)NULL) { - if (texture_attrib == (RenderAttrib *)NULL) { + if (def._texture != nullptr) { + if (texture_attrib == nullptr) { texture_attrib = def._texture; } else { texture_attrib = texture_attrib->compose(def._texture); @@ -115,7 +115,7 @@ fill_state(EggPrimitive *egg_prim) { if (egg_tex->affects_polygon_alpha()) { const TextureAttrib *tex_attrib = DCAST(TextureAttrib, def._texture); Texture *tex = tex_attrib->get_texture(); - nassertv(tex != (Texture *)NULL); + nassertv(tex != nullptr); Texture::Format format = tex->get_format(); if (Texture::has_alpha(format) && !Texture::has_binary_alpha(format)) { @@ -139,7 +139,7 @@ fill_state(EggPrimitive *egg_prim) { bool has_tex_gen = false; if (egg_tex->get_tex_gen() != EggTexture::TG_unspecified) { has_tex_gen = true; - if (tex_gen_attrib == (const RenderAttrib *)NULL) { + if (tex_gen_attrib == nullptr) { tex_gen_attrib = TexGenAttrib::make(); } tex_gen_attrib = DCAST(TexGenAttrib, tex_gen_attrib)-> @@ -228,15 +228,15 @@ fill_state(EggPrimitive *egg_prim) { } } - if (texture_attrib != (RenderAttrib *)NULL) { + if (texture_attrib != nullptr) { add_attrib(texture_attrib); } - if (tex_gen_attrib != (RenderAttrib *)NULL) { + if (tex_gen_attrib != nullptr) { add_attrib(tex_gen_attrib); } - if (tex_mat_attrib != (RenderAttrib *)NULL) { + if (tex_mat_attrib != nullptr) { add_attrib(tex_mat_attrib); } @@ -580,7 +580,7 @@ apply_tex_mat(CPT(RenderAttrib) tex_mat_attrib, if (egg_tex->has_transform()) { CPT(TransformState) transform = _loader.make_transform(egg_tex); - if (tex_mat_attrib == (const RenderAttrib *)NULL) { + if (tex_mat_attrib == nullptr) { tex_mat_attrib = TexMatrixAttrib::make(); } tex_mat_attrib = DCAST(TexMatrixAttrib, tex_mat_attrib)-> diff --git a/panda/src/egg2pg/eggSaver.cxx b/panda/src/egg2pg/eggSaver.cxx index ab56a074dd..b54b6df744 100644 --- a/panda/src/egg2pg/eggSaver.cxx +++ b/panda/src/egg2pg/eggSaver.cxx @@ -82,7 +82,7 @@ EggSaver:: EggSaver(EggData *data) : _data(data) { - if (_data == NULL) { + if (_data == nullptr) { _data = new EggData; } } @@ -97,13 +97,13 @@ add_node(PandaNode *node) { _data->add_child(_vpool); NodePath root(node); - convert_node(WorkingNodePath(root), _data, false, NULL); + convert_node(WorkingNodePath(root), _data, false, nullptr); // Remove the vertex pool if it has no vertices. if (_vpool->empty()) { _data->remove_child(_vpool); } - _vpool = NULL; + _vpool = nullptr; } /** @@ -117,13 +117,13 @@ add_subgraph(PandaNode *root) { _data->add_child(_vpool); NodePath root_path(root); - recurse_nodes(root_path, _data, false, NULL); + recurse_nodes(root_path, _data, false, nullptr); // Remove the vertex pool if it has no vertices. if (_vpool->empty()) { _data->remove_child(_vpool); } - _vpool = NULL; + _vpool = nullptr; } /** @@ -288,7 +288,7 @@ convert_switch_node(SwitchNode *node, const WorkingNodePath &node_path, EggGroupNode * EggSaver::convert_animGroup_node(AnimGroup *animGroup, double fps ) { int num_children = animGroup->get_num_children(); - EggGroupNode *eggNode = NULL; + EggGroupNode *eggNode = nullptr; if (animGroup->is_of_type(AnimBundle::get_class_type())) { EggTable *eggTable = new EggTable(animGroup->get_name()); eggTable ->set_table_type(EggTable::TT_bundle); @@ -319,8 +319,8 @@ EggGroupNode * EggSaver::convert_animGroup_node(AnimGroup *animGroup, double fps for (int i = 0; i < num_children; i++) { AnimGroup *animChild = animGroup->get_child(i); EggGroupNode *eggChildNode = convert_animGroup_node(animChild, fps); - if (eggChildNode!=NULL) { - nassertr(eggNode!=NULL, NULL); + if (eggChildNode!=nullptr) { + nassertr(eggNode!=nullptr, nullptr); eggNode->add_child(eggChildNode); } } @@ -378,7 +378,7 @@ convert_character_bundle(PartGroup *bundleNode, EggGroupNode *egg_parent, Charac joint_group = joint; egg_parent->add_child(joint_group); - if (joint_map != NULL) { + if (joint_map != nullptr) { CharacterJointMap::iterator mi = joint_map->find(character_joint); if (mi != joint_map->end()) { pvector > &joint_vertices = (*mi).second; @@ -789,11 +789,11 @@ convert_primitive(const GeomVertexData *vertex_data, } // Check for a material. - EggMaterial *egg_mat = (EggMaterial *)NULL; + EggMaterial *egg_mat = nullptr; const MaterialAttrib *ma; if (net_state->get_attrib(ma)) { egg_mat = get_egg_material(ma->get_material()); - if (egg_mat != (EggMaterial *)NULL) { + if (egg_mat != nullptr) { egg_prim->set_material(egg_mat); } } @@ -803,9 +803,9 @@ convert_primitive(const GeomVertexData *vertex_data, if (net_state->get_attrib(ta)) { EggTexture *egg_tex = get_egg_texture(ta->get_texture()); - if (egg_tex != (EggTexture *)NULL) { + if (egg_tex != nullptr) { TextureStage *tex_stage = ta->get_on_stage(0); - if (tex_stage != (TextureStage *)NULL) { + if (tex_stage != nullptr) { switch (tex_stage->get_mode()) { case TextureStage::M_modulate: if (has_color_off == true) { @@ -908,7 +908,7 @@ convert_primitive(const GeomVertexData *vertex_data, EggVertex *new_egg_vert = _vpool->create_unique_vertex(egg_vert); if (vertex_data->has_column(InternalName::get_transform_blend()) && - joint_map != NULL && transformBlendTable != NULL) { + joint_map != nullptr && transformBlendTable != nullptr) { reader.set_column(InternalName::get_transform_blend()); int idx = reader.get_data1i(); const TransformBlend &blend = transformBlendTable->get_blend(idx); @@ -1006,7 +1006,7 @@ apply_node_properties(EggGroup *egg_group, PandaNode *node, bool allow_backstage const RenderEffects *effects = node->get_effects(); const RenderEffect *effect = effects->get_effect(BillboardEffect::get_class_type()); - if (effect != (RenderEffect *)NULL) { + if (effect != nullptr) { const BillboardEffect *bbe = DCAST(BillboardEffect, effect); if (bbe->get_axial_rotate()) { egg_group->set_billboard_type(EggGroup::BT_axis); @@ -1198,7 +1198,7 @@ apply_tag(EggGroup *egg_group, PandaNode *node, const string &tag) { */ EggMaterial *EggSaver:: get_egg_material(Material *mat) { - if (mat != (Material *)NULL) { + if (mat != nullptr) { EggMaterial temp(mat->get_name()); if (mat->has_base_color()) { temp.set_base(mat->get_base_color()); @@ -1239,7 +1239,7 @@ get_egg_material(Material *mat) { return _materials.create_unique_material(temp, ~EggMaterial::E_mref_name); } - return NULL; + return nullptr; } /** @@ -1247,7 +1247,7 @@ get_egg_material(Material *mat) { */ EggTexture *EggSaver:: get_egg_texture(Texture *tex) { - if (tex != (Texture *)NULL) { + if (tex != nullptr) { if (tex->has_filename()) { Filename filename = tex->get_filename(); EggTexture temp(filename.get_basename_wo_extension(), filename); @@ -1383,5 +1383,5 @@ get_egg_texture(Texture *tex) { } } - return NULL; + return nullptr; } diff --git a/panda/src/egg2pg/eggSaver.h b/panda/src/egg2pg/eggSaver.h index a361591241..bd2905398f 100644 --- a/panda/src/egg2pg/eggSaver.h +++ b/panda/src/egg2pg/eggSaver.h @@ -52,7 +52,7 @@ class EggVertex; */ class EggSaver { PUBLISHED: - EggSaver(EggData *data = NULL); + EggSaver(EggData *data = nullptr); void add_node(PandaNode *node); void add_subgraph(PandaNode *root); @@ -82,7 +82,7 @@ private: EggGroupNode *egg_parent, bool has_decal, CharacterJointMap *joint_map); void convert_geom_node(GeomNode *node, const WorkingNodePath &node_path, - EggGroupNode *egg_parent, bool has_decal, CharacterJointMap *jointMap=NULL); + EggGroupNode *egg_parent, bool has_decal, CharacterJointMap *jointMap=nullptr); void convert_primitive(const GeomVertexData *vertex_data, const GeomPrimitive *primitive, const RenderState *geom_state, diff --git a/panda/src/egg2pg/egg_parametrics.cxx b/panda/src/egg2pg/egg_parametrics.cxx index e57f49e297..eb2036d8a7 100644 --- a/panda/src/egg2pg/egg_parametrics.cxx +++ b/panda/src/egg2pg/egg_parametrics.cxx @@ -26,14 +26,14 @@ make_nurbs_surface(EggNurbsSurface *egg_surface, const LMatrix4d &mat) { egg2pg_cat.error() << "Invalid NURBSSurface U order for " << egg_surface->get_name() << ": " << egg_surface->get_u_order() << "\n"; - return NULL; + return nullptr; } if (egg_surface->get_v_order() < 1 || egg_surface->get_v_order() > 4) { egg2pg_cat.error() << "Invalid NURBSSurface V order for " << egg_surface->get_name() << ": " << egg_surface->get_v_order() << "\n"; - return NULL; + return nullptr; } PT(NurbsSurfaceEvaluator) nurbs = new NurbsSurfaceEvaluator; @@ -61,7 +61,7 @@ make_nurbs_surface(EggNurbsSurface *egg_surface, const LMatrix4d &mat) { << "Invalid NURBSSurface number of U knots for " << egg_surface->get_name() << ": got " << num_u_knots << " knots, expected " << nurbs->get_num_u_knots() << "\n"; - return NULL; + return nullptr; } int num_v_knots = egg_surface->get_num_v_knots(); @@ -70,7 +70,7 @@ make_nurbs_surface(EggNurbsSurface *egg_surface, const LMatrix4d &mat) { << "Invalid NURBSSurface number of U knots for " << egg_surface->get_name() << ": got " << num_v_knots << " knots, expected " << nurbs->get_num_v_knots() << "\n"; - return NULL; + return nullptr; } int i; @@ -96,7 +96,7 @@ make_nurbs_curve(EggNurbsCurve *egg_curve, const LMatrix4d &mat) { egg2pg_cat.error() << "Invalid NURBSCurve order for " << egg_curve->get_name() << ": " << egg_curve->get_order() << "\n"; - return NULL; + return nullptr; } PT(NurbsCurveEvaluator) nurbs = new NurbsCurveEvaluator; @@ -119,7 +119,7 @@ make_nurbs_curve(EggNurbsCurve *egg_curve, const LMatrix4d &mat) { << "Invalid NURBSCurve number of knots for " << egg_curve->get_name() << ": got " << num_knots << " knots, expected " << nurbs->get_num_knots() << "\n"; - return NULL; + return nullptr; } for (int i = 0; i < num_knots; i++) { diff --git a/panda/src/egg2pg/load_egg_file.cxx b/panda/src/egg2pg/load_egg_file.cxx index 36b60bb92c..bee738af4b 100644 --- a/panda/src/egg2pg/load_egg_file.cxx +++ b/panda/src/egg2pg/load_egg_file.cxx @@ -28,10 +28,10 @@ load_from_loader(EggLoader &loader) { if (loader._error && !egg_accept_errors) { egg2pg_cat.error() << "Errors in egg file.\n"; - return NULL; + return nullptr; } - if (loader._root != (PandaNode *)NULL && egg_flatten) { + if (loader._root != nullptr && egg_flatten) { SceneGraphReducer gr; int combine_siblings_bits = 0; @@ -76,7 +76,7 @@ load_egg_file(const Filename &filename, CoordinateSystem cs, egg_filename.set_text(); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(egg_filename); } @@ -87,18 +87,18 @@ load_egg_file(const Filename &filename, CoordinateSystem cs, loader._record = record; PT(VirtualFile) vfile = vfs->get_file(egg_filename); - if (vfile == NULL) { - return NULL; + if (vfile == nullptr) { + return nullptr; } loader._data->set_egg_timestamp(vfile->get_timestamp()); bool okflag; istream *istr = vfile->open_read_file(true); - if (istr == (istream *)NULL) { + if (istr == nullptr) { egg2pg_cat.error() << "Couldn't read " << egg_filename << "\n"; - return NULL; + return nullptr; } egg2pg_cat.info() @@ -110,7 +110,7 @@ load_egg_file(const Filename &filename, CoordinateSystem cs, if (!okflag) { egg2pg_cat.error() << "Error reading " << egg_filename << "\n"; - return NULL; + return nullptr; } return load_from_loader(loader); diff --git a/panda/src/egg2pg/load_egg_file.h b/panda/src/egg2pg/load_egg_file.h index 296d1aaa60..45ea636f94 100644 --- a/panda/src/egg2pg/load_egg_file.h +++ b/panda/src/egg2pg/load_egg_file.h @@ -33,7 +33,7 @@ BEGIN_PUBLISH */ EXPCL_PANDAEGG PT(PandaNode) load_egg_file(const Filename &filename, CoordinateSystem cs = CS_default, - BamCacheRecord *record = NULL); + BamCacheRecord *record = nullptr); /** * Another convenience function; works like load_egg_file() but starts from an diff --git a/panda/src/egldisplay/eglGraphicsBuffer.cxx b/panda/src/egldisplay/eglGraphicsBuffer.cxx index 14f6121653..07057818ab 100644 --- a/panda/src/egldisplay/eglGraphicsBuffer.cxx +++ b/panda/src/egldisplay/eglGraphicsBuffer.cxx @@ -62,7 +62,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } @@ -105,7 +105,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void eglGraphicsBuffer:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { copy_to_textures(); @@ -124,7 +124,7 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void eglGraphicsBuffer:: close_buffer() { - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { eglGraphicsStateGuardian *eglgsg; DCAST_INTO_V(eglgsg, _gsg); if (!eglMakeCurrent(eglgsg->_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) { @@ -158,7 +158,7 @@ open_buffer() { eglGraphicsStateGuardian *eglgsg; if (_gsg == 0) { // There is no old gsg. Create a new one. - eglgsg = new eglGraphicsStateGuardian(_engine, _pipe, NULL); + eglgsg = new eglGraphicsStateGuardian(_engine, _pipe, nullptr); eglgsg->choose_pixel_format(_fb_properties, egl_pipe->get_display(), egl_pipe->get_screen(), true, false); _gsg = eglgsg; } else { diff --git a/panda/src/egldisplay/eglGraphicsPipe.cxx b/panda/src/egldisplay/eglGraphicsPipe.cxx index 441fc10512..93ddb7f92c 100644 --- a/panda/src/egldisplay/eglGraphicsPipe.cxx +++ b/panda/src/egldisplay/eglGraphicsPipe.cxx @@ -27,7 +27,7 @@ TypeHandle eglGraphicsPipe::_type_handle; eglGraphicsPipe:: eglGraphicsPipe(const string &display) : x11GraphicsPipe(display) { _egl_display = eglGetDisplay((NativeDisplayType) _display); - if (!eglInitialize(_egl_display, NULL, NULL)) { + if (!eglInitialize(_egl_display, nullptr, nullptr)) { egldisplay_cat.error() << "Couldn't initialize the EGL display: " << get_egl_error_string(eglGetError()) << "\n"; @@ -88,12 +88,12 @@ make_output(const string &name, bool &precertify) { if (!_is_valid) { - return NULL; + return nullptr; } eglGraphicsStateGuardian *eglgsg = 0; if (gsg != 0) { - DCAST_INTO_R(eglgsg, gsg, NULL); + DCAST_INTO_R(eglgsg, gsg, nullptr); } bool support_rtt; @@ -117,7 +117,7 @@ make_output(const string &name, ((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_color)!=0)|| ((flags&BF_can_bind_every)!=0)) { - return NULL; + return nullptr; } return new eglGraphicsWindow(engine, this, name, fb_prop, win_prop, flags, gsg, host); @@ -129,7 +129,7 @@ make_output(const string &name, // (!gl_support_fbo)|| ((flags&BF_require_parasite)!=0)|| ((flags&BF_require_window)!=0)) { - return NULL; + return nullptr; } // Early failure - if we are sure that this buffer WONT meet specs, we can // bail out early. @@ -138,7 +138,7 @@ make_output(const string &name, (fb_prop.get_back_buffers() > 0)|| (fb_prop.get_accum_bits() > 0)|| (fb_prop.get_multisamples() > 0)) { - return NULL; + return nullptr; } } // Early success - if we are sure that this buffer WILL meet specs, we can @@ -166,7 +166,7 @@ make_output(const string &name, ((flags&BF_require_window)!=0)|| ((flags&BF_resizeable)!=0)|| ((flags&BF_size_track_host)!=0)) { - return NULL; + return nullptr; } if (!support_rtt) { @@ -174,7 +174,7 @@ make_output(const string &name, ((flags&BF_can_bind_every)!=0)) { // If we require Render-to-Texture, but can't be sure we support it, // bail. - return NULL; + return nullptr; } } @@ -188,12 +188,12 @@ make_output(const string &name, ((flags&BF_require_window)!=0)|| ((flags&BF_resizeable)!=0)|| ((flags&BF_size_track_host)!=0)) { - return NULL; + return nullptr; } if (((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_every)!=0)) { - return NULL; + return nullptr; } return new eglGraphicsPixmap(engine, this, name, fb_prop, win_prop, @@ -201,5 +201,5 @@ make_output(const string &name, } // Nothing else left to try. - return NULL; + return nullptr; } diff --git a/panda/src/egldisplay/eglGraphicsPixmap.cxx b/panda/src/egldisplay/eglGraphicsPixmap.cxx index ce0abdfdb7..ec34b460a3 100644 --- a/panda/src/egldisplay/eglGraphicsPixmap.cxx +++ b/panda/src/egldisplay/eglGraphicsPixmap.cxx @@ -67,7 +67,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } @@ -110,7 +110,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void eglGraphicsPixmap:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { copy_to_textures(); @@ -129,7 +129,7 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void eglGraphicsPixmap:: close_buffer() { - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { if (!eglMakeCurrent(_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) { egldisplay_cat.error() << "Failed to call eglMakeCurrent: " << get_egl_error_string(eglGetError()) << "\n"; @@ -166,7 +166,7 @@ open_buffer() { eglGraphicsStateGuardian *eglgsg; if (_gsg == 0) { // There is no old gsg. Create a new one. - eglgsg = new eglGraphicsStateGuardian(_engine, _pipe, NULL); + eglgsg = new eglGraphicsStateGuardian(_engine, _pipe, nullptr); eglgsg->choose_pixel_format(_fb_properties, _display, egl_pipe->get_screen(), false, true); _gsg = eglgsg; } else { @@ -187,7 +187,7 @@ open_buffer() { } XVisualInfo *visual_info = eglgsg->_visual; - if (visual_info == NULL) { + if (visual_info == nullptr) { // No X visual for this fbconfig; how can we create the pixmap? egldisplay_cat.error() << "No X visual: cannot create pixmap.\n"; @@ -195,7 +195,7 @@ open_buffer() { } _drawable = egl_pipe->get_root(); - if (_host != NULL) { + if (_host != nullptr) { if (_host->is_of_type(eglGraphicsWindow::get_class_type())) { eglGraphicsWindow *win = DCAST(eglGraphicsWindow, _host); _drawable = win->get_xwindow(); @@ -215,7 +215,7 @@ open_buffer() { } nassertr(eglgsg->_fbconfig, false); - _egl_surface = eglCreatePixmapSurface(_egl_display, eglgsg->_fbconfig, (NativePixmapType) _x_pixmap, NULL); + _egl_surface = eglCreatePixmapSurface(_egl_display, eglgsg->_fbconfig, (NativePixmapType) _x_pixmap, nullptr); if (_egl_surface == EGL_NO_SURFACE) { egldisplay_cat.error() diff --git a/panda/src/egldisplay/eglGraphicsStateGuardian.cxx b/panda/src/egldisplay/eglGraphicsStateGuardian.cxx index 84fc303efb..0d9a70e910 100644 --- a/panda/src/egldisplay/eglGraphicsStateGuardian.cxx +++ b/panda/src/egldisplay/eglGraphicsStateGuardian.cxx @@ -40,7 +40,7 @@ eglGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, _visuals=0; _fbconfig=0; - if (share_with != (eglGraphicsStateGuardian *)NULL) { + if (share_with != nullptr) { _prepared_objects = share_with->get_prepared_objects(); _share_context = share_with->_context; } @@ -51,15 +51,15 @@ eglGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, */ eglGraphicsStateGuardian:: ~eglGraphicsStateGuardian() { - if (_visuals != (XVisualInfo *)NULL) { + if (_visuals != nullptr) { XFree(_visuals); } - if (_context != (EGLContext)NULL) { + if (_context != (EGLContext)nullptr) { if (!eglDestroyContext(_egl_display, _context)) { egldisplay_cat.error() << "Failed to destroy EGL context: " << get_egl_error_string(eglGetError()) << "\n"; } - _context = (EGLContext)NULL; + _context = (EGLContext)nullptr; } } @@ -157,7 +157,7 @@ choose_pixel_format(const FrameBufferProperties &properties, // First get the number of matching configurations, so we know how much // memory to allocate. int num_configs = 0, returned_configs; - if (!eglChooseConfig(_egl_display, attrib_list, NULL, num_configs, &returned_configs) || returned_configs <= 0) { + if (!eglChooseConfig(_egl_display, attrib_list, nullptr, num_configs, &returned_configs) || returned_configs <= 0) { egldisplay_cat.error() << "eglChooseConfig failed: " << get_egl_error_string(eglGetError()) << "\n"; return; @@ -218,7 +218,7 @@ choose_pixel_format(const FrameBufferProperties &properties, EGLint context_attribs[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE}; _context = eglCreateContext(_egl_display, _fbconfig, _share_context, context_attribs); #else - _context = eglCreateContext(_egl_display, _fbconfig, _share_context, NULL); + _context = eglCreateContext(_egl_display, _fbconfig, _share_context, nullptr); #endif int err = eglGetError(); if (_context && err == EGL_SUCCESS) { diff --git a/panda/src/egldisplay/eglGraphicsWindow.cxx b/panda/src/egldisplay/eglGraphicsWindow.cxx index b7e7d5dccf..094d4ae547 100644 --- a/panda/src/egldisplay/eglGraphicsWindow.cxx +++ b/panda/src/egldisplay/eglGraphicsWindow.cxx @@ -104,7 +104,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } if (_awaiting_configure) { @@ -156,7 +156,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void eglGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { // end_render_texture(); @@ -180,7 +180,7 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void eglGraphicsWindow:: end_flip() { - if (_gsg != (GraphicsStateGuardian *)NULL && _flip_ready) { + if (_gsg != nullptr && _flip_ready) { // It doesn't appear to be necessary to ensure the graphics context is // current before flipping the windows, and insisting on doing so can be a @@ -199,7 +199,7 @@ end_flip() { */ void eglGraphicsWindow:: close_window() { - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { if (!eglMakeCurrent(_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) { egldisplay_cat.error() << "Failed to call eglMakeCurrent: " << get_egl_error_string(eglGetError()) << "\n"; @@ -207,9 +207,9 @@ close_window() { _gsg.clear(); } - if (_ic != (XIC)NULL) { + if (_ic != (XIC)nullptr) { XDestroyIC(_ic); - _ic = (XIC)NULL; + _ic = (XIC)nullptr; } if (_egl_surface != 0) { @@ -219,9 +219,9 @@ close_window() { } } - if (_xwindow != (X11_Window)NULL) { + if (_xwindow != (X11_Window)nullptr) { XDestroyWindow(_display, _xwindow); - _xwindow = (X11_Window)NULL; + _xwindow = (X11_Window)nullptr; // This may be necessary if we just closed the last X window in an // application, so the server hears the close request. @@ -243,7 +243,7 @@ open_window() { eglGraphicsStateGuardian *eglgsg; if (_gsg == 0) { // There is no old gsg. Create a new one. - eglgsg = new eglGraphicsStateGuardian(_engine, _pipe, NULL); + eglgsg = new eglGraphicsStateGuardian(_engine, _pipe, nullptr); eglgsg->choose_pixel_format(_fb_properties, egl_pipe->get_display(), egl_pipe->get_screen(), false, false); _gsg = eglgsg; } else { @@ -258,7 +258,7 @@ open_window() { } _visual_info = eglgsg->_visual; - if (_visual_info == NULL) { + if (_visual_info == nullptr) { // No X visual for this fbconfig; how can we open the window? egldisplay_cat.error() << "No X visual: cannot open window.\n"; @@ -271,7 +271,7 @@ open_window() { return false; } - _egl_surface = eglCreateWindowSurface(_egl_display, eglgsg->_fbconfig, (NativeWindowType) _xwindow, NULL); + _egl_surface = eglCreateWindowSurface(_egl_display, eglgsg->_fbconfig, (NativeWindowType) _xwindow, nullptr); if (eglGetError() != EGL_SUCCESS) { egldisplay_cat.error() << "Failed to create window surface.\n"; diff --git a/panda/src/event/asyncTask.cxx b/panda/src/event/asyncTask.cxx index 95b4e5aad1..f5a796643c 100644 --- a/panda/src/event/asyncTask.cxx +++ b/panda/src/event/asyncTask.cxx @@ -34,8 +34,8 @@ AsyncTask(const string &name) : _sort(0), _priority(0), _state(S_inactive), - _servicing_thread(NULL), - _chain(NULL), + _servicing_thread(nullptr), + _chain(nullptr), _start_time(0.0), _start_frame(0), _dt(0.0), @@ -59,7 +59,7 @@ AsyncTask(const string &name) : */ AsyncTask:: ~AsyncTask() { - nassertv(_state == S_inactive && _manager == NULL && _chain == NULL); + nassertv(_state == S_inactive && _manager == nullptr && _chain == nullptr); } /** @@ -100,7 +100,7 @@ remove() { */ double AsyncTask:: get_wake_time() const { - if (_manager != (AsyncTaskManager *)NULL) { + if (_manager != nullptr) { MutexHolder holder(_manager->_lock); if (_state == S_sleeping) { return _wake_time; @@ -122,7 +122,7 @@ get_wake_time() const { */ void AsyncTask:: recalc_wake_time() { - if (_manager != (AsyncTaskManager *)NULL) { + if (_manager != nullptr) { MutexHolder holder(_manager->_lock); if (_state == S_sleeping) { double now = _manager->_clock->get_frame_time(); @@ -144,7 +144,7 @@ recalc_wake_time() { double AsyncTask:: get_elapsed_time() const { nassertr(_state != S_inactive, 0.0); - nassertr(_manager != (AsyncTaskManager *)NULL, 0.0); + nassertr(_manager != nullptr, 0.0); return _manager->_clock->get_frame_time() - _start_time; } @@ -157,7 +157,7 @@ get_elapsed_time() const { int AsyncTask:: get_elapsed_frames() const { nassertr(_state != S_inactive, 0); - nassertr(_manager != (AsyncTaskManager *)NULL, 0); + nassertr(_manager != nullptr, 0); return _manager->_clock->get_frame_count() - _start_frame; } @@ -166,7 +166,7 @@ get_elapsed_frames() const { */ void AsyncTask:: set_name(const string &name) { - if (_manager != (AsyncTaskManager *)NULL) { + if (_manager != nullptr) { MutexHolder holder(_manager->_lock); if (Namable::get_name() != name) { // Changing an active task's name requires moving it around on its name @@ -247,7 +247,7 @@ get_name_prefix() const { void AsyncTask:: set_task_chain(const string &chain_name) { if (chain_name != _chain_name) { - if (_manager != (AsyncTaskManager *)NULL) { + if (_manager != nullptr) { MutexHolder holder(_manager->_lock); if (_state == S_active) { // Changing chains on an "active" (i.e. enqueued) task means removing @@ -256,7 +256,7 @@ set_task_chain(const string &chain_name) { PT(AsyncTaskManager) manager = _manager; AsyncTaskChain *chain_a = manager->do_find_task_chain(_chain_name); - nassertv(chain_a != (AsyncTaskChain *)NULL); + nassertv(chain_a != nullptr); chain_a->do_remove(this); _chain_name = chain_name; @@ -290,14 +290,14 @@ set_task_chain(const string &chain_name) { void AsyncTask:: set_sort(int sort) { if (sort != _sort) { - if (_manager != (AsyncTaskManager *)NULL) { + if (_manager != nullptr) { MutexHolder holder(_manager->_lock); if (_state == S_active && _sort >= _chain->_current_sort) { // Changing sort on an "active" (i.e. enqueued) task means removing // it and re-inserting it into the queue. PT(AsyncTask) hold_task = this; AsyncTaskChain *chain = _manager->do_find_task_chain(_chain_name); - nassertv(chain != (AsyncTaskChain *)NULL); + nassertv(chain != nullptr); chain->do_remove(this); _sort = sort; chain->do_add(this); @@ -335,14 +335,14 @@ set_sort(int sort) { void AsyncTask:: set_priority(int priority) { if (priority != _priority) { - if (_manager != (AsyncTaskManager *)NULL) { + if (_manager != nullptr) { MutexHolder holder(_manager->_lock); if (_state == S_active && _sort >= _chain->_current_sort) { // Changing priority on an "active" (i.e. enqueued) task means // removing it and re-inserting it into the queue. PT(AsyncTask) hold_task = this; AsyncTaskChain *chain = _manager->do_find_task_chain(_chain_name); - nassertv(chain != (AsyncTaskChain *)NULL); + nassertv(chain != nullptr); chain->do_remove(this); _priority = priority; chain->do_add(this); @@ -378,7 +378,7 @@ output(ostream &out) const { void AsyncTask:: jump_to_task_chain(AsyncTaskManager *manager) { AsyncTaskChain *chain_b = manager->do_find_task_chain(_chain_name); - if (chain_b == (AsyncTaskChain *)NULL) { + if (chain_b == nullptr) { task_cat.warning() << "Creating implicit AsyncTaskChain " << _chain_name << " for " << manager->get_type() << " " @@ -540,7 +540,7 @@ upon_death(AsyncTaskManager *manager, bool clean_exit) { //NB. done_event is now being thrown in AsyncFuture::notify_done(). // Throw a generic remove event for the manager. - if (manager != (AsyncTaskManager *)NULL) { + if (manager != nullptr) { string remove_name = manager->get_name() + "-removeTask"; PT_Event event = new Event(remove_name); event->add_parameter(EventParameter(this)); diff --git a/panda/src/event/asyncTaskChain.cxx b/panda/src/event/asyncTaskChain.cxx index 1d131d62df..eb00a5b08d 100644 --- a/panda/src/event/asyncTaskChain.cxx +++ b/panda/src/event/asyncTaskChain.cxx @@ -404,8 +404,8 @@ write(ostream &out, int indent_level) const { */ void AsyncTaskChain:: do_add(AsyncTask *task) { - nassertv(task->_chain == NULL && - task->_manager == NULL && + nassertv(task->_chain == nullptr && + task->_manager == nullptr && task->_chain_name == get_name() && task->_state == AsyncTask::S_inactive); nassertv(!do_has_task(task)); @@ -652,7 +652,7 @@ service_one_task(AsyncTaskChain::AsyncTaskChainThread *thread) { pop_heap(_active.begin(), _active.end(), AsyncTaskSortPriority()); _active.pop_back(); - if (thread != (AsyncTaskChain::AsyncTaskChainThread *)NULL) { + if (thread != nullptr) { thread->_servicing = task; } @@ -669,10 +669,10 @@ service_one_task(AsyncTaskChain::AsyncTaskChainThread *thread) { AsyncTask::DoneStatus ds = task->unlock_and_do_task(); - if (thread != (AsyncTaskChain::AsyncTaskChainThread *)NULL) { - thread->_servicing = NULL; + if (thread != nullptr) { + thread->_servicing = nullptr; } - task->_servicing_thread = NULL; + task->_servicing_thread = nullptr; if (task->_chain == this) { if (task->_state == AsyncTask::S_servicing_removed) { @@ -1099,7 +1099,7 @@ do_get_active_tasks() const { Threads::const_iterator thi; for (thi = _threads.begin(); thi != _threads.end(); ++thi) { AsyncTask *task = (*thi)->_servicing; - if (task != (AsyncTask *)NULL) { + if (task != nullptr) { result.add_task(task); } } @@ -1188,7 +1188,7 @@ do_poll() { // in poll(). But it's possible, if someone calls set_num_threads() // while we're processing. _num_busy_threads++; - service_one_task(NULL); + service_one_task(nullptr); _num_busy_threads--; _cvar.notify_all(); @@ -1228,7 +1228,7 @@ cleanup_pickup_mode() { */ void AsyncTaskChain:: do_output(ostream &out) const { - if (_manager != (AsyncTaskManager *)NULL) { + if (_manager != nullptr) { out << _manager->get_type() << " " << _manager->get_name(); } else { out << "(no manager)"; @@ -1288,7 +1288,7 @@ do_write(ostream &out, int indent_level) const { Threads::const_iterator thi; for (thi = _threads.begin(); thi != _threads.end(); ++thi) { AsyncTask *task = (*thi)->_servicing; - if (task != (AsyncTask *)NULL) { + if (task != nullptr) { tasks.push_back(task); } } @@ -1379,7 +1379,7 @@ AsyncTaskChain::AsyncTaskChainThread:: AsyncTaskChainThread(const string &name, AsyncTaskChain *chain) : Thread(name, chain->get_name()), _chain(chain), - _servicing(NULL) + _servicing(nullptr) { } diff --git a/panda/src/event/asyncTaskCollection.cxx b/panda/src/event/asyncTaskCollection.cxx index 80999362e1..af5b1bc2f5 100644 --- a/panda/src/event/asyncTaskCollection.cxx +++ b/panda/src/event/asyncTaskCollection.cxx @@ -46,7 +46,7 @@ add_task(AsyncTask *task) { // If the pointer to our internal array is shared by any other // AsyncTaskCollections, we have to copy the array now so we won't // inadvertently modify any of our brethren AsyncTaskCollection objects. - nassertv(task != (AsyncTask *)NULL); + nassertv(task != nullptr); if (_tasks.get_ref_count() > 1) { AsyncTasks old_tasks = _tasks; @@ -182,7 +182,7 @@ find_task(const string &name) const { return task; } } - return NULL; + return nullptr; } /** diff --git a/panda/src/event/asyncTaskManager.I b/panda/src/event/asyncTaskManager.I index c1e5775a55..8cf788dc9e 100644 --- a/panda/src/event/asyncTaskManager.I +++ b/panda/src/event/asyncTaskManager.I @@ -48,7 +48,7 @@ get_num_tasks() const { */ INLINE AsyncTaskManager *AsyncTaskManager:: get_global_ptr() { - if (_global_ptr == (AsyncTaskManager *)NULL) { + if (_global_ptr == nullptr) { make_global_ptr(); } return _global_ptr; diff --git a/panda/src/event/asyncTaskManager.cxx b/panda/src/event/asyncTaskManager.cxx index c19c194e60..a9bab44898 100644 --- a/panda/src/event/asyncTaskManager.cxx +++ b/panda/src/event/asyncTaskManager.cxx @@ -22,7 +22,7 @@ #include "config_event.h" #include -AsyncTaskManager *AsyncTaskManager::_global_ptr = NULL; +AsyncTaskManager *AsyncTaskManager::_global_ptr = nullptr; TypeHandle AsyncTaskManager::_type_handle; @@ -114,7 +114,7 @@ get_num_task_chains() const { AsyncTaskChain *AsyncTaskManager:: get_task_chain(int n) const { MutexHolder holder(_lock); - nassertr(n >= 0 && n < (int)_task_chains.size(), NULL); + nassertr(n >= 0 && n < (int)_task_chains.size(), nullptr); return _task_chains[n]; } @@ -196,19 +196,19 @@ add(AsyncTask *task) { } } - nassertv(task->_manager == NULL && + nassertv(task->_manager == nullptr && task->_state == AsyncTask::S_inactive); nassertv(!do_has_task(task)); _lock.unlock(); task->upon_birth(this); _lock.lock(); - nassertv(task->_manager == NULL && + nassertv(task->_manager == nullptr && task->_state == AsyncTask::S_inactive); nassertv(!do_has_task(task)); AsyncTaskChain *chain = do_find_task_chain(task->_chain_name); - if (chain == (AsyncTaskChain *)NULL) { + if (chain == nullptr) { task_cat.warning() << "Creating implicit AsyncTaskChain " << task->_chain_name << " for " << get_type() << " " << get_name() << "\n"; @@ -257,7 +257,7 @@ find_task(const string &name) const { return (*tbni); } - return NULL; + return nullptr; } /** @@ -576,7 +576,7 @@ do_find_task_chain(const string &name) { return (*tci); } - return NULL; + return nullptr; } /** @@ -639,7 +639,7 @@ do_output(ostream &out) const { */ void AsyncTaskManager:: make_global_ptr() { - nassertv(_global_ptr == (AsyncTaskManager *)NULL); + nassertv(_global_ptr == nullptr); _global_ptr = new AsyncTaskManager("TaskManager"); _global_ptr->ref(); diff --git a/panda/src/event/asyncTaskSequence.cxx b/panda/src/event/asyncTaskSequence.cxx index fe306c26a3..b84a968386 100644 --- a/panda/src/event/asyncTaskSequence.cxx +++ b/panda/src/event/asyncTaskSequence.cxx @@ -32,7 +32,7 @@ AsyncTaskSequence(const string &name) : */ AsyncTaskSequence:: ~AsyncTaskSequence() { - set_current_task(NULL, true); + set_current_task(nullptr, true); } /** @@ -60,7 +60,7 @@ do_task() { if (_task_index >= get_num_tasks()) { // Ran off the end of the task list. - set_current_task(NULL, true); + set_current_task(nullptr, true); _task_index = 0; if (_task_index >= get_num_tasks()) { return DS_done; @@ -76,7 +76,7 @@ do_task() { AsyncTask *task = get_task(_task_index); set_current_task(task, true); - nassertr(_current_task != (AsyncTask *)NULL, DS_exit); + nassertr(_current_task != nullptr, DS_exit); DoneStatus result = _current_task->do_task(); switch (result) { @@ -127,7 +127,7 @@ void AsyncTaskSequence:: upon_birth(AsyncTaskManager *manager) { AsyncTask::upon_birth(manager); _task_index = 0; - set_current_task(NULL, true); + set_current_task(nullptr, true); } /** @@ -147,7 +147,7 @@ upon_birth(AsyncTaskManager *manager) { void AsyncTaskSequence:: upon_death(AsyncTaskManager *manager, bool clean_exit) { AsyncTask::upon_death(manager, clean_exit); - set_current_task(NULL, clean_exit); + set_current_task(nullptr, clean_exit); } /** @@ -159,22 +159,22 @@ set_current_task(AsyncTask *task, bool clean_exit) { return; } - if (_current_task != (AsyncTask *)NULL) { + if (_current_task != nullptr) { nassertv(_current_task->_state == S_active_nested); - nassertv(_current_task->_manager == _manager || _manager == NULL); + nassertv(_current_task->_manager == _manager || _manager == nullptr); _current_task->_state = S_inactive; - _current_task->_manager = NULL; + _current_task->_manager = nullptr; _current_task->upon_death(_manager, clean_exit); } _current_task = task; - if (_current_task != (AsyncTask *)NULL) { + if (_current_task != nullptr) { nassertv(_current_task->_state == S_inactive); - nassertv(_current_task->_manager == NULL); + nassertv(_current_task->_manager == nullptr); _current_task->upon_birth(_manager); nassertv(_current_task->_state == S_inactive); - nassertv(_current_task->_manager == NULL); + nassertv(_current_task->_manager == nullptr); _current_task->_manager = _manager; _current_task->_state = S_active_nested; diff --git a/panda/src/event/event.cxx b/panda/src/event/event.cxx index fb510626d2..4453b890f3 100644 --- a/panda/src/event/event.cxx +++ b/panda/src/event/event.cxx @@ -86,7 +86,7 @@ get_parameter(int n) const { */ bool Event:: has_receiver() const { - return _receiver != (EventReceiver *)NULL; + return _receiver != nullptr; } /** @@ -110,7 +110,7 @@ set_receiver(EventReceiver *receiver) { */ void Event:: clear_receiver() { - _receiver = (EventReceiver *)NULL; + _receiver = nullptr; } /** diff --git a/panda/src/event/event.h b/panda/src/event/event.h index e09c4c2500..383329e233 100644 --- a/panda/src/event/event.h +++ b/panda/src/event/event.h @@ -32,7 +32,7 @@ class EventReceiver; */ class EXPCL_PANDA_EVENT Event : public TypedReferenceCount { PUBLISHED: - Event(const string &event_name, EventReceiver *receiver = NULL); + Event(const string &event_name, EventReceiver *receiver = nullptr); Event(const Event ©); void operator = (const Event ©); ~Event(); diff --git a/panda/src/event/eventHandler.cxx b/panda/src/event/eventHandler.cxx index 020ba905d5..998946e92b 100644 --- a/panda/src/event/eventHandler.cxx +++ b/panda/src/event/eventHandler.cxx @@ -17,7 +17,7 @@ TypeHandle EventHandler::_type_handle; -EventHandler *EventHandler::_global_event_handler = NULL; +EventHandler *EventHandler::_global_event_handler = nullptr; /** @@ -64,7 +64,7 @@ process_events() { */ void EventHandler:: dispatch_event(const Event *event) { - nassertv(event != (Event *)NULL); + nassertv(event != nullptr); // Is the event name defined in the hook table? It will be if anyone has // ever assigned a hook to this particular event name. diff --git a/panda/src/event/eventHandler.h b/panda/src/event/eventHandler.h index 39d84475a4..cefba2710f 100644 --- a/panda/src/event/eventHandler.h +++ b/panda/src/event/eventHandler.h @@ -52,7 +52,7 @@ PUBLISHED: void write(ostream &out) const; - INLINE static EventHandler *get_global_event_handler(EventQueue *queue = NULL); + INLINE static EventHandler *get_global_event_handler(EventQueue *queue = nullptr); public: bool add_hook(const string &event_name, EventFunction *function); diff --git a/panda/src/event/eventParameter.I b/panda/src/event/eventParameter.I index 14727106e6..1aa1888017 100644 --- a/panda/src/event/eventParameter.I +++ b/panda/src/event/eventParameter.I @@ -93,7 +93,7 @@ INLINE EventParameter:: */ INLINE bool EventParameter:: is_empty() const { - return (_ptr == (TypedWritableReferenceCount *)NULL); + return (_ptr == nullptr); } /** @@ -205,7 +205,7 @@ is_typed_ref_count() const { */ INLINE TypedReferenceCount *EventParameter:: get_typed_ref_count_value() const { - nassertr(is_typed_ref_count(), NULL); + nassertr(is_typed_ref_count(), nullptr); return ((const EventStoreTypedRefCount *)_ptr.p())->get_value(); } diff --git a/panda/src/event/eventParameter.cxx b/panda/src/event/eventParameter.cxx index e5e55a1bac..40122908cd 100644 --- a/panda/src/event/eventParameter.cxx +++ b/panda/src/event/eventParameter.cxx @@ -22,7 +22,7 @@ template class ParamValue; */ void EventParameter:: output(ostream &out) const { - if (_ptr == (TypedWritableReferenceCount *)NULL) { + if (_ptr == nullptr) { out << "(empty)"; } else if (_ptr->is_of_type(ParamValueBase::get_class_type())) { diff --git a/panda/src/event/eventQueue.I b/panda/src/event/eventQueue.I index 7887696222..22b97a99d7 100644 --- a/panda/src/event/eventQueue.I +++ b/panda/src/event/eventQueue.I @@ -17,7 +17,7 @@ */ INLINE EventQueue *EventQueue:: get_global_event_queue() { - if (_global_event_queue == NULL) { + if (_global_event_queue == nullptr) { make_global_event_queue(); } return _global_event_queue; diff --git a/panda/src/event/eventQueue.cxx b/panda/src/event/eventQueue.cxx index fa423b0ca9..bbd07a3725 100644 --- a/panda/src/event/eventQueue.cxx +++ b/panda/src/event/eventQueue.cxx @@ -15,7 +15,7 @@ #include "config_event.h" #include "lightMutexHolder.h" -EventQueue *EventQueue::_global_event_queue = NULL; +EventQueue *EventQueue::_global_event_queue = nullptr; /** diff --git a/panda/src/event/genericAsyncTask.cxx b/panda/src/event/genericAsyncTask.cxx index 28cbebe55f..c0d68fa3ff 100644 --- a/panda/src/event/genericAsyncTask.cxx +++ b/panda/src/event/genericAsyncTask.cxx @@ -23,10 +23,10 @@ GenericAsyncTask:: GenericAsyncTask(const string &name) : AsyncTask(name) { - _function = NULL; - _upon_birth = NULL; - _upon_death = NULL; - _user_data = NULL; + _function = nullptr; + _upon_birth = nullptr; + _upon_death = nullptr; + _user_data = nullptr; } /** @@ -38,8 +38,8 @@ GenericAsyncTask(const string &name, GenericAsyncTask::TaskFunc *function, void _function(function), _user_data(user_data) { - _upon_birth = NULL; - _upon_death = NULL; + _upon_birth = nullptr; + _upon_death = nullptr; } /** @@ -51,7 +51,7 @@ GenericAsyncTask(const string &name, GenericAsyncTask::TaskFunc *function, void */ bool GenericAsyncTask:: is_runnable() { - return _function != NULL; + return _function != nullptr; } /** @@ -61,7 +61,7 @@ is_runnable() { */ AsyncTask::DoneStatus GenericAsyncTask:: do_task() { - nassertr(_function != NULL, DS_interrupt); + nassertr(_function != nullptr, DS_interrupt); return (*_function)(this, _user_data); } @@ -75,7 +75,7 @@ void GenericAsyncTask:: upon_birth(AsyncTaskManager *manager) { AsyncTask::upon_birth(manager); - if (_upon_birth != NULL) { + if (_upon_birth != nullptr) { (*_upon_birth)(this, _user_data); } } @@ -97,7 +97,7 @@ void GenericAsyncTask:: upon_death(AsyncTaskManager *manager, bool clean_exit) { AsyncTask::upon_death(manager, clean_exit); - if (_upon_death != NULL) { + if (_upon_death != nullptr) { (*_upon_death)(this, clean_exit, _user_data); } } diff --git a/panda/src/event/pythonTask.cxx b/panda/src/event/pythonTask.cxx index 6a818ad19c..8ffa0e0793 100644 --- a/panda/src/event/pythonTask.cxx +++ b/panda/src/event/pythonTask.cxx @@ -134,7 +134,7 @@ set_function(PyObject *function) { void PythonTask:: set_args(PyObject *args, bool append_task) { Py_XDECREF(_args); - _args = NULL; + _args = nullptr; if (args == Py_None) { // None means no arguments; create an empty tuple. @@ -145,7 +145,7 @@ set_args(PyObject *args, bool append_task) { } } - if (_args == NULL) { + if (_args == nullptr) { nassert_raise("Invalid args passed to PythonTask"); _args = PyTuple_New(0); } @@ -213,15 +213,15 @@ set_owner(PyObject *owner) { PyObject *add = PyObject_GetAttrString(owner, "_addTask"); PyObject *clear = PyObject_GetAttrString(owner, "_clearTask"); - if (add == NULL || !PyCallable_Check(add) || - clear == NULL || !PyCallable_Check(clear)) { + if (add == nullptr || !PyCallable_Check(add) || + clear == nullptr || !PyCallable_Check(clear)) { Dtool_Raise_TypeError("owner object should have _addTask and _clearTask methods"); return; } } #endif - if (_owner != NULL && _owner != Py_None && _state != S_inactive) { + if (_owner != nullptr && _owner != Py_None && _state != S_inactive) { unregister_from_owner(); } @@ -318,7 +318,7 @@ __setattr__(PyObject *self, PyObject *attr, PyObject *v) { */ int PythonTask:: __delattr__(PyObject *self, PyObject *attr) { - if (PyObject_GenericSetAttr(self, attr, NULL) == 0) { + if (PyObject_GenericSetAttr(self, attr, nullptr) == 0) { return 0; } @@ -360,7 +360,7 @@ __getattr__(PyObject *attr) const { PyObject *item = PyDict_GetItem(__dict__, attr); - if (item == NULL) { + if (item == nullptr) { // PyDict_GetItem does not raise an exception. #if PY_MAJOR_VERSION < 3 PyErr_Format(PyExc_AttributeError, @@ -371,7 +371,7 @@ __getattr__(PyObject *attr) const { "'PythonTask' object has no attribute '%U'", attr); #endif - return NULL; + return nullptr; } // PyDict_GetItem returns a borrowed reference. @@ -683,7 +683,7 @@ do_python_task() { switch (retval) { case DS_again: Py_XDECREF(_generator); - _generator = NULL; + _generator = nullptr; // Fall through. case DS_done: @@ -727,14 +727,14 @@ do_python_task() { ostringstream strm; #if PY_MAJOR_VERSION >= 3 PyObject *str = PyObject_ASCII(result); - if (str == NULL) { + if (str == nullptr) { str = PyUnicode_FromString(""); } strm << *this << " returned " << PyUnicode_AsUTF8(str); #else PyObject *str = PyObject_Repr(result); - if (str == NULL) { + if (str == nullptr) { str = PyString_FromString(""); } strm @@ -844,7 +844,7 @@ void PythonTask:: call_owner_method(const char *method_name) { if (_owner != Py_None) { PyObject *func = PyObject_GetAttrString(_owner, (char *)method_name); - if (func == (PyObject *)NULL) { + if (func == nullptr) { task_cat.error() << "Owner object added to " << *this << " has no method " << method_name << "().\n"; diff --git a/panda/src/express/compress_string.cxx b/panda/src/express/compress_string.cxx index 8a32947490..2959d5d1a6 100644 --- a/panda/src/express/compress_string.cxx +++ b/panda/src/express/compress_string.cxx @@ -73,14 +73,14 @@ compress_file(const Filename &source, const Filename &dest, int compression_leve source_filename.set_binary(); } istream *source_stream = vfs->open_read_file(source_filename, false); - if (source_stream == NULL) { + if (source_stream == nullptr) { express_cat.info() << "Couldn't open file " << source_filename << "\n"; return false; } Filename dest_filename = Filename::binary_filename(dest); ostream *dest_stream = vfs->open_write_file(dest_filename, false, true); - if (dest_stream == NULL) { + if (dest_stream == nullptr) { express_cat.info() << "Couldn't open file " << dest_filename << "\n"; vfs->close_read_file(source_stream); return false; @@ -106,7 +106,7 @@ decompress_file(const Filename &source, const Filename &dest) { Filename source_filename = Filename::binary_filename(source); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *source_stream = vfs->open_read_file(source_filename, false); - if (source_stream == NULL) { + if (source_stream == nullptr) { express_cat.info() << "Couldn't open file " << source_filename << "\n"; return false; } @@ -117,7 +117,7 @@ decompress_file(const Filename &source, const Filename &dest) { dest_filename.set_binary(); } ostream *dest_stream = vfs->open_write_file(dest_filename, false, true); - if (dest_stream == NULL) { + if (dest_stream == nullptr) { express_cat.info() << "Couldn't open file " << dest_filename << "\n"; vfs->close_read_file(source_stream); return false; diff --git a/panda/src/express/config_express.cxx b/panda/src/express/config_express.cxx index d86e300436..ee38f6cd69 100644 --- a/panda/src/express/config_express.cxx +++ b/panda/src/express/config_express.cxx @@ -150,9 +150,9 @@ init_libexpress() { bool get_use_high_res_clock() { - static ConfigVariableBool *use_high_res_clock = NULL; + static ConfigVariableBool *use_high_res_clock = nullptr; - if (use_high_res_clock == (ConfigVariableBool *)NULL) { + if (use_high_res_clock == nullptr) { use_high_res_clock = new ConfigVariableBool ("use-high-res-clock", true, PRC_DESC("Set this to false to avoid using the high-precision clock, even if " @@ -164,9 +164,9 @@ get_use_high_res_clock() { bool get_paranoid_clock() { - static ConfigVariableBool *paranoid_clock = NULL; + static ConfigVariableBool *paranoid_clock = nullptr; - if (paranoid_clock == (ConfigVariableBool *)NULL) { + if (paranoid_clock == nullptr) { paranoid_clock = new ConfigVariableBool ("paranoid-clock", false, PRC_DESC("Set this to true to double-check the results of the high-resolution " @@ -178,9 +178,9 @@ get_paranoid_clock() { bool get_verify_dcast() { - static ConfigVariableBool *verify_dcast = NULL; + static ConfigVariableBool *verify_dcast = nullptr; - if (verify_dcast == (ConfigVariableBool *)NULL) { + if (verify_dcast == nullptr) { verify_dcast = new ConfigVariableBool ("verify-dcast", true, PRC_DESC("Set this to true to verify that every attempted DCAST operation in " diff --git a/panda/src/express/datagram.I b/panda/src/express/datagram.I index cac87f1111..98f5fcea14 100644 --- a/panda/src/express/datagram.I +++ b/panda/src/express/datagram.I @@ -378,7 +378,7 @@ get_array() const { */ INLINE PTA_uchar Datagram:: modify_array() { - if (_data == (uchar *)NULL) { + if (_data == nullptr) { // Create a new array. _data = PTA_uchar::empty_array(0); @@ -420,7 +420,7 @@ operator == (const Datagram &other) const { if (_data == other._data) { return true; } - if (_data != (uchar *)NULL && other._data != (uchar *)NULL) { + if (_data != nullptr && other._data != nullptr) { return _data.v() == other._data.v(); } return false; @@ -444,7 +444,7 @@ operator < (const Datagram &other) const { return false; } - if (_data != (uchar *)NULL && other._data != (uchar *)NULL) { + if (_data != nullptr && other._data != nullptr) { // Different pointers, neither NULL. return _data.v() < other._data.v(); } diff --git a/panda/src/express/datagram.cxx b/panda/src/express/datagram.cxx index 1121953948..826a261f93 100644 --- a/panda/src/express/datagram.cxx +++ b/panda/src/express/datagram.cxx @@ -99,7 +99,7 @@ void Datagram:: pad_bytes(size_t size) { nassertv((int)size >= 0); - if (_data == (uchar *)NULL) { + if (_data == nullptr) { // Create a new array. _data = PTA_uchar::empty_array(0); @@ -129,7 +129,7 @@ void Datagram:: append_data(const void *data, size_t size) { nassertv((int)size >= 0); - if (_data == (uchar *)NULL) { + if (_data == nullptr) { // Create a new array. _data = PTA_uchar::empty_array(0); diff --git a/panda/src/express/datagramGenerator.cxx b/panda/src/express/datagramGenerator.cxx index a5e9f52bb8..08d792bd70 100644 --- a/panda/src/express/datagramGenerator.cxx +++ b/panda/src/express/datagramGenerator.cxx @@ -44,7 +44,7 @@ save_datagram(SubfileInfo &info) { const Filename &DatagramGenerator:: get_filename() { const FileReference *file = get_file(); - if (file != (FileReference *)NULL) { + if (file != nullptr) { return file->get_filename(); } static const Filename empty_filename; @@ -66,7 +66,7 @@ get_timestamp() const { */ const FileReference *DatagramGenerator:: get_file() { - return NULL; + return nullptr; } /** @@ -75,7 +75,7 @@ get_file() { */ VirtualFile *DatagramGenerator:: get_vfile() { - return NULL; + return nullptr; } /** diff --git a/panda/src/express/datagramIterator.I b/panda/src/express/datagramIterator.I index 42c25eeed4..33af92539f 100644 --- a/panda/src/express/datagramIterator.I +++ b/panda/src/express/datagramIterator.I @@ -16,7 +16,7 @@ */ INLINE DatagramIterator:: DatagramIterator() : - _datagram((Datagram *)NULL), + _datagram(nullptr), _current_index(0) { } @@ -54,7 +54,7 @@ get_bool() { */ INLINE int8_t DatagramIterator:: get_int8() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); // Avoid reading junk data off the end of the datagram: nassertr(_current_index < _datagram->get_length(), 0); // Get the Data: @@ -70,7 +70,7 @@ get_int8() { */ INLINE uint8_t DatagramIterator:: get_uint8() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); // Avoid reading junk data off the end of the datagram: nassertr(_current_index < _datagram->get_length(), 0); // Get the Data: @@ -86,7 +86,7 @@ get_uint8() { */ INLINE int16_t DatagramIterator:: get_int16() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); int16_t tempvar; @@ -105,7 +105,7 @@ get_int16() { */ INLINE int32_t DatagramIterator:: get_int32() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); int32_t tempvar; @@ -124,7 +124,7 @@ get_int32() { */ INLINE int64_t DatagramIterator:: get_int64() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); int64_t tempvar; @@ -143,7 +143,7 @@ get_int64() { */ INLINE uint16_t DatagramIterator:: get_uint16() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); uint16_t tempvar; @@ -162,7 +162,7 @@ get_uint16() { */ INLINE uint32_t DatagramIterator:: get_uint32() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); uint32_t tempvar; @@ -181,7 +181,7 @@ get_uint32() { */ INLINE uint64_t DatagramIterator:: get_uint64() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); uint64_t tempvar; @@ -200,7 +200,7 @@ get_uint64() { */ INLINE PN_float32 DatagramIterator:: get_float32() { - nassertr(_datagram != (const Datagram *)NULL, 0.0); + nassertr(_datagram != nullptr, 0.0); nassertr(_current_index < _datagram->get_length(), 0.0); PN_float32 tempvar; @@ -219,7 +219,7 @@ get_float32() { */ INLINE PN_float64 DatagramIterator:: get_float64() { - nassertr(_datagram != (const Datagram *)NULL, 0.0); + nassertr(_datagram != nullptr, 0.0); nassertr(_current_index < _datagram->get_length(), 0.0); PN_float64 tempvar; @@ -240,7 +240,7 @@ get_float64() { */ INLINE PN_stdfloat DatagramIterator:: get_stdfloat() { - nassertr(_datagram != (const Datagram *)NULL, 0.0); + nassertr(_datagram != nullptr, 0.0); if (_datagram->get_stdfloat_double()) { return (PN_stdfloat)get_float64(); } else { @@ -253,7 +253,7 @@ get_stdfloat() { */ INLINE int16_t DatagramIterator:: get_be_int16() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); int16_t tempvar; @@ -272,7 +272,7 @@ get_be_int16() { */ INLINE int32_t DatagramIterator:: get_be_int32() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); int32_t tempvar; @@ -291,7 +291,7 @@ get_be_int32() { */ INLINE int64_t DatagramIterator:: get_be_int64() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); int64_t tempvar; @@ -310,7 +310,7 @@ get_be_int64() { */ INLINE uint16_t DatagramIterator:: get_be_uint16() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); uint16_t tempvar; @@ -329,7 +329,7 @@ get_be_uint16() { */ INLINE uint32_t DatagramIterator:: get_be_uint32() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); uint32_t tempvar; @@ -348,7 +348,7 @@ get_be_uint32() { */ INLINE uint64_t DatagramIterator:: get_be_uint64() { - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index < _datagram->get_length(), 0); uint64_t tempvar; @@ -367,7 +367,7 @@ get_be_uint64() { */ INLINE PN_float32 DatagramIterator:: get_be_float32() { - nassertr(_datagram != (const Datagram *)NULL, 0.0); + nassertr(_datagram != nullptr, 0.0); nassertr(_current_index < _datagram->get_length(), 0.0); PN_float32 tempvar; @@ -386,7 +386,7 @@ get_be_float32() { */ INLINE PN_float64 DatagramIterator:: get_be_float64() { - nassertr(_datagram != (const Datagram *)NULL, 0.0); + nassertr(_datagram != nullptr, 0.0); nassertr(_current_index < _datagram->get_length(), 0.0); PN_float64 tempvar; @@ -405,7 +405,7 @@ get_be_float64() { */ INLINE void DatagramIterator:: skip_bytes(size_t size) { - nassertv(_datagram != (const Datagram *)NULL); + nassertv(_datagram != nullptr); nassertv((int)size >= 0); #ifndef NDEBUG if (_current_index + size > _datagram->get_length()) { @@ -424,7 +424,7 @@ skip_bytes(size_t size) { */ INLINE vector_uchar DatagramIterator:: get_remaining_bytes() const { - nassertr(_datagram != (const Datagram *)NULL, vector_uchar()); + nassertr(_datagram != nullptr, vector_uchar()); nassertr(_current_index <= _datagram->get_length(), vector_uchar()); const unsigned char *ptr = (const unsigned char *)_datagram->get_data(); diff --git a/panda/src/express/datagramIterator.cxx b/panda/src/express/datagramIterator.cxx index 880719f32b..4006ec1eea 100644 --- a/panda/src/express/datagramIterator.cxx +++ b/panda/src/express/datagramIterator.cxx @@ -24,7 +24,7 @@ get_string() { // First, get the length of the string uint16_t s_len = get_uint16(); - nassertr(_datagram != (const Datagram *)NULL, ""); + nassertr(_datagram != nullptr, ""); nassertr(_current_index + s_len <= _datagram->get_length(), ""); const char *ptr = (const char *)_datagram->get_data(); @@ -43,7 +43,7 @@ get_string32() { // First, get the length of the string uint32_t s_len = get_uint32(); - nassertr(_datagram != (const Datagram *)NULL, ""); + nassertr(_datagram != nullptr, ""); nassertr(_current_index + s_len <= _datagram->get_length(), ""); const char *ptr = (const char *)_datagram->get_data(); @@ -59,7 +59,7 @@ get_string32() { */ string DatagramIterator:: get_z_string() { - nassertr(_datagram != (const Datagram *)NULL, ""); + nassertr(_datagram != nullptr, ""); // First, determine the length of the string. const char *ptr = (const char *)_datagram->get_data(); @@ -82,7 +82,7 @@ get_z_string() { */ string DatagramIterator:: get_fixed_string(size_t size) { - nassertr(_datagram != (const Datagram *)NULL, ""); + nassertr(_datagram != nullptr, ""); nassertr(_current_index + size <= _datagram->get_length(), ""); const char *ptr = (const char *)_datagram->get_data(); @@ -102,7 +102,7 @@ get_wstring() { // First, get the length of the string uint32_t s_len = get_uint32(); - nassertr(_datagram != (const Datagram *)NULL, wstring()); + nassertr(_datagram != nullptr, wstring()); nassertr(_current_index + s_len * 2 <= _datagram->get_length(), wstring()); wstring result; @@ -122,7 +122,7 @@ get_wstring() { vector_uchar DatagramIterator:: extract_bytes(size_t size) { nassertr((int)size >= 0, vector_uchar()); - nassertr(_datagram != (const Datagram *)NULL, vector_uchar()); + nassertr(_datagram != nullptr, vector_uchar()); nassertr(_current_index + size <= _datagram->get_length(), vector_uchar()); const unsigned char *ptr = (const unsigned char *)_datagram->get_data(); @@ -142,7 +142,7 @@ extract_bytes(size_t size) { size_t DatagramIterator:: extract_bytes(unsigned char *into, size_t size) { nassertr((int)size >= 0, 0); - nassertr(_datagram != (const Datagram *)NULL, 0); + nassertr(_datagram != nullptr, 0); nassertr(_current_index + size <= _datagram->get_length(), 0); const char *ptr = (const char *)_datagram->get_data(); diff --git a/panda/src/express/datagramSink.cxx b/panda/src/express/datagramSink.cxx index 0941ce10fb..5b451d3bb2 100644 --- a/panda/src/express/datagramSink.cxx +++ b/panda/src/express/datagramSink.cxx @@ -56,7 +56,7 @@ copy_datagram(SubfileInfo &result, const SubfileInfo &source) { const Filename &DatagramSink:: get_filename() { const FileReference *file = get_file(); - if (file != (FileReference *)NULL) { + if (file != nullptr) { return file->get_filename(); } static const Filename empty_filename; @@ -69,7 +69,7 @@ get_filename() { */ const FileReference *DatagramSink:: get_file() { - return NULL; + return nullptr; } /** diff --git a/panda/src/express/dcast.cxx b/panda/src/express/dcast.cxx index fcb0e02baf..63265fec6f 100644 --- a/panda/src/express/dcast.cxx +++ b/panda/src/express/dcast.cxx @@ -30,7 +30,7 @@ bool _dcast_verify(TypeHandle want_handle, size_t want_size, const TypedObject *ptr) { if (get_verify_dcast()) { - if (ptr == (const TypedObject *)NULL) { + if (ptr == nullptr) { // This is allowed these days. It used to be an error, but what the // heck. return true; diff --git a/panda/src/express/dcast.h b/panda/src/express/dcast.h index 4ab30bae3d..32ea9e4238 100644 --- a/panda/src/express/dcast.h +++ b/panda/src/express/dcast.h @@ -72,13 +72,13 @@ _dcast_verify(TypeHandle want_handle, size_t want_size, #define DCAST_INTO_V(to_pointer, from_pointer) \ { \ (to_pointer) = _dcast_ref(to_pointer, from_pointer); \ - nassertv((void *)(to_pointer) != (void *)NULL); \ + nassertv((void *)(to_pointer) != nullptr); \ } #define DCAST_INTO_R(to_pointer, from_pointer, return_value) \ { \ (to_pointer) = _dcast_ref(to_pointer, from_pointer); \ - nassertr((void *)(to_pointer) != (void *)NULL, return_value); \ + nassertr((void *)(to_pointer) != nullptr, return_value); \ } #include "dcast.T" diff --git a/panda/src/express/encrypt_string.cxx b/panda/src/express/encrypt_string.cxx index 0736e30be6..db72921aa8 100644 --- a/panda/src/express/encrypt_string.cxx +++ b/panda/src/express/encrypt_string.cxx @@ -85,14 +85,14 @@ encrypt_file(const Filename &source, const Filename &dest, const string &passwor source_filename.set_binary(); } istream *source_stream = vfs->open_read_file(source_filename, true); - if (source_stream == NULL) { + if (source_stream == nullptr) { express_cat.info() << "Couldn't open file " << source_filename << "\n"; return false; } Filename dest_filename = Filename::binary_filename(dest); ostream *dest_stream = vfs->open_write_file(dest_filename, true, true); - if (dest_stream == NULL) { + if (dest_stream == nullptr) { express_cat.info() << "Couldn't open file " << dest_filename << "\n"; vfs->close_read_file(source_stream); return false; @@ -120,7 +120,7 @@ decrypt_file(const Filename &source, const Filename &dest, const string &passwor Filename source_filename = Filename::binary_filename(source); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *source_stream = vfs->open_read_file(source_filename, false); - if (source_stream == NULL) { + if (source_stream == nullptr) { express_cat.info() << "Couldn't open file " << source_filename << "\n"; return false; } @@ -131,7 +131,7 @@ decrypt_file(const Filename &source, const Filename &dest, const string &passwor dest_filename.set_binary(); } ostream *dest_stream = vfs->open_write_file(dest_filename, true, true); - if (dest_stream == NULL) { + if (dest_stream == nullptr) { express_cat.info() << "Couldn't open file " << dest_filename << "\n"; vfs->close_read_file(source_stream); return false; diff --git a/panda/src/express/hashVal.cxx b/panda/src/express/hashVal.cxx index 02065e1a5b..797ead2ed2 100644 --- a/panda/src/express/hashVal.cxx +++ b/panda/src/express/hashVal.cxx @@ -174,7 +174,7 @@ hash_file(const Filename &filename) { Filename bin_filename = Filename::binary_filename(filename); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *istr = vfs->open_read_file(bin_filename, false); - if (istr == (istream *)NULL) { + if (istr == nullptr) { (*this) = HashVal(); return false; } diff --git a/panda/src/express/make_ca_bundle.cxx b/panda/src/express/make_ca_bundle.cxx index bc57eb97d8..a619a0a9f1 100644 --- a/panda/src/express/make_ca_bundle.cxx +++ b/panda/src/express/make_ca_bundle.cxx @@ -21,7 +21,7 @@ static const char *target_filename = "ca_bundle_data_src.c"; int main(int argc, char *argv[]) { FILE *fin = fopen(source_filename, "r"); - if (fin == NULL) { + if (fin == nullptr) { cerr << "Couldn't open " << source_filename << " for reading.\n"; return 1; } @@ -33,7 +33,7 @@ main(int argc, char *argv[]) { // function, or it will get confused. ERR_clear_error(); STACK_OF(X509_INFO) *inf; - inf = PEM_X509_INFO_read(fin, NULL, NULL, NULL); + inf = PEM_X509_INFO_read(fin, nullptr, nullptr, nullptr); if (!inf) { // Could not scan certificates. @@ -55,7 +55,7 @@ main(int argc, char *argv[]) { if (itmp->x509) { X509 *cert = itmp->x509; - int der_len = i2d_X509(cert, NULL); + int der_len = i2d_X509(cert, nullptr); unsigned char *der_buf = new unsigned char[der_len]; unsigned char *p = der_buf; i2d_X509(cert, &p); diff --git a/panda/src/express/memoryInfo.I b/panda/src/express/memoryInfo.I index 4fb25b34ca..2e1a0ba9ac 100644 --- a/panda/src/express/memoryInfo.I +++ b/panda/src/express/memoryInfo.I @@ -16,13 +16,13 @@ * NULL. */ void *MemoryInfo::get_void_ptr() const { - if (_void_ptr != (void *)NULL) { + if (_void_ptr != nullptr) { return _void_ptr; } - if (_ref_ptr == (void *)NULL) { + if (_ref_ptr == nullptr) { return _typed_ptr; } - if (_typed_ptr == (void *)NULL) { + if (_typed_ptr == nullptr) { return _ref_ptr; } return ((void *)_ref_ptr < (void *)_typed_ptr) ? (void *)_ref_ptr : (void *)_typed_ptr; diff --git a/panda/src/express/memoryInfo.cxx b/panda/src/express/memoryInfo.cxx index d12b7313a0..b753caa043 100644 --- a/panda/src/express/memoryInfo.cxx +++ b/panda/src/express/memoryInfo.cxx @@ -23,9 +23,9 @@ */ MemoryInfo:: MemoryInfo() { - _void_ptr = (void *)NULL; - _ref_ptr = (ReferenceCount *)NULL; - _typed_ptr = (TypedObject *)NULL; + _void_ptr = nullptr; + _ref_ptr = nullptr; + _typed_ptr = nullptr; _size = 0; _static_type = TypeHandle::none(); _dynamic_type = TypeHandle::none(); @@ -79,7 +79,7 @@ determine_dynamic_type() { _static_type != TypeHandle::none()) { // See if we know enough now to infer the dynamic type from the pointer. - if (_typed_ptr == (TypedObject *)NULL) { + if (_typed_ptr == nullptr) { // If our static type is known to inherit from TypedReferenceCount, then // we can directly downcast to get the TypedObject pointer. if (_static_type.is_derived_from(TypedReferenceCount::get_class_type())) { @@ -87,7 +87,7 @@ determine_dynamic_type() { } } - if (_typed_ptr != (TypedObject *)NULL) { + if (_typed_ptr != nullptr) { // If we have a TypedObject pointer, we can determine the type. This // might still not return the exact type, particularly if we are being // called within the destructor or constructor of this object. diff --git a/panda/src/express/memoryUsage.cxx b/panda/src/express/memoryUsage.cxx index 178de476fa..d38ac0c77e 100644 --- a/panda/src/express/memoryUsage.cxx +++ b/panda/src/express/memoryUsage.cxx @@ -387,7 +387,7 @@ mark_pointer(void *ptr, size_t size, ReferenceCount *ref_ptr) { // We're recording this pointer as now in use. ns_record_void_pointer(ptr, size); - if (ref_ptr != (ReferenceCount *)NULL) { + if (ref_ptr != nullptr) { // Make the pointer typed. This is particularly necessary in case the // ref_ptr is a different value than the base void pointer; this may be // our only opportunity to associate the two pointers. @@ -599,7 +599,7 @@ ns_record_pointer(ReferenceCount *ptr) { // We might already have a ReferenceCount pointer, thanks to a previous // call to mark_pointer(). - nassertv(info->_ref_ptr == NULL || info->_ref_ptr == ptr); + nassertv(info->_ref_ptr == nullptr || info->_ref_ptr == ptr); info->_ref_ptr = ptr; info->_static_type = ReferenceCount::get_class_type(); @@ -765,7 +765,7 @@ ns_remove_pointer(ReferenceCount *ptr) { MemoryInfo *info = (*ti).second; - if (info->_ref_ptr == NULL) { + if (info->_ref_ptr == nullptr) { express_cat.error() << "Pointer " << (void *)ptr << " deleted twice!\n"; return; @@ -777,8 +777,8 @@ ns_remove_pointer(ReferenceCount *ptr) { << "Removing ReferenceCount pointer " << (void *)ptr << "\n"; } - info->_ref_ptr = (ReferenceCount *)NULL; - info->_typed_ptr = (TypedObject *)NULL; + info->_ref_ptr = nullptr; + info->_typed_ptr = nullptr; if (info->_freeze_index == _freeze_index) { double now = TrueClock::get_global_ptr()->get_long_time(); @@ -791,7 +791,7 @@ ns_remove_pointer(ReferenceCount *ptr) { _recursion_protect = false; } - if (ptr != info->_void_ptr || info->_void_ptr == NULL) { + if (ptr != info->_void_ptr || info->_void_ptr == nullptr) { // Remove the entry from the table. // We have to protect modifications to the table from recursive calls by @@ -800,7 +800,7 @@ ns_remove_pointer(ReferenceCount *ptr) { _table.erase(ti); _recursion_protect = false; - if (info->_void_ptr == NULL) { + if (info->_void_ptr == nullptr) { // That was the last entry. Remove it altogether. _total_cpp_size -= info->_size; if (info->_freeze_index == _freeze_index) { @@ -847,7 +847,7 @@ ns_record_void_pointer(void *ptr, size_t size) { MemoryInfo *info = (*insert_result.first).second; // We shouldn't already have a void pointer. - if (info->_void_ptr != (void *)NULL) { + if (info->_void_ptr != nullptr) { express_cat.error() << "Void pointer " << (void *)ptr << " recorded twice!\n"; nassertv(false); @@ -900,14 +900,14 @@ ns_remove_void_pointer(void *ptr) { MemoryInfo *info = (*ti).second; - if (info->_void_ptr == (void *)NULL) { + if (info->_void_ptr == nullptr) { express_cat.error() << "Pointer " << (void *)ptr << " deleted twice!\n"; return; } nassertv(info->_void_ptr == ptr); - if (info->_ref_ptr != (ReferenceCount *)NULL) { + if (info->_ref_ptr != nullptr) { express_cat.error() << "Pointer " << (void *)ptr << " did not destruct before being deleted!\n"; @@ -916,7 +916,7 @@ ns_remove_void_pointer(void *ptr) { } } - info->_void_ptr = NULL; + info->_void_ptr = nullptr; // Remove it from the table. @@ -970,7 +970,7 @@ ns_get_pointers(MemoryUsagePointers &result) { for (si = _info_set.begin(); si != _info_set.end(); ++si) { MemoryInfo *info = (*si); if (info->_freeze_index == _freeze_index && - info->_ref_ptr != (ReferenceCount *)NULL) { + info->_ref_ptr != nullptr) { result.add_entry(info->_ref_ptr, info->_typed_ptr, info->get_type(), now - info->_time); } @@ -997,7 +997,7 @@ ns_get_pointers_of_type(MemoryUsagePointers &result, TypeHandle type) { for (si = _info_set.begin(); si != _info_set.end(); ++si) { MemoryInfo *info = (*si); if (info->_freeze_index == _freeze_index && - info->_ref_ptr != (ReferenceCount *)NULL) { + info->_ref_ptr != nullptr) { TypeHandle info_type = info->get_type(); if (info_type != TypeHandle::none() && info_type.is_derived_from(type)) { @@ -1029,7 +1029,7 @@ ns_get_pointers_of_age(MemoryUsagePointers &result, for (si = _info_set.begin(); si != _info_set.end(); ++si) { MemoryInfo *info = (*si); if (info->_freeze_index == _freeze_index && - info->_ref_ptr != (ReferenceCount *)NULL) { + info->_ref_ptr != nullptr) { double age = now - info->_time; if ((age >= from && age <= to) || (age >= to && age <= from)) { @@ -1071,7 +1071,7 @@ ns_get_pointers_with_zero_count(MemoryUsagePointers &result) { for (si = _info_set.begin(); si != _info_set.end(); ++si) { MemoryInfo *info = (*si); if (info->_freeze_index == _freeze_index && - info->_ref_ptr != (ReferenceCount *)NULL) { + info->_ref_ptr != nullptr) { if (info->_ref_ptr->get_ref_count() == 0) { info->_ref_ptr->ref(); result.add_entry(info->_ref_ptr, info->_typed_ptr, info->get_type(), @@ -1185,7 +1185,7 @@ consolidate_void_ptr(MemoryInfo *info) { return; } - if (info->_typed_ptr == (TypedObject *)NULL) { + if (info->_typed_ptr == nullptr) { // We don't have a typed pointer for this thing yet. return; } @@ -1199,7 +1199,7 @@ consolidate_void_ptr(MemoryInfo *info) { return; } - nassertv(info->_void_ptr == NULL); + nassertv(info->_void_ptr == nullptr); Table::iterator ti; ti = _table.find(typed_ptr); @@ -1212,7 +1212,7 @@ consolidate_void_ptr(MemoryInfo *info) { MemoryInfo *typed_info = (*ti).second; nassertv(typed_info->_void_ptr == typed_ptr && - typed_info->_ref_ptr == NULL); + typed_info->_ref_ptr == nullptr); info->_void_ptr = typed_info->_void_ptr; if (typed_info->is_size_known()) { diff --git a/panda/src/express/memoryUsagePointers_ext.cxx b/panda/src/express/memoryUsagePointers_ext.cxx index c1013027ab..27376b9cad 100644 --- a/panda/src/express/memoryUsagePointers_ext.cxx +++ b/panda/src/express/memoryUsagePointers_ext.cxx @@ -36,18 +36,18 @@ get_python_pointer(size_t n) const { ReferenceCount *ref_ptr = _this->get_pointer(n); bool memory_rules = false; - if (ref_ptr != (ReferenceCount *)NULL) { + if (ref_ptr != nullptr) { memory_rules = true; ref_ptr->ref(); } - if (typed_ptr != (TypedObject *)NULL) { + if (typed_ptr != nullptr) { return DTool_CreatePyInstanceTyped(typed_ptr, Dtool_TypedObject, memory_rules, false, typed_ptr->get_type_index()); } - if (ref_ptr == (ReferenceCount *)NULL) { + if (ref_ptr == nullptr) { return Py_BuildValue(""); } diff --git a/panda/src/express/multifile.I b/panda/src/express/multifile.I index a498534726..aa10b223f1 100644 --- a/panda/src/express/multifile.I +++ b/panda/src/express/multifile.I @@ -35,7 +35,7 @@ set_multifile_name(const Filename &multifile_name) { */ INLINE bool Multifile:: is_read_valid() const { - return (_read != (IStreamWrapper *)NULL); + return (_read != nullptr); } /** @@ -44,7 +44,7 @@ is_read_valid() const { */ INLINE bool Multifile:: is_write_valid() const { - return (_write != (ostream *)NULL && !_write->fail()); + return (_write != nullptr && !_write->fail()); } /** @@ -354,11 +354,11 @@ Subfile() { _data_start = 0; _data_length = 0; _timestamp = 0; - _source = (istream *)NULL; + _source = nullptr; _flags = 0; _compression_level = 0; #ifdef HAVE_OPENSSL - _pkey = NULL; + _pkey = nullptr; #endif } diff --git a/panda/src/express/multifile.cxx b/panda/src/express/multifile.cxx index 2ae60892d4..937bfa8435 100644 --- a/panda/src/express/multifile.cxx +++ b/panda/src/express/multifile.cxx @@ -102,8 +102,8 @@ Multifile() : "be loaded quickly, without paying the cost of an expensive hash on " "each subfile in order to decrypt it.")); - _read = (IStreamWrapper *)NULL; - _write = (ostream *)NULL; + _read = nullptr; + _write = nullptr; _offset = 0; _owns_stream = false; _next_index = 0; @@ -152,11 +152,11 @@ open_read(const Filename &multifile_name, const streampos &offset) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); PT(VirtualFile) vfile = vfs->get_file(fname); - if (vfile == NULL) { + if (vfile == nullptr) { return false; } istream *multifile_stream = vfile->open_read_file(false); - if (multifile_stream == NULL) { + if (multifile_stream == nullptr) { return false; } @@ -181,7 +181,7 @@ bool Multifile:: open_read(IStreamWrapper *multifile_stream, bool owns_pointer, const streampos &offset) { close(); - _timestamp = time(NULL); + _timestamp = time(nullptr); _timestamp_dirty = true; _read = multifile_stream; _owns_stream = owns_pointer; @@ -206,7 +206,7 @@ open_write(const Filename &multifile_name) { if (!fname.open_write(_write_file, true)) { return false; } - _timestamp = time(NULL); + _timestamp = time(nullptr); _timestamp_dirty = true; _write = &_write_file; _multifile_name = multifile_name; @@ -224,7 +224,7 @@ open_write(const Filename &multifile_name) { bool Multifile:: open_write(ostream *multifile_stream, bool owns_pointer) { close(); - _timestamp = time(NULL); + _timestamp = time(nullptr); _timestamp_dirty = true; _write = multifile_stream; _owns_stream = owns_pointer; @@ -253,7 +253,7 @@ open_read_write(const Filename &multifile_name) { if (exists) { _timestamp = fname.get_timestamp(); } else { - _timestamp = time(NULL); + _timestamp = time(nullptr); } _timestamp_dirty = true; _read = &_read_write_filew; @@ -279,7 +279,7 @@ open_read_write(const Filename &multifile_name) { bool Multifile:: open_read_write(iostream *multifile_stream, bool owns_pointer) { close(); - _timestamp = time(NULL); + _timestamp = time(nullptr); _timestamp_dirty = true; // We don't support locking when opening a file in read-write mode, because @@ -319,15 +319,15 @@ close() { if (_owns_stream) { // We prefer to delete the IStreamWrapper over the ostream, if possible. - if (_read != (IStreamWrapper *)NULL) { + if (_read != nullptr) { delete _read; - } else if (_write != (ostream *)NULL) { + } else if (_write != nullptr) { delete _write; } } - _read = (IStreamWrapper *)NULL; - _write = (ostream *)NULL; + _read = nullptr; + _write = nullptr; _offset = 0; _owns_stream = false; _next_index = 0; @@ -424,7 +424,7 @@ add_subfile(const string &subfile_name, const Filename &filename, add_new_subfile(subfile, compression_level); } - _timestamp = time(NULL); + _timestamp = time(nullptr); _timestamp_dirty = true; return name; @@ -509,7 +509,7 @@ update_subfile(const string &subfile_name, const Filename &filename, add_new_subfile(subfile, compression_level); } - _timestamp = time(NULL); + _timestamp = time(nullptr); _timestamp_dirty = true; return name; @@ -603,9 +603,9 @@ add_signature(const Filename &certificate, const Filename &chain, // Create an in-memory BIO to read the "file" from the buffer. BIO *certificate_mbio = BIO_new_mem_buf((void *)certificate_data.data(), certificate_data.size()); - X509 *x509 = PEM_read_bio_X509(certificate_mbio, NULL, NULL, (void *)""); + X509 *x509 = PEM_read_bio_X509(certificate_mbio, nullptr, nullptr, (void *)""); BIO_free(certificate_mbio); - if (x509 == NULL) { + if (x509 == nullptr) { express_cat.info() << "Could not read certificate in " << certificate << ".\n"; return false; @@ -625,10 +625,10 @@ add_signature(const Filename &certificate, const Filename &chain, } BIO *chain_mbio = BIO_new_mem_buf((void *)chain_data.data(), chain_data.size()); - X509 *c = PEM_read_bio_X509(chain_mbio, NULL, NULL, (void *)""); - while (c != NULL) { + X509 *c = PEM_read_bio_X509(chain_mbio, nullptr, nullptr, (void *)""); + while (c != nullptr) { cert_chain.push_back(c); - c = PEM_read_bio_X509(chain_mbio, NULL, NULL, (void *)""); + c = PEM_read_bio_X509(chain_mbio, nullptr, nullptr, (void *)""); } BIO_free(chain_mbio); @@ -649,10 +649,10 @@ add_signature(const Filename &certificate, const Filename &chain, } BIO *pkey_mbio = BIO_new_mem_buf((void *)pkey_data.data(), pkey_data.size()); - EVP_PKEY *evp_pkey = PEM_read_bio_PrivateKey(pkey_mbio, NULL, NULL, + EVP_PKEY *evp_pkey = PEM_read_bio_PrivateKey(pkey_mbio, nullptr, nullptr, (void *)password.c_str()); BIO_free(pkey_mbio); - if (evp_pkey == NULL) { + if (evp_pkey == nullptr) { express_cat.info() << "Could not read private key in " << pkey << ".\n"; return false; @@ -694,10 +694,10 @@ add_signature(const Filename &composite, const string &password) { // Get the private key. BIO *pkey_mbio = BIO_new_mem_buf((void *)composite_data.data(), composite_data.size()); - EVP_PKEY *evp_pkey = PEM_read_bio_PrivateKey(pkey_mbio, NULL, NULL, + EVP_PKEY *evp_pkey = PEM_read_bio_PrivateKey(pkey_mbio, nullptr, nullptr, (void *)password.c_str()); BIO_free(pkey_mbio); - if (evp_pkey == NULL) { + if (evp_pkey == nullptr) { express_cat.info() << "Could not read private key in " << composite << ".\n"; return false; @@ -707,10 +707,10 @@ add_signature(const Filename &composite, const string &password) { CertChain cert_chain; BIO *chain_mbio = BIO_new_mem_buf((void *)composite_data.data(), composite_data.size()); - X509 *c = PEM_read_bio_X509(chain_mbio, NULL, NULL, (void *)""); - while (c != NULL) { + X509 *c = PEM_read_bio_X509(chain_mbio, nullptr, nullptr, (void *)""); + while (c != nullptr) { cert_chain.push_back(c); - c = PEM_read_bio_X509(chain_mbio, NULL, NULL, (void *)""); + c = PEM_read_bio_X509(chain_mbio, nullptr, nullptr, (void *)""); } BIO_free(chain_mbio); @@ -791,7 +791,7 @@ add_signature(const Multifile::CertChain &cert_chain, EVP_PKEY *pkey) { return false; } - if (pkey == NULL) { + if (pkey == nullptr) { express_cat.info() << "No private key given.\n"; return false; @@ -812,7 +812,7 @@ add_signature(const Multifile::CertChain &cert_chain, EVP_PKEY *pkey) { for (ci = cert_chain.begin(); ci != cert_chain.end(); ++ci) { X509 *cert = (*ci)._cert; - int der_len = i2d_X509(cert, NULL); + int der_len = i2d_X509(cert, nullptr); unsigned char *der_buf = new unsigned char[der_len]; unsigned char *p = der_buf; i2d_X509(cert, &p); @@ -886,7 +886,7 @@ get_signature_subject_name(int n) const { nassertr(!cert_chain.empty(), string()); X509_NAME *xname = X509_get_subject_name(cert_chain[0]._cert); - if (xname != NULL) { + if (xname != nullptr) { // We use "print" to dump the output to a memory BIO. Is there an easier // way to extract the X509_NAME text? Curse these incomplete docs. BIO *mbio = BIO_new(BIO_s_mem()); @@ -930,15 +930,15 @@ get_signature_friendly_name(int n) const { // A complex OpenSSL interface to extract out the name in utf-8. X509_NAME *xname = X509_get_subject_name(cert_chain[0]._cert); - if (xname != NULL) { + if (xname != nullptr) { int pos = X509_NAME_get_index_by_NID(xname, nid, -1); if (pos != -1) { // We just get the first common name. I guess it's possible to have // more than one; not sure what that means in this context. X509_NAME_ENTRY *xentry = X509_NAME_get_entry(xname, pos); - if (xentry != NULL) { + if (xentry != nullptr) { ASN1_STRING *data = X509_NAME_ENTRY_get_data(xentry); - if (data != NULL) { + if (data != nullptr) { // We use "print" to dump the output to a memory BIO. Is there an // easier way to decode the ASN1_STRING? Curse these incomplete // docs. @@ -976,8 +976,8 @@ get_signature_public_key(int n) const { nassertr(!cert_chain.empty(), string()); EVP_PKEY *pkey = X509_get_pubkey(cert_chain[0]._cert); - if (pkey != NULL) { - int key_len = i2d_PublicKey(pkey, NULL); + if (pkey != nullptr) { + int key_len = i2d_PublicKey(pkey, nullptr); unsigned char *key_buf = new unsigned char[key_len]; unsigned char *p = key_buf; i2d_PublicKey(pkey, &p); @@ -1059,9 +1059,9 @@ validate_signature_certificate(int n) const { // Copy our CertChain structure into an X509 pointer and accompanying // STACK_OF(X509) pointer. X509 *x509 = chain[0]._cert; - STACK_OF(X509) *stack = NULL; + STACK_OF(X509) *stack = nullptr; if (chain.size() > 1) { - stack = sk_X509_new(NULL); + stack = sk_X509_new(nullptr); for (size_t n = 1; n < chain.size(); ++n) { sk_X509_push(stack, chain[n]._cert); } @@ -1129,7 +1129,7 @@ flush() { } } - nassertr(_write != (ostream *)NULL, false); + nassertr(_write != nullptr, false); // First, mark out all of the removed subfiles. PendingSubfiles::iterator pi; @@ -1188,14 +1188,14 @@ flush() { for (pi = _new_subfiles.begin(); pi != _new_subfiles.end(); ++pi) { Subfile *subfile = (*pi); - if (_read != (IStreamWrapper *)NULL) { + if (_read != nullptr) { _read->acquire(); _next_index = subfile->write_data(*_write, _read->get_istream(), _next_index, this); _read->release(); } else { - _next_index = subfile->write_data(*_write, NULL, _next_index, this); + _next_index = subfile->write_data(*_write, nullptr, _next_index, this); } nassertr(_next_index == _write->tellp(), false); @@ -1448,7 +1448,7 @@ remove_subfile(int index) { _removed_subfiles.push_back(subfile); _subfiles.erase(_subfiles.begin() + index); - _timestamp = time(NULL); + _timestamp = time(nullptr); _timestamp_dirty = true; _needs_repack = true; @@ -1585,18 +1585,18 @@ get_subfile_internal_length(int index) const { */ istream *Multifile:: open_read_subfile(int index) { - nassertr(is_read_valid(), NULL); - nassertr(index >= 0 && index < (int)_subfiles.size(), NULL); + nassertr(is_read_valid(), nullptr); + nassertr(index >= 0 && index < (int)_subfiles.size(), nullptr); Subfile *subfile = _subfiles[index]; - if (subfile->_source != (istream *)NULL || + if (subfile->_source != nullptr || !subfile->_source_filename.empty()) { // The subfile has not yet been copied into the physical Multifile. Force // a flush operation to incorporate it. flush(); // That shouldn't change the subfile index or delete the subfile pointer. - nassertr(subfile == _subfiles[index], NULL); + nassertr(subfile == _subfiles[index], nullptr); } return open_read_subfile(subfile); @@ -1610,7 +1610,7 @@ open_read_subfile(int index) { */ void Multifile:: close_read_subfile(istream *stream) { - if (stream != (istream *)NULL) { + if (stream != nullptr) { // For some reason--compiler bug in gcc 3.2?--explicitly deleting the // stream pointer does not call the appropriate global delete function; // instead apparently calling the system delete function. So we call the @@ -1666,7 +1666,7 @@ extract_subfile_to(int index, ostream &out) { nassertr(index >= 0 && index < (int)_subfiles.size(), false); istream *in = open_read_subfile(index); - if (in == (istream *)NULL) { + if (in == nullptr) { return false; } @@ -1741,7 +1741,7 @@ compare_subfile(int index, const Filename &filename) { } istream *in1 = open_read_subfile(index); - if (in1 == (istream *)NULL) { + if (in1 == nullptr) { return false; } @@ -1889,7 +1889,7 @@ read_subfile(int index, pvector &result) { nassertr(index >= 0 && index < (int)_subfiles.size(), false); Subfile *subfile = _subfiles[index]; - if (subfile->_source != (istream *)NULL || + if (subfile->_source != nullptr || !subfile->_source_filename.empty()) { // The subfile has not yet been copied into the physical Multifile. Force // a flush operation to incorporate it. @@ -1906,7 +1906,7 @@ read_subfile(int index, pvector &result) { // If the subfile is encrypted or compressed, we can't read it directly. // Fall back to the generic implementation. istream *in = open_read_subfile(index); - if (in == (istream *)NULL) { + if (in == nullptr) { return false; } @@ -1958,7 +1958,7 @@ read_subfile(int index, pvector &result) { */ streampos Multifile:: pad_to_streampos(streampos fpos) { - nassertr(_write != (ostream *)NULL, fpos); + nassertr(_write != nullptr, fpos); nassertr(_write->tellp() == fpos, fpos); streampos new_fpos = normalize_streampos(fpos); while (fpos < new_fpos) { @@ -2029,12 +2029,12 @@ add_new_subfile(Subfile *subfile, int compression_level) { */ istream *Multifile:: open_read_subfile(Subfile *subfile) { - nassertr(subfile->_source == (istream *)NULL && - subfile->_source_filename.empty(), NULL); + nassertr(subfile->_source == nullptr && + subfile->_source_filename.empty(), nullptr); // Return an ISubStream object that references into the open Multifile // istream. - nassertr(subfile->_data_start != (streampos)0, NULL); + nassertr(subfile->_data_start != (streampos)0, nullptr); istream *stream = new ISubStream(_read, _offset + subfile->_data_start, _offset + subfile->_data_start + (streampos)subfile->_data_length); @@ -2044,7 +2044,7 @@ open_read_subfile(Subfile *subfile) { express_cat.error() << "OpenSSL not compiled in; cannot read encrypted multifiles.\n"; delete stream; - return NULL; + return nullptr; #else // HAVE_OPENSSL // The subfile is encrypted. So actually, return an IDecryptStream that // wraps around the ISubStream. @@ -2060,7 +2060,7 @@ open_read_subfile(Subfile *subfile) { express_cat.error() << "Unable to decrypt subfile " << subfile->_name << ".\n"; delete stream; - return NULL; + return nullptr; } #endif // HAVE_OPENSSL } @@ -2070,7 +2070,7 @@ open_read_subfile(Subfile *subfile) { express_cat.error() << "zlib not compiled in; cannot read compressed multifiles.\n"; delete stream; - return NULL; + return nullptr; #else // HAVE_ZLIB // Oops, the subfile is compressed. So actually, return an // IDecompressStream that wraps around the ISubStream. @@ -2082,7 +2082,7 @@ open_read_subfile(Subfile *subfile) { if (stream->fail()) { // Hmm, some inexplicable problem. delete stream; - return NULL; + return nullptr; } return stream; @@ -2151,7 +2151,7 @@ clear_subfiles() { */ bool Multifile:: read_index() { - nassertr(_read != (IStreamWrapper *)NULL, false); + nassertr(_read != nullptr, false); // We acquire the IStreamWrapper lock for the duration of this method. _read->acquire(); @@ -2331,7 +2331,7 @@ write_header() { _file_major_ver = _current_major_ver; _file_minor_ver = _current_minor_ver; - nassertr(_write != (ostream *)NULL, false); + nassertr(_write != nullptr, false); nassertr(_write->tellp() == (streampos)0, false); _write->write(_header_prefix.data(), _header_prefix.size()); _write->write(_header, _header_size); @@ -2380,7 +2380,7 @@ check_signatures() { // Extract the signature data and certificate separately. istream *stream = open_read_subfile(subfile); - nassertv(stream != NULL); + nassertv(stream != nullptr); StreamReader reader(*stream); size_t sig_size = reader.get_uint32(); vector_uchar sig_data = reader.extract_bytes(sig_size); @@ -2396,7 +2396,7 @@ check_signatures() { // Now convert each of the certificates to an X509 object, and store it in // our CertChain. CertChain chain; - EVP_PKEY *pkey = NULL; + EVP_PKEY *pkey = nullptr; if (!buffer.empty()) { #if OPENSSL_VERSION_NUMBER >= 0x00908000L // Beginning in 0.9.8, d2i_X509() accepted a const unsigned char **. @@ -2407,13 +2407,13 @@ check_signatures() { #endif bp = (unsigned char *)&buffer[0]; bp_end = bp + buffer.size(); - X509 *x509 = d2i_X509(NULL, &bp, bp_end - bp); - while (num_certs > 0 && x509 != NULL) { + X509 *x509 = d2i_X509(nullptr, &bp, bp_end - bp); + while (num_certs > 0 && x509 != nullptr) { chain.push_back(CertRecord(x509)); --num_certs; - x509 = d2i_X509(NULL, &bp, bp_end - bp); + x509 = d2i_X509(nullptr, &bp, bp_end - bp); } - if (num_certs != 0 || x509 != NULL) { + if (num_certs != 0 || x509 != nullptr) { express_cat.warning() << "Extra data in signature record.\n"; } @@ -2423,11 +2423,11 @@ check_signatures() { pkey = X509_get_pubkey(chain[0]._cert); } - if (pkey != NULL) { + if (pkey != nullptr) { EVP_MD_CTX *md_ctx = EVP_MD_CTX_create(); EVP_VerifyInit(md_ctx, EVP_sha1()); - nassertv(_read != NULL); + nassertv(_read != nullptr); _read->acquire(); istream *read = _read->get_istream(); @@ -2520,7 +2520,7 @@ read_index(istream &read, streampos fpos, Multifile *multifile) { // And finally, get the rest of the name. char *name_buffer = (char *)PANDA_MALLOC_ARRAY(name_length); - nassertr(name_buffer != (char *)NULL, next_index); + nassertr(name_buffer != nullptr, next_index); for (size_t ni = 0; ni < name_length; ni++) { name_buffer[ni] = read.get() ^ 0xff; } @@ -2608,7 +2608,7 @@ write_data(ostream &write, istream *read, streampos fpos, istream *source = _source; pifstream source_file; - if (source == (istream *)NULL && !_source_filename.empty()) { + if (source == nullptr && !_source_filename.empty()) { // If we have a filename, open it up and read that. if (!_source_filename.open_read(source_file)) { // Unable to open the source file. @@ -2622,10 +2622,10 @@ write_data(ostream &write, istream *read, streampos fpos, } } - if (source == (istream *)NULL) { + if (source == nullptr) { // We don't have any source data. Perhaps we're reading from an already- // packed Subfile (e.g. during repack()). - if (read == (istream *)NULL) { + if (read == nullptr) { // No, we're just screwed. express_cat.info() << "No source for subfile " << _name << ".\n"; @@ -2698,10 +2698,10 @@ write_data(ostream &write, istream *read, streampos fpos, // In order to generate a signature, we need to have a valid read // pointer. - nassertr(read != NULL, fpos); + nassertr(read != nullptr, fpos); // And we also need to have a private key. - nassertr(_pkey != NULL, fpos); + nassertr(_pkey != nullptr, fpos); EVP_MD_CTX *md_ctx = EVP_MD_CTX_create(); EVP_SignInit(md_ctx, EVP_sha1()); @@ -2776,10 +2776,10 @@ write_data(ostream &write, istream *read, streampos fpos, _timestamp = _source_filename.get_timestamp(); } if (_timestamp == 0) { - _timestamp = time(NULL); + _timestamp = time(nullptr); } - _source = (istream *)NULL; + _source = nullptr; _source_filename = Filename(); source_file.close(); diff --git a/panda/src/express/nodePointerTo.h b/panda/src/express/nodePointerTo.h index 169aeb71e5..52ce974879 100644 --- a/panda/src/express/nodePointerTo.h +++ b/panda/src/express/nodePointerTo.h @@ -29,7 +29,7 @@ public: // and memory utilization. #ifndef CPPPARSER typedef TYPENAME NodePointerToBase::To To; - INLINE NodePointerTo(To *ptr = (To *)NULL); + INLINE NodePointerTo(To *ptr = nullptr); INLINE NodePointerTo(const NodePointerTo ©); INLINE NodePointerTo(NodePointerTo &&from) noexcept; @@ -60,7 +60,7 @@ public: // and memory utilization. #ifndef CPPPARSER typedef TYPENAME NodePointerToBase::To To; - INLINE NodeConstPointerTo(const To *ptr = (const To *)NULL); + INLINE NodeConstPointerTo(const To *ptr = nullptr); INLINE NodeConstPointerTo(const NodePointerTo ©); INLINE NodeConstPointerTo(const NodeConstPointerTo ©); INLINE NodeConstPointerTo(NodePointerTo &&from) noexcept; diff --git a/panda/src/express/nodePointerToBase.I b/panda/src/express/nodePointerToBase.I index 1cb22132d5..40c9eb6506 100644 --- a/panda/src/express/nodePointerToBase.I +++ b/panda/src/express/nodePointerToBase.I @@ -35,7 +35,7 @@ NodePointerToBase(const NodePointerToBase ©) { template INLINE NodePointerToBase:: ~NodePointerToBase() { - reassign((To *)NULL); + reassign(nullptr); } /** @@ -45,7 +45,7 @@ template INLINE NodePointerToBase:: NodePointerToBase(NodePointerToBase &&from) noexcept { _void_ptr = from._void_ptr; - from._void_ptr = (void *)NULL; + from._void_ptr = nullptr; } /** @@ -60,10 +60,10 @@ reassign(NodePointerToBase &&from) noexcept { To *old_ptr = (To *)this->_void_ptr; this->_void_ptr = from._void_ptr; - from._void_ptr = NULL; + from._void_ptr = nullptr; // Now delete the old pointer. - if (old_ptr != (To *)NULL) { + if (old_ptr != nullptr) { node_unref_delete(old_ptr); } } @@ -83,7 +83,7 @@ reassign(To *ptr) { To *old_ptr = (To *)_void_ptr; _void_ptr = (void *)ptr; - if (ptr != (To *)NULL) { + if (ptr != nullptr) { ptr->node_ref(); #ifdef DO_MEMORY_USAGE if (MemoryUsage::get_track_memory_usage()) { @@ -102,7 +102,7 @@ reassign(To *ptr) { } // Now delete the old pointer. - if (old_ptr != (To *)NULL) { + if (old_ptr != nullptr) { node_unref_delete(old_ptr); } } @@ -125,7 +125,7 @@ reassign(const NodePointerToBase ©) { template INLINE void NodePointerToBase:: clear() { - reassign((To *)NULL); + reassign(nullptr); } /** @@ -136,7 +136,7 @@ template INLINE void NodePointerToBase:: output(ostream &out) const { out << _void_ptr; - if (_void_ptr != (void *)NULL) { + if (_void_ptr != nullptr) { out << ":" << ((To *)_void_ptr)->get_node_ref_count() << "/" << ((To *)_void_ptr)->get_ref_count(); } diff --git a/panda/src/express/openSSLWrapper.cxx b/panda/src/express/openSSLWrapper.cxx index 6492bb1596..97fe936d21 100644 --- a/panda/src/express/openSSLWrapper.cxx +++ b/panda/src/express/openSSLWrapper.cxx @@ -18,7 +18,7 @@ #include "virtualFileSystem.h" #include "ca_bundle_data_src.c" -OpenSSLWrapper *OpenSSLWrapper::_global_ptr = NULL; +OpenSSLWrapper *OpenSSLWrapper::_global_ptr = nullptr; /** * @@ -154,7 +154,7 @@ load_certificates_from_pem_ram(const char *data, size_t data_size) { // We have to be sure and clear the OpenSSL error state before we call this // function, or it will get confused. ERR_clear_error(); - inf = PEM_X509_INFO_read_bio(mbio, NULL, NULL, NULL); + inf = PEM_X509_INFO_read_bio(mbio, nullptr, nullptr, nullptr); BIO_free(mbio); if (!inf) { @@ -257,8 +257,8 @@ load_certificates_from_der_ram(const char *data, size_t data_size) { bp = (unsigned char *)data; bp_end = bp + data_size; while (bp < bp_end) { - X509 *x509 = d2i_X509(NULL, &bp, bp_end - bp); - if (x509 == NULL) { + X509 *x509 = d2i_X509(nullptr, &bp, bp_end - bp); + if (x509 == nullptr) { notify_ssl_errors(); break; } @@ -350,7 +350,7 @@ notify_debug_ssl_errors() { */ OpenSSLWrapper *OpenSSLWrapper:: get_global_ptr() { - if (_global_ptr == NULL) { + if (_global_ptr == nullptr) { _global_ptr = new OpenSSLWrapper; } return _global_ptr; diff --git a/panda/src/express/patchfile.cxx b/panda/src/express/patchfile.cxx index 73b04139a0..9c0ebc9481 100644 --- a/panda/src/express/patchfile.cxx +++ b/panda/src/express/patchfile.cxx @@ -32,7 +32,7 @@ #endif // HAVE_TAR #ifdef HAVE_TAR -istream *Patchfile::_tar_istream = NULL; +istream *Patchfile::_tar_istream = nullptr; #endif // HAVE_TAR // this actually slows things down... #define @@ -99,7 +99,7 @@ void Patchfile:: init(PT(Buffer) buffer) { _rename_output_to_orig = false; _delete_patchfile = false; - _hash_table = NULL; + _hash_table = nullptr; _initiated = false; nassertv(!buffer.is_null()); _buffer = buffer; @@ -107,8 +107,8 @@ init(PT(Buffer) buffer) { _version_number = 0; _allow_multifile = true; - _patch_stream = NULL; - _origfile_stream = NULL; + _patch_stream = nullptr; + _origfile_stream = nullptr; reset_footprint_length(); } @@ -118,7 +118,7 @@ init(PT(Buffer) buffer) { */ Patchfile:: ~Patchfile() { - if (_hash_table != (uint32_t *)NULL) { + if (_hash_table != nullptr) { PANDA_FREE_ARRAY(_hash_table); } @@ -126,8 +126,8 @@ Patchfile:: cleanup(); } - nassertv(_patch_stream == NULL); - nassertv(_origfile_stream == NULL); + nassertv(_patch_stream == nullptr); + nassertv(_origfile_stream == nullptr); } /** @@ -144,13 +144,13 @@ cleanup() { // close files VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - if (_origfile_stream != NULL) { + if (_origfile_stream != nullptr) { vfs->close_read_file(_origfile_stream); - _origfile_stream = NULL; + _origfile_stream = nullptr; } - if (_patch_stream != NULL) { + if (_patch_stream != nullptr) { vfs->close_read_file(_patch_stream); - _patch_stream = NULL; + _patch_stream = nullptr; } _write_stream.close(); @@ -195,11 +195,11 @@ initiate(const Filename &patch_file, const Filename &orig_file, VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); // Open the original file for read - nassertr(_origfile_stream == NULL, EU_error_abort); + nassertr(_origfile_stream == nullptr, EU_error_abort); _orig_file = orig_file; _orig_file.set_binary(); _origfile_stream = vfs->open_read_file(_orig_file, false); - if (_origfile_stream == NULL) { + if (_origfile_stream == nullptr) { express_cat.error() << "Patchfile::initiate() - Failed to open file: " << _orig_file << endl; return get_write_error(); @@ -241,10 +241,10 @@ read_header(const Filename &patch_file) { } int result = internal_read_header(patch_file); - if (_patch_stream != NULL) { + if (_patch_stream != nullptr) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->close_read_file(_patch_stream); - _patch_stream = NULL; + _patch_stream = nullptr; } return result; } @@ -272,8 +272,8 @@ run() { return EU_error_abort; } - nassertr(_patch_stream != NULL, EU_error_abort); - nassertr(_origfile_stream != NULL, EU_error_abort); + nassertr(_patch_stream != nullptr, EU_error_abort); + nassertr(_origfile_stream != nullptr, EU_error_abort); StreamReader patch_reader(*_patch_stream); buflen = _buffer->get_length(); @@ -399,10 +399,10 @@ run() { MD5_actual.hash_file(_output_file); if (_MD5_ofResult != MD5_actual) { // Whoops, patching screwed up somehow. - if (_origfile_stream != NULL) { + if (_origfile_stream != nullptr) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->close_read_file(_origfile_stream); - _origfile_stream = NULL; + _origfile_stream = nullptr; } _write_stream.close(); @@ -520,11 +520,11 @@ int Patchfile:: internal_read_header(const Filename &patch_file) { // Open the patch file for read VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - nassertr(_patch_stream == NULL, EU_error_abort); + nassertr(_patch_stream == nullptr, EU_error_abort); _patch_file = patch_file; _patch_file.set_binary(); _patch_stream = vfs->open_read_file(_patch_file, true); - if (_patch_stream == NULL) { + if (_patch_stream == nullptr) { express_cat.error() << "Patchfile::initiate() - Failed to open file: " << _patch_file << endl; return get_write_error(); @@ -840,7 +840,7 @@ emit_add_and_copy(ostream &write_stream, emit_COPY(write_stream, max_write, copy_pos); copy_pos += max_write; copy_length -= max_write; - emit_ADD(write_stream, 0, NULL); + emit_ADD(write_stream, 0, nullptr); } emit_COPY(write_stream, copy_length, copy_pos); @@ -946,7 +946,7 @@ void Patchfile:: write_terminator(ostream &write_stream) { cache_flush(write_stream); // write terminator (null ADD, null COPY) - emit_ADD(write_stream, 0, NULL); + emit_ADD(write_stream, 0, nullptr); emit_COPY(write_stream, 0, 0); } @@ -987,7 +987,7 @@ compute_file_patches(ostream &write_stream, stream_new.read(buffer_new, result_file_length); // allocate hashlink tables - if (_hash_table == (uint32_t *)NULL) { + if (_hash_table == nullptr) { if (express_cat.is_debug()) { express_cat.debug() << "Allocating hashtable of size " << _HASHTABLESIZE << " * 4\n"; @@ -1166,10 +1166,10 @@ read_tar(TarDef &tar, istream &stream) { tt.writefunc = tar_writefunc; stream.seekg(0, ios::beg); - nassertr(_tar_istream == NULL, false); + nassertr(_tar_istream == nullptr, false); _tar_istream = &stream; if (tar_open(&tfile, (char *)"dummy", &tt, O_RDONLY, 0, 0) != 0) { - _tar_istream = NULL; + _tar_istream = nullptr; return false; } @@ -1205,7 +1205,7 @@ read_tar(TarDef &tar, istream &stream) { tar.push_back(subfile); tar_close(tfile); - _tar_istream = NULL; + _tar_istream = nullptr; return (flag == 1); } #endif // HAVE_TAR @@ -1326,7 +1326,7 @@ tar_closefunc(int) { */ ssize_t Patchfile:: tar_readfunc(int, void *buffer, size_t nbytes) { - nassertr(_tar_istream != NULL, 0); + nassertr(_tar_istream != nullptr, 0); _tar_istream->read((char *)buffer, nbytes); return (ssize_t)_tar_istream->gcount(); } @@ -1436,8 +1436,8 @@ do_compute_patches(const Filename &file_orig, const Filename &file_new, #endif // HAVE_TAR if (_allow_multifile) { - if (strstr(file_orig.get_basename().c_str(), ".mf") != NULL || - strstr(file_new.get_basename().c_str(), ".mf") != NULL) { + if (strstr(file_orig.get_basename().c_str(), ".mf") != nullptr || + strstr(file_new.get_basename().c_str(), ".mf") != nullptr) { // Read the first n bytes of both files for the Multifile magic number. string magic_number = Multifile::get_magic_number(); char *buffer = (char *)PANDA_MALLOC_ARRAY(magic_number.size()); @@ -1456,8 +1456,8 @@ do_compute_patches(const Filename &file_orig, const Filename &file_new, PANDA_FREE_ARRAY(buffer); } #ifdef HAVE_TAR - if (strstr(file_orig.get_basename().c_str(), ".tar") != NULL || - strstr(file_new.get_basename().c_str(), ".tar") != NULL) { + if (strstr(file_orig.get_basename().c_str(), ".tar") != nullptr || + strstr(file_new.get_basename().c_str(), ".tar") != nullptr) { if (read_tar(tar_orig, stream_orig) && read_tar(tar_new, stream_new)) { is_tarfile = true; @@ -1534,7 +1534,7 @@ patch_subfile(ostream &write_stream, express_cat.debug() << "Keeping subfile " << filename << "\n"; } - cache_add_and_copy(write_stream, 0, NULL, + cache_add_and_copy(write_stream, 0, nullptr, orig_size, offset_orig + orig_start); } else { diff --git a/panda/src/express/pointerToArray.I b/panda/src/express/pointerToArray.I index f665e38415..bb0946897f 100644 --- a/panda/src/express/pointerToArray.I +++ b/panda/src/express/pointerToArray.I @@ -25,7 +25,7 @@ pvector ConstPointerToArray::_empty_array; template INLINE PointerToArray:: PointerToArray(TypeHandle type_handle) : - PointerToArrayBase((ReferenceCountedVector *)NULL), + PointerToArrayBase(nullptr), _type_handle(type_handle) { } @@ -107,7 +107,7 @@ PointerToArray(pvector &&from, TypeHandle type_handle) : template INLINE TYPENAME PointerToArray::iterator PointerToArray:: begin() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { return _empty_array.begin(); } return ((To *)(this->_void_ptr))->begin(); @@ -119,7 +119,7 @@ begin() const { template INLINE TYPENAME PointerToArray::iterator PointerToArray:: end() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { return _empty_array.begin(); } return ((To *)(this->_void_ptr))->end(); @@ -131,7 +131,7 @@ end() const { template INLINE TYPENAME PointerToArray::reverse_iterator PointerToArray:: rbegin() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { return _empty_array.rbegin(); } return ((To *)(this->_void_ptr))->rbegin(); @@ -143,7 +143,7 @@ rbegin() const { template INLINE TYPENAME PointerToArray::reverse_iterator PointerToArray:: rend() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { return _empty_array.rbegin(); } return ((To *)(this->_void_ptr))->rend(); @@ -155,7 +155,7 @@ rend() const { template INLINE TYPENAME PointerToArray::size_type PointerToArray:: size() const { - return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->size(); + return ((this->_void_ptr) == nullptr) ? 0 : ((To *)(this->_void_ptr))->size(); } /** @@ -164,7 +164,7 @@ size() const { template INLINE TYPENAME PointerToArray::size_type PointerToArray:: max_size() const { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } return ((To *)(this->_void_ptr))->max_size(); @@ -176,7 +176,7 @@ max_size() const { template INLINE bool PointerToArray:: empty() const { - return ((this->_void_ptr) == NULL) ? true : ((To *)(this->_void_ptr))->empty(); + return ((this->_void_ptr) == nullptr) ? true : ((To *)(this->_void_ptr))->empty(); } /** @@ -185,7 +185,7 @@ empty() const { template INLINE void PointerToArray:: reserve(TYPENAME PointerToArray::size_type n) { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } ((To *)(this->_void_ptr))->reserve(n); @@ -197,7 +197,7 @@ reserve(TYPENAME PointerToArray::size_type n) { template INLINE void PointerToArray:: resize(TYPENAME PointerToArray::size_type n) { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } ((To *)(this->_void_ptr))->resize(n); @@ -209,7 +209,7 @@ resize(TYPENAME PointerToArray::size_type n) { template INLINE TYPENAME PointerToArray::size_type PointerToArray:: capacity() const { - nassertr((this->_void_ptr) != NULL, 0); + nassertr((this->_void_ptr) != nullptr, 0); return ((To *)(this->_void_ptr))->capacity(); } @@ -219,7 +219,7 @@ capacity() const { template INLINE TYPENAME PointerToArray::reference PointerToArray:: front() const { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } nassertd(!((To *)(this->_void_ptr))->empty()) { @@ -234,7 +234,7 @@ front() const { template INLINE TYPENAME PointerToArray::reference PointerToArray:: back() const { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } nassertd(!((To *)(this->_void_ptr))->empty()) { @@ -249,7 +249,7 @@ back() const { template INLINE TYPENAME PointerToArray::iterator PointerToArray:: insert(iterator position, const Element &x) { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); position = end(); } @@ -264,7 +264,7 @@ insert(iterator position, const Element &x) { template INLINE void PointerToArray:: insert(iterator position, size_type n, const Element &x) { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); position = end(); } @@ -279,7 +279,7 @@ insert(iterator position, size_type n, const Element &x) { template INLINE void PointerToArray:: erase(iterator position) { - nassertv((this->_void_ptr) != NULL); + nassertv((this->_void_ptr) != nullptr); nassertv(position >= ((To *)(this->_void_ptr))->begin() && position <= ((To *)(this->_void_ptr))->end()); ((To *)(this->_void_ptr))->erase(position); @@ -291,7 +291,7 @@ erase(iterator position) { template INLINE void PointerToArray:: erase(iterator first, iterator last) { - nassertv((this->_void_ptr) != NULL); + nassertv((this->_void_ptr) != nullptr); nassertv(first >= ((To *)(this->_void_ptr))->begin() && first <= ((To *)(this->_void_ptr))->end()); nassertv(last >= ((To *)(this->_void_ptr))->begin() && last <= ((To *)(this->_void_ptr))->end()); ((To *)(this->_void_ptr))->erase(first, last); @@ -304,7 +304,7 @@ erase(iterator first, iterator last) { template INLINE TYPENAME PointerToArray::reference PointerToArray:: operator [](size_type n) const { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } nassertd(!((To *)(this->_void_ptr))->empty()) { @@ -330,7 +330,7 @@ operator [](int n) const { template INLINE void PointerToArray:: push_back(const Element &x) { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } ((To *)(this->_void_ptr))->push_back(x); @@ -342,7 +342,7 @@ push_back(const Element &x) { template INLINE void PointerToArray:: pop_back() { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } nassertv(!((To *)(this->_void_ptr))->empty()); @@ -356,7 +356,7 @@ pop_back() { template INLINE void PointerToArray:: make_empty() { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } nassertv(!((To *)(this->_void_ptr))->empty()); @@ -373,7 +373,7 @@ template INLINE PointerToArray:: operator Element *() const { To *vec = (To *)(this->_void_ptr); - return ((vec == NULL)||(vec->empty())) ? (Element *)NULL : &(vec->front()); + return ((vec == nullptr)||(vec->empty())) ? nullptr : &(vec->front()); } /** @@ -384,7 +384,7 @@ template INLINE Element *PointerToArray:: p() const { To *vec = (To *)(this->_void_ptr); - return ((vec == NULL)||(vec->empty())) ? (Element *)NULL : &(vec->front()); + return ((vec == nullptr)||(vec->empty())) ? nullptr : &(vec->front()); } /** @@ -394,7 +394,7 @@ p() const { template INLINE pvector &PointerToArray:: v() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } return *((To *)(this->_void_ptr)); @@ -492,7 +492,7 @@ INLINE void PointerToArray:: set_subdata(size_type n, size_type count, const string &data) { nassertv((data.length() % sizeof(Element)) == 0); nassertv(n <= size() && n + count <= size()); - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } size_type ncount = data.length() / sizeof(Element); @@ -534,7 +534,7 @@ set_void_ptr(void *p) { template INLINE int PointerToArray:: get_ref_count() const { - return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->get_ref_count(); + return ((this->_void_ptr) == nullptr) ? 0 : ((To *)(this->_void_ptr))->get_ref_count(); } /** @@ -543,7 +543,7 @@ get_ref_count() const { template INLINE void PointerToArray:: ref() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } ((To *)(this->_void_ptr))->ref(); @@ -555,7 +555,7 @@ ref() const { template INLINE bool PointerToArray:: unref() const { - nassertr((this->_void_ptr) != NULL, true); + nassertr((this->_void_ptr) != nullptr, true); return ((To *)(this->_void_ptr))->unref(); } @@ -565,7 +565,7 @@ unref() const { template INLINE int PointerToArray:: get_node_ref_count() const { - return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->get_node_ref_count(); + return ((this->_void_ptr) == nullptr) ? 0 : ((To *)(this->_void_ptr))->get_node_ref_count(); } /** @@ -574,7 +574,7 @@ get_node_ref_count() const { template INLINE void PointerToArray:: node_ref() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } ((To *)(this->_void_ptr))->node_ref(); @@ -586,7 +586,7 @@ node_ref() const { template INLINE bool PointerToArray:: node_unref() const { - nassertr((this->_void_ptr) != NULL, true); + nassertr((this->_void_ptr) != nullptr, true); return ((To *)(this->_void_ptr))->node_unref(); } @@ -642,7 +642,7 @@ operator = (PointerToArray &&from) noexcept { template INLINE void PointerToArray:: clear() { - ((PointerToArray *)this)->reassign((ReferenceCountedVector *)NULL); + ((PointerToArray *)this)->reassign(nullptr); } @@ -653,7 +653,7 @@ clear() { template INLINE ConstPointerToArray:: ConstPointerToArray(TypeHandle type_handle) : - PointerToArrayBase((ReferenceCountedVector *)NULL), + PointerToArrayBase(nullptr), _type_handle(type_handle) { } @@ -730,7 +730,7 @@ ConstPointerToArray(pvector &&from, TypeHandle type_handle) : template INLINE TYPENAME ConstPointerToArray::iterator ConstPointerToArray:: begin() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { return _empty_array.begin(); } return ((To *)(this->_void_ptr))->begin(); @@ -742,7 +742,7 @@ begin() const { template INLINE TYPENAME ConstPointerToArray::iterator ConstPointerToArray:: end() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { return _empty_array.begin(); } return ((To *)(this->_void_ptr))->end(); @@ -754,7 +754,7 @@ end() const { template INLINE TYPENAME ConstPointerToArray::reverse_iterator ConstPointerToArray:: rbegin() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { return _empty_array.rbegin(); } return ((To *)(this->_void_ptr))->rbegin(); @@ -766,7 +766,7 @@ rbegin() const { template INLINE TYPENAME ConstPointerToArray::reverse_iterator ConstPointerToArray:: rend() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { return _empty_array.rbegin(); } return ((To *)(this->_void_ptr))->rend(); @@ -778,7 +778,7 @@ rend() const { template INLINE TYPENAME ConstPointerToArray::size_type ConstPointerToArray:: size() const { - return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->size(); + return ((this->_void_ptr) == nullptr) ? 0 : ((To *)(this->_void_ptr))->size(); } /** @@ -787,7 +787,7 @@ size() const { template INLINE TYPENAME ConstPointerToArray::size_type ConstPointerToArray:: max_size() const { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((ConstPointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } return ((To *)(this->_void_ptr))->max_size(); @@ -799,7 +799,7 @@ max_size() const { template INLINE bool ConstPointerToArray:: empty() const { - return ((this->_void_ptr) == NULL) ? true : ((To *)(this->_void_ptr))->empty(); + return ((this->_void_ptr) == nullptr) ? true : ((To *)(this->_void_ptr))->empty(); } /** @@ -808,7 +808,7 @@ empty() const { template INLINE TYPENAME ConstPointerToArray::size_type ConstPointerToArray:: capacity() const { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((ConstPointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } return ((To *)(this->_void_ptr))->capacity(); @@ -820,7 +820,7 @@ capacity() const { template INLINE TYPENAME ConstPointerToArray::reference ConstPointerToArray:: front() const { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((ConstPointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } nassertd(!((To *)(this->_void_ptr))->empty()) { @@ -835,7 +835,7 @@ front() const { template INLINE TYPENAME ConstPointerToArray::reference ConstPointerToArray:: back() const { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((ConstPointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } nassertd(!((To *)(this->_void_ptr))->empty()) { @@ -851,7 +851,7 @@ back() const { template INLINE TYPENAME ConstPointerToArray::reference ConstPointerToArray:: operator [](size_type n) const { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((ConstPointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } nassertd(!((To *)(this->_void_ptr))->empty()) { @@ -881,7 +881,7 @@ template INLINE ConstPointerToArray:: operator const Element *() const { const To *vec = (const To *)(this->_void_ptr); - return ((vec == NULL)||(vec->empty())) ? (const Element *)NULL : &(vec->front()); + return ((vec == nullptr)||(vec->empty())) ? nullptr : &(vec->front()); } /** @@ -892,7 +892,7 @@ template INLINE const Element *ConstPointerToArray:: p() const { const To *vec = (const To *)(this->_void_ptr); - return ((vec == NULL)||(vec->empty())) ? (const Element *)NULL : &(vec->front()); + return ((vec == nullptr)||(vec->empty())) ? nullptr : &(vec->front()); } /** @@ -902,7 +902,7 @@ p() const { template INLINE const pvector &ConstPointerToArray:: v() const { - nassertd((this->_void_ptr) != NULL) { + nassertd((this->_void_ptr) != nullptr) { ((ConstPointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } return *(const To *)(this->_void_ptr); @@ -977,7 +977,7 @@ get_subdata(size_type n, size_type count) const { template INLINE int ConstPointerToArray:: get_ref_count() const { - return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->get_ref_count(); + return ((this->_void_ptr) == nullptr) ? 0 : ((To *)(this->_void_ptr))->get_ref_count(); } /** @@ -986,7 +986,7 @@ get_ref_count() const { template INLINE void ConstPointerToArray:: ref() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { ((ConstPointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } ((To *)(this->_void_ptr))->ref(); @@ -998,7 +998,7 @@ ref() const { template INLINE bool ConstPointerToArray:: unref() const { - nassertr((this->_void_ptr) != NULL, true); + nassertr((this->_void_ptr) != nullptr, true); return ((To *)(this->_void_ptr))->unref(); } @@ -1008,7 +1008,7 @@ unref() const { template INLINE int ConstPointerToArray:: get_node_ref_count() const { - return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->get_node_ref_count(); + return ((this->_void_ptr) == nullptr) ? 0 : ((To *)(this->_void_ptr))->get_node_ref_count(); } /** @@ -1017,7 +1017,7 @@ get_node_ref_count() const { template INLINE void ConstPointerToArray:: node_ref() const { - if ((this->_void_ptr) == NULL) { + if ((this->_void_ptr) == nullptr) { ((ConstPointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } ((To *)(this->_void_ptr))->node_ref(); @@ -1029,7 +1029,7 @@ node_ref() const { template INLINE bool ConstPointerToArray:: node_unref() const { - nassertr((this->_void_ptr) != NULL, true); + nassertr((this->_void_ptr) != nullptr, true); return ((To *)(this->_void_ptr))->node_unref(); } @@ -1107,7 +1107,7 @@ operator = (ConstPointerToArray &&from) noexcept { template INLINE void ConstPointerToArray:: clear() { - ((ConstPointerToArray *)this)->reassign((ReferenceCountedVector *)NULL); + ((ConstPointerToArray *)this)->reassign(nullptr); } #endif // CPPPARSER diff --git a/panda/src/express/pointerToArrayBase.cxx b/panda/src/express/pointerToArrayBase.cxx index 86366ae892..0be7bbc08a 100644 --- a/panda/src/express/pointerToArrayBase.cxx +++ b/panda/src/express/pointerToArrayBase.cxx @@ -13,4 +13,4 @@ #include "pointerToArrayBase.h" -EXPCL_PANDAEXPRESS PTASetLevelFunc *pta_set_level = NULL; +EXPCL_PANDAEXPRESS PTASetLevelFunc *pta_set_level = nullptr; diff --git a/panda/src/express/pointerToArray_ext.I b/panda/src/express/pointerToArray_ext.I index fb42878b3f..eedb92d3f4 100644 --- a/panda/src/express/pointerToArray_ext.I +++ b/panda/src/express/pointerToArray_ext.I @@ -44,12 +44,12 @@ INLINE void set_matrix_view(Py_buffer &view, int flags, int length, int size, bo view.len = length * mat_size; view.readonly = (read_only ? 1 : 0); view.itemsize = item_size; - view.format = NULL; + view.format = nullptr; if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) { view.format = (char*) format; } view.ndim = 3; - view.shape = NULL; + view.shape = nullptr; if ((flags & PyBUF_ND) == PyBUF_ND) { // This leaks, which sucks, but __releasebuffer__ doesn't give us the same // pointer, so we would need to store it elsewhere if we wanted to delete @@ -60,7 +60,7 @@ INLINE void set_matrix_view(Py_buffer &view, int flags, int length, int size, bo shape[2] = size; view.shape = shape; } - view.strides = NULL; + view.strides = nullptr; if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES) { Py_ssize_t* strides = new Py_ssize_t[3]; strides[0] = mat_size; @@ -68,7 +68,7 @@ INLINE void set_matrix_view(Py_buffer &view, int flags, int length, int size, bo strides[2] = item_size; view.strides = strides; } - view.suboffsets = NULL; + view.suboffsets = nullptr; } /** @@ -101,7 +101,7 @@ __init__(PyObject *self, PyObject *source) { // from Python. PyObject *dict = DtoolInstance_TYPE(self)->_PyType.tp_dict; PyObject *push_back = PyDict_GetItemString(dict, "push_back"); - if (push_back == NULL) { + if (push_back == nullptr) { PyErr_BadArgument(); return; } @@ -113,12 +113,12 @@ __init__(PyObject *self, PyObject *source) { this->_this->reserve(size); for (Py_ssize_t i = 0; i < size; ++i) { PyObject *item = PySequence_GetItem(source, i); - if (item == NULL) { + if (item == nullptr) { return; } - PyObject *result = PyObject_CallFunctionObjArgs(push_back, self, item, NULL); + PyObject *result = PyObject_CallFunctionObjArgs(push_back, self, item, nullptr); Py_DECREF(item); - if (result == NULL) { + if (result == nullptr) { // Unable to add item--probably it wasn't of the appropriate type. PyErr_Print(); PyErr_Format(PyExc_TypeError, @@ -312,12 +312,12 @@ INLINE int Extension >:: __getbuffer__(PyObject *self, Py_buffer *view, int flags) { #if PY_VERSION_HEX >= 0x02060000 const char *format = get_format_code(Element); - if (format == NULL) { + if (format == nullptr) { // Not supported. return -1; } - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -325,23 +325,23 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) { view->len = this->_this->size() * sizeof(Element); view->readonly = 0; view->itemsize = sizeof(Element); - view->format = NULL; + view->format = nullptr; if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) { view->format = (char*) format; } view->ndim = 1; - view->shape = NULL; + view->shape = nullptr; if ((flags & PyBUF_ND) == PyBUF_ND) { // This leaks, which sucks, but __releasebuffer__ doesn't give us the same // pointer, so we would need to store it elsewhere if we wanted to delete // it there. Eh, it's just an int, who cares. view->shape = new Py_ssize_t(this->_this->size()); } - view->strides = NULL; + view->strides = nullptr; if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES) { view->strides = &(view->itemsize); } - view->suboffsets = NULL; + view->suboffsets = nullptr; // Store a reference to ourselves on the Py_buffer object as a reminder that // we have increased our refcount. @@ -362,7 +362,7 @@ template<> INLINE int Extension >:: __getbuffer__(PyObject *self, Py_buffer *view, int flags) { #if PY_VERSION_HEX >= 0x02060000 - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -388,7 +388,7 @@ template<> INLINE int Extension >:: __getbuffer__(PyObject *self, Py_buffer *view, int flags) { #if PY_VERSION_HEX >= 0x02060000 - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -414,7 +414,7 @@ template<> INLINE int Extension >:: __getbuffer__(PyObject *self, Py_buffer *view, int flags) { #if PY_VERSION_HEX >= 0x02060000 - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -440,7 +440,7 @@ template<> INLINE int Extension >:: __getbuffer__(PyObject *self, Py_buffer *view, int flags) { #if PY_VERSION_HEX >= 0x02060000 - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -466,10 +466,10 @@ INLINE void Extension >:: __releasebuffer__(PyObject *self, Py_buffer *view) const { #if PY_VERSION_HEX >= 0x02060000 // Note: PyBuffer_Release automatically decrements view->obj. - if (view->internal != NULL) { + if (view->internal != nullptr) { // Oh, right, let's not forget to unref this. unref_delete((const PointerToArray *)view->internal); - view->internal = NULL; + view->internal = nullptr; } #endif } @@ -489,12 +489,12 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { } const char *format = get_format_code(Element); - if (format == NULL) { + if (format == nullptr) { // Not supported. return -1; } - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -502,23 +502,23 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { view->len = this->_this->size() * sizeof(Element); view->readonly = 1; view->itemsize = sizeof(Element); - view->format = NULL; + view->format = nullptr; if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) { view->format = (char*) format; } view->ndim = 1; - view->shape = NULL; + view->shape = nullptr; if ((flags & PyBUF_ND) == PyBUF_ND) { // This leaks, which sucks, but __releasebuffer__ doesn't give us the same // pointer, so we would need to store it elsewhere if we wanted to delete // it there. Eh, it's just an int, who cares. view->shape = new Py_ssize_t(this->_this->size()); } - view->strides = NULL; + view->strides = nullptr; if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES) { view->strides = &(view->itemsize); } - view->suboffsets = NULL; + view->suboffsets = nullptr; // Store a reference to ourselves on the Py_buffer object as a reminder that // we have increased our refcount. @@ -543,7 +543,7 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { "Object is not writable."); return -1; } - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -573,7 +573,7 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { "Object is not writable."); return -1; } - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -603,7 +603,7 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { "Object is not writable."); return -1; } - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -633,7 +633,7 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { "Object is not writable."); return -1; } - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -659,10 +659,10 @@ INLINE void Extension >:: __releasebuffer__(PyObject *self, Py_buffer *view) const { #if PY_VERSION_HEX >= 0x02060000 // Note: PyBuffer_Release automatically decrements obj->view. - if (view->internal != NULL) { + if (view->internal != nullptr) { // Oh, right, let's not forget to unref this. unref_delete((const PointerToArray *)view->internal); - view->internal = NULL; + view->internal = nullptr; } #endif } diff --git a/panda/src/express/pointerToArray_ext.h b/panda/src/express/pointerToArray_ext.h index 469b449fed..2daf885943 100644 --- a/panda/src/express/pointerToArray_ext.h +++ b/panda/src/express/pointerToArray_ext.h @@ -125,7 +125,7 @@ template class EXPORT_THIS Extension; template INLINE const char *_get_format_code(const T *) { - return NULL; + return nullptr; } define_format_code("c", char); diff --git a/panda/src/express/pointerToBase.I b/panda/src/express/pointerToBase.I index 27a02daa46..acd3123394 100644 --- a/panda/src/express/pointerToBase.I +++ b/panda/src/express/pointerToBase.I @@ -18,7 +18,7 @@ template INLINE PointerToBase:: PointerToBase(To *ptr) { _void_ptr = (void *)ptr; - if (ptr != (To *)NULL) { + if (ptr != nullptr) { ptr->ref(); #ifdef DO_MEMORY_USAGE update_type(ptr); @@ -33,7 +33,7 @@ template INLINE PointerToBase:: PointerToBase(const PointerToBase ©) { _void_ptr = copy._void_ptr; - if (_void_ptr != NULL) { + if (_void_ptr != nullptr) { To *ptr = (To *)_void_ptr; ptr->ref(); } @@ -45,9 +45,9 @@ PointerToBase(const PointerToBase ©) { template INLINE PointerToBase:: ~PointerToBase() { - if (_void_ptr != NULL) { + if (_void_ptr != nullptr) { unref_delete((To *)_void_ptr); - _void_ptr = NULL; + _void_ptr = nullptr; } } @@ -58,7 +58,7 @@ template INLINE PointerToBase:: PointerToBase(PointerToBase &&from) noexcept { _void_ptr = from._void_ptr; - from._void_ptr = (void *)NULL; + from._void_ptr = nullptr; } /** @@ -75,10 +75,10 @@ reassign(PointerToBase &&from) noexcept { To *old_ptr = (To *)this->_void_ptr; this->_void_ptr = from._void_ptr; - from._void_ptr = NULL; + from._void_ptr = nullptr; // Now delete the old pointer. - if (old_ptr != (To *)NULL) { + if (old_ptr != nullptr) { unref_delete(old_ptr); } } @@ -167,7 +167,7 @@ update_type(To *ptr) { template ALWAYS_INLINE void PointerToBase:: clear() { - reassign((To *)NULL); + reassign(nullptr); } /** @@ -178,7 +178,7 @@ template INLINE void PointerToBase:: output(ostream &out) const { out << _void_ptr; - if (_void_ptr != (void *)NULL) { + if (_void_ptr != nullptr) { out << ":" << ((To *)_void_ptr)->get_ref_count(); } } diff --git a/panda/src/express/profileTimer.cxx b/panda/src/express/profileTimer.cxx index ef571fc929..e21b41da59 100644 --- a/panda/src/express/profileTimer.cxx +++ b/panda/src/express/profileTimer.cxx @@ -22,7 +22,7 @@ ProfileTimer* ProfileTimer::_head; ProfileTimer:: ProfileTimer(const char* name, int maxEntries) : - _entries(0), + _entries(nullptr), _autoTimerCount(0) { // Keep a list of the ProfileTimers, so we can print them: _next=_head; diff --git a/panda/src/express/ramfile_ext.cxx b/panda/src/express/ramfile_ext.cxx index 6de3e62bfd..c52641abca 100644 --- a/panda/src/express/ramfile_ext.cxx +++ b/panda/src/express/ramfile_ext.cxx @@ -58,8 +58,8 @@ readline() { PyObject *Extension:: readlines() { PyObject *lst = PyList_New(0); - if (lst == NULL) { - return NULL; + if (lst == nullptr) { + return nullptr; } string line = _this->readline(); diff --git a/panda/src/express/referenceCount.I b/panda/src/express/referenceCount.I index 00f9d44b8c..da0ede4a73 100644 --- a/panda/src/express/referenceCount.I +++ b/panda/src/express/referenceCount.I @@ -28,7 +28,7 @@ TypeHandle RefCountObj::_type_handle; */ INLINE ReferenceCount:: ReferenceCount() { - _weak_list = (WeakReferenceList *)NULL; + _weak_list = nullptr; _ref_count = 0; #ifdef DO_MEMORY_USAGE MemoryUsage::record_pointer(this); @@ -45,7 +45,7 @@ ReferenceCount() { */ INLINE ReferenceCount:: ReferenceCount(const ReferenceCount &) { - _weak_list = (WeakReferenceList *)NULL; + _weak_list = nullptr; _ref_count = 0; #ifdef DO_MEMORY_USAGE MemoryUsage::record_pointer(this); @@ -242,7 +242,7 @@ local_object() { */ INLINE bool ReferenceCount:: has_weak_list() const { - return _weak_list != (WeakReferenceList *)NULL; + return _weak_list != nullptr; } /** @@ -255,7 +255,7 @@ has_weak_list() const { */ INLINE WeakReferenceList *ReferenceCount:: get_weak_list() const { - if (AtomicAdjust::get_ptr(_weak_list) == (WeakReferenceList *)NULL) { + if (AtomicAdjust::get_ptr(_weak_list) == nullptr) { ((ReferenceCount *)this)->create_weak_list(); } return (WeakReferenceList *)AtomicAdjust::get_ptr(_weak_list); diff --git a/panda/src/express/referenceCount.cxx b/panda/src/express/referenceCount.cxx index 371f755673..f446b3be46 100644 --- a/panda/src/express/referenceCount.cxx +++ b/panda/src/express/referenceCount.cxx @@ -56,8 +56,8 @@ void ReferenceCount:: create_weak_list() { WeakReferenceList *weak_list = new WeakReferenceList; void *orig = - AtomicAdjust::compare_and_exchange_ptr(_weak_list, NULL, weak_list); - if (orig != (void *)NULL) { + AtomicAdjust::compare_and_exchange_ptr(_weak_list, nullptr, weak_list); + if (orig != nullptr) { // Someone else created it first. delete weak_list; } diff --git a/panda/src/express/subStream.I b/panda/src/express/subStream.I index 346b66d46a..0749a4012a 100644 --- a/panda/src/express/subStream.I +++ b/panda/src/express/subStream.I @@ -38,7 +38,7 @@ ISubStream(IStreamWrapper *source, streampos start, streampos end) : istream(&_b INLINE ISubStream &ISubStream:: open(IStreamWrapper *source, streampos start, streampos end) { clear((ios_iostate)0); - _buf.open(source, NULL, start, end, false); + _buf.open(source, nullptr, start, end, false); return *this; } @@ -79,7 +79,7 @@ OSubStream(OStreamWrapper *dest, streampos start, streampos end, bool append) : INLINE OSubStream &OSubStream:: open(OStreamWrapper *dest, streampos start, streampos end, bool append) { clear((ios_iostate)0); - _buf.open(NULL, dest, start, end, append); + _buf.open(nullptr, dest, start, end, append); return *this; } diff --git a/panda/src/express/subStreamBuf.cxx b/panda/src/express/subStreamBuf.cxx index 22d3515767..0a3f44da9e 100644 --- a/panda/src/express/subStreamBuf.cxx +++ b/panda/src/express/subStreamBuf.cxx @@ -22,8 +22,8 @@ static const size_t substream_buffer_size = 4096; */ SubStreamBuf:: SubStreamBuf() { - _source = (IStreamWrapper *)NULL; - _dest = (OStreamWrapper *)NULL; + _source = nullptr; + _dest = nullptr; // _start is the streampos of the first byte of the SubStream within its // parent stream. @@ -93,8 +93,8 @@ close() { // Make sure the write buffer is flushed. sync(); - _source = (IStreamWrapper *)NULL; - _dest = (OStreamWrapper *)NULL; + _source = nullptr; + _dest = nullptr; _start = 0; _end = 0; @@ -246,7 +246,7 @@ overflow(int ch) { } } - nassertr(_dest != NULL, EOF); + nassertr(_dest != nullptr, EOF); bool fail = false; if (_append) { _dest->seek_eof_write(pbase(), n, fail); @@ -286,7 +286,7 @@ sync() { size_t n = pptr() - pbase(); if (n != 0) { - nassertr(_dest != NULL, EOF); + nassertr(_dest != nullptr, EOF); bool fail = false; if (_append) { _dest->seek_eof_write(pbase(), n, fail); @@ -335,7 +335,7 @@ underflow() { nassertr(egptr() - gptr() == num_bytes, EOF); } - nassertr(_source != NULL, EOF); + nassertr(_source != nullptr, EOF); streamsize read_count; bool eof; _source->seek_read(_gpos, gptr(), num_bytes, read_count, eof); diff --git a/panda/src/express/subfileInfo.I b/panda/src/express/subfileInfo.I index d34fe7af97..d488537b60 100644 --- a/panda/src/express/subfileInfo.I +++ b/panda/src/express/subfileInfo.I @@ -70,7 +70,7 @@ operator = (const SubfileInfo ©) { */ INLINE bool SubfileInfo:: is_empty() const { - return _file == (FileReference *)NULL; + return _file == nullptr; } /** @@ -86,7 +86,7 @@ get_file() const { */ INLINE const Filename &SubfileInfo:: get_filename() const { - if (_file != (FileReference *)NULL) { + if (_file != nullptr) { return _file->get_filename(); } static const Filename empty_filename; diff --git a/panda/src/express/threadSafePointerTo.h b/panda/src/express/threadSafePointerTo.h index 56eeed1651..f3801a5669 100644 --- a/panda/src/express/threadSafePointerTo.h +++ b/panda/src/express/threadSafePointerTo.h @@ -28,7 +28,7 @@ class ThreadSafePointerTo : public ThreadSafePointerToBase { public: typedef TYPENAME ThreadSafePointerToBase::To To; PUBLISHED: - INLINE ThreadSafePointerTo(To *ptr = (To *)NULL); + INLINE ThreadSafePointerTo(To *ptr = nullptr); INLINE ThreadSafePointerTo(const ThreadSafePointerTo ©); INLINE ~ThreadSafePointerTo(); @@ -73,7 +73,7 @@ class ThreadSafeConstPointerTo : public ThreadSafePointerToBase { public: typedef TYPENAME ThreadSafePointerToBase::To To; PUBLISHED: - INLINE ThreadSafeConstPointerTo(const To *ptr = (const To *)NULL); + INLINE ThreadSafeConstPointerTo(const To *ptr = nullptr); INLINE ThreadSafeConstPointerTo(const ThreadSafePointerTo ©); INLINE ThreadSafeConstPointerTo(const ThreadSafeConstPointerTo ©); INLINE ~ThreadSafeConstPointerTo(); diff --git a/panda/src/express/threadSafePointerToBase.I b/panda/src/express/threadSafePointerToBase.I index 4d200a483a..d00bcf1dbc 100644 --- a/panda/src/express/threadSafePointerToBase.I +++ b/panda/src/express/threadSafePointerToBase.I @@ -35,7 +35,7 @@ ThreadSafePointerToBase(const ThreadSafePointerToBase ©) { template INLINE ThreadSafePointerToBase:: ~ThreadSafePointerToBase() { - reassign((To *)NULL); + reassign(nullptr); } /** @@ -65,7 +65,7 @@ reassign(To *ptr) { _void_ptr = ptr; #endif // HAVE_THREADS - if (ptr != (To *)NULL) { + if (ptr != nullptr) { ptr->ref(); #ifdef DO_MEMORY_USAGE if (MemoryUsage::get_track_memory_usage()) { @@ -75,7 +75,7 @@ reassign(To *ptr) { } // Now delete the old pointer. - if (old_ptr != (To *)NULL) { + if (old_ptr != nullptr) { unref_delete(old_ptr); } } @@ -115,7 +115,7 @@ update_type(To *ptr) { template INLINE void ThreadSafePointerToBase:: clear() { - reassign((To *)NULL); + reassign(nullptr); } /** @@ -126,7 +126,7 @@ template INLINE void ThreadSafePointerToBase:: output(ostream &out) const { out << _void_ptr; - if (_void_ptr != (void *)NULL) { + if (_void_ptr != nullptr) { out << ":" << ((To *)_void_ptr)->get_ref_count(); } } diff --git a/panda/src/express/trueClock.I b/panda/src/express/trueClock.I index e9bc56aed4..3b7a80f66d 100644 --- a/panda/src/express/trueClock.I +++ b/panda/src/express/trueClock.I @@ -66,7 +66,7 @@ get_error_count() const { */ INLINE TrueClock *TrueClock:: get_global_ptr() { - if (_global_ptr == (TrueClock *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new TrueClock; } return _global_ptr; diff --git a/panda/src/express/trueClock.cxx b/panda/src/express/trueClock.cxx index d2104f0ae0..ea60c5bb1e 100644 --- a/panda/src/express/trueClock.cxx +++ b/panda/src/express/trueClock.cxx @@ -17,7 +17,7 @@ #include // for fabs() -TrueClock *TrueClock::_global_ptr = NULL; +TrueClock *TrueClock::_global_ptr = nullptr; #if defined(WIN32_VC) || defined(WIN64_VC) @@ -501,7 +501,7 @@ get_long_time() { #ifdef GETTIMEOFDAY_ONE_PARAM result = gettimeofday(&tv); #else - result = gettimeofday(&tv, (struct timezone *)NULL); + result = gettimeofday(&tv, nullptr); #endif if (result < 0) { @@ -527,7 +527,7 @@ get_short_raw_time() { #ifdef GETTIMEOFDAY_ONE_PARAM result = gettimeofday(&tv); #else - result = gettimeofday(&tv, (struct timezone *)NULL); + result = gettimeofday(&tv, nullptr); #endif if (result < 0) { @@ -561,7 +561,7 @@ TrueClock() { #ifdef GETTIMEOFDAY_ONE_PARAM result = gettimeofday(&tv); #else - result = gettimeofday(&tv, (struct timezone *)NULL); + result = gettimeofday(&tv, nullptr); #endif if (result < 0) { diff --git a/panda/src/express/virtualFile.cxx b/panda/src/express/virtualFile.cxx index eb010f2806..67595b586b 100644 --- a/panda/src/express/virtualFile.cxx +++ b/panda/src/express/virtualFile.cxx @@ -130,7 +130,7 @@ scan_directory() const { if (!scan_local_directory(file_list, mount_points)) { // Not a directory, or unable to read directory. if (file_list->get_num_files() == 0) { - return NULL; + return nullptr; } // We couldn't read the physical directory, but we do have some mounted @@ -155,7 +155,7 @@ output(ostream &out) const { void VirtualFile:: ls(ostream &out) const { CPT(VirtualFileList) contents = scan_directory(); - if (contents == (VirtualFileList *)NULL) { + if (contents == nullptr) { if (!is_directory()) { out << get_filename() << "\n"; } else { @@ -191,7 +191,7 @@ ls_all(ostream &out) const { */ istream *VirtualFile:: open_read_file(bool auto_unwrap) const { - return NULL; + return nullptr; } /** @@ -224,7 +224,7 @@ was_read_successful() const { */ ostream *VirtualFile:: open_write_file(bool auto_wrap, bool truncate) { - return NULL; + return nullptr; } /** @@ -234,7 +234,7 @@ open_write_file(bool auto_wrap, bool truncate) { */ ostream *VirtualFile:: open_append_file() { - return NULL; + return nullptr; } /** @@ -255,7 +255,7 @@ close_write_file(ostream *stream) { */ iostream *VirtualFile:: open_read_write_file(bool truncate) { - return NULL; + return nullptr; } /** @@ -265,7 +265,7 @@ open_read_write_file(bool truncate) { */ iostream *VirtualFile:: open_read_append_file() { - return NULL; + return nullptr; } /** @@ -443,7 +443,7 @@ scan_local_directory(VirtualFileList *, const ov_set &) const { void VirtualFile:: r_ls_all(ostream &out, const Filename &root) const { CPT(VirtualFileList) contents = scan_directory(); - if (contents == (VirtualFileList *)NULL) { + if (contents == nullptr) { return; } diff --git a/panda/src/express/virtualFileList.I b/panda/src/express/virtualFileList.I index efd87c2711..14b29361b3 100644 --- a/panda/src/express/virtualFileList.I +++ b/panda/src/express/virtualFileList.I @@ -46,7 +46,7 @@ get_num_files() const { */ INLINE VirtualFile *VirtualFileList:: get_file(size_t n) const { - nassertr(n < _files.size(), NULL); + nassertr(n < _files.size(), nullptr); return _files[n]; } @@ -55,7 +55,7 @@ get_file(size_t n) const { */ INLINE VirtualFile *VirtualFileList:: operator [](size_t n) const { - nassertr(n < _files.size(), NULL); + nassertr(n < _files.size(), nullptr); return _files[n]; } diff --git a/panda/src/express/virtualFileMount.I b/panda/src/express/virtualFileMount.I index 81e22016bf..f1195a49ef 100644 --- a/panda/src/express/virtualFileMount.I +++ b/panda/src/express/virtualFileMount.I @@ -16,7 +16,7 @@ */ INLINE VirtualFileMount:: VirtualFileMount() : - _file_system(NULL), + _file_system(nullptr), _mount_flags(0) { } diff --git a/panda/src/express/virtualFileMount.cxx b/panda/src/express/virtualFileMount.cxx index 89e8ddfc24..0c60f96f7f 100644 --- a/panda/src/express/virtualFileMount.cxx +++ b/panda/src/express/virtualFileMount.cxx @@ -24,7 +24,7 @@ TypeHandle VirtualFileMount::_type_handle; */ VirtualFileMount:: ~VirtualFileMount() { - nassertv(_file_system == NULL); + nassertv(_file_system == nullptr); } /** @@ -128,7 +128,7 @@ read_file(const Filename &file, bool do_uncompress, result.clear(); istream *in = open_read_file(file, do_uncompress); - if (in == (istream *)NULL) { + if (in == nullptr) { express_cat.info() << "Unable to read " << file << "\n"; return false; @@ -158,7 +158,7 @@ bool VirtualFileMount:: write_file(const Filename &file, bool do_compress, const unsigned char *data, size_t data_size) { ostream *out = open_write_file(file, do_compress, true); - if (out == (ostream *)NULL) { + if (out == nullptr) { express_cat.info() << "Unable to write " << file << "\n"; return false; @@ -188,7 +188,7 @@ open_read_file(const Filename &file, bool do_uncompress) const { istream *result = open_read_file(file); #ifdef HAVE_ZLIB - if (result != (istream *)NULL && do_uncompress) { + if (result != nullptr && do_uncompress) { // We have to slip in a layer to decompress the file on the fly. IDecompressStream *wrapper = new IDecompressStream(result, true); result = wrapper; @@ -216,7 +216,7 @@ close_read_file(istream *stream) const { */ ostream *VirtualFileMount:: open_write_file(const Filename &file, bool truncate) { - return NULL; + return nullptr; } /** @@ -231,7 +231,7 @@ open_write_file(const Filename &file, bool do_compress, bool truncate) { ostream *result = open_write_file(file, truncate); #ifdef HAVE_ZLIB - if (result != (ostream *)NULL && do_compress) { + if (result != nullptr && do_compress) { // We have to slip in a layer to compress the file on the fly. OCompressStream *wrapper = new OCompressStream(result, true); result = wrapper; @@ -248,7 +248,7 @@ open_write_file(const Filename &file, bool do_compress, bool truncate) { */ ostream *VirtualFileMount:: open_append_file(const Filename &file) { - return NULL; + return nullptr; } /** @@ -269,7 +269,7 @@ close_write_file(ostream *stream) { */ iostream *VirtualFileMount:: open_read_write_file(const Filename &file, bool truncate) { - return NULL; + return nullptr; } /** @@ -279,7 +279,7 @@ open_read_write_file(const Filename &file, bool truncate) { */ iostream *VirtualFileMount:: open_read_append_file(const Filename &file) { - return NULL; + return nullptr; } /** diff --git a/panda/src/express/virtualFileMountAndroidAsset.cxx b/panda/src/express/virtualFileMountAndroidAsset.cxx index d7ffb6254a..8f8494b58a 100644 --- a/panda/src/express/virtualFileMountAndroidAsset.cxx +++ b/panda/src/express/virtualFileMountAndroidAsset.cxx @@ -80,7 +80,7 @@ is_regular_file(const Filename &file) const { //express_cat.error() << "is_regular_file " << file << " - " << asset << "\n"; - if (asset == NULL) { + if (asset == nullptr) { return false; } AAsset_close(asset); @@ -107,7 +107,7 @@ read_file(const Filename &file, bool do_uncompress, AAsset* asset; asset = AAssetManager_open(_asset_mgr, file.c_str(), AASSET_MODE_STREAMING); - if (asset == (AAsset *)NULL) { + if (asset == nullptr) { express_cat.info() << "Unable to read " << file << "\n"; return false; @@ -144,8 +144,8 @@ istream *VirtualFileMountAndroidAsset:: open_read_file(const Filename &file) const { AAsset* asset; asset = AAssetManager_open(_asset_mgr, file.c_str(), AASSET_MODE_UNKNOWN); - if (asset == (AAsset *)NULL) { - return NULL; + if (asset == nullptr) { + return nullptr; } AssetStream *stream = new AssetStream(asset); @@ -229,14 +229,14 @@ get_system_info(const Filename &file, SubfileInfo &info) { bool VirtualFileMountAndroidAsset:: scan_directory(vector_string &contents, const Filename &dir) const { AAssetDir *asset_dir = AAssetManager_openDir(_asset_mgr, dir.c_str()); - if (asset_dir == NULL) { + if (asset_dir == nullptr) { return false; } // Note: this returns the full path. const char *fullpath = AAssetDir_getNextFileName(asset_dir); - while (fullpath != NULL) { + while (fullpath != nullptr) { express_cat.error() << fullpath << "\n"; // DEBUG // Determine the basename and add it to the vector. Filename fname (fullpath); diff --git a/panda/src/express/virtualFileMountMultifile.cxx b/panda/src/express/virtualFileMountMultifile.cxx index c871ea39a1..da449c7bc9 100644 --- a/panda/src/express/virtualFileMountMultifile.cxx +++ b/panda/src/express/virtualFileMountMultifile.cxx @@ -89,7 +89,7 @@ istream *VirtualFileMountMultifile:: open_read_file(const Filename &file) const { int subfile_index = _multifile->find_subfile(file); if (subfile_index < 0) { - return NULL; + return nullptr; } // The caller will eventually pass this pointer to diff --git a/panda/src/express/virtualFileMountRamdisk.I b/panda/src/express/virtualFileMountRamdisk.I index 37d89f9ce3..b943f8bb51 100644 --- a/panda/src/express/virtualFileMountRamdisk.I +++ b/panda/src/express/virtualFileMountRamdisk.I @@ -15,7 +15,7 @@ * */ INLINE VirtualFileMountRamdisk::FileBase:: -FileBase(const string &basename) : _basename(basename), _timestamp(time(NULL)) { +FileBase(const string &basename) : _basename(basename), _timestamp(time(nullptr)) { } /** diff --git a/panda/src/express/virtualFileMountRamdisk.cxx b/panda/src/express/virtualFileMountRamdisk.cxx index 78652e9cc3..2f1f481b3d 100644 --- a/panda/src/express/virtualFileMountRamdisk.cxx +++ b/panda/src/express/virtualFileMountRamdisk.cxx @@ -35,7 +35,7 @@ has_file(const Filename &file) const { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); _lock.unlock(); - return (f != NULL); + return (f != nullptr); } /** @@ -48,7 +48,7 @@ create_file(const Filename &file) { _lock.lock(); PT(File) f = _root.do_create_file(file); _lock.unlock(); - return (f != NULL); + return (f != nullptr); } /** @@ -61,7 +61,7 @@ delete_file(const Filename &file) { _lock.lock(); PT(FileBase) f = _root.do_delete_file(file); _lock.unlock(); - return (f != NULL); + return (f != nullptr); } /** @@ -74,7 +74,7 @@ bool VirtualFileMountRamdisk:: rename_file(const Filename &orig_filename, const Filename &new_filename) { _lock.lock(); PT(FileBase) orig_fb = _root.do_find_file(orig_filename); - if (orig_fb == NULL) { + if (orig_fb == nullptr) { _lock.unlock(); return false; } @@ -83,7 +83,7 @@ rename_file(const Filename &orig_filename, const Filename &new_filename) { // Rename the directory. Directory *orig_d = DCAST(Directory, orig_fb); PT(Directory) new_d = _root.do_make_directory(new_filename); - if (new_d == NULL || !new_d->_files.empty()) { + if (new_d == nullptr || !new_d->_files.empty()) { _lock.unlock(); return false; } @@ -102,7 +102,7 @@ rename_file(const Filename &orig_filename, const Filename &new_filename) { // Rename the file. File *orig_f = DCAST(File, orig_fb); PT(File) new_f = _root.do_create_file(new_filename); - if (new_f == NULL) { + if (new_f == nullptr) { _lock.unlock(); return false; } @@ -129,7 +129,7 @@ bool VirtualFileMountRamdisk:: copy_file(const Filename &orig_filename, const Filename &new_filename) { _lock.lock(); PT(FileBase) orig_fb = _root.do_find_file(orig_filename); - if (orig_fb == NULL || orig_fb->is_directory()) { + if (orig_fb == nullptr || orig_fb->is_directory()) { _lock.unlock(); return false; } @@ -137,7 +137,7 @@ copy_file(const Filename &orig_filename, const Filename &new_filename) { // Copy the file. File *orig_f = DCAST(File, orig_fb); PT(File) new_f = _root.do_create_file(new_filename); - if (new_f == NULL) { + if (new_f == nullptr) { _lock.unlock(); return false; } @@ -164,7 +164,7 @@ make_directory(const Filename &file) { _lock.lock(); PT(Directory) f = _root.do_make_directory(file); _lock.unlock(); - return (f != NULL); + return (f != nullptr); } /** @@ -176,7 +176,7 @@ is_directory(const Filename &file) const { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); _lock.unlock(); - return (f != NULL && f->is_directory()); + return (f != nullptr && f->is_directory()); } /** @@ -188,7 +188,7 @@ is_regular_file(const Filename &file) const { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); _lock.unlock(); - return (f != NULL && !f->is_directory()); + return (f != nullptr && !f->is_directory()); } /** @@ -210,8 +210,8 @@ open_read_file(const Filename &file) const { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); _lock.unlock(); - if (f == (FileBase *)NULL || f->is_directory()) { - return NULL; + if (f == nullptr || f->is_directory()) { + return nullptr; } File *f2 = DCAST(File, f); @@ -228,8 +228,8 @@ open_write_file(const Filename &file, bool truncate) { _lock.lock(); PT(File) f = _root.do_create_file(file); _lock.unlock(); - if (f == (File *)NULL) { - return NULL; + if (f == nullptr) { + return nullptr; } if (truncate) { @@ -241,7 +241,7 @@ open_write_file(const Filename &file, bool truncate) { // second, since the timer only has a one second precision. The proper // solution to fix this would be to switch to a higher precision // timer everywhere. - f->_timestamp = max(f->_timestamp + 1, time(NULL)); + f->_timestamp = max(f->_timestamp + 1, time(nullptr)); } return new OSubStream(&f->_wrapper, 0, 0); @@ -257,8 +257,8 @@ open_append_file(const Filename &file) { _lock.lock(); PT(File) f = _root.do_create_file(file); _lock.unlock(); - if (f == (File *)NULL) { - return NULL; + if (f == nullptr) { + return nullptr; } return new OSubStream(&f->_wrapper, 0, 0, true); @@ -274,8 +274,8 @@ open_read_write_file(const Filename &file, bool truncate) { _lock.lock(); PT(File) f = _root.do_create_file(file); _lock.unlock(); - if (f == (File *)NULL) { - return NULL; + if (f == nullptr) { + return nullptr; } if (truncate) { @@ -283,7 +283,7 @@ open_read_write_file(const Filename &file, bool truncate) { f->_data.str(string()); // See open_write_file - f->_timestamp = max(f->_timestamp + 1, time(NULL)); + f->_timestamp = max(f->_timestamp + 1, time(nullptr)); } return new SubStream(&f->_wrapper, 0, 0); @@ -299,8 +299,8 @@ open_read_append_file(const Filename &file) { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); _lock.unlock(); - if (f == (FileBase *)NULL || f->is_directory()) { - return NULL; + if (f == nullptr || f->is_directory()) { + return nullptr; } File *f2 = DCAST(File, f); @@ -317,7 +317,7 @@ get_file_size(const Filename &file, istream *stream) const { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); _lock.unlock(); - if (f == (FileBase *)NULL || f->is_directory()) { + if (f == nullptr || f->is_directory()) { return 0; } @@ -334,7 +334,7 @@ get_file_size(const Filename &file) const { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); _lock.unlock(); - if (f == (FileBase *)NULL || f->is_directory()) { + if (f == nullptr || f->is_directory()) { return 0; } @@ -374,7 +374,7 @@ bool VirtualFileMountRamdisk:: scan_directory(vector_string &contents, const Filename &dir) const { _lock.lock(); PT(FileBase) f = _root.do_find_file(dir); - if (f == (FileBase *)NULL || !f->is_directory()) { + if (f == nullptr || !f->is_directory()) { _lock.unlock(); return false; } @@ -395,7 +395,7 @@ atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents const string &new_contents) { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); - if (f == (FileBase *)NULL || f->is_directory()) { + if (f == nullptr || f->is_directory()) { _lock.unlock(); return false; } @@ -405,7 +405,7 @@ atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents orig_contents = f2->_data.str(); if (orig_contents == old_contents) { f2->_data.str(new_contents); - f2->_timestamp = time(NULL); + f2->_timestamp = time(nullptr); retval = true; } @@ -420,7 +420,7 @@ bool VirtualFileMountRamdisk:: atomic_read_contents(const Filename &file, string &contents) const { _lock.lock(); PT(FileBase) f = _root.do_find_file(file); - if (f == (FileBase *)NULL || f->is_directory()) { + if (f == nullptr || f->is_directory()) { _lock.unlock(); return false; } @@ -479,7 +479,7 @@ do_find_file(const string &filename) const { if (fi != _files.end()) { return (*fi); } - return NULL; + return nullptr; } // A nested directory. Search for the directory name, then recurse. @@ -495,7 +495,7 @@ do_find_file(const string &filename) const { } } - return NULL; + return nullptr; } /** @@ -516,7 +516,7 @@ do_create_file(const string &filename) { return DCAST(File, file.p()); } // Cannot create: a directory by the same name already exists. - return NULL; + return nullptr; } // Create a new file. @@ -526,7 +526,7 @@ do_create_file(const string &filename) { } PT(File) file = new File(filename); _files.insert(file.p()); - _timestamp = time(NULL); + _timestamp = time(nullptr); return file; } @@ -543,7 +543,7 @@ do_create_file(const string &filename) { } } - return NULL; + return nullptr; } /** @@ -564,7 +564,7 @@ do_make_directory(const string &filename) { return DCAST(Directory, file.p()); } // Cannot create: a file by the same name already exists. - return NULL; + return nullptr; } // Create a new directory. @@ -574,7 +574,7 @@ do_make_directory(const string &filename) { } PT(Directory) file = new Directory(filename); _files.insert(file.p()); - _timestamp = time(NULL); + _timestamp = time(nullptr); return file; } @@ -591,7 +591,7 @@ do_make_directory(const string &filename) { } } - return NULL; + return nullptr; } /** @@ -612,14 +612,14 @@ do_delete_file(const string &filename) { Directory *dir = DCAST(Directory, file.p()); if (!dir->_files.empty()) { // Can't delete a nonempty directory. - return NULL; + return nullptr; } } _files.erase(fi); - _timestamp = time(NULL); + _timestamp = time(nullptr); return file; } - return NULL; + return nullptr; } // A nested directory. Search for the directory name, then recurse. @@ -635,7 +635,7 @@ do_delete_file(const string &filename) { } } - return NULL; + return nullptr; } /** diff --git a/panda/src/express/virtualFileMountSystem.cxx b/panda/src/express/virtualFileMountSystem.cxx index cc6041b12c..4ef0d32ab1 100644 --- a/panda/src/express/virtualFileMountSystem.cxx +++ b/panda/src/express/virtualFileMountSystem.cxx @@ -167,7 +167,7 @@ open_read_file(const Filename &file) const { // First ensure that the file exists to validate its case. if (VirtualFileSystem::get_global_ptr()->vfs_case_sensitive) { if (!has_file(file)) { - return NULL; + return nullptr; } } #endif // WIN32 @@ -176,7 +176,7 @@ open_read_file(const Filename &file) const { if (!pathname.open_read(*stream)) { // Couldn't open the file for some reason. close_read_file(stream); - return NULL; + return nullptr; } return stream; @@ -193,7 +193,7 @@ open_write_file(const Filename &file, bool truncate) { // First ensure that the file exists to validate its case. if (VirtualFileSystem::get_global_ptr()->vfs_case_sensitive) { if (!has_file(file)) { - return NULL; + return nullptr; } } #endif // WIN32 @@ -202,7 +202,7 @@ open_write_file(const Filename &file, bool truncate) { if (!pathname.open_write(*stream, truncate)) { // Couldn't open the file for some reason. close_write_file(stream); - return NULL; + return nullptr; } return stream; @@ -219,7 +219,7 @@ open_append_file(const Filename &file) { // First ensure that the file exists to validate its case. if (VirtualFileSystem::get_global_ptr()->vfs_case_sensitive) { if (!has_file(file)) { - return NULL; + return nullptr; } } #endif // WIN32 @@ -228,7 +228,7 @@ open_append_file(const Filename &file) { if (!pathname.open_append(*stream)) { // Couldn't open the file for some reason. close_write_file(stream); - return NULL; + return nullptr; } return stream; @@ -245,7 +245,7 @@ open_read_write_file(const Filename &file, bool truncate) { // First ensure that the file exists to validate its case. if (VirtualFileSystem::get_global_ptr()->vfs_case_sensitive) { if (!has_file(file)) { - return NULL; + return nullptr; } } #endif // WIN32 @@ -254,7 +254,7 @@ open_read_write_file(const Filename &file, bool truncate) { if (!pathname.open_read_write(*stream, truncate)) { // Couldn't open the file for some reason. close_read_write_file(stream); - return NULL; + return nullptr; } return stream; @@ -271,7 +271,7 @@ open_read_append_file(const Filename &file) { // First ensure that the file exists to validate its case. if (VirtualFileSystem::get_global_ptr()->vfs_case_sensitive) { if (!has_file(file)) { - return NULL; + return nullptr; } } #endif // WIN32 @@ -280,7 +280,7 @@ open_read_append_file(const Filename &file) { if (!pathname.open_read_append(*stream)) { // Couldn't open the file for some reason. close_read_write_file(stream); - return NULL; + return nullptr; } return stream; diff --git a/panda/src/express/virtualFileSystem.I b/panda/src/express/virtualFileSystem.I index 3a33e3df9c..b2f86e17bb 100644 --- a/panda/src/express/virtualFileSystem.I +++ b/panda/src/express/virtualFileSystem.I @@ -16,7 +16,7 @@ */ INLINE bool VirtualFileSystem:: exists(const Filename &filename) const { - return get_file(filename, true) != (VirtualFile *)NULL; + return get_file(filename, true) != nullptr; } /** @@ -26,7 +26,7 @@ exists(const Filename &filename) const { INLINE bool VirtualFileSystem:: is_directory(const Filename &filename) const { PT(VirtualFile) file = get_file(filename, true); - return (file != (VirtualFile *)NULL && file->is_directory()); + return (file != nullptr && file->is_directory()); } /** @@ -36,7 +36,7 @@ is_directory(const Filename &filename) const { INLINE bool VirtualFileSystem:: is_regular_file(const Filename &filename) const { PT(VirtualFile) file = get_file(filename, true); - return (file != (VirtualFile *)NULL && file->is_regular_file()); + return (file != nullptr && file->is_regular_file()); } /** @@ -48,8 +48,8 @@ is_regular_file(const Filename &filename) const { INLINE PT(VirtualFileList) VirtualFileSystem:: scan_directory(const Filename &filename) const { PT(VirtualFile) file = get_file(filename, true); - if (file == (VirtualFile *)NULL) { - return NULL; + if (file == nullptr) { + return nullptr; } return file->scan_directory(); @@ -61,7 +61,7 @@ scan_directory(const Filename &filename) const { INLINE void VirtualFileSystem:: ls(const Filename &filename) const { PT(VirtualFile) file = get_file(filename, true); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { express_cat.info() << "Not found: " << filename << "\n"; } else { @@ -76,7 +76,7 @@ ls(const Filename &filename) const { INLINE void VirtualFileSystem:: ls_all(const Filename &filename) const { PT(VirtualFile) file = get_file(filename, true); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { express_cat.info() << "Not found: " << filename << "\n"; } else { @@ -126,7 +126,7 @@ write_file(const Filename &filename, const string &data, bool auto_wrap) { INLINE bool VirtualFileSystem:: read_file(const Filename &filename, string &result, bool auto_unwrap) const { PT(VirtualFile) file = get_file(filename, false); - return (file != (VirtualFile *)NULL && file->read_file(result, auto_unwrap)); + return (file != nullptr && file->read_file(result, auto_unwrap)); } /** @@ -142,7 +142,7 @@ read_file(const Filename &filename, string &result, bool auto_unwrap) const { INLINE bool VirtualFileSystem:: read_file(const Filename &filename, pvector &result, bool auto_unwrap) const { PT(VirtualFile) file = get_file(filename, false); - return (file != (VirtualFile *)NULL && file->read_file(result, auto_unwrap)); + return (file != nullptr && file->read_file(result, auto_unwrap)); } /** @@ -155,5 +155,5 @@ read_file(const Filename &filename, pvector &result, bool auto_un INLINE bool VirtualFileSystem:: write_file(const Filename &filename, const unsigned char *data, size_t data_size, bool auto_wrap) { PT(VirtualFile) file = create_file(filename); - return (file != (VirtualFile *)NULL && file->write_file(data, data_size, auto_wrap)); + return (file != nullptr && file->write_file(data, data_size, auto_wrap)); } diff --git a/panda/src/express/virtualFileSystem.cxx b/panda/src/express/virtualFileSystem.cxx index d69f518bc1..0262392216 100644 --- a/panda/src/express/virtualFileSystem.cxx +++ b/panda/src/express/virtualFileSystem.cxx @@ -25,7 +25,7 @@ #include "executionEnvironment.h" #include "pset.h" -VirtualFileSystem *VirtualFileSystem::_global_ptr = NULL; +VirtualFileSystem *VirtualFileSystem::_global_ptr = nullptr; /** @@ -151,7 +151,7 @@ bool VirtualFileSystem:: mount_loop(const Filename &virtual_filename, const Filename &mount_point, int flags, const string &password) { PT(VirtualFile) file = get_file(virtual_filename, false); - if (file == NULL) { + if (file == nullptr) { express_cat->warning() << "Attempt to mount " << virtual_filename << ", not found.\n"; return false; @@ -218,7 +218,7 @@ unmount(Multifile *multifile) { express_cat->debug() << "unmount " << *mount << " from " << mount->get_mount_point() << "\n"; } - mount->_file_system = NULL; + mount->_file_system = nullptr; } else { // Don't remove this one. @@ -260,7 +260,7 @@ unmount(const Filename &physical_filename) { express_cat->debug() << "unmount " << *mount << " from " << mount->get_mount_point() << "\n"; } - mount->_file_system = NULL; + mount->_file_system = nullptr; } else { // Don't remove this one. @@ -276,7 +276,7 @@ unmount(const Filename &physical_filename) { express_cat->debug() << "unmount " << *mount << " from " << mount->get_mount_point() << "\n"; } - mount->_file_system = NULL; + mount->_file_system = nullptr; } else { // Don't remove this one. @@ -314,7 +314,7 @@ unmount(VirtualFileMount *mount) { express_cat->debug() << "unmount " << *mount << " from " << mount->get_mount_point() << "\n"; } - (*ri)->_file_system = NULL; + (*ri)->_file_system = nullptr; } else { // Don't remove this one. @@ -350,7 +350,7 @@ unmount_point(const Filename &mount_point) { express_cat->debug() << "unmount " << *mount << " from " << mount->get_mount_point() << "\n"; } - mount->_file_system = NULL; + mount->_file_system = nullptr; } else { // Don't remove this one. @@ -380,7 +380,7 @@ unmount_all() { express_cat->debug() << "unmount " << *mount << " from " << mount->get_mount_point() << "\n"; } - mount->_file_system = NULL; + mount->_file_system = nullptr; } int num_removed = _mounts.size(); @@ -409,7 +409,7 @@ get_mount(int n) const { _lock.lock(); nassertd(n >= 0 && n < (int)_mounts.size()) { _lock.unlock(); - return NULL; + return nullptr; } PT(VirtualFileMount) result = _mounts[n]; _lock.unlock(); @@ -432,7 +432,7 @@ chdir(const Filename &new_directory) { } PT(VirtualFile) file = do_get_file(new_directory, OF_status_only); - if (file != (VirtualFile *)NULL && file->is_directory()) { + if (file != nullptr && file->is_directory()) { _cwd = file->get_filename(); _lock.unlock(); return true; @@ -463,7 +463,7 @@ make_directory(const Filename &filename) { _lock.lock(); PT(VirtualFile) result = do_get_file(filename, OF_make_directory); _lock.unlock(); - nassertr_always(result != NULL, false); + nassertr_always(result != nullptr, false); return result->is_directory(); } @@ -490,7 +490,7 @@ make_directory_full(const Filename &filename) { // Now make the last one, and check the return value. PT(VirtualFile) result = do_get_file(filename, OF_make_directory); _lock.unlock(); - nassertr_always(result != NULL, false); + nassertr_always(result != nullptr, false); return result->is_directory(); } @@ -552,12 +552,12 @@ find_file(const Filename &filename, const DSearchPath &searchpath, match = filename; } PT(VirtualFile) found_file = get_file(match, status_only); - if (found_file != (VirtualFile *)NULL) { + if (found_file != nullptr) { return found_file; } } - return NULL; + return nullptr; } /** @@ -568,7 +568,7 @@ find_file(const Filename &filename, const DSearchPath &searchpath, bool VirtualFileSystem:: delete_file(const Filename &filename) { PT(VirtualFile) file = get_file(filename, true); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { return false; } @@ -590,13 +590,13 @@ bool VirtualFileSystem:: rename_file(const Filename &orig_filename, const Filename &new_filename) { _lock.lock(); PT(VirtualFile) orig_file = do_get_file(orig_filename, OF_status_only); - if (orig_file == (VirtualFile *)NULL) { + if (orig_file == nullptr) { _lock.unlock(); return false; } PT(VirtualFile) new_file = do_get_file(new_filename, OF_status_only | OF_allow_nonexist); - if (new_file == (VirtualFile *)NULL) { + if (new_file == nullptr) { _lock.unlock(); return false; } @@ -613,12 +613,12 @@ rename_file(const Filename &orig_filename, const Filename &new_filename) { bool VirtualFileSystem:: copy_file(const Filename &orig_filename, const Filename &new_filename) { PT(VirtualFile) orig_file = get_file(orig_filename, true); - if (orig_file == (VirtualFile *)NULL) { + if (orig_file == nullptr) { return false; } PT(VirtualFile) new_file = create_file(new_filename); - if (new_file == (VirtualFile *)NULL) { + if (new_file == nullptr) { return false; } @@ -733,7 +733,7 @@ write(ostream &out) const { */ VirtualFileSystem *VirtualFileSystem:: get_global_ptr() { - if (_global_ptr == (VirtualFileSystem *)NULL) { + if (_global_ptr == nullptr) { // Make sure this is initialized. init_libexpress(); @@ -839,13 +839,13 @@ get_global_ptr() { istream *VirtualFileSystem:: open_read_file(const Filename &filename, bool auto_unwrap) const { PT(VirtualFile) file = get_file(filename, false); - if (file == (VirtualFile *)NULL) { - return NULL; + if (file == nullptr) { + return nullptr; } istream *str = file->open_read_file(auto_unwrap); - if (str != (istream *)NULL && str->fail()) { + if (str != nullptr && str->fail()) { close_read_file(str); - str = (istream *)NULL; + str = nullptr; } return str; } @@ -858,7 +858,7 @@ open_read_file(const Filename &filename, bool auto_unwrap) const { */ void VirtualFileSystem:: close_read_file(istream *stream) { - if (stream != (istream *)NULL) { + if (stream != nullptr) { // For some reason--compiler bug in gcc 3.2?--explicitly deleting the // stream pointer does not call the appropriate global delete function; // instead apparently calling the system delete function. So we call the @@ -883,13 +883,13 @@ close_read_file(istream *stream) { ostream *VirtualFileSystem:: open_write_file(const Filename &filename, bool auto_wrap, bool truncate) { PT(VirtualFile) file = create_file(filename); - if (file == (VirtualFile *)NULL) { - return NULL; + if (file == nullptr) { + return nullptr; } ostream *str = file->open_write_file(auto_wrap, truncate); - if (str != (ostream *)NULL && str->fail()) { + if (str != nullptr && str->fail()) { close_write_file(str); - str = (ostream *)NULL; + str = nullptr; } return str; } @@ -902,13 +902,13 @@ open_write_file(const Filename &filename, bool auto_wrap, bool truncate) { ostream *VirtualFileSystem:: open_append_file(const Filename &filename) { PT(VirtualFile) file = create_file(filename); - if (file == (VirtualFile *)NULL) { - return NULL; + if (file == nullptr) { + return nullptr; } ostream *str = file->open_append_file(); - if (str != (ostream *)NULL && str->fail()) { + if (str != nullptr && str->fail()) { close_write_file(str); - str = (ostream *)NULL; + str = nullptr; } return str; } @@ -921,7 +921,7 @@ open_append_file(const Filename &filename) { */ void VirtualFileSystem:: close_write_file(ostream *stream) { - if (stream != (ostream *)NULL) { + if (stream != nullptr) { #if (!defined(WIN32_VC) && !defined(WIN64_VC)) && !defined(USE_MEMORY_NOWRAPPERS) && defined(REDEFINE_GLOBAL_OPERATOR_NEW) stream->~ostream(); (*global_operator_delete)(stream); @@ -939,13 +939,13 @@ close_write_file(ostream *stream) { iostream *VirtualFileSystem:: open_read_write_file(const Filename &filename, bool truncate) { PT(VirtualFile) file = create_file(filename); - if (file == (VirtualFile *)NULL) { - return NULL; + if (file == nullptr) { + return nullptr; } iostream *str = file->open_read_write_file(truncate); - if (str != (iostream *)NULL && str->fail()) { + if (str != nullptr && str->fail()) { close_read_write_file(str); - str = (iostream *)NULL; + str = nullptr; } return str; } @@ -958,13 +958,13 @@ open_read_write_file(const Filename &filename, bool truncate) { iostream *VirtualFileSystem:: open_read_append_file(const Filename &filename) { PT(VirtualFile) file = create_file(filename); - if (file == (VirtualFile *)NULL) { - return NULL; + if (file == nullptr) { + return nullptr; } iostream *str = file->open_read_append_file(); - if (str != (iostream *)NULL && str->fail()) { + if (str != nullptr && str->fail()) { close_read_write_file(str); - str = (iostream *)NULL; + str = nullptr; } return str; } @@ -977,7 +977,7 @@ open_read_append_file(const Filename &filename) { */ void VirtualFileSystem:: close_read_write_file(iostream *stream) { - if (stream != (iostream *)NULL) { + if (stream != nullptr) { #if (!defined(WIN32_VC) && !defined(WIN64_VC)) && !defined(USE_MEMORY_NOWRAPPERS) && defined(REDEFINE_GLOBAL_OPERATOR_NEW) stream->~iostream(); (*global_operator_delete)(stream); @@ -995,7 +995,7 @@ atomic_compare_and_exchange_contents(const Filename &filename, string &orig_cont const string &old_contents, const string &new_contents) { PT(VirtualFile) file = create_file(filename); - if (file == NULL) { + if (file == nullptr) { return false; } @@ -1008,7 +1008,7 @@ atomic_compare_and_exchange_contents(const Filename &filename, string &orig_cont bool VirtualFileSystem:: atomic_read_contents(const Filename &filename, string &contents) const { PT(VirtualFile) file = get_file(filename, false); - if (file == NULL) { + if (file == nullptr) { return false; } @@ -1118,7 +1118,7 @@ normalize_mount_point(const Filename &mount_point) const { */ bool VirtualFileSystem:: do_mount(VirtualFileMount *mount, const Filename &mount_point, int flags) { - nassertr(mount->_file_system == NULL, false); + nassertr(mount->_file_system == nullptr, false); mount->_file_system = this; mount->_mount_point = normalize_mount_point(mount_point); mount->_mount_flags = flags; @@ -1134,7 +1134,7 @@ do_mount(VirtualFileMount *mount, const Filename &mount_point, int flags) { PT(VirtualFile) VirtualFileSystem:: do_get_file(const Filename &filename, int open_flags) const { if (filename.empty()) { - return NULL; + return nullptr; } Filename pathname(filename); if (pathname.is_local()) { @@ -1151,8 +1151,8 @@ do_get_file(const Filename &filename, int open_flags) const { // Now scan all the mount points, from the back (since later mounts override // more recent ones), until a match is found. - PT(VirtualFile) found_file = NULL; - VirtualFileComposite *composite_file = NULL; + PT(VirtualFile) found_file = nullptr; + VirtualFileComposite *composite_file = nullptr; // We use an index instead of an iterator, since the vector might change if // implicit mounts are added during this loop. @@ -1214,7 +1214,7 @@ do_get_file(const Filename &filename, int open_flags) const { } } - if (found_file == (VirtualFile *)NULL && vfs_implicit_mf) { + if (found_file == nullptr && vfs_implicit_mf) { // The file wasn't found, as-is. Does it appear to be an implicit .mf // file reference? ((VirtualFileSystem *)this)->consider_mount_mf(filename); @@ -1268,7 +1268,7 @@ consider_match(PT(VirtualFile) &found_file, VirtualFileComposite *&composite_fil return false; } - if (found_file == (VirtualFile *)NULL) { + if (found_file == nullptr) { // This was our first match. Save it. found_file = vfile; if (!found_file->is_directory() || ((open_flags & OF_make_directory) != 0)) { @@ -1279,7 +1279,7 @@ consider_match(PT(VirtualFile) &found_file, VirtualFileComposite *&composite_fil // It is a directory, so save it for later. if (implicit_pz_file) { // Don't look for directories named file.pz. - found_file = NULL; + found_file = nullptr; } } else { @@ -1293,7 +1293,7 @@ consider_match(PT(VirtualFile) &found_file, VirtualFileComposite *&composite_fil if (!implicit_pz_file) { // At least two directories matched to the same path. We need a // composite directory. - if (composite_file == (VirtualFileComposite *)NULL) { + if (composite_file == nullptr) { composite_file = new VirtualFileComposite((VirtualFileSystem *)this, found_file->get_original_filename()); composite_file->set_original_filename(original_filename); @@ -1333,7 +1333,7 @@ consider_mount_mf(const Filename &filename) { // Hey, here's a multifile reference! dirname.set_binary(); PT(VirtualFile) file = do_get_file(dirname, false); - if (file == (VirtualFile *)NULL || !file->is_regular_file()) { + if (file == nullptr || !file->is_regular_file()) { // Oh, never mind. Not a real file. return false; } @@ -1341,7 +1341,7 @@ consider_mount_mf(const Filename &filename) { PT(Multifile) multifile = new Multifile; istream *stream = file->open_read_file(false); - if (stream == (istream *)NULL) { + if (stream == nullptr) { // Couldn't read file. return false; } diff --git a/panda/src/express/virtualFileSystem_ext.cxx b/panda/src/express/virtualFileSystem_ext.cxx index 6bc375c0d9..6018378f90 100644 --- a/panda/src/express/virtualFileSystem_ext.cxx +++ b/panda/src/express/virtualFileSystem_ext.cxx @@ -73,11 +73,11 @@ write_file(const Filename &filename, PyObject *data, bool auto_wrap) { #if PY_MAJOR_VERSION >= 3 if (PyBytes_AsStringAndSize(data, &buffer, &length) == -1) { - return NULL; + return nullptr; } #else if (PyString_AsStringAndSize(data, &buffer, &length) == -1) { - return NULL; + return nullptr; } #endif diff --git a/panda/src/express/virtualFile_ext.cxx b/panda/src/express/virtualFile_ext.cxx index db1a9a62ab..afe7473bbd 100644 --- a/panda/src/express/virtualFile_ext.cxx +++ b/panda/src/express/virtualFile_ext.cxx @@ -74,11 +74,11 @@ write_file(PyObject *data, bool auto_wrap) { #if PY_MAJOR_VERSION >= 3 if (PyBytes_AsStringAndSize(data, &buffer, &length) == -1) { - return NULL; + return nullptr; } #else if (PyString_AsStringAndSize(data, &buffer, &length) == -1) { - return NULL; + return nullptr; } #endif diff --git a/panda/src/express/weakPointerTo.h b/panda/src/express/weakPointerTo.h index 897c46a210..ffc1d0dd3a 100644 --- a/panda/src/express/weakPointerTo.h +++ b/panda/src/express/weakPointerTo.h @@ -30,7 +30,7 @@ class WeakPointerTo : public WeakPointerToBase { public: typedef TYPENAME WeakPointerToBase::To To; PUBLISHED: - INLINE WeakPointerTo(To *ptr = (To *)NULL); + INLINE WeakPointerTo(To *ptr = nullptr); INLINE WeakPointerTo(const PointerTo ©); INLINE WeakPointerTo(const WeakPointerTo ©); @@ -66,7 +66,7 @@ class WeakConstPointerTo : public WeakPointerToBase { public: typedef TYPENAME WeakPointerToBase::To To; PUBLISHED: - INLINE WeakConstPointerTo(const To *ptr = (const To *)NULL); + INLINE WeakConstPointerTo(const To *ptr = nullptr); INLINE WeakConstPointerTo(const PointerTo ©); INLINE WeakConstPointerTo(const ConstPointerTo ©); INLINE WeakConstPointerTo(const WeakPointerTo ©); diff --git a/panda/src/express/weakPointerToBase.I b/panda/src/express/weakPointerToBase.I index 5ba737d507..938196cc33 100644 --- a/panda/src/express/weakPointerToBase.I +++ b/panda/src/express/weakPointerToBase.I @@ -509,7 +509,7 @@ output(ostream &out) const { out << _void_ptr; if (was_deleted()) { out << ":deleted"; - } else if (_void_ptr != (void *)NULL) { + } else if (_void_ptr != nullptr) { out << ":" << ((To *)_void_ptr)->get_ref_count(); } } diff --git a/panda/src/express/windowsRegistry.cxx b/panda/src/express/windowsRegistry.cxx index a803234a6c..29255a5e74 100644 --- a/panda/src/express/windowsRegistry.cxx +++ b/panda/src/express/windowsRegistry.cxx @@ -44,8 +44,8 @@ set_string_value(const string &key, const string &name, const string &value, int mb_result_len = WideCharToMultiByte(CP_ACP, 0, wvalue.data(), wvalue.length(), - NULL, 0, - NULL, NULL); + nullptr, 0, + nullptr, nullptr); if (mb_result_len == 0) { express_cat.error() << "Unable to convert '" << value @@ -57,7 +57,7 @@ set_string_value(const string &key, const string &name, const string &value, WideCharToMultiByte(CP_ACP, 0, wvalue.data(), wvalue.length(), mb_result, mb_result_len, - NULL, NULL); + nullptr, nullptr); if (express_cat.is_debug()) { express_cat.debug() @@ -139,7 +139,7 @@ get_string_value(const string &key, const string &name, int wide_result_len = MultiByteToWideChar(CP_ACP, 0, data.data(), data.length(), - NULL, 0); + nullptr, 0); if (wide_result_len == 0) { express_cat.error() << "Unable to convert '" << data @@ -345,7 +345,7 @@ format_message(int error_code) { PVOID buffer; DWORD length = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, error_code, 0, (LPTSTR)&buffer, 0, NULL); + nullptr, error_code, 0, (LPTSTR)&buffer, 0, nullptr); if (length == 0) { return "Unknown error message"; } diff --git a/panda/src/express/zStreamBuf.cxx b/panda/src/express/zStreamBuf.cxx index c6af03499b..c037252895 100644 --- a/panda/src/express/zStreamBuf.cxx +++ b/panda/src/express/zStreamBuf.cxx @@ -35,9 +35,9 @@ do_zlib_free(voidpf opaque, voidpf address) { */ ZStreamBuf:: ZStreamBuf() { - _source = (istream *)NULL; + _source = nullptr; _owns_source = false; - _dest = (ostream *)NULL; + _dest = nullptr; _owns_dest = false; #ifdef PHAVE_IOSTREAM @@ -100,7 +100,7 @@ open_read(istream *source, bool owns_source) { */ void ZStreamBuf:: close_read() { - if (_source != (istream *)NULL) { + if (_source != nullptr) { int result = inflateEnd(&_z_source); if (result < 0) { @@ -112,7 +112,7 @@ close_read() { delete _source; _owns_source = false; } - _source = (istream *)NULL; + _source = nullptr; } } @@ -151,7 +151,7 @@ open_write(ostream *dest, bool owns_dest, int compression_level) { */ void ZStreamBuf:: close_write() { - if (_dest != (ostream *)NULL) { + if (_dest != nullptr) { size_t n = pptr() - pbase(); write_chars(pbase(), n, Z_FINISH); pbump(-(int)n); @@ -166,7 +166,7 @@ close_write() { delete _dest; _owns_dest = false; } - _dest = (ostream *)NULL; + _dest = nullptr; } } @@ -250,12 +250,12 @@ overflow(int ch) { */ int ZStreamBuf:: sync() { - if (_source != (istream *)NULL) { + if (_source != nullptr) { size_t n = egptr() - gptr(); gbump(n); } - if (_dest != (ostream *)NULL) { + if (_dest != nullptr) { size_t n = pptr() - pbase(); write_chars(pbase(), n, Z_SYNC_FLUSH); pbump(-(int)n); @@ -427,7 +427,7 @@ show_zlib_error(const char *function, int error_code, z_stream &z) { default: error_line << error_code; } - if (z.msg != (char *)NULL) { + if (z.msg != nullptr) { error_line << " = " << z.msg; } diff --git a/panda/src/ffmpeg/ffmpegAudio.cxx b/panda/src/ffmpeg/ffmpegAudio.cxx index ee7fee8669..6fd9a01c9e 100644 --- a/panda/src/ffmpeg/ffmpegAudio.cxx +++ b/panda/src/ffmpeg/ffmpegAudio.cxx @@ -41,9 +41,9 @@ FfmpegAudio:: PT(MovieAudioCursor) FfmpegAudio:: open() { PT(FfmpegAudioCursor) result = new FfmpegAudioCursor(this); - if (result->_format_ctx == 0) { + if (result->_format_ctx == nullptr) { ffmpeg_cat.error() << "Could not open " << _filename << "\n"; - return NULL; + return nullptr; } else { return (MovieAudioCursor*)(FfmpegAudioCursor*)result; } diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.cxx b/panda/src/ffmpeg/ffmpegAudioCursor.cxx index ef6cd14d92..dd5d49cc59 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.cxx +++ b/panda/src/ffmpeg/ffmpegAudioCursor.cxx @@ -46,14 +46,14 @@ FfmpegAudioCursor:: FfmpegAudioCursor(FfmpegAudio *src) : MovieAudioCursor(src), _filename(src->_filename), - _packet(0), - _packet_data(0), - _format_ctx(0), - _audio_ctx(0), - _resample_ctx(0), - _buffer(0), - _buffer_alloc(0), - _frame(0) + _packet(nullptr), + _packet_data(nullptr), + _format_ctx(nullptr), + _audio_ctx(nullptr), + _resample_ctx(nullptr), + _buffer(nullptr), + _buffer_alloc(nullptr), + _frame(nullptr) { if (!_ffvfile.open_vfs(_filename)) { cleanup(); @@ -61,9 +61,9 @@ FfmpegAudioCursor(FfmpegAudio *src) : } _format_ctx = _ffvfile.get_format_context(); - nassertv(_format_ctx != NULL); + nassertv(_format_ctx != nullptr); - if (avformat_find_stream_info(_format_ctx, NULL) < 0) { + if (avformat_find_stream_info(_format_ctx, nullptr) < 0) { cleanup(); return; } @@ -102,7 +102,7 @@ FfmpegAudioCursor(FfmpegAudio *src) : _audio_channels = codecpar->channels; AVCodec *pAudioCodec = avcodec_find_decoder(codecpar->codec_id); - if (pAudioCodec == 0) { + if (pAudioCodec == nullptr) { cleanup(); return; } @@ -120,9 +120,9 @@ FfmpegAudioCursor(FfmpegAudio *src) : avcodec_copy_context(_audio_ctx, codecpar); #endif - AVDictionary *opts = NULL; + AVDictionary *opts = nullptr; av_dict_set(&opts, "request_sample_fmt", "s16", 0); - if (avcodec_open2(_audio_ctx, pAudioCodec, NULL) < 0) { + if (avcodec_open2(_audio_ctx, pAudioCodec, nullptr) < 0) { cleanup(); return; } @@ -148,7 +148,7 @@ FfmpegAudioCursor(FfmpegAudio *src) : if (swr_init(_resample_ctx) != 0) { ffmpeg_cat.error() << "Failed to set up resample context.\n"; - _resample_ctx = NULL; + _resample_ctx = nullptr; } #else ffmpeg_cat.error() @@ -176,7 +176,7 @@ FfmpegAudioCursor(FfmpegAudio *src) : _buffer_alloc = new int16_t[_buffer_size + 64]; // Allocate enough space for 1024 samples per channel. - if ((_packet == 0)||(_buffer_alloc == 0)) { + if ((_packet == nullptr)||(_buffer_alloc == nullptr)) { cleanup(); return; } @@ -216,7 +216,7 @@ cleanup() { #else avcodec_free_frame(&_frame); #endif - _frame = NULL; + _frame = nullptr; } if (_packet) { @@ -227,14 +227,14 @@ cleanup() { av_free_packet(_packet); } delete _packet; - _packet = NULL; + _packet = nullptr; #endif } if (_buffer_alloc) { delete[] _buffer_alloc; - _buffer_alloc = 0; - _buffer = NULL; + _buffer_alloc = nullptr; + _buffer = nullptr; } if ((_audio_ctx)&&(_audio_ctx->codec)) { @@ -245,17 +245,17 @@ cleanup() { delete _audio_ctx; #endif } - _audio_ctx = NULL; + _audio_ctx = nullptr; if (_format_ctx) { _ffvfile.close(); - _format_ctx = NULL; + _format_ctx = nullptr; } #ifdef HAVE_SWRESAMPLE if (_resample_ctx) { swr_free(&_resample_ctx); - _resample_ctx = NULL; + _resample_ctx = nullptr; } #endif @@ -287,9 +287,9 @@ fetch_packet() { av_free_packet(_packet); #endif } - _packet->data = 0; + _packet->data = nullptr; _packet_size = 0; - _packet_data = 0; + _packet_data = nullptr; } /** @@ -320,7 +320,7 @@ reload_buffer() { fetch_packet(); if (_packet->data == nullptr) { // fetch_packet() says we're out of packets. Let the codec know. - ret = avcodec_send_packet(_audio_ctx, NULL); + ret = avcodec_send_packet(_audio_ctx, nullptr); } } @@ -444,7 +444,7 @@ seek(double t) { double ts = _packet->dts * _audio_timebase; if (t > ts) { int skip = (int)((t-ts) * _audio_rate); - read_samples(skip, 0); + read_samples(skip, nullptr); } _last_seek = t; _samples_read = 0; @@ -469,7 +469,7 @@ read_samples(int n, int16_t *data) { int available = _buffer_tail - _buffer_head; int ncopy = (desired > available) ? available : desired; if (ncopy) { - if (data != 0) { + if (data != nullptr) { memcpy(data, _buffer + _buffer_head, ncopy * 2); data += ncopy; } diff --git a/panda/src/ffmpeg/ffmpegVideo.cxx b/panda/src/ffmpeg/ffmpegVideo.cxx index a16336260e..c12892fe47 100644 --- a/panda/src/ffmpeg/ffmpegVideo.cxx +++ b/panda/src/ffmpeg/ffmpegVideo.cxx @@ -56,9 +56,9 @@ FfmpegVideo:: PT(MovieVideoCursor) FfmpegVideo:: open() { PT(FfmpegVideoCursor) result = new FfmpegVideoCursor(this); - if (result->_format_ctx == 0) { + if (result->_format_ctx == nullptr) { ffmpeg_cat.error() << "Could not open " << _filename << "\n"; - return NULL; + return nullptr; } else { return result.p(); } diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.cxx b/panda/src/ffmpeg/ffmpegVideoCursor.cxx index 21137b30e8..b7b67a8ecf 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx +++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx @@ -51,14 +51,14 @@ FfmpegVideoCursor() : _action_cvar(_lock), _thread_status(TS_stopped), _seek_frame(0), - _packet(NULL), - _format_ctx(NULL), - _video_ctx(NULL), - _convert_ctx(NULL), + _packet(nullptr), + _format_ctx(nullptr), + _video_ctx(nullptr), + _convert_ctx(nullptr), _pixel_format((int)AV_PIX_FMT_NONE), _video_index(-1), - _frame(NULL), - _frame_out(NULL), + _frame(nullptr), + _frame_out(nullptr), _eof_known(false) { } @@ -69,8 +69,8 @@ FfmpegVideoCursor() : */ void FfmpegVideoCursor:: init_from(FfmpegVideo *source) { - nassertv(_thread == NULL && _thread_status == TS_stopped); - nassertv(source != NULL); + nassertv(_thread == nullptr && _thread_status == TS_stopped); + nassertv(source != nullptr); _source = source; _filename = _source->get_filename(); @@ -89,7 +89,7 @@ init_from(FfmpegVideo *source) { _frame_out = avcodec_alloc_frame(); #endif - if ((_frame == 0)||(_frame_out == 0)) { + if ((_frame == nullptr)||(_frame_out == nullptr)) { cleanup(); return; } @@ -122,10 +122,10 @@ init_from(FfmpegVideo *source) { } #ifdef HAVE_SWSCALE - nassertv(_convert_ctx == NULL); + nassertv(_convert_ctx == nullptr); _convert_ctx = sws_getContext(_size_x, _size_y, _video_ctx->pix_fmt, _size_x, _size_y, (AVPixelFormat)_pixel_format, - SWS_BILINEAR | SWS_PRINT_INFO, NULL, NULL, NULL); + SWS_BILINEAR | SWS_PRINT_INFO, nullptr, nullptr, nullptr); #endif // HAVE_SWSCALE #ifdef HAVE_THREADS @@ -144,13 +144,13 @@ FfmpegVideoCursor(FfmpegVideo *src) : _action_cvar(_lock), _thread_status(TS_stopped), _seek_frame(0), - _packet(NULL), - _format_ctx(NULL), - _video_ctx(NULL), - _convert_ctx(NULL), + _packet(nullptr), + _format_ctx(nullptr), + _video_ctx(nullptr), + _convert_ctx(nullptr), _video_index(-1), - _frame(NULL), - _frame_out(NULL), + _frame(nullptr), + _frame_out(nullptr), _eof_known(false) { init_from(src); @@ -256,7 +256,7 @@ start_thread() { _thread = new GenericThread(_filename.get_basename(), _sync_name, st_thread_main, this); if (!_thread->start(_thread_priority, true)) { // Couldn't start the thread. - _thread = NULL; + _thread = nullptr; _thread_status = TS_stopped; } } @@ -279,7 +279,7 @@ stop_thread() { _thread_status = TS_shutdown; } _action_cvar.notify(); - _thread = NULL; + _thread = nullptr; } // Now that we've released the lock, we can join the thread. @@ -334,7 +334,7 @@ set_time(double timestamp, int loop_count) { } _current_frame = frame; - if (_current_frame_buffer != NULL) { + if (_current_frame_buffer != nullptr) { // If we've previously returned a frame, don't bother asking for a next // one if that frame is still valid. return (_current_frame >= _current_frame_buffer->_end_frame || @@ -353,8 +353,8 @@ fetch_buffer() { MutexHolder holder(_lock); // If there was an error at any point, just return NULL. - if (_format_ctx == (AVFormatContext *)NULL) { - return NULL; + if (_format_ctx == nullptr) { + return nullptr; } PT(FfmpegBuffer) frame; @@ -400,7 +400,7 @@ fetch_buffer() { } } } - if (frame == NULL || frame->_end_frame < _current_frame) { + if (frame == nullptr || frame->_end_frame < _current_frame) { // No frame available, or the frame is too old. Seek. if (_thread_status == TS_wait || _thread_status == TS_seek || _thread_status == TS_readahead) { _thread_status = TS_seek; @@ -410,16 +410,16 @@ fetch_buffer() { } } - if (frame != NULL) { + if (frame != nullptr) { bool too_old = (frame->_end_frame < _current_frame && !ffmpeg_show_seek_frames); bool too_new = frame->_begin_frame > _current_frame; if (too_old || too_new) { // The frame is too old or too new. Just recycle it. - frame = NULL; + frame = nullptr; } } - if (frame != NULL) { + if (frame != nullptr) { _current_frame_buffer = frame; if (ffmpeg_cat.is_debug()) { ffmpeg_cat.debug() @@ -475,18 +475,18 @@ open_stream() { } } - nassertr(_format_ctx == NULL, false); + nassertr(_format_ctx == nullptr, false); _format_ctx = _ffvfile.get_format_context(); - nassertr(_format_ctx != NULL, false); + nassertr(_format_ctx != nullptr, false); - if (avformat_find_stream_info(_format_ctx, NULL) < 0) { + if (avformat_find_stream_info(_format_ctx, nullptr) < 0) { ffmpeg_cat.info() << "Couldn't find stream info\n"; close_stream(); return false; } - nassertr(_video_ctx == NULL, false); + nassertr(_video_ctx == nullptr, false); // As of libavformat version 57.41.100, AVStream.codec is deprecated in favor // of AVStream.codecpar. Fortunately, the two structures have @@ -522,7 +522,7 @@ open_stream() { _video_timebase = av_q2d(stream->time_base); _min_fseek = (int)(3.0 / _video_timebase); - AVCodec *pVideoCodec = NULL; + AVCodec *pVideoCodec = nullptr; if (ffmpeg_prefer_libvpx) { #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 0, 0) if (codecpar->codec_id == AV_CODEC_ID_VP9) { @@ -533,10 +533,10 @@ open_stream() { pVideoCodec = avcodec_find_decoder_by_name("libvpx"); } } - if (pVideoCodec == NULL) { + if (pVideoCodec == nullptr) { pVideoCodec = avcodec_find_decoder(codecpar->codec_id); } - if (pVideoCodec == NULL) { + if (pVideoCodec == nullptr) { ffmpeg_cat.info() << "Couldn't find codec\n"; close_stream(); @@ -558,7 +558,7 @@ open_stream() { avcodec_copy_context(_video_ctx, codecpar); #endif - if (avcodec_open2(_video_ctx, pVideoCodec, NULL) < 0) { + if (avcodec_open2(_video_ctx, pVideoCodec, nullptr) < 0) { ffmpeg_cat.info() << "Couldn't open codec\n"; close_stream(); @@ -591,10 +591,10 @@ close_stream() { delete _video_ctx; #endif } - _video_ctx = NULL; + _video_ctx = nullptr; _ffvfile.close(); - _format_ctx = NULL; + _format_ctx = nullptr; _video_index = -1; } @@ -610,21 +610,21 @@ cleanup() { ReMutexHolder av_holder(_av_lock); #ifdef HAVE_SWSCALE - if (_convert_ctx != NULL) { + if (_convert_ctx != nullptr) { sws_freeContext(_convert_ctx); } - _convert_ctx = NULL; + _convert_ctx = nullptr; #endif // HAVE_SWSCALE if (_frame) { av_free(_frame); - _frame = NULL; + _frame = nullptr; } if (_frame_out) { - _frame_out->data[0] = 0; + _frame_out->data[0] = nullptr; av_free(_frame_out); - _frame_out = NULL; + _frame_out = nullptr; } if (_packet) { @@ -635,7 +635,7 @@ cleanup() { av_free_packet(_packet); } delete _packet; - _packet = NULL; + _packet = nullptr; #endif } } @@ -711,7 +711,7 @@ do_poll() { if ((int)_readahead_frames.size() < _max_readahead_frames) { // Time to read the next frame. PT(FfmpegBuffer) frame = do_alloc_frame(); - nassertr(frame != NULL, false); + nassertr(frame != nullptr, false); _lock.release(); fetch_frame(-1); if (_frame_ready) { @@ -734,7 +734,7 @@ do_poll() { int seek_frame = _seek_frame; _thread_status = TS_seeking; PT(FfmpegBuffer) frame = do_alloc_frame(); - nassertr(frame != NULL, false); + nassertr(frame != nullptr, false); _lock.release(); advance_to_frame(seek_frame); if (_frame_ready) { @@ -819,7 +819,7 @@ do_fetch_packet(int default_frame) { av_free_packet(_packet); #endif } - _packet->data = 0; + _packet->data = nullptr; if (!_eof_known && default_frame != 0) { _eof_frame = _packet_frame; @@ -1146,7 +1146,7 @@ export_frame(FfmpegBuffer *buffer) { if (ffmpeg_global_lock) { ReMutexHolder av_holder(_av_lock); #ifdef HAVE_SWSCALE - nassertv(_convert_ctx != NULL && _frame != NULL && _frame_out != NULL); + nassertv(_convert_ctx != nullptr && _frame != nullptr && _frame_out != nullptr); sws_scale(_convert_ctx, _frame->data, _frame->linesize, 0, _size_y, _frame_out->data, _frame_out->linesize); #else img_convert((AVPicture *)_frame_out, (AVPixelFormat)_pixel_format, @@ -1154,7 +1154,7 @@ export_frame(FfmpegBuffer *buffer) { #endif } else { #ifdef HAVE_SWSCALE - nassertv(_convert_ctx != NULL && _frame != NULL && _frame_out != NULL); + nassertv(_convert_ctx != nullptr && _frame != nullptr && _frame_out != nullptr); sws_scale(_convert_ctx, _frame->data, _frame->linesize, 0, _size_y, _frame_out->data, _frame_out->linesize); #else img_convert((AVPicture *)_frame_out, (AVPixelFormat)_pixel_format, @@ -1190,7 +1190,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { */ void FfmpegVideoCursor:: finalize(BamReader *) { - if (_source != (MovieVideo *)NULL) { + if (_source != nullptr) { FfmpegVideo *video; DCAST_INTO_V(video, _source); init_from(video); diff --git a/panda/src/ffmpeg/ffmpegVirtualFile.I b/panda/src/ffmpeg/ffmpegVirtualFile.I index c7a65bef36..c7e8e5d6c2 100644 --- a/panda/src/ffmpeg/ffmpegVirtualFile.I +++ b/panda/src/ffmpeg/ffmpegVirtualFile.I @@ -16,7 +16,7 @@ */ INLINE bool FfmpegVirtualFile:: is_open() const { - return (_format_context != NULL); + return (_format_context != nullptr); } /** diff --git a/panda/src/ffmpeg/ffmpegVirtualFile.cxx b/panda/src/ffmpeg/ffmpegVirtualFile.cxx index b671ce0ba6..6acf6debcd 100644 --- a/panda/src/ffmpeg/ffmpegVirtualFile.cxx +++ b/panda/src/ffmpeg/ffmpegVirtualFile.cxx @@ -31,9 +31,9 @@ extern "C" { */ FfmpegVirtualFile:: FfmpegVirtualFile() : - _io_context(NULL), - _format_context(NULL), - _in(NULL), + _io_context(nullptr), + _format_context(nullptr), + _in(nullptr), _owns_in(false), _buffer_size(ffmpeg_read_buffer_size) { @@ -65,12 +65,12 @@ open_vfs(const Filename &filename) { Filename fname = filename; fname.set_binary(); PT(VirtualFile) vfile = vfs->get_file(fname); - if (vfile == NULL) { + if (vfile == nullptr) { return false; } _in = vfile->open_read_file(true); - if (_in == NULL) { + if (_in == nullptr) { return false; } @@ -84,14 +84,14 @@ open_vfs(const Filename &filename) { // pointer. unsigned char *buffer = (unsigned char*) av_malloc(_buffer_size); _io_context = avio_alloc_context(buffer, _buffer_size, 0, (void*) this, - &read_packet, 0, &seek); + &read_packet, nullptr, &seek); _format_context = avformat_alloc_context(); _format_context->pb = _io_context; // Now we can open the stream. int result = - avformat_open_input(&_format_context, "", NULL, NULL); + avformat_open_input(&_format_context, "", nullptr, nullptr); if (result < 0) { close(); return false; @@ -132,14 +132,14 @@ open_subfile(const SubfileInfo &info) { // pointer. unsigned char *buffer = (unsigned char*) av_malloc(_buffer_size); _io_context = avio_alloc_context(buffer, _buffer_size, 0, (void*) this, - &read_packet, 0, &seek); + &read_packet, nullptr, &seek); _format_context = avformat_alloc_context(); _format_context->pb = _io_context; // Now we can open the stream. int result = - avformat_open_input(&_format_context, fname.c_str(), NULL, NULL); + avformat_open_input(&_format_context, fname.c_str(), nullptr, nullptr); if (result < 0) { close(); return false; @@ -154,24 +154,24 @@ open_subfile(const SubfileInfo &info) { */ void FfmpegVirtualFile:: close() { - if (_format_context != NULL) { + if (_format_context != nullptr) { avformat_close_input(&_format_context); } - if (_io_context != NULL) { - if (_io_context->buffer != NULL) { + if (_io_context != nullptr) { + if (_io_context->buffer != nullptr) { av_free(_io_context->buffer); } av_free(_io_context); - _io_context = NULL; + _io_context = nullptr; } if (_owns_in) { - nassertv(_in != NULL); + nassertv(_in != nullptr); VirtualFileSystem::close_read_file(_in); _owns_in = false; } - _in = NULL; + _in = nullptr; } /** diff --git a/panda/src/framework/pandaFramework.I b/panda/src/framework/pandaFramework.I index 552d5bc2f2..d17bc8dad7 100644 --- a/panda/src/framework/pandaFramework.I +++ b/panda/src/framework/pandaFramework.I @@ -17,7 +17,7 @@ */ INLINE GraphicsEngine *PandaFramework:: get_graphics_engine() { - if (_engine == (GraphicsEngine *)NULL) { + if (_engine == nullptr) { _engine = GraphicsEngine::get_global_ptr(); PT(GenericAsyncTask) task = new GenericAsyncTask("igloop", task_igloop, this); task->set_sort(50); @@ -74,7 +74,7 @@ get_num_windows() const { */ INLINE WindowFramework *PandaFramework:: get_window(int n) const { - nassertr(n >= 0 && n < (int)_windows.size(), NULL); + nassertr(n >= 0 && n < (int)_windows.size(), nullptr); return _windows[n]; } diff --git a/panda/src/framework/pandaFramework.cxx b/panda/src/framework/pandaFramework.cxx index 30968e70b3..26f5f2d3ce 100644 --- a/panda/src/framework/pandaFramework.cxx +++ b/panda/src/framework/pandaFramework.cxx @@ -50,7 +50,7 @@ PandaFramework() : _is_open = false; _made_default_pipe = false; _window_title = string(); - _engine = (GraphicsEngine *)NULL; + _engine = nullptr; _start_time = 0.0; _frame_count = 0; _wireframe_enabled = false; @@ -172,9 +172,9 @@ close_framework() { close_all_windows(); // Also close down any other windows that might have been opened. - if (_engine != (GraphicsEngine *)NULL) { + if (_engine != nullptr) { _engine->remove_all_windows(); - _engine = NULL; + _engine = nullptr; } _event_handler.remove_all_hooks(); @@ -191,7 +191,7 @@ close_framework() { _default_keys_enabled = false; _exit_flag = false; - _recorder = NULL; + _recorder = nullptr; Thread::prepare_for_exit(); } @@ -208,7 +208,7 @@ close_framework() { */ GraphicsPipe *PandaFramework:: get_default_pipe() { - nassertr(_is_open, NULL); + nassertr(_is_open, nullptr); if (!_made_default_pipe) { make_default_pipe(); _made_default_pipe = true; @@ -240,7 +240,7 @@ get_mouse(GraphicsOutput *window) { mouse = data_root.attach_new_node(mouse_node); RecorderController *recorder = get_recorder(); - if (recorder != (RecorderController *)NULL) { + if (recorder != nullptr) { // If we're in recording or playback mode, associate a recorder. MouseRecorder *mouse_recorder = new MouseRecorder("mouse"); mouse = mouse.attach_new_node(mouse_recorder); @@ -324,13 +324,13 @@ get_default_window_props(WindowProperties &props) { WindowFramework *PandaFramework:: open_window() { GraphicsPipe *pipe = get_default_pipe(); - if (pipe == (GraphicsPipe *)NULL) { + if (pipe == nullptr) { // Can't get a pipe. - return NULL; + return nullptr; } - WindowFramework *wf = open_window(pipe, NULL); - if (wf == (WindowFramework *)NULL) { + WindowFramework *wf = open_window(pipe, nullptr); + if (wf == nullptr) { // Ok, the default graphics pipe failed; try a little harder. GraphicsPipeSelection *selection = GraphicsPipeSelection::get_global_ptr(); selection->load_aux_modules(); @@ -340,9 +340,9 @@ open_window() { TypeHandle pipe_type = selection->get_pipe_type(i); if (pipe_type != _default_pipe->get_type()) { PT(GraphicsPipe) new_pipe = selection->make_pipe(pipe_type); - if (new_pipe != (GraphicsPipe *)NULL) { - wf = open_window(new_pipe, NULL); - if (wf != (WindowFramework *)NULL) { + if (new_pipe != nullptr) { + wf = open_window(new_pipe, nullptr); + if (wf != nullptr) { // Here's the winner! _default_pipe = new_pipe; return wf; @@ -364,7 +364,7 @@ open_window() { */ WindowFramework *PandaFramework:: open_window(GraphicsPipe *pipe, GraphicsStateGuardian *gsg) { - nassertr(_is_open, NULL); + nassertr(_is_open, nullptr); WindowProperties props; get_default_window_props(props); @@ -387,15 +387,15 @@ open_window(GraphicsPipe *pipe, GraphicsStateGuardian *gsg) { WindowFramework *PandaFramework:: open_window(const WindowProperties &props, int flags, GraphicsPipe *pipe, GraphicsStateGuardian *gsg) { - if (pipe == (GraphicsPipe *)NULL) { + if (pipe == nullptr) { pipe = get_default_pipe(); - if (pipe == (GraphicsPipe *)NULL) { + if (pipe == nullptr) { // Can't get a pipe. - return NULL; + return nullptr; } } - nassertr(_is_open, NULL); + nassertr(_is_open, nullptr); PT(WindowFramework) wf = make_window_framework(); wf->set_wireframe(get_wireframe()); wf->set_texture(get_texture()); @@ -407,18 +407,18 @@ open_window(const WindowProperties &props, int flags, GraphicsOutput *win = wf->open_window(props, flags, get_graphics_engine(), pipe, gsg); _engine->open_windows(); - if (win != (GraphicsOutput *)NULL && !win->is_valid()) { + if (win != nullptr && !win->is_valid()) { // The window won't open. _engine->remove_window(win); wf->close_window(); - win = NULL; + win = nullptr; } - if (win == (GraphicsOutput *)NULL) { + if (win == nullptr) { // Oops, couldn't make a window or buffer. framework_cat.error() << "Unable to create window.\n"; - return NULL; + return nullptr; } _windows.push_back(wf); @@ -467,7 +467,7 @@ close_window(int n) { WindowFramework *wf = _windows[n]; GraphicsOutput *win = wf->get_graphics_output(); - if (win != (GraphicsOutput *)NULL) { + if (win != nullptr) { _engine->remove_window(win); } @@ -485,7 +485,7 @@ close_all_windows() { WindowFramework *wf = (*wi); GraphicsOutput *win = wf->get_graphics_output(); - if (win != (GraphicsOutput *)NULL) { + if (win != nullptr) { _engine->remove_window(win); } @@ -780,7 +780,7 @@ make_default_pipe() { _default_pipe = selection->make_default_pipe(); - if (_default_pipe == (GraphicsPipe*)NULL) { + if (_default_pipe == nullptr) { nout << "No graphics pipe is available!\n" << "Your Config.prc file must name at least one valid panda display\n" << "library via load-display or aux-display.\n"; @@ -1412,7 +1412,7 @@ AsyncTask::DoneStatus PandaFramework:: task_record_frame(GenericAsyncTask *task, void *data) { PandaFramework *self = (PandaFramework *)data; - if (self->_recorder != (RecorderController *)NULL) { + if (self->_recorder != nullptr) { self->_recorder->record_frame(); } @@ -1427,7 +1427,7 @@ AsyncTask::DoneStatus PandaFramework:: task_play_frame(GenericAsyncTask *task, void *data) { PandaFramework *self = (PandaFramework *)data; - if (self->_recorder != (RecorderController *)NULL) { + if (self->_recorder != nullptr) { self->_recorder->play_frame(); } diff --git a/panda/src/framework/pandaFramework.h b/panda/src/framework/pandaFramework.h index 46df0f3bdd..01c50ae8d0 100644 --- a/panda/src/framework/pandaFramework.h +++ b/panda/src/framework/pandaFramework.h @@ -61,10 +61,10 @@ public: WindowFramework *open_window(); WindowFramework *open_window(GraphicsPipe *pipe, - GraphicsStateGuardian *gsg = NULL); + GraphicsStateGuardian *gsg = nullptr); WindowFramework *open_window(const WindowProperties &props, int flags, - GraphicsPipe *pipe = NULL, - GraphicsStateGuardian *gsg = NULL); + GraphicsPipe *pipe = nullptr, + GraphicsStateGuardian *gsg = nullptr); INLINE int get_num_windows() const; INLINE WindowFramework *get_window(int n) const; diff --git a/panda/src/framework/windowFramework.I b/panda/src/framework/windowFramework.I index 6cd1da7d64..5fa4caafe8 100644 --- a/panda/src/framework/windowFramework.I +++ b/panda/src/framework/windowFramework.I @@ -25,11 +25,11 @@ get_panda_framework() const { */ INLINE GraphicsWindow *WindowFramework:: get_graphics_window() const { - if (_window != (GraphicsOutput *)NULL && + if (_window != nullptr && _window->is_of_type(GraphicsWindow::get_class_type())) { return DCAST(GraphicsWindow, _window); } - return NULL; + return nullptr; } /** @@ -55,7 +55,7 @@ get_num_cameras() const { */ INLINE Camera *WindowFramework:: get_camera(int n) const { - nassertr(n >= 0 && n < (int)_cameras.size(), NULL); + nassertr(n >= 0 && n < (int)_cameras.size(), nullptr); return _cameras[n]; } diff --git a/panda/src/framework/windowFramework.cxx b/panda/src/framework/windowFramework.cxx index 756a1b61f1..3b1cb1807c 100644 --- a/panda/src/framework/windowFramework.cxx +++ b/panda/src/framework/windowFramework.cxx @@ -65,7 +65,7 @@ // This number is chosen arbitrarily to override any settings in model files. static const int override_priority = 100; -PT(TextFont) WindowFramework::_shuttle_controls_font = NULL; +PT(TextFont) WindowFramework::_shuttle_controls_font = nullptr; TypeHandle WindowFramework::_type_handle; /** @@ -134,7 +134,7 @@ GraphicsOutput *WindowFramework:: open_window(const WindowProperties &props, int flags, GraphicsEngine *engine, GraphicsPipe *pipe, GraphicsStateGuardian *gsg, const FrameBufferProperties &fbprops) { - nassertr(_window == (GraphicsOutput *)NULL, _window); + nassertr(_window == nullptr, _window); static int next_window_index = 1; ostringstream stream; @@ -142,11 +142,11 @@ open_window(const WindowProperties &props, int flags, GraphicsEngine *engine, next_window_index++; string name = stream.str(); - _window = 0; + _window = nullptr; GraphicsOutput *winout = engine->make_output(pipe, name, 0, fbprops, - props, flags, gsg, NULL); - if (winout != (GraphicsOutput *)NULL) { + props, flags, gsg, nullptr); + if (winout != nullptr) { _window = winout; // _window->request_properties(props); @@ -203,13 +203,13 @@ close_window() { _lighting_enabled = false; _perpixel_enabled = false; - if (_frame_rate_meter != (FrameRateMeter *)NULL) { + if (_frame_rate_meter != nullptr) { _frame_rate_meter->clear_window(); - _frame_rate_meter = (FrameRateMeter *)NULL; + _frame_rate_meter = nullptr; } - if (_scene_graph_analyzer_meter != (SceneGraphAnalyzerMeter *)NULL) { + if (_scene_graph_analyzer_meter != nullptr) { _scene_graph_analyzer_meter->clear_window(); - _scene_graph_analyzer_meter = (SceneGraphAnalyzerMeter *)NULL; + _scene_graph_analyzer_meter = nullptr; } } @@ -455,13 +455,13 @@ setup_trackball() { */ void WindowFramework:: center_trackball(const NodePath &object) { - if (_trackball == (Trackball *)NULL) { + if (_trackball == nullptr) { return; } PT(BoundingVolume) volume = object.get_bounds(); // We expect at least a geometric bounding volume around the world. - nassertv(volume != (BoundingVolume *)NULL); + nassertv(volume != nullptr); nassertv(volume->is_of_type(GeometricBoundingVolume::get_class_type())); CPT(GeometricBoundingVolume) gbv = DCAST(GeometricBoundingVolume, volume); @@ -502,17 +502,17 @@ center_trackball(const NodePath &object) { // Choose a suitable distance to view the whole volume in our frame. This // is based on the camera lens in use. Determine the lens based on the // first camera; this will be the default camera. - Lens *lens = (Lens *)NULL; + Lens *lens = nullptr; if (!_cameras.empty()) { Cameras::const_iterator ci; for (ci = _cameras.begin(); - ci != _cameras.end() && lens == (Lens *)NULL; + ci != _cameras.end() && lens == nullptr; ++ci) { lens = (*ci)->get_lens(); } } - if (lens != (Lens *)NULL) { + if (lens != nullptr) { LVecBase2 fov = lens->get_fov(); distance = radius / ctan(deg_2_rad(min(fov[0], fov[1]) / 2.0f)); @@ -544,7 +544,7 @@ bool WindowFramework:: load_models(const NodePath &parent, int argc, char *argv[], int first_arg) { pvector files; - for (int i = first_arg; i < argc && argv[i] != (char *)NULL; i++) { + for (int i = first_arg; i < argc && argv[i] != nullptr; i++) { files.push_back(Filename::from_os_specific(argv[i])); } @@ -596,17 +596,17 @@ load_model(const NodePath &parent, Filename filename) { } #endif // HAVE_ZLIB TexturePool *texture_pool = TexturePool::get_global_ptr(); - LoaderFileType *model_type = NULL; + LoaderFileType *model_type = nullptr; if (!extension.empty()) { LoaderFileTypeRegistry *reg = LoaderFileTypeRegistry::get_global_ptr(); model_type = reg->get_type_from_extension(extension); - if (model_type == (LoaderFileType *)NULL) { + if (model_type == nullptr) { // The extension isn't a known model file type; is it a known image file // extension? TexturePool *texture_pool = TexturePool::get_global_ptr(); - if (texture_pool->get_texture_type(extension) != NULL) { + if (texture_pool->get_texture_type(extension) != nullptr) { // It is a known image file extension. is_image = true; } @@ -630,12 +630,12 @@ load_model(const NodePath &parent, Filename filename) { // It failed to load. Is it because the extension isn't recognised? If // so, then we just got done printing out the known scene types, and we // should also print out the supported texture types. - if (node == (PandaNode *)NULL && !is_image && model_type == NULL) { + if (node == nullptr && !is_image && model_type == nullptr) { texture_pool->write_texture_types(nout, 2); } } - if (node == (PandaNode *)NULL) { + if (node == nullptr) { nout << "Unable to load " << filename << "\n"; return NodePath::not_found(); } @@ -822,7 +822,7 @@ adjust_dimensions() { Cameras::iterator ci; for (ci = _cameras.begin(); ci != _cameras.end(); ++ci) { Lens *lens = (*ci)->get_lens(); - if (lens != (Lens *)NULL) { + if (lens != nullptr) { if (y_size != 0) { lens->set_film_size(x_size, y_size); } else { @@ -840,7 +840,7 @@ adjust_dimensions() { */ WindowFramework *WindowFramework:: split_window(SplitType split_type) { - DisplayRegion *new_region = NULL; + DisplayRegion *new_region = nullptr; if (split_type == ST_default) { // Choose either horizontal or vertical according to the largest @@ -860,7 +860,7 @@ split_window(SplitType split_type) { if (split_type == ST_vertical) { _display_region_3d->set_dimensions(left, right, bottom, (top + bottom) / 2.0f); - if (_display_region_2d != (DisplayRegion *)NULL) { + if (_display_region_2d != nullptr) { _display_region_2d->set_dimensions(left, right, bottom, (top + bottom) / 2.0f); } @@ -868,7 +868,7 @@ split_window(SplitType split_type) { } else { _display_region_3d->set_dimensions(left, (left + right) / 2.0f, bottom, top); - if (_display_region_2d != (DisplayRegion *)NULL) { + if (_display_region_2d != nullptr) { _display_region_2d->set_dimensions(left, (left + right) / 2.0f, bottom, top); } @@ -1044,7 +1044,7 @@ void WindowFramework:: set_background_type(WindowFramework::BackgroundType type) { _background_type = type; - if (_display_region_3d == (DisplayRegion *)NULL) { + if (_display_region_3d == nullptr) { return; } @@ -1101,7 +1101,7 @@ set_background_type(WindowFramework::BackgroundType type) { */ TextFont *WindowFramework:: get_shuttle_controls_font() { - if (_shuttle_controls_font == (TextFont *)NULL) { + if (_shuttle_controls_font == nullptr) { PT(TextFont) font; string shuttle_controls_string((const char *)shuttle_controls, shuttle_controls_len); @@ -1109,7 +1109,7 @@ get_shuttle_controls_font() { BamFile bam_file; if (bam_file.open_read(in, "shuttle_controls font stream")) { PT(PandaNode) node = bam_file.read_node(); - if (node != (PandaNode *)NULL) { + if (node != nullptr) { _shuttle_controls_font = new StaticTextFont(node); } } @@ -1182,8 +1182,8 @@ setup_lights() { PT(PandaNode) WindowFramework:: load_image_as_model(const Filename &filename) { PT(Texture) tex = TexturePool::load_texture(filename); - if (tex == NULL) { - return NULL; + if (tex == nullptr) { + return nullptr; } // Yes, it is an image file; make a texture out of it. @@ -1365,7 +1365,7 @@ create_anim_controls() { } AnimControl *control = _anim_controls.get_anim(_anim_index); - nassertv(control != (AnimControl *)NULL); + nassertv(control != nullptr); if (control->get_num_frames() <= 1) { // Don't show the controls when the animation has only 0 or 1 frames. @@ -1438,7 +1438,7 @@ destroy_anim_controls() { _anim_controls_group.remove_node(); _panda_framework->get_event_handler().remove_hooks_with((void *)this); - if (_update_anim_controls_task != NULL) { + if (_update_anim_controls_task != nullptr) { _panda_framework->get_task_mgr().remove(_update_anim_controls_task); _update_anim_controls_task.clear(); } @@ -1451,9 +1451,9 @@ destroy_anim_controls() { void WindowFramework:: update_anim_controls() { AnimControl *control = _anim_controls.get_anim(_anim_index); - nassertv(control != (AnimControl *)NULL); + nassertv(control != nullptr); - if (_anim_slider != NULL) { + if (_anim_slider != nullptr) { if (_anim_slider->is_button_down()) { control->pose((int)(_anim_slider->get_value() + 0.5)); } else { @@ -1461,7 +1461,7 @@ update_anim_controls() { } } - if (_frame_number != NULL) { + if (_frame_number != nullptr) { _frame_number->set_text(format_string(control->get_frame())); } @@ -1494,7 +1494,7 @@ setup_shuttle_button(const string &label, int index, style.set_type(PGFrameStyle::T_bevel_out); button->set_frame_style(PGButton::S_rollover, style); - if (get_shuttle_controls_font() != (TextFont *)NULL) { + if (get_shuttle_controls_font() != nullptr) { PT(TextNode) tn = new TextNode("label"); tn->set_align(TextNode::A_center); tn->set_font(get_shuttle_controls_font()); @@ -1521,7 +1521,7 @@ setup_shuttle_button(const string &label, int index, void WindowFramework:: back_button() { AnimControl *control = _anim_controls.get_anim(_anim_index); - nassertv(control != (AnimControl *)NULL); + nassertv(control != nullptr); control->pose(control->get_frame() - 1); } @@ -1531,7 +1531,7 @@ back_button() { void WindowFramework:: pause_button() { AnimControl *control = _anim_controls.get_anim(_anim_index); - nassertv(control != (AnimControl *)NULL); + nassertv(control != nullptr); control->stop(); } @@ -1541,7 +1541,7 @@ pause_button() { void WindowFramework:: play_button() { AnimControl *control = _anim_controls.get_anim(_anim_index); - nassertv(control != (AnimControl *)NULL); + nassertv(control != nullptr); control->loop(false); } @@ -1551,7 +1551,7 @@ play_button() { void WindowFramework:: forward_button() { AnimControl *control = _anim_controls.get_anim(_anim_index); - nassertv(control != (AnimControl *)NULL); + nassertv(control != nullptr); control->pose(control->get_frame() + 1); } diff --git a/panda/src/framework/windowFramework.h b/panda/src/framework/windowFramework.h index c74310e197..c7745b0fea 100644 --- a/panda/src/framework/windowFramework.h +++ b/panda/src/framework/windowFramework.h @@ -59,7 +59,7 @@ public: protected: GraphicsOutput *open_window(const WindowProperties &props, int flags, GraphicsEngine *engine, GraphicsPipe *pipe, - GraphicsStateGuardian *gsg = NULL, + GraphicsStateGuardian *gsg = nullptr, const FrameBufferProperties &fbprops = FrameBufferProperties::get_default()); void close_window(); diff --git a/panda/src/glstuff/glCgShaderContext_src.cxx b/panda/src/glstuff/glCgShaderContext_src.cxx index 574648300b..d70b2a4a1a 100644 --- a/panda/src/glstuff/glCgShaderContext_src.cxx +++ b/panda/src/glstuff/glCgShaderContext_src.cxx @@ -195,7 +195,7 @@ CLP(CgShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderConte // used, but it instead uses specially named variables. A bit of // guesswork is involved here; Cg seems to mostly use the semantics as // attribute names in GLSL, with a few exceptions. - const char *attribname = NULL; + const char *attribname = nullptr; switch (res) { case CG_POSITION0: attribname = "cg_Vertex"; @@ -519,7 +519,7 @@ issue_parameters(int altered) { Shader::ShaderPtrSpec &spec = _shader->_ptr_spec[i]; const Shader::ShaderPtrData *ptr_data =_glgsg->fetch_ptr_parameter(spec); - if (ptr_data == NULL){ //the input is not contained in ShaderPtrData + if (ptr_data == nullptr){ //the input is not contained in ShaderPtrData release_resources(); return; } @@ -736,7 +736,7 @@ update_transform_table(const TransformTable *table) { LMatrix4f *matrices = (LMatrix4f *)alloca(_transform_table_size * 64); int i = 0; - if (table != NULL) { + if (table != nullptr) { int num_transforms = min(_transform_table_size, (long)table->get_num_transforms()); for (; i < num_transforms; ++i) { #ifdef STDFLOAT_DOUBLE @@ -764,7 +764,7 @@ update_slider_table(const SliderTable *table) { float *sliders = (float *)alloca(_slider_table_size * 4); memset(sliders, 0, _slider_table_size * 4); - if (table != NULL) { + if (table != nullptr) { int num_sliders = min(_slider_table_size, (long)table->get_num_sliders()); for (int i = 0; i < num_sliders; ++i) { sliders[i] = table->get_slider(i)->get_slider(); @@ -1110,7 +1110,7 @@ update_shader_texture_bindings(ShaderContext *prev) { _glgsg->set_active_texture_stage(texunit); TextureContext *tc = tex->prepare_now(view, _glgsg->_prepared_objects, _glgsg); - if (tc == (TextureContext*)NULL) { + if (tc == nullptr) { continue; } diff --git a/panda/src/glstuff/glGeomContext_src.cxx b/panda/src/glstuff/glGeomContext_src.cxx index 11a9cf3f23..2640c1d855 100644 --- a/panda/src/glstuff/glGeomContext_src.cxx +++ b/panda/src/glstuff/glGeomContext_src.cxx @@ -41,7 +41,7 @@ get_display_list(GLuint &index, const CLP(GeomMunger) *munger, if (dl._index == 0) { dl._index = glGenLists(1); list_current = false; - if (munger != (CLP(GeomMunger) *)NULL) { + if (munger != (CLP(GeomMunger) *)nullptr) { ((CLP(GeomMunger) *)munger)->_geom_contexts.insert(this); } } @@ -70,7 +70,7 @@ release_display_lists() { ++dli) { CLP(GeomMunger) *munger = (*dli).first; const DisplayList &dl = (*dli).second; - if (munger != (CLP(GeomMunger) *)NULL) { + if (munger != (CLP(GeomMunger) *)nullptr) { munger->_geom_contexts.erase(this); } diff --git a/panda/src/glstuff/glGeomMunger_src.cxx b/panda/src/glstuff/glGeomMunger_src.cxx index eea42762ce..fae758f2c8 100644 --- a/panda/src/glstuff/glGeomMunger_src.cxx +++ b/panda/src/glstuff/glGeomMunger_src.cxx @@ -84,13 +84,13 @@ munge_format_impl(const GeomVertexFormat *orig, new_format->set_animation(animation); CLP(GraphicsStateGuardian) *glgsg; - DCAST_INTO_R(glgsg, get_gsg(), NULL); + DCAST_INTO_R(glgsg, get_gsg(), nullptr); #ifndef OPENGLES // OpenGL ES 1 does, but regular OpenGL doesn't support GL_BYTE vertices and // texture coordinates. const GeomVertexColumn *vertex_type = orig->get_vertex_column(); - if (vertex_type != (GeomVertexColumn *)NULL && + if (vertex_type != nullptr && (vertex_type->get_numeric_type() == NT_int8 || vertex_type->get_numeric_type() == NT_uint8)) { int vertex_array = orig->get_array_with(InternalName::get_vertex()); @@ -127,7 +127,7 @@ munge_format_impl(const GeomVertexFormat *orig, #endif // !OPENGLES const GeomVertexColumn *color_type = orig->get_color_column(); - if (color_type != (GeomVertexColumn *)NULL && + if (color_type != nullptr && color_type->get_numeric_type() == NT_packed_dabc && !glgsg->_supports_packed_dabc) { // We need to convert the color format; OpenGL doesn't support the byte @@ -198,7 +198,7 @@ munge_format_impl(const GeomVertexFormat *orig, PT(GeomVertexArrayFormat) new_array_format = new GeomVertexArrayFormat; const GeomVertexColumn *column = format->get_vertex_column(); - if (column != (const GeomVertexColumn *)NULL) { + if (column != nullptr) { new_array_format->add_column (column->get_name(), column->get_num_components(), column->get_numeric_type(), column->get_contents(), @@ -207,7 +207,7 @@ munge_format_impl(const GeomVertexFormat *orig, } column = format->get_normal_column(); - if (column != (const GeomVertexColumn *)NULL) { + if (column != nullptr) { new_array_format->add_column (column->get_name(), column->get_num_components(), column->get_numeric_type(), column->get_contents(), @@ -216,7 +216,7 @@ munge_format_impl(const GeomVertexFormat *orig, } column = format->get_color_column(); - if (column != (const GeomVertexColumn *)NULL) { + if (column != nullptr) { new_array_format->add_column (column->get_name(), column->get_num_components(), column->get_numeric_type(), column->get_contents(), @@ -239,7 +239,7 @@ munge_format_impl(const GeomVertexFormat *orig, // This is the first time we've encountered this texcoord name. const GeomVertexColumn *texcoord_type = format->get_column(name); - if (texcoord_type != (const GeomVertexColumn *)NULL) { + if (texcoord_type != nullptr) { new_array_format->add_column (name, texcoord_type->get_num_values(), NT_stdfloat, C_texcoord, -1, texcoord_type->get_column_alignment()); @@ -270,13 +270,13 @@ premunge_format_impl(const GeomVertexFormat *orig) { PT(GeomVertexFormat) new_format = new GeomVertexFormat(*orig); CLP(GraphicsStateGuardian) *glgsg; - DCAST_INTO_R(glgsg, get_gsg(), NULL); + DCAST_INTO_R(glgsg, get_gsg(), nullptr); #ifndef OPENGLES // OpenGL ES 1 does, but regular OpenGL doesn't support GL_BYTE vertices and // texture coordinates. const GeomVertexColumn *vertex_type = orig->get_vertex_column(); - if (vertex_type != (GeomVertexColumn *)NULL && + if (vertex_type != nullptr && (vertex_type->get_numeric_type() == NT_int8 || vertex_type->get_numeric_type() == NT_uint8)) { int vertex_array = orig->get_array_with(InternalName::get_vertex()); @@ -337,7 +337,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { PT(GeomVertexArrayFormat) new_array_format = new GeomVertexArrayFormat; const GeomVertexColumn *column = format->get_vertex_column(); - if (column != (const GeomVertexColumn *)NULL) { + if (column != nullptr) { new_array_format->add_column (column->get_name(), column->get_num_components(), column->get_numeric_type(), column->get_contents(), @@ -346,7 +346,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { } column = format->get_normal_column(); - if (column != (const GeomVertexColumn *)NULL) { + if (column != nullptr) { new_array_format->add_column (column->get_name(), column->get_num_components(), column->get_numeric_type(), column->get_contents(), @@ -355,7 +355,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { } column = format->get_color_column(); - if (column != (const GeomVertexColumn *)NULL) { + if (column != nullptr) { new_array_format->add_column (column->get_name(), column->get_num_components(), column->get_numeric_type(), column->get_contents(), @@ -379,7 +379,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { // This is the first time we've encountered this texcoord name. const GeomVertexColumn *texcoord_type = format->get_column(name); - if (texcoord_type != (const GeomVertexColumn *)NULL) { + if (texcoord_type != nullptr) { new_array_format->add_column (name, texcoord_type->get_num_values(), NT_stdfloat, C_texcoord, -1, texcoord_type->get_column_alignment()); diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index 35daa0b225..8d77e56086 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -32,7 +32,7 @@ CLP(GraphicsBuffer)(GraphicsEngine *engine, GraphicsPipe *pipe, _resolve_multisample_pcollector(_draw_window_pcollector, "Resolve multisamples"), _requested_multisamples(0), _requested_coverage_samples(0), - _rb_context(NULL) + _rb_context(nullptr) { // A FBO doesn't have a back buffer. _draw_buffer_type = RenderBuffer::T_front; @@ -97,7 +97,7 @@ clear(Thread *current_thread) { CLP(GraphicsStateGuardian) *glgsg = (CLP(GraphicsStateGuardian) *)_gsg.p(); - if (glgsg->_glClearBufferfv == NULL) { + if (glgsg->_glClearBufferfv == nullptr) { // We can't efficiently clear the buffer. Fall back to the inefficient // default implementation for now. GraphicsOutput::clear(current_thread); @@ -267,7 +267,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { for (it = _texture_contexts.begin(); it != _texture_contexts.end(); ++it) { CLP(TextureContext) *gtc = *it; - if (gtc != NULL && gtc->needs_barrier(GL_FRAMEBUFFER_BARRIER_BIT)) { + if (gtc != nullptr && gtc->needs_barrier(GL_FRAMEBUFFER_BARRIER_BIT)) { glgsg->issue_memory_barrier(GL_FRAMEBUFFER_BARRIER_BIT); // If we've done it for one, we've done it for all. break; @@ -492,7 +492,7 @@ rebuild_bitplanes() { // requested. _use_depth_stencil = true; } - } else if (attach[RTP_depth_stencil] != NULL && attach[RTP_depth] == NULL) { + } else if (attach[RTP_depth_stencil] != nullptr && attach[RTP_depth] == nullptr) { // The depth stencil slot was assigned a texture, but we don't support it. // Downgrade to a regular depth texture. swap(attach[RTP_depth], attach[RTP_depth_stencil]); @@ -510,7 +510,7 @@ rebuild_bitplanes() { // depth_stencil implies depth, and we can't bind them both. Detect that // case, normalize it, and complain. if (_use_depth_stencil && attach[RTP_depth] && attach[RTP_depth_stencil]) { - attach[RTP_depth] = NULL; + attach[RTP_depth] = nullptr; GLCAT.warning() << "Attempt to bind both RTP_depth and RTP_depth_stencil bitplanes.\n"; } @@ -562,7 +562,7 @@ rebuild_bitplanes() { if (_fb_properties.is_stereo()) { // The second tex view has already been initialized, so bind it // straight away. - if (attach[RTP_color] != NULL) { + if (attach[RTP_color] != nullptr) { attach_tex(layer, 1, attach[RTP_color], next++); } else { // XXX hack: I needed a slot to use, and we don't currently use @@ -696,7 +696,7 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, if (tex && layer >= tex->get_z_size()) { // If the requested layer index exceeds the number of layers in the // texture, we will not bind this layer. - tex = NULL; + tex = nullptr; } if (!tex && _rb_size_z > 1) { @@ -1154,7 +1154,7 @@ attach_tex(int layer, int view, Texture *attach, GLenum attachpoint) { // Create the OpenGL texture object. TextureContext *tc = attach->prepare_now(view, glgsg->get_prepared_objects(), glgsg); - nassertv(tc != (TextureContext *)NULL); + nassertv(tc != nullptr); CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), tc); glgsg->update_texture(gtc, true); @@ -1175,7 +1175,7 @@ attach_tex(int layer, int view, Texture *attach, GLenum attachpoint) { #ifndef OPENGLES if (_rb_size_z != 1) { // Bind all of the layers of the texture. - nassertv(glgsg->_glFramebufferTexture != NULL); + nassertv(glgsg->_glFramebufferTexture != nullptr); glgsg->_glFramebufferTexture(GL_FRAMEBUFFER_EXT, attachpoint, gtc->_index, 0); return; @@ -1240,7 +1240,7 @@ generate_mipmaps() { void CLP(GraphicsBuffer):: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); // Resolve Multisample rendering if using it. if (_requested_multisamples && _fbo_multisample) { @@ -1347,7 +1347,7 @@ open_buffer() { return false; } - if (_rb_context == NULL) { + if (_rb_context == nullptr) { _rb_context = new BufferContext(&(glgsg->_renderbuffer_residency)); } @@ -1534,10 +1534,10 @@ get_host() { void CLP(GraphicsBuffer):: close_buffer() { _rb_data_size_bytes = 0; - if (_rb_context != NULL) { + if (_rb_context != nullptr) { _rb_context->update_data_size_bytes(0); delete _rb_context; - _rb_context = NULL; + _rb_context = nullptr; } check_host_valid(); @@ -1718,12 +1718,12 @@ void CLP(GraphicsBuffer):: check_host_valid() { if (_host != nullptr && !_host->is_valid()) { _rb_data_size_bytes = 0; - if (_rb_context != NULL) { + if (_rb_context != nullptr) { // We must delete this object first, because when the GSG destructs, so // will the tracker that this context is attached to. _rb_context->update_data_size_bytes(0); delete _rb_context; - _rb_context = NULL; + _rb_context = nullptr; } _is_valid = false; _gsg.clear(); @@ -1751,7 +1751,7 @@ resolve_multisamples() { for (it = _texture_contexts.begin(); it != _texture_contexts.end(); ++it) { CLP(TextureContext) *gtc = *it; - if (gtc != NULL && gtc->needs_barrier(GL_FRAMEBUFFER_BARRIER_BIT)) { + if (gtc != nullptr && gtc->needs_barrier(GL_FRAMEBUFFER_BARRIER_BIT)) { glgsg->issue_memory_barrier(GL_FRAMEBUFFER_BARRIER_BIT); // If we've done it for one, we've done it for all. break; @@ -1773,7 +1773,7 @@ resolve_multisamples() { bool do_depth_blit = false; if (_rbm[RTP_depth_stencil] != 0 || _rbm[RTP_depth] != 0) { if (_shared_depth_buffer) { - CLP(GraphicsBuffer) *graphics_buffer = NULL; + CLP(GraphicsBuffer) *graphics_buffer = nullptr; //CLP(GraphicsBuffer) *highest_sort_graphics_buffer = NULL; list ::iterator graphics_buffer_iterator; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index f5e56585e0..6c06ae0b6b 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -86,7 +86,7 @@ PStatCollector CLP(GraphicsStateGuardian)::_fbo_bind_pcollector("Draw:Bind FBO") PStatCollector CLP(GraphicsStateGuardian)::_check_error_pcollector("Draw:Check errors"); #ifndef OPENGLES_1 -PT(Shader) CLP(GraphicsStateGuardian)::_default_shader = NULL; +PT(Shader) CLP(GraphicsStateGuardian)::_default_shader = nullptr; #endif // The following noop functions are assigned to the corresponding glext @@ -528,7 +528,7 @@ reset() { PFNGLGETSTRINGIPROC _glGetStringi = (PFNGLGETSTRINGIPROC)get_extension_func("glGetStringi"); - if (_glGetStringi != NULL) { + if (_glGetStringi != nullptr) { GLint n = 0; glGetIntegerv(GL_NUM_EXTENSIONS, &n); for (GLint i = 0; i < n; ++i) { @@ -611,13 +611,13 @@ reset() { if (_supports_debug) { // Set the categories we want to listen to. _glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_HIGH, - 0, NULL, GLCAT.is_error()); + 0, nullptr, GLCAT.is_error()); _glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_MEDIUM, - 0, NULL, GLCAT.is_warning()); + 0, nullptr, GLCAT.is_warning()); _glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW, - 0, NULL, GLCAT.is_info()); + 0, nullptr, GLCAT.is_info()); _glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_NOTIFICATION, - 0, NULL, GLCAT.is_debug()); + 0, nullptr, GLCAT.is_debug()); // Enable the callback. _glDebugMessageCallback((GLDEBUGPROC_P) &debug_callback, (void*)this); @@ -677,7 +677,7 @@ reset() { get_extension_func("glPointParameterfvARB"); } if (_supports_point_parameters) { - if (_glPointParameterfv == NULL) { + if (_glPointParameterfv == nullptr) { GLCAT.warning() << "glPointParameterfv advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _supports_point_parameters = false; @@ -718,7 +718,7 @@ reset() { #else _explicit_primitive_restart = false; - _glPrimitiveRestartIndex = NULL; + _glPrimitiveRestartIndex = nullptr; if (gl_support_primitive_restart_index) { if ((is_at_least_gl_version(4, 3) || has_extension("GL_ARB_ES3_compatibility")) && @@ -772,7 +772,7 @@ reset() { get_extension_func("glDrawRangeElementsEXT"); } #endif - if (_glDrawRangeElements == NULL) { + if (_glDrawRangeElements == nullptr) { GLCAT.warning() << "glDrawRangeElements advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _glDrawRangeElements = null_glDrawRangeElements; @@ -801,7 +801,7 @@ reset() { _glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC) get_extension_func("glTexSubImage3DEXT"); - _glCopyTexSubImage3D = NULL; + _glCopyTexSubImage3D = nullptr; if (has_extension("GL_EXT_copy_texture")) { _glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC) get_extension_func("glCopyTexSubImage3DEXT"); @@ -822,7 +822,7 @@ reset() { } if (_supports_3d_texture) { - if (_glTexImage3D == NULL || _glTexSubImage3D == NULL) { + if (_glTexImage3D == nullptr || _glTexSubImage3D == nullptr) { GLCAT.warning() << "3-D textures advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _supports_3d_texture = false; @@ -860,7 +860,7 @@ reset() { #endif if (_supports_tex_storage) { - if (_glTexStorage1D == NULL || _glTexStorage2D == NULL || _glTexStorage3D == NULL) { + if (_glTexStorage1D == nullptr || _glTexStorage2D == nullptr || _glTexStorage3D == nullptr) { GLCAT.warning() << "Immutable texture storage advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _supports_tex_storage = false; @@ -873,7 +873,7 @@ reset() { _glClearTexImage = (PFNGLCLEARTEXIMAGEPROC) get_extension_func("glClearTexImage"); - if (_glClearTexImage == NULL) { + if (_glClearTexImage == nullptr) { GLCAT.warning() << "GL_ARB_clear_texture advertised as supported by OpenGL runtime, but could not get pointers to extension function.\n"; } else { @@ -888,7 +888,7 @@ reset() { _glClearBufferData = (PFNGLCLEARBUFFERDATAPROC) get_extension_func("glClearBufferData"); - if (_glClearBufferData == NULL) { + if (_glClearBufferData == nullptr) { GLCAT.warning() << "GL_ARB_clear_buffer_object advertised as supported by OpenGL runtime, but could not get pointers to extension function.\n"; } else { @@ -914,7 +914,7 @@ reset() { #endif } - if (_supports_2d_texture_array && _glFramebufferTextureLayer == NULL) { + if (_supports_2d_texture_array && _glFramebufferTextureLayer == nullptr) { GLCAT.warning() << "Texture arrays advertised as supported by OpenGL runtime, but could not get pointer to glFramebufferTextureLayer function.\n"; } @@ -965,14 +965,14 @@ reset() { _supports_compressed_texture = true; // Supported in the core. 1D textures are not supported by OpenGL ES. - _glCompressedTexImage1D = NULL; + _glCompressedTexImage1D = nullptr; _glCompressedTexImage2D = glCompressedTexImage2D; - _glCompressedTexSubImage1D = NULL; + _glCompressedTexSubImage1D = nullptr; _glCompressedTexSubImage2D = glCompressedTexSubImage2D; - _glGetCompressedTexImage = NULL; + _glGetCompressedTexImage = nullptr; - _glCompressedTexImage3D = NULL; - _glCompressedTexSubImage3D = NULL; + _glCompressedTexImage3D = nullptr; + _glCompressedTexSubImage3D = nullptr; #ifdef OPENGLES_2 if (_supports_3d_texture) { _glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC) @@ -1024,13 +1024,13 @@ reset() { } if (_supports_compressed_texture) { - if (_glCompressedTexImage1D == NULL || - _glCompressedTexImage2D == NULL || - _glCompressedTexImage3D == NULL || - _glCompressedTexSubImage1D == NULL || - _glCompressedTexSubImage2D == NULL || - _glCompressedTexSubImage3D == NULL || - _glGetCompressedTexImage == NULL) { + if (_glCompressedTexImage1D == nullptr || + _glCompressedTexImage2D == nullptr || + _glCompressedTexImage3D == nullptr || + _glCompressedTexSubImage1D == nullptr || + _glCompressedTexSubImage2D == nullptr || + _glCompressedTexSubImage3D == nullptr || + _glGetCompressedTexImage == nullptr) { GLCAT.warning() << "Compressed textures advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _supports_compressed_texture = false; @@ -1245,13 +1245,13 @@ reset() { } if (supports_multitexture) { - if (_glActiveTexture == NULL + if (_glActiveTexture == nullptr #ifdef SUPPORT_FIXED_FUNCTION - || (has_fixed_function_pipeline() && _glClientActiveTexture == NULL) + || (has_fixed_function_pipeline() && _glClientActiveTexture == nullptr) #endif #ifdef SUPPORT_IMMEDIATE_MODE - || GLf(_glMultiTexCoord1) == NULL || GLf(_glMultiTexCoord2) == NULL - || GLf(_glMultiTexCoord3) == NULL || GLf(_glMultiTexCoord4) == NULL + || GLf(_glMultiTexCoord1) == nullptr || GLf(_glMultiTexCoord2) == nullptr + || GLf(_glMultiTexCoord3) == nullptr || GLf(_glMultiTexCoord4) == nullptr #endif ) { GLCAT.warning() @@ -1414,9 +1414,9 @@ reset() { #endif // OPENGLES_1 if (_supports_buffers) { - if (_glGenBuffers == NULL || _glBindBuffer == NULL || - _glBufferData == NULL || _glBufferSubData == NULL || - _glDeleteBuffers == NULL) { + if (_glGenBuffers == nullptr || _glBindBuffer == nullptr || + _glBufferData == nullptr || _glBufferSubData == nullptr || + _glDeleteBuffers == nullptr) { GLCAT.warning() << "Buffers advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _supports_buffers = false; @@ -1434,7 +1434,7 @@ reset() { get_extension_func("glMapBufferRangeEXT"); } else { - _glMapBufferRange = NULL; + _glMapBufferRange = nullptr; } #else // Check for various advanced buffer management features. @@ -1442,14 +1442,14 @@ reset() { _glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC) get_extension_func("glMapBufferRange"); } else { - _glMapBufferRange = NULL; + _glMapBufferRange = nullptr; } if (is_at_least_gl_version(4, 4) || has_extension("GL_ARB_buffer_storage")) { _glBufferStorage = (PFNGLBUFFERSTORAGEPROC) get_extension_func("glBufferStorage"); - if (_glBufferStorage != NULL) { + if (_glBufferStorage != nullptr) { _supports_buffer_storage = true; } else { GLCAT.warning() @@ -1491,8 +1491,8 @@ reset() { } if (_supports_vao) { - if (_glBindVertexArray == NULL || _glDeleteVertexArrays == NULL || - _glGenVertexArrays == NULL) { + if (_glBindVertexArray == nullptr || _glDeleteVertexArrays == nullptr || + _glGenVertexArrays == nullptr) { GLCAT.warning() << "Vertex array objects advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _supports_vao = false; @@ -1526,13 +1526,13 @@ reset() { } else if (has_extension("GL_EXT_geometry_shader4")) { _supports_geometry_shaders = true; - _glFramebufferTexture = NULL; + _glFramebufferTexture = nullptr; _glProgramParameteri = (PFNGLPROGRAMPARAMETERIPROC) get_extension_func("glProgramParameteriEXT"); } else { _supports_geometry_shaders = false; - _glFramebufferTexture = NULL; + _glFramebufferTexture = nullptr; } #endif _shader_caps._supports_glsl = _supports_glsl; @@ -1620,7 +1620,7 @@ reset() { _glDispatchCompute = (PFNGLDISPATCHCOMPUTEPROC) get_extension_func("glDispatchCompute"); - if (_glDispatchCompute != NULL) { + if (_glDispatchCompute != nullptr) { _supports_compute_shaders = true; } } @@ -1707,14 +1707,14 @@ reset() { _glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC) get_extension_func("glVertexAttribIPointer"); } else { - _glVertexAttribIPointer = NULL; + _glVertexAttribIPointer = nullptr; } if (is_at_least_gl_version(4, 1) || has_extension("GL_ARB_vertex_attrib_64bit")) { _glVertexAttribLPointer = (PFNGLVERTEXATTRIBLPOINTERPROC) get_extension_func("glVertexAttribLPointer"); } else { - _glVertexAttribLPointer = NULL; + _glVertexAttribLPointer = nullptr; } if (_supports_tessellation_shaders) { @@ -1735,8 +1735,8 @@ reset() { _glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) get_extension_func("glVertexAttribPointerARB"); - _glVertexAttribIPointer = NULL; - _glVertexAttribLPointer = NULL; + _glVertexAttribIPointer = nullptr; + _glVertexAttribLPointer = nullptr; } #endif @@ -1774,13 +1774,13 @@ reset() { _glVertexAttrib4fv = glVertexAttrib4fv; _glVertexAttrib4dv = null_glVertexAttrib4dv; _glVertexAttribPointer = glVertexAttribPointer; - _glVertexAttribLPointer = NULL; + _glVertexAttribLPointer = nullptr; if (is_at_least_gles_version(3, 0)) { _glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC) get_extension_func("glVertexAttribIPointer"); } else { - _glVertexAttribIPointer = NULL; + _glVertexAttribIPointer = nullptr; } #endif @@ -1817,7 +1817,7 @@ reset() { // to have a shader applied, or if it failed to compile. This default // shader just outputs a red color, indicating that something went wrong. #ifndef OPENGLES_1 - if (_default_shader == NULL && !has_fixed_function_pipeline()) { + if (_default_shader == nullptr && !has_fixed_function_pipeline()) { _default_shader = Shader::make(Shader::SL_GLSL, default_vshader, default_fshader); } #endif @@ -1985,7 +1985,7 @@ reset() { #ifndef OPENGLES_1 if (_supports_geometry_instancing) { - if (_glDrawArraysInstanced == NULL || _glDrawElementsInstanced == NULL) { + if (_glDrawArraysInstanced == nullptr || _glDrawElementsInstanced == nullptr) { GLCAT.warning() << "Geometry instancing advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _supports_geometry_instancing = false; @@ -1993,7 +1993,7 @@ reset() { } if (_supports_vertex_attrib_divisor) { - if (_glVertexAttribDivisor == NULL) { + if (_glVertexAttribDivisor == nullptr) { GLCAT.warning() << "Instanced vertex arrays advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _supports_vertex_attrib_divisor = false; @@ -2014,7 +2014,7 @@ reset() { _glDrawElementsIndirect = (PFNGLDRAWELEMENTSINDIRECTPROC) get_extension_func("glDrawElementsIndirect"); - if (_glDrawArraysIndirect == NULL || _glDrawElementsIndirect == NULL) { + if (_glDrawArraysIndirect == nullptr || _glDrawElementsIndirect == nullptr) { GLCAT.warning() << "Indirect draw advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; } else { @@ -2051,7 +2051,7 @@ reset() { get_extension_func("glGenFramebuffersOES"); _glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSOESPROC) get_extension_func("glCheckFramebufferStatusOES"); - _glFramebufferTexture1D = NULL; + _glFramebufferTexture1D = nullptr; _glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DOESPROC) get_extension_func("glFramebufferTexture2DOES"); _glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFEROESPROC) @@ -2062,7 +2062,7 @@ reset() { get_extension_func("glGenerateMipmapOES"); } else { _supports_framebuffer_object = false; - _glGenerateMipmap = NULL; + _glGenerateMipmap = nullptr; } #elif defined(OPENGLES) // In OpenGL ES 2.x, FBO's are supported in the core. @@ -2078,7 +2078,7 @@ reset() { _glDeleteFramebuffers = glDeleteFramebuffers; _glGenFramebuffers = glGenFramebuffers; _glCheckFramebufferStatus = glCheckFramebufferStatus; - _glFramebufferTexture1D = NULL; + _glFramebufferTexture1D = nullptr; _glFramebufferTexture2D = glFramebufferTexture2D; _glFramebufferRenderbuffer = glFramebufferRenderbuffer; _glGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameteriv; @@ -2209,7 +2209,7 @@ reset() { _supports_framebuffer_object = false; _supports_framebuffer_multisample = false; _supports_framebuffer_blit = false; - _glGenerateMipmap = NULL; + _glGenerateMipmap = nullptr; } #endif @@ -2218,7 +2218,7 @@ reset() { _glGenerateTextureMipmap = (PFNGLGENERATETEXTUREMIPMAPPROC) get_extension_func("glGenerateTextureMipmap"); } else { - _glGenerateTextureMipmap = NULL; + _glGenerateTextureMipmap = nullptr; } #endif @@ -2248,7 +2248,7 @@ reset() { #endif #if defined(OPENGLES_1) - _glDrawBuffers = NULL; + _glDrawBuffers = nullptr; _max_color_targets = 1; #elif defined(OPENGLES_2) @@ -2265,7 +2265,7 @@ reset() { get_extension_func("glDrawBuffersNV"); } else { - _glDrawBuffers = NULL; + _glDrawBuffers = nullptr; } #else @@ -2278,13 +2278,13 @@ reset() { get_extension_func("glDrawBuffersARB"); } else { - _glDrawBuffers = NULL; + _glDrawBuffers = nullptr; } #endif #ifndef OPENGLES_1 _max_color_targets = 1; - if (_glDrawBuffers != NULL) { + if (_glDrawBuffers != nullptr) { GLint max_draw_buffers = 0; glGetIntegerv(GL_MAX_DRAW_BUFFERS, &max_draw_buffers); _max_color_targets = max_draw_buffers; @@ -2301,9 +2301,9 @@ reset() { get_extension_func("glClearBufferfi"); } else { - _glClearBufferfv = NULL; - _glClearBufferiv = NULL; - _glClearBufferfi = NULL; + _glClearBufferfv = nullptr; + _glClearBufferiv = nullptr; + _glClearBufferfi = nullptr; } #endif // !OPENGLES @@ -2318,7 +2318,7 @@ reset() { _glDepthRangeArrayv = (PFNGLDEPTHRANGEARRAYVPROC) get_extension_func("glDepthRangeArrayv"); - if (_glViewportArrayv == NULL || _glScissorArrayv == NULL || _glDepthRangeArrayv == NULL) { + if (_glViewportArrayv == nullptr || _glScissorArrayv == nullptr || _glDepthRangeArrayv == nullptr) { GLCAT.warning() << "Viewport arrays advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; } else { @@ -2371,9 +2371,9 @@ reset() { } if (_supports_occlusion_query) { - if (_glGenQueries == NULL || _glBeginQuery == NULL || - _glEndQuery == NULL || _glDeleteQueries == NULL || - _glGetQueryiv == NULL || _glGetQueryObjectuiv == NULL) { + if (_glGenQueries == nullptr || _glBeginQuery == nullptr || + _glEndQuery == nullptr || _glDeleteQueries == nullptr || + _glGetQueryiv == nullptr || _glGetQueryObjectuiv == nullptr) { GLCAT.warning() << "Occlusion queries advertised as supported by OpenGL runtime, but could not get pointers to extension functions.\n"; _supports_occlusion_query = false; @@ -2414,7 +2414,7 @@ reset() { _glBlendEquation = (PFNGLBLENDEQUATIONPROC) get_extension_func("glBlendEquationOES"); - if (_glBlendEquation == NULL) { + if (_glBlendEquation == nullptr) { _glBlendEquation = null_glBlendEquation; GLCAT.warning() << "BlendEquationOES advertised as supported by OpenGL ES runtime, but " @@ -2428,7 +2428,7 @@ reset() { _glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEOESPROC) get_extension_func("glBlendEquationSeparateOES"); - if (_glBlendEquation == NULL) { + if (_glBlendEquation == nullptr) { _supports_blend_equation_separate = false; GLCAT.warning() << "BlendEquationSeparateOES advertised as supported by OpenGL ES " @@ -2438,14 +2438,14 @@ reset() { } } else { _supports_blend_equation_separate = false; - _glBlendEquationSeparate = NULL; + _glBlendEquationSeparate = nullptr; } if (has_extension("GL_OES_blend_func_separate")) { _glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEOESPROC) get_extension_func("glBlendFuncSeparateOES"); - if (_glBlendFuncSeparate == NULL) { + if (_glBlendFuncSeparate == nullptr) { _glBlendFuncSeparate = null_glBlendFuncSeparate; GLCAT.warning() << "BlendFuncSeparateOES advertised as supported by OpenGL ES runtime, but " @@ -2472,7 +2472,7 @@ reset() { _glBlendEquation = null_glBlendEquation; } - if (_glBlendEquation == NULL) { + if (_glBlendEquation == nullptr) { _glBlendEquation = null_glBlendEquation; GLCAT.warning() << "BlendEquation advertised as supported by OpenGL runtime, but could " @@ -2491,10 +2491,10 @@ reset() { } else { _supports_blend_equation_separate = false; - _glBlendEquationSeparate = NULL; + _glBlendEquationSeparate = nullptr; } - if (_supports_blend_equation_separate && _glBlendEquationSeparate == NULL) { + if (_supports_blend_equation_separate && _glBlendEquationSeparate == nullptr) { _supports_blend_equation_separate = false; GLCAT.warning() << "BlendEquationSeparate advertised as supported by OpenGL runtime, " @@ -2513,7 +2513,7 @@ reset() { _glBlendFuncSeparate = null_glBlendFuncSeparate; } - if (_glBlendFuncSeparate == NULL) { + if (_glBlendFuncSeparate == nullptr) { _glBlendFuncSeparate = null_glBlendFuncSeparate; GLCAT.warning() << "BlendFuncSeparate advertised as supported by OpenGL runtime, but could not get pointers to extension function.\n"; @@ -2522,7 +2522,7 @@ reset() { // In OpenGL ES 2.x, this is supported in the core. In 1.x, not at all. #ifndef OPENGLES - _glBlendColor = NULL; + _glBlendColor = nullptr; bool supports_blend_color = false; if (is_at_least_gl_version(1, 2)) { supports_blend_color = true; @@ -2533,11 +2533,11 @@ reset() { _glBlendColor = (PFNGLBLENDCOLORPROC) get_extension_func("glBlendColorEXT"); } - if (supports_blend_color && _glBlendColor == NULL) { + if (supports_blend_color && _glBlendColor == nullptr) { GLCAT.warning() << "BlendColor advertised as supported by OpenGL runtime, but could not get pointers to extension function.\n"; } - if (_glBlendColor == NULL) { + if (_glBlendColor == nullptr) { _glBlendColor = null_glBlendColor; } #endif @@ -2742,7 +2742,7 @@ reset() { glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, formats); for (int i = 0; i < num_compressed_formats; ++i) { const char *format_str = get_compressed_format_string(formats[i]); - if (format_str != NULL) { + if (format_str != nullptr) { GLCAT.debug(false) << " " << format_str << '\n'; } else { GLCAT.debug(false) @@ -2794,8 +2794,8 @@ reset() { #endif } else { - _glBindImageTexture = NULL; - _glMemoryBarrier = NULL; + _glBindImageTexture = nullptr; + _glMemoryBarrier = nullptr; } #endif // !OPENGLES_1 @@ -2816,10 +2816,10 @@ reset() { _glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC) get_extension_func("glSamplerParameterf"); _glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC) get_extension_func("glSamplerParameterfv"); - if (_glGenSamplers == NULL || _glDeleteSamplers == NULL || - _glBindSampler == NULL || _glSamplerParameteri == NULL || - _glSamplerParameteriv == NULL || _glSamplerParameterf == NULL || - _glSamplerParameterfv == NULL) { + if (_glGenSamplers == nullptr || _glDeleteSamplers == nullptr || + _glBindSampler == nullptr || _glSamplerParameteri == nullptr || + _glSamplerParameteriv == nullptr || _glSamplerParameterf == nullptr || + _glSamplerParameterfv == nullptr) { GLCAT.warning() << "GL_ARB_sampler_objects advertised as supported by OpenGL runtime, but could not get pointers to extension function.\n"; } else { @@ -2847,7 +2847,7 @@ reset() { get_extension_func("glBindVertexBuffers"); } - if (_glBindTextures != NULL && _glBindImageTextures != NULL) { + if (_glBindTextures != nullptr && _glBindImageTextures != nullptr) { _supports_multi_bind = true; } else { GLCAT.warning() @@ -2865,7 +2865,7 @@ reset() { _glGetInternalformativ = (PFNGLGETINTERNALFORMATIVPROC) get_extension_func("glGetInternalformativ"); - if (_glGetInternalformativ == NULL) { + if (_glGetInternalformativ == nullptr) { GLCAT.warning() << "ARB_internalformat_query2 advertised as supported by OpenGL runtime, but could not get pointers to extension function.\n"; } @@ -2884,8 +2884,8 @@ reset() { _glUniformHandleui64 = (PFNGLUNIFORMHANDLEUI64PROC) get_extension_func("glUniformHandleui64ARB"); - if (_glGetTextureHandle == NULL || _glMakeTextureHandleResident == NULL || - _glUniformHandleui64 == NULL) { + if (_glGetTextureHandle == nullptr || _glMakeTextureHandleResident == nullptr || + _glUniformHandleui64 == nullptr) { GLCAT.warning() << "GL_ARB_bindless_texture advertised as supported by OpenGL runtime, but could not get pointers to extension function.\n"; } else { @@ -2911,9 +2911,9 @@ reset() { get_extension_func("glProgramParameteri"); GLint num_binary_formats = 0; - if (_glGetProgramBinary != NULL && - _glProgramBinary != NULL && - _glProgramParameteri != NULL) { + if (_glGetProgramBinary != nullptr && + _glProgramBinary != nullptr && + _glProgramParameteri != nullptr) { glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &num_binary_formats); } @@ -3015,12 +3015,12 @@ reset() { _dithering_enabled = false; #ifndef OPENGLES_1 - _current_shader = (Shader *)NULL; - _current_shader_context = (ShaderContext *)NULL; - _vertex_array_shader = (Shader *)NULL; - _vertex_array_shader_context = (ShaderContext *)NULL; - _texture_binding_shader = (Shader *)NULL; - _texture_binding_shader_context = (ShaderContext *)NULL; + _current_shader = nullptr; + _current_shader_context = nullptr; + _vertex_array_shader = nullptr; + _vertex_array_shader_context = nullptr; + _texture_binding_shader = nullptr; + _texture_binding_shader_context = nullptr; #endif // Count the max number of lights @@ -3302,7 +3302,7 @@ clear(DrawableRegion *clearable) { int mask = 0; #ifndef OPENGLES_1 - if (_current_fbo != 0 && _glClearBufferfv != NULL) { + if (_current_fbo != 0 && _glClearBufferfv != nullptr) { // We can use glClearBuffer to clear all the color attachments, which // protects us from the overhead of having to call set_draw_buffer for // every single attachment. @@ -3457,7 +3457,7 @@ clear(DrawableRegion *clearable) { */ void CLP(GraphicsStateGuardian):: prepare_display_region(DisplayRegionPipelineReader *dr) { - nassertv(dr != (DisplayRegionPipelineReader *)NULL); + nassertv(dr != nullptr); GraphicsStateGuardian::prepare_display_region(dr); int l, b, w, h; @@ -3580,8 +3580,8 @@ clear_before_callback() { #ifndef OPENGLES_1 if (_vertex_array_shader_context != 0) { _vertex_array_shader_context->disable_shader_vertex_arrays(); - _vertex_array_shader = (Shader *)NULL; - _vertex_array_shader_context = (ShaderContext *)NULL; + _vertex_array_shader = nullptr; + _vertex_array_shader_context = nullptr; } #endif unbind_buffers(); @@ -3617,12 +3617,12 @@ clear_before_callback() { */ CPT(TransformState) CLP(GraphicsStateGuardian):: calc_projection_mat(const Lens *lens) { - if (lens == (Lens *)NULL) { - return NULL; + if (lens == nullptr) { + return nullptr; } if (!lens->is_linear()) { - return NULL; + return nullptr; } // The projection matrix must always be right-handed Y-up, even if our @@ -3815,18 +3815,18 @@ end_frame(Thread *current_thread) { // This breaks shaders across multiple regions. if (_vertex_array_shader_context != 0) { _vertex_array_shader_context->disable_shader_vertex_arrays(); - _vertex_array_shader = (Shader *)NULL; - _vertex_array_shader_context = (ShaderContext *)NULL; + _vertex_array_shader = nullptr; + _vertex_array_shader_context = nullptr; } if (_texture_binding_shader_context != 0) { _texture_binding_shader_context->disable_shader_texture_bindings(); - _texture_binding_shader = (Shader *)NULL; - _texture_binding_shader_context = (ShaderContext *)NULL; + _texture_binding_shader = nullptr; + _texture_binding_shader_context = nullptr; } if (_current_shader_context != 0) { _current_shader_context->unbind(); - _current_shader = (Shader *)NULL; - _current_shader_context = (ShaderContext *)NULL; + _current_shader = nullptr; + _current_shader_context = nullptr; } #endif @@ -3964,7 +3964,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, if (!has_fixed_function_pipeline()) { // We can't draw without a shader bound in OpenGL ES 2. This shouldn't // happen anyway unless the default shader failed to compile somehow. - if (_current_shader_context == NULL) { + if (_current_shader_context == nullptr) { return false; } } @@ -3973,7 +3973,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, if (!GraphicsStateGuardian::begin_draw_primitives(geom_reader, data_reader, force)) { return false; } - nassertr(_data_reader != (GeomVertexDataPipelineReader *)NULL, false); + nassertr(_data_reader != nullptr, false); _geom_display_list = 0; @@ -4033,7 +4033,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, unbind_buffers(); GeomContext *gc = geom_reader->prepare_now(get_prepared_objects(), this); - nassertr(gc != (GeomContext *)NULL, false); + nassertr(gc != nullptr, false); CLP(GeomContext) *ggc = DCAST(CLP(GeomContext), gc); //const CLP(GeomMunger) *gmunger = DCAST(CLP(GeomMunger), _munger); @@ -4176,7 +4176,7 @@ update_standard_vertex_arrays(bool force) { _sender.clear(); _sender.add_column(_data_reader, InternalName::get_normal(), - NULL, NULL, GLPf(Normal3), NULL); + nullptr, nullptr, GLPf(Normal3), nullptr); #ifndef NDEBUG if (_show_texture_usage) { // In show_texture_usage mode, all colors are white, so as not to @@ -4185,7 +4185,7 @@ update_standard_vertex_arrays(bool force) { } else #endif // NDEBUG if (!_sender.add_column(_data_reader, InternalName::get_color(), - NULL, NULL, GLPf(Color3), GLPf(Color4))) { + nullptr, nullptr, GLPf(Color3), GLPf(Color4))) { // If we didn't have a color column, the item color is white. GLPf(Color4)(1.0f, 1.0f, 1.0f, 1.0f); } @@ -4229,7 +4229,7 @@ update_standard_vertex_arrays(bool force) { // We must add vertex last, because glVertex3f() is the key function call // that actually issues the vertex. _sender.add_column(_data_reader, InternalName::get_vertex(), - NULL, GLPf(Vertex2), GLPf(Vertex3), GLPf(Vertex4)); + nullptr, GLPf(Vertex2), GLPf(Vertex3), GLPf(Vertex4)); } else #endif // SUPPORT_IMMEDIATE_MODE @@ -4365,7 +4365,7 @@ unbind_buffers() { #ifndef OPENGLES if (_current_vertex_buffers.size() > 1 && _supports_multi_bind) { - _glBindVertexBuffers(0, _current_vertex_buffers.size(), NULL, NULL, NULL); + _glBindVertexBuffers(0, _current_vertex_buffers.size(), nullptr, nullptr, nullptr); } else { for (int i = 0; i < _current_vertex_buffers.size(); ++i) { if (_current_vertex_buffers[i] != 0) { @@ -4443,7 +4443,7 @@ update_shader_vertex_format(const GeomVertexFormat *format) { continue; } - if (_vertex_attrib_columns[loc] != NULL && + if (_vertex_attrib_columns[loc] != nullptr && _vertex_attrib_columns[loc]->compare_to(*column) == 0) { continue; } @@ -5480,7 +5480,7 @@ end_draw_primitives() { */ void CLP(GraphicsStateGuardian):: issue_memory_barrier(GLbitfield barriers) { - if (!gl_enable_memory_barriers || _glMemoryBarrier == NULL) { + if (!gl_enable_memory_barriers || _glMemoryBarrier == nullptr) { return; } @@ -5542,7 +5542,7 @@ prepare_texture(Texture *tex, int view) { if (!_supports_3d_texture) { GLCAT.warning() << "3-D textures are not supported by this OpenGL driver.\n"; - return NULL; + return nullptr; } break; @@ -5550,7 +5550,7 @@ prepare_texture(Texture *tex, int view) { if (!_supports_2d_texture_array) { GLCAT.warning() << "2-D texture arrays are not supported by this OpenGL driver.\n"; - return NULL; + return nullptr; } break; @@ -5558,7 +5558,7 @@ prepare_texture(Texture *tex, int view) { if (!_supports_cube_map) { GLCAT.warning() << "Cube map textures are not supported by this OpenGL driver.\n"; - return NULL; + return nullptr; } break; @@ -5566,7 +5566,7 @@ prepare_texture(Texture *tex, int view) { if (!_supports_buffer_texture) { GLCAT.warning() << "Buffer textures are not supported by this OpenGL driver.\n"; - return NULL; + return nullptr; } break; @@ -5574,7 +5574,7 @@ prepare_texture(Texture *tex, int view) { if (!_supports_cube_map_array) { GLCAT.warning() << "Cube map arrays are not supported by this OpenGL driver.\n"; - return NULL; + return nullptr; } break; @@ -5693,7 +5693,7 @@ extract_texture_data(Texture *tex) { int num_views = tex->get_num_views(); for (int view = 0; view < num_views; ++view) { TextureContext *tc = tex->prepare_now(view, get_prepared_objects(), this); - nassertr(tc != (TextureContext *)NULL, false); + nassertr(tc != nullptr, false); CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), tc); if (!do_extract_texture_data(gtc)) { @@ -5717,7 +5717,7 @@ extract_texture_data(Texture *tex) { */ SamplerContext *CLP(GraphicsStateGuardian):: prepare_sampler(const SamplerState &sampler) { - nassertr(_supports_sampler_objects, NULL); + nassertr(_supports_sampler_objects, nullptr); PStatGPUTimer timer(this, _prepare_sampler_pcollector); CLP(SamplerContext) *gsc = new CLP(SamplerContext)(this, sampler); @@ -5852,7 +5852,7 @@ prepare_shader(Shader *se) { PStatGPUTimer timer(this, _prepare_shader_pcollector); #ifndef OPENGLES_1 - ShaderContext *result = NULL; + ShaderContext *result = nullptr; switch (se->get_language()) { case Shader::SL_GLSL: @@ -5862,7 +5862,7 @@ prepare_shader(Shader *se) { } else { GLCAT.error() << "Tried to load GLSL shader, but GLSL shaders not supported.\n"; - return NULL; + return nullptr; } case Shader::SL_Cg: @@ -5873,22 +5873,22 @@ prepare_shader(Shader *se) { } else { GLCAT.error() << "Tried to load Cg shader, but basic shaders not supported.\n"; - return NULL; + return nullptr; } #elif defined(OPENGLES) GLCAT.error() << "Tried to load Cg shader, but Cg support is not available for OpenGL ES.\n"; - return NULL; + return nullptr; #else GLCAT.error() << "Tried to load Cg shader, but Cg support not compiled in.\n"; - return NULL; + return nullptr; #endif default: GLCAT.error() << "Tried to load shader with unsupported shader language!\n"; - return NULL; + return nullptr; } if (result->valid()) { @@ -5898,7 +5898,7 @@ prepare_shader(Shader *se) { delete result; #endif // OPENGLES_1 - return NULL; + return nullptr; } /** @@ -5961,7 +5961,7 @@ prepare_vertex_buffer(GeomVertexArrayData *data) { return gvbc; } - return NULL; + return nullptr; } /** @@ -5988,7 +5988,7 @@ update_vertex_buffer(CLP(VertexBufferContext) *gvbc, } if (num_bytes != 0) { const unsigned char *client_pointer = reader->get_read_pointer(force); - if (client_pointer == NULL) { + if (client_pointer == nullptr) { return false; } @@ -6077,7 +6077,7 @@ setup_array_data(const unsigned char *&client_pointer, if (!_supports_buffers) { // No support for buffer objects; always render from client. client_pointer = array_reader->get_read_pointer(force); - return (client_pointer != NULL); + return (client_pointer != nullptr); } if (!vertex_buffers || _geom_display_list != 0 || array_reader->get_usage_hint() < gl_min_buffer_usage_hint) { @@ -6092,14 +6092,14 @@ setup_array_data(const unsigned char *&client_pointer, _current_vbuffer_index = 0; } client_pointer = array_reader->get_read_pointer(force); - return (client_pointer != NULL); + return (client_pointer != nullptr); } // Prepare the buffer object and bind it. CLP(VertexBufferContext) *gvbc = DCAST(CLP(VertexBufferContext), array_reader->prepare_now(get_prepared_objects(), this)); - nassertr(gvbc != (CLP(VertexBufferContext) *)NULL, false); + nassertr(gvbc != (CLP(VertexBufferContext) *)nullptr, false); if (!update_vertex_buffer(gvbc, array_reader, force)) { return false; } @@ -6114,7 +6114,7 @@ setup_array_data(const unsigned char *&client_pointer, } // NULL is the OpenGL convention for the first byte of the buffer object. - client_pointer = NULL; + client_pointer = nullptr; return true; } @@ -6149,7 +6149,7 @@ prepare_index_buffer(GeomPrimitive *data) { return gibc; } - return NULL; + return nullptr; } /** @@ -6186,7 +6186,7 @@ apply_index_buffer(IndexBufferContext *ibc, } if (num_bytes != 0) { const unsigned char *client_pointer = reader->get_read_pointer(force); - if (client_pointer == NULL) { + if (client_pointer == nullptr) { return false; } @@ -6266,7 +6266,7 @@ setup_primitive(const unsigned char *&client_pointer, if (!_supports_buffers) { // No support for buffer objects; always render from client. client_pointer = reader->get_read_pointer(force); - return (client_pointer != NULL); + return (client_pointer != nullptr); } if (!vertex_buffers || _geom_display_list != 0 || reader->get_usage_hint() == Geom::UH_client) { @@ -6281,18 +6281,18 @@ setup_primitive(const unsigned char *&client_pointer, _current_ibuffer_index = 0; } client_pointer = reader->get_read_pointer(force); - return (client_pointer != NULL); + return (client_pointer != nullptr); } // Prepare the buffer object and bind it. IndexBufferContext *ibc = reader->prepare_now(get_prepared_objects(), this); - nassertr(ibc != (IndexBufferContext *)NULL, false); + nassertr(ibc != nullptr, false); if (!apply_index_buffer(ibc, reader, force)) { return false; } // NULL is the OpenGL convention for the first byte of the buffer object. - client_pointer = NULL; + client_pointer = nullptr; return true; } @@ -6339,7 +6339,7 @@ prepare_shader_buffer(ShaderBuffer *data) { return gbc; } - return NULL; + return nullptr; } /** @@ -6348,9 +6348,9 @@ prepare_shader_buffer(ShaderBuffer *data) { void CLP(GraphicsStateGuardian):: apply_shader_buffer(GLuint base, ShaderBuffer *buffer) { GLuint index = 0; - if (buffer != NULL) { + if (buffer != nullptr) { BufferContext *bc = buffer->prepare_now(get_prepared_objects(), this); - if (bc != NULL) { + if (bc != nullptr) { CLP(BufferContext) *gbc = DCAST(CLP(BufferContext), bc); index = gbc->_index; gbc->set_active(true); @@ -6427,7 +6427,7 @@ release_shader_buffer(BufferContext *bc) { void CLP(GraphicsStateGuardian):: begin_occlusion_query() { nassertv(_supports_occlusion_query); - nassertv(_current_occlusion_query == (OcclusionQueryContext *)NULL); + nassertv(_current_occlusion_query == nullptr); PT(CLP(OcclusionQueryContext)) query = new CLP(OcclusionQueryContext)(this); _glGenQueries(1, &query->_index); @@ -6453,7 +6453,7 @@ begin_occlusion_query() { */ PT(OcclusionQueryContext) CLP(GraphicsStateGuardian):: end_occlusion_query() { - nassertr(_current_occlusion_query != (OcclusionQueryContext *)NULL, NULL); + nassertr(_current_occlusion_query != nullptr, nullptr); PT(OcclusionQueryContext) result = _current_occlusion_query; GLuint index = DCAST(CLP(OcclusionQueryContext), result)->_index; @@ -6463,7 +6463,7 @@ end_occlusion_query() { << "ending occlusion query index " << (int)index << "\n"; } - _current_occlusion_query = NULL; + _current_occlusion_query = nullptr; _glEndQuery(GL_SAMPLES_PASSED); // Temporary hack to try working around an apparent driver bug on iMacs. @@ -6493,7 +6493,7 @@ end_occlusion_query() { PT(TimerQueryContext) CLP(GraphicsStateGuardian):: issue_timer_query(int pstats_index) { #if defined(DO_PSTATS) && !defined(OPENGLES) - nassertr(_supports_timer_query, NULL); + nassertr(_supports_timer_query, nullptr); PT(CLP(TimerQueryContext)) query; @@ -6531,7 +6531,7 @@ issue_timer_query(int pstats_index) { return (TimerQueryContext *)query; #else - return NULL; + return nullptr; #endif } @@ -6546,7 +6546,7 @@ dispatch_compute(int num_groups_x, int num_groups_y, int num_groups_z) { PStatGPUTimer timer(this, _compute_dispatch_pcollector); nassertv(_supports_compute_shaders); - nassertv(_current_shader_context != NULL); + nassertv(_current_shader_context != nullptr); _glDispatchCompute(num_groups_x, num_groups_y, num_groups_z); maybe_gl_finish(); @@ -6572,7 +6572,7 @@ make_geom_munger(const RenderState *state, Thread *current_thread) { bool CLP(GraphicsStateGuardian):: framebuffer_copy_to_texture(Texture *tex, int view, int z, const DisplayRegion *dr, const RenderBuffer &rb) { - nassertr(tex != NULL && dr != NULL, false); + nassertr(tex != nullptr && dr != nullptr, false); set_read_buffer(rb._buffer_type); clear_color_write_mask(); @@ -6659,7 +6659,7 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, } TextureContext *tc = tex->prepare_now(view, get_prepared_objects(), this); - nassertr(tc != (TextureContext *)NULL, false); + nassertr(tc != nullptr, false); CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), tc); apply_texture(gtc); @@ -6675,7 +6675,7 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, if (uses_mipmaps) { if (_supports_generate_mipmap) { #ifndef OPENGLES_2 - if (_glGenerateMipmap == NULL) { + if (_glGenerateMipmap == nullptr) { glTexParameteri(target, GL_GENERATE_MIPMAP, true); } #endif @@ -6735,7 +6735,7 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, // to specify them. Might as well use the actual values. GLint external_format = get_external_image_format(tex); GLint component_type = get_component_type(tex->get_component_type()); - _glTexImage3D(target, 0, internal_format, width, height, depth, 0, external_format, component_type, NULL); + _glTexImage3D(target, 0, internal_format, width, height, depth, 0, external_format, component_type, nullptr); } _glCopyTexSubImage3D(target, 0, 0, 0, z, xo, yo, w, h); @@ -6752,7 +6752,7 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, } } - if (uses_mipmaps && _glGenerateMipmap != NULL) { + if (uses_mipmaps && _glGenerateMipmap != nullptr) { glEnable(target); _glGenerateMipmap(target); glDisable(target); @@ -6787,7 +6787,7 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, bool CLP(GraphicsStateGuardian):: framebuffer_copy_to_ram(Texture *tex, int view, int z, const DisplayRegion *dr, const RenderBuffer &rb) { - nassertr(tex != NULL && dr != NULL, false); + nassertr(tex != nullptr && dr != nullptr, false); set_read_buffer(rb._buffer_type); glPixelStorei(GL_PACK_ALIGNMENT, 1); clear_color_write_mask(); @@ -7059,7 +7059,7 @@ do_issue_shader() { // If we don't have a shader, apply the default shader. if (!has_fixed_function_pipeline() && !shader) { shader = _default_shader; - nassertv(shader != NULL); + nassertv(shader != nullptr); } if (shader) { @@ -7074,7 +7074,7 @@ do_issue_shader() { if (_default_shader != nullptr && shader != _default_shader && (context == 0 || !context->valid())) { shader = _default_shader; - nassertv(shader != NULL); + nassertv(shader != nullptr); if (_current_shader != shader) { context = shader->prepare_now(get_prepared_objects(), this); } else { @@ -7092,7 +7092,7 @@ do_issue_shader() { if (context != _current_shader_context) { // Use a completely different shader than before. Unbind old shader, // bind the new one. - if (_current_shader_context != NULL && + if (_current_shader_context != nullptr && _current_shader->get_language() != shader->get_language()) { // If it's a different type of shader, make sure to unbind the old. _current_shader_context->unbind(); @@ -7403,7 +7403,7 @@ do_issue_fog() { if (!target_fog->is_off()) { enable_fog(true); Fog *fog = target_fog->get_fog(); - nassertv(fog != (Fog *)NULL); + nassertv(fog != nullptr); apply_fog(fog); } else { enable_fog(false); @@ -7461,7 +7461,7 @@ do_issue_material() { const MaterialAttrib *target_material; _target_rs->get_attrib_def(target_material); - if (target_material == (MaterialAttrib *)NULL || + if (target_material == nullptr || target_material->is_off()) { material = ∅ } else { @@ -7890,7 +7890,7 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { // _draw_set_state_light_bind_spotlight_pcollector); Lens *lens = light_obj->get_lens(); - nassertv(lens != (Lens *)NULL); + nassertv(lens != nullptr); GLenum id = get_light_id(light_id); static const LColor black(0.0f, 0.0f, 0.0f, 1.0f); @@ -8116,7 +8116,7 @@ show_gl_string(const string &name, GLenum id) { const GLubyte *text = glGetString(id); - if (text == (const GLubyte *)NULL) { + if (text == nullptr) { GLCAT.warning() << "Unable to query " << name << "\n"; @@ -8281,7 +8281,7 @@ query_glsl_version() { */ void CLP(GraphicsStateGuardian):: save_extensions(const char *extensions) { - if (extensions != (const char *)NULL) { + if (extensions != nullptr) { vector_string tokens; extract_words(extensions, tokens); @@ -8397,11 +8397,11 @@ get_extension_func(const char *name) { { "glDeleteBuffers", (void *)&glDeleteBuffers }, { "glGenBuffers", (void *)&glGenBuffers }, #endif - { NULL, NULL } + { nullptr, nullptr } }; int i = 0; - while (compiled_function_table[i].name != NULL) { + while (compiled_function_table[i].name != nullptr) { if (strcmp(compiled_function_table[i].name, name) == 0) { return compiled_function_table[i].fptr; } @@ -8421,7 +8421,7 @@ get_extension_func(const char *name) { */ void *CLP(GraphicsStateGuardian):: do_get_extension_func(const char *) { - return NULL; + return nullptr; } /** @@ -10446,7 +10446,7 @@ get_compressed_format_string(GLenum format) { case 0x93F0: return "GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG"; case 0x93F1: return "GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG"; default: - return NULL; + return nullptr; } } #endif @@ -10760,13 +10760,13 @@ set_state_and_transform(const RenderState *target, _state_shader = _target_shader; _state_mask.clear_bit(TextureAttrib::get_class_slot()); } - else if (!has_fixed_function_pipeline() && _current_shader == NULL) { // In the case of OpenGL ES 2.x, we need to glUseShader before we draw anything. + else if (!has_fixed_function_pipeline() && _current_shader == nullptr) { // In the case of OpenGL ES 2.x, we need to glUseShader before we draw anything. do_issue_shader(); _state_mask.clear_bit(TextureAttrib::get_class_slot()); } // Update all of the state that is bound to the shader program. - if (_current_shader_context != NULL) { + if (_current_shader_context != nullptr) { _current_shader_context->set_state_and_transform(target, transform, _scene_setup->get_camera_transform(), _projection_mat); } #endif @@ -11055,7 +11055,7 @@ do_issue_texture() { disable_standard_texture_bindings(); } #endif - _current_shader_context->update_shader_texture_bindings(NULL); + _current_shader_context->update_shader_texture_bindings(nullptr); } else { _current_shader_context-> update_shader_texture_bindings(_texture_binding_shader_context); @@ -11088,7 +11088,7 @@ update_standard_texture_bindings() { // see if our flash_texture is in the texture stack here. If so, then we // need to call the special show_texture method instead of the normal // texture stack. - if (_flash_texture != (Texture *)NULL) { + if (_flash_texture != nullptr) { double now = ClockObject::get_global_clock()->get_frame_time(); int this_second = (int)floor(now); if (this_second & 1) { @@ -11120,7 +11120,7 @@ update_standard_texture_bindings() { for (i = 0; i < num_stages; i++) { TextureStage *stage = _target_texture->get_on_ff_stage(i); Texture *texture = _target_texture->get_on_texture(stage); - nassertv(texture != (Texture *)NULL); + nassertv(texture != nullptr); // Issue the texture on stage i. set_active_texture_stage(i); @@ -11140,7 +11140,7 @@ update_standard_texture_bindings() { int view = get_current_tex_view_offset() + stage->get_tex_view_offset(); TextureContext *tc = texture->prepare_now(view, _prepared_objects, this); - if (tc == (TextureContext *)NULL) { + if (tc == nullptr) { // Something wrong with this texture; skip it. continue; } @@ -11375,11 +11375,11 @@ update_show_usage_texture_bindings(int show_stage_index) { for (i = 0; i < num_stages; i++) { TextureStage *stage = _target_texture->get_on_ff_stage(i); Texture *texture = _target_texture->get_on_texture(stage); - nassertv(texture != (Texture *)NULL); + nassertv(texture != nullptr); int view = get_current_tex_view_offset() + stage->get_tex_view_offset(); TextureContext *tc = texture->prepare_now(view, _prepared_objects, this); - if (tc == (TextureContext *)NULL) { + if (tc == nullptr) { // Something wrong with this texture; skip it. break; } @@ -11420,7 +11420,7 @@ update_show_usage_texture_bindings(int show_stage_index) { TextureStage *stage = _target_texture->get_on_ff_stage(i); Texture *texture = _target_texture->get_on_texture(stage); - nassertv(texture != (Texture *)NULL); + nassertv(texture != nullptr); // Choose the corresponding usage texture and apply it. set_active_texture_stage(i); @@ -12040,7 +12040,7 @@ apply_sampler(GLuint unit, const SamplerState &sampler, CLP(TextureContext) *gtc // We support sampler objects. Prepare the sampler object and bind it to // the indicated texture unit. SamplerContext *sc = sampler.prepare_now(get_prepared_objects(), this); - nassertr(sc != (SamplerContext *)NULL, false); + nassertr(sc != nullptr, false); CLP(SamplerContext) *gsc = DCAST(CLP(SamplerContext), sc); gsc->enqueue_lru(&_prepared_objects->_sampler_object_lru); @@ -12397,7 +12397,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { } #ifndef OPENGLES_2 - if (gtc->_generate_mipmaps && _glGenerateMipmap == NULL) { + if (gtc->_generate_mipmaps && _glGenerateMipmap == nullptr) { // The old, deprecated way to generate mipmaps. glTexParameteri(target, GL_GENERATE_MIPMAP, GL_TRUE); } @@ -12547,7 +12547,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { component_type, false, 0, image_compression); } - if (gtc->_generate_mipmaps && _glGenerateMipmap != NULL && + if (gtc->_generate_mipmaps && _glGenerateMipmap != nullptr && !image.is_null()) { // We uploaded an image; we may need to generate mipmaps. if (GLCAT.is_debug()) { @@ -12582,7 +12582,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { if (tex->has_ram_image()) { BamCache *cache = BamCache::get_global_ptr(); PT(BamCacheRecord) record = cache->lookup(tex->get_fullpath(), "txo"); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->set_data(tex, tex); cache->store(record); } @@ -12591,7 +12591,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { } GraphicsEngine *engine = get_engine(); - nassertr(engine != (GraphicsEngine *)NULL, false); + nassertr(engine != nullptr, false); engine->texture_uploaded(tex); gtc->mark_loaded(); @@ -12634,7 +12634,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, } Texture *tex = gtc->get_texture(); - nassertr(tex != (Texture *)NULL, false); + nassertr(tex != nullptr, false); CPTA_uchar image = tex->get_ram_mipmap_image(mipmap_bias); int width = tex->get_expected_mipmap_x_size(mipmap_bias); @@ -12697,7 +12697,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, // mipmap image pointer which is a PTA_uchar const unsigned char *image_ptr = (unsigned char*)tex->get_ram_mipmap_pointer(n); CPTA_uchar ptimage; - if (image_ptr == (const unsigned char *)NULL) { + if (image_ptr == nullptr) { ptimage = tex->get_ram_mipmap_image(n); if (ptimage.is_null()) { if (n < num_ram_mipmap_levels) { @@ -12750,7 +12750,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, PTA_uchar bgr_image; size_t view_size = tex->get_ram_mipmap_view_size(n); - if (image_ptr != (const unsigned char *)NULL) { + if (image_ptr != nullptr) { const unsigned char *orig_image_ptr = image_ptr; image_ptr += view_size * gtc->get_view(); if (one_page_only) { @@ -12894,7 +12894,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, for (int n = mipmap_bias; n < num_levels; ++n) { const unsigned char *image_ptr = (unsigned char*)tex->get_ram_mipmap_pointer(n); CPTA_uchar ptimage; - if (image_ptr == (const unsigned char *)NULL) { + if (image_ptr == nullptr) { ptimage = tex->get_ram_mipmap_image(n); if (ptimage.is_null()) { if (n < num_ram_mipmap_levels) { @@ -12930,7 +12930,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, PTA_uchar bgr_image; size_t view_size = tex->get_ram_mipmap_view_size(n); - if (image_ptr != (const unsigned char *)NULL) { + if (image_ptr != nullptr) { const unsigned char *orig_image_ptr = image_ptr; image_ptr += view_size * gtc->get_view(); if (one_page_only) { @@ -13054,14 +13054,14 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, void CLP(GraphicsStateGuardian):: generate_mipmaps(CLP(TextureContext) *gtc) { #ifndef OPENGLES - if (_glGenerateTextureMipmap != NULL) { + if (_glGenerateTextureMipmap != nullptr) { // OpenGL 4.5 offers an easy way to do this without binding. _glGenerateTextureMipmap(gtc->_index); return; } #endif - if (_glGenerateMipmap != NULL) { + if (_glGenerateMipmap != nullptr) { _state_texture = 0; update_texture(gtc, true); apply_texture(gtc); @@ -13082,13 +13082,13 @@ upload_simple_texture(CLP(TextureContext) *gtc) { PStatGPUTimer timer(this, _load_texture_pcollector); Texture *tex = gtc->get_texture(); - nassertr(tex != (Texture *)NULL, false); + nassertr(tex != nullptr, false); GLenum internal_format = GL_RGBA; GLenum external_format = GL_BGRA; const unsigned char *image_ptr = tex->get_simple_ram_image(); - if (image_ptr == (const unsigned char *)NULL) { + if (image_ptr == nullptr) { return false; } @@ -13248,7 +13248,7 @@ check_nonresident_texture(BufferContextChain &chain) { GLuint *texture_list = (GLuint *)alloca(num_textures * sizeof(GLuint)); size_t ti = 0; BufferContext *node = chain.get_first(); - while (node != (BufferContext *)NULL) { + while (node != nullptr) { CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), node); gtc_list[ti] = gtc; texture_list[ti] = gtc->_index; diff --git a/panda/src/glstuff/glImmediateModeSender_src.cxx b/panda/src/glstuff/glImmediateModeSender_src.cxx index b832132a33..f7fba14cc3 100644 --- a/panda/src/glstuff/glImmediateModeSender_src.cxx +++ b/panda/src/glstuff/glImmediateModeSender_src.cxx @@ -74,35 +74,35 @@ add_column(const GeomVertexDataPipelineReader *data_reader, const InternalName * Func1f *func1f, Func2f *func2, Func3f *func3, Func4f *func4) { if (data_reader->has_column(name)) { GeomVertexReader *reader = new GeomVertexReader(data_reader, name); - ComponentSender *sender = NULL; + ComponentSender *sender = nullptr; const GeomVertexColumn *column = reader->get_column(); switch (column->get_num_components()) { case 1: - if (func1f != (Func1f *)NULL) { + if (func1f != nullptr) { sender = new ComponentSender1f(reader, func1f); } break; case 2: - if (func2 != (Func2f *)NULL) { + if (func2 != nullptr) { sender = new ComponentSender2f(reader, func2); } break; case 3: - if (func3 != (Func3f *)NULL) { + if (func3 != nullptr) { sender = new ComponentSender3f(reader, func3); } break; case 4: - if (func4 != (Func4f *)NULL) { + if (func4 != nullptr) { sender = new ComponentSender4f(reader, func4); } break; } - if (sender != (ComponentSender *)NULL) { + if (sender != nullptr) { // Ok, we've got a valid sender; add it to the list. _senders.push_back(sender); return true; @@ -135,7 +135,7 @@ add_texcoord_column(const GeomVertexDataPipelineReader *data_reader, TexcoordFunc3f *func3, TexcoordFunc4f *func4) { if (data_reader->has_column(name)) { GeomVertexReader *reader = new GeomVertexReader(data_reader, name); - ComponentSender *sender = NULL; + ComponentSender *sender = nullptr; const GeomVertexColumn *column = reader->get_column(); switch (column->get_num_components()) { case 1: @@ -155,7 +155,7 @@ add_texcoord_column(const GeomVertexDataPipelineReader *data_reader, break; } - if (sender != (ComponentSender *)NULL) { + if (sender != nullptr) { // Ok, we've got a valid sender; add it to the list. _senders.push_back(sender); return true; @@ -186,7 +186,7 @@ add_vector_column(const GeomVertexDataPipelineReader *data_reader, const Interna VectorFunc *func) { if (data_reader->has_column(name)) { GeomVertexReader *reader = new GeomVertexReader(data_reader, name); - ComponentSender *sender = NULL; + ComponentSender *sender = nullptr; const GeomVertexColumn *column = reader->get_column(); switch (column->get_num_components()) { case 1: @@ -206,7 +206,7 @@ add_vector_column(const GeomVertexDataPipelineReader *data_reader, const Interna break; } - if (sender != (ComponentSender *)NULL) { + if (sender != nullptr) { // Ok, we've got a valid sender; add it to the list. _senders.push_back(sender); return true; @@ -236,7 +236,7 @@ add_vector_uint_column(const GeomVertexDataPipelineReader *data_reader, const InternalName *name, VectorUintFunc *func) { if (data_reader->has_column(name)) { GeomVertexReader *reader = new GeomVertexReader(data_reader, name); - ComponentSender *sender = NULL; + ComponentSender *sender = nullptr; const GeomVertexColumn *column = reader->get_column(); switch (column->get_num_components()) { case 1: @@ -256,7 +256,7 @@ add_vector_uint_column(const GeomVertexDataPipelineReader *data_reader, break; } - if (sender != (ComponentSender *)NULL) { + if (sender != nullptr) { // Ok, we've got a valid sender; add it to the list. _senders.push_back(sender); return true; diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index 6c756631e2..203cccb727 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -318,7 +318,7 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext for (int i = 0; i < block_count; ++i) { block_name_cstr[0] = 0; - _glgsg->_glGetActiveUniformBlockName(_glsl_program, i, block_maxlength, NULL, block_name_cstr); + _glgsg->_glGetActiveUniformBlockName(_glsl_program, i, block_maxlength, nullptr, block_name_cstr); reflect_uniform_block(i, block_name_cstr, name_buffer, name_buflen); } @@ -337,11 +337,11 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext for (int i = 0; i < block_count; ++i) { block_name_cstr[0] = 0; - _glgsg->_glGetProgramResourceName(_glsl_program, GL_SHADER_STORAGE_BLOCK, i, block_maxlength, NULL, block_name_cstr); + _glgsg->_glGetProgramResourceName(_glsl_program, GL_SHADER_STORAGE_BLOCK, i, block_maxlength, nullptr, block_name_cstr); const GLenum props[] = {GL_BUFFER_BINDING, GL_BUFFER_DATA_SIZE}; GLint values[2]; - _glgsg->_glGetProgramResourceiv(_glsl_program, GL_SHADER_STORAGE_BLOCK, i, 2, props, 2, NULL, values); + _glgsg->_glGetProgramResourceiv(_glsl_program, GL_SHADER_STORAGE_BLOCK, i, 2, props, 2, nullptr, values); StorageBlock block; block._name = InternalName::make(block_name_cstr); @@ -369,7 +369,7 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext _glgsg->report_my_gl_errors(); // Restore the active shader. - if (_glgsg->_current_shader_context == NULL) { + if (_glgsg->_current_shader_context == nullptr) { _glgsg->_glUseProgram(0); } else { _glgsg->_current_shader_context->bind(); @@ -387,7 +387,7 @@ reflect_attribute(int i, char *name_buffer, GLsizei name_buflen) { // Get the name, size, and type of this attribute. name_buffer[0] = 0; - _glgsg->_glGetActiveAttrib(_glsl_program, i, name_buflen, NULL, + _glgsg->_glGetActiveAttrib(_glsl_program, i, name_buflen, nullptr, ¶m_size, ¶m_type, name_buffer); // Get the attrib location. @@ -415,7 +415,7 @@ reflect_attribute(int i, char *name_buffer, GLsizei name_buflen) { Shader::ShaderVarSpec bind; bind._id = arg_id; - bind._name = NULL; + bind._name = nullptr; bind._append_uv = -1; bind._elements = 1; @@ -564,7 +564,7 @@ reflect_uniform_block(int i, const char *name, char *name_buffer, GLsizei name_b name_buffer[0] = 0; GLint param_size; GLenum param_type; - _glgsg->_glGetActiveUniform(_glsl_program, indices[ui], name_buflen, NULL, ¶m_size, ¶m_type, name_buffer); + _glgsg->_glGetActiveUniform(_glsl_program, indices[ui], name_buflen, nullptr, ¶m_size, ¶m_type, name_buffer); // Strip off [0] suffix that some drivers append to arrays. size_t size = strlen(name_buffer); @@ -701,7 +701,7 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { // Get the name, location, type and size of this uniform. name_buffer[0] = 0; - _glgsg->_glGetActiveUniform(_glsl_program, i, name_buflen, NULL, ¶m_size, ¶m_type, name_buffer); + _glgsg->_glGetActiveUniform(_glsl_program, i, name_buflen, nullptr, ¶m_size, ¶m_type, name_buffer); GLint p = _glgsg->_glGetUniformLocation(_glsl_program, name_buffer); if (GLCAT.is_debug()) { @@ -785,8 +785,8 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { << "Matrix input p3d_" << matrix_name << " should be mat3 or mat4\n"; return; } - bind._arg[0] = NULL; - bind._arg[1] = NULL; + bind._arg[0] = nullptr; + bind._arg[1] = nullptr; if (matrix_name == "ModelViewProjectionMatrix") { if (inverse) { @@ -884,14 +884,14 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._part[0] = Shader::SMO_light_source_i_attrib; bind._arg[0] = InternalName::make(name_buffer); bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; } else if (strncmp(name_buffer, "shadowMatrix", 127) == 0) { // Only supported for backward compatibility: includes the model // matrix. Not very efficient to do this. bind._func = Shader::SMF_compose; bind._part[0] = Shader::SMO_model_to_apiview; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = Shader::SMO_light_source_i_attrib; bind._arg[1] = InternalName::make("shadowViewMatrix"); @@ -946,10 +946,10 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._id = arg_id; bind._func = Shader::SMF_first; bind._part[0] = Shader::SMO_attr_material; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._dep[0] = Shader::SSD_general | Shader::SSD_material | Shader::SSD_frame; bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._dep[1] = Shader::SSD_NONE; if (noprefix == "Material.baseColor") { @@ -1053,10 +1053,10 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._id = arg_id; bind._func = Shader::SMF_first; bind._part[0] = Shader::SMO_attr_colorscale; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._dep[0] = Shader::SSD_general | Shader::SSD_colorscale; bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._dep[1] = Shader::SSD_NONE; if (param_type == GL_FLOAT_VEC3) { @@ -1077,10 +1077,10 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._id = arg_id; bind._func = Shader::SMF_first; bind._part[0] = Shader::SMO_attr_color; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._dep[0] = Shader::SSD_general | Shader::SSD_color; bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._dep[1] = Shader::SSD_NONE; if (param_type == GL_FLOAT_VEC3) { @@ -1110,10 +1110,10 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._func = Shader::SMF_first; bind._index = i; bind._part[0] = Shader::SMO_apiview_clipplane_i; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._dep[0] = Shader::SSD_general | Shader::SSD_clip_planes; bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._dep[1] = Shader::SSD_NONE; _shader->_mat_spec.push_back(bind); _shader->_mat_deps |= bind._dep[0]; @@ -1125,10 +1125,10 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._id = arg_id; bind._func = Shader::SMF_first; bind._part[0] = Shader::SMO_light_ambient; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._dep[0] = Shader::SSD_general | Shader::SSD_light; bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._dep[1] = Shader::SSD_NONE; if (param_type == GL_FLOAT_VEC3) { @@ -1183,7 +1183,7 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._arg[0] = InternalName::make(member_name); bind._dep[0] = Shader::SSD_general | Shader::SSD_light | Shader::SSD_frame; bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._dep[1] = Shader::SSD_NONE; if (member_name == "position" || member_name == "halfVector" || @@ -1245,10 +1245,10 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._func = Shader::SMF_first; bind._index = 0; bind._part[0] = Shader::SMO_tex_is_alpha_i; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._dep[0] = Shader::SSD_general | Shader::SSD_texture | Shader::SSD_frame; bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._dep[1] = Shader::SSD_NONE; bind._piece = Shader::SMP_row3; _shader->_mat_spec.push_back(bind); @@ -1265,8 +1265,8 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { Shader::ShaderMatSpec bind; bind._id = arg_id; - bind._arg[0] = NULL; - bind._arg[1] = NULL; + bind._arg[0] = nullptr; + bind._arg[1] = nullptr; if (noprefix == "ViewMatrix") { bind._piece = Shader::SMP_whole; @@ -1395,7 +1395,7 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._arg[0] = InternalName::make(param_name); bind._dep[0] = Shader::SSD_general | Shader::SSD_shaderinputs | Shader::SSD_frame; bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._dep[1] = Shader::SSD_NONE; _shader->_mat_spec.push_back(bind); _shader->_mat_deps |= bind._dep[0]; @@ -1407,7 +1407,7 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._piece = Shader::SMP_whole; bind._func = Shader::SMF_first; bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._dep[1] = Shader::SSD_NONE; PT(InternalName) iname = InternalName::make(param_name); if (iname->get_parent() != InternalName::get_root()) { @@ -1428,7 +1428,7 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { } bind._func = Shader::SMF_compose; bind._part[0] = Shader::SMO_model_to_apiview; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._dep[0] = Shader::SSD_general | Shader::SSD_transform; bind._part[1] = Shader::SMO_mat_constant_x_attrib; bind._arg[1] = iname->get_parent()->append("shadowViewMatrix"); @@ -1478,7 +1478,7 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { // position) have to be transformed to view space. bind._dep[0] = Shader::SSD_general | Shader::SSD_shaderinputs | Shader::SSD_frame | Shader::SSD_view_transform; bind._part[1] = Shader::SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._dep[1] = Shader::SSD_NONE; _shader->_mat_spec.push_back(bind); _shader->_mat_deps |= bind._dep[0]; @@ -1568,7 +1568,7 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { ImageInput input; input._name = InternalName::make(param_name); input._writable = false; - input._gtc = NULL; + input._gtc = nullptr; _glsl_img_inputs.push_back(input); } return; @@ -1987,7 +1987,7 @@ issue_parameters(int altered) { Shader::ShaderPtrSpec &spec = _shader->_ptr_spec[i]; const Shader::ShaderPtrData* ptr_data = _glgsg->fetch_ptr_parameter(spec); - if (ptr_data == NULL) { //the input is not contained in ShaderPtrData + if (ptr_data == nullptr) { //the input is not contained in ShaderPtrData release_resources(); return; } @@ -1997,7 +1997,7 @@ issue_parameters(int altered) { switch (spec._type) { case Shader::SPT_float: { - float *data = NULL; + float *data = nullptr; switch (ptr_data->_type) { case Shader::SPT_int: @@ -2149,7 +2149,7 @@ update_transform_table(const TransformTable *table) { LMatrix4f *matrices = (LMatrix4f *)alloca(_transform_table_size * 64); size_t i = 0; - if (table != NULL) { + if (table != nullptr) { size_t num_transforms = min((size_t)_transform_table_size, table->get_num_transforms()); for (; i < num_transforms; ++i) { #ifdef STDFLOAT_DOUBLE @@ -2177,7 +2177,7 @@ update_slider_table(const SliderTable *table) { float *sliders = (float *)alloca(_slider_table_size * 4); memset(sliders, 0, _slider_table_size * 4); - if (table != NULL) { + if (table != nullptr) { size_t num_sliders = min((size_t)_slider_table_size, table->get_num_sliders()); for (size_t i = 0; i < num_sliders; ++i) { sliders[i] = table->get_slider(i)->get_slider(); @@ -2236,7 +2236,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { // Make sure the vertex buffer is up-to-date. CLP(VertexBufferContext) *gvbc = DCAST(CLP(VertexBufferContext), array_reader->prepare_now(_glgsg->get_prepared_objects(), _glgsg)); - nassertr(gvbc != (CLP(VertexBufferContext) *)NULL, false); + nassertr(gvbc != (CLP(VertexBufferContext) *)nullptr, false); if (!_glgsg->update_vertex_buffer(gvbc, array_reader, force)) { return false; @@ -2409,7 +2409,7 @@ disable_shader_texture_bindings() { // There are non-bindless textures to unbind, and we're lazy, so let's // go and unbind everything after this point using one multi-bind call, // and then break out of the loop. - _glgsg->_glBindTextures(i, _shader->_tex_spec.size() - i, NULL); + _glgsg->_glBindTextures(i, _shader->_tex_spec.size() - i, nullptr); break; } #endif @@ -2453,7 +2453,7 @@ disable_shader_texture_bindings() { if (num_image_units > 0) { #ifndef OPENGLES if (_glgsg->_supports_multi_bind) { - _glgsg->_glBindImageTextures(0, num_image_units, NULL); + _glgsg->_glBindImageTextures(0, num_image_units, nullptr); } else #endif { @@ -2466,9 +2466,9 @@ disable_shader_texture_bindings() { for (int i = 0; i < num_image_units; ++i) { ImageInput &input = _glsl_img_inputs[i]; - if (input._gtc != NULL) { + if (input._gtc != nullptr) { input._gtc->mark_incoherent(input._writable); - input._gtc = NULL; + input._gtc = nullptr; } } } @@ -2501,7 +2501,7 @@ update_shader_texture_bindings(ShaderContext *prev) { if (num_image_units > 0) { for (int i = 0; i < num_image_units; ++i) { ImageInput &input = _glsl_img_inputs[i]; - const ParamTextureImage *param = NULL; + const ParamTextureImage *param = nullptr; Texture *tex; const ShaderInput &sinp = _glgsg->_target_shader->get_shader_input(input._name); @@ -2531,11 +2531,11 @@ update_shader_texture_bindings(ShaderContext *prev) { GLuint gl_tex = 0; CLP(TextureContext) *gtc; - if (tex != NULL) { + if (tex != nullptr) { int view = _glgsg->get_current_tex_view_offset(); gtc = DCAST(CLP(TextureContext), tex->prepare_now(view, _glgsg->_prepared_objects, _glgsg)); - if (gtc != (TextureContext*)NULL) { + if (gtc != nullptr) { input._gtc = gtc; _glgsg->update_texture(gtc, true); @@ -2569,7 +2569,7 @@ update_shader_texture_bindings(ShaderContext *prev) { GLint bind_layer = 0; GLboolean layered = GL_TRUE; - if (param != NULL) { + if (param != nullptr) { layered = param->get_bind_layered(); bind_level = param->get_bind_level(); bind_layer = param->get_bind_layer(); @@ -2638,7 +2638,7 @@ update_shader_texture_bindings(ShaderContext *prev) { } if (tex->get_texture_type() != spec._desired_type) { - if (id != NULL) { + if (id != nullptr) { GLCAT.error() << "Sampler type of GLSL shader input '" << *id << "' does not " "match type of texture " << *tex << ".\n"; @@ -2652,7 +2652,7 @@ update_shader_texture_bindings(ShaderContext *prev) { } CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), tex->prepare_now(view, _glgsg->_prepared_objects, _glgsg)); - if (gtc == NULL) { + if (gtc == nullptr) { if (multi_bind) { textures[i] = 0; samplers[i] = 0; @@ -2715,7 +2715,7 @@ update_shader_texture_bindings(ShaderContext *prev) { } SamplerContext *sc = sampler.prepare_now(_glgsg->get_prepared_objects(), _glgsg); - if (sc == NULL) { + if (sc == nullptr) { samplers[i] = 0; } else { CLP(SamplerContext) *gsc = DCAST(CLP(SamplerContext), sc); @@ -2935,7 +2935,7 @@ glsl_compile_shader(Shader::ShaderType type) { string text_str = _shader->get_text(type); const char* text = text_str.c_str(); - _glgsg->_glShaderSource(handle, 1, &text, NULL); + _glgsg->_glShaderSource(handle, 1, &text, nullptr); _glgsg->_glCompileShader(handle); GLint status; _glgsg->_glGetShaderiv(handle, GL_COMPILE_STATUS, &status); diff --git a/panda/src/glxdisplay/glxGraphicsBuffer.cxx b/panda/src/glxdisplay/glxGraphicsBuffer.cxx index fb70d352dc..835adeed97 100644 --- a/panda/src/glxdisplay/glxGraphicsBuffer.cxx +++ b/panda/src/glxdisplay/glxGraphicsBuffer.cxx @@ -64,7 +64,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL || + if (_gsg == nullptr || _pbuffer == None) { return false; } @@ -105,7 +105,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void glxGraphicsBuffer:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { copy_to_textures(); @@ -124,8 +124,8 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void glxGraphicsBuffer:: close_buffer() { - if (_gsg != (GraphicsStateGuardian *)NULL) { - glXMakeCurrent(_display, None, NULL); + if (_gsg != nullptr) { + glXMakeCurrent(_display, None, nullptr); if (_pbuffer != None) { glxGraphicsStateGuardian *glxgsg; @@ -152,9 +152,9 @@ open_buffer() { // GSG CreationInitialization glxGraphicsStateGuardian *glxgsg; - if (_gsg == 0) { + if (_gsg == nullptr) { // There is no old gsg. Create a new one. - glxgsg = new glxGraphicsStateGuardian(_engine, _pipe, NULL); + glxgsg = new glxGraphicsStateGuardian(_engine, _pipe, nullptr); glxgsg->choose_pixel_format(_fb_properties, glx_pipe->get_display(), glx_pipe->get_screen(), true, false); _gsg = glxgsg; } else { diff --git a/panda/src/glxdisplay/glxGraphicsPipe.cxx b/panda/src/glxdisplay/glxGraphicsPipe.cxx index cd2f082c91..06266e6e96 100644 --- a/panda/src/glxdisplay/glxGraphicsPipe.cxx +++ b/panda/src/glxdisplay/glxGraphicsPipe.cxx @@ -78,14 +78,14 @@ make_output(const string &name, bool &precertify) { if (!_is_valid) { - return NULL; + return nullptr; } // This may not be a GLX GSG; it might be a callback GSG. - PosixGraphicsStateGuardian *posixgsg = NULL; - glxGraphicsStateGuardian *glxgsg = NULL; - if (gsg != NULL) { - DCAST_INTO_R(posixgsg, gsg, NULL); + PosixGraphicsStateGuardian *posixgsg = nullptr; + glxGraphicsStateGuardian *glxgsg = nullptr; + if (gsg != nullptr) { + DCAST_INTO_R(posixgsg, gsg, nullptr); glxgsg = DCAST(glxGraphicsStateGuardian, posixgsg); } @@ -103,9 +103,9 @@ make_output(const string &name, // First thing to try: a glxGraphicsWindow if (retry == 0) { - if (gsg != NULL && glxgsg == NULL) { + if (gsg != nullptr && glxgsg == nullptr) { // We can't use a non-GLX GSG. - return NULL; + return nullptr; } if (((flags&BF_require_parasite)!=0)|| ((flags&BF_refuse_window)!=0)|| @@ -115,7 +115,7 @@ make_output(const string &name, ((flags&BF_can_bind_color)!=0)|| ((flags&BF_can_bind_every)!=0)|| ((flags&BF_can_bind_layered)!=0)) { - return NULL; + return nullptr; } return new glxGraphicsWindow(engine, this, name, fb_prop, win_prop, flags, gsg, host); @@ -124,9 +124,9 @@ make_output(const string &name, // Second thing to try: a GLGraphicsBuffer if (retry == 1) { - if (!gl_support_fbo || host == NULL || + if (!gl_support_fbo || host == nullptr || (flags & (BF_require_parasite | BF_require_window)) != 0) { - return NULL; + return nullptr; } // Early failure - if we are sure that this buffer WONT meet specs, we can // bail out early. @@ -134,13 +134,13 @@ make_output(const string &name, if (fb_prop.get_indexed_color() || fb_prop.get_back_buffers() > 0 || fb_prop.get_accum_bits() > 0) { - return NULL; + return nullptr; } } - if (posixgsg != NULL && posixgsg->is_valid() && !posixgsg->needs_reset()) { + if (posixgsg != nullptr && posixgsg->is_valid() && !posixgsg->needs_reset()) { if (!posixgsg->_supports_framebuffer_object || - posixgsg->_glDrawBuffers == NULL) { - return NULL; + posixgsg->_glDrawBuffers == nullptr) { + return nullptr; } else { // Early success - if we are sure that this buffer WILL meet specs, we // can precertify it. @@ -152,10 +152,10 @@ make_output(const string &name, } // Third thing to try: a glxGraphicsBuffer - if (glxgsg == NULL || glxgsg->_supports_fbconfig) { + if (glxgsg == nullptr || glxgsg->_supports_fbconfig) { if (retry == 2) { if (!glx_support_pbuffer) { - return NULL; + return nullptr; } if (((flags&BF_require_parasite)!=0)|| @@ -163,7 +163,7 @@ make_output(const string &name, ((flags&BF_resizeable)!=0)|| ((flags&BF_size_track_host)!=0)|| ((flags&BF_can_bind_layered)!=0)) { - return NULL; + return nullptr; } if (!support_rtt) { @@ -171,7 +171,7 @@ make_output(const string &name, ((flags&BF_can_bind_every)!=0)) { // If we require Render-to-Texture, but can't be sure we support it, // bail. - return NULL; + return nullptr; } } @@ -183,7 +183,7 @@ make_output(const string &name, // Third thing to try: a glxGraphicsPixmap. if (retry == 3) { if (!glx_support_pixmap) { - return NULL; + return nullptr; } if (((flags&BF_require_parasite)!=0)|| @@ -191,12 +191,12 @@ make_output(const string &name, ((flags&BF_resizeable)!=0)|| ((flags&BF_size_track_host)!=0)|| ((flags&BF_can_bind_layered)!=0)) { - return NULL; + return nullptr; } if (((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_every)!=0)) { - return NULL; + return nullptr; } return new glxGraphicsPixmap(engine, this, name, fb_prop, win_prop, @@ -204,7 +204,7 @@ make_output(const string &name, } // Nothing else left to try. - return NULL; + return nullptr; } /** diff --git a/panda/src/glxdisplay/glxGraphicsPixmap.cxx b/panda/src/glxdisplay/glxGraphicsPixmap.cxx index 8c8c5a330d..8c9c317b2c 100644 --- a/panda/src/glxdisplay/glxGraphicsPixmap.cxx +++ b/panda/src/glxdisplay/glxGraphicsPixmap.cxx @@ -67,7 +67,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL || + if (_gsg == nullptr || _glx_pixmap == None) { return false; } @@ -108,7 +108,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void glxGraphicsPixmap:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { copy_to_textures(); @@ -127,8 +127,8 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void glxGraphicsPixmap:: close_buffer() { - if (_gsg != (GraphicsStateGuardian *)NULL) { - glXMakeCurrent(_display, None, NULL); + if (_gsg != nullptr) { + glXMakeCurrent(_display, None, nullptr); _gsg.clear(); } @@ -156,9 +156,9 @@ open_buffer() { // GSG CreationInitialization glxGraphicsStateGuardian *glxgsg; - if (_gsg == 0) { + if (_gsg == nullptr) { // There is no old gsg. Create a new one. - glxgsg = new glxGraphicsStateGuardian(_engine, _pipe, NULL); + glxgsg = new glxGraphicsStateGuardian(_engine, _pipe, nullptr); glxgsg->choose_pixel_format(_fb_properties, _display, glx_pipe->get_screen(), false, true); _gsg = glxgsg; } else { @@ -179,7 +179,7 @@ open_buffer() { } XVisualInfo *visual_info = glxgsg->_visual; - if (visual_info == NULL) { + if (visual_info == nullptr) { // No X visual for this fbconfig; how can we create the pixmap? glxdisplay_cat.error() << "No X visual: cannot create pixmap.\n"; @@ -187,7 +187,7 @@ open_buffer() { } _drawable = glx_pipe->get_root(); - if (_host != NULL) { + if (_host != nullptr) { if (_host->is_of_type(glxGraphicsWindow::get_class_type())) { glxGraphicsWindow *win = DCAST(glxGraphicsWindow, _host); _drawable = win->get_xwindow(); @@ -208,7 +208,7 @@ open_buffer() { if (glxgsg->_fbconfig) { // Use the FBConfig to create the pixmap. - _glx_pixmap = glxgsg->_glXCreatePixmap(_display, glxgsg->_fbconfig, _x_pixmap, NULL); + _glx_pixmap = glxgsg->_glXCreatePixmap(_display, glxgsg->_fbconfig, _x_pixmap, nullptr); } else { // Use the XVisual to create the pixmap. _glx_pixmap = glXCreateGLXPixmap(_display, visual_info, _x_pixmap); diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx index e79f80be3e..2b877b2168 100644 --- a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx @@ -29,13 +29,13 @@ glxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, glxGraphicsStateGuardian *share_with) : PosixGraphicsStateGuardian(engine, pipe) { - _share_context=0; - _context=0; - _display=0; + _share_context=nullptr; + _context=nullptr; + _display=nullptr; _screen=0; - _visual=0; - _visuals=0; - _fbconfig=0; + _visual=nullptr; + _visuals=nullptr; + _fbconfig=nullptr; _context_has_pbuffer = false; _context_has_pixmap = false; _slow = false; @@ -45,16 +45,16 @@ glxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, _supports_pbuffer = false; _uses_sgix_pbuffer = false; - if (share_with != (glxGraphicsStateGuardian *)NULL) { + if (share_with != nullptr) { _prepared_objects = share_with->get_prepared_objects(); _share_context = share_with->_context; } _checked_get_proc_address = false; - _glXGetProcAddress = NULL; - _temp_context = (GLXContext)NULL; - _temp_xwindow = (X11_Window)NULL; - _temp_colormap = (Colormap)NULL; + _glXGetProcAddress = nullptr; + _temp_context = (GLXContext)nullptr; + _temp_xwindow = (X11_Window)nullptr; + _temp_colormap = (Colormap)nullptr; } /** @@ -63,12 +63,12 @@ glxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, glxGraphicsStateGuardian:: ~glxGraphicsStateGuardian() { destroy_temp_xwindow(); - if (_visuals != (XVisualInfo *)NULL) { + if (_visuals != nullptr) { XFree(_visuals); } - if (_context != (GLXContext)NULL) { + if (_context != (GLXContext)nullptr) { glXDestroyContext(_display, _context); - _context = (GLXContext)NULL; + _context = (GLXContext)nullptr; } } @@ -224,12 +224,12 @@ choose_pixel_format(const FrameBufferProperties &properties, _display = display; _screen = screen; - _context = 0; - _fbconfig = 0; - _visual = 0; - if (_visuals != (XVisualInfo *)NULL) { + _context = nullptr; + _fbconfig = nullptr; + _visual = nullptr; + if (_visuals != nullptr) { XFree(_visuals); - _visuals = NULL; + _visuals = nullptr; } _fbprops.clear(); @@ -239,7 +239,7 @@ choose_pixel_format(const FrameBufferProperties &properties, // OpenGL context to get the required extension function pointers. destroy_temp_xwindow(); choose_temp_visual(properties); - if (_temp_context == NULL) { + if (_temp_context == nullptr) { // No good. return; } @@ -257,7 +257,7 @@ choose_pixel_format(const FrameBufferProperties &properties, << _fbprops << "\n"; _context = _temp_context; - _temp_context = (GLXContext)NULL; + _temp_context = (GLXContext)nullptr; // By convention, every indirect XVisual that can render to a window can // also render to a GLXPixmap. Direct visuals we're not as sure about. @@ -297,7 +297,7 @@ choose_pixel_format(const FrameBufferProperties &properties, GLXFBConfig *configs = _glXChooseFBConfig(_display, _screen, attrib_list, &num_configs); - if (configs != 0) { + if (configs != nullptr) { bool context_has_pbuffer, context_has_pixmap, slow; int quality, i; for (i = 0; i < num_configs; ++i) { @@ -332,7 +332,7 @@ choose_pixel_format(const FrameBufferProperties &properties, if (best_quality > 0) { _fbconfig = configs[best_result]; - if (_glXCreateContextAttribs != NULL) { + if (_glXCreateContextAttribs != nullptr) { // NB. This is a wholly different type of attrib list than below, the // same values are not used! n = 0; @@ -362,9 +362,9 @@ choose_pixel_format(const FrameBufferProperties &properties, if (_context) { mark_new(); - if (_visuals != (XVisualInfo *)NULL) { + if (_visuals != nullptr) { XFree(_visuals); - _visuals = NULL; + _visuals = nullptr; } _visuals = _glXGetVisualFromFBConfig(_display, _fbconfig); _visual = _visuals; @@ -391,10 +391,10 @@ choose_pixel_format(const FrameBufferProperties &properties, // This really shouldn't happen, so I'm not too careful about cleanup. glxdisplay_cat.error() << "Could not create FBConfig context!\n"; - _fbconfig = 0; - _context = 0; - _visual = 0; - _visuals = 0; + _fbconfig = nullptr; + _context = nullptr; + _visual = nullptr; + _visuals = nullptr; } glxdisplay_cat.warning() @@ -402,7 +402,7 @@ choose_pixel_format(const FrameBufferProperties &properties, << _fbprops << "\n"; _context = _temp_context; - _temp_context = (GLXContext)NULL; + _temp_context = (GLXContext)nullptr; // By convention, every indirect XVisual that can render to a window can // also render to a GLXPixmap. Direct visuals we're not as sure about. @@ -492,7 +492,7 @@ get_extra_extensions() { */ void *glxGraphicsStateGuardian:: do_get_extension_func(const char *name) { - nassertr(name != NULL, NULL); + nassertr(name != nullptr, nullptr); if (glx_get_proc_address) { // First, check if we have glXGetProcAddress available. This will be @@ -514,7 +514,7 @@ do_get_extension_func(const char *name) { // Otherwise, we have to fiddle around with the dynamic runtime. if (!_checked_get_proc_address) { - const char *funcName = NULL; + const char *funcName = nullptr; if (glx_is_at_least_version(1, 4)) { funcName = "glXGetProcAddress"; @@ -523,9 +523,9 @@ do_get_extension_func(const char *name) { funcName = "glXGetProcAddressARB"; } - if (funcName != NULL) { + if (funcName != nullptr) { _glXGetProcAddress = (PFNGLXGETPROCADDRESSPROC)get_system_func(funcName); - if (_glXGetProcAddress == NULL) { + if (_glXGetProcAddress == nullptr) { glxdisplay_cat.warning() << "Couldn't load function " << funcName << ", GL extensions may be unavailable.\n"; @@ -536,7 +536,7 @@ do_get_extension_func(const char *name) { } // Use glxGetProcAddress() if we've got it; it should be more robust. - if (_glXGetProcAddress != NULL) { + if (_glXGetProcAddress != nullptr) { return (void *)_glXGetProcAddress((const GLubyte *)name); } #endif // HAVE_GLXGETPROCADDRESS @@ -556,7 +556,7 @@ query_glx_extensions() { if (_supports_swap_control) { _glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)get_extension_func("glXSwapIntervalSGI"); - if (_glXSwapIntervalSGI == NULL) { + if (_glXSwapIntervalSGI == nullptr) { glxdisplay_cat.error() << "Driver claims to support GLX_SGI_swap_control extension, but does not define all functions.\n"; _supports_swap_control = false; @@ -585,11 +585,11 @@ query_glx_extensions() { _glXCreatePixmap = (PFNGLXCREATEPIXMAPPROC)get_extension_func("glXCreatePixmap"); - if (_glXChooseFBConfig == NULL || - _glXCreateNewContext == NULL || - _glXGetVisualFromFBConfig == NULL || - _glXGetFBConfigAttrib == NULL || - _glXCreatePixmap == NULL) { + if (_glXChooseFBConfig == nullptr || + _glXCreateNewContext == nullptr || + _glXGetVisualFromFBConfig == nullptr || + _glXGetFBConfigAttrib == nullptr || + _glXCreatePixmap == nullptr) { glxdisplay_cat.error() << "Driver claims to support GLX_fbconfig extension, but does not define all functions.\n"; _supports_fbconfig = false; @@ -611,11 +611,11 @@ query_glx_extensions() { _glXCreatePixmap = (PFNGLXCREATEPIXMAPPROC)get_extension_func("glXCreateGLXPixmapWithConfigSGIX"); - if (_glXChooseFBConfig == NULL || - _glXCreateNewContext == NULL || - _glXGetVisualFromFBConfig == NULL || - _glXGetFBConfigAttrib == NULL || - _glXCreatePixmap == NULL) { + if (_glXChooseFBConfig == nullptr || + _glXCreateNewContext == nullptr || + _glXGetVisualFromFBConfig == nullptr || + _glXGetFBConfigAttrib == nullptr || + _glXCreatePixmap == nullptr) { glxdisplay_cat.error() << "Driver claims to support GLX_SGIX_fbconfig extension, but does not define all functions.\n"; _supports_fbconfig = false; @@ -629,11 +629,11 @@ query_glx_extensions() { _glXCreatePbuffer = (PFNGLXCREATEPBUFFERPROC)get_extension_func("glXCreatePbuffer"); - _glXCreateGLXPbufferSGIX = NULL; + _glXCreateGLXPbufferSGIX = nullptr; _glXDestroyPbuffer = (PFNGLXDESTROYPBUFFERPROC)get_extension_func("glXDestroyPbuffer"); - if (_glXCreatePbuffer == NULL || - _glXDestroyPbuffer == NULL) { + if (_glXCreatePbuffer == nullptr || + _glXDestroyPbuffer == nullptr) { glxdisplay_cat.error() << "Driver claims to support GLX_pbuffer extension, but does not define all functions.\n"; _supports_pbuffer = false; @@ -646,13 +646,13 @@ query_glx_extensions() { // CreatePbuffer has a different form between SGIX and 1.3, however, so // we must treat it specially. But we can use the same function pointer // for DestroyPbuffer. - _glXCreatePbuffer = NULL; + _glXCreatePbuffer = nullptr; _glXCreateGLXPbufferSGIX = (PFNGLXCREATEGLXPBUFFERSGIXPROC)get_extension_func("glXCreateGLXPbufferSGIX"); _glXDestroyPbuffer = (PFNGLXDESTROYPBUFFERPROC)get_extension_func("glXDestroyGLXPbufferSGIX"); - if (_glXCreateGLXPbufferSGIX == NULL || - _glXDestroyPbuffer == NULL) { + if (_glXCreateGLXPbufferSGIX == nullptr || + _glXDestroyPbuffer == nullptr) { glxdisplay_cat.error() << "Driver claims to support GLX_SGIX_pbuffer extension, but does not define all functions.\n"; _supports_pbuffer = false; @@ -663,7 +663,7 @@ query_glx_extensions() { _glXCreateContextAttribs = (PFNGLXCREATECONTEXTATTRIBSARBPROC)get_extension_func("glXCreateContextAttribsARB"); } else { - _glXCreateContextAttribs = NULL; + _glXCreateContextAttribs = nullptr; } } @@ -697,7 +697,7 @@ void glxGraphicsStateGuardian:: show_glx_client_string(const string &name, int id) { if (glgsg_cat.is_debug()) { const char *text = glXGetClientString(_display, id); - if (text == (const char *)NULL) { + if (text == nullptr) { glgsg_cat.debug() << "Unable to query " << name << " (client)\n"; } else { @@ -714,7 +714,7 @@ void glxGraphicsStateGuardian:: show_glx_server_string(const string &name, int id) { if (glgsg_cat.is_debug()) { const char *text = glXQueryServerString(_display, _screen, id); - if (text == (const char *)NULL) { + if (text == nullptr) { glgsg_cat.debug() << "Unable to query " << name << " (server)\n"; } else { @@ -732,20 +732,20 @@ show_glx_server_string(const string &name, int id) { */ void glxGraphicsStateGuardian:: choose_temp_visual(const FrameBufferProperties &properties) { - nassertv(_temp_context == (GLXContext)NULL); + nassertv(_temp_context == (GLXContext)nullptr); int best_quality = 0; int best_result = 0; FrameBufferProperties best_props; // Scan available visuals. - if (_visuals != (XVisualInfo *)NULL) { + if (_visuals != nullptr) { XFree(_visuals); - _visuals = NULL; + _visuals = nullptr; } int nvisuals = 0; - _visuals = XGetVisualInfo(_display, 0, 0, &nvisuals); - if (_visuals != 0) { + _visuals = XGetVisualInfo(_display, 0, nullptr, &nvisuals); + if (_visuals != nullptr) { for (int i = 0; i < nvisuals; i++) { FrameBufferProperties fbprops; get_properties(fbprops, _visuals + i); @@ -794,7 +794,7 @@ init_temp_context() { (_display, root_window, 0, 0, 100, 100, 0, _visual->depth, InputOutput, visual, attrib_mask, &wa); - if (_temp_xwindow == (X11_Window)NULL) { + if (_temp_xwindow == (X11_Window)nullptr) { glxdisplay_cat.error() << "Could not create temporary window for context\n"; return; @@ -812,19 +812,19 @@ init_temp_context() { */ void glxGraphicsStateGuardian:: destroy_temp_xwindow() { - glXMakeCurrent(_display, None, NULL); + glXMakeCurrent(_display, None, nullptr); - if (_temp_colormap != (Colormap)NULL) { + if (_temp_colormap != (Colormap)nullptr) { XFreeColormap(_display, _temp_colormap); - _temp_colormap = (Colormap)NULL; + _temp_colormap = (Colormap)nullptr; } - if (_temp_xwindow != (X11_Window)NULL) { + if (_temp_xwindow != (X11_Window)nullptr) { XDestroyWindow(_display, _temp_xwindow); - _temp_xwindow = (X11_Window)NULL; + _temp_xwindow = (X11_Window)nullptr; } - if (_temp_context != (GLXContext)NULL) { + if (_temp_context != (GLXContext)nullptr) { glXDestroyContext(_display, _temp_context); - _temp_context = (GLXContext)NULL; + _temp_context = (GLXContext)nullptr; } } diff --git a/panda/src/glxdisplay/glxGraphicsWindow.cxx b/panda/src/glxdisplay/glxGraphicsWindow.cxx index 7dd43c8675..28f4652266 100644 --- a/panda/src/glxdisplay/glxGraphicsWindow.cxx +++ b/panda/src/glxdisplay/glxGraphicsWindow.cxx @@ -57,7 +57,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } if (_awaiting_configure) { @@ -106,7 +106,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { */ void glxGraphicsWindow:: end_flip() { - if (_gsg != (GraphicsStateGuardian *)NULL && _flip_ready) { + if (_gsg != nullptr && _flip_ready) { // It doesn't appear to be necessary to ensure the graphics context is // current before flipping the windows, and insisting on doing so can be a @@ -125,8 +125,8 @@ end_flip() { */ void glxGraphicsWindow:: close_window() { - if (_gsg != (GraphicsStateGuardian *)NULL) { - glXMakeCurrent(_display, None, NULL); + if (_gsg != nullptr) { + glXMakeCurrent(_display, None, nullptr); _gsg.clear(); } @@ -144,9 +144,9 @@ open_window() { // GSG CreationInitialization glxGraphicsStateGuardian *glxgsg; - if (_gsg == 0) { + if (_gsg == nullptr) { // There is no old gsg. Create a new one. - glxgsg = new glxGraphicsStateGuardian(_engine, _pipe, NULL); + glxgsg = new glxGraphicsStateGuardian(_engine, _pipe, nullptr); glxgsg->choose_pixel_format(_fb_properties, glx_pipe->get_display(), glx_pipe->get_screen(), false, false); _gsg = glxgsg; } else { @@ -160,7 +160,7 @@ open_window() { } } - if (glxgsg->_context == NULL) { + if (glxgsg->_context == nullptr) { // We're supposed to have a context at this point. glxdisplay_cat.error() << "No GLX context: cannot open window.\n"; @@ -168,7 +168,7 @@ open_window() { } _visual_info = glxgsg->_visual; - if (_visual_info == NULL) { + if (_visual_info == nullptr) { // No X visual for this fbconfig; how can we open the window? glxdisplay_cat.error() << "No X visual: cannot open window.\n"; @@ -212,7 +212,7 @@ setup_colormap(GLXFBConfig fbconfig) { nassertv(glxgsg->_supports_fbconfig); XVisualInfo *visual_info = glxgsg->_glXGetVisualFromFBConfig(_display, fbconfig); - if (visual_info == NULL) { + if (visual_info == nullptr) { // No X visual; no need to set up a colormap. return; } diff --git a/panda/src/glxdisplay/posixGraphicsStateGuardian.cxx b/panda/src/glxdisplay/posixGraphicsStateGuardian.cxx index 8bf738b3c2..ac5f10f8a1 100644 --- a/panda/src/glxdisplay/posixGraphicsStateGuardian.cxx +++ b/panda/src/glxdisplay/posixGraphicsStateGuardian.cxx @@ -24,7 +24,7 @@ PosixGraphicsStateGuardian:: PosixGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe) : GLGraphicsStateGuardian(engine, pipe) { - _libgl_handle = NULL; + _libgl_handle = nullptr; } /** @@ -32,7 +32,7 @@ PosixGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe) : */ PosixGraphicsStateGuardian:: ~PosixGraphicsStateGuardian() { - if (_libgl_handle != (void *)NULL) { + if (_libgl_handle != nullptr) { dlclose(_libgl_handle); } } @@ -45,13 +45,13 @@ PosixGraphicsStateGuardian:: */ void *PosixGraphicsStateGuardian:: do_get_extension_func(const char *name) { - nassertr(name != NULL, NULL); + nassertr(name != nullptr, nullptr); if (glx_get_os_address) { return get_system_func(name); } - return NULL; + return nullptr; } /** @@ -61,23 +61,23 @@ do_get_extension_func(const char *name) { */ void *PosixGraphicsStateGuardian:: get_system_func(const char *name) { - if (_libgl_handle == (void *)NULL) { + if (_libgl_handle == nullptr) { // We open the current executable, rather than naming a particular // library. Presumably libGL.so (or whatever the library should be // called) is already available in the current executable address space, // so this is more portable than insisting on a particular shared library // name. - _libgl_handle = dlopen(NULL, RTLD_LAZY); - nassertr(_libgl_handle != (void *)NULL, NULL); + _libgl_handle = dlopen(nullptr, RTLD_LAZY); + nassertr(_libgl_handle != nullptr, nullptr); // If that doesn't locate the symbol we expected, then fall back to // loading the GL library by its usual name. - if (dlsym(_libgl_handle, name) == NULL) { + if (dlsym(_libgl_handle, name) == nullptr) { dlclose(_libgl_handle); glxdisplay_cat.warning() << name << " not found in executable; looking in libGL.so instead.\n"; _libgl_handle = dlopen("libGL.so", RTLD_LAZY); - nassertr(_libgl_handle != (void *)NULL, NULL); + nassertr(_libgl_handle != nullptr, nullptr); } } diff --git a/panda/src/gobj/adaptiveLru.I b/panda/src/gobj/adaptiveLru.I index 77c3fcd5de..41acf47c38 100644 --- a/panda/src/gobj/adaptiveLru.I +++ b/panda/src/gobj/adaptiveLru.I @@ -134,7 +134,7 @@ get_lru() const { */ INLINE void AdaptiveLruPage:: dequeue_lru() { - enqueue_lru(NULL); + enqueue_lru(nullptr); } /** @@ -146,7 +146,7 @@ dequeue_lru() { */ INLINE void AdaptiveLruPage:: mark_used_lru() const { - if (_lru != (AdaptiveLru *)NULL) { + if (_lru != nullptr) { ((AdaptiveLruPage *)this)->mark_used_lru(_lru); } } @@ -174,7 +174,7 @@ get_lru_size() const { */ INLINE void AdaptiveLruPage:: set_lru_size(size_t lru_size) { - if (_lru != (AdaptiveLru *)NULL) { + if (_lru != nullptr) { LightMutexHolder holder(_lru->_lock); _lru->_total_size -= _lru_size; _lru->_total_size += lru_size; diff --git a/panda/src/gobj/adaptiveLru.cxx b/panda/src/gobj/adaptiveLru.cxx index ecb4d033c9..85bb3ab36c 100644 --- a/panda/src/gobj/adaptiveLru.cxx +++ b/panda/src/gobj/adaptiveLru.cxx @@ -55,10 +55,10 @@ AdaptiveLru:: // to disk unnecessarily). while (_static_list._next != &_static_list) { - nassertv(_static_list._next != (LinkedListNode *)NULL); + nassertv(_static_list._next != nullptr); AdaptiveLruPage *page = (AdaptiveLruPage *)(AdaptiveLruPageStaticList *)_static_list._next; - page->_lru = NULL; + page->_lru = nullptr; ((AdaptiveLruPageDynamicList *)page)->remove_from_list(); ((AdaptiveLruPageStaticList *)page)->remove_from_list(); } @@ -170,19 +170,19 @@ update_page(AdaptiveLruPage *page) { */ void AdaptiveLruPage:: enqueue_lru(AdaptiveLru *lru) { - if (lru != _lru && _lru != (AdaptiveLru *)NULL) { + if (lru != _lru && _lru != nullptr) { // It was previously on a different LRU. Remove it first. _lru->do_remove_page(this); - _lru = NULL; + _lru = nullptr; } if (lru == _lru) { - if (_lru != (AdaptiveLru *)NULL) { + if (_lru != nullptr) { // It's already on this LRU. Access it. _lru->do_access_page(this); } } else { - nassertv(lru != (AdaptiveLru *)NULL); + nassertv(lru != nullptr); // Add it to a new LRU. _lru = lru; @@ -281,7 +281,7 @@ write(ostream &out, int indent_level) const { */ void AdaptiveLru:: do_add_page(AdaptiveLruPage *page) { - nassertv(page != (AdaptiveLruPage *)NULL && page->_lru == this); + nassertv(page != nullptr && page->_lru == this); LightMutexHolder holder(_lock); _total_size += page->_lru_size; @@ -294,7 +294,7 @@ do_add_page(AdaptiveLruPage *page) { */ void AdaptiveLru:: do_remove_page(AdaptiveLruPage *page) { - nassertv(page != (AdaptiveLruPage *)NULL && page->_lru == this); + nassertv(page != nullptr && page->_lru == this); LightMutexHolder holder(_lock); _total_size -= page->_lru_size; @@ -307,7 +307,7 @@ do_remove_page(AdaptiveLruPage *page) { */ void AdaptiveLru:: do_access_page(AdaptiveLruPage *page) { - nassertv(page != (AdaptiveLruPage *)NULL && page->_lru == this); + nassertv(page != nullptr && page->_lru == this); LightMutexHolder holder(_lock); if (page->_current_frame_identifier == _current_frame_identifier) { @@ -447,7 +447,7 @@ do_validate() { */ AdaptiveLruPage:: AdaptiveLruPage(size_t lru_size) : - _lru(NULL), + _lru(nullptr), _lru_size(lru_size), _priority(0), _first_frame_identifier(0), @@ -465,7 +465,7 @@ AdaptiveLruPage(size_t lru_size) : */ AdaptiveLruPage:: AdaptiveLruPage(const AdaptiveLruPage ©) : - _lru(NULL), + _lru(nullptr), _lru_size(copy._lru_size), _priority(0), _first_frame_identifier(0), @@ -491,7 +491,7 @@ operator = (const AdaptiveLruPage ©) { */ AdaptiveLruPage:: ~AdaptiveLruPage() { - if (_lru != NULL) { + if (_lru != nullptr) { dequeue_lru(); } } @@ -533,7 +533,7 @@ write(ostream &out, int indent_level) const { */ unsigned int AdaptiveLruPage:: get_num_frames() const { - if (_lru == (AdaptiveLru *)NULL) { + if (_lru == nullptr) { return 0; } return _lru->_current_frame_identifier - _first_frame_identifier; @@ -545,7 +545,7 @@ get_num_frames() const { */ unsigned int AdaptiveLruPage:: get_num_inactive_frames() const { - if (_lru == (AdaptiveLru *)NULL) { + if (_lru == nullptr) { return 0; } return _lru->_current_frame_identifier - _current_frame_identifier; diff --git a/panda/src/gobj/bufferContext.I b/panda/src/gobj/bufferContext.I index 978e3b73da..3c34d93a8a 100644 --- a/panda/src/gobj/bufferContext.I +++ b/panda/src/gobj/bufferContext.I @@ -85,9 +85,9 @@ set_resident(bool flag) { */ INLINE BufferContext *BufferContext:: get_next() const { - nassertr(_owning_chain != (BufferContextChain *)NULL, NULL); + nassertr(_owning_chain != nullptr, nullptr); if ((BufferContextChain *)_next == _owning_chain) { - return NULL; + return nullptr; } return (BufferContext *)_next; } @@ -98,7 +98,7 @@ get_next() const { */ INLINE void BufferContext:: update_data_size_bytes(size_t new_data_size_bytes) { - if (_owning_chain != (BufferContextChain *)NULL) { + if (_owning_chain != nullptr) { _owning_chain->adjust_bytes((int)new_data_size_bytes - (int)_data_size_bytes); } _data_size_bytes = new_data_size_bytes; diff --git a/panda/src/gobj/bufferContext.cxx b/panda/src/gobj/bufferContext.cxx index b8d7ed4ba8..52cac06ce4 100644 --- a/panda/src/gobj/bufferContext.cxx +++ b/panda/src/gobj/bufferContext.cxx @@ -23,7 +23,7 @@ BufferContext(BufferResidencyTracker *residency) : _residency(residency), _residency_state(0), _data_size_bytes(0), - _owning_chain(NULL) + _owning_chain(nullptr) { set_owning_chain(&residency->_chains[0]); } @@ -33,7 +33,7 @@ BufferContext(BufferResidencyTracker *residency) : */ BufferContext:: ~BufferContext() { - set_owning_chain(NULL); + set_owning_chain(nullptr); } /** @@ -42,7 +42,7 @@ BufferContext:: void BufferContext:: set_owning_chain(BufferContextChain *chain) { if (chain != _owning_chain) { - if (_owning_chain != (BufferContextChain *)NULL){ + if (_owning_chain != nullptr){ --(_owning_chain->_count); _owning_chain->adjust_bytes(-(int)_data_size_bytes); remove_from_list(); @@ -50,7 +50,7 @@ set_owning_chain(BufferContextChain *chain) { _owning_chain = chain; - if (_owning_chain != (BufferContextChain *)NULL) { + if (_owning_chain != nullptr) { ++(_owning_chain->_count); _owning_chain->adjust_bytes((int)_data_size_bytes); insert_before(_owning_chain); diff --git a/panda/src/gobj/bufferContextChain.cxx b/panda/src/gobj/bufferContextChain.cxx index a5f9d782b5..9a94ff2919 100644 --- a/panda/src/gobj/bufferContextChain.cxx +++ b/panda/src/gobj/bufferContextChain.cxx @@ -25,7 +25,7 @@ get_first() { // This method is declared non-inline so we can include bufferContext.h, // which is necessary for proper downcasting of the _next pointer. if (_next == this) { - return NULL; + return nullptr; } return (BufferContext *)_next; } diff --git a/panda/src/gobj/bufferResidencyTracker.cxx b/panda/src/gobj/bufferResidencyTracker.cxx index 00f0a4e5be..abb51610e6 100644 --- a/panda/src/gobj/bufferResidencyTracker.cxx +++ b/panda/src/gobj/bufferResidencyTracker.cxx @@ -118,7 +118,7 @@ write(ostream &out, int indent_level) const { void BufferResidencyTracker:: move_inactive(BufferContextChain &inactive, BufferContextChain &active) { BufferContext *node = active.get_first(); - while (node != (BufferContext *)NULL) { + while (node != nullptr) { nassertv((node->_residency_state & S_active) != 0); node->_residency_state &= ~S_active; node = node->get_next(); diff --git a/panda/src/gobj/geom.I b/panda/src/gobj/geom.I index 0f504f4dac..81a545d6b6 100644 --- a/panda/src/gobj/geom.I +++ b/panda/src/gobj/geom.I @@ -98,7 +98,7 @@ INLINE PT(GeomPrimitive) Geom:: modify_primitive(size_t i) { Thread *current_thread = Thread::get_current_thread(); CDWriter cdata(_cycler, true, current_thread); - nassertr(i < cdata->_primitives.size(), NULL); + nassertr(i < cdata->_primitives.size(), nullptr); cdata->_modified = Geom::get_next_modified(); clear_cache_stage(current_thread); return cdata->_primitives[i].get_write_pointer(); @@ -285,8 +285,8 @@ get_bounds_type() const { INLINE void Geom:: set_bounds(const BoundingVolume *volume) { CDWriter cdata(_cycler, true); - if (volume == NULL) { - cdata->_user_bounds = NULL; + if (volume == nullptr) { + cdata->_user_bounds = nullptr; } else { cdata->_user_bounds = volume->make_copy(); } @@ -303,7 +303,7 @@ set_bounds(const BoundingVolume *volume) { INLINE void Geom:: clear_bounds() { CDWriter cdata(_cycler, true); - cdata->_user_bounds = NULL; + cdata->_user_bounds = nullptr; mark_internal_bounds_stale(cdata); } @@ -385,9 +385,9 @@ mark_internal_bounds_stale(CData *cdata) { */ INLINE Geom::CDataCache:: CDataCache() : - _source(NULL), - _geom_result(NULL), - _data_result(NULL) + _source(nullptr), + _geom_result(nullptr), + _data_result(nullptr) { } @@ -400,7 +400,7 @@ CDataCache(const Geom::CDataCache ©) : _geom_result(copy._geom_result), _data_result(copy._data_result) { - if (_geom_result != _source && _geom_result != (Geom *)NULL) { + if (_geom_result != _source && _geom_result != nullptr) { _geom_result->ref(); } } @@ -412,11 +412,11 @@ CDataCache(const Geom::CDataCache ©) : INLINE void Geom::CDataCache:: set_result(const Geom *geom_result, const GeomVertexData *data_result) { if (geom_result != _geom_result) { - if (_geom_result != _source && _geom_result != (Geom *)NULL) { + if (_geom_result != _source && _geom_result != nullptr) { unref_delete(_geom_result); } _geom_result = geom_result; - if (_geom_result != _source && _geom_result != (Geom *)NULL) { + if (_geom_result != _source && _geom_result != nullptr) { _geom_result->ref(); } } @@ -577,8 +577,8 @@ INLINE GeomPipelineReader:: #endif // DO_PIPELINING #ifdef _DEBUG - _object = NULL; - _cdata = NULL; + _object = nullptr; + _cdata = nullptr; #endif // _DEBUG } @@ -591,7 +591,7 @@ set_object(const Geom *object) { // _object->_cycler.release_read(_cdata); #ifdef DO_PIPELINING - if (_cdata != NULL) { + if (_cdata != nullptr) { unref_delete((CycleData *)_cdata); } #endif // DO_PIPELINING @@ -667,7 +667,7 @@ get_num_primitives() const { */ INLINE CPT(GeomPrimitive) GeomPipelineReader:: get_primitive(int i) const { - nassertr(i >= 0 && i < (int)_cdata->_primitives.size(), NULL); + nassertr(i >= 0 && i < (int)_cdata->_primitives.size(), nullptr); return _cdata->_primitives[i].get_read_pointer(); } diff --git a/panda/src/gobj/geom.cxx b/panda/src/gobj/geom.cxx index 26dd3c942c..0c627d6e5b 100644 --- a/panda/src/gobj/geom.cxx +++ b/panda/src/gobj/geom.cxx @@ -301,7 +301,7 @@ set_primitive(size_t i, const GeomPrimitive *primitive) { // They also should have a compatible shade model. CPT(GeomPrimitive) compat = primitive->match_shade_model(cdata->_shade_model); - nassertv_always(compat != (GeomPrimitive *)NULL); + nassertv_always(compat != nullptr); cdata->_primitives[i] = (GeomPrimitive *)compat.p(); PrimitiveType new_primitive_type = compat->get_primitive_type(); @@ -1030,7 +1030,7 @@ check_valid(const GeomVertexData *vertex_data) const { CPT(BoundingVolume) Geom:: get_bounds(Thread *current_thread) const { CDLockedReader cdata(_cycler, current_thread); - if (cdata->_user_bounds != (BoundingVolume *)NULL) { + if (cdata->_user_bounds != nullptr) { return cdata->_user_bounds; } @@ -1133,7 +1133,7 @@ clear_cache_stage(Thread *current_thread) { ++ci) { CacheEntry *entry = (*ci).second; CDCacheWriter cdata(entry->_cycler, current_thread); - cdata->set_result(NULL, NULL); + cdata->set_result(nullptr, nullptr); } } @@ -1231,7 +1231,7 @@ prepare_now(PreparedGraphicsObjects *prepared_objects, } GeomContext *gc = prepared_objects->prepare_geom_now(this, gsg); - if (gc != (GeomContext *)NULL) { + if (gc != nullptr) { _contexts[prepared_objects] = gc; } return gc; @@ -1597,7 +1597,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { */ TypedWritable *Geom:: make_from_bam(const FactoryParams ¶ms) { - Geom *object = new Geom(NULL); + Geom *object = new Geom(nullptr); DatagramIterator scan; BamReader *manager; @@ -1644,7 +1644,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { */ Geom::CDataCache:: ~CDataCache() { - set_result(NULL, NULL); + set_result(nullptr, nullptr); } /** @@ -1740,7 +1740,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _primitives.reserve(num_primitives); for (int i = 0; i < num_primitives; ++i) { manager->read_pointer(scan); - _primitives.push_back(NULL); + _primitives.push_back(nullptr); } _primitive_type = (PrimitiveType)scan.get_uint8(); diff --git a/panda/src/gobj/geomCacheEntry.I b/panda/src/gobj/geomCacheEntry.I index 9c7987d855..6d9f2dd2cc 100644 --- a/panda/src/gobj/geomCacheEntry.I +++ b/panda/src/gobj/geomCacheEntry.I @@ -17,8 +17,8 @@ INLINE GeomCacheEntry:: GeomCacheEntry() { #ifndef NDEBUG - _next = NULL; - _prev = NULL; + _next = nullptr; + _prev = nullptr; #endif } @@ -31,8 +31,8 @@ remove_from_list() { _prev->_next = _next; _next->_prev = _prev; #ifndef NDEBUG - _next = NULL; - _prev = NULL; + _next = nullptr; + _prev = nullptr; #endif } @@ -43,8 +43,8 @@ remove_from_list() { INLINE void GeomCacheEntry:: insert_before(GeomCacheEntry *node) { nassertv(node->_prev->_next == node && node->_next->_prev == node); - nassertv(_prev == (GeomCacheEntry *)NULL && - _next == (GeomCacheEntry *)NULL); + nassertv(_prev == nullptr && + _next == nullptr); _prev = node->_prev; _next = node; _prev->_next = this; diff --git a/panda/src/gobj/geomCacheEntry.cxx b/panda/src/gobj/geomCacheEntry.cxx index d16a7f6a08..608ebbdac4 100644 --- a/panda/src/gobj/geomCacheEntry.cxx +++ b/panda/src/gobj/geomCacheEntry.cxx @@ -31,7 +31,7 @@ GeomCacheEntry:: */ PT(GeomCacheEntry) GeomCacheEntry:: record(Thread *current_thread) { - nassertr(_next == (GeomCacheEntry *)NULL && _prev == (GeomCacheEntry *)NULL, NULL); + nassertr(_next == nullptr && _prev == nullptr, nullptr); PT(GeomCacheEntry) keepme = this; GeomCacheManager *cache_mgr = GeomCacheManager::get_global_ptr(); @@ -72,7 +72,7 @@ void GeomCacheEntry:: refresh(Thread *current_thread) { GeomCacheManager *cache_mgr = GeomCacheManager::get_global_ptr(); LightMutexHolder holder(cache_mgr->_lock); - nassertv(_next != (GeomCacheEntry *)NULL && _prev != (GeomCacheEntry *)NULL); + nassertv(_next != nullptr && _prev != nullptr); remove_from_list(); insert_before(cache_mgr->_list); @@ -93,7 +93,7 @@ refresh(Thread *current_thread) { */ PT(GeomCacheEntry) GeomCacheEntry:: erase() { - nassertr(_next != (GeomCacheEntry *)NULL && _prev != (GeomCacheEntry *)NULL, NULL); + nassertr(_next != nullptr && _prev != nullptr, nullptr); PT(GeomCacheEntry) keepme; keepme.cheat() = this; diff --git a/panda/src/gobj/geomCacheManager.cxx b/panda/src/gobj/geomCacheManager.cxx index b0d2624a2d..7fef373373 100644 --- a/panda/src/gobj/geomCacheManager.cxx +++ b/panda/src/gobj/geomCacheManager.cxx @@ -16,7 +16,7 @@ #include "lightMutexHolder.h" #include "clockObject.h" -GeomCacheManager *GeomCacheManager::_global_ptr = NULL; +GeomCacheManager *GeomCacheManager::_global_ptr = nullptr; PStatCollector GeomCacheManager::_geom_cache_size_pcollector("Geom cache size"); PStatCollector GeomCacheManager::_geom_cache_active_pcollector("Geom cache size:Active"); @@ -62,7 +62,7 @@ flush() { */ GeomCacheManager *GeomCacheManager:: get_global_ptr() { - if (_global_ptr == (GeomCacheManager *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new GeomCacheManager; } return _global_ptr; diff --git a/panda/src/gobj/geomLines.cxx b/panda/src/gobj/geomLines.cxx index 20c9aa198b..dee3c89ccf 100644 --- a/panda/src/gobj/geomLines.cxx +++ b/panda/src/gobj/geomLines.cxx @@ -182,7 +182,7 @@ rotate_impl() const { to.set_data1i(from.get_data1i()); } - nassertr(to.is_at_end(), NULL); + nassertr(to.is_at_end(), nullptr); } else { // Nonindexed case. @@ -194,7 +194,7 @@ rotate_impl() const { to.set_data1i(begin + first_vertex); } - nassertr(to.is_at_end(), NULL); + nassertr(to.is_at_end(), nullptr); } return new_vertices; diff --git a/panda/src/gobj/geomLinestrips.cxx b/panda/src/gobj/geomLinestrips.cxx index 8a3365a201..0b54de3410 100644 --- a/panda/src/gobj/geomLinestrips.cxx +++ b/panda/src/gobj/geomLinestrips.cxx @@ -231,7 +231,7 @@ decompose_impl() const { } ++li; } - nassertr(vi == get_num_vertices(), NULL); + nassertr(vi == get_num_vertices(), nullptr); return lines.p(); } @@ -262,7 +262,7 @@ rotate_impl() const { begin = end; } - nassertr(to.is_at_end(), NULL); + nassertr(to.is_at_end(), nullptr); } else { // Nonindexed case. @@ -279,7 +279,7 @@ rotate_impl() const { begin = end; } - nassertr(to.is_at_end(), NULL); + nassertr(to.is_at_end(), nullptr); } return new_vertices; } diff --git a/panda/src/gobj/geomMunger.I b/panda/src/gobj/geomMunger.I index 8cbd51aa91..f1c28bb451 100644 --- a/panda/src/gobj/geomMunger.I +++ b/panda/src/gobj/geomMunger.I @@ -177,7 +177,7 @@ unregister_myself() { */ INLINE GeomMunger::Registry *GeomMunger:: get_registry() { - if (_registry == (Registry *)NULL) { + if (_registry == nullptr) { make_registry(); } return _registry; diff --git a/panda/src/gobj/geomMunger.cxx b/panda/src/gobj/geomMunger.cxx index bbbc9e3522..83d57467c1 100644 --- a/panda/src/gobj/geomMunger.cxx +++ b/panda/src/gobj/geomMunger.cxx @@ -18,7 +18,7 @@ #include "lightReMutexHolder.h" #include "pStatTimer.h" -GeomMunger::Registry *GeomMunger::_registry = NULL; +GeomMunger::Registry *GeomMunger::_registry = nullptr; TypeHandle GeomMunger::_type_handle; PStatCollector GeomMunger::_munge_pcollector("*:Munge"); @@ -116,7 +116,7 @@ munge_geom(CPT(Geom) &geom, CPT(GeomVertexData) &data, // Now check that it's fresh. Geom::CDCacheReader cdata(entry->_cycler, current_thread); if (cdata->_source == geom && - cdata->_geom_result != (Geom *)NULL && + cdata->_geom_result != nullptr && geom->get_modified(current_thread) <= cdata->_geom_result->get_modified(current_thread) && data->get_modified(current_thread) <= cdata->_data_result->get_modified(current_thread)) { // The cache entry is still good; use it. @@ -145,7 +145,7 @@ munge_geom(CPT(Geom) &geom, CPT(GeomVertexData) &data, munge_geom_impl(geom, data, current_thread); // Record the new result in the cache. - if (entry == (Geom::CacheEntry *)NULL) { + if (entry == nullptr) { // Create a new entry for the result. // We don't need the key anymore, move the pointers into the CacheEntry. entry = new Geom::CacheEntry(orig_geom, move(key)); @@ -179,8 +179,8 @@ munge_geom(CPT(Geom) &geom, CPT(GeomVertexData) &data, CPT(GeomVertexFormat) GeomMunger:: do_munge_format(const GeomVertexFormat *format, const GeomVertexAnimationSpec &animation) { - nassertr(_is_registered, NULL); - nassertr(format->is_registered(), NULL); + nassertr(_is_registered, nullptr); + nassertr(format->is_registered(), nullptr); LightMutexHolder holder(_formats_lock); @@ -195,11 +195,11 @@ do_munge_format(const GeomVertexFormat *format, // We have to munge this format for the first time. CPT(GeomVertexFormat) derived_format = munge_format_impl(format, animation); - nassertr(derived_format->is_registered(), NULL); + nassertr(derived_format->is_registered(), nullptr); // Store the answer in the map, so we can quickly get it next time. bool inserted = formats.insert(Formats::value_type(format, derived_format)).second; - nassertr(inserted, NULL); + nassertr(inserted, nullptr); return derived_format; } @@ -218,7 +218,7 @@ munge_format_impl(const GeomVertexFormat *orig, const GeomVertexAnimationSpec &) */ CPT(GeomVertexData) GeomMunger:: munge_data_impl(const GeomVertexData *data) { - nassertr(_is_registered, NULL); + nassertr(_is_registered, nullptr); CPT(GeomVertexFormat) orig_format = data->get_format(); CPT(GeomVertexFormat) new_format = @@ -247,8 +247,8 @@ munge_geom_impl(CPT(Geom) &, CPT(GeomVertexData) &, Thread *) { */ CPT(GeomVertexFormat) GeomMunger:: do_premunge_format(const GeomVertexFormat *format) { - nassertr(_is_registered, NULL); - nassertr(format->is_registered(), NULL); + nassertr(_is_registered, nullptr); + nassertr(format->is_registered(), nullptr); LightMutexHolder holder(_formats_lock); @@ -261,11 +261,11 @@ do_premunge_format(const GeomVertexFormat *format) { // We have to munge this format for the first time. CPT(GeomVertexFormat) derived_format = premunge_format_impl(format); - nassertr(derived_format->is_registered(), NULL); + nassertr(derived_format->is_registered(), nullptr); // Store the answer in the map, so we can quickly get it next time. bool inserted = _premunge_formats.insert(Formats::value_type(format, derived_format)).second; - nassertr(inserted, NULL); + nassertr(inserted, nullptr); return derived_format; } @@ -284,7 +284,7 @@ premunge_format_impl(const GeomVertexFormat *orig) { */ CPT(GeomVertexData) GeomMunger:: premunge_data_impl(const GeomVertexData *data) { - nassertr(_is_registered, NULL); + nassertr(_is_registered, nullptr); CPT(GeomVertexFormat) orig_format = data->get_format(); CPT(GeomVertexFormat) new_format = premunge_format(orig_format); @@ -332,7 +332,7 @@ geom_compare_to_impl(const GeomMunger *other) const { */ void GeomMunger:: make_registry() { - if (_registry == (Registry *)NULL) { + if (_registry == nullptr) { _registry = new Registry; } } diff --git a/panda/src/gobj/geomPrimitive.I b/panda/src/gobj/geomPrimitive.I index 9863701e21..061a49c527 100644 --- a/panda/src/gobj/geomPrimitive.I +++ b/panda/src/gobj/geomPrimitive.I @@ -450,7 +450,7 @@ GeomPrimitivePipelineReader(CPT(GeomPrimitive) object, #ifndef CPPPARSER _cdata(_object->_cycler.read_unlocked(current_thread)), #endif - _vertices_cdata(NULL) + _vertices_cdata(nullptr) { nassertv(_object->test_ref_count_nonzero()); #ifdef DO_PIPELINING @@ -494,8 +494,8 @@ INLINE GeomPrimitivePipelineReader:: } #ifdef _DEBUG - _object = NULL; - _cdata = NULL; + _object = nullptr; + _cdata = nullptr; #endif // _DEBUG } @@ -635,8 +635,8 @@ get_ends() const { */ INLINE CPT(GeomVertexArrayData) GeomPrimitivePipelineReader:: get_mins() const { - nassertr(is_indexed(), NULL); - nassertr(_cdata->_got_minmax, NULL); + nassertr(is_indexed(), nullptr); + nassertr(_cdata->_got_minmax, nullptr); return _cdata->_mins.get_read_pointer(); } @@ -645,8 +645,8 @@ get_mins() const { */ INLINE CPT(GeomVertexArrayData) GeomPrimitivePipelineReader:: get_maxs() const { - nassertr(is_indexed(), NULL); - nassertr(_cdata->_got_minmax, NULL); + nassertr(is_indexed(), nullptr); + nassertr(_cdata->_got_minmax, nullptr); return _cdata->_maxs.get_read_pointer(); } diff --git a/panda/src/gobj/geomPrimitive.cxx b/panda/src/gobj/geomPrimitive.cxx index b85747a945..db939d3bef 100644 --- a/panda/src/gobj/geomPrimitive.cxx +++ b/panda/src/gobj/geomPrimitive.cxx @@ -789,7 +789,7 @@ rotate() const { PStatTimer timer(_rotate_pcollector); CPT(GeomVertexArrayData) rotated_vertices = rotate_impl(); - if (rotated_vertices == (GeomVertexArrayData *)NULL) { + if (rotated_vertices == nullptr) { // This primitive type can't be rotated. return this; } @@ -882,13 +882,13 @@ match_shade_model(GeomPrimitive::ShadeModel shade_model) const { CPT(GeomPrimitive) rotated = rotate(); if (rotated.p() == this) { // Oops, can't be rotated, sorry. - return NULL; + return nullptr; } return rotated; } // Not compatible, sorry. - return NULL; + return nullptr; } /** @@ -1195,7 +1195,7 @@ void GeomPrimitive:: set_nonindexed_vertices(int first_vertex, int num_vertices) { nassertv(num_vertices != -1); CDWriter cdata(_cycler, true); - cdata->_vertices = (GeomVertexArrayData *)NULL; + cdata->_vertices = nullptr; cdata->_first_vertex = first_vertex; cdata->_num_vertices = num_vertices; @@ -1391,7 +1391,7 @@ is_prepared(PreparedGraphicsObjects *prepared_objects) const { IndexBufferContext *GeomPrimitive:: prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) { - nassertr(is_indexed(), NULL); + nassertr(is_indexed(), nullptr); Contexts::const_iterator ci; ci = _contexts.find(prepared_objects); @@ -1400,7 +1400,7 @@ prepare_now(PreparedGraphicsObjects *prepared_objects, } IndexBufferContext *ibc = prepared_objects->prepare_index_buffer_now(this, gsg); - if (ibc != (IndexBufferContext *)NULL) { + if (ibc != nullptr) { _contexts[prepared_objects] = ibc; } return ibc; @@ -1460,24 +1460,24 @@ get_index_format(NumericType index_type) { switch (index_type) { case NT_uint8: { - static CPT(GeomVertexArrayFormat) cformat = NULL; - if (cformat == NULL) { + static CPT(GeomVertexArrayFormat) cformat = nullptr; + if (cformat == nullptr) { cformat = make_index_format(NT_uint8); } return cformat; } case NT_uint16: { - static CPT(GeomVertexArrayFormat) cformat = NULL; - if (cformat == NULL) { + static CPT(GeomVertexArrayFormat) cformat = nullptr; + if (cformat == nullptr) { cformat = make_index_format(NT_uint16); } return cformat; } case NT_uint32: { - static CPT(GeomVertexArrayFormat) cformat = NULL; - if (cformat == NULL) { + static CPT(GeomVertexArrayFormat) cformat = nullptr; + if (cformat == nullptr) { cformat = make_index_format(NT_uint32); } return cformat; @@ -1486,10 +1486,10 @@ get_index_format(NumericType index_type) { default: gobj_cat.error() << "Not a valid index type: " << index_type << "\n"; - return NULL; + return nullptr; } - return NULL; + return nullptr; } /** @@ -1791,8 +1791,8 @@ decompose_impl() const { CPT(GeomVertexArrayData) GeomPrimitive:: rotate_impl() const { // The default implementation doesn't even try to do anything. - nassertr(false, NULL); - return NULL; + nassertr(false, nullptr); + return nullptr; } /** @@ -2074,7 +2074,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { void GeomPrimitive:: finalize(BamReader *manager) { const GeomVertexArrayData *vertices = get_vertices(); - if (vertices != (GeomVertexArrayData *)NULL) { + if (vertices != nullptr) { set_usage_hint(vertices->get_usage_hint()); } } diff --git a/panda/src/gobj/geomTriangles.cxx b/panda/src/gobj/geomTriangles.cxx index fa24ce761a..494f59be74 100644 --- a/panda/src/gobj/geomTriangles.cxx +++ b/panda/src/gobj/geomTriangles.cxx @@ -283,7 +283,7 @@ rotate_impl() const { nassertr(false, vertices); } - nassertr(to.is_at_end(), NULL); + nassertr(to.is_at_end(), nullptr); } else { // Nonindexed case. @@ -315,10 +315,10 @@ rotate_impl() const { default: // This shouldn't get called with any other shade model. - nassertr(false, NULL); + nassertr(false, nullptr); } - nassertr(to.is_at_end(), NULL); + nassertr(to.is_at_end(), nullptr); } return new_vertices; diff --git a/panda/src/gobj/geomTrifans.cxx b/panda/src/gobj/geomTrifans.cxx index 3808da40bb..0c5d87f53a 100644 --- a/panda/src/gobj/geomTrifans.cxx +++ b/panda/src/gobj/geomTrifans.cxx @@ -127,7 +127,7 @@ decompose_impl() const { ++li; } - nassertr(vi == num_vertices, NULL); + nassertr(vi == num_vertices, nullptr); return triangles.p(); } @@ -139,8 +139,8 @@ CPT(GeomVertexArrayData) GeomTrifans:: rotate_impl() const { // Actually, we can't rotate fans without chaging the winding order. It's // an error to define a flat shade model for a GeomTrifan. - nassertr(false, NULL); - return NULL; + nassertr(false, nullptr); + return nullptr; } /** diff --git a/panda/src/gobj/geomTristrips.cxx b/panda/src/gobj/geomTristrips.cxx index 01f97e8bee..7c8eff61f9 100644 --- a/panda/src/gobj/geomTristrips.cxx +++ b/panda/src/gobj/geomTristrips.cxx @@ -280,7 +280,7 @@ decompose_impl() const { // Skip unused vertices between tristrips. vi += num_unused; int end = ends[li]; - nassertr(vi + 2 <= end, NULL); + nassertr(vi + 2 <= end, nullptr); int v0 = get_vertex(vi); ++vi; int v1 = get_vertex(vi); @@ -311,7 +311,7 @@ decompose_impl() const { } ++li; } - nassertr(vi == num_vertices, NULL); + nassertr(vi == num_vertices, nullptr); } else { // Preserve the last vertex of each component triangle as the last vertex @@ -322,7 +322,7 @@ decompose_impl() const { // Skip unused vertices between tristrips. vi += num_unused; int end = ends[li]; - nassertr(vi + 2 <= end, NULL); + nassertr(vi + 2 <= end, nullptr); int v0 = get_vertex(vi); ++vi; int v1 = get_vertex(vi); @@ -353,7 +353,7 @@ decompose_impl() const { } ++li; } - nassertr(vi == num_vertices, NULL); + nassertr(vi == num_vertices, nullptr); } return triangles.p(); @@ -416,7 +416,7 @@ rotate_impl() const { // If this assertion is triggered, there was a triangle strip with an // odd number of vertices, which is not allowed. - nassertr((num_vertices & 1) == 0, NULL); + nassertr((num_vertices & 1) == 0, nullptr); for (int vi = end - 1; vi >= begin; --vi) { from.set_row_unsafe(vi); last_added = from.get_data1i(); @@ -426,7 +426,7 @@ rotate_impl() const { begin = end; } - nassertr(to.is_at_end(), NULL); + nassertr(to.is_at_end(), nullptr); } else { // Nonindexed case. @@ -449,7 +449,7 @@ rotate_impl() const { // If this assertion is triggered, there was a triangle strip with an // odd number of vertices, which is not allowed. - nassertr((num_vertices & 1) == 0, NULL); + nassertr((num_vertices & 1) == 0, nullptr); for (int vi = end - 1; vi >= begin; --vi) { last_added = vi + first_vertex; to.set_data1i(last_added); @@ -458,7 +458,7 @@ rotate_impl() const { begin = end; } - nassertr(to.is_at_end(), NULL); + nassertr(to.is_at_end(), nullptr); } return new_vertices; } diff --git a/panda/src/gobj/geomVertexArrayData.I b/panda/src/gobj/geomVertexArrayData.I index a9005fde12..a4b3f51397 100644 --- a/panda/src/gobj/geomVertexArrayData.I +++ b/panda/src/gobj/geomVertexArrayData.I @@ -393,8 +393,8 @@ INLINE GeomVertexArrayDataHandle:: #endif // DO_PIPELINING #ifdef _DEBUG - _object = NULL; - _cdata = NULL; + _object = nullptr; + _cdata = nullptr; #endif // _DEBUG } @@ -493,7 +493,7 @@ get_modified() const { */ INLINE bool GeomVertexArrayDataHandle:: request_resident() const { - return (get_read_pointer(false) != (const unsigned char *)NULL); + return (get_read_pointer(false) != nullptr); } /** diff --git a/panda/src/gobj/geomVertexArrayData.cxx b/panda/src/gobj/geomVertexArrayData.cxx index 50a4529159..9b4803d3bf 100644 --- a/panda/src/gobj/geomVertexArrayData.cxx +++ b/panda/src/gobj/geomVertexArrayData.cxx @@ -57,7 +57,7 @@ ALLOC_DELETED_CHAIN_DEF(GeomVertexArrayDataHandle); */ GeomVertexArrayData:: GeomVertexArrayData() : SimpleLruPage(0) { - _contexts = NULL; + _contexts = nullptr; // Can't put it in the LRU until it has been read in and made valid. } @@ -207,7 +207,7 @@ prepare(PreparedGraphicsObjects *prepared_objects) { */ bool GeomVertexArrayData:: is_prepared(PreparedGraphicsObjects *prepared_objects) const { - if (_contexts == (Contexts *)NULL) { + if (_contexts == nullptr) { return false; } Contexts::const_iterator ci; @@ -232,7 +232,7 @@ is_prepared(PreparedGraphicsObjects *prepared_objects) const { VertexBufferContext *GeomVertexArrayData:: prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) { - if (_contexts == (Contexts *)NULL) { + if (_contexts == nullptr) { _contexts = new Contexts; } Contexts::const_iterator ci; @@ -242,7 +242,7 @@ prepare_now(PreparedGraphicsObjects *prepared_objects, } VertexBufferContext *vbc = prepared_objects->prepare_vertex_buffer_now(this, gsg); - if (vbc != (VertexBufferContext *)NULL) { + if (vbc != nullptr) { (*_contexts)[prepared_objects] = vbc; } return vbc; @@ -254,7 +254,7 @@ prepare_now(PreparedGraphicsObjects *prepared_objects, */ bool GeomVertexArrayData:: release(PreparedGraphicsObjects *prepared_objects) { - if (_contexts != (Contexts *)NULL) { + if (_contexts != nullptr) { Contexts::iterator ci; ci = _contexts->find(prepared_objects); if (ci != _contexts->end()) { @@ -276,7 +276,7 @@ int GeomVertexArrayData:: release_all() { int num_freed = 0; - if (_contexts != (Contexts *)NULL) { + if (_contexts != nullptr) { // We have to traverse a copy of the _contexts list, because the // PreparedGraphicsObjects object will call clear_prepared() in response // to each release_vertex_buffer(), and we don't want to be modifying the @@ -293,7 +293,7 @@ release_all() { // Now that we've called release_vertex_buffer() on every known context, // the _contexts list should have completely emptied itself. - nassertr(_contexts == NULL, num_freed); + nassertr(_contexts == nullptr, num_freed); } return num_freed; @@ -335,7 +335,7 @@ evict_lru() { */ void GeomVertexArrayData:: clear_prepared(PreparedGraphicsObjects *prepared_objects) { - nassertv(_contexts != (Contexts *)NULL); + nassertv(_contexts != nullptr); Contexts::iterator ci; ci = _contexts->find(prepared_objects); @@ -343,7 +343,7 @@ clear_prepared(PreparedGraphicsObjects *prepared_objects) { _contexts->erase(ci); if (_contexts->empty()) { delete _contexts; - _contexts = NULL; + _contexts = nullptr; } } else { // If this assertion fails, clear_prepared() was given a prepared_objects @@ -457,7 +457,7 @@ finalize(BamReader *manager) { _array_format = new_array_format; PT(BamAuxData) aux_data = (BamAuxData *)manager->get_aux_data(this, ""); - if (aux_data != (BamAuxData *)NULL) { + if (aux_data != nullptr) { if (aux_data->_endian_reversed) { // Now is the time to endian-reverse the data. VertexDataBuffer new_buffer(cdata->_buffer.get_size()); @@ -571,7 +571,7 @@ fillin(DatagramIterator &scan, BamReader *manager, void *extra_data) { if (manager->get_file_endian() != BamReader::BE_native) { // For non-native endian files, we have to convert the data. - if (array_data->_array_format == (GeomVertexArrayFormat *)NULL) { + if (array_data->_array_format == nullptr) { // But we can't do that until we've completed the _array_format pointer, // which tells us how to convert it. endian_reversed = true; @@ -600,7 +600,7 @@ fillin(DatagramIterator &scan, BamReader *manager, void *extra_data) { */ unsigned char *GeomVertexArrayDataHandle:: get_write_pointer() { - nassertr(_writable, NULL); + nassertr(_writable, nullptr); mark_used(); _cdata->_modified = Geom::get_next_modified(); return _cdata->_buffer.get_write_pointer(); diff --git a/panda/src/gobj/geomVertexArrayData_ext.cxx b/panda/src/gobj/geomVertexArrayData_ext.cxx index 72b206c469..f35d96ae3a 100644 --- a/panda/src/gobj/geomVertexArrayData_ext.cxx +++ b/panda/src/gobj/geomVertexArrayData_ext.cxx @@ -54,7 +54,7 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) { view->internal = (void*) data; - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -62,20 +62,20 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) { view->len = row_size * handle->get_num_rows(); view->readonly = 0; view->itemsize = row_size; - view->format = NULL; + view->format = nullptr; if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) { view->format = (char*) data->_format.c_str(); } view->ndim = 1; - view->shape = NULL; + view->shape = nullptr; if ((flags & PyBUF_ND) == PyBUF_ND) { view->shape = &data->_num_rows; } - view->strides = NULL; + view->strides = nullptr; if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES) { view->strides = &data->_stride; } - view->suboffsets = NULL; + view->suboffsets = nullptr; return 0; #else @@ -120,7 +120,7 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { view->internal = (void*) data; - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -128,20 +128,20 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { view->len = row_size * handle->get_num_rows(); view->readonly = 1; view->itemsize = row_size; - view->format = NULL; + view->format = nullptr; if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) { view->format = (char*) data->_format.c_str(); } view->ndim = 1; - view->shape = NULL; + view->shape = nullptr; if ((flags & PyBUF_ND) == PyBUF_ND) { view->shape = &data->_num_rows; } - view->strides = NULL; + view->strides = nullptr; if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES) { view->strides = &data->_stride; } - view->suboffsets = NULL; + view->suboffsets = nullptr; return 0; #else @@ -158,11 +158,11 @@ __releasebuffer__(PyObject *self, Py_buffer *view) const { // Note: PyBuffer_Release automatically decrements view->obj. InternalBufferData *data; data = (InternalBufferData *) view->internal; - if (data == NULL) { + if (data == nullptr) { return; } delete data; - view->internal = NULL; + view->internal = nullptr; #endif } diff --git a/panda/src/gobj/geomVertexArrayFormat.I b/panda/src/gobj/geomVertexArrayFormat.I index 1765b0fcc4..94e62b109b 100644 --- a/panda/src/gobj/geomVertexArrayFormat.I +++ b/panda/src/gobj/geomVertexArrayFormat.I @@ -126,7 +126,7 @@ get_num_columns() const { */ INLINE const GeomVertexColumn *GeomVertexArrayFormat:: get_column(int i) const { - nassertr(i >= 0 && i < (int)_columns.size(), NULL); + nassertr(i >= 0 && i < (int)_columns.size(), nullptr); consider_sort_columns(); return _columns[(size_t)i]; } @@ -136,7 +136,7 @@ get_column(int i) const { */ INLINE bool GeomVertexArrayFormat:: has_column(const InternalName *name) const { - return (get_column(name) != (GeomVertexColumn *)NULL); + return (get_column(name) != nullptr); } /** @@ -144,7 +144,7 @@ has_column(const InternalName *name) const { */ INLINE GeomVertexArrayFormat::Registry *GeomVertexArrayFormat:: get_registry() { - if (_registry == (Registry *)NULL) { + if (_registry == nullptr) { make_registry(); } return _registry; diff --git a/panda/src/gobj/geomVertexArrayFormat.cxx b/panda/src/gobj/geomVertexArrayFormat.cxx index c8adfa81eb..9e0d35cccd 100644 --- a/panda/src/gobj/geomVertexArrayFormat.cxx +++ b/panda/src/gobj/geomVertexArrayFormat.cxx @@ -21,7 +21,7 @@ #include "indirectLess.h" #include "lightMutexHolder.h" -GeomVertexArrayFormat::Registry *GeomVertexArrayFormat::_registry = NULL; +GeomVertexArrayFormat::Registry *GeomVertexArrayFormat::_registry = nullptr; TypeHandle GeomVertexArrayFormat::_type_handle; /** @@ -243,7 +243,7 @@ add_column(const GeomVertexColumn &column) { // Also make sure there aren't any columns that overlap with this one. const GeomVertexColumn *orig_column = get_column(column.get_start(), column.get_total_bytes()); - while (orig_column != (const GeomVertexColumn *)NULL) { + while (orig_column != nullptr) { remove_column(orig_column->get_name()); orig_column = get_column(column.get_start(), column.get_total_bytes()); } @@ -381,7 +381,7 @@ get_column(const InternalName *name) const { if (ni != _columns_by_name.end()) { return (*ni).second; } - return NULL; + return nullptr; } /** @@ -399,7 +399,7 @@ get_column(int start_byte, int num_bytes) const { } } - return NULL; + return nullptr; } /** @@ -603,7 +603,7 @@ get_format_string(bool pad) const { default: gobj_cat.error() << "Unknown numeric type " << column->get_numeric_type() << "!\n"; - return NULL; + return nullptr; } memset((void*) (fmt + fi), fmt_code, column->get_num_components()); offset += column->get_total_bytes(); @@ -667,7 +667,7 @@ sort_columns() { */ void GeomVertexArrayFormat:: make_registry() { - if (_registry == (Registry *)NULL) { + if (_registry == nullptr) { _registry = new Registry; } } diff --git a/panda/src/gobj/geomVertexColumn.I b/panda/src/gobj/geomVertexColumn.I index 262c19c3a2..c9e4a2fb8a 100644 --- a/panda/src/gobj/geomVertexColumn.I +++ b/panda/src/gobj/geomVertexColumn.I @@ -16,7 +16,7 @@ */ INLINE GeomVertexColumn:: GeomVertexColumn() : - _packer(NULL) + _packer(nullptr) { } @@ -36,7 +36,7 @@ GeomVertexColumn(CPT_InternalName name, int num_components, _column_alignment(column_alignment), _num_elements(num_elements), _element_stride(element_stride), - _packer(NULL) + _packer(nullptr) { setup(); } @@ -54,7 +54,7 @@ GeomVertexColumn(const GeomVertexColumn ©) : _column_alignment(copy._column_alignment), _num_elements(copy._num_elements), _element_stride(copy._element_stride), - _packer(NULL) + _packer(nullptr) { setup(); } diff --git a/panda/src/gobj/geomVertexColumn.cxx b/panda/src/gobj/geomVertexColumn.cxx index 06a3af8a97..b43930d3b5 100644 --- a/panda/src/gobj/geomVertexColumn.cxx +++ b/panda/src/gobj/geomVertexColumn.cxx @@ -225,7 +225,7 @@ setup() { } _total_bytes = _element_stride * _num_elements; - if (_packer != NULL) { + if (_packer != nullptr) { delete _packer; } diff --git a/panda/src/gobj/geomVertexData.I b/panda/src/gobj/geomVertexData.I index 1d42671e67..6575397fa2 100644 --- a/panda/src/gobj/geomVertexData.I +++ b/panda/src/gobj/geomVertexData.I @@ -220,7 +220,7 @@ get_transform_table() const { */ INLINE void GeomVertexData:: clear_transform_table() { - set_transform_table(NULL); + set_transform_table(nullptr); } /** @@ -245,7 +245,7 @@ get_transform_blend_table() const { */ INLINE void GeomVertexData:: clear_transform_blend_table() { - set_transform_blend_table(NULL); + set_transform_blend_table(nullptr); } /** @@ -268,7 +268,7 @@ get_slider_table() const { */ INLINE void GeomVertexData:: clear_slider_table() { - set_slider_table(NULL); + set_slider_table(nullptr); } /** @@ -637,8 +637,8 @@ INLINE GeomVertexDataPipelineBase:: #endif // DO_PIPELINING #ifdef _DEBUG - _object = NULL; - _cdata = NULL; + _object = nullptr; + _cdata = nullptr; #endif // _DEBUG } @@ -687,7 +687,7 @@ get_num_arrays() const { */ INLINE CPT(GeomVertexArrayData) GeomVertexDataPipelineBase:: get_array(int i) const { - nassertr(i >= 0 && i < (int)_cdata->_arrays.size(), NULL); + nassertr(i >= 0 && i < (int)_cdata->_arrays.size(), nullptr); return _cdata->_arrays[i].get_read_pointer(); } @@ -751,7 +751,7 @@ GeomVertexDataPipelineReader(const GeomVertexData *object, INLINE void GeomVertexDataPipelineReader:: set_object(const GeomVertexData *object) { #ifdef DO_PIPELINING - if (_cdata != NULL) { + if (_cdata != nullptr) { unref_delete((CycleData *)_cdata); } #endif // DO_PIPELINING @@ -787,8 +787,8 @@ check_array_readers() const { */ INLINE const GeomVertexArrayDataHandle *GeomVertexDataPipelineReader:: get_array_reader(int i) const { - nassertr(_got_array_readers, NULL); - nassertr(i >= 0 && i < (int)_array_readers.size(), NULL); + nassertr(_got_array_readers, nullptr); + nassertr(i >= 0 && i < (int)_array_readers.size(), nullptr); return _array_readers[i]; } @@ -797,7 +797,7 @@ get_array_reader(int i) const { */ INLINE bool GeomVertexDataPipelineReader:: has_vertex() const { - return (_cdata->_format->get_vertex_column() != (GeomVertexColumn *)NULL); + return (_cdata->_format->get_vertex_column() != nullptr); } /** @@ -806,7 +806,7 @@ has_vertex() const { INLINE bool GeomVertexDataPipelineReader:: is_vertex_transformed() const { const GeomVertexColumn *column = _cdata->_format->get_vertex_column(); - if (column != (GeomVertexColumn *)NULL) { + if (column != nullptr) { return column->get_contents() == C_clip_point; } @@ -818,7 +818,7 @@ is_vertex_transformed() const { */ INLINE bool GeomVertexDataPipelineReader:: has_normal() const { - return (_cdata->_format->get_normal_column() != (GeomVertexColumn *)NULL); + return (_cdata->_format->get_normal_column() != nullptr); } /** @@ -826,7 +826,7 @@ has_normal() const { */ INLINE bool GeomVertexDataPipelineReader:: has_color() const { - return (_cdata->_format->get_color_column() != (GeomVertexColumn *)NULL); + return (_cdata->_format->get_color_column() != nullptr); } /** @@ -881,7 +881,7 @@ check_array_writers() const { */ INLINE GeomVertexArrayDataHandle *GeomVertexDataPipelineWriter:: get_array_writer(size_t i) const { - nassertr(_got_array_writers, NULL); + nassertr(_got_array_writers, nullptr); nassertr(i < _array_writers.size(), nullptr); return _array_writers[i]; } diff --git a/panda/src/gobj/geomVertexData.cxx b/panda/src/gobj/geomVertexData.cxx index 05992e5378..f2597614ef 100644 --- a/panda/src/gobj/geomVertexData.cxx +++ b/panda/src/gobj/geomVertexData.cxx @@ -89,7 +89,7 @@ GeomVertexData(const GeomVertexData ©) : OPEN_ITERATE_ALL_STAGES(_cycler) { CDStageWriter cdata(_cycler, pipeline_stage); // It's important that we *not* copy the animated_vertices pointer. - cdata->_animated_vertices = NULL; + cdata->_animated_vertices = nullptr; cdata->_animated_vertices_modified = UpdateSeq(); } CLOSE_ITERATE_ALL_STAGES(_cycler); @@ -128,7 +128,7 @@ GeomVertexData(const GeomVertexData ©, } // It's important that we *not* copy the animated_vertices pointer. - cdata->_animated_vertices = NULL; + cdata->_animated_vertices = nullptr; cdata->_animated_vertices_modified = UpdateSeq(); } CLOSE_ITERATE_ALL_STAGES(_cycler); @@ -155,7 +155,7 @@ operator = (const GeomVertexData ©) { OPEN_ITERATE_ALL_STAGES(_cycler) { CDStageWriter cdata(_cycler, pipeline_stage); cdata->_modified = Geom::get_next_modified(); - cdata->_animated_vertices = NULL; + cdata->_animated_vertices = nullptr; cdata->_animated_vertices_modified = UpdateSeq(); } CLOSE_ITERATE_ALL_STAGES(_cycler); @@ -367,7 +367,7 @@ clear_rows() { void GeomVertexData:: set_transform_table(const TransformTable *table) { Thread *current_thread = Thread::get_current_thread(); - nassertv(table == (TransformTable *)NULL || table->is_registered()); + nassertv(table == nullptr || table->is_registered()); CDWriter cdata(_cycler, true, current_thread); cdata->_transform_table = (TransformTable *)table; @@ -425,7 +425,7 @@ set_transform_blend_table(const TransformBlendTable *table) { */ void GeomVertexData:: set_slider_table(const SliderTable *table) { - nassertv(table == (SliderTable *)NULL || table->is_registered()); + nassertv(table == nullptr || table->is_registered()); CDWriter cdata(_cycler, true); cdata->_slider_table = (SliderTable *)table; @@ -540,7 +540,7 @@ copy_from(const GeomVertexData *source, bool keep_data_objects, dest_format->get_array(dest_i); const GeomVertexColumn *dest_column = dest_array_format->get_column(source_column->get_name()); - nassertv(dest_column != (const GeomVertexColumn *)NULL); + nassertv(dest_column != nullptr); if (dest_column->is_bytewise_equivalent(*source_column)) { // We can do a quick bytewise copy. @@ -604,7 +604,7 @@ copy_from(const GeomVertexData *source, bool keep_data_objects, // Convert Panda-style animation tables to hardware-style animation // tables. CPT(TransformBlendTable) blend_table = source->get_transform_blend_table(); - if (blend_table != (TransformBlendTable *)NULL) { + if (blend_table != nullptr) { PT(TransformTable) transform_table = new TransformTable; TransformMap already_added; @@ -725,14 +725,14 @@ convert_to(const GeomVertexFormat *new_format) const { } else { entry = (*ci).second; _cache_lock.release(); - nassertr(entry->_source == this, NULL); + nassertr(entry->_source == this, nullptr); // Here's an element in the cache for this computation. Record a cache // hit, so this element will stay in the cache a while longer. entry->refresh(current_thread); CDCacheReader cdata(entry->_cycler); - if (cdata->_result != (GeomVertexData *)NULL) { + if (cdata->_result != nullptr) { return cdata->_result; } @@ -758,7 +758,7 @@ convert_to(const GeomVertexFormat *new_format) const { new_data->copy_from(this, false); // Record the new result in the cache. - if (entry == (CacheEntry *)NULL) { + if (entry == nullptr) { // Create a new entry for the result. // We don't need the key anymore, move the pointers into the CacheEntry. entry = new CacheEntry((GeomVertexData *)this, move(key)); @@ -795,7 +795,7 @@ CPT(GeomVertexData) GeomVertexData:: scale_color(const LVecBase4 &color_scale) const { const GeomVertexColumn *old_column = get_format()->get_column(InternalName::get_color()); - if (old_column == (GeomVertexColumn *)NULL) { + if (old_column == nullptr) { return this; } @@ -866,7 +866,7 @@ CPT(GeomVertexData) GeomVertexData:: set_color(const LColor &color) const { const GeomVertexColumn *old_column = get_format()->get_column(InternalName::get_color()); - if (old_column == (GeomVertexColumn *)NULL) { + if (old_column == nullptr) { return this; } @@ -910,7 +910,7 @@ CPT(GeomVertexData) GeomVertexData:: reverse_normals() const { const GeomVertexColumn *old_column = get_format()->get_column(InternalName::get_normal()); - if (old_column == (GeomVertexColumn *)NULL) { + if (old_column == nullptr) { return this; } @@ -967,7 +967,7 @@ animate_vertices(bool force, Thread *current_thread) const { { PStatTimer timer2(((GeomVertexData *)this)->_blends_pcollector, current_thread); if (!cdata->_transform_blend_table.is_null()) { - if (cdata->_slider_table != (SliderTable *)NULL) { + if (cdata->_slider_table != nullptr) { modified = max(cdata->_transform_blend_table.get_read_pointer()->get_modified(current_thread), cdata->_slider_table->get_modified(current_thread)); @@ -975,7 +975,7 @@ animate_vertices(bool force, Thread *current_thread) const { modified = cdata->_transform_blend_table.get_read_pointer()->get_modified(current_thread); } - } else if (cdata->_slider_table != (SliderTable *)NULL) { + } else if (cdata->_slider_table != nullptr) { modified = cdata->_slider_table->get_modified(current_thread); } else { @@ -985,14 +985,14 @@ animate_vertices(bool force, Thread *current_thread) const { } if (cdata->_animated_vertices_modified == modified && - cdata->_animated_vertices != (GeomVertexData *)NULL) { + cdata->_animated_vertices != nullptr) { // No changes. return cdata->_animated_vertices; } if (!force && !request_resident()) { // The vertex data isn't resident. Return the best information we've got. - if (cdata->_animated_vertices != (GeomVertexData *)NULL) { + if (cdata->_animated_vertices != nullptr) { return cdata->_animated_vertices; } return this; @@ -1112,7 +1112,7 @@ do_set_color(GeomVertexData *vdata, const LColor &color) { size_t stride = format->get_array(array_index)->get_stride(); GeomVertexColumn::Packer *packer = column->_packer; - nassertv(packer != NULL); + nassertv(packer != nullptr); // Pack into a buffer, which we will then copy. unsigned char buffer[32]; @@ -1284,7 +1284,7 @@ write(ostream &out, int indent_level) const { } get_format()->write_with_data(out, indent_level + 2, this); CPT(TransformBlendTable) table = get_transform_blend_table(); - if (table != (TransformBlendTable *)NULL) { + if (table != nullptr) { indent(out, indent_level) << "Transform blend table:\n"; table->write(out, indent_level + 2); @@ -1305,7 +1305,7 @@ describe_vertex(ostream &out, int row) const { reader.set_row_unsafe(row); const GeomVertexFormat *format = get_format(); - const TransformBlendTable *tb_table = NULL; + const TransformBlendTable *tb_table = nullptr; if (format->get_animation().get_animation_type() == AT_panda) { tb_table = get_transform_blend_table(); } @@ -1326,7 +1326,7 @@ describe_vertex(ostream &out, int row) const { out << "\n"; if (column->get_name() == InternalName::get_transform_blend() && - tb_table != NULL) { + tb_table != nullptr) { // This is an index into the transform blend table. Look up the index // and report the vertex weighting. reader.set_column(ai, column); @@ -1344,15 +1344,15 @@ describe_vertex(ostream &out, int row) const { for (int ai = 0; ai < num_arrays; ++ai) { const GeomVertexArrayData *array = get_array(ai); const GeomVertexArrayFormat *aformat = format->get_array(ai); - nassertv(array != NULL && aformat != NULL); + nassertv(array != nullptr && aformat != nullptr); out << " " << *aformat << "\n"; CPT(GeomVertexArrayDataHandle) handle = array->get_handle(); - nassertv(handle != (const GeomVertexArrayDataHandle *)NULL); + nassertv(handle != nullptr); const unsigned char *data = handle->get_read_pointer(true); - nassertv(data != NULL); + nassertv(data != nullptr); int stride = aformat->get_stride(); int start = stride * row; - if (data != NULL) { + if (data != nullptr) { Datagram dg(data + start, stride); dg.dump_hex(out, 4); } @@ -1393,7 +1393,7 @@ clear_cache_stage() { ++ci) { CacheEntry *entry = (*ci).second; CDCacheWriter cdata(entry->_cycler); - cdata->_result = NULL; + cdata->_result = nullptr; } } @@ -1466,7 +1466,7 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { const GeomVertexFormat *orig_format = cdata->_format; CPT(GeomVertexFormat) new_format = orig_format; - if (cdata->_animated_vertices == (GeomVertexData *)NULL) { + if (cdata->_animated_vertices == nullptr) { new_format = orig_format->get_post_animated_format(); cdata->_animated_vertices = new GeomVertexData(get_name(), new_format, @@ -1482,7 +1482,7 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { // First, apply all of the morphs. CPT(SliderTable) slider_table = cdata->_slider_table; - if (slider_table != (SliderTable *)NULL) { + if (slider_table != nullptr) { PStatTimer timer2(_morphs_pcollector); int num_morphs = orig_format->get_num_morphs(); for (int mi = 0; mi < num_morphs; mi++) { @@ -1565,7 +1565,7 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { // Then apply the transforms. CPT(TransformBlendTable) tb_table = cdata->_transform_blend_table.get_read_pointer(current_thread); - if (tb_table != (TransformBlendTable *)NULL) { + if (tb_table != nullptr) { // Recompute all the blends up front, so we don't have to test each one // for staleness at each vertex. { @@ -2072,14 +2072,14 @@ finalize(BamReader *manager) { array_obj->_array_format = new_array_format; } - if (cdata->_transform_table != (TransformTable *)NULL) { + if (cdata->_transform_table != nullptr) { CPT(TransformTable) new_transform_table = TransformTable::register_table(cdata->_transform_table); manager->change_pointer(cdata->_transform_table, new_transform_table); cdata->_transform_table = new_transform_table; } - if (cdata->_slider_table != (SliderTable *)NULL) { + if (cdata->_slider_table != nullptr) { CPT(SliderTable) new_slider_table = SliderTable::register_table(cdata->_slider_table); manager->change_pointer(cdata->_slider_table, new_slider_table); @@ -2186,7 +2186,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { CPT(GeomVertexArrayData) adata = _arrays[0].get_read_pointer(); all_rows.set_range(0, adata->get_num_rows()); - if (_slider_table != (SliderTable *)NULL) { + if (_slider_table != nullptr) { int num_sliders = _slider_table->get_num_sliders(); for (int i = 0; i < num_sliders; ++i) { ((SliderTable *)_slider_table.p())->set_slider_rows(i, all_rows); @@ -2213,7 +2213,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _arrays.reserve(num_arrays); for (size_t i = 0; i < num_arrays; ++i) { manager->read_pointer(scan); - _arrays.push_back(NULL); + _arrays.push_back(nullptr); } manager->read_pointer(scan); diff --git a/panda/src/gobj/geomVertexFormat.I b/panda/src/gobj/geomVertexFormat.I index 2879599cc5..680f779447 100644 --- a/panda/src/gobj/geomVertexFormat.I +++ b/panda/src/gobj/geomVertexFormat.I @@ -88,7 +88,7 @@ get_num_arrays() const { */ INLINE const GeomVertexArrayFormat *GeomVertexFormat:: get_array(size_t array) const { - nassertr(array < _arrays.size(), NULL); + nassertr(array < _arrays.size(), nullptr); return _arrays[array]; } @@ -97,7 +97,7 @@ get_array(size_t array) const { */ INLINE bool GeomVertexFormat:: has_column(const InternalName *name) const { - return (get_column(name) != (GeomVertexColumn *)NULL); + return (get_column(name) != nullptr); } /** @@ -120,8 +120,8 @@ get_num_points() const { */ INLINE const InternalName *GeomVertexFormat:: get_point(size_t n) const { - nassertr(_is_registered, NULL); - nassertr(n < _points.size(), NULL); + nassertr(_is_registered, nullptr); + nassertr(n < _points.size(), nullptr); return _points[n]; } @@ -146,8 +146,8 @@ get_num_vectors() const { */ INLINE const InternalName *GeomVertexFormat:: get_vector(size_t n) const { - nassertr(_is_registered, NULL); - nassertr(n < _vectors.size(), NULL); + nassertr(_is_registered, nullptr); + nassertr(n < _vectors.size(), nullptr); return _vectors[n]; } @@ -171,8 +171,8 @@ get_num_texcoords() const { */ INLINE const InternalName *GeomVertexFormat:: get_texcoord(size_t n) const { - nassertr(_is_registered, NULL); - nassertr(n < _texcoords.size(), NULL); + nassertr(_is_registered, nullptr); + nassertr(n < _texcoords.size(), nullptr); return _texcoords[n]; } @@ -198,8 +198,8 @@ get_num_morphs() const { */ INLINE const InternalName *GeomVertexFormat:: get_morph_slider(size_t n) const { - nassertr(_is_registered, NULL); - nassertr(n < _morphs.size(), NULL); + nassertr(_is_registered, nullptr); + nassertr(n < _morphs.size(), nullptr); return _morphs[n]._slider; } @@ -213,8 +213,8 @@ get_morph_slider(size_t n) const { */ INLINE const InternalName *GeomVertexFormat:: get_morph_base(size_t n) const { - nassertr(_is_registered, NULL); - nassertr(n < _morphs.size(), NULL); + nassertr(_is_registered, nullptr); + nassertr(n < _morphs.size(), nullptr); return _morphs[n]._base; } @@ -229,8 +229,8 @@ get_morph_base(size_t n) const { */ INLINE const InternalName *GeomVertexFormat:: get_morph_delta(size_t n) const { - nassertr(_is_registered, NULL); - nassertr(n < _morphs.size(), NULL); + nassertr(_is_registered, nullptr); + nassertr(n < _morphs.size(), nullptr); return _morphs[n]._delta; } @@ -373,7 +373,7 @@ get_vertex_array_index() const { */ INLINE const GeomVertexColumn *GeomVertexFormat:: get_vertex_column() const { - nassertr(_is_registered, NULL); + nassertr(_is_registered, nullptr); return _vertex_column; } @@ -397,7 +397,7 @@ get_normal_array_index() const { */ INLINE const GeomVertexColumn *GeomVertexFormat:: get_normal_column() const { - nassertr(_is_registered, NULL); + nassertr(_is_registered, nullptr); return _normal_column; } @@ -421,7 +421,7 @@ get_color_array_index() const { */ INLINE const GeomVertexColumn *GeomVertexFormat:: get_color_column() const { - nassertr(_is_registered, NULL); + nassertr(_is_registered, nullptr); return _color_column; } @@ -430,7 +430,7 @@ get_color_column() const { */ INLINE GeomVertexFormat::Registry *GeomVertexFormat:: get_registry() { - if (_registry == (Registry *)NULL) { + if (_registry == nullptr) { make_registry(); } return _registry; diff --git a/panda/src/gobj/geomVertexFormat.cxx b/panda/src/gobj/geomVertexFormat.cxx index f3652e8321..05814c5bd8 100644 --- a/panda/src/gobj/geomVertexFormat.cxx +++ b/panda/src/gobj/geomVertexFormat.cxx @@ -19,7 +19,7 @@ #include "bamReader.h" #include "bamWriter.h" -GeomVertexFormat::Registry *GeomVertexFormat::_registry = NULL; +GeomVertexFormat::Registry *GeomVertexFormat::_registry = nullptr; TypeHandle GeomVertexFormat::_type_handle; /** @@ -28,7 +28,7 @@ TypeHandle GeomVertexFormat::_type_handle; GeomVertexFormat:: GeomVertexFormat() : _is_registered(false), - _post_animated_format(NULL) + _post_animated_format(nullptr) { } @@ -38,7 +38,7 @@ GeomVertexFormat() : GeomVertexFormat:: GeomVertexFormat(const GeomVertexArrayFormat *array_format) : _is_registered(false), - _post_animated_format(NULL) + _post_animated_format(nullptr) { add_array(array_format); } @@ -51,7 +51,7 @@ GeomVertexFormat(const GeomVertexFormat ©) : _is_registered(false), _animation(copy._animation), _arrays(copy._arrays), - _post_animated_format(NULL) + _post_animated_format(nullptr) { } @@ -105,9 +105,9 @@ unref() const { */ CPT(GeomVertexFormat) GeomVertexFormat:: get_post_animated_format() const { - nassertr(is_registered(), NULL); + nassertr(is_registered(), nullptr); - if (_post_animated_format == (GeomVertexFormat *)NULL) { + if (_post_animated_format == nullptr) { PT(GeomVertexFormat) new_format = new GeomVertexFormat(*this); new_format->remove_column(InternalName::get_transform_blend()); @@ -145,7 +145,7 @@ get_post_animated_format() const { */ CPT(GeomVertexFormat) GeomVertexFormat:: get_union_format(const GeomVertexFormat *other) const { - nassertr(is_registered() && other->is_registered(), NULL); + nassertr(is_registered() && other->is_registered(), nullptr); PT(GeomVertexFormat) new_format = new GeomVertexFormat; @@ -186,7 +186,7 @@ get_union_format(const GeomVertexFormat *other) const { bool inserted = column_names.insert(column_a->get_name()).second; if (inserted) { const GeomVertexColumn *column_b = other->get_column(column_a->get_name()); - if (column_b != (GeomVertexColumn *)NULL && + if (column_b != nullptr && column_b->get_total_bytes() > column_a->get_total_bytes()) { // Column b is larger. Keep it. new_array->add_column(column_b->get_name(), @@ -213,7 +213,7 @@ get_union_format(const GeomVertexFormat *other) const { bool inserted = column_names.insert(column_a->get_name()).second; if (inserted) { const GeomVertexColumn *column_b = get_column(column_a->get_name()); - if (column_b != (GeomVertexColumn *)NULL && + if (column_b != nullptr && column_b->get_total_bytes() > column_a->get_total_bytes()) { // Column b is larger. Keep it. new_array->add_column(column_b->get_name(), @@ -248,8 +248,8 @@ get_union_format(const GeomVertexFormat *other) const { */ GeomVertexArrayFormat *GeomVertexFormat:: modify_array(size_t array) { - nassertr(!is_registered(), NULL); - nassertr(array < _arrays.size(), NULL); + nassertr(!is_registered(), nullptr); + nassertr(array < _arrays.size(), nullptr); if (_arrays[array]->is_registered() || _arrays[array]->get_ref_count() > 1) { @@ -376,7 +376,7 @@ get_column(size_t i) const { i -= (*ai)->get_num_columns(); } - return NULL; + return nullptr; } /** @@ -450,11 +450,11 @@ get_column(const InternalName *name) const { Arrays::const_iterator ai; for (ai = _arrays.begin(); ai != _arrays.end(); ++ai) { const GeomVertexColumn *column = (*ai)->get_column(name); - if (column != (GeomVertexColumn *)NULL) { + if (column != nullptr) { return column; } } - return NULL; + return nullptr; } else { // If the format has been registered, we can just check the toplevel @@ -466,10 +466,10 @@ get_column(const InternalName *name) const { int array_index = (*ai).second._array_index; int column_index = (*ai).second._column_index; - nassertr(array_index >= 0 && array_index < (int)_arrays.size(), NULL); + nassertr(array_index >= 0 && array_index < (int)_arrays.size(), nullptr); return _arrays[array_index]->get_column(column_index); } - return NULL; + return nullptr; } } @@ -491,7 +491,7 @@ remove_column(const InternalName *name, bool keep_empty_array) { for (int array = 0; array < (int)_arrays.size(); ++array) { GeomVertexArrayFormat *array_format = _arrays[array]; - if (array_format->get_column(name) != (GeomVertexColumn *)NULL) { + if (array_format->get_column(name) != nullptr) { // Here's the array with the named column! if (array_format->is_registered() || array_format->get_ref_count() > 1) { @@ -642,7 +642,7 @@ get_array_info(const InternalName *name, int &array_index, } array_index = -1; - column = NULL; + column = nullptr; return false; } @@ -676,7 +676,7 @@ compare_to(const GeomVertexFormat &other) const { */ void GeomVertexFormat:: make_registry() { - if (_registry == (Registry *)NULL) { + if (_registry == nullptr) { _registry = new Registry; _registry->make_standard_formats(); } @@ -813,11 +813,11 @@ do_unregister() { _texcoords.clear(); _morphs.clear(); - if (_post_animated_format != (GeomVertexFormat *)NULL && + if (_post_animated_format != nullptr && _post_animated_format != this) { unref_delete(_post_animated_format); } - _post_animated_format = NULL; + _post_animated_format = nullptr; } /** @@ -892,7 +892,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _arrays.reserve(num_arrays); for (int i = 0; i < num_arrays; i++) { manager->read_pointer(scan); - _arrays.push_back(NULL); + _arrays.push_back(nullptr); } } diff --git a/panda/src/gobj/geomVertexReader.I b/panda/src/gobj/geomVertexReader.I index 412bfa611d..893d6458cf 100644 --- a/panda/src/gobj/geomVertexReader.I +++ b/panda/src/gobj/geomVertexReader.I @@ -18,7 +18,7 @@ */ INLINE GeomVertexReader:: GeomVertexReader(Thread *current_thread) : - _vertex_data(NULL), + _vertex_data(nullptr), _current_thread(current_thread) { initialize(); @@ -227,7 +227,7 @@ get_force() const { */ INLINE bool GeomVertexReader:: set_column(int column) { - if (_vertex_data != (const GeomVertexData *)NULL) { + if (_vertex_data != nullptr) { GeomVertexDataPipelineReader reader(_vertex_data, _current_thread); reader.check_array_readers(); const GeomVertexFormat *format = reader.get_format(); @@ -235,7 +235,7 @@ set_column(int column) { format->get_column(column), &reader); } - if (_array_data != (const GeomVertexArrayData *)NULL) { + if (_array_data != nullptr) { return set_array_column(_array_data->get_array_format()->get_column(column)); } return false; @@ -252,7 +252,7 @@ set_column(int column) { */ INLINE bool GeomVertexReader:: set_column(CPT_InternalName name) { - if (_vertex_data != (const GeomVertexData *)NULL) { + if (_vertex_data != nullptr) { GeomVertexDataPipelineReader reader(_vertex_data, _current_thread); reader.check_array_readers(); const GeomVertexFormat *format = reader.get_format(); @@ -260,7 +260,7 @@ set_column(CPT_InternalName name) { format->get_column(name), &reader); } - if (_array_data != (const GeomVertexArrayData *)NULL) { + if (_array_data != nullptr) { return set_array_column(_array_data->get_array_format()->get_column(name)); } @@ -282,7 +282,7 @@ clear() { */ INLINE bool GeomVertexReader:: has_column() const { - return (_packer != (GeomVertexColumn::Packer *)NULL); + return (_packer != nullptr); } /** @@ -299,10 +299,10 @@ get_array() const { */ INLINE const GeomVertexColumn *GeomVertexReader:: get_column() const { - if (_packer != (GeomVertexColumn::Packer *)NULL) { + if (_packer != nullptr) { return _packer->_column; } - return NULL; + return nullptr; } /** @@ -683,9 +683,9 @@ get_packer() const { INLINE bool GeomVertexReader:: set_pointer(int row) { _pointer_begin = _handle->get_read_pointer(_force); - if (_pointer_begin == NULL && _handle->get_data_size_bytes() != 0) { + if (_pointer_begin == nullptr && _handle->get_data_size_bytes() != 0) { // Vertex data is not resident. - set_column(0, NULL); + set_column(0, nullptr); return false; } @@ -701,7 +701,7 @@ set_pointer(int row) { */ INLINE void GeomVertexReader:: quick_set_pointer(int row) { - nassertv(has_column() && (_pointer_begin != NULL || row == 0)); + nassertv(has_column() && (_pointer_begin != nullptr || row == 0)); #if defined(_DEBUG) // Make sure we still have the same pointer as stored in the array. diff --git a/panda/src/gobj/geomVertexReader.cxx b/panda/src/gobj/geomVertexReader.cxx index 054e7df942..b803095915 100644 --- a/panda/src/gobj/geomVertexReader.cxx +++ b/panda/src/gobj/geomVertexReader.cxx @@ -32,23 +32,23 @@ const unsigned char GeomVertexReader::empty_buffer[100] = { 0 }; */ bool GeomVertexReader:: set_column(int array, const GeomVertexColumn *column) { - if (column == (const GeomVertexColumn *)NULL) { + if (column == nullptr) { // Clear the data type. _array = -1; - _packer = NULL; + _packer = nullptr; _stride = 0; - _pointer = NULL; - _pointer_end = NULL; + _pointer = nullptr; + _pointer_end = nullptr; return false; } - if (_vertex_data != (const GeomVertexData *)NULL) { + if (_vertex_data != nullptr) { GeomVertexDataPipelineReader reader(_vertex_data, _current_thread); reader.check_array_readers(); return set_vertex_column(array, column, &reader); } - if (_array_data != (const GeomVertexArrayData *)NULL) { + if (_array_data != nullptr) { return set_array_column(column); } @@ -62,7 +62,7 @@ set_column(int array, const GeomVertexColumn *column) { void GeomVertexReader:: output(ostream &out) const { const GeomVertexColumn *column = get_column(); - if (column == (GeomVertexColumn *)NULL) { + if (column == nullptr) { out << "GeomVertexReader()"; } else { @@ -79,10 +79,10 @@ output(ostream &out) const { void GeomVertexReader:: initialize() { _array = 0; - _packer = NULL; - _pointer_begin = NULL; - _pointer_end = NULL; - _pointer = NULL; + _packer = nullptr; + _pointer_begin = nullptr; + _pointer_end = nullptr; + _pointer = nullptr; _start_row = 0; _force = true; } @@ -94,15 +94,15 @@ initialize() { bool GeomVertexReader:: set_vertex_column(int array, const GeomVertexColumn *column, const GeomVertexDataPipelineReader *data_reader) { - if (column == (const GeomVertexColumn *)NULL) { - return set_column(0, NULL); + if (column == nullptr) { + return set_column(0, nullptr); } - nassertr(_vertex_data != (const GeomVertexData *)NULL, false); + nassertr(_vertex_data != nullptr, false); #ifndef NDEBUG _array = -1; - _packer = NULL; + _packer = nullptr; nassertr(array >= 0 && array < _vertex_data->get_num_arrays(), false); #endif @@ -120,11 +120,11 @@ set_vertex_column(int array, const GeomVertexColumn *column, */ bool GeomVertexReader:: set_array_column(const GeomVertexColumn *column) { - if (column == (const GeomVertexColumn *)NULL) { - return set_column(0, NULL); + if (column == nullptr) { + return set_column(0, nullptr); } - nassertr(_array_data != (const GeomVertexArrayData *)NULL, false); + nassertr(_array_data != nullptr, false); _handle = _array_data->get_handle(); _stride = _handle->get_array_format()->get_stride(); diff --git a/panda/src/gobj/geomVertexRewriter.I b/panda/src/gobj/geomVertexRewriter.I index ac092d6979..077dc3963c 100644 --- a/panda/src/gobj/geomVertexRewriter.I +++ b/panda/src/gobj/geomVertexRewriter.I @@ -104,7 +104,7 @@ INLINE GeomVertexRewriter:: INLINE GeomVertexData *GeomVertexRewriter:: get_vertex_data() const { nassertr(GeomVertexWriter::get_vertex_data() == - GeomVertexReader::get_vertex_data(), NULL); + GeomVertexReader::get_vertex_data(), nullptr); return GeomVertexWriter::get_vertex_data(); } @@ -115,7 +115,7 @@ get_vertex_data() const { INLINE GeomVertexArrayData *GeomVertexRewriter:: get_array_data() const { nassertr(GeomVertexWriter::get_array_data() == - GeomVertexReader::get_array_data(), NULL); + GeomVertexReader::get_array_data(), nullptr); return GeomVertexWriter::get_array_data(); } @@ -148,7 +148,7 @@ get_stride() const { INLINE Thread *GeomVertexRewriter:: get_current_thread() const { nassertr(GeomVertexWriter::get_current_thread() == - GeomVertexReader::get_current_thread(), NULL); + GeomVertexReader::get_current_thread(), nullptr); return GeomVertexWriter::get_current_thread(); } @@ -242,7 +242,7 @@ get_array() const { INLINE const GeomVertexColumn *GeomVertexRewriter:: get_column() const { nassertr(GeomVertexWriter::get_column() == - GeomVertexReader::get_column(), NULL); + GeomVertexReader::get_column(), nullptr); return GeomVertexWriter::get_column(); } diff --git a/panda/src/gobj/geomVertexRewriter.cxx b/panda/src/gobj/geomVertexRewriter.cxx index 304606a9c3..e1743ca39d 100644 --- a/panda/src/gobj/geomVertexRewriter.cxx +++ b/panda/src/gobj/geomVertexRewriter.cxx @@ -19,7 +19,7 @@ void GeomVertexRewriter:: output(ostream &out) const { const GeomVertexColumn *column = get_column(); - if (column == (GeomVertexColumn *)NULL) { + if (column == nullptr) { out << "GeomVertexRewriter()"; } else { diff --git a/panda/src/gobj/geomVertexWriter.I b/panda/src/gobj/geomVertexWriter.I index f21280c3ad..cc25e79531 100644 --- a/panda/src/gobj/geomVertexWriter.I +++ b/panda/src/gobj/geomVertexWriter.I @@ -18,7 +18,7 @@ */ INLINE GeomVertexWriter:: GeomVertexWriter(Thread *current_thread) : - _vertex_data(NULL), + _vertex_data(nullptr), _current_thread(current_thread) { initialize(); @@ -199,7 +199,7 @@ get_current_thread() const { */ INLINE bool GeomVertexWriter:: set_column(int column) { - if (_vertex_data != (GeomVertexData *)NULL) { + if (_vertex_data != nullptr) { GeomVertexDataPipelineWriter writer(_vertex_data, true, _current_thread); writer.check_array_writers(); const GeomVertexFormat *format = writer.get_format(); @@ -207,7 +207,7 @@ set_column(int column) { format->get_column(column), &writer); } - if (_array_data != (GeomVertexArrayData *)NULL) { + if (_array_data != nullptr) { return set_array_column(_array_data->get_array_format()->get_column(column)); } return false; @@ -223,7 +223,7 @@ set_column(int column) { */ INLINE bool GeomVertexWriter:: set_column(CPT_InternalName name) { - if (_vertex_data != (GeomVertexData *)NULL) { + if (_vertex_data != nullptr) { GeomVertexDataPipelineWriter writer(_vertex_data, true, _current_thread); writer.check_array_writers(); const GeomVertexFormat *format = writer.get_format(); @@ -231,7 +231,7 @@ set_column(CPT_InternalName name) { format->get_column(name), &writer); } - if (_array_data != (GeomVertexArrayData *)NULL) { + if (_array_data != nullptr) { return set_array_column(_array_data->get_array_format()->get_column(name)); } return false; @@ -251,7 +251,7 @@ clear() { */ INLINE bool GeomVertexWriter:: has_column() const { - return (_packer != (GeomVertexColumn::Packer *)NULL); + return (_packer != nullptr); } /** @@ -268,10 +268,10 @@ get_array() const { */ INLINE const GeomVertexColumn *GeomVertexWriter:: get_column() const { - if (_packer != (GeomVertexColumn::Packer *)NULL) { + if (_packer != nullptr) { return _packer->_column; } - return NULL; + return nullptr; } /** @@ -1376,10 +1376,10 @@ inc_add_pointer() { // Reset the data pointer. int write_row = get_write_row(); - if (_vertex_data != (GeomVertexData *)NULL) { + if (_vertex_data != nullptr) { // If we have a whole GeomVertexData, we must set the length of all its // arrays at once. - _handle = NULL; + _handle = nullptr; GeomVertexDataPipelineWriter writer(_vertex_data, true, _current_thread); writer.check_array_writers(); writer.set_num_rows(max(write_row + 1, writer.get_num_rows())); diff --git a/panda/src/gobj/geomVertexWriter.cxx b/panda/src/gobj/geomVertexWriter.cxx index ef05c3bc44..51e8b91bf5 100644 --- a/panda/src/gobj/geomVertexWriter.cxx +++ b/panda/src/gobj/geomVertexWriter.cxx @@ -32,28 +32,28 @@ unsigned char GeomVertexWriter::empty_buffer[100] = { 0 }; */ bool GeomVertexWriter:: set_column(int array, const GeomVertexColumn *column) { - if (_vertex_data == (GeomVertexData *)NULL && - _array_data == (GeomVertexArrayData *)NULL) { + if (_vertex_data == nullptr && + _array_data == nullptr) { return false; } - if (column == (const GeomVertexColumn *)NULL) { + if (column == nullptr) { // Clear the data type. _array = -1; - _packer = NULL; + _packer = nullptr; _stride = 0; - _pointer = NULL; - _pointer_end = NULL; + _pointer = nullptr; + _pointer_end = nullptr; return false; } - if (_vertex_data != (GeomVertexData *)NULL) { + if (_vertex_data != nullptr) { GeomVertexDataPipelineWriter writer(_vertex_data, true, _current_thread); writer.check_array_writers(); return set_vertex_column(array, column, &writer); } - if (_array_data != (GeomVertexArrayData *)NULL) { + if (_array_data != nullptr) { return set_array_column(column); } @@ -71,7 +71,7 @@ bool GeomVertexWriter:: reserve_num_rows(int num_rows) { bool result; - if (_vertex_data != (GeomVertexData *)NULL) { + if (_vertex_data != nullptr) { // If we have a whole GeomVertexData, we must set the length of all its // arrays at once. GeomVertexDataPipelineWriter writer(_vertex_data, true, _current_thread); @@ -94,7 +94,7 @@ reserve_num_rows(int num_rows) { void GeomVertexWriter:: output(ostream &out) const { const GeomVertexColumn *column = get_column(); - if (column == (GeomVertexColumn *)NULL) { + if (column == nullptr) { out << "GeomVertexWriter()"; } else { @@ -111,10 +111,10 @@ output(ostream &out) const { void GeomVertexWriter:: initialize() { _array = 0; - _packer = NULL; - _pointer_begin = NULL; - _pointer_end = NULL; - _pointer = NULL; + _packer = nullptr; + _pointer_begin = nullptr; + _pointer_end = nullptr; + _pointer = nullptr; _start_row = 0; } @@ -125,15 +125,15 @@ initialize() { bool GeomVertexWriter:: set_vertex_column(int array, const GeomVertexColumn *column, GeomVertexDataPipelineWriter *data_writer) { - if (column == (const GeomVertexColumn *)NULL) { - return set_column(0, NULL); + if (column == nullptr) { + return set_column(0, nullptr); } - nassertr(_vertex_data != (GeomVertexData *)NULL, false); + nassertr(_vertex_data != nullptr, false); #ifndef NDEBUG _array = -1; - _packer = NULL; + _packer = nullptr; nassertr(array >= 0 && array < _vertex_data->get_num_arrays(), false); #endif @@ -153,11 +153,11 @@ set_vertex_column(int array, const GeomVertexColumn *column, */ bool GeomVertexWriter:: set_array_column(const GeomVertexColumn *column) { - if (column == (const GeomVertexColumn *)NULL) { - return set_column(0, NULL); + if (column == nullptr) { + return set_column(0, nullptr); } - nassertr(_array_data != (GeomVertexArrayData *)NULL, false); + nassertr(_array_data != nullptr, false); _handle = _array_data->modify_handle(); _stride = _handle->get_array_format()->get_stride(); diff --git a/panda/src/gobj/internalName.I b/panda/src/gobj/internalName.I index d7475550e9..644ed998d3 100644 --- a/panda/src/gobj/internalName.I +++ b/panda/src/gobj/internalName.I @@ -75,8 +75,8 @@ get_basename() const { */ INLINE PT(InternalName) InternalName:: get_root() { - if (_root == (InternalName *)NULL) { - _root = new InternalName(NULL, ""); + if (_root == nullptr) { + _root = new InternalName(nullptr, ""); } return _root; } @@ -86,7 +86,7 @@ get_root() { */ INLINE PT(InternalName) InternalName:: get_error() { - if (_error == (InternalName *)NULL) { + if (_error == nullptr) { _error = InternalName::make("error"); } return _error; @@ -98,7 +98,7 @@ get_error() { */ INLINE PT(InternalName) InternalName:: get_vertex() { - if (_vertex == (InternalName *)NULL) { + if (_vertex == nullptr) { _vertex = InternalName::make("vertex"); } return _vertex; @@ -110,7 +110,7 @@ get_vertex() { */ INLINE PT(InternalName) InternalName:: get_normal() { - if (_normal == (InternalName *)NULL) { + if (_normal == nullptr) { _normal = InternalName::make("normal"); } return _normal; @@ -124,7 +124,7 @@ get_normal() { */ INLINE PT(InternalName) InternalName:: get_tangent() { - if (_tangent == (InternalName *)NULL) { + if (_tangent == nullptr) { _tangent = InternalName::make("tangent"); } return _tangent; @@ -149,7 +149,7 @@ get_tangent_name(const string &name) { */ INLINE PT(InternalName) InternalName:: get_binormal() { - if (_binormal == (InternalName *)NULL) { + if (_binormal == nullptr) { _binormal = InternalName::make("binormal"); } return _binormal; @@ -172,7 +172,7 @@ get_binormal_name(const string &name) { */ INLINE PT(InternalName) InternalName:: get_texcoord() { - if (_texcoord == (InternalName *)NULL) { + if (_texcoord == nullptr) { _texcoord = InternalName::make("texcoord"); } return _texcoord; @@ -195,7 +195,7 @@ get_texcoord_name(const string &name) { */ INLINE PT(InternalName) InternalName:: get_color() { - if (_color == (InternalName *)NULL) { + if (_color == nullptr) { _color = InternalName::make("color"); } return _color; @@ -208,7 +208,7 @@ get_color() { */ INLINE PT(InternalName) InternalName:: get_rotate() { - if (_rotate == (InternalName *)NULL) { + if (_rotate == nullptr) { _rotate = InternalName::make("rotate"); } return _rotate; @@ -221,7 +221,7 @@ get_rotate() { */ INLINE PT(InternalName) InternalName:: get_size() { - if (_size == (InternalName *)NULL) { + if (_size == nullptr) { _size = InternalName::make("size"); } return _size; @@ -235,7 +235,7 @@ get_size() { */ INLINE PT(InternalName) InternalName:: get_aspect_ratio() { - if (_aspect_ratio == (InternalName *)NULL) { + if (_aspect_ratio == nullptr) { _aspect_ratio = InternalName::make("aspect_ratio"); } return _aspect_ratio; @@ -249,7 +249,7 @@ get_aspect_ratio() { */ INLINE PT(InternalName) InternalName:: get_transform_blend() { - if (_transform_blend == (InternalName *)NULL) { + if (_transform_blend == nullptr) { _transform_blend = InternalName::make("transform_blend"); } return _transform_blend; @@ -266,7 +266,7 @@ get_transform_blend() { */ INLINE PT(InternalName) InternalName:: get_transform_weight() { - if (_transform_weight == (InternalName *)NULL) { + if (_transform_weight == nullptr) { _transform_weight = InternalName::make("transform_weight"); } return _transform_weight; @@ -282,7 +282,7 @@ get_transform_weight() { */ INLINE PT(InternalName) InternalName:: get_transform_index() { - if (_transform_index == (InternalName *)NULL) { + if (_transform_index == nullptr) { _transform_index = InternalName::make("transform_index"); } return _transform_index; @@ -312,7 +312,7 @@ get_morph(InternalName *column, const string &slider) { */ INLINE PT(InternalName) InternalName:: get_index() { - if (_index == (InternalName *)NULL) { + if (_index == nullptr) { _index = InternalName::make("index"); } return _index; @@ -324,7 +324,7 @@ get_index() { */ INLINE PT(InternalName) InternalName:: get_world() { - if (_world == (InternalName *)NULL) { + if (_world == nullptr) { _world = InternalName::make("world"); } return _world; @@ -336,7 +336,7 @@ get_world() { */ INLINE PT(InternalName) InternalName:: get_camera() { - if (_camera == (InternalName *)NULL) { + if (_camera == nullptr) { _camera = InternalName::make("camera"); } return _camera; @@ -348,7 +348,7 @@ get_camera() { */ INLINE PT(InternalName) InternalName:: get_model() { - if (_model == (InternalName *)NULL) { + if (_model == nullptr) { _model = InternalName::make("model"); } return _model; @@ -360,7 +360,7 @@ get_model() { */ INLINE PT(InternalName) InternalName:: get_view() { - if (_view == (InternalName *)NULL) { + if (_view == nullptr) { _view = InternalName::make("view"); } return _view; diff --git a/panda/src/gobj/internalName.cxx b/panda/src/gobj/internalName.cxx index dcebada06e..828b6db97a 100644 --- a/panda/src/gobj/internalName.cxx +++ b/panda/src/gobj/internalName.cxx @@ -65,7 +65,7 @@ InternalName(InternalName *parent, const string &basename) : InternalName:: ~InternalName() { #ifndef NDEBUG - if (_parent != (const InternalName *)NULL) { + if (_parent != nullptr) { // unref() should have removed us from our parent's table already. LightMutexHolder holder(_parent->_name_table_lock); NameTable::iterator ni = _parent->_name_table.find(_basename); @@ -80,7 +80,7 @@ InternalName:: */ bool InternalName:: unref() const { - if (_parent == (const InternalName *)NULL) { + if (_parent == nullptr) { // No parent; no problem. This is the root InternalName. Actually, this // probably shouldn't be destructing, but I guess it might at application // shutdown. @@ -140,7 +140,7 @@ get_name() const { if (_parent == get_root()) { return _basename; - } else if (_parent == (InternalName *)NULL) { + } else if (_parent == nullptr) { return string(); } else { @@ -156,7 +156,7 @@ join(const string &sep) const { if (_parent == get_root()) { return _basename; - } else if (_parent == (InternalName *)NULL) { + } else if (_parent == nullptr) { return string(); } else { @@ -178,7 +178,7 @@ find_ancestor(const string &basename) const { if (_basename == basename) { return 0; - } else if (_parent != (InternalName *)NULL) { + } else if (_parent != nullptr) { int index = _parent->find_ancestor(basename); if (index >= 0) { return index + 1; @@ -200,7 +200,7 @@ get_ancestor(int n) const { if (n == 0) { return this; - } else if (_parent != (InternalName *)NULL) { + } else if (_parent != nullptr) { return _parent->get_ancestor(n - 1); } else { @@ -217,7 +217,7 @@ const InternalName *InternalName:: get_top() const { test_ref_count_integrity(); - if (_parent != (InternalName *)NULL && _parent != get_root()) { + if (_parent != nullptr && _parent != get_root()) { return _parent->get_top(); } return this; @@ -236,7 +236,7 @@ get_net_basename(int n) const { } else if (n == 0) { return _basename; - } else if (_parent != (InternalName *)NULL && _parent != get_root()) { + } else if (_parent != nullptr && _parent != get_root()) { return _parent->get_net_basename(n - 1) + "." + _basename; } else { @@ -252,7 +252,7 @@ output(ostream &out) const { if (_parent == get_root()) { out << _basename; - } else if (_parent == (InternalName *)NULL) { + } else if (_parent == nullptr) { out << "(root)"; } else { diff --git a/panda/src/gobj/internalName.h b/panda/src/gobj/internalName.h index 7706723021..1c8b942a5b 100644 --- a/panda/src/gobj/internalName.h +++ b/panda/src/gobj/internalName.h @@ -196,7 +196,7 @@ typedef ConstPointerTo CPT_InternalName; #else class CPT_InternalName : public ConstPointerTo { public: - INLINE CPT_InternalName(const To *ptr = (const To *)NULL); + INLINE CPT_InternalName(const To *ptr = nullptr); INLINE CPT_InternalName(const PointerTo ©); INLINE CPT_InternalName(PointerTo &&from) noexcept; INLINE CPT_InternalName(const ConstPointerTo ©); diff --git a/panda/src/gobj/internalName_ext.cxx b/panda/src/gobj/internalName_ext.cxx index 0c157f2541..a03651dbf5 100644 --- a/panda/src/gobj/internalName_ext.cxx +++ b/panda/src/gobj/internalName_ext.cxx @@ -27,8 +27,8 @@ make(PyUnicodeObject *str) { // Not an interned string; don't bother. Py_ssize_t len = 0; const char *c_str = PyUnicode_AsUTF8AndSize((PyObject *)str, &len); - if (c_str == NULL) { - return NULL; + if (c_str == nullptr) { + return nullptr; } string name(c_str, len); diff --git a/panda/src/gobj/lens.cxx b/panda/src/gobj/lens.cxx index 8b7df0b5ac..cb7a496e97 100644 --- a/panda/src/gobj/lens.cxx +++ b/panda/src/gobj/lens.cxx @@ -41,7 +41,7 @@ Lens:: Lens(const Lens ©) : _cycler(copy._cycler) { // We don't copy the _geom_data. That's unique to each Lens. CDWriter cdata(_cycler, true); - cdata->_geom_data = NULL; + cdata->_geom_data = nullptr; } /** @@ -53,7 +53,7 @@ operator = (const Lens ©) { // We don't copy the _geom_data. That's unique to each Lens. CDWriter cdata(_cycler, true); - cdata->_geom_data = NULL; + cdata->_geom_data = nullptr; } /** @@ -577,7 +577,7 @@ make_geometry() { if (num_segments == 0) { // Can't do a frustum. cdata->_geom_data.clear(); - return (Geom *)NULL; + return nullptr; } // Now string together the line segments. @@ -648,25 +648,25 @@ make_bounds() const { // Upper left. corner.set(-1.0f, 1.0f, 0.0f); if (!do_extrude(cdata, corner, nul, ful)) { - return (BoundingVolume *)NULL; + return nullptr; } // Upper right. corner.set(1.0f, 1.0f, 0.0f); if (!do_extrude(cdata, corner, nur, fur)) { - return (BoundingVolume *)NULL; + return nullptr; } // Lower right. corner.set(1.0f, -1.0f, 0.0f); if (!do_extrude(cdata, corner, nlr, flr)) { - return (BoundingVolume *)NULL; + return nullptr; } // Lower left. corner.set(-1.0f, -1.0f, 0.0f); if (!do_extrude(cdata, corner, nll, fll)) { - return (BoundingVolume *)NULL; + return nullptr; } return new BoundingHexahedron(fll, flr, fur, ful, nll, nlr, nur, nul); @@ -1613,7 +1613,7 @@ do_define_geom_data(CData *cdata) { num_segments = lens_geom_segments; } - if (cdata->_geom_data == (GeomVertexData *)NULL) { + if (cdata->_geom_data == nullptr) { cdata->_geom_data = new GeomVertexData ("lens", GeomVertexFormat::get_v3(), Geom::UH_dynamic); diff --git a/panda/src/gobj/materialPool.cxx b/panda/src/gobj/materialPool.cxx index 22b8f9c5ee..58fec6dcbc 100644 --- a/panda/src/gobj/materialPool.cxx +++ b/panda/src/gobj/materialPool.cxx @@ -15,7 +15,7 @@ #include "config_gobj.h" #include "lightMutexHolder.h" -MaterialPool *MaterialPool::_global_ptr = (MaterialPool *)NULL; +MaterialPool *MaterialPool::_global_ptr = nullptr; /** @@ -119,7 +119,7 @@ ns_list_contents(ostream &out) const { */ MaterialPool *MaterialPool:: get_global_ptr() { - if (_global_ptr == (MaterialPool *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new MaterialPool; } return _global_ptr; diff --git a/panda/src/gobj/paramTexture.cxx b/panda/src/gobj/paramTexture.cxx index 0710f506f2..7250cab5ec 100644 --- a/panda/src/gobj/paramTexture.cxx +++ b/panda/src/gobj/paramTexture.cxx @@ -24,7 +24,7 @@ void ParamTextureSampler:: output(ostream &out) const { out << "texture "; - if (_texture != (Texture *)NULL) { + if (_texture != nullptr) { out << _texture->get_name(); } else { out << "(empty)"; @@ -99,7 +99,7 @@ void ParamTextureImage:: output(ostream &out) const { out << "texture "; - if (_texture != (Texture *)NULL) { + if (_texture != nullptr) { out << _texture->get_name(); } else { out << "(empty)"; diff --git a/panda/src/gobj/preparedGraphicsObjects.cxx b/panda/src/gobj/preparedGraphicsObjects.cxx index 8a7beb7ffe..a77a8837d7 100644 --- a/panda/src/gobj/preparedGraphicsObjects.cxx +++ b/panda/src/gobj/preparedGraphicsObjects.cxx @@ -274,7 +274,7 @@ release_texture(TextureContext *tc) { // We have to set the Texture pointer to NULL at this point, since the // Texture itself might destruct at any time after it has been released. - tc->_texture = (Texture *)NULL; + tc->_texture = nullptr; bool removed = (_prepared_textures.erase(tc) != 0); nassertv(removed); @@ -308,7 +308,7 @@ release_all_textures() { ++tci) { TextureContext *tc = (*tci); tc->_texture->clear_prepared(tc->get_view(), this); - tc->_texture = (Texture *)NULL; + tc->_texture = nullptr; _released_textures.insert(tc); } @@ -372,7 +372,7 @@ prepare_texture_now(Texture *tex, int view, GraphicsStateGuardianBase *gsg) { // them creates the context (since they're all shared anyway). TextureContext *tc = gsg->prepare_texture(tex, view); - if (tc != (TextureContext *)NULL) { + if (tc != nullptr) { bool prepared = _prepared_textures.insert(tc).second; nassertr(prepared, tc); } @@ -532,7 +532,7 @@ prepare_sampler_now(const SamplerState &sampler, GraphicsStateGuardianBase *gsg) // Ask the GSG to create a brand new SamplerContext. SamplerContext *sc = gsg->prepare_sampler(sampler); - if (sc != (SamplerContext *)NULL) { + if (sc != nullptr) { _prepared_samplers[sampler] = sc; } @@ -608,7 +608,7 @@ release_geom(GeomContext *gc) { // We have to set the Geom pointer to NULL at this point, since the Geom // itself might destruct at any time after it has been released. - gc->_geom = (Geom *)NULL; + gc->_geom = nullptr; bool removed = (_prepared_geoms.erase(gc) != 0); nassertv(removed); @@ -633,7 +633,7 @@ release_all_geoms() { ++gci) { GeomContext *gc = (*gci); gc->_geom->clear_prepared(this); - gc->_geom = (Geom *)NULL; + gc->_geom = nullptr; _released_geoms.insert(gc); } @@ -686,7 +686,7 @@ prepare_geom_now(Geom *geom, GraphicsStateGuardianBase *gsg) { // them creates the context (since they're all shared anyway). GeomContext *gc = gsg->prepare_geom(geom); - if (gc != (GeomContext *)NULL) { + if (gc != nullptr) { bool prepared = _prepared_geoms.insert(gc).second; nassertr(prepared, gc); } @@ -783,7 +783,7 @@ release_shader(ShaderContext *sc) { // We have to set the Shader pointer to NULL at this point, since the Shader // itself might destruct at any time after it has been released. - sc->_shader = (Shader *)NULL; + sc->_shader = nullptr; bool removed = (_prepared_shaders.erase(sc) != 0); nassertv(removed); @@ -808,7 +808,7 @@ release_all_shaders() { ++sci) { ShaderContext *sc = (*sci); sc->_shader->clear_prepared(this); - sc->_shader = (Shader *)NULL; + sc->_shader = nullptr; _released_shaders.insert(sc); } @@ -872,7 +872,7 @@ prepare_shader_now(Shader *se, GraphicsStateGuardianBase *gsg) { // them creates the context (since they're all shared anyway). ShaderContext *sc = gsg->prepare_shader(se); - if (sc != (ShaderContext *)NULL) { + if (sc != nullptr) { bool prepared = _prepared_shaders.insert(sc).second; nassertr(prepared, sc); } @@ -953,7 +953,7 @@ release_vertex_buffer(VertexBufferContext *vbc) { // We have to set the Data pointer to NULL at this point, since the Data // itself might destruct at any time after it has been released. - vbc->_data = (GeomVertexArrayData *)NULL; + vbc->_data = nullptr; bool removed = (_prepared_vertex_buffers.erase(vbc) != 0); nassertv(removed); @@ -986,7 +986,7 @@ release_all_vertex_buffers() { ++vbci) { VertexBufferContext *vbc = (VertexBufferContext *)(*vbci); vbc->_data->clear_prepared(this); - vbc->_data = (GeomVertexArrayData *)NULL; + vbc->_data = nullptr; _released_vertex_buffers.insert(vbc); } @@ -1060,7 +1060,7 @@ prepare_vertex_buffer_now(GeomVertexArrayData *data, GraphicsStateGuardianBase * get_cached_buffer(data_size_bytes, usage_hint, _vertex_buffer_cache, _vertex_buffer_cache_lru, _vertex_buffer_cache_size); - if (vbc != (VertexBufferContext *)NULL) { + if (vbc != nullptr) { vbc->_data = data; } else { @@ -1070,7 +1070,7 @@ prepare_vertex_buffer_now(GeomVertexArrayData *data, GraphicsStateGuardianBase * vbc = gsg->prepare_vertex_buffer(data); } - if (vbc != (VertexBufferContext *)NULL) { + if (vbc != nullptr) { bool prepared = _prepared_vertex_buffers.insert(vbc).second; nassertr(prepared, vbc); } @@ -1151,7 +1151,7 @@ release_index_buffer(IndexBufferContext *ibc) { // We have to set the Data pointer to NULL at this point, since the Data // itself might destruct at any time after it has been released. - ibc->_data = (GeomPrimitive *)NULL; + ibc->_data = nullptr; bool removed = (_prepared_index_buffers.erase(ibc) != 0); nassertv(removed); @@ -1184,7 +1184,7 @@ release_all_index_buffers() { ++ibci) { IndexBufferContext *ibc = (IndexBufferContext *)(*ibci); ibc->_data->clear_prepared(this); - ibc->_data = (GeomPrimitive *)NULL; + ibc->_data = nullptr; _released_index_buffers.insert(ibc); } @@ -1257,7 +1257,7 @@ prepare_index_buffer_now(GeomPrimitive *data, GraphicsStateGuardianBase *gsg) { get_cached_buffer(data_size_bytes, usage_hint, _index_buffer_cache, _index_buffer_cache_lru, _index_buffer_cache_size); - if (ibc != (IndexBufferContext *)NULL) { + if (ibc != nullptr) { ibc->_data = data; } else { @@ -1267,7 +1267,7 @@ prepare_index_buffer_now(GeomPrimitive *data, GraphicsStateGuardianBase *gsg) { ibc = gsg->prepare_index_buffer(data); } - if (ibc != (IndexBufferContext *)NULL) { + if (ibc != nullptr) { bool prepared = _prepared_index_buffers.insert(ibc).second; nassertr(prepared, ibc); } @@ -1416,7 +1416,7 @@ prepare_shader_buffer_now(ShaderBuffer *data, GraphicsStateGuardianBase *gsg) { // which of them creates the context (since they're all shared anyway). BufferContext *bc = gsg->prepare_shader_buffer(data); - if (bc != (BufferContext *)NULL) { + if (bc != nullptr) { bool prepared = _prepared_shader_buffers.insert(bc).second; nassertr(prepared, bc); } @@ -1742,11 +1742,11 @@ get_cached_buffer(size_t data_size_bytes, GeomEnums::UsageHint usage_hint, BufferCache::iterator bci = buffer_cache.find(key); if (bci == buffer_cache.end()) { - return NULL; + return nullptr; } BufferList &buffer_list = (*bci).second; - nassertr(!buffer_list.empty(), NULL); + nassertr(!buffer_list.empty(), nullptr); BufferContext *buffer = buffer_list.back(); buffer_list.pop_back(); diff --git a/panda/src/gobj/shader.I b/panda/src/gobj/shader.I index fcefc1e235..080fd46860 100644 --- a/panda/src/gobj/shader.I +++ b/panda/src/gobj/shader.I @@ -205,7 +205,7 @@ operator == (const ShaderCaps &other) const { */ INLINE Shader::ShaderPtrData:: ShaderPtrData() : - _ptr(NULL), + _ptr(nullptr), _type(SPT_unknown), _updated(true), _size(0) diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index 834757a4d1..4f41cf57f1 100644 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -338,7 +338,7 @@ cp_parse_coord_sys(ShaderArgInfo &p, if (fromflag) { if (word2 == "") { bind._part[0] = from_single; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; } else { if (from_double == SMO_INVALID) { cp_report_error(p, "Could not parse coordinate system name"); @@ -350,7 +350,7 @@ cp_parse_coord_sys(ShaderArgInfo &p, } else { if (word2 == "") { bind._part[1] = to_single; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; } else { if (to_double == SMO_INVALID) { cp_report_error(p, "Could not parse coordinate system name"); @@ -505,7 +505,7 @@ cp_optimize_mat_spec(ShaderMatSpec &spec) { if (spec._func == SMF_first) { spec._part[1] = SMO_INVALID; - spec._arg[1] = 0; + spec._arg[1] = nullptr; } if (spec._func == SMF_compose) { if (spec._part[1] == SMO_identity) { @@ -750,7 +750,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._part[1] = SMO_light_source_i_attrib; bind._arg[1] = InternalName::make("shadowViewMatrix"); bind._part[0] = SMO_view_to_apiview; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._index = atoi(pieces[2].c_str()); cp_optimize_mat_spec(bind); @@ -863,7 +863,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._part[1] = SMO_light_source_i_attrib; bind._arg[1] = InternalName::make("shadowViewMatrix"); bind._part[0] = SMO_view_to_apiview; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._index = atoi(pieces[2].c_str()); int next = 1; @@ -931,9 +931,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_transpose; bind._func = SMF_first; bind._part[0] = SMO_attr_material; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; } else if (pieces[1] == "color") { if (!cp_errchk_parameter_float(p,3,4)) { return false; @@ -942,9 +942,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_attr_color; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; } else if (pieces[1] == "colorscale") { if (!cp_errchk_parameter_float(p,3,4)) { return false; @@ -953,9 +953,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_attr_colorscale; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; } else if (pieces[1] == "fog") { if (!cp_errchk_parameter_float(p,3,4)) { return false; @@ -964,9 +964,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_attr_fog; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; } else if (pieces[1] == "fogcolor") { if (!cp_errchk_parameter_float(p,3,4)) { return false; @@ -975,9 +975,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_attr_fogcolor; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; } else if (pieces[1] == "ambient") { if (!cp_errchk_parameter_float(p,3,4)) { return false; @@ -986,9 +986,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_light_ambient; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; } else if (pieces[1].compare(0, 5, "light") == 0) { if (!cp_errchk_parameter_float(p,16,16)) { return false; @@ -997,9 +997,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_transpose; bind._func = SMF_first; bind._part[0] = SMO_light_source_i_packed; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._index = atoi(pieces[1].c_str() + 5); } else if (pieces[1].compare(0, 5, "lspec") == 0) { if (!cp_errchk_parameter_float(p,3,4)) { @@ -1011,7 +1011,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._part[0] = SMO_light_source_i_attrib; bind._arg[0] = InternalName::make("specular"); bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._index = atoi(pieces[1].c_str() + 5); } else { cp_report_error(p,"Unknown attr parameter."); @@ -1054,7 +1054,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._part[0] = SMO_alight_x; bind._arg[0] = InternalName::make(pieces[1]); bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; cp_optimize_mat_spec(bind); _mat_spec.push_back(bind); @@ -1076,7 +1076,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._part[0] = SMO_satten_x; bind._arg[0] = InternalName::make(pieces[1]); bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; cp_optimize_mat_spec(bind); _mat_spec.push_back(bind); @@ -1138,9 +1138,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_whole; bind._func = SMF_first; bind._part[0] = SMO_texmat_i; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._index = atoi(pieces[1].c_str()); cp_optimize_mat_spec(bind); @@ -1161,9 +1161,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_texscale_i; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._index = atoi(pieces[1].c_str()); cp_optimize_mat_spec(bind); @@ -1184,9 +1184,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_row3; bind._func = SMF_first; bind._part[0] = SMO_texcolor_i; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; bind._index = atoi(pieces[1].c_str()); cp_optimize_mat_spec(bind); @@ -1209,7 +1209,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._part[0] = SMO_plane_x; bind._arg[0] = InternalName::make(pieces[1]); bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; cp_optimize_mat_spec(bind); _mat_spec.push_back(bind); @@ -1231,7 +1231,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._part[0] = SMO_clipplane_x; bind._arg[0] = InternalName::make(pieces[1]); bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; cp_optimize_mat_spec(bind); _mat_spec.push_back(bind); @@ -1252,20 +1252,20 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._piece = SMP_row3; bind._func = SMF_first; bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; if (pieces[1] == "pixelsize") { if (!cp_errchk_parameter_float(p, 2, 2)) { return false; } bind._part[0] = SMO_pixel_size; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; } else if (pieces[1] == "windowsize") { if (!cp_errchk_parameter_float(p, 2, 2)) { return false; } bind._part[0] = SMO_window_size; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; } else if (pieces[1] == "time") { if (!cp_errchk_parameter_float(p, 1, 1)) { @@ -1273,7 +1273,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { } bind._piece = SMP_row3x1; bind._part[0] = SMO_frame_time; - bind._arg[0] = NULL; + bind._arg[0] = nullptr; } else { cp_report_error(p, "unknown system parameter"); @@ -1299,7 +1299,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { } ShaderTexSpec bind; bind._id = p._id; - bind._name = 0; + bind._name = nullptr; bind._stage = atoi(pieces[1].c_str()); bind._part = STO_stage_i; switch (p._type) { @@ -1364,7 +1364,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._part[0] = SMO_texpad_x; bind._arg[0] = InternalName::make(pieces[1]); bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; cp_optimize_mat_spec(bind); _mat_spec.push_back(bind); _mat_deps |= bind._dep[0] | bind._dep[1]; @@ -1385,7 +1385,7 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._part[0] = SMO_texpix_x; bind._arg[0] = InternalName::make(pieces[1]); bind._part[1] = SMO_identity; - bind._arg[1] = NULL; + bind._arg[1] = nullptr; cp_optimize_mat_spec(bind); _mat_spec.push_back(bind); _mat_deps |= bind._dep[0] | bind._dep[1]; @@ -1777,7 +1777,7 @@ cg_compile_entry_point(const char *entry, const ShaderCaps &caps, << "Compilation with active profile failed: " << cgGetErrorString(err) << "\n"; if (err == CG_COMPILER_ERROR) { const char *listing = cgGetLastListing(context); - if (listing != NULL) { + if (listing != nullptr) { shader_cat.debug(false) << listing; } } @@ -1792,13 +1792,13 @@ cg_compile_entry_point(const char *entry, const ShaderCaps &caps, // The active profile failed, so recompile it with the ultimate profile. prog = cgCreateProgram(context, CG_SOURCE, text.c_str(), - (CGprofile)ultimate, entry, (const char **)NULL); + (CGprofile)ultimate, entry, nullptr); // Extract the output listing. err = cgGetError(); const char *listing = cgGetLastListing(context); - if (err == CG_NO_ERROR && listing != NULL && strlen(listing) > 1) { + if (err == CG_NO_ERROR && listing != nullptr && strlen(listing) > 1) { shader_cat.warning() << "Encountered warnings during compilation of " << get_filename(type) << ":\n" << listing; @@ -1806,7 +1806,7 @@ cg_compile_entry_point(const char *entry, const ShaderCaps &caps, } else if (err == CG_COMPILER_ERROR) { shader_cat.error() << "Failed to compile Cg shader " << get_filename(type); - if (listing != NULL) { + if (listing != nullptr) { shader_cat.error(false) << ":\n" << listing; } else { shader_cat.error(false) << "!\n"; @@ -1915,7 +1915,7 @@ cg_compile_shader(const ShaderCaps &caps, CGcontext context) { CGprogram new_program; new_program = cgCreateProgram(context, CG_OBJECT, result.c_str(), (CGprofile)_cg_fprofile, "fshader", - (const char**)NULL); + nullptr); if (new_program) { cgDestroyProgram(_cg_fprogram); _cg_fprogram = new_program; @@ -2245,7 +2245,7 @@ cg_compile_for(const ShaderCaps &caps, CGcontext context, if (shader_cat.is_debug()) { const char *resource = cgGetParameterResourceName(map[id._seqno]); - if (resource != NULL) { + if (resource != nullptr) { shader_cat.debug() << "Uniform parameter " << id._name << " is bound to resource " << resource << "\n"; } @@ -2258,7 +2258,7 @@ cg_compile_for(const ShaderCaps &caps, CGcontext context, if (shader_cat.is_debug()) { const char *resource = cgGetParameterResourceName(p); - if (resource != NULL) { + if (resource != nullptr) { shader_cat.debug() << "Texture parameter " << id._name << " is bound to resource " << resource << "\n"; } @@ -2271,7 +2271,7 @@ cg_compile_for(const ShaderCaps &caps, CGcontext context, CGparameter p = cgGetNamedParameter(programs_by_type[id._type], id._name.c_str()); const char *resource = cgGetParameterResourceName(p); - if (shader_cat.is_debug() && resource != NULL) { + if (shader_cat.is_debug() && resource != nullptr) { if (cgGetParameterResource(p) == CG_GLSL_ATTRIB) { shader_cat.debug() << "Varying parameter " << id._name << " is bound to GLSL attribute " @@ -2293,7 +2293,7 @@ cg_compile_for(const ShaderCaps &caps, CGcontext context, if (shader_cat.is_debug()) { const char *resource = cgGetParameterResourceName(map[id._seqno]); - if (resource != NULL) { + if (resource != nullptr) { shader_cat.debug() << "Uniform ptr parameter " << id._name << " is bound to resource " << resource << "\n"; } @@ -2467,7 +2467,7 @@ do_read_source(string &into, const Filename &fn, BamCacheRecord *record) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); PT(VirtualFile) vf = vfs->find_file(fn, get_model_path()); - if (vf == NULL) { + if (vf == nullptr) { shader_cat.error() << "Could not find shader file: " << fn << "\n"; return false; @@ -2479,7 +2479,7 @@ do_read_source(string &into, const Filename &fn, BamCacheRecord *record) { return false; } - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(vf); } _last_modified = max(_last_modified, vf->get_timestamp()); @@ -2521,7 +2521,7 @@ r_preprocess_source(ostream &out, const Filename &fn, VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); PT(VirtualFile) vf = vfs->find_file(fn, path); - if (vf == NULL) { + if (vf == nullptr) { shader_cat.error() << "Could not find shader file: " << fn << "\n"; return false; @@ -2534,13 +2534,13 @@ r_preprocess_source(ostream &out, const Filename &fn, } istream *source = vf->open_read_file(true); - if (source == NULL) { + if (source == nullptr) { shader_cat.error() << "Could not open shader file: " << fn << "\n"; return false; } - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(vf); } _last_modified = max(_last_modified, vf->get_timestamp()); @@ -2856,7 +2856,7 @@ check_modified() const { const Filename &fn = (*it); PT(VirtualFile) vfile = vfs->get_file(fn, true); - if (vfile == (VirtualFile *)NULL || vfile->get_timestamp() > _last_modified) { + if (vfile == nullptr || vfile->get_timestamp() > _last_modified) { return true; } } @@ -3051,7 +3051,7 @@ load(const Filename &file, ShaderLanguage lang) { PT(Shader) shader = new Shader(lang); if (!shader->read(sfile)) { - return NULL; + return nullptr; } _load_table[sfile] = shader; @@ -3089,7 +3089,7 @@ load(ShaderLanguage lang, const Filename &vertex, PT(Shader) shader = new Shader(lang); if (!shader->read(sfile)) { - return NULL; + return nullptr; } _load_table[sfile] = shader; @@ -3112,7 +3112,7 @@ load_compute(ShaderLanguage lang, const Filename &fn) { if (lang != SL_GLSL) { shader_cat.error() << "Only GLSL compute shaders are currently supported.\n"; - return NULL; + return nullptr; } Filename fullpath(fn); @@ -3120,7 +3120,7 @@ load_compute(ShaderLanguage lang, const Filename &fn) { if (!vfs->resolve_filename(fullpath, get_model_path())) { shader_cat.error() << "Could not find compute shader file: " << fn << "\n"; - return NULL; + return nullptr; } ShaderFile sfile; @@ -3142,7 +3142,7 @@ load_compute(ShaderLanguage lang, const Filename &fn) { BamCache *cache = BamCache::get_global_ptr(); PT(BamCacheRecord) record = cache->lookup(fullpath, "sho"); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { if (record->has_data()) { shader_cat.info() << "Compute shader " << fn << " was found in disk cache.\n"; @@ -3154,7 +3154,7 @@ load_compute(ShaderLanguage lang, const Filename &fn) { PT(Shader) shader = new Shader(lang); if (!shader->read(sfile, record)) { - return NULL; + return nullptr; } _load_table[sfile] = shader; @@ -3182,7 +3182,7 @@ make(string body, ShaderLanguage lang) { if (lang == SL_GLSL) { shader_cat.error() << "GLSL shaders must have separate shader bodies!\n"; - return NULL; + return nullptr; } else if (lang == SL_none) { shader_cat.warning() @@ -3192,7 +3192,7 @@ make(string body, ShaderLanguage lang) { #ifndef HAVE_CG if (lang == SL_Cg) { shader_cat.error() << "Support for Cg shaders is not enabled.\n"; - return NULL; + return nullptr; } #endif @@ -3216,7 +3216,7 @@ make(string body, ShaderLanguage lang) { if (!shader->cg_analyze_shader(_default_caps)) { shader_cat.error() << "Shader encountered an error.\n"; - return NULL; + return nullptr; } } #endif @@ -3249,13 +3249,13 @@ make(ShaderLanguage lang, string vertex, string fragment, string geometry, #ifndef HAVE_CG if (lang == SL_Cg) { shader_cat.error() << "Support for Cg shaders is not enabled.\n"; - return NULL; + return nullptr; } #endif if (lang == SL_none) { shader_cat.error() << "Shader::make() requires an explicit shader language.\n"; - return NULL; + return nullptr; } ShaderFile sbody(move(vertex), move(fragment), move(geometry), @@ -3277,7 +3277,7 @@ make(ShaderLanguage lang, string vertex, string fragment, string geometry, if (!shader->cg_analyze_shader(_default_caps)) { shader_cat.error() << "Shader encountered an error.\n"; - return NULL; + return nullptr; } } #endif @@ -3297,7 +3297,7 @@ make_compute(ShaderLanguage lang, string body) { if (lang != SL_GLSL) { shader_cat.error() << "Only GLSL compute shaders are currently supported.\n"; - return NULL; + return nullptr; } ShaderFile sbody; @@ -3436,7 +3436,7 @@ release(PreparedGraphicsObjects *prepared_objects) { ci = _contexts.find(prepared_objects); if (ci != _contexts.end()) { ShaderContext *sc = (*ci).second; - if (sc != (ShaderContext *)NULL) { + if (sc != nullptr) { prepared_objects->release_shader(sc); } else { _contexts.erase(ci); @@ -3510,7 +3510,7 @@ release_all() { for (ci = temp.begin(); ci != temp.end(); ++ci) { PreparedGraphicsObjects *prepared_objects = (*ci).first; ShaderContext *sc = (*ci).second; - if (sc != (ShaderContext *)NULL) { + if (sc != nullptr) { prepared_objects->release_shader(sc); } } diff --git a/panda/src/gobj/shader.h b/panda/src/gobj/shader.h index 996ee1b7aa..07e1e8b46e 100644 --- a/panda/src/gobj/shader.h +++ b/panda/src/gobj/shader.h @@ -614,7 +614,7 @@ private: Shader(ShaderLanguage lang); - bool read(const ShaderFile &sfile, BamCacheRecord *record = NULL); + bool read(const ShaderFile &sfile, BamCacheRecord *record = nullptr); bool do_read_source(string &into, const Filename &fn, BamCacheRecord *record); bool r_preprocess_source(ostream &out, const Filename &fn, const Filename &source_dir, diff --git a/panda/src/gobj/shaderBuffer.I b/panda/src/gobj/shaderBuffer.I index fbd0b42e46..8e328e933e 100644 --- a/panda/src/gobj/shaderBuffer.I +++ b/panda/src/gobj/shaderBuffer.I @@ -58,7 +58,7 @@ get_usage_hint() const { INLINE const unsigned char *ShaderBuffer:: get_initial_data() const { if (_initial_data.empty()) { - return NULL; + return nullptr; } else { return &_initial_data[0]; } diff --git a/panda/src/gobj/shaderBuffer.cxx b/panda/src/gobj/shaderBuffer.cxx index f0b45df540..da9dc37d4d 100644 --- a/panda/src/gobj/shaderBuffer.cxx +++ b/panda/src/gobj/shaderBuffer.cxx @@ -51,7 +51,7 @@ prepare(PreparedGraphicsObjects *prepared_objects) { */ bool ShaderBuffer:: is_prepared(PreparedGraphicsObjects *prepared_objects) const { - if (_contexts == (Contexts *)NULL) { + if (_contexts == nullptr) { return false; } Contexts::const_iterator ci; @@ -76,7 +76,7 @@ is_prepared(PreparedGraphicsObjects *prepared_objects) const { BufferContext *ShaderBuffer:: prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) { - if (_contexts == (Contexts *)NULL) { + if (_contexts == nullptr) { _contexts = new Contexts; } Contexts::const_iterator ci; @@ -86,7 +86,7 @@ prepare_now(PreparedGraphicsObjects *prepared_objects, } BufferContext *vbc = prepared_objects->prepare_shader_buffer_now(this, gsg); - if (vbc != (BufferContext *)NULL) { + if (vbc != nullptr) { (*_contexts)[prepared_objects] = vbc; } return vbc; @@ -98,7 +98,7 @@ prepare_now(PreparedGraphicsObjects *prepared_objects, */ bool ShaderBuffer:: release(PreparedGraphicsObjects *prepared_objects) { - if (_contexts != (Contexts *)NULL) { + if (_contexts != nullptr) { Contexts::iterator ci; ci = _contexts->find(prepared_objects); if (ci != _contexts->end()) { @@ -120,7 +120,7 @@ int ShaderBuffer:: release_all() { int num_freed = 0; - if (_contexts != (Contexts *)NULL) { + if (_contexts != nullptr) { // We have to traverse a copy of the _contexts list, because the // PreparedGraphicsObjects object will call clear_prepared() in response // to each release_shader_buffer(), and we don't want to be modifying the @@ -137,7 +137,7 @@ release_all() { // Now that we've called release_shader_buffer() on every known context, // the _contexts list should have completely emptied itself. - nassertr(_contexts == NULL, num_freed); + nassertr(_contexts == nullptr, num_freed); } return num_freed; diff --git a/panda/src/gobj/simpleAllocator.I b/panda/src/gobj/simpleAllocator.I index e537526d8a..2129ba6681 100644 --- a/panda/src/gobj/simpleAllocator.I +++ b/panda/src/gobj/simpleAllocator.I @@ -95,7 +95,7 @@ get_contiguous() const { INLINE SimpleAllocatorBlock *SimpleAllocator:: get_first_block() const { MutexHolder holder(_lock); - return (_next == this) ? (SimpleAllocatorBlock *)NULL : (SimpleAllocatorBlock *)_next; + return (_next == this) ? nullptr : (SimpleAllocatorBlock *)_next; } /** @@ -161,7 +161,7 @@ INLINE SimpleAllocatorBlock:: */ INLINE void SimpleAllocatorBlock:: free() { - if (_allocator != (SimpleAllocator *)NULL) { + if (_allocator != nullptr) { MutexHolder holder(_allocator->_lock); do_free(); } @@ -182,7 +182,7 @@ get_allocator() const { */ INLINE size_t SimpleAllocatorBlock:: get_start() const { - nassertr(_allocator != (SimpleAllocator *)NULL, 0); + nassertr(_allocator != nullptr, 0); return _start; } @@ -192,7 +192,7 @@ get_start() const { */ INLINE size_t SimpleAllocatorBlock:: get_size() const { - nassertr(_allocator != (SimpleAllocator *)NULL, 0); + nassertr(_allocator != nullptr, 0); return _size; } @@ -201,7 +201,7 @@ get_size() const { */ INLINE bool SimpleAllocatorBlock:: is_free() const { - return (_allocator != (SimpleAllocator *)NULL); + return (_allocator != nullptr); } /** @@ -210,7 +210,7 @@ is_free() const { */ INLINE size_t SimpleAllocatorBlock:: get_max_size() const { - nassertr(_allocator != (SimpleAllocator *)NULL, 0); + nassertr(_allocator != nullptr, 0); MutexHolder holder(_allocator->_lock); return do_get_max_size(); } @@ -221,7 +221,7 @@ get_max_size() const { */ INLINE bool SimpleAllocatorBlock:: realloc(size_t size) { - nassertr(_allocator != (SimpleAllocator *)NULL, false); + nassertr(_allocator != nullptr, false); MutexHolder holder(_allocator->_lock); return do_realloc(size); } @@ -232,9 +232,9 @@ realloc(size_t size) { */ INLINE SimpleAllocatorBlock *SimpleAllocatorBlock:: get_next_block() const { - nassertr(_allocator != (SimpleAllocator *)NULL, NULL); + nassertr(_allocator != nullptr, nullptr); MutexHolder holder(_allocator->_lock); - return (_next == _allocator) ? (SimpleAllocatorBlock *)NULL : (SimpleAllocatorBlock *)_next; + return (_next == _allocator) ? nullptr : (SimpleAllocatorBlock *)_next; } /** @@ -244,13 +244,13 @@ get_next_block() const { */ INLINE void SimpleAllocatorBlock:: do_free() { - nassertv(_allocator != (SimpleAllocator *)NULL); + nassertv(_allocator != nullptr); _allocator->_total_size -= _size; LinkedListNode *prev = _prev; remove_from_list(); _allocator->mark_contiguous(prev); - _allocator = NULL; + _allocator = nullptr; } /** diff --git a/panda/src/gobj/simpleAllocator.cxx b/panda/src/gobj/simpleAllocator.cxx index ddae004ee8..5790f35428 100644 --- a/panda/src/gobj/simpleAllocator.cxx +++ b/panda/src/gobj/simpleAllocator.cxx @@ -22,7 +22,7 @@ SimpleAllocator:: if (_next != (LinkedListNode *)this) { MutexHolder holder(_lock); while (_next != (LinkedListNode *)this) { - nassertv(_next != (LinkedListNode *)NULL); + nassertv(_next != nullptr); ((SimpleAllocatorBlock *)_next)->do_free(); } } @@ -69,13 +69,13 @@ SimpleAllocatorBlock *SimpleAllocator:: do_alloc(size_t size) { if (size > _contiguous) { // Don't even bother. - return NULL; + return nullptr; } // First fit algorithm: walk through all the empty blocks until we find one // that has enough room. - SimpleAllocatorBlock *block = NULL; + SimpleAllocatorBlock *block = nullptr; size_t end = 0; size_t best = 0; if (_next != this) { @@ -89,7 +89,7 @@ do_alloc(size_t size) { size_t free_size = next->_start - end; if (size <= free_size) { SimpleAllocatorBlock *new_block = make_block(end, size); - nassertr(new_block->get_allocator() == this, NULL); + nassertr(new_block->get_allocator() == this, nullptr); new_block->insert_before(next); _total_size += size; @@ -116,7 +116,7 @@ do_alloc(size_t size) { size_t free_size = _max_size - end; if (size <= free_size) { SimpleAllocatorBlock *new_block = make_block(end, size); - nassertr(new_block->get_allocator() == this, NULL); + nassertr(new_block->get_allocator() == this, nullptr); new_block->insert_before(this); _total_size += size; @@ -143,7 +143,7 @@ do_alloc(size_t size) { } // No room for this block. - return NULL; + return nullptr; } /** @@ -169,7 +169,7 @@ changed_contiguous() { */ void SimpleAllocatorBlock:: output(ostream &out) const { - if (_allocator == (SimpleAllocator *)NULL) { + if (_allocator == nullptr) { out << "free block\n"; } else { MutexHolder holder(_allocator->_lock); diff --git a/panda/src/gobj/simpleLru.I b/panda/src/gobj/simpleLru.I index fa872c7829..5ba8f342f6 100644 --- a/panda/src/gobj/simpleLru.I +++ b/panda/src/gobj/simpleLru.I @@ -94,7 +94,7 @@ validate() { */ INLINE SimpleLruPage:: SimpleLruPage(size_t lru_size) : - _lru(NULL), + _lru(nullptr), _lru_size(lru_size) { } @@ -104,7 +104,7 @@ SimpleLruPage(size_t lru_size) : */ INLINE SimpleLruPage:: SimpleLruPage(const SimpleLruPage ©) : - _lru(NULL), + _lru(nullptr), _lru_size(copy._lru_size) { } @@ -134,10 +134,10 @@ INLINE void SimpleLruPage:: dequeue_lru() { LightMutexHolder holder(SimpleLru::_global_lock); - if (_lru != (SimpleLru *)NULL) { + if (_lru != nullptr) { remove_from_list(); _lru->_total_size -= _lru_size; - _lru = NULL; + _lru = nullptr; } } @@ -150,7 +150,7 @@ dequeue_lru() { */ INLINE void SimpleLruPage:: mark_used_lru() const { - if (_lru != (SimpleLru *)NULL) { + if (_lru != nullptr) { ((SimpleLruPage *)this)->mark_used_lru(_lru); } } @@ -179,7 +179,7 @@ get_lru_size() const { INLINE void SimpleLruPage:: set_lru_size(size_t lru_size) { LightMutexHolder holder(SimpleLru::_global_lock); - if (_lru != (SimpleLru *)NULL) { + if (_lru != nullptr) { _lru->_total_size -= _lru_size; _lru->_total_size += lru_size; _lru_size = lru_size; diff --git a/panda/src/gobj/simpleLru.cxx b/panda/src/gobj/simpleLru.cxx index 8531c321bc..b24b48146c 100644 --- a/panda/src/gobj/simpleLru.cxx +++ b/panda/src/gobj/simpleLru.cxx @@ -45,8 +45,8 @@ SimpleLru:: // explicitly evict it (that would force vertex buffers to write themselves // to disk unnecessarily). while (_next != (LinkedListNode *)this) { - nassertv(_next != (LinkedListNode *)NULL); - ((SimpleLruPage *)_next)->_lru = NULL; + nassertv(_next != nullptr); + ((SimpleLruPage *)_next)->_lru = nullptr; ((SimpleLruPage *)_next)->remove_from_list(); } #endif @@ -63,22 +63,22 @@ enqueue_lru(SimpleLru *lru) { LightMutexHolder holder(SimpleLru::_global_lock); if (_lru == lru) { - if (_lru != (SimpleLru *)NULL) { + if (_lru != nullptr) { remove_from_list(); insert_before(_lru); } return; } - if (_lru != (SimpleLru *)NULL) { + if (_lru != nullptr) { remove_from_list(); _lru->_total_size -= _lru_size; - _lru = NULL; + _lru = nullptr; } _lru = lru; - if (_lru != (SimpleLru *)NULL) { + if (_lru != nullptr) { _lru->_total_size += _lru_size; insert_before(_lru); } @@ -208,7 +208,7 @@ do_validate() { */ SimpleLruPage:: ~SimpleLruPage() { - if (_lru != NULL) { + if (_lru != nullptr) { dequeue_lru(); } } diff --git a/panda/src/gobj/sliderTable.I b/panda/src/gobj/sliderTable.I index 959c2e8651..be2d86f12f 100644 --- a/panda/src/gobj/sliderTable.I +++ b/panda/src/gobj/sliderTable.I @@ -59,7 +59,7 @@ get_num_sliders() const { */ INLINE const VertexSlider *SliderTable:: get_slider(size_t n) const { - nassertr(n < _sliders.size(), NULL); + nassertr(n < _sliders.size(), nullptr); return _sliders[n]._slider; } diff --git a/panda/src/gobj/texture.I b/panda/src/gobj/texture.I index 8f3a91a54c..17023fce5c 100644 --- a/panda/src/gobj/texture.I +++ b/panda/src/gobj/texture.I @@ -2454,6 +2454,6 @@ inc_simple_image_modified() { INLINE Texture::RamImage:: RamImage() : _page_size(0), - _pointer_image(NULL) + _pointer_image(nullptr) { } diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index d48c6a7c73..2479105093 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -546,7 +546,7 @@ read(const Filename &fullpath, const LoaderOptions &options) { cdata->inc_properties_modified(); cdata->inc_image_modified(); return do_read(cdata, fullpath, Filename(), 0, 0, 0, 0, false, false, - options, NULL); + options, nullptr); } /** @@ -566,7 +566,7 @@ read(const Filename &fullpath, const Filename &alpha_fullpath, cdata->inc_image_modified(); return do_read(cdata, fullpath, alpha_fullpath, primary_file_num_channels, alpha_file_channel, 0, 0, false, false, - options, NULL); + options, nullptr); } /** @@ -584,7 +584,7 @@ read(const Filename &fullpath, int z, int n, cdata->inc_properties_modified(); cdata->inc_image_modified(); return do_read(cdata, fullpath, Filename(), 0, 0, z, n, read_pages, read_mipmaps, - options, NULL); + options, nullptr); } /** @@ -817,7 +817,7 @@ get_aux_data(const string &key) const { if (di != _aux_data.end()) { return (*di).second; } - return NULL; + return nullptr; } /** @@ -850,30 +850,30 @@ make_from_txo(istream &in, const string &filename) { if (!din.open(in, filename)) { gobj_cat.error() << "Could not read texture object: " << filename << "\n"; - return NULL; + return nullptr; } string head; if (!din.read_header(head, _bam_header.size())) { gobj_cat.error() << filename << " is not a texture object file.\n"; - return NULL; + return nullptr; } if (head != _bam_header) { gobj_cat.error() << filename << " is not a texture object file.\n"; - return NULL; + return nullptr; } BamReader reader(&din); if (!reader.init()) { - return NULL; + return nullptr; } TypedWritable *object = reader.read_object(); - if (object != (TypedWritable *)NULL && + if (object != nullptr && object->is_exact_type(BamCacheRecord::get_class_type())) { // Here's a special case: if the first object in the file is a // BamCacheRecord, it's really a cache data file and not a true txo file; @@ -882,23 +882,23 @@ make_from_txo(istream &in, const string &filename) { object = reader.read_object(); } - if (object == (TypedWritable *)NULL) { + if (object == nullptr) { gobj_cat.error() << "Texture object " << filename << " is empty.\n"; - return NULL; + return nullptr; } else if (!object->is_of_type(Texture::get_class_type())) { gobj_cat.error() << "Texture object " << filename << " contains a " << object->get_type() << ", not a Texture.\n"; - return NULL; + return nullptr; } PT(Texture) other = DCAST(Texture, object); if (!reader.resolve()) { gobj_cat.error() << "Unable to fully resolve texture object file.\n"; - return NULL; + return nullptr; } return other; @@ -967,7 +967,7 @@ load_related(const InternalName *suffix) const { return (*ti).second; } if (cdata->_fullpath.empty()) { - return (Texture*)NULL; + return nullptr; } Filename main = cdata->_fullpath; main.set_basename_wo_extension(main.get_basename_wo_extension() + @@ -1216,7 +1216,7 @@ get_ram_mipmap_pointer(int n) const { if (n < (int)cdata->_ram_images.size()) { return cdata->_ram_images[n]._pointer_image; } - return NULL; + return nullptr; } /** @@ -1267,7 +1267,7 @@ clear_ram_mipmap_image(int n) { } cdata->_ram_images[n]._page_size = 0; cdata->_ram_images[n]._image.clear(); - cdata->_ram_images[n]._pointer_image = NULL; + cdata->_ram_images[n]._pointer_image = nullptr; } /** @@ -1277,7 +1277,7 @@ clear_ram_mipmap_image(int n) { PTA_uchar Texture:: modify_simple_ram_image() { CDWriter cdata(_cycler, true); - cdata->_simple_image_date_generated = (int32_t)time(NULL); + cdata->_simple_image_date_generated = (int32_t)time(nullptr); return cdata->_simple_ram_image._image; } @@ -1295,7 +1295,7 @@ new_simple_ram_image(int x_size, int y_size) { cdata->_simple_y_size = y_size; cdata->_simple_ram_image._image = PTA_uchar::empty_array(expected_page_size); cdata->_simple_ram_image._page_size = expected_page_size; - cdata->_simple_image_date_generated = (int32_t)time(NULL); + cdata->_simple_image_date_generated = (int32_t)time(nullptr); cdata->inc_simple_image_modified(); return cdata->_simple_ram_image._image; @@ -1381,7 +1381,7 @@ generate_simple_ram_image() { convert_from_pnmimage(image, expected_page_size, x_size, 0, 0, 0, scaled, 4, 1); do_set_simple_ram_image(cdata, image, x_size, y_size); - cdata->_simple_image_date_generated = (int32_t)time(NULL); + cdata->_simple_image_date_generated = (int32_t)time(nullptr); } /** @@ -1405,7 +1405,7 @@ peek() { return peeker; } - return NULL; + return nullptr; } /** @@ -1567,7 +1567,7 @@ release(PreparedGraphicsObjects *prepared_objects) { Contexts::iterator ci; for (ci = temp.begin(); ci != temp.end(); ++ci) { TextureContext *tc = (*ci).second; - if (tc != (TextureContext *)NULL) { + if (tc != nullptr) { prepared_objects->release_texture(tc); } } @@ -1602,7 +1602,7 @@ release_all() { Contexts::iterator ci; for (ci = temp.begin(); ci != temp.end(); ++ci) { TextureContext *tc = (*ci).second; - if (tc != (TextureContext *)NULL) { + if (tc != nullptr) { prepared_objects->release_texture(tc); } } @@ -2706,7 +2706,7 @@ adjust_size(int &x_size, int &y_size, const string &name, if (max_dimension < 0) { GraphicsStateGuardianBase *gsg = GraphicsStateGuardianBase::get_default_gsg(); - if (gsg != (GraphicsStateGuardianBase *)NULL) { + if (gsg != nullptr) { max_dimension = gsg->get_max_texture_dimension(); } } @@ -2778,7 +2778,7 @@ do_read(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpath, } bool header_only = ((options.get_texture_flags() & (LoaderOptions::TF_preload | LoaderOptions::TF_preload_simple)) == 0); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { header_only = false; } @@ -2789,21 +2789,21 @@ do_read(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpath, } if (is_txo_filename(fullpath)) { - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(fullpath); } return do_read_txo_file(cdata, fullpath); } if (is_dds_filename(fullpath)) { - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(fullpath); } return do_read_dds_file(cdata, fullpath, header_only); } if (is_ktx_filename(fullpath)) { - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(fullpath); } return do_read_ktx_file(cdata, fullpath, header_only); @@ -3013,15 +3013,15 @@ bool Texture:: do_read_one(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpath, int z, int n, int primary_file_num_channels, int alpha_file_channel, const LoaderOptions &options, bool header_only, BamCacheRecord *record) { - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { nassertr(!header_only, false); record->add_dependent_file(fullpath); } PNMImage image; PfmFile pfm; - PNMReader *image_reader = image.make_reader(fullpath, NULL, false); - if (image_reader == NULL) { + PNMReader *image_reader = image.make_reader(fullpath, nullptr, false); + if (image_reader == nullptr) { gobj_cat.error() << "Texture::read() - couldn't read: " << fullpath << endl; return false; @@ -3125,15 +3125,15 @@ do_read_one(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpa PNMImage alpha_image; if (!alpha_fullpath.empty()) { - PNMReader *alpha_image_reader = alpha_image.make_reader(alpha_fullpath, NULL, false); - if (alpha_image_reader == NULL) { + PNMReader *alpha_image_reader = alpha_image.make_reader(alpha_fullpath, nullptr, false); + if (alpha_image_reader == nullptr) { gobj_cat.error() << "Texture::read() - couldn't read: " << alpha_fullpath << endl; return false; } alpha_image.copy_header_from(*alpha_image_reader); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(alpha_fullpath); } @@ -3468,7 +3468,7 @@ do_read_txo_file(CData *cdata, const Filename &fullpath) { Filename filename = Filename::binary_filename(fullpath); PT(VirtualFile) file = vfs->get_file(filename); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { // No such file. gobj_cat.error() << "Could not find " << fullpath << "\n"; @@ -3497,7 +3497,7 @@ do_read_txo_file(CData *cdata, const Filename &fullpath) { bool Texture:: do_read_txo(CData *cdata, istream &in, const string &filename) { PT(Texture) other = make_from_txo(in, filename); - if (other == (Texture *)NULL) { + if (other == nullptr) { return false; } @@ -3523,7 +3523,7 @@ do_read_dds_file(CData *cdata, const Filename &fullpath, bool header_only) { Filename filename = Filename::binary_filename(fullpath); PT(VirtualFile) file = vfs->get_file(filename); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { // No such file. gobj_cat.error() << "Could not find " << fullpath << "\n"; @@ -3632,7 +3632,7 @@ do_read_dds(CData *cdata, istream &in, const string &filename, bool header_only) // Determine the function to use to read the DDS image. typedef PTA_uchar (*ReadDDSLevelFunc)(Texture *tex, Texture::CData *cdata, const DDSHeader &header, int n, istream &in); - ReadDDSLevelFunc func = NULL; + ReadDDSLevelFunc func = nullptr; Format format = F_rgb; ComponentType component_type = T_unsigned_byte; @@ -4173,7 +4173,7 @@ do_read_ktx_file(CData *cdata, const Filename &fullpath, bool header_only) { Filename filename = Filename::binary_filename(fullpath); PT(VirtualFile) file = vfs->get_file(filename); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { // No such file. gobj_cat.error() << "Could not find " << fullpath << "\n"; @@ -5144,7 +5144,7 @@ do_write_txo_file(const CData *cdata, const Filename &fullpath) const { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); Filename filename = Filename::binary_filename(fullpath); ostream *out = vfs->open_write_file(filename, true, true); - if (out == NULL) { + if (out == nullptr) { gobj_cat.error() << "Unable to open " << filename << "\n"; return false; @@ -5234,7 +5234,7 @@ unlocked_ensure_ram_image(bool allow_compression) { } // We need to reload. - nassertr(!_reloading, NULL); + nassertr(!_reloading, nullptr); _reloading = true; PT(Texture) tex = do_make_copy(cdata); @@ -5288,7 +5288,7 @@ unlocked_ensure_ram_image(bool allow_compression) { cdataw->_ram_image_compression = cdata_tex->_ram_image_compression; cdataw->_ram_images = cdata_tex->_ram_images; - nassertr(_reloading, NULL); + nassertr(_reloading, nullptr); _reloading = false; // We don't generally increment the cdata->_image_modified semaphore, @@ -5322,7 +5322,7 @@ do_reload_ram_image(CData *cdata, bool allow_compression) { // See if the texture can be found in the on-disk cache, if it is active. record = cache->lookup(cdata->_fullpath, "txo"); - if (record != (BamCacheRecord *)NULL && + if (record != nullptr && record->has_data()) { PT(Texture) tex = DCAST(Texture, record->get_data()); @@ -5413,7 +5413,7 @@ do_reload_ram_image(CData *cdata, bool allow_compression) { } do_read(cdata, cdata->_fullpath, cdata->_alpha_fullpath, cdata->_primary_file_num_channels, cdata->_alpha_file_channel, - z, n, cdata->_has_read_pages, cdata->_has_read_mipmaps, options, NULL); + z, n, cdata->_has_read_pages, cdata->_has_read_mipmaps, options, nullptr); if (orig_num_components == cdata->_num_components) { // Restore the original format, in case it was needlessly changed during @@ -5421,10 +5421,10 @@ do_reload_ram_image(CData *cdata, bool allow_compression) { cdata->_format = orig_format; } - if (do_has_ram_image(cdata) && record != (BamCacheRecord *)NULL) { + if (do_has_ram_image(cdata) && record != nullptr) { if (cache->get_cache_textures() || (cdata->_ram_image_compression != CM_off && cache->get_cache_compressed_textures())) { // Update the cache. - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(cdata->_fullpath); } record->set_data(this, this); @@ -5459,7 +5459,7 @@ do_make_ram_image(CData *cdata) { cdata->_ram_images.push_back(RamImage()); cdata->_ram_images[0]._page_size = do_get_expected_ram_page_size(cdata); cdata->_ram_images[0]._image = PTA_uchar::empty_array(image_size, get_class_type()); - cdata->_ram_images[0]._pointer_image = NULL; + cdata->_ram_images[0]._pointer_image = nullptr; cdata->_ram_image_compression = CM_off; if (cdata->_has_clear_color) { @@ -5502,7 +5502,7 @@ do_set_ram_image(CData *cdata, CPTA_uchar image, Texture::CompressionMode compre cdata->_ram_image_compression != compression) { cdata->_ram_images[0]._image = image.cast_non_const(); cdata->_ram_images[0]._page_size = page_size; - cdata->_ram_images[0]._pointer_image = NULL; + cdata->_ram_images[0]._pointer_image = nullptr; cdata->_ram_image_compression = compression; cdata->inc_image_modified(); } @@ -5536,7 +5536,7 @@ do_make_ram_mipmap_image(CData *cdata, int n) { size_t image_size = do_get_expected_ram_mipmap_image_size(cdata, n); cdata->_ram_images[n]._image = PTA_uchar::empty_array(image_size, get_class_type()); - cdata->_ram_images[n]._pointer_image = NULL; + cdata->_ram_images[n]._pointer_image = nullptr; cdata->_ram_images[n]._page_size = do_get_expected_ram_mipmap_page_size(cdata, n); if (cdata->_has_clear_color) { @@ -5571,7 +5571,7 @@ do_set_ram_mipmap_image(CData *cdata, int n, CPTA_uchar image, size_t page_size) if (cdata->_ram_images[n]._image != image || cdata->_ram_images[n]._page_size != page_size) { cdata->_ram_images[n]._image = image.cast_non_const(); - cdata->_ram_images[n]._pointer_image = NULL; + cdata->_ram_images[n]._pointer_image = nullptr; cdata->_ram_images[n]._page_size = page_size; cdata->inc_image_modified(); } @@ -5841,7 +5841,7 @@ do_compress_ram_image(CData *cdata, Texture::CompressionMode compression, case Texture::F_rgb16: case Texture::F_rgb32: case Texture::F_rgb10_a2: - if (gsg == NULL || gsg->get_supports_compressed_texture_format(CM_dxt1)) { + if (gsg == nullptr || gsg->get_supports_compressed_texture_format(CM_dxt1)) { compression = CM_dxt1; } else if (gsg->get_supports_compressed_texture_format(CM_dxt3)) { compression = CM_dxt3; @@ -5855,7 +5855,7 @@ do_compress_ram_image(CData *cdata, Texture::CompressionMode compression, break; case Texture::F_rgba4: - if (gsg == NULL || gsg->get_supports_compressed_texture_format(CM_dxt3)) { + if (gsg == nullptr || gsg->get_supports_compressed_texture_format(CM_dxt3)) { compression = CM_dxt3; } else if (gsg->get_supports_compressed_texture_format(CM_dxt5)) { compression = CM_dxt5; @@ -5869,7 +5869,7 @@ do_compress_ram_image(CData *cdata, Texture::CompressionMode compression, case Texture::F_rgba12: case Texture::F_rgba16: case Texture::F_rgba32: - if (gsg == NULL || gsg->get_supports_compressed_texture_format(CM_dxt5)) { + if (gsg == nullptr || gsg->get_supports_compressed_texture_format(CM_dxt5)) { compression = CM_dxt5; } else if (gsg->get_supports_compressed_texture_format(CM_etc2)) { compression = CM_etc2; @@ -5878,7 +5878,7 @@ do_compress_ram_image(CData *cdata, Texture::CompressionMode compression, case Texture::F_red: case Texture::F_rg: - if (gsg == NULL || gsg->get_supports_compressed_texture_format(CM_rgtc)) { + if (gsg == nullptr || gsg->get_supports_compressed_texture_format(CM_rgtc)) { compression = CM_rgtc; } else if (gsg->get_supports_compressed_texture_format(CM_eac)) { compression = CM_eac; @@ -7289,7 +7289,7 @@ get_ram_image_as(const string &requested_format) { // Make sure we can grab something that's uncompressed. CPTA_uchar data = do_get_uncompressed_ram_image(cdata); - if (data == NULL) { + if (data == nullptr) { gobj_cat.error() << "Couldn't find an uncompressed RAM image!\n"; return CPTA_uchar(get_class_type()); } @@ -7495,7 +7495,7 @@ do_set_simple_ram_image(CData *cdata, CPTA_uchar image, int x_size, int y_size) cdata->_simple_y_size = y_size; cdata->_simple_ram_image._image = image.cast_non_const(); cdata->_simple_ram_image._page_size = image.size(); - cdata->_simple_image_date_generated = (int32_t)time(NULL); + cdata->_simple_image_date_generated = (int32_t)time(nullptr); cdata->inc_simple_image_modified(); } @@ -7697,7 +7697,7 @@ do_generate_ram_mipmap_images(CData *cdata, bool allow_recompress) { RamImage uncompressed_image = cdata->_ram_images[0]; cdata->_ram_images.erase(cdata->_ram_images.begin()); - bool success = do_compress_ram_image(cdata, orig_compression_mode, QL_default, NULL); + bool success = do_compress_ram_image(cdata, orig_compression_mode, QL_default, nullptr); // Now restore the toplevel image. if (success) { if (gobj_cat.is_debug()) { @@ -10159,7 +10159,7 @@ make_this_from_bam(const FactoryParams ¶ms) { has_read_mipmaps = scan.get_bool(); } - Texture *me = NULL; + Texture *me = nullptr; if (has_rawdata) { // If the raw image data is included, then just load the texture directly // from the stream, and return it. In this case we return the "this" @@ -10252,7 +10252,7 @@ make_this_from_bam(const FactoryParams ¶ms) { } } - if (me != (Texture *)NULL) { + if (me != nullptr) { me->set_name(name); CDWriter cdata_me(me->_cycler, true); me->do_fillin_from(cdata_me, dummy); diff --git a/panda/src/gobj/texture.h b/panda/src/gobj/texture.h index 890710a216..7e7f5ad57f 100644 --- a/panda/src/gobj/texture.h +++ b/panda/src/gobj/texture.h @@ -279,7 +279,7 @@ PUBLISHED: BLOCKING bool read(const Filename &fullpath, const Filename &alpha_fullpath, int primary_file_num_channels, int alpha_file_channel, int z, int n, bool read_pages, bool read_mipmaps, - BamCacheRecord *record = NULL, + BamCacheRecord *record = nullptr, const LoaderOptions &options = LoaderOptions()); BLOCKING INLINE bool write(const Filename &fullpath); @@ -466,7 +466,7 @@ PUBLISHED: BLOCKING INLINE bool compress_ram_image(CompressionMode compression = CM_on, QualityLevel quality_level = QL_default, - GraphicsStateGuardianBase *gsg = NULL); + GraphicsStateGuardianBase *gsg = nullptr); BLOCKING INLINE bool uncompress_ram_image(); INLINE int get_num_ram_mipmap_images() const; diff --git a/panda/src/gobj/textureCollection.cxx b/panda/src/gobj/textureCollection.cxx index ce2eee4519..16c6a908f6 100644 --- a/panda/src/gobj/textureCollection.cxx +++ b/panda/src/gobj/textureCollection.cxx @@ -189,7 +189,7 @@ find_texture(const string &name) const { return texture; } } - return NULL; + return nullptr; } /** @@ -205,7 +205,7 @@ get_num_textures() const { */ Texture *TextureCollection:: get_texture(int index) const { - nassertr(index >= 0 && index < (int)_textures.size(), NULL); + nassertr(index >= 0 && index < (int)_textures.size(), nullptr); return _textures[index]; } @@ -216,7 +216,7 @@ get_texture(int index) const { */ Texture *TextureCollection:: operator [] (int index) const { - nassertr(index >= 0 && index < (int)_textures.size(), NULL); + nassertr(index >= 0 && index < (int)_textures.size(), nullptr); return _textures[index]; } diff --git a/panda/src/gobj/textureCollection_ext.cxx b/panda/src/gobj/textureCollection_ext.cxx index de104e775c..233249ee6f 100644 --- a/panda/src/gobj/textureCollection_ext.cxx +++ b/panda/src/gobj/textureCollection_ext.cxx @@ -27,7 +27,7 @@ extern struct Dtool_PyTypedObject Dtool_Texture; void Extension:: __init__(PyObject *self, PyObject *sequence) { PyObject *fast = PySequence_Fast(sequence, "TextureCollection constructor requires a sequence"); - if (fast == NULL) { + if (fast == nullptr) { return; } @@ -36,13 +36,13 @@ __init__(PyObject *self, PyObject *sequence) { for (int i = 0; i < size; ++i) { PyObject *item = PySequence_Fast_GET_ITEM(fast, i); - if (item == NULL) { + if (item == nullptr) { return; } Texture *tex; DTOOL_Call_ExtractThisPointerForType(item, &Dtool_Texture, (void **)&tex); - if (tex == (Texture *)NULL) { + if (tex == nullptr) { // Unable to add item--probably it wasn't of the appropriate type. ostringstream stream; stream << "Element " << i << " in sequence passed to TextureCollection constructor is not a Texture"; @@ -72,8 +72,8 @@ __reduce__(PyObject *self) const { // necessary to reconstruct this object. PyObject *this_class = PyObject_Type(self); - if (this_class == NULL) { - return NULL; + if (this_class == nullptr) { + return nullptr; } // Since a TextureCollection is itself an iterator, we can simply pass it as diff --git a/panda/src/gobj/texturePool.I b/panda/src/gobj/texturePool.I index 499ab04a83..d8b1e96c9d 100644 --- a/panda/src/gobj/texturePool.I +++ b/panda/src/gobj/texturePool.I @@ -30,7 +30,7 @@ has_texture(const Filename &filename) { */ INLINE bool TexturePool:: verify_texture(const Filename &filename) { - return load_texture(filename) != (Texture *)NULL; + return load_texture(filename) != nullptr; } /** diff --git a/panda/src/gobj/texturePool.cxx b/panda/src/gobj/texturePool.cxx index 6b4c0a5168..1b39a24273 100644 --- a/panda/src/gobj/texturePool.cxx +++ b/panda/src/gobj/texturePool.cxx @@ -90,14 +90,14 @@ get_texture_type(const string &extension) const { // Check the PNM type registry. PNMFileTypeRegistry *pnm_reg = PNMFileTypeRegistry::get_global_ptr(); PNMFileType *type = pnm_reg->get_type_from_extension(c); - if (type != (PNMFileType *)NULL || c == "txo" || c == "dds" || c == "ktx") { + if (type != nullptr || c == "txo" || c == "dds" || c == "ktx") { // This is a known image type; create an ordinary Texture. ((TexturePool *)this)->_type_registry[c] = Texture::make_texture; return Texture::make_texture; } // This is an unknown texture type. - return NULL; + return nullptr; } /** @@ -124,7 +124,7 @@ write_texture_types(ostream &out, int indent_level) const { string extension = (*ti).first; MakeTextureFunc *func = (*ti).second; - if (pnm_reg->get_type_from_extension(extension) == NULL) { + if (pnm_reg->get_type_from_extension(extension) == nullptr) { PT(Texture) tex = func(); string name = tex->get_type().get_name(); indent(out, indent_level) << name; @@ -140,7 +140,7 @@ write_texture_types(ostream &out, int indent_level) const { */ TexturePool *TexturePool:: get_global_ptr() { - if (_global_ptr == (TexturePool *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new TexturePool; // We have to call this here, not in the constructor, so that the @@ -221,7 +221,7 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, try_load_cache(tex, cache, filename, record, compressed_cache_record, options); - if (tex == (Texture *)NULL) { + if (tex == nullptr) { // The texture was neither in the pool, nor found in the on-disk cache; it // needs to be loaded from its source image(s). gobj_cat.info() @@ -236,11 +236,11 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, filename.set_binary(); PT(VirtualFile) file = vfs->get_file(filename); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { // No such file. gobj_cat.error() << "Could not find " << filename << "\n"; - return NULL; + return nullptr; } if (gobj_cat.is_debug()) { @@ -252,8 +252,8 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, tex = Texture::make_from_txo(*in, filename); vfs->close_read_file(in); - if (tex == (Texture *)NULL) { - return NULL; + if (tex == nullptr) { + return nullptr; } tex->set_fullpath(filename); tex->clear_alpha_fullpath(); @@ -266,7 +266,7 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, 0, 0, false, read_mipmaps, record, options)) { // This texture was not found or could not be read. report_texture_unreadable(filename); - return NULL; + return nullptr; } } @@ -274,7 +274,7 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, tex->generate_simple_ram_image(); } - store_record = (record != (BamCacheRecord *)NULL); + store_record = (record != nullptr); } if (cache->get_cache_compressed_textures() && tex->has_compression()) { @@ -298,7 +298,7 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, } // Set the original filename, before we searched along the path. - nassertr(tex != (Texture *)NULL, NULL); + nassertr(tex != nullptr, nullptr); tex->set_filename(orig_filename); tex->set_fullpath(filename); tex->_texture_pool_key = filename; @@ -384,7 +384,7 @@ ns_load_texture(const Filename &orig_filename, try_load_cache(tex, cache, filename, record, compressed_cache_record, options); - if (tex == (Texture *)NULL) { + if (tex == nullptr) { // The texture was neither in the pool, nor found in the on-disk cache; it // needs to be loaded from its source image(s). gobj_cat.info() @@ -392,18 +392,18 @@ ns_load_texture(const Filename &orig_filename, << alpha_filename << endl; tex = ns_make_texture(filename.get_extension()); if (!tex->read(filename, alpha_filename, primary_file_num_channels, - alpha_file_channel, 0, 0, false, read_mipmaps, NULL, + alpha_file_channel, 0, 0, false, read_mipmaps, nullptr, options)) { // This texture was not found or could not be read. report_texture_unreadable(filename); - return NULL; + return nullptr; } if (options.get_texture_flags() & LoaderOptions::TF_preload_simple) { tex->generate_simple_ram_image(); } - store_record = (record != (BamCacheRecord *)NULL); + store_record = (record != nullptr); } if (cache->get_cache_compressed_textures() && tex->has_compression()) { @@ -427,7 +427,7 @@ ns_load_texture(const Filename &orig_filename, } // Set the original filenames, before we searched along the path. - nassertr(tex != (Texture *)NULL, NULL); + nassertr(tex != nullptr, nullptr); tex->set_filename(orig_filename); tex->set_fullpath(filename); tex->set_alpha_filename(orig_alpha_filename); @@ -502,7 +502,7 @@ ns_load_3d_texture(const Filename &filename_pattern, try_load_cache(tex, cache, filename, record, compressed_cache_record, options); - if (tex == (Texture *)NULL || + if (tex == nullptr || tex->get_texture_type() != Texture::TT_3d_texture) { // The texture was neither in the pool, nor found in the on-disk cache; it // needs to be loaded from its source image(s). @@ -513,9 +513,9 @@ ns_load_3d_texture(const Filename &filename_pattern, if (!tex->read(filename, 0, 0, true, read_mipmaps, options)) { // This texture was not found or could not be read. report_texture_unreadable(filename); - return NULL; + return nullptr; } - store_record = (record != (BamCacheRecord *)NULL); + store_record = (record != nullptr); } if (cache->get_cache_compressed_textures() && tex->has_compression()) { @@ -539,7 +539,7 @@ ns_load_3d_texture(const Filename &filename_pattern, } // Set the original filename, before we searched along the path. - nassertr(tex != (Texture *)NULL, NULL); + nassertr(tex != nullptr, nullptr); tex->set_filename(filename_pattern); tex->set_fullpath(filename); tex->_texture_pool_key = filename; @@ -606,7 +606,7 @@ ns_load_2d_texture_array(const Filename &filename_pattern, try_load_cache(tex, cache, filename, record, compressed_cache_record, options); - if (tex == (Texture *)NULL || + if (tex == nullptr || tex->get_texture_type() != Texture::TT_2d_texture_array) { // The texture was neither in the pool, nor found in the on-disk cache; it // needs to be loaded from its source image(s). @@ -617,9 +617,9 @@ ns_load_2d_texture_array(const Filename &filename_pattern, if (!tex->read(filename, 0, 0, true, read_mipmaps, options)) { // This texture was not found or could not be read. report_texture_unreadable(filename); - return NULL; + return nullptr; } - store_record = (record != (BamCacheRecord *)NULL); + store_record = (record != nullptr); } if (cache->get_cache_compressed_textures() && tex->has_compression()) { @@ -643,7 +643,7 @@ ns_load_2d_texture_array(const Filename &filename_pattern, } // Set the original filename, before we searched along the path. - nassertr(tex != (Texture *)NULL, NULL); + nassertr(tex != nullptr, nullptr); tex->set_filename(filename_pattern); tex->set_fullpath(filename); tex->_texture_pool_key = unique_filename; @@ -705,7 +705,7 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, try_load_cache(tex, cache, filename, record, compressed_cache_record, options); - if (tex == (Texture *)NULL || + if (tex == nullptr || tex->get_texture_type() != Texture::TT_cube_map) { // The texture was neither in the pool, nor found in the on-disk cache; it // needs to be loaded from its source image(s). @@ -716,9 +716,9 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, if (!tex->read(filename, 0, 0, true, read_mipmaps, options)) { // This texture was not found or could not be read. report_texture_unreadable(filename); - return NULL; + return nullptr; } - store_record = (record != (BamCacheRecord *)NULL); + store_record = (record != nullptr); } if (cache->get_cache_compressed_textures() && tex->has_compression()) { @@ -742,7 +742,7 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, } // Set the original filename, before we searched along the path. - nassertr(tex != (Texture *)NULL, NULL); + nassertr(tex != nullptr, nullptr); tex->set_filename(filename_pattern); tex->set_fullpath(filename); tex->_texture_pool_key = filename; @@ -778,7 +778,7 @@ Texture *TexturePool:: ns_get_normalization_cube_map(int size) { MutexHolder holder(_lock); - if (_normalization_cube_map == (Texture *)NULL) { + if (_normalization_cube_map == nullptr) { _normalization_cube_map = new Texture("normalization_cube_map"); } if (_normalization_cube_map->get_x_size() < size || @@ -796,7 +796,7 @@ Texture *TexturePool:: ns_get_alpha_scale_map() { MutexHolder holder(_lock); - if (_alpha_scale_map == (Texture *)NULL) { + if (_alpha_scale_map == nullptr) { _alpha_scale_map = new Texture("alpha_scale_map"); _alpha_scale_map->generate_alpha_scale_map(); } @@ -860,7 +860,7 @@ ns_release_all_textures() { } _textures.clear(); - _normalization_cube_map = NULL; + _normalization_cube_map = nullptr; // Blow away the cache of resolved relative filenames. _relpath_lookup.clear(); @@ -893,14 +893,14 @@ ns_garbage_collect() { _textures.swap(new_set); - if (_normalization_cube_map != (Texture *)NULL && + if (_normalization_cube_map != nullptr && _normalization_cube_map->get_ref_count() == 1) { if (gobj_cat.is_debug()) { gobj_cat.debug() << "Releasing normalization cube map\n"; } ++num_released; - _normalization_cube_map = NULL; + _normalization_cube_map = nullptr; } return num_released; @@ -957,7 +957,7 @@ ns_find_texture(const string &name) const { } } - return NULL; + return nullptr; } /** @@ -988,7 +988,7 @@ ns_find_all_textures(const string &name) const { PT(Texture) TexturePool:: ns_make_texture(const string &extension) const { MakeTextureFunc *func = get_texture_type(extension); - if (func != NULL) { + if (func != nullptr) { return func(); } @@ -1034,7 +1034,7 @@ void TexturePool:: try_load_cache(PT(Texture) &tex, BamCache *cache, const Filename &filename, PT(BamCacheRecord) &record, bool &compressed_cache_record, const LoaderOptions &options) { - if (tex == (Texture *)NULL) { + if (tex == nullptr) { // The texture was not supplied by a texture filter. See if it can be // found in the on-disk cache, if it is active. if ((cache->get_cache_textures() || cache->get_cache_compressed_textures()) && !textures_header_only) { @@ -1049,7 +1049,7 @@ try_load_cache(PT(Texture) &tex, BamCache *cache, const Filename &filename, dummy.clear(); record = cache->lookup(filename, "txo"); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { if (record->has_data()) { tex = DCAST(Texture, record->get_data()); compressed_cache_record = (tex->get_ram_image_compression() != Texture::CM_off); @@ -1063,8 +1063,8 @@ try_load_cache(PT(Texture) &tex, BamCache *cache, const Filename &filename, gobj_cat.debug() << "Not caching uncompressed texture " << *tex << "\n"; } - tex = NULL; - record = NULL; + tex = nullptr; + record = nullptr; } else if (x_size != tex->get_x_size() || y_size != tex->get_y_size()) { @@ -1079,7 +1079,7 @@ try_load_cache(PT(Texture) &tex, BamCache *cache, const Filename &filename, << " instead of " << x_size << " x " << y_size << "; dropping cache.\n"; } - tex = NULL; + tex = nullptr; } else if (!tex->has_compression() && tex->get_ram_image_compression() != Texture::CM_off) { // This texture shouldn't be compressed, but it is. Go reload it. @@ -1088,7 +1088,7 @@ try_load_cache(PT(Texture) &tex, BamCache *cache, const Filename &filename, << "Cached texture " << *tex << " is compressed in cache; dropping cache.\n"; } - tex = NULL; + tex = nullptr; } else { gobj_cat.info() @@ -1127,7 +1127,7 @@ try_load_cache(PT(Texture) &tex, BamCache *cache, const Filename &filename, gobj_cat.debug() << "Not caching uncompressed texture\n"; } - record = NULL; + record = nullptr; } } } @@ -1170,7 +1170,7 @@ report_texture_unreadable(const Filename &filename) const { // Maybe the filename extension is unknown. MakeTextureFunc *func = get_texture_type(filename.get_extension()); - if (func == (MakeTextureFunc *)NULL) { + if (func == nullptr) { gobj_cat.error() << "Texture extension \"" << filename.get_extension() << "\" is unknown. Supported texture types:\n"; @@ -1199,7 +1199,7 @@ pre_load(const Filename &orig_filename, const Filename &orig_alpha_filename, tex = (*fi)->pre_load(orig_filename, orig_alpha_filename, primary_file_num_channels, alpha_file_channel, read_mipmaps, options); - if (tex != (Texture *)NULL) { + if (tex != nullptr) { return tex; } } @@ -1247,7 +1247,7 @@ load_filters() { gobj_cat->info() << "loading texture filter: " << dlname.to_os_specific() << endl; void *tmp = load_dso(get_plugin_path().get_value(), dlname); - if (tmp == (void *)NULL) { + if (tmp == nullptr) { gobj_cat.info() << "Unable to load: " << load_dso_error() << endl; } diff --git a/panda/src/gobj/texturePoolFilter.cxx b/panda/src/gobj/texturePoolFilter.cxx index 6d752dd7c7..f0b98c877e 100644 --- a/panda/src/gobj/texturePoolFilter.cxx +++ b/panda/src/gobj/texturePoolFilter.cxx @@ -32,7 +32,7 @@ TexturePoolFilter:: PT(Texture) TexturePoolFilter:: pre_load(const Filename &, const Filename &, int, int, bool, const LoaderOptions &) { - return NULL; + return nullptr; } /** diff --git a/panda/src/gobj/textureReloadRequest.I b/panda/src/gobj/textureReloadRequest.I index d17bdc72b4..a4e4e6fd7b 100644 --- a/panda/src/gobj/textureReloadRequest.I +++ b/panda/src/gobj/textureReloadRequest.I @@ -24,8 +24,8 @@ TextureReloadRequest(const string &name, _texture(texture), _allow_compressed(allow_compressed) { - nassertv(_pgo != (PreparedGraphicsObjects *)NULL); - nassertv(_texture != (Texture *)NULL); + nassertv(_pgo != nullptr); + nassertv(_texture != nullptr); } /** diff --git a/panda/src/gobj/textureStage.I b/panda/src/gobj/textureStage.I index 17034231a3..dd8e24bce2 100644 --- a/panda/src/gobj/textureStage.I +++ b/panda/src/gobj/textureStage.I @@ -139,7 +139,7 @@ get_texcoord_name() const { */ INLINE InternalName *TextureStage:: get_tangent_name() const { - if (_texcoord_name->get_parent() == NULL) { + if (_texcoord_name->get_parent() == nullptr) { return InternalName::get_tangent(); } else { return InternalName::get_tangent_name(_texcoord_name->get_basename()); @@ -152,7 +152,7 @@ get_tangent_name() const { */ INLINE InternalName *TextureStage:: get_binormal_name() const { - if (_texcoord_name->get_parent() == NULL) { + if (_texcoord_name->get_parent() == nullptr) { return InternalName::get_binormal(); } else { return InternalName::get_binormal_name(_texcoord_name->get_basename()); @@ -659,7 +659,7 @@ operator < (const TextureStage &other) const { */ INLINE TextureStage *TextureStage:: get_default() { - if (_default_stage == (TextureStage *)NULL) { + if (_default_stage == nullptr) { _default_stage = new TextureStage("default"); } return _default_stage; diff --git a/panda/src/gobj/textureStagePool.cxx b/panda/src/gobj/textureStagePool.cxx index 2d9b33a036..f47addd52b 100644 --- a/panda/src/gobj/textureStagePool.cxx +++ b/panda/src/gobj/textureStagePool.cxx @@ -17,7 +17,7 @@ #include "configVariableEnum.h" #include "string_utils.h" -TextureStagePool *TextureStagePool::_global_ptr = (TextureStagePool *)NULL; +TextureStagePool *TextureStagePool::_global_ptr = nullptr; /** @@ -86,7 +86,7 @@ ns_get_stage(TextureStage *temp) { } } - return NULL; + return nullptr; } /** @@ -258,7 +258,7 @@ ns_list_contents(ostream &out) const { */ TextureStagePool *TextureStagePool:: get_global_ptr() { - if (_global_ptr == (TextureStagePool *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new TextureStagePool; } return _global_ptr; diff --git a/panda/src/gobj/transformBlend.I b/panda/src/gobj/transformBlend.I index 936ca57cc4..aed8e95ca7 100644 --- a/panda/src/gobj/transformBlend.I +++ b/panda/src/gobj/transformBlend.I @@ -128,7 +128,7 @@ get_num_transforms() const { */ INLINE const VertexTransform *TransformBlend:: get_transform(size_t n) const { - nassertr(n < _entries.size(), NULL); + nassertr(n < _entries.size(), nullptr); return _entries[n]._transform; } diff --git a/panda/src/gobj/transformTable.I b/panda/src/gobj/transformTable.I index ce8fe2d196..acf7aa95fb 100644 --- a/panda/src/gobj/transformTable.I +++ b/panda/src/gobj/transformTable.I @@ -59,7 +59,7 @@ get_num_transforms() const { */ INLINE const VertexTransform *TransformTable:: get_transform(size_t n) const { - nassertr(n < _transforms.size(), NULL); + nassertr(n < _transforms.size(), nullptr); return _transforms[n]; } diff --git a/panda/src/gobj/transformTable.cxx b/panda/src/gobj/transformTable.cxx index 73d0665079..df66f7a696 100644 --- a/panda/src/gobj/transformTable.cxx +++ b/panda/src/gobj/transformTable.cxx @@ -221,7 +221,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _transforms.reserve(num_transforms); for (size_t i = 0; i < num_transforms; ++i) { manager->read_pointer(scan); - _transforms.push_back(NULL); + _transforms.push_back(nullptr); } manager->read_cdata(scan, _cycler); diff --git a/panda/src/gobj/vertexDataBlock.I b/panda/src/gobj/vertexDataBlock.I index 61aa8e3a14..7660bd315f 100644 --- a/panda/src/gobj/vertexDataBlock.I +++ b/panda/src/gobj/vertexDataBlock.I @@ -38,10 +38,10 @@ get_page() const { */ INLINE unsigned char *VertexDataBlock:: get_pointer(bool force) const { - nassertr(get_page() != (VertexDataPage *)NULL, NULL); + nassertr(get_page() != nullptr, nullptr); unsigned char *page_data = get_page()->get_page_data(force); - if (page_data == (unsigned char *)NULL) { - return NULL; + if (page_data == nullptr) { + return nullptr; } else { return page_data + get_start(); } diff --git a/panda/src/gobj/vertexDataBook.cxx b/panda/src/gobj/vertexDataBook.cxx index 5be3a0718a..555033da3c 100644 --- a/panda/src/gobj/vertexDataBook.cxx +++ b/panda/src/gobj/vertexDataBook.cxx @@ -141,7 +141,7 @@ do_alloc(size_t size) { // This is why we've already computed pnext. VertexDataBlock *block = page->do_alloc(size); - if (block != (VertexDataBlock *)NULL) { + if (block != nullptr) { // This page worked. return block; } diff --git a/panda/src/gobj/vertexDataBuffer.I b/panda/src/gobj/vertexDataBuffer.I index 3bc1f85b80..f3770d3b21 100644 --- a/panda/src/gobj/vertexDataBuffer.I +++ b/panda/src/gobj/vertexDataBuffer.I @@ -16,7 +16,7 @@ */ INLINE VertexDataBuffer:: VertexDataBuffer() : - _resident_data(NULL), + _resident_data(nullptr), _size(0), _reserved_size(0) { @@ -27,7 +27,7 @@ VertexDataBuffer() : */ INLINE VertexDataBuffer:: VertexDataBuffer(size_t size) : - _resident_data(NULL), + _resident_data(nullptr), _size(0), _reserved_size(0) { @@ -40,7 +40,7 @@ VertexDataBuffer(size_t size) : */ INLINE VertexDataBuffer:: VertexDataBuffer(const VertexDataBuffer ©) : - _resident_data(NULL), + _resident_data(nullptr), _size(0), _reserved_size(0) { @@ -68,11 +68,11 @@ get_read_pointer(bool force) const { LightMutexHolder holder(_lock); const unsigned char *ptr; - if (_resident_data != (unsigned char *)NULL || _size == 0) { + if (_resident_data != nullptr || _size == 0) { ptr = _resident_data; } else { - nassertr(_block != (VertexDataBlock *)NULL, NULL); - nassertr(_reserved_size >= _size, NULL); + nassertr(_block != nullptr, nullptr); + nassertr(_reserved_size >= _size, nullptr); // We don't necessarily need to page the buffer all the way into independent // status; it's sufficient just to return the block's pointer, which will @@ -92,10 +92,10 @@ INLINE unsigned char *VertexDataBuffer:: get_write_pointer() { LightMutexHolder holder(_lock); - if (_resident_data == (unsigned char *)NULL && _reserved_size != 0) { + if (_resident_data == nullptr && _reserved_size != 0) { do_page_in(); } - nassertr(_reserved_size >= _size, NULL); + nassertr(_reserved_size >= _size, nullptr); #ifdef _DEBUG assert(((uintptr_t)_resident_data % MEMORY_HOOK_ALIGNMENT) == 0); #endif @@ -133,7 +133,7 @@ set_size(size_t size) { nassertv(size <= _reserved_size); if (size != _size) { - if (_resident_data == (unsigned char *)NULL && _reserved_size != 0) { + if (_resident_data == nullptr && _reserved_size != 0) { do_page_in(); } diff --git a/panda/src/gobj/vertexDataBuffer.cxx b/panda/src/gobj/vertexDataBuffer.cxx index 19f50b3013..a891811091 100644 --- a/panda/src/gobj/vertexDataBuffer.cxx +++ b/panda/src/gobj/vertexDataBuffer.cxx @@ -25,12 +25,12 @@ operator = (const VertexDataBuffer ©) { LightMutexHolder holder(_lock); LightMutexHolder holder2(copy._lock); - if (_resident_data != (unsigned char *)NULL) { + if (_resident_data != nullptr) { nassertv(_reserved_size != 0); get_class_type().deallocate_array(_resident_data); - _resident_data = NULL; + _resident_data = nullptr; } - if (copy._resident_data != (unsigned char *)NULL && copy._size != 0) { + if (copy._resident_data != nullptr && copy._size != 0) { // We only allocate _size bytes, not the full _reserved_size allocated by // the original copy. _resident_data = (unsigned char *)get_class_type().allocate_array(copy._size); @@ -87,18 +87,18 @@ do_clean_realloc(size_t reserved_size) { } // Page in if we're currently paged out. - if (_reserved_size != 0 && _resident_data == (unsigned char *)NULL) { + if (_reserved_size != 0 && _resident_data == nullptr) { do_page_in(); } if (_reserved_size == 0) { - nassertv(_resident_data == (unsigned char *)NULL); + nassertv(_resident_data == nullptr); _resident_data = (unsigned char *)get_class_type().allocate_array(reserved_size); } else { - nassertv(_resident_data != (unsigned char *)NULL); + nassertv(_resident_data != nullptr); _resident_data = (unsigned char *)get_class_type().reallocate_array(_resident_data, reserved_size); } - nassertv(_resident_data != (unsigned char *)NULL); + nassertv(_resident_data != nullptr); _reserved_size = reserved_size; } @@ -113,25 +113,25 @@ do_clean_realloc(size_t reserved_size) { */ void VertexDataBuffer:: do_unclean_realloc(size_t reserved_size) { - if (reserved_size != _reserved_size || _resident_data == (unsigned char *)NULL) { + if (reserved_size != _reserved_size || _resident_data == nullptr) { if (gobj_cat.is_debug()) { gobj_cat.debug() << this << ".unclean_realloc(" << reserved_size << ")\n"; } // If we're paged out, discard the page. - _block = NULL; + _block = nullptr; - if (_resident_data != (unsigned char *)NULL) { + if (_resident_data != nullptr) { nassertv(_reserved_size != 0); get_class_type().deallocate_array(_resident_data); - _resident_data = NULL; + _resident_data = nullptr; _reserved_size = 0; } if (reserved_size != 0) { - nassertv(_resident_data == (unsigned char *)NULL); + nassertv(_resident_data == nullptr); _resident_data = (unsigned char *)get_class_type().allocate_array(reserved_size); } @@ -151,30 +151,30 @@ do_unclean_realloc(size_t reserved_size) { */ void VertexDataBuffer:: do_page_out(VertexDataBook &book) { - if (_block != (VertexDataBlock *)NULL || _reserved_size == 0) { + if (_block != nullptr || _reserved_size == 0) { // We're already paged out. return; } - nassertv(_resident_data != (unsigned char *)NULL); + nassertv(_resident_data != nullptr); if (_size == 0) { // It's an empty buffer. Just deallocate it; don't bother to create a // block. get_class_type().deallocate_array(_resident_data); - _resident_data = NULL; + _resident_data = nullptr; _reserved_size = 0; } else { // It's a nonempty buffer, so write _size bytes (but not the full // _reserved_size bytes) to a block. _block = book.alloc(_size); - nassertv(_block != (VertexDataBlock *)NULL); + nassertv(_block != nullptr); unsigned char *pointer = _block->get_pointer(true); - nassertv(pointer != (unsigned char *)NULL); + nassertv(pointer != nullptr); memcpy(pointer, _resident_data, _size); get_class_type().deallocate_array(_resident_data); - _resident_data = NULL; + _resident_data = nullptr; _reserved_size = _size; } @@ -189,16 +189,16 @@ do_page_out(VertexDataBook &book) { */ void VertexDataBuffer:: do_page_in() { - if (_resident_data != (unsigned char *)NULL || _reserved_size == 0) { + if (_resident_data != nullptr || _reserved_size == 0) { // We're already paged in. return; } - nassertv(_block != (VertexDataBlock *)NULL); + nassertv(_block != nullptr); nassertv(_reserved_size == _size); _resident_data = (unsigned char *)get_class_type().allocate_array(_size); - nassertv(_resident_data != (unsigned char *)NULL); + nassertv(_resident_data != nullptr); memcpy(_resident_data, _block->get_pointer(true), _size); } diff --git a/panda/src/gobj/vertexDataPage.I b/panda/src/gobj/vertexDataPage.I index 0dd8109adb..d5dc44be9e 100644 --- a/panda/src/gobj/vertexDataPage.I +++ b/panda/src/gobj/vertexDataPage.I @@ -81,7 +81,7 @@ get_book() const { */ INLINE SimpleLru *VertexDataPage:: get_global_lru(RamClass rclass) { - nassertr(rclass >= 0 && rclass < RC_end_of_list, NULL); + nassertr(rclass >= 0 && rclass < RC_end_of_list, nullptr); return _global_lru[rclass]; } @@ -100,7 +100,7 @@ get_pending_lru() { */ INLINE VertexDataSaveFile *VertexDataPage:: get_save_file() { - if (_save_file == (VertexDataSaveFile *)NULL) { + if (_save_file == nullptr) { make_save_file(); } return _save_file; @@ -126,7 +126,7 @@ save_to_disk() { INLINE int VertexDataPage:: get_num_threads() { MutexHolder holder(_tlock); - if (_thread_mgr == (PageThreadManager *)NULL) { + if (_thread_mgr == nullptr) { return 0; } return _thread_mgr->get_num_threads(); @@ -139,7 +139,7 @@ get_num_threads() { INLINE int VertexDataPage:: get_num_pending_reads() { MutexHolder holder(_tlock); - if (_thread_mgr == (PageThreadManager *)NULL) { + if (_thread_mgr == nullptr) { return 0; } return _thread_mgr->get_num_pending_reads(); @@ -152,7 +152,7 @@ get_num_pending_reads() { INLINE int VertexDataPage:: get_num_pending_writes() { MutexHolder holder(_tlock); - if (_thread_mgr == (PageThreadManager *)NULL) { + if (_thread_mgr == nullptr) { return 0; } return _thread_mgr->get_num_pending_writes(); @@ -175,7 +175,7 @@ get_page_data(bool force) { } else { request_ram_class(RC_resident); if (_ram_class != RC_resident) { - return NULL; + return nullptr; } } } diff --git a/panda/src/gobj/vertexDataPage.cxx b/panda/src/gobj/vertexDataPage.cxx index ada598b9df..e7adb80d33 100644 --- a/panda/src/gobj/vertexDataPage.cxx +++ b/panda/src/gobj/vertexDataPage.cxx @@ -109,9 +109,9 @@ VertexDataPage(size_t book_size) : SimpleLruPage(book_size), _book_size(book_size), _block_size(0), - _book(NULL) + _book(nullptr) { - _page_data = NULL; + _page_data = nullptr; _size = 0; _uncompressed_size = 0; _ram_class = RC_resident; @@ -150,17 +150,17 @@ VertexDataPage:: { MutexHolder holder2(_tlock); if (_pending_ram_class != _ram_class) { - nassertv(_thread_mgr != (PageThreadManager *)NULL); + nassertv(_thread_mgr != nullptr); _thread_mgr->remove_page(this); } } - if (_page_data != NULL) { + if (_page_data != nullptr) { free_page_data(_page_data, _allocated_size); _size = 0; } - nassertv(_book == NULL); + nassertv(_book == nullptr); } /** @@ -176,7 +176,7 @@ stop_threads() { _thread_mgr.clear(); } - if (thread_mgr != (PageThreadManager *)NULL) { + if (thread_mgr != nullptr) { gobj_cat.info() << "Stopping vertex paging threads.\n"; thread_mgr->stop_threads(); @@ -200,7 +200,7 @@ flush_threads() { thread_mgr = _thread_mgr; } - if (thread_mgr != (PageThreadManager *)NULL) { + if (thread_mgr != nullptr) { thread_mgr->stop_threads(); MutexHolder holder(_tlock); thread_mgr->start_threads(num_threads); @@ -244,7 +244,7 @@ changed_contiguous() { VertexDataBook::Pages::iterator pi = _book->_pages.find(this); nassertv(pi != _book->_pages.end()); _book->_pages.erase(pi); - _book = NULL; + _book = nullptr; delete this; return; } @@ -301,7 +301,7 @@ VertexDataBlock *VertexDataPage:: do_alloc(size_t size) { VertexDataBlock *block = (VertexDataBlock *)SimpleAllocator::do_alloc(size); - if (block != (VertexDataBlock *)NULL && _ram_class != RC_disk) { + if (block != nullptr && _ram_class != RC_disk) { // When we allocate a new block within a resident page, we have to clear // the disk cache (since we have just invalidated it). _saved_block.clear(); @@ -321,7 +321,7 @@ void VertexDataPage:: make_resident_now() { MutexHolder holder(_tlock); if (_pending_ram_class != _ram_class) { - nassertv(_thread_mgr != (PageThreadManager *)NULL); + nassertv(_thread_mgr != nullptr); _thread_mgr->remove_page(this); } @@ -522,7 +522,7 @@ make_compressed() { size_t copied_size = 0; unsigned char *p = new_data; page = head; - while (page != NULL) { + while (page != nullptr) { memcpy(p, page->_buffer, page->_used_size); copied_size += page->_used_size; p += page->_used_size; @@ -573,7 +573,7 @@ make_disk() { } free_page_data(_page_data, _allocated_size); - _page_data = NULL; + _page_data = nullptr; _size = 0; set_ram_class(RC_disk); @@ -593,7 +593,7 @@ do_save_to_disk() { if (_ram_class == RC_resident || _ram_class == RC_compressed) { PStatTimer timer(_vdata_save_pcollector); - if (_saved_block == (VertexDataSaveBlock *)NULL) { + if (_saved_block == nullptr) { if (gobj_cat.is_debug()) { gobj_cat.debug() << "Storing page, " << _size << " bytes, to disk\n"; @@ -602,7 +602,7 @@ do_save_to_disk() { bool compressed = (_ram_class == RC_compressed); _saved_block = get_save_file()->write_data(_page_data, _allocated_size, compressed); - if (_saved_block == (VertexDataSaveBlock *)NULL) { + if (_saved_block == nullptr) { // Can't write it to disk. Too bad. return false; } @@ -626,8 +626,8 @@ do_save_to_disk() { void VertexDataPage:: do_restore_from_disk() { if (_ram_class == RC_disk) { - nassertv(_saved_block != (VertexDataSaveBlock *)NULL); - nassertv(_page_data == (unsigned char *)NULL && _size == 0); + nassertv(_saved_block != nullptr); + nassertv(_page_data == nullptr && _size == 0); PStatTimer timer(_vdata_restore_pcollector); @@ -643,7 +643,7 @@ do_restore_from_disk() { nassert_raise("read error"); } - nassertv(_page_data == (unsigned char *)NULL); + nassertv(_page_data == nullptr); _page_data = new_data; _size = buffer_size; _allocated_size = new_allocated_size; @@ -669,7 +669,7 @@ adjust_book_size() { new_size = 0; } - if (_book != (VertexDataBook *)NULL && new_size != _book_size) { + if (_book != nullptr && new_size != _book_size) { VertexDataBook::Pages::iterator pi = _book->_pages.find(this); nassertv(pi != _book->_pages.end()); _book->_pages.erase(pi); @@ -713,7 +713,7 @@ request_ram_class(RamClass ram_class) { } MutexHolder holder(_tlock); - if (_thread_mgr == (PageThreadManager *)NULL) { + if (_thread_mgr == nullptr) { // Create the thread manager. gobj_cat.info() << "Spawning " << num_threads << " vertex paging threads.\n"; @@ -812,7 +812,7 @@ add_page(VertexDataPage *page, RamClass ram_class) { */ void VertexDataPage::PageThreadManager:: remove_page(VertexDataPage *page) { - nassertv(page != (VertexDataPage *)NULL); + nassertv(page != nullptr); PageThreads::iterator ti; for (ti = _threads.begin(); ti != _threads.end(); ++ti) { @@ -980,7 +980,7 @@ thread_main() { _tlock.acquire(); - _working_page = NULL; + _working_page = nullptr; _working_cvar.notify(); Thread::consider_yield(); diff --git a/panda/src/gobj/vertexDataPage.h b/panda/src/gobj/vertexDataPage.h index 4c7fd02bf2..24cc6af7d0 100644 --- a/panda/src/gobj/vertexDataPage.h +++ b/panda/src/gobj/vertexDataPage.h @@ -176,7 +176,7 @@ private: public: DeflatePage() { _used_size = 0; - _next = NULL; + _next = nullptr; } ALLOC_DELETED_CHAIN(DeflatePage); diff --git a/panda/src/gobj/vertexDataSaveFile.cxx b/panda/src/gobj/vertexDataSaveFile.cxx index 7fab0a9110..97a77688a8 100644 --- a/panda/src/gobj/vertexDataSaveFile.cxx +++ b/panda/src/gobj/vertexDataSaveFile.cxx @@ -70,7 +70,7 @@ VertexDataSaveFile(const Filename &directory, const string &prefix, flags |= FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING; #endif _handle = CreateFile(os_specific.c_str(), GENERIC_READ | GENERIC_WRITE, - 0, NULL, CREATE_ALWAYS, flags, NULL); + 0, nullptr, CREATE_ALWAYS, flags, nullptr); if (_handle != INVALID_HANDLE_VALUE) { // The file was successfully opened and locked. break; @@ -167,7 +167,7 @@ VertexDataSaveFile(const Filename &directory, const string &prefix, VertexDataSaveFile:: ~VertexDataSaveFile() { #ifdef _WIN32 - if (_handle != NULL) { + if (_handle != nullptr) { CloseHandle(_handle); } #else @@ -196,11 +196,11 @@ write_data(const unsigned char *data, size_t size, bool compressed) { MutexHolder holder(_lock); if (!_is_valid) { - return NULL; + return nullptr; } PT(VertexDataSaveBlock) block = (VertexDataSaveBlock *)SimpleAllocator::do_alloc(size); - if (block != (VertexDataSaveBlock *)NULL) { + if (block != nullptr) { _total_file_size = max(_total_file_size, block->get_start() + size); block->set_compressed(compressed); @@ -224,11 +224,11 @@ write_data(const unsigned char *data, size_t size, bool compressed) { << "Error writing " << size << " bytes to save file, windows error code 0x" << hex << error << dec << ". Disk full?\n"; - return NULL; + return nullptr; } success = GetOverlappedResult(_handle, &overlapped, &bytes_written, false); } - nassertr(bytes_written == size, NULL); + nassertr(bytes_written == size, nullptr); double finish_time = ClockObject::get_global_clock()->get_real_time(); if (gobj_cat.is_debug()) { gobj_cat.debug() @@ -239,7 +239,7 @@ write_data(const unsigned char *data, size_t size, bool compressed) { if (lseek(_fd, block->get_start(), SEEK_SET) == -1) { gobj_cat.error() << "Error seeking to position " << block->get_start() << " in save file.\n"; - return NULL; + return nullptr; } while (size > 0) { @@ -250,7 +250,7 @@ write_data(const unsigned char *data, size_t size, bool compressed) { } else { gobj_cat.error() << "Error writing " << size << " bytes to save file. Disk full?\n"; - return NULL; + return nullptr; } continue; } @@ -310,7 +310,7 @@ read_data(unsigned char *data, size_t size, VertexDataSaveBlock *block) { } success = GetOverlappedResult(_handle, &overlapped, &bytes_read, false); } - nassertr(bytes_read == size, NULL); + nassertr(bytes_read == size, nullptr); double finish_time = ClockObject::get_global_clock()->get_real_time(); if (gobj_cat.is_debug()) { gobj_cat.debug() diff --git a/panda/src/grutil/cardMaker.I b/panda/src/grutil/cardMaker.I index 8d051a72bc..c10991e92d 100644 --- a/panda/src/grutil/cardMaker.I +++ b/panda/src/grutil/cardMaker.I @@ -134,5 +134,5 @@ set_source_geometry(PandaNode *node, const LVecBase4 &frame) { */ INLINE void CardMaker:: clear_source_geometry() { - _source_geometry = (PandaNode *)NULL; + _source_geometry = nullptr; } diff --git a/panda/src/grutil/cardMaker.cxx b/panda/src/grutil/cardMaker.cxx index ddfeae6947..1b68d1482a 100644 --- a/panda/src/grutil/cardMaker.cxx +++ b/panda/src/grutil/cardMaker.cxx @@ -33,7 +33,7 @@ reset() { _color.set(1.0f, 1.0f, 1.0f, 1.0f); _has_normals = true; - _source_geometry = (PandaNode *)NULL; + _source_geometry = nullptr; _source_frame.set(0.0f, 0.0f, 0.0f, 0.0f); } @@ -43,7 +43,7 @@ reset() { */ PT(PandaNode) CardMaker:: generate() { - if (_source_geometry != (PandaNode *)NULL) { + if (_source_geometry != nullptr) { return rescale_source_geometry(); } diff --git a/panda/src/grutil/frameRateMeter.cxx b/panda/src/grutil/frameRateMeter.cxx index 044a87a9a9..0b9fc9d1bb 100644 --- a/panda/src/grutil/frameRateMeter.cxx +++ b/panda/src/grutil/frameRateMeter.cxx @@ -58,7 +58,7 @@ FrameRateMeter(const string &name) : // calculation within TextAssembler. PN_stdfloat height = 1.0f; TextFont *font = get_font(); - if (font != NULL){ + if (font != nullptr){ height = font->get_line_height() * 0.8; } @@ -134,10 +134,10 @@ setup_window(GraphicsOutput *window) { */ void FrameRateMeter:: clear_window() { - if (_window != (GraphicsOutput *)NULL) { + if (_window != nullptr) { _window->remove_display_region(_display_region); - _window = (GraphicsOutput *)NULL; - _display_region = (DisplayRegion *)NULL; + _window = nullptr; + _display_region = nullptr; } _root = NodePath(); } @@ -164,7 +164,7 @@ bool FrameRateMeter:: cull_callback(CullTraverser *trav, CullTraverserData &data) { // This triggers when you try to parent a frame rate meter into the scene // graph yourself. Instead, use setup_window(). - nassertr(_display_region != NULL, false); + nassertr(_display_region != nullptr, false); Thread *current_thread = trav->get_current_thread(); diff --git a/panda/src/grutil/geoMipTerrain.cxx b/panda/src/grutil/geoMipTerrain.cxx index 0df3787086..a627ac11f7 100644 --- a/panda/src/grutil/geoMipTerrain.cxx +++ b/panda/src/grutil/geoMipTerrain.cxx @@ -50,8 +50,8 @@ generate_block(unsigned short mx, unsigned short my, unsigned short level) { - nassertr(mx < (_xsize - 1) / _block_size, NULL); - nassertr(my < (_ysize - 1) / _block_size, NULL); + nassertr(mx < (_xsize - 1) / _block_size, nullptr); + nassertr(my < (_ysize - 1) / _block_size, nullptr); unsigned short center = _block_size / 2; unsigned int vcounter = 0; diff --git a/panda/src/grutil/geoMipTerrain.h b/panda/src/grutil/geoMipTerrain.h index 88727e9077..cc68450419 100644 --- a/panda/src/grutil/geoMipTerrain.h +++ b/panda/src/grutil/geoMipTerrain.h @@ -39,11 +39,11 @@ PUBLISHED: INLINE ~GeoMipTerrain(); INLINE PNMImage &heightfield(); - bool set_heightfield(const Filename &filename, PNMFileType *type = NULL); + bool set_heightfield(const Filename &filename, PNMFileType *type = nullptr); INLINE bool set_heightfield(const PNMImage &image); INLINE PNMImage &color_map(); INLINE bool set_color_map(const Filename &filename, - PNMFileType *type = NULL); + PNMFileType *type = nullptr); INLINE bool set_color_map(const PNMImage &image); INLINE bool set_color_map(const Texture *image); INLINE bool set_color_map(const string &path); diff --git a/panda/src/grutil/heightfieldTesselator.cxx b/panda/src/grutil/heightfieldTesselator.cxx index 8106071ed7..58d8324521 100644 --- a/panda/src/grutil/heightfieldTesselator.cxx +++ b/panda/src/grutil/heightfieldTesselator.cxx @@ -175,9 +175,9 @@ generate() { delete[] _vertex_index; delete[] _dirty_vertices; delete[] _triangle_totals; - _vertex_index =0; - _dirty_vertices =0; - _triangle_totals =0; + _vertex_index =nullptr; + _dirty_vertices =nullptr; + _triangle_totals =nullptr; return root; } @@ -257,7 +257,7 @@ generate_square(NodePath root, int scale, int x, int y, bool forceclose) { #define POINTH get_vertex(x+hsize,y+size) #define POINTI get_vertex(x+size ,y+size) - if (_triangles == 0) { + if (_triangles == nullptr) { open_geom(); } if (subdivide(scale, x, y)) { @@ -376,7 +376,7 @@ open_geom() { */ void HeightfieldTesselator:: close_geom(NodePath root) { - if (_triangles == 0) { + if (_triangles == nullptr) { return; } _triangles->close_primitive(); @@ -395,7 +395,7 @@ close_geom(NodePath root) { _next_index = 0; _last_vertex_a = -1; _last_vertex_b = -1; - _vertex_writer = 0; - _normal_writer = 0; - _triangles = 0; + _vertex_writer = nullptr; + _normal_writer = nullptr; + _triangles = nullptr; } diff --git a/panda/src/grutil/heightfieldTesselator.h b/panda/src/grutil/heightfieldTesselator.h index 247d1de218..cd39245e7b 100644 --- a/panda/src/grutil/heightfieldTesselator.h +++ b/panda/src/grutil/heightfieldTesselator.h @@ -61,7 +61,7 @@ PUBLISHED: INLINE ~HeightfieldTesselator(); INLINE PNMImage &heightfield(); - INLINE bool set_heightfield(const Filename &filename, PNMFileType *type = NULL); + INLINE bool set_heightfield(const Filename &filename, PNMFileType *type = nullptr); INLINE void set_poly_count(int n); INLINE void set_visibility_radius(int r); INLINE void set_focal_point(int x, int y); diff --git a/panda/src/grutil/lineSegs.I b/panda/src/grutil/lineSegs.I index d9e8101c1c..5236f13b74 100644 --- a/panda/src/grutil/lineSegs.I +++ b/panda/src/grutil/lineSegs.I @@ -117,7 +117,7 @@ create(bool dynamic) { */ INLINE int LineSegs:: get_num_vertices() const { - if (_created_data == (GeomVertexData *)NULL) { + if (_created_data == nullptr) { return 0; } return _created_data->get_num_rows(); diff --git a/panda/src/grutil/lineSegs.cxx b/panda/src/grutil/lineSegs.cxx index 9bb54f40ab..7e53416855 100644 --- a/panda/src/grutil/lineSegs.cxx +++ b/panda/src/grutil/lineSegs.cxx @@ -105,7 +105,7 @@ is_empty() { */ LVertex LineSegs:: get_vertex(int n) const { - nassertr(_created_data != (GeomVertexData *)NULL, LVertex::zero()); + nassertr(_created_data != nullptr, LVertex::zero()); GeomVertexReader vertex(_created_data, InternalName::get_vertex()); vertex.set_row_unsafe(n); return vertex.get_data3(); @@ -118,7 +118,7 @@ get_vertex(int n) const { */ void LineSegs:: set_vertex(int n, const LVertex &vert) { - nassertv(_created_data != (GeomVertexData *)NULL); + nassertv(_created_data != nullptr); GeomVertexWriter vertex(_created_data, InternalName::get_vertex()); vertex.set_row_unsafe(n); vertex.set_data3(vert); @@ -129,7 +129,7 @@ set_vertex(int n, const LVertex &vert) { */ LColor LineSegs:: get_vertex_color(int n) const { - nassertr(_created_data != (GeomVertexData *)NULL, LColor::zero()); + nassertr(_created_data != nullptr, LColor::zero()); GeomVertexReader color(_created_data, InternalName::get_color()); color.set_row_unsafe(n); return color.get_data4(); @@ -140,7 +140,7 @@ get_vertex_color(int n) const { */ void LineSegs:: set_vertex_color(int n, const LColor &c) { - nassertv(_created_data != (GeomVertexData *)NULL); + nassertv(_created_data != nullptr); GeomVertexWriter color(_created_data, InternalName::get_color()); color.set_row_unsafe(n); color.set_data4(c); diff --git a/panda/src/grutil/meshDrawer.I b/panda/src/grutil/meshDrawer.I index 72a21bd504..030f646cb9 100644 --- a/panda/src/grutil/meshDrawer.I +++ b/panda/src/grutil/meshDrawer.I @@ -20,13 +20,13 @@ INLINE MeshDrawer:: MeshDrawer() { _root = NodePath("MeshDrawer"); _at_start = 0; - _bv = NULL; - _vertex = NULL; - _normal = NULL; - _uv = NULL; - _color = NULL; + _bv = nullptr; + _vertex = nullptr; + _normal = nullptr; + _uv = nullptr; + _color = nullptr; _budget = 5000; - _vdata = NULL; + _vdata = nullptr; } /** @@ -35,10 +35,10 @@ MeshDrawer() { INLINE MeshDrawer:: ~MeshDrawer() { _root.remove_node(); - if (_vertex != NULL) delete _vertex; - if (_normal != NULL) delete _normal; - if (_uv != NULL) delete _uv; - if (_color != NULL) delete _color; + if (_vertex != nullptr) delete _vertex; + if (_normal != nullptr) delete _normal; + if (_uv != nullptr) delete _uv; + if (_color != nullptr) delete _color; } /** diff --git a/panda/src/grutil/meshDrawer.cxx b/panda/src/grutil/meshDrawer.cxx index 57ac0d9590..a727c15ced 100644 --- a/panda/src/grutil/meshDrawer.cxx +++ b/panda/src/grutil/meshDrawer.cxx @@ -71,7 +71,7 @@ void MeshDrawer::generator(int budget) { _prim->close_primitive(); _geom = new Geom(_vdata); _geom->add_primitive(_prim); - if (_geomnode == NULL) { + if (_geomnode == nullptr) { _geomnode = new GeomNode("__MeshDrawer_GeomNode"); _root.attach_new_node(_geomnode); } else { @@ -104,12 +104,12 @@ void MeshDrawer::begin(NodePath camera, NodePath render) { _b4 = - _right + _up; // recreate our rewriters - if (_vertex != NULL) delete _vertex; - if (_normal != NULL) delete _normal; - if (_uv != NULL) delete _uv; - if (_color != NULL) delete _color; + if (_vertex != nullptr) delete _vertex; + if (_normal != nullptr) delete _normal; + if (_uv != nullptr) delete _uv; + if (_color != nullptr) delete _color; - if (_vdata == NULL) { + if (_vdata == nullptr) { generator(_budget); } @@ -141,10 +141,10 @@ void MeshDrawer::end() { _last_clear_index = _clear_index; // delete the re writers - delete _vertex; _vertex = NULL; - delete _uv; _uv = NULL; - delete _normal; _normal = NULL; - delete _color; _color = NULL; + delete _vertex; _vertex = nullptr; + delete _uv; _uv = nullptr; + delete _normal; _normal = nullptr; + delete _color; _color = nullptr; } diff --git a/panda/src/grutil/meshDrawer2D.I b/panda/src/grutil/meshDrawer2D.I index 9846eda7ee..4ff460c567 100644 --- a/panda/src/grutil/meshDrawer2D.I +++ b/panda/src/grutil/meshDrawer2D.I @@ -19,10 +19,10 @@ INLINE MeshDrawer2D:: MeshDrawer2D() { _root = NodePath("MeshDrawer"); - _bv = NULL; - _vertex = NULL; - _uv = NULL; - _color = NULL; + _bv = nullptr; + _vertex = nullptr; + _uv = nullptr; + _color = nullptr; _budget = 5000; _clip_x = -1000000; @@ -37,9 +37,9 @@ MeshDrawer2D() { INLINE MeshDrawer2D:: ~MeshDrawer2D() { _root.remove_node(); - if (_vertex != NULL) delete _vertex; - if (_uv != NULL) delete _uv; - if (_color != NULL) delete _color; + if (_vertex != nullptr) delete _vertex; + if (_uv != nullptr) delete _uv; + if (_color != nullptr) delete _color; } /** diff --git a/panda/src/grutil/meshDrawer2D.cxx b/panda/src/grutil/meshDrawer2D.cxx index fbf99a2778..a34f4b7d34 100644 --- a/panda/src/grutil/meshDrawer2D.cxx +++ b/panda/src/grutil/meshDrawer2D.cxx @@ -88,9 +88,9 @@ void MeshDrawer2D::generator(int budget) { void MeshDrawer2D::begin() { // recreate our rewriters - if (_vertex != NULL) delete _vertex; - if (_uv != NULL) delete _uv; - if (_color != NULL) delete _color; + if (_vertex != nullptr) delete _vertex; + if (_uv != nullptr) delete _uv; + if (_color != nullptr) delete _color; _vertex = new GeomVertexRewriter(_vdata, "vertex"); _uv = new GeomVertexRewriter(_vdata, "texcoord"); @@ -120,9 +120,9 @@ void MeshDrawer2D::end() { _last_clear_index = _clear_index; // delete the re writers - delete _vertex; _vertex = NULL; - delete _uv; _uv = NULL; - delete _color; _color = NULL; + delete _vertex; _vertex = nullptr; + delete _uv; _uv = nullptr; + delete _color; _color = nullptr; } diff --git a/panda/src/grutil/movieTexture.I b/panda/src/grutil/movieTexture.I index d52220695e..9b3f6eceb8 100644 --- a/panda/src/grutil/movieTexture.I +++ b/panda/src/grutil/movieTexture.I @@ -49,7 +49,7 @@ get_video_height() const { INLINE MovieVideoCursor *MovieTexture:: get_color_cursor(int page) { CDReader cdata(_cycler); - nassertr(page >= 0 && page < (int)cdata->_pages.size(), NULL); + nassertr(page >= 0 && page < (int)cdata->_pages.size(), nullptr); return cdata->_pages[page]._color; } @@ -60,6 +60,6 @@ get_color_cursor(int page) { INLINE MovieVideoCursor *MovieTexture:: get_alpha_cursor(int page) { CDReader cdata(_cycler); - nassertr(page >= 0 && page < (int)cdata->_pages.size(), NULL); + nassertr(page >= 0 && page < (int)cdata->_pages.size(), nullptr); return cdata->_pages[page]._alpha; } diff --git a/panda/src/grutil/movieTexture.cxx b/panda/src/grutil/movieTexture.cxx index e395916bce..c62eb23715 100644 --- a/panda/src/grutil/movieTexture.cxx +++ b/panda/src/grutil/movieTexture.cxx @@ -48,7 +48,7 @@ MovieTexture(MovieVideo *video) : Texture(video->get_name()) { Texture::CDWriter cdata_tex(Texture::_cycler, true); - do_load_one(cdata_tex, video->open(), NULL, 0, LoaderOptions()); + do_load_one(cdata_tex, video->open(), nullptr, 0, LoaderOptions()); } /** @@ -211,7 +211,7 @@ do_read_one(Texture::CData *cdata_tex, } nassertr(z >= 0 && z < cdata_tex->_z_size * cdata_tex->_num_views, false); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(fullpath); } @@ -219,12 +219,12 @@ do_read_one(Texture::CData *cdata_tex, PT(MovieVideoCursor) alpha; color = MovieVideo::get(fullpath)->open(); - if (color == 0) { + if (color == nullptr) { return false; } if (!alpha_fullpath.empty()) { alpha = MovieVideo::get(alpha_fullpath)->open(); - if (alpha == 0) { + if (alpha == nullptr) { return false; } } @@ -326,7 +326,7 @@ cull_callback(CullTraverser *, const CullTraverserData &) const { // compute a new one. double offset; int true_loop_count = 1; - if (cdata->_synchronize != 0) { + if (cdata->_synchronize != nullptr) { offset = cdata->_synchronize->get_time(); } else { // Calculate the cursor position modulo the length of the movie. @@ -358,11 +358,11 @@ cull_callback(CullTraverser *, const CullTraverserData &) const { MovieVideoCursor *alpha = page._alpha; size_t i = pi - cdata->_pages.begin(); - if (color != NULL && alpha != NULL) { + if (color != nullptr && alpha != nullptr) { color->apply_to_texture_rgb(page._cbuffer, (MovieTexture*)this, i); alpha->apply_to_texture_alpha(page._abuffer, (MovieTexture*)this, i, cdata_tex->_alpha_file_channel); - } else if (color != NULL) { + } else if (color != nullptr) { color->apply_to_texture(page._cbuffer, (MovieTexture*)this, i); } @@ -634,7 +634,7 @@ synchronize_to(AudioSound *s) { void MovieTexture:: unsynchronize() { CDWriter cdata(_cycler); - cdata->_synchronize = 0; + cdata->_synchronize = nullptr; } @@ -657,12 +657,12 @@ do_update_frames(const CData *cdata) const { MovieVideoCursor *color = page._color; MovieVideoCursor *alpha = page._alpha; - if (color != NULL && page._cbuffer == NULL) { + if (color != nullptr && page._cbuffer == nullptr) { if (color->set_time(cdata->_offset, cdata->_true_loop_count)) { ((VideoPage &)page)._cbuffer = color->fetch_buffer(); } } - if (alpha != NULL && page._abuffer == NULL) { + if (alpha != nullptr && page._abuffer == nullptr) { if (alpha->set_time(cdata->_offset, cdata->_true_loop_count)) { ((VideoPage &)page)._abuffer = alpha->fetch_buffer(); } @@ -682,15 +682,15 @@ do_update_frames(const CData *cdata) const { PT(MovieVideoCursor::Buffer) newest; for (pi = cdata->_pages.begin(); pi != cdata->_pages.end(); ++pi) { const VideoPage &page = (*pi); - if (page._cbuffer == NULL) { - if (page._color != NULL) { + if (page._cbuffer == nullptr) { + if (page._color != nullptr) { // This page isn't ready at all. in_sync = false; } } else { - nassertr(page._color != NULL, true); + nassertr(page._color != nullptr, true); any_frames = true; - if (newest == NULL) { + if (newest == nullptr) { newest = page._cbuffer; } else { int ref = newest->compare_timestamp(page._cbuffer); @@ -704,14 +704,14 @@ do_update_frames(const CData *cdata) const { } } } - if (page._abuffer == NULL) { - if (page._alpha != NULL) { + if (page._abuffer == nullptr) { + if (page._alpha != nullptr) { in_sync = false; } } else { - nassertr(page._alpha != NULL, true); + nassertr(page._alpha != nullptr, true); any_frames = true; - if (newest == NULL) { + if (newest == nullptr) { newest = page._abuffer; } else { int ref = newest->compare_timestamp(page._abuffer); @@ -734,15 +734,15 @@ do_update_frames(const CData *cdata) const { if (!in_sync) { // If we're not in sync, throw away pages that are older than the newest // available frame. - if (newest != NULL) { + if (newest != nullptr) { Pages::const_iterator pi; for (pi = cdata->_pages.begin(); pi != cdata->_pages.end(); ++pi) { const VideoPage &page = (*pi); - if (page._cbuffer != NULL && newest->compare_timestamp(page._cbuffer) > 0) { + if (page._cbuffer != nullptr && newest->compare_timestamp(page._cbuffer) > 0) { ((VideoPage &)page)._cbuffer.clear(); any_dropped = true; } - if (page._abuffer != NULL && newest->compare_timestamp(page._abuffer) > 0) { + if (page._abuffer != nullptr && newest->compare_timestamp(page._abuffer) > 0) { ((VideoPage &)page)._abuffer.clear(); any_dropped = true; } diff --git a/panda/src/grutil/multitexReducer.cxx b/panda/src/grutil/multitexReducer.cxx index 8481444a2d..5d76ade23a 100644 --- a/panda/src/grutil/multitexReducer.cxx +++ b/panda/src/grutil/multitexReducer.cxx @@ -241,7 +241,7 @@ flatten(GraphicsOutput *window) { multitex_id++; GraphicsOutput *buffer = window->make_texture_buffer - (multitex_name_strm.str(), x_size, y_size, NULL, false); + (multitex_name_strm.str(), x_size, y_size, nullptr, false); // TODO: this no longer automatically deletes the buffer. We need to take // care of this explicitly now. @@ -323,7 +323,7 @@ flatten(GraphicsOutput *window) { // first texture layer to apply only. nassertv(bake_in_color); PT(GeomNode) geom_node = new GeomNode("background"); - transfer_geom(geom_node, NULL, geom_list, true); + transfer_geom(geom_node, nullptr, geom_list, true); render.attach_new_node(geom_node); } @@ -362,7 +362,7 @@ flatten(GraphicsOutput *window) { const RenderAttrib *attrib = geom_info._geom_net_state->get_attrib(ColorScaleAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { geom_state = geom_state->add_attrib (attrib->invert_compose(ColorScaleAttrib::make_identity())); } @@ -372,7 +372,7 @@ flatten(GraphicsOutput *window) { CPT(TransformState) tex_mat = TransformState::make_identity(); const RenderAttrib *ra = geom_info._state->get_attrib(TexMatrixAttrib::get_class_slot()); - if (ra != (const RenderAttrib *)NULL) { + if (ra != nullptr) { // There is a texture matrix inherited from above; put an inverse // matrix on the Geom to compensate. const TexMatrixAttrib *tma = DCAST(TexMatrixAttrib, ra); @@ -442,14 +442,14 @@ scan_geom_node(GeomNode *node, const RenderState *state, // Get out the net TextureAttrib and TexMatrixAttrib from the state. const RenderAttrib *attrib; - const TextureAttrib *ta = NULL; + const TextureAttrib *ta = nullptr; attrib = geom_net_state->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { ta = DCAST(TextureAttrib, attrib); } - if (ta == (TextureAttrib *)NULL) { + if (ta == nullptr) { // No texture should be on the Geom. CPT(RenderState) geom_state = node->get_geom_state(gi); geom_state = geom_state->remove_attrib(TextureAttrib::get_class_slot()); @@ -468,7 +468,7 @@ scan_geom_node(GeomNode *node, const RenderState *state, // Ok, we have multitexture. Record the Geom. CPT(TexMatrixAttrib) tma = DCAST(TexMatrixAttrib, TexMatrixAttrib::make()); attrib = geom_net_state->get_attrib(TexMatrixAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { tma = DCAST(TexMatrixAttrib, attrib); } @@ -880,13 +880,13 @@ transfer_geom(GeomNode *geom_node, const InternalName *texcoord_name, } } - if (texcoord_name != (const InternalName *)NULL && + if (texcoord_name != nullptr && texcoord_name != InternalName::get_texcoord()) { // Copy the texture coordinates from the indicated name over to the // default name. const GeomVertexColumn *column = vdata->get_format()->get_column(texcoord_name); - if (column != (const GeomVertexColumn *)NULL) { + if (column != nullptr) { vdata = vdata->replace_column (InternalName::get_texcoord(), column->get_num_components(), column->get_numeric_type(), column->get_contents()); @@ -904,11 +904,11 @@ transfer_geom(GeomNode *geom_node, const InternalName *texcoord_name, if (preserve_color) { // Be sure to preserve whatever colors are on the geom. const RenderAttrib *ca = geom_info._geom_net_state->get_attrib(ColorAttrib::get_class_slot()); - if (ca != (const RenderAttrib *)NULL) { + if (ca != nullptr) { geom_state = geom_state->add_attrib(ca); } const RenderAttrib *csa = geom_info._geom_net_state->get_attrib(ColorScaleAttrib::get_class_slot()); - if (csa != (const RenderAttrib *)NULL) { + if (csa != nullptr) { geom_state = geom_state->add_attrib(csa); } } @@ -938,7 +938,7 @@ scan_color(const MultitexReducer::GeomList &geom_list, LColor &geom_color, LColor color_scale(1.0f, 1.0f, 1.0f, 1.0f); const RenderAttrib *csa = geom_info._geom_net_state->get_attrib(ColorScaleAttrib::get_class_slot()); - if (csa != (const RenderAttrib *)NULL) { + if (csa != nullptr) { const ColorScaleAttrib *a = DCAST(ColorScaleAttrib, csa); if (a->has_scale()) { color_scale = a->get_scale(); @@ -947,7 +947,7 @@ scan_color(const MultitexReducer::GeomList &geom_list, LColor &geom_color, ColorAttrib::Type color_type = ColorAttrib::T_vertex; const RenderAttrib *ca = geom_info._geom_net_state->get_attrib(ColorAttrib::get_class_slot()); - if (ca != (const RenderAttrib *)NULL) { + if (ca != nullptr) { color_type = DCAST(ColorAttrib, ca)->get_color_type(); } diff --git a/panda/src/grutil/nodeVertexTransform.cxx b/panda/src/grutil/nodeVertexTransform.cxx index de5b14d0f0..5fb44d6cc1 100644 --- a/panda/src/grutil/nodeVertexTransform.cxx +++ b/panda/src/grutil/nodeVertexTransform.cxx @@ -32,7 +32,7 @@ NodeVertexTransform(const PandaNode *node, */ void NodeVertexTransform:: get_matrix(LMatrix4 &matrix) const { - if (_prev != (const VertexTransform *)NULL) { + if (_prev != nullptr) { LMatrix4 prev_matrix; _prev->get_matrix(prev_matrix); matrix.multiply(_node->get_transform()->get_mat(), prev_matrix); @@ -47,7 +47,7 @@ get_matrix(LMatrix4 &matrix) const { */ void NodeVertexTransform:: output(ostream &out) const { - if (_prev != (const VertexTransform *)NULL) { + if (_prev != nullptr) { _prev->output(out); out << " * "; } diff --git a/panda/src/grutil/nodeVertexTransform.h b/panda/src/grutil/nodeVertexTransform.h index 9f1d891615..55bb0bc6bf 100644 --- a/panda/src/grutil/nodeVertexTransform.h +++ b/panda/src/grutil/nodeVertexTransform.h @@ -29,7 +29,7 @@ class FactoryParams; class EXPCL_PANDA_GRUTIL NodeVertexTransform : public VertexTransform { PUBLISHED: NodeVertexTransform(const PandaNode *node, - const VertexTransform *prev = NULL); + const VertexTransform *prev = nullptr); INLINE const PandaNode *get_node() const; INLINE const VertexTransform *get_prev() const; diff --git a/panda/src/grutil/pfmVizzer.I b/panda/src/grutil/pfmVizzer.I index 2185248829..7af594088a 100644 --- a/panda/src/grutil/pfmVizzer.I +++ b/panda/src/grutil/pfmVizzer.I @@ -79,7 +79,7 @@ set_flat_texcoord_name(InternalName *flat_texcoord_name) { */ INLINE void PfmVizzer:: clear_flat_texcoord_name() { - _flat_texcoord_name = NULL; + _flat_texcoord_name = nullptr; } /** @@ -149,7 +149,7 @@ set_vis_blend(const PNMImage *vis_blend) { */ INLINE void PfmVizzer:: clear_vis_blend() { - _vis_blend = NULL; + _vis_blend = nullptr; } /** @@ -171,7 +171,7 @@ get_vis_blend() const { */ INLINE void PfmVizzer:: set_aux_pfm(const PfmFile *pfm) { - assert(pfm == NULL || (pfm->get_x_size() == _pfm.get_x_size() && + assert(pfm == nullptr || (pfm->get_x_size() == _pfm.get_x_size() && pfm->get_y_size() == _pfm.get_y_size())); _aux_pfm = pfm; } @@ -181,7 +181,7 @@ set_aux_pfm(const PfmFile *pfm) { */ INLINE void PfmVizzer:: clear_aux_pfm() { - _aux_pfm = NULL; + _aux_pfm = nullptr; } /** @@ -199,5 +199,5 @@ get_aux_pfm() const { */ INLINE PfmVizzer::VisColumn:: VisColumn() { - _undist_lut = NULL; + _undist_lut = nullptr; } diff --git a/panda/src/grutil/pfmVizzer.cxx b/panda/src/grutil/pfmVizzer.cxx index 72a0cbf7a2..4d1a65d416 100644 --- a/panda/src/grutil/pfmVizzer.cxx +++ b/panda/src/grutil/pfmVizzer.cxx @@ -34,8 +34,8 @@ PfmVizzer(PfmFile &pfm) : _pfm(pfm) { _vis_inverse = false; _vis_2d = false; _keep_beyond_lens = false; - _vis_blend = NULL; - _aux_pfm = NULL; + _vis_blend = nullptr; + _aux_pfm = nullptr; } /** @@ -73,7 +73,7 @@ project(const Lens *lens, const PfmFile *undist_lut) { // these to [0, 1]. LPoint3f uvw = LCAST(float, film * to_uv); - if (undist_lut != NULL) { + if (undist_lut != nullptr) { // Apply the undistortion map, if given. LPoint3f p2; undist_lut->calc_bilinear_point(p2, uvw[0], 1.0 - uvw[1]); @@ -244,7 +244,7 @@ generate_vis_points() const { nassertr(_pfm.is_valid(), NodePath()); bool check_aux_pfm = uses_aux_pfm(); - nassertr(!check_aux_pfm || (_aux_pfm != NULL && _aux_pfm->is_valid()), NodePath()); + nassertr(!check_aux_pfm || (_aux_pfm != nullptr && _aux_pfm->is_valid()), NodePath()); CPT(GeomVertexFormat) format; if (_vis_inverse) { @@ -323,7 +323,7 @@ generate_vis_points() const { NodePath PfmVizzer:: generate_vis_mesh(MeshFace face) const { nassertr(_pfm.is_valid(), NodePath()); - nassertr(!uses_aux_pfm() || (_aux_pfm != NULL && _aux_pfm->is_valid()), NodePath()); + nassertr(!uses_aux_pfm() || (_aux_pfm != nullptr && _aux_pfm->is_valid()), NodePath()); nassertr(face != 0, NodePath()); if (_pfm.get_num_channels() == 1 && _vis_columns.empty()) { @@ -877,11 +877,11 @@ add_vis_column(VisColumns &vis_columns, ColumnType source, ColumnType target, column._target = target; column._name = name; column._transform = transform; - if (transform == NULL) { + if (transform == nullptr) { column._transform = TransformState::make_identity(); } column._lens = lens; - if (undist_lut != NULL && undist_lut->is_valid()) { + if (undist_lut != nullptr && undist_lut->is_valid()) { column._undist_lut = undist_lut; } vis_columns.push_back(column); @@ -922,12 +922,12 @@ build_auto_vis_columns(VisColumns &vis_columns, bool for_points) const { } } - if (_flat_texcoord_name != (InternalName *)NULL) { + if (_flat_texcoord_name != nullptr) { // We need an additional texcoord column for the flat texcoords. add_vis_column(vis_columns, CT_texcoord2, CT_texcoord2, _flat_texcoord_name); } - if (_vis_blend != (PNMImage *)NULL) { + if (_vis_blend != nullptr) { // The blend map, if specified, also gets applied to the vertices. add_vis_column(vis_columns, CT_blend1, CT_blend1, InternalName::get_color()); } @@ -995,7 +995,7 @@ make_array_format(const VisColumns &vis_columns) const { contents = GeomEnums::C_color; break; } - nassertr(num_components != 0, NULL); + nassertr(num_components != 0, nullptr); array_format->add_column(name, num_components, numeric_type, contents); } @@ -1049,7 +1049,7 @@ add_data(const PfmVizzer &vizzer, GeomVertexWriter &vwriter, int xi, int yi, boo case CT_aux_vertex1: { - nassertr(vizzer.get_aux_pfm() != NULL, false); + nassertr(vizzer.get_aux_pfm() != nullptr, false); PN_float32 p = vizzer.get_aux_pfm()->get_point1(xi, yi); LPoint2f point(p, 0.0); if (!transform_point(point)) { @@ -1071,7 +1071,7 @@ add_data(const PfmVizzer &vizzer, GeomVertexWriter &vwriter, int xi, int yi, boo case CT_aux_vertex2: { - nassertr(vizzer.get_aux_pfm() != NULL, false); + nassertr(vizzer.get_aux_pfm() != nullptr, false); LPoint2f point = vizzer.get_aux_pfm()->get_point2(xi, yi); if (!transform_point(point)) { success = false; @@ -1155,7 +1155,7 @@ add_data(const PfmVizzer &vizzer, GeomVertexWriter &vwriter, int xi, int yi, boo case CT_blend1: { const PNMImage *vis_blend = vizzer.get_vis_blend(); - if (vis_blend != NULL) { + if (vis_blend != nullptr) { double gray = vis_blend->get_gray(xi, yi); vwriter.set_data3d(gray, gray, gray); } @@ -1188,7 +1188,7 @@ transform_point(LPoint3f &point) const { if (!_transform->is_identity()) { LCAST(PN_float32, _transform->get_mat()).xform_point_in_place(point); } - if (_lens != (Lens *)NULL) { + if (_lens != nullptr) { static LMatrix4f to_uv(0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, @@ -1200,7 +1200,7 @@ transform_point(LPoint3f &point) const { point = to_uv.xform_point(LCAST(PN_float32, film)); } - if (_undist_lut != NULL) { + if (_undist_lut != nullptr) { LPoint3f p; if (!_undist_lut->calc_bilinear_point(p, point[0], 1.0 - point[1])) { // Point is missing. diff --git a/panda/src/grutil/pfmVizzer.h b/panda/src/grutil/pfmVizzer.h index e04e8a06bc..3f3fbeb62c 100644 --- a/panda/src/grutil/pfmVizzer.h +++ b/panda/src/grutil/pfmVizzer.h @@ -34,7 +34,7 @@ PUBLISHED: INLINE PfmFile &get_pfm(); INLINE const PfmFile &get_pfm() const; - BLOCKING void project(const Lens *lens, const PfmFile *undist_lut = NULL); + BLOCKING void project(const Lens *lens, const PfmFile *undist_lut = nullptr); BLOCKING void extrude(const Lens *lens); INLINE void set_vis_inverse(bool vis_inverse); @@ -70,8 +70,8 @@ PUBLISHED: void clear_vis_columns(); void add_vis_column(ColumnType source, ColumnType target, InternalName *name, - const TransformState *transform = NULL, const Lens *lens = NULL, - const PfmFile *undist_lut = NULL); + const TransformState *transform = nullptr, const Lens *lens = nullptr, + const PfmFile *undist_lut = nullptr); BLOCKING NodePath generate_vis_points() const; @@ -120,8 +120,8 @@ private: static void add_vis_column(VisColumns &vis_columns, ColumnType source, ColumnType target, InternalName *name, - const TransformState *transform = NULL, - const Lens *lens = NULL, const PfmFile *undist_lut = NULL); + const TransformState *transform = nullptr, + const Lens *lens = nullptr, const PfmFile *undist_lut = nullptr); void build_auto_vis_columns(VisColumns &vis_columns, bool for_points) const; CPT(GeomVertexFormat) make_array_format(const VisColumns &vis_columns) const; diff --git a/panda/src/grutil/pipeOcclusionCullTraverser.cxx b/panda/src/grutil/pipeOcclusionCullTraverser.cxx index d257611767..2a7f27a878 100644 --- a/panda/src/grutil/pipeOcclusionCullTraverser.cxx +++ b/panda/src/grutil/pipeOcclusionCullTraverser.cxx @@ -103,14 +103,14 @@ PipeOcclusionCullTraverser(GraphicsOutput *host) { _buffer = engine->make_output(pipe, "occlusion", 0, fb_prop, win_prop, GraphicsPipe::BF_refuse_window, gsg, host->get_host()); - nassertv(_buffer != (GraphicsOutput *)NULL); + nassertv(_buffer != nullptr); // This buffer isn't really active--we render it by hand; we don't want the // GraphicsEngine to render it. _buffer->set_active(0); _display_region = _buffer->make_display_region(); - _internal_cull_handler = NULL; + _internal_cull_handler = nullptr; make_sphere(); make_box(); @@ -192,8 +192,8 @@ set_scene(SceneSetup *scene_setup, GraphicsStateGuardianBase *gsgbase, _internal_trav->set_view_frustum(get_view_frustum()); _internal_trav->set_camera_mask(_occlusion_mask); - _current_query = NULL; - _next_query = NULL; + _current_query = nullptr; + _next_query = nullptr; // Begin by rendering all the occluders into our internal scene. PStatTimer timer2(_draw_occlusion_pcollector); @@ -214,13 +214,13 @@ end_traverse() { GraphicsStateGuardian *gsg = _buffer->get_gsg(); Thread *current_thread = get_current_thread(); - _current_query = NULL; - _next_query = NULL; + _current_query = nullptr; + _next_query = nullptr; PendingObjects::iterator oi; for (oi = _pending_objects.begin(); oi != _pending_objects.end(); ++oi) { PendingObject &pobj = (*oi); - if (pobj._query == (OcclusionQueryContext *)NULL) { + if (pobj._query == nullptr) { _occlusion_untested_pcollector.add_level(1); _true_cull_handler->record_object(pobj._object, this); } else { @@ -237,7 +237,7 @@ end_traverse() { // The CullableObject has by now either been recorded (which will // eventually delete it) or deleted directly. #ifndef NDEBUG - pobj._object = NULL; + pobj._object = nullptr; #endif // NDEBUG } _pending_objects.clear(); @@ -250,7 +250,7 @@ end_traverse() { _buffer->end_flip(); delete _internal_cull_handler; - _internal_cull_handler = NULL; + _internal_cull_handler = nullptr; _occlusion_untested_pcollector.flush_level(); _occlusion_passed_pcollector.flush_level(); @@ -264,7 +264,7 @@ end_traverse() { */ Texture *PipeOcclusionCullTraverser:: get_texture() { - if (_texture != (Texture *)NULL) { + if (_texture != nullptr) { return _texture; } @@ -288,7 +288,7 @@ get_texture() { */ bool PipeOcclusionCullTraverser:: is_in_view(CullTraverserData &data) { - _next_query = NULL; + _next_query = nullptr; if (!CullTraverser::is_in_view(data)) { return false; @@ -297,7 +297,7 @@ is_in_view(CullTraverserData &data) { return true; } - if (_current_query != (OcclusionQueryContext *)NULL) { + if (_current_query != nullptr) { // We've already performed an occlusion test for some ancestor of this // node; no need to perform another. return true; @@ -341,15 +341,15 @@ traverse_below(CullTraverserData &data) { // Save and restore _current_query, and clear _next_query, for traversing // the children of this node. PT(OcclusionQueryContext) prev_query = _current_query; - if (_next_query != (OcclusionQueryContext *)NULL) { + if (_next_query != nullptr) { _current_query = _next_query; } - _next_query = NULL; + _next_query = nullptr; CullTraverser::traverse_below(data); _current_query = prev_query; - _next_query = NULL; + _next_query = nullptr; } /** @@ -369,12 +369,12 @@ record_object(CullableObject *object, const CullTraverser *traverser) { Thread *current_thread = get_current_thread(); - if (_next_query != (OcclusionQueryContext *)NULL) { + if (_next_query != nullptr) { // We have just performed an occlusion query for this node. Don't perform // another one. pobj._query = _next_query; - } else if (_current_query != (OcclusionQueryContext *)NULL) { + } else if (_current_query != nullptr) { // We have previously performed an occlusion query for this node or some // ancestor. Don't perform another one. pobj._query = _current_query; diff --git a/panda/src/grutil/rigidBodyCombiner.cxx b/panda/src/grutil/rigidBodyCombiner.cxx index 7e3ccefd65..44f2971aa5 100644 --- a/panda/src/grutil/rigidBodyCombiner.cxx +++ b/panda/src/grutil/rigidBodyCombiner.cxx @@ -90,7 +90,7 @@ collect() { Children cr = get_children(); int num_children = cr.get_num_children(); for (int i = 0; i < num_children; i++) { - r_collect(cr.get_child(i), RenderState::make_empty(), NULL); + r_collect(cr.get_child(i), RenderState::make_empty(), nullptr); } _vd_table.clear(); @@ -179,7 +179,7 @@ r_collect(PandaNode *node, const RenderState *state, int num_geoms = gnode->get_num_geoms(); for (int i = 0; i < num_geoms; ++i) { PT(Geom) geom = gnode->get_geom(i)->make_copy(); - if (next_transform != (const VertexTransform *)NULL) { + if (next_transform != nullptr) { geom->set_vertex_data(convert_vd(next_transform, geom->get_vertex_data())); } CPT(RenderState) gstate = next_state->compose(gnode->get_geom_state(i)); @@ -225,7 +225,7 @@ convert_vd(const VertexTransform *transform, const GeomVertexData *orig) { CPT(GeomVertexData) converted = orig->convert_to(new_format); PT(GeomVertexData) new_data = new GeomVertexData(*converted); - if (new_data->get_transform_blend_table() == (TransformBlendTable *)NULL) { + if (new_data->get_transform_blend_table() == nullptr) { // Create a new table that has just the one blend: all vertices hard- // assigned to the indicated transform. PT(TransformBlendTable) new_table = new TransformBlendTable; diff --git a/panda/src/grutil/sceneGraphAnalyzerMeter.cxx b/panda/src/grutil/sceneGraphAnalyzerMeter.cxx index f5a14caed3..9881575f62 100644 --- a/panda/src/grutil/sceneGraphAnalyzerMeter.cxx +++ b/panda/src/grutil/sceneGraphAnalyzerMeter.cxx @@ -105,10 +105,10 @@ setup_window(GraphicsOutput *window) { */ void SceneGraphAnalyzerMeter:: clear_window() { - if (_window != (GraphicsOutput *)NULL) { + if (_window != nullptr) { _window->remove_display_region(_display_region); - _window = (GraphicsOutput *)NULL; - _display_region = (DisplayRegion *)NULL; + _window = nullptr; + _display_region = nullptr; } _root = NodePath(); } diff --git a/panda/src/grutil/shaderTerrainMesh.I b/panda/src/grutil/shaderTerrainMesh.I index 91ac1035d3..f6a66bc7f5 100644 --- a/panda/src/grutil/shaderTerrainMesh.I +++ b/panda/src/grutil/shaderTerrainMesh.I @@ -153,7 +153,7 @@ INLINE bool ShaderTerrainMesh::get_update_enabled() const { INLINE void ShaderTerrainMesh::Chunk::clear_children() { for (size_t i = 0; i < 4; ++i) { delete children[i]; - children[i] = NULL; + children[i] = nullptr; } } @@ -163,7 +163,7 @@ INLINE void ShaderTerrainMesh::Chunk::clear_children() { */ INLINE ShaderTerrainMesh::Chunk::Chunk() { for (size_t i = 0; i < 4; ++i) - children[i] = NULL; + children[i] = nullptr; } /** diff --git a/panda/src/grutil/shaderTerrainMesh.cxx b/panda/src/grutil/shaderTerrainMesh.cxx index 8c9c7bd9b6..d5ecdf21e2 100644 --- a/panda/src/grutil/shaderTerrainMesh.cxx +++ b/panda/src/grutil/shaderTerrainMesh.cxx @@ -94,13 +94,13 @@ ShaderTerrainMesh::ShaderTerrainMesh() : _size(0), _chunk_size(32), _generate_patches(false), - _data_texture(NULL), - _chunk_geom(NULL), + _data_texture(nullptr), + _chunk_geom(nullptr), _current_view_index(0), _last_frame_count(-1), _target_triangle_width(10.0f), _update_enabled(true), - _heightfield_tex(NULL) + _heightfield_tex(nullptr) { set_final(true); set_bounds(new OmniBoundingVolume()); @@ -261,7 +261,7 @@ void ShaderTerrainMesh::do_init_chunk(Chunk* chunk) { } else { // Final chunk, initialize all children to zero for (size_t i = 0; i < 4; ++i) { - chunk->children[i] = NULL; + chunk->children[i] = nullptr; } } } @@ -375,7 +375,7 @@ void ShaderTerrainMesh::do_create_chunk_geom() { GeomVertexWriter vertex_writer(gvd, "vertex"); // Create primitive - PT(GeomPrimitive) triangles = NULL; + PT(GeomPrimitive) triangles = nullptr; if (_generate_patches) { triangles = new GeomPatches(3, Geom::UH_static); } else { @@ -460,8 +460,8 @@ void ShaderTerrainMesh::add_for_draw(CullTraverser *trav, CullTraverserData &dat // Make sure the terrain was properly initialized, and the geom was created // successfully - nassertv(_data_texture != NULL); - nassertv(_chunk_geom != NULL); + nassertv(_data_texture != nullptr); + nassertv(_chunk_geom != nullptr); _basic_collector.start(); @@ -524,7 +524,7 @@ void ShaderTerrainMesh::add_for_draw(CullTraverser *trav, CullTraverserData &dat } // Should never happen - nassertv(current_shader_attrib != NULL); + nassertv(current_shader_attrib != nullptr); current_shader_attrib = DCAST(ShaderAttrib, current_shader_attrib)->set_shader_input( ShaderInput("ShaderTerrainMesh.terrain_size", LVecBase2i(_size))); @@ -707,11 +707,11 @@ void ShaderTerrainMesh::do_emit_chunk(Chunk* chunk, TraversalData* data) { * @return World-Space point */ LPoint3 ShaderTerrainMesh::uv_to_world(const LTexCoord& coord) const { - nassertr(_heightfield_tex != NULL, LPoint3(0)); // Heightfield not set yet + nassertr(_heightfield_tex != nullptr, LPoint3(0)); // Heightfield not set yet nassertr(_heightfield_tex->has_ram_image(), LPoint3(0)); // Heightfield not in memory PT(TexturePeeker) peeker = _heightfield_tex->peek(); - nassertr(peeker != NULL, LPoint3(0)); + nassertr(peeker != nullptr, LPoint3(0)); LColor result; if (!peeker->lookup_bilinear(result, coord.get_x(), coord.get_y())) { diff --git a/panda/src/gsgbase/graphicsStateGuardianBase.cxx b/panda/src/gsgbase/graphicsStateGuardianBase.cxx index fefd8037f2..5ac46dd4af 100644 --- a/panda/src/gsgbase/graphicsStateGuardianBase.cxx +++ b/panda/src/gsgbase/graphicsStateGuardianBase.cxx @@ -30,9 +30,9 @@ TypeHandle GraphicsStateGuardianBase::_type_handle; GraphicsStateGuardianBase *GraphicsStateGuardianBase:: get_default_gsg() { GSGList *gsg_list = (GSGList *)AtomicAdjust::get_ptr(_gsg_list); - if (gsg_list == NULL) { + if (gsg_list == nullptr) { // Nobody created a GSG list, so we won't have any GSGs either. - return NULL; + return nullptr; } LightMutexHolder holder(gsg_list->_lock); return gsg_list->_default_gsg; @@ -45,7 +45,7 @@ get_default_gsg() { void GraphicsStateGuardianBase:: set_default_gsg(GraphicsStateGuardianBase *default_gsg) { GSGList *gsg_list = (GSGList *)AtomicAdjust::get_ptr(_gsg_list); - if (gsg_list == NULL) { + if (gsg_list == nullptr) { // Nobody ever created a GSG list. How could we have a GSG? nassertv(false); return; @@ -67,7 +67,7 @@ set_default_gsg(GraphicsStateGuardianBase *default_gsg) { size_t GraphicsStateGuardianBase:: get_num_gsgs() { GSGList *gsg_list = (GSGList *)AtomicAdjust::get_ptr(_gsg_list); - if (gsg_list == NULL) { + if (gsg_list == nullptr) { // Nobody created a GSG list, so we won't have any GSGs either. return 0; } @@ -82,10 +82,10 @@ get_num_gsgs() { GraphicsStateGuardianBase *GraphicsStateGuardianBase:: get_gsg(size_t n) { GSGList *gsg_list = (GSGList *)AtomicAdjust::get_ptr(_gsg_list); - nassertr(gsg_list != NULL, NULL); + nassertr(gsg_list != nullptr, nullptr); LightMutexHolder holder(gsg_list->_lock); - nassertr(n < gsg_list->_gsgs.size(), NULL); + nassertr(n < gsg_list->_gsgs.size(), nullptr); return gsg_list->_gsgs[n]; } @@ -96,14 +96,14 @@ get_gsg(size_t n) { void GraphicsStateGuardianBase:: add_gsg(GraphicsStateGuardianBase *gsg) { GSGList *gsg_list = (GSGList *)AtomicAdjust::get_ptr(_gsg_list); - if (gsg_list == NULL) { + if (gsg_list == nullptr) { gsg_list = new GSGList; - gsg_list->_default_gsg = NULL; + gsg_list->_default_gsg = nullptr; GSGList *orig_gsg_list = (GSGList *) - AtomicAdjust::compare_and_exchange_ptr(_gsg_list, NULL, gsg_list); + AtomicAdjust::compare_and_exchange_ptr(_gsg_list, nullptr, gsg_list); - if (orig_gsg_list != NULL) { + if (orig_gsg_list != nullptr) { // Another thread beat us to it. No problem, we'll use that. delete gsg_list; gsg_list = orig_gsg_list; @@ -119,7 +119,7 @@ add_gsg(GraphicsStateGuardianBase *gsg) { gsg_list->_gsgs.push_back(gsg); - if (gsg_list->_default_gsg == (GraphicsStateGuardianBase *)NULL) { + if (gsg_list->_default_gsg == nullptr) { gsg_list->_default_gsg = gsg; } } @@ -130,7 +130,7 @@ add_gsg(GraphicsStateGuardianBase *gsg) { void GraphicsStateGuardianBase:: remove_gsg(GraphicsStateGuardianBase *gsg) { GSGList *gsg_list = (GSGList *)AtomicAdjust::get_ptr(_gsg_list); - if (gsg_list == NULL) { + if (gsg_list == nullptr) { // No GSGs were added yet, or the program is destructing anyway. return; } @@ -150,7 +150,7 @@ remove_gsg(GraphicsStateGuardianBase *gsg) { if (!gsg_list->_gsgs.empty()) { gsg_list->_default_gsg = *gsg_list->_gsgs.begin(); } else { - gsg_list->_default_gsg = NULL; + gsg_list->_default_gsg = nullptr; } } } diff --git a/panda/src/linmath/configVariableColor.I b/panda/src/linmath/configVariableColor.I index 21a0af8660..c600d7246b 100644 --- a/panda/src/linmath/configVariableColor.I +++ b/panda/src/linmath/configVariableColor.I @@ -141,7 +141,7 @@ get_value() const { INLINE LColor ConfigVariableColor:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); - if (decl != (ConfigDeclaration *)NULL) { + if (decl != nullptr) { switch (decl->get_num_words()) { case 1: return LColor((PN_stdfloat)decl->get_double_word(0), (PN_stdfloat)decl->get_double_word(0), diff --git a/panda/src/linmath/lmatrix3_ext_src.I b/panda/src/linmath/lmatrix3_ext_src.I index b1997ec746..a58a57c155 100644 --- a/panda/src/linmath/lmatrix3_ext_src.I +++ b/panda/src/linmath/lmatrix3_ext_src.I @@ -21,8 +21,8 @@ __reduce__(PyObject *self) const { // object whose constructor we should call (e.g. this), and the arguments // necessary to reconstruct this object. PyObject *this_class = PyObject_Type(self); - if (this_class == NULL) { - return NULL; + if (this_class == nullptr) { + return nullptr; } PyObject *result = Py_BuildValue("(O(fffffffff))", this_class, diff --git a/panda/src/linmath/lmatrix4_ext_src.I b/panda/src/linmath/lmatrix4_ext_src.I index 23a4a26518..928ce1c837 100644 --- a/panda/src/linmath/lmatrix4_ext_src.I +++ b/panda/src/linmath/lmatrix4_ext_src.I @@ -21,8 +21,8 @@ __reduce__(PyObject *self) const { // object whose constructor we should call (e.g. this), and the arguments // necessary to reconstruct this object. PyObject *this_class = PyObject_Type(self); - if (this_class == NULL) { - return NULL; + if (this_class == nullptr) { + return nullptr; } PyObject *result = Py_BuildValue("(O(ffffffffffffffff))", this_class, diff --git a/panda/src/linmath/lvecBase2_ext_src.I b/panda/src/linmath/lvecBase2_ext_src.I index 40399dc327..3e0a35fff4 100644 --- a/panda/src/linmath/lvecBase2_ext_src.I +++ b/panda/src/linmath/lvecBase2_ext_src.I @@ -46,8 +46,8 @@ __reduce__(PyObject *self) const { // object whose constructor we should call (e.g. this), and the arguments // necessary to reconstruct this object. PyObject *this_class = PyObject_Type(self); - if (this_class == NULL) { - return NULL; + if (this_class == nullptr) { + return nullptr; } #if FLOATTOKEN == 'i' @@ -133,7 +133,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Whoosh. PyObject* fast = PySequence_Fast(assign, ""); - nassertr(fast != NULL, -1); + nassertr(fast != nullptr, -1); // Let's be strict about size mismatches, to prevent user error. if (PySequence_Fast_GET_SIZE(fast) != (int)attr_name.size()) { @@ -148,7 +148,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { for (size_t i = 0; i < attr_name.size(); ++i) { PyObject* fl = PYNUMBER_FLOATTYPE(items[i]); - if (fl == NULL) { + if (fl == nullptr) { // Oh darn. Not when we've come this far. #ifdef FLOATTYPE_IS_INT PyErr_SetString(PyExc_ValueError, "a sequence of integers is required"); @@ -169,7 +169,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { } else { // Maybe it's a single floating-point value. PyObject* fl = PYNUMBER_FLOATTYPE(assign); - if (fl == NULL) { + if (fl == nullptr) { // It's not a floating-point value either? Sheesh, I don't know what to // do with it then. if (attr_name.size() == 1) { diff --git a/panda/src/linmath/lvecBase3_ext_src.I b/panda/src/linmath/lvecBase3_ext_src.I index a2705edbb6..871928da2f 100644 --- a/panda/src/linmath/lvecBase3_ext_src.I +++ b/panda/src/linmath/lvecBase3_ext_src.I @@ -47,8 +47,8 @@ __reduce__(PyObject *self) const { // object whose constructor we should call (e.g. this), and the arguments // necessary to reconstruct this object. PyObject *this_class = PyObject_Type(self); - if (this_class == NULL) { - return NULL; + if (this_class == nullptr) { + return nullptr; } #if FLOATTOKEN == 'i' @@ -134,7 +134,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Whoosh. PyObject* fast = PySequence_Fast(assign, ""); - nassertr(fast != NULL, -1); + nassertr(fast != nullptr, -1); // Let's be strict about size mismatches, to prevent user error. if (PySequence_Fast_GET_SIZE(fast) != (int)attr_name.size()) { @@ -149,7 +149,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { for (size_t i = 0; i < attr_name.size(); ++i) { PyObject* fl = PYNUMBER_FLOATTYPE(items[i]); - if (fl == NULL) { + if (fl == nullptr) { // Oh darn. Not when we've come this far. #ifdef FLOATTYPE_IS_INT PyErr_SetString(PyExc_ValueError, "a sequence of integers is required"); @@ -170,7 +170,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { } else { // Maybe it's a single floating-point value. PyObject* fl = PYNUMBER_FLOATTYPE(assign); - if (fl == NULL) { + if (fl == nullptr) { // It's not a floating-point value either? Sheesh, I don't know what to // do with it then. if (attr_name.size() == 1) { diff --git a/panda/src/linmath/lvecBase4_ext_src.I b/panda/src/linmath/lvecBase4_ext_src.I index 76eee6b7bf..cab78609a3 100644 --- a/panda/src/linmath/lvecBase4_ext_src.I +++ b/panda/src/linmath/lvecBase4_ext_src.I @@ -48,8 +48,8 @@ __reduce__(PyObject *self) const { // object whose constructor we should call (e.g. this), and the arguments // necessary to reconstruct this object. PyObject *this_class = PyObject_Type(self); - if (this_class == NULL) { - return NULL; + if (this_class == nullptr) { + return nullptr; } #if FLOATTOKEN == 'i' @@ -139,7 +139,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Whoosh. PyObject* fast = PySequence_Fast(assign, ""); - nassertr(fast != NULL, -1); + nassertr(fast != nullptr, -1); // Let's be strict about size mismatches, to prevent user error. if (PySequence_Fast_GET_SIZE(fast) != (int)attr_name.size()) { @@ -154,7 +154,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { for (size_t i = 0; i < attr_name.size(); ++i) { PyObject* fl = PYNUMBER_FLOATTYPE(items[i]); - if (fl == NULL) { + if (fl == nullptr) { // Oh darn. Not when we've come this far. #ifdef FLOATTYPE_IS_INT PyErr_SetString(PyExc_ValueError, "a sequence of integers is required"); @@ -176,7 +176,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Maybe it's a single floating-point value. PyObject* fl = PYNUMBER_FLOATTYPE(assign); - if (fl == NULL) { + if (fl == nullptr) { // It's not a floating-point value either? Sheesh, I don't know what to // do with it then. if (attr_name.size() == 1) { diff --git a/panda/src/mathutil/boundingSphere.cxx b/panda/src/mathutil/boundingSphere.cxx index 5ea6661aa7..a0754b9b55 100644 --- a/panda/src/mathutil/boundingSphere.cxx +++ b/panda/src/mathutil/boundingSphere.cxx @@ -363,17 +363,17 @@ around_finite(const BoundingVolume **first, const BoundingVolume **p = first; nassertr(!(*p)->is_empty() && !(*p)->is_infinite(), false); const FiniteBoundingVolume *vol = (*p)->as_finite_bounding_volume(); - nassertr(vol != (FiniteBoundingVolume *)NULL, false); + nassertr(vol != nullptr, false); LPoint3 min_box = vol->get_min(); LPoint3 max_box = vol->get_max(); - bool any_spheres = (vol->as_bounding_sphere() != NULL); + bool any_spheres = (vol->as_bounding_sphere() != nullptr); for (++p; p != last; ++p) { nassertr(!(*p)->is_infinite(), false); if (!(*p)->is_empty()) { vol = (*p)->as_finite_bounding_volume(); - if (vol == (FiniteBoundingVolume *)NULL) { + if (vol == nullptr) { set_infinite(); return true; } @@ -386,7 +386,7 @@ around_finite(const BoundingVolume **first, max(max_box[1], max1[1]), max(max_box[2], max1[2])); - if (vol->as_bounding_sphere() != NULL) { + if (vol->as_bounding_sphere() != nullptr) { any_spheres = true; } } @@ -407,7 +407,7 @@ around_finite(const BoundingVolume **first, for (p = first; p != last; ++p) { if (!(*p)->is_empty()) { const BoundingSphere *sphere = (*p)->as_bounding_sphere(); - if (sphere != (BoundingSphere *)NULL) { + if (sphere != nullptr) { // This is a sphere; consider its corner. PN_stdfloat dist = length(sphere->_center - _center); _radius = max(_radius, dist + sphere->_radius); @@ -415,7 +415,7 @@ around_finite(const BoundingVolume **first, } else { // This is a nonsphere. We fit around it. const FiniteBoundingVolume *vol = (*p)->as_finite_bounding_volume(); - nassertr(vol != (FiniteBoundingVolume *)NULL, false); + nassertr(vol != nullptr, false); BoundingBox box(vol->get_min(), vol->get_max()); box.local_object(); diff --git a/panda/src/mathutil/boundingVolume.cxx b/panda/src/mathutil/boundingVolume.cxx index 3a2bee0577..d81f905e25 100644 --- a/panda/src/mathutil/boundingVolume.cxx +++ b/panda/src/mathutil/boundingVolume.cxx @@ -84,7 +84,7 @@ write(ostream &out, int indent_level) const { */ GeometricBoundingVolume *BoundingVolume:: as_geometric_bounding_volume() { - return NULL; + return nullptr; } /** @@ -93,7 +93,7 @@ as_geometric_bounding_volume() { */ const GeometricBoundingVolume *BoundingVolume:: as_geometric_bounding_volume() const { - return NULL; + return nullptr; } /** @@ -102,7 +102,7 @@ as_geometric_bounding_volume() const { */ const FiniteBoundingVolume *BoundingVolume:: as_finite_bounding_volume() const { - return NULL; + return nullptr; } /** @@ -111,7 +111,7 @@ as_finite_bounding_volume() const { */ const BoundingSphere *BoundingVolume:: as_bounding_sphere() const { - return NULL; + return nullptr; } /** @@ -120,7 +120,7 @@ as_bounding_sphere() const { */ const BoundingBox *BoundingVolume:: as_bounding_box() const { - return NULL; + return nullptr; } /** @@ -129,7 +129,7 @@ as_bounding_box() const { */ const BoundingHexahedron *BoundingVolume:: as_bounding_hexahedron() const { - return NULL; + return nullptr; } /** @@ -138,7 +138,7 @@ as_bounding_hexahedron() const { */ const BoundingLine *BoundingVolume:: as_bounding_line() const { - return NULL; + return nullptr; } /** @@ -147,7 +147,7 @@ as_bounding_line() const { */ const BoundingPlane *BoundingVolume:: as_bounding_plane() const { - return NULL; + return nullptr; } /** diff --git a/panda/src/mathutil/fftCompressor.cxx b/panda/src/mathutil/fftCompressor.cxx index 0a5b7425e1..b8a9764d8f 100644 --- a/panda/src/mathutil/fftCompressor.cxx +++ b/panda/src/mathutil/fftCompressor.cxx @@ -386,9 +386,9 @@ write_hprs(Datagram &datagram, const LVecBase3 *array, int length) { } if (length == 0) { - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); } else { write_reals(datagram, &h[0], length); write_reals(datagram, &p[0], length); @@ -419,15 +419,15 @@ write_hprs(Datagram &datagram, const LVecBase3 *array, int length) { } if (length == 0) { - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); } else { write_reals(datagram, &m00[0], length); write_reals(datagram, &m01[0], length); @@ -513,16 +513,16 @@ write_hprs(Datagram &datagram, const LVecBase3 *array, int length) { #ifndef NDEBUG if (_quality >= 102) { if (length == 0) { - write_reals(datagram, NULL, length); + write_reals(datagram, nullptr, length); } else { write_reals(datagram, &qr[0], length); } } #endif if (length == 0) { - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); - write_reals(datagram, NULL, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); + write_reals(datagram, nullptr, length); } else { write_reals(datagram, &qi[0], length); write_reals(datagram, &qj[0], length); @@ -1060,7 +1060,7 @@ get_real_compress_plan(int length) { } fftw_plan plan; - plan = fftw_plan_dft_r2c_1d(length, NULL, NULL, FFTW_ESTIMATE); + plan = fftw_plan_dft_r2c_1d(length, nullptr, nullptr, FFTW_ESTIMATE); _real_compress_plans.insert(RealPlans::value_type(length, plan)); return plan; @@ -1079,7 +1079,7 @@ get_real_decompress_plan(int length) { } fftw_plan plan; - plan = fftw_plan_dft_c2r_1d(length, NULL, NULL, FFTW_ESTIMATE); + plan = fftw_plan_dft_c2r_1d(length, nullptr, nullptr, FFTW_ESTIMATE); _real_decompress_plans.insert(RealPlans::value_type(length, plan)); return plan; diff --git a/panda/src/mathutil/intersectionBoundingVolume.I b/panda/src/mathutil/intersectionBoundingVolume.I index 514c692333..4242446c1d 100644 --- a/panda/src/mathutil/intersectionBoundingVolume.I +++ b/panda/src/mathutil/intersectionBoundingVolume.I @@ -32,6 +32,6 @@ get_num_components() const { */ INLINE_MATHUTIL const GeometricBoundingVolume *IntersectionBoundingVolume:: get_component(int n) const { - nassertr(n >= 0 && n < (int)_components.size(), NULL); + nassertr(n >= 0 && n < (int)_components.size(), nullptr); return _components[n]; } diff --git a/panda/src/mathutil/randomizer.I b/panda/src/mathutil/randomizer.I index 3cb30939b9..410d1c266e 100644 --- a/panda/src/mathutil/randomizer.I +++ b/panda/src/mathutil/randomizer.I @@ -68,7 +68,7 @@ random_real_unit() { INLINE unsigned long Randomizer:: get_next_seed() { if (!_got_first_seed) { - _next_seed = Mersenne((unsigned long)time(NULL)); + _next_seed = Mersenne((unsigned long)time(nullptr)); _got_first_seed = true; } return _next_seed.get_uint31(); diff --git a/panda/src/mathutil/unionBoundingVolume.I b/panda/src/mathutil/unionBoundingVolume.I index 6212b1f2b8..9c7e782b45 100644 --- a/panda/src/mathutil/unionBoundingVolume.I +++ b/panda/src/mathutil/unionBoundingVolume.I @@ -31,6 +31,6 @@ get_num_components() const { */ INLINE_MATHUTIL const GeometricBoundingVolume *UnionBoundingVolume:: get_component(int n) const { - nassertr(n >= 0 && n < (int)_components.size(), NULL); + nassertr(n >= 0 && n < (int)_components.size(), nullptr); return _components[n]; } diff --git a/panda/src/mathutil/unionBoundingVolume.cxx b/panda/src/mathutil/unionBoundingVolume.cxx index dfc96f8e92..ed575b518b 100644 --- a/panda/src/mathutil/unionBoundingVolume.cxx +++ b/panda/src/mathutil/unionBoundingVolume.cxx @@ -236,7 +236,7 @@ around_geometric(const BoundingVolume **first, nassertr(!(*p)->is_infinite(), false); if (!(*p)->is_empty()) { const GeometricBoundingVolume *volume = (*p)->as_geometric_bounding_volume(); - if (volume != (GeometricBoundingVolume *)NULL) { + if (volume != nullptr) { add_component(volume); } else { set_infinite(); diff --git a/panda/src/movies/flacAudio.cxx b/panda/src/movies/flacAudio.cxx index 8bfbd56ad2..b7c205b25b 100644 --- a/panda/src/movies/flacAudio.cxx +++ b/panda/src/movies/flacAudio.cxx @@ -43,12 +43,12 @@ open() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *stream = vfs->open_read_file(_filename, true); - if (stream == NULL) { - return NULL; + if (stream == nullptr) { + return nullptr; } else { PT(FlacAudioCursor) cursor = new FlacAudioCursor(this, stream); - if (cursor == NULL || !cursor->_is_valid) { - return NULL; + if (cursor == nullptr || !cursor->_is_valid) { + return nullptr; } else { return DCAST(MovieAudioCursor, cursor); } diff --git a/panda/src/movies/flacAudioCursor.cxx b/panda/src/movies/flacAudioCursor.cxx index a4c33822cd..e30fbfba8f 100644 --- a/panda/src/movies/flacAudioCursor.cxx +++ b/panda/src/movies/flacAudioCursor.cxx @@ -26,7 +26,7 @@ extern "C" { */ static size_t cb_read_proc(void *user, void *buffer, size_t size) { istream *stream = (istream *)user; - nassertr(stream != NULL, false); + nassertr(stream != nullptr, false); stream->read((char *)buffer, size); @@ -43,7 +43,7 @@ static size_t cb_read_proc(void *user, void *buffer, size_t size) { */ static bool cb_seek_proc(void *user, int offset) { istream *stream = (istream *)user; - nassertr(stream != NULL, false); + nassertr(stream != nullptr, false); stream->seekg(offset, ios::cur); return !stream->fail(); @@ -59,14 +59,14 @@ FlacAudioCursor:: FlacAudioCursor(FlacAudio *src, istream *stream) : MovieAudioCursor(src), _is_valid(false), - _drflac(NULL) + _drflac(nullptr) { - nassertv(stream != NULL); + nassertv(stream != nullptr); nassertv(stream->good()); _drflac = drflac_open(&cb_read_proc, &cb_seek_proc, (void *)stream); - if (_drflac == NULL) { + if (_drflac == nullptr) { movies_cat.error() << "Failed to open FLAC file.\n"; _is_valid = false; @@ -88,7 +88,7 @@ FlacAudioCursor(FlacAudio *src, istream *stream) : */ FlacAudioCursor:: ~FlacAudioCursor() { - if (_drflac != NULL) { + if (_drflac != nullptr) { drflac_close(_drflac); } } diff --git a/panda/src/movies/microphoneAudio.cxx b/panda/src/movies/microphoneAudio.cxx index bc21c758d9..65ff4010bf 100644 --- a/panda/src/movies/microphoneAudio.cxx +++ b/panda/src/movies/microphoneAudio.cxx @@ -69,6 +69,6 @@ get_num_options() { PT(MicrophoneAudio) MicrophoneAudio:: get_option(int n) { find_all_microphones(); - nassertr((n >= 0) && (n < (int)_all_microphones.size()), NULL); + nassertr((n >= 0) && (n < (int)_all_microphones.size()), nullptr); return _all_microphones[n]; } diff --git a/panda/src/movies/microphoneAudioDS.cxx b/panda/src/movies/microphoneAudioDS.cxx index aa32f0c544..cea9c65f60 100644 --- a/panda/src/movies/microphoneAudioDS.cxx +++ b/panda/src/movies/microphoneAudioDS.cxx @@ -146,7 +146,7 @@ find_all_microphones_ds() { format.nBlockAlign = 2 * chan; format.wBitsPerSample = 16; format.cbSize = 0; - stat = waveInOpen(NULL, i, &format, 0, 0, WAVE_FORMAT_QUERY); + stat = waveInOpen(nullptr, i, &format, 0, 0, WAVE_FORMAT_QUERY); if (stat == MMSYSERR_NOERROR) { PT(MicrophoneAudioDS) p = new MicrophoneAudioDS(); ostringstream name; @@ -235,7 +235,7 @@ open() { if (failed) { delete_buffers(buffers); nassert_raise("Could not allocate audio input buffers."); - return NULL; + return nullptr; } WAVEFORMATEX format; @@ -253,7 +253,7 @@ open() { if (stat != MMSYSERR_NOERROR) { delete_buffers(buffers); nassert_raise("Could not open audio input device."); - return NULL; + return nullptr; } for (int i=0; i<(int)buffers.size(); i++) { @@ -265,7 +265,7 @@ open() { waveInClose(hwav); delete_buffers(buffers); nassert_raise("Could not queue buffers for audio input device."); - return NULL; + return nullptr; } } stat = waveInStart(hwav); @@ -273,7 +273,7 @@ open() { waveInClose(hwav); delete_buffers(buffers); nassert_raise("Could not start recording on input device."); - return NULL; + return nullptr; } return new MicrophoneAudioCursorDS(this, buffers, hwav); } diff --git a/panda/src/movies/movieTypeRegistry.I b/panda/src/movies/movieTypeRegistry.I index a444d91d9b..901abca903 100644 --- a/panda/src/movies/movieTypeRegistry.I +++ b/panda/src/movies/movieTypeRegistry.I @@ -16,7 +16,7 @@ */ INLINE MovieTypeRegistry *MovieTypeRegistry:: get_global_ptr() { - if (_global_ptr == NULL) { + if (_global_ptr == nullptr) { _global_ptr = new MovieTypeRegistry; } diff --git a/panda/src/movies/movieTypeRegistry.cxx b/panda/src/movies/movieTypeRegistry.cxx index 9c747b6fe3..024cf53634 100644 --- a/panda/src/movies/movieTypeRegistry.cxx +++ b/panda/src/movies/movieTypeRegistry.cxx @@ -17,7 +17,7 @@ #include "config_putil.h" #include "load_dso.h" -MovieTypeRegistry *MovieTypeRegistry::_global_ptr = NULL; +MovieTypeRegistry *MovieTypeRegistry::_global_ptr = nullptr; /** * Obtains a MovieVideo that references a file. @@ -104,7 +104,7 @@ load_audio_types() { movies_cat.info() << "loading audio type module: " << name << endl; void *tmp = load_dso(get_plugin_path().get_value(), dlname); - if (tmp == (void *)NULL) { + if (tmp == nullptr) { movies_cat.warning() << "Unable to load " << dlname.to_os_specific() << ": " << load_dso_error() << endl; @@ -220,7 +220,7 @@ load_video_types() { movies_cat.info() << "loading video type module: " << name << endl; void *tmp = load_dso(get_plugin_path().get_value(), dlname); - if (tmp == (void *)NULL) { + if (tmp == nullptr) { movies_cat.warning() << "Unable to load " << dlname.to_os_specific() << ": " << load_dso_error() << endl; @@ -261,7 +261,7 @@ load_movie_library(const string &name) { << "loading video type module: " << name << endl; void *tmp = load_dso(get_plugin_path().get_value(), dlname); - if (tmp == (void *)NULL) { + if (tmp == nullptr) { movies_cat.warning() << "Unable to load " << dlname.to_os_specific() << ": " << load_dso_error() << endl; diff --git a/panda/src/movies/movieVideo.cxx b/panda/src/movies/movieVideo.cxx index 9b6c970472..cdeb797213 100644 --- a/panda/src/movies/movieVideo.cxx +++ b/panda/src/movies/movieVideo.cxx @@ -44,7 +44,7 @@ MovieVideo:: */ PT(MovieVideoCursor) MovieVideo:: open() { - return NULL; + return nullptr; } /** diff --git a/panda/src/movies/movieVideoCursor.cxx b/panda/src/movies/movieVideoCursor.cxx index f1f531453a..761e7e2fa6 100644 --- a/panda/src/movies/movieVideoCursor.cxx +++ b/panda/src/movies/movieVideoCursor.cxx @@ -97,7 +97,7 @@ set_time(double timestamp, int loop_count) { */ PT(MovieVideoCursor::Buffer) MovieVideoCursor:: fetch_buffer() { - return NULL; + return nullptr; } /** @@ -105,7 +105,7 @@ fetch_buffer() { */ void MovieVideoCursor:: apply_to_texture(const Buffer *buffer, Texture *t, int page) { - if (buffer == NULL) { + if (buffer == nullptr) { return; } @@ -162,7 +162,7 @@ apply_to_texture(const Buffer *buffer, Texture *t, int page) { */ void MovieVideoCursor:: apply_to_texture_alpha(const Buffer *buffer, Texture *t, int page, int alpha_src) { - if (buffer == NULL) { + if (buffer == nullptr) { return; } @@ -216,7 +216,7 @@ apply_to_texture_alpha(const Buffer *buffer, Texture *t, int page, int alpha_src */ void MovieVideoCursor:: apply_to_texture_rgb(const Buffer *buffer, Texture *t, int page) { - if (buffer == NULL) { + if (buffer == nullptr) { return; } @@ -259,7 +259,7 @@ apply_to_texture_rgb(const Buffer *buffer, Texture *t, int page) { */ MovieVideoCursor::Buffer *MovieVideoCursor:: get_standard_buffer() { - if (_standard_buffer == NULL) { + if (_standard_buffer == nullptr) { _standard_buffer = make_new_buffer(); } return _standard_buffer; diff --git a/panda/src/movies/movieVideoCursor.h b/panda/src/movies/movieVideoCursor.h index 0fb11fe04b..8357f14693 100644 --- a/panda/src/movies/movieVideoCursor.h +++ b/panda/src/movies/movieVideoCursor.h @@ -40,7 +40,7 @@ class BamReader; */ class EXPCL_PANDA_MOVIES MovieVideoCursor : public TypedWritableReferenceCount { protected: - MovieVideoCursor(MovieVideo *src = NULL); + MovieVideoCursor(MovieVideo *src = nullptr); PUBLISHED: virtual ~MovieVideoCursor(); diff --git a/panda/src/movies/userDataAudio.cxx b/panda/src/movies/userDataAudio.cxx index 7575ad977b..81865e3b8b 100644 --- a/panda/src/movies/userDataAudio.cxx +++ b/panda/src/movies/userDataAudio.cxx @@ -25,7 +25,7 @@ UserDataAudio(int rate, int channels, bool remove_after_read) : MovieAudio("User Data Audio"), _desired_rate(rate), _desired_channels(channels), - _cursor(NULL), + _cursor(nullptr), _aborted(false), _remove_after_read(remove_after_read) { @@ -46,7 +46,7 @@ PT(MovieAudioCursor) UserDataAudio:: open() { if (_cursor) { nassert_raise("A UserDataAudio can only be opened by one consumer at a time."); - return NULL; + return nullptr; } _cursor = new UserDataAudioCursor(this); return _cursor; diff --git a/panda/src/movies/userDataAudioCursor.cxx b/panda/src/movies/userDataAudioCursor.cxx index e0494cf53e..93bab206fa 100644 --- a/panda/src/movies/userDataAudioCursor.cxx +++ b/panda/src/movies/userDataAudioCursor.cxx @@ -39,7 +39,7 @@ UserDataAudioCursor(UserDataAudio *src) : UserDataAudioCursor:: ~UserDataAudioCursor() { UserDataAudio *source = (UserDataAudio*)(MovieAudio*)_source; - source->_cursor = NULL; + source->_cursor = nullptr; } /** diff --git a/panda/src/movies/vorbisAudio.cxx b/panda/src/movies/vorbisAudio.cxx index bd704e2bd1..b3e32c84f4 100644 --- a/panda/src/movies/vorbisAudio.cxx +++ b/panda/src/movies/vorbisAudio.cxx @@ -45,12 +45,12 @@ open() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *stream = vfs->open_read_file(_filename, true); - if (stream == NULL) { - return NULL; + if (stream == nullptr) { + return nullptr; } else { PT(VorbisAudioCursor) cursor = new VorbisAudioCursor(this, stream); - if (cursor == NULL || !cursor->_is_valid) { - return NULL; + if (cursor == nullptr || !cursor->_is_valid) { + return nullptr; } else { return DCAST(MovieAudioCursor, cursor); } diff --git a/panda/src/movies/vorbisAudioCursor.cxx b/panda/src/movies/vorbisAudioCursor.cxx index 9d751629c2..6f6002158f 100644 --- a/panda/src/movies/vorbisAudioCursor.cxx +++ b/panda/src/movies/vorbisAudioCursor.cxx @@ -28,7 +28,7 @@ VorbisAudioCursor(VorbisAudio *src, istream *stream) : _is_valid(false), _bitstream(0) { - nassertv(stream != NULL); + nassertv(stream != nullptr); nassertv(stream->good()); // Set up the callbacks to read via the VFS. @@ -40,10 +40,10 @@ VorbisAudioCursor(VorbisAudio *src, istream *stream) : if (vorbis_enable_seek) { callbacks.seek_func = &cb_seek_func; } else { - callbacks.seek_func = NULL; + callbacks.seek_func = nullptr; } - if (ov_open_callbacks((void*) stream, &_ov, NULL, 0, callbacks) != 0) { + if (ov_open_callbacks((void*) stream, &_ov, nullptr, 0, callbacks) != 0) { movies_cat.error() << "Failed to read Ogg Vorbis file.\n"; return; @@ -162,7 +162,7 @@ read_samples(int n, int16_t *data) { size_t VorbisAudioCursor:: cb_read_func(void *ptr, size_t size, size_t nmemb, void *datasource) { istream *stream = (istream*) datasource; - nassertr(stream != NULL, -1); + nassertr(stream != nullptr, -1); stream->read((char *)ptr, size * nmemb); @@ -185,7 +185,7 @@ cb_seek_func(void *datasource, ogg_int64_t offset, int whence) { } istream *stream = (istream*) datasource; - nassertr(stream != NULL, -1); + nassertr(stream != nullptr, -1); switch (whence) { case SEEK_SET: @@ -239,7 +239,7 @@ cb_seek_func(void *datasource, ogg_int64_t offset, int whence) { int VorbisAudioCursor:: cb_close_func(void *datasource) { istream *stream = (istream*) datasource; - nassertr(stream != NULL, -1); + nassertr(stream != nullptr, -1); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->close_read_file(stream); @@ -255,7 +255,7 @@ cb_close_func(void *datasource) { long VorbisAudioCursor:: cb_tell_func(void *datasource) { istream *stream = (istream*) datasource; - nassertr(stream != NULL, -1); + nassertr(stream != nullptr, -1); return stream->tellg(); } diff --git a/panda/src/movies/wavAudio.cxx b/panda/src/movies/wavAudio.cxx index 0240c37a94..685a0a7d68 100644 --- a/panda/src/movies/wavAudio.cxx +++ b/panda/src/movies/wavAudio.cxx @@ -43,12 +43,12 @@ open() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *stream = vfs->open_read_file(_filename, true); - if (stream == NULL) { - return NULL; + if (stream == nullptr) { + return nullptr; } else { PT(WavAudioCursor) cursor = new WavAudioCursor(this, stream); - if (cursor == NULL || !cursor->_is_valid) { - return NULL; + if (cursor == nullptr || !cursor->_is_valid) { + return nullptr; } else { return DCAST(MovieAudioCursor, cursor); } diff --git a/panda/src/movies/wavAudioCursor.cxx b/panda/src/movies/wavAudioCursor.cxx index ccfaa9733e..5f6cf05047 100644 --- a/panda/src/movies/wavAudioCursor.cxx +++ b/panda/src/movies/wavAudioCursor.cxx @@ -103,7 +103,7 @@ WavAudioCursor(WavAudio *src, istream *stream) : _data_pos(0), _data_size(0) { - nassertv(stream != NULL); + nassertv(stream != nullptr); // Beginning of "RIFF" chunk. unsigned char magic[4]; @@ -279,7 +279,7 @@ WavAudioCursor(WavAudio *src, istream *stream) : */ WavAudioCursor:: ~WavAudioCursor() { - if (_stream != NULL) { + if (_stream != nullptr) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->close_read_file(_stream); } diff --git a/panda/src/nativenet/membuffer.I b/panda/src/nativenet/membuffer.I index 157df8301a..a2e7ad6d1d 100644 --- a/panda/src/nativenet/membuffer.I +++ b/panda/src/nativenet/membuffer.I @@ -6,11 +6,11 @@ inline void MemBuffer:: ClearBuffer(void) { if (_BufferLocal == true) { - if (_Buffer != NULL) { + if (_Buffer != nullptr) { delete[] _Buffer; } - _Buffer = NULL; + _Buffer = nullptr; } } @@ -29,7 +29,7 @@ AllocBuffer(size_t len) { */ inline MemBuffer:: MemBuffer(void) { - _Buffer = NULL; + _Buffer = nullptr; _BufferLocal = false; _BufferLen = 0; } @@ -87,7 +87,7 @@ GrowBuffer(size_t new_len) { char *tmp = new char[len]; - if (_Buffer != NULL) { + if (_Buffer != nullptr) { memcpy(tmp,_Buffer,_BufferLen); } diff --git a/panda/src/nativenet/socket_address.cxx b/panda/src/nativenet/socket_address.cxx index cf27b0771c..3d7882aeed 100644 --- a/panda/src/nativenet/socket_address.cxx +++ b/panda/src/nativenet/socket_address.cxx @@ -26,12 +26,12 @@ set_host(const std::string &hostname, unsigned short port) { return set_broadcast(port); } - struct addrinfo hints, *res = NULL; + struct addrinfo hints, *res = nullptr; memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_ADDRCONFIG; hints.ai_family = support_ipv6 ? AF_UNSPEC : AF_INET; - if (getaddrinfo(hostname.c_str(), NULL, &hints, &res)) { + if (getaddrinfo(hostname.c_str(), nullptr, &hints, &res)) { return false; } @@ -92,10 +92,10 @@ get_ip() const { buf[0] = 0; if (_storage.ss_family == AF_INET) { - getnameinfo(&_addr, sizeof(sockaddr_in), buf, sizeof(buf), NULL, 0, NI_NUMERICHOST); + getnameinfo(&_addr, sizeof(sockaddr_in), buf, sizeof(buf), nullptr, 0, NI_NUMERICHOST); } else if (_storage.ss_family == AF_INET6) { - getnameinfo(&_addr, sizeof(sockaddr_in6), buf, sizeof(buf), NULL, 0, NI_NUMERICHOST); + getnameinfo(&_addr, sizeof(sockaddr_in6), buf, sizeof(buf), nullptr, 0, NI_NUMERICHOST); } else { nassertr(false, std::string()); @@ -114,13 +114,13 @@ get_ip_port() const { buf[0] = 0; if (_storage.ss_family == AF_INET) { - getnameinfo(&_addr, sizeof(sockaddr_in), buf, sizeof(buf), NULL, 0, NI_NUMERICHOST); + getnameinfo(&_addr, sizeof(sockaddr_in), buf, sizeof(buf), nullptr, 0, NI_NUMERICHOST); sprintf(buf + strlen(buf), ":%hu", get_port()); } else if (_storage.ss_family == AF_INET6) { // Protect the IPv6 address within square brackets. buf[0] = '['; - getnameinfo(&_addr, sizeof(sockaddr_in6), buf + 1, sizeof(buf) - 1, NULL, 0, NI_NUMERICHOST); + getnameinfo(&_addr, sizeof(sockaddr_in6), buf + 1, sizeof(buf) - 1, nullptr, 0, NI_NUMERICHOST); sprintf(buf + strlen(buf), "]:%hu", get_port()); } else { diff --git a/panda/src/nativenet/socket_fdset.h b/panda/src/nativenet/socket_fdset.h index 45c990bf27..7da876c0f8 100644 --- a/panda/src/nativenet/socket_fdset.h +++ b/panda/src/nativenet/socket_fdset.h @@ -90,13 +90,13 @@ inline int Socket_fdset::WaitForRead(bool zeroFds, uint32_t sleep_time) { int retVal = 0; if (sleep_time == 0xffffffff) { - retVal = DO_SELECT(_maxid + 1, &_the_set, NULL, NULL, NULL); + retVal = DO_SELECT(_maxid + 1, &_the_set, nullptr, nullptr, nullptr); } else { timeval timeoutValue; timeoutValue.tv_sec = sleep_time / 1000; timeoutValue.tv_usec = (sleep_time % 1000) * 1000; - retVal = DO_SELECT(_maxid + 1, &_the_set, NULL, NULL, &timeoutValue); + retVal = DO_SELECT(_maxid + 1, &_the_set, nullptr, nullptr, &timeoutValue); } if (zeroFds) clear(); @@ -111,7 +111,7 @@ inline int Socket_fdset::WaitForRead(bool zeroFds, const Time_Span & timeout) { timeval localtv = timeout.GetTval(); - int retVal = DO_SELECT(_maxid + 1, &_the_set, NULL, NULL, &localtv); + int retVal = DO_SELECT(_maxid + 1, &_the_set, nullptr, nullptr, &localtv); if (zeroFds) clear(); @@ -144,7 +144,7 @@ inline int Socket_fdset::WaitForWrite(bool zeroFds, uint32_t sleep_time) int retVal = 0; if (sleep_time == 0xffffffff) { - retVal = DO_SELECT(_maxid + 1, NULL, &_the_set, NULL, NULL); + retVal = DO_SELECT(_maxid + 1, nullptr, &_the_set, nullptr, nullptr); } else { @@ -152,7 +152,7 @@ inline int Socket_fdset::WaitForWrite(bool zeroFds, uint32_t sleep_time) timeoutValue.tv_sec = sleep_time / 1000; timeoutValue.tv_usec = (sleep_time % 1000) * 1000; - retVal = DO_SELECT(_maxid + 1, NULL, &_the_set, NULL, &timeoutValue); + retVal = DO_SELECT(_maxid + 1, nullptr, &_the_set, nullptr, &timeoutValue); } if (zeroFds) clear(); @@ -169,7 +169,7 @@ inline int Socket_fdset::WaitForError(bool zeroFds, uint32_t sleep_time) int retVal = 0; if (sleep_time == 0xffffffff) { - retVal = DO_SELECT(_maxid + 1, NULL, NULL, &_the_set, NULL); + retVal = DO_SELECT(_maxid + 1, nullptr, nullptr, &_the_set, nullptr); } else { @@ -177,7 +177,7 @@ inline int Socket_fdset::WaitForError(bool zeroFds, uint32_t sleep_time) timeoutValue.tv_sec = sleep_time / 1000; timeoutValue.tv_usec = (sleep_time % 1000) * 1000; - retVal = DO_SELECT(_maxid + 1, NULL, NULL, &_the_set, &timeoutValue); + retVal = DO_SELECT(_maxid + 1, nullptr, nullptr, &_the_set, &timeoutValue); } if (zeroFds) clear(); diff --git a/panda/src/nativenet/socket_tcp_ssl.h b/panda/src/nativenet/socket_tcp_ssl.h index 83b45b4389..8f16f188dc 100644 --- a/panda/src/nativenet/socket_tcp_ssl.h +++ b/panda/src/nativenet/socket_tcp_ssl.h @@ -30,10 +30,10 @@ struct SSlStartup { ~SSlStartup() { SSL_CTX_free (global_ssl_ctx); - global_ssl_ctx = NULL; + global_ssl_ctx = nullptr; } - bool isactive() { return global_ssl_ctx != NULL; }; + bool isactive() { return global_ssl_ctx != nullptr; }; }; /** @@ -42,7 +42,7 @@ struct SSlStartup { class EXPCL_PANDA_NATIVENET Socket_TCP_SSL : public Socket_IP { public: inline Socket_TCP_SSL(SOCKET); - inline Socket_TCP_SSL() : _ssl(NULL) {} + inline Socket_TCP_SSL() : _ssl(nullptr) {} virtual inline ~Socket_TCP_SSL() { @@ -67,10 +67,10 @@ private: SSL *_ssl; void CleanSslUp() { - if (_ssl != NULL) { + if (_ssl != nullptr) { SSL_shutdown(_ssl); SSL_free(_ssl); - _ssl = NULL; + _ssl = nullptr; } } @@ -101,7 +101,7 @@ Socket_TCP_SSL(SOCKET sck) : ::Socket_IP(sck) { SetNonBlocking(); // maybe should be blocking? _ssl = SSL_new(global_ssl_ctx); - if (_ssl == NULL) { + if (_ssl == nullptr) { return; } @@ -188,7 +188,7 @@ ActiveOpen(const Socket_Address &theaddress) { } _ssl = SSL_new(global_ssl_ctx); - if (_ssl == NULL) { + if (_ssl == nullptr) { return false; } SSL_set_fd(_ssl, (int)GetSocket()); @@ -206,7 +206,7 @@ ActiveOpen(const Socket_Address &theaddress) { */ inline int Socket_TCP_SSL:: SendData(const char *data, int size) { - if (_ssl == NULL) { + if (_ssl == nullptr) { return -1; } @@ -221,7 +221,7 @@ SendData(const char *data, int size) { */ inline int Socket_TCP_SSL:: RecvData(char *data, int len) { - if (_ssl == NULL) { + if (_ssl == nullptr) { return -1; } @@ -235,7 +235,7 @@ RecvData(char *data, int len) { */ inline bool Socket_TCP_SSL:: ErrorIs_WouldBlocking(int err) { - if (_ssl == NULL || err >= 0) { + if (_ssl == nullptr || err >= 0) { nativenet_cat.warning() << "Socket_TCP_SSL::ErrorIs_WouldBlocking->Called With Error number " << err << " or _ssl is NULL\n"; diff --git a/panda/src/nativenet/time_accumulator.h b/panda/src/nativenet/time_accumulator.h index 32d0747310..3b7959a018 100644 --- a/panda/src/nativenet/time_accumulator.h +++ b/panda/src/nativenet/time_accumulator.h @@ -26,7 +26,7 @@ inline void Time_Accumulator::Set(const Time_Span & in) // this seems to make the most since .. if you are running the clock right // know... assume the timespane you are passing in is inclusive.. but keep // clock running.. May need to rethink this... - if(_accum_start != NULL) + if(_accum_start != nullptr) { Stop(); Start(); @@ -35,7 +35,7 @@ inline void Time_Accumulator::Set(const Time_Span & in) /** * */ -inline Time_Accumulator::Time_Accumulator() : _total_time(0,0,0,0,0), _accum_start(NULL) +inline Time_Accumulator::Time_Accumulator() : _total_time(0,0,0,0,0), _accum_start(nullptr) { } /** @@ -43,7 +43,7 @@ inline Time_Accumulator::Time_Accumulator() : _total_time(0,0,0,0,0), _accum_sta */ inline Time_Accumulator::~Time_Accumulator() { - if(_accum_start != NULL) + if(_accum_start != nullptr) delete _accum_start; } /** @@ -51,7 +51,7 @@ inline Time_Accumulator::~Time_Accumulator() */ inline void Time_Accumulator::Start() { - if(_accum_start == NULL) + if(_accum_start == nullptr) _accum_start = new Time_Clock(); } /** @@ -59,12 +59,12 @@ inline void Time_Accumulator::Start() */ inline void Time_Accumulator::Stop() { - if(_accum_start != NULL) + if(_accum_start != nullptr) { Time_Span work1(Time_Clock::GetCurrentTime() - *_accum_start); _total_time += work1; delete _accum_start; - _accum_start = NULL; + _accum_start = nullptr; } } /** @@ -72,10 +72,10 @@ inline void Time_Accumulator::Stop() */ void Time_Accumulator::Reset() { - if(_accum_start != NULL) + if(_accum_start != nullptr) { delete _accum_start; - _accum_start = NULL; + _accum_start = nullptr; } _total_time.Set(0,0,0,0,0); } @@ -85,7 +85,7 @@ void Time_Accumulator::Reset() inline Time_Span Time_Accumulator::Report() { Time_Span answer(_total_time); - if(_accum_start != NULL) + if(_accum_start != nullptr) { Time_Span ww(Time_Clock::GetCurrentTime() - *_accum_start); answer += ww; diff --git a/panda/src/nativenet/time_clock.h b/panda/src/nativenet/time_clock.h index 2c326fd7da..08f3616377 100644 --- a/panda/src/nativenet/time_clock.h +++ b/panda/src/nativenet/time_clock.h @@ -134,7 +134,7 @@ GetCurrentTime() { */ inline Time_Clock:: Time_Clock() { - gettimeofday(&_my_time, NULL); + gettimeofday(&_my_time, nullptr); } /** @@ -142,7 +142,7 @@ Time_Clock() { */ inline void Time_Clock:: ToCurrentTime() { - gettimeofday(&_my_time, NULL); + gettimeofday(&_my_time, nullptr); } /** @@ -152,9 +152,9 @@ ToCurrentTime() { */ inline struct tm *Time_Clock:: GetGmtTm(struct tm *ptm) const { - nassertr(ptm != NULL, NULL); + nassertr(ptm != nullptr, nullptr); #ifdef _WIN32 - return (gmtime_s(ptm, (const time_t *)&_my_time.tv_sec) == 0) ? ptm : NULL; + return (gmtime_s(ptm, (const time_t *)&_my_time.tv_sec) == 0) ? ptm : nullptr; #else return gmtime_r((const time_t *)&_my_time.tv_sec, ptm); #endif @@ -165,9 +165,9 @@ GetGmtTm(struct tm *ptm) const { */ inline struct tm *Time_Clock:: GetLocalTm(struct tm *ptm) const { - nassertr(ptm != NULL, NULL); + nassertr(ptm != nullptr, nullptr); #ifdef _WIN32 - return (localtime_s(ptm, (const time_t *)&_my_time.tv_sec) == 0) ? ptm : NULL; + return (localtime_s(ptm, (const time_t *)&_my_time.tv_sec) == 0) ? ptm : nullptr; #else return localtime_r((const time_t *)&_my_time.tv_sec, ptm); #endif @@ -210,7 +210,7 @@ Format(const char *pFormat) const { char szBuffer1[maxTimeBufferSize]; struct tm tmTemp; - if (GetLocalTm(&tmTemp) == NULL || + if (GetLocalTm(&tmTemp) == nullptr || !strftime(szBuffer1, sizeof(szBuffer1), szBuffer, &tmTemp)) { szBuffer1[0] = '\0'; } @@ -253,7 +253,7 @@ FormatGmt(const char *pFormat) const { char szBuffer1[maxTimeBufferSize]; struct tm tmTemp; - if (GetGmtTm(&tmTemp) == NULL || + if (GetGmtTm(&tmTemp) == nullptr || !strftime(szBuffer1, sizeof(szBuffer1), szBuffer, &tmTemp)) { szBuffer1[0] = '\0'; } diff --git a/panda/src/net/config_net.cxx b/panda/src/net/config_net.cxx index ae717bb580..9fcbdcbe91 100644 --- a/panda/src/net/config_net.cxx +++ b/panda/src/net/config_net.cxx @@ -40,9 +40,9 @@ ConfigureFn(config_net) { int get_net_max_write_queue() { - static ConfigVariableInt *net_max_write_queue = NULL; + static ConfigVariableInt *net_max_write_queue = nullptr; - if (net_max_write_queue == (ConfigVariableInt *)NULL) { + if (net_max_write_queue == nullptr) { net_max_write_queue = new ConfigVariableInt ("net-max-write-queue", 10000, PRC_DESC("This limits the number of datagrams in a ConnectionWriter's " @@ -54,9 +54,9 @@ get_net_max_write_queue() { int get_net_max_response_queue() { - static ConfigVariableInt *net_max_response_queue = NULL; + static ConfigVariableInt *net_max_response_queue = nullptr; - if (net_max_response_queue == (ConfigVariableInt *)NULL) { + if (net_max_response_queue == nullptr) { net_max_response_queue = new ConfigVariableInt ("net-max-response-queue", 50000, PRC_DESC("This limits the number of datagrams, messages, what have you, " @@ -69,9 +69,9 @@ get_net_max_response_queue() { bool get_net_error_abort() { - static ConfigVariableBool *net_error_abort = NULL; + static ConfigVariableBool *net_error_abort = nullptr; - if (net_error_abort == (ConfigVariableBool *)NULL) { + if (net_error_abort == nullptr) { net_error_abort = new ConfigVariableBool ("net-error-abort", false); } @@ -81,9 +81,9 @@ get_net_error_abort() { double get_net_max_poll_cycle() { - static ConfigVariableDouble *net_max_poll_cycle = NULL; + static ConfigVariableDouble *net_max_poll_cycle = nullptr; - if (net_max_poll_cycle == (ConfigVariableDouble *)NULL) { + if (net_max_poll_cycle == nullptr) { net_max_poll_cycle = new ConfigVariableDouble ("net-max-poll-cycle", 0.2, PRC_DESC("Specifies the maximum amount of time, in seconds, to " @@ -100,9 +100,9 @@ get_net_max_poll_cycle() { double get_net_max_block() { - static ConfigVariableDouble *net_max_block = NULL; + static ConfigVariableDouble *net_max_block = nullptr; - if (net_max_block == (ConfigVariableDouble *)NULL) { + if (net_max_block == nullptr) { net_max_block = new ConfigVariableDouble ("net-max-block", 0.01, PRC_DESC("Specifies the maximum amount of time, in seconds, to " diff --git a/panda/src/net/connection.cxx b/panda/src/net/connection.cxx index 4c42614f7c..1e96a758de 100644 --- a/panda/src/net/connection.cxx +++ b/panda/src/net/connection.cxx @@ -60,7 +60,7 @@ Connection:: net_cat.info() << "Deleting connection " << (void *)this << "\n"; - if (_socket != (Socket_IP *)NULL) { + if (_socket != nullptr) { flush(); _socket->Close(); @@ -294,7 +294,7 @@ set_max_segment(int size) { */ bool Connection:: send_datagram(const NetDatagram &datagram, int tcp_header_size) { - nassertr(_socket != (Socket_IP *)NULL, false); + nassertr(_socket != nullptr, false); if (_socket->is_exact_type(Socket_UDP::get_class_type())) { // We have to send UDP right away. @@ -367,7 +367,7 @@ send_datagram(const NetDatagram &datagram, int tcp_header_size) { */ bool Connection:: send_raw_datagram(const NetDatagram &datagram) { - nassertr(_socket != (Socket_IP *)NULL, false); + nassertr(_socket != nullptr, false); if (_socket->is_exact_type(Socket_UDP::get_class_type())) { // We have to send UDP right away. @@ -483,7 +483,7 @@ check_send_error(bool okflag) { // Assume any error means the connection has been reset; tell our manager // about it and ignore it. - if (_manager != (ConnectionManager *)NULL) { + if (_manager != nullptr) { _manager->flush_read_connection(this); _manager->connection_reset(this, okflag); } diff --git a/panda/src/net/connectionListener.cxx b/panda/src/net/connectionListener.cxx index c959051653..a48791b24d 100644 --- a/panda/src/net/connectionListener.cxx +++ b/panda/src/net/connectionListener.cxx @@ -82,7 +82,7 @@ process_incoming_data(SocketInfo *sinfo) { << "\n"; PT(Connection) new_connection = new Connection(_manager, session); - if (_manager != (ConnectionManager *)NULL) { + if (_manager != nullptr) { _manager->new_connection(new_connection); } connection_opened(sinfo->_connection, net_addr, new_connection); diff --git a/panda/src/net/connectionManager.cxx b/panda/src/net/connectionManager.cxx index 8a0bfc1e86..0d7da68000 100644 --- a/panda/src/net/connectionManager.cxx +++ b/panda/src/net/connectionManager.cxx @@ -328,7 +328,7 @@ open_TCP_client_connection(const string &hostname, uint16_t port, */ bool ConnectionManager:: close_connection(const PT(Connection) &connection) { - if (connection != (Connection *)NULL) { + if (connection != nullptr) { connection->flush(); } @@ -479,13 +479,13 @@ scan_interfaces() { int flags = GAA_FLAG_INCLUDE_PREFIX | GAA_FLAG_SKIP_UNICAST | GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER; ULONG family = support_ipv6 ? AF_UNSPEC : AF_INET; ULONG buffer_size = 0; - ULONG result = GetAdaptersAddresses(family, flags, NULL, NULL, &buffer_size); + ULONG result = GetAdaptersAddresses(family, flags, nullptr, nullptr, &buffer_size); if (result == ERROR_BUFFER_OVERFLOW) { IP_ADAPTER_ADDRESSES *addresses = (IP_ADAPTER_ADDRESSES *)PANDA_MALLOC_ARRAY(buffer_size); - result = GetAdaptersAddresses(family, flags, NULL, addresses, &buffer_size); + result = GetAdaptersAddresses(family, flags, nullptr, addresses, &buffer_size); if (result == ERROR_SUCCESS) { IP_ADAPTER_ADDRESSES *p = addresses; - while (p != NULL) { + while (p != nullptr) { // p->AdapterName appears to be a GUID. Not sure if this is actually // useful to anyone; we'll store the "friendly name" instead. TextEncoder encoder; @@ -505,7 +505,7 @@ scan_interfaces() { NetAddress addresses[3]; IP_ADAPTER_PREFIX *m = p->FirstPrefix; int mc = 0; - while (m != NULL && mc < 3) { + while (m != nullptr && mc < 3) { addresses[mc] = NetAddress(Socket_Address(*m->Address.lpSockaddr)); m = m->Next; ++mc; @@ -551,20 +551,20 @@ scan_interfaces() { } struct ifaddrs *p = ifa; - while (p != NULL) { + while (p != nullptr) { if (p->ifa_addr->sa_family == AF_INET || (support_ipv6 && p->ifa_addr->sa_family == AF_INET6)) { Interface iface; iface.set_name(p->ifa_name); - if (p->ifa_addr != NULL) { + if (p->ifa_addr != nullptr) { iface.set_ip(NetAddress(Socket_Address(*p->ifa_addr))); } - if (p->ifa_netmask != NULL) { + if (p->ifa_netmask != nullptr) { iface.set_netmask(NetAddress(Socket_Address(*p->ifa_netmask))); } - if ((p->ifa_flags & IFF_BROADCAST) && p->ifa_broadaddr != NULL) { + if ((p->ifa_flags & IFF_BROADCAST) && p->ifa_broadaddr != nullptr) { iface.set_broadcast(NetAddress(Socket_Address(*p->ifa_broadaddr))); - } else if ((p->ifa_flags & IFF_POINTOPOINT) && p->ifa_dstaddr != NULL) { + } else if ((p->ifa_flags & IFF_POINTOPOINT) && p->ifa_dstaddr != nullptr) { iface.set_p2p(NetAddress(Socket_Address(*p->ifa_dstaddr))); } _interfaces.push_back(iface); diff --git a/panda/src/net/connectionReader.cxx b/panda/src/net/connectionReader.cxx index 0ca114e476..4f9a31dca5 100644 --- a/panda/src/net/connectionReader.cxx +++ b/panda/src/net/connectionReader.cxx @@ -132,7 +132,7 @@ ConnectionReader(ConnectionManager *manager, int num_threads, */ ConnectionReader:: ~ConnectionReader() { - if (_manager != (ConnectionManager *)NULL) { + if (_manager != nullptr) { _manager->remove_reader(this); } @@ -172,7 +172,7 @@ ConnectionReader:: */ bool ConnectionReader:: add_connection(Connection *connection) { - nassertr(connection != (Connection *)NULL, false); + nassertr(connection != nullptr, false); LightMutexHolder holder(_sockets_mutex); @@ -261,11 +261,11 @@ poll() { } SocketInfo *sinfo = get_next_available_socket(false, -2); - if (sinfo != (SocketInfo *)NULL) { + if (sinfo != nullptr) { double max_poll_cycle = get_net_max_poll_cycle(); if (max_poll_cycle < 0.0) { // Continue to read all data. - while (sinfo != (SocketInfo *)NULL) { + while (sinfo != nullptr) { process_incoming_data(sinfo); sinfo = get_next_available_socket(false, -2); } @@ -275,7 +275,7 @@ poll() { TrueClock *global_clock = TrueClock::get_global_ptr(); double stop = global_clock->get_short_time() + max_poll_cycle; - while (sinfo != (SocketInfo *)NULL) { + while (sinfo != nullptr) { process_incoming_data(sinfo); if (global_clock->get_short_time() >= stop) { return; @@ -406,7 +406,7 @@ flush_read_connection(Connection *connection) { */ void ConnectionReader:: clear_manager() { - _manager = (ConnectionManager *)NULL; + _manager = nullptr; } /** @@ -465,7 +465,7 @@ process_incoming_udp_data(SocketInfo *sinfo) { } else if (bytes_read == 0) { // The socket was closed (!). This shouldn't happen with a UDP // connection. Oh well. Report that and return. - if (_manager != (ConnectionManager *)NULL) { + if (_manager != nullptr) { _manager->connection_reset(sinfo->_connection, 0); } finish_socket(sinfo); @@ -547,7 +547,7 @@ process_incoming_tcp_data(SocketInfo *sinfo) { if (bytes_read <= 0) { // The socket was closed. Report that and return. - if (_manager != (ConnectionManager *)NULL) { + if (_manager != nullptr) { _manager->connection_reset(sinfo->_connection, 0); } finish_socket(sinfo); @@ -601,7 +601,7 @@ process_incoming_tcp_data(SocketInfo *sinfo) { if (bytes_read <= 0) { // The socket was closed. Report that and return. - if (_manager != (ConnectionManager *)NULL) { + if (_manager != nullptr) { _manager->connection_reset(sinfo->_connection, 0); } finish_socket(sinfo); @@ -674,7 +674,7 @@ process_raw_incoming_udp_data(SocketInfo *sinfo) { } else if (bytes_read == 0) { // The socket was closed (!). This shouldn't happen with a UDP // connection. Oh well. Report that and return. - if (_manager != (ConnectionManager *)NULL) { + if (_manager != nullptr) { _manager->connection_reset(sinfo->_connection, 0); } finish_socket(sinfo); @@ -728,7 +728,7 @@ process_raw_incoming_tcp_data(SocketInfo *sinfo) { if (bytes_read <= 0) { // The socket was closed. Report that and return. - if (_manager != (ConnectionManager *)NULL) { + if (_manager != nullptr) { _manager->connection_reset(sinfo->_connection, 0); } finish_socket(sinfo); @@ -772,7 +772,7 @@ thread_run(int thread_index) { while (!_shutdown) { SocketInfo *sinfo = get_next_available_socket(true, thread_index); - if (sinfo != (SocketInfo *)NULL) { + if (sinfo != nullptr) { process_incoming_data(sinfo); Thread::consider_yield(); } else { @@ -801,7 +801,7 @@ get_next_available_socket(bool allow_block, int current_thread_index) { // First, check the result from the previous select call. If there are // any sockets remaining there, process them first. while (!_shutdown && _num_results > 0) { - nassertr(_next_index < (int)_selecting_sockets.size(), NULL); + nassertr(_next_index < (int)_selecting_sockets.size(), nullptr); int i = _next_index; _next_index++; @@ -858,7 +858,7 @@ get_next_available_socket(bool allow_block, int current_thread_index) { } else if (_num_results < 0) { // If we had an error, just return. But yield the timeslice first. Thread::force_yield(); - return (SocketInfo *)NULL; + return nullptr; } } while (!_shutdown && interrupted); @@ -868,7 +868,7 @@ get_next_available_socket(bool allow_block, int current_thread_index) { // (b) return from PR_Poll() with no sockets available. } while (!_shutdown && _num_results > 0); - return (SocketInfo *)NULL; + return nullptr; } diff --git a/panda/src/net/connectionWriter.cxx b/panda/src/net/connectionWriter.cxx index a07b52fa63..554f8118c1 100644 --- a/panda/src/net/connectionWriter.cxx +++ b/panda/src/net/connectionWriter.cxx @@ -91,7 +91,7 @@ ConnectionWriter(ConnectionManager *manager, int num_threads, */ ConnectionWriter:: ~ConnectionWriter() { - if (_manager != (ConnectionManager *)NULL) { + if (_manager != nullptr) { _manager->remove_writer(this); } @@ -142,7 +142,7 @@ get_current_queue_size() const { bool ConnectionWriter:: send(const Datagram &datagram, const PT(Connection) &connection, bool block) { nassertr(!_shutdown, false); - nassertr(connection != (Connection *)NULL, false); + nassertr(connection != nullptr, false); nassertr(connection->get_socket()->is_exact_type(Socket_TCP::get_class_type()), false); NetDatagram copy(datagram); @@ -177,7 +177,7 @@ bool ConnectionWriter:: send(const Datagram &datagram, const PT(Connection) &connection, const NetAddress &address, bool block) { nassertr(!_shutdown, false); - nassertr(connection != (Connection *)NULL, false); + nassertr(connection != nullptr, false); nassertr(connection->get_socket()->is_exact_type(Socket_UDP::get_class_type()), false); if ((int)datagram.get_length() > maximum_udp_datagram) { @@ -309,7 +309,7 @@ shutdown() { */ void ConnectionWriter:: clear_manager() { - _manager = (ConnectionManager *)NULL; + _manager = nullptr; shutdown(); } diff --git a/panda/src/net/datagramSinkNet.cxx b/panda/src/net/datagramSinkNet.cxx index d09bc465ac..89e0d7c294 100644 --- a/panda/src/net/datagramSinkNet.cxx +++ b/panda/src/net/datagramSinkNet.cxx @@ -32,7 +32,7 @@ DatagramSinkNet(ConnectionManager *manager, int num_threads) : */ bool DatagramSinkNet:: put_datagram(const Datagram &data) { - if (_target == (Connection *)NULL) { + if (_target == nullptr) { return false; } return send(data, _target, true); @@ -44,7 +44,7 @@ put_datagram(const Datagram &data) { */ bool DatagramSinkNet:: is_error() { - return (_target == (Connection *)NULL || _target->get_socket() == (Socket_IP *)NULL); + return (_target == nullptr || _target->get_socket() == nullptr); } /** @@ -53,7 +53,7 @@ is_error() { */ void DatagramSinkNet:: flush() { - if (_target != (Connection *)NULL) { + if (_target != nullptr) { _target->flush(); } } diff --git a/panda/src/ode/odeAMotorJoint.cxx b/panda/src/ode/odeAMotorJoint.cxx index 8b7a16d6bc..8923453068 100644 --- a/panda/src/ode/odeAMotorJoint.cxx +++ b/panda/src/ode/odeAMotorJoint.cxx @@ -23,7 +23,7 @@ OdeAMotorJoint(dJointID id) : OdeAMotorJoint:: OdeAMotorJoint(OdeWorld &world) : - OdeJoint(dJointCreateAMotor(world.get_id(), 0)) { + OdeJoint(dJointCreateAMotor(world.get_id(), nullptr)) { } OdeAMotorJoint:: diff --git a/panda/src/ode/odeBallJoint.cxx b/panda/src/ode/odeBallJoint.cxx index b578c72c6b..f051c07c9a 100644 --- a/panda/src/ode/odeBallJoint.cxx +++ b/panda/src/ode/odeBallJoint.cxx @@ -23,7 +23,7 @@ OdeBallJoint(dJointID id) : OdeBallJoint:: OdeBallJoint(OdeWorld &world) : - OdeJoint(dJointCreateBall(world.get_id(), 0)) { + OdeJoint(dJointCreateBall(world.get_id(), nullptr)) { } OdeBallJoint:: diff --git a/panda/src/ode/odeBody.cxx b/panda/src/ode/odeBody.cxx index 4f70faff08..412759f8e7 100644 --- a/panda/src/ode/odeBody.cxx +++ b/panda/src/ode/odeBody.cxx @@ -63,8 +63,8 @@ get_data() const { OdeJoint OdeBody:: get_joint(int index) const { - nassertr(_id != 0, OdeJoint(0)); - nassertr(index < get_num_joints(), OdeJoint(0)); + nassertr(_id != nullptr, OdeJoint(nullptr)); + nassertr(index < get_num_joints(), OdeJoint(nullptr)); return OdeJoint(dBodyGetJoint(_id, index)); } @@ -77,5 +77,5 @@ write(ostream &out, unsigned int indent) const { OdeBody:: operator bool () const { - return (_id != NULL); + return (_id != nullptr); } diff --git a/panda/src/ode/odeBoxGeom.cxx b/panda/src/ode/odeBoxGeom.cxx index 77a594b552..2636da81da 100644 --- a/panda/src/ode/odeBoxGeom.cxx +++ b/panda/src/ode/odeBoxGeom.cxx @@ -23,7 +23,7 @@ OdeBoxGeom(dGeomID id) : OdeBoxGeom:: OdeBoxGeom(dReal lx, dReal ly, dReal lz) : - OdeGeom(dCreateBox(0, lx, ly, lz)) { + OdeGeom(dCreateBox(nullptr, lx, ly, lz)) { } OdeBoxGeom:: diff --git a/panda/src/ode/odeCappedCylinderGeom.cxx b/panda/src/ode/odeCappedCylinderGeom.cxx index 5b1a3b5b40..7fa7120f69 100644 --- a/panda/src/ode/odeCappedCylinderGeom.cxx +++ b/panda/src/ode/odeCappedCylinderGeom.cxx @@ -23,7 +23,7 @@ OdeCappedCylinderGeom(dGeomID id) : OdeCappedCylinderGeom:: OdeCappedCylinderGeom(dReal radius, dReal length) : - OdeGeom(dCreateCapsule(0, radius, length)) { + OdeGeom(dCreateCapsule(nullptr, radius, length)) { } OdeCappedCylinderGeom:: diff --git a/panda/src/ode/odeContactJoint.cxx b/panda/src/ode/odeContactJoint.cxx index b53694b1b3..10bf0b94ec 100644 --- a/panda/src/ode/odeContactJoint.cxx +++ b/panda/src/ode/odeContactJoint.cxx @@ -23,7 +23,7 @@ OdeContactJoint(dJointID id) : OdeContactJoint:: OdeContactJoint(OdeWorld &world, const OdeContact &contact) : - OdeJoint(dJointCreateContact(world.get_id(), 0, contact.get_contact_ptr())) { + OdeJoint(dJointCreateContact(world.get_id(), nullptr, contact.get_contact_ptr())) { } OdeContactJoint:: diff --git a/panda/src/ode/odeConvexGeom.cxx b/panda/src/ode/odeConvexGeom.cxx index 3160d343de..9a3b07d29a 100644 --- a/panda/src/ode/odeConvexGeom.cxx +++ b/panda/src/ode/odeConvexGeom.cxx @@ -23,7 +23,7 @@ OdeConvexGeom(dGeomID id) : OdeConvexGeom:: OdeConvexGeom(dReal radius, dReal length) : - OdeGeom(dCreateConvex(0, radius, length)) { + OdeGeom(dCreateConvex(nullptr, radius, length)) { } OdeConvexGeom:: diff --git a/panda/src/ode/odeCylinderGeom.cxx b/panda/src/ode/odeCylinderGeom.cxx index 7b7eccc49e..4076e3aa36 100644 --- a/panda/src/ode/odeCylinderGeom.cxx +++ b/panda/src/ode/odeCylinderGeom.cxx @@ -23,7 +23,7 @@ OdeCylinderGeom(dGeomID id) : OdeCylinderGeom:: OdeCylinderGeom(dReal radius, dReal length) : - OdeGeom(dCreateCylinder(0, radius, length)) { + OdeGeom(dCreateCylinder(nullptr, radius, length)) { } OdeCylinderGeom:: diff --git a/panda/src/ode/odeFixedJoint.cxx b/panda/src/ode/odeFixedJoint.cxx index 346a1dbdaa..a339776d60 100644 --- a/panda/src/ode/odeFixedJoint.cxx +++ b/panda/src/ode/odeFixedJoint.cxx @@ -23,7 +23,7 @@ OdeFixedJoint(dJointID id) : OdeFixedJoint:: OdeFixedJoint(OdeWorld &world) : - OdeJoint(dJointCreateFixed(world.get_id(), 0)) { + OdeJoint(dJointCreateFixed(world.get_id(), nullptr)) { } OdeFixedJoint:: diff --git a/panda/src/ode/odeGeom.I b/panda/src/ode/odeGeom.I index 883e367e70..e402b470e9 100644 --- a/panda/src/ode/odeGeom.I +++ b/panda/src/ode/odeGeom.I @@ -31,7 +31,7 @@ get_id() const { INLINE bool OdeGeom:: has_body() const { - return (dGeomGetBody(_id) != NULL); + return (dGeomGetBody(_id) != nullptr); } INLINE OdeBody OdeGeom:: diff --git a/panda/src/ode/odeGeom.cxx b/panda/src/ode/odeGeom.cxx index c1d4d0866f..c291025912 100644 --- a/panda/src/ode/odeGeom.cxx +++ b/panda/src/ode/odeGeom.cxx @@ -114,93 +114,93 @@ write(ostream &out, unsigned int indent) const { OdeBoxGeom OdeGeom:: convert_to_box() const { - nassertr(_id != 0, OdeBoxGeom((dGeomID)0)); - nassertr(get_class() == GC_box, OdeBoxGeom((dGeomID)0)); + nassertr(_id != nullptr, OdeBoxGeom(nullptr)); + nassertr(get_class() == GC_box, OdeBoxGeom(nullptr)); return OdeBoxGeom(_id); } OdeCappedCylinderGeom OdeGeom:: convert_to_capped_cylinder() const { - nassertr(_id != 0, OdeCappedCylinderGeom((dGeomID)0)); - nassertr(get_class() == GC_capped_cylinder, OdeCappedCylinderGeom((dGeomID)0)); + nassertr(_id != nullptr, OdeCappedCylinderGeom(nullptr)); + nassertr(get_class() == GC_capped_cylinder, OdeCappedCylinderGeom(nullptr)); return OdeCappedCylinderGeom(_id); } /* OdeConvexGeom OdeGeom:: convert_to_convex() const { - nassertr(_id != 0, OdeConvexGeom((dGeomID)0)); - nassertr(get_class() == GC_convex, OdeConvexGeom((dGeomID)0)); + nassertr(_id != nullptr, OdeConvexGeom(nullptr)); + nassertr(get_class() == GC_convex, OdeConvexGeom(nullptr)); return OdeConvexGeom(_id); } */ OdeCylinderGeom OdeGeom:: convert_to_cylinder() const { - nassertr(_id != 0, OdeCylinderGeom((dGeomID)0)); - nassertr(get_class() == GC_cylinder, OdeCylinderGeom((dGeomID)0)); + nassertr(_id != nullptr, OdeCylinderGeom(nullptr)); + nassertr(get_class() == GC_cylinder, OdeCylinderGeom(nullptr)); return OdeCylinderGeom(_id); } /* OdeHeightfieldGeom OdeGeom:: convert_to_heightfield() const { - nassertr(_id != 0, OdeHeightfieldGeom((dGeomID)0)); - nassertr(get_class() == GC_heightfield, OdeHeightfieldGeom((dGeomID)0)); + nassertr(_id != nullptr, OdeHeightfieldGeom(nullptr)); + nassertr(get_class() == GC_heightfield, OdeHeightfieldGeom(nullptr)); return OdeHeightfieldGeom(_id); } */ OdePlaneGeom OdeGeom:: convert_to_plane() const { - nassertr(_id != 0, OdePlaneGeom((dGeomID)0)); - nassertr(get_class() == GC_plane, OdePlaneGeom((dGeomID)0)); + nassertr(_id != nullptr, OdePlaneGeom(nullptr)); + nassertr(get_class() == GC_plane, OdePlaneGeom(nullptr)); return OdePlaneGeom(_id); } OdeRayGeom OdeGeom:: convert_to_ray() const { - nassertr(_id != 0, OdeRayGeom((dGeomID)0)); - nassertr(get_class() == GC_ray, OdeRayGeom((dGeomID)0)); + nassertr(_id != nullptr, OdeRayGeom(nullptr)); + nassertr(get_class() == GC_ray, OdeRayGeom(nullptr)); return OdeRayGeom(_id); } OdeSphereGeom OdeGeom:: convert_to_sphere() const { - nassertr(_id != 0, OdeSphereGeom((dGeomID)0)); - nassertr(get_class() == GC_sphere, OdeSphereGeom((dGeomID)0)); + nassertr(_id != nullptr, OdeSphereGeom(nullptr)); + nassertr(get_class() == GC_sphere, OdeSphereGeom(nullptr)); return OdeSphereGeom(_id); } OdeTriMeshGeom OdeGeom:: convert_to_tri_mesh() const { - nassertr(_id != 0, OdeTriMeshGeom((dGeomID)0)); - nassertr(get_class() == GC_tri_mesh, OdeTriMeshGeom((dGeomID)0)); + nassertr(_id != nullptr, OdeTriMeshGeom(nullptr)); + nassertr(get_class() == GC_tri_mesh, OdeTriMeshGeom(nullptr)); return OdeTriMeshGeom(_id); } OdeSimpleSpace OdeGeom:: convert_to_simple_space() const { - nassertr(_id != 0, OdeSimpleSpace((dSpaceID)0)); - nassertr(get_class() == GC_simple_space, OdeSimpleSpace((dSpaceID)0)); + nassertr(_id != nullptr, OdeSimpleSpace(nullptr)); + nassertr(get_class() == GC_simple_space, OdeSimpleSpace(nullptr)); return OdeSimpleSpace((dSpaceID)_id); } OdeHashSpace OdeGeom:: convert_to_hash_space() const { - nassertr(_id != 0, OdeHashSpace((dSpaceID)0)); - nassertr(get_class() == GC_hash_space, OdeHashSpace((dSpaceID)0)); + nassertr(_id != nullptr, OdeHashSpace(nullptr)); + nassertr(get_class() == GC_hash_space, OdeHashSpace(nullptr)); return OdeHashSpace((dSpaceID)_id); } OdeQuadTreeSpace OdeGeom:: convert_to_quad_tree_space() const { - nassertr(_id != 0, OdeQuadTreeSpace((dSpaceID)0)); - nassertr(get_class() == GC_quad_tree_space, OdeQuadTreeSpace((dSpaceID)0)); + nassertr(_id != nullptr, OdeQuadTreeSpace(nullptr)); + nassertr(get_class() == GC_quad_tree_space, OdeQuadTreeSpace(nullptr)); return OdeQuadTreeSpace((dSpaceID)_id); } OdeGeom:: operator bool () const { - return (_id != NULL); + return (_id != nullptr); } diff --git a/panda/src/ode/odeHashSpace.cxx b/panda/src/ode/odeHashSpace.cxx index af81c100a8..863bb1ae8d 100644 --- a/panda/src/ode/odeHashSpace.cxx +++ b/panda/src/ode/odeHashSpace.cxx @@ -23,7 +23,7 @@ OdeHashSpace(dSpaceID id) : OdeHashSpace:: OdeHashSpace() : - OdeSpace(dHashSpaceCreate(0)) { + OdeSpace(dHashSpaceCreate(nullptr)) { } OdeHashSpace:: diff --git a/panda/src/ode/odeHinge2Joint.cxx b/panda/src/ode/odeHinge2Joint.cxx index 157d642f2f..48b373ef21 100644 --- a/panda/src/ode/odeHinge2Joint.cxx +++ b/panda/src/ode/odeHinge2Joint.cxx @@ -23,7 +23,7 @@ OdeHinge2Joint(dJointID id) : OdeHinge2Joint:: OdeHinge2Joint(OdeWorld &world) : - OdeJoint(dJointCreateHinge2(world.get_id(), 0)) { + OdeJoint(dJointCreateHinge2(world.get_id(), nullptr)) { } OdeHinge2Joint:: diff --git a/panda/src/ode/odeHingeJoint.cxx b/panda/src/ode/odeHingeJoint.cxx index 352cf0ee32..3b2c1b509e 100644 --- a/panda/src/ode/odeHingeJoint.cxx +++ b/panda/src/ode/odeHingeJoint.cxx @@ -23,7 +23,7 @@ OdeHingeJoint(dJointID id) : OdeHingeJoint:: OdeHingeJoint(OdeWorld &world) : - OdeJoint(dJointCreateHinge(world.get_id(), 0)) { + OdeJoint(dJointCreateHinge(world.get_id(), nullptr)) { } OdeHingeJoint:: diff --git a/panda/src/ode/odeJoint.I b/panda/src/ode/odeJoint.I index a71fc8ac84..946dae9456 100644 --- a/panda/src/ode/odeJoint.I +++ b/panda/src/ode/odeJoint.I @@ -49,13 +49,13 @@ get_joint_type() const { INLINE void OdeJoint:: set_feedback(bool flag) { if (flag) { - if (dJointGetFeedback(_id) != NULL) { + if (dJointGetFeedback(_id) != nullptr) { return; } OdeJointFeedback* feedback = new OdeJointFeedback; dJointSetFeedback(_id, (dJointFeedback*) feedback); } else if (dJointFeedback* feedback = dJointGetFeedback(_id)) { - dJointSetFeedback(_id, NULL); + dJointSetFeedback(_id, nullptr); delete feedback; } } diff --git a/panda/src/ode/odeJoint.cxx b/panda/src/ode/odeJoint.cxx index cdaa12e95f..a089a7b303 100644 --- a/panda/src/ode/odeJoint.cxx +++ b/panda/src/ode/odeJoint.cxx @@ -30,7 +30,7 @@ TypeHandle OdeJoint::_type_handle; OdeJoint:: OdeJoint() : - _id(0) { + _id(nullptr) { ostream &out = odejoint_cat.debug(); out << get_type() << "(" << _id << ")\n"; } @@ -60,7 +60,7 @@ destroy() { void OdeJoint:: attach_bodies(const OdeBody &body1, const OdeBody &body2) { nassertv(_id); - nassertv(body1.get_id() != 0 || body2.get_id() != 0); + nassertv(body1.get_id() != nullptr || body2.get_id() != nullptr); dJointAttach(_id, body1.get_id(), body2.get_id()); } @@ -72,25 +72,25 @@ attach_bodies(const OdeBody &body1, const OdeBody &body2) { void OdeJoint:: attach_body(const OdeBody &body, int index) { nassertv(_id); - nassertv(body.get_id() != 0); + nassertv(body.get_id() != nullptr); nassertv(index == 0 || index == 1); if (index == 0) { - dJointAttach(_id, body.get_id(), 0); + dJointAttach(_id, body.get_id(), nullptr); } else { - dJointAttach(_id, 0, body.get_id()); + dJointAttach(_id, nullptr, body.get_id()); } } void OdeJoint:: detach() { nassertv(_id); - dJointAttach(_id, 0, 0); + dJointAttach(_id, nullptr, nullptr); } OdeBody OdeJoint:: get_body(int index) const { - nassertr(_id, OdeBody(0)); - nassertr(index == 0 || index == 1, OdeBody(0)); + nassertr(_id, OdeBody(nullptr)); + nassertr(index == 0 || index == 1, OdeBody(nullptr)); return OdeBody(dJointGetBody(_id, index)); } @@ -100,7 +100,7 @@ write(ostream &out, unsigned int indent) const { << "(id = " << _id \ << ", body1 = "; OdeBody body = get_body(0); - if (body.get_id() != 0) { + if (body.get_id() != nullptr) { body.write(out); } else { @@ -108,7 +108,7 @@ write(ostream &out, unsigned int indent) const { } out << ", body2 = "; body = get_body(1); - if (body.get_id() != 0) { + if (body.get_id() != nullptr) { body.write(out); } else { @@ -120,82 +120,82 @@ write(ostream &out, unsigned int indent) const { OdeJoint:: operator bool () const { - return (_id != NULL); + return (_id != nullptr); } OdeBallJoint OdeJoint:: convert_to_ball() const { - nassertr(_id != 0, OdeBallJoint(0)); - nassertr(get_joint_type() == JT_ball, OdeBallJoint(0)); + nassertr(_id != nullptr, OdeBallJoint(nullptr)); + nassertr(get_joint_type() == JT_ball, OdeBallJoint(nullptr)); return OdeBallJoint(_id); } OdeHingeJoint OdeJoint:: convert_to_hinge() const { - nassertr(_id != 0, OdeHingeJoint(0)); - nassertr(get_joint_type() == JT_hinge, OdeHingeJoint(0)); + nassertr(_id != nullptr, OdeHingeJoint(nullptr)); + nassertr(get_joint_type() == JT_hinge, OdeHingeJoint(nullptr)); return OdeHingeJoint(_id); } OdeSliderJoint OdeJoint:: convert_to_slider() const { - nassertr(_id != 0, OdeSliderJoint(0)); - nassertr(get_joint_type() == JT_slider, OdeSliderJoint(0)); + nassertr(_id != nullptr, OdeSliderJoint(nullptr)); + nassertr(get_joint_type() == JT_slider, OdeSliderJoint(nullptr)); return OdeSliderJoint(_id); } OdeContactJoint OdeJoint:: convert_to_contact() const { - nassertr(_id != 0, OdeContactJoint(0)); - nassertr(get_joint_type() == JT_contact, OdeContactJoint(0)); + nassertr(_id != nullptr, OdeContactJoint(nullptr)); + nassertr(get_joint_type() == JT_contact, OdeContactJoint(nullptr)); return OdeContactJoint(_id); } OdeUniversalJoint OdeJoint:: convert_to_universal() const { - nassertr(_id != 0, OdeUniversalJoint(0)); - nassertr(get_joint_type() == JT_universal, OdeUniversalJoint(0)); + nassertr(_id != nullptr, OdeUniversalJoint(nullptr)); + nassertr(get_joint_type() == JT_universal, OdeUniversalJoint(nullptr)); return OdeUniversalJoint(_id); } OdeHinge2Joint OdeJoint:: convert_to_hinge2() const { - nassertr(_id != 0, OdeHinge2Joint(0)); - nassertr(get_joint_type() == JT_hinge2, OdeHinge2Joint(0)); + nassertr(_id != nullptr, OdeHinge2Joint(nullptr)); + nassertr(get_joint_type() == JT_hinge2, OdeHinge2Joint(nullptr)); return OdeHinge2Joint(_id); } OdeFixedJoint OdeJoint:: convert_to_fixed() const { - nassertr(_id != 0, OdeFixedJoint(0)); - nassertr(get_joint_type() == JT_fixed, OdeFixedJoint(0)); + nassertr(_id != nullptr, OdeFixedJoint(nullptr)); + nassertr(get_joint_type() == JT_fixed, OdeFixedJoint(nullptr)); return OdeFixedJoint(_id); } OdeNullJoint OdeJoint:: convert_to_null() const { - nassertr(_id != 0, OdeNullJoint(0)); - nassertr(get_joint_type() == JT_null, OdeNullJoint(0)); + nassertr(_id != nullptr, OdeNullJoint(nullptr)); + nassertr(get_joint_type() == JT_null, OdeNullJoint(nullptr)); return OdeNullJoint(_id); } OdeAMotorJoint OdeJoint:: convert_to_a_motor() const { - nassertr(_id != 0, OdeAMotorJoint(0)); - nassertr(get_joint_type() == JT_a_motor, OdeAMotorJoint(0)); + nassertr(_id != nullptr, OdeAMotorJoint(nullptr)); + nassertr(get_joint_type() == JT_a_motor, OdeAMotorJoint(nullptr)); return OdeAMotorJoint(_id); } OdeLMotorJoint OdeJoint:: convert_to_l_motor() const { - nassertr(_id != 0, OdeLMotorJoint(0)); - nassertr(get_joint_type() == JT_l_motor, OdeLMotorJoint(0)); + nassertr(_id != nullptr, OdeLMotorJoint(nullptr)); + nassertr(get_joint_type() == JT_l_motor, OdeLMotorJoint(nullptr)); return OdeLMotorJoint(_id); } OdePlane2dJoint OdeJoint:: convert_to_plane2d() const { - nassertr(_id != 0, OdePlane2dJoint(0)); - nassertr(get_joint_type() == JT_plane2d, OdePlane2dJoint(0)); + nassertr(_id != nullptr, OdePlane2dJoint(nullptr)); + nassertr(get_joint_type() == JT_plane2d, OdePlane2dJoint(nullptr)); return OdePlane2dJoint(_id); } diff --git a/panda/src/ode/odeLMotorJoint.cxx b/panda/src/ode/odeLMotorJoint.cxx index 6c8abd2ee2..e1194603ac 100644 --- a/panda/src/ode/odeLMotorJoint.cxx +++ b/panda/src/ode/odeLMotorJoint.cxx @@ -23,7 +23,7 @@ OdeLMotorJoint(dJointID id) : OdeLMotorJoint:: OdeLMotorJoint(OdeWorld &world ) : - OdeJoint(dJointCreateLMotor(world.get_id(), 0)) { + OdeJoint(dJointCreateLMotor(world.get_id(), nullptr)) { } OdeLMotorJoint:: diff --git a/panda/src/ode/odeNullJoint.cxx b/panda/src/ode/odeNullJoint.cxx index 2cf348a6b2..214f101430 100644 --- a/panda/src/ode/odeNullJoint.cxx +++ b/panda/src/ode/odeNullJoint.cxx @@ -23,7 +23,7 @@ OdeNullJoint(dJointID id) : OdeNullJoint:: OdeNullJoint(OdeWorld &world) : - OdeJoint(dJointCreateNull(world.get_id(), 0)) { + OdeJoint(dJointCreateNull(world.get_id(), nullptr)) { } OdeNullJoint:: diff --git a/panda/src/ode/odePlane2dJoint.cxx b/panda/src/ode/odePlane2dJoint.cxx index 000f893ea6..1618452bb8 100644 --- a/panda/src/ode/odePlane2dJoint.cxx +++ b/panda/src/ode/odePlane2dJoint.cxx @@ -23,7 +23,7 @@ OdePlane2dJoint(dJointID id) : OdePlane2dJoint:: OdePlane2dJoint(OdeWorld &world) : - OdeJoint(dJointCreatePlane2D(world.get_id(), 0)) { + OdeJoint(dJointCreatePlane2D(world.get_id(), nullptr)) { } OdePlane2dJoint:: diff --git a/panda/src/ode/odePlaneGeom.cxx b/panda/src/ode/odePlaneGeom.cxx index a23d4961bb..5fe4b0bdb8 100644 --- a/panda/src/ode/odePlaneGeom.cxx +++ b/panda/src/ode/odePlaneGeom.cxx @@ -23,12 +23,12 @@ OdePlaneGeom(dGeomID id) : OdePlaneGeom:: OdePlaneGeom(dReal a, dReal b, dReal c, dReal d) : - OdeGeom(dCreatePlane(0, a, b, c, d)) { + OdeGeom(dCreatePlane(nullptr, a, b, c, d)) { } OdePlaneGeom:: OdePlaneGeom(const LVecBase4f ¶ms) : - OdeGeom(dCreatePlane(0, params[0], params[1], params[2], params[3])) { + OdeGeom(dCreatePlane(nullptr, params[0], params[1], params[2], params[3])) { } OdePlaneGeom:: diff --git a/panda/src/ode/odeQuadTreeSpace.cxx b/panda/src/ode/odeQuadTreeSpace.cxx index 2ced39a003..52b151e46e 100644 --- a/panda/src/ode/odeQuadTreeSpace.cxx +++ b/panda/src/ode/odeQuadTreeSpace.cxx @@ -38,7 +38,7 @@ OdeQuadTreeSpace:: OdeQuadTreeSpace(const LPoint3f ¢er, const LVecBase3f &extents, const int depth) : - OdeSpace(dQuadTreeSpaceCreate(0, + OdeSpace(dQuadTreeSpaceCreate(nullptr, LVec3_to_sdVector4(center).vec, LVec3_to_sdVector4(extents).vec, depth)) { diff --git a/panda/src/ode/odeRayGeom.cxx b/panda/src/ode/odeRayGeom.cxx index 10e727d76f..88a361948c 100644 --- a/panda/src/ode/odeRayGeom.cxx +++ b/panda/src/ode/odeRayGeom.cxx @@ -23,7 +23,7 @@ OdeRayGeom(dGeomID id) : OdeRayGeom:: OdeRayGeom(dReal length) : - OdeGeom(dCreateRay(0, length)) { + OdeGeom(dCreateRay(nullptr, length)) { } OdeRayGeom:: diff --git a/panda/src/ode/odeSimpleSpace.cxx b/panda/src/ode/odeSimpleSpace.cxx index a9e52d2015..1714d9af27 100644 --- a/panda/src/ode/odeSimpleSpace.cxx +++ b/panda/src/ode/odeSimpleSpace.cxx @@ -23,7 +23,7 @@ OdeSimpleSpace(dSpaceID id) : OdeSimpleSpace:: OdeSimpleSpace() : - OdeSpace(dSimpleSpaceCreate(0)) { + OdeSpace(dSimpleSpaceCreate(nullptr)) { } OdeSimpleSpace:: diff --git a/panda/src/ode/odeSliderJoint.cxx b/panda/src/ode/odeSliderJoint.cxx index 2976cbe65e..1e86396637 100644 --- a/panda/src/ode/odeSliderJoint.cxx +++ b/panda/src/ode/odeSliderJoint.cxx @@ -23,7 +23,7 @@ OdeSliderJoint(dJointID id) : OdeSliderJoint:: OdeSliderJoint(OdeWorld &world) : - OdeJoint(dJointCreateSlider(world.get_id(), 0)) { + OdeJoint(dJointCreateSlider(world.get_id(), nullptr)) { } OdeSliderJoint:: diff --git a/panda/src/ode/odeSpace.cxx b/panda/src/ode/odeSpace.cxx index 6c4749f946..a07342b82f 100644 --- a/panda/src/ode/odeSpace.cxx +++ b/panda/src/ode/odeSpace.cxx @@ -31,8 +31,8 @@ dJointGroupID OdeSpace::_static_auto_collide_joint_group; OdeSpace:: OdeSpace(dSpaceID id) : _id(id) { - _auto_collide_world = NULL; - _auto_collide_joint_group = NULL; + _auto_collide_world = nullptr; + _auto_collide_joint_group = nullptr; } OdeSpace:: @@ -89,7 +89,7 @@ clean() { OdeGeom OdeSpace:: get_geom(int i) { - nassertr(_id, OdeGeom(0)); + nassertr(_id, OdeGeom(nullptr)); return OdeGeom(dSpaceGetGeom(_id, i)); } @@ -101,7 +101,7 @@ write(ostream &out, unsigned int indent) const { OdeSpace:: operator bool () const { - return (_id != NULL); + return (_id != nullptr); } void OdeSpace:: @@ -116,10 +116,10 @@ set_auto_collide_joint_group(OdeJointGroup &joint_group) { void OdeSpace:: auto_collide() { - if (_auto_collide_world == NULL) { + if (_auto_collide_world == nullptr) { odespace_cat.error() << "No collide world has been set!\n"; } else { - nassertv(_id != NULL); + nassertv(_id != nullptr); _static_auto_collide_space = this; _static_auto_collide_world = _auto_collide_world; _static_auto_collide_joint_group = _auto_collide_joint_group; @@ -140,7 +140,7 @@ auto_callback(void *data, dGeomID o1, dGeomID o2) { int surface1 = _static_auto_collide_space->get_surface_type(o1); int surface2 = _static_auto_collide_space->get_surface_type(o2); - nassertv(_static_auto_collide_world != NULL); + nassertv(_static_auto_collide_world != nullptr); sSurfaceParams collide_params; collide_params = _static_auto_collide_world->get_surface(surface1, surface2); @@ -191,22 +191,22 @@ auto_callback(void *data, dGeomID o1, dGeomID o2) { OdeSimpleSpace OdeSpace:: convert_to_simple_space() const { - nassertr(_id != 0, OdeSimpleSpace((dSpaceID)0)); - nassertr(get_class() == OdeGeom::GC_simple_space, OdeSimpleSpace((dSpaceID)0)); + nassertr(_id != nullptr, OdeSimpleSpace(nullptr)); + nassertr(get_class() == OdeGeom::GC_simple_space, OdeSimpleSpace(nullptr)); return OdeSimpleSpace(_id); } OdeHashSpace OdeSpace:: convert_to_hash_space() const { - nassertr(_id != 0, OdeHashSpace((dSpaceID)0)); - nassertr(get_class() == OdeGeom::GC_hash_space, OdeHashSpace((dSpaceID)0)); + nassertr(_id != nullptr, OdeHashSpace(nullptr)); + nassertr(get_class() == OdeGeom::GC_hash_space, OdeHashSpace(nullptr)); return OdeHashSpace(_id); } OdeQuadTreeSpace OdeSpace:: convert_to_quad_tree_space() const { - nassertr(_id != 0, OdeQuadTreeSpace((dSpaceID)0)); - nassertr(get_class() == OdeGeom::GC_quad_tree_space, OdeQuadTreeSpace((dSpaceID)0)); + nassertr(_id != nullptr, OdeQuadTreeSpace(nullptr)); + nassertr(get_class() == OdeGeom::GC_quad_tree_space, OdeQuadTreeSpace(nullptr)); return OdeQuadTreeSpace(_id); } diff --git a/panda/src/ode/odeSpace_ext.cxx b/panda/src/ode/odeSpace_ext.cxx index bed4a3e30b..97e841f30b 100644 --- a/panda/src/ode/odeSpace_ext.cxx +++ b/panda/src/ode/odeSpace_ext.cxx @@ -29,7 +29,7 @@ extern Dtool_PyTypedObject Dtool_OdeSpace; extern Dtool_PyTypedObject Dtool_OdeQuadTreeSpace; #endif -PyObject *Extension::_python_callback = NULL; +PyObject *Extension::_python_callback = nullptr; /** * Do a sort of pseudo-downcast on this space in order to expose its @@ -69,13 +69,13 @@ convert() const { int Extension:: collide(PyObject* arg, PyObject* callback) { - nassertr(callback != NULL, -1); + nassertr(callback != nullptr, -1); if (!PyCallable_Check(callback)) { PyErr_Format(PyExc_TypeError, "'%s' object is not callable", callback->ob_type->tp_name); return -1; - } else if (_this->get_id() == NULL) { + } else if (_this->get_id() == nullptr) { // Well, while we're in the mood of python exceptions, let's make this one // too. PyErr_Format(PyExc_TypeError, "OdeSpace is not valid!"); @@ -96,7 +96,7 @@ near_callback(void *data, dGeomID o1, dGeomID o2) { OdeGeom g2 (o2); PyObject* p1 = invoke_extension(&g1).convert(); PyObject* p2 = invoke_extension(&g2).convert(); - PyObject *result = PyObject_CallFunctionObjArgs(_python_callback, (PyObject*) data, p1, p2, NULL); + PyObject *result = PyObject_CallFunctionObjArgs(_python_callback, (PyObject*) data, p1, p2, nullptr); if (!result) { odespace_cat.error() << "An error occurred while calling python function!\n"; PyErr_Print(); diff --git a/panda/src/ode/odeSphereGeom.cxx b/panda/src/ode/odeSphereGeom.cxx index 96cb041495..eb49b7ea5e 100644 --- a/panda/src/ode/odeSphereGeom.cxx +++ b/panda/src/ode/odeSphereGeom.cxx @@ -23,7 +23,7 @@ OdeSphereGeom(dGeomID id) : OdeSphereGeom:: OdeSphereGeom(dReal radius) : - OdeGeom(dCreateSphere(0, radius)) { + OdeGeom(dCreateSphere(nullptr, radius)) { } OdeSphereGeom:: diff --git a/panda/src/ode/odeTriMeshData.I b/panda/src/ode/odeTriMeshData.I index e0cc754623..2aad3a2404 100644 --- a/panda/src/ode/odeTriMeshData.I +++ b/panda/src/ode/odeTriMeshData.I @@ -13,7 +13,7 @@ INLINE OdeTriMeshData::TriMeshDataMap &OdeTriMeshData:: get_tri_mesh_data_map() { - if (_tri_mesh_data_map == (TriMeshDataMap *)NULL) { + if (_tri_mesh_data_map == nullptr) { _tri_mesh_data_map = new TriMeshDataMap; } return *_tri_mesh_data_map; diff --git a/panda/src/ode/odeTriMeshData.cxx b/panda/src/ode/odeTriMeshData.cxx index 0c04196833..07d265a41d 100644 --- a/panda/src/ode/odeTriMeshData.cxx +++ b/panda/src/ode/odeTriMeshData.cxx @@ -14,7 +14,7 @@ #include "odeTriMeshData.h" TypeHandle OdeTriMeshData::_type_handle; -OdeTriMeshData::TriMeshDataMap *OdeTriMeshData::_tri_mesh_data_map = NULL; +OdeTriMeshData::TriMeshDataMap *OdeTriMeshData::_tri_mesh_data_map = nullptr; void OdeTriMeshData:: link_data(dGeomID id, PT(OdeTriMeshData) data) { @@ -29,13 +29,13 @@ get_data(dGeomID id) { if (iter != data_map.end()) { return iter->second; } - return NULL; + return nullptr; } void OdeTriMeshData:: unlink_data(dGeomID id) { odetrimeshdata_cat.debug() << get_class_type() << "::unlink_data(" << id << ")" << "\n"; - nassertv(_tri_mesh_data_map != (TriMeshDataMap *)NULL); + nassertv(_tri_mesh_data_map != nullptr); TriMeshDataMap::iterator iter = _tri_mesh_data_map->find(id); if (iter != _tri_mesh_data_map->end()) { _tri_mesh_data_map->erase(iter); @@ -58,7 +58,7 @@ remove_data(OdeTriMeshData *data) { odetrimeshdata_cat.debug() << get_class_type() << "::remove_data(" << data->get_id() << ")" << "\n"; } - if (_tri_mesh_data_map == (TriMeshDataMap *)NULL) { + if (_tri_mesh_data_map == nullptr) { return; } @@ -88,9 +88,9 @@ remove_data(OdeTriMeshData *data) { OdeTriMeshData:: OdeTriMeshData(const NodePath& model, bool use_normals) : _id(dGeomTriMeshDataCreate()), - _vertices(0), - _faces(0), - _normals(0), + _vertices(nullptr), + _faces(nullptr), + _normals(nullptr), _num_vertices(0), _num_faces(0) { odetrimeshdata_cat.debug() << get_type() << "(" << _id << ")" << "\n"; @@ -131,16 +131,16 @@ OdeTriMeshData:: ~OdeTriMeshData() { odetrimeshdata_cat.debug() << "~" << get_type() << "(" << _id << ")" << "\n"; destroy(); - if (_vertices != 0) { + if (_vertices != nullptr) { PANDA_FREE_ARRAY(_vertices); - _vertices = 0; + _vertices = nullptr; _num_vertices = 0; } - if (_faces != 0) { + if (_faces != nullptr) { PANDA_FREE_ARRAY(_faces); - _faces = 0; + _faces = nullptr; } - if (_normals != 0) { + if (_normals != nullptr) { // This is never allocated? Until we use _normals, assert that we don't // accidentally free it here through some mistake. nassertv(false); @@ -151,10 +151,10 @@ OdeTriMeshData:: void OdeTriMeshData:: destroy() { odetrimeshdata_cat.debug() << get_type() << "::destroy(" << _id << ")" << "\n"; - if (_id != 0) { + if (_id != nullptr) { dGeomTriMeshDataDestroy(_id); remove_data(this); - _id = 0; + _id = nullptr; } } diff --git a/panda/src/ode/odeTriMeshGeom.I b/panda/src/ode/odeTriMeshGeom.I index b0a2e6177c..0a7dccaf53 100644 --- a/panda/src/ode/odeTriMeshGeom.I +++ b/panda/src/ode/odeTriMeshGeom.I @@ -34,7 +34,7 @@ set_tri_mesh_data(OdeTriMeshData &data) { INLINE PT(OdeTriMeshData) OdeTriMeshGeom:: get_tri_mesh_data() const { - nassertr(_id != 0, NULL); + nassertr(_id != 0, nullptr); return OdeTriMeshData::get_data(_id); } diff --git a/panda/src/ode/odeTriMeshGeom.cxx b/panda/src/ode/odeTriMeshGeom.cxx index f3e596d72b..257dbef3bb 100644 --- a/panda/src/ode/odeTriMeshGeom.cxx +++ b/panda/src/ode/odeTriMeshGeom.cxx @@ -23,19 +23,19 @@ OdeTriMeshGeom(dGeomID id) : OdeTriMeshGeom:: OdeTriMeshGeom(OdeTriMeshData &data) : - OdeGeom(dCreateTriMesh(0, data.get_id(), 0, 0, 0)) { + OdeGeom(dCreateTriMesh(nullptr, data.get_id(), nullptr, nullptr, nullptr)) { OdeTriMeshData::link_data(_id, &data); } OdeTriMeshGeom:: OdeTriMeshGeom(OdeSpace &space, OdeTriMeshData &data) : - OdeGeom(dCreateTriMesh(space.get_id(), data.get_id(), 0, 0, 0)) { + OdeGeom(dCreateTriMesh(space.get_id(), data.get_id(), nullptr, nullptr, nullptr)) { OdeTriMeshData::link_data(_id, &data); } OdeTriMeshGeom:: OdeTriMeshGeom(const OdeTriMeshGeom ©) : - OdeGeom(dCreateTriMesh(0, copy.get_data_id(), 0, 0, 0)) { + OdeGeom(dCreateTriMesh(nullptr, copy.get_data_id(), nullptr, nullptr, nullptr)) { OdeTriMeshData::link_data(_id, copy.get_data()); } diff --git a/panda/src/ode/odeUniversalJoint.cxx b/panda/src/ode/odeUniversalJoint.cxx index 4e9780bf92..ca8264e9ee 100644 --- a/panda/src/ode/odeUniversalJoint.cxx +++ b/panda/src/ode/odeUniversalJoint.cxx @@ -23,7 +23,7 @@ OdeUniversalJoint(dJointID id) : OdeUniversalJoint:: OdeUniversalJoint(OdeWorld &world) : - OdeJoint(dJointCreateUniversal(world.get_id(), 0)) { + OdeJoint(dJointCreateUniversal(world.get_id(), nullptr)) { } OdeUniversalJoint:: diff --git a/panda/src/ode/odeUtil_ext.cxx b/panda/src/ode/odeUtil_ext.cxx index 862e215eae..c5aabaa812 100644 --- a/panda/src/ode/odeUtil_ext.cxx +++ b/panda/src/ode/odeUtil_ext.cxx @@ -18,7 +18,7 @@ #ifdef HAVE_PYTHON -PyObject *Extension::_python_callback = NULL; +PyObject *Extension::_python_callback = nullptr; /** * Calls the callback for all potentially intersecting pairs that contain one @@ -26,7 +26,7 @@ PyObject *Extension::_python_callback = NULL; */ int Extension:: collide2(const OdeGeom &geom1, const OdeGeom &geom2, PyObject* arg, PyObject* callback) { - nassertr(callback != NULL, -1); + nassertr(callback != nullptr, -1); if (!PyCallable_Check(callback)) { PyErr_Format(PyExc_TypeError, "'%s' object is not callable", callback->ob_type->tp_name); return -1; @@ -50,7 +50,7 @@ near_callback(void *data, dGeomID o1, dGeomID o2) { OdeGeom g2 (o2); PyObject* p1 = invoke_extension(&g1).convert(); PyObject* p2 = invoke_extension(&g2).convert(); - PyObject* result = PyObject_CallFunctionObjArgs(_python_callback, (PyObject*) data, p1, p2, NULL); + PyObject* result = PyObject_CallFunctionObjArgs(_python_callback, (PyObject*) data, p1, p2, nullptr); if (!result) { ode_cat.error() << "An error occurred while calling python function!\n"; PyErr_Print(); diff --git a/panda/src/ode/odeWorld.cxx b/panda/src/ode/odeWorld.cxx index 30b98ddd8b..f087c46374 100644 --- a/panda/src/ode/odeWorld.cxx +++ b/panda/src/ode/odeWorld.cxx @@ -178,5 +178,5 @@ apply_dampening(float dt, OdeBody& body) { OdeWorld:: operator bool () const { - return (_id != NULL); + return (_id != nullptr); } diff --git a/panda/src/osxdisplay/osxGraphicsBuffer.cxx b/panda/src/osxdisplay/osxGraphicsBuffer.cxx index 7b1beb26f8..d98b5d956a 100644 --- a/panda/src/osxdisplay/osxGraphicsBuffer.cxx +++ b/panda/src/osxdisplay/osxGraphicsBuffer.cxx @@ -36,7 +36,7 @@ osxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, osxGraphicsPipe *osx_pipe; DCAST_INTO_V(osx_pipe, _pipe); - _pbuffer = NULL; + _pbuffer = nullptr; // Since the pbuffer never gets flipped, we get screenshots from the same // buffer we draw into. @@ -48,7 +48,7 @@ osxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, */ osxGraphicsBuffer:: ~osxGraphicsBuffer() { - nassertv(_pbuffer == NULL); + nassertv(_pbuffer == nullptr); } /** @@ -62,10 +62,10 @@ begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector); begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } - nassertr(_pbuffer != NULL, false); + nassertr(_pbuffer != nullptr, false); osxGraphicsStateGuardian *osxgsg; DCAST_INTO_R(osxgsg, _gsg, false); @@ -106,7 +106,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void osxGraphicsBuffer:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { copy_to_textures(); @@ -125,13 +125,13 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void osxGraphicsBuffer:: close_buffer() { - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { // aglSetPBuffer(osxgsg->get_context(), _pbuffer, 0, 0, 0); _gsg.clear(); } - if (_pbuffer != NULL) { + if (_pbuffer != nullptr) { aglDestroyPBuffer(_pbuffer); - _pbuffer = NULL; + _pbuffer = nullptr; } _is_valid = false; } @@ -143,10 +143,10 @@ close_buffer() { bool osxGraphicsBuffer:: open_buffer() { if (_gsg == 0) { - _gsg = new osxGraphicsStateGuardian(_engine, _pipe, NULL); + _gsg = new osxGraphicsStateGuardian(_engine, _pipe, nullptr); } - if (_pbuffer == NULL) { + if (_pbuffer == nullptr) { GLenum target = GL_TEXTURE_RECTANGLE_ARB; if (_size[0] == Texture::up_to_power_2(_size[0]) && _size[1] == Texture::up_to_power_2(_size[1])) { diff --git a/panda/src/osxdisplay/osxGraphicsPipe.cxx b/panda/src/osxdisplay/osxGraphicsPipe.cxx index 721f54b585..9211c52515 100644 --- a/panda/src/osxdisplay/osxGraphicsPipe.cxx +++ b/panda/src/osxdisplay/osxGraphicsPipe.cxx @@ -34,7 +34,7 @@ Boolean GetDictionaryBoolean(CFDictionaryRef theDict, const void* key) { Boolean value = false; CFBooleanRef boolRef; boolRef = (CFBooleanRef)CFDictionaryGetValue(theDict, key); - if (boolRef != NULL) + if (boolRef != nullptr) value = CFBooleanGetValue(boolRef); return value; } @@ -44,7 +44,7 @@ long GetDictionaryLong(CFDictionaryRef theDict, const void* key) { long value = 0; CFNumberRef numRef; numRef = (CFNumberRef)CFDictionaryGetValue(theDict, key); - if (numRef != NULL) + if (numRef != nullptr) CFNumberGetValue(numRef, kCFNumberLongType, &value); return value; } @@ -94,7 +94,7 @@ CFArrayRef GSCGDisplayAvailableModesUsefulForOpenGL(CGDirectDisplayID display) { unsigned int numberOfAvailableModes = CFArrayGetCount(availableModes); // creat mutable array to hold the display modes we are interested int. - CFMutableArrayRef usefulModes = CFArrayCreateMutable(kCFAllocatorDefault, numberOfAvailableModes, NULL); + CFMutableArrayRef usefulModes = CFArrayCreateMutable(kCFAllocatorDefault, numberOfAvailableModes, nullptr); // get the current bits per pixel. long currentModeBitsPerPixel = GetModeBitsPerPixel(CGDisplayCurrentMode(display)); @@ -152,7 +152,7 @@ CFArrayRef GSCGDisplayAvailableModesUsefulForOpenGL(CGDirectDisplayID display) { // now sort the useful mode array, using the comparison callback. CFArraySortValues( usefulModes, CFRangeMake(0, CFArrayGetCount(usefulModes)), - (CFComparatorFunction) CompareModes, NULL); + (CFComparatorFunction) CompareModes, nullptr); // return the CFArray of the useful display modes. return usefulModes; } @@ -250,7 +250,7 @@ create_cg_image(const PNMImage &pnm_image) { bool has_alpha; bool is_grayscale; - CFStringRef color_space_name = NULL; + CFStringRef color_space_name = nullptr; switch (pnm_image.get_color_type()) { case PNMImage::CT_grayscale: color_space_name = kCGColorSpaceGenericGray; @@ -278,13 +278,13 @@ create_cg_image(const PNMImage &pnm_image) { case PNMImage::CT_invalid: // Shouldn't get here. - nassertr(false, NULL); + nassertr(false, nullptr); break; } - nassertr(color_space_name != NULL, NULL); + nassertr(color_space_name != nullptr, nullptr); CGColorSpaceRef color_space = CGColorSpaceCreateWithName(color_space_name); - nassertr(color_space != NULL, NULL); + nassertr(color_space != nullptr, nullptr); CGBitmapInfo bitmap_info = 0; #ifdef PGM_BIGGRAYS @@ -312,17 +312,17 @@ create_cg_image(const PNMImage &pnm_image) { } } } - nassertr((void *)dp == (void *)(char_array + num_bytes), NULL); + nassertr((void *)dp == (void *)(char_array + num_bytes), nullptr); CGDataProviderRef provider = - CGDataProviderCreateWithData(NULL, char_array, num_bytes, release_data); - nassertr(provider != NULL, NULL); + CGDataProviderCreateWithData(nullptr, char_array, num_bytes, release_data); + nassertr(provider != nullptr, nullptr); CGImageRef image = CGImageCreate (width, height, bits_per_component, bits_per_pixel, bytes_per_row, color_space, bitmap_info, provider, - NULL, false, kCGRenderingIntentDefault); - nassertr(image != NULL, NULL); + nullptr, false, kCGRenderingIntentDefault); + nassertr(image != nullptr, nullptr); CGColorSpaceRelease(color_space); CGDataProviderRelease(provider); @@ -354,12 +354,12 @@ make_output(const string &name, int retry, bool &precertify) { if (!_is_valid) { - return NULL; + return nullptr; } osxGraphicsStateGuardian *osxgsg = 0; if (gsg != 0) { - DCAST_INTO_R(osxgsg, gsg, NULL); + DCAST_INTO_R(osxgsg, gsg, nullptr); } // First thing to try: an osxGraphicsWindow @@ -372,15 +372,15 @@ make_output(const string &name, ((flags&BF_can_bind_color)!=0)|| ((flags&BF_can_bind_every)!=0)|| ((flags&BF_can_bind_layered)!=0)) { - return NULL; + return nullptr; } WindowHandle *window_handle = win_prop.get_parent_window(); - if (window_handle != NULL) { + if (window_handle != nullptr) { osxdisplay_cat.info() << "Got parent_window " << *window_handle << "\n"; #ifdef SUPPORT_SUBPROCESS_WINDOW WindowHandle::OSHandle *os_handle = window_handle->get_os_handle(); - if (os_handle != NULL && + if (os_handle != nullptr && os_handle->is_of_type(NativeWindowHandle::SubprocessHandle::get_class_type())) { return new SubprocessWindow(engine, this, name, fb_prop, win_prop, flags, gsg, host); @@ -394,9 +394,9 @@ make_output(const string &name, // Second thing to try: a GLGraphicsBuffer if (retry == 1) { - if (!osx_support_gl_buffer || !gl_support_fbo || host == NULL || + if (!osx_support_gl_buffer || !gl_support_fbo || host == nullptr || (flags & (BF_require_parasite | BF_require_window)) != 0) { - return NULL; + return nullptr; } // Early failure - if we are sure that this buffer WONT meet specs, we can // bail out early. @@ -404,13 +404,13 @@ make_output(const string &name, if (fb_prop.get_indexed_color() || fb_prop.get_back_buffers() > 0 || fb_prop.get_accum_bits() > 0) { - return NULL; + return nullptr; } } - if (osxgsg != NULL && osxgsg->is_valid() && !osxgsg->needs_reset()) { + if (osxgsg != nullptr && osxgsg->is_valid() && !osxgsg->needs_reset()) { if (!osxgsg->_supports_framebuffer_object || - osxgsg->_glDrawBuffers == NULL) { - return NULL; + osxgsg->_glDrawBuffers == nullptr) { + return nullptr; } else if (fb_prop.is_basic()) { // Early success - if we are sure that this buffer WILL meet specs, we // can precertify it. @@ -429,14 +429,14 @@ make_output(const string &name, ((flags&BF_size_track_host)!=0)|| ((flags&BF_can_bind_every)!=0)|| ((flags&BF_can_bind_layered)!=0)) { - return NULL; + return nullptr; } return new osxGraphicsBuffer(engine, this, name, fb_prop, win_prop, flags, gsg, host); } // Nothing else left to try. - return NULL; + return nullptr; } /** @@ -447,5 +447,5 @@ make_output(const string &name, */ PT(GraphicsStateGuardian) osxGraphicsPipe:: make_callback_gsg(GraphicsEngine *engine) { - return new osxGraphicsStateGuardian(engine, this, NULL); + return new osxGraphicsStateGuardian(engine, this, nullptr); } diff --git a/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx b/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx index 8099eb5547..0ae735b055 100644 --- a/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx +++ b/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx @@ -36,13 +36,13 @@ TypeHandle osxGraphicsStateGuardian::_type_handle; void *osxGraphicsStateGuardian:: do_get_extension_func(const char *name) { string fullname = "_" + string(name); - NSSymbol symbol = NULL; + NSSymbol symbol = nullptr; if (NSIsSymbolNameDefined(fullname.c_str())) { symbol = NSLookupAndBindSymbol(fullname.c_str()); } - return symbol ? NSAddressOfSymbol(symbol) : NULL; + return symbol ? NSAddressOfSymbol(symbol) : nullptr; } /** @@ -53,8 +53,8 @@ osxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, osxGraphicsStateGuardian *share_with) : GLGraphicsStateGuardian(engine, pipe), _share_with(share_with), - _aglPixFmt(NULL), - _aglcontext(NULL) + _aglPixFmt(nullptr), + _aglcontext(nullptr) { _shared_buffer = 1011; get_gamma_table(); @@ -65,11 +65,11 @@ osxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, */ osxGraphicsStateGuardian:: ~osxGraphicsStateGuardian() { - if (_aglcontext != (AGLContext)NULL) { - aglSetCurrentContext(NULL); + if (_aglcontext != (AGLContext)nullptr) { + aglSetCurrentContext(nullptr); aglDestroyContext(_aglcontext); report_agl_error("aglDestroyContext"); - _aglcontext = (AGLContext)NULL; + _aglcontext = (AGLContext)nullptr; } } @@ -89,7 +89,7 @@ void osxGraphicsStateGuardian::reset() GLGraphicsStateGuardian::reset(); - if (_aglcontext != (AGLContext)NULL) { + if (_aglcontext != (AGLContext)nullptr) { // Apply the video-sync setting. GLint value = sync_video ? 1 : 0; aglSetInteger(_aglcontext, AGL_SWAP_INTERVAL, &value); @@ -106,7 +106,7 @@ void osxGraphicsStateGuardian:: draw_resize_box() { // This state is created, once, and never freed. static CPT(RenderState) state; - if (state == (RenderState *)NULL) { + if (state == nullptr) { state = RenderState::make(TransparencyAttrib::make(TransparencyAttrib::M_alpha), DepthWriteAttrib::make(DepthWriteAttrib::M_off), DepthTestAttrib::make(DepthTestAttrib::M_none)); @@ -229,18 +229,18 @@ build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props) { attrib.push_back(AGL_NONE); // build context - _aglcontext = NULL; + _aglcontext = nullptr; _aglPixFmt = aglChoosePixelFormat(&display, 1, &attrib[0]); err = report_agl_error("aglChoosePixelFormat"); if (_aglPixFmt) { - if(_share_with == NULL) { - _aglcontext = aglCreateContext(_aglPixFmt, NULL); + if(_share_with == nullptr) { + _aglcontext = aglCreateContext(_aglPixFmt, nullptr); } else { _aglcontext = aglCreateContext(_aglPixFmt, ((osxGraphicsStateGuardian *)_share_with)->_aglcontext); } err = report_agl_error("aglCreateContext"); - if (_aglcontext == NULL) { + if (_aglcontext == nullptr) { osxdisplay_cat.error() << "osxGraphicsStateGuardian::build_gl Error Getting GL Context \n" ; if(err == noErr) { @@ -348,9 +348,9 @@ describe_pixel_format(FrameBufferProperties &fb_props) { GLint ndevs; AGLDevice *gdevs = aglDevicesOfPixelFormat(_aglPixFmt, &ndevs); - if (gdevs != (AGLDevice *)NULL) { + if (gdevs != nullptr) { AGLRendererInfo rinfo = aglQueryRendererInfo(gdevs, ndevs); - if (rinfo != NULL) { + if (rinfo != nullptr) { if (aglDescribeRenderer(rinfo, AGL_ACCELERATED, &value)) { // Now we know whether it's hardware or software. fb_props.set_force_hardware(value); diff --git a/panda/src/parametrics/curveFitter.cxx b/panda/src/parametrics/curveFitter.cxx index 6592d7aff2..e929ebd21e 100644 --- a/panda/src/parametrics/curveFitter.cxx +++ b/panda/src/parametrics/curveFitter.cxx @@ -152,7 +152,7 @@ remove_samples(int begin, int end) { */ void CurveFitter:: sample(ParametricCurveCollection *curves, int count) { - nassertv(curves != (ParametricCurveCollection *)NULL); + nassertv(curves != nullptr); PN_stdfloat max_t = curves->get_max_t(); PN_stdfloat t; DataPoint dp; @@ -166,10 +166,10 @@ sample(ParametricCurveCollection *curves, int count) { } } - if (curves->get_xyz_curve() != (ParametricCurve *)NULL) { + if (curves->get_xyz_curve() != nullptr) { _got_xyz = true; } - if (curves->get_hpr_curve() != (ParametricCurve *)NULL) { + if (curves->get_hpr_curve() != nullptr) { _got_hpr = true; } } diff --git a/panda/src/parametrics/nurbsCurveInterface.cxx b/panda/src/parametrics/nurbsCurveInterface.cxx index 9c9affa03d..b00edb3364 100644 --- a/panda/src/parametrics/nurbsCurveInterface.cxx +++ b/panda/src/parametrics/nurbsCurveInterface.cxx @@ -156,7 +156,7 @@ format_egg(ostream &out, const string &name, const string &curve_type, bool NurbsCurveInterface:: convert_to_nurbs(ParametricCurve *nc) const { NurbsCurveInterface *nurbs = nc->get_nurbs_interface(); - nassertr(nurbs != (NurbsCurveInterface *)NULL, false); + nassertr(nurbs != nullptr, false); nurbs->remove_all_cvs(); nurbs->set_order(get_order()); diff --git a/panda/src/parametrics/parametricCurve.cxx b/panda/src/parametrics/parametricCurve.cxx index 403f9e8c04..5d3d014722 100644 --- a/panda/src/parametrics/parametricCurve.cxx +++ b/panda/src/parametrics/parametricCurve.cxx @@ -418,7 +418,7 @@ get_bezier_seg(ParametricCurve::BezierSeg &) const { */ NurbsCurveInterface *ParametricCurve:: get_nurbs_interface() { - return (NurbsCurveInterface *)NULL; + return nullptr; } /** @@ -497,7 +497,7 @@ convert_to_hermite(HermiteCurve *hc) const { bool ParametricCurve:: convert_to_nurbs(ParametricCurve *nc) const { NurbsCurveInterface *nurbs = nc->get_nurbs_interface(); - nassertr(nurbs != (NurbsCurveInterface *)NULL, false); + nassertr(nurbs != nullptr, false); BezierSegs bz_segs; if (!get_bezier_segs(bz_segs)) { diff --git a/panda/src/parametrics/parametricCurveCollection.I b/panda/src/parametrics/parametricCurveCollection.I index 07fd5e9f26..ba4cf949a0 100644 --- a/panda/src/parametrics/parametricCurveCollection.I +++ b/panda/src/parametrics/parametricCurveCollection.I @@ -31,7 +31,7 @@ get_num_curves() const { */ INLINE ParametricCurve *ParametricCurveCollection:: get_curve(int index) const { - nassertr(index >= 0 && index < (int)_curves.size(), (ParametricCurve *)NULL); + nassertr(index >= 0 && index < (int)_curves.size(), nullptr); return _curves[index]; } diff --git a/panda/src/parametrics/parametricCurveCollection.cxx b/panda/src/parametrics/parametricCurveCollection.cxx index 45d61ccfe8..9e3d8b4a1b 100644 --- a/panda/src/parametrics/parametricCurveCollection.cxx +++ b/panda/src/parametrics/parametricCurveCollection.cxx @@ -150,8 +150,8 @@ clear() { */ void ParametricCurveCollection:: clear_timewarps() { - PT(ParametricCurve) xyz_curve = (ParametricCurve *)NULL; - PT(ParametricCurve) hpr_curve = (ParametricCurve *)NULL; + PT(ParametricCurve) xyz_curve = nullptr; + PT(ParametricCurve) hpr_curve = nullptr; ParametricCurves::iterator ci; for (ci = _curves.begin(); ci != _curves.end(); ++ci) { @@ -159,7 +159,7 @@ clear_timewarps() { switch (curve->get_curve_type()) { case PCT_XYZ: - if (xyz_curve == (ParametricCurve *)NULL) { + if (xyz_curve == nullptr) { xyz_curve = curve; } else { prepare_remove_curve(curve); @@ -167,7 +167,7 @@ clear_timewarps() { break; case PCT_HPR: - if (hpr_curve == (ParametricCurve *)NULL) { + if (hpr_curve == nullptr) { hpr_curve = curve; } else { prepare_remove_curve(curve); @@ -182,7 +182,7 @@ clear_timewarps() { _curves.clear(); _curves.push_back(xyz_curve); - if (hpr_curve != (ParametricCurve *)NULL) { + if (hpr_curve != nullptr) { _curves.push_back(hpr_curve); } @@ -202,7 +202,7 @@ get_xyz_curve() const { return curve; } } - return (ParametricCurve *)NULL; + return nullptr; } /** @@ -218,7 +218,7 @@ get_hpr_curve() const { return curve; } } - return (ParametricCurve *)NULL; + return nullptr; } /** @@ -229,7 +229,7 @@ get_hpr_curve() const { ParametricCurve *ParametricCurveCollection:: get_default_curve() const { ParametricCurve *xyz_curve = get_xyz_curve(); - if (xyz_curve != (ParametricCurve *)NULL) { + if (xyz_curve != nullptr) { return xyz_curve; } @@ -240,7 +240,7 @@ get_default_curve() const { return curve; } } - return (ParametricCurve *)NULL; + return nullptr; } /** @@ -276,8 +276,8 @@ get_timewarp_curve(int n) const { n--; } } - nassertr(false, (ParametricCurve *)NULL); - return (ParametricCurve *)NULL; + nassertr(false, nullptr); + return nullptr; } /** @@ -295,7 +295,7 @@ get_timewarp_curve(int n) const { void ParametricCurveCollection:: make_even(PN_stdfloat max_t, PN_stdfloat segments_per_unit) { ParametricCurve *xyz_curve = get_xyz_curve(); - if (xyz_curve == (ParametricCurve *)NULL) { + if (xyz_curve == nullptr) { parametrics_cat.error() << "No XYZ curve for make_even().\n"; return; @@ -349,7 +349,7 @@ make_even(PN_stdfloat max_t, PN_stdfloat segments_per_unit) { fitter.compute_tangents(1); PT(ParametricCurveCollection) fit = fitter.make_nurbs(); ParametricCurve *t_curve = fit->get_xyz_curve(); - nassertv(t_curve != (ParametricCurve *)NULL); + nassertv(t_curve != nullptr); t_curve->set_curve_type(PCT_T); add_curve(t_curve); } @@ -362,7 +362,7 @@ make_even(PN_stdfloat max_t, PN_stdfloat segments_per_unit) { void ParametricCurveCollection:: face_forward(PN_stdfloat segments_per_unit) { ParametricCurve *xyz_curve = get_xyz_curve(); - if (xyz_curve == (ParametricCurve *)NULL) { + if (xyz_curve == nullptr) { parametrics_cat.error() << "No XYZ curve for face_forward().\n"; return; @@ -412,7 +412,7 @@ face_forward(PN_stdfloat segments_per_unit) { fitter.compute_tangents(1); PT(ParametricCurveCollection) fit = fitter.make_nurbs(); ParametricCurve *hpr_curve = fit->get_hpr_curve(); - nassertv(hpr_curve != (ParametricCurve *)NULL); + nassertv(hpr_curve != nullptr); add_curve(hpr_curve, xyz_index + 1); } @@ -452,9 +452,9 @@ bool ParametricCurveCollection:: evaluate(PN_stdfloat t, LVecBase3 &xyz, LVecBase3 &hpr) const { // First, apply all the timewarps in sequence, from back to front. Also // take note of the XYZ and HPR curves. - ParametricCurve *xyz_curve = (ParametricCurve *)NULL; - ParametricCurve *hpr_curve = (ParametricCurve *)NULL; - ParametricCurve *default_curve = (ParametricCurve *)NULL; + ParametricCurve *xyz_curve = nullptr; + ParametricCurve *hpr_curve = nullptr; + ParametricCurve *default_curve = nullptr; PN_stdfloat t0 = t; LVecBase3 point; @@ -484,18 +484,18 @@ evaluate(PN_stdfloat t, LVecBase3 &xyz, LVecBase3 &hpr) const { } } - if (xyz_curve == (ParametricCurve *)NULL) { + if (xyz_curve == nullptr) { xyz_curve = default_curve; } // Now compute the position and orientation. - if (xyz_curve != (ParametricCurve *)NULL) { + if (xyz_curve != nullptr) { if (!xyz_curve->get_point(t0, xyz)) { return false; } } - if (hpr_curve != (ParametricCurve *)NULL) { + if (hpr_curve != nullptr) { if (!hpr_curve->get_point(t0, hpr)) { return false; } @@ -564,7 +564,7 @@ evaluate_t(PN_stdfloat t) const { bool ParametricCurveCollection:: adjust_xyz(PN_stdfloat t, const LVecBase3 &xyz) { ParametricCurve *xyz_curve = get_xyz_curve(); - if (xyz_curve == (ParametricCurve *)NULL) { + if (xyz_curve == nullptr) { return false; } @@ -583,7 +583,7 @@ adjust_xyz(PN_stdfloat t, const LVecBase3 &xyz) { bool ParametricCurveCollection:: adjust_hpr(PN_stdfloat t, const LVecBase3 &hpr) { ParametricCurve *hpr_curve = get_hpr_curve(); - if (hpr_curve == (ParametricCurve *)NULL) { + if (hpr_curve == nullptr) { return false; } @@ -631,7 +631,7 @@ stitch(const ParametricCurveCollection *a, clear(); - if (a_xyz != (ParametricCurve *)NULL && b_xyz != (ParametricCurve *)NULL) { + if (a_xyz != nullptr && b_xyz != nullptr) { PT(NurbsCurve) new_xyz = new NurbsCurve; if (!new_xyz->stitch(a_xyz, b_xyz)) { return false; @@ -640,7 +640,7 @@ stitch(const ParametricCurveCollection *a, add_curve(new_xyz); } - if (a_hpr != (ParametricCurve *)NULL && b_hpr != (ParametricCurve *)NULL) { + if (a_hpr != nullptr && b_hpr != nullptr) { PT(NurbsCurve) new_hpr = new NurbsCurve; if (!new_hpr->stitch(a_hpr, b_hpr)) { return false; diff --git a/panda/src/parametrics/piecewiseCurve.cxx b/panda/src/parametrics/piecewiseCurve.cxx index cbaa7497f6..d69b4f7025 100644 --- a/panda/src/parametrics/piecewiseCurve.cxx +++ b/panda/src/parametrics/piecewiseCurve.cxx @@ -68,7 +68,7 @@ bool PiecewiseCurve:: get_point(PN_stdfloat t, LVecBase3 &point) const { const ParametricCurve *curve; bool result = find_curve(curve, t); - if (curve == NULL){ + if (curve == nullptr){ return false; } // We use | instead of || so we won't short-circuit this calculation. @@ -438,7 +438,7 @@ find_curve(const ParametricCurve *&curve, PN_stdfloat &t) const { if (ti >= (int)_segs.size()) { if (_segs.empty()) { - curve = NULL; + curve = nullptr; t = 0.0f; return false; } else { @@ -523,7 +523,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { for (i = 0; i < num_segs; i++) { Curveseg seg; manager->read_pointer(scan); - seg._curve = (ParametricCurve *)NULL; + seg._curve = nullptr; seg._tend = scan.get_float64(); _segs.push_back(seg); } diff --git a/panda/src/parametrics/ropeNode.cxx b/panda/src/parametrics/ropeNode.cxx index 365795adf7..5837bfd361 100644 --- a/panda/src/parametrics/ropeNode.cxx +++ b/panda/src/parametrics/ropeNode.cxx @@ -50,7 +50,7 @@ void RopeNode::CData:: write_datagram(BamWriter *writer, Datagram &dg) const { // For now, we write a NULL pointer. Eventually we will write out the // NurbsCurveEvaluator pointer. - writer->write_pointer(dg, (TypedWritable *)NULL); + writer->write_pointer(dg, nullptr); } /** @@ -129,7 +129,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // Create some geometry on-the-fly to render the rope. if (get_num_subdiv() > 0) { NurbsCurveEvaluator *curve = get_curve(); - if (curve != (NurbsCurveEvaluator *)NULL) { + if (curve != nullptr) { PT(NurbsCurveResult) result; if (has_matrix()) { result = curve->evaluate(data.get_node_path(), get_matrix()); @@ -180,7 +180,7 @@ void RopeNode:: output(ostream &out) const { PandaNode::output(out); NurbsCurveEvaluator *curve = get_curve(); - if (curve != (NurbsCurveEvaluator *)NULL) { + if (curve != nullptr) { out << " " << *curve; } else { out << " (no curve)"; @@ -270,7 +270,7 @@ do_recompute_bounds(const NodePath &rel_to, int pipeline_stage, PT(BoundingVolume) bound = new BoundingSphere; NurbsCurveEvaluator *curve = get_curve(); - if (curve != (NurbsCurveEvaluator *)NULL) { + if (curve != nullptr) { NurbsCurveEvaluator::Vert3Array verts; get_curve()->get_vertices(verts, rel_to); @@ -519,14 +519,14 @@ get_connected_segments(RopeNode::CurveSegments &curve_segments, bool use_vertex_color = get_use_vertex_color(); bool use_vertex_thickness = get_use_vertex_thickness(); - CurveSegment *curve_segment = NULL; + CurveSegment *curve_segment = nullptr; LPoint3 last_point; for (int segment = 0; segment < num_segments; ++segment) { LPoint3 point; result->eval_segment_point(segment, 0.0f, point); - if (curve_segment == (CurveSegment *)NULL || + if (curve_segment == nullptr || !point.almost_equal(last_point)) { // If the first point of this segment is different from the last point // of the previous segment, end the previous segment and begin a new diff --git a/panda/src/parametrics/sheetNode.cxx b/panda/src/parametrics/sheetNode.cxx index b4e4cc5a4d..294c3a7ff4 100644 --- a/panda/src/parametrics/sheetNode.cxx +++ b/panda/src/parametrics/sheetNode.cxx @@ -48,7 +48,7 @@ void SheetNode::CData:: write_datagram(BamWriter *writer, Datagram &dg) const { // For now, we write a NULL pointer. Eventually we will write out the // NurbsSurfaceEvaluator pointer. - writer->write_pointer(dg, (TypedWritable *)NULL); + writer->write_pointer(dg, nullptr); } /** @@ -128,7 +128,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // Create some geometry on-the-fly to render the sheet. if (get_num_u_subdiv() > 0 && get_num_v_subdiv() > 0) { NurbsSurfaceEvaluator *surface = get_surface(); - if (surface != (NurbsSurfaceEvaluator *)NULL) { + if (surface != nullptr) { PT(NurbsSurfaceResult) result = surface->evaluate(data.get_node_path()); if (result->get_num_u_segments() > 0 && result->get_num_v_segments() > 0) { @@ -158,7 +158,7 @@ void SheetNode:: output(ostream &out) const { PandaNode::output(out); NurbsSurfaceEvaluator *surface = get_surface(); - if (surface != (NurbsSurfaceEvaluator *)NULL) { + if (surface != nullptr) { out << " " << *surface; } else { out << " (no surface)"; @@ -172,7 +172,7 @@ void SheetNode:: write(ostream &out, int indent_level) const { PandaNode::write(out, indent_level); NurbsSurfaceEvaluator *surface = get_surface(); - if (surface != (NurbsSurfaceEvaluator *)NULL) { + if (surface != nullptr) { indent(out, indent_level + 2) << *surface << "\n"; } else { indent(out, indent_level + 2) << "(no surface)\n"; @@ -224,7 +224,7 @@ do_recompute_bounds(const NodePath &rel_to, int pipeline_stage, PT(BoundingVolume) bound = new BoundingSphere; NurbsSurfaceEvaluator *surface = get_surface(); - if (surface != (NurbsSurfaceEvaluator *)NULL) { + if (surface != nullptr) { NurbsSurfaceEvaluator::Vert3Array verts; get_surface()->get_vertices(verts, rel_to); diff --git a/panda/src/particlesystem/colorInterpolationManager.I b/panda/src/particlesystem/colorInterpolationManager.I index 4a76521cea..e9b087605f 100644 --- a/panda/src/particlesystem/colorInterpolationManager.I +++ b/panda/src/particlesystem/colorInterpolationManager.I @@ -231,7 +231,7 @@ get_segment(const int seg_id) { if( seg_id == (*iter)->get_id() ) return (*iter); - return NULL; + return nullptr; } /** diff --git a/panda/src/particlesystem/geomParticleRenderer.I b/panda/src/particlesystem/geomParticleRenderer.I index 25ce5035c3..cdb3906ac0 100644 --- a/panda/src/particlesystem/geomParticleRenderer.I +++ b/panda/src/particlesystem/geomParticleRenderer.I @@ -21,7 +21,7 @@ INLINE void GeomParticleRenderer:: set_geom_node(PandaNode *node) { - nassertv(node != (PandaNode *)NULL); + nassertv(node != nullptr); _geom_node = node; resize_pool(_pool_size); } diff --git a/panda/src/particlesystem/geomParticleRenderer.cxx b/panda/src/particlesystem/geomParticleRenderer.cxx index 92ebc5a218..74df181f2e 100644 --- a/panda/src/particlesystem/geomParticleRenderer.cxx +++ b/panda/src/particlesystem/geomParticleRenderer.cxx @@ -105,7 +105,7 @@ resize_pool(int new_size) { int i; for (i = 0; i < new_size; i++) { - _node_vector.push_back(NULL); + _node_vector.push_back(nullptr); } _pool_size = new_size; @@ -122,7 +122,7 @@ kill_nodes() { PandaNode *render_node = get_render_node(); for (; vec_iter != _node_vector.end(); vec_iter++) { PandaNode *node = *vec_iter; - if (node != (PandaNode *)NULL) { + if (node != nullptr) { render_node->remove_child(node); } } @@ -136,7 +136,7 @@ kill_nodes() { void GeomParticleRenderer:: birth_particle(int index) { - if (_node_vector[index] == (PandaNode *)NULL) { + if (_node_vector[index] == nullptr) { PandaNode *node = new PandaNode(""); get_render_node()->add_child(node); node->add_child(_geom_node); @@ -150,9 +150,9 @@ birth_particle(int index) { void GeomParticleRenderer:: kill_particle(int index) { - if (_node_vector[index] != (PandaNode *)NULL) { + if (_node_vector[index] != nullptr) { get_render_node()->remove_child(_node_vector[index]); - _node_vector[index] = (PandaNode *)NULL; + _node_vector[index] = nullptr; } } @@ -179,11 +179,11 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { if (cur_particle->get_alive()) { // living particle - if (cur_node == (PandaNode *)NULL) { + if (cur_node == nullptr) { birth_particle(i); cur_node = *cur_node_iter; } - nassertv(cur_node != (PandaNode *)NULL); + nassertv(cur_node != nullptr); cur_node->set_state(_render_state); diff --git a/panda/src/particlesystem/geomParticleRenderer.h b/panda/src/particlesystem/geomParticleRenderer.h index 54e58a2d65..1e4fccf320 100644 --- a/panda/src/particlesystem/geomParticleRenderer.h +++ b/panda/src/particlesystem/geomParticleRenderer.h @@ -26,7 +26,7 @@ class EXPCL_PANDAPHYSICS GeomParticleRenderer : public BaseParticleRenderer { PUBLISHED: explicit GeomParticleRenderer(ParticleRendererAlphaMode am = PR_ALPHA_NONE, - PandaNode *geom_node = (PandaNode *) NULL); + PandaNode *geom_node = nullptr); GeomParticleRenderer(const GeomParticleRenderer& copy); virtual ~GeomParticleRenderer(); diff --git a/panda/src/particlesystem/spriteParticleRenderer.I b/panda/src/particlesystem/spriteParticleRenderer.I index 1f1d4e488b..ccdaa9977b 100644 --- a/panda/src/particlesystem/spriteParticleRenderer.I +++ b/panda/src/particlesystem/spriteParticleRenderer.I @@ -21,7 +21,7 @@ */ INLINE void SpriteParticleRenderer:: set_texture(Texture *tex, PN_stdfloat texels_per_unit) { - if (tex != (Texture *)NULL) { + if (tex != nullptr) { // Clear all texture information _anims.clear(); @@ -46,8 +46,8 @@ add_texture(Texture *tex, PN_stdfloat texels_per_unit, bool resize) { if (_anims.size() == 0) { set_texture(tex, texels_per_unit); } else { - if(tex != (Texture *)NULL) { - if (tex != (Texture *)NULL) { + if(tex != nullptr) { + if (tex != nullptr) { _anims.push_back(new SpriteAnim(tex,LTexCoord(0.0f, 0.0f),LTexCoord(1.0f, 1.0f))); } if(resize) { @@ -269,9 +269,9 @@ get_texture() const { INLINE Texture *SpriteParticleRenderer:: get_texture(const int anim, const int frame) const { if(_anims.size() == 0) { - return (Texture*)NULL; + return nullptr; } - nassertr(anim < (int)_anims.size() && anim >= 0, (Texture*)NULL); + nassertr(anim < (int)_anims.size() && anim >= 0, nullptr); nassertr(frame < (int)_anims[anim]->get_num_frames() && frame >= 0,_anims[anim]->get_frame(0)); return _anims[anim]->get_frame(frame); } @@ -283,7 +283,7 @@ get_num_anims() const { INLINE SpriteAnim *SpriteParticleRenderer:: get_anim(const int n) const { - nassertr(n < (int)_anims.size(), (SpriteAnim*)NULL); + nassertr(n < (int)_anims.size(), nullptr); return _anims[n]; } @@ -292,7 +292,7 @@ get_last_anim() const { if (_anims.size()) { return *(_anims.end()-1); } else { - return (SpriteAnim *)NULL; + return nullptr; } } diff --git a/panda/src/particlesystem/spriteParticleRenderer.cxx b/panda/src/particlesystem/spriteParticleRenderer.cxx index 7c5756bc6f..58cec0e50a 100644 --- a/panda/src/particlesystem/spriteParticleRenderer.cxx +++ b/panda/src/particlesystem/spriteParticleRenderer.cxx @@ -272,7 +272,7 @@ add_from_node(const NodePath &node_path, bool size_from_texels, bool resize) { // Load the found textures into the renderer. if (extract_textures_from_node(node_path,np_col,tex_col)) { pvector< LTexCoord > ll,ur; - GeomNode *gnode = NULL; + GeomNode *gnode = nullptr; const Geom *geom; const GeomPrimitive *primitive; @@ -479,7 +479,7 @@ init_geoms() { _sprite_writer[i].push_back(SpriteWriter()); state = state->add_attrib(RenderModeAttrib::make(RenderModeAttrib::M_unchanged, _base_y_scale * _height, true)); - if (anim->get_frame(j) != (Texture *)NULL) { + if (anim->get_frame(j) != nullptr) { state = state->add_attrib(TextureAttrib::make(anim->get_frame(j))); state = state->add_attrib(TexGenAttrib::make(TextureStage::get_default(), TexGenAttrib::M_point_sprite)); diff --git a/panda/src/particlesystem/spriteParticleRenderer.h b/panda/src/particlesystem/spriteParticleRenderer.h index 4ab65c02fb..ecb9f579fd 100644 --- a/panda/src/particlesystem/spriteParticleRenderer.h +++ b/panda/src/particlesystem/spriteParticleRenderer.h @@ -153,7 +153,7 @@ private: */ class EXPCL_PANDAPHYSICS SpriteParticleRenderer : public BaseParticleRenderer { PUBLISHED: - explicit SpriteParticleRenderer(Texture *tex = (Texture *) NULL); + explicit SpriteParticleRenderer(Texture *tex = nullptr); SpriteParticleRenderer(const SpriteParticleRenderer ©); virtual ~SpriteParticleRenderer(); diff --git a/panda/src/pgraph/accumulatedAttribs.cxx b/panda/src/pgraph/accumulatedAttribs.cxx index ea35b495ab..f82ec15d03 100644 --- a/panda/src/pgraph/accumulatedAttribs.cxx +++ b/panda/src/pgraph/accumulatedAttribs.cxx @@ -90,35 +90,35 @@ write(ostream &out, int attrib_types, int indent_level) const { _transform->write(out, indent_level); } if ((attrib_types & SceneGraphReducer::TT_color) != 0) { - if (_color == (const RenderAttrib *)NULL) { + if (_color == nullptr) { indent(out, indent_level) << "no color\n"; } else { _color->write(out, indent_level); } } if ((attrib_types & SceneGraphReducer::TT_color_scale) != 0) { - if (_color_scale == (const RenderAttrib *)NULL) { + if (_color_scale == nullptr) { indent(out, indent_level) << "no color scale\n"; } else { _color_scale->write(out, indent_level); } } if ((attrib_types & SceneGraphReducer::TT_tex_matrix) != 0) { - if (_tex_matrix == (const RenderAttrib *)NULL) { + if (_tex_matrix == nullptr) { indent(out, indent_level) << "no tex matrix\n"; } else { _tex_matrix->write(out, indent_level); } } if ((attrib_types & SceneGraphReducer::TT_clip_plane) != 0) { - if (_clip_plane == (const RenderAttrib *)NULL) { + if (_clip_plane == nullptr) { indent(out, indent_level) << "no clip plane\n"; } else { _clip_plane->write(out, indent_level); } } if ((attrib_types & SceneGraphReducer::TT_cull_face) != 0) { - if (_cull_face == (const RenderAttrib *)NULL) { + if (_cull_face == nullptr) { indent(out, indent_level) << "no cull face\n"; } else { _cull_face->write(out, indent_level); @@ -137,7 +137,7 @@ void AccumulatedAttribs:: collect(PandaNode *node, int attrib_types) { if ((attrib_types & SceneGraphReducer::TT_transform) != 0) { // Collect the node's transform. - nassertv(_transform != (TransformState *)NULL); + nassertv(_transform != nullptr); _transform = _transform->compose(node->get_transform()); node->set_transform(TransformState::make_identity()); node->set_prev_transform(TransformState::make_identity()); @@ -158,12 +158,12 @@ collect(const RenderState *state, int attrib_types) { if ((attrib_types & SceneGraphReducer::TT_color) != 0) { const RenderAttrib *node_attrib = new_state->get_attrib(ColorAttrib::get_class_slot()); - if (node_attrib != (const RenderAttrib *)NULL) { + if (node_attrib != nullptr) { int color_override = new_state->get_override(ColorAttrib::get_class_slot()); if (color_override >= _color_override || - _color == (const RenderAttrib *)NULL) { + _color == nullptr) { // The node has a color attribute; apply it. - if (_color == (const RenderAttrib *)NULL) { + if (_color == nullptr) { _color = node_attrib; } else { _color = _color->compose(node_attrib); @@ -177,11 +177,11 @@ collect(const RenderState *state, int attrib_types) { if ((attrib_types & SceneGraphReducer::TT_color_scale) != 0) { const RenderAttrib *node_attrib = new_state->get_attrib(ColorScaleAttrib::get_class_slot()); - if (node_attrib != (const RenderAttrib *)NULL) { + if (node_attrib != nullptr) { int color_scale_override = new_state->get_override(ColorScaleAttrib::get_class_slot()); if (color_scale_override >= _color_scale_override || - _color_scale == (const RenderAttrib *)NULL) { - if (_color_scale == (const RenderAttrib *)NULL) { + _color_scale == nullptr) { + if (_color_scale == nullptr) { _color_scale = node_attrib; } else { _color_scale = _color_scale->compose(node_attrib); @@ -195,11 +195,11 @@ collect(const RenderState *state, int attrib_types) { if ((attrib_types & SceneGraphReducer::TT_tex_matrix) != 0) { const RenderAttrib *node_attrib = new_state->get_attrib(TexMatrixAttrib::get_class_slot()); - if (node_attrib != (const RenderAttrib *)NULL) { + if (node_attrib != nullptr) { int tex_matrix_override = new_state->get_override(TexMatrixAttrib::get_class_slot()); if (tex_matrix_override >= _tex_matrix_override || - _tex_matrix == (const RenderAttrib *)NULL) { - if (_tex_matrix == (const RenderAttrib *)NULL) { + _tex_matrix == nullptr) { + if (_tex_matrix == nullptr) { _tex_matrix = node_attrib; } else { _tex_matrix = _tex_matrix->compose(node_attrib); @@ -213,11 +213,11 @@ collect(const RenderState *state, int attrib_types) { // texture matrix. const RenderAttrib *tex_attrib = new_state->get_attrib(TextureAttrib::get_class_slot()); - if (tex_attrib != (const RenderAttrib *)NULL) { + if (tex_attrib != nullptr) { int texture_override = new_state->get_override(TextureAttrib::get_class_slot()); if (texture_override >= _texture_override || - _texture == (const RenderAttrib *)NULL) { - if (_texture == (const RenderAttrib *)NULL) { + _texture == nullptr) { + if (_texture == nullptr) { _texture = tex_attrib; } else { _texture = _texture->compose(tex_attrib); @@ -234,11 +234,11 @@ collect(const RenderState *state, int attrib_types) { if ((attrib_types & SceneGraphReducer::TT_clip_plane) != 0) { const RenderAttrib *node_attrib = new_state->get_attrib(ClipPlaneAttrib::get_class_slot()); - if (node_attrib != (const RenderAttrib *)NULL) { + if (node_attrib != nullptr) { int clip_plane_override = new_state->get_override(ClipPlaneAttrib::get_class_slot()); if (clip_plane_override >= _clip_plane_override || - _clip_plane == (const RenderAttrib *)NULL) { - if (_clip_plane == (const RenderAttrib *)NULL) { + _clip_plane == nullptr) { + if (_clip_plane == nullptr) { _clip_plane = node_attrib; } else { _clip_plane = _clip_plane->compose(node_attrib); @@ -252,11 +252,11 @@ collect(const RenderState *state, int attrib_types) { if ((attrib_types & SceneGraphReducer::TT_cull_face) != 0) { const RenderAttrib *node_attrib = new_state->get_attrib(CullFaceAttrib::get_class_slot()); - if (node_attrib != (const RenderAttrib *)NULL) { + if (node_attrib != nullptr) { int cull_face_override = new_state->get_override(CullFaceAttrib::get_class_slot()); if (cull_face_override >= _cull_face_override || - _cull_face == (const RenderAttrib *)NULL) { - if (_cull_face == (const RenderAttrib *)NULL) { + _cull_face == nullptr) { + if (_cull_face == nullptr) { _cull_face = node_attrib; } else { _cull_face = _cull_face->compose(node_attrib); @@ -269,7 +269,7 @@ collect(const RenderState *state, int attrib_types) { if ((attrib_types & SceneGraphReducer::TT_other) != 0) { // Collect everything else. - nassertr(_other != (RenderState *)NULL, new_state); + nassertr(_other != nullptr, new_state); _other = _other->compose(new_state); new_state = RenderState::make_empty(); } @@ -291,67 +291,67 @@ apply_to_node(PandaNode *node, int attrib_types) { } if ((attrib_types & SceneGraphReducer::TT_color) != 0) { - if (_color != (RenderAttrib *)NULL) { + if (_color != nullptr) { const RenderAttrib *node_attrib = node->get_attrib(ColorAttrib::get_class_slot()); - if (node_attrib != (RenderAttrib *)NULL) { + if (node_attrib != nullptr) { node->set_attrib(_color->compose(node_attrib)->get_unique()); } else { node->set_attrib(_color->get_unique()); } - _color = (RenderAttrib *)NULL; + _color = nullptr; } } if ((attrib_types & SceneGraphReducer::TT_color_scale) != 0) { - if (_color_scale != (RenderAttrib *)NULL) { + if (_color_scale != nullptr) { const RenderAttrib *node_attrib = node->get_attrib(ColorScaleAttrib::get_class_slot()); - if (node_attrib != (RenderAttrib *)NULL) { + if (node_attrib != nullptr) { node->set_attrib(_color_scale->compose(node_attrib)->get_unique()); } else { node->set_attrib(_color_scale->get_unique()); } - _color_scale = (RenderAttrib *)NULL; + _color_scale = nullptr; } } if ((attrib_types & SceneGraphReducer::TT_tex_matrix) != 0) { - if (_tex_matrix != (RenderAttrib *)NULL) { + if (_tex_matrix != nullptr) { const RenderAttrib *node_attrib = node->get_attrib(TexMatrixAttrib::get_class_slot()); - if (node_attrib != (RenderAttrib *)NULL) { + if (node_attrib != nullptr) { node->set_attrib(_tex_matrix->compose(node_attrib)->get_unique()); } else { node->set_attrib(_tex_matrix->get_unique()); } - _tex_matrix = (RenderAttrib *)NULL; + _tex_matrix = nullptr; } } if ((attrib_types & SceneGraphReducer::TT_clip_plane) != 0) { - if (_clip_plane != (RenderAttrib *)NULL) { + if (_clip_plane != nullptr) { const RenderAttrib *node_attrib = node->get_attrib(ClipPlaneAttrib::get_class_slot()); - if (node_attrib != (RenderAttrib *)NULL) { + if (node_attrib != nullptr) { node->set_attrib(_clip_plane->compose(node_attrib)->get_unique()); } else { node->set_attrib(_clip_plane->get_unique()); } - _clip_plane = (RenderAttrib *)NULL; + _clip_plane = nullptr; } } if ((attrib_types & SceneGraphReducer::TT_cull_face) != 0) { - if (_cull_face != (RenderAttrib *)NULL) { + if (_cull_face != nullptr) { const RenderAttrib *node_attrib = node->get_attrib(CullFaceAttrib::get_class_slot()); - if (node_attrib != (RenderAttrib *)NULL) { + if (node_attrib != nullptr) { node->set_attrib(_cull_face->compose(node_attrib)->get_unique()); } else { node->set_attrib(_cull_face->get_unique()); } - _cull_face = (RenderAttrib *)NULL; + _cull_face = nullptr; } } diff --git a/panda/src/pgraph/attribNodeRegistry.I b/panda/src/pgraph/attribNodeRegistry.I index 30e66ca84c..b78c9bd78e 100644 --- a/panda/src/pgraph/attribNodeRegistry.I +++ b/panda/src/pgraph/attribNodeRegistry.I @@ -16,7 +16,7 @@ */ INLINE AttribNodeRegistry *AttribNodeRegistry:: get_global_ptr() { - if (_global_ptr == (AttribNodeRegistry *)NULL) { + if (_global_ptr == nullptr) { make_global_ptr(); } return _global_ptr; diff --git a/panda/src/pgraph/attribNodeRegistry.cxx b/panda/src/pgraph/attribNodeRegistry.cxx index 0d540c19d2..995fe2b63c 100644 --- a/panda/src/pgraph/attribNodeRegistry.cxx +++ b/panda/src/pgraph/attribNodeRegistry.cxx @@ -229,10 +229,10 @@ void AttribNodeRegistry:: make_global_ptr() { AttribNodeRegistry *ptr = new AttribNodeRegistry; void *result = AtomicAdjust::compare_and_exchange_ptr - ((void * TVOLATILE &)_global_ptr, (void *)NULL, (void *)ptr); - if (result != NULL) { + ((void * TVOLATILE &)_global_ptr, nullptr, (void *)ptr); + if (result != nullptr) { // Someone else got there first. delete ptr; } - assert(_global_ptr != (AttribNodeRegistry *)NULL); + assert(_global_ptr != nullptr); } diff --git a/panda/src/pgraph/audioVolumeAttrib.cxx b/panda/src/pgraph/audioVolumeAttrib.cxx index 1f545cef8e..52d12156d0 100644 --- a/panda/src/pgraph/audioVolumeAttrib.cxx +++ b/panda/src/pgraph/audioVolumeAttrib.cxx @@ -43,7 +43,7 @@ CPT(RenderAttrib) AudioVolumeAttrib:: make_identity() { // We make identity a special case and store a pointer forever once we find // it the first time. - if (_identity_attrib == (AudioVolumeAttrib *)NULL) { + if (_identity_attrib == nullptr) { AudioVolumeAttrib *attrib = new AudioVolumeAttrib(false, 1.0f);; _identity_attrib = return_new(attrib); } diff --git a/panda/src/pgraph/auxBitplaneAttrib.cxx b/panda/src/pgraph/auxBitplaneAttrib.cxx index 8f8e2d8a9f..662ae36b19 100644 --- a/panda/src/pgraph/auxBitplaneAttrib.cxx +++ b/panda/src/pgraph/auxBitplaneAttrib.cxx @@ -28,7 +28,7 @@ CPT(RenderAttrib) AuxBitplaneAttrib::_default; */ CPT(RenderAttrib) AuxBitplaneAttrib:: make() { - if (_default == 0) { + if (_default == nullptr) { AuxBitplaneAttrib *attrib = new AuxBitplaneAttrib(0); _default = return_new(attrib); } diff --git a/panda/src/pgraph/bamFile.I b/panda/src/pgraph/bamFile.I index b3305cbe48..70e264358e 100644 --- a/panda/src/pgraph/bamFile.I +++ b/panda/src/pgraph/bamFile.I @@ -17,7 +17,7 @@ */ INLINE bool BamFile:: is_valid_read() const { - return (_reader != (BamReader *)NULL); + return (_reader != nullptr); } @@ -27,5 +27,5 @@ is_valid_read() const { */ INLINE bool BamFile:: is_valid_write() const { - return (_writer != (BamWriter *)NULL); + return (_writer != nullptr); } diff --git a/panda/src/pgraph/bamFile.cxx b/panda/src/pgraph/bamFile.cxx index 871ec94587..fa8ae7f4c0 100644 --- a/panda/src/pgraph/bamFile.cxx +++ b/panda/src/pgraph/bamFile.cxx @@ -29,8 +29,8 @@ */ BamFile:: BamFile() { - _reader = NULL; - _writer = NULL; + _reader = nullptr; + _writer = nullptr; } /** @@ -81,8 +81,8 @@ open_read(istream &in, const string &bam_filename, bool report_errors) { */ TypedWritable *BamFile:: read_object() { - if (_reader == (BamReader *)NULL) { - return NULL; + if (_reader == nullptr) { + return nullptr; } return _reader->read_object(); @@ -94,7 +94,7 @@ read_object() { */ bool BamFile:: is_eof() const { - return _reader != (BamReader *)NULL && _reader->is_eof(); + return _reader != nullptr && _reader->is_eof(); } /** @@ -106,7 +106,7 @@ is_eof() const { */ bool BamFile:: resolve() { - if (_reader == (BamReader *)NULL) { + if (_reader == nullptr) { return false; } @@ -134,7 +134,7 @@ read_node(bool report_errors) { TypedWritable *object = read_object(); - if (object != (TypedWritable *)NULL && + if (object != nullptr && object->is_exact_type(BamCacheRecord::get_class_type())) { // Here's a special case: if the first object in the file is a // BamCacheRecord, it's really a cache data file and not a true bam file; @@ -172,7 +172,7 @@ read_node(bool report_errors) { loader_cat.error() << "Unable to resolve Bam file.\n"; } - result = (PandaNode *)NULL; + result = nullptr; } return result; @@ -222,7 +222,7 @@ open_write(ostream &out, const string &bam_filename, bool report_errors) { */ bool BamFile:: write_object(const TypedWritable *object) { - if (_writer == (BamWriter *)NULL) { + if (_writer == nullptr) { return false; } @@ -239,14 +239,14 @@ write_object(const TypedWritable *object) { */ void BamFile:: close() { - if (_reader != (BamReader *)NULL) { + if (_reader != nullptr) { // resolve(); delete _reader; - _reader = NULL; + _reader = nullptr; } - if (_writer != (BamWriter *)NULL) { + if (_writer != nullptr) { delete _writer; - _writer = NULL; + _writer = nullptr; } _din.close(); _dout.close(); @@ -260,7 +260,7 @@ close() { */ int BamFile:: get_file_major_ver() { - if (_reader == (BamReader *)NULL) { + if (_reader == nullptr) { return _bam_major_ver; } return _reader->get_file_major_ver(); @@ -273,7 +273,7 @@ get_file_major_ver() { */ int BamFile:: get_file_minor_ver() { - if (_reader == (BamReader *)NULL) { + if (_reader == nullptr) { return _bam_minor_ver; } return _reader->get_file_minor_ver(); @@ -285,10 +285,10 @@ get_file_minor_ver() { */ BamFile::BamEndian BamFile:: get_file_endian() const { - if (_writer != (BamWriter *)NULL) { + if (_writer != nullptr) { return _writer->get_file_endian(); } - if (_reader != (BamReader *)NULL) { + if (_reader != nullptr) { return _reader->get_file_endian(); } @@ -301,10 +301,10 @@ get_file_endian() const { */ bool BamFile:: get_file_stdfloat_double() const { - if (_writer != (BamWriter *)NULL) { + if (_writer != nullptr) { return _writer->get_file_stdfloat_double(); } - if (_reader != (BamReader *)NULL) { + if (_reader != nullptr) { return _reader->get_file_stdfloat_double(); } diff --git a/panda/src/pgraph/camera.cxx b/panda/src/pgraph/camera.cxx index aabf56eda2..4ab1039d05 100644 --- a/panda/src/pgraph/camera.cxx +++ b/panda/src/pgraph/camera.cxx @@ -153,7 +153,7 @@ get_tag_state(const string &tag_state) const { */ void Camera:: set_aux_scene_data(const NodePath &node_path, AuxSceneData *data) { - if (data == (AuxSceneData *)NULL) { + if (data == nullptr) { clear_aux_scene_data(node_path); } else { _aux_data[node_path] = data; @@ -188,7 +188,7 @@ get_aux_scene_data(const NodePath &node_path) const { return (*ai).second; } - return NULL; + return nullptr; } /** diff --git a/panda/src/pgraph/clipPlaneAttrib.cxx b/panda/src/pgraph/clipPlaneAttrib.cxx index 0e37f618a5..f833d2dd94 100644 --- a/panda/src/pgraph/clipPlaneAttrib.cxx +++ b/panda/src/pgraph/clipPlaneAttrib.cxx @@ -35,7 +35,7 @@ public: nassertr(!a.is_empty() && !b.is_empty(), a < b); PlaneNode *pa = DCAST(PlaneNode, a.node()); PlaneNode *pb = DCAST(PlaneNode, b.node()); - nassertr(pa != (PlaneNode *)NULL && pb != (PlaneNode *)NULL, a < b); + nassertr(pa != nullptr && pb != nullptr, a < b); return pa->get_priority() > pb->get_priority(); } @@ -340,7 +340,7 @@ CPT(RenderAttrib) ClipPlaneAttrib:: make() { // We make it a special case and store a pointer to the empty attrib forever // once we find it the first time, as an optimization. - if (_empty_attrib == (RenderAttrib *)NULL) { + if (_empty_attrib == nullptr) { _empty_attrib = return_new(new ClipPlaneAttrib); } @@ -355,7 +355,7 @@ CPT(RenderAttrib) ClipPlaneAttrib:: make_all_off() { // We make it a special case and store a pointer to the off attrib forever // once we find it the first time, as an optimization. - if (_all_off_attrib == (RenderAttrib *)NULL) { + if (_all_off_attrib == nullptr) { ClipPlaneAttrib *attrib = new ClipPlaneAttrib; attrib->_off_all_planes = true; _all_off_attrib = return_new(attrib); @@ -487,7 +487,7 @@ filter_to_max(int max_clip_planes) const { CPT(RenderAttrib) ClipPlaneAttrib:: compose_off(const RenderAttrib *other) const { const ClipPlaneAttrib *ta; - DCAST_INTO_R(ta, other, NULL); + DCAST_INTO_R(ta, other, nullptr); if (_off_all_planes || (!ta->_off_all_planes && ta->_off_planes.empty())) { // If we turn off all planes, or the other turns none off, the result is @@ -701,7 +701,7 @@ get_hash_impl() const { CPT(RenderAttrib) ClipPlaneAttrib:: compose_impl(const RenderAttrib *other) const { const ClipPlaneAttrib *ta; - DCAST_INTO_R(ta, other, NULL); + DCAST_INTO_R(ta, other, nullptr); if (ta->_off_all_planes) { // If the other type turns off all planes, it doesn't matter what we are. @@ -912,7 +912,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { } else { BamAuxData *aux = (BamAuxData *)manager->get_aux_data(this, "planes"); - nassertr(aux != NULL, pi); + nassertr(aux != nullptr, pi); int i; aux->_off_list.reserve(aux->_num_off_planes); @@ -964,7 +964,7 @@ finalize(BamReader *manager) { } else { // Now it's safe to convert our saved PandaNodes into NodePaths. BamAuxData *aux = (BamAuxData *)manager->get_aux_data(this, "planes"); - nassertv(aux != NULL); + nassertv(aux != nullptr); nassertv(aux->_num_off_planes == (int)aux->_off_list.size()); nassertv(aux->_num_on_planes == (int)aux->_on_list.size()); diff --git a/panda/src/pgraph/colorAttrib.cxx b/panda/src/pgraph/colorAttrib.cxx index 42e7c5578d..5af6ace015 100644 --- a/panda/src/pgraph/colorAttrib.cxx +++ b/panda/src/pgraph/colorAttrib.cxx @@ -30,7 +30,7 @@ CPT(RenderAttrib) ColorAttrib::_vertex; */ CPT(RenderAttrib) ColorAttrib:: make_vertex() { - if (_vertex != 0) { + if (_vertex != nullptr) { return _vertex; } ColorAttrib *attrib = new ColorAttrib(T_vertex, LColor::zero()); @@ -54,7 +54,7 @@ make_flat(const LColor &color) { */ CPT(RenderAttrib) ColorAttrib:: make_off() { - if (_off != 0) { + if (_off != nullptr) { return _off; } ColorAttrib *attrib = new ColorAttrib(T_off, LColor(1.0f, 1.0f, 1.0f, 1.0f)); diff --git a/panda/src/pgraph/colorScaleAttrib.cxx b/panda/src/pgraph/colorScaleAttrib.cxx index 79394a51f1..572f3e0e14 100644 --- a/panda/src/pgraph/colorScaleAttrib.cxx +++ b/panda/src/pgraph/colorScaleAttrib.cxx @@ -45,7 +45,7 @@ CPT(RenderAttrib) ColorScaleAttrib:: make_identity() { // We make identity a special case and store a pointer forever once we find // it the first time. - if (_identity_attrib == (ColorScaleAttrib *)NULL) { + if (_identity_attrib == nullptr) { ColorScaleAttrib *attrib = new ColorScaleAttrib(false, LVecBase4(1.0f, 1.0f, 1.0f, 1.0f));; _identity_attrib = return_new(attrib); } diff --git a/panda/src/pgraph/cullBin.cxx b/panda/src/pgraph/cullBin.cxx index 4d5cea887a..1c73c952b6 100644 --- a/panda/src/pgraph/cullBin.cxx +++ b/panda/src/pgraph/cullBin.cxx @@ -41,7 +41,7 @@ CullBin:: */ PT(CullBin) CullBin:: make_next() const { - return (CullBin *)NULL; + return nullptr; } /** diff --git a/panda/src/pgraph/cullBinManager.I b/panda/src/pgraph/cullBinManager.I index 7bafdea5d6..603622ba2f 100644 --- a/panda/src/pgraph/cullBinManager.I +++ b/panda/src/pgraph/cullBinManager.I @@ -279,7 +279,7 @@ set_bin_flash_color(int bin_index, const LColor &color) { */ INLINE CullBinManager *CullBinManager:: get_global_ptr() { - if (_global_ptr == (CullBinManager *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new CullBinManager; } return _global_ptr; diff --git a/panda/src/pgraph/cullBinManager.cxx b/panda/src/pgraph/cullBinManager.cxx index 0d979cf7e7..56aed8c730 100644 --- a/panda/src/pgraph/cullBinManager.cxx +++ b/panda/src/pgraph/cullBinManager.cxx @@ -18,7 +18,7 @@ #include "string_utils.h" #include "configVariableColor.h" -CullBinManager *CullBinManager::_global_ptr = (CullBinManager *)NULL; +CullBinManager *CullBinManager::_global_ptr = nullptr; /** * The constructor is not intended to be called directly; there is only one @@ -185,8 +185,8 @@ write(ostream &out) const { PT(CullBin) CullBinManager:: make_new_bin(int bin_index, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) { - nassertr(bin_index >= 0 && bin_index < (int)_bin_definitions.size(), NULL); - nassertr(_bin_definitions[bin_index]._in_use, NULL); + nassertr(bin_index >= 0 && bin_index < (int)_bin_definitions.size(), nullptr); + nassertr(_bin_definitions[bin_index]._in_use, nullptr); string name = get_bin_name(bin_index); BinType type = _bin_definitions[bin_index]._type; @@ -197,8 +197,8 @@ make_new_bin(int bin_index, GraphicsStateGuardianBase *gsg, } // Hmm, unknown (or unregistered) bin type. - nassertr(false, NULL); - return NULL; + nassertr(false, nullptr); + return nullptr; } /** diff --git a/panda/src/pgraph/cullPlanes.cxx b/panda/src/pgraph/cullPlanes.cxx index 43a249403b..fcb7a0c532 100644 --- a/panda/src/pgraph/cullPlanes.cxx +++ b/panda/src/pgraph/cullPlanes.cxx @@ -24,7 +24,7 @@ CPT(CullPlanes) CullPlanes:: make_empty() { static CPT(CullPlanes) empty; - if (empty == NULL) { + if (empty == nullptr) { empty = new CullPlanes; // Artificially tick the reference count, just to ensure we won't // accidentally modify this object in any of the copy-on-write operations @@ -81,7 +81,7 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, const ClipPlaneAttrib *net_attrib, const ClipPlaneAttrib *off_attrib, const OccluderEffect *node_effect) const { - if (net_attrib == (ClipPlaneAttrib *)NULL && node_effect == (OccluderEffect *)NULL) { + if (net_attrib == nullptr && node_effect == nullptr) { return this; } @@ -92,9 +92,9 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, new_planes = new CullPlanes(*this); } - CPT(TransformState) net_transform = NULL; + CPT(TransformState) net_transform = nullptr; - if (net_attrib != (ClipPlaneAttrib *)NULL) { + if (net_attrib != nullptr) { int num_on_planes = net_attrib->get_num_on_planes(); for (int i = 0; i < num_on_planes; ++i) { NodePath clip_plane = net_attrib->get_on_plane(i); @@ -103,7 +103,7 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, if (!off_attrib->has_off_plane(clip_plane)) { // Here's a new clip plane; add it to the list. For this we need // the net transform to this node. - if (net_transform == (TransformState *)NULL) { + if (net_transform == nullptr) { net_transform = data->get_net_transform(trav); } @@ -118,8 +118,8 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, } } - if (node_effect != (OccluderEffect *)NULL) { - CPT(TransformState) center_transform = NULL; + if (node_effect != nullptr) { + CPT(TransformState) center_transform = nullptr; // We'll need to know the occluder's frustum in cull-center space. SceneSetup *scene = trav->get_scene(); const Lens *lens = scene->get_lens(); @@ -137,8 +137,8 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, // And the transform from cull-center space into the current node's // coordinate space. - if (center_transform == (TransformState *)NULL) { - if (net_transform == (TransformState *)NULL) { + if (center_transform == nullptr) { + if (net_transform == nullptr) { net_transform = data->get_net_transform(trav); } @@ -177,7 +177,7 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, occluder_gbv = new BoundingBox(ccp_min, ccp_max); - if (data->_view_frustum != (GeometricBoundingVolume *)NULL) { + if (data->_view_frustum != nullptr) { int occluder_result = data->_view_frustum->contains(occluder_gbv); if (occluder_result == BoundingVolume::IF_no_intersection) { // This occluder is outside the view frustum; ignore it. @@ -289,7 +289,7 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, if (show_occluder_volumes) { // Draw the frustum for visualization. - nassertr(net_transform != NULL, new_planes); + nassertr(net_transform != nullptr, new_planes); trav->draw_bounding_volume(frustum, data->get_internal_transform(trav)); } } diff --git a/panda/src/pgraph/cullResult.I b/panda/src/pgraph/cullResult.I index 92b60a88b4..303a06dfd8 100644 --- a/panda/src/pgraph/cullResult.I +++ b/panda/src/pgraph/cullResult.I @@ -26,7 +26,7 @@ INLINE CullResult:: INLINE CullBin *CullResult:: get_bin(int bin_index) { if (bin_index >= 0 && bin_index < (int)_bins.size() && - _bins[bin_index] != (CullBin *)NULL) { + _bins[bin_index] != nullptr) { return _bins[bin_index]; } return make_new_bin(bin_index); diff --git a/panda/src/pgraph/cullResult.cxx b/panda/src/pgraph/cullResult.cxx index 7dbe002c9e..8f3e8dc19a 100644 --- a/panda/src/pgraph/cullResult.cxx +++ b/panda/src/pgraph/cullResult.cxx @@ -83,9 +83,9 @@ make_next() const { for (size_t i = 0; i < _bins.size(); ++i) { CullBin *old_bin = _bins[i]; - if (old_bin == (CullBin *)NULL || + if (old_bin == nullptr || old_bin->get_bin_type() != bin_manager->get_bin_type(i)) { - new_result->_bins.push_back((CullBin *)NULL); + new_result->_bins.push_back(nullptr); } else { new_result->_bins.push_back(old_bin->make_next()); } @@ -140,7 +140,7 @@ add_object(CullableObject *object, const CullTraverser *traverser) { traverser, force)) { int wireframe_bin_index = bin_manager->find_bin("fixed"); CullBin *bin = get_bin(wireframe_bin_index); - nassertv(bin != (CullBin *)NULL); + nassertv(bin != nullptr); check_flash_bin(wireframe_part->_state, bin_manager, wireframe_bin_index); bin->add_object(wireframe_part, current_thread); } else { @@ -211,7 +211,7 @@ add_object(CullableObject *object, const CullTraverser *traverser) { traverser, force)) { int transparent_bin_index = transparent_part->_state->get_bin_index(); CullBin *bin = get_bin(transparent_bin_index); - nassertv(bin != (CullBin *)NULL); + nassertv(bin != nullptr); check_flash_bin(transparent_part->_state, bin_manager, transparent_bin_index); bin->add_object(transparent_part, current_thread); } else { @@ -241,7 +241,7 @@ add_object(CullableObject *object, const CullTraverser *traverser) { int bin_index = object->_state->get_bin_index(); CullBin *bin = get_bin(bin_index); - nassertv(bin != (CullBin *)NULL); + nassertv(bin != nullptr); check_flash_bin(object->_state, bin_manager, bin_index); // Munge vertices as needed for the GSG's requirements, and the object's @@ -269,11 +269,11 @@ finish_cull(SceneSetup *scene_setup, Thread *current_thread) { if (!bin_manager->get_bin_active(i)) { // If the bin isn't active, don't sort it, and don't draw it. In fact, // clear it. - _bins[i] = NULL; + _bins[i] = nullptr; } else { CullBin *bin = _bins[i]; - if (bin != (CullBin *)NULL) { + if (bin != nullptr) { bin->finish_cull(scene_setup, current_thread); } } @@ -294,7 +294,7 @@ draw(Thread *current_thread) { int bin_index = bin_manager->get_bin(i); nassertv(bin_index >= 0); - if (bin_index < (int)_bins.size() && _bins[bin_index] != (CullBin *)NULL) { + if (bin_index < (int)_bins.size() && _bins[bin_index] != nullptr) { _bins[bin_index]->draw(force, current_thread); } } @@ -319,9 +319,9 @@ make_result_graph() { int num_bins = bin_manager->get_num_bins(); for (int i = 0; i < num_bins; i++) { int bin_index = bin_manager->get_bin(i); - nassertr(bin_index >= 0, NULL); + nassertr(bin_index >= 0, nullptr); - if (bin_index < (int)_bins.size() && _bins[bin_index] != (CullBin *)NULL) { + if (bin_index < (int)_bins.size() && _bins[bin_index] != nullptr) { root_node->add_child(_bins[bin_index]->make_result_graph()); } } @@ -351,12 +351,12 @@ make_new_bin(int bin_index) { _draw_region_pcollector); CullBin *bin_ptr = bin.p(); - if (bin_ptr != (CullBin *)NULL) { + if (bin_ptr != nullptr) { // Now store it in the vector. while (bin_index >= (int)_bins.size()) { - _bins.push_back((CullBin *)NULL); + _bins.push_back(nullptr); } - nassertr(bin_index >= 0 && bin_index < (int)_bins.size(), NULL); + nassertr(bin_index >= 0 && bin_index < (int)_bins.size(), nullptr); // Prevent unnecessary refunref by swapping the PointerTos. swap(_bins[bin_index], bin); @@ -384,8 +384,8 @@ get_rescale_normal_state(RescaleNormalAttrib::Mode mode) { */ const RenderState *CullResult:: get_alpha_state() { - static CPT(RenderState) state = NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { // We don't monkey with the priority, since we want to allow the user to // override this if he desires. state = RenderState::make(AlphaTestAttrib::make(AlphaTestAttrib::M_greater, 0.0f)); @@ -398,8 +398,8 @@ get_alpha_state() { */ const RenderState *CullResult:: get_binary_state() { - static CPT(RenderState) state = NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make(AlphaTestAttrib::make(AlphaTestAttrib::M_greater_equal, 0.5f), TransparencyAttrib::make(TransparencyAttrib::M_none), RenderState::get_max_priority()); @@ -431,8 +431,8 @@ apply_flash_color(CPT(RenderState) &state, const LColor &flash_color) { */ const RenderState *CullResult:: get_dual_transparent_state() { - static CPT(RenderState) state = NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { // The alpha test for > 0 prevents us from drawing empty pixels, and hence // filling up the depth buffer with large empty spaces that may obscure // other things. However, this does mean we draw pixels twice where the @@ -448,8 +448,8 @@ get_dual_transparent_state() { if (m_dual_flash) { int cycle = (int)(ClockObject::get_global_clock()->get_frame_time() * bin_color_flash_rate); if ((cycle & 1) == 0) { - static CPT(RenderState) flash_state = NULL; - if (flash_state == (const RenderState *)NULL) { + static CPT(RenderState) flash_state = nullptr; + if (flash_state == nullptr) { flash_state = state->add_attrib(ColorAttrib::make_flat(LColor(0.8f, 0.2, 0.2, 1.0f)), RenderState::get_max_priority()); @@ -473,8 +473,8 @@ get_dual_transparent_state() { */ const RenderState *CullResult:: get_dual_opaque_state() { - static CPT(RenderState) state = NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make(AlphaTestAttrib::make(AlphaTestAttrib::M_greater_equal, dual_opaque_level), TransparencyAttrib::make(TransparencyAttrib::M_none), RenderState::get_max_priority()); @@ -484,8 +484,8 @@ get_dual_opaque_state() { if (m_dual_flash) { int cycle = (int)(ClockObject::get_global_clock()->get_frame_time() * bin_color_flash_rate); if ((cycle & 1) == 0) { - static CPT(RenderState) flash_state = NULL; - if (flash_state == (const RenderState *)NULL) { + static CPT(RenderState) flash_state = nullptr; + if (flash_state == nullptr) { flash_state = state->add_attrib(ColorAttrib::make_flat(LColor(0.2, 0.2, 0.8f, 1.0f)), RenderState::get_max_priority()); flash_state = flash_state->add_attrib(ColorScaleAttrib::make(LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)), diff --git a/panda/src/pgraph/cullTraverser.I b/panda/src/pgraph/cullTraverser.I index 5da999d673..137d8105b1 100644 --- a/panda/src/pgraph/cullTraverser.I +++ b/panda/src/pgraph/cullTraverser.I @@ -224,7 +224,7 @@ do_traverse(CullTraverserData &data) { const FogAttrib *fog = (const FogAttrib *) node_reader->get_state()->get_attrib(FogAttrib::get_class_slot()); - if (fog != (const FogAttrib *)NULL && fog->get_fog() != (Fog *)NULL) { + if (fog != nullptr && fog->get_fog() != nullptr) { // If we just introduced a FogAttrib here, call adjust_to_camera() // now. This maybe isn't the perfect time to call it, but it's good // enough; and at this time we have all the information we need for diff --git a/panda/src/pgraph/cullTraverser.cxx b/panda/src/pgraph/cullTraverser.cxx index 7ed990637b..50726c2ee7 100644 --- a/panda/src/pgraph/cullTraverser.cxx +++ b/panda/src/pgraph/cullTraverser.cxx @@ -47,14 +47,14 @@ TypeHandle CullTraverser::_type_handle; */ CullTraverser:: CullTraverser() : - _gsg(NULL), + _gsg(nullptr), _current_thread(Thread::get_current_thread()) { _camera_mask = DrawMask::all_on(); _has_tag_state_key = false; _initial_state = RenderState::make_empty(); - _cull_handler = (CullHandler *)NULL; - _portal_clipper = (PortalClipper *)NULL; + _cull_handler = nullptr; + _portal_clipper = nullptr; _effective_incomplete_render = true; } @@ -104,14 +104,14 @@ set_scene(SceneSetup *scene_setup, GraphicsStateGuardianBase *gsg, */ void CullTraverser:: traverse(const NodePath &root) { - nassertv(_cull_handler != (CullHandler *)NULL); - nassertv(_scene_setup != (SceneSetup *)NULL); + nassertv(_cull_handler != nullptr); + nassertv(_scene_setup != nullptr); if (allow_portal_cull) { // This _view_frustum is in cull_center space Erik: obsolete? // PT(GeometricBoundingVolume) vf = _view_frustum; - GeometricBoundingVolume *local_frustum = NULL; + GeometricBoundingVolume *local_frustum = nullptr; PT(BoundingVolume) bv = _scene_setup->get_lens()->make_bounds(); if (bv != nullptr) { local_frustum = bv->as_geometric_bounding_volume(); @@ -229,7 +229,7 @@ draw_bounding_volume(const BoundingVolume *vol, const TransformState *internal_transform) const { PT(Geom) bounds_viz = make_bounds_viz(vol); - if (bounds_viz != (Geom *)NULL) { + if (bounds_viz != nullptr) { _geoms_pcollector.add_level(2); CullableObject *outer_viz = new CullableObject(bounds_viz, get_bounds_outer_viz_state(), @@ -264,7 +264,7 @@ show_bounds(CullTraverserData &data, bool tight) { if (tight) { PT(Geom) bounds_viz = make_tight_bounds_viz(node); - if (bounds_viz != (Geom *)NULL) { + if (bounds_viz != nullptr) { _geoms_pcollector.add_level(1); CullableObject *outer_viz = new CullableObject(move(bounds_viz), get_bounds_outer_viz_state(), @@ -489,8 +489,8 @@ CPT(RenderState) CullTraverser:: get_bounds_outer_viz_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) state = (const RenderState *)NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make (ColorAttrib::make_flat(LColor(0.3, 1.0f, 0.5f, 1.0f)), RenderModeAttrib::make(RenderModeAttrib::M_wireframe), @@ -507,8 +507,8 @@ CPT(RenderState) CullTraverser:: get_bounds_inner_viz_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) state = (const RenderState *)NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make (ColorAttrib::make_flat(LColor(0.15f, 0.5f, 0.25f, 1.0f)), RenderModeAttrib::make(RenderModeAttrib::M_wireframe), @@ -524,8 +524,8 @@ CPT(RenderState) CullTraverser:: get_depth_offset_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) state = (const RenderState *)NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make (DepthOffsetAttrib::make(1)); } diff --git a/panda/src/pgraph/cullTraverserData.I b/panda/src/pgraph/cullTraverserData.I index e2a9a64c95..c985e3bda9 100644 --- a/panda/src/pgraph/cullTraverserData.I +++ b/panda/src/pgraph/cullTraverserData.I @@ -31,7 +31,7 @@ CullTraverserData(const NodePath &start, _portal_depth(0) { // Only update the bounding volume if we're going to end up needing it. - bool check_bounds = (view_frustum != (GeometricBoundingVolume *)NULL); + bool check_bounds = (view_frustum != nullptr); _node_reader.check_cached(check_bounds); } @@ -55,7 +55,7 @@ CullTraverserData(const CullTraverserData &parent, PandaNode *child) : { // Only update the bounding volume if we're going to end up needing it. bool check_bounds = !_cull_planes->is_empty() || - (_view_frustum != (GeometricBoundingVolume *)NULL); + (_view_frustum != nullptr); _node_reader.check_cached(check_bounds); } @@ -140,7 +140,7 @@ is_in_view(const DrawMask &camera_mask) { return false; } - if (_view_frustum == (GeometricBoundingVolume *)NULL && + if (_view_frustum == nullptr && _cull_planes->is_empty()) { // If the transform is valid, but we don't have a frustum or any clip // planes or occluders, it's always in. diff --git a/panda/src/pgraph/cullTraverserData.cxx b/panda/src/pgraph/cullTraverserData.cxx index 1a8280948f..e0aed703e9 100644 --- a/panda/src/pgraph/cullTraverserData.cxx +++ b/panda/src/pgraph/cullTraverserData.cxx @@ -76,14 +76,14 @@ apply_transform(const TransformState *node_transform) { if (!node_transform->is_identity()) { _net_transform = _net_transform->compose(node_transform); - if ((_view_frustum != (GeometricBoundingVolume *)NULL) || + if ((_view_frustum != nullptr) || (!_cull_planes->is_empty())) { // We need to move the viewing frustums into the node's coordinate space // by applying the node's inverse transform. if (node_transform->is_singular()) { // But we can't invert a singular transform! Instead of trying, we'll // just give up on frustum culling from this point down. - _view_frustum = (GeometricBoundingVolume *)NULL; + _view_frustum = nullptr; _cull_planes = CullPlanes::make_empty(); } else { @@ -92,9 +92,9 @@ apply_transform(const TransformState *node_transform) { // Copy the bounding volumes for the frustums so we can transform // them. - if (_view_frustum != (GeometricBoundingVolume *)NULL) { + if (_view_frustum != nullptr) { _view_frustum = _view_frustum->make_copy()->as_geometric_bounding_volume(); - nassertv(_view_frustum != (GeometricBoundingVolume *)NULL); + nassertv(_view_frustum != nullptr); _view_frustum->xform(inv_transform->get_mat()); } @@ -144,11 +144,11 @@ r_get_node_path() const { */ bool CullTraverserData:: is_in_view_impl() { - const GeometricBoundingVolume *node_gbv = NULL; + const GeometricBoundingVolume *node_gbv = nullptr; - if (_view_frustum != (GeometricBoundingVolume *)NULL) { + if (_view_frustum != nullptr) { node_gbv = _node_reader.get_bounds()->as_geometric_bounding_volume(); - nassertr(node_gbv != (const GeometricBoundingVolume *)NULL, false); + nassertr(node_gbv != nullptr, false); int result = _view_frustum->contains(node_gbv); @@ -168,14 +168,14 @@ is_in_view_impl() { // If we have fake view-frustum culling enabled, instead of actually // culling an object we simply force it to be drawn in red wireframe. - _view_frustum = (GeometricBoundingVolume *)NULL; + _view_frustum = nullptr; _state = _state->compose(get_fake_view_frustum_cull_state()); #endif } else if ((result & BoundingVolume::IF_all) != 0) { // The node and its descendents are completely enclosed within the // frustum. No need to cull further. - _view_frustum = (GeometricBoundingVolume *)NULL; + _view_frustum = nullptr; } else { // The node is partially, but not completely, within the viewing @@ -185,15 +185,15 @@ is_in_view_impl() { // down. But this node has the "final" flag, so the user is claiming // that there is some important reason we should consider everything // visible at this point. So be it. - _view_frustum = (GeometricBoundingVolume *)NULL; + _view_frustum = nullptr; } } } if (!_cull_planes->is_empty()) { - if (node_gbv == (const GeometricBoundingVolume *)NULL) { + if (node_gbv == nullptr) { node_gbv = _node_reader.get_bounds()->as_geometric_bounding_volume(); - nassertr(node_gbv != (const GeometricBoundingVolume *)NULL, false); + nassertr(node_gbv != nullptr, false); } // Also cull against the current clip planes. diff --git a/panda/src/pgraph/cullableObject.I b/panda/src/pgraph/cullableObject.I index e5e7229d09..96564a4088 100644 --- a/panda/src/pgraph/cullableObject.I +++ b/panda/src/pgraph/cullableObject.I @@ -70,7 +70,7 @@ operator = (const CullableObject ©) { */ INLINE void CullableObject:: draw(GraphicsStateGuardianBase *gsg, bool force, Thread *current_thread) { - if (_draw_callback != (CallbackObject *)NULL) { + if (_draw_callback != nullptr) { // It has a callback associated. gsg->clear_before_callback(); gsg->set_state_and_transform(_state, _internal_transform); @@ -82,7 +82,7 @@ draw(GraphicsStateGuardianBase *gsg, bool force, Thread *current_thread) { } // Now the callback has taken care of drawing. } else { - nassertv(_geom != (Geom *)NULL); + nassertv(_geom != nullptr); gsg->set_state_and_transform(_state, _internal_transform); draw_inline(gsg, force, current_thread); } diff --git a/panda/src/pgraph/cullableObject.cxx b/panda/src/pgraph/cullableObject.cxx index 31ebfb2484..3e6db8453c 100644 --- a/panda/src/pgraph/cullableObject.cxx +++ b/panda/src/pgraph/cullableObject.cxx @@ -188,7 +188,7 @@ munge_geom(GraphicsStateGuardianBase *gsg, GeomMunger *munger, */ void CullableObject:: output(ostream &out) const { - if (_geom != (Geom *)NULL) { + if (_geom != nullptr) { out << *_geom; } else { out << "(null)"; @@ -243,7 +243,7 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { bool sprite_texcoord = false; const TexGenAttrib *tex_gen = DCAST(TexGenAttrib, _state->get_attrib(TexGenAttrib::get_class_slot())); - if (tex_gen != (TexGenAttrib *)NULL) { + if (tex_gen != nullptr) { if (tex_gen->get_mode(TextureStage::get_default()) == TexGenAttrib::M_point_sprite) { sprite_texcoord = true; @@ -255,7 +255,7 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { PN_stdfloat point_size = 1; bool perspective = false; const RenderModeAttrib *render_mode = DCAST(RenderModeAttrib, _state->get_attrib(RenderModeAttrib::get_class_slot())); - if (render_mode != (RenderModeAttrib *)NULL) { + if (render_mode != nullptr) { point_size = render_mode->get_thickness(); perspective = render_mode->get_perspective(); @@ -491,7 +491,7 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { // Determine the format we should use to store the indices. Don't choose // NT_uint8, as Direct3D 9 doesn't support it. - const GeomVertexArrayFormat *new_prim_format = NULL; + const GeomVertexArrayFormat *new_prim_format = nullptr; if (new_verts < 0xffff) { new_prim_format = GeomPrimitive::get_index_format(GeomEnums::NT_uint16); @@ -575,7 +575,7 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { int min_vi = primitive->get_min_vertex(); int max_vi = primitive->get_max_vertex(); - new_primitive->set_minmax(min_vi * 4, max_vi * 4 + 3, NULL, NULL); + new_primitive->set_minmax(min_vi * 4, max_vi * 4 + 3, nullptr, nullptr); new_geom->add_primitive(new_primitive); } @@ -598,8 +598,8 @@ get_flash_cpu_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) flash_cpu_state = (const RenderState *)NULL; - if (flash_cpu_state == (const RenderState *)NULL) { + static CPT(RenderState) flash_cpu_state = nullptr; + if (flash_cpu_state == nullptr) { flash_cpu_state = RenderState::make (LightAttrib::make_all_off(), TextureAttrib::make_off(), @@ -619,8 +619,8 @@ get_flash_hardware_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) flash_hardware_state = (const RenderState *)NULL; - if (flash_hardware_state == (const RenderState *)NULL) { + static CPT(RenderState) flash_hardware_state = nullptr; + if (flash_hardware_state == nullptr) { flash_hardware_state = RenderState::make (LightAttrib::make_all_off(), TextureAttrib::make_off(), diff --git a/panda/src/pgraph/depthOffsetAttrib.cxx b/panda/src/pgraph/depthOffsetAttrib.cxx index ed6f942b1c..a04e72bffb 100644 --- a/panda/src/pgraph/depthOffsetAttrib.cxx +++ b/panda/src/pgraph/depthOffsetAttrib.cxx @@ -41,8 +41,8 @@ make(int offset) { */ CPT(RenderAttrib) DepthOffsetAttrib:: make(int offset, PN_stdfloat min_value, PN_stdfloat max_value) { - nassertr(min_value >= 0.0f && min_value <= 1.0f, NULL); - nassertr(max_value >= 0.0f && max_value <= 1.0f, NULL); + nassertr(min_value >= 0.0f && min_value <= 1.0f, nullptr); + nassertr(max_value >= 0.0f && max_value <= 1.0f, nullptr); DepthOffsetAttrib *attrib = new DepthOffsetAttrib(offset, min_value, max_value); return return_new(attrib); } diff --git a/panda/src/pgraph/findApproxLevelEntry.I b/panda/src/pgraph/findApproxLevelEntry.I index 6404f93be4..9a9fb61a49 100644 --- a/panda/src/pgraph/findApproxLevelEntry.I +++ b/panda/src/pgraph/findApproxLevelEntry.I @@ -20,7 +20,7 @@ FindApproxLevelEntry(const WorkingNodePath &node_path, FindApproxPath &approx_pa _approx_path(approx_path) { _i = 0; - _next = NULL; + _next = nullptr; nassertv(_node_path.is_valid()); } @@ -50,7 +50,7 @@ FindApproxLevelEntry(const FindApproxLevelEntry ©) : _i(copy._i), _approx_path(copy._approx_path) { - _next = NULL; + _next = nullptr; nassertv(_node_path.is_valid()); } diff --git a/panda/src/pgraph/findApproxLevelEntry.cxx b/panda/src/pgraph/findApproxLevelEntry.cxx index 2b5679e271..2ea72cd889 100644 --- a/panda/src/pgraph/findApproxLevelEntry.cxx +++ b/panda/src/pgraph/findApproxLevelEntry.cxx @@ -40,7 +40,7 @@ output(ostream &out) const { void FindApproxLevelEntry:: write_level(ostream &out, int indent_level) const { for (const FindApproxLevelEntry *entry = this; - entry != (const FindApproxLevelEntry *)NULL; + entry != nullptr; entry = entry->_next) { indent(out, indent_level); out << *entry << "\n"; @@ -92,7 +92,7 @@ consider_node(NodePathCollection &result, FindApproxLevelEntry *&next_level, } PandaNode *this_node = _node_path.node(); - nassertr(this_node != (PandaNode *)NULL, false); + nassertr(this_node != nullptr, false); bool stashed_only = next_is_stashed(increment); diff --git a/panda/src/pgraph/fogAttrib.I b/panda/src/pgraph/fogAttrib.I index e19a72a376..863d5c153a 100644 --- a/panda/src/pgraph/fogAttrib.I +++ b/panda/src/pgraph/fogAttrib.I @@ -24,7 +24,7 @@ FogAttrib() { */ INLINE bool FogAttrib:: is_off() const { - return _fog == (const Fog *)NULL; + return _fog == nullptr; } /** diff --git a/panda/src/pgraph/fogAttrib.cxx b/panda/src/pgraph/fogAttrib.cxx index 87e12086d4..17016cd7b0 100644 --- a/panda/src/pgraph/fogAttrib.cxx +++ b/panda/src/pgraph/fogAttrib.cxx @@ -128,7 +128,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = RenderAttrib::complete_pointers(p_list, manager); TypedWritable *fog = p_list[pi++]; - if (fog != (TypedWritable *)NULL) { + if (fog != nullptr) { _fog = DCAST(Fog, fog); } diff --git a/panda/src/pgraph/geomNode.I b/panda/src/pgraph/geomNode.I index 7766631662..91c197d1d3 100644 --- a/panda/src/pgraph/geomNode.I +++ b/panda/src/pgraph/geomNode.I @@ -48,7 +48,7 @@ INLINE CPT(Geom) GeomNode:: get_geom(int n) const { CDReader cdata(_cycler); CPT(GeomList) geoms = cdata->get_geoms(); - nassertr(n >= 0 && n < (int)geoms->size(), NULL); + nassertr(n >= 0 && n < (int)geoms->size(), nullptr); return (*geoms)[n]._geom.get_read_pointer(); } @@ -68,7 +68,7 @@ INLINE PT(Geom) GeomNode:: modify_geom(int n) { CDWriter cdata(_cycler, true); PT(GeomList) geoms = cdata->modify_geoms(); - nassertr(n >= 0 && n < (int)geoms->size(), NULL); + nassertr(n >= 0 && n < (int)geoms->size(), nullptr); mark_internal_bounds_stale(); return (*geoms)[n]._geom.get_write_pointer(); } @@ -83,7 +83,7 @@ INLINE const RenderState *GeomNode:: get_geom_state(int n) const { CDReader cdata(_cycler); CPT(GeomList) geoms = cdata->get_geoms(); - nassertr(n >= 0 && n < (int)geoms->size(), NULL); + nassertr(n >= 0 && n < (int)geoms->size(), nullptr); return (*geoms)[n]._state; } @@ -287,8 +287,8 @@ get_num_geoms() const { */ INLINE CPT(Geom) GeomNode::Geoms:: get_geom(int n) const { - nassertr(!_geoms.is_null(), NULL); - nassertr(n >= 0 && n < (int)_geoms->size(), NULL); + nassertr(!_geoms.is_null(), nullptr); + nassertr(n >= 0 && n < (int)_geoms->size(), nullptr); return (*_geoms)[n]._geom.get_read_pointer(); } @@ -300,7 +300,7 @@ get_geom(int n) const { */ INLINE const RenderState *GeomNode::Geoms:: get_geom_state(int n) const { - nassertr(!_geoms.is_null(), NULL); - nassertr(n >= 0 && n < (int)_geoms->size(), NULL); + nassertr(!_geoms.is_null(), nullptr); + nassertr(n >= 0 && n < (int)_geoms->size(), nullptr); return (*_geoms)[n]._state; } diff --git a/panda/src/pgraph/geomNode.cxx b/panda/src/pgraph/geomNode.cxx index 8c9da5d331..cbbb7bb609 100644 --- a/panda/src/pgraph/geomNode.cxx +++ b/panda/src/pgraph/geomNode.cxx @@ -134,7 +134,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, if ((attrib_types & SceneGraphReducer::TT_color) != 0) { CPT(RenderAttrib) ra = geom_attribs._color; - if (ra != (const RenderAttrib *)NULL) { + if (ra != nullptr) { int override = geom_attribs._color_override; entry->_state = entry->_state->add_attrib(ra, override); } @@ -155,7 +155,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, } } if ((attrib_types & SceneGraphReducer::TT_color_scale) != 0) { - if (geom_attribs._color_scale != (const RenderAttrib *)NULL) { + if (geom_attribs._color_scale != nullptr) { CPT(ColorScaleAttrib) csa = DCAST(ColorScaleAttrib, geom_attribs._color_scale); if (csa->get_scale() != LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)) { @@ -198,7 +198,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, } if ((attrib_types & SceneGraphReducer::TT_tex_matrix) != 0) { - if (geom_attribs._tex_matrix != (const RenderAttrib *)NULL) { + if (geom_attribs._tex_matrix != nullptr) { // Determine which texture coordinate names are used more than once. // This assumes we have discovered all of the textures that are in // effect on the GeomNode; this may not be true if there is a @@ -206,7 +206,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, // started the flatten operation, but caveat programmer. NameCount name_count; - if (geom_attribs._texture != (RenderAttrib *)NULL) { + if (geom_attribs._texture != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, geom_attribs._texture); int num_on_stages = ta->get_num_on_stages(); for (int si = 0; si < num_on_stages; si++) { @@ -254,7 +254,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, // applied in the above. if ((attrib_types & SceneGraphReducer::TT_cull_face) != 0) { - if (geom_attribs._cull_face != (const RenderAttrib *)NULL) { + if (geom_attribs._cull_face != nullptr) { const CullFaceAttrib *cfa = DCAST(CullFaceAttrib, geom_attribs._cull_face); CullFaceAttrib::Mode mode = cfa->get_effective_mode(); switch (mode) { @@ -532,7 +532,7 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { // otherwise the bounding volume of the GeomNode is (probably) the same as // that of the one Geom, and we've already culled against that. if (num_geoms > 1) { - if (data._view_frustum != (GeometricBoundingVolume *)NULL) { + if (data._view_frustum != nullptr) { // Cull the individual Geom against the view frustum. CPT(BoundingVolume) geom_volume = geom->get_bounds(); const GeometricBoundingVolume *geom_gbv = @@ -584,9 +584,9 @@ get_legal_collide_mask() const { */ void GeomNode:: add_geom(Geom *geom, const RenderState *state) { - nassertv(geom != (Geom *)NULL); + nassertv(geom != nullptr); nassertv(geom->check_valid()); - nassertv(state != (RenderState *)NULL); + nassertv(state != nullptr); Thread *current_thread = Thread::get_current_thread(); OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) { @@ -635,7 +635,7 @@ add_geoms_from(const GeomNode *other) { */ void GeomNode:: set_geom(int n, Geom *geom) { - nassertv(geom != (Geom *)NULL); + nassertv(geom != nullptr); nassertv(geom->check_valid()); CDWriter cdata(_cycler, true); @@ -1144,7 +1144,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { for (int i = 0; i < num_geoms; i++) { manager->read_pointer(scan); manager->read_pointer(scan); - geoms->push_back(GeomEntry(NULL, NULL)); + geoms->push_back(GeomEntry(nullptr, nullptr)); } _geoms = geoms; } diff --git a/panda/src/pgraph/geomTransformer.cxx b/panda/src/pgraph/geomTransformer.cxx index 65c1ca6c80..c77fc35e28 100644 --- a/panda/src/pgraph/geomTransformer.cxx +++ b/panda/src/pgraph/geomTransformer.cxx @@ -108,7 +108,7 @@ bool GeomTransformer:: transform_vertices(Geom *geom, const LMatrix4 &mat) { PStatTimer timer(_apply_vertex_collector); - nassertr(geom != (Geom *)NULL, false); + nassertr(geom != nullptr, false); SourceVertices sv; sv._mat = mat; sv._vertex_data = geom->get_vertex_data(); @@ -175,7 +175,7 @@ transform_texcoords(Geom *geom, const InternalName *from_name, InternalName *to_name, const LMatrix4 &mat) { PStatTimer timer(_apply_texcoord_collector); - nassertr(geom != (Geom *)NULL, false); + nassertr(geom != nullptr, false); SourceTexCoords st; st._mat = mat; @@ -319,7 +319,7 @@ bool GeomTransformer:: transform_colors(Geom *geom, const LVecBase4 &scale) { PStatTimer timer(_apply_scale_color_collector); - nassertr(geom != (Geom *)NULL, false); + nassertr(geom != nullptr, false); SourceColors sc; sc._color = scale; @@ -384,10 +384,10 @@ apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, bool keep_vertex_color) { PStatTimer timer(_apply_texture_color_collector); - nassertr(geom != (Geom *)NULL, false); + nassertr(geom != nullptr, false); PT(TexturePeeker) peeker = tex->peek(); - if (peeker == (TexturePeeker *)NULL) { + if (peeker == nullptr) { return false; } @@ -411,7 +411,7 @@ apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, bool got_mat = false; LMatrix4 mat = LMatrix4::ident_mat(); - if (tma != (TexMatrixAttrib *)NULL && tma->has_stage(ts)) { + if (tma != nullptr && tma->has_stage(ts)) { mat = tma->get_mat(ts); got_mat = !mat.almost_equal(LMatrix4::ident_mat()); } @@ -478,7 +478,7 @@ apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, // Check whether it has 2-d or 3-d texture coordinates. bool tex3d = false; const GeomVertexColumn *column = vdata->get_format()->get_column(ts->get_texcoord_name()); - if (column == (GeomVertexColumn *)NULL) { + if (column == nullptr) { return false; } if (column->get_num_components() >= 3) { @@ -585,7 +585,7 @@ apply_texture_colors(GeomNode *node, const RenderState *state) { CPT(RenderState) geom_state = state->compose(entry._state); const TextureAttrib *ta = DCAST(TextureAttrib, geom_state->get_attrib(TextureAttrib::get_class_slot())); - if (ta != (TextureAttrib *)NULL) { + if (ta != nullptr) { CPT(TextureAttrib) ta2 = ta->filter_to_max(1); if (ta2->get_num_on_stages() > 0) { TextureStage *ts = ta2->get_on_stage(0); @@ -595,7 +595,7 @@ apply_texture_colors(GeomNode *node, const RenderState *state) { const ColorAttrib *ca = DCAST(ColorAttrib, geom_state->get_attrib(ColorAttrib::get_class_slot())); LColor base_color(1.0f, 1.0f, 1.0f, 1.0f); bool keep_vertex_color = true; - if (ca != (ColorAttrib *)NULL && ca->get_color_type() == ColorAttrib::T_flat) { + if (ca != nullptr && ca->get_color_type() == ColorAttrib::T_flat) { base_color = ca->get_color(); keep_vertex_color = false; } @@ -659,7 +659,7 @@ bool GeomTransformer:: set_format(Geom *geom, const GeomVertexFormat *new_format) { PStatTimer timer(_apply_set_format_collector); - nassertr(geom != (Geom *)NULL, false); + nassertr(geom != nullptr, false); SourceFormat sf; sf._format = new_format; @@ -819,7 +819,7 @@ make_compatible_state(GeomNode *node) { */ bool GeomTransformer:: reverse_normals(Geom *geom) { - nassertr(geom != (Geom *)NULL, false); + nassertr(geom != nullptr, false); CPT(GeomVertexData) orig_data = geom->get_vertex_data(); NewVertexData &new_data = _reversed_normals[orig_data]; if (new_data._vdata.is_null()) { @@ -1047,7 +1047,7 @@ collect_vertex_data(Geom *geom, int collect_bits, bool format_only) { int GeomTransformer:: collect_vertex_data(GeomNode *node, int collect_bits, bool format_only) { int num_adjusted = 0; - GeomTransformer *dynamic = NULL; + GeomTransformer *dynamic = nullptr; GeomNode::CDWriter cdata(node->_cycler); GeomNode::GeomList::iterator gi; @@ -1061,7 +1061,7 @@ collect_vertex_data(GeomNode *node, int collect_bits, bool format_only) { new_geom->get_vertex_data()->get_usage_hint() < Geom::UH_static) { // This one has some dynamic properties. Collect it independently of // the outside world. - if (dynamic == (GeomTransformer *)NULL) { + if (dynamic == nullptr) { dynamic = new GeomTransformer(*this); } num_adjusted += dynamic->collect_vertex_data(new_geom, collect_bits, format_only); @@ -1071,7 +1071,7 @@ collect_vertex_data(GeomNode *node, int collect_bits, bool format_only) { } } - if (dynamic != (GeomTransformer *)NULL) { + if (dynamic != nullptr) { num_adjusted += dynamic->finish_collect(format_only); delete dynamic; } @@ -1222,7 +1222,7 @@ apply_collect_changes() { nassertr(vertex_offset == _num_vertices, 0); - if (_new_btable != (TransformBlendTable *)NULL) { + if (_new_btable != nullptr) { _new_btable->set_rows(_new_btable_rows); _new_data->set_transform_blend_table(_new_btable); } @@ -1258,11 +1258,11 @@ append_vdata(const GeomVertexData *vdata, int vertex_offset) { // in the vertices. Each of these has a slightly different way to handle // the remapping, because they have slightly different kinds of data. - if (vdata->get_transform_table() != (TransformTable *)NULL || - _new_data->get_transform_table() != (TransformTable *)NULL) { + if (vdata->get_transform_table() != nullptr || + _new_data->get_transform_table() != nullptr) { // The TransformTable. CPT(TransformTable) old_table; - if (vdata->get_transform_table() != (TransformTable *)NULL) { + if (vdata->get_transform_table() != nullptr) { old_table = vdata->get_transform_table(); } else { PT(TransformTable) temp_table = new TransformTable; @@ -1287,7 +1287,7 @@ append_vdata(const GeomVertexData *vdata, int vertex_offset) { // modifying the existing one, since a registered TransformTable cannot be // modified. PT(TransformTable) new_table; - if (_new_data->get_transform_table() != (TransformTable *)NULL) { + if (_new_data->get_transform_table() != nullptr) { new_table = new TransformTable(*_new_data->get_transform_table()); } else { new_table = new TransformTable; @@ -1335,7 +1335,7 @@ append_vdata(const GeomVertexData *vdata, int vertex_offset) { } } - if (vdata->get_transform_blend_table() != (TransformBlendTable *)NULL) { + if (vdata->get_transform_blend_table() != nullptr) { // The TransformBlendTable. This one is the easiest, because we can // modify it directly, and it will uniquify blend objects for us. @@ -1345,7 +1345,7 @@ append_vdata(const GeomVertexData *vdata, int vertex_offset) { CPT(TransformBlendTable) old_btable = vdata->get_transform_blend_table(); - if (_new_btable == (TransformBlendTable *)NULL) { + if (_new_btable == nullptr) { _new_btable = new TransformBlendTable; _new_btable->add_blend(TransformBlend()); } @@ -1380,7 +1380,7 @@ append_vdata(const GeomVertexData *vdata, int vertex_offset) { } } - if (vdata->get_slider_table() != (SliderTable *)NULL) { + if (vdata->get_slider_table() != nullptr) { // The SliderTable. This one requires making a copy, like the // TransformTable (since it can't be modified once registered either), but // at least it uniquifies sliders added to it. Also, it doesn't require @@ -1388,7 +1388,7 @@ append_vdata(const GeomVertexData *vdata, int vertex_offset) { // vertices with. const SliderTable *old_sliders = vdata->get_slider_table(); PT(SliderTable) new_sliders; - if (_new_data->get_slider_table() != (SliderTable *)NULL) { + if (_new_data->get_slider_table() != nullptr) { new_sliders = new SliderTable(*_new_data->get_slider_table()); } else { new_sliders = new SliderTable; diff --git a/panda/src/pgraph/internalNameCollection.cxx b/panda/src/pgraph/internalNameCollection.cxx index f1ab629206..93b92e3518 100644 --- a/panda/src/pgraph/internalNameCollection.cxx +++ b/panda/src/pgraph/internalNameCollection.cxx @@ -181,7 +181,7 @@ get_num_names() const { */ const InternalName *InternalNameCollection:: get_name(int index) const { - nassertr(index >= 0 && index < (int)_names.size(), NULL); + nassertr(index >= 0 && index < (int)_names.size(), nullptr); return _names[index]; } @@ -192,7 +192,7 @@ get_name(int index) const { */ const InternalName *InternalNameCollection:: operator [] (int index) const { - nassertr(index >= 0 && index < (int)_names.size(), NULL); + nassertr(index >= 0 && index < (int)_names.size(), nullptr); return _names[index]; } diff --git a/panda/src/pgraph/lensNode.I b/panda/src/pgraph/lensNode.I index fd7c67f192..c1bb15afd1 100644 --- a/panda/src/pgraph/lensNode.I +++ b/panda/src/pgraph/lensNode.I @@ -45,12 +45,12 @@ set_lens(Lens *lens) { */ INLINE Lens *LensNode:: get_lens(int index) const { - nassertr(index >= 0 && index < max_lenses, NULL); // Sanity check + nassertr(index >= 0 && index < max_lenses, nullptr); // Sanity check if (index < (int)_lenses.size()) { return _lenses[index]._lens; } - return NULL; + return nullptr; } /** diff --git a/panda/src/pgraph/lensNode.cxx b/panda/src/pgraph/lensNode.cxx index 4fa15e2aa7..60307c2ce0 100644 --- a/panda/src/pgraph/lensNode.cxx +++ b/panda/src/pgraph/lensNode.cxx @@ -29,7 +29,7 @@ LensNode:: LensNode(const string &name, Lens *lens) : PandaNode(name) { - if (lens == NULL) { + if (lens == nullptr) { lens = new PerspectiveLens; } set_lens(0, lens); @@ -84,7 +84,7 @@ set_lens(int index, Lens *lens) { _lenses[index]._lens = lens; _lenses[index]._is_active = true; - if (_shown_frustum != (PandaNode *)NULL) { + if (_shown_frustum != nullptr) { show_frustum(); } } @@ -111,7 +111,7 @@ set_lens_active(int index, bool flag) { _lenses[index]._is_active = flag; - if (_shown_frustum != (PandaNode *)NULL) { + if (_shown_frustum != nullptr) { show_frustum(); } return true; @@ -124,9 +124,9 @@ set_lens_active(int index, bool flag) { bool LensNode:: is_in_view(int index, const LPoint3 &pos) { Lens *lens = get_lens(index); - nassertr(lens != (Lens *)NULL, false); + nassertr(lens != nullptr, false); PT(BoundingVolume) bv = lens->make_bounds(); - if (bv == (BoundingVolume *)NULL) { + if (bv == nullptr) { return false; } GeometricBoundingVolume *gbv = DCAST(GeometricBoundingVolume, bv); @@ -140,7 +140,7 @@ is_in_view(int index, const LPoint3 &pos) { */ void LensNode:: show_frustum() { - if (_shown_frustum != (PandaNode *)NULL) { + if (_shown_frustum != nullptr) { hide_frustum(); } PT(GeomNode) geom_node = new GeomNode("frustum"); @@ -150,7 +150,7 @@ show_frustum() { for (Lenses::const_iterator li = _lenses.begin(); li != _lenses.end(); ++li) { - if ((*li)._is_active && (*li)._lens != (Lens *)NULL) { + if ((*li)._is_active && (*li)._lens != nullptr) { geom_node->add_geom((*li)._lens->make_geometry()); } } @@ -161,9 +161,9 @@ show_frustum() { */ void LensNode:: hide_frustum() { - if (_shown_frustum != (PandaNode *)NULL) { + if (_shown_frustum != nullptr) { remove_child(_shown_frustum); - _shown_frustum = (PandaNode *)NULL; + _shown_frustum = nullptr; } } @@ -178,7 +178,7 @@ output(ostream &out) const { for (Lenses::const_iterator li = _lenses.begin(); li != _lenses.end(); ++li) { - if ((*li)._is_active && (*li)._lens != (Lens *)NULL) { + if ((*li)._is_active && (*li)._lens != nullptr) { out << " "; (*li)._lens->output(out); } @@ -196,7 +196,7 @@ write(ostream &out, int indent_level) const { for (Lenses::const_iterator li = _lenses.begin(); li != _lenses.end(); ++li) { - if ((*li)._is_active && (*li)._lens != (Lens *)NULL) { + if ((*li)._is_active && (*li)._lens != nullptr) { (*li)._lens->write(out, indent_level + 2); } } @@ -245,7 +245,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { (*li)._lens = DCAST(Lens, p_list[pi++]); } - if (_shown_frustum != (PandaNode *)NULL) { + if (_shown_frustum != nullptr) { show_frustum(); } diff --git a/panda/src/pgraph/lensNode.h b/panda/src/pgraph/lensNode.h index da9d9ef5f6..9e1dd9fb00 100644 --- a/panda/src/pgraph/lensNode.h +++ b/panda/src/pgraph/lensNode.h @@ -28,7 +28,7 @@ */ class EXPCL_PANDA_PGRAPH LensNode : public PandaNode { PUBLISHED: - explicit LensNode(const string &name, Lens *lens = NULL); + explicit LensNode(const string &name, Lens *lens = nullptr); protected: LensNode(const LensNode ©); diff --git a/panda/src/pgraph/lightAttrib.cxx b/panda/src/pgraph/lightAttrib.cxx index fea2094a23..1ad177b1b4 100644 --- a/panda/src/pgraph/lightAttrib.cxx +++ b/panda/src/pgraph/lightAttrib.cxx @@ -38,7 +38,7 @@ public: nassertr(!a.is_empty() && !b.is_empty(), a < b); Light *la = a.node()->as_light(); Light *lb = b.node()->as_light(); - nassertr(la != (Light *)NULL && lb != (Light *)NULL, a < b); + nassertr(la != nullptr && lb != nullptr, a < b); if (la->get_priority() != lb->get_priority()) { return la->get_priority() > lb->get_priority(); @@ -384,7 +384,7 @@ CPT(RenderAttrib) LightAttrib:: make() { // We make it a special case and store a pointer to the empty attrib forever // once we find it the first time, as an optimization. - if (_empty_attrib == (RenderAttrib *)NULL) { + if (_empty_attrib == nullptr) { _empty_attrib = return_new(new LightAttrib); } @@ -399,7 +399,7 @@ CPT(RenderAttrib) LightAttrib:: make_all_off() { // We make it a special case and store a pointer to the off attrib forever // once we find it the first time, as an optimization. - if (_all_off_attrib == (RenderAttrib *)NULL) { + if (_all_off_attrib == nullptr) { LightAttrib *attrib = new LightAttrib; attrib->_off_all_lights = true; _all_off_attrib = return_new(attrib); @@ -475,7 +475,7 @@ add_off_light(const NodePath &light) const { */ CPT(RenderAttrib) LightAttrib:: remove_off_light(const NodePath &light) const { - nassertr(!light.is_empty() && light.node()->as_light() != (Light *)NULL, this); + nassertr(!light.is_empty() && light.node()->as_light() != nullptr, this); LightAttrib *attrib = new LightAttrib(*this); attrib->_off_lights.erase(light); return return_new(attrib); @@ -967,7 +967,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { } else { BamAuxData *aux = (BamAuxData *)manager->get_aux_data(this, "lights"); - nassertr(aux != NULL, pi); + nassertr(aux != nullptr, pi); int i; aux->_off_list.reserve(aux->_num_off_lights); @@ -1023,7 +1023,7 @@ finalize(BamReader *manager) { } else { // Now it's safe to convert our saved PandaNodes into NodePaths. BamAuxData *aux = (BamAuxData *)manager->get_aux_data(this, "lights"); - nassertv(aux != NULL); + nassertv(aux != nullptr); nassertv(aux->_num_off_lights == (int)aux->_off_list.size()); nassertv(aux->_num_on_lights == (int)aux->_on_list.size()); diff --git a/panda/src/pgraph/lightRampAttrib.cxx b/panda/src/pgraph/lightRampAttrib.cxx index 7a7637a35f..93adfc305b 100644 --- a/panda/src/pgraph/lightRampAttrib.cxx +++ b/panda/src/pgraph/lightRampAttrib.cxx @@ -29,7 +29,7 @@ CPT(RenderAttrib) LightRampAttrib::_default; */ CPT(RenderAttrib) LightRampAttrib:: make_default() { - if (_default == 0) { + if (_default == nullptr) { LightRampAttrib *attrib = new LightRampAttrib(); _default = return_new(attrib); } diff --git a/panda/src/pgraph/loader.I b/panda/src/pgraph/loader.I index c86753b3be..eddac45376 100644 --- a/panda/src/pgraph/loader.I +++ b/panda/src/pgraph/loader.I @@ -72,7 +72,7 @@ get_file(int n) const { */ INLINE LoaderFileType *Loader::Results:: get_file_type(int n) const { - nassertr(n >= 0 && n < (int)_files.size(), NULL); + nassertr(n >= 0 && n < (int)_files.size(), nullptr); return _files[n]._type; } @@ -127,7 +127,7 @@ get_task_chain() const { INLINE void Loader:: stop_threads() { PT(AsyncTaskChain) chain = _task_manager->find_task_chain(_task_chain); - if (chain != (AsyncTaskChain *)NULL) { + if (chain != nullptr) { chain->stop_threads(); } } @@ -210,7 +210,7 @@ save_async(AsyncTask *request) { */ INLINE Loader *Loader:: get_global_ptr() { - if (_global_ptr == (Loader *)NULL) { + if (_global_ptr == nullptr) { make_global_ptr(); } return _global_ptr; diff --git a/panda/src/pgraph/loader.cxx b/panda/src/pgraph/loader.cxx index 7e8c201daf..866f3c2f14 100644 --- a/panda/src/pgraph/loader.cxx +++ b/panda/src/pgraph/loader.cxx @@ -46,7 +46,7 @@ Loader(const string &name) : _task_manager = AsyncTaskManager::get_global_ptr(); _task_chain = name; - if (_task_manager->find_task_chain(_task_chain) == NULL) { + if (_task_manager->find_task_chain(_task_chain) == nullptr) { PT(AsyncTaskChain) chain = _task_manager->make_task_chain(_task_chain); ConfigVariableInt loader_num_threads @@ -99,7 +99,7 @@ PT(PandaNode) Loader:: load_bam_stream(istream &in) { BamFile bam_file; if (!bam_file.open_read(in)) { - return NULL; + return nullptr; } return bam_file.read_node(); @@ -159,13 +159,13 @@ load_file(const Filename &filename, const LoaderOptions &options) const { "in your Config.prc to globally assume a particular model " "filename extension.\n"; } - return NULL; + return nullptr; } LoaderFileTypeRegistry *reg = LoaderFileTypeRegistry::get_global_ptr(); LoaderFileType *requested_type = reg->get_type_from_extension(extension); - if (requested_type == (LoaderFileType *)NULL) { + if (requested_type == nullptr) { if (report_errors) { loader_cat.error() << "Extension of file " << this_filename @@ -174,21 +174,21 @@ load_file(const Filename &filename, const LoaderOptions &options) const { << "Currently known scene file types are:\n"; reg->write(loader_cat.error(false), 2); } - return NULL; + return nullptr; } else if (!requested_type->supports_load()) { if (report_errors) { loader_cat.error() << requested_type->get_name() << " file type (." << extension << ") does not support loading.\n"; } - return NULL; + return nullptr; } else if (compressed && !requested_type->supports_compressed()) { if (report_errors) { loader_cat.error() << requested_type->get_name() << " file type (." << extension << ") does not support in-line compression.\n"; } - return NULL; + return nullptr; } bool search = (this_options.get_flags() & LoaderOptions::LF_search) != 0; @@ -211,7 +211,7 @@ load_file(const Filename &filename, const LoaderOptions &options) const { Filename pathname(model_path.get_directory(i), this_filename); PT(PandaNode) result = try_load_file(pathname, this_options, requested_type); - if (result != (PandaNode *)NULL) { + if (result != nullptr) { return result; } } @@ -243,7 +243,7 @@ load_file(const Filename &filename, const LoaderOptions &options) const { // Look for the file only where it is. VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); PT(PandaNode) result = try_load_file(this_filename, this_options, requested_type); - if (result != (PandaNode *)NULL) { + if (result != nullptr) { return result; } if (report_errors) { @@ -256,7 +256,7 @@ load_file(const Filename &filename, const LoaderOptions &options) const { } } } - return NULL; + return nullptr; } /** @@ -273,7 +273,7 @@ try_load_file(const Filename &pathname, const LoaderOptions &options, if (allow_ram_cache) { // If we're allowing a RAM cache, use the ModelPool to load the file. PT(PandaNode) node = ModelPool::get_model(pathname, true); - if (node != (PandaNode *)NULL) { + if (node != nullptr) { if ((options.get_flags() & LoaderOptions::LF_allow_instance) == 0) { if (loader_cat.is_debug()) { loader_cat.debug() @@ -292,7 +292,7 @@ try_load_file(const Filename &pathname, const LoaderOptions &options, if (cache->get_cache_models() && requested_type->get_allow_disk_cache(options)) { // See if the model can be found in the on-disk cache, if it is active. record = cache->lookup(pathname, "bam"); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { if (record->has_data()) { if (report_errors) { loader_cat.info() @@ -334,8 +334,8 @@ try_load_file(const Filename &pathname, const LoaderOptions &options, if (!cache_only) { // Load the model from disk. PT(PandaNode) result = requested_type->load_file(pathname, options, record); - if (result != (PandaNode *)NULL) { - if (record != (BamCacheRecord *)NULL) { + if (result != nullptr) { + if (record != nullptr) { // Store the loaded model in the model cache. record->set_data(result); cache->store(record); @@ -359,7 +359,7 @@ try_load_file(const Filename &pathname, const LoaderOptions &options, } } - return NULL; + return nullptr; } /** @@ -403,7 +403,7 @@ save_file(const Filename &filename, const LoaderOptions &options, LoaderFileType *requested_type = reg->get_type_from_extension(extension); - if (requested_type == (LoaderFileType *)NULL) { + if (requested_type == nullptr) { if (report_errors) { loader_cat.error() << "Extension of file " << this_filename @@ -475,7 +475,7 @@ load_file_types() { loader_cat.info() << "loading file type module: " << name << endl; void *tmp = load_dso(get_plugin_path().get_value(), dlname); - if (tmp == (void *)NULL) { + if (tmp == nullptr) { loader_cat.warning() << "Unable to load " << dlname.to_os_specific() << ": " << load_dso_error() << endl; @@ -512,7 +512,7 @@ load_file_types() { */ void Loader:: make_global_ptr() { - nassertv(_global_ptr == (Loader *)NULL); + nassertv(_global_ptr == nullptr); _global_ptr = new Loader("loader"); } diff --git a/panda/src/pgraph/loaderFileType.cxx b/panda/src/pgraph/loaderFileType.cxx index 326dce8720..a7189526ed 100644 --- a/panda/src/pgraph/loaderFileType.cxx +++ b/panda/src/pgraph/loaderFileType.cxx @@ -101,7 +101,7 @@ load_file(const Filename &path, const LoaderOptions &options, BamCacheRecord *record) const { loader_cat.error() << get_type() << " cannot read PandaNode objects.\n"; - return NULL; + return nullptr; } /** diff --git a/panda/src/pgraph/loaderFileTypeBam.cxx b/panda/src/pgraph/loaderFileTypeBam.cxx index 9394c69357..985ffb706a 100644 --- a/panda/src/pgraph/loaderFileTypeBam.cxx +++ b/panda/src/pgraph/loaderFileTypeBam.cxx @@ -80,7 +80,7 @@ supports_save() const { PT(PandaNode) LoaderFileTypeBam:: load_file(const Filename &path, const LoaderOptions &options, BamCacheRecord *record) const { - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(path); } @@ -88,13 +88,13 @@ load_file(const Filename &path, const LoaderOptions &options, BamFile bam_file; if (!bam_file.open_read(path, report_errors)) { - return NULL; + return nullptr; } bam_file.get_reader()->set_loader_options(options); time_t timestamp = bam_file.get_reader()->get_source()->get_timestamp(); PT(PandaNode) node = bam_file.read_node(report_errors); - if (node != (PandaNode *)NULL && node->is_of_type(ModelRoot::get_class_type())) { + if (node != nullptr && node->is_of_type(ModelRoot::get_class_type())) { ModelRoot *model_root = DCAST(ModelRoot, node.p()); model_root->set_fullpath(path); model_root->set_timestamp(timestamp); diff --git a/panda/src/pgraph/loaderFileTypeRegistry.cxx b/panda/src/pgraph/loaderFileTypeRegistry.cxx index 8ed3774368..6f5f6fed44 100644 --- a/panda/src/pgraph/loaderFileTypeRegistry.cxx +++ b/panda/src/pgraph/loaderFileTypeRegistry.cxx @@ -124,7 +124,7 @@ get_num_types() const { */ LoaderFileType *LoaderFileTypeRegistry:: get_type(int n) const { - nassertr(n >= 0 && n < (int)_types.size(), NULL); + nassertr(n >= 0 && n < (int)_types.size(), nullptr); return _types[n]; } @@ -154,11 +154,11 @@ get_type_from_extension(const string &extension) { loader_cat->info() << "loading file type module: " << name << endl; void *tmp = load_dso(get_plugin_path().get_value(), dlname); - if (tmp == (void *)NULL) { + if (tmp == nullptr) { loader_cat->warning() << "Unable to load " << dlname.to_os_specific() << ": " << load_dso_error() << endl; - return NULL; + return nullptr; } else if (loader_cat.is_debug()) { loader_cat.debug() << "done loading file type module: " << name << endl; @@ -172,7 +172,7 @@ get_type_from_extension(const string &extension) { if (ei == _extensions.end()) { // Nothing matches that extension, even after we've checked for a deferred // type description. - return NULL; + return nullptr; } return (*ei).second; @@ -231,7 +231,7 @@ write(ostream &out, int indent_level) const { */ LoaderFileTypeRegistry *LoaderFileTypeRegistry:: get_global_ptr() { - if (_global_ptr == (LoaderFileTypeRegistry *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new LoaderFileTypeRegistry; } return _global_ptr; diff --git a/panda/src/pgraph/materialCollection.cxx b/panda/src/pgraph/materialCollection.cxx index 665a924cbc..386758f1c5 100644 --- a/panda/src/pgraph/materialCollection.cxx +++ b/panda/src/pgraph/materialCollection.cxx @@ -181,7 +181,7 @@ find_material(const string &name) const { return material; } } - return NULL; + return nullptr; } /** @@ -197,7 +197,7 @@ get_num_materials() const { */ Material *MaterialCollection:: get_material(int index) const { - nassertr(index >= 0 && index < (int)_materials.size(), NULL); + nassertr(index >= 0 && index < (int)_materials.size(), nullptr); return _materials[index]; } @@ -208,7 +208,7 @@ get_material(int index) const { */ Material *MaterialCollection:: operator [] (int index) const { - nassertr(index >= 0 && index < (int)_materials.size(), NULL); + nassertr(index >= 0 && index < (int)_materials.size(), nullptr); return _materials[index]; } diff --git a/panda/src/pgraph/modelPool.I b/panda/src/pgraph/modelPool.I index 26efd0a8c8..f52be7de00 100644 --- a/panda/src/pgraph/modelPool.I +++ b/panda/src/pgraph/modelPool.I @@ -33,7 +33,7 @@ has_model(const Filename &filename) { */ INLINE bool ModelPool:: verify_model(const Filename &filename) { - return load_model(filename) != (ModelRoot *)NULL; + return load_model(filename) != nullptr; } /** diff --git a/panda/src/pgraph/modelPool.cxx b/panda/src/pgraph/modelPool.cxx index 70d7b318c9..b5722f2271 100644 --- a/panda/src/pgraph/modelPool.cxx +++ b/panda/src/pgraph/modelPool.cxx @@ -18,7 +18,7 @@ #include "virtualFileSystem.h" -ModelPool *ModelPool::_global_ptr = (ModelPool *)NULL; +ModelPool *ModelPool::_global_ptr = nullptr; /** * Lists the contents of the model pool to the indicated output stream. Helps @@ -37,7 +37,7 @@ ns_has_model(const Filename &filename) { LightMutexHolder holder(_lock); Models::const_iterator ti; ti = _models.find(filename); - if (ti != _models.end() && (*ti).second != (ModelRoot *)NULL) { + if (ti != _models.end() && (*ti).second != nullptr) { // This model was previously loaded. return true; } @@ -71,7 +71,7 @@ ns_get_model(const Filename &filename, bool verify) { << "ModelPool found " << cached_model << " for " << filename << "\n"; } - if (cached_model == NULL) { + if (cached_model == nullptr) { // This filename was previously attempted, but it did not exist (or the // model could not be loaded for some reason). if (cache_check_timestamps) { @@ -89,7 +89,7 @@ ns_get_model(const Filename &filename, bool verify) { // Compare the timestamp to the file on-disk. VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); PT(VirtualFile) vfile = vfs->get_file(cached_model->get_fullpath()); - if (vfile == NULL) { + if (vfile == nullptr) { // The file has disappeared! Look further along the model-path. got_cached_model = false; @@ -109,7 +109,7 @@ ns_get_model(const Filename &filename, bool verify) { } return cached_model; } else { - return NULL; + return nullptr; } } @@ -121,7 +121,7 @@ ns_load_model(const Filename &filename, const LoaderOptions &options) { // First check if it has already been loaded and is still current. PT(ModelRoot) cached_model = ns_get_model(filename, true); - if (cached_model != (ModelRoot *)NULL) { + if (cached_model != nullptr) { return cached_model; } @@ -239,7 +239,7 @@ ns_garbage_collect() { Models::iterator ti; for (ti = _models.begin(); ti != _models.end(); ++ti) { ModelRoot *node = (*ti).second; - if (node == (ModelRoot *)NULL || + if (node == nullptr || node->get_model_ref_count() == 1) { if (loader_cat.is_debug()) { loader_cat.debug() @@ -267,7 +267,7 @@ ns_list_contents(ostream &out) const { Models::const_iterator ti; int num_models = 0; for (ti = _models.begin(); ti != _models.end(); ++ti) { - if ((*ti).second != NULL) { + if ((*ti).second != nullptr) { ++num_models; out << (*ti).first << "\n" << " (count = " << (*ti).second->get_model_ref_count() @@ -285,7 +285,7 @@ ns_list_contents(ostream &out) const { */ ModelPool *ModelPool:: get_ptr() { - if (_global_ptr == (ModelPool *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new ModelPool; } return _global_ptr; diff --git a/panda/src/pgraph/nodePath.I b/panda/src/pgraph/nodePath.I index 74bcc01bd9..641ab1c2b7 100644 --- a/panda/src/pgraph/nodePath.I +++ b/panda/src/pgraph/nodePath.I @@ -46,7 +46,7 @@ INLINE NodePath:: NodePath(PandaNode *node, Thread *current_thread) : _error_type(ET_ok) { - if (node != (PandaNode *)NULL) { + if (node != nullptr) { int pipeline_stage = current_thread->get_pipeline_stage(); _head = node->get_generic_component(false, pipeline_stage, current_thread); } @@ -61,7 +61,7 @@ NodePath(PandaNode *node, Thread *current_thread) : INLINE NodePath NodePath:: any_path(PandaNode *node, Thread *current_thread) { NodePath result; - if (node != (PandaNode *)NULL) { + if (node != nullptr) { int pipeline_stage = current_thread->get_pipeline_stage(); result._head = node->get_generic_component(true, pipeline_stage, current_thread); @@ -186,7 +186,7 @@ get_max_search_depth() { */ INLINE bool NodePath:: is_empty() const { - return (_head == (NodePathComponent *)NULL); + return (_head == nullptr); } /** @@ -195,7 +195,7 @@ is_empty() const { INLINE bool NodePath:: is_singleton(Thread *current_thread) const { int pipeline_stage = current_thread->get_pipeline_stage(); - return (_head != (NodePathComponent *)NULL && _head->is_top_node(pipeline_stage, current_thread)); + return (_head != nullptr && _head->is_top_node(pipeline_stage, current_thread)); } /** @@ -214,7 +214,7 @@ get_error_type() const { INLINE PandaNode *NodePath:: get_top_node(Thread *current_thread) const { if (is_empty()) { - return (PandaNode *)NULL; + return nullptr; } return get_top(current_thread).node(); @@ -225,7 +225,7 @@ get_top_node(Thread *current_thread) const { */ INLINE PandaNode *NodePath:: node() const { - nassertr_always(!is_empty(), (PandaNode *)NULL); + nassertr_always(!is_empty(), nullptr); return _head->get_node(); } @@ -283,7 +283,7 @@ is_same_graph(const NodePath &other, Thread *current_thread) const { // different instance of render that appears to have the same top node. But // this is a very rare thing to do. int a_count, b_count; - return (find_common_ancestor(*this, other, a_count, b_count, current_thread) != (NodePathComponent *)NULL); + return (find_common_ancestor(*this, other, a_count, b_count, current_thread) != nullptr); } /** @@ -293,7 +293,7 @@ is_same_graph(const NodePath &other, Thread *current_thread) const { INLINE bool NodePath:: is_ancestor_of(const NodePath &other, Thread *current_thread) const { int a_count, b_count; - if (find_common_ancestor(*this, other, a_count, b_count, current_thread) == (NodePathComponent *)NULL) { + if (find_common_ancestor(*this, other, a_count, b_count, current_thread) == nullptr) { // Not related. return false; } @@ -312,7 +312,7 @@ INLINE NodePath NodePath:: get_common_ancestor(const NodePath &other, Thread *current_thread) const { int a_count, b_count; NodePathComponent *common = find_common_ancestor(*this, other, a_count, b_count, current_thread); - if (common == (NodePathComponent *)NULL) { + if (common == nullptr) { return NodePath::not_found(); } @@ -457,7 +457,7 @@ set_attrib(const RenderAttrib *attrib, int priority) { */ INLINE const RenderAttrib *NodePath:: get_attrib(TypeHandle type) const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); return node()->get_attrib(type); } @@ -498,7 +498,7 @@ set_effect(const RenderEffect *effect) { */ INLINE const RenderEffect *NodePath:: get_effect(TypeHandle type) const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); return node()->get_effect(type); } diff --git a/panda/src/pgraph/nodePath.cxx b/panda/src/pgraph/nodePath.cxx index f8d7d6c4b0..065bef7424 100644 --- a/panda/src/pgraph/nodePath.cxx +++ b/panda/src/pgraph/nodePath.cxx @@ -90,7 +90,7 @@ NodePath(const NodePath &parent, PandaNode *child_node, Thread *current_thread) : _error_type(ET_fail) { - nassertv(child_node != (PandaNode *)NULL); + nassertv(child_node != nullptr); int pipeline_stage = current_thread->get_pipeline_stage(); if (parent.is_empty()) { @@ -102,9 +102,9 @@ NodePath(const NodePath &parent, PandaNode *child_node, _head = PandaNode::get_component(parent._head, child_node, pipeline_stage, current_thread); } - nassertv(_head != (NodePathComponent *)NULL); + nassertv(_head != nullptr); - if (_head != (NodePathComponent *)NULL) { + if (_head != nullptr) { _error_type = ET_ok; } _backup_key = 0; @@ -145,7 +145,7 @@ get_num_nodes(Thread *current_thread) const { */ PandaNode *NodePath:: get_node(int index, Thread *current_thread) const { - nassertr(index >= 0 && index < get_num_nodes(), NULL); + nassertr(index >= 0 && index < get_num_nodes(), nullptr); int pipeline_stage = current_thread->get_pipeline_stage(); @@ -153,14 +153,14 @@ get_node(int index, Thread *current_thread) const { while (index > 0) { // If this assertion fails, the index was out of range; the component's // length must have been invalid. - nassertr(comp != (NodePathComponent *)NULL, NULL); + nassertr(comp != nullptr, nullptr); comp = comp->get_next(pipeline_stage, current_thread); index--; } // If this assertion fails, the index was out of range; the component's // length must have been invalid. - nassertr(comp != (NodePathComponent *)NULL, NULL); + nassertr(comp != nullptr, nullptr); return comp->get_node(); } @@ -181,14 +181,14 @@ get_ancestor(int index, Thread *current_thread) const { while (index > 0) { // If this assertion fails, the index was out of range; the component's // length must have been invalid. - nassertr(comp != (NodePathComponent *)NULL, NodePath::fail()); + nassertr(comp != nullptr, NodePath::fail()); comp = comp->get_next(pipeline_stage, current_thread); index--; } // If this assertion fails, the index was out of range; the component's // length must have been invalid. - nassertr(comp != (NodePathComponent *)NULL, NodePath::fail()); + nassertr(comp != nullptr, NodePath::fail()); NodePath result; result._head = comp; @@ -210,7 +210,7 @@ get_top(Thread *current_thread) const { NodePathComponent *comp = _head; while (!comp->is_top_node(pipeline_stage, current_thread)) { comp = comp->get_next(pipeline_stage, current_thread); - nassertr(comp != (NodePathComponent *)NULL, NodePath::fail()); + nassertr(comp != nullptr, NodePath::fail()); } NodePath top; @@ -284,7 +284,7 @@ get_sort(Thread *current_thread) const { PandaNode *parent = _head->get_next(pipeline_stage, current_thread)->get_node(); PandaNode *child = node(); - nassertr(parent != (PandaNode *)NULL && child != (PandaNode *)NULL, 0); + nassertr(parent != nullptr && child != nullptr, 0); int child_index = parent->find_child(child); if (child_index != -1) { return parent->get_child_sort(child_index); @@ -325,7 +325,7 @@ find(const string &path) const { NodePath NodePath:: find_path_to(PandaNode *node) const { nassertr_always(!is_empty(), fail()); - nassertr(node != (PandaNode *)NULL, fail()); + nassertr(node != nullptr, fail()); NodePathCollection col; FindApproxPath approx_path; @@ -362,7 +362,7 @@ find_all_paths_to(PandaNode *node) const { NodePathCollection col; nassertr_always(!is_empty(), col); nassertr(verify_complete(), col); - nassertr(node != (PandaNode *)NULL, col); + nassertr(node != nullptr, col); FindApproxPath approx_path; approx_path.add_match_many(0); approx_path.add_match_pointer(node, 0); @@ -472,7 +472,7 @@ instance_to(const NodePath &other, int sort, Thread *current_thread) const { // First, we'll attach to NULL, to guarantee we get a brand new instance. int pipeline_stage = current_thread->get_pipeline_stage(); - new_instance._head = PandaNode::attach(NULL, node(), sort, pipeline_stage, + new_instance._head = PandaNode::attach(nullptr, node(), sort, pipeline_stage, current_thread); // Now, we'll reparent the new instance to the target node. @@ -534,7 +534,7 @@ copy_to(const NodePath &other, int sort, Thread *current_thread) const { PandaNode *source_node = node(); PT(PandaNode) copy_node = source_node->copy_subgraph(current_thread); - nassertr(copy_node != (PandaNode *)NULL, fail()); + nassertr(copy_node != nullptr, fail()); copy_node->reset_prev_transform(current_thread); @@ -557,7 +557,7 @@ NodePath NodePath:: attach_new_node(PandaNode *node, int sort, Thread *current_thread) const { nassertr(verify_complete(current_thread), NodePath::fail()); nassertr(_error_type == ET_ok, NodePath::fail()); - nassertr(node != (PandaNode *)NULL, NodePath::fail()); + nassertr(node != nullptr, NodePath::fail()); NodePath new_path(*this); int pipeline_stage = current_thread->get_pipeline_stage(); @@ -666,7 +666,7 @@ output(ostream &out) const { break; } - if (_head == (NodePathComponent *)NULL) { + if (_head == nullptr) { out << "(empty)"; } else { _head->output(out); @@ -705,7 +705,7 @@ get_state(const NodePath &other, Thread *current_thread) const { #endif int a_count, b_count; - if (find_common_ancestor(*this, other, a_count, b_count, current_thread) == (NodePathComponent *)NULL) { + if (find_common_ancestor(*this, other, a_count, b_count, current_thread) == nullptr) { if (allow_unrelated_wrt) { pgraph_cat.debug() << *this << " is not related to " << other << "\n"; @@ -777,7 +777,7 @@ get_transform(const NodePath &other, Thread *current_thread) const { #endif int a_count, b_count; - if (find_common_ancestor(*this, other, a_count, b_count, current_thread) == (NodePathComponent *)NULL) { + if (find_common_ancestor(*this, other, a_count, b_count, current_thread) == nullptr) { if (allow_unrelated_wrt) { if (pgraph_cat.is_debug()) { pgraph_cat.debug() @@ -793,10 +793,10 @@ get_transform(const NodePath &other, Thread *current_thread) const { CPT(TransformState) a_transform, b_transform; a_transform = r_get_partial_transform(_head, a_count, current_thread); - if (a_transform != (TransformState *)NULL) { + if (a_transform != nullptr) { b_transform = r_get_partial_transform(other._head, b_count, current_thread); } - if (b_transform == (TransformState *)NULL) { + if (b_transform == nullptr) { // If either path involved a node with a net_transform RenderEffect // applied, we have to go all the way up to the root to get the right // answer. @@ -864,7 +864,7 @@ get_prev_transform(const NodePath &other, Thread *current_thread) const { #endif int a_count, b_count; - if (find_common_ancestor(*this, other, a_count, b_count, current_thread) == (NodePathComponent *)NULL) { + if (find_common_ancestor(*this, other, a_count, b_count, current_thread) == nullptr) { if (allow_unrelated_wrt) { pgraph_cat.debug() << *this << " is not related to " << other << "\n"; @@ -1998,7 +1998,7 @@ get_color() const { nassertr_always(!is_empty(), false); const RenderAttrib *attrib = node()->get_attrib(ColorAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ColorAttrib *ca = DCAST(ColorAttrib, attrib); if (ca->get_color_type() == ColorAttrib::T_flat) { return ca->get_color(); @@ -2043,7 +2043,7 @@ compose_color_scale(const LVecBase4 &scale, int priority) { const RenderAttrib *attrib = node()->get_attrib(ColorScaleAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(ColorScaleAttrib::get_class_slot())); const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attrib); @@ -2073,7 +2073,7 @@ set_color_scale(const LVecBase4 &scale, int priority) { const RenderAttrib *attrib = node()->get_attrib(ColorScaleAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(ColorScaleAttrib::get_class_slot())); const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attrib); @@ -2115,7 +2115,7 @@ set_alpha_scale(PN_stdfloat scale, int priority) { const RenderAttrib *attrib = node()->get_attrib(ColorScaleAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(ColorScaleAttrib::get_class_slot())); const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attrib); @@ -2141,7 +2141,7 @@ set_all_color_scale(PN_stdfloat scale, int priority) { const RenderAttrib *attrib = node()->get_attrib(ColorScaleAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(ColorScaleAttrib::get_class_slot())); const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attrib); @@ -2167,7 +2167,7 @@ get_color_scale() const { nassertr_always(!is_empty(), ident_scale); const RenderAttrib *attrib = node()->get_attrib(ColorScaleAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attrib); return csa->get_scale(); } @@ -2186,11 +2186,11 @@ set_light(const NodePath &light, int priority) { nassertv_always(!is_empty()); if (!light.is_empty()) { Light *light_obj = light.node()->as_light(); - if (light_obj != (Light *)NULL) { + if (light_obj != nullptr) { // It's an actual Light object. const RenderAttrib *attrib = node()->get_attrib(LightAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(LightAttrib::get_class_slot())); const LightAttrib *la = DCAST(LightAttrib, attrib); @@ -2216,7 +2216,7 @@ set_light(const NodePath &light, int priority) { const RenderEffect *effect = node()->get_effect(PolylightEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { const PolylightEffect *ple = DCAST(PolylightEffect, effect); // Modify the existing PolylightEffect to add the indicated light. @@ -2264,10 +2264,10 @@ set_light_off(const NodePath &light, int priority) { if (!light.is_empty()) { Light *light_obj = light.node()->as_light(); - if (light_obj != (Light *)NULL) { + if (light_obj != nullptr) { const RenderAttrib *attrib = node()->get_attrib(LightAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(LightAttrib::get_class_slot())); const LightAttrib *la = DCAST(LightAttrib, attrib); @@ -2310,10 +2310,10 @@ clear_light(const NodePath &light) { if (!light.is_empty()) { Light *light_obj = light.node()->as_light(); - if (light_obj != (Light *)NULL) { + if (light_obj != nullptr) { const RenderAttrib *attrib = node()->get_attrib(LightAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { CPT(LightAttrib) la = DCAST(LightAttrib, attrib); la = DCAST(LightAttrib, la->remove_on_light(light)); la = DCAST(LightAttrib, la->remove_off_light(light)); @@ -2331,7 +2331,7 @@ clear_light(const NodePath &light) { } else if (light.node()->is_of_type(PolylightNode::get_class_type())) { const RenderEffect *effect = node()->get_effect(PolylightEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { CPT(PolylightEffect) ple = DCAST(PolylightEffect, effect); ple = DCAST(PolylightEffect, ple->remove_light(light)); node()->set_effect(ple); @@ -2353,10 +2353,10 @@ has_light(const NodePath &light) const { if (!light.is_empty()) { Light *light_obj = light.node()->as_light(); - if (light_obj != (Light *)NULL) { + if (light_obj != nullptr) { const RenderAttrib *attrib = node()->get_attrib(LightAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const LightAttrib *la = DCAST(LightAttrib, attrib); return la->has_on_light(light); } @@ -2365,7 +2365,7 @@ has_light(const NodePath &light) const { } else if (light.node()->is_of_type(PolylightNode::get_class_type())) { const RenderEffect *effect = node()->get_effect(PolylightEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { const PolylightEffect *ple = DCAST(PolylightEffect, effect); return ple->has_light(light); } @@ -2387,7 +2387,7 @@ has_light_off() const { const RenderAttrib *attrib = node()->get_attrib(LightAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const LightAttrib *la = DCAST(LightAttrib, attrib); return la->has_all_off(); } @@ -2408,10 +2408,10 @@ has_light_off(const NodePath &light) const { nassertr_always(!is_empty(), false); if (!light.is_empty()) { Light *light_obj = light.node()->as_light(); - if (light_obj != (Light *)NULL) { + if (light_obj != nullptr) { const RenderAttrib *attrib = node()->get_attrib(LightAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const LightAttrib *la = DCAST(LightAttrib, attrib); return la->has_off_light(light); } @@ -2434,7 +2434,7 @@ set_clip_plane(const NodePath &clip_plane, int priority) { if (!clip_plane.is_empty() && clip_plane.node()->is_of_type(PlaneNode::get_class_type())) { const RenderAttrib *attrib = node()->get_attrib(ClipPlaneAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(ClipPlaneAttrib::get_class_slot())); const ClipPlaneAttrib *la = DCAST(ClipPlaneAttrib, attrib); @@ -2482,7 +2482,7 @@ set_clip_plane_off(const NodePath &clip_plane, int priority) { if (!clip_plane.is_empty() && clip_plane.node()->is_of_type(PlaneNode::get_class_type())) { const RenderAttrib *attrib = node()->get_attrib(ClipPlaneAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(ClipPlaneAttrib::get_class_slot())); const ClipPlaneAttrib *la = DCAST(ClipPlaneAttrib, attrib); @@ -2523,7 +2523,7 @@ clear_clip_plane(const NodePath &clip_plane) { if (!clip_plane.is_empty() && clip_plane.node()->is_of_type(PlaneNode::get_class_type())) { const RenderAttrib *attrib = node()->get_attrib(ClipPlaneAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { CPT(ClipPlaneAttrib) la = DCAST(ClipPlaneAttrib, attrib); la = DCAST(ClipPlaneAttrib, la->remove_on_plane(clip_plane)); la = DCAST(ClipPlaneAttrib, la->remove_off_plane(clip_plane)); @@ -2553,7 +2553,7 @@ has_clip_plane(const NodePath &clip_plane) const { if (!clip_plane.is_empty() && clip_plane.node()->is_of_type(PlaneNode::get_class_type())) { const RenderAttrib *attrib = node()->get_attrib(ClipPlaneAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ClipPlaneAttrib *la = DCAST(ClipPlaneAttrib, attrib); return la->has_on_plane(clip_plane); } @@ -2574,7 +2574,7 @@ has_clip_plane_off() const { const RenderAttrib *attrib = node()->get_attrib(ClipPlaneAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ClipPlaneAttrib *la = DCAST(ClipPlaneAttrib, attrib); return la->has_all_off(); } @@ -2593,7 +2593,7 @@ has_clip_plane_off(const NodePath &clip_plane) const { if (!clip_plane.is_empty() && clip_plane.node()->is_of_type(PlaneNode::get_class_type())) { const RenderAttrib *attrib = node()->get_attrib(ClipPlaneAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ClipPlaneAttrib *la = DCAST(ClipPlaneAttrib, attrib); return la->has_off_plane(clip_plane); } @@ -2615,7 +2615,7 @@ set_occluder(const NodePath &occluder) { if (!occluder.is_empty() && occluder.node()->is_of_type(OccluderNode::get_class_type())) { const RenderEffect *effect = node()->get_effect(OccluderEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { const OccluderEffect *la = DCAST(OccluderEffect, effect); // Modify the existing OccluderEffect to add the indicated occluder. @@ -2651,7 +2651,7 @@ clear_occluder(const NodePath &occluder) { if (!occluder.is_empty() && occluder.node()->is_of_type(OccluderNode::get_class_type())) { const RenderEffect *effect = node()->get_effect(OccluderEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { CPT(OccluderEffect) la = DCAST(OccluderEffect, effect); la = DCAST(OccluderEffect, la->remove_on_occluder(occluder)); @@ -2679,7 +2679,7 @@ has_occluder(const NodePath &occluder) const { if (!occluder.is_empty() && occluder.node()->is_of_type(OccluderNode::get_class_type())) { const RenderEffect *effect = node()->get_effect(OccluderEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { const OccluderEffect *la = DCAST(OccluderEffect, effect); return la->has_on_occluder(occluder); } @@ -2824,7 +2824,7 @@ get_bin_name() const { nassertr_always(!is_empty(), string()); const RenderAttrib *attrib = node()->get_attrib(CullBinAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const CullBinAttrib *ba = DCAST(CullBinAttrib, attrib); return ba->get_bin_name(); } @@ -2842,7 +2842,7 @@ get_bin_draw_order() const { nassertr_always(!is_empty(), false); const RenderAttrib *attrib = node()->get_attrib(CullBinAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const CullBinAttrib *ba = DCAST(CullBinAttrib, attrib); return ba->get_draw_order(); } @@ -2878,7 +2878,7 @@ set_texture(TextureStage *stage, Texture *tex, int priority) { const RenderAttrib *attrib = node()->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *tsa = DCAST(TextureAttrib, attrib); int sg_priority = node()->get_state()->get_override(TextureAttrib::get_class_slot()); @@ -2928,7 +2928,7 @@ set_texture(TextureStage *stage, Texture *tex, const SamplerState &sampler, int const RenderAttrib *attrib = node()->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *tsa = DCAST(TextureAttrib, attrib); int sg_priority = node()->get_state()->get_override(TextureAttrib::get_class_slot()); @@ -2966,7 +2966,7 @@ set_texture_off(TextureStage *stage, int priority) { const RenderAttrib *attrib = node()->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *tsa = DCAST(TextureAttrib, attrib); int sg_priority = node()->get_state()->get_override(TextureAttrib::get_class_slot()); @@ -3004,7 +3004,7 @@ clear_texture(TextureStage *stage) { const RenderAttrib *attrib = node()->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { CPT(TextureAttrib) tsa = DCAST(TextureAttrib, attrib); tsa = DCAST(TextureAttrib, tsa->remove_on_stage(stage)); tsa = DCAST(TextureAttrib, tsa->remove_off_stage(stage)); @@ -3027,7 +3027,7 @@ clear_texture(TextureStage *stage) { */ bool NodePath:: has_texture() const { - return get_texture() != (Texture *)NULL; + return get_texture() != nullptr; } /** @@ -3042,7 +3042,7 @@ has_texture(TextureStage *stage) const { const RenderAttrib *attrib = node()->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); return ta->has_on_stage(stage); } @@ -3061,7 +3061,7 @@ has_texture_off() const { nassertr_always(!is_empty(), false); const RenderAttrib *attrib = node()->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); return ta->has_all_off(); } @@ -3081,7 +3081,7 @@ has_texture_off(TextureStage *stage) const { const RenderAttrib *attrib = node()->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); return ta->has_off_stage(stage); } @@ -3099,15 +3099,15 @@ has_texture_off(TextureStage *stage) const { */ Texture *NodePath:: get_texture() const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); const RenderAttrib *attrib = node()->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); return ta->get_texture(); } - return NULL; + return nullptr; } /** @@ -3116,15 +3116,15 @@ get_texture() const { */ Texture *NodePath:: get_texture(TextureStage *stage) const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); const RenderAttrib *attrib = node()->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); return ta->get_on_texture(stage); } - return NULL; + return nullptr; } /** @@ -3153,7 +3153,7 @@ get_texture_sampler(TextureStage *stage) const { nassertr_always(!is_empty(), SamplerState::get_default()); const RenderAttrib *attrib = node()->get_attrib(TextureAttrib::get_class_slot()); - nassertr_always(attrib != NULL, SamplerState::get_default()); + nassertr_always(attrib != nullptr, SamplerState::get_default()); const TextureAttrib *ta = DCAST(TextureAttrib, attrib); return ta->get_on_sampler(stage); @@ -3168,7 +3168,7 @@ set_shader(const Shader *sha, int priority) { const RenderAttrib *attrib = node()->get_attrib(ShaderAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(ShaderAttrib::get_class_slot())); const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib); @@ -3185,7 +3185,7 @@ set_shader(const Shader *sha, int priority) { */ void NodePath:: set_shader_off(int priority) { - set_shader(NULL, priority); + set_shader(nullptr, priority); } /** @@ -3197,7 +3197,7 @@ set_shader_auto(int priority) { const RenderAttrib *attrib = node()->get_attrib(ShaderAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(ShaderAttrib::get_class_slot())); const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib); @@ -3218,7 +3218,7 @@ set_shader_auto(BitMask32 shader_switch, int priority) { const RenderAttrib *attrib = node()->get_attrib(ShaderAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(ShaderAttrib::get_class_slot())); const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib); @@ -3238,7 +3238,7 @@ clear_shader() { const RenderAttrib *attrib = node()->get_attrib(ShaderAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib); node()->set_attrib(sa->clear_shader()); } @@ -3249,14 +3249,14 @@ clear_shader() { */ const Shader *NodePath:: get_shader() const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); const RenderAttrib *attrib = node()->get_attrib(ShaderAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib); return sa->get_shader(); } - return NULL; + return nullptr; } /** @@ -3326,7 +3326,7 @@ get_instance_count() const { const RenderAttrib *attrib = node()->get_attrib(ShaderAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib); return sa->get_instance_count(); } @@ -3343,7 +3343,7 @@ clear_shader_input(CPT_InternalName id) { const RenderAttrib *attrib = node()->get_attrib(ShaderAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib); node()->set_attrib(sa->clear_shader_input(id)); } @@ -3360,7 +3360,7 @@ set_instance_count(int instance_count) { const RenderAttrib *attrib = node()->get_attrib(ShaderAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib); node()->set_attrib(sa->set_instance_count(instance_count)); } else { @@ -3380,7 +3380,7 @@ set_tex_transform(TextureStage *stage, const TransformState *transform) { const RenderAttrib *attrib = node()->get_attrib(TexMatrixAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TexMatrixAttrib *tma = DCAST(TexMatrixAttrib, attrib); // Modify the existing TexMatrixAttrib to add the indicated stage. @@ -3410,7 +3410,7 @@ clear_tex_transform(TextureStage *stage) { const RenderAttrib *attrib = node()->get_attrib(TexMatrixAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { CPT(TexMatrixAttrib) tma = DCAST(TexMatrixAttrib, attrib); tma = DCAST(TexMatrixAttrib, tma->remove_stage(stage)); @@ -3433,7 +3433,7 @@ has_tex_transform(TextureStage *stage) const { const RenderAttrib *attrib = node()->get_attrib(TexMatrixAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TexMatrixAttrib *tma = DCAST(TexMatrixAttrib, attrib); return tma->has_stage(stage); } @@ -3448,11 +3448,11 @@ has_tex_transform(TextureStage *stage) const { */ CPT(TransformState) NodePath:: get_tex_transform(TextureStage *stage) const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); const RenderAttrib *attrib = node()->get_attrib(TexMatrixAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TexMatrixAttrib *tma = DCAST(TexMatrixAttrib, attrib); return tma->get_transform(stage); } @@ -3472,7 +3472,7 @@ set_tex_transform(const NodePath &other, TextureStage *stage, const TransformSta CPT(RenderState) state = get_state(other); const RenderAttrib *attrib = state->get_attrib(TexMatrixAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TexMatrixAttrib *tma = DCAST(TexMatrixAttrib, attrib); // Modify the existing TexMatrixAttrib to add the indicated stage. @@ -3508,7 +3508,7 @@ get_tex_transform(const NodePath &other, TextureStage *stage) const { CPT(RenderState) state = get_state(other); const RenderAttrib *attrib = state->get_attrib(TexMatrixAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TexMatrixAttrib *tma = DCAST(TexMatrixAttrib, attrib); return tma->get_transform(stage); } @@ -3529,7 +3529,7 @@ set_tex_gen(TextureStage *stage, RenderAttrib::TexGenMode mode, int priority) { CPT(TexGenAttrib) tga; - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(TextureAttrib::get_class_slot())); tga = DCAST(TexGenAttrib, attrib); @@ -3556,7 +3556,7 @@ set_tex_gen(TextureStage *stage, RenderAttrib::TexGenMode mode, CPT(TexGenAttrib) tga; - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(TextureAttrib::get_class_slot())); tga = DCAST(TexGenAttrib, attrib); @@ -3588,7 +3588,7 @@ clear_tex_gen(TextureStage *stage) { const RenderAttrib *attrib = node()->get_attrib(TexGenAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { CPT(TexGenAttrib) tga = DCAST(TexGenAttrib, attrib); tga = DCAST(TexGenAttrib, tga->remove_stage(stage)); @@ -3611,7 +3611,7 @@ has_tex_gen(TextureStage *stage) const { const RenderAttrib *attrib = node()->get_attrib(TexGenAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TexGenAttrib *tga = DCAST(TexGenAttrib, attrib); return tga->has_stage(stage); } @@ -3629,7 +3629,7 @@ get_tex_gen(TextureStage *stage) const { const RenderAttrib *attrib = node()->get_attrib(TexGenAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TexGenAttrib *tga = DCAST(TexGenAttrib, attrib); return tga->get_mode(stage); } @@ -3658,7 +3658,7 @@ set_tex_projector(TextureStage *stage, const NodePath &from, const NodePath &to, CPT(TexProjectorEffect) tpe; - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { tpe = DCAST(TexProjectorEffect, effect); } else { @@ -3677,7 +3677,7 @@ clear_tex_projector(TextureStage *stage) { const RenderEffect *effect = node()->get_effect(TexProjectorEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { CPT(TexProjectorEffect) tpe = DCAST(TexProjectorEffect, effect); tpe = DCAST(TexProjectorEffect, tpe->remove_stage(stage)); @@ -3709,7 +3709,7 @@ has_tex_projector(TextureStage *stage) const { const RenderEffect *effect = node()->get_effect(TexProjectorEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { const TexProjectorEffect *tpe = DCAST(TexProjectorEffect, effect); return tpe->has_stage(stage); } @@ -3728,7 +3728,7 @@ get_tex_projector_from(TextureStage *stage) const { const RenderEffect *effect = node()->get_effect(TexProjectorEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { const TexProjectorEffect *tpe = DCAST(TexProjectorEffect, effect); return tpe->get_from(stage); } @@ -3747,7 +3747,7 @@ get_tex_projector_to(TextureStage *stage) const { const RenderEffect *effect = node()->get_effect(TexProjectorEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { const TexProjectorEffect *tpe = DCAST(TexProjectorEffect, effect); return tpe->get_to(stage); } @@ -3886,7 +3886,7 @@ find_all_texcoords(const string &name) const { */ Texture *NodePath:: find_texture(const string &name) const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); GlobPattern glob(name); return r_find_texture(node(), get_net_state(), glob); } @@ -3898,7 +3898,7 @@ find_texture(const string &name) const { */ Texture *NodePath:: find_texture(TextureStage *stage) const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); return r_find_texture(node(), stage); } @@ -3968,7 +3968,7 @@ find_all_textures(TextureStage *stage) const { */ TextureStage *NodePath:: find_texture_stage(const string &name) const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); GlobPattern glob(name); return r_find_texture_stage(node(), get_net_state(), glob); } @@ -4035,7 +4035,7 @@ find_all_texture_stages(const string &name) const { */ Material *NodePath:: find_material(const string &name) const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); GlobPattern glob(name); return r_find_material(node(), get_net_state(), glob); } @@ -4090,7 +4090,7 @@ find_all_materials(const string &name) const { void NodePath:: set_material(Material *mat, int priority) { nassertv_always(!is_empty()); - nassertv(mat != NULL); + nassertv(mat != nullptr); node()->set_attrib(MaterialAttrib::make(mat), priority); } @@ -4125,7 +4125,7 @@ has_material() const { nassertr_always(!is_empty(), false); const RenderAttrib *attrib = node()->get_attrib(MaterialAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const MaterialAttrib *ma = DCAST(MaterialAttrib, attrib); return !ma->is_off(); } @@ -4143,15 +4143,15 @@ has_material() const { */ PT(Material) NodePath:: get_material() const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); const RenderAttrib *attrib = node()->get_attrib(MaterialAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const MaterialAttrib *ma = DCAST(MaterialAttrib, attrib); return ma->get_material(); } - return NULL; + return nullptr; } /** @@ -4198,7 +4198,7 @@ has_fog() const { nassertr_always(!is_empty(), false); const RenderAttrib *attrib = node()->get_attrib(FogAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const FogAttrib *fa = DCAST(FogAttrib, attrib); return !fa->is_off(); } @@ -4217,7 +4217,7 @@ has_fog_off() const { nassertr_always(!is_empty(), false); const RenderAttrib *attrib = node()->get_attrib(FogAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const FogAttrib *fa = DCAST(FogAttrib, attrib); return fa->is_off(); } @@ -4233,15 +4233,15 @@ has_fog_off() const { */ Fog *NodePath:: get_fog() const { - nassertr_always(!is_empty(), NULL); + nassertr_always(!is_empty(), nullptr); const RenderAttrib *attrib = node()->get_attrib(FogAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const FogAttrib *fa = DCAST(FogAttrib, attrib); return fa->get_fog(); } - return NULL; + return nullptr; } /** @@ -4356,7 +4356,7 @@ get_render_mode() const { nassertr_always(!is_empty(), RenderModeAttrib::M_unchanged); const RenderAttrib *attrib = node()->get_attrib(RenderModeAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const RenderModeAttrib *ta = DCAST(RenderModeAttrib, attrib); return ta->get_mode(); } @@ -4373,7 +4373,7 @@ get_render_mode_thickness() const { nassertr_always(!is_empty(), 0.0f); const RenderAttrib *attrib = node()->get_attrib(RenderModeAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const RenderModeAttrib *ta = DCAST(RenderModeAttrib, attrib); return ta->get_thickness(); } @@ -4390,7 +4390,7 @@ get_render_mode_perspective() const { nassertr_always(!is_empty(), 0.0f); const RenderAttrib *attrib = node()->get_attrib(RenderModeAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const RenderModeAttrib *ta = DCAST(RenderModeAttrib, attrib); return ta->get_perspective(); } @@ -4451,7 +4451,7 @@ get_two_sided() const { nassertr_always(!is_empty(), false); const RenderAttrib *attrib = node()->get_attrib(CullFaceAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const CullFaceAttrib *cfa = DCAST(CullFaceAttrib, attrib); return (cfa->get_actual_mode() == CullFaceAttrib::M_cull_none); } @@ -4508,7 +4508,7 @@ get_depth_test() const { nassertr_always(!is_empty(), false); const RenderAttrib *attrib = node()->get_attrib(DepthTestAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const DepthTestAttrib *dta = DCAST(DepthTestAttrib, attrib); return (dta->get_mode() != DepthTestAttrib::M_none); } @@ -4565,7 +4565,7 @@ get_depth_write() const { nassertr_always(!is_empty(), false); const RenderAttrib *attrib = node()->get_attrib(DepthWriteAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const DepthWriteAttrib *dta = DCAST(DepthWriteAttrib, attrib); return (dta->get_mode() != DepthWriteAttrib::M_off); } @@ -4619,7 +4619,7 @@ get_depth_offset() const { nassertr_always(!is_empty(), 0); const RenderAttrib *attrib = node()->get_attrib(DepthOffsetAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const DepthOffsetAttrib *doa = DCAST(DepthOffsetAttrib, attrib); return doa->get_offset(); } @@ -4853,7 +4853,7 @@ get_transparency() const { nassertr_always(!is_empty(), TransparencyAttrib::M_none); const RenderAttrib *attrib = node()->get_attrib(TransparencyAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TransparencyAttrib *ta = DCAST(TransparencyAttrib, attrib); return ta->get_mode(); } @@ -4909,7 +4909,7 @@ get_logic_op() const { nassertr_always(!is_empty(), LogicOpAttrib::O_none); const RenderAttrib *attrib = node()->get_attrib(LogicOpAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const LogicOpAttrib *ta = DCAST(LogicOpAttrib, attrib); return ta->get_operation(); } @@ -4958,7 +4958,7 @@ get_antialias() const { nassertr_always(!is_empty(), AntialiasAttrib::M_none); const RenderAttrib *attrib = node()->get_attrib(AntialiasAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const AntialiasAttrib *ta = DCAST(AntialiasAttrib, attrib); return ta->get_mode(); } @@ -4997,7 +4997,7 @@ set_audio_volume(PN_stdfloat volume, int priority) { const RenderAttrib *attrib = node()->get_attrib(AudioVolumeAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { priority = max(priority, node()->get_state()->get_override(AudioVolumeAttrib::get_class_slot())); CPT(AudioVolumeAttrib) ava = DCAST(AudioVolumeAttrib, attrib); @@ -5035,7 +5035,7 @@ PN_stdfloat NodePath:: get_audio_volume() const { const RenderAttrib *attrib = node()->get_attrib(AudioVolumeAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const AudioVolumeAttrib *ava = DCAST(AudioVolumeAttrib, attrib); return ava->get_volume(); } @@ -5051,9 +5051,9 @@ PN_stdfloat NodePath:: get_net_audio_volume() const { CPT(RenderState) net_state = get_net_state(); const RenderAttrib *attrib = net_state->get_attrib(AudioVolumeAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const AudioVolumeAttrib *ava = DCAST(AudioVolumeAttrib, attrib); - if (ava != (const AudioVolumeAttrib *)NULL) { + if (ava != nullptr) { return ava->get_volume(); } } @@ -5072,7 +5072,7 @@ get_hidden_ancestor(DrawMask camera_mask, Thread *current_thread) const { NodePathComponent *comp; for (comp = _head; - comp != (NodePathComponent *)NULL; + comp != nullptr; comp = comp->get_next(pipeline_stage, current_thread)) { PandaNode *node = comp->get_node(); if (node->is_overall_hidden() || @@ -5143,11 +5143,11 @@ unstash_all(Thread *current_thread) { NodePath NodePath:: get_stashed_ancestor(Thread *current_thread) const { NodePathComponent *comp = _head; - if (comp != (NodePathComponent *)NULL) { + if (comp != nullptr) { int pipeline_stage = current_thread->get_pipeline_stage(); NodePathComponent *next = comp->get_next(pipeline_stage, current_thread); - while (next != (NodePathComponent *)NULL) { + while (next != nullptr) { PandaNode *node = comp->get_node(); PandaNode *parent_node = next->get_node(); @@ -5237,19 +5237,19 @@ verify_complete(Thread *current_thread) const { PStatTimer timer(_verify_complete_pcollector); const NodePathComponent *comp = _head; - nassertr(comp != (const NodePathComponent *)NULL, false); + nassertr(comp != nullptr, false); int pipeline_stage = current_thread->get_pipeline_stage(); PandaNode *node = comp->get_node(); - nassertr(node != (const PandaNode *)NULL, false); + nassertr(node != nullptr, false); int length = comp->get_length(pipeline_stage, current_thread); comp = comp->get_next(pipeline_stage, current_thread); length--; - while (comp != (const NodePathComponent *)NULL) { + while (comp != nullptr) { PandaNode *next_node = comp->get_node(); - nassertr(next_node != (const PandaNode *)NULL, false); + nassertr(next_node != nullptr, false); if (node->find_parent(next_node) < 0) { pgraph_cat.warning() @@ -5654,7 +5654,7 @@ encode_to_bam_stream(vector_uchar &data, BamWriter *writer) const { DatagramBuffer buffer; BamWriter local_writer; bool used_local_writer = false; - if (writer == NULL) { + if (writer == nullptr) { // Create our own writer. if (!buffer.write_header(_bam_header)) { @@ -5683,20 +5683,20 @@ encode_to_bam_stream(vector_uchar &data, BamWriter *writer) const { dg.add_int32(num_nodes); if (!buffer.put_datagram(dg)) { - writer->set_target(NULL); + writer->set_target(nullptr); return false; } // Now write the nodes, one at a time. for (int i = 0; i < num_nodes; ++i) { PandaNode *node = get_node(num_nodes - i - 1); - nassertr(node != NULL, false); + nassertr(node != nullptr, false); if (!writer->write_object(node)) { - writer->set_target(NULL); + writer->set_target(nullptr); return false; } } - writer->set_target(NULL); + writer->set_target(nullptr); buffer.swap_data(data); return true; @@ -5713,7 +5713,7 @@ decode_from_bam_stream(vector_uchar data, BamReader *reader) { DatagramBuffer buffer(move(data)); BamReader local_reader; - if (reader == NULL) { + if (reader == nullptr) { // Create a local reader. string head; @@ -5748,14 +5748,14 @@ decode_from_bam_stream(vector_uchar data, BamReader *reader) { for (int i = 0; i < num_nodes; ++i) { TypedWritable *object = reader->read_object(); - if (object == (TypedWritable *)NULL || + if (object == nullptr || !object->is_of_type(PandaNode::get_class_type())) { - reader->set_source(NULL); + reader->set_source(nullptr); return NodePath::fail(); } if (!reader->resolve()) { - reader->set_source(NULL); + reader->set_source(nullptr); return NodePath::fail(); } @@ -5764,7 +5764,7 @@ decode_from_bam_stream(vector_uchar data, BamReader *reader) { } } - reader->set_source(NULL); + reader->set_source(nullptr); return result; } @@ -5780,7 +5780,7 @@ decode_from_bam_stream(vector_uchar data, BamReader *reader) { NodePathComponent *NodePath:: find_common_ancestor(const NodePath &a, const NodePath &b, int &a_count, int &b_count, Thread *current_thread) { - nassertr(!a.is_empty() && !b.is_empty(), NULL); + nassertr(!a.is_empty() && !b.is_empty(), nullptr); NodePathComponent *ac = a._head; NodePathComponent *bc = b._head; a_count = 0; @@ -5790,12 +5790,12 @@ find_common_ancestor(const NodePath &a, const NodePath &b, // Shorten up the longer one until they are the same length. while (ac->get_length(pipeline_stage, current_thread) > bc->get_length(pipeline_stage, current_thread)) { - nassertr(ac != (NodePathComponent *)NULL, NULL); + nassertr(ac != nullptr, nullptr); ac = ac->get_next(pipeline_stage, current_thread); a_count++; } while (bc->get_length(pipeline_stage, current_thread) > ac->get_length(pipeline_stage, current_thread)) { - nassertr(bc != (NodePathComponent *)NULL, NULL); + nassertr(bc != nullptr, nullptr); bc = bc->get_next(pipeline_stage, current_thread); b_count++; } @@ -5803,8 +5803,8 @@ find_common_ancestor(const NodePath &a, const NodePath &b, // Now shorten them both up until we reach the same component. while (ac != bc) { // These shouldn't go to NULL unless they both go there together. - nassertr(ac != (NodePathComponent *)NULL, NULL); - nassertr(bc != (NodePathComponent *)NULL, NULL); + nassertr(ac != nullptr, nullptr); + nassertr(bc != nullptr, nullptr); ac = ac->get_next(pipeline_stage, current_thread); a_count++; bc = bc->get_next(pipeline_stage, current_thread); @@ -5820,7 +5820,7 @@ find_common_ancestor(const NodePath &a, const NodePath &b, */ CPT(RenderState) NodePath:: r_get_net_state(NodePathComponent *comp, Thread *current_thread) const { - if (comp == (NodePathComponent *)NULL) { + if (comp == nullptr) { return RenderState::make_empty(); } else { CPT(RenderState) state = comp->get_node()->get_state(current_thread); @@ -5837,7 +5837,7 @@ r_get_net_state(NodePathComponent *comp, Thread *current_thread) const { CPT(RenderState) NodePath:: r_get_partial_state(NodePathComponent *comp, int n, Thread *current_thread) const { - if (n == 0 || comp == (NodePathComponent *)NULL) { + if (n == 0 || comp == nullptr) { return RenderState::make_empty(); } else { CPT(RenderState) state = comp->get_node()->get_state(current_thread); @@ -5852,7 +5852,7 @@ r_get_partial_state(NodePathComponent *comp, int n, */ CPT(TransformState) NodePath:: r_get_net_transform(NodePathComponent *comp, Thread *current_thread) const { - if (comp == (NodePathComponent *)NULL) { + if (comp == nullptr) { return TransformState::make_identity(); } else { PandaNode *node = comp->get_node(); @@ -5885,18 +5885,18 @@ r_get_net_transform(NodePathComponent *comp, Thread *current_thread) const { CPT(TransformState) NodePath:: r_get_partial_transform(NodePathComponent *comp, int n, Thread *current_thread) const { - if (n == 0 || comp == (NodePathComponent *)NULL) { + if (n == 0 || comp == nullptr) { return TransformState::make_identity(); } else { PandaNode *node = comp->get_node(); PandaNode::CDReader node_cdata(node->_cycler, current_thread); if (node_cdata->_effects->has_adjust_transform()) { - return NULL; + return nullptr; } int pipeline_stage = current_thread->get_pipeline_stage(); CPT(TransformState) partial = r_get_partial_transform(comp->get_next(pipeline_stage, current_thread), n - 1, current_thread); - if (partial == (const TransformState *)NULL) { - return NULL; + if (partial == nullptr) { + return nullptr; } if (node_cdata->_transform->is_identity()) { return partial; @@ -5912,7 +5912,7 @@ r_get_partial_transform(NodePathComponent *comp, int n, */ CPT(TransformState) NodePath:: r_get_net_prev_transform(NodePathComponent *comp, Thread *current_thread) const { - if (comp == (NodePathComponent *)NULL) { + if (comp == nullptr) { return TransformState::make_identity(); } else { CPT(TransformState) transform = comp->get_node()->get_prev_transform(current_thread); @@ -5928,7 +5928,7 @@ r_get_net_prev_transform(NodePathComponent *comp, Thread *current_thread) const */ CPT(TransformState) NodePath:: r_get_partial_prev_transform(NodePathComponent *comp, int n, Thread *current_thread) const { - if (n == 0 || comp == (NodePathComponent *)NULL) { + if (n == 0 || comp == nullptr) { return TransformState::make_identity(); } else { CPT(TransformState) transform = comp->get_node()->get_prev_transform(current_thread); @@ -5989,9 +5989,9 @@ find_matches(NodePathCollection &result, FindApproxLevelEntry *level, int num_levels_remaining = _max_search_depth; - FindApproxLevelEntry *deleted_entries = NULL; + FindApproxLevelEntry *deleted_entries = nullptr; - while (num_levels_remaining > 0 && level != NULL) { + while (num_levels_remaining > 0 && level != nullptr) { if (pgraph_cat.is_spam()) { pgraph_cat.spam() << "find_matches pass: " << result << ", " @@ -6001,27 +6001,27 @@ find_matches(NodePathCollection &result, FindApproxLevelEntry *level, num_levels_remaining--; - FindApproxLevelEntry *next_level = NULL; + FindApproxLevelEntry *next_level = nullptr; // For each node in the current level, build up the set of possible // matches in the next level. FindApproxLevelEntry *entry = level; - while (entry != (FindApproxLevelEntry *)NULL) { + while (entry != nullptr) { if (entry->consider_node(result, next_level, max_matches, 0)) { // If we found the requisite number of matches, we can stop. Delete // all remaining entries and return immediately. - while (entry != (FindApproxLevelEntry *)NULL) { + while (entry != nullptr) { FindApproxLevelEntry *next = entry->_next; delete entry; entry = next; } - while (next_level != (FindApproxLevelEntry *)NULL) { + while (next_level != nullptr) { FindApproxLevelEntry *next = next_level->_next; delete next_level; next_level = next; } - while (deleted_entries != (FindApproxLevelEntry *)NULL) { + while (deleted_entries != nullptr) { FindApproxLevelEntry *next = deleted_entries->_next; delete deleted_entries; deleted_entries = next; @@ -6042,7 +6042,7 @@ find_matches(NodePathCollection &result, FindApproxLevelEntry *level, // Make sure the remaining entries from this level are added to the delete // chain. - while (entry != (FindApproxLevelEntry *)NULL) { + while (entry != nullptr) { FindApproxLevelEntry *next = entry->_next; entry->_next = deleted_entries; deleted_entries = entry; @@ -6054,7 +6054,7 @@ find_matches(NodePathCollection &result, FindApproxLevelEntry *level, } // Now it's safe to delete all entries on the delete chain. - while (deleted_entries != (FindApproxLevelEntry *)NULL) { + while (deleted_entries != nullptr) { FindApproxLevelEntry *next = deleted_entries->_next; delete deleted_entries; deleted_entries = next; @@ -6231,7 +6231,7 @@ r_find_texture(PandaNode *node, const RenderState *state, const GlobPattern &glob) const { if (node->is_geom_node()) { GeomNode *gnode; - DCAST_INTO_R(gnode, node, NULL); + DCAST_INTO_R(gnode, node, nullptr); int num_geoms = gnode->get_num_geoms(); for (int i = 0; i < num_geoms; i++) { @@ -6241,11 +6241,11 @@ r_find_texture(PandaNode *node, const RenderState *state, // Look for a TextureAttrib on the state. const RenderAttrib *attrib = geom_state->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); for (int i = 0; i < ta->get_num_on_stages(); i++) { Texture *texture = ta->get_on_texture(ta->get_on_stage(i)); - if (texture != (Texture *)NULL) { + if (texture != nullptr) { if (glob.matches(texture->get_name())) { return texture; } @@ -6263,12 +6263,12 @@ r_find_texture(PandaNode *node, const RenderState *state, CPT(RenderState) next_state = state->compose(child->get_state()); Texture *result = r_find_texture(child, next_state, glob); - if (result != (Texture *)NULL) { + if (result != nullptr) { return result; } } - return NULL; + return nullptr; } /** @@ -6289,11 +6289,11 @@ r_find_all_textures(PandaNode *node, const RenderState *state, // Look for a TextureAttrib on the state. const RenderAttrib *attrib = geom_state->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); for (int i = 0; i < ta->get_num_on_stages(); i++) { Texture *texture = ta->get_on_texture(ta->get_on_stage(i)); - if (texture != (Texture *)NULL) { + if (texture != nullptr) { textures.insert(texture); } } @@ -6319,7 +6319,7 @@ r_find_texture(PandaNode *node, TextureStage *stage) const { // Look for a TextureAttrib on the node. const RenderAttrib *attrib = node->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); if (ta->has_on_stage(stage)) { return ta->get_on_texture(stage); @@ -6328,7 +6328,7 @@ r_find_texture(PandaNode *node, TextureStage *stage) const { if (node->is_geom_node()) { GeomNode *gnode; - DCAST_INTO_R(gnode, node, NULL); + DCAST_INTO_R(gnode, node, nullptr); int num_geoms = gnode->get_num_geoms(); for (int i = 0; i < num_geoms; i++) { @@ -6337,7 +6337,7 @@ r_find_texture(PandaNode *node, TextureStage *stage) const { // Look for a TextureAttrib on the state. const RenderAttrib *attrib = geom_state->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); if (ta->has_on_stage(stage)) { return ta->get_on_texture(stage); @@ -6353,12 +6353,12 @@ r_find_texture(PandaNode *node, TextureStage *stage) const { PandaNode *child = cr.get_child(i); Texture *result = r_find_texture(child, stage); - if (result != (Texture *)NULL) { + if (result != nullptr) { return result; } } - return NULL; + return nullptr; } /** @@ -6370,7 +6370,7 @@ r_find_all_textures(PandaNode *node, TextureStage *stage, // Look for a TextureAttrib on the node. const RenderAttrib *attrib = node->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); if (ta->has_on_stage(stage)) { textures.insert(ta->get_on_texture(stage)); @@ -6388,7 +6388,7 @@ r_find_all_textures(PandaNode *node, TextureStage *stage, // Look for a TextureAttrib on the state. const RenderAttrib *attrib = geom_state->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); if (ta->has_on_stage(stage)) { textures.insert(ta->get_on_texture(stage)); @@ -6414,7 +6414,7 @@ r_find_texture_stage(PandaNode *node, const RenderState *state, const GlobPattern &glob) const { if (node->is_geom_node()) { GeomNode *gnode; - DCAST_INTO_R(gnode, node, NULL); + DCAST_INTO_R(gnode, node, nullptr); int num_geoms = gnode->get_num_geoms(); for (int i = 0; i < num_geoms; i++) { @@ -6424,11 +6424,11 @@ r_find_texture_stage(PandaNode *node, const RenderState *state, // Look for a TextureAttrib on the state. const RenderAttrib *attrib = geom_state->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); for (int i = 0; i < ta->get_num_on_stages(); i++) { TextureStage *texture_stage = ta->get_on_stage(i); - if (texture_stage != (TextureStage *)NULL) { + if (texture_stage != nullptr) { if (glob.matches(texture_stage->get_name())) { return texture_stage; } @@ -6446,12 +6446,12 @@ r_find_texture_stage(PandaNode *node, const RenderState *state, CPT(RenderState) next_state = state->compose(child->get_state()); TextureStage *result = r_find_texture_stage(child, next_state, glob); - if (result != (TextureStage *)NULL) { + if (result != nullptr) { return result; } } - return NULL; + return nullptr; } /** @@ -6472,11 +6472,11 @@ r_find_all_texture_stages(PandaNode *node, const RenderState *state, // Look for a TextureAttrib on the state. const RenderAttrib *attrib = geom_state->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); for (int i = 0; i < ta->get_num_on_stages(); i++) { TextureStage *texture_stage = ta->get_on_stage(i); - if (texture_stage != (TextureStage *)NULL) { + if (texture_stage != nullptr) { texture_stages.insert(texture_stage); } } @@ -6502,7 +6502,7 @@ r_unify_texture_stages(PandaNode *node, TextureStage *stage) { // Look for a TextureAttrib on the state. const RenderAttrib *attrib = node->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); CPT(RenderAttrib) new_attrib = ta->unify_texture_stages(stage); if (new_attrib != ta) { @@ -6521,7 +6521,7 @@ r_unify_texture_stages(PandaNode *node, TextureStage *stage) { // Look for a TextureAttrib on the state. const RenderAttrib *attrib = state->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); CPT(RenderAttrib) new_attrib = ta->unify_texture_stages(stage); if (new_attrib != ta) { @@ -6549,7 +6549,7 @@ r_find_material(PandaNode *node, const RenderState *state, const GlobPattern &glob) const { if (node->is_geom_node()) { GeomNode *gnode; - DCAST_INTO_R(gnode, node, NULL); + DCAST_INTO_R(gnode, node, nullptr); int num_geoms = gnode->get_num_geoms(); for (int i = 0; i < num_geoms; i++) { @@ -6559,11 +6559,11 @@ r_find_material(PandaNode *node, const RenderState *state, // Look for a MaterialAttrib on the state. const RenderAttrib *attrib = geom_state->get_attrib(MaterialAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const MaterialAttrib *ta = DCAST(MaterialAttrib, attrib); if (!ta->is_off()) { Material *material = ta->get_material(); - if (material != (Material *)NULL) { + if (material != nullptr) { if (glob.matches(material->get_name())) { return material; } @@ -6581,12 +6581,12 @@ r_find_material(PandaNode *node, const RenderState *state, CPT(RenderState) next_state = state->compose(child->get_state()); Material *result = r_find_material(child, next_state, glob); - if (result != (Material *)NULL) { + if (result != nullptr) { return result; } } - return NULL; + return nullptr; } /** @@ -6607,11 +6607,11 @@ r_find_all_materials(PandaNode *node, const RenderState *state, // Look for a MaterialAttrib on the state. const RenderAttrib *attrib = geom_state->get_attrib(MaterialAttrib::get_class_slot()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const MaterialAttrib *ta = DCAST(MaterialAttrib, attrib); if (!ta->is_off()) { Material *material = ta->get_material(); - if (material != (Material *)NULL) { + if (material != nullptr) { materials.insert(material); } } @@ -6638,9 +6638,9 @@ write_datagram(BamWriter *manager, Datagram &dg) const { PandaNode *root = DCAST(PandaNode, manager->get_root_node()); // We have no root node to measure from. - if (root == (PandaNode *)NULL || root == node()) { + if (root == nullptr || root == node()) { manager->write_pointer(dg, node()); - manager->write_pointer(dg, NULL); + manager->write_pointer(dg, nullptr); return; } @@ -6650,7 +6650,7 @@ write_datagram(BamWriter *manager, Datagram &dg) const { // Record the chain of nodes from the root to this node. pvector path; NodePathComponent *comp = _head; - while (comp != NULL) { + while (comp != nullptr) { PandaNode *node = comp->get_node(); path.push_back(node); @@ -6661,10 +6661,10 @@ write_datagram(BamWriter *manager, Datagram &dg) const { comp = comp->get_next(pipeline_stage, current_thread); } - if (comp == (NodePathComponent *)NULL) { + if (comp == nullptr) { // We did not encounter the root node. Not much we can do. manager->write_pointer(dg, node()); - manager->write_pointer(dg, NULL); + manager->write_pointer(dg, nullptr); return; } @@ -6672,7 +6672,7 @@ write_datagram(BamWriter *manager, Datagram &dg) const { for (int i = path.size() - 1; i >= 0; --i) { manager->write_pointer(dg, path[i]); } - manager->write_pointer(dg, NULL); + manager->write_pointer(dg, nullptr); } /** @@ -6685,7 +6685,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { PT(PandaNode) node = DCAST(PandaNode, p_list[pi++]); if (node.is_null()) { // An empty NodePath. - _head = (NodePathComponent *)NULL; + _head = nullptr; return pi; } @@ -6702,7 +6702,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { } // Build up the chain of NodePathComponents leading up to this node. - while (p_list[pi] != NULL) { + while (p_list[pi] != nullptr) { PT(PandaNode) node = DCAST(PandaNode, p_list[pi++]); LightReMutexHolder holder(node->_paths_lock); diff --git a/panda/src/pgraph/nodePath.h b/panda/src/pgraph/nodePath.h index bdd9d3f2d7..f932b48efc 100644 --- a/panda/src/pgraph/nodePath.h +++ b/panda/src/pgraph/nodePath.h @@ -887,7 +887,7 @@ PUBLISHED: // Miscellaneous bool verify_complete(Thread *current_thread = Thread::get_current_thread()) const; - void premunge_scene(GraphicsStateGuardianBase *gsg = NULL); + void premunge_scene(GraphicsStateGuardianBase *gsg = nullptr); void prepare_scene(GraphicsStateGuardianBase *gsg); void show_bounds(); diff --git a/panda/src/pgraph/nodePathCollection.cxx b/panda/src/pgraph/nodePathCollection.cxx index 40efb80192..68977a8b4b 100644 --- a/panda/src/pgraph/nodePathCollection.cxx +++ b/panda/src/pgraph/nodePathCollection.cxx @@ -229,7 +229,7 @@ find_all_matches(const string &path) const { FindApproxPath approx_path; if (approx_path.add_string(path)) { if (!is_empty()) { - FindApproxLevelEntry *level = NULL; + FindApproxLevelEntry *level = nullptr; for (int i = 0; i < get_num_paths(); i++) { FindApproxLevelEntry *start = new FindApproxLevelEntry(get_path(i), approx_path); diff --git a/panda/src/pgraph/nodePathCollection_ext.cxx b/panda/src/pgraph/nodePathCollection_ext.cxx index 32f5ac0d13..1e2b13fe1e 100644 --- a/panda/src/pgraph/nodePathCollection_ext.cxx +++ b/panda/src/pgraph/nodePathCollection_ext.cxx @@ -32,7 +32,7 @@ extern struct Dtool_PyTypedObject Dtool_LPoint3f; void Extension:: __init__(PyObject *self, PyObject *sequence) { PyObject *fast = PySequence_Fast(sequence, "NodePathCollection constructor requires a sequence"); - if (fast == NULL) { + if (fast == nullptr) { return; } @@ -41,7 +41,7 @@ __init__(PyObject *self, PyObject *sequence) { for (int i = 0; i < size; ++i) { PyObject *item = PySequence_Fast_GET_ITEM(fast, i); - if (item == NULL) { + if (item == nullptr) { return; } @@ -76,13 +76,13 @@ __reduce__(PyObject *self) const { // necessary to reconstruct this object. PyObject *this_class = (PyObject *)self->ob_type; - if (this_class == NULL) { - return NULL; + if (this_class == nullptr) { + return nullptr; } PyObject *self_iter = PyObject_GetIter(self); - if (self_iter == NULL) { - return NULL; + if (self_iter == nullptr) { + return nullptr; } // Since a NodePathCollection is itself an iterator, we can simply pass it diff --git a/panda/src/pgraph/nodePathComponent.I b/panda/src/pgraph/nodePathComponent.I index b54d4cfc7d..00b8d6d19d 100644 --- a/panda/src/pgraph/nodePathComponent.I +++ b/panda/src/pgraph/nodePathComponent.I @@ -34,7 +34,7 @@ CData(const NodePathComponent::CData ©) : */ INLINE NodePathComponent:: ~NodePathComponent() { - nassertv(_node != (PandaNode *)NULL); + nassertv(_node != nullptr); _node->delete_component(this); } @@ -43,7 +43,7 @@ INLINE NodePathComponent:: */ INLINE PandaNode *NodePathComponent:: get_node() const { - nassertr(_node != (PandaNode *)NULL, _node); + nassertr(_node != nullptr, _node); return _node; } diff --git a/panda/src/pgraph/nodePathComponent.cxx b/panda/src/pgraph/nodePathComponent.cxx index a9f8a38788..dd767cf172 100644 --- a/panda/src/pgraph/nodePathComponent.cxx +++ b/panda/src/pgraph/nodePathComponent.cxx @@ -50,7 +50,7 @@ NodePathComponent(PandaNode *node, NodePathComponent *next, CDStageWriter cdata(_cycler, pipeline_stage_i, current_thread); cdata->_next = next; - if (next != (NodePathComponent *)NULL) { + if (next != nullptr) { cdata->_length = next->get_length(pipeline_stage_i, current_thread) + 1; } } @@ -80,7 +80,7 @@ get_key() const { bool NodePathComponent:: is_top_node(int pipeline_stage, Thread *current_thread) const { CDStageReader cdata(_cycler, pipeline_stage, current_thread); - return (cdata->_next == (NodePathComponent *)NULL); + return (cdata->_next == nullptr); } /** @@ -102,7 +102,7 @@ fix_length(int pipeline_stage, Thread *current_thread) { CDLockedStageReader cdata(_cycler, pipeline_stage, current_thread); int length_should_be = 1; - if (cdata->_next != (NodePathComponent *)NULL) { + if (cdata->_next != nullptr) { length_should_be = cdata->_next->get_length(pipeline_stage, current_thread) + 1; } @@ -127,7 +127,7 @@ output(ostream &out) const { PandaNode *node = get_node(); NodePathComponent *next = get_next(pipeline_stage, current_thread); - if (next != (NodePathComponent *)NULL) { + if (next != nullptr) { // This is not the head of the list; keep going up. next->output(out); out << "/"; @@ -157,7 +157,7 @@ output(ostream &out) const { */ void NodePathComponent:: set_next(NodePathComponent *next, int pipeline_stage, Thread *current_thread) { - nassertv(next != (NodePathComponent *)NULL); + nassertv(next != nullptr); CDStageWriter cdata(_cycler, pipeline_stage, current_thread); cdata->_next = next; } @@ -169,5 +169,5 @@ set_next(NodePathComponent *next, int pipeline_stage, Thread *current_thread) { void NodePathComponent:: set_top_node(int pipeline_stage, Thread *current_thread) { CDStageWriter cdata(_cycler, pipeline_stage, current_thread); - cdata->_next = (NodePathComponent *)NULL; + cdata->_next = nullptr; } diff --git a/panda/src/pgraph/nodePath_ext.cxx b/panda/src/pgraph/nodePath_ext.cxx index 1c7576290a..f167d0c57a 100644 --- a/panda/src/pgraph/nodePath_ext.cxx +++ b/panda/src/pgraph/nodePath_ext.cxx @@ -57,7 +57,7 @@ __deepcopy__(PyObject *self, PyObject *memo) const { // Borrowed reference. PyObject *dupe = PyDict_GetItem(memo, self); - if (dupe != NULL) { + if (dupe != nullptr) { // Already in the memo dictionary. Py_INCREF(dupe); return dupe; @@ -74,7 +74,7 @@ __deepcopy__(PyObject *self, PyObject *memo) const { true, false); if (PyDict_SetItem(memo, self, dupe) != 0) { Py_DECREF(dupe); - return NULL; + return nullptr; } return dupe; @@ -89,7 +89,7 @@ __deepcopy__(PyObject *self, PyObject *memo) const { */ PyObject *Extension:: __reduce__(PyObject *self) const { - return __reduce_persist__(self, NULL); + return __reduce_persist__(self, nullptr); } /** @@ -107,10 +107,10 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { // object whose constructor we should call (e.g. this), and the arguments // necessary to reconstruct this object. - BamWriter *writer = NULL; - if (pickler != NULL) { + BamWriter *writer = nullptr; + if (pickler != nullptr) { PyObject *py_writer = PyObject_GetAttrString(pickler, "bamWriter"); - if (py_writer == NULL) { + if (py_writer == nullptr) { // It's OK if there's no bamWriter. PyErr_Clear(); } else { @@ -127,33 +127,33 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { stream << "Could not bamify " << _this; string message = stream.str(); PyErr_SetString(PyExc_TypeError, message.c_str()); - return NULL; + return nullptr; } // Start by getting this class object. PyObject *this_class = (PyObject *)Py_TYPE(self); - if (this_class == NULL) { - return NULL; + if (this_class == nullptr) { + return nullptr; } PyObject *func; - if (writer != NULL) { + if (writer != nullptr) { // The modified pickle support: call the "persistent" version of this // function, which receives the unpickler itself as an additional // parameter. func = Extension::find_global_decode(this_class, "py_decode_NodePath_from_bam_stream_persist"); - if (func == NULL) { + if (func == nullptr) { PyErr_SetString(PyExc_TypeError, "Couldn't find py_decode_NodePath_from_bam_stream_persist()"); - return NULL; + return nullptr; } } else { // The traditional pickle support: call the non-persistent version of this // function. func = Extension::find_global_decode(this_class, "py_decode_NodePath_from_bam_stream"); - if (func == NULL) { + if (func == nullptr) { PyErr_SetString(PyExc_TypeError, "Couldn't find py_decode_NodePath_from_bam_stream()"); - return NULL; + return nullptr; } } @@ -221,10 +221,10 @@ py_decode_NodePath_from_bam_stream(vector_uchar data) { */ NodePath py_decode_NodePath_from_bam_stream_persist(PyObject *unpickler, vector_uchar data) { - BamReader *reader = NULL; - if (unpickler != NULL) { + BamReader *reader = nullptr; + if (unpickler != nullptr) { PyObject *py_reader = PyObject_GetAttrString(unpickler, "bamReader"); - if (py_reader == NULL) { + if (py_reader == nullptr) { // It's OK if there's no bamReader. PyErr_Clear(); } else { diff --git a/panda/src/pgraph/occluderEffect.cxx b/panda/src/pgraph/occluderEffect.cxx index f27c486d88..9e81d4e52d 100644 --- a/panda/src/pgraph/occluderEffect.cxx +++ b/panda/src/pgraph/occluderEffect.cxx @@ -31,7 +31,7 @@ CPT(RenderEffect) OccluderEffect:: make() { // We make it a special case and store a pointer to the empty effect forever // once we find it the first time, as an optimization. - if (_empty_effect == (RenderEffect *)NULL) { + if (_empty_effect == nullptr) { _empty_effect = return_new(new OccluderEffect); } diff --git a/panda/src/pgraph/occluderNode.cxx b/panda/src/pgraph/occluderNode.cxx index c1a4c4d9da..3fc81bc944 100644 --- a/panda/src/pgraph/occluderNode.cxx +++ b/panda/src/pgraph/occluderNode.cxx @@ -146,7 +146,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { trav->get_cull_handler()->record_object(occluder_viz, trav); // Also get the frame. - nassertr(_frame_viz != (Geom *)NULL, false); + nassertr(_frame_viz != nullptr, false); CullableObject *frame_viz = new CullableObject(_frame_viz, get_frame_viz_state(trav, data), data.get_internal_transform(trav)); @@ -210,8 +210,8 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, */ PT(Geom) OccluderNode:: get_occluder_viz(CullTraverser *trav, CullTraverserData &data) { - if (_occluder_viz == (Geom *)NULL) { - nassertr(_vertices.size() == 4, NULL); + if (_occluder_viz == nullptr) { + nassertr(_vertices.size() == 4, nullptr); if (pgraph_cat.is_debug()) { pgraph_cat.debug() @@ -270,7 +270,7 @@ get_occluder_viz(CullTraverser *trav, CullTraverserData &data) { */ CPT(RenderState) OccluderNode:: get_occluder_viz_state(CullTraverser *trav, CullTraverserData &data) { - if (_viz_tex == NULL) { + if (_viz_tex == nullptr) { // Create a default texture. We set it up as a 2x2 graytone checkerboard, // since that's real easy, and it doesn't look like a CollisionPolygon. _viz_tex = new Texture("occluder_viz"); @@ -283,7 +283,7 @@ get_occluder_viz_state(CullTraverser *trav, CullTraverserData &data) { } static CPT(RenderState) viz_state; - if (viz_state == NULL) { + if (viz_state == nullptr) { viz_state = RenderState::make (ColorAttrib::make_flat(LVecBase4(1.0f, 1.0f, 1.0f, 0.5f)), TransparencyAttrib::make(TransparencyAttrib::M_alpha), @@ -308,7 +308,7 @@ get_occluder_viz_state(CullTraverser *trav, CullTraverserData &data) { CPT(RenderState) OccluderNode:: get_frame_viz_state(CullTraverser *trav, CullTraverserData &data) { static CPT(RenderState) viz_state; - if (viz_state == NULL) { + if (viz_state == nullptr) { viz_state = RenderState::make (ColorAttrib::make_flat(LVecBase4(0.0f, 0.0f, 0.0f, 1.0f)), TextureAttrib::make_off()); diff --git a/panda/src/pgraph/pandaNode.I b/panda/src/pgraph/pandaNode.I index 93bf19cc2d..fcd02ae429 100644 --- a/panda/src/pgraph/pandaNode.I +++ b/panda/src/pgraph/pandaNode.I @@ -32,7 +32,7 @@ INLINE PandaNode *PandaNode:: get_parent(int n, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); CPT(Up) up = cdata->get_up(); - nassertr(n >= 0 && n < (int)up->size(), NULL); + nassertr(n >= 0 && n < (int)up->size(), nullptr); return (*up)[n].get_parent(); } @@ -66,7 +66,7 @@ INLINE PandaNode *PandaNode:: get_child(int n, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); CPT(Down) down = cdata->get_down(); - nassertr(n >= 0 && n < (int)down->size(), NULL); + nassertr(n >= 0 && n < (int)down->size(), nullptr); return (*down)[n].get_child(); } @@ -154,7 +154,7 @@ INLINE PandaNode *PandaNode:: get_stashed(int n, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); CPT(Down) stashed = cdata->get_stashed(); - nassertr(n >= 0 && n < (int)stashed->size(), NULL); + nassertr(n >= 0 && n < (int)stashed->size(), nullptr); return (*stashed)[n].get_child(); } @@ -247,7 +247,7 @@ get_effect(TypeHandle type) const { if (index >= 0) { return cdata->_effects->get_effect(index); } - return NULL; + return nullptr; } /** @@ -496,7 +496,7 @@ get_into_collide_mask() const { */ INLINE void PandaNode:: clear_bounds() { - set_bounds((BoundingVolume *)NULL); + set_bounds(nullptr); } /** @@ -806,7 +806,7 @@ get_parent() const { */ INLINE PandaNode::BoundsData:: BoundsData() : - _internal_bounds(NULL), + _internal_bounds(nullptr), _internal_vertices(0) { ++_internal_bounds_mark; @@ -951,7 +951,7 @@ operator = (PandaNode::Children &&from) noexcept { */ INLINE size_t PandaNode::Children:: get_num_children() const { - nassertr(_down != (Down *)NULL, 0); + nassertr(_down != nullptr, 0); return _down->size(); } @@ -960,8 +960,8 @@ get_num_children() const { */ INLINE PandaNode *PandaNode::Children:: get_child(size_t n) const { - nassertr(_down != (Down *)NULL, NULL); - nassertr(n < (size_t)_down->size(), NULL); + nassertr(_down != nullptr, nullptr); + nassertr(n < (size_t)_down->size(), nullptr); return (*_down)[n].get_child(); } @@ -971,7 +971,7 @@ get_child(size_t n) const { */ INLINE int PandaNode::Children:: get_child_sort(size_t n) const { - nassertr(_down != (Down *)NULL, -1); + nassertr(_down != nullptr, -1); nassertr(n < _down->size(), -1); return (*_down)[n].get_sort(); } @@ -1031,7 +1031,7 @@ operator = (PandaNode::Stashed &&from) noexcept { */ INLINE size_t PandaNode::Stashed:: get_num_stashed() const { - nassertr(_stashed != (Down *)NULL, 0); + nassertr(_stashed != nullptr, 0); return _stashed->size(); } @@ -1040,8 +1040,8 @@ get_num_stashed() const { */ INLINE PandaNode *PandaNode::Stashed:: get_stashed(size_t n) const { - nassertr(_stashed != (Down *)NULL, NULL); - nassertr(n < _stashed->size(), NULL); + nassertr(_stashed != nullptr, nullptr); + nassertr(n < _stashed->size(), nullptr); return (*_stashed)[n].get_child(); } @@ -1051,7 +1051,7 @@ get_stashed(size_t n) const { */ INLINE int PandaNode::Stashed:: get_stashed_sort(size_t n) const { - nassertr(_stashed != (Down *)NULL, -1); + nassertr(_stashed != nullptr, -1); nassertr(n < _stashed->size(), -1); return (*_stashed)[n].get_sort(); } @@ -1111,7 +1111,7 @@ operator = (PandaNode::Parents &&from) noexcept { */ INLINE size_t PandaNode::Parents:: get_num_parents() const { - nassertr(_up != (Up *)NULL, 0); + nassertr(_up != nullptr, 0); return _up->size(); } @@ -1120,8 +1120,8 @@ get_num_parents() const { */ INLINE PandaNode *PandaNode::Parents:: get_parent(size_t n) const { - nassertr(_up != (Up *)NULL, NULL); - nassertr(n < _up->size(), NULL); + nassertr(_up != nullptr, nullptr); + nassertr(n < _up->size(), nullptr); return (*_up)[n].get_parent(); } @@ -1213,8 +1213,8 @@ INLINE PandaNodePipelineReader:: #endif // DO_PIPELINING #ifdef _DEBUG - _node = NULL; - _cdata = NULL; + _node = nullptr; + _cdata = nullptr; #endif // _DEBUG } @@ -1254,7 +1254,7 @@ release() { */ INLINE void PandaNodePipelineReader:: compose_draw_mask(DrawMask &running_draw_mask) const { - nassertv(_cdata != (PandaNode::CData *)NULL); + nassertv(_cdata != nullptr); running_draw_mask = (running_draw_mask & ~_cdata->_draw_control_mask) | (_cdata->_draw_show_mask & _cdata->_draw_control_mask); } @@ -1267,7 +1267,7 @@ compose_draw_mask(DrawMask &running_draw_mask) const { */ INLINE bool PandaNodePipelineReader:: compare_draw_mask(DrawMask running_draw_mask, DrawMask camera_mask) const { - nassertr(_cdata != (PandaNode::CData *)NULL, false); + nassertr(_cdata != nullptr, false); nassertr(_cdata->_last_update == _cdata->_next_update, false); // As a special case, if net_draw_show_mask is all 0, it means either that @@ -1316,7 +1316,7 @@ get_num_parents() const { INLINE PandaNode *PandaNodePipelineReader:: get_parent(int n) const { CPT(PandaNode::Up) up = _cdata->get_up(); - nassertr(n >= 0 && n < (int)up->size(), NULL); + nassertr(n >= 0 && n < (int)up->size(), nullptr); return (*up)[n].get_parent(); } @@ -1347,7 +1347,7 @@ get_num_children() const { INLINE PandaNode *PandaNodePipelineReader:: get_child(int n) const { CPT(PandaNode::Down) down = _cdata->get_down(); - nassertr(n >= 0 && n < (int)down->size(), NULL); + nassertr(n >= 0 && n < (int)down->size(), nullptr); return (*down)[n].get_child(); } @@ -1389,7 +1389,7 @@ get_num_stashed() const { INLINE PandaNode *PandaNodePipelineReader:: get_stashed(int n) const { CPT(PandaNode::Down) stashed = _cdata->get_stashed(); - nassertr(n >= 0 && n < (int)stashed->size(), NULL); + nassertr(n >= 0 && n < (int)stashed->size(), nullptr); return (*stashed)[n].get_child(); } diff --git a/panda/src/pgraph/pandaNode.cxx b/panda/src/pgraph/pandaNode.cxx index 91afd2f768..c6cc323d2a 100644 --- a/panda/src/pgraph/pandaNode.cxx +++ b/panda/src/pgraph/pandaNode.cxx @@ -166,7 +166,7 @@ PandaNode(const PandaNode ©) : cdata->_into_collide_mask = copy_cdata->_into_collide_mask; cdata->_bounds_type = copy_cdata->_bounds_type; cdata->_user_bounds = copy_cdata->_user_bounds; - cdata->_internal_bounds = NULL; + cdata->_internal_bounds = nullptr; cdata->_internal_bounds_computed = UpdateSeq::initial(); cdata->_internal_bounds_mark = UpdateSeq::initial(); ++cdata->_internal_bounds_mark; @@ -333,7 +333,7 @@ combine_with(PandaNode *other) { } // We're something other than an ordinary PandaNode. Don't combine. - return (PandaNode *)NULL; + return nullptr; } /** @@ -523,7 +523,7 @@ count_num_descendants() const { */ void PandaNode:: add_child(PandaNode *child_node, int sort, Thread *current_thread) { - nassertv(child_node != (PandaNode *)NULL); + nassertv(child_node != nullptr); if (!verify_child_no_cycles(child_node)) { // Whoops, adding this child node would introduce a cycle in the scene @@ -596,7 +596,7 @@ remove_child(int child_index, Thread *current_thread) { */ bool PandaNode:: remove_child(PandaNode *child_node, Thread *current_thread) { - nassertr(child_node != (PandaNode *)NULL, false); + nassertr(child_node != nullptr, false); // Make sure the child node is not destructed during the execution of this // method. @@ -633,8 +633,8 @@ remove_child(PandaNode *child_node, Thread *current_thread) { bool PandaNode:: replace_child(PandaNode *orig_child, PandaNode *new_child, Thread *current_thread) { - nassertr(orig_child != (PandaNode *)NULL, false); - nassertr(new_child != (PandaNode *)NULL, false); + nassertr(orig_child != nullptr, false); + nassertr(new_child != nullptr, false); if (orig_child == new_child) { // Trivial no-op. @@ -1182,8 +1182,8 @@ reset_all_prev_transform(Thread *current_thread) { list_node = panda_node->_next; #ifndef NDEBUG - panda_node->_prev = NULL; - panda_node->_next = NULL; + panda_node->_prev = nullptr; + panda_node->_next = nullptr; #endif // NDEBUG panda_node->mark_bam_modified(); } @@ -1768,7 +1768,7 @@ is_scene_root() const { // This function pointer has to be filled in when the global GraphicsEngine // is created, because we can't link with the GraphicsEngine functions // directly. - if (_scene_root_func != (SceneRootFunc *)NULL) { + if (_scene_root_func != nullptr) { return (*_scene_root_func)(this); } return false; @@ -1906,8 +1906,8 @@ set_bounds(const BoundingVolume *volume) { Thread *current_thread = Thread::get_current_thread(); OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) { CDStageWriter cdata(_cycler, pipeline_stage, current_thread); - if (volume == NULL) { - cdata->_user_bounds = NULL; + if (volume == nullptr) { + cdata->_user_bounds = nullptr; } else { cdata->_user_bounds = volume->make_copy(); } @@ -2091,7 +2091,7 @@ is_collision_node() const { */ Light *PandaNode:: as_light() { - return NULL; + return nullptr; } /** @@ -2135,7 +2135,7 @@ get_internal_bounds(int pipeline_stage, Thread *current_thread) const { UpdateSeq mark; { CDStageReader cdata(_cycler, pipeline_stage, current_thread); - if (cdata->_user_bounds != (BoundingVolume *)NULL) { + if (cdata->_user_bounds != nullptr) { return cdata->_user_bounds; } @@ -2152,7 +2152,7 @@ get_internal_bounds(int pipeline_stage, Thread *current_thread) const { int internal_vertices; compute_internal_bounds(internal_bounds, internal_vertices, pipeline_stage, current_thread); - nassertr(!internal_bounds.is_null(), NULL); + nassertr(!internal_bounds.is_null(), nullptr); // Now, acquire the lock, and apply the above-computed bounds. CDStageWriter cdataw(((PandaNode *)this)->_cycler, pipeline_stage); @@ -2373,13 +2373,13 @@ draw_mask_changed() { PT(PandaNode) PandaNode:: r_copy_subgraph(PandaNode::InstanceMap &inst_map, Thread *current_thread) const { PT(PandaNode) copy = make_copy(); - nassertr(copy != (PandaNode *)NULL, NULL); + nassertr(copy != nullptr, nullptr); if (copy->get_type() != get_type()) { pgraph_cat.warning() << "Don't know how to copy nodes of type " << get_type() << "\n"; if (no_unsupported_copy) { - nassertr(false, NULL); + nassertr(false, nullptr); } } @@ -2666,11 +2666,11 @@ find_node_above(PandaNode *node) { PT(NodePathComponent) PandaNode:: attach(NodePathComponent *parent, PandaNode *child_node, int sort, int pipeline_stage, Thread *current_thread) { - if (parent == (NodePathComponent *)NULL) { + if (parent == nullptr) { // Attaching to NULL means to create a new "instance" with no attachments, // and no questions asked. PT(NodePathComponent) child = - new NodePathComponent(child_node, (NodePathComponent *)NULL, + new NodePathComponent(child_node, nullptr, pipeline_stage, current_thread); LightReMutexHolder holder(child_node->_paths_lock); child_node->_paths.insert(child); @@ -2681,7 +2681,7 @@ attach(NodePathComponent *parent, PandaNode *child_node, int sort, // use that same NodePathComponent. PT(NodePathComponent) child = get_component(parent, child_node, pipeline_stage, current_thread); - if (child == (NodePathComponent *)NULL) { + if (child == nullptr) { // The child was not already attached to the parent, so get a new // component. child = get_top_component(child_node, true, pipeline_stage, current_thread); @@ -2700,7 +2700,7 @@ attach(NodePathComponent *parent, PandaNode *child_node, int sort, */ void PandaNode:: detach(NodePathComponent *child, int pipeline_stage, Thread *current_thread) { - nassertv(child != (NodePathComponent *)NULL); + nassertv(child != nullptr); for (int pipeline_stage_i = pipeline_stage; pipeline_stage_i >= 0; @@ -2720,7 +2720,7 @@ detach(NodePathComponent *child, int pipeline_stage, Thread *current_thread) { void PandaNode:: detach_one_stage(NodePathComponent *child, int pipeline_stage, Thread *current_thread) { - nassertv(child != (NodePathComponent *)NULL); + nassertv(child != nullptr); if (child->is_top_node(pipeline_stage, current_thread)) { return; } @@ -2786,7 +2786,7 @@ reparent(NodePathComponent *new_parent, NodePathComponent *child, int sort, bool as_stashed, int pipeline_stage, Thread *current_thread) { bool any_ok = false; - if (new_parent != (NodePathComponent *)NULL && + if (new_parent != nullptr && !new_parent->get_node()->verify_child_no_cycles(child->get_node())) { // Whoops, adding this child node would introduce a cycle in the scene // graph. @@ -2802,7 +2802,7 @@ reparent(NodePathComponent *new_parent, NodePathComponent *child, int sort, } } - if (new_parent != (NodePathComponent *)NULL) { + if (new_parent != nullptr) { new_parent->get_node()->children_changed(); new_parent->get_node()->mark_bam_modified(); } @@ -2825,7 +2825,7 @@ bool PandaNode:: reparent_one_stage(NodePathComponent *new_parent, NodePathComponent *child, int sort, bool as_stashed, int pipeline_stage, Thread *current_thread) { - nassertr(child != (NodePathComponent *)NULL, false); + nassertr(child != nullptr, false); // Keep a reference count to the new parent, since detaching the child might // lose the count. @@ -2835,7 +2835,7 @@ reparent_one_stage(NodePathComponent *new_parent, NodePathComponent *child, detach(child, pipeline_stage, current_thread); } - if (new_parent != (NodePathComponent *)NULL) { + if (new_parent != nullptr) { PandaNode *child_node = child->get_node(); PandaNode *parent_node = new_parent->get_node(); @@ -2887,7 +2887,7 @@ reparent_one_stage(NodePathComponent *new_parent, NodePathComponent *child, PT(NodePathComponent) PandaNode:: get_component(NodePathComponent *parent, PandaNode *child_node, int pipeline_stage, Thread *current_thread) { - nassertr(parent != (NodePathComponent *)NULL, (NodePathComponent *)NULL); + nassertr(parent != nullptr, nullptr); PandaNode *parent_node = parent->get_node(); LightReMutexHolder holder(child_node->_paths_lock); @@ -2916,7 +2916,7 @@ get_component(NodePathComponent *parent, PandaNode *child_node, return child; } else { // They aren't related. Return NULL. - return NULL; + return nullptr; } } @@ -2948,13 +2948,13 @@ get_top_component(PandaNode *child_node, bool force, int pipeline_stage, if (!force) { // If we don't care to force the point, return NULL to indicate there's // not already a top component. - return NULL; + return nullptr; } // We don't already have such a NodePathComponent; create and return a new // one. PT(NodePathComponent) child = - new NodePathComponent(child_node, (NodePathComponent *)NULL, + new NodePathComponent(child_node, nullptr, pipeline_stage, current_thread); child_node->_paths.insert(child); @@ -3169,7 +3169,7 @@ r_list_descendants(ostream &out, int indent_level) const { */ int PandaNode:: do_find_child(PandaNode *node, const PandaNode::Down *down) const { - nassertr(node != (PandaNode *)NULL, -1); + nassertr(node != nullptr, -1); // We have to search for the child by brute force, since we don't know what // sort index it was added as. @@ -3232,7 +3232,7 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe << "\n"; } CPT(RenderAttrib) off_clip_planes = cdata->_state->get_attrib(ClipPlaneAttrib::get_class_slot()); - if (off_clip_planes == (RenderAttrib *)NULL) { + if (off_clip_planes == nullptr) { off_clip_planes = ClipPlaneAttrib::make(); } @@ -3261,7 +3261,7 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe int child_volumes_i = 0; bool all_box = true; - CPT(BoundingVolume) internal_bounds = NULL; + CPT(BoundingVolume) internal_bounds = nullptr; if (update_bounds) { child_volumes = (const BoundingVolume **)alloca(sizeof(BoundingVolume *) * (num_children + 1)); @@ -3273,7 +3273,7 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe #endif nassertr(child_volumes_i < num_children + 1, CDStageWriter(_cycler, pipeline_stage, cdata)); child_volumes[child_volumes_i++] = internal_bounds; - if (internal_bounds->as_bounding_box() == NULL) { + if (internal_bounds->as_bounding_box() == nullptr) { all_box = false; } } @@ -3371,7 +3371,7 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe #endif nassertr(child_volumes_i < num_children + 1, CDStageWriter(_cycler, pipeline_stage, cdata)); child_volumes[child_volumes_i++] = child_cdataw->_external_bounds; - if (child_cdataw->_external_bounds->as_bounding_box() == NULL) { + if (child_cdataw->_external_bounds->as_bounding_box() == nullptr) { all_box = false; } } @@ -3426,7 +3426,7 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe #endif nassertr(child_volumes_i < num_children + 1, CDStageWriter(_cycler, pipeline_stage, cdata)); child_volumes[child_volumes_i++] = child_cdata->_external_bounds; - if (child_cdata->_external_bounds->as_bounding_box() == NULL) { + if (child_cdata->_external_bounds->as_bounding_box() == nullptr) { all_box = false; } } @@ -3668,7 +3668,7 @@ CData() : _draw_show_mask(DrawMask::all_on()), _into_collide_mask(CollideMask::all_off()), _bounds_type(BoundingVolume::BT_default), - _user_bounds(NULL), + _user_bounds(nullptr), _final_bounds(false), _fancy_bits(0), @@ -4075,7 +4075,7 @@ fillin_down_list(PandaNode::Down &down_list, const string &tag, for (int i = 0; i < num_children; i++) { manager->read_pointer(scan); int sort = scan.get_int32(); - DownConnection connection(NULL, sort); + DownConnection connection(nullptr, sort); new_down_list.push_back(connection); } @@ -4104,7 +4104,7 @@ check_cached(bool update_bounds) const { #ifdef DO_PIPELINING node_unref_delete((CycleData *)_cdata); #endif // DO_PIPELINING - ((PandaNodePipelineReader *)this)->_cdata = NULL; + ((PandaNodePipelineReader *)this)->_cdata = nullptr; int pipeline_stage = _current_thread->get_pipeline_stage(); PandaNode::CDLockedStageReader fresh_cdata(_node->_cycler, pipeline_stage, _current_thread); if (fresh_cdata->_last_update == fresh_cdata->_next_update && diff --git a/panda/src/pgraph/pandaNodeChain.I b/panda/src/pgraph/pandaNodeChain.I index 8a401d3a80..c53beec7e7 100644 --- a/panda/src/pgraph/pandaNodeChain.I +++ b/panda/src/pgraph/pandaNodeChain.I @@ -26,6 +26,6 @@ PandaNodeChain(const char *lock_name) : */ INLINE PandaNodeChain:: ~PandaNodeChain() { - _next = NULL; - _prev = NULL; + _next = nullptr; + _prev = nullptr; } diff --git a/panda/src/pgraph/pandaNode_ext.cxx b/panda/src/pgraph/pandaNode_ext.cxx index 4f0a1b4e8d..bc6427b1d0 100644 --- a/panda/src/pgraph/pandaNode_ext.cxx +++ b/panda/src/pgraph/pandaNode_ext.cxx @@ -48,7 +48,7 @@ __deepcopy__(PyObject *self, PyObject *memo) const { // Borrowed reference. PyObject *dupe = PyDict_GetItem(memo, self); - if (dupe != NULL) { + if (dupe != nullptr) { // Already in the memo dictionary. Py_INCREF(dupe); return dupe; @@ -64,7 +64,7 @@ __deepcopy__(PyObject *self, PyObject *memo) const { if (PyDict_SetItem(memo, self, dupe) != 0) { Py_DECREF(dupe); - return NULL; + return nullptr; } return dupe; @@ -120,14 +120,14 @@ set_python_tag(PyObject *key, PyObject *value) { */ PyObject *Extension:: get_python_tag(PyObject *key) const { - if (_this->_python_tag_data == NULL) { + if (_this->_python_tag_data == nullptr) { Py_INCREF(Py_None); return Py_None; } PyObject *dict = ((PythonTagDataImpl *)_this->_python_tag_data.p())->_dict; PyObject *value = PyDict_GetItem(dict, key); - if (value == NULL) { + if (value == nullptr) { value = Py_None; } // PyDict_GetItem returns a borrowed reference. @@ -142,12 +142,12 @@ get_python_tag(PyObject *key) const { */ bool Extension:: has_python_tag(PyObject *key) const { - if (_this->_python_tag_data == NULL) { + if (_this->_python_tag_data == nullptr) { return false; } PyObject *dict = ((PythonTagDataImpl *)_this->_python_tag_data.p())->_dict; - return (PyDict_GetItem(dict, key) != NULL); + return (PyDict_GetItem(dict, key) != nullptr); } /** @@ -157,12 +157,12 @@ has_python_tag(PyObject *key) const { */ void Extension:: clear_python_tag(PyObject *key) { - if (_this->_python_tag_data == NULL) { + if (_this->_python_tag_data == nullptr) { return; } PyObject *dict = do_get_python_tags(); - if (PyDict_GetItem(dict, key) != NULL) { + if (PyDict_GetItem(dict, key) != nullptr) { PyDict_DelItem(dict, key); } } @@ -172,7 +172,7 @@ clear_python_tag(PyObject *key) { */ PyObject *Extension:: get_python_tag_keys() const { - if (_this->_python_tag_data == NULL) { + if (_this->_python_tag_data == nullptr) { return PyTuple_New(0); } @@ -190,7 +190,7 @@ __traverse__(visitproc visit, void *arg) { // quite expensive, so I'd rather not do it unless we had some optimization // that would allow us to quickly find out whether there are children with // Python tags. - if (_this->_python_tag_data != NULL) { + if (_this->_python_tag_data != nullptr) { Py_VISIT(((PythonTagDataImpl *)_this->_python_tag_data.p())->_dict); } return 0; @@ -201,7 +201,7 @@ __traverse__(visitproc visit, void *arg) { */ PyObject *Extension:: do_get_python_tags() { - if (_this->_python_tag_data == NULL) { + if (_this->_python_tag_data == nullptr) { _this->_python_tag_data = new PythonTagDataImpl; } else if (_this->_python_tag_data->get_ref_count() > 1) { diff --git a/panda/src/pgraph/paramNodePath.cxx b/panda/src/pgraph/paramNodePath.cxx index a620144a14..32d5aeb585 100644 --- a/panda/src/pgraph/paramNodePath.cxx +++ b/panda/src/pgraph/paramNodePath.cxx @@ -45,7 +45,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { // Before bam 6.40, we did not support writing NodePaths. Instaed, we // write the PandaNode pointer and pray there is an unambiguous path. if (_node_path.is_empty()) { - manager->write_pointer(dg, NULL); + manager->write_pointer(dg, nullptr); } else { manager->write_pointer(dg, _node_path.node()); } diff --git a/panda/src/pgraph/planeNode.I b/panda/src/pgraph/planeNode.I index e3983c1305..fd4e8d4634 100644 --- a/panda/src/pgraph/planeNode.I +++ b/panda/src/pgraph/planeNode.I @@ -42,8 +42,8 @@ set_plane(const LPlane &plane) { CDWriter cdata(_cycler); if (cdata->_plane != plane) { cdata->_plane = plane; - cdata->_front_viz = NULL; - cdata->_back_viz = NULL; + cdata->_front_viz = nullptr; + cdata->_back_viz = nullptr; } } @@ -65,8 +65,8 @@ set_viz_scale(PN_stdfloat viz_scale) { CDWriter cdata(_cycler); if (cdata->_viz_scale != viz_scale) { cdata->_viz_scale = viz_scale; - cdata->_front_viz = NULL; - cdata->_back_viz = NULL; + cdata->_front_viz = nullptr; + cdata->_back_viz = nullptr; } } diff --git a/panda/src/pgraph/planeNode.cxx b/panda/src/pgraph/planeNode.cxx index c096eaeb49..2af7609809 100644 --- a/panda/src/pgraph/planeNode.cxx +++ b/panda/src/pgraph/planeNode.cxx @@ -112,8 +112,8 @@ xform(const LMatrix4 &mat) { PandaNode::xform(mat); CDWriter cdata(_cycler); cdata->_plane = cdata->_plane * mat; - cdata->_front_viz = NULL; - cdata->_back_viz = NULL; + cdata->_front_viz = nullptr; + cdata->_back_viz = nullptr; } /** @@ -186,7 +186,7 @@ get_viz(CullTraverser *trav, CullTraverserData &data) { LPlane eye_plane = cdata->_plane * data.get_modelview_transform(trav)->get_mat(); bool front = (eye_plane.dist_to_plane(lens->get_nodal_point()) >= 0.0f); - if (cdata->_front_viz != (Geom *)NULL) { + if (cdata->_front_viz != nullptr) { return front ? cdata->_front_viz : cdata->_back_viz; } diff --git a/panda/src/pgraph/polylightNode.I b/panda/src/pgraph/polylightNode.I index 7a4fcb5899..26eafa9898 100644 --- a/panda/src/pgraph/polylightNode.I +++ b/panda/src/pgraph/polylightNode.I @@ -322,7 +322,7 @@ get_color_scenegraph() const { const RenderAttrib *attrib = PandaNode::get_attrib(ColorAttrib::get_class_type()); - if (attrib != (const RenderAttrib *)NULL) { + if (attrib != nullptr) { const ColorAttrib *ca = DCAST(ColorAttrib, attrib); if (ca->get_color_type() == ColorAttrib::T_flat) { return ca->get_color(); diff --git a/panda/src/pgraph/portalClipper.cxx b/panda/src/pgraph/portalClipper.cxx index f6d45aab8f..c0fe73f73f 100644 --- a/panda/src/pgraph/portalClipper.cxx +++ b/panda/src/pgraph/portalClipper.cxx @@ -39,7 +39,7 @@ PortalClipper:: PortalClipper(GeometricBoundingVolume *frustum, SceneSetup *scene_setup): _reduced_viewport_min(-1,-1), _reduced_viewport_max(1,1), -_clip_state(NULL) +_clip_state(nullptr) { _previous = new GeomNode("my_frustum"); @@ -140,7 +140,7 @@ draw_current_portal() void PortalClipper:: draw_lines() { if (!_list.empty()) { - _created_data = NULL; + _created_data = nullptr; PT(GeomVertexData) vdata = new GeomVertexData ("portal", GeomVertexFormat::get_v3cp(), Geom::UH_static); @@ -200,7 +200,7 @@ prepare_portal(const NodePath &node_path) { // Get the Portal Node from this node_path PandaNode *node = node_path.node(); - _portal_node = NULL; + _portal_node = nullptr; if (node->is_of_type(PortalNode::get_class_type())) { _portal_node = DCAST(PortalNode, node); } diff --git a/panda/src/pgraph/portalNode.cxx b/panda/src/pgraph/portalNode.cxx index dccfef23c4..8ddb409f09 100644 --- a/panda/src/pgraph/portalNode.cxx +++ b/panda/src/pgraph/portalNode.cxx @@ -180,7 +180,7 @@ combine_with(PandaNode *other) { } // Two PortalNodes with different names can't combine. - return (PandaNode *)NULL; + return nullptr; } return PandaNode::combine_with(other); @@ -273,7 +273,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // undo parent clip state and compose our new clip state ito the new // state - if (old_clip_state != NULL) { + if (old_clip_state != nullptr) { next_state = old_clip_state->invert_compose(next_state); portal_cat.spam() << "next state after removing parent state " << *next_state << endl; } @@ -376,8 +376,8 @@ CPT(RenderState) PortalNode:: get_last_pos_state() { // Once someone asks for this pointer, we hold its reference count and never // free it. - static CPT(RenderState) state = (const RenderState *)NULL; - if (state == (const RenderState *)NULL) { + static CPT(RenderState) state = nullptr; + if (state == nullptr) { state = RenderState::make (ColorScaleAttrib::make(LVecBase4(1.0f, 1.0f, 1.0f, 0.5f)), TransparencyAttrib::make(TransparencyAttrib::M_alpha)); diff --git a/panda/src/pgraph/renderAttrib.cxx b/panda/src/pgraph/renderAttrib.cxx index 45f8ea2fb9..66c507c1c8 100644 --- a/panda/src/pgraph/renderAttrib.cxx +++ b/panda/src/pgraph/renderAttrib.cxx @@ -18,8 +18,8 @@ #include "lightReMutexHolder.h" #include "pStatTimer.h" -LightReMutex *RenderAttrib::_attribs_lock = NULL; -RenderAttrib::Attribs *RenderAttrib::_attribs = NULL; +LightReMutex *RenderAttrib::_attribs_lock = nullptr; +RenderAttrib::Attribs *RenderAttrib::_attribs = nullptr; TypeHandle RenderAttrib::_type_handle; size_t RenderAttrib::_garbage_index = 0; @@ -31,7 +31,7 @@ PStatCollector RenderAttrib::_garbage_collect_pcollector("*:State Cache:Garbage */ RenderAttrib:: RenderAttrib() { - if (_attribs == (Attribs *)NULL) { + if (_attribs == nullptr) { init_attribs(); } _saved_entry = -1; @@ -155,7 +155,7 @@ int RenderAttrib:: get_num_attribs() { LightReMutexHolder holder(*_attribs_lock); - if (_attribs == (Attribs *)NULL) { + if (_attribs == nullptr) { return 0; } return _attribs->get_num_entries(); @@ -184,7 +184,7 @@ list_attribs(ostream &out) { */ int RenderAttrib:: garbage_collect() { - if (_attribs == (Attribs *)NULL || !garbage_collect_states) { + if (_attribs == nullptr || !garbage_collect_states) { return 0; } LightReMutexHolder holder(*_attribs_lock); @@ -313,7 +313,7 @@ validate_attribs() { */ CPT(RenderAttrib) RenderAttrib:: return_new(RenderAttrib *attrib) { - nassertr(attrib != (RenderAttrib *)NULL, attrib); + nassertr(attrib != nullptr, attrib); if (!uniquify_attribs) { attrib->calc_hash(); return attrib; @@ -334,7 +334,7 @@ return_new(RenderAttrib *attrib) { */ CPT(RenderAttrib) RenderAttrib:: return_unique(RenderAttrib *attrib) { - nassertr(attrib != (RenderAttrib *)NULL, attrib); + nassertr(attrib != nullptr, attrib); attrib->calc_hash(); diff --git a/panda/src/pgraph/renderAttribRegistry.I b/panda/src/pgraph/renderAttribRegistry.I index 5ad950dd4d..e90c306821 100644 --- a/panda/src/pgraph/renderAttribRegistry.I +++ b/panda/src/pgraph/renderAttribRegistry.I @@ -86,7 +86,7 @@ get_sorted_slot(int n) const { */ INLINE RenderAttribRegistry *RenderAttribRegistry:: get_global_ptr() { - if (_global_ptr == (RenderAttribRegistry *)NULL) { + if (_global_ptr == nullptr) { init_global_ptr(); } return _global_ptr; diff --git a/panda/src/pgraph/renderAttribRegistry.cxx b/panda/src/pgraph/renderAttribRegistry.cxx index ba3cc9a3b6..939f9753f7 100644 --- a/panda/src/pgraph/renderAttribRegistry.cxx +++ b/panda/src/pgraph/renderAttribRegistry.cxx @@ -28,7 +28,7 @@ RenderAttribRegistry() { // Reserve slot 0 for TypeHandle::none(), and for types that exceed // max_slots. - _registry.push_back(RegistryNode(TypeHandle::none(), 0, NULL)); + _registry.push_back(RegistryNode(TypeHandle::none(), 0, nullptr)); } /** @@ -86,7 +86,7 @@ register_slot(TypeHandle type_handle, int sort, RenderAttrib *default_attrib) { // it even if the state cache is disabled, because we can't read the // state_cache config variable yet at this time. It probably doesn't hurt // to have these 32 entries around in the attrib cache. - if (default_attrib != (RenderAttrib *)NULL) { + if (default_attrib != nullptr) { default_attrib->calc_hash(); if (default_attrib->_saved_entry == -1) { diff --git a/panda/src/pgraph/renderEffect.cxx b/panda/src/pgraph/renderEffect.cxx index 585db7db26..583c04d812 100644 --- a/panda/src/pgraph/renderEffect.cxx +++ b/panda/src/pgraph/renderEffect.cxx @@ -16,7 +16,7 @@ #include "indent.h" #include "config_pgraph.h" -RenderEffect::Effects *RenderEffect::_effects = NULL; +RenderEffect::Effects *RenderEffect::_effects = nullptr; TypeHandle RenderEffect::_type_handle; /** @@ -24,7 +24,7 @@ TypeHandle RenderEffect::_type_handle; */ RenderEffect:: RenderEffect() { - if (_effects == (Effects *)NULL) { + if (_effects == nullptr) { // Make sure the global _effects map is allocated. This only has to be // done once. We could make this map static, but then we run into // problems if anyone creates a RenderState object at static init time; it @@ -169,7 +169,7 @@ write(ostream &out, int indent_level) const { */ int RenderEffect:: get_num_effects() { - if (_effects == (Effects *)NULL) { + if (_effects == nullptr) { return 0; } return _effects->size(); @@ -231,7 +231,7 @@ validate_effects() { */ CPT(RenderEffect) RenderEffect:: return_new(RenderEffect *effect) { - nassertr(effect != (RenderEffect *)NULL, effect); + nassertr(effect != nullptr, effect); // This should be a newly allocated pointer, not one that was used for // anything else. diff --git a/panda/src/pgraph/renderEffects.I b/panda/src/pgraph/renderEffects.I index 23c00f9a3b..a0ae6af279 100644 --- a/panda/src/pgraph/renderEffects.I +++ b/panda/src/pgraph/renderEffects.I @@ -37,7 +37,7 @@ Effect() { INLINE RenderEffects::Effect:: Effect(TypeHandle type) : _type(type), - _effect(NULL) + _effect(nullptr) { } diff --git a/panda/src/pgraph/renderEffects.cxx b/panda/src/pgraph/renderEffects.cxx index 139eb9e00f..4ef038625d 100644 --- a/panda/src/pgraph/renderEffects.cxx +++ b/panda/src/pgraph/renderEffects.cxx @@ -29,8 +29,8 @@ #include -LightReMutex *RenderEffects::_states_lock = NULL; -RenderEffects::States *RenderEffects::_states = NULL; +LightReMutex *RenderEffects::_states_lock = nullptr; +RenderEffects::States *RenderEffects::_states = nullptr; CPT(RenderEffects) RenderEffects::_empty_state; TypeHandle RenderEffects::_type_handle; @@ -41,7 +41,7 @@ TypeHandle RenderEffects::_type_handle; */ RenderEffects:: RenderEffects() : _lock("RenderEffects") { - if (_states == (States *)NULL) { + if (_states == nullptr) { init_states(); } _saved_entry = _states->end(); @@ -176,7 +176,7 @@ CPT(RenderEffects) RenderEffects:: make_empty() { // The empty state is asked for so often, we make it a special case and // store a pointer forever once we find it the first time. - if (_empty_state == (RenderEffects *)NULL) { + if (_empty_state == nullptr) { RenderEffects *state = new RenderEffects; _empty_state = return_new(state); } @@ -315,7 +315,7 @@ get_effect(TypeHandle type) const { if (ai != _effects.end()) { return (*ai)._effect; } - return NULL; + return nullptr; } /** @@ -387,7 +387,7 @@ write(ostream &out, int indent_level) const { */ int RenderEffects:: get_num_states() { - if (_states == (States *)NULL) { + if (_states == nullptr) { return 0; } LightReMutexHolder holder(*_states_lock); @@ -514,7 +514,7 @@ init_states() { */ CPT(RenderEffects) RenderEffects:: return_new(RenderEffects *state) { - nassertr(state != (RenderEffects *)NULL, state); + nassertr(state != nullptr, state); #ifndef NDEBUG if (!state_cache) { @@ -580,7 +580,7 @@ determine_decal() { } const RenderEffect *effect = get_effect(DecalEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { _flags |= F_has_decal; } _flags |= F_checked_decal; @@ -598,7 +598,7 @@ determine_show_bounds() { } const RenderEffect *effect = get_effect(ShowBoundsEffect::get_class_type()); - if (effect != (const RenderEffect *)NULL) { + if (effect != nullptr) { _flags |= F_has_show_bounds; const ShowBoundsEffect *sba = DCAST(ShowBoundsEffect, effect); if (sba->get_tight()) { @@ -694,7 +694,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { Effect &effect = _effects[i]; effect._effect = DCAST(RenderEffect, p_list[pi++]); - if (effect._effect == (RenderEffect *)NULL) { + if (effect._effect == nullptr) { // Remove this bogus RenderEffect pointer (it must have been from an // unwritable class). _effects.erase(_effects.begin() + i); diff --git a/panda/src/pgraph/renderState.I b/panda/src/pgraph/renderState.I index 185b18b24d..faf68f2fe2 100644 --- a/panda/src/pgraph/renderState.I +++ b/panda/src/pgraph/renderState.I @@ -67,7 +67,7 @@ remove_attrib(TypeHandle type) const { */ INLINE bool RenderState:: has_attrib(TypeHandle type) const { - return get_attrib(type) != (RenderAttrib *)NULL; + return get_attrib(type) != nullptr; } /** @@ -76,7 +76,7 @@ has_attrib(TypeHandle type) const { */ INLINE bool RenderState:: has_attrib(int slot) const { - return get_attrib(slot) != (RenderAttrib *)NULL; + return get_attrib(slot) != nullptr; } /** @@ -105,7 +105,7 @@ get_attrib(int slot) const { */ INLINE const RenderAttrib *RenderState:: get_attrib_def(int slot) const { - if (_attributes[slot]._attrib != (RenderAttrib *)NULL) { + if (_attributes[slot]._attrib != nullptr) { return _attributes[slot]._attrib; } RenderAttribRegistry *reg = RenderAttribRegistry::quick_get_global_ptr(); @@ -448,9 +448,9 @@ operator = (const Attribute ©) { INLINE int RenderState::Attribute:: compare_to(const Attribute &other) const { if (_attrib != other._attrib) { - if (_attrib == NULL) { + if (_attrib == nullptr) { return -1; - } else if (other._attrib == NULL) { + } else if (other._attrib == nullptr) { return 1; } @@ -490,7 +490,7 @@ template INLINE bool RenderState:: get_attrib(const AttribType *&attrib) const { attrib = (const AttribType *)get_attrib((int)AttribType::get_class_slot()); - return (attrib != (const AttribType *)NULL); + return (attrib != nullptr); } /** diff --git a/panda/src/pgraph/renderState.cxx b/panda/src/pgraph/renderState.cxx index a4d2952e50..1a8a3f0a56 100644 --- a/panda/src/pgraph/renderState.cxx +++ b/panda/src/pgraph/renderState.cxx @@ -36,9 +36,9 @@ #include "thread.h" #include "renderAttribRegistry.h" -LightReMutex *RenderState::_states_lock = NULL; -RenderState::States *RenderState::_states = NULL; -const RenderState *RenderState::_empty_state = NULL; +LightReMutex *RenderState::_states_lock = nullptr; +RenderState::States *RenderState::_states = nullptr; +const RenderState *RenderState::_empty_state = nullptr; UpdateSeq RenderState::_last_cycle_detect; size_t RenderState::_garbage_index = 0; @@ -66,14 +66,14 @@ RenderState() : _flags(0), _lock("RenderState") { - if (_states == (States *)NULL) { + if (_states == nullptr) { init_states(); } _saved_entry = -1; _last_mi = -1; _cache_stats.add_num_states(1); - _read_overrides = NULL; - _generated_shader = NULL; + _read_overrides = nullptr; + _generated_shader = nullptr; #ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, this); @@ -97,8 +97,8 @@ RenderState(const RenderState ©) : _saved_entry = -1; _last_mi = -1; _cache_stats.add_num_states(1); - _read_overrides = NULL; - _generated_shader = NULL; + _read_overrides = nullptr; + _generated_shader = nullptr; #ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, this); @@ -169,7 +169,7 @@ compare_sort(const RenderState &other) const { int num_sorted_slots = reg->get_num_sorted_slots(); for (int n = 0; n < num_sorted_slots; ++n) { int slot = reg->get_sorted_slot(n); - nassertr((_attributes[slot]._attrib != NULL) == _filled_slots.get_bit(slot), 0); + nassertr((_attributes[slot]._attrib != nullptr) == _filled_slots.get_bit(slot), 0); const RenderAttrib *a = _attributes[slot]._attrib; const RenderAttrib *b = other._attributes[slot]._attrib; @@ -214,7 +214,7 @@ cull_callback(CullTraverser *trav, const CullTraverserData &data) const { int slot = mask.get_lowest_on_bit(); while (slot >= 0) { const Attribute &attrib = _attributes[slot]; - nassertr(attrib._attrib != NULL, false); + nassertr(attrib._attrib != nullptr, false); if (!attrib._attrib->cull_callback(trav, data)) { return false; } @@ -362,7 +362,7 @@ compose(const RenderState *other) const { int index = _composition_cache.find(other); if (index != -1) { Composition &comp = ((RenderState *)this)->_composition_cache.modify_data(index); - if (comp._result == (const RenderState *)NULL) { + if (comp._result == nullptr) { // Well, it wasn't cached already, but we already had an entry (probably // created for the reverse direction), so use the same entry to store // the new result. @@ -397,7 +397,7 @@ compose(const RenderState *other) const { if (other != this) { _cache_stats.add_total_size(1); _cache_stats.inc_adds(other->_composition_cache.is_empty()); - ((RenderState *)other)->_composition_cache[this]._result = NULL; + ((RenderState *)other)->_composition_cache[this]._result = nullptr; } if (result != (const RenderState *)this) { @@ -451,7 +451,7 @@ invert_compose(const RenderState *other) const { int index = _invert_composition_cache.find(other); if (index != -1) { Composition &comp = ((RenderState *)this)->_invert_composition_cache.modify_data(index); - if (comp._result == (const RenderState *)NULL) { + if (comp._result == nullptr) { // Well, it wasn't cached already, but we already had an entry (probably // created for the reverse direction), so use the same entry to store // the new result. @@ -485,7 +485,7 @@ invert_compose(const RenderState *other) const { if (other != this) { _cache_stats.add_total_size(1); _cache_stats.inc_adds(other->_invert_composition_cache.is_empty()); - ((RenderState *)other)->_invert_composition_cache[this]._result = NULL; + ((RenderState *)other)->_invert_composition_cache[this]._result = nullptr; } if (result != (const RenderState *)this) { @@ -559,7 +559,7 @@ set_attrib(const RenderAttrib *attrib, int override) const { */ CPT(RenderState) RenderState:: remove_attrib(int slot) const { - if (_attributes[slot]._attrib == NULL) { + if (_attributes[slot]._attrib == nullptr) { // Already removed. return this; } @@ -570,7 +570,7 @@ remove_attrib(int slot) const { } RenderState *new_state = new RenderState(*this); - new_state->_attributes[slot].set(NULL, 0); + new_state->_attributes[slot].set(nullptr, 0); new_state->_filled_slots.clear_bit(slot); return return_new(new_state); } @@ -589,7 +589,7 @@ adjust_all_priorities(int adjustment) const { int slot = mask.get_lowest_on_bit(); while (slot >= 0) { Attribute &attrib = new_state->_attributes[slot]; - nassertr(attrib._attrib != (RenderAttrib *)NULL, this); + nassertr(attrib._attrib != nullptr, this); attrib._override = max(attrib._override + adjustment, 0); mask.clear_bit(slot); @@ -664,7 +664,7 @@ output(ostream &out) const { int slot = mask.get_lowest_on_bit(); while (slot >= 0) { const Attribute &attrib = _attributes[slot]; - nassertv(attrib._attrib != (RenderAttrib *)NULL); + nassertv(attrib._attrib != nullptr); out << sep << attrib._attrib->get_type(); sep = " "; @@ -689,7 +689,7 @@ write(ostream &out, int indent_level) const { int slot = mask.get_lowest_on_bit(); while (slot >= 0) { const Attribute &attrib = _attributes[slot]; - nassertv(attrib._attrib != (RenderAttrib *)NULL); + nassertv(attrib._attrib != nullptr); attrib._attrib->write(out, indent_level); mask.clear_bit(slot); @@ -714,7 +714,7 @@ get_max_priority() { */ int RenderState:: get_num_states() { - if (_states == (States *)NULL) { + if (_states == nullptr) { return 0; } LightReMutexHolder holder(*_states_lock); @@ -736,7 +736,7 @@ get_num_states() { */ int RenderState:: get_num_unused_states() { - if (_states == (States *)NULL) { + if (_states == nullptr) { return 0; } LightReMutexHolder holder(*_states_lock); @@ -754,7 +754,7 @@ get_num_unused_states() { size_t cache_size = state->_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const RenderState *result = state->_composition_cache.get_data(i)._result; - if (result != (const RenderState *)NULL && result != state) { + if (result != nullptr && result != state) { // Here's a RenderState that's recorded in the cache. Count it. pair ir = state_count.insert(StateCount::value_type(result, 1)); @@ -768,7 +768,7 @@ get_num_unused_states() { cache_size = state->_invert_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const RenderState *result = state->_invert_composition_cache.get_data(i)._result; - if (result != (const RenderState *)NULL && result != state) { + if (result != nullptr && result != state) { pair ir = state_count.insert(StateCount::value_type(result, 1)); if (!ir.second) { @@ -819,7 +819,7 @@ get_num_unused_states() { */ int RenderState:: clear_cache() { - if (_states == (States *)NULL) { + if (_states == nullptr) { return 0; } LightReMutexHolder holder(*_states_lock); @@ -852,7 +852,7 @@ clear_cache() { size_t cache_size = (int)state->_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const RenderState *result = state->_composition_cache.get_data(i)._result; - if (result != (const RenderState *)NULL && result != state) { + if (result != nullptr && result != state) { result->cache_unref(); nassertr(result->get_ref_count() > 0, 0); } @@ -863,7 +863,7 @@ clear_cache() { cache_size = (int)state->_invert_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const RenderState *result = state->_invert_composition_cache.get_data(i)._result; - if (result != (const RenderState *)NULL && result != state) { + if (result != nullptr && result != state) { result->cache_unref(); nassertr(result->get_ref_count() > 0, 0); } @@ -893,7 +893,7 @@ int RenderState:: garbage_collect() { int num_attribs = RenderAttrib::garbage_collect(); - if (_states == (States *)NULL || !garbage_collect_states) { + if (_states == nullptr || !garbage_collect_states) { return num_attribs; } @@ -999,7 +999,7 @@ clear_munger_cache() { */ void RenderState:: list_cycles(ostream &out) { - if (_states == (States *)NULL) { + if (_states == nullptr) { return; } LightReMutexHolder holder(*_states_lock); @@ -1076,7 +1076,7 @@ list_cycles(ostream &out) { */ void RenderState:: list_states(ostream &out) { - if (_states == (States *)NULL) { + if (_states == nullptr) { out << "0 states:\n"; return; } @@ -1098,7 +1098,7 @@ list_states(ostream &out) { */ bool RenderState:: validate_states() { - if (_states == (States *)NULL) { + if (_states == nullptr) { return true; } @@ -1194,7 +1194,7 @@ validate_filled_slots() const { int max_slots = reg->get_max_slots(); for (int slot = 1; slot < max_slots; ++slot) { const Attribute &attribute = _attributes[slot]; - if (attribute._attrib != (RenderAttrib *)NULL) { + if (attribute._attrib != nullptr) { mask.set_bit(slot); } } @@ -1213,7 +1213,7 @@ do_calc_hash() { int slot = mask.get_lowest_on_bit(); while (slot >= 0) { const Attribute &attrib = _attributes[slot]; - nassertv(attrib._attrib != (RenderAttrib *)NULL); + nassertv(attrib._attrib != nullptr); _hash = pointer_hash::add_hash(_hash, attrib._attrib); _hash = int_hash::add_hash(_hash, attrib._override); @@ -1233,12 +1233,12 @@ do_calc_hash() { */ CPT(RenderState) RenderState:: return_new(RenderState *state) { - nassertr(state != (RenderState *)NULL, state); + nassertr(state != nullptr, state); // Make sure we don't have anything in the 0 slot. If we did, that would // indicate an uninitialized slot number. #ifndef NDEBUG - if (state->_attributes[0]._attrib != (RenderAttrib *)NULL) { + if (state->_attributes[0]._attrib != nullptr) { const RenderAttrib *attrib = state->_attributes[0]._attrib; if (attrib->get_type() == TypeHandle::none()) { ((RenderAttrib *)attrib)->force_init_type(); @@ -1255,7 +1255,7 @@ return_new(RenderState *state) { } } #endif - state->_attributes[0]._attrib = NULL; + state->_attributes[0]._attrib = nullptr; state->_filled_slots.clear_bit(0); #ifndef NDEBUG @@ -1279,7 +1279,7 @@ return_new(RenderState *state) { */ CPT(RenderState) RenderState:: return_unique(RenderState *state) { - nassertr(state != (RenderState *)NULL, NULL); + nassertr(state != nullptr, nullptr); if (!state_cache) { return state; @@ -1306,7 +1306,7 @@ return_unique(RenderState *state) { int slot = mask.get_lowest_on_bit(); while (slot >= 0) { Attribute &attrib = state->_attributes[slot]; - nassertd(attrib._attrib != (RenderAttrib *)NULL) continue; + nassertd(attrib._attrib != nullptr) continue; attrib._attrib = attrib._attrib->get_unique(); mask.clear_bit(slot); slot = mask.get_lowest_on_bit(); @@ -1357,12 +1357,12 @@ do_compose(const RenderState *other) const { const Attribute &b = other->_attributes[slot]; Attribute &result = new_state->_attributes[slot]; - if (a._attrib == NULL) { - nassertr(b._attrib != NULL, this); + if (a._attrib == nullptr) { + nassertr(b._attrib != nullptr, this); // B wins. result = b; - } else if (b._attrib == NULL) { + } else if (b._attrib == nullptr) { // A wins. result = a; @@ -1411,12 +1411,12 @@ do_invert_compose(const RenderState *other) const { const Attribute &b = other->_attributes[slot]; Attribute &result = new_state->_attributes[slot]; - if (a._attrib == NULL) { - nassertr(b._attrib != NULL, this); + if (a._attrib == nullptr) { + nassertr(b._attrib != nullptr, this); // B wins. result = b; - } else if (b._attrib == NULL) { + } else if (b._attrib == nullptr) { // A wins. Invert it. RenderAttribRegistry *reg = RenderAttribRegistry::quick_get_global_ptr(); result.set(a._attrib->invert_compose(reg->get_slot_default(slot)), 0); @@ -1441,7 +1441,7 @@ detect_and_break_cycles() { PStatTimer timer(_state_break_cycles_pcollector); ++_last_cycle_detect; - if (r_detect_cycles(this, this, 1, _last_cycle_detect, NULL)) { + if (r_detect_cycles(this, this, 1, _last_cycle_detect, nullptr)) { // Ok, we have a cycle. This will be a leak unless we break the cycle by // freeing the cache on this object. if (pgraph_cat.is_debug()) { @@ -1452,7 +1452,7 @@ detect_and_break_cycles() { ((RenderState *)this)->remove_cache_pointers(); } else { ++_last_cycle_detect; - if (r_detect_reverse_cycles(this, this, 1, _last_cycle_detect, NULL)) { + if (r_detect_reverse_cycles(this, this, 1, _last_cycle_detect, nullptr)) { if (pgraph_cat.is_debug()) { pgraph_cat.debug() << "Breaking cycle involving " << (*this) << "\n"; @@ -1489,11 +1489,11 @@ r_detect_cycles(const RenderState *start_state, size_t cache_size = current_state->_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const RenderState *result = current_state->_composition_cache.get_data(i)._result; - if (result != (const RenderState *)NULL) { + if (result != nullptr) { if (r_detect_cycles(start_state, result, length + 1, this_seq, cycle_desc)) { // Cycle detected. - if (cycle_desc != (CompositionCycleDesc *)NULL) { + if (cycle_desc != nullptr) { const RenderState *other = current_state->_composition_cache.get_key(i); CompositionCycleDescEntry entry(other, result, false); cycle_desc->push_back(entry); @@ -1506,11 +1506,11 @@ r_detect_cycles(const RenderState *start_state, cache_size = current_state->_invert_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const RenderState *result = current_state->_invert_composition_cache.get_data(i)._result; - if (result != (const RenderState *)NULL) { + if (result != nullptr) { if (r_detect_cycles(start_state, result, length + 1, this_seq, cycle_desc)) { // Cycle detected. - if (cycle_desc != (CompositionCycleDesc *)NULL) { + if (cycle_desc != nullptr) { const RenderState *other = current_state->_invert_composition_cache.get_key(i); CompositionCycleDescEntry entry(other, result, true); cycle_desc->push_back(entry); @@ -1553,11 +1553,11 @@ r_detect_reverse_cycles(const RenderState *start_state, nassertr(oi != -1, false); const RenderState *result = other->_composition_cache.get_data(oi)._result; - if (result != (const RenderState *)NULL) { + if (result != nullptr) { if (r_detect_reverse_cycles(start_state, result, length + 1, this_seq, cycle_desc)) { // Cycle detected. - if (cycle_desc != (CompositionCycleDesc *)NULL) { + if (cycle_desc != nullptr) { const RenderState *other = current_state->_composition_cache.get_key(i); CompositionCycleDescEntry entry(other, result, false); cycle_desc->push_back(entry); @@ -1576,11 +1576,11 @@ r_detect_reverse_cycles(const RenderState *start_state, nassertr(oi != -1, false); const RenderState *result = other->_invert_composition_cache.get_data(oi)._result; - if (result != (const RenderState *)NULL) { + if (result != nullptr) { if (r_detect_reverse_cycles(start_state, result, length + 1, this_seq, cycle_desc)) { // Cycle detected. - if (cycle_desc != (CompositionCycleDesc *)NULL) { + if (cycle_desc != nullptr) { const RenderState *other = current_state->_invert_composition_cache.get_key(i); CompositionCycleDescEntry entry(other, result, false); cycle_desc->push_back(entry); @@ -1682,7 +1682,7 @@ remove_cache_pointers() { // It's finally safe to let our held pointers go away. This may have // cascading effects as other RenderState objects are destructed, but // there will be no harm done if they destruct now. - if (ocomp._result != (const RenderState *)NULL && ocomp._result != other) { + if (ocomp._result != nullptr && ocomp._result != other) { cache_unref_delete(ocomp._result); } } @@ -1690,7 +1690,7 @@ remove_cache_pointers() { // It's finally safe to let our held pointers go away. (See comment // above.) - if (comp._result != (const RenderState *)NULL && comp._result != this) { + if (comp._result != nullptr && comp._result != this) { cache_unref_delete(comp._result); } } @@ -1711,12 +1711,12 @@ remove_cache_pointers() { other->_invert_composition_cache.remove_element(oi); _cache_stats.add_total_size(-1); _cache_stats.inc_dels(); - if (ocomp._result != (const RenderState *)NULL && ocomp._result != other) { + if (ocomp._result != nullptr && ocomp._result != other) { cache_unref_delete(ocomp._result); } } } - if (comp._result != (const RenderState *)NULL && comp._result != this) { + if (comp._result != nullptr && comp._result != this) { cache_unref_delete(comp._result); } } @@ -1788,7 +1788,7 @@ determine_cull_callback() { int slot = mask.get_lowest_on_bit(); while (slot >= 0) { const Attribute &attrib = _attributes[slot]; - nassertv(attrib._attrib != (RenderAttrib *)NULL); + nassertv(attrib._attrib != nullptr); if (attrib._attrib->has_cull_callback()) { _flags |= F_has_cull_callback; break; @@ -1888,7 +1888,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { int slot = mask.get_lowest_on_bit(); while (slot >= 0) { const Attribute &attrib = _attributes[slot]; - nassertv(attrib._attrib != (RenderAttrib *)NULL); + nassertv(attrib._attrib != nullptr); manager->write_pointer(dg, attrib._attrib); dg.add_int32(attrib._override); @@ -1912,7 +1912,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { int override = (*_read_overrides)[i]; RenderAttrib *attrib = DCAST(RenderAttrib, p_list[pi++]); - if (attrib != (RenderAttrib *)NULL) { + if (attrib != nullptr) { int slot = attrib->get_slot(); if (slot > 0 && slot < reg->get_max_slots()) { _attributes[slot].set(attrib, override); @@ -1923,7 +1923,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { } delete _read_overrides; - _read_overrides = NULL; + _read_overrides = nullptr; return pi; } diff --git a/panda/src/pgraph/renderState_ext.cxx b/panda/src/pgraph/renderState_ext.cxx index 0dc0d8acc5..2b7e3a4791 100644 --- a/panda/src/pgraph/renderState_ext.cxx +++ b/panda/src/pgraph/renderState_ext.cxx @@ -37,7 +37,7 @@ get_composition_cache() const { PyObject *tuple = PyTuple_New(2); PyObject *a, *b; const RenderState *source = _this->_composition_cache.get_key(i); - if (source == (RenderState *)NULL) { + if (source == nullptr) { a = Py_None; Py_INCREF(a); } else { @@ -46,7 +46,7 @@ get_composition_cache() const { true, true, source->get_type_index()); } const RenderState *result = _this->_composition_cache.get_data(i)._result; - if (result == (RenderState *)NULL) { + if (result == nullptr) { b = Py_None; Py_INCREF(b); } else { @@ -85,7 +85,7 @@ get_invert_composition_cache() const { PyObject *tuple = PyTuple_New(2); PyObject *a, *b; const RenderState *source = _this->_invert_composition_cache.get_key(i); - if (source == (RenderState *)NULL) { + if (source == nullptr) { a = Py_None; Py_INCREF(a); } else { @@ -94,7 +94,7 @@ get_invert_composition_cache() const { true, true, source->get_type_index()); } const RenderState *result = _this->_invert_composition_cache.get_data(i)._result; - if (result == (RenderState *)NULL) { + if (result == nullptr) { b = Py_None; Py_INCREF(b); } else { @@ -118,7 +118,7 @@ get_invert_composition_cache() const { PyObject *Extension:: get_states() { extern struct Dtool_PyTypedObject Dtool_RenderState; - if (RenderState::_states == (RenderState::States *)NULL) { + if (RenderState::_states == nullptr) { return PyList_New(0); } LightReMutexHolder holder(*RenderState::_states_lock); diff --git a/panda/src/pgraph/sceneGraphReducer.I b/panda/src/pgraph/sceneGraphReducer.I index 4319b118df..2db336c546 100644 --- a/panda/src/pgraph/sceneGraphReducer.I +++ b/panda/src/pgraph/sceneGraphReducer.I @@ -77,7 +77,7 @@ get_combine_radius() const { INLINE void SceneGraphReducer:: apply_attribs(PandaNode *node, int attrib_types) { nassertv(check_live_flatten(node)); - nassertv(node != (PandaNode *)NULL); + nassertv(node != nullptr); PStatTimer timer(_apply_collector); AccumulatedAttribs attribs; r_apply_attribs(node, attribs, attrib_types, _transformer); @@ -93,7 +93,7 @@ apply_attribs(PandaNode *node, int attrib_types) { INLINE void SceneGraphReducer:: apply_attribs(PandaNode *node, const AccumulatedAttribs &attribs, int attrib_types, GeomTransformer &transformer) { - nassertv(node != (PandaNode *)NULL); + nassertv(node != nullptr); r_apply_attribs(node, attribs, attrib_types, transformer); } @@ -115,7 +115,7 @@ apply_attribs(PandaNode *node, const AccumulatedAttribs &attribs, */ INLINE int SceneGraphReducer:: make_compatible_format(PandaNode *root, int collect_bits) { - nassertr(root != (PandaNode *)NULL, 0); + nassertr(root != nullptr, 0); nassertr(check_live_flatten(root), 0); PStatTimer timer(_collect_collector); int count = 0; @@ -137,7 +137,7 @@ make_compatible_format(PandaNode *root, int collect_bits) { */ INLINE int SceneGraphReducer:: collect_vertex_data(PandaNode *root, int collect_bits) { - nassertr(root != (PandaNode *)NULL, 0); + nassertr(root != nullptr, 0); nassertr(check_live_flatten(root), 0); PStatTimer timer(_collect_collector); int count = 0; @@ -155,7 +155,7 @@ collect_vertex_data(PandaNode *root, int collect_bits) { */ INLINE int SceneGraphReducer:: make_nonindexed(PandaNode *root, int nonindexed_bits) { - nassertr(root != (PandaNode *)NULL, 0); + nassertr(root != nullptr, 0); nassertr(check_live_flatten(root), 0); PStatTimer timer(_make_nonindexed_collector); return r_make_nonindexed(root, nonindexed_bits); @@ -171,9 +171,9 @@ make_nonindexed(PandaNode *root, int nonindexed_bits) { */ INLINE void SceneGraphReducer:: premunge(PandaNode *root, const RenderState *initial_state) { - nassertv(root != (PandaNode *)NULL); + nassertv(root != nullptr); nassertv(check_live_flatten(root)); - if (_gsg != (GraphicsStateGuardianBase *)NULL) { + if (_gsg != nullptr) { PStatTimer timer(_premunge_collector); r_premunge(root, initial_state); } diff --git a/panda/src/pgraph/sceneGraphReducer.cxx b/panda/src/pgraph/sceneGraphReducer.cxx index d0dc3e4411..3b1e075a90 100644 --- a/panda/src/pgraph/sceneGraphReducer.cxx +++ b/panda/src/pgraph/sceneGraphReducer.cxx @@ -42,7 +42,7 @@ PStatCollector SceneGraphReducer::_premunge_collector("*:Premunge"); */ void SceneGraphReducer:: set_gsg(GraphicsStateGuardianBase *gsg) { - if (gsg != (GraphicsStateGuardianBase *)NULL) { + if (gsg != nullptr) { _gsg = gsg; } else { _gsg = GraphicsStateGuardianBase::get_default_gsg(); @@ -50,7 +50,7 @@ set_gsg(GraphicsStateGuardianBase *gsg) { int max_vertices = max_collect_vertices; - if (_gsg != (GraphicsStateGuardianBase *)NULL) { + if (_gsg != nullptr) { max_vertices = min(max_vertices, _gsg->get_max_vertices_per_array()); } @@ -64,7 +64,7 @@ set_gsg(GraphicsStateGuardianBase *gsg) { */ void SceneGraphReducer:: clear_gsg() { - _gsg = NULL; + _gsg = nullptr; _transformer.set_max_collect_vertices(max_collect_vertices); } @@ -180,7 +180,7 @@ unify(PandaNode *root, bool preserve_order) { PStatTimer timer(_unify_collector); int max_indices = max_collect_indices; - if (_gsg != (GraphicsStateGuardianBase *)NULL) { + if (_gsg != nullptr) { max_indices = min(max_indices, _gsg->get_max_vertices_per_primitive()); } r_unify(root, max_indices, preserve_order); @@ -578,7 +578,7 @@ flatten_siblings(PandaNode *parent_node, int combine_siblings_bits) { if (consider_siblings(parent_node, child1, child2)) { PT(PandaNode) new_node = do_flatten_siblings(parent_node, child1, child2); - if (new_node != (PandaNode *)NULL) { + if (new_node != nullptr) { // We successfully collapsed a node. (*ai1_hold) = new_node; nodes.erase(ai2_hold); @@ -655,7 +655,7 @@ do_flatten_child(PandaNode *grandparent_node, PandaNode *parent_node, } PT(PandaNode) new_parent = collapse_nodes(parent_node, child_node, false); - if (new_parent == (PandaNode *)NULL) { + if (new_parent == nullptr) { if (pgraph_cat.is_spam()) { pgraph_cat.spam() << "Decided not to collapse " << *parent_node @@ -689,12 +689,12 @@ do_flatten_siblings(PandaNode *parent_node, PandaNode *child1, } PT(PandaNode) new_child = collapse_nodes(child2, child1, true); - if (new_child == (PandaNode *)NULL) { + if (new_child == nullptr) { if (pgraph_cat.is_spam()) { pgraph_cat.spam() << "Decided not to collapse " << *child1 << " and " << *child2 << "\n"; } - return NULL; + return nullptr; } choose_name(new_child, child2, child1); @@ -717,7 +717,7 @@ do_flatten_siblings(PandaNode *parent_node, PandaNode *child1, PT(PandaNode) SceneGraphReducer:: collapse_nodes(PandaNode *node1, PandaNode *node2, bool siblings) { PT(PandaNode) result = node2->combine_with(node1); - if (result == NULL) { + if (result == nullptr) { result = node1->combine_with(node2); } return result; diff --git a/panda/src/pgraph/sceneGraphReducer.h b/panda/src/pgraph/sceneGraphReducer.h index 5d9550856a..ec898d5820 100644 --- a/panda/src/pgraph/sceneGraphReducer.h +++ b/panda/src/pgraph/sceneGraphReducer.h @@ -38,7 +38,7 @@ class PandaNode; */ class EXPCL_PANDA_PGRAPH SceneGraphReducer { PUBLISHED: - INLINE explicit SceneGraphReducer(GraphicsStateGuardianBase *gsg = NULL); + INLINE explicit SceneGraphReducer(GraphicsStateGuardianBase *gsg = nullptr); INLINE ~SceneGraphReducer(); enum AttribTypes { diff --git a/panda/src/pgraph/sceneSetup.I b/panda/src/pgraph/sceneSetup.I index 425c538d85..cf420ee132 100644 --- a/panda/src/pgraph/sceneSetup.I +++ b/panda/src/pgraph/sceneSetup.I @@ -16,7 +16,7 @@ */ INLINE SceneSetup:: SceneSetup() { - _display_region = NULL; + _display_region = nullptr; _viewport_width = 0; _viewport_height = 0; _inverted = false; @@ -175,7 +175,7 @@ get_cull_center() const { INLINE PT(BoundingVolume) SceneSetup:: get_cull_bounds() const { PT(BoundingVolume) bounds = _camera_node->get_cull_bounds(); - if (bounds != (BoundingVolume *)NULL) { + if (bounds != nullptr) { return bounds; } diff --git a/panda/src/pgraph/scissorAttrib.cxx b/panda/src/pgraph/scissorAttrib.cxx index e1c3c29e01..f6281cd083 100644 --- a/panda/src/pgraph/scissorAttrib.cxx +++ b/panda/src/pgraph/scissorAttrib.cxx @@ -44,7 +44,7 @@ ScissorAttrib(const LVecBase4 &frame) : */ CPT(RenderAttrib) ScissorAttrib:: make_off() { - if (_off_attrib != NULL) { + if (_off_attrib != nullptr) { return _off_attrib; } ScissorAttrib *attrib = new ScissorAttrib(LVecBase4(0.0f, 1.0f, 0.0f, 1.0f)); diff --git a/panda/src/pgraph/scissorEffect.cxx b/panda/src/pgraph/scissorEffect.cxx index 9794250346..8e0d47ca9e 100644 --- a/panda/src/pgraph/scissorEffect.cxx +++ b/panda/src/pgraph/scissorEffect.cxx @@ -58,7 +58,7 @@ ScissorEffect(const ScissorEffect ©) : */ CPT(RenderEffect) ScissorEffect:: make_screen(const LVecBase4 &frame, bool clip) { - ScissorEffect *effect = new ScissorEffect(true, frame, NULL, 0, clip); + ScissorEffect *effect = new ScissorEffect(true, frame, nullptr, 0, clip); return return_new(effect); } @@ -69,7 +69,7 @@ make_screen(const LVecBase4 &frame, bool clip) { */ CPT(RenderEffect) ScissorEffect:: make_node(bool clip) { - ScissorEffect *effect = new ScissorEffect(false, LVecBase4::zero(), NULL, 0, clip); + ScissorEffect *effect = new ScissorEffect(false, LVecBase4::zero(), nullptr, 0, clip); return return_new(effect); } @@ -273,7 +273,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data, // Set up the culling. We do this by extruding the four corners of the // frame into the eight corners of the bounding frustum. PT(GeometricBoundingVolume) frustum = make_frustum(lens, frame); - if (frustum != (GeometricBoundingVolume *)NULL) { + if (frustum != nullptr) { frustum->xform(modelview_transform->get_inverse()->get_mat()); data._view_frustum = frustum; } @@ -362,7 +362,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { */ TypedWritable *ScissorEffect:: make_from_bam(const FactoryParams ¶ms) { - ScissorEffect *effect = new ScissorEffect(true, LVecBase4::zero(), NULL, 0, false); + ScissorEffect *effect = new ScissorEffect(true, LVecBase4::zero(), nullptr, 0, false); DatagramIterator scan; BamReader *manager; @@ -415,28 +415,28 @@ make_frustum(const Lens *lens, const LVecBase4 &frame) const{ // Upper left. if (!lens->extrude(corner, nul, ful)) { - return (GeometricBoundingVolume *)NULL; + return nullptr; } corner[0] = f2[1]; corner[1] = f2[3]; // Upper right. if (!lens->extrude(corner, nur, fur)) { - return (GeometricBoundingVolume *)NULL; + return nullptr; } corner[0] = f2[1]; corner[1] = f2[2]; // Lower right. if (!lens->extrude(corner, nlr, flr)) { - return (GeometricBoundingVolume *)NULL; + return nullptr; } corner[0] = f2[0]; corner[1] = f2[2]; // Lower left. if (!lens->extrude(corner, nll, fll)) { - return (GeometricBoundingVolume *)NULL; + return nullptr; } return new BoundingHexahedron(fll, flr, fur, ful, nll, nlr, nur, nul); diff --git a/panda/src/pgraph/shaderAttrib.I b/panda/src/pgraph/shaderAttrib.I index 6513604ae9..baea58607f 100644 --- a/panda/src/pgraph/shaderAttrib.I +++ b/panda/src/pgraph/shaderAttrib.I @@ -18,7 +18,7 @@ */ INLINE ShaderAttrib:: ShaderAttrib() : - _shader(NULL), + _shader(nullptr), _shader_priority(0), _auto_shader(false), _has_shader(false), diff --git a/panda/src/pgraph/shaderAttrib.cxx b/panda/src/pgraph/shaderAttrib.cxx index 130d85c1b8..982497497e 100644 --- a/panda/src/pgraph/shaderAttrib.cxx +++ b/panda/src/pgraph/shaderAttrib.cxx @@ -39,7 +39,7 @@ int ShaderAttrib::_attrib_slot; CPT(RenderAttrib) ShaderAttrib:: make_off() { static CPT(RenderAttrib) _off_attrib; - if (_off_attrib == 0) { + if (_off_attrib == nullptr) { ShaderAttrib *attrib = new ShaderAttrib; attrib->_has_shader = true; _off_attrib = return_new(attrib); @@ -53,12 +53,12 @@ make_off() { CPT(RenderAttrib) ShaderAttrib:: make(const Shader *shader, int priority) { static CPT(RenderAttrib) _null_attrib; - if (_null_attrib == 0) { + if (_null_attrib == nullptr) { ShaderAttrib *attrib = new ShaderAttrib; _null_attrib = return_new(attrib); } - if (shader == NULL) { + if (shader == nullptr) { return _null_attrib; } else { return DCAST(ShaderAttrib, _null_attrib)->set_shader(shader, priority); @@ -93,7 +93,7 @@ set_shader(const Shader *s, int priority) const { CPT(RenderAttrib) ShaderAttrib:: set_shader_off(int priority) const { ShaderAttrib *result = new ShaderAttrib(*this); - result->_shader = NULL; + result->_shader = nullptr; result->_shader_priority = priority; result->_auto_shader = false; result->_auto_normal_on = false; @@ -112,7 +112,7 @@ set_shader_off(int priority) const { CPT(RenderAttrib) ShaderAttrib:: set_shader_auto(int priority) const { ShaderAttrib *result = new ShaderAttrib(*this); - result->_shader = NULL; + result->_shader = nullptr; result->_shader_priority = priority; result->_auto_shader = true; result->_has_shader = true; @@ -132,7 +132,7 @@ CPT(RenderAttrib) ShaderAttrib:: set_shader_auto(BitMask32 shader_switch, int priority) const { ShaderAttrib *result = new ShaderAttrib(*this); - result->_shader = NULL; + result->_shader = nullptr; result->_shader_priority = priority; result->_auto_shader = true; result->_has_shader = true; @@ -151,7 +151,7 @@ set_shader_auto(BitMask32 shader_switch, int priority) const { CPT(RenderAttrib) ShaderAttrib:: clear_shader() const { ShaderAttrib *result = new ShaderAttrib(*this); - result->_shader = NULL; + result->_shader = nullptr; result->_shader_priority = 0; result->_auto_shader = false; result->_has_shader = false; @@ -355,7 +355,7 @@ get_shader_input_vector(InternalName *id) const { } else if (p.get_value_type() == ShaderInput::M_param) { // Temporary solution until the new param system TypedWritableReferenceCount *param = p.get_value(); - if (param != NULL && param->is_of_type(ParamVecBase4::get_class_type())) { + if (param != nullptr && param->is_of_type(ParamVecBase4::get_class_type())) { return ((const ParamVecBase4 *)param)->get_value(); } } @@ -385,14 +385,14 @@ get_shader_input_ptr(const InternalName *id) const { ostringstream strm; strm << "Shader input " << id->get_name() << " is not a PTA(float/double) type.\n"; nassert_raise(strm.str()); - return NULL; + return nullptr; } return &(p.get_ptr()); } else { ostringstream strm; strm << "Shader input " << id->get_name() << " is not present.\n"; nassert_raise(strm.str()); - return NULL; + return nullptr; } } @@ -431,14 +431,14 @@ get_shader_input_texture(const InternalName *id, SamplerState *sampler) const { ostringstream strm; strm << "Shader input " << id->get_name() << " is not a texture.\n"; nassert_raise(strm.str()); - return NULL; + return nullptr; } } else { ostringstream strm; strm << "Shader input " << id->get_name() << " is not present.\n"; nassert_raise(strm.str()); - return NULL; + return nullptr; } } @@ -506,20 +506,20 @@ get_shader_input_buffer(const InternalName *id) const { ostringstream strm; strm << "Shader input " << id->get_name() << " is not present.\n"; nassert_raise(strm.str()); - return NULL; + return nullptr; } else { const ShaderInput &p = (*i).second; if (p.get_value_type() == ShaderInput::M_buffer) { ShaderBuffer *value; - DCAST_INTO_R(value, p._value, NULL); + DCAST_INTO_R(value, p._value, nullptr); return value; } ostringstream strm; strm << "Shader input " << id->get_name() << " is not a ShaderBuffer.\n"; nassert_raise(strm.str()); - return NULL; + return nullptr; } } diff --git a/panda/src/pgraph/shaderAttrib.h b/panda/src/pgraph/shaderAttrib.h index 02a3189233..33af01fc99 100644 --- a/panda/src/pgraph/shaderAttrib.h +++ b/panda/src/pgraph/shaderAttrib.h @@ -42,7 +42,7 @@ private: INLINE ShaderAttrib(const ShaderAttrib ©); PUBLISHED: - static CPT(RenderAttrib) make(const Shader *shader = NULL, int priority = 0); + static CPT(RenderAttrib) make(const Shader *shader = nullptr, int priority = 0); static CPT(RenderAttrib) make_off(); static CPT(RenderAttrib) make_default(); @@ -115,7 +115,7 @@ PUBLISHED: const NodePath &get_shader_input_nodepath(const InternalName *id) const; LVecBase4 get_shader_input_vector(InternalName *id) const; - Texture *get_shader_input_texture(const InternalName *id, SamplerState *sampler=NULL) const; + Texture *get_shader_input_texture(const InternalName *id, SamplerState *sampler=nullptr) const; const Shader::ShaderPtrData *get_shader_input_ptr(const InternalName *id) const; const LMatrix4 &get_shader_input_matrix(const InternalName *id, LMatrix4 &matrix) const; ShaderBuffer *get_shader_input_buffer(const InternalName *id) const; diff --git a/panda/src/pgraph/shaderInput.cxx b/panda/src/pgraph/shaderInput.cxx index 86a3912ec4..a1d698cce7 100644 --- a/panda/src/pgraph/shaderInput.cxx +++ b/panda/src/pgraph/shaderInput.cxx @@ -110,7 +110,7 @@ get_texture() const { return DCAST(Texture, _value); default: - return NULL; + return nullptr; } } diff --git a/panda/src/pgraph/shaderPool.I b/panda/src/pgraph/shaderPool.I index 3139ff2daf..074a24e147 100644 --- a/panda/src/pgraph/shaderPool.I +++ b/panda/src/pgraph/shaderPool.I @@ -27,7 +27,7 @@ has_shader(const Filename &filename) { */ INLINE bool ShaderPool:: verify_shader(const Filename &filename) { - return load_shader(filename) != (Shader *)NULL; + return load_shader(filename) != nullptr; } /** diff --git a/panda/src/pgraph/shaderPool.cxx b/panda/src/pgraph/shaderPool.cxx index ba9f99e8c2..87823b9e50 100644 --- a/panda/src/pgraph/shaderPool.cxx +++ b/panda/src/pgraph/shaderPool.cxx @@ -19,7 +19,7 @@ #include "shader.h" #include "string_utils.h" -ShaderPool *ShaderPool::_global_ptr = (ShaderPool *)NULL; +ShaderPool *ShaderPool::_global_ptr = nullptr; /** * Lists the contents of the shader pool to the indicated output stream. @@ -89,9 +89,9 @@ ns_load_shader(const Filename &orig_filename) { } PT(Shader) shader = Shader::load(filename, lang); - if (shader == (Shader *)NULL) { + if (shader == nullptr) { // This shader was not found or could not be read. - return NULL; + return nullptr; } { @@ -211,7 +211,7 @@ resolve_filename(Filename &new_filename, const Filename &orig_filename) { */ ShaderPool *ShaderPool:: get_ptr() { - if (_global_ptr == (ShaderPool *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new ShaderPool; } return _global_ptr; diff --git a/panda/src/pgraph/texGenAttrib.cxx b/panda/src/pgraph/texGenAttrib.cxx index 451eacab83..9842d1158f 100644 --- a/panda/src/pgraph/texGenAttrib.cxx +++ b/panda/src/pgraph/texGenAttrib.cxx @@ -38,7 +38,7 @@ CPT(RenderAttrib) TexGenAttrib:: make() { // We make it a special case and store a pointer to the empty attrib forever // once we find it the first time, as an optimization. - if (_empty_attrib == (RenderAttrib *)NULL) { + if (_empty_attrib == nullptr) { _empty_attrib = return_new(new TexGenAttrib); } diff --git a/panda/src/pgraph/texMatrixAttrib.cxx b/panda/src/pgraph/texMatrixAttrib.cxx index 4e2e1adba8..a228b79072 100644 --- a/panda/src/pgraph/texMatrixAttrib.cxx +++ b/panda/src/pgraph/texMatrixAttrib.cxx @@ -38,7 +38,7 @@ CPT(RenderAttrib) TexMatrixAttrib:: make() { // We make it a special case and store a pointer to the empty attrib forever // once we find it the first time, as an optimization. - if (_empty_attrib == (RenderAttrib *)NULL) { + if (_empty_attrib == nullptr) { _empty_attrib = return_new(new TexMatrixAttrib); } @@ -148,7 +148,7 @@ get_num_stages() const { */ TextureStage *TexMatrixAttrib:: get_stage(int n) const { - nassertr(n >= 0 && n < (int)_stages.size(), NULL); + nassertr(n >= 0 && n < (int)_stages.size(), nullptr); return _stages[n]._stage; } @@ -504,7 +504,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { override = scan.get_int32(); } - StageNode sn(NULL); + StageNode sn(nullptr); sn._override = override; _stages.push_back(sn); } diff --git a/panda/src/pgraph/texProjectorEffect.I b/panda/src/pgraph/texProjectorEffect.I index 35e699476e..067d023574 100644 --- a/panda/src/pgraph/texProjectorEffect.I +++ b/panda/src/pgraph/texProjectorEffect.I @@ -34,7 +34,7 @@ TexProjectorEffect(const TexProjectorEffect ©) : */ INLINE TexProjectorEffect::StageDef:: StageDef() : - _to_lens_node(NULL) + _to_lens_node(nullptr) { } diff --git a/panda/src/pgraph/texProjectorEffect.cxx b/panda/src/pgraph/texProjectorEffect.cxx index a8f0078dea..5d850ab0f5 100644 --- a/panda/src/pgraph/texProjectorEffect.cxx +++ b/panda/src/pgraph/texProjectorEffect.cxx @@ -39,7 +39,7 @@ CPT(RenderEffect) TexProjectorEffect:: make() { // We make it a special case and store a pointer to the empty effect forever // once we find it the first time, as an optimization. - if (_empty_effect == (RenderEffect *)NULL) { + if (_empty_effect == nullptr) { _empty_effect = return_new(new TexProjectorEffect); } @@ -189,18 +189,18 @@ cull_callback(CullTraverser *trav, CullTraverserData &data, CPT(TransformState) transform = def._from.get_transform(def._to); - if (def._to_lens_node != (LensNode *)NULL && - def._to_lens_node->get_lens() != (Lens *)NULL) { + if (def._to_lens_node != nullptr && + def._to_lens_node->get_lens() != nullptr) { // Get the lens's projection matrix, as a TransformState. Lens *lens = def._to_lens_node->get_lens(def._lens_index); - if (lens != NULL) { + if (lens != nullptr) { CPT(TransformState) projmat = TransformState::make_mat(lens->get_projection_mat()); // We need a special transform to convert the -0.5, 0.5 centering of // the lens's projection matrix to UV's in the range of (0, 1). static CPT(TransformState) fixmat; - if (fixmat == (TransformState *)NULL) { + if (fixmat == nullptr) { fixmat = TransformState::make_pos_hpr_scale (LVecBase3(0.5f, 0.5f, 0.0f), LVecBase3(0.0f, 0.0f, 0.0f), @@ -357,6 +357,6 @@ set_to(const NodePath &to) { if (!_to.is_empty() && _to.node()->is_of_type(LensNode::get_class_type())) { DCAST_INTO_V(_to_lens_node, _to.node()); } else { - _to_lens_node = (LensNode *)NULL; + _to_lens_node = nullptr; } } diff --git a/panda/src/pgraph/textureAttrib.I b/panda/src/pgraph/textureAttrib.I index da1feca0be..9ee2f69f62 100644 --- a/panda/src/pgraph/textureAttrib.I +++ b/panda/src/pgraph/textureAttrib.I @@ -60,7 +60,7 @@ is_off() const { INLINE Texture *TextureAttrib:: get_texture() const { if (_on_stages.empty()) { - return NULL; + return nullptr; } check_sorted(); return get_on_texture(filter_to_max(1)->get_on_stage(0)); @@ -80,7 +80,7 @@ get_num_on_stages() const { */ INLINE TextureStage *TextureAttrib:: get_on_stage(int n) const { - nassertr(n >= 0 && n < (int)_render_stages.size(), (TextureStage *)NULL); + nassertr(n >= 0 && n < (int)_render_stages.size(), nullptr); return _render_stages[n]->_stage; } @@ -101,7 +101,7 @@ get_num_on_ff_stages() const { */ INLINE TextureStage *TextureAttrib:: get_on_ff_stage(int n) const { - nassertr(n >= 0 && n < (int)_render_ff_stages.size(), (TextureStage *)NULL); + nassertr(n >= 0 && n < (int)_render_ff_stages.size(), nullptr); return _render_ff_stages[n]->_stage; } @@ -137,7 +137,7 @@ get_on_texture(TextureStage *stage) const { if (si != _on_stages.end()) { return (*si)._texture; } - return NULL; + return nullptr; } /** @@ -183,7 +183,7 @@ get_num_off_stages() const { */ INLINE TextureStage *TextureAttrib:: get_off_stage(int n) const { - nassertr(n >= 0 && n < (int)_off_stages.size(), (TextureStage *)NULL); + nassertr(n >= 0 && n < (int)_off_stages.size(), nullptr); return _off_stages[n]._stage; } diff --git a/panda/src/pgraph/textureAttrib.cxx b/panda/src/pgraph/textureAttrib.cxx index ee3c5a8165..49bf20f5b9 100644 --- a/panda/src/pgraph/textureAttrib.cxx +++ b/panda/src/pgraph/textureAttrib.cxx @@ -52,7 +52,7 @@ CPT(RenderAttrib) TextureAttrib:: make() { // We make it a special case and store a pointer to the empty attrib forever // once we find it the first time, as an optimization. - if (_empty_attrib == (RenderAttrib *)NULL) { + if (_empty_attrib == nullptr) { _empty_attrib = return_new(new TextureAttrib); } @@ -67,7 +67,7 @@ CPT(RenderAttrib) TextureAttrib:: make_all_off() { // We make it a special case and store a pointer to the off attrib forever // once we find it the first time, as an optimization. - if (_all_off_attrib == (RenderAttrib *)NULL) { + if (_all_off_attrib == nullptr) { TextureAttrib *attrib = new TextureAttrib; attrib->_off_all_stages = true; _all_off_attrib = return_new(attrib); @@ -768,7 +768,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { for (si = _on_stages.begin(); si != _on_stages.end(); ++si) { TextureStage *stage = (*si)._stage; Texture *tex = (*si)._texture; - nassertv(tex != (Texture *)NULL); + nassertv(tex != nullptr); manager->write_pointer(dg, stage); manager->write_pointer(dg, tex); @@ -811,7 +811,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { // have to do anything special here. Texture *tex = DCAST(Texture, p_list[pi++]); - if (tex != (Texture *)NULL) { + if (tex != nullptr) { StageNode &sn = _on_stages[sni]; sn._stage = ts; sn._texture = tex; @@ -867,7 +867,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _off_stages.reserve(num_off_stages); for (i = 0; i < num_off_stages; i++) { manager->read_pointer(scan); - _off_stages.push_back(StageNode(NULL)); + _off_stages.push_back(StageNode(nullptr)); } // Read the _on_stages data. @@ -893,7 +893,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _next_implicit_sort = max(_next_implicit_sort, implicit_sort + 1); Stages::iterator si = - _on_stages.insert_nonunique(StageNode(NULL, _next_implicit_sort, override)); + _on_stages.insert_nonunique(StageNode(nullptr, _next_implicit_sort, override)); ++_next_implicit_sort; if (manager->get_file_minor_ver() >= 36) { @@ -923,8 +923,8 @@ sort_on_stages() { StageNode &sn = (*si); TextureStage *stage = sn._stage; Texture *texture = sn._texture; - nassertv(stage != NULL); - nassertv(texture != NULL); + nassertv(stage != nullptr); + nassertv(texture != nullptr); if (stage->is_fixed_function() && texture->get_texture_type() != Texture::TT_2d_texture_array) { const InternalName *name = stage->get_texcoord_name(); diff --git a/panda/src/pgraph/textureStageCollection.cxx b/panda/src/pgraph/textureStageCollection.cxx index 42d6320b33..33e3ce00a6 100644 --- a/panda/src/pgraph/textureStageCollection.cxx +++ b/panda/src/pgraph/textureStageCollection.cxx @@ -184,7 +184,7 @@ find_texture_stage(const string &name) const { return texture_stage; } } - return NULL; + return nullptr; } /** @@ -200,7 +200,7 @@ get_num_texture_stages() const { */ TextureStage *TextureStageCollection:: get_texture_stage(int index) const { - nassertr(index >= 0 && index < (int)_texture_stages.size(), NULL); + nassertr(index >= 0 && index < (int)_texture_stages.size(), nullptr); return _texture_stages[index]; } @@ -211,7 +211,7 @@ get_texture_stage(int index) const { */ TextureStage *TextureStageCollection:: operator [] (int index) const { - nassertr(index >= 0 && index < (int)_texture_stages.size(), NULL); + nassertr(index >= 0 && index < (int)_texture_stages.size(), nullptr); return _texture_stages[index]; } diff --git a/panda/src/pgraph/transformState.cxx b/panda/src/pgraph/transformState.cxx index c66bd3a281..a58bd78510 100644 --- a/panda/src/pgraph/transformState.cxx +++ b/panda/src/pgraph/transformState.cxx @@ -24,8 +24,8 @@ #include "lightMutexHolder.h" #include "thread.h" -LightReMutex *TransformState::_states_lock = NULL; -TransformState::States *TransformState::_states = NULL; +LightReMutex *TransformState::_states_lock = nullptr; +TransformState::States *TransformState::_states = nullptr; CPT(TransformState) TransformState::_identity_state; CPT(TransformState) TransformState::_invalid_state; UpdateSeq TransformState::_last_cycle_detect; @@ -55,12 +55,12 @@ TypeHandle TransformState::_type_handle; */ TransformState:: TransformState() : _lock("TransformState") { - if (_states == (States *)NULL) { + if (_states == nullptr) { init_states(); } _saved_entry = -1; _flags = F_is_identity | F_singular_known | F_is_2d; - _inv_mat = (LMatrix4 *)NULL; + _inv_mat = nullptr; _cache_stats.add_num_states(1); #ifdef DO_MEMORY_USAGE @@ -79,9 +79,9 @@ TransformState:: set_destructing(); // Free the inverse matrix computation, if it has been stored. - if (_inv_mat != (LMatrix4 *)NULL) { + if (_inv_mat != nullptr) { delete _inv_mat; - _inv_mat = (LMatrix4 *)NULL; + _inv_mat = nullptr; } LightReMutexHolder holder(*_states_lock); @@ -235,7 +235,7 @@ CPT(TransformState) TransformState:: make_identity() { // The identity state is asked for so often, we make it a special case and // store a pointer forever once we find it the first time. - if (_identity_state == (TransformState *)NULL) { + if (_identity_state == nullptr) { TransformState *state = new TransformState; _identity_state = return_unique(state); } @@ -249,7 +249,7 @@ make_identity() { */ CPT(TransformState) TransformState:: make_invalid() { - if (_invalid_state == (TransformState *)NULL) { + if (_invalid_state == nullptr) { TransformState *state = new TransformState; state->_flags = F_is_invalid | F_singular_known | F_is_singular | F_components_known | F_mat_known; _invalid_state = return_unique(state); @@ -647,7 +647,7 @@ compose(const TransformState *other) const { if (other != this) { _cache_stats.add_total_size(1); _cache_stats.inc_adds(other->_composition_cache.is_empty()); - other->_composition_cache[this]._result = NULL; + other->_composition_cache[this]._result = nullptr; } if (result != (TransformState *)this) { @@ -753,7 +753,7 @@ invert_compose(const TransformState *other) const { if (other != this) { _cache_stats.add_total_size(1); _cache_stats.inc_adds(other->_invert_composition_cache.is_empty()); - other->_invert_composition_cache[this]._result = NULL; + other->_invert_composition_cache[this]._result = nullptr; } if (result != (TransformState *)this) { @@ -829,7 +829,7 @@ validate_composition_cache() const { size_t size = _composition_cache.get_num_entries(); for (size_t i = 0; i < size; ++i) { const TransformState *source = _composition_cache.get_key(i); - if (source != (TransformState *)NULL) { + if (source != nullptr) { // Check that the source also has a pointer back to this one. We always // add entries to the composition cache in pairs. int ri = source->_composition_cache.find(this); @@ -849,7 +849,7 @@ validate_composition_cache() const { size = _invert_composition_cache.get_num_entries(); for (size_t i = 0; i < size; ++i) { const TransformState *source = _invert_composition_cache.get_key(i); - if (source != (TransformState *)NULL) { + if (source != nullptr) { // Check that the source also has a pointer back to this one. We always // add entries to the composition cache in pairs. int ri = source->_invert_composition_cache.find(this); @@ -982,7 +982,7 @@ write_composition_cache(ostream &out, int indent_level) const { */ int TransformState:: get_num_states() { - if (_states == (States *)NULL) { + if (_states == nullptr) { return 0; } LightReMutexHolder holder(*_states_lock); @@ -1004,7 +1004,7 @@ get_num_states() { */ int TransformState:: get_num_unused_states() { - if (_states == (States *)NULL) { + if (_states == nullptr) { return 0; } LightReMutexHolder holder(*_states_lock); @@ -1023,7 +1023,7 @@ get_num_unused_states() { size_t cache_size = state->_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const TransformState *result = state->_composition_cache.get_data(i)._result; - if (result != (const TransformState *)NULL && result != state) { + if (result != nullptr && result != state) { // Here's a TransformState that's recorded in the cache. Count it. pair ir = state_count.insert(StateCount::value_type(result, 1)); @@ -1037,7 +1037,7 @@ get_num_unused_states() { cache_size = state->_invert_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const TransformState *result = state->_invert_composition_cache.get_data(i)._result; - if (result != (const TransformState *)NULL && result != state) { + if (result != nullptr && result != state) { pair ir = state_count.insert(StateCount::value_type(result, 1)); if (!ir.second) { @@ -1089,7 +1089,7 @@ get_num_unused_states() { */ int TransformState:: clear_cache() { - if (_states == (States *)NULL) { + if (_states == nullptr) { return 0; } LightReMutexHolder holder(*_states_lock); @@ -1122,7 +1122,7 @@ clear_cache() { size_t cache_size = state->_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const TransformState *result = state->_composition_cache.get_data(i)._result; - if (result != (const TransformState *)NULL && result != state) { + if (result != nullptr && result != state) { result->cache_unref(); nassertr(result->get_ref_count() > 0, 0); } @@ -1133,7 +1133,7 @@ clear_cache() { cache_size = state->_invert_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const TransformState *result = state->_invert_composition_cache.get_data(i)._result; - if (result != (const TransformState *)NULL && result != state) { + if (result != nullptr && result != state) { result->cache_unref(); nassertr(result->get_ref_count() > 0, 0); } @@ -1159,7 +1159,7 @@ clear_cache() { */ int TransformState:: garbage_collect() { - if (_states == (States *)NULL || !garbage_collect_states) { + if (_states == nullptr || !garbage_collect_states) { return 0; } @@ -1248,7 +1248,7 @@ garbage_collect() { */ void TransformState:: list_cycles(ostream &out) { - if (_states == (States *)NULL) { + if (_states == nullptr) { return; } LightReMutexHolder holder(*_states_lock); @@ -1325,7 +1325,7 @@ list_cycles(ostream &out) { */ void TransformState:: list_states(ostream &out) { - if (_states == (States *)NULL) { + if (_states == nullptr) { out << "0 states:\n"; return; } @@ -1347,7 +1347,7 @@ list_states(ostream &out) { */ bool TransformState:: validate_states() { - if (_states == (States *)NULL) { + if (_states == nullptr) { return true; } @@ -1438,7 +1438,7 @@ init_states() { */ CPT(TransformState) TransformState:: return_new(TransformState *state) { - nassertr(state != (TransformState *)NULL, state); + nassertr(state != nullptr, state); if (!uniquify_transforms && !state->is_identity()) { return state; } @@ -1457,7 +1457,7 @@ return_new(TransformState *state) { */ CPT(TransformState) TransformState:: return_unique(TransformState *state) { - nassertr(state != (TransformState *)NULL, state); + nassertr(state != nullptr, state); if (!transform_cache) { return state; @@ -1663,7 +1663,7 @@ do_invert_compose(const TransformState *other) const { pgraph_cat.warning() << "Unexpected singular matrix found for " << *this << "\n"; } else { - nassertr(_inv_mat != (LMatrix4 *)NULL, make_invalid()); + nassertr(_inv_mat != nullptr, make_invalid()); LMatrix4 new_mat; new_mat.multiply(other->get_mat(), *_inv_mat); if (!new_mat.almost_equal(result->get_mat(), 0.1)) { @@ -1687,7 +1687,7 @@ do_invert_compose(const TransformState *other) const { // Now that is_singular() has returned false, we can assume that _inv_mat // has been allocated and filled in. - nassertr(_inv_mat != (LMatrix4 *)NULL, make_invalid()); + nassertr(_inv_mat != nullptr, make_invalid()); if (is_2d() && other->is_2d()) { const LMatrix4 &i = *_inv_mat; @@ -1717,7 +1717,7 @@ detect_and_break_cycles() { PStatTimer timer(_transform_break_cycles_pcollector); ++_last_cycle_detect; - if (r_detect_cycles(this, this, 1, _last_cycle_detect, NULL)) { + if (r_detect_cycles(this, this, 1, _last_cycle_detect, nullptr)) { // Ok, we have a cycle. This will be a leak unless we break the cycle by // freeing the cache on this object. if (pgraph_cat.is_debug()) { @@ -1728,7 +1728,7 @@ detect_and_break_cycles() { remove_cache_pointers(); } else { ++_last_cycle_detect; - if (r_detect_reverse_cycles(this, this, 1, _last_cycle_detect, NULL)) { + if (r_detect_reverse_cycles(this, this, 1, _last_cycle_detect, nullptr)) { if (pgraph_cat.is_debug()) { pgraph_cat.debug() << "Breaking cycle involving " << (*this) << "\n"; @@ -1765,11 +1765,11 @@ r_detect_cycles(const TransformState *start_state, size_t cache_size = current_state->_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const TransformState *result = current_state->_composition_cache.get_data(i)._result; - if (result != (const TransformState *)NULL) { + if (result != nullptr) { if (r_detect_cycles(start_state, result, length + 1, this_seq, cycle_desc)) { // Cycle detected. - if (cycle_desc != (CompositionCycleDesc *)NULL) { + if (cycle_desc != nullptr) { const TransformState *other = current_state->_composition_cache.get_key(i); CompositionCycleDescEntry entry(other, result, false); cycle_desc->push_back(entry); @@ -1782,11 +1782,11 @@ r_detect_cycles(const TransformState *start_state, cache_size = current_state->_invert_composition_cache.get_num_entries(); for (i = 0; i < cache_size; ++i) { const TransformState *result = current_state->_invert_composition_cache.get_data(i)._result; - if (result != (const TransformState *)NULL) { + if (result != nullptr) { if (r_detect_cycles(start_state, result, length + 1, this_seq, cycle_desc)) { // Cycle detected. - if (cycle_desc != (CompositionCycleDesc *)NULL) { + if (cycle_desc != nullptr) { const TransformState *other = current_state->_invert_composition_cache.get_key(i); CompositionCycleDescEntry entry(other, result, true); cycle_desc->push_back(entry); @@ -1829,11 +1829,11 @@ r_detect_reverse_cycles(const TransformState *start_state, nassertr(oi != -1, false); const TransformState *result = other->_composition_cache.get_data(oi)._result; - if (result != (const TransformState *)NULL) { + if (result != nullptr) { if (r_detect_reverse_cycles(start_state, result, length + 1, this_seq, cycle_desc)) { // Cycle detected. - if (cycle_desc != (CompositionCycleDesc *)NULL) { + if (cycle_desc != nullptr) { const TransformState *other = current_state->_composition_cache.get_key(i); CompositionCycleDescEntry entry(other, result, false); cycle_desc->push_back(entry); @@ -1852,11 +1852,11 @@ r_detect_reverse_cycles(const TransformState *start_state, nassertr(oi != -1, false); const TransformState *result = other->_invert_composition_cache.get_data(oi)._result; - if (result != (const TransformState *)NULL) { + if (result != nullptr) { if (r_detect_reverse_cycles(start_state, result, length + 1, this_seq, cycle_desc)) { // Cycle detected. - if (cycle_desc != (CompositionCycleDesc *)NULL) { + if (cycle_desc != nullptr) { const TransformState *other = current_state->_invert_composition_cache.get_key(i); CompositionCycleDescEntry entry(other, result, false); cycle_desc->push_back(entry); @@ -1961,7 +1961,7 @@ remove_cache_pointers() { // It's finally safe to let our held pointers go away. This may have // cascading effects as other TransformState objects are destructed, // but there will be no harm done if they destruct now. - if (ocomp._result != (const TransformState *)NULL && ocomp._result != other) { + if (ocomp._result != nullptr && ocomp._result != other) { cache_unref_delete(ocomp._result); } } @@ -1969,7 +1969,7 @@ remove_cache_pointers() { // It's finally safe to let our held pointers go away. (See comment // above.) - if (comp._result != (const TransformState *)NULL && comp._result != this) { + if (comp._result != nullptr && comp._result != this) { cache_unref_delete(comp._result); } } @@ -1990,12 +1990,12 @@ remove_cache_pointers() { other->_invert_composition_cache.remove_element(oi); _cache_stats.add_total_size(-1); _cache_stats.inc_dels(); - if (ocomp._result != (const TransformState *)NULL && ocomp._result != other) { + if (ocomp._result != nullptr && ocomp._result != other) { cache_unref_delete(ocomp._result); } } } - if (comp._result != (const TransformState *)NULL && comp._result != this) { + if (comp._result != nullptr && comp._result != this) { cache_unref_delete(comp._result); } } @@ -2077,7 +2077,7 @@ calc_singular() { // is asking whether we're singular). // This should be NULL if no one has called calc_singular() yet. - nassertv(_inv_mat == (LMatrix4 *)NULL); + nassertv(_inv_mat == nullptr); _inv_mat = new LMatrix4; if ((_flags & F_mat_known) == 0) { @@ -2088,7 +2088,7 @@ calc_singular() { if (!inverted) { _flags |= F_is_singular; delete _inv_mat; - _inv_mat = (LMatrix4 *)NULL; + _inv_mat = nullptr; } _flags |= F_singular_known; } diff --git a/panda/src/pgraph/transformState_ext.cxx b/panda/src/pgraph/transformState_ext.cxx index 44ddfd71f8..08a47b92cd 100644 --- a/panda/src/pgraph/transformState_ext.cxx +++ b/panda/src/pgraph/transformState_ext.cxx @@ -41,7 +41,7 @@ get_composition_cache() const { PyObject *a, *b; const TransformState *source = _this->_composition_cache.get_key(si); - if (source == (TransformState *)NULL) { + if (source == nullptr) { a = Py_None; Py_INCREF(a); } else { @@ -50,7 +50,7 @@ get_composition_cache() const { true, true, source->get_type_index()); } const TransformState *result = _this->_composition_cache.get_data(si)._result; - if (result == (TransformState *)NULL) { + if (result == nullptr) { b = Py_None; Py_INCREF(b); } else { @@ -96,7 +96,7 @@ get_invert_composition_cache() const { PyObject *a, *b; const TransformState *source = _this->_invert_composition_cache.get_key(si); - if (source == (TransformState *)NULL) { + if (source == nullptr) { a = Py_None; Py_INCREF(a); } else { @@ -105,7 +105,7 @@ get_invert_composition_cache() const { true, true, source->get_type_index()); } const TransformState *result = _this->_invert_composition_cache.get_data(si)._result; - if (result == (TransformState *)NULL) { + if (result == nullptr) { b = Py_None; Py_INCREF(b); } else { @@ -132,7 +132,7 @@ get_invert_composition_cache() const { PyObject *Extension:: get_states() { extern struct Dtool_PyTypedObject Dtool_TransformState; - if (TransformState::_states == (TransformState::States *)NULL) { + if (TransformState::_states == nullptr) { return PyList_New(0); } LightReMutexHolder holder(*TransformState::_states_lock); @@ -163,7 +163,7 @@ get_states() { PyObject *Extension:: get_unused_states() { extern struct Dtool_PyTypedObject Dtool_TransformState; - if (TransformState::_states == (TransformState::States *)NULL) { + if (TransformState::_states == nullptr) { return PyList_New(0); } LightReMutexHolder holder(*TransformState::_states_lock); diff --git a/panda/src/pgraph/weakNodePath.I b/panda/src/pgraph/weakNodePath.I index 613afe0800..8191821b12 100644 --- a/panda/src/pgraph/weakNodePath.I +++ b/panda/src/pgraph/weakNodePath.I @@ -79,7 +79,7 @@ operator bool () const { */ INLINE bool WeakNodePath:: is_empty() const { - return _head == (NodePathComponent *)NULL || _head.was_deleted(); + return _head == nullptr || _head.was_deleted(); } /** @@ -88,7 +88,7 @@ is_empty() const { */ INLINE bool WeakNodePath:: was_deleted() const { - return _head != (NodePathComponent *)NULL && _head.was_deleted(); + return _head != nullptr && _head.was_deleted(); } /** diff --git a/panda/src/pgraph/workingNodePath.I b/panda/src/pgraph/workingNodePath.I index b74921827b..ad5c80ba18 100644 --- a/panda/src/pgraph/workingNodePath.I +++ b/panda/src/pgraph/workingNodePath.I @@ -19,7 +19,7 @@ INLINE WorkingNodePath:: WorkingNodePath(const NodePath &start) { nassertv(!start.is_empty()); - _next = (WorkingNodePath *)NULL; + _next = nullptr; _start = start._head; _node = start.node(); } @@ -33,8 +33,8 @@ WorkingNodePath(const WorkingNodePath ©) : _start(copy._start), _node(copy._node) { - nassertv(_next != (WorkingNodePath *)NULL || - _start != (NodePathComponent *)NULL); + nassertv(_next != nullptr || + _start != nullptr); } /** @@ -66,8 +66,8 @@ operator = (const WorkingNodePath ©) { _start = copy._start; _node = copy._node; - nassertv(_next != (WorkingNodePath *)NULL || - _start != (NodePathComponent *)NULL); + nassertv(_next != nullptr || + _start != nullptr); } /** @@ -78,7 +78,7 @@ INLINE NodePath WorkingNodePath:: get_node_path() const { NodePath result; result._head = r_get_node_path(); - nassertr(result._head != (NodePathComponent *)NULL, NodePath::fail()); + nassertr(result._head != nullptr, NodePath::fail()); return result; } diff --git a/panda/src/pgraph/workingNodePath.cxx b/panda/src/pgraph/workingNodePath.cxx index 42e8bd7141..af9a1fb8e8 100644 --- a/panda/src/pgraph/workingNodePath.cxx +++ b/panda/src/pgraph/workingNodePath.cxx @@ -20,11 +20,11 @@ */ bool WorkingNodePath:: is_valid() const { - if (_node == (PandaNode *)NULL) { + if (_node == nullptr) { return false; } - if (_next == (WorkingNodePath *)NULL) { - return (_start != (NodePathComponent *)NULL); + if (_next == nullptr) { + return (_start != nullptr); } nassertr(_node != _next->_node, false); @@ -39,7 +39,7 @@ is_valid() const { */ int WorkingNodePath:: get_num_nodes() const { - if (_next == (WorkingNodePath *)NULL) { + if (_next == nullptr) { Thread *current_thread = Thread::get_current_thread(); int pipeline_stage = current_thread->get_pipeline_stage(); return _start->get_length(pipeline_stage, current_thread); @@ -55,12 +55,12 @@ get_num_nodes() const { */ PandaNode *WorkingNodePath:: get_node(int index) const { - nassertr(index >= 0, NULL); + nassertr(index >= 0, nullptr); if (index == 0) { return _node; } - if (_next == (WorkingNodePath *)NULL) { + if (_next == nullptr) { return get_node_path().get_node(index - 1); } @@ -83,22 +83,22 @@ output(ostream &out) const { */ PT(NodePathComponent) WorkingNodePath:: r_get_node_path() const { - if (_next == (WorkingNodePath *)NULL) { - nassertr(_start != (NodePathComponent *)NULL, NULL); + if (_next == nullptr) { + nassertr(_start != nullptr, nullptr); return _start; } - nassertr(_start == (NodePathComponent *)NULL, NULL); - nassertr(_node != (PandaNode *)NULL, NULL); + nassertr(_start == nullptr, nullptr); + nassertr(_node != nullptr, nullptr); PT(NodePathComponent) comp = _next->r_get_node_path(); - nassertr(comp != (NodePathComponent *)NULL, NULL); + nassertr(comp != nullptr, nullptr); Thread *current_thread = Thread::get_current_thread(); int pipeline_stage = current_thread->get_pipeline_stage(); PT(NodePathComponent) result = PandaNode::get_component(comp, _node, pipeline_stage, current_thread); - if (result == (NodePathComponent *)NULL) { + if (result == nullptr) { // This means we found a disconnected chain in the WorkingNodePath's // ancestry: the node above this node isn't connected. In this case, // don't attempt to go higher; just truncate the NodePath at the bottom of diff --git a/panda/src/pgraphnodes/callbackNode.I b/panda/src/pgraphnodes/callbackNode.I index 4db6cb59de..6314f124e3 100644 --- a/panda/src/pgraphnodes/callbackNode.I +++ b/panda/src/pgraphnodes/callbackNode.I @@ -44,7 +44,7 @@ set_cull_callback(CallbackObject *object) { */ INLINE void CallbackNode:: clear_cull_callback() { - set_cull_callback(NULL); + set_cull_callback(nullptr); } /** @@ -86,7 +86,7 @@ set_draw_callback(CallbackObject *object) { */ INLINE void CallbackNode:: clear_draw_callback() { - set_draw_callback(NULL); + set_draw_callback(nullptr); } /** diff --git a/panda/src/pgraphnodes/callbackNode.cxx b/panda/src/pgraphnodes/callbackNode.cxx index 17424d5a0a..12018de8da 100644 --- a/panda/src/pgraphnodes/callbackNode.cxx +++ b/panda/src/pgraphnodes/callbackNode.cxx @@ -90,7 +90,7 @@ safe_to_combine() const { bool CallbackNode:: cull_callback(CullTraverser *trav, CullTraverserData &data) { CallbackObject *cbobj = get_cull_callback(); - if (cbobj != (CallbackObject *)NULL) { + if (cbobj != nullptr) { NodeCullCallbackData cbdata(trav, data); cbobj->do_callback(&cbdata); @@ -130,9 +130,9 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { // CullableObject for the draw_callback, if any. We don't need to pass any // Geoms, however. CallbackObject *cbobj = get_draw_callback(); - if (cbobj != (CallbackObject *)NULL) { + if (cbobj != nullptr) { CullableObject *object = - new CullableObject(NULL, data._state, + new CullableObject(nullptr, data._state, data.get_internal_transform(trav)); object->set_draw_callback(cbobj); trav->get_cull_handler()->record_object(object, trav); diff --git a/panda/src/pgraphnodes/computeNode.cxx b/panda/src/pgraphnodes/computeNode.cxx index 7962378afa..0a55d988ef 100644 --- a/panda/src/pgraphnodes/computeNode.cxx +++ b/panda/src/pgraphnodes/computeNode.cxx @@ -93,7 +93,7 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { // CullableObject for the Dispatcher. We don't need to pass any Geoms, // however. CullableObject *object = - new CullableObject(NULL, data._state, + new CullableObject(nullptr, data._state, data.get_internal_transform(trav)); object->set_draw_callback(_dispatcher); trav->get_cull_handler()->record_object(object, trav); diff --git a/panda/src/pgraphnodes/fadeLodNode.cxx b/panda/src/pgraphnodes/fadeLodNode.cxx index de952457e8..92141d7f2d 100644 --- a/panda/src/pgraphnodes/fadeLodNode.cxx +++ b/panda/src/pgraphnodes/fadeLodNode.cxx @@ -99,7 +99,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { double now = ClockObject::get_global_clock()->get_frame_time(); - if (ldata == (AuxSceneData *)NULL || now > ldata->get_expiration_time()) { + if (ldata == nullptr || now > ldata->get_expiration_time()) { // This is the first time we have rendered this instance of this LOD node // in a while. ldata = new FadeLODNodeData; @@ -169,7 +169,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // drawing the old LOD opaque with z writing on if (out_child >= 0 && out_child < get_num_children()) { PandaNode *child = get_child(out_child); - if (child != (PandaNode *)NULL) { + if (child != nullptr) { CullTraverserData next_data_out(data, child); next_data_out._state = next_data_out._state->compose(get_fade_1_old_state()); @@ -179,7 +179,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { if (in_child >= 0 && in_child < get_num_children()) { PandaNode *child = get_child(in_child); - if (child != (PandaNode *)NULL) { + if (child != nullptr) { CullTraverserData next_data_in(data, child); PN_stdfloat in_alpha = elapsed / half_fade_time; @@ -194,7 +194,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // draw the opaque new LOD with z write on if (in_child >= 0 && in_child < get_num_children()) { PandaNode *child = get_child(in_child); - if (child != (PandaNode *)NULL) { + if (child != nullptr) { CullTraverserData next_data_in(data, child); next_data_in._state = next_data_in._state->compose(get_fade_2_new_state()); @@ -204,7 +204,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { if (out_child >= 0 && out_child < get_num_children()) { PandaNode *child = get_child(out_child); - if (child != (PandaNode *)NULL) { + if (child != nullptr) { CullTraverserData next_data_out(data, child); PN_stdfloat out_alpha = 1.0f - (elapsed - half_fade_time) / half_fade_time; @@ -224,7 +224,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { int index = ldata->_fade_in; if (index >= 0 && index < get_num_children()) { PandaNode *child = get_child(index); - if (child != (PandaNode *)NULL) { + if (child != nullptr) { CullTraverserData next_data(data, child); trav->traverse(next_data); } @@ -278,7 +278,7 @@ set_fade_state_override(int override) { */ CPT(RenderState) FadeLODNode:: get_fade_1_old_state() { - if (_fade_1_old_state == (const RenderState *)NULL) { + if (_fade_1_old_state == nullptr) { _fade_1_old_state = RenderState::make_empty(); } @@ -291,7 +291,7 @@ get_fade_1_old_state() { */ CPT(RenderState) FadeLODNode:: get_fade_1_new_state(PN_stdfloat in_alpha) { - if (_fade_1_new_state == (const RenderState *)NULL) { + if (_fade_1_new_state == nullptr) { _fade_1_new_state = RenderState::make (TransparencyAttrib::make(TransparencyAttrib::M_alpha), CullBinAttrib::make(_fade_bin_name, _fade_bin_draw_order), @@ -310,7 +310,7 @@ get_fade_1_new_state(PN_stdfloat in_alpha) { */ CPT(RenderState) FadeLODNode:: get_fade_2_old_state(PN_stdfloat out_alpha) { - if (_fade_2_old_state == (const RenderState *)NULL) { + if (_fade_2_old_state == nullptr) { _fade_2_old_state = RenderState::make (TransparencyAttrib::make(TransparencyAttrib::M_alpha), DepthWriteAttrib::make(DepthWriteAttrib::M_off), @@ -329,7 +329,7 @@ get_fade_2_old_state(PN_stdfloat out_alpha) { */ CPT(RenderState) FadeLODNode:: get_fade_2_new_state() { - if (_fade_2_new_state == (const RenderState *)NULL) { + if (_fade_2_new_state == nullptr) { _fade_2_new_state = RenderState::make (DepthOffsetAttrib::make(), _fade_state_override); diff --git a/panda/src/pgraphnodes/lightLensNode.I b/panda/src/pgraphnodes/lightLensNode.I index 1df14eb971..9c59b6c998 100644 --- a/panda/src/pgraphnodes/lightLensNode.I +++ b/panda/src/pgraphnodes/lightLensNode.I @@ -110,7 +110,7 @@ INLINE GraphicsOutputBase *LightLensNode:: get_shadow_buffer(GraphicsStateGuardianBase *gsg) { ShadowBuffers::iterator it = _sbuffers.find(gsg); if (it == _sbuffers.end()) { - return NULL; + return nullptr; } else { return (*it).second; } diff --git a/panda/src/pgraphnodes/lodNode.cxx b/panda/src/pgraphnodes/lodNode.cxx index 4c2ca87528..e39f0d0c97 100644 --- a/panda/src/pgraphnodes/lodNode.cxx +++ b/panda/src/pgraphnodes/lodNode.cxx @@ -160,7 +160,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { if (in_range) { // This switch level is in range. Draw its children. PandaNode *child = get_child(index); - if (child != (PandaNode *)NULL) { + if (child != nullptr) { CullTraverserData next_data(data, child); trav->traverse(next_data); } @@ -384,7 +384,7 @@ show_switches_cull_callback(CullTraverser *trav, CullTraverserData &data) { // wireframe mode. if (index < get_num_children()) { PandaNode *child = get_child(index); - if (child != (PandaNode *)NULL) { + if (child != nullptr) { CullTraverserData next_data3(data, child); next_data3._state = next_data3._state->compose(sw.get_viz_model_state()); trav->traverse(next_data3); @@ -524,7 +524,7 @@ do_verify_child_bounds(const LODNode::CData *cdata, int index, if (index < get_num_children()) { const Switch &sw = cdata->_switch_vector[index]; PandaNode *child = get_child(index); - if (child != (PandaNode *)NULL) { + if (child != nullptr) { UpdateSeq seq; CPT(BoundingVolume) bv = child->get_bounds(seq); diff --git a/panda/src/pgraphnodes/nodeCullCallbackData.cxx b/panda/src/pgraphnodes/nodeCullCallbackData.cxx index b0cbd9d980..e4ee2acdb1 100644 --- a/panda/src/pgraphnodes/nodeCullCallbackData.cxx +++ b/panda/src/pgraphnodes/nodeCullCallbackData.cxx @@ -47,9 +47,9 @@ upcall() { // CullableObject for the draw_callback, if any. We don't need to pass // any Geoms, however. CallbackObject *cbobj = cbnode->get_draw_callback(); - if (cbobj != (CallbackObject *)NULL) { + if (cbobj != nullptr) { CullableObject *object = - new CullableObject(NULL, _data._state, + new CullableObject(nullptr, _data._state, _data.get_internal_transform(_trav)); object->set_draw_callback(cbobj); _trav->get_cull_handler()->record_object(object, _trav); diff --git a/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx b/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx index b24678b333..7e374721f6 100644 --- a/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx +++ b/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx @@ -284,7 +284,7 @@ collect_statistics(PandaNode *node, bool under_instance) { _num_nodes_with_attribs++; const RenderAttrib *attrib = node->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); for (int i = 0; i < ta->get_num_on_stages(); i++) { collect_statistics(ta->get_on_texture(ta->get_on_stage(i))); @@ -336,7 +336,7 @@ collect_statistics(PandaNode *node, bool under_instance) { */ void SceneGraphAnalyzer:: collect_statistics(GeomNode *geom_node) { - nassertv(geom_node != (GeomNode *)NULL); + nassertv(geom_node != nullptr); ++_num_geom_nodes; @@ -351,7 +351,7 @@ collect_statistics(GeomNode *geom_node) { const RenderAttrib *attrib = geom_state->get_attrib(TextureAttrib::get_class_slot()); - if (attrib != (RenderAttrib *)NULL) { + if (attrib != nullptr) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); for (int i = 0; i < ta->get_num_on_stages(); i++) { collect_statistics(ta->get_on_texture(ta->get_on_stage(i))); @@ -477,7 +477,7 @@ collect_statistics(const Geom *geom) { */ void SceneGraphAnalyzer:: collect_statistics(Texture *texture) { - nassertv(texture != (Texture *)NULL); + nassertv(texture != nullptr); Textures::iterator ti = _textures.find(texture); if (ti == _textures.end()) { @@ -506,7 +506,7 @@ collect_statistics(Texture *texture) { */ void SceneGraphAnalyzer:: collect_statistics(const GeomVertexArrayData *vadata) { - nassertv(vadata != NULL); + nassertv(vadata != nullptr); bool inserted = _vadatas.insert(vadata).second; if (inserted) { // This is the first time we've encountered this vertex array. @@ -523,7 +523,7 @@ collect_statistics(const GeomVertexArrayData *vadata) { */ void SceneGraphAnalyzer:: collect_prim_statistics(const GeomVertexArrayData *vadata) { - nassertv(vadata != NULL); + nassertv(vadata != nullptr); bool inserted = _prim_vadatas.insert(vadata).second; if (inserted) { // This is the first time we've encountered this vertex array. diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index a2a749729e..af4410aea2 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -661,23 +661,23 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { // These variables will hold the results of register allocation. - const char *tangent_freg = 0; - const char *binormal_freg = 0; + const char *tangent_freg = nullptr; + const char *binormal_freg = nullptr; string tangent_input; string binormal_input; pmap texcoord_fregs; pvector lightcoord_fregs; - const char *world_position_freg = 0; - const char *world_normal_freg = 0; - const char *eye_position_freg = 0; - const char *eye_normal_freg = 0; - const char *hpos_freg = 0; + const char *world_position_freg = nullptr; + const char *world_normal_freg = nullptr; + const char *eye_position_freg = nullptr; + const char *eye_normal_freg = nullptr; + const char *hpos_freg = nullptr; const char *position_vreg; - const char *transform_weight_vreg = 0; + const char *transform_weight_vreg = nullptr; const char *normal_vreg; - const char *color_vreg = 0; - const char *transform_index_vreg = 0; + const char *color_vreg = nullptr; + const char *transform_index_vreg = nullptr; if (_use_generic_attr) { position_vreg = "ATTR0"; diff --git a/panda/src/pgraphnodes/spotlight.cxx b/panda/src/pgraphnodes/spotlight.cxx index 99432a904b..5935485ceb 100644 --- a/panda/src/pgraphnodes/spotlight.cxx +++ b/panda/src/pgraphnodes/spotlight.cxx @@ -123,7 +123,7 @@ write(ostream &out, int indent_level) const { } Lens *lens = get_lens(); - if (lens != (Lens *)NULL) { + if (lens != nullptr) { lens->write(out, indent_level + 2); } } @@ -214,12 +214,12 @@ bind(GraphicsStateGuardianBase *gsg, const NodePath &light, int light_id) { void Spotlight:: fill_viz_geom(GeomNode *viz_geom) { Lens *lens = get_lens(); - if (lens == (Lens *)NULL) { + if (lens == nullptr) { return; } PT(Geom) geom = lens->make_geometry(); - if (geom == (Geom *)NULL) { + if (geom == nullptr) { return; } diff --git a/panda/src/pgui/pgEntry.I b/panda/src/pgui/pgEntry.I index dec418c9fd..2e15320b8f 100644 --- a/panda/src/pgui/pgEntry.I +++ b/panda/src/pgui/pgEntry.I @@ -23,7 +23,7 @@ INLINE bool PGEntry:: set_text(const string &text) { LightReMutexHolder holder(_lock); TextNode *text_node = get_text_def(S_focus); - nassertr(text_node != (TextNode *)NULL, false); + nassertr(text_node != nullptr, false); return set_wtext(text_node->decode_text(text)); } @@ -38,7 +38,7 @@ INLINE string PGEntry:: get_plain_text() const { LightReMutexHolder holder(_lock); TextNode *text_node = get_text_def(S_focus); - nassertr(text_node != (TextNode *)NULL, string()); + nassertr(text_node != nullptr, string()); return text_node->encode_wtext(get_plain_wtext()); } @@ -51,7 +51,7 @@ INLINE string PGEntry:: get_text() const { LightReMutexHolder holder(_lock); TextNode *text_node = get_text_def(S_focus); - nassertr(text_node != (TextNode *)NULL, string()); + nassertr(text_node != nullptr, string()); return text_node->encode_wtext(get_wtext()); } diff --git a/panda/src/pgui/pgEntry.cxx b/panda/src/pgui/pgEntry.cxx index c9f84fae4f..bc8fb204c7 100644 --- a/panda/src/pgui/pgEntry.cxx +++ b/panda/src/pgui/pgEntry.cxx @@ -49,7 +49,7 @@ PGEntry(const string &name) : _max_width = 0.0f; _num_lines = 1; _accept_enabled = true; - _last_text_def = (TextNode *)NULL; + _last_text_def = nullptr; _text_geom_stale = true; _text_geom_flattened = true; _blink_start = 0.0f; @@ -117,7 +117,7 @@ PGEntry(const PGEntry ©) : _overflow_mode(copy._overflow_mode) { _cursor_stale = true; - _last_text_def = (TextNode *)NULL; + _last_text_def = nullptr; _text_geom_stale = true; _text_geom_flattened = true; @@ -642,7 +642,7 @@ void PGEntry:: set_text_def(int state, TextNode *node) { LightReMutexHolder holder(_lock); nassertv(state >= 0 && state < 1000); // Sanity check. - if (node == (TextNode *)NULL && state >= (int)_text_defs.size()) { + if (node == nullptr && state >= (int)_text_defs.size()) { // If we're setting it to NULL, we don't need to slot a new one. return; } @@ -662,7 +662,7 @@ get_text_def(int state) const { // If we don't have a definition, use the global one. return get_text_node(); } - if (_text_defs[state] == (TextNode *)NULL) { + if (_text_defs[state] == nullptr) { return get_text_node(); } return _text_defs[state]; @@ -715,7 +715,7 @@ is_wtext() const { void PGEntry:: slot_text_def(int state) { while (state >= (int)_text_defs.size()) { - _text_defs.push_back((TextNode *)NULL); + _text_defs.push_back(nullptr); } } @@ -725,7 +725,7 @@ slot_text_def(int state) { void PGEntry:: update_text() { TextNode *node = get_text_def(get_state()); - nassertv(node != (TextNode *)NULL); + nassertv(node != nullptr); if (_text_geom_stale || node != _last_text_def) { TextProperties props = *node; @@ -846,7 +846,7 @@ update_text() { void PGEntry:: update_cursor() { TextNode *node = get_text_def(get_state()); - nassertv(node != (TextNode *)NULL); + nassertv(node != nullptr); _cursor_scale.set_mat(node->get_transform()); _cursor_scale.set_color(node->get_text_color()); diff --git a/panda/src/pgui/pgFrameStyle.cxx b/panda/src/pgui/pgFrameStyle.cxx index c2106e3ef2..0f0458265c 100644 --- a/panda/src/pgui/pgFrameStyle.cxx +++ b/panda/src/pgui/pgFrameStyle.cxx @@ -191,7 +191,7 @@ generate_into(const NodePath &parent, const LVecBase4 &frame, break; } - if (new_node != (PandaNode *)NULL && _color[3] != 1.0f) { + if (new_node != nullptr && _color[3] != 1.0f) { // We've got some alpha on the color; we need transparency. new_node->set_attrib(TransparencyAttrib::make(TransparencyAttrib::M_alpha)); } diff --git a/panda/src/pgui/pgItem.I b/panda/src/pgui/pgItem.I index 7d00a0e595..ce2c9f0532 100644 --- a/panda/src/pgui/pgItem.I +++ b/panda/src/pgui/pgItem.I @@ -42,11 +42,11 @@ get_region() const { INLINE void PGItem:: set_notify(PGItemNotify *notify) { LightReMutexHolder holder(_lock); - if (_notify != (PGItemNotify *)NULL) { + if (_notify != nullptr) { _notify->remove_item(this); } _notify = notify; - if (_notify != (PGItemNotify *)NULL) { + if (_notify != nullptr) { _notify->add_item(this); } } @@ -58,7 +58,7 @@ set_notify(PGItemNotify *notify) { INLINE bool PGItem:: has_notify() const { LightReMutexHolder holder(_lock); - return (_notify != (PGItemNotify *)NULL); + return (_notify != nullptr); } /** diff --git a/panda/src/pgui/pgItem.cxx b/panda/src/pgui/pgItem.cxx index 53966e26d7..da3dfe86ba 100644 --- a/panda/src/pgui/pgItem.cxx +++ b/panda/src/pgui/pgItem.cxx @@ -37,7 +37,7 @@ TypeHandle PGItem::_type_handle; PT(TextNode) PGItem::_text_node; -PGItem *PGItem::_focus_item = (PGItem *)NULL; +PGItem *PGItem::_focus_item = nullptr; PGItem::BackgroundFocus PGItem::_background_focus; @@ -59,7 +59,7 @@ PGItem(const string &name) : { set_cull_callback(); - _notify = NULL; + _notify = nullptr; _has_frame = false; _frame.set(0, 0, 0, 0); _region = new PGMouseWatcherRegion(this); @@ -72,17 +72,17 @@ PGItem(const string &name) : */ PGItem:: ~PGItem() { - if (_notify != (PGItemNotify *)NULL) { + if (_notify != nullptr) { _notify->remove_item(this); - _notify = NULL; + _notify = nullptr; } nassertv(_region->_item == this); - _region->_item = (PGItem *)NULL; + _region->_item = nullptr; set_background_focus(false); if (_focus_item == this) { - _focus_item = (PGItem *)NULL; + _focus_item = nullptr; } } @@ -100,7 +100,7 @@ PGItem(const PGItem ©) : , _sounds(copy._sounds) #endif { - _notify = NULL; + _notify = nullptr; _region = new PGMouseWatcherRegion(this); // We give our region the same name as the region for the PGItem we're @@ -415,7 +415,7 @@ activate_region(const LMatrix4 &transform, int sort, } LVecBase4 frame; - if (cpa != (ClipPlaneAttrib *)NULL && cpa->get_num_on_planes() != 0) { + if (cpa != nullptr && cpa->get_num_on_planes() != 0) { // Apply the clip plane(s) andor scissor region now that we are here in // world space. @@ -462,7 +462,7 @@ activate_region(const LMatrix4 &transform, int sort, max(max(ll[up_axis], lr[up_axis]), max(ul[up_axis], ur[up_axis]))); } - if (sa != (ScissorAttrib *)NULL) { + if (sa != nullptr) { // Also restrict it to within the scissor region. const LVecBase4 &sf = sa->get_frame(); // Expand sf from 0..1 to -1..1. @@ -835,7 +835,7 @@ set_focus(bool focus) { // Set the keyboard focus to this item. if (_focus_item != this) { - if (_focus_item != (PGItem *)NULL) { + if (_focus_item != nullptr) { // Clear the focus from whatever item currently has it. _focus_item->set_focus(false); } @@ -849,7 +849,7 @@ set_focus(bool focus) { } else { if (_focus_item == this) { // Remove this item from the focus. - _focus_item = (PGItem *)NULL; + _focus_item = nullptr; } if (get_focus()) { @@ -1033,7 +1033,7 @@ get_sound(const string &event) const { if (si != _sounds.end()) { return (*si).second; } - return (AudioSound *)NULL; + return nullptr; } /** @@ -1054,7 +1054,7 @@ has_sound(const string &event) const { */ TextNode *PGItem:: get_text_node() { - if (_text_node == (TextNode *)NULL) { + if (_text_node == nullptr) { _text_node = new TextNode("pguiText"); _text_node->set_text_color(0.0f, 0.0f, 0.0f, 1.0f); @@ -1093,7 +1093,7 @@ play_sound(const string &event) { */ void PGItem:: reduce_region(LVecBase4 &frame, PGItem *obscurer) const { - if (obscurer != (PGItem *)NULL && !obscurer->is_overall_hidden()) { + if (obscurer != nullptr && !obscurer->is_overall_hidden()) { LVecBase4 oframe = get_relative_frame(obscurer); // Determine the four rectangular regions on the four sides of the diff --git a/panda/src/pgui/pgItemNotify.cxx b/panda/src/pgui/pgItemNotify.cxx index 52f01dc63b..da232d6a95 100644 --- a/panda/src/pgui/pgItemNotify.cxx +++ b/panda/src/pgui/pgItemNotify.cxx @@ -23,7 +23,7 @@ PGItemNotify:: // Disconnect all of the items that are connected to this object. PGItem *item = (*_items.begin()); nassertv(item->get_notify() == this); - (*_items.begin())->set_notify(NULL); + (*_items.begin())->set_notify(nullptr); } } diff --git a/panda/src/pgui/pgMouseWatcherGroup.I b/panda/src/pgui/pgMouseWatcherGroup.I index db3ce6b80a..f0ae87c891 100644 --- a/panda/src/pgui/pgMouseWatcherGroup.I +++ b/panda/src/pgui/pgMouseWatcherGroup.I @@ -25,5 +25,5 @@ PGMouseWatcherGroup(PGTop *top) : _top(top) { INLINE void PGMouseWatcherGroup:: clear_top(PGTop *top) { nassertv(_top == top); - _top = (PGTop *)NULL; + _top = nullptr; } diff --git a/panda/src/pgui/pgMouseWatcherGroup.cxx b/panda/src/pgui/pgMouseWatcherGroup.cxx index ccc3e91f31..d5f14976ce 100644 --- a/panda/src/pgui/pgMouseWatcherGroup.cxx +++ b/panda/src/pgui/pgMouseWatcherGroup.cxx @@ -23,8 +23,8 @@ PGMouseWatcherGroup:: ~PGMouseWatcherGroup() { // When the MouseWatcherGroup destructs for whatever reason, the PGTop // object should lose its MouseWatcher. - if (_top != (PGTop *)NULL) { - _top->_watcher_group = (PGMouseWatcherGroup *)NULL; - _top->set_mouse_watcher((MouseWatcher *)NULL); + if (_top != nullptr) { + _top->_watcher_group = nullptr; + _top->set_mouse_watcher(nullptr); } } diff --git a/panda/src/pgui/pgMouseWatcherRegion.cxx b/panda/src/pgui/pgMouseWatcherRegion.cxx index 6e0a18daad..2f0155722f 100644 --- a/panda/src/pgui/pgMouseWatcherRegion.cxx +++ b/panda/src/pgui/pgMouseWatcherRegion.cxx @@ -47,7 +47,7 @@ PGMouseWatcherRegion:: */ void PGMouseWatcherRegion:: enter_region(const MouseWatcherParameter ¶m) { - if (_item != (PGItem *)NULL) { + if (_item != nullptr) { _item->enter_region(param); } } @@ -60,7 +60,7 @@ enter_region(const MouseWatcherParameter ¶m) { */ void PGMouseWatcherRegion:: exit_region(const MouseWatcherParameter ¶m) { - if (_item != (PGItem *)NULL) { + if (_item != nullptr) { _item->exit_region(param); } } @@ -73,7 +73,7 @@ exit_region(const MouseWatcherParameter ¶m) { */ void PGMouseWatcherRegion:: within_region(const MouseWatcherParameter ¶m) { - if (_item != (PGItem *)NULL) { + if (_item != nullptr) { _item->within_region(param); } } @@ -84,7 +84,7 @@ within_region(const MouseWatcherParameter ¶m) { */ void PGMouseWatcherRegion:: without_region(const MouseWatcherParameter ¶m) { - if (_item != (PGItem *)NULL) { + if (_item != nullptr) { _item->without_region(param); } } @@ -95,7 +95,7 @@ without_region(const MouseWatcherParameter ¶m) { */ void PGMouseWatcherRegion:: press(const MouseWatcherParameter ¶m) { - if (_item != (PGItem *)NULL) { + if (_item != nullptr) { _item->press(param, false); } } @@ -106,7 +106,7 @@ press(const MouseWatcherParameter ¶m) { */ void PGMouseWatcherRegion:: release(const MouseWatcherParameter ¶m) { - if (_item != (PGItem *)NULL) { + if (_item != nullptr) { _item->release(param, false); } } @@ -116,7 +116,7 @@ release(const MouseWatcherParameter ¶m) { */ void PGMouseWatcherRegion:: keystroke(const MouseWatcherParameter ¶m) { - if (_item != (PGItem *)NULL) { + if (_item != nullptr) { _item->keystroke(param, false); } } @@ -127,7 +127,7 @@ keystroke(const MouseWatcherParameter ¶m) { */ void PGMouseWatcherRegion:: candidate(const MouseWatcherParameter ¶m) { - if (_item != (PGItem *)NULL) { + if (_item != nullptr) { _item->candidate(param, false); } } @@ -138,7 +138,7 @@ candidate(const MouseWatcherParameter ¶m) { */ void PGMouseWatcherRegion:: move(const MouseWatcherParameter ¶m) { - if (_item != (PGItem *)NULL) { + if (_item != nullptr) { _item->move(param); } } diff --git a/panda/src/pgui/pgScrollFrame.I b/panda/src/pgui/pgScrollFrame.I index ede2f4201e..69353db31b 100644 --- a/panda/src/pgui/pgScrollFrame.I +++ b/panda/src/pgui/pgScrollFrame.I @@ -127,11 +127,11 @@ get_auto_hide() const { INLINE void PGScrollFrame:: set_horizontal_slider(PGSliderBar *horizontal_slider) { LightReMutexHolder holder(_lock); - if (_horizontal_slider != (PGSliderBar *)NULL) { - _horizontal_slider->set_notify(NULL); + if (_horizontal_slider != nullptr) { + _horizontal_slider->set_notify(nullptr); } _horizontal_slider = horizontal_slider; - if (_horizontal_slider != (PGSliderBar *)NULL) { + if (_horizontal_slider != nullptr) { _horizontal_slider->set_notify(this); } _needs_recompute_clip = true; @@ -143,7 +143,7 @@ set_horizontal_slider(PGSliderBar *horizontal_slider) { */ INLINE void PGScrollFrame:: clear_horizontal_slider() { - set_horizontal_slider(NULL); + set_horizontal_slider(nullptr); } /** @@ -164,11 +164,11 @@ get_horizontal_slider() const { INLINE void PGScrollFrame:: set_vertical_slider(PGSliderBar *vertical_slider) { LightReMutexHolder holder(_lock); - if (_vertical_slider != (PGSliderBar *)NULL) { - _vertical_slider->set_notify(NULL); + if (_vertical_slider != nullptr) { + _vertical_slider->set_notify(nullptr); } _vertical_slider = vertical_slider; - if (_vertical_slider != (PGSliderBar *)NULL) { + if (_vertical_slider != nullptr) { _vertical_slider->set_notify(this); } _needs_recompute_clip = true; @@ -180,7 +180,7 @@ set_vertical_slider(PGSliderBar *vertical_slider) { */ INLINE void PGScrollFrame:: clear_vertical_slider() { - set_vertical_slider(NULL); + set_vertical_slider(nullptr); } /** diff --git a/panda/src/pgui/pgScrollFrame.cxx b/panda/src/pgui/pgScrollFrame.cxx index e930ba3b15..c35ea7b395 100644 --- a/panda/src/pgui/pgScrollFrame.cxx +++ b/panda/src/pgui/pgScrollFrame.cxx @@ -30,8 +30,8 @@ PGScrollFrame(const string &name) : PGVirtualFrame(name) _virtual_frame.set(0.0f, 0.0f, 0.0f, 0.0f); _manage_pieces = false; _auto_hide = false; - _horizontal_slider = NULL; - _vertical_slider = NULL; + _horizontal_slider = nullptr; + _vertical_slider = nullptr; } /** @@ -39,8 +39,8 @@ PGScrollFrame(const string &name) : PGVirtualFrame(name) */ PGScrollFrame:: ~PGScrollFrame() { - set_horizontal_slider(NULL); - set_vertical_slider(NULL); + set_horizontal_slider(nullptr); + set_vertical_slider(nullptr); } /** @@ -143,13 +143,13 @@ setup(PN_stdfloat width, PN_stdfloat height, set_virtual_frame(left, right, bottom, top); // Remove the slider nodes created by a previous call to setup(), if any. - if (_horizontal_slider != (PGSliderBar *)NULL) { + if (_horizontal_slider != nullptr) { remove_child(_horizontal_slider); - set_horizontal_slider(NULL); + set_horizontal_slider(nullptr); } - if (_vertical_slider != (PGSliderBar *)NULL) { + if (_vertical_slider != nullptr) { remove_child(_vertical_slider); - set_vertical_slider(NULL); + set_vertical_slider(nullptr); } // Create new slider bars. @@ -185,7 +185,7 @@ remanage() { bool got_horizontal = false; PN_stdfloat horizontal_width = 0.0f; - if (_horizontal_slider != (PGSliderBar *)NULL) { + if (_horizontal_slider != nullptr) { got_horizontal = true; const LVecBase4 &slider_frame = _horizontal_slider->get_frame(); horizontal_width = slider_frame[3] - slider_frame[2]; @@ -193,7 +193,7 @@ remanage() { bool got_vertical = false; PN_stdfloat vertical_width = 0.0f; - if (_vertical_slider != (PGSliderBar *)NULL) { + if (_vertical_slider != nullptr) { got_vertical = true; const LVecBase4 &slider_frame = _vertical_slider->get_frame(); vertical_width = slider_frame[1] - slider_frame[0]; @@ -235,7 +235,7 @@ remanage() { } // Now show or hide the sliders appropriately. - if (_horizontal_slider != (PGSliderBar *)NULL) { + if (_horizontal_slider != nullptr) { if (got_horizontal) { _horizontal_slider->set_overall_hidden(false); } else { @@ -244,7 +244,7 @@ remanage() { horizontal_width = 0.0f; } } - if (_vertical_slider != (PGSliderBar *)NULL) { + if (_vertical_slider != nullptr) { if (got_vertical) { _vertical_slider->set_overall_hidden(false); } else { @@ -350,10 +350,10 @@ recompute_clip() { set_clip_frame(clip); - if (_horizontal_slider != (PGSliderBar *)NULL) { + if (_horizontal_slider != nullptr) { _horizontal_slider->set_page_size((clip[1] - clip[0]) / (_virtual_frame[1] - _virtual_frame[0])); } - if (_vertical_slider != (PGSliderBar *)NULL) { + if (_vertical_slider != nullptr) { _vertical_slider->set_page_size((clip[3] - clip[2]) / (_virtual_frame[3] - _virtual_frame[2])); } } @@ -390,7 +390,7 @@ interpolate_canvas(PN_stdfloat clip_min, PN_stdfloat clip_max, PGSliderBar *slider_bar) { LightReMutexHolder holder(_lock); PN_stdfloat t = 0.0f; - if (slider_bar != (PGSliderBar *)NULL) { + if (slider_bar != nullptr) { t = slider_bar->get_ratio(); } diff --git a/panda/src/pgui/pgSliderBar.I b/panda/src/pgui/pgSliderBar.I index 927424706f..866dd1dec3 100644 --- a/panda/src/pgui/pgSliderBar.I +++ b/panda/src/pgui/pgSliderBar.I @@ -185,7 +185,7 @@ INLINE bool PGSliderBar:: is_button_down() const { LightReMutexHolder holder(_lock); return _dragging || _mouse_button_page || - (_scroll_button_held != (PGItem *)NULL); + (_scroll_button_held != nullptr); } /** @@ -243,11 +243,11 @@ get_manage_pieces() const { INLINE void PGSliderBar:: set_thumb_button(PGButton *thumb_button) { LightReMutexHolder holder(_lock); - if (_thumb_button != (PGButton *)NULL) { - _thumb_button->set_notify(NULL); + if (_thumb_button != nullptr) { + _thumb_button->set_notify(nullptr); } _thumb_button = thumb_button; - if (_thumb_button != (PGButton *)NULL) { + if (_thumb_button != nullptr) { _thumb_button->set_notify(this); } _needs_remanage = true; @@ -260,7 +260,7 @@ set_thumb_button(PGButton *thumb_button) { */ INLINE void PGSliderBar:: clear_thumb_button() { - set_thumb_button(NULL); + set_thumb_button(nullptr); } /** @@ -284,11 +284,11 @@ get_thumb_button() const { INLINE void PGSliderBar:: set_left_button(PGButton *left_button) { LightReMutexHolder holder(_lock); - if (_left_button != (PGButton *)NULL) { - _left_button->set_notify(NULL); + if (_left_button != nullptr) { + _left_button->set_notify(nullptr); } _left_button = left_button; - if (_left_button != (PGButton *)NULL) { + if (_left_button != nullptr) { _left_button->set_notify(this); } _needs_remanage = true; @@ -301,7 +301,7 @@ set_left_button(PGButton *left_button) { */ INLINE void PGSliderBar:: clear_left_button() { - set_left_button(NULL); + set_left_button(nullptr); } /** @@ -325,11 +325,11 @@ get_left_button() const { INLINE void PGSliderBar:: set_right_button(PGButton *right_button) { LightReMutexHolder holder(_lock); - if (_right_button != (PGButton *)NULL) { - _right_button->set_notify(NULL); + if (_right_button != nullptr) { + _right_button->set_notify(nullptr); } _right_button = right_button; - if (_right_button != (PGButton *)NULL) { + if (_right_button != nullptr) { _right_button->set_notify(this); } _needs_remanage = true; @@ -342,7 +342,7 @@ set_right_button(PGButton *right_button) { */ INLINE void PGSliderBar:: clear_right_button() { - set_right_button(NULL); + set_right_button(nullptr); } /** diff --git a/panda/src/pgui/pgSliderBar.cxx b/panda/src/pgui/pgSliderBar.cxx index da09bf73f3..ae7720140a 100644 --- a/panda/src/pgui/pgSliderBar.cxx +++ b/panda/src/pgui/pgSliderBar.cxx @@ -42,7 +42,7 @@ PGSliderBar(const string &name) _needs_remanage = false; _needs_recompute = true; _needs_reposition = false; - _scroll_button_held = NULL; + _scroll_button_held = nullptr; _mouse_button_page = false; _dragging = false; _thumb_width = 0.1f; @@ -76,7 +76,7 @@ PGSliderBar(const PGSliderBar ©) : { _needs_remanage = false; _needs_recompute = true; - _scroll_button_held = NULL; + _scroll_button_held = nullptr; _mouse_button_page = false; _dragging = false; } @@ -109,7 +109,7 @@ press(const MouseWatcherParameter ¶m, bool background) { if (_range_x != 0.0f) { _mouse_button_page = true; - _scroll_button_held = NULL; + _scroll_button_held = nullptr; advance_page(); _next_advance_time = ClockObject::get_global_clock()->get_frame_time() + scroll_initial_delay; @@ -180,7 +180,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { recompute(); } - if (_scroll_button_held != (PGItem *)NULL && + if (_scroll_button_held != nullptr && _next_advance_time <= ClockObject::get_global_clock()->get_frame_time()) { advance_scroll(); } @@ -209,7 +209,7 @@ xform(const LMatrix4 &mat) { // Make sure we set the thumb to identity position first, so it won't be // accidentally flattened. - if (_thumb_button != (PGButton *)NULL) { + if (_thumb_button != nullptr) { _thumb_button->clear_transform(); } @@ -267,17 +267,17 @@ setup_scroll_bar(bool vertical, PN_stdfloat length, PN_stdfloat width, PN_stdflo style.set_width(bevel, bevel); // Remove the button nodes created by a previous call to setup(), if any. - if (_thumb_button != (PGButton *)NULL) { + if (_thumb_button != nullptr) { remove_child(_thumb_button); - set_thumb_button(NULL); + set_thumb_button(nullptr); } - if (_left_button != (PGButton *)NULL) { + if (_left_button != nullptr) { remove_child(_left_button); - set_left_button(NULL); + set_left_button(nullptr); } - if (_right_button != (PGButton *)NULL) { + if (_right_button != nullptr) { remove_child(_right_button); - set_right_button(NULL); + set_right_button(nullptr); } PT(PGButton) thumb = new PGButton("thumb"); @@ -336,17 +336,17 @@ setup_slider(bool vertical, PN_stdfloat length, PN_stdfloat width, PN_stdfloat b set_frame_style(0, style); // Remove the button nodes created by a previous call to setup(), if any. - if (_thumb_button != (PGButton *)NULL) { + if (_thumb_button != nullptr) { remove_child(_thumb_button); - set_thumb_button(NULL); + set_thumb_button(nullptr); } - if (_left_button != (PGButton *)NULL) { + if (_left_button != nullptr) { remove_child(_left_button); - set_left_button(NULL); + set_left_button(nullptr); } - if (_right_button != (PGButton *)NULL) { + if (_right_button != nullptr) { remove_child(_right_button); - set_right_button(NULL); + set_right_button(nullptr); } PT(PGButton) thumb = new PGButton("thumb"); @@ -372,13 +372,13 @@ set_active(bool active) { PGItem::set_active(active); // This also implicitly sets the managed pieces. - if (_thumb_button != (PGButton *)NULL) { + if (_thumb_button != nullptr) { _thumb_button->set_active(active); } - if (_left_button != (PGButton *)NULL) { + if (_left_button != nullptr) { _left_button->set_active(active); } - if (_right_button != (PGButton *)NULL) { + if (_right_button != nullptr) { _right_button->set_active(active); } } @@ -410,19 +410,19 @@ remanage() { 0.0f, (frame[2] + frame[3]) / 2.0f); - if (_left_button != (PGButton *)NULL) { + if (_left_button != nullptr) { _left_button->set_frame(-width / 2.0f, width / 2.0f, -width / 2.0f, width / 2.0f); _left_button->set_transform(TransformState::make_pos(center + ((width - length) / 2.0f) * _axis)); } - if (_right_button != (PGButton *)NULL) { + if (_right_button != nullptr) { _right_button->set_frame(-width / 2.0f, width / 2.0f, -width / 2.0f, width / 2.0f); _right_button->set_transform(TransformState::make_pos(center + ((length - width) / 2.0f) * _axis)); } - if (_thumb_button != (PGButton *)NULL) { + if (_thumb_button != nullptr) { _thumb_button->set_frame(-width / 2.0f, width / 2.0f, -width / 2.0f, width / 2.0f); _thumb_button->set_transform(TransformState::make_pos(center)); @@ -469,7 +469,7 @@ recompute() { PN_stdfloat trough_width = _max_x - _min_x; - if (_thumb_button == (PGButton *)NULL) { + if (_thumb_button == nullptr) { _thumb_width = 0.0f; _range_x = 0.0f; _thumb_start.set(0.0f, 0.0f, 0.0f); @@ -510,7 +510,7 @@ recompute() { PN_stdfloat trough_width = _max_x - _min_x; - if (_thumb_button == (PGButton *)NULL) { + if (_thumb_button == nullptr) { _thumb_width = 0.0f; _range_x = 0.0f; _thumb_start.set(0.0f, 0.0f, 0.0f); @@ -603,7 +603,7 @@ item_press(PGItem *item, const MouseWatcherParameter ¶m) { ClockObject::get_global_clock()->get_frame_time() + scroll_initial_delay; } else if (item == _thumb_button) { - _scroll_button_held = NULL; + _scroll_button_held = nullptr; begin_drag(); } } @@ -616,10 +616,10 @@ void PGSliderBar:: item_release(PGItem *item, const MouseWatcherParameter &) { LightReMutexHolder holder(_lock); if (item == _scroll_button_held) { - _scroll_button_held = NULL; + _scroll_button_held = nullptr; } else if (item == _thumb_button) { - _scroll_button_held = NULL; + _scroll_button_held = nullptr; if (_dragging) { end_drag(); } @@ -651,7 +651,7 @@ reposition() { PN_stdfloat t = get_ratio(); - if (_thumb_button != (PGButton *)NULL) { + if (_thumb_button != nullptr) { LPoint3 pos = (t * _range_x) * _axis + _thumb_start; CPT(TransformState) transform = TransformState::make_pos(pos); CPT(TransformState) orig_transform = _thumb_button->get_transform(); diff --git a/panda/src/pgui/pgTop.I b/panda/src/pgui/pgTop.I index 76bee2d409..775e8cf827 100644 --- a/panda/src/pgui/pgTop.I +++ b/panda/src/pgui/pgTop.I @@ -74,6 +74,6 @@ get_start_sort() const { */ INLINE void PGTop:: add_region(MouseWatcherRegion *region) { - nassertv(_watcher_group != (PGMouseWatcherGroup *)NULL); + nassertv(_watcher_group != nullptr); _watcher_group->add_region(region); } diff --git a/panda/src/pgui/pgTop.cxx b/panda/src/pgui/pgTop.cxx index b65aaa81ac..172f62123c 100644 --- a/panda/src/pgui/pgTop.cxx +++ b/panda/src/pgui/pgTop.cxx @@ -47,7 +47,7 @@ PGTop(const string &name) : */ PGTop:: ~PGTop() { - set_mouse_watcher((MouseWatcher *)NULL); + set_mouse_watcher(nullptr); } /** @@ -83,7 +83,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // We create a new MouseWatcherGroup for the purposes of collecting a new // set of regions visible onscreen. PT(PGMouseWatcherGroup) old_watcher_group; - if (_watcher_group != (PGMouseWatcherGroup *)NULL) { + if (_watcher_group != nullptr) { _watcher_group->clear_top(this); old_watcher_group = _watcher_group; _watcher_group = new PGMouseWatcherGroup(this); @@ -102,8 +102,8 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // shouldn't do this until the frame that we're about to render has been // presented; otherwise, we may make regions active before they are actually // visible. But no one has complained about this so far. - if (_watcher_group != (PGMouseWatcherGroup *)NULL) { - nassertr(_watcher != (MouseWatcher *)NULL, false); + if (_watcher_group != nullptr) { + nassertr(_watcher != nullptr, false); _watcher->replace_group(old_watcher_group, _watcher_group); } @@ -130,17 +130,17 @@ is_renderable() const { */ void PGTop:: set_mouse_watcher(MouseWatcher *watcher) { - if (_watcher_group != (PGMouseWatcherGroup *)NULL) { + if (_watcher_group != nullptr) { _watcher_group->clear_top(this); } - if (_watcher != (MouseWatcher *)NULL) { + if (_watcher != nullptr) { _watcher->remove_group(_watcher_group); } _watcher = watcher; - _watcher_group = (PGMouseWatcherGroup *)NULL; + _watcher_group = nullptr; - if (_watcher != (MouseWatcher *)NULL) { + if (_watcher != nullptr) { _watcher_group = new PGMouseWatcherGroup(this); _watcher->add_group(_watcher_group); } diff --git a/panda/src/pgui/test_pgentry.cxx b/panda/src/pgui/test_pgentry.cxx index fb7440c6b4..f00369a603 100644 --- a/panda/src/pgui/test_pgentry.cxx +++ b/panda/src/pgui/test_pgentry.cxx @@ -22,7 +22,7 @@ main(int argc, char *argv[]) { framework.set_window_title("Panda Viewer"); WindowFramework *window = framework.open_window(); - if (window != (WindowFramework *)NULL) { + if (window != nullptr) { window->enable_keyboard(); NodePath aspect2d = window->get_aspect_2d(); diff --git a/panda/src/physics/angularEulerIntegrator.cxx b/panda/src/physics/angularEulerIntegrator.cxx index 3207450871..1ca581eaf6 100644 --- a/panda/src/physics/angularEulerIntegrator.cxx +++ b/panda/src/physics/angularEulerIntegrator.cxx @@ -51,7 +51,7 @@ child_integrate(Physical *physical, PhysicsObject *current_object = *current_object_iter; // bail out if this object doesn't exist or doesn't want to be processed. - if (current_object == (PhysicsObject *) NULL) { + if (current_object == nullptr) { continue; } diff --git a/panda/src/physics/baseForce.cxx b/panda/src/physics/baseForce.cxx index 7a7ba6d71b..c06ba12180 100644 --- a/panda/src/physics/baseForce.cxx +++ b/panda/src/physics/baseForce.cxx @@ -21,7 +21,7 @@ TypeHandle BaseForce::_type_handle; */ BaseForce:: BaseForce(bool active) : - _force_node(NULL), + _force_node(nullptr), _active(active) { } @@ -34,7 +34,7 @@ BaseForce(const BaseForce ©) : TypedReferenceCount(copy) { _active = copy._active; - _force_node = (ForceNode *) NULL; + _force_node = nullptr; } /** diff --git a/panda/src/physics/forceNode.I b/panda/src/physics/forceNode.I index 8fd6845727..f1c4db3d60 100644 --- a/panda/src/physics/forceNode.I +++ b/panda/src/physics/forceNode.I @@ -24,7 +24,7 @@ clear() { */ INLINE BaseForce *ForceNode:: get_force(size_t index) const { - nassertr(index < _forces.size(), (BaseForce *) NULL); + nassertr(index < _forces.size(), nullptr); return _forces[index]; } diff --git a/panda/src/physics/forceNode.cxx b/panda/src/physics/forceNode.cxx index e317052561..326962b7c1 100644 --- a/panda/src/physics/forceNode.cxx +++ b/panda/src/physics/forceNode.cxx @@ -114,7 +114,7 @@ remove_force(size_t index) { pvector< PT(BaseForce) >::iterator remove; remove = _forces.begin() + index; - (*remove)->_force_node = (ForceNode *) NULL; + (*remove)->_force_node = nullptr; (*remove)->_force_node_path = NodePath(); _forces.erase(remove); diff --git a/panda/src/physics/linearControlForce.I b/panda/src/physics/linearControlForce.I index 164d462c57..fb6fa1b1b9 100644 --- a/panda/src/physics/linearControlForce.I +++ b/panda/src/physics/linearControlForce.I @@ -16,7 +16,7 @@ */ INLINE void LinearControlForce:: clear_physics_object() { - _physics_object = (const PhysicsObject*)NULL; + _physics_object = nullptr; } /** diff --git a/panda/src/physics/linearControlForce.cxx b/panda/src/physics/linearControlForce.cxx index 7bc5ced199..e2f6b3356a 100644 --- a/panda/src/physics/linearControlForce.cxx +++ b/panda/src/physics/linearControlForce.cxx @@ -60,7 +60,7 @@ make_copy() { */ LVector3 LinearControlForce:: get_child_vector(const PhysicsObject *po) { - if (_physics_object != 0 && po == _physics_object) { + if (_physics_object != nullptr && po == _physics_object) { return _fvec; } else { return LVector3::zero(); diff --git a/panda/src/physics/linearEulerIntegrator.cxx b/panda/src/physics/linearEulerIntegrator.cxx index 0ba61f7be4..5095937a48 100644 --- a/panda/src/physics/linearEulerIntegrator.cxx +++ b/panda/src/physics/linearEulerIntegrator.cxx @@ -72,7 +72,7 @@ child_integrate(Physical *physical, PhysicsObject *current_object = *current_object_iter; // bail out if this object doesn't exist or doesn't want to be processed. - if (current_object == (PhysicsObject *) NULL) { + if (current_object == nullptr) { continue; } diff --git a/panda/src/physics/linearIntegrator.cxx b/panda/src/physics/linearIntegrator.cxx index ebb6655a91..9efd0a3c1b 100644 --- a/panda/src/physics/linearIntegrator.cxx +++ b/panda/src/physics/linearIntegrator.cxx @@ -53,7 +53,7 @@ integrate(Physical *physical, LinearForceVector &forces, PhysicsObject *current_object = *current_object_iter; // bail out if this object doesn't exist or doesn't want to be processed. - if (current_object == (PhysicsObject *) NULL) { + if (current_object == nullptr) { continue; } diff --git a/panda/src/physics/linearUserDefinedForce.h b/panda/src/physics/linearUserDefinedForce.h index 6a1d4bed42..93051290c2 100644 --- a/panda/src/physics/linearUserDefinedForce.h +++ b/panda/src/physics/linearUserDefinedForce.h @@ -21,7 +21,7 @@ */ class EXPCL_PANDAPHYSICS LinearUserDefinedForce : public LinearForce { PUBLISHED: - explicit LinearUserDefinedForce(LVector3 (*proc)(const PhysicsObject *) = NULL, + explicit LinearUserDefinedForce(LVector3 (*proc)(const PhysicsObject *) = nullptr, PN_stdfloat a = 1.0f, bool md = false); LinearUserDefinedForce(const LinearUserDefinedForce ©); virtual ~LinearUserDefinedForce(); diff --git a/panda/src/physics/physical.I b/panda/src/physics/physical.I index 3b44d50917..7232c1ebdf 100644 --- a/panda/src/physics/physical.I +++ b/panda/src/physics/physical.I @@ -167,7 +167,7 @@ get_num_linear_forces() const { */ INLINE PT(LinearForce) Physical:: get_linear_force(int index) const { - nassertr(index >= 0 && index < (int)_linear_forces.size(), NULL); + nassertr(index >= 0 && index < (int)_linear_forces.size(), nullptr); return _linear_forces[index]; } @@ -184,7 +184,7 @@ get_num_angular_forces() const { */ INLINE PT(AngularForce) Physical:: get_angular_force(int index) const { - nassertr(index >= 0 && index < (int)_angular_forces.size(), NULL); + nassertr(index >= 0 && index < (int)_angular_forces.size(), nullptr); return _angular_forces[index]; } diff --git a/panda/src/physics/physical.cxx b/panda/src/physics/physical.cxx index 9ca8f28b7a..1cad199507 100644 --- a/panda/src/physics/physical.cxx +++ b/panda/src/physics/physical.cxx @@ -39,7 +39,7 @@ Physical(int total_objects, bool pre_alloc) : _phys_body = new PhysicsObject; add_physics_object(_phys_body); } else { - _phys_body = (PhysicsObject *) NULL; + _phys_body = nullptr; // allocate each object. if (pre_alloc == true) { for (int i = 0; i < total_objects; ++i) { @@ -87,7 +87,7 @@ Physical(const Physical& copy) : if (_physics_objects.size() == 1) _phys_body = _physics_objects[0]; else - _phys_body = (PhysicsObject *) NULL; + _phys_body = nullptr; } /** @@ -99,7 +99,7 @@ Physical:: // because the physics manager doesn't keep PT's to physicals, simply *'s, // and also means that we don't have to tell the physics manager ourselves // when one of our physicals is dead. - if (_physics_manager != (PhysicsManager *) NULL) { + if (_physics_manager != nullptr) { _physics_manager->remove_physical(this); } } diff --git a/panda/src/physics/physicalNode.I b/panda/src/physics/physicalNode.I index 700511b1e6..407cf52f5a 100644 --- a/panda/src/physics/physicalNode.I +++ b/panda/src/physics/physicalNode.I @@ -29,7 +29,7 @@ clear() { */ INLINE Physical *PhysicalNode:: get_physical(size_t index) const { - nassertr(index < _physicals.size(), (Physical *) NULL); + nassertr(index < _physicals.size(), nullptr); return _physicals[index]; } diff --git a/panda/src/physics/physicalNode.cxx b/panda/src/physics/physicalNode.cxx index 31343f925a..0166b81ade 100644 --- a/panda/src/physics/physicalNode.cxx +++ b/panda/src/physics/physicalNode.cxx @@ -124,7 +124,7 @@ remove_physical(size_t index) { pvector< PT(Physical) >::iterator remove; remove = _physicals.begin() + index; - (*remove)->_physical_node = (PhysicalNode *) NULL; + (*remove)->_physical_node = nullptr; _physicals.erase(remove); } diff --git a/panda/src/physics/physicsManager.I b/panda/src/physics/physicsManager.I index 6b2c94c94c..3e4704a3ba 100644 --- a/panda/src/physics/physicsManager.I +++ b/panda/src/physics/physicsManager.I @@ -16,7 +16,7 @@ */ INLINE void PhysicsManager:: attach_physical(Physical *p) { - nassertv(p && p->_physics_manager == NULL); + nassertv(p && p->_physics_manager == nullptr); p->_physics_manager = this; PhysicalsVector::iterator found; found = find(_physicals.begin(), _physicals.end(), p); diff --git a/panda/src/physics/physicsManager.cxx b/panda/src/physics/physicsManager.cxx index 7bd75bec33..510d61abce 100644 --- a/panda/src/physics/physicsManager.cxx +++ b/panda/src/physics/physicsManager.cxx @@ -38,7 +38,7 @@ PhysicsManager:: PhysicalsVector::iterator pi; for (pi = _physicals.begin(); pi != _physicals.end(); ++pi) { nassertv((*pi)->_physics_manager == this); - (*pi)->_physics_manager = NULL; + (*pi)->_physics_manager = nullptr; } } @@ -100,7 +100,7 @@ remove_physical(Physical *p) { return; } nassertv(p->_physics_manager == this); - p->_physics_manager = (PhysicsManager *) NULL; + p->_physics_manager = nullptr; _physicals.erase(found); } diff --git a/panda/src/physx/physxActor.cxx b/panda/src/physx/physxActor.cxx index fdbce36aff..2b3075e45a 100644 --- a/panda/src/physx/physxActor.cxx +++ b/panda/src/physx/physxActor.cxx @@ -61,7 +61,7 @@ unlink() { } // Unlink self - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; @@ -78,7 +78,7 @@ release() { unlink(); _ptr->getScene().releaseActor(*_ptr); - _ptr = NULL; + _ptr = nullptr; } /** @@ -358,7 +358,7 @@ get_node_path() const { PhysxScene *PhysxActor:: get_scene() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); NxScene *scenePtr = &(_ptr->getScene()); PhysxScene *scene = (PhysxScene *)(scenePtr->userData); @@ -387,14 +387,14 @@ get_num_shapes() const { PhysxShape *PhysxActor:: create_shape(PhysxShapeDesc &desc) { - nassertr(_error_type == ET_ok, NULL); - nassertr(desc.is_valid(),NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr(desc.is_valid(),nullptr); PhysxShape *shape = PhysxShape::factory(desc.ptr()->getType()); - nassertr(shape, NULL); + nassertr(shape, nullptr); NxShape *shapePtr = _ptr->createShape(*desc.ptr()); - nassertr(shapePtr, NULL); + nassertr(shapePtr, nullptr); shape->link(shapePtr); @@ -408,8 +408,8 @@ create_shape(PhysxShapeDesc &desc) { PhysxShape *PhysxActor:: get_shape(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _ptr->getNbShapes(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _ptr->getNbShapes(), nullptr); NxShape * const *shapes = _ptr->getShapes(); NxShape *shapePtr = shapes[idx]; @@ -426,10 +426,10 @@ get_shape(unsigned int idx) const { PhysxShape *PhysxActor:: get_shape_by_name(const char *name) const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); NxShape * const *shapes = _ptr->getShapes(); - NxShape *shapePtr = NULL; + NxShape *shapePtr = nullptr; NxU32 nShapes = _ptr->getNbShapes(); for (NxU32 i=0; i < nShapes; i++) { @@ -440,7 +440,7 @@ get_shape_by_name(const char *name) const { } } - return NULL; + return nullptr; } /** diff --git a/panda/src/physx/physxBoxForceFieldShape.cxx b/panda/src/physx/physxBoxForceFieldShape.cxx index 2aff7e32a7..af874e3b4b 100644 --- a/panda/src/physx/physxBoxForceFieldShape.cxx +++ b/panda/src/physx/physxBoxForceFieldShape.cxx @@ -39,7 +39,7 @@ link(NxForceFieldShape *shapePtr) { void PhysxBoxForceFieldShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxForceFieldShapeGroup *group = (PhysxForceFieldShapeGroup *)_ptr->getShapeGroup().userData; diff --git a/panda/src/physx/physxBoxShape.cxx b/panda/src/physx/physxBoxShape.cxx index 695ed1fd71..0ec704bc02 100644 --- a/panda/src/physx/physxBoxShape.cxx +++ b/panda/src/physx/physxBoxShape.cxx @@ -39,7 +39,7 @@ link(NxShape *shapePtr) { void PhysxBoxShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; diff --git a/panda/src/physx/physxCapsuleForceFieldShape.cxx b/panda/src/physx/physxCapsuleForceFieldShape.cxx index 0aacd1e61b..be0ce986e6 100644 --- a/panda/src/physx/physxCapsuleForceFieldShape.cxx +++ b/panda/src/physx/physxCapsuleForceFieldShape.cxx @@ -38,7 +38,7 @@ link(NxForceFieldShape *shapePtr) { void PhysxCapsuleForceFieldShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxForceFieldShapeGroup *group = (PhysxForceFieldShapeGroup *)_ptr->getShapeGroup().userData; diff --git a/panda/src/physx/physxCapsuleShape.cxx b/panda/src/physx/physxCapsuleShape.cxx index ed4dc24d75..29269dd4dd 100644 --- a/panda/src/physx/physxCapsuleShape.cxx +++ b/panda/src/physx/physxCapsuleShape.cxx @@ -38,7 +38,7 @@ link(NxShape *shapePtr) { void PhysxCapsuleShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; diff --git a/panda/src/physx/physxCcdSkeleton.cxx b/panda/src/physx/physxCcdSkeleton.cxx index 22dc3f4173..e18ff74023 100644 --- a/panda/src/physx/physxCcdSkeleton.cxx +++ b/panda/src/physx/physxCcdSkeleton.cxx @@ -49,7 +49,7 @@ release() { unlink(); NxGetPhysicsSDK()->releaseCCDSkeleton(*_ptr); - _ptr = NULL; + _ptr = nullptr; // TODO PhysxMeshPool::release_ccd_skeleton(this); } diff --git a/panda/src/physx/physxCcdSkeletonDesc.I b/panda/src/physx/physxCcdSkeletonDesc.I index 227a6f9684..271e1c94e9 100644 --- a/panda/src/physx/physxCcdSkeletonDesc.I +++ b/panda/src/physx/physxCcdSkeletonDesc.I @@ -20,11 +20,11 @@ PhysxCcdSkeletonDesc() { _desc.flags = 0; _desc.pointStrideBytes = sizeof(NxVec3); _desc.triangleStrideBytes = 3*sizeof(NxU32); - _desc.points = NULL; - _desc.triangles = NULL; + _desc.points = nullptr; + _desc.triangles = nullptr; - _vertices = NULL; - _triangles = NULL; + _vertices = nullptr; + _triangles = nullptr; } /** diff --git a/panda/src/physx/physxCloth.cxx b/panda/src/physx/physxCloth.cxx index 9f2583f7df..05e77b54b6 100644 --- a/panda/src/physx/physxCloth.cxx +++ b/panda/src/physx/physxCloth.cxx @@ -46,13 +46,13 @@ void PhysxCloth:: unlink() { // Unlink self - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; scene->_cloths.remove(this); - _node = NULL; + _node = nullptr; } /** @@ -65,7 +65,7 @@ release() { unlink(); _ptr->getScene().releaseCloth(*_ptr); - _ptr = NULL; + _ptr = nullptr; } /** @@ -95,7 +95,7 @@ update() { PhysxScene *PhysxCloth:: get_scene() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return (PhysxScene *)_ptr->getScene().userData; } @@ -105,7 +105,7 @@ get_scene() const { PhysxClothNode *PhysxCloth:: get_cloth_node() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return _node; } @@ -115,7 +115,7 @@ get_cloth_node() const { PhysxClothNode *PhysxCloth:: create_cloth_node(const char *name) { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); _node = new PhysxClothNode(name); _node->allocate(this); @@ -455,11 +455,11 @@ get_vertex_attachment_status(unsigned int vertexId) const { PhysxShape *PhysxCloth:: get_vertex_attachment_shape(unsigned int vertexId) const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); // --TODO-- nassertr(vertexId < _ptr->getNumberOfParticles(), NULL); NxShape *shapePtr = _ptr->getVertexAttachmentShape(vertexId); - PhysxShape *shape = shapePtr ? (PhysxShape *)(shapePtr->userData) : NULL; + PhysxShape *shape = shapePtr ? (PhysxShape *)(shapePtr->userData) : nullptr; return shape; } diff --git a/panda/src/physx/physxClothMesh.cxx b/panda/src/physx/physxClothMesh.cxx index 7a11a450e3..493b781a0a 100644 --- a/panda/src/physx/physxClothMesh.cxx +++ b/panda/src/physx/physxClothMesh.cxx @@ -49,7 +49,7 @@ release() { unlink(); NxGetPhysicsSDK()->releaseClothMesh(*_ptr); - _ptr = NULL; + _ptr = nullptr; PhysxMeshPool::release_cloth_mesh(this); } diff --git a/panda/src/physx/physxClothMeshDesc.I b/panda/src/physx/physxClothMeshDesc.I index 973883686b..2cf02c8152 100644 --- a/panda/src/physx/physxClothMeshDesc.I +++ b/panda/src/physx/physxClothMeshDesc.I @@ -20,12 +20,12 @@ PhysxClothMeshDesc() { _desc.flags = 0; _desc.pointStrideBytes = sizeof(NxVec3); _desc.triangleStrideBytes = 3*sizeof(NxU32); - _desc.points = NULL; - _desc.triangles = NULL; + _desc.points = nullptr; + _desc.triangles = nullptr; - _points = NULL; - _triangles = NULL; - _texcoords = NULL; + _points = nullptr; + _triangles = nullptr; + _texcoords = nullptr; } /** diff --git a/panda/src/physx/physxClothNode.I b/panda/src/physx/physxClothNode.I index 3597004f03..a06bfcc3c3 100644 --- a/panda/src/physx/physxClothNode.I +++ b/panda/src/physx/physxClothNode.I @@ -30,7 +30,7 @@ PhysxClothNode(const char *name) : GeomNode(name) { this->add_geom(_geom); _numTexcoords = 0; - _texcoords = NULL; + _texcoords = nullptr; } /** diff --git a/panda/src/physx/physxContactPair.cxx b/panda/src/physx/physxContactPair.cxx index 1ecd1fab6d..3e8d69e34f 100644 --- a/panda/src/physx/physxContactPair.cxx +++ b/panda/src/physx/physxContactPair.cxx @@ -26,11 +26,11 @@ get_actor_a() const { if (_pair.isDeletedActor[0]) { physx_cat.warning() << "actor A has been deleted" << endl; - return NULL; + return nullptr; } NxActor *actorPtr = _pair.actors[0]; - return (actorPtr == NULL) ? NULL : (PhysxActor *)actorPtr->userData; + return (actorPtr == nullptr) ? nullptr : (PhysxActor *)actorPtr->userData; } /** @@ -41,11 +41,11 @@ get_actor_b() const { if (_pair.isDeletedActor[1]) { physx_cat.warning() << "actor B has been deleted" << endl; - return NULL; + return nullptr; } NxActor *actorPtr = _pair.actors[1]; - return (actorPtr == NULL) ? NULL : (PhysxActor *)actorPtr->userData; + return (actorPtr == nullptr) ? nullptr : (PhysxActor *)actorPtr->userData; } /** diff --git a/panda/src/physx/physxController.cxx b/panda/src/physx/physxController.cxx index 4e83a282a4..7787c4019e 100644 --- a/panda/src/physx/physxController.cxx +++ b/panda/src/physx/physxController.cxx @@ -55,7 +55,7 @@ factory(NxControllerType controllerType) { } physx_cat.error() << "Unknown controller type.\n"; - return NULL; + return nullptr; } @@ -65,7 +65,7 @@ factory(NxControllerType controllerType) { PhysxActor *PhysxController:: get_actor() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return (PhysxActor *)(ptr()->getActor()->userData); } diff --git a/panda/src/physx/physxControllerReport.cxx b/panda/src/physx/physxControllerReport.cxx index dd6cfb225c..a9b570fcda 100644 --- a/panda/src/physx/physxControllerReport.cxx +++ b/panda/src/physx/physxControllerReport.cxx @@ -23,8 +23,8 @@ enable() { _enabled = true; - _shape_hit_cbobj = NULL; - _controller_hit_cbobj = NULL; + _shape_hit_cbobj = nullptr; + _controller_hit_cbobj = nullptr; } /** diff --git a/panda/src/physx/physxControllerShapeHit.I b/panda/src/physx/physxControllerShapeHit.I index a894ae013d..b6500ca736 100644 --- a/panda/src/physx/physxControllerShapeHit.I +++ b/panda/src/physx/physxControllerShapeHit.I @@ -30,7 +30,7 @@ get_controller() const { return (PhysxController *)(_hit.controller->getUserData()); } else { - return NULL; + return nullptr; } } @@ -44,7 +44,7 @@ get_shape() const { return (PhysxShape *)(_hit.shape->userData); } else { - return NULL; + return nullptr; } } diff --git a/panda/src/physx/physxControllersHit.I b/panda/src/physx/physxControllersHit.I index 74816e9159..e3d9aea411 100644 --- a/panda/src/physx/physxControllersHit.I +++ b/panda/src/physx/physxControllersHit.I @@ -27,7 +27,7 @@ INLINE PhysxController *PhysxControllersHit:: get_controller() const { NxController *controllerPtr = _hit.controller; - PhysxController *controller = controllerPtr ? (PhysxController *)controllerPtr : NULL; + PhysxController *controller = controllerPtr ? (PhysxController *)controllerPtr : nullptr; return controller; } @@ -39,7 +39,7 @@ INLINE PhysxController *PhysxControllersHit:: get_other() const { NxController *otherPtr = _hit.other; - PhysxController *other = otherPtr ? (PhysxController *)otherPtr : NULL; + PhysxController *other = otherPtr ? (PhysxController *)otherPtr : nullptr; return other; } diff --git a/panda/src/physx/physxConvexForceFieldShape.cxx b/panda/src/physx/physxConvexForceFieldShape.cxx index 406fabd878..bf89f9c485 100644 --- a/panda/src/physx/physxConvexForceFieldShape.cxx +++ b/panda/src/physx/physxConvexForceFieldShape.cxx @@ -38,7 +38,7 @@ link(NxForceFieldShape *shapePtr) { void PhysxConvexForceFieldShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxForceFieldShapeGroup *group = (PhysxForceFieldShapeGroup *)_ptr->getShapeGroup().userData; diff --git a/panda/src/physx/physxConvexMesh.cxx b/panda/src/physx/physxConvexMesh.cxx index 85bc518d9e..f703533856 100644 --- a/panda/src/physx/physxConvexMesh.cxx +++ b/panda/src/physx/physxConvexMesh.cxx @@ -49,7 +49,7 @@ release() { unlink(); NxGetPhysicsSDK()->releaseConvexMesh(*_ptr); - _ptr = NULL; + _ptr = nullptr; PhysxMeshPool::release_convex_mesh(this); } diff --git a/panda/src/physx/physxConvexMeshDesc.I b/panda/src/physx/physxConvexMeshDesc.I index fae24d3130..1611726ecb 100644 --- a/panda/src/physx/physxConvexMeshDesc.I +++ b/panda/src/physx/physxConvexMeshDesc.I @@ -19,9 +19,9 @@ PhysxConvexMeshDesc() { _desc.flags = NX_CF_COMPUTE_CONVEX; _desc.pointStrideBytes = sizeof(NxVec3); - _desc.points = NULL; + _desc.points = nullptr; - _vertices = NULL; + _vertices = nullptr; } /** diff --git a/panda/src/physx/physxConvexShape.cxx b/panda/src/physx/physxConvexShape.cxx index 58d4a6c510..73acc06b87 100644 --- a/panda/src/physx/physxConvexShape.cxx +++ b/panda/src/physx/physxConvexShape.cxx @@ -38,7 +38,7 @@ link(NxShape *shapePtr) { void PhysxConvexShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; diff --git a/panda/src/physx/physxCylindricalJoint.cxx b/panda/src/physx/physxCylindricalJoint.cxx index 2a2fbb22d3..037668db54 100644 --- a/panda/src/physx/physxCylindricalJoint.cxx +++ b/panda/src/physx/physxCylindricalJoint.cxx @@ -38,7 +38,7 @@ link(NxJoint *jointPtr) { void PhysxCylindricalJoint:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; diff --git a/panda/src/physx/physxD6Joint.cxx b/panda/src/physx/physxD6Joint.cxx index d52f1cdae1..a95abddcf5 100644 --- a/panda/src/physx/physxD6Joint.cxx +++ b/panda/src/physx/physxD6Joint.cxx @@ -38,7 +38,7 @@ link(NxJoint *jointPtr) { void PhysxD6Joint:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; diff --git a/panda/src/physx/physxDistanceJoint.cxx b/panda/src/physx/physxDistanceJoint.cxx index 648821ce66..f24baa7c87 100644 --- a/panda/src/physx/physxDistanceJoint.cxx +++ b/panda/src/physx/physxDistanceJoint.cxx @@ -38,7 +38,7 @@ link(NxJoint *jointPtr) { void PhysxDistanceJoint:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; diff --git a/panda/src/physx/physxFileStream.cxx b/panda/src/physx/physxFileStream.cxx index 1f308ab410..a93444148b 100644 --- a/panda/src/physx/physxFileStream.cxx +++ b/panda/src/physx/physxFileStream.cxx @@ -20,7 +20,7 @@ /** * */ -PhysxFileStream::PhysxFileStream(const Filename &fn, bool load) : _fp(NULL), _vf(NULL), _in(NULL) +PhysxFileStream::PhysxFileStream(const Filename &fn, bool load) : _fp(nullptr), _vf(nullptr), _in(nullptr) { if (load) { _vf = VirtualFileSystem::get_global_ptr()->get_file(fn); diff --git a/panda/src/physx/physxFixedJoint.cxx b/panda/src/physx/physxFixedJoint.cxx index 49b5265923..e3257eb22c 100644 --- a/panda/src/physx/physxFixedJoint.cxx +++ b/panda/src/physx/physxFixedJoint.cxx @@ -38,7 +38,7 @@ link(NxJoint *jointPtr) { void PhysxFixedJoint:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; diff --git a/panda/src/physx/physxForceField.cxx b/panda/src/physx/physxForceField.cxx index eada698729..26149e72e0 100644 --- a/panda/src/physx/physxForceField.cxx +++ b/panda/src/physx/physxForceField.cxx @@ -50,7 +50,7 @@ unlink() { group->unlink(); // Unlink self - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; @@ -67,7 +67,7 @@ release() { unlink(); _ptr->getScene().releaseForceField(*_ptr); - _ptr = NULL; + _ptr = nullptr; } /** @@ -98,7 +98,7 @@ get_name() const { PhysxScene *PhysxForceField:: get_scene() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return (PhysxScene *)(_ptr->getScene().userData); } @@ -108,7 +108,7 @@ get_scene() const { PhysxForceFieldShapeGroup *PhysxForceField:: get_include_shape_group() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return (PhysxForceFieldShapeGroup *)(_ptr->getIncludeShapeGroup().userData); } @@ -128,8 +128,8 @@ get_num_shape_groups() const { PhysxForceFieldShapeGroup *PhysxForceField:: get_shape_group(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _ptr->getNbShapeGroups(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _ptr->getNbShapeGroups(), nullptr); NxForceFieldShapeGroup *groupPtr; NxU32 nGroups = _ptr->getNbShapeGroups(); diff --git a/panda/src/physx/physxForceFieldShape.cxx b/panda/src/physx/physxForceFieldShape.cxx index a0a2d1b931..fe5cdfb316 100644 --- a/panda/src/physx/physxForceFieldShape.cxx +++ b/panda/src/physx/physxForceFieldShape.cxx @@ -56,7 +56,7 @@ factory(NxShapeType shapeType) { } physx_cat.error() << "Unknown shape type.\n"; - return NULL; + return nullptr; } /** @@ -66,11 +66,11 @@ factory(NxShapeType shapeType) { PhysxForceField *PhysxForceFieldShape:: get_force_field() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); NxForceField *fieldPtr = ptr()->getForceField(); - if (fieldPtr == NULL) { - return NULL; + if (fieldPtr == nullptr) { + return nullptr; } return (PhysxForceField *)(fieldPtr->userData); } @@ -81,7 +81,7 @@ get_force_field() const { PhysxForceFieldShapeGroup *PhysxForceFieldShape:: get_shape_group() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return (PhysxForceFieldShapeGroup *)(ptr()->getShapeGroup().userData); } diff --git a/panda/src/physx/physxForceFieldShapeGroup.cxx b/panda/src/physx/physxForceFieldShapeGroup.cxx index c0bb56b93d..8819fbfd19 100644 --- a/panda/src/physx/physxForceFieldShapeGroup.cxx +++ b/panda/src/physx/physxForceFieldShapeGroup.cxx @@ -60,7 +60,7 @@ unlink() { } // Unlink self - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; @@ -77,7 +77,7 @@ release() { unlink(); _ptr->getScene().releaseForceFieldShapeGroup(*_ptr); - _ptr = NULL; + _ptr = nullptr; } /** @@ -86,7 +86,7 @@ release() { PhysxScene *PhysxForceFieldShapeGroup:: get_scene() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return (PhysxScene *)(_ptr->getScene().userData); } @@ -97,10 +97,10 @@ get_scene() const { PhysxForceField *PhysxForceFieldShapeGroup:: get_force_field() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); - if (_ptr->getForceField() == NULL) { - return NULL; + if (_ptr->getForceField() == nullptr) { + return nullptr; } else { return (PhysxForceField *)(_ptr->getForceField()->userData); @@ -157,14 +157,14 @@ get_num_shapes() const { PhysxForceFieldShape *PhysxForceFieldShapeGroup:: create_shape(PhysxForceFieldShapeDesc &desc) { - nassertr(_error_type == ET_ok, NULL); - nassertr(desc.is_valid(),NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr(desc.is_valid(),nullptr); PhysxForceFieldShape *shape = PhysxForceFieldShape::factory(desc.ptr()->getType()); - nassertr(shape, NULL); + nassertr(shape, nullptr); NxForceFieldShape *shapePtr = _ptr->createShape(*desc.ptr()); - nassertr(shapePtr, NULL); + nassertr(shapePtr, nullptr); shape->link(shapePtr); @@ -177,8 +177,8 @@ create_shape(PhysxForceFieldShapeDesc &desc) { PhysxForceFieldShape *PhysxForceFieldShapeGroup:: get_shape(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _ptr->getNbShapes(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _ptr->getNbShapes(), nullptr); NxForceFieldShape *shapePtr; NxU32 nShapes = _ptr->getNbShapes(); diff --git a/panda/src/physx/physxHeightField.cxx b/panda/src/physx/physxHeightField.cxx index b4885a1b26..4234eaf9e6 100644 --- a/panda/src/physx/physxHeightField.cxx +++ b/panda/src/physx/physxHeightField.cxx @@ -46,7 +46,7 @@ release() { unlink(); NxGetPhysicsSDK()->releaseHeightField(*_ptr); - _ptr = NULL; + _ptr = nullptr; } /** diff --git a/panda/src/physx/physxHeightFieldDesc.I b/panda/src/physx/physxHeightFieldDesc.I index e6870dd4cb..daf9ebc58c 100644 --- a/panda/src/physx/physxHeightFieldDesc.I +++ b/panda/src/physx/physxHeightFieldDesc.I @@ -17,7 +17,7 @@ INLINE PhysxHeightFieldDesc:: PhysxHeightFieldDesc() { - _samples = NULL; + _samples = nullptr; _desc.setToDefault(); } @@ -76,7 +76,7 @@ unset_size() { if (_samples) { _desc.nbRows = (NxU32) 0; _desc.nbColumns = (NxU32) 0; - _desc.samples = NULL; + _desc.samples = nullptr; delete[] _samples; } } diff --git a/panda/src/physx/physxHeightFieldShape.cxx b/panda/src/physx/physxHeightFieldShape.cxx index 21d0f6f81f..87b8ef7581 100644 --- a/panda/src/physx/physxHeightFieldShape.cxx +++ b/panda/src/physx/physxHeightFieldShape.cxx @@ -38,7 +38,7 @@ link(NxShape *shapePtr) { void PhysxHeightFieldShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; diff --git a/panda/src/physx/physxJoint.cxx b/panda/src/physx/physxJoint.cxx index 0217d43849..0af47ee6e0 100644 --- a/panda/src/physx/physxJoint.cxx +++ b/panda/src/physx/physxJoint.cxx @@ -80,7 +80,7 @@ factory(NxJointType shapeType) { } physx_cat.error() << "Unknown joint type.\n"; - return NULL; + return nullptr; } /** @@ -112,8 +112,8 @@ get_name() const { PhysxActor *PhysxJoint:: get_actor(unsigned int idx) const { - nassertr_always(idx < 2, NULL); - nassertr(_error_type == ET_ok, NULL); + nassertr_always(idx < 2, nullptr); + nassertr(_error_type == ET_ok, nullptr); NxActor *actorPtr[2]; ptr()->getActors(&actorPtr[0], &actorPtr[1]); @@ -126,7 +126,7 @@ get_actor(unsigned int idx) const { PhysxScene *PhysxJoint:: get_scene() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return (PhysxScene *)(ptr()->getScene().userData); } diff --git a/panda/src/physx/physxJointDesc.cxx b/panda/src/physx/physxJointDesc.cxx index fec3e3f791..dc0eeb1196 100644 --- a/panda/src/physx/physxJointDesc.cxx +++ b/panda/src/physx/physxJointDesc.cxx @@ -208,11 +208,11 @@ get_joint_flag(const PhysxJointFlag flag) const { PhysxActor *PhysxJointDesc:: get_actor(unsigned int idx) const { - nassertr_always(idx < 2, NULL); + nassertr_always(idx < 2, nullptr); NxActor *actorPtr = ptr()->actor[idx]; - if (actorPtr == NULL) { - return NULL; + if (actorPtr == nullptr) { + return nullptr; } else { return (PhysxActor *)(actorPtr->userData); diff --git a/panda/src/physx/physxKitchen.cxx b/panda/src/physx/physxKitchen.cxx index 144e6b2cbe..8dda747eaa 100644 --- a/panda/src/physx/physxKitchen.cxx +++ b/panda/src/physx/physxKitchen.cxx @@ -151,20 +151,20 @@ cook_texcoords(const PhysxClothMeshDesc &meshDesc, const Filename &filename) { PhysxConvexMesh *PhysxKitchen:: cook_convex_mesh(const PhysxConvexMeshDesc &meshDesc) { - nassertr_always(meshDesc.is_valid(), NULL); + nassertr_always(meshDesc.is_valid(), nullptr); PhysxMemoryWriteBuffer buffer; bool status = _cooking->NxCookConvexMesh(meshDesc.get_desc(), buffer); - nassertr(status, NULL); + nassertr(status, nullptr); NxPhysicsSDK *sdk = NxGetPhysicsSDK(); - nassertr(sdk, NULL); + nassertr(sdk, nullptr); PhysxConvexMesh *mesh = new PhysxConvexMesh(); - nassertr(mesh, NULL); + nassertr(mesh, nullptr); NxConvexMesh *meshPtr = sdk->createConvexMesh(PhysxMemoryReadBuffer(buffer.data)); - nassertr(meshPtr, NULL); + nassertr(meshPtr, nullptr); mesh->link(meshPtr); @@ -177,20 +177,20 @@ cook_convex_mesh(const PhysxConvexMeshDesc &meshDesc) { PhysxTriangleMesh *PhysxKitchen:: cook_triangle_mesh(const PhysxTriangleMeshDesc &meshDesc) { - nassertr_always(meshDesc.is_valid(), NULL); + nassertr_always(meshDesc.is_valid(), nullptr); PhysxMemoryWriteBuffer buffer; bool status = _cooking->NxCookTriangleMesh(meshDesc.get_desc(), buffer); - nassertr(status, NULL); + nassertr(status, nullptr); NxPhysicsSDK *sdk = NxGetPhysicsSDK(); - nassertr(sdk, NULL); + nassertr(sdk, nullptr); PhysxTriangleMesh *mesh = new PhysxTriangleMesh(); - nassertr(mesh, NULL); + nassertr(mesh, nullptr); NxTriangleMesh *meshPtr = sdk->createTriangleMesh(PhysxMemoryReadBuffer(buffer.data)); - nassertr(meshPtr, NULL); + nassertr(meshPtr, nullptr); mesh->link(meshPtr); @@ -203,21 +203,21 @@ cook_triangle_mesh(const PhysxTriangleMeshDesc &meshDesc) { PhysxClothMesh *PhysxKitchen:: cook_cloth_mesh(const PhysxClothMeshDesc &meshDesc) { - nassertr_always(meshDesc.is_valid(), NULL); + nassertr_always(meshDesc.is_valid(), nullptr); PhysxMemoryWriteBuffer wbuffer; bool status = _cooking->NxCookClothMesh(meshDesc.get_desc(), wbuffer); - nassertr(status, NULL); + nassertr(status, nullptr); NxPhysicsSDK *sdk = NxGetPhysicsSDK(); - nassertr(sdk, NULL); + nassertr(sdk, nullptr); PhysxClothMesh *mesh = new PhysxClothMesh(); - nassertr(mesh, NULL); + nassertr(mesh, nullptr); PhysxMemoryReadBuffer rbuffer(wbuffer.data); NxClothMesh *meshPtr = sdk->createClothMesh(rbuffer); - nassertr(meshPtr, NULL); + nassertr(meshPtr, nullptr); mesh->link(meshPtr); @@ -230,21 +230,21 @@ cook_cloth_mesh(const PhysxClothMeshDesc &meshDesc) { PhysxSoftBodyMesh *PhysxKitchen:: cook_soft_body_mesh(const PhysxSoftBodyMeshDesc &meshDesc) { - nassertr_always(meshDesc.is_valid(), NULL); + nassertr_always(meshDesc.is_valid(), nullptr); PhysxMemoryWriteBuffer wbuffer; bool status = _cooking->NxCookSoftBodyMesh(meshDesc.get_desc(), wbuffer); - nassertr(status, NULL); + nassertr(status, nullptr); NxPhysicsSDK *sdk = NxGetPhysicsSDK(); - nassertr(sdk, NULL); + nassertr(sdk, nullptr); PhysxSoftBodyMesh *mesh = new PhysxSoftBodyMesh(); - nassertr(mesh, NULL); + nassertr(mesh, nullptr); PhysxMemoryReadBuffer rbuffer(wbuffer.data); NxSoftBodyMesh *meshPtr = sdk->createSoftBodyMesh(rbuffer); - nassertr(meshPtr, NULL); + nassertr(meshPtr, nullptr); mesh->link(meshPtr); diff --git a/panda/src/physx/physxManager.cxx b/panda/src/physx/physxManager.cxx index 297bbbaed4..56f63149c8 100644 --- a/panda/src/physx/physxManager.cxx +++ b/panda/src/physx/physxManager.cxx @@ -28,7 +28,7 @@ PhysxManager() { NxSDKCreateError error; NxPhysicsSDKDesc desc = NxPhysicsSDKDesc(); - _sdk = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION, NULL, &_outputStream, desc, &error); + _sdk = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION, nullptr, &_outputStream, desc, &error); if (error == NXCE_NO_ERROR) { physx_cat.info() << "PhysX subsystem initialized. Number of PPUs=" @@ -37,7 +37,7 @@ PhysxManager() { else { physx_cat.error() << "Error when setting up the PhysX subsystem: " << get_sdk_error_string(error) << endl; - _sdk = NULL; + _sdk = nullptr; } nassertv_always(error == NXCE_NO_ERROR); @@ -95,12 +95,12 @@ PhysxManager:: PhysxManager *PhysxManager:: get_global_ptr() { - if (_global_ptr == (PhysxManager *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new PhysxManager; } - if (_global_ptr->_sdk == NULL) { - return NULL; + if (_global_ptr->_sdk == nullptr) { + return nullptr; } else { return _global_ptr; @@ -122,7 +122,7 @@ get_num_scenes() const { PhysxScene *PhysxManager:: create_scene(PhysxSceneDesc &sceneDesc) { - nassertr(sceneDesc.is_valid(),NULL); + nassertr(sceneDesc.is_valid(),nullptr); // _desc.timeStepMethod = NX_TIMESTEP_FIXED; _desc.maxTimestep = 1.0f // 240.0f; _desc.maxIter = 8; @@ -139,10 +139,10 @@ create_scene(PhysxSceneDesc &sceneDesc) { } PhysxScene *scene = new PhysxScene(); - nassertr(scene, NULL); + nassertr(scene, nullptr); NxScene *scenePtr = _sdk->createScene(sceneDesc._desc); - nassertr(scenePtr, NULL); + nassertr(scenePtr, nullptr); scene->link(scenePtr); @@ -155,7 +155,7 @@ create_scene(PhysxSceneDesc &sceneDesc) { PhysxScene *PhysxManager:: get_scene(unsigned int idx) const { - nassertr_always(idx < _sdk->getNbScenes(), NULL); + nassertr_always(idx < _sdk->getNbScenes(), nullptr); NxScene *scenePtr = _sdk->getScene(idx); PhysxScene *scene = (PhysxScene *)(scenePtr->userData); @@ -178,13 +178,13 @@ get_num_height_fields() { PhysxHeightField *PhysxManager:: create_height_field(PhysxHeightFieldDesc &desc) { - nassertr(desc.is_valid(),NULL); + nassertr(desc.is_valid(),nullptr); PhysxHeightField *hf = new PhysxHeightField(); - nassertr(hf, NULL); + nassertr(hf, nullptr); NxHeightField *hfPtr = _sdk->createHeightField(desc._desc); - nassertr(hfPtr, NULL); + nassertr(hfPtr, nullptr); hf->link(hfPtr); @@ -197,7 +197,7 @@ create_height_field(PhysxHeightFieldDesc &desc) { PhysxHeightField *PhysxManager:: get_height_field(unsigned int idx) { - nassertr_always(idx < _sdk->getNbHeightFields(), NULL); + nassertr_always(idx < _sdk->getNbHeightFields(), nullptr); return (PhysxHeightField *)_heightfields[idx]; } @@ -217,7 +217,7 @@ get_num_convex_meshes() { PhysxConvexMesh *PhysxManager:: get_convex_mesh(unsigned int idx) { - nassertr_always(idx < _sdk->getNbConvexMeshes(), NULL); + nassertr_always(idx < _sdk->getNbConvexMeshes(), nullptr); return (PhysxConvexMesh *)_convex_meshes[idx]; } @@ -237,7 +237,7 @@ get_num_triangle_meshes() { PhysxTriangleMesh *PhysxManager:: get_triangle_mesh(unsigned int idx) { - nassertr_always(idx < _sdk->getNbTriangleMeshes(), NULL); + nassertr_always(idx < _sdk->getNbTriangleMeshes(), nullptr); return (PhysxTriangleMesh *)_triangle_meshes[idx]; } @@ -257,7 +257,7 @@ get_num_cloth_meshes() { PhysxClothMesh *PhysxManager:: get_cloth_mesh(unsigned int idx) { - nassertr_always(idx < _sdk->getNbClothMeshes(), NULL); + nassertr_always(idx < _sdk->getNbClothMeshes(), nullptr); return (PhysxClothMesh *)_cloth_meshes[idx]; } @@ -277,7 +277,7 @@ get_num_soft_body_meshes() { PhysxSoftBodyMesh *PhysxManager:: get_soft_body_mesh(unsigned int idx) { - nassertr_always(idx < _sdk->getNbSoftBodyMeshes(), NULL); + nassertr_always(idx < _sdk->getNbSoftBodyMeshes(), nullptr); return (PhysxSoftBodyMesh *)_softbody_meshes[idx]; } @@ -297,14 +297,14 @@ get_num_ccd_skeletons() { PhysxCcdSkeleton *PhysxManager:: create_ccd_skeleton(PhysxCcdSkeletonDesc &desc) { - nassertr(desc.is_valid(), NULL); - nassertr(desc.get_desc().numVertices < 64, NULL); + nassertr(desc.is_valid(), nullptr); + nassertr(desc.get_desc().numVertices < 64, nullptr); PhysxCcdSkeleton *skel = new PhysxCcdSkeleton(); - nassertr(skel, NULL); + nassertr(skel, nullptr); NxCCDSkeleton *skelPtr = _sdk->createCCDSkeleton(desc.get_desc()); - nassertr(skelPtr, NULL); + nassertr(skelPtr, nullptr); skel->link(skelPtr); @@ -317,7 +317,7 @@ create_ccd_skeleton(PhysxCcdSkeletonDesc &desc) { PhysxCcdSkeleton *PhysxManager:: get_ccd_skeleton(unsigned int idx) { - nassertr_always(idx < _sdk->getNbCCDSkeletons(), NULL); + nassertr_always(idx < _sdk->getNbCCDSkeletons(), nullptr); return (PhysxCcdSkeleton *)_ccd_skeletons[idx]; } diff --git a/panda/src/physx/physxMaterial.cxx b/panda/src/physx/physxMaterial.cxx index b583bcd000..11dedcacd4 100644 --- a/panda/src/physx/physxMaterial.cxx +++ b/panda/src/physx/physxMaterial.cxx @@ -39,7 +39,7 @@ void PhysxMaterial:: unlink() { // Unlink self - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; @@ -56,7 +56,7 @@ release() { unlink(); _ptr->getScene().releaseMaterial(*_ptr); - _ptr = NULL; + _ptr = nullptr; } /** @@ -65,7 +65,7 @@ release() { PhysxScene *PhysxMaterial:: get_scene() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return (PhysxScene *)(_ptr->getScene().userData); } diff --git a/panda/src/physx/physxMemoryWriteBuffer.cxx b/panda/src/physx/physxMemoryWriteBuffer.cxx index f690b1e327..0bede7e426 100644 --- a/panda/src/physx/physxMemoryWriteBuffer.cxx +++ b/panda/src/physx/physxMemoryWriteBuffer.cxx @@ -16,7 +16,7 @@ /** * */ -PhysxMemoryWriteBuffer::PhysxMemoryWriteBuffer() : currentSize(0), maxSize(0), data(NULL) +PhysxMemoryWriteBuffer::PhysxMemoryWriteBuffer() : currentSize(0), maxSize(0), data(nullptr) { } diff --git a/panda/src/physx/physxMeshPool.cxx b/panda/src/physx/physxMeshPool.cxx index 71fb20f495..4bf65576e2 100644 --- a/panda/src/physx/physxMeshPool.cxx +++ b/panda/src/physx/physxMeshPool.cxx @@ -50,7 +50,7 @@ check_filename(const Filename &fn) { PhysxConvexMesh *PhysxMeshPool:: load_convex_mesh(const Filename &fn) { - if (!check_filename(fn)) return NULL; + if (!check_filename(fn)) return nullptr; PhysxConvexMesh *mesh; @@ -61,13 +61,13 @@ load_convex_mesh(const Filename &fn) { PhysxFileStream stream = PhysxFileStream(fn, true); mesh = new PhysxConvexMesh(); - nassertr_always(mesh, NULL); + nassertr_always(mesh, nullptr); NxPhysicsSDK *sdk = NxGetPhysicsSDK(); - nassertr_always(sdk, NULL); + nassertr_always(sdk, nullptr); meshPtr = sdk->createConvexMesh(stream); - nassertr_always(meshPtr, NULL); + nassertr_always(meshPtr, nullptr); mesh->link(meshPtr); @@ -87,7 +87,7 @@ load_convex_mesh(const Filename &fn) { PhysxTriangleMesh *PhysxMeshPool:: load_triangle_mesh(const Filename &fn) { - if (!check_filename(fn)) return NULL; + if (!check_filename(fn)) return nullptr; PhysxTriangleMesh *mesh; @@ -98,13 +98,13 @@ load_triangle_mesh(const Filename &fn) { PhysxFileStream stream = PhysxFileStream(fn, true); mesh = new PhysxTriangleMesh(); - nassertr_always(mesh, NULL); + nassertr_always(mesh, nullptr); NxPhysicsSDK *sdk = NxGetPhysicsSDK(); - nassertr_always(sdk, NULL); + nassertr_always(sdk, nullptr); meshPtr = sdk->createTriangleMesh(stream); - nassertr_always(meshPtr, NULL); + nassertr_always(meshPtr, nullptr); mesh->link(meshPtr); @@ -124,7 +124,7 @@ load_triangle_mesh(const Filename &fn) { PhysxClothMesh *PhysxMeshPool:: load_cloth_mesh(const Filename &fn) { - if (!check_filename(fn)) return NULL; + if (!check_filename(fn)) return nullptr; PhysxClothMesh *mesh; @@ -135,13 +135,13 @@ load_cloth_mesh(const Filename &fn) { PhysxFileStream stream = PhysxFileStream(fn, true); mesh = new PhysxClothMesh(); - nassertr_always(mesh, NULL); + nassertr_always(mesh, nullptr); NxPhysicsSDK *sdk = NxGetPhysicsSDK(); - nassertr_always(sdk, NULL); + nassertr_always(sdk, nullptr); meshPtr = sdk->createClothMesh(stream); - nassertr_always(meshPtr, NULL); + nassertr_always(meshPtr, nullptr); mesh->link(meshPtr); @@ -161,7 +161,7 @@ load_cloth_mesh(const Filename &fn) { PhysxSoftBodyMesh *PhysxMeshPool:: load_soft_body_mesh(const Filename &fn) { - if (!check_filename(fn)) return NULL; + if (!check_filename(fn)) return nullptr; PhysxSoftBodyMesh *mesh; @@ -172,13 +172,13 @@ load_soft_body_mesh(const Filename &fn) { PhysxFileStream stream = PhysxFileStream(fn, true); mesh = new PhysxSoftBodyMesh(); - nassertr_always(mesh, NULL); + nassertr_always(mesh, nullptr); NxPhysicsSDK *sdk = NxGetPhysicsSDK(); - nassertr_always(sdk, NULL); + nassertr_always(sdk, nullptr); meshPtr = sdk->createSoftBodyMesh(stream); - nassertr_always(meshPtr, NULL); + nassertr_always(meshPtr, nullptr); mesh->link(meshPtr); diff --git a/panda/src/physx/physxObjectCollection.I b/panda/src/physx/physxObjectCollection.I index 128d031bfc..62270910f7 100644 --- a/panda/src/physx/physxObjectCollection.I +++ b/panda/src/physx/physxObjectCollection.I @@ -58,7 +58,7 @@ template INLINE T *PhysxObjectCollection:: get(unsigned int index) const { - nassertr(index < _objects.size(), NULL); + nassertr(index < _objects.size(), nullptr); return _objects[index]; } @@ -70,7 +70,7 @@ template INLINE T *PhysxObjectCollection:: operator [] (unsigned int index) const { - nassertr(index < _objects.size(), NULL); + nassertr(index < _objects.size(), nullptr); return _objects[index]; } diff --git a/panda/src/physx/physxOverlapReport.cxx b/panda/src/physx/physxOverlapReport.cxx index dc5fafb431..4589740dc4 100644 --- a/panda/src/physx/physxOverlapReport.cxx +++ b/panda/src/physx/physxOverlapReport.cxx @@ -58,7 +58,7 @@ get_next_overlap() { } // No more items. Return empty overlap. - return NULL; + return nullptr; } /** @@ -67,6 +67,6 @@ get_next_overlap() { PhysxShape *PhysxOverlapReport:: get_overlap(unsigned int idx) { - nassertr(idx < get_num_overlaps(), NULL); + nassertr(idx < get_num_overlaps(), nullptr); return _overlaps[idx]; } diff --git a/panda/src/physx/physxPlaneShape.cxx b/panda/src/physx/physxPlaneShape.cxx index 49ce975f38..05a22a60f7 100644 --- a/panda/src/physx/physxPlaneShape.cxx +++ b/panda/src/physx/physxPlaneShape.cxx @@ -39,7 +39,7 @@ link(NxShape *shapePtr) { void PhysxPlaneShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; diff --git a/panda/src/physx/physxPointInPlaneJoint.cxx b/panda/src/physx/physxPointInPlaneJoint.cxx index 34c4b0df42..fc05d6f8ca 100644 --- a/panda/src/physx/physxPointInPlaneJoint.cxx +++ b/panda/src/physx/physxPointInPlaneJoint.cxx @@ -38,7 +38,7 @@ link(NxJoint *jointPtr) { void PhysxPointInPlaneJoint:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; diff --git a/panda/src/physx/physxPointOnLineJoint.cxx b/panda/src/physx/physxPointOnLineJoint.cxx index 1cdf84981f..5e5d4e8665 100644 --- a/panda/src/physx/physxPointOnLineJoint.cxx +++ b/panda/src/physx/physxPointOnLineJoint.cxx @@ -38,7 +38,7 @@ link(NxJoint *jointPtr) { void PhysxPointOnLineJoint:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; diff --git a/panda/src/physx/physxPrismaticJoint.cxx b/panda/src/physx/physxPrismaticJoint.cxx index 9fd765c94f..94b9fd0949 100644 --- a/panda/src/physx/physxPrismaticJoint.cxx +++ b/panda/src/physx/physxPrismaticJoint.cxx @@ -38,7 +38,7 @@ link(NxJoint *jointPtr) { void PhysxPrismaticJoint:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; diff --git a/panda/src/physx/physxPulleyJoint.cxx b/panda/src/physx/physxPulleyJoint.cxx index 3b98de1cef..0986774ae8 100644 --- a/panda/src/physx/physxPulleyJoint.cxx +++ b/panda/src/physx/physxPulleyJoint.cxx @@ -39,7 +39,7 @@ link(NxJoint *jointPtr) { void PhysxPulleyJoint:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; diff --git a/panda/src/physx/physxRaycastHit.cxx b/panda/src/physx/physxRaycastHit.cxx index 30d983f0ea..5d2bce1737 100644 --- a/panda/src/physx/physxRaycastHit.cxx +++ b/panda/src/physx/physxRaycastHit.cxx @@ -21,7 +21,7 @@ bool PhysxRaycastHit:: is_empty() const { - return (_hit.shape == NULL); + return (_hit.shape == nullptr); } /** @@ -30,7 +30,7 @@ is_empty() const { PhysxShape *PhysxRaycastHit:: get_shape() const { - nassertr_always(_hit.shape, NULL); + nassertr_always(_hit.shape, nullptr); return (PhysxShape *)_hit.shape->userData; } diff --git a/panda/src/physx/physxRaycastReport.cxx b/panda/src/physx/physxRaycastReport.cxx index cb00d85b10..368c5a5c54 100644 --- a/panda/src/physx/physxRaycastReport.cxx +++ b/panda/src/physx/physxRaycastReport.cxx @@ -55,7 +55,7 @@ get_next_hit() { // No more items. Return an empty hit. NxRaycastHit hit; - hit.shape = NULL; + hit.shape = nullptr; return PhysxRaycastHit(hit); } @@ -69,7 +69,7 @@ get_hit(unsigned int idx) { { // Index out of bounds. Return an empty hit. NxRaycastHit hit; - hit.shape = NULL; + hit.shape = nullptr; return PhysxRaycastHit(hit); } diff --git a/panda/src/physx/physxRevoluteJoint.cxx b/panda/src/physx/physxRevoluteJoint.cxx index 5b3f9c5cde..a969c78cee 100644 --- a/panda/src/physx/physxRevoluteJoint.cxx +++ b/panda/src/physx/physxRevoluteJoint.cxx @@ -41,7 +41,7 @@ link(NxJoint *jointPtr) { void PhysxRevoluteJoint:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; @@ -242,7 +242,7 @@ set_limits(const PhysxJointLimitDesc &low, const PhysxJointLimitDesc &high) { PhysxMotorDesc PhysxRevoluteJoint:: get_motor() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); PhysxMotorDesc value; _ptr->getMotor(value._desc); @@ -255,7 +255,7 @@ get_motor() const { PhysxSpringDesc PhysxRevoluteJoint:: get_spring() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); PhysxSpringDesc value; _ptr->getSpring(value._desc); diff --git a/panda/src/physx/physxScene.I b/panda/src/physx/physxScene.I index d611cbe3db..9f9e2c5aa8 100644 --- a/panda/src/physx/physxScene.I +++ b/panda/src/physx/physxScene.I @@ -26,7 +26,7 @@ PhysxScene() : PhysxObject() { INLINE PhysxScene:: ~PhysxScene() { - _debugNode = NULL; + _debugNode = nullptr; } /** diff --git a/panda/src/physx/physxScene.cxx b/panda/src/physx/physxScene.cxx index e2623ef47a..b07a373729 100644 --- a/panda/src/physx/physxScene.cxx +++ b/panda/src/physx/physxScene.cxx @@ -157,7 +157,7 @@ unlink() { _cm->purgeControllers(); NxReleaseControllerManager(_cm); - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxManager::get_global_ptr()->_scenes.remove(this); @@ -174,7 +174,7 @@ release() { unlink(); NxPhysicsSDK *sdk = NxGetPhysicsSDK(); sdk->releaseScene(*_ptr); - _ptr = NULL; + _ptr = nullptr; } /** @@ -226,7 +226,7 @@ void PhysxScene:: fetch_results() { nassertv(_error_type == ET_ok); - nassertv(_ptr != NULL); + nassertv(_ptr != nullptr); _pcollector_fetch_results.start(); _ptr->fetchResults(NX_RIGID_BODY_FINISHED, true); @@ -354,14 +354,14 @@ get_num_actors() const { PhysxActor *PhysxScene:: create_actor(PhysxActorDesc &desc) { - nassertr(_error_type == ET_ok, NULL); - nassertr(desc.is_valid(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr(desc.is_valid(), nullptr); PhysxActor *actor = new PhysxActor(); - nassertr(actor, NULL); + nassertr(actor, nullptr); NxActor *actorPtr = _ptr->createActor(desc._desc); - nassertr(actorPtr, NULL); + nassertr(actorPtr, nullptr); actor->link(actorPtr); @@ -374,8 +374,8 @@ create_actor(PhysxActorDesc &desc) { PhysxActor *PhysxScene:: get_actor(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _ptr->getNbActors(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _ptr->getNbActors(), nullptr); NxActor *actorPtr = _ptr->getActors()[idx]; PhysxActor *actor = (PhysxActor *)(actorPtr->userData); @@ -395,7 +395,7 @@ get_actor(unsigned int idx) const { PhysxDebugGeomNode *PhysxScene:: get_debug_geom_node() { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return _debugNode; } @@ -412,7 +412,7 @@ enable_contact_reporting(bool enabled) { _contact_report.enable(); } else { - _ptr->setUserContactReport(NULL); + _ptr->setUserContactReport(nullptr); _contact_report.disable(); } } @@ -441,7 +441,7 @@ enable_trigger_reporting(bool enabled) { _trigger_report.enable(); } else { - _ptr->setUserTriggerReport(NULL); + _ptr->setUserTriggerReport(nullptr); _trigger_report.disable(); } } @@ -510,14 +510,14 @@ get_num_materials() const { PhysxMaterial *PhysxScene:: create_material(PhysxMaterialDesc &desc) { - nassertr(_error_type == ET_ok, NULL); - nassertr(desc.is_valid(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr(desc.is_valid(), nullptr); PhysxMaterial *material = new PhysxMaterial(); - nassertr(material, NULL); + nassertr(material, nullptr); NxMaterial *materialPtr = _ptr->createMaterial(desc._desc); - nassertr(materialPtr, NULL); + nassertr(materialPtr, nullptr); material->link(materialPtr); @@ -531,15 +531,15 @@ create_material(PhysxMaterialDesc &desc) { PhysxMaterial *PhysxScene:: create_material() { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); PhysxMaterial *material = new PhysxMaterial(); - nassertr(material, NULL); + nassertr(material, nullptr); NxMaterialDesc desc; desc.setToDefault(); NxMaterial *materialPtr = _ptr->createMaterial(desc); - nassertr(materialPtr, NULL); + nassertr(materialPtr, nullptr); material->link(materialPtr); @@ -570,7 +570,7 @@ get_hightest_material_index() const { PhysxMaterial *PhysxScene:: get_material_from_index(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); NxMaterial *materialPtr = _ptr->getMaterialFromIndex(idx); @@ -584,8 +584,8 @@ get_material_from_index(unsigned int idx) const { PhysxMaterial *PhysxScene:: get_material(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _ptr->getNbMaterials(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _ptr->getNbMaterials(), nullptr); NxU32 n = _ptr->getNbMaterials(); NxMaterial **materials = new NxMaterial *[n]; @@ -593,7 +593,7 @@ get_material(unsigned int idx) const { NxU32 iterator = 0; materialCount = _ptr->getMaterialArray(materials, n, iterator); - nassertr((materialCount == n), NULL); + nassertr((materialCount == n), nullptr); NxMaterial *materialPtr = materials[idx]; delete[] materials; @@ -618,17 +618,17 @@ get_num_controllers() const { PhysxController *PhysxScene:: create_controller(PhysxControllerDesc &desc) { - nassertr(_error_type == ET_ok, NULL); - nassertr(desc.is_valid(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr(desc.is_valid(), nullptr); PhysxController *controller = PhysxController::factory(desc.ptr()->getType()); - nassertr(controller, NULL); + nassertr(controller, nullptr); desc.ptr()->callback = &_controller_report; desc.ptr()->userData = controller; NxController *controllerPtr = _cm->createController(_ptr,*desc.ptr()); - nassertr(controllerPtr, NULL); + nassertr(controllerPtr, nullptr); controller->link(controllerPtr); controller->get_actor()->set_name(""); @@ -642,8 +642,8 @@ create_controller(PhysxControllerDesc &desc) { PhysxController *PhysxScene:: get_controller(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _cm->getNbControllers(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _cm->getNbControllers(), nullptr); NxController *controllerPtr = _cm->getController(idx); PhysxController *controller = (PhysxController *)(controllerPtr->getUserData()); @@ -668,14 +668,14 @@ get_num_joints() const { PhysxJoint *PhysxScene:: create_joint(PhysxJointDesc &desc) { - nassertr(_error_type == ET_ok, NULL); - nassertr(desc.is_valid(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr(desc.is_valid(), nullptr); PhysxJoint *joint = PhysxJoint::factory(desc.ptr()->getType()); - nassertr(joint, NULL); + nassertr(joint, nullptr); NxJoint *jointPtr = _ptr->createJoint(*desc.ptr()); - nassertr(jointPtr, NULL); + nassertr(jointPtr, nullptr); joint->link(jointPtr); @@ -688,8 +688,8 @@ create_joint(PhysxJointDesc &desc) { PhysxJoint *PhysxScene:: get_joint(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _ptr->getNbJoints(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _ptr->getNbJoints(), nullptr); NxJoint *jointPtr; NxU32 nJoints = _ptr->getNbJoints(); @@ -718,18 +718,18 @@ get_num_force_fields() const { PhysxForceField *PhysxScene:: create_force_field(PhysxForceFieldDesc &desc) { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); // Create the kernel desc.create_kernel(_ptr); - nassertr(desc.is_valid(), NULL); + nassertr(desc.is_valid(), nullptr); // Create the force field PhysxForceField *field = new PhysxForceField(); - nassertr(field, NULL); + nassertr(field, nullptr); NxForceField *fieldPtr = _ptr->createForceField(desc._desc); - nassertr(fieldPtr, NULL); + nassertr(fieldPtr, nullptr); field->link(fieldPtr); @@ -743,8 +743,8 @@ create_force_field(PhysxForceFieldDesc &desc) { PhysxForceField *PhysxScene:: get_force_field(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _ptr->getNbForceFields(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _ptr->getNbForceFields(), nullptr); NxForceField **fields = _ptr->getForceFields(); NxForceField *fieldPtr = fields[idx]; @@ -768,13 +768,13 @@ get_num_force_field_shape_groups() const { PhysxForceFieldShapeGroup *PhysxScene:: create_force_field_shape_group(PhysxForceFieldShapeGroupDesc &desc) { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); PhysxForceFieldShapeGroup *group = new PhysxForceFieldShapeGroup(); - nassertr(group, NULL); + nassertr(group, nullptr); NxForceFieldShapeGroup *groupPtr = _ptr->createForceFieldShapeGroup(desc._desc); - nassertr(groupPtr, NULL); + nassertr(groupPtr, nullptr); group->link(groupPtr); @@ -787,17 +787,17 @@ create_force_field_shape_group(PhysxForceFieldShapeGroupDesc &desc) { PhysxForceFieldShapeGroup *PhysxScene:: get_force_field_shape_group(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _ptr->getNbForceFieldShapeGroups(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _ptr->getNbForceFieldShapeGroups(), nullptr); _ptr->resetForceFieldShapeGroupsIterator(); - NxForceFieldShapeGroup *groupPtr = NULL; + NxForceFieldShapeGroup *groupPtr = nullptr; idx++; while (idx-- > 0) { groupPtr = _ptr->getNextForceFieldShapeGroup(); } - return groupPtr ? (PhysxForceFieldShapeGroup *)groupPtr->userData : NULL; + return groupPtr ? (PhysxForceFieldShapeGroup *)groupPtr->userData : nullptr; } /** @@ -816,13 +816,13 @@ get_num_cloths() const { PhysxCloth *PhysxScene:: create_cloth(PhysxClothDesc &desc) { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); PhysxCloth *cloth = new PhysxCloth(); - nassertr(cloth, NULL); + nassertr(cloth, nullptr); NxCloth *clothPtr = _ptr->createCloth(desc._desc); - nassertr(clothPtr, NULL); + nassertr(clothPtr, nullptr); cloth->link(clothPtr); @@ -835,8 +835,8 @@ create_cloth(PhysxClothDesc &desc) { PhysxCloth *PhysxScene:: get_cloth(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _ptr->getNbCloths(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _ptr->getNbCloths(), nullptr); NxCloth **cloths = _ptr->getCloths(); NxCloth *clothPtr = cloths[idx]; @@ -860,13 +860,13 @@ get_num_soft_bodies() const { PhysxSoftBody *PhysxScene:: create_soft_body(PhysxSoftBodyDesc &desc) { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); PhysxSoftBody *softbody = new PhysxSoftBody(); - nassertr(softbody, NULL); + nassertr(softbody, nullptr); NxSoftBody *softbodyPtr = _ptr->createSoftBody(desc._desc); - nassertr(softbodyPtr, NULL); + nassertr(softbodyPtr, nullptr); softbody->link(softbodyPtr); @@ -880,8 +880,8 @@ create_soft_body(PhysxSoftBodyDesc &desc) { PhysxSoftBody *PhysxScene:: get_soft_body(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _ptr->getNbSoftBodies(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _ptr->getNbSoftBodies(), nullptr); NxSoftBody **softbodies = _ptr->getSoftBodies(); NxSoftBody *softbodyPtr = softbodies[idx]; @@ -905,11 +905,11 @@ get_num_vehicles() const { PhysxVehicle *PhysxScene:: create_vehicle(PhysxVehicleDesc &desc) { - nassertr(_error_type == ET_ok, NULL); - nassertr(desc.is_valid(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr(desc.is_valid(), nullptr); PhysxVehicle *vehicle = new PhysxVehicle(); - nassertr(vehicle, NULL); + nassertr(vehicle, nullptr); vehicle->create(this, desc); @@ -922,8 +922,8 @@ create_vehicle(PhysxVehicleDesc &desc) { PhysxVehicle *PhysxScene:: get_vehicle(unsigned int idx) const { - nassertr(_error_type == ET_ok, NULL); - nassertr_always(idx < _vehicles.size(), NULL); + nassertr(_error_type == ET_ok, nullptr); + nassertr_always(idx < _vehicles.size(), nullptr); return _vehicles[idx]; } @@ -934,7 +934,7 @@ get_vehicle(unsigned int idx) const { PhysxSceneStats2 PhysxScene:: get_stats2() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return PhysxSceneStats2(_ptr->getStats2()); } @@ -949,7 +949,7 @@ raycast_any_shape(const PhysxRay &ray, nassertr(_error_type == ET_ok, false); - NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : NULL; + NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : nullptr; return _ptr->raycastAnyShape(ray._ray, (NxShapesType)shapesType, mask.get_mask(), ray._length, groupsPtr); @@ -969,7 +969,7 @@ raycast_closest_shape(const PhysxRay &ray, nassertr(_error_type == ET_ok, hit); - NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : NULL; + NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : nullptr; NxU32 hints = NX_RAYCAST_SHAPE | NX_RAYCAST_IMPACT | NX_RAYCAST_DISTANCE; if (smoothNormal == true) { @@ -1000,7 +1000,7 @@ raycast_all_shapes(const PhysxRay &ray, nassertr(_error_type == ET_ok, report); - NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : NULL; + NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : nullptr; NxU32 hints = NX_RAYCAST_SHAPE | NX_RAYCAST_IMPACT | NX_RAYCAST_DISTANCE; if (smoothNormal == true) { @@ -1028,7 +1028,7 @@ raycast_any_bounds(const PhysxRay &ray, nassertr(_error_type == ET_ok, false); - NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : NULL; + NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : nullptr; return _ptr->raycastAnyBounds(ray._ray, (NxShapesType)shapesType, mask.get_mask(), ray._length, groupsPtr); @@ -1046,7 +1046,7 @@ raycast_closest_bounds(const PhysxRay &ray, PhysxShapesType shapesType, PhysxMas nassertr(_error_type == ET_ok, hit); - NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : NULL; + NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : nullptr; NxU32 hints = NX_RAYCAST_SHAPE | NX_RAYCAST_IMPACT | NX_RAYCAST_DISTANCE; if (smoothNormal == true) { @@ -1078,7 +1078,7 @@ raycast_all_bounds(const PhysxRay &ray, nassertr(_error_type == ET_ok, report); - NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : NULL; + NxGroupsMask *groupsPtr = groups ? &(groups->_mask) : nullptr; NxU32 hints = NX_RAYCAST_SHAPE | NX_RAYCAST_IMPACT | NX_RAYCAST_DISTANCE; if (smoothNormal == true) { @@ -1109,8 +1109,8 @@ overlap_sphere_shapes(const LPoint3f ¢er, float radius, NxSphere worldSphere(PhysxManager::point3_to_nxVec3(center), radius); - _ptr->overlapSphereShapes(worldSphere, (NxShapesType)shapesType, 0, NULL, &report, - mask.get_mask(), NULL, accurateCollision); + _ptr->overlapSphereShapes(worldSphere, (NxShapesType)shapesType, 0, nullptr, &report, + mask.get_mask(), nullptr, accurateCollision); return report; } @@ -1132,8 +1132,8 @@ overlap_capsule_shapes(const LPoint3f &p0, const LPoint3f &p1, float radius, PhysxManager::point3_to_nxVec3(p1)); NxCapsule worldCapsule(segment, radius); - _ptr->overlapCapsuleShapes(worldCapsule, (NxShapesType)shapesType, 0, NULL, &report, - mask.get_mask(), NULL, accurateCollision); + _ptr->overlapCapsuleShapes(worldCapsule, (NxShapesType)shapesType, 0, nullptr, &report, + mask.get_mask(), nullptr, accurateCollision); return report; } @@ -1541,9 +1541,9 @@ get_dominance_group_pair(unsigned int g1, unsigned int g2) { PhysxMaterial *PhysxScene:: get_wheel_shape_material() { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); - if (_wheelShapeMaterial == NULL) { + if (_wheelShapeMaterial == nullptr) { PhysxMaterialDesc materialDesc; materialDesc.set_flag(PhysxMaterialDesc::MF_disable_friction, true); _wheelShapeMaterial = create_material(materialDesc); diff --git a/panda/src/physx/physxScene.h b/panda/src/physx/physxScene.h index b26105c644..ed3b39ff4e 100644 --- a/panda/src/physx/physxScene.h +++ b/panda/src/physx/physxScene.h @@ -157,32 +157,32 @@ PUBLISHED: bool raycast_any_shape(const PhysxRay &ray, PhysxShapesType shapesType=ST_all, PhysxMask mask=PhysxMask::all_on(), - PhysxGroupsMask *groups=NULL) const; + PhysxGroupsMask *groups=nullptr) const; PhysxRaycastHit raycast_closest_shape(const PhysxRay &ray, PhysxShapesType shapesType=ST_all, PhysxMask mask=PhysxMask::all_on(), - PhysxGroupsMask *groups=NULL, bool smoothNormal=true) const; + PhysxGroupsMask *groups=nullptr, bool smoothNormal=true) const; PhysxRaycastReport raycast_all_shapes(const PhysxRay &ray, PhysxShapesType shapesType=ST_all, PhysxMask mask=PhysxMask::all_on(), - PhysxGroupsMask *groups=NULL, bool smoothNormal=true) const; + PhysxGroupsMask *groups=nullptr, bool smoothNormal=true) const; bool raycast_any_bounds(const PhysxRay &ray, PhysxShapesType shapesType=ST_all, PhysxMask mask=PhysxMask::all_on(), - PhysxGroupsMask *groups=NULL) const; + PhysxGroupsMask *groups=nullptr) const; PhysxRaycastHit raycast_closest_bounds(const PhysxRay &ray, PhysxShapesType shapesType=ST_all, PhysxMask mask=PhysxMask::all_on(), - PhysxGroupsMask *groups=NULL, bool smoothNormal=true) const; + PhysxGroupsMask *groups=nullptr, bool smoothNormal=true) const; PhysxRaycastReport raycast_all_bounds(const PhysxRay &ray, PhysxShapesType shapesType=ST_all, PhysxMask mask=PhysxMask::all_on(), - PhysxGroupsMask *groups=NULL, bool smoothNormal=true) const; + PhysxGroupsMask *groups=nullptr, bool smoothNormal=true) const; // Overlap queries PhysxOverlapReport overlap_sphere_shapes(const LPoint3f ¢er, float radius, diff --git a/panda/src/physx/physxShape.cxx b/panda/src/physx/physxShape.cxx index 926001f1be..0518f81d12 100644 --- a/panda/src/physx/physxShape.cxx +++ b/panda/src/physx/physxShape.cxx @@ -79,7 +79,7 @@ factory(NxShapeType shapeType) { } physx_cat.error() << "Unknown shape type.\n"; - return NULL; + return nullptr; } /** @@ -88,7 +88,7 @@ factory(NxShapeType shapeType) { PhysxActor *PhysxShape:: get_actor() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return (PhysxActor *)(ptr()->getActor().userData); } @@ -406,7 +406,7 @@ set_ccd_skeleton(PhysxCcdSkeleton *skel) { PhysxCcdSkeleton *PhysxShape:: get_ccd_skeleton() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return _skel; } diff --git a/panda/src/physx/physxSoftBody.cxx b/panda/src/physx/physxSoftBody.cxx index 268a229502..1e5ed73685 100644 --- a/panda/src/physx/physxSoftBody.cxx +++ b/panda/src/physx/physxSoftBody.cxx @@ -45,13 +45,13 @@ void PhysxSoftBody:: unlink() { // Unlink self - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; scene->_softbodies.remove(this); - _node = NULL; + _node = nullptr; } /** @@ -64,7 +64,7 @@ release() { unlink(); _ptr->getScene().releaseSoftBody(*_ptr); - _ptr = NULL; + _ptr = nullptr; } /** @@ -94,7 +94,7 @@ update() { PhysxScene *PhysxSoftBody:: get_scene() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return (PhysxScene *)_ptr->getScene().userData; } @@ -104,7 +104,7 @@ get_scene() const { PhysxSoftBodyNode *PhysxSoftBody:: get_soft_body_node() const { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); return _node; } @@ -114,7 +114,7 @@ get_soft_body_node() const { PhysxSoftBodyNode *PhysxSoftBody:: create_soft_body_node(const char *name) { - nassertr(_error_type == ET_ok, NULL); + nassertr(_error_type == ET_ok, nullptr); _node = new PhysxSoftBodyNode(name); _node->allocate(this); diff --git a/panda/src/physx/physxSoftBodyMesh.cxx b/panda/src/physx/physxSoftBodyMesh.cxx index 4cb0c9cc26..2f69f3d173 100644 --- a/panda/src/physx/physxSoftBodyMesh.cxx +++ b/panda/src/physx/physxSoftBodyMesh.cxx @@ -49,7 +49,7 @@ release() { unlink(); NxGetPhysicsSDK()->releaseSoftBodyMesh(*_ptr); - _ptr = NULL; + _ptr = nullptr; PhysxMeshPool::release_soft_body_mesh(this); } diff --git a/panda/src/physx/physxSoftBodyMeshDesc.I b/panda/src/physx/physxSoftBodyMeshDesc.I index 0cf5663cd7..0125b456ec 100644 --- a/panda/src/physx/physxSoftBodyMeshDesc.I +++ b/panda/src/physx/physxSoftBodyMeshDesc.I @@ -20,11 +20,11 @@ PhysxSoftBodyMeshDesc() { _desc.flags = 0; _desc.vertexStrideBytes = sizeof(NxVec3); _desc.tetrahedronStrideBytes = 4*sizeof(NxU32); - _desc.vertices = NULL; - _desc.tetrahedra = NULL; + _desc.vertices = nullptr; + _desc.tetrahedra = nullptr; - _vertices = NULL; - _tetrahedra = NULL; + _vertices = nullptr; + _tetrahedra = nullptr; } /** diff --git a/panda/src/physx/physxSphereForceFieldShape.cxx b/panda/src/physx/physxSphereForceFieldShape.cxx index 4f140de456..bb04de907a 100644 --- a/panda/src/physx/physxSphereForceFieldShape.cxx +++ b/panda/src/physx/physxSphereForceFieldShape.cxx @@ -38,7 +38,7 @@ link(NxForceFieldShape *shapePtr) { void PhysxSphereForceFieldShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxForceFieldShapeGroup *group = (PhysxForceFieldShapeGroup *)_ptr->getShapeGroup().userData; diff --git a/panda/src/physx/physxSphereShape.cxx b/panda/src/physx/physxSphereShape.cxx index 60d7f15425..a67a3b2062 100644 --- a/panda/src/physx/physxSphereShape.cxx +++ b/panda/src/physx/physxSphereShape.cxx @@ -38,7 +38,7 @@ link(NxShape *shapePtr) { void PhysxSphereShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; diff --git a/panda/src/physx/physxSphericalJoint.cxx b/panda/src/physx/physxSphericalJoint.cxx index f1e8606ffa..3dabd9bfe4 100644 --- a/panda/src/physx/physxSphericalJoint.cxx +++ b/panda/src/physx/physxSphericalJoint.cxx @@ -38,7 +38,7 @@ link(NxJoint *jointPtr) { void PhysxSphericalJoint:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData; diff --git a/panda/src/physx/physxTriangleMesh.cxx b/panda/src/physx/physxTriangleMesh.cxx index 80971a3f2e..2b3d81280c 100644 --- a/panda/src/physx/physxTriangleMesh.cxx +++ b/panda/src/physx/physxTriangleMesh.cxx @@ -49,7 +49,7 @@ release() { unlink(); NxGetPhysicsSDK()->releaseTriangleMesh(*_ptr); - _ptr = NULL; + _ptr = nullptr; PhysxMeshPool::release_triangle_mesh(this); } diff --git a/panda/src/physx/physxTriangleMeshDesc.I b/panda/src/physx/physxTriangleMeshDesc.I index 4acd6b09f9..e337b35d18 100644 --- a/panda/src/physx/physxTriangleMeshDesc.I +++ b/panda/src/physx/physxTriangleMeshDesc.I @@ -21,13 +21,13 @@ PhysxTriangleMeshDesc() { _desc.pointStrideBytes = sizeof(NxVec3); _desc.triangleStrideBytes = 3*sizeof(NxU32); _desc.materialIndexStride = sizeof(NxMaterialIndex); - _desc.points = NULL; - _desc.triangles = NULL; - _desc.materialIndices = NULL; + _desc.points = nullptr; + _desc.triangles = nullptr; + _desc.materialIndices = nullptr; - _vertices = NULL; - _triangles = NULL; - _materials = NULL; + _vertices = nullptr; + _triangles = nullptr; + _materials = nullptr; } /** diff --git a/panda/src/physx/physxTriangleMeshShape.cxx b/panda/src/physx/physxTriangleMeshShape.cxx index 954d0cf321..eaa57db4fc 100644 --- a/panda/src/physx/physxTriangleMeshShape.cxx +++ b/panda/src/physx/physxTriangleMeshShape.cxx @@ -38,7 +38,7 @@ link(NxShape *shapePtr) { void PhysxTriangleMeshShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; diff --git a/panda/src/physx/physxUtilLib.I b/panda/src/physx/physxUtilLib.I index ff04f2a2c2..dcdcb328ae 100644 --- a/panda/src/physx/physxUtilLib.I +++ b/panda/src/physx/physxUtilLib.I @@ -26,5 +26,5 @@ PhysxUtilLib() { INLINE PhysxUtilLib:: ~PhysxUtilLib() { - _ptr = NULL; + _ptr = nullptr; } diff --git a/panda/src/physx/physxWheelShape.cxx b/panda/src/physx/physxWheelShape.cxx index de34bf760c..69a3e5d02a 100644 --- a/panda/src/physx/physxWheelShape.cxx +++ b/panda/src/physx/physxWheelShape.cxx @@ -39,7 +39,7 @@ link(NxShape *shapePtr) { void PhysxWheelShape:: unlink() { - _ptr->userData = NULL; + _ptr->userData = nullptr; _error_type = ET_released; PhysxActor *actor = (PhysxActor *)_ptr->getActor().userData; diff --git a/panda/src/pipeline/conditionVarDebug.cxx b/panda/src/pipeline/conditionVarDebug.cxx index 0cc738542f..fb67e7d3c9 100644 --- a/panda/src/pipeline/conditionVarDebug.cxx +++ b/panda/src/pipeline/conditionVarDebug.cxx @@ -75,8 +75,8 @@ wait() { << *current_thread << " waiting on " << *this << "\n"; } - nassertd(current_thread->_waiting_on_cvar == NULL && - current_thread->_waiting_on_cvar_full == NULL) { + nassertd(current_thread->_waiting_on_cvar == nullptr && + current_thread->_waiting_on_cvar_full == nullptr) { } current_thread->_waiting_on_cvar = this; @@ -86,7 +86,7 @@ wait() { nassertd(current_thread->_waiting_on_cvar == this) { } - current_thread->_waiting_on_cvar = NULL; + current_thread->_waiting_on_cvar = nullptr; if (thread_cat.is_spam()) { thread_cat.spam() @@ -125,8 +125,8 @@ wait(double timeout) { << ", with timeout " << timeout << "\n"; } - nassertd(current_thread->_waiting_on_cvar == NULL && - current_thread->_waiting_on_cvar_full == NULL) { + nassertd(current_thread->_waiting_on_cvar == nullptr && + current_thread->_waiting_on_cvar_full == nullptr) { } current_thread->_waiting_on_cvar = this; @@ -136,7 +136,7 @@ wait(double timeout) { nassertd(current_thread->_waiting_on_cvar == this) { } - current_thread->_waiting_on_cvar = NULL; + current_thread->_waiting_on_cvar = nullptr; if (thread_cat.is_spam()) { thread_cat.spam() diff --git a/panda/src/pipeline/conditionVarFullDebug.cxx b/panda/src/pipeline/conditionVarFullDebug.cxx index 8f59702a3f..24f9d1cdc3 100644 --- a/panda/src/pipeline/conditionVarFullDebug.cxx +++ b/panda/src/pipeline/conditionVarFullDebug.cxx @@ -75,8 +75,8 @@ wait() { << *current_thread << " waiting on " << *this << "\n"; } - nassertd(current_thread->_waiting_on_cvar == NULL && - current_thread->_waiting_on_cvar_full == NULL) { + nassertd(current_thread->_waiting_on_cvar == nullptr && + current_thread->_waiting_on_cvar_full == nullptr) { } current_thread->_waiting_on_cvar_full = this; @@ -86,7 +86,7 @@ wait() { nassertd(current_thread->_waiting_on_cvar_full == this) { } - current_thread->_waiting_on_cvar_full = NULL; + current_thread->_waiting_on_cvar_full = nullptr; if (thread_cat.is_spam()) { thread_cat.spam() @@ -125,8 +125,8 @@ wait(double timeout) { << ", with timeout " << timeout << "\n"; } - nassertd(current_thread->_waiting_on_cvar == NULL && - current_thread->_waiting_on_cvar_full == NULL) { + nassertd(current_thread->_waiting_on_cvar == nullptr && + current_thread->_waiting_on_cvar_full == nullptr) { } current_thread->_waiting_on_cvar_full = this; @@ -136,7 +136,7 @@ wait(double timeout) { nassertd(current_thread->_waiting_on_cvar_full == this) { } - current_thread->_waiting_on_cvar_full = NULL; + current_thread->_waiting_on_cvar_full = nullptr; if (thread_cat.is_spam()) { thread_cat.spam() diff --git a/panda/src/pipeline/conditionVarFullWin32Impl.I b/panda/src/pipeline/conditionVarFullWin32Impl.I index 361e81ac93..386a9d5784 100644 --- a/panda/src/pipeline/conditionVarFullWin32Impl.I +++ b/panda/src/pipeline/conditionVarFullWin32Impl.I @@ -19,8 +19,8 @@ ConditionVarFullWin32Impl(MutexWin32Impl &mutex) { _external_mutex = &mutex._lock; // Create an auto-reset event and a manual-reset event. - _event_signal = CreateEvent(NULL, false, false, NULL); - _event_broadcast = CreateEvent(NULL, true, false, NULL); + _event_signal = CreateEvent(nullptr, false, false, nullptr); + _event_broadcast = CreateEvent(nullptr, true, false, nullptr); _waiters_count = 0; } diff --git a/panda/src/pipeline/conditionVarPosixImpl.I b/panda/src/pipeline/conditionVarPosixImpl.I index e51c0e8447..0b3e533717 100644 --- a/panda/src/pipeline/conditionVarPosixImpl.I +++ b/panda/src/pipeline/conditionVarPosixImpl.I @@ -19,7 +19,7 @@ ConditionVarPosixImpl(MutexPosixImpl &mutex) : _mutex(mutex) { TAU_PROFILE("ConditionVarPosixImpl::ConditionVarPosixImpl()", " ", TAU_USER); - int result = pthread_cond_init(&_cvar, NULL); + int result = pthread_cond_init(&_cvar, nullptr); nassertv(result == 0); } diff --git a/panda/src/pipeline/conditionVarPosixImpl.cxx b/panda/src/pipeline/conditionVarPosixImpl.cxx index 6613dd53b4..e2e527c369 100644 --- a/panda/src/pipeline/conditionVarPosixImpl.cxx +++ b/panda/src/pipeline/conditionVarPosixImpl.cxx @@ -26,7 +26,7 @@ wait(double timeout) { // TAU_PROFILE("ConditionVarPosixImpl::wait()", " ", TAU_USER); struct timeval now; - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); // Convert from timeval to timespec struct timespec ts; diff --git a/panda/src/pipeline/conditionVarWin32Impl.I b/panda/src/pipeline/conditionVarWin32Impl.I index 263a7d37a4..5994c638d5 100644 --- a/panda/src/pipeline/conditionVarWin32Impl.I +++ b/panda/src/pipeline/conditionVarWin32Impl.I @@ -19,7 +19,7 @@ ConditionVarWin32Impl(MutexWin32Impl &mutex) { _external_mutex = &mutex._lock; // Create an auto-reset event. - _event_signal = CreateEvent(NULL, false, false, NULL); + _event_signal = CreateEvent(nullptr, false, false, nullptr); } /** diff --git a/panda/src/pipeline/cycleDataLockedReader.I b/panda/src/pipeline/cycleDataLockedReader.I index 311314e1dd..a622b9a2c0 100644 --- a/panda/src/pipeline/cycleDataLockedReader.I +++ b/panda/src/pipeline/cycleDataLockedReader.I @@ -28,7 +28,7 @@ CycleDataLockedReader(const PipelineCycler &cycler, _current_thread(current_thread) { _pointer = _cycler->read(_current_thread); - nassertv(_pointer != (const CycleDataType *)NULL); + nassertv(_pointer != nullptr); } /** @@ -41,7 +41,7 @@ CycleDataLockedReader(const CycleDataLockedReader ©) : _current_thread(copy._current_thread), _pointer(copy._pointer) { - nassertv(_pointer != (const CycleDataType *)NULL); + nassertv(_pointer != nullptr); _cycler->increment_read(_pointer); } @@ -51,13 +51,13 @@ CycleDataLockedReader(const CycleDataLockedReader ©) : template INLINE void CycleDataLockedReader:: operator = (const CycleDataLockedReader ©) { - nassertv(_pointer == (CycleDataType *)NULL); + nassertv(_pointer == nullptr); nassertv(_current_thread == copy._current_thread); _cycler = copy._cycler; _pointer = copy._pointer; - nassertv(_pointer != (const CycleDataType *)NULL); + nassertv(_pointer != nullptr); _cycler->increment_read(_pointer); } @@ -71,7 +71,7 @@ CycleDataLockedReader(CycleDataLockedReader &&from) noexcept : _current_thread(from._current_thread), _pointer(from._pointer) { - from._pointer = NULL; + from._pointer = nullptr; } /** @@ -80,13 +80,13 @@ CycleDataLockedReader(CycleDataLockedReader &&from) noexcept : template INLINE void CycleDataLockedReader:: operator = (CycleDataLockedReader &&from) noexcept { - nassertv(_pointer == (CycleDataType *)NULL); + nassertv(_pointer == nullptr); nassertv(_current_thread == from._current_thread); _cycler = from._cycler; _pointer = from._pointer; - from._pointer = NULL; + from._pointer = nullptr; } /** @@ -95,7 +95,7 @@ operator = (CycleDataLockedReader &&from) noexcept { template INLINE CycleDataLockedReader:: ~CycleDataLockedReader() { - if (_pointer != NULL) { + if (_pointer != nullptr) { _cycler->release_read(_pointer); } } @@ -106,7 +106,7 @@ INLINE CycleDataLockedReader:: template INLINE const CycleDataType *CycleDataLockedReader:: operator -> () const { - nassertr(_pointer != (const CycleDataType *)NULL, _cycler->cheat()); + nassertr(_pointer != nullptr, _cycler->cheat()); return _pointer; } @@ -117,7 +117,7 @@ operator -> () const { template INLINE CycleDataLockedReader:: operator const CycleDataType * () const { - nassertr(_pointer != (const CycleDataType *)NULL, _cycler->cheat()); + nassertr(_pointer != nullptr, _cycler->cheat()); return _pointer; } @@ -131,8 +131,8 @@ template INLINE const CycleDataType *CycleDataLockedReader:: take_pointer() { const CycleDataType *pointer = _pointer; - _pointer = (CycleDataType *)NULL; - nassertr(pointer != (const CycleDataType *)NULL, _cycler->cheat()); + _pointer = nullptr; + nassertr(pointer != nullptr, _cycler->cheat()); return pointer; } diff --git a/panda/src/pipeline/cycleDataLockedStageReader.I b/panda/src/pipeline/cycleDataLockedStageReader.I index d65d9da889..22b8785c82 100644 --- a/panda/src/pipeline/cycleDataLockedStageReader.I +++ b/panda/src/pipeline/cycleDataLockedStageReader.I @@ -29,7 +29,7 @@ CycleDataLockedStageReader(const PipelineCycler &cycler, _stage(stage) { _pointer = _cycler->read_stage(_stage, _current_thread); - nassertv(_pointer != (const CycleDataType *)NULL); + nassertv(_pointer != nullptr); } /** @@ -43,7 +43,7 @@ CycleDataLockedStageReader(const CycleDataLockedStageReader © _pointer(copy._pointer), _stage(copy._stage) { - nassertv(_pointer != (const CycleDataType *)NULL); + nassertv(_pointer != nullptr); _cycler->increment_read(_pointer); } @@ -53,14 +53,14 @@ CycleDataLockedStageReader(const CycleDataLockedStageReader © template INLINE void CycleDataLockedStageReader:: operator = (const CycleDataLockedStageReader ©) { - nassertv(_pointer == (CycleDataType *)NULL); + nassertv(_pointer == nullptr); nassertv(_current_thread == copy._current_thread); _cycler = copy._cycler; _pointer = copy._pointer; _stage = copy._stage; - nassertv(_pointer != (const CycleDataType *)NULL); + nassertv(_pointer != nullptr); _cycler->increment_read(_pointer); } @@ -75,7 +75,7 @@ CycleDataLockedStageReader(CycleDataLockedStageReader &&from) noe _pointer(from._pointer), _stage(from._stage) { - from._pointer = NULL; + from._pointer = nullptr; } /** @@ -84,14 +84,14 @@ CycleDataLockedStageReader(CycleDataLockedStageReader &&from) noe template INLINE void CycleDataLockedStageReader:: operator = (CycleDataLockedStageReader &&from) noexcept { - nassertv(_pointer == (CycleDataType *)NULL); + nassertv(_pointer == nullptr); nassertv(_current_thread == from._current_thread); _cycler = from._cycler; _pointer = from._pointer; _stage = from._stage; - from._pointer = NULL; + from._pointer = nullptr; } /** @@ -100,7 +100,7 @@ operator = (CycleDataLockedStageReader &&from) noexcept { template INLINE CycleDataLockedStageReader:: ~CycleDataLockedStageReader() { - if (_pointer != NULL) { + if (_pointer != nullptr) { _cycler->release_read_stage(_stage, _pointer); } } @@ -111,7 +111,7 @@ INLINE CycleDataLockedStageReader:: template INLINE const CycleDataType *CycleDataLockedStageReader:: operator -> () const { - nassertr(_pointer != (const CycleDataType *)NULL, _cycler->cheat()); + nassertr(_pointer != nullptr, _cycler->cheat()); return _pointer; } @@ -122,7 +122,7 @@ operator -> () const { template INLINE CycleDataLockedStageReader:: operator const CycleDataType * () const { - nassertr(_pointer != (const CycleDataType *)NULL, _cycler->cheat()); + nassertr(_pointer != nullptr, _cycler->cheat()); return _pointer; } @@ -136,8 +136,8 @@ template INLINE const CycleDataType *CycleDataLockedStageReader:: take_pointer() { const CycleDataType *pointer = _pointer; - _pointer = (CycleDataType *)NULL; - nassertr(pointer != (const CycleDataType *)NULL, _cycler->cheat()); + _pointer = nullptr; + nassertr(pointer != nullptr, _cycler->cheat()); return pointer; } diff --git a/panda/src/pipeline/cycleDataStageWriter.I b/panda/src/pipeline/cycleDataStageWriter.I index a4ccc54c60..a4c1851dde 100644 --- a/panda/src/pipeline/cycleDataStageWriter.I +++ b/panda/src/pipeline/cycleDataStageWriter.I @@ -29,7 +29,7 @@ CycleDataStageWriter(PipelineCycler &cycler, int stage, _stage(stage) { _pointer = _cycler->write_stage(_stage, _current_thread); - nassertv(_pointer != (CycleDataType *)NULL); + nassertv(_pointer != nullptr); } /** @@ -44,7 +44,7 @@ CycleDataStageWriter(PipelineCycler &cycler, int stage, _stage(stage) { _pointer = _cycler->write_stage_upstream(_stage, force_to_0, _current_thread); - nassertv(_pointer != (CycleDataType *)NULL); + nassertv(_pointer != nullptr); } /** @@ -58,7 +58,7 @@ CycleDataStageWriter(const CycleDataStageWriter ©) : _pointer(copy._pointer), _stage(copy._stage) { - nassertv(_pointer != (CycleDataType *)NULL); + nassertv(_pointer != nullptr); _cycler->increment_write(_pointer); } @@ -68,14 +68,14 @@ CycleDataStageWriter(const CycleDataStageWriter ©) : template INLINE void CycleDataStageWriter:: operator = (const CycleDataStageWriter ©) { - nassertv(_pointer == (CycleDataType *)NULL); + nassertv(_pointer == nullptr); nassertv(_current_thread == copy._current_thread); _cycler = copy._cycler; _pointer = copy._pointer; _stage = copy._stage; - nassertv(_pointer != (CycleDataType *)NULL); + nassertv(_pointer != nullptr); _cycler->increment_write(_pointer); } @@ -125,7 +125,7 @@ CycleDataStageWriter(CycleDataStageWriter &&from) noexcept : _pointer(from._pointer), _stage(from._stage) { - from._pointer = NULL; + from._pointer = nullptr; } /** @@ -134,14 +134,14 @@ CycleDataStageWriter(CycleDataStageWriter &&from) noexcept : template INLINE void CycleDataStageWriter:: operator = (CycleDataStageWriter &&from) noexcept { - nassertv(_pointer == (CycleDataType *)NULL); + nassertv(_pointer == nullptr); nassertv(_current_thread == from._current_thread); _cycler = from._cycler; _pointer = from._pointer; _stage = from._stage; - from._pointer = NULL; + from._pointer = nullptr; } /** @@ -150,7 +150,7 @@ operator = (CycleDataStageWriter &&from) noexcept { template INLINE CycleDataStageWriter:: ~CycleDataStageWriter() { - if (_pointer != (CycleDataType *)NULL) { + if (_pointer != nullptr) { _cycler->release_write_stage(_stage, _pointer); } } @@ -161,7 +161,7 @@ INLINE CycleDataStageWriter:: template INLINE CycleDataType *CycleDataStageWriter:: operator -> () { - nassertr(_pointer != (CycleDataType *)NULL, _cycler->cheat()); + nassertr(_pointer != nullptr, _cycler->cheat()); return _pointer; } @@ -171,7 +171,7 @@ operator -> () { template INLINE const CycleDataType *CycleDataStageWriter:: operator -> () const { - nassertr(_pointer != (CycleDataType *)NULL, _cycler->cheat()); + nassertr(_pointer != nullptr, _cycler->cheat()); return _pointer; } @@ -182,7 +182,7 @@ operator -> () const { template INLINE CycleDataStageWriter:: operator CycleDataType * () { - nassertr(_pointer != (CycleDataType *)NULL, _cycler->cheat()); + nassertr(_pointer != nullptr, _cycler->cheat()); return _pointer; } diff --git a/panda/src/pipeline/cycleDataWriter.I b/panda/src/pipeline/cycleDataWriter.I index e142c38b3a..584c3ea129 100644 --- a/panda/src/pipeline/cycleDataWriter.I +++ b/panda/src/pipeline/cycleDataWriter.I @@ -27,7 +27,7 @@ CycleDataWriter(PipelineCycler &cycler, Thread *current_thread) : _current_thread(current_thread) { _pointer = _cycler->write(_current_thread); - nassertv(_pointer != (CycleDataType *)NULL); + nassertv(_pointer != nullptr); } /** @@ -45,7 +45,7 @@ CycleDataWriter(PipelineCycler &cycler, bool force_to_0, _current_thread(current_thread) { _pointer = _cycler->write_upstream(force_to_0, _current_thread); - nassertv(_pointer != (CycleDataType *)NULL); + nassertv(_pointer != nullptr); } /** @@ -64,7 +64,7 @@ CycleDataWriter(PipelineCycler &cycler, CycleDataType *locked_cda _current_thread(current_thread) { _pointer = locked_cdata; - nassertv(_pointer != (CycleDataType *)NULL); + nassertv(_pointer != nullptr); } /** @@ -77,7 +77,7 @@ CycleDataWriter(const CycleDataWriter ©) : _current_thread(copy._current_thread), _pointer(copy._pointer) { - nassertv(_pointer != (CycleDataType *)NULL); + nassertv(_pointer != nullptr); _cycler->increment_write(_pointer); } @@ -87,13 +87,13 @@ CycleDataWriter(const CycleDataWriter ©) : template INLINE void CycleDataWriter:: operator = (const CycleDataWriter ©) { - nassertv(_pointer == (CycleDataType *)NULL); + nassertv(_pointer == nullptr); nassertv(_current_thread == copy._current_thread); _cycler = copy._cycler; _pointer = copy._pointer; - nassertv(_pointer != (CycleDataType *)NULL); + nassertv(_pointer != nullptr); _cycler->increment_write(_pointer); } @@ -140,7 +140,7 @@ CycleDataWriter(CycleDataWriter &&from) noexcept : _current_thread(from._current_thread), _pointer(from._pointer) { - from._pointer = NULL; + from._pointer = nullptr; } /** @@ -149,13 +149,13 @@ CycleDataWriter(CycleDataWriter &&from) noexcept : template INLINE void CycleDataWriter:: operator = (CycleDataWriter &&from) noexcept { - nassertv(_pointer == (CycleDataType *)NULL); + nassertv(_pointer == nullptr); nassertv(_current_thread == from._current_thread); _cycler = from._cycler; _pointer = from._pointer; - from._pointer = NULL; + from._pointer = nullptr; } /** @@ -164,7 +164,7 @@ operator = (CycleDataWriter &&from) noexcept { template INLINE CycleDataWriter:: ~CycleDataWriter() { - if (_pointer != (CycleDataType *)NULL) { + if (_pointer != nullptr) { _cycler->release_write(_pointer); } } @@ -175,7 +175,7 @@ INLINE CycleDataWriter:: template INLINE CycleDataType *CycleDataWriter:: operator -> () { - nassertr(_pointer != (CycleDataType *)NULL, _cycler->cheat()); + nassertr(_pointer != nullptr, _cycler->cheat()); return _pointer; } @@ -185,7 +185,7 @@ operator -> () { template INLINE const CycleDataType *CycleDataWriter:: operator -> () const { - nassertr(_pointer != (CycleDataType *)NULL, _cycler->cheat()); + nassertr(_pointer != nullptr, _cycler->cheat()); return _pointer; } @@ -196,7 +196,7 @@ operator -> () const { template INLINE CycleDataWriter:: operator CycleDataType * () { - nassertr(_pointer != (CycleDataType *)NULL, _cycler->cheat()); + nassertr(_pointer != nullptr, _cycler->cheat()); return _pointer; } diff --git a/panda/src/pipeline/genericThread.cxx b/panda/src/pipeline/genericThread.cxx index eb1941a5e3..b91819f61f 100644 --- a/panda/src/pipeline/genericThread.cxx +++ b/panda/src/pipeline/genericThread.cxx @@ -23,8 +23,8 @@ GenericThread:: GenericThread(const string &name, const string &sync_name) : Thread(name, sync_name) { - _function = NULL; - _user_data = NULL; + _function = nullptr; + _user_data = nullptr; } /** @@ -43,6 +43,6 @@ GenericThread(const string &name, const string &sync_name, GenericThread::Thread */ void GenericThread:: thread_main() { - nassertv(_function != NULL); + nassertv(_function != nullptr); (*_function)(_user_data); } diff --git a/panda/src/pipeline/lightMutexHolder.I b/panda/src/pipeline/lightMutexHolder.I index fb8a8951e4..6793c533ca 100644 --- a/panda/src/pipeline/lightMutexHolder.I +++ b/panda/src/pipeline/lightMutexHolder.I @@ -33,7 +33,7 @@ LightMutexHolder(const LightMutex &mutex) { INLINE LightMutexHolder:: LightMutexHolder(LightMutex *&mutex) { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) - if (mutex == (LightMutex *)NULL) { + if (mutex == nullptr) { mutex = new LightMutex; } _mutex = mutex; diff --git a/panda/src/pipeline/lightReMutexDirect.I b/panda/src/pipeline/lightReMutexDirect.I index 388387517c..bdfe87059b 100644 --- a/panda/src/pipeline/lightReMutexDirect.I +++ b/panda/src/pipeline/lightReMutexDirect.I @@ -21,7 +21,7 @@ LightReMutexDirect() #endif { #ifndef HAVE_REMUTEXIMPL - _locking_thread = NULL; + _locking_thread = nullptr; _lock_count = 0; #endif } diff --git a/panda/src/pipeline/lightReMutexHolder.I b/panda/src/pipeline/lightReMutexHolder.I index 4158d92c26..8c0f82d98a 100644 --- a/panda/src/pipeline/lightReMutexHolder.I +++ b/panda/src/pipeline/lightReMutexHolder.I @@ -45,7 +45,7 @@ LightReMutexHolder(const LightReMutex &mutex, Thread *current_thread) { INLINE LightReMutexHolder:: LightReMutexHolder(LightReMutex *&mutex) { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) - if (mutex == (LightReMutex *)NULL) { + if (mutex == nullptr) { mutex = new LightReMutex; } _mutex = mutex; diff --git a/panda/src/pipeline/mutexDebug.I b/panda/src/pipeline/mutexDebug.I index 9262f3e6d3..ae3ce74967 100644 --- a/panda/src/pipeline/mutexDebug.I +++ b/panda/src/pipeline/mutexDebug.I @@ -142,7 +142,7 @@ debug_is_locked() const { */ INLINE MutexTrueImpl *MutexDebug:: get_global_lock() { - if (_global_lock == (MutexTrueImpl *)NULL) { + if (_global_lock == nullptr) { _global_lock = new MutexTrueImpl; } return _global_lock; diff --git a/panda/src/pipeline/mutexDebug.cxx b/panda/src/pipeline/mutexDebug.cxx index ea75142fc6..a73e1257bc 100644 --- a/panda/src/pipeline/mutexDebug.cxx +++ b/panda/src/pipeline/mutexDebug.cxx @@ -28,9 +28,9 @@ MutexDebug(const string &name, bool allow_recursion, bool lightweight) : Namable(name), _allow_recursion(allow_recursion), _lightweight(lightweight), - _locking_thread(NULL), + _locking_thread(nullptr), _lock_count(0), - _deleted_name(NULL), + _deleted_name(nullptr), _cvar_impl(*get_global_lock()) { #ifndef SIMPLE_THREADS @@ -45,7 +45,7 @@ MutexDebug(const string &name, bool allow_recursion, bool lightweight) : */ MutexDebug:: ~MutexDebug() { - nassertv(_locking_thread == NULL && _lock_count == 0); + nassertv(_locking_thread == nullptr && _lock_count == 0); // If the config variable says to, allocate (and leak) a string name for the // mutex, so we can report which mutex it is that has destructed after the @@ -86,7 +86,7 @@ void MutexDebug:: output_with_holder(ostream &out) const { _global_lock->lock(); output(out); - if (_locking_thread != (Thread *)NULL) { + if (_locking_thread != nullptr) { out << " (held by " << *_locking_thread << ")\n"; } _global_lock->unlock(); @@ -125,7 +125,7 @@ do_lock(Thread *current_thread) { nassertd(_lock_count != -100) { pipeline_cat.error() << "Destructed mutex: " << (void *)this << "\n"; - if (name_deleted_mutexes && _deleted_name != NULL) { + if (name_deleted_mutexes && _deleted_name != nullptr) { pipeline_cat.error() << _deleted_name << "\n"; } else { @@ -135,7 +135,7 @@ do_lock(Thread *current_thread) { return; } - if (_locking_thread == (Thread *)NULL) { + if (_locking_thread == nullptr) { // The mutex is not already locked by anyone. Lock it. _locking_thread = current_thread; ++_lock_count; @@ -178,7 +178,7 @@ do_lock(Thread *current_thread) { // Check for deadlock. MutexDebug *next_mutex = this; - while (next_mutex != NULL) { + while (next_mutex != nullptr) { if (next_mutex->_locking_thread == current_thread) { // Whoops, the thread is blocked on me! Deadlock! report_deadlock(current_thread); @@ -186,7 +186,7 @@ do_lock(Thread *current_thread) { return; } Thread *next_thread = next_mutex->_locking_thread; - if (next_thread == NULL) { + if (next_thread == nullptr) { // Looks like this mutex isn't actually locked, which means the last // thread isn't really blocked--it just hasn't woken up yet to // discover that. In any case, no deadlock. @@ -209,7 +209,7 @@ do_lock(Thread *current_thread) { << *_locking_thread << ")\n"; } - while (_locking_thread != (Thread *)NULL) { + while (_locking_thread != nullptr) { thread_cat.debug() << *current_thread << " still blocking on " << *this << " (held by " << *_locking_thread << ")\n"; @@ -221,7 +221,7 @@ do_lock(Thread *current_thread) { << *current_thread << " acquired " << *this << "\n"; } - current_thread->_blocked_on_mutex = NULL; + current_thread->_blocked_on_mutex = nullptr; _locking_thread = current_thread; ++_lock_count; @@ -241,7 +241,7 @@ do_try_lock(Thread *current_thread) { nassertd(_lock_count != -100) { pipeline_cat.error() << "Destructed mutex: " << (void *)this << "\n"; - if (name_deleted_mutexes && _deleted_name != NULL) { + if (name_deleted_mutexes && _deleted_name != nullptr) { pipeline_cat.error() << _deleted_name << "\n"; } else { @@ -252,7 +252,7 @@ do_try_lock(Thread *current_thread) { } bool acquired = true; - if (_locking_thread == (Thread *)NULL) { + if (_locking_thread == nullptr) { // The mutex is not already locked by anyone. Lock it. _locking_thread = current_thread; ++_lock_count; @@ -307,7 +307,7 @@ do_unlock() { nassertd(_lock_count != -100) { pipeline_cat.error() << "Destructed mutex: " << (void *)this << "\n"; - if (name_deleted_mutexes && _deleted_name != NULL) { + if (name_deleted_mutexes && _deleted_name != nullptr) { pipeline_cat.error() << _deleted_name << "\n"; } else { @@ -350,7 +350,7 @@ do_unlock() { --_lock_count; if (_lock_count == 0) { // That was the last lock held by this thread. Release the lock. - _locking_thread = (Thread *)NULL; + _locking_thread = nullptr; if (_lightweight) { if (!_missed_threads.empty()) { @@ -415,7 +415,7 @@ report_deadlock(Thread *current_thread) { MutexDebug *next_mutex = this; Thread *next_thread = next_mutex->_locking_thread; next_mutex = next_thread->_blocked_on_mutex; - while (next_mutex != NULL) { + while (next_mutex != nullptr) { thread_cat.error() << *next_thread << " is blocked waiting on " << *next_mutex << " which is held by " diff --git a/panda/src/pipeline/mutexHolder.I b/panda/src/pipeline/mutexHolder.I index c2b6204e5a..f70220f338 100644 --- a/panda/src/pipeline/mutexHolder.I +++ b/panda/src/pipeline/mutexHolder.I @@ -47,7 +47,7 @@ MutexHolder(const Mutex &mutex, Thread *current_thread) { INLINE MutexHolder:: MutexHolder(Mutex *&mutex) { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) - if (mutex == (Mutex *)NULL) { + if (mutex == nullptr) { mutex = new Mutex; } _mutex = mutex; diff --git a/panda/src/pipeline/pipeline.I b/panda/src/pipeline/pipeline.I index 9d3512ae6c..163612e5f2 100644 --- a/panda/src/pipeline/pipeline.I +++ b/panda/src/pipeline/pipeline.I @@ -16,7 +16,7 @@ */ INLINE Pipeline *Pipeline:: get_render_pipeline() { - if (_render_pipeline == (Pipeline *)NULL) { + if (_render_pipeline == nullptr) { make_render_pipeline(); } return _render_pipeline; diff --git a/panda/src/pipeline/pipeline.cxx b/panda/src/pipeline/pipeline.cxx index 94e1ff3c2a..c12e72114b 100644 --- a/panda/src/pipeline/pipeline.cxx +++ b/panda/src/pipeline/pipeline.cxx @@ -16,7 +16,7 @@ #include "configVariableInt.h" #include "config_pipeline.h" -Pipeline *Pipeline::_render_pipeline = (Pipeline *)NULL; +Pipeline *Pipeline::_render_pipeline = nullptr; /** * @@ -500,7 +500,7 @@ make_render_pipeline() { "pipeline stages than your application requires will incur " "additional runtime overhead.")); - nassertv(_render_pipeline == (Pipeline *)NULL); + nassertv(_render_pipeline == nullptr); _render_pipeline = new Pipeline("render", pipeline_stages); } diff --git a/panda/src/pipeline/pipelineCyclerDummyImpl.I b/panda/src/pipeline/pipelineCyclerDummyImpl.I index 997bdc9a09..2d0a9a8f04 100644 --- a/panda/src/pipeline/pipelineCyclerDummyImpl.I +++ b/panda/src/pipeline/pipelineCyclerDummyImpl.I @@ -22,7 +22,7 @@ PipelineCyclerDummyImpl(CycleData *initial_data, Pipeline *pipeline) : _write_count(0), _locked(false) { - if (_pipeline == (Pipeline *)NULL) { + if (_pipeline == nullptr) { _pipeline = Pipeline::get_render_pipeline(); } } @@ -259,7 +259,7 @@ get_num_stages() { INLINE const CycleData *PipelineCyclerDummyImpl:: read_stage_unlocked(int pipeline_stage) const { TAU_PROFILE("const CycleData *PipelineCyclerDummyImpl::read_stage_unlocked(int)", " ", TAU_USER); - nassertr(pipeline_stage == 0, NULL); + nassertr(pipeline_stage == 0, nullptr); return _data; } @@ -276,7 +276,7 @@ read_stage(int pipeline_stage, Thread *) const { TAU_PROFILE("const CycleData *PipelineCyclerDummyImpl::read_stage(int, Thread *)", " ", TAU_USER); // This function isn't truly const, but it doesn't change the data in any // meaningful way, so we pretend it is. - nassertr(pipeline_stage == 0, NULL); + nassertr(pipeline_stage == 0, nullptr); ((PipelineCyclerDummyImpl *)this)->_read_count++; // It's not an error to grab a read pointer while someone else holds a read @@ -307,7 +307,7 @@ release_read_stage(int pipeline_stage, const CycleData *pointer) const { INLINE CycleData *PipelineCyclerDummyImpl:: write_stage(int pipeline_stage, Thread *) { TAU_PROFILE("CycleData *PipelineCyclerDummyImpl::write_stage(int)", " ", TAU_USER); - nassertr(pipeline_stage == 0, (CycleData *)NULL); + nassertr(pipeline_stage == 0, nullptr); _write_count++; return _data; } @@ -321,7 +321,7 @@ write_stage(int pipeline_stage, Thread *) { INLINE CycleData *PipelineCyclerDummyImpl:: write_stage_upstream(int pipeline_stage, bool, Thread *) { TAU_PROFILE("CycleData *PipelineCyclerDummyImpl::write_stage_upstream(int)", " ", TAU_USER); - nassertr(pipeline_stage == 0, (CycleData *)NULL); + nassertr(pipeline_stage == 0, nullptr); _write_count++; return _data; } @@ -334,7 +334,7 @@ write_stage_upstream(int pipeline_stage, bool, Thread *) { INLINE CycleData *PipelineCyclerDummyImpl:: elevate_read_stage(int pipeline_stage, const CycleData *pointer, Thread *current_thread) { TAU_PROFILE("CycleData *PipelineCyclerDummyImpl::elevate_read_stage(int, CycleData *)", " ", TAU_USER); - nassertr(pipeline_stage == 0, NULL); + nassertr(pipeline_stage == 0, nullptr); release_read(pointer); return write(current_thread); } @@ -348,7 +348,7 @@ INLINE CycleData *PipelineCyclerDummyImpl:: elevate_read_stage_upstream(int pipeline_stage, const CycleData *pointer, bool, Thread *current_thread) { TAU_PROFILE("CycleData *PipelineCyclerDummyImpl::elevate_read_stage(int, CycleData *)", " ", TAU_USER); - nassertr(pipeline_stage == 0, NULL); + nassertr(pipeline_stage == 0, nullptr); release_read(pointer); return write(current_thread); } diff --git a/panda/src/pipeline/pipelineCyclerDummyImpl.h b/panda/src/pipeline/pipelineCyclerDummyImpl.h index 00e0df9387..588bb09d0c 100644 --- a/panda/src/pipeline/pipelineCyclerDummyImpl.h +++ b/panda/src/pipeline/pipelineCyclerDummyImpl.h @@ -38,12 +38,12 @@ */ struct EXPCL_PANDA_PIPELINE PipelineCyclerDummyImpl { public: - INLINE PipelineCyclerDummyImpl(CycleData *initial_data, Pipeline *pipeline = NULL); + INLINE PipelineCyclerDummyImpl(CycleData *initial_data, Pipeline *pipeline = nullptr); INLINE PipelineCyclerDummyImpl(const PipelineCyclerDummyImpl ©); INLINE void operator = (const PipelineCyclerDummyImpl ©); INLINE ~PipelineCyclerDummyImpl(); - INLINE void acquire(Thread *current_thread = NULL); + INLINE void acquire(Thread *current_thread = nullptr); INLINE void release(); INLINE const CycleData *read_unlocked(Thread *current_thread) const; diff --git a/panda/src/pipeline/pipelineCyclerLinks.I b/panda/src/pipeline/pipelineCyclerLinks.I index 7b52a935a5..bc002e8cd6 100644 --- a/panda/src/pipeline/pipelineCyclerLinks.I +++ b/panda/src/pipeline/pipelineCyclerLinks.I @@ -18,8 +18,8 @@ INLINE PipelineCyclerLinks:: PipelineCyclerLinks() { #ifndef NDEBUG - _next = NULL; - _prev = NULL; + _next = nullptr; + _prev = nullptr; #endif } #endif // THREADED_PIPELINE @@ -30,7 +30,7 @@ PipelineCyclerLinks() { */ INLINE PipelineCyclerLinks:: ~PipelineCyclerLinks() { - nassertv(_next == NULL && _prev == NULL); + nassertv(_next == nullptr && _prev == nullptr); } #endif // THREADED_PIPELINE @@ -40,7 +40,7 @@ INLINE PipelineCyclerLinks:: */ INLINE void PipelineCyclerLinks:: make_head() { - nassertv(_next == NULL && _prev == NULL); + nassertv(_next == nullptr && _prev == nullptr); _next = this; _prev = this; } @@ -55,8 +55,8 @@ INLINE void PipelineCyclerLinks:: clear_head() { nassertv(_next == this && _prev == this); #ifndef NDEBUG - _next = NULL; - _prev = NULL; + _next = nullptr; + _prev = nullptr; #endif } #endif // THREADED_PIPELINE @@ -71,8 +71,8 @@ remove_from_list() { _prev->_next = _next; _next->_prev = _prev; #ifndef NDEBUG - _next = NULL; - _prev = NULL; + _next = nullptr; + _prev = nullptr; #endif } #endif // THREADED_PIPELINE @@ -85,8 +85,8 @@ remove_from_list() { INLINE void PipelineCyclerLinks:: insert_before(PipelineCyclerLinks *node) { nassertv(node->_prev->_next == node && node->_next->_prev == node); - nassertv(_prev == (PipelineCyclerLinks *)NULL && - _next == (PipelineCyclerLinks *)NULL); + nassertv(_prev == nullptr && + _next == nullptr); _prev = node->_prev; _next = node; _prev->_next = this; diff --git a/panda/src/pipeline/pipelineCyclerTrivialImpl.h b/panda/src/pipeline/pipelineCyclerTrivialImpl.h index 9bcc9f12c9..75b2b6fffb 100644 --- a/panda/src/pipeline/pipelineCyclerTrivialImpl.h +++ b/panda/src/pipeline/pipelineCyclerTrivialImpl.h @@ -40,13 +40,13 @@ class Pipeline; */ struct EXPCL_PANDA_PIPELINE PipelineCyclerTrivialImpl { public: - INLINE PipelineCyclerTrivialImpl(CycleData *initial_data, Pipeline *pipeline = NULL); + INLINE PipelineCyclerTrivialImpl(CycleData *initial_data, Pipeline *pipeline = nullptr); PipelineCyclerTrivialImpl(const PipelineCyclerTrivialImpl ©) = delete; ~PipelineCyclerTrivialImpl() = default; PipelineCyclerTrivialImpl &operator = (const PipelineCyclerTrivialImpl ©) = delete; - INLINE void acquire(Thread *current_thread = NULL); + INLINE void acquire(Thread *current_thread = nullptr); INLINE void release(); INLINE const CycleData *read_unlocked(Thread *current_thread) const; diff --git a/panda/src/pipeline/pipelineCyclerTrueImpl.I b/panda/src/pipeline/pipelineCyclerTrueImpl.I index fa6a97499b..4d6591b9b7 100644 --- a/panda/src/pipeline/pipelineCyclerTrueImpl.I +++ b/panda/src/pipeline/pipelineCyclerTrueImpl.I @@ -54,7 +54,7 @@ read_unlocked(Thread *current_thread) const { TAU_PROFILE("const CycleData *PipelineCyclerTrueImpl::read_unlocked(Thread *)", " ", TAU_USER); int pipeline_stage = current_thread->get_pipeline_stage(); #ifdef _DEBUG - nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL); + nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, nullptr); #endif return _data[pipeline_stage]._cdata; } @@ -72,7 +72,7 @@ read(Thread *current_thread) const { TAU_PROFILE("const CycleData *PipelineCyclerTrueImpl::read(Thread *)", " ", TAU_USER); int pipeline_stage = current_thread->get_pipeline_stage(); #ifdef _DEBUG - nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL); + nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, nullptr); #endif _lock.acquire(current_thread); return _data[pipeline_stage]._cdata; @@ -161,8 +161,8 @@ elevate_read(const CycleData *pointer, Thread *current_thread) { TAU_PROFILE("CycleData *PipelineCyclerTrueImpl::elevate_read(const CycleData *)", " ", TAU_USER); #ifdef _DEBUG int pipeline_stage = current_thread->get_pipeline_stage(); - nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL); - nassertr(_data[pipeline_stage]._cdata == pointer, NULL); + nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, nullptr); + nassertr(_data[pipeline_stage]._cdata == pointer, nullptr); #endif CycleData *new_pointer = write(current_thread); _lock.release(); @@ -179,8 +179,8 @@ elevate_read_upstream(const CycleData *pointer, bool force_to_0, Thread *current TAU_PROFILE("CycleData *PipelineCyclerTrueImpl::elevate_read_upstream(const CycleData *, bool)", " ", TAU_USER); #ifdef _DEBUG int pipeline_stage = current_thread->get_pipeline_stage(); - nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL); - nassertr(_data[pipeline_stage]._cdata == pointer, NULL); + nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, nullptr); + nassertr(_data[pipeline_stage]._cdata == pointer, nullptr); #endif CycleData *new_pointer = write_upstream(force_to_0, current_thread); _lock.release(); @@ -230,7 +230,7 @@ INLINE const CycleData *PipelineCyclerTrueImpl:: read_stage_unlocked(int pipeline_stage) const { TAU_PROFILE("const CycleData *PipelineCyclerTrueImpl::read_stage_unlocked(int)", " ", TAU_USER); #ifdef _DEBUG - nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL); + nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, nullptr); #elif defined(__has_builtin) && __has_builtin(__builtin_assume) __builtin_assume(pipeline_stage >= 0); #endif @@ -249,7 +249,7 @@ INLINE const CycleData *PipelineCyclerTrueImpl:: read_stage(int pipeline_stage, Thread *current_thread) const { TAU_PROFILE("const CycleData *PipelineCyclerTrueImpl::read_stage(int, Thread *)", " ", TAU_USER); #ifdef _DEBUG - nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL); + nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, nullptr); #elif defined(__has_builtin) && __has_builtin(__builtin_assume) __builtin_assume(pipeline_stage >= 0); #endif @@ -280,8 +280,8 @@ elevate_read_stage(int pipeline_stage, const CycleData *pointer, Thread *current_thread) { TAU_PROFILE("CycleData *PipelineCyclerTrueImpl::elevate_read_stage(int, const CycleData *)", " ", TAU_USER); #ifdef _DEBUG - nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL); - nassertr(_data[pipeline_stage]._cdata == pointer, NULL); + nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, nullptr); + nassertr(_data[pipeline_stage]._cdata == pointer, nullptr); #elif defined(__has_builtin) && __has_builtin(__builtin_assume) __builtin_assume(pipeline_stage >= 0); #endif @@ -300,8 +300,8 @@ elevate_read_stage_upstream(int pipeline_stage, const CycleData *pointer, bool force_to_0, Thread *current_thread) { TAU_PROFILE("CycleData *PipelineCyclerTrueImpl::elevate_read_stage(int, const CycleData *)", " ", TAU_USER); #ifdef _DEBUG - nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL); - nassertr(_data[pipeline_stage]._cdata == pointer, NULL); + nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, nullptr); + nassertr(_data[pipeline_stage]._cdata == pointer, nullptr); #elif defined(__has_builtin) && __has_builtin(__builtin_assume) __builtin_assume(pipeline_stage >= 0); #endif @@ -347,7 +347,7 @@ INLINE CycleData *PipelineCyclerTrueImpl:: cheat() const { TAU_PROFILE("CycleData *PipelineCyclerTrueImpl::cheat()", " ", TAU_USER); int pipeline_stage = Thread::get_current_pipeline_stage(); - nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL); + nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, nullptr); return _data[pipeline_stage]._cdata; } diff --git a/panda/src/pipeline/pipelineCyclerTrueImpl.cxx b/panda/src/pipeline/pipelineCyclerTrueImpl.cxx index f943a030f8..fb31088501 100644 --- a/panda/src/pipeline/pipelineCyclerTrueImpl.cxx +++ b/panda/src/pipeline/pipelineCyclerTrueImpl.cxx @@ -27,7 +27,7 @@ PipelineCyclerTrueImpl(CycleData *initial_data, Pipeline *pipeline) : _dirty(0), _lock(this) { - if (_pipeline == (Pipeline *)NULL) { + if (_pipeline == nullptr) { _pipeline = Pipeline::get_render_pipeline(); } @@ -64,7 +64,7 @@ PipelineCyclerTrueImpl(const PipelineCyclerTrueImpl ©) : for (int i = 0; i < _num_stages; ++i) { PT(CycleData) &new_pt = pointers[copy._data[i]._cdata]; - if (new_pt == NULL) { + if (new_pt == nullptr) { new_pt = copy._data[i]._cdata->make_copy(); } _data[i]._cdata = new_pt.p(); @@ -90,7 +90,7 @@ operator = (const PipelineCyclerTrueImpl ©) { for (int i = 0; i < _num_stages; ++i) { PT(CycleData) &new_pt = pointers[copy._data[i]._cdata]; - if (new_pt == NULL) { + if (new_pt == nullptr) { new_pt = copy._data[i]._cdata->make_copy(); } _data[i]._cdata = new_pt.p(); @@ -111,7 +111,7 @@ PipelineCyclerTrueImpl:: _pipeline->remove_cycler(this); delete[] _data; - _data = NULL; + _data = nullptr; _num_stages = 0; } @@ -128,7 +128,7 @@ write_stage(int pipeline_stage, Thread *current_thread) { #ifndef NDEBUG nassertd(pipeline_stage >= 0 && pipeline_stage < _num_stages) { _lock.release(); - return NULL; + return nullptr; } #endif // NDEBUG @@ -176,7 +176,7 @@ write_stage_upstream(int pipeline_stage, bool force_to_0, Thread *current_thread #ifndef NDEBUG nassertd(pipeline_stage >= 0 && pipeline_stage < _num_stages) { _lock.release(); - return NULL; + return nullptr; } #endif // NDEBUG @@ -209,7 +209,7 @@ write_stage_upstream(int pipeline_stage, bool force_to_0, Thread *current_thread k = pipeline_stage - 1; while (k >= 0 && (_data[k]._cdata == old_data || force_to_0)) { - nassertr(_data[k]._writes_outstanding == 0, NULL); + nassertr(_data[k]._writes_outstanding == 0, nullptr); _data[k]._cdata = new_data.p(); --k; } @@ -228,7 +228,7 @@ write_stage_upstream(int pipeline_stage, bool force_to_0, Thread *current_thread // There are no external pointers, so no need to copy-on-write, but the // current pointer doesn't go all the way back. Make it do so. while (k >= 0) { - nassertr(_data[k]._writes_outstanding == 0, NULL); + nassertr(_data[k]._writes_outstanding == 0, nullptr); _data[k]._cdata = old_data; --k; } diff --git a/panda/src/pipeline/pipelineCyclerTrueImpl.h b/panda/src/pipeline/pipelineCyclerTrueImpl.h index 59896c8b18..809fda99f4 100644 --- a/panda/src/pipeline/pipelineCyclerTrueImpl.h +++ b/panda/src/pipeline/pipelineCyclerTrueImpl.h @@ -44,7 +44,7 @@ struct EXPCL_PANDA_PIPELINE PipelineCyclerTrueImpl : public PipelineCyclerLinks private: PipelineCyclerTrueImpl(); public: - PipelineCyclerTrueImpl(CycleData *initial_data, Pipeline *pipeline = NULL); + PipelineCyclerTrueImpl(CycleData *initial_data, Pipeline *pipeline = nullptr); PipelineCyclerTrueImpl(const PipelineCyclerTrueImpl ©); void operator = (const PipelineCyclerTrueImpl ©); ~PipelineCyclerTrueImpl(); diff --git a/panda/src/pipeline/pythonThread.cxx b/panda/src/pipeline/pythonThread.cxx index 28bef610b5..ae64aba2a4 100644 --- a/panda/src/pipeline/pythonThread.cxx +++ b/panda/src/pipeline/pythonThread.cxx @@ -29,8 +29,8 @@ PythonThread(PyObject *function, PyObject *args, { _function = function; Py_INCREF(_function); - _args = NULL; - _result = NULL; + _args = nullptr; + _result = nullptr; if (!PyCallable_Check(_function)) { nassert_raise("Invalid function passed to PythonThread constructor"); @@ -78,7 +78,7 @@ PyObject *PythonThread:: join() { Thread::join(); - if (_result == NULL) { + if (_result == nullptr) { // No result; return None. Py_INCREF(Py_None); return Py_None; @@ -107,11 +107,11 @@ set_args(PyObject *args) { // None means no arguments; create an empty tuple. _args = PyTuple_New(0); } else { - _args = NULL; + _args = nullptr; if (PySequence_Check(args)) { _args = PySequence_Tuple(args); } - if (_args == NULL) { + if (_args == nullptr) { Dtool_Raise_TypeError("PythonThread args must be a tuple"); } } @@ -130,13 +130,13 @@ call_python_func(PyObject *function, PyObject *args) { // Create a new Python thread state data structure, so Python can properly // lock itself. - PyObject *result = NULL; + PyObject *result = nullptr; if (current_thread == get_main_thread()) { // In the main thread, just call the function. - result = PyObject_Call(function, args, NULL); + result = PyObject_Call(function, args, nullptr); - if (result == (PyObject *)NULL) { + if (result == nullptr) { if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_SystemExit)) { // If we caught SystemExit, let it pass by without bothering to print // a callback. @@ -161,7 +161,7 @@ call_python_func(PyObject *function, PyObject *args) { #ifndef HAVE_THREADS // Shouldn't be possible to come here without having some kind of // threading support enabled. - nassertr(false, NULL); + nassertr(false, nullptr); #else #ifdef SIMPLE_THREADS @@ -193,8 +193,8 @@ call_python_func(PyObject *function, PyObject *args) { PyThreadState_Swap(new_thread_state); // Call the user's function. - result = PyObject_Call(function, args, NULL); - if (result == (PyObject *)NULL && PyErr_Occurred()) { + result = PyObject_Call(function, args, nullptr); + if (result == nullptr && PyErr_Occurred()) { // We got an exception. Move the exception from the current thread into // the main thread, so it can be handled there. PyObject *exc, *val, *tb; @@ -237,8 +237,8 @@ call_python_func(PyObject *function, PyObject *args) { gstate = PyGILState_Ensure(); // Call the user's function. - result = PyObject_Call(function, args, NULL); - if (result == (PyObject *)NULL && PyErr_Occurred()) { + result = PyObject_Call(function, args, nullptr); + if (result == nullptr && PyErr_Occurred()) { // We got an exception. Move the exception from the current thread into // the main thread, so it can be handled there. PyObject *exc, *val, *tb; diff --git a/panda/src/pipeline/reMutexDirect.I b/panda/src/pipeline/reMutexDirect.I index cdcc7fd45e..51b380ac57 100644 --- a/panda/src/pipeline/reMutexDirect.I +++ b/panda/src/pipeline/reMutexDirect.I @@ -21,7 +21,7 @@ ReMutexDirect() #endif { #ifndef HAVE_REMUTEXTRUEIMPL - _locking_thread = NULL; + _locking_thread = nullptr; _lock_count = 0; #endif } diff --git a/panda/src/pipeline/reMutexDirect.cxx b/panda/src/pipeline/reMutexDirect.cxx index b82ed0f364..b83a2f30a6 100644 --- a/panda/src/pipeline/reMutexDirect.cxx +++ b/panda/src/pipeline/reMutexDirect.cxx @@ -36,7 +36,7 @@ void ReMutexDirect:: do_lock(Thread *current_thread) { _lock_impl.lock(); - if (_locking_thread == (Thread *)NULL) { + if (_locking_thread == nullptr) { // The mutex is not already locked by anyone. Lock it. _locking_thread = current_thread; ++_lock_count; @@ -52,7 +52,7 @@ do_lock(Thread *current_thread) { } else { // The mutex is locked by some other thread. Go to sleep on the condition // variable until it's unlocked. - while (_locking_thread != (Thread *)NULL) { + while (_locking_thread != nullptr) { _cvar_impl.wait(); } @@ -77,7 +77,7 @@ do_try_lock(Thread *current_thread) { bool acquired = true; _lock_impl.lock(); - if (_locking_thread == (Thread *)NULL) { + if (_locking_thread == nullptr) { // The mutex is not already locked by anyone. Lock it. _locking_thread = current_thread; ++_lock_count; @@ -117,7 +117,7 @@ do_elevate_lock() { return; } #elif !defined(NDEBUG) - nassertd(_locking_thread != (Thread *)NULL) { + nassertd(_locking_thread != nullptr) { _lock_impl.unlock(); return; } @@ -161,7 +161,7 @@ do_unlock() { --_lock_count; if (_lock_count == 0) { // That was the last lock held by this thread. Release the lock. - _locking_thread = (Thread *)NULL; + _locking_thread = nullptr; _cvar_impl.notify(); } _lock_impl.unlock(); diff --git a/panda/src/pipeline/reMutexHolder.I b/panda/src/pipeline/reMutexHolder.I index 00cd980e01..1c05196c7e 100644 --- a/panda/src/pipeline/reMutexHolder.I +++ b/panda/src/pipeline/reMutexHolder.I @@ -44,7 +44,7 @@ ReMutexHolder(const ReMutex &mutex, Thread *current_thread) { INLINE ReMutexHolder:: ReMutexHolder(ReMutex *&mutex) { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) - if (mutex == (ReMutex *)NULL) { + if (mutex == nullptr) { mutex = new ReMutex; } _mutex = mutex; diff --git a/panda/src/pipeline/test_threaddata.cxx b/panda/src/pipeline/test_threaddata.cxx index 2a397ac5c5..2e347823c9 100644 --- a/panda/src/pipeline/test_threaddata.cxx +++ b/panda/src/pipeline/test_threaddata.cxx @@ -17,7 +17,7 @@ #include "mutexHolder.h" #include "pointerTo.h" -Mutex *cout_mutex = (Mutex *)NULL; +Mutex *cout_mutex = nullptr; // Test forking a thread with some private data. class ThreadWithData : public Thread { diff --git a/panda/src/pipeline/thread.I b/panda/src/pipeline/thread.I index d108f025dd..d8c8503742 100644 --- a/panda/src/pipeline/thread.I +++ b/panda/src/pipeline/thread.I @@ -84,7 +84,7 @@ set_min_pipeline_stage(int min_pipeline_stage) { */ INLINE Thread *Thread:: get_main_thread() { - if (_main_thread == (Thread *)NULL) { + if (_main_thread == nullptr) { init_main_thread(); } return _main_thread; @@ -98,7 +98,7 @@ get_main_thread() { */ INLINE Thread *Thread:: get_external_thread() { - if (_external_thread == (Thread *)NULL) { + if (_external_thread == nullptr) { init_external_thread(); } return _external_thread; @@ -121,7 +121,7 @@ get_current_thread() { return get_main_thread(); #else // HAVE_THREADS Thread *thread = ThreadImpl::get_current_thread(); - if (thread == (Thread *)NULL) { + if (thread == nullptr) { return Thread::get_external_thread(); } return thread; diff --git a/panda/src/pipeline/thread.cxx b/panda/src/pipeline/thread.cxx index 6a0f0278fc..3dc5994282 100644 --- a/panda/src/pipeline/thread.cxx +++ b/panda/src/pipeline/thread.cxx @@ -44,15 +44,15 @@ Thread(const string &name, const string &sync_name) : _started = false; _pstats_index = -1; _python_index = -1; - _pstats_callback = NULL; + _pstats_callback = nullptr; _pipeline_stage = 0; _joinable = false; - _current_task = NULL; + _current_task = nullptr; #ifdef DEBUG_THREADS - _blocked_on_mutex = NULL; - _waiting_on_cvar = NULL; - _waiting_on_cvar_full = NULL; + _blocked_on_mutex = nullptr; + _waiting_on_cvar = nullptr; + _waiting_on_cvar_full = nullptr; #endif } @@ -62,9 +62,9 @@ Thread(const string &name, const string &sync_name) : Thread:: ~Thread() { #ifdef DEBUG_THREADS - nassertv(_blocked_on_mutex == NULL && - _waiting_on_cvar == NULL && - _waiting_on_cvar_full == NULL); + nassertv(_blocked_on_mutex == nullptr && + _waiting_on_cvar == nullptr && + _waiting_on_cvar_full == nullptr); #endif } @@ -141,11 +141,11 @@ output(ostream &out) const { void Thread:: output_blocker(ostream &out) const { #ifdef DEBUG_THREADS - if (_blocked_on_mutex != (MutexDebug *)NULL) { + if (_blocked_on_mutex != nullptr) { _blocked_on_mutex->output_with_holder(out); - } else if (_waiting_on_cvar != (ConditionVarDebug *)NULL) { + } else if (_waiting_on_cvar != nullptr) { out << *_waiting_on_cvar; - } else if (_waiting_on_cvar_full != (ConditionVarFullDebug *)NULL) { + } else if (_waiting_on_cvar_full != nullptr) { out << *_waiting_on_cvar_full; } #endif // DEBUG_THREADS @@ -210,7 +210,7 @@ init_main_thread() { // here attempts to protect against that. static int count = 0; ++count; - if (count == 1 && _main_thread == (Thread *)NULL) { + if (count == 1 && _main_thread == nullptr) { _main_thread = new MainThread; _main_thread->ref(); } @@ -221,7 +221,7 @@ init_main_thread() { */ void Thread:: init_external_thread() { - if (_external_thread == (Thread *)NULL) { + if (_external_thread == nullptr) { _external_thread = new ExternalThread; _external_thread->ref(); } diff --git a/panda/src/pipeline/threadDummyImpl.I b/panda/src/pipeline/threadDummyImpl.I index 930f53fe4b..0bd2f7747a 100644 --- a/panda/src/pipeline/threadDummyImpl.I +++ b/panda/src/pipeline/threadDummyImpl.I @@ -107,7 +107,7 @@ sleep(double seconds) { struct timespec rqtp; rqtp.tv_sec = time_t(seconds); rqtp.tv_nsec = long((seconds - (double)rqtp.tv_sec) * 1000000000.0); - nanosleep(&rqtp, NULL); + nanosleep(&rqtp, nullptr); #endif // WIN32 } diff --git a/panda/src/pipeline/threadPosixImpl.I b/panda/src/pipeline/threadPosixImpl.I index 62b6026061..22a8c90118 100644 --- a/panda/src/pipeline/threadPosixImpl.I +++ b/panda/src/pipeline/threadPosixImpl.I @@ -101,7 +101,7 @@ sleep(double seconds) { struct timespec rqtp; rqtp.tv_sec = time_t(seconds); rqtp.tv_nsec = long((seconds - (double)rqtp.tv_sec) * 1000000000.0); - nanosleep(&rqtp, NULL); + nanosleep(&rqtp, nullptr); } /** diff --git a/panda/src/pipeline/threadPosixImpl.cxx b/panda/src/pipeline/threadPosixImpl.cxx index 9983ad24ea..dcae44e721 100644 --- a/panda/src/pipeline/threadPosixImpl.cxx +++ b/panda/src/pipeline/threadPosixImpl.cxx @@ -243,13 +243,13 @@ root_func(void *data) { ThreadPosixImpl *self = (ThreadPosixImpl *)data; int result = pthread_setspecific(_pt_ptr_index, self->_parent_obj); - nassertr(result == 0, NULL); + nassertr(result == 0, nullptr); { self->_mutex.lock(); nassertd(self->_status == S_start_called) { self->_mutex.unlock(); - return NULL; + return nullptr; } self->_status = S_running; @@ -273,7 +273,7 @@ root_func(void *data) { self->_mutex.lock(); nassertd(self->_status == S_running) { self->_mutex.unlock(); - return NULL; + return nullptr; } self->_status = S_finished; self->_mutex.unlock(); @@ -293,7 +293,7 @@ root_func(void *data) { unref_delete(self->_parent_obj); } - return NULL; + return nullptr; } /** @@ -304,7 +304,7 @@ void ThreadPosixImpl:: init_pt_ptr_index() { nassertv(!_got_pt_ptr_index); - int result = pthread_key_create(&_pt_ptr_index, NULL); + int result = pthread_key_create(&_pt_ptr_index, nullptr); if (result != 0) { thread_cat->error() << "Unable to associate Thread pointers with threads.\n"; diff --git a/panda/src/pipeline/threadSimpleImpl.cxx b/panda/src/pipeline/threadSimpleImpl.cxx index b4c90cd54e..1bde4c7ca0 100644 --- a/panda/src/pipeline/threadSimpleImpl.cxx +++ b/panda/src/pipeline/threadSimpleImpl.cxx @@ -43,7 +43,7 @@ ThreadSimpleImpl(Thread *parent_obj) : _wake_time = 0.0; _context = alloc_thread_context(); - _stack = NULL; + _stack = nullptr; _stack_size = 0; // Save this pointer for convenience. @@ -70,7 +70,7 @@ ThreadSimpleImpl:: free_thread_context(_context); - if (_stack != (void *)NULL) { + if (_stack != nullptr) { memory_hook->mmap_free(_stack, _stack_size); } _manager->remove_thread(this); @@ -107,7 +107,7 @@ start(ThreadPriority priority, bool joinable) { nassertr(_status == TS_new, false); - nassertr(_stack == NULL, false); + nassertr(_stack == nullptr, false); _stack_size = memory_hook->round_up_to_page_size((size_t)thread_stack_size); if (needs_stack_prealloc) { _stack = (unsigned char *)memory_hook->mmap_alloc(_stack_size, true); @@ -141,7 +141,7 @@ start(ThreadPriority priority, bool joinable) { #ifdef HAVE_PYTHON // Query the current Python thread state. - _python_state = PyThreadState_Swap(NULL); + _python_state = PyThreadState_Swap(nullptr); PyThreadState_Swap(_python_state); #endif // HAVE_PYTHON diff --git a/panda/src/pipeline/threadSimpleManager.cxx b/panda/src/pipeline/threadSimpleManager.cxx index 4c7640b885..8b58579642 100644 --- a/panda/src/pipeline/threadSimpleManager.cxx +++ b/panda/src/pipeline/threadSimpleManager.cxx @@ -71,9 +71,9 @@ ThreadSimpleManager() : { _tick_scale = 1000000.0; _total_ticks = 0; - _current_thread = NULL; + _current_thread = nullptr; _clock = TrueClock::get_global_ptr(); - _waiting_for_exit = NULL; + _waiting_for_exit = nullptr; // Install these global pointers so very low-level code (code defined before // the pipeline directory) can yield when necessary. @@ -235,12 +235,12 @@ next_context() { #ifdef HAVE_PYTHON // Save the current Python thread state. - _current_thread->_python_state = PyThreadState_Swap(NULL); + _current_thread->_python_state = PyThreadState_Swap(nullptr); #endif // HAVE_PYTHON #ifdef DO_PSTATS Thread::PStatsCallback *pstats_callback = _current_thread->_parent_obj->get_pstats_callback(); - if (pstats_callback != NULL) { + if (pstats_callback != nullptr) { pstats_callback->deactivate_hook(_current_thread->_parent_obj); } #endif // DO_PSTATS @@ -250,7 +250,7 @@ next_context() { // current thread. #ifdef DO_PSTATS - if (pstats_callback != NULL) { + if (pstats_callback != nullptr) { pstats_callback->activate_hook(_current_thread->_parent_obj); } #endif // DO_PSTATS @@ -281,7 +281,7 @@ prepare_for_exit() { << "prepare_for_exit\n"; } - nassertv(_waiting_for_exit == NULL); + nassertv(_waiting_for_exit == nullptr); _waiting_for_exit = _current_thread; // At this point, any non-joinable threads on any of the queues are @@ -321,7 +321,7 @@ prepare_for_exit() { */ void ThreadSimpleManager:: set_current_thread(ThreadSimpleImpl *current_thread) { - nassertv(_current_thread == (ThreadSimpleImpl *)NULL); + nassertv(_current_thread == nullptr); _current_thread = current_thread; } @@ -369,7 +369,7 @@ system_sleep(double seconds) { struct timeval tv; tv.tv_sec = time_t(seconds); tv.tv_usec = long((seconds - (double)tv.tv_sec) * 1000000.0 + 0.5); - select(0, NULL, NULL, NULL, &tv); + select(0, nullptr, nullptr, nullptr, &tv); #endif // WIN32 } @@ -498,7 +498,7 @@ choose_next_context(struct ThreadContext *from_context) { double now = get_current_time(); do_timeslice_accounting(_current_thread, now); - _current_thread = NULL; + _current_thread = nullptr; if (!_sleeping.empty() || !_volunteers.empty()) { if (_ready.empty() && _next_ready.empty()) { @@ -578,12 +578,12 @@ choose_next_context(struct ThreadContext *from_context) { } else { // No threads are ready! - if (_waiting_for_exit != NULL) { + if (_waiting_for_exit != nullptr) { // This is a shutdown situation. In this case, we quietly abandoned // the remaining blocked threads, if any, and switch back to the // main thread to finish shutting down. _ready.push_back(_waiting_for_exit); - _waiting_for_exit = NULL; + _waiting_for_exit = nullptr; break; } diff --git a/panda/src/pipeline/threadWin32Impl.cxx b/panda/src/pipeline/threadWin32Impl.cxx index 8508f23ac6..998dc44b8c 100644 --- a/panda/src/pipeline/threadWin32Impl.cxx +++ b/panda/src/pipeline/threadWin32Impl.cxx @@ -70,7 +70,7 @@ start(ThreadPriority priority, bool joinable) { // eventually decrement it when it terminates. _parent_obj->ref(); _thread = - CreateThread(NULL, 0, &root_func, (void *)this, 0, &_thread_id); + CreateThread(nullptr, 0, &root_func, (void *)this, 0, &_thread_id); if (_thread_id == 0) { // Oops, we couldn't start the thread. Be sure to decrement the reference diff --git a/panda/src/pnmimage/pfmFile.cxx b/panda/src/pnmimage/pfmFile.cxx index d0424fcafe..97a151f324 100644 --- a/panda/src/pnmimage/pfmFile.cxx +++ b/panda/src/pnmimage/pfmFile.cxx @@ -118,7 +118,7 @@ read(const Filename &fullpath) { Filename filename = Filename::binary_filename(fullpath); PT(VirtualFile) file = vfs->get_file(filename); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { // No such file. pnmimage_cat.error() << "Could not find " << fullpath << "\n"; @@ -147,7 +147,7 @@ read(const Filename &fullpath) { bool PfmFile:: read(istream &in, const Filename &fullpath) { PNMReader *reader = make_reader(&in, false, fullpath); - if (reader == (PNMReader *)NULL) { + if (reader == nullptr) { clear(); return false; } @@ -163,7 +163,7 @@ bool PfmFile:: read(PNMReader *reader) { clear(); - if (reader == NULL) { + if (reader == nullptr) { return false; } @@ -230,7 +230,7 @@ write(ostream &out, const Filename &fullpath) { } PNMWriter *writer = make_writer(&out, false, fullpath); - if (writer == (PNMWriter *)NULL) { + if (writer == nullptr) { return false; } @@ -244,7 +244,7 @@ write(ostream &out, const Filename &fullpath) { */ bool PfmFile:: write(PNMWriter *writer) { - if (writer == NULL) { + if (writer == nullptr) { return false; } @@ -1816,7 +1816,7 @@ compute_planar_bounds(const LPoint2f ¢er, PN_float32 point_dist, PN_float32 break; default: - nassertr(false, NULL); + nassertr(false, nullptr); } // Rotate the bounding volume back into the original space of the screen. diff --git a/panda/src/pnmimage/pfmFile_ext.cxx b/panda/src/pnmimage/pfmFile_ext.cxx index 4e041e986f..fb31f7ead5 100644 --- a/panda/src/pnmimage/pfmFile_ext.cxx +++ b/panda/src/pnmimage/pfmFile_ext.cxx @@ -93,7 +93,7 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { int channels = _this->get_num_channels(); int num_pixels = _this->get_x_size() * _this->get_y_size(); - if (self != NULL) { + if (self != nullptr) { Py_INCREF(self); } view->obj = self; @@ -101,20 +101,20 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { view->len = 4 * table.size(); view->readonly = 1; view->itemsize = 4; - view->format = NULL; + view->format = nullptr; if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) { view->format = (char *) "f"; } view->ndim = 2; - view->shape = NULL; + view->shape = nullptr; if ((flags & PyBUF_ND) == PyBUF_ND) { // If you're leaking and you know it, clap your hands! view->shape = new Py_ssize_t[2]; view->shape[0] = num_pixels; view->shape[1] = channels; } - view->strides = NULL; - view->suboffsets = NULL; + view->strides = nullptr; + view->suboffsets = nullptr; return 0; #else diff --git a/panda/src/pnmimage/pnmFileType.cxx b/panda/src/pnmimage/pnmFileType.cxx index 762d86fee4..80fae2784a 100644 --- a/panda/src/pnmimage/pnmFileType.cxx +++ b/panda/src/pnmimage/pnmFileType.cxx @@ -92,7 +92,7 @@ matches_magic_number(const string &) const { */ PNMReader *PNMFileType:: make_reader(istream *, bool, const string &) { - return NULL; + return nullptr; } /** @@ -102,7 +102,7 @@ make_reader(istream *, bool, const string &) { */ PNMWriter *PNMFileType:: make_writer(ostream *, bool) { - return NULL; + return nullptr; } /** diff --git a/panda/src/pnmimage/pnmFileTypeRegistry.cxx b/panda/src/pnmimage/pnmFileTypeRegistry.cxx index 96e24ef1bb..c1dd16f211 100644 --- a/panda/src/pnmimage/pnmFileTypeRegistry.cxx +++ b/panda/src/pnmimage/pnmFileTypeRegistry.cxx @@ -132,7 +132,7 @@ get_num_types() const { */ PNMFileType *PNMFileTypeRegistry:: get_type(int n) const { - nassertr(n >= 0 && n < (int)_types.size(), NULL); + nassertr(n >= 0 && n < (int)_types.size(), nullptr); return _types[n]; } @@ -190,7 +190,7 @@ get_type_from_extension(const string &filename) const { if (ei == _extensions.end() || (*ei).second.empty()) { // Nothing matches that string. - return NULL; + return nullptr; } } @@ -219,7 +219,7 @@ get_type_from_magic_number(const string &magic_number) const { } } - return NULL; + return nullptr; } /** @@ -235,7 +235,7 @@ get_type_by_handle(TypeHandle handle) const { return (*hi).second; } - return (PNMFileType *)NULL; + return nullptr; } /** @@ -273,7 +273,7 @@ write(ostream &out, int indent_level) const { */ PNMFileTypeRegistry *PNMFileTypeRegistry:: get_global_ptr() { - if (_global_ptr == (PNMFileTypeRegistry *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new PNMFileTypeRegistry; } return _global_ptr; diff --git a/panda/src/pnmimage/pnmImage.I b/panda/src/pnmimage/pnmImage.I index d4a7026483..21c6619ea8 100644 --- a/panda/src/pnmimage/pnmImage.I +++ b/panda/src/pnmimage/pnmImage.I @@ -16,8 +16,8 @@ */ INLINE PNMImage:: PNMImage() { - _array = NULL; - _alpha = NULL; + _array = nullptr; + _alpha = nullptr; clear(); } @@ -28,8 +28,8 @@ PNMImage() { INLINE PNMImage:: PNMImage(int x_size, int y_size, int num_channels, xelval maxval, PNMFileType *type, ColorSpace color_space) { - _array = NULL; - _alpha = NULL; + _array = nullptr; + _alpha = nullptr; clear(x_size, y_size, num_channels, maxval, type, color_space); } @@ -41,8 +41,8 @@ INLINE PNMImage:: PNMImage(const PNMImage ©) { // We don't need to invoke PNMImageHeader's copy constructor, because we'll // just call copy_from(). - _array = NULL; - _alpha = NULL; + _array = nullptr; + _alpha = nullptr; copy_from(copy); } @@ -251,7 +251,7 @@ get_color_space() const { */ INLINE bool PNMImage:: is_valid() const { - return (_array != NULL); + return (_array != nullptr); } /** @@ -403,7 +403,7 @@ get_gray_val(int x, int y) const { */ INLINE xelval PNMImage:: get_alpha_val(int x, int y) const { - nassertr(_alpha != NULL && x >= 0 && x < _x_size && y >= 0 && y < _y_size, 0); + nassertr(_alpha != nullptr && x >= 0 && x < _x_size && y >= 0 && y < _y_size, 0); return alpha_row(y)[x]; } @@ -468,7 +468,7 @@ set_gray_val(int x, int y, xelval gray) { */ INLINE void PNMImage:: set_alpha_val(int x, int y, xelval a) { - nassertv(_alpha != NULL && x >= 0 && x < _x_size && y >= 0 && y < _y_size); + nassertv(_alpha != nullptr && x >= 0 && x < _x_size && y >= 0 && y < _y_size); alpha_row(y)[x] = a; } @@ -1120,7 +1120,7 @@ get_alpha_array() const { INLINE xel *PNMImage:: take_array() { xel *array = _array; - _array = NULL; + _array = nullptr; return array; } @@ -1133,7 +1133,7 @@ take_array() { INLINE xelval *PNMImage:: take_alpha_array() { xelval *alpha = _alpha; - _alpha = NULL; + _alpha = nullptr; return alpha; } @@ -1159,7 +1159,7 @@ allocate_alpha() { */ INLINE xel *PNMImage:: row(int y) const { - nassertr(y >= 0 && y < _y_size, NULL); + nassertr(y >= 0 && y < _y_size, nullptr); return _array + y * _x_size; } @@ -1169,7 +1169,7 @@ row(int y) const { */ INLINE xelval *PNMImage:: alpha_row(int y) const { - nassertr(_alpha != NULL && y >= 0 && y < _y_size, NULL); + nassertr(_alpha != nullptr && y >= 0 && y < _y_size, nullptr); return _alpha + y * _x_size; } diff --git a/panda/src/pnmimage/pnmImage.cxx b/panda/src/pnmimage/pnmImage.cxx index 6f9daaf000..ce9871d6f0 100644 --- a/panda/src/pnmimage/pnmImage.cxx +++ b/panda/src/pnmimage/pnmImage.cxx @@ -26,8 +26,8 @@ */ PNMImage:: PNMImage(const Filename &filename, PNMFileType *type) { - _array = NULL; - _alpha = NULL; + _array = nullptr; + _alpha = nullptr; _has_read_size = false; bool result = read(filename, type); @@ -43,13 +43,13 @@ PNMImage(const Filename &filename, PNMFileType *type) { */ void PNMImage:: clear() { - if (_array != (xel *)NULL) { + if (_array != nullptr) { PANDA_FREE_ARRAY(_array); - _array = (xel *)NULL; + _array = nullptr; } - if (_alpha != (xelval *)NULL) { + if (_alpha != nullptr) { PANDA_FREE_ARRAY(_alpha); - _alpha = (xelval *)NULL; + _alpha = nullptr; } _x_size = 0; _y_size = 0; @@ -58,7 +58,7 @@ clear() { _inv_maxval = 1.0 / 255.0; _color_space = CS_linear; _comment.clear(); - _type = (PNMFileType *)NULL; + _type = nullptr; _has_read_size = false; _xel_encoding = XE_generic; } @@ -226,10 +226,10 @@ take_from(PNMImage &orig) { if (has_alpha()) { _alpha = orig._alpha; - orig._alpha = NULL; + orig._alpha = nullptr; } _array = orig._array; - orig._array = NULL; + orig._array = nullptr; orig.clear(); } @@ -274,7 +274,7 @@ alpha_fill_val(xelval alpha) { bool PNMImage:: read(const Filename &filename, PNMFileType *type, bool report_unknown_type) { PNMReader *reader = make_reader(filename, type, report_unknown_type); - if (reader == (PNMReader *)NULL) { + if (reader == nullptr) { clear(); return false; } @@ -299,7 +299,7 @@ read(istream &data, const string &filename, PNMFileType *type, bool report_unknown_type) { PNMReader *reader = PNMImageHeader::make_reader (&data, false, filename, string(), type, report_unknown_type); - if (reader == (PNMReader *)NULL) { + if (reader == nullptr) { clear(); return false; } @@ -322,7 +322,7 @@ read(PNMReader *reader) { clear(); - if (reader == NULL) { + if (reader == nullptr) { return false; } @@ -385,7 +385,7 @@ write(const Filename &filename, PNMFileType *type) const { } PNMWriter *writer = PNMImageHeader::make_writer(filename, type); - if (writer == (PNMWriter *)NULL) { + if (writer == nullptr) { return false; } @@ -409,7 +409,7 @@ write(ostream &data, const string &filename, PNMFileType *type) const { PNMWriter *writer = PNMImageHeader::make_writer (&data, false, filename, type); - if (writer == (PNMWriter *)NULL) { + if (writer == nullptr) { return false; } @@ -425,7 +425,7 @@ write(ostream &data, const string &filename, PNMFileType *type) const { */ bool PNMImage:: write(PNMWriter *writer) const { - if (writer == NULL) { + if (writer == nullptr) { return false; } @@ -497,9 +497,9 @@ set_color_type(PNMImage::ColorType color_type) { if (has_alpha() && !has_alpha(color_type)) { // Discard the alpha channel - if (_alpha != NULL) { + if (_alpha != nullptr) { PANDA_FREE_ARRAY(_alpha); - _alpha = NULL; + _alpha = nullptr; } } else if (!has_alpha() && has_alpha(color_type)) { @@ -535,7 +535,7 @@ set_color_space(ColorSpace color_space) { return; } - if (_array != NULL) { + if (_array != nullptr) { size_t array_size = _x_size * _y_size; // Note: only convert RGB, since alpha channel is always linear. @@ -680,7 +680,7 @@ unpremultiply_alpha() { */ void PNMImage:: reverse_rows() { - if (_array != NULL) { + if (_array != nullptr) { xel *new_array = (xel *)PANDA_MALLOC_ARRAY(_x_size * _y_size * sizeof(xel)); for (int y = 0; y < _y_size; y++) { int new_y = _y_size - 1 - y; @@ -690,7 +690,7 @@ reverse_rows() { _array = new_array; } - if (_alpha != NULL) { + if (_alpha != nullptr) { xelval *new_alpha = (xelval *)PANDA_MALLOC_ARRAY(_x_size * _y_size * sizeof(xelval)); for (int y = 0; y < _y_size; y++) { int new_y = _y_size - 1 - y; @@ -712,7 +712,7 @@ void PNMImage:: flip(bool flip_x, bool flip_y, bool transpose) { if (transpose) { // Transposed case. X becomes Y, Y becomes X. - if (_array != NULL) { + if (_array != nullptr) { xel *new_array = (xel *)PANDA_MALLOC_ARRAY(_x_size * _y_size * sizeof(xel)); for (int xi = 0; xi < _x_size; ++xi) { xel *row = new_array + xi * _y_size; @@ -727,7 +727,7 @@ flip(bool flip_x, bool flip_y, bool transpose) { _array = new_array; } - if (_alpha != NULL) { + if (_alpha != nullptr) { xelval *new_alpha = (xelval *)PANDA_MALLOC_ARRAY(_x_size * _y_size * sizeof(xelval)); for (int xi = 0; xi < _x_size; ++xi) { xelval *row = new_alpha + xi * _y_size; @@ -749,7 +749,7 @@ flip(bool flip_x, bool flip_y, bool transpose) { } else { // Non-transposed. X is X, Y is Y. - if (_array != NULL) { + if (_array != nullptr) { xel *new_array = (xel *)PANDA_MALLOC_ARRAY(_x_size * _y_size * sizeof(xel)); for (int yi = 0; yi < _y_size; ++yi) { xel *row = new_array + yi * _x_size; @@ -765,7 +765,7 @@ flip(bool flip_x, bool flip_y, bool transpose) { _array = new_array; } - if (_alpha != NULL) { + if (_alpha != nullptr) { xelval *new_alpha = (xelval *)PANDA_MALLOC_ARRAY(_x_size * _y_size * sizeof(xelval)); for (int yi = 0; yi < _y_size; ++yi) { xelval *row = new_alpha + yi * _x_size; @@ -984,7 +984,7 @@ set_pixel(int x, int y, const PixelSpec &pixel) { xel p; PPM_ASSIGN(p, pixel._red, pixel._green, pixel._blue); set_xel_val(x, y, p); - if (_alpha != NULL) { + if (_alpha != nullptr) { set_alpha_val(x, y, pixel._alpha); } } @@ -1039,7 +1039,7 @@ blend(int x, int y, float r, float g, float b, float alpha) { */ void PNMImage:: set_array(xel *array) { - if (_array != (xel *)NULL) { + if (_array != nullptr) { PANDA_FREE_ARRAY(_array); } _array = array; @@ -1055,7 +1055,7 @@ set_array(xel *array) { */ void PNMImage:: set_alpha_array(xelval *alpha) { - if (_alpha != (xelval *)NULL) { + if (_alpha != nullptr) { PANDA_FREE_ARRAY(_alpha); } _alpha = alpha; @@ -1596,7 +1596,7 @@ threshold(const PNMImage &select_image, int channel, float threshold, void PNMImage:: fill_distance_inside(const PNMImage &mask, float threshold, int radius, bool shrink_from_border) { nassertv(radius <= PNM_MAXMAXVAL); - PNMImage dist(mask.get_x_size(), mask.get_y_size(), 1, radius, NULL, CS_linear); + PNMImage dist(mask.get_x_size(), mask.get_y_size(), 1, radius, nullptr, CS_linear); dist.fill_val(radius); xelval threshold_val = mask.to_val(threshold); @@ -1640,7 +1640,7 @@ fill_distance_inside(const PNMImage &mask, float threshold, int radius, bool shr void PNMImage:: fill_distance_outside(const PNMImage &mask, float threshold, int radius) { nassertv(radius <= PNM_MAXMAXVAL); - PNMImage dist(mask.get_x_size(), mask.get_y_size(), 1, radius, NULL, CS_linear); + PNMImage dist(mask.get_x_size(), mask.get_y_size(), 1, radius, nullptr, CS_linear); dist.fill_val(radius); xelval threshold_val = mask.to_val(threshold); @@ -2252,20 +2252,20 @@ operator ~ () const { PNMImage target (*this); size_t array_size = _x_size * _y_size; - if (_array != NULL && _alpha != NULL) { + if (_array != nullptr && _alpha != nullptr) { for (size_t i = 0; i < array_size; ++i) { target._array[i].r = _maxval - _array[i].r; target._array[i].g = _maxval - _array[i].g; target._array[i].b = _maxval - _array[i].b; target._alpha[i] = _maxval - _alpha[i]; } - } else if (_array != NULL) { + } else if (_array != nullptr) { for (size_t i = 0; i < array_size; ++i) { target._array[i].r = _maxval - _array[i].r; target._array[i].g = _maxval - _array[i].g; target._array[i].b = _maxval - _array[i].b; } - } else if (_alpha != NULL) { + } else if (_alpha != nullptr) { for (size_t i = 0; i < array_size; ++i) { target._alpha[i] = _maxval - _alpha[i]; } @@ -2288,7 +2288,7 @@ operator += (const PNMImage &other) { size_t array_size = _x_size * _y_size; // Simple case: add vals directly. - if (_alpha != NULL && other._alpha != NULL) { + if (_alpha != nullptr && other._alpha != nullptr) { for (size_t i = 0; i < array_size; ++i) { _array[i].r = clamp_val((int)_array[i].r + (int)other._array[i].r); _array[i].g = clamp_val((int)_array[i].g + (int)other._array[i].g); @@ -2329,7 +2329,7 @@ operator += (const LColorf &other) { int add_b = (int)(other.get_z() * get_maxval() + 0.5); int add_a = (int)(other.get_w() * get_maxval() + 0.5); - if (_alpha != NULL) { + if (_alpha != nullptr) { for (size_t i = 0; i < array_size; ++i) { _array[i].r = clamp_val((int)_array[i].r + add_r); _array[i].g = clamp_val((int)_array[i].g + add_g); @@ -2370,7 +2370,7 @@ operator -= (const PNMImage &other) { size_t array_size = _x_size * _y_size; // Simple case: subtract vals directly. - if (_alpha != NULL && other._alpha != NULL) { + if (_alpha != nullptr && other._alpha != nullptr) { for (size_t i = 0; i < array_size; ++i) { _array[i].r = clamp_val((int)_array[i].r - (int)other._array[i].r); _array[i].g = clamp_val((int)_array[i].g - (int)other._array[i].g); @@ -2433,7 +2433,7 @@ operator *= (float multiplier) { if (get_color_space() == CS_linear) { size_t array_size = _x_size * _y_size; - if (_alpha != NULL) { + if (_alpha != nullptr) { for (size_t i = 0; i < array_size; ++i) { _array[i].r = clamp_val((int)(_array[i].r * multiplier + 0.5f)); _array[i].g = clamp_val((int)(_array[i].g * multiplier + 0.5f)); @@ -2470,7 +2470,7 @@ operator *= (const LColorf &other) { if (get_color_space() == CS_linear) { size_t array_size = _x_size * _y_size; - if (_alpha != NULL) { + if (_alpha != nullptr) { for (size_t i = 0; i < array_size; ++i) { _array[i].r = clamp_val((int)(_array[i].r * other[0] + 0.5f)); _array[i].g = clamp_val((int)(_array[i].g * other[1] + 0.5f)); diff --git a/panda/src/pnmimage/pnmImage.h b/panda/src/pnmimage/pnmImage.h index 2f7b653185..583d5edef2 100644 --- a/panda/src/pnmimage/pnmImage.h +++ b/panda/src/pnmimage/pnmImage.h @@ -58,9 +58,9 @@ class PNMFileType; class EXPCL_PANDA_PNMIMAGE PNMImage : public PNMImageHeader { PUBLISHED: INLINE PNMImage(); - explicit PNMImage(const Filename &filename, PNMFileType *type = NULL); + explicit PNMImage(const Filename &filename, PNMFileType *type = nullptr); INLINE explicit PNMImage(int x_size, int y_size, int num_channels = 3, - xelval maxval = 255, PNMFileType *type = NULL, + xelval maxval = 255, PNMFileType *type = nullptr, ColorSpace color_space = CS_linear); INLINE PNMImage(const PNMImage ©); INLINE void operator = (const PNMImage ©); @@ -75,7 +75,7 @@ PUBLISHED: void clear(); void clear(int x_size, int y_size, int num_channels = 3, - xelval maxval = 255, PNMFileType *type = NULL, + xelval maxval = 255, PNMFileType *type = nullptr, ColorSpace color_space = CS_linear); void copy_from(const PNMImage ©); @@ -100,16 +100,16 @@ PUBLISHED: INLINE int get_read_y_size() const; INLINE ColorSpace get_color_space() const; - BLOCKING bool read(const Filename &filename, PNMFileType *type = NULL, + BLOCKING bool read(const Filename &filename, PNMFileType *type = nullptr, bool report_unknown_type = true); BLOCKING bool read(istream &data, const string &filename = string(), - PNMFileType *type = NULL, + PNMFileType *type = nullptr, bool report_unknown_type = true); BLOCKING bool read(PNMReader *reader); - BLOCKING bool write(const Filename &filename, PNMFileType *type = NULL) const; + BLOCKING bool write(const Filename &filename, PNMFileType *type = nullptr) const; BLOCKING bool write(ostream &data, const string &filename = string(), - PNMFileType *type = NULL) const; + PNMFileType *type = nullptr) const; BLOCKING bool write(PNMWriter *writer) const; INLINE bool is_valid() const; diff --git a/panda/src/pnmimage/pnmImageHeader.I b/panda/src/pnmimage/pnmImageHeader.I index fc62587986..2801d4d89d 100644 --- a/panda/src/pnmimage/pnmImageHeader.I +++ b/panda/src/pnmimage/pnmImageHeader.I @@ -21,7 +21,7 @@ PNMImageHeader() { _num_channels = 0; _maxval = 255; _color_space = CS_unspecified; - _type = (PNMFileType *)NULL; + _type = nullptr; } /** @@ -184,7 +184,7 @@ set_comment(const string& comment) { */ INLINE bool PNMImageHeader:: has_type() const { - return _type != (PNMFileType *)NULL; + return _type != nullptr; } /** diff --git a/panda/src/pnmimage/pnmImageHeader.cxx b/panda/src/pnmimage/pnmImageHeader.cxx index a0098b58f7..b51e2d8c4d 100644 --- a/panda/src/pnmimage/pnmImageHeader.cxx +++ b/panda/src/pnmimage/pnmImageHeader.cxx @@ -29,7 +29,7 @@ bool PNMImageHeader:: read_header(const Filename &filename, PNMFileType *type, bool report_unknown_type) { PNMReader *reader = make_reader(filename, type, report_unknown_type); - if (reader != (PNMReader *)NULL) { + if (reader != nullptr) { (*this) = (*reader); delete reader; return true; @@ -55,7 +55,7 @@ read_header(istream &data, const string &filename, PNMFileType *type, bool report_unknown_type) { PNMReader *reader = PNMImageHeader::make_reader (&data, false, filename, string(), type, report_unknown_type); - if (reader != (PNMReader *)NULL) { + if (reader != nullptr) { (*this) = (*reader); delete reader; return true; @@ -80,7 +80,7 @@ make_reader(const Filename &filename, PNMFileType *type, << "Reading image from " << filename << "\n"; } bool owns_file = false; - istream *file = (istream *)NULL; + istream *file = nullptr; if (filename == "-") { owns_file = false; @@ -96,12 +96,12 @@ make_reader(const Filename &filename, PNMFileType *type, file = vfs->open_read_file(filename, true); } - if (file == (istream *)NULL) { + if (file == nullptr) { if (pnmimage_cat.is_debug()) { pnmimage_cat.debug() << "Unable to open file.\n"; } - return NULL; + return nullptr; } return make_reader(file, owns_file, filename, string(), type, @@ -135,7 +135,7 @@ PNMReader *PNMImageHeader:: make_reader(istream *file, bool owns_file, const Filename &filename, string magic_number, PNMFileType *type, bool report_unknown_type) const { - if (type == (PNMFileType *)NULL) { + if (type == nullptr) { if (!read_magic_number(file, magic_number, 2)) { // No magic number. No image. if (pnmimage_cat.is_debug()) { @@ -151,14 +151,14 @@ make_reader(istream *file, bool owns_file, const Filename &filename, // since vfs->close_read_file() just deletes the file pointer anyway. vfs->close_read_file(file); } - return NULL; + return nullptr; } type = PNMFileTypeRegistry::get_global_ptr()-> get_type_from_magic_number(magic_number); if (pnmimage_cat.is_debug()) { - if (type != (PNMFileType *)NULL) { + if (type != nullptr) { pnmimage_cat.debug() << "By magic number, image file appears to be type " << type->get_name() << ".\n"; @@ -169,13 +169,13 @@ make_reader(istream *file, bool owns_file, const Filename &filename, } } - if (type == (PNMFileType *)NULL && !filename.empty()) { + if (type == nullptr && !filename.empty()) { // We still don't know the type; attempt to guess it from the filename // extension. type = PNMFileTypeRegistry::get_global_ptr()->get_type_from_extension(filename); if (pnmimage_cat.is_debug()) { - if (type != (PNMFileType *)NULL) { + if (type != nullptr) { pnmimage_cat.debug() << "From its extension, image file is probably type " << type->get_name() << ".\n"; @@ -187,17 +187,17 @@ make_reader(istream *file, bool owns_file, const Filename &filename, } } - if (type == (PNMFileType *)NULL) { + if (type == nullptr) { // No? How about the default type associated with this image header. type = _type; - if (pnmimage_cat.is_debug() && type != (PNMFileType *)NULL) { + if (pnmimage_cat.is_debug() && type != nullptr) { pnmimage_cat.debug() << "Assuming image file type is " << type->get_name() << ".\n"; } } - if (type == (PNMFileType *)NULL) { + if (type == nullptr) { // We can't figure out what type the file is; give up. if (report_unknown_type && pnmimage_cat.is_error()) { pnmimage_cat.error() @@ -215,18 +215,18 @@ make_reader(istream *file, bool owns_file, const Filename &filename, // since vfs->close_read_file() just deletes the file pointer anyway. vfs->close_read_file(file); } - return NULL; + return nullptr; } PNMReader *reader = type->make_reader(file, owns_file, magic_number); - if (reader == NULL && owns_file) { + if (reader == nullptr && owns_file) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->close_read_file(file); } if (!reader->is_valid()) { delete reader; - reader = NULL; + reader = nullptr; } return reader; @@ -247,7 +247,7 @@ make_writer(const Filename &filename, PNMFileType *type) const { << "Writing image to " << filename << "\n"; } bool owns_file = false; - ostream *file = (ostream *)NULL; + ostream *file = nullptr; if (filename == "-") { owns_file = false; @@ -262,17 +262,17 @@ make_writer(const Filename &filename, PNMFileType *type) const { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); Filename actual_name = Filename::binary_filename(filename); file = vfs->open_write_file(actual_name, true, true); - if (file != NULL) { + if (file != nullptr) { owns_file = true; } } - if (file == (ostream *)NULL) { + if (file == nullptr) { if (pnmimage_cat.is_debug()) { pnmimage_cat.debug() << "Unable to write to file.\n"; } - return NULL; + return nullptr; } return make_writer(file, owns_file, filename, type); @@ -299,13 +299,13 @@ make_writer(const Filename &filename, PNMFileType *type) const { PNMWriter *PNMImageHeader:: make_writer(ostream *file, bool owns_file, const Filename &filename, PNMFileType *type) const { - if (type == (PNMFileType *)NULL && !filename.empty()) { + if (type == nullptr && !filename.empty()) { // We don't know the type; attempt to guess it from the filename // extension. type = PNMFileTypeRegistry::get_global_ptr()->get_type_from_extension(filename); if (pnmimage_cat.is_debug()) { - if (type != (PNMFileType *)NULL) { + if (type != nullptr) { pnmimage_cat.debug() << "From its extension, image file is intended to be type " << type->get_name() << ".\n"; @@ -316,17 +316,17 @@ make_writer(ostream *file, bool owns_file, const Filename &filename, } } - if (type == (PNMFileType *)NULL) { + if (type == nullptr) { // No? How about the default type associated with this image header. type = _type; - if (pnmimage_cat.is_debug() && type != (PNMFileType *)NULL) { + if (pnmimage_cat.is_debug() && type != nullptr) { pnmimage_cat.debug() << "Assuming image file type is " << type->get_name() << ".\n"; } } - if (type == (PNMFileType *)NULL) { + if (type == nullptr) { // We can't figure out what type the file is; give up. if (pnmimage_cat.is_debug()) { pnmimage_cat.debug() @@ -335,17 +335,17 @@ make_writer(ostream *file, bool owns_file, const Filename &filename, if (owns_file) { delete file; } - return NULL; + return nullptr; } PNMWriter *writer = type->make_writer(file, owns_file); - if (writer == NULL && owns_file) { + if (writer == nullptr && owns_file) { delete file; } - if (writer != NULL && !writer->is_valid()) { + if (writer != nullptr && !writer->is_valid()) { delete writer; - writer = NULL; + writer = nullptr; } return writer; diff --git a/panda/src/pnmimage/pnmImageHeader.h b/panda/src/pnmimage/pnmImageHeader.h index 1132bed14f..6aeb40642d 100644 --- a/panda/src/pnmimage/pnmImageHeader.h +++ b/panda/src/pnmimage/pnmImageHeader.h @@ -84,25 +84,25 @@ PUBLISHED: INLINE void set_type(PNMFileType *type); MAKE_PROPERTY2(type, has_type, get_type); - BLOCKING bool read_header(const Filename &filename, PNMFileType *type = NULL, + BLOCKING bool read_header(const Filename &filename, PNMFileType *type = nullptr, bool report_unknown_type = true); BLOCKING bool read_header(istream &data, const string &filename = string(), - PNMFileType *type = NULL, bool report_unknown_type = true); + PNMFileType *type = nullptr, bool report_unknown_type = true); PNMReader *make_reader(const Filename &filename, - PNMFileType *type = NULL, + PNMFileType *type = nullptr, bool report_unknown_type = true) const; PNMReader *make_reader(istream *file, bool owns_file = true, const Filename &filename = Filename(), string magic_number = string(), - PNMFileType *type = NULL, + PNMFileType *type = nullptr, bool report_unknown_type = true) const; PNMWriter *make_writer(const Filename &filename, - PNMFileType *type = NULL) const; + PNMFileType *type = nullptr) const; PNMWriter *make_writer(ostream *file, bool owns_file = true, const Filename &filename = Filename(), - PNMFileType *type = NULL) const; + PNMFileType *type = nullptr) const; static bool read_magic_number(istream *file, string &magic_number, int num_bytes); diff --git a/panda/src/pnmimage/pnmReader.cxx b/panda/src/pnmimage/pnmReader.cxx index 9f6c3bc2c9..b40bf3ce40 100644 --- a/panda/src/pnmimage/pnmReader.cxx +++ b/panda/src/pnmimage/pnmReader.cxx @@ -29,7 +29,7 @@ PNMReader:: // vfs->close_read_file() just deletes the file pointer anyway. vfs->close_read_file(_file); } - _file = (istream *)NULL; + _file = nullptr; } /** diff --git a/panda/src/pnmimage/pnmWriter.cxx b/panda/src/pnmimage/pnmWriter.cxx index 0115f261aa..936608e69e 100644 --- a/panda/src/pnmimage/pnmWriter.cxx +++ b/panda/src/pnmimage/pnmWriter.cxx @@ -22,7 +22,7 @@ PNMWriter:: if (_owns_file) { delete _file; } - _file = (ostream *)NULL; + _file = nullptr; } /** diff --git a/panda/src/pnmimage/pnmbitio.cxx b/panda/src/pnmimage/pnmbitio.cxx index ec44d05d44..2dcbfbfacc 100644 --- a/panda/src/pnmimage/pnmbitio.cxx +++ b/panda/src/pnmimage/pnmbitio.cxx @@ -48,7 +48,7 @@ struct bitstream EXPCL_PANDA_PNMIMAGE struct bitstream * pm_bitinit(istream *f, const char *mode) { - struct bitstream *ans = (struct bitstream *)0; + struct bitstream *ans = nullptr; if(!f || !mode || !*mode) return ans; @@ -68,7 +68,7 @@ pm_bitinit(istream *f, const char *mode) EXPCL_PANDA_PNMIMAGE struct bitstream * pm_bitinit(ostream *f, const char *mode) { - struct bitstream *ans = (struct bitstream *)0; + struct bitstream *ans = nullptr; if(!f || !mode || !*mode) return ans; diff --git a/panda/src/pnmimage/ppmcmap.cxx b/panda/src/pnmimage/ppmcmap.cxx index c061bfbde5..48de568d68 100644 --- a/panda/src/pnmimage/ppmcmap.cxx +++ b/panda/src/pnmimage/ppmcmap.cxx @@ -31,8 +31,8 @@ ppm_computecolorhist(pixel** pixels, colorhist_vector chv; cht = ppm_computecolorhash( pixels, cols, rows, maxcolors, colorsP ); - if ( cht == (colorhash_table) 0 ) - return (colorhist_vector) 0; + if ( cht == nullptr ) + return nullptr; chv = ppm_colorhashtocolorhist( cht, maxcolors ); ppm_freecolorhash( cht ); return chv; @@ -95,20 +95,20 @@ ppm_computecolorhash(pixel** pixels, for ( col = 0, pP = pixels[row]; col < cols; ++col, ++pP ) { hash = ppm_hashpixel( *pP ); - for ( chl = cht[hash]; chl != (colorhist_list) 0; chl = chl->next ) + for ( chl = cht[hash]; chl != nullptr; chl = chl->next ) if ( PPM_EQUAL( chl->ch.color, *pP ) ) break; - if ( chl != (colorhist_list) 0 ) + if ( chl != nullptr ) ++(chl->ch.value); else { if ( ++(*colorsP) > maxcolors ) { ppm_freecolorhash( cht ); - return (colorhash_table) 0; + return nullptr; } chl = (colorhist_list) malloc( sizeof(struct colorhist_list_item) ); - if ( chl == 0 ) + if ( chl == nullptr ) pm_error( "out of memory computing hash table" ); chl->ch.color = *pP; chl->ch.value = 1; @@ -127,11 +127,11 @@ ppm_alloccolorhash( ) int i; cht = (colorhash_table) malloc( HASH_SIZE * sizeof(colorhist_list) ); - if ( cht == 0 ) + if ( cht == nullptr ) pm_error( "out of memory allocating hash table" ); for ( i = 0; i < HASH_SIZE; ++i ) - cht[i] = (colorhist_list) 0; + cht[i] = nullptr; return cht; } @@ -145,7 +145,7 @@ ppm_addtocolorhash(colorhash_table cht, colorhist_list chl; chl = (colorhist_list) malloc( sizeof(struct colorhist_list_item) ); - if ( chl == 0 ) + if ( chl == nullptr ) return -1; hash = ppm_hashpixel( *colorP ); chl->ch.color = *colorP; @@ -166,13 +166,13 @@ ppm_colorhashtocolorhist(colorhash_table cht, /* Now collate the hash table into a simple colorhist array. */ chv = (colorhist_vector) malloc( maxcolors * sizeof(struct colorhist_item) ); /* (Leave room for expansion by caller.) */ - if ( chv == (colorhist_vector) 0 ) + if ( chv == nullptr ) pm_error( "out of memory generating histogram" ); /* Loop through the hash table. */ j = 0; for ( i = 0; i < HASH_SIZE; ++i ) - for ( chl = cht[i]; chl != (colorhist_list) 0; chl = chl->next ) + for ( chl = cht[i]; chl != nullptr; chl = chl->next ) { /* Add the new entry. */ chv[j] = chl->ch; @@ -198,13 +198,13 @@ ppm_colorhisttocolorhash(colorhist_vector chv, { color = chv[i].color; hash = ppm_hashpixel( color ); - for ( chl = cht[hash]; chl != (colorhist_list) 0; chl = chl->next ) + for ( chl = cht[hash]; chl != nullptr; chl = chl->next ) if ( PPM_EQUAL( chl->ch.color, color ) ) pm_error( "same color found twice - %d %d %d", PPM_GETR(color), PPM_GETG(color), PPM_GETB(color) ); chl = (colorhist_list) malloc( sizeof(struct colorhist_list_item) ); - if ( chl == (colorhist_list) 0 ) + if ( chl == nullptr ) pm_error( "out of memory" ); chl->ch.color = color; chl->ch.value = i; @@ -223,7 +223,7 @@ ppm_lookupcolor(colorhash_table cht, colorhist_list chl; hash = ppm_hashpixel( *colorP ); - for ( chl = cht[hash]; chl != (colorhist_list) 0; chl = chl->next ) + for ( chl = cht[hash]; chl != nullptr; chl = chl->next ) if ( PPM_EQUAL( chl->ch.color, *colorP ) ) return chl->ch.value; @@ -243,7 +243,7 @@ ppm_freecolorhash(colorhash_table cht) colorhist_list chl, chlnext; for ( i = 0; i < HASH_SIZE; ++i ) - for ( chl = cht[i]; chl != (colorhist_list) 0; chl = chlnext ) + for ( chl = cht[i]; chl != nullptr; chl = chlnext ) { chlnext = chl->next; free( (char*) chl ); diff --git a/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx b/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx index 5d33812216..394445f257 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx @@ -332,13 +332,13 @@ BMPreadrow( pixval *G, pixval *B) { - BITSTREAM b = NULL; + BITSTREAM b = nullptr; unsigned nbyte = 0; int rc; unsigned x; if (indexed) { - if ((b = pm_bitinit(fp, "r")) == (BITSTREAM) 0) + if ((b = pm_bitinit(fp, "r")) == nullptr) { return -1; } diff --git a/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx b/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx index 879682a297..b624314b6b 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx @@ -276,7 +276,7 @@ BMPwriterow( unsigned x; if (indexed) { - if ((b = pm_bitinit(fp, "w")) == (BITSTREAM) 0) + if ((b = pm_bitinit(fp, "w")) == nullptr) { return -1; } @@ -580,7 +580,7 @@ write_data(xel *array, xelval *) { // Quietly generate a 24-bit image. BMPEncode24(_file, classv, _x_size, _y_size, pixels, _maxval); - } else if (chv == (colorhist_vector) 0) { + } else if (chv == nullptr) { if (bmp_bpp != 0) { // Even though we asked for fewer bits, we have to settle for 24-bit. pnmimage_bmp_cat.info() diff --git a/panda/src/pnmimagetypes/pnmFileTypeEXR.cxx b/panda/src/pnmimagetypes/pnmFileTypeEXR.cxx index 6f27c5e09a..157bd716be 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeEXR.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeEXR.cxx @@ -216,8 +216,8 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : // grayscale/alpha images correctly, but also incorrectly detects // luminance/chroma images as grayscale only. However, these kind // of images are a pain to handle anyway, so maybe that's OK. - const char *possible_channel_names[] = { "R", "G", "B", "Y", "A", NULL }; - for (const char **pni = possible_channel_names; *pni != NULL; ++pni) { + const char *possible_channel_names[] = { "R", "G", "B", "Y", "A", nullptr }; + for (const char **pni = possible_channel_names; *pni != nullptr; ++pni) { std::string name = *pni; IMF::ChannelList::ConstIterator ci = channels.find(name.c_str()); if (ci != channels.end()) { @@ -376,7 +376,7 @@ write_pfm(const PfmFile &pfm) { const char *channel_names_2[] = { "G", "A" }; const char *channel_names_3[] = { "R", "G", "B" }; const char *channel_names_4[] = { "R", "G", "B", "A" }; - const char **channel_names = NULL; + const char **channel_names = nullptr; switch (pfm.get_num_channels()) { case 1: diff --git a/panda/src/pnmimagetypes/pnmFileTypeJPGReader.cxx b/panda/src/pnmimagetypes/pnmFileTypeJPGReader.cxx index 333bac61eb..4525dda22a 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeJPGReader.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeJPGReader.cxx @@ -216,7 +216,7 @@ jpeg_istream_src (j_decompress_ptr cinfo, istream * infile) * This makes it unsafe to use this manager and a different source * manager serially with the same JPEG object. Caveat programmer. */ - if (cinfo->src == NULL) { /* first time for this JPEG object? */ + if (cinfo->src == nullptr) { /* first time for this JPEG object? */ cinfo->src = (struct jpeg_source_mgr *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof(my_source_mgr)); @@ -234,7 +234,7 @@ jpeg_istream_src (j_decompress_ptr cinfo, istream * infile) src->pub.term_source = term_source; src->infile = infile; src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ - src->pub.next_input_byte = NULL; /* until buffer loaded */ + src->pub.next_input_byte = nullptr; /* until buffer loaded */ } diff --git a/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx b/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx index 5e0f52f5a6..5308a3417e 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx @@ -166,7 +166,7 @@ jpeg_ostream_dest (j_compress_ptr cinfo, ostream * outfile) * manager serially with the same JPEG object, because their private object * sizes may be different. Caveat programmer. */ - if (cinfo->dest == NULL) { /* first time for this JPEG object? */ + if (cinfo->dest == nullptr) { /* first time for this JPEG object? */ cinfo->dest = (struct jpeg_destination_mgr *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof(my_destination_mgr)); diff --git a/panda/src/pnmimagetypes/pnmFileTypePNG.cxx b/panda/src/pnmimagetypes/pnmFileTypePNG.cxx index bf4ab4ac31..3c2bb2b1d0 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePNG.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypePNG.cxx @@ -162,19 +162,19 @@ PNMFileTypePNG::Reader:: Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : PNMReader(type, file, owns_file) { - _png = NULL; - _info = NULL; + _png = nullptr; + _info = nullptr; _is_valid = false; - _png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, + _png = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, png_error, png_warning); - if (_png == NULL) { + if (_png == nullptr) { return; } _info = png_create_info_struct(_png); - if (_info == NULL) { - png_destroy_read_struct(&_png, NULL, NULL); + if (_info == nullptr) { + png_destroy_read_struct(&_png, nullptr, nullptr); return; } @@ -201,7 +201,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : double gamma; png_get_IHDR(_png, _info, &width, &height, - &bit_depth, &color_type, NULL, NULL, NULL); + &bit_depth, &color_type, nullptr, nullptr, nullptr); // Look for an sRGB chunk. if (png_get_sRGB(_png, _info, &srgb_intent) == PNG_INFO_sRGB) { @@ -403,7 +403,7 @@ read_data(xel *array, xelval *alpha_data) { PANDA_FREE_ARRAY(rows); - png_read_end(_png, NULL); + png_read_end(_png, nullptr); return _y_size; } @@ -414,7 +414,7 @@ read_data(xel *array, xelval *alpha_data) { void PNMFileTypePNG::Reader:: free_png() { if (_is_valid) { - png_destroy_read_struct(&_png, &_info, NULL); + png_destroy_read_struct(&_png, &_info, nullptr); _is_valid = false; } } @@ -456,7 +456,7 @@ png_error(png_structp png_ptr, png_const_charp error_msg) { // The PNG library insists we should not return, so instead of returning, we // will do a longjmp out of the png code. Reader *self = (Reader *)png_get_io_ptr(png_ptr); - if (self == (Reader *)NULL) { + if (self == nullptr) { // Oops, we haven't got a self pointer yet. Return anyway and hope we'll // be ok. pnmimage_png_cat.error() @@ -474,19 +474,19 @@ PNMFileTypePNG::Writer:: Writer(PNMFileType *type, ostream *file, bool owns_file) : PNMWriter(type, file, owns_file) { - _png = NULL; - _info = NULL; + _png = nullptr; + _info = nullptr; _is_valid = false; - _png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, + _png = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, png_error, png_warning); - if (_png == NULL) { + if (_png == nullptr) { return; } _info = png_create_info_struct(_png); - if (_info == NULL) { - png_destroy_write_struct(&_png, NULL); + if (_info == nullptr) { + png_destroy_write_struct(&_png, nullptr); return; } @@ -610,7 +610,7 @@ write_data(xel *array, xelval *alpha_data) { if (has_alpha()) { pnmimage_png_cat.debug() << "palette contains " << num_alpha << " transparent entries.\n"; - png_set_tRNS(_png, _info, png_trans, num_alpha, NULL); + png_set_tRNS(_png, _info, png_trans, num_alpha, nullptr); } } else { pnmimage_png_cat.debug() @@ -828,7 +828,7 @@ write_data(xel *array, xelval *alpha_data) { } PANDA_FREE_ARRAY(row); - png_write_end(_png, NULL); + png_write_end(_png, nullptr); return _y_size; } @@ -918,7 +918,7 @@ png_error(png_structp png_ptr, png_const_charp error_msg) { // The PNG library insists we should not return, so instead of returning, we // will do a longjmp out of the png code. Writer *self = (Writer *)png_get_io_ptr(png_ptr); - if (self == (Writer *)NULL) { + if (self == nullptr) { // Oops, we haven't got a self pointer yet. Return anyway and hope we'll // be ok. pnmimage_png_cat.error() diff --git a/panda/src/pnmimagetypes/pnmFileTypePNM.cxx b/panda/src/pnmimagetypes/pnmFileTypePNM.cxx index efbee9e646..7fd918aa73 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePNM.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypePNM.cxx @@ -127,21 +127,21 @@ pm_allocarray(int const cols, int const rows, int const size ) { char * rowheap; rowIndex = (char **)PANDA_MALLOC_ARRAY((rows + 1) * sizeof(char *)); - if ( rowIndex == NULL ) + if ( rowIndex == nullptr ) pm_error("out of memory allocating row index (%u rows) for an array", rows); rowheap = (char *)PANDA_MALLOC_ARRAY( rows * cols * size ); - if ( rowheap == NULL ) { + if ( rowheap == nullptr ) { /* We couldn't get the whole heap in one block, so try fragmented format. */ int row; - rowIndex[rows] = NULL; /* Declare it fragmented format */ + rowIndex[rows] = nullptr; /* Declare it fragmented format */ for (row = 0; row < rows; ++row) { rowIndex[row] = pm_allocrow(cols, size); - if (rowIndex[row] == NULL) + if (rowIndex[row] == nullptr) pm_error("out of memory allocating Row %u " "(%u columns, %u bytes per tuple) " "of an array", row, cols, size); @@ -163,7 +163,7 @@ pm_freearray(char ** const rowIndex, void * const rowheap = rowIndex[rows]; - if (rowheap != NULL) { + if (rowheap != nullptr) { PANDA_FREE_ARRAY(rowheap); } else { int row; diff --git a/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx b/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx index 597dc9296a..2f56552d18 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx @@ -86,7 +86,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : PNMReader(type, file, owns_file) { eof_err = false; - table = NULL; + table = nullptr; if (!read_magic_number(_file, magic_number, 4)) { // No magic number. No image. @@ -146,7 +146,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : */ PNMFileTypeSGI::Reader:: ~Reader() { - if (table != NULL) { + if (table != nullptr) { free(table); } } @@ -333,7 +333,7 @@ read_channel(istream *ifp, TabEntry *table, ScanElem *channel_data, long table_start, int channel, int row) { - ScanElem *temp = NULL; + ScanElem *temp = nullptr; int sgi_index, i; long offset, length; @@ -486,10 +486,10 @@ xmalloc(int bytes) { void *mem; if( bytes == 0 ) - return NULL; + return nullptr; mem = malloc(bytes); - if( mem == NULL ) + if( mem == nullptr ) pm_error("out of memory allocating %d bytes", bytes); return mem; } diff --git a/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx b/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx index f63431bba1..faf45cc093 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx @@ -88,7 +88,7 @@ Writer(PNMFileType *type, ostream *file, bool owns_file) : */ PNMFileTypeSGI::Writer:: ~Writer() { - if (table!=NULL) { + if (table!=nullptr) { // Rewrite the table with the correct values in it. _file->seekp(table_start); write_table(); @@ -119,7 +119,7 @@ supports_write_row() const { */ bool PNMFileTypeSGI::Writer:: write_header() { - table = NULL; + table = nullptr; switch (_num_channels) { case 1: @@ -155,7 +155,7 @@ write_header() { write_rgb_header(sgi_imagename.c_str()); - if (table!=NULL) { + if (table!=nullptr) { table_start = _file->tellp(); // The first time we write the table, it has zeroes. We'll correct this diff --git a/panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx b/panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx index e17e0e9df8..93599cac83 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeStbImage.cxx @@ -91,7 +91,7 @@ static const int num_stb_extensions = sizeof(stb_extensions) / sizeof(const char // Callbacks to allow stb_image to read from VFS. static int cb_read(void *user, char *data, int size) { istream *in = (istream *)user; - nassertr(in != NULL, 0); + nassertr(in != nullptr, 0); in->read(data, size); @@ -105,7 +105,7 @@ static int cb_read(void *user, char *data, int size) { static void cb_skip(void *user, int n) { istream *in = (istream *)user; - nassertv(in != NULL); + nassertv(in != nullptr); in->seekg(n, ios::cur); @@ -118,7 +118,7 @@ static void cb_skip(void *user, int n) { static int cb_eof(void *user) { istream *in = (istream *)user; - nassertr(in != NULL, 1); + nassertr(in != nullptr, 1); return in->eof(); } @@ -358,7 +358,7 @@ read_pfm(PfmFile &pfm) { return false; } token += 3; - width = (int) strtol(token, NULL, 10); + width = (int) strtol(token, nullptr, 10); // Read data pfm.clear(width, height, 3); @@ -380,7 +380,7 @@ main_decode_loop: } } else { // Read RLE-encoded data - scanline = NULL; + scanline = nullptr; for (j = 0; j < height; ++j) { c1 = stbi__get8(&_context); diff --git a/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx b/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx index 75e90d630d..3be6bd1ff0 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx @@ -176,8 +176,8 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : tga_head = new ImageHeader; RLE_count = 0; RLE_flag = 0; - ColorMap = NULL; - AlphaMap = NULL; + ColorMap = nullptr; + AlphaMap = nullptr; Red = 0; Grn = 0; @@ -283,7 +283,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : temp1 = tga_head->Index_lo + tga_head->Index_hi * 256; temp2 = tga_head->Length_lo + tga_head->Length_hi * 256; int num_colors = temp1 + temp2 + 1; - nassertv(ColorMap == NULL && AlphaMap == NULL); + nassertv(ColorMap == nullptr && AlphaMap == nullptr); ColorMap = (pixel *)PANDA_MALLOC_ARRAY(num_colors * sizeof(pixel)); AlphaMap = (gray *)PANDA_MALLOC_ARRAY(num_colors * sizeof(gray)); for ( unsigned int i = temp1; i < ( temp1 + temp2 ); ++i ) @@ -311,10 +311,10 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : PNMFileTypeTGA::Reader:: ~Reader() { delete tga_head; - if (ColorMap != NULL) { + if (ColorMap != nullptr) { PANDA_FREE_ARRAY(ColorMap); } - if (AlphaMap != NULL) { + if (AlphaMap != nullptr) { PANDA_FREE_ARRAY(AlphaMap); } } @@ -363,9 +363,9 @@ Writer(PNMFileType *type, ostream *file, bool owns_file) : PNMWriter(type, file, owns_file) { tgaHeader = new ImageHeader; - chv = (colorhist_vector)0; - cht = (colorhash_table)0; - runlength = (int*)0; + chv = nullptr; + cht = nullptr; + runlength = nullptr; } /** @@ -375,13 +375,13 @@ PNMFileTypeTGA::Writer:: ~Writer() { delete tgaHeader; - if (chv != (colorhist_vector)0) { + if (chv != nullptr) { ppm_freecolorhist(chv); } - if (cht != (colorhash_table)0) { + if (cht != nullptr) { ppm_freecolorhash(cht); } - if (runlength != (int *)0) { + if (runlength != nullptr) { pm_freerow((char *)runlength); } } @@ -432,7 +432,7 @@ write_data(xel *array, xelval *) { pnmimage_tga_cat.info() << "computing colormap...\n"; chv = ppm_computecolorhist(&array, cols * rows, 1, TGA_MAXCOLORS, &ncolors ); - if ( chv == (colorhist_vector) 0 ) { + if ( chv == nullptr ) { pnmimage_tga_cat.info() << "too many colors, writing RGB.\n"; } else { @@ -498,7 +498,7 @@ write_data(xel *array, xelval *) { tgaHeader->OrgBit = 0; /* Write out the Targa header. */ - writetga( tgaHeader, (char*) 0 ); + writetga( tgaHeader, nullptr ); if ( tgaHeader->ImgType == TGA_Map || tgaHeader->ImgType == TGA_RLEMap ) { diff --git a/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx b/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx index d4870c22d3..e2d5cf0fa1 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx @@ -338,7 +338,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : iostream_dont_close, istream_size, iostream_map, iostream_unmap); - if ( tif == NULL ) { + if ( tif == nullptr ) { _is_valid = false; } } @@ -374,7 +374,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : if (_is_valid) { unsigned short num_extra_samples; - unsigned short *extra_samples = NULL; + unsigned short *extra_samples = nullptr; if (!TIFFGetField(tif, TIFFTAG_EXTRASAMPLES, &num_extra_samples, &extra_samples)) { @@ -547,7 +547,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : */ PNMFileTypeTIFF::Reader:: ~Reader() { - if (tif != (struct tiff *)NULL) { + if (tif != nullptr) { TIFFClose(tif); } } @@ -898,7 +898,7 @@ write_pfm(const PfmFile &pfm) { (TIFFSeekProc)ostream_seek, iostream_dont_close, ostream_size, iostream_map, iostream_unmap); - if (tif == NULL) { + if (tif == nullptr) { return false; } @@ -958,7 +958,7 @@ write_pfm(const PfmFile &pfm) { */ int PNMFileTypeTIFF::Writer:: write_data(xel *array, xelval *alpha) { - colorhist_vector chv = (colorhist_vector) 0; + colorhist_vector chv = nullptr; colorhash_table cht; unsigned short red[TIFF_COLORMAP_MAXCOLORS], @@ -986,7 +986,7 @@ write_data(xel *array, xelval *alpha) { // the number of colors we can read. chv = ppm_computecolorhist( (pixel **)&array, _x_size * _y_size, 1, 256, &colors ); - if ( chv == (colorhist_vector) 0 ) { + if ( chv == nullptr ) { pnmimage_tiff_cat.debug() << colors << " colors found; too many for a palette.\n" << "Writing a 24-bit RGB file.\n"; @@ -1011,12 +1011,12 @@ write_data(xel *array, xelval *alpha) { case CT_two_channel: // We don't yet support two-channel output for TIFF's. case CT_four_channel: - chv = (colorhist_vector) 0; + chv = nullptr; grayscale = false; break; case CT_grayscale: - chv = (colorhist_vector) 0; + chv = nullptr; grayscale = true; break; @@ -1031,7 +1031,7 @@ write_data(xel *array, xelval *alpha) { (TIFFSeekProc)ostream_seek, iostream_dont_close, ostream_size, iostream_map, iostream_unmap); - if ( tif == NULL ) { + if ( tif == nullptr ) { return 0; } @@ -1039,7 +1039,7 @@ write_data(xel *array, xelval *alpha) { switch ( get_color_type() ) { case CT_color: case CT_four_channel: - if ( chv == (colorhist_vector) 0 ) { + if ( chv == nullptr ) { samplesperpixel = _num_channels; bitspersample = 8; photometric = PHOTOMETRIC_RGB; @@ -1072,7 +1072,7 @@ write_data(xel *array, xelval *alpha) { } buf = (unsigned char*) malloc( bytesperrow ); - if ( buf == (unsigned char*) 0 ) { + if ( buf == nullptr ) { pnmimage_tiff_cat.error() << "Can't allocate memory for row buffer\n"; return 0; @@ -1100,8 +1100,8 @@ write_data(xel *array, xelval *alpha) { } TIFFSetField( tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG ); - if ( chv == (colorhist_vector) 0 ) { - cht = (colorhash_table) 0; + if ( chv == nullptr ) { + cht = nullptr; } else { /* Make TIFF colormap. */ for ( i = 0; i < colors; ++i ) { @@ -1122,7 +1122,7 @@ write_data(xel *array, xelval *alpha) { xelval *alpha_data = alpha + row*_x_size; if ( !is_grayscale() && ! grayscale ) { - if ( cht == (colorhash_table) 0 ) { + if ( cht == nullptr ) { tP = buf; for ( col = 0; col < _x_size; ++col ) { *tP++ = (unsigned char)(255 * PPM_GETR(row_data[col]) / _maxval); diff --git a/panda/src/pnmtext/freetypeFace.cxx b/panda/src/pnmtext/freetypeFace.cxx index 0366e3c49a..6dee837486 100644 --- a/panda/src/pnmtext/freetypeFace.cxx +++ b/panda/src/pnmtext/freetypeFace.cxx @@ -28,7 +28,7 @@ TypeHandle FreetypeFace::_type_handle; */ FreetypeFace:: FreetypeFace() : _lock("FreetypeFace::_lock") { - _face = NULL; + _face = nullptr; _char_size = 0; _dpi = 0; _pixel_width = 0; @@ -44,7 +44,7 @@ FreetypeFace() : _lock("FreetypeFace::_lock") { */ FreetypeFace:: ~FreetypeFace() { - if (_face != NULL){ + if (_face != nullptr){ FT_Done_Face(_face); } } @@ -101,7 +101,7 @@ void FreetypeFace:: set_face(FT_Face face) { MutexHolder holder(_lock); - if (_face != NULL){ + if (_face != nullptr){ FT_Done_Face(_face); } _face = face; @@ -111,7 +111,7 @@ set_face(FT_Face face) { _pixel_height = 0; _name = _face->family_name; - if (_face->style_name != NULL) { + if (_face->style_name != nullptr) { _name += " "; _name += _face->style_name; } @@ -129,7 +129,7 @@ set_face(FT_Face face) { pnmtext_cat.debug() << "default charmap is " << (void *)_face->charmap << "\n"; } - if (_face->charmap == NULL) { + if (_face->charmap == nullptr) { // If for some reason FreeType didn't set us up a charmap, then set it up // ourselves. if (_face->num_charmaps == 0) { diff --git a/panda/src/pnmtext/freetypeFont.I b/panda/src/pnmtext/freetypeFont.I index 897100998b..dc0f4ae60b 100644 --- a/panda/src/pnmtext/freetypeFont.I +++ b/panda/src/pnmtext/freetypeFont.I @@ -207,7 +207,7 @@ get_winding_order() const { */ INLINE FT_Face FreetypeFont:: acquire_face() const { - nassertr(_face != NULL, NULL); + nassertr(_face != nullptr, nullptr); return _face->acquire_face(_char_size, _dpi, _pixel_width, _pixel_height); } @@ -217,7 +217,7 @@ acquire_face() const { */ INLINE void FreetypeFont:: release_face(FT_Face face) const { - nassertv(_face != NULL); + nassertv(_face != nullptr); _face->release_face(face); } diff --git a/panda/src/pnmtext/freetypeFont.cxx b/panda/src/pnmtext/freetypeFont.cxx index 379a139426..78a7455b96 100644 --- a/panda/src/pnmtext/freetypeFont.cxx +++ b/panda/src/pnmtext/freetypeFont.cxx @@ -37,7 +37,7 @@ const PN_stdfloat FreetypeFont::_points_per_inch = 72.0f; */ FreetypeFont:: FreetypeFont() { - _face = NULL; + _face = nullptr; _point_size = text_point_size; _requested_pixels_per_unit = text_pixels_per_unit; @@ -183,7 +183,7 @@ load_font(const char *font_data, int data_length, int face_index) { */ void FreetypeFont:: unload_font() { - _face = NULL; + _face = nullptr; } /** @@ -297,7 +297,7 @@ copy_bitmap_to_pnmimage(const FT_Bitmap &bitmap, PNMImage &image) { */ bool FreetypeFont:: reset_scale() { - if (_face == NULL) { + if (_face == nullptr) { return false; } diff --git a/panda/src/pnmtext/pnmTextMaker.cxx b/panda/src/pnmtext/pnmTextMaker.cxx index 1c11dac21c..1cf2c92a75 100644 --- a/panda/src/pnmtext/pnmTextMaker.cxx +++ b/panda/src/pnmtext/pnmTextMaker.cxx @@ -171,7 +171,7 @@ make_glyph(int glyph_index) { FT_Face face = acquire_face(); if (!load_glyph(face, glyph_index)) { release_face(face); - return (PNMTextGlyph *)NULL; + return nullptr; } FT_GlyphSlot slot = face->glyph; diff --git a/panda/src/pstatclient/pStatClient.I b/panda/src/pstatclient/pStatClient.I index 2338eaa0ad..b13eb43401 100644 --- a/panda/src/pstatclient/pStatClient.I +++ b/panda/src/pstatclient/pStatClient.I @@ -25,7 +25,7 @@ get_num_collectors() const { */ INLINE PStatCollectorDef *PStatClient:: get_collector_def(int index) const { - nassertr(index >= 0 && index < _num_collectors, NULL); + nassertr(index >= 0 && index < _num_collectors, nullptr); return get_collector_ptr(index)->get_def(this, index); } @@ -62,7 +62,7 @@ get_thread_sync_name(int index) const { */ INLINE PT(Thread) PStatClient:: get_thread_object(int index) const { - nassertr(index >= 0 && index < AtomicAdjust::get(_num_threads), NULL); + nassertr(index >= 0 && index < AtomicAdjust::get(_num_threads), nullptr); InternalThread *thread = get_thread_ptr(index); return thread->_thread.lock(); } @@ -109,7 +109,7 @@ resume_after_pause() { */ INLINE bool PStatClient:: has_impl() const { - return (_impl != (PStatClientImpl *)NULL); + return (_impl != nullptr); } /** @@ -119,7 +119,7 @@ has_impl() const { INLINE PStatClientImpl *PStatClient:: get_impl() { ReMutexHolder holder(_lock); - if (_impl == (PStatClientImpl *)NULL) { + if (_impl == nullptr) { make_impl(); } return _impl; @@ -132,7 +132,7 @@ get_impl() { INLINE const PStatClientImpl *PStatClient:: get_impl() const { ReMutexHolder holder(_lock); - if (_impl == (PStatClientImpl *)NULL) { + if (_impl == nullptr) { make_impl(); } return _impl; @@ -162,7 +162,7 @@ get_thread_ptr(int thread_index) const { */ INLINE PStatClient::Collector:: Collector(int parent_index, const string &name) : - _def(NULL), + _def(nullptr), _parent_index(parent_index), _name(name) { @@ -191,7 +191,7 @@ get_name() const { */ INLINE bool PStatClient::Collector:: is_active() const { - return _def != (PStatCollectorDef *)NULL && _def->_is_active; + return _def != nullptr && _def->_is_active; } /** @@ -200,7 +200,7 @@ is_active() const { */ INLINE PStatCollectorDef *PStatClient::Collector:: get_def(const PStatClient *client, int this_index) const { - if (_def == (PStatCollectorDef *)NULL) { + if (_def == nullptr) { ((Collector *)this)->make_def(client, this_index); } diff --git a/panda/src/pstatclient/pStatClient.cxx b/panda/src/pstatclient/pStatClient.cxx index a735ea080e..8a4a9fc288 100644 --- a/panda/src/pstatclient/pStatClient.cxx +++ b/panda/src/pstatclient/pStatClient.cxx @@ -44,7 +44,7 @@ PStatCollector PStatClient::_clock_wait_pcollector("Wait:Clock Wait:Sleep"); PStatCollector PStatClient::_clock_busy_wait_pcollector("Wait:Clock Wait:Spin"); PStatCollector PStatClient::_thread_block_pcollector("Wait:Thread block"); -PStatClient *PStatClient::_global_pstats = NULL; +PStatClient *PStatClient::_global_pstats = nullptr; // This class is used to report memory usage per TypeHandle. We create one of @@ -73,13 +73,13 @@ PerThreadData() { PStatClient:: PStatClient() : _lock("PStatClient::_lock"), - _impl(NULL) + _impl(nullptr) { - _collectors = NULL; + _collectors = nullptr; _collectors_size = 0; _num_collectors = 0; - _threads = NULL; + _threads = nullptr; _threads_size = 0; _num_threads = 0; @@ -457,7 +457,7 @@ client_disconnect() { if (has_impl()) { _impl->client_disconnect(); delete _impl; - _impl = NULL; + _impl = nullptr; } ThreadPointer *threads = (ThreadPointer *)_threads; @@ -508,7 +508,7 @@ client_resume_after_pause() { */ PStatClient *PStatClient:: get_global_pstats() { - if (_global_pstats == (PStatClient *)NULL) { + if (_global_pstats == nullptr) { _global_pstats = new PStatClient; ClockObject::_start_clock_wait = start_clock_wait; @@ -1129,7 +1129,7 @@ deactivate_hook(Thread *thread) { // We shouldn't use a mutex here, because this code is only called during // the SIMPLE_THREADS case, so a mutex isn't necessary; and because we are // called during a context switch, so a mutex might be dangerous. - if (_impl == NULL) { + if (_impl == nullptr) { return; } int thread_index = thread->get_pstats_index(); @@ -1154,7 +1154,7 @@ activate_hook(Thread *thread) { // We shouldn't use a mutex here, because this code is only called during // the SIMPLE_THREADS case, so a mutex isn't necessary; and because we are // called during a context switch, so a mutex might be dangerous. - if (_impl == NULL) { + if (_impl == nullptr) { return; } @@ -1173,7 +1173,7 @@ activate_hook(Thread *thread) { void PStatClient::Collector:: make_def(const PStatClient *client, int this_index) { ReMutexHolder holder(client->_lock); - if (_def == (PStatCollectorDef *)NULL) { + if (_def == nullptr) { _def = new PStatCollectorDef(this_index, _name); if (_parent_index != this_index) { const PStatCollectorDef *parent_def = @@ -1205,7 +1205,7 @@ InternalThread(Thread *thread) : */ PStatClient::InternalThread:: InternalThread(const string &name, const string &sync_name) : - _thread(NULL), + _thread(nullptr), _name(name), _sync_name(sync_name), _is_active(false), diff --git a/panda/src/pstatclient/pStatCollector.I b/panda/src/pstatclient/pStatCollector.I index f103bbbae0..23a2cf6199 100644 --- a/panda/src/pstatclient/pStatCollector.I +++ b/panda/src/pstatclient/pStatCollector.I @@ -33,7 +33,7 @@ PStatCollector(PStatClient *client, int index) : */ INLINE PStatCollector:: PStatCollector() : - _client(NULL), + _client(nullptr), _index(0), _level(0.0f) { @@ -57,7 +57,7 @@ INLINE PStatCollector:: PStatCollector(const string &name, PStatClient *client) : _level(0.0f) { - if (client == (PStatClient *)NULL) { + if (client == nullptr) { client = PStatClient::get_global_pstats(); } (*this) = client->make_collector_with_relname(0, name); @@ -83,7 +83,7 @@ INLINE PStatCollector:: PStatCollector(const PStatCollector &parent, const string &name) : _level(0.0f) { - nassertv(parent._client != (PStatClient *)NULL); + nassertv(parent._client != nullptr); (*this) = parent._client->make_collector_with_relname(parent._index, name); } @@ -115,7 +115,7 @@ operator = (const PStatCollector ©) { */ INLINE bool PStatCollector:: is_valid() const { - return (_client != (PStatClient *)NULL); + return (_client != nullptr); } /** @@ -124,7 +124,7 @@ is_valid() const { */ INLINE string PStatCollector:: get_name() const { - if (_client != (PStatClient *)NULL) { + if (_client != nullptr) { return _client->get_collector_name(_index); } return string(); @@ -136,7 +136,7 @@ get_name() const { */ INLINE string PStatCollector:: get_fullname() const { - if (_client != (PStatClient *)NULL) { + if (_client != nullptr) { return _client->get_collector_fullname(_index); } return string(); @@ -384,7 +384,7 @@ is_started(const PStatThread &thread) { */ INLINE void PStatCollector:: start(const PStatThread &thread) { - nassertv(_client != NULL); + nassertv(_client != nullptr); _client->start(_index, thread._index); } @@ -498,7 +498,7 @@ PStatCollector(const string &, PStatClient *client) { // We need this bogus comparison just to prevent the SGI compiler from // dumping core. It's perfectly meaningless. #ifdef mips - if (client == (PStatClient *)NULL) { + if (client == nullptr) { return; } #endif @@ -513,7 +513,7 @@ PStatCollector(const PStatCollector &parent, const string &) { // We need this bogus comparison just to prevent the SGI compiler from // dumping core. It's perfectly meaningless. #ifdef mips - if (&parent == (const PStatCollector *)NULL) { + if (&parent == nullptr) { return; } #endif diff --git a/panda/src/pstatclient/pStatCollector.h b/panda/src/pstatclient/pStatCollector.h index 6c265f5e0c..3f96b79f41 100644 --- a/panda/src/pstatclient/pStatCollector.h +++ b/panda/src/pstatclient/pStatCollector.h @@ -51,7 +51,7 @@ public: PUBLISHED: INLINE explicit PStatCollector(const string &name, - PStatClient *client = NULL); + PStatClient *client = nullptr); INLINE explicit PStatCollector(const PStatCollector &parent, const string &name); @@ -111,7 +111,7 @@ public: PUBLISHED: INLINE PStatCollector(const string &name, - PStatClient *client = NULL); + PStatClient *client = nullptr); INLINE PStatCollector(const PStatCollector &parent, const string &name); diff --git a/panda/src/pstatclient/pStatProperties.cxx b/panda/src/pstatclient/pStatProperties.cxx index 01411f3f74..32db833ed5 100644 --- a/panda/src/pstatclient/pStatProperties.cxx +++ b/panda/src/pstatclient/pStatProperties.cxx @@ -146,7 +146,7 @@ static TimeCollectorProperties time_properties[] = { { 1, "Draw:Set State", { 0.2, 0.6, 0.8 } }, { 1, "Draw:Wait occlusion", { 1.0, 0.5, 0.0 } }, { 1, "Draw:Bind FBO", { 0.0, 0.8, 0.8 } }, - { 0, NULL } + { 0, nullptr } }; static LevelCollectorProperties level_properties[] = { @@ -218,7 +218,7 @@ static LevelCollectorProperties level_properties[] = { { 1, "Collision Volumes", { 1.0, 0.8, 0.5 }, "", 500 }, { 1, "Collision Tests", { 0.5, 0.8, 1.0 }, "", 100 }, { 1, "Command latency", { 0.8, 0.2, 0.0 }, "ms", 10, 1.0 / 1000.0 }, - { 0, NULL } + { 0, nullptr } }; @@ -231,7 +231,7 @@ initialize_collector_def_from_table(const string &fullname, PStatCollectorDef *d int i; for (i = 0; - time_properties[i].name != (const char *)NULL; + time_properties[i].name != nullptr; i++) { const TimeCollectorProperties &tp = time_properties[i]; if (fullname == tp.name) { @@ -248,7 +248,7 @@ initialize_collector_def_from_table(const string &fullname, PStatCollectorDef *d } for (i = 0; - level_properties[i].name != (const char *)NULL; + level_properties[i].name != nullptr; i++) { const LevelCollectorProperties &lp = level_properties[i]; if (fullname == lp.name) { @@ -260,7 +260,7 @@ initialize_collector_def_from_table(const string &fullname, PStatCollectorDef *d if (lp.suggested_scale != 0.0) { def->_suggested_scale = lp.suggested_scale; } - if (lp.units != (const char *)NULL) { + if (lp.units != nullptr) { def->_level_units = lp.units; } if (lp.inv_factor != 0.0) { diff --git a/panda/src/pstatclient/pStatThread.I b/panda/src/pstatclient/pStatThread.I index 4fd43c5669..fb68d4d3f9 100644 --- a/panda/src/pstatclient/pStatThread.I +++ b/panda/src/pstatclient/pStatThread.I @@ -37,7 +37,7 @@ PStatThread(PStatClient *client, int index) : INLINE PStatThread:: PStatThread(Thread *thread, PStatClient *client) { #ifdef DO_PSTATS - if (client == (PStatClient *)NULL) { + if (client == nullptr) { client = PStatClient::get_global_pstats(); } @@ -51,7 +51,7 @@ PStatThread(Thread *thread, PStatClient *client) { (*this) = client->make_thread(thread); } #else - _client = (PStatClient *)NULL; + _client = nullptr; _index = 0; #endif } diff --git a/panda/src/pstatclient/pStatThread.h b/panda/src/pstatclient/pStatThread.h index 0ad8567c7a..74defa2a15 100644 --- a/panda/src/pstatclient/pStatThread.h +++ b/panda/src/pstatclient/pStatThread.h @@ -31,7 +31,7 @@ public: PUBLISHED: INLINE PStatThread(PStatClient *client, int index); - INLINE PStatThread(Thread *thread, PStatClient *client = NULL); + INLINE PStatThread(Thread *thread, PStatClient *client = nullptr); INLINE PStatThread(const PStatThread ©); INLINE void operator = (const PStatThread ©); diff --git a/panda/src/pstatclient/test_client.cxx b/panda/src/pstatclient/test_client.cxx index 35a79a8cbd..b60aa6c625 100644 --- a/panda/src/pstatclient/test_client.cxx +++ b/panda/src/pstatclient/test_client.cxx @@ -45,13 +45,13 @@ SampleData dataset_zero[] = { { "Cull", 5, 6, false }, { "App", 0, 5, false }, { "Texture memory", 8000000, 100000, true }, - { NULL }, + { nullptr }, }; SampleData dataset_one[] = { { "Draw", 10, 12, false }, { "Squeak", 25, 30, false }, - { NULL }, + { nullptr }, }; SampleData dataset_two[] = { @@ -63,7 +63,7 @@ SampleData dataset_two[] = { { "Animation:donald", 5, 6, false }, { "Animation:goofy", 5, 6, false }, { "Animation:pluto", 5, 6, false }, - { NULL }, + { nullptr }, }; #define NUM_DATASETS 3 @@ -113,7 +113,7 @@ main(int argc, char *argv[]) { exit(1); } - srand(time(NULL)); + srand(time(nullptr)); int ds_index; if (argc > 3) { @@ -132,7 +132,7 @@ main(int argc, char *argv[]) { pvector _collectors; int i = 0; - while (ds[i].category != (const char *)NULL) { + while (ds[i].category != nullptr) { _collectors.push_back(PStatCollector(ds[i].category)); if (ds[i].is_level) { _collectors[i].set_level(ds[i].min_ms); diff --git a/panda/src/putil/bamCache.I b/panda/src/putil/bamCache.I index 0d359ad29b..38a9e45540 100644 --- a/panda/src/putil/bamCache.I +++ b/panda/src/putil/bamCache.I @@ -221,7 +221,7 @@ get_read_only() const { */ INLINE BamCache *BamCache:: get_global_ptr() { - if (_global_ptr == (BamCache *)NULL) { + if (_global_ptr == nullptr) { make_global(); } return _global_ptr; @@ -232,7 +232,7 @@ get_global_ptr() { */ INLINE void BamCache:: consider_flush_global_index() { - if (_global_ptr != (BamCache *)NULL) { + if (_global_ptr != nullptr) { _global_ptr->consider_flush_index(); } } @@ -242,7 +242,7 @@ consider_flush_global_index() { */ INLINE void BamCache:: flush_global_index() { - if (_global_ptr != (BamCache *)NULL) { + if (_global_ptr != nullptr) { _global_ptr->flush_index(); } } @@ -254,6 +254,6 @@ flush_global_index() { INLINE void BamCache:: mark_index_stale() { if (_index_stale_since == 0) { - _index_stale_since = time(NULL); + _index_stale_since = time(nullptr); } } diff --git a/panda/src/putil/bamCache.cxx b/panda/src/putil/bamCache.cxx index cd3fab2113..385079d7ee 100644 --- a/panda/src/putil/bamCache.cxx +++ b/panda/src/putil/bamCache.cxx @@ -27,7 +27,7 @@ #include "configVariableFilename.h" #include "virtualFileSystem.h" -BamCache *BamCache::_global_ptr = NULL; +BamCache *BamCache::_global_ptr = nullptr; /** * @@ -101,7 +101,7 @@ BamCache:: ~BamCache() { flush_index(); delete _index; - _index = NULL; + _index = nullptr; } /** @@ -165,7 +165,7 @@ lookup(const Filename &source_filename, const string &cache_extension) { if (rel_pathname.is_local()) { // If the source pathname is already within the cache directory, don't // cache it further. - return NULL; + return nullptr; } Filename cache_filename = hash_filename(source_pathname.get_fullpath()); @@ -199,7 +199,7 @@ store(BamCacheRecord *record) { nassertr(rel_pathname.is_local(), false); #endif // NDEBUG - record->_recorded_time = time(NULL); + record->_recorded_time = time(nullptr); Filename cache_pathname = Filename::binary_filename(record->_cache_pathname); @@ -319,7 +319,7 @@ consider_flush_index() { #endif if (_index_stale_since != 0) { - int elapsed = (int)time(NULL) - (int)_index_stale_since; + int elapsed = (int)time(nullptr) - (int)_index_stale_since; if (elapsed > _flush_time) { flush_index(); } @@ -404,7 +404,7 @@ read_index() { while (true) { BamCacheIndex *new_index = do_read_index(_index_pathname); - if (new_index != (BamCacheIndex *)NULL) { + if (new_index != nullptr) { merge_index(new_index); return; } @@ -514,7 +514,7 @@ merge_index(BamCacheIndex *new_index) { if (cache_pathname.exists()) { PT(BamCacheRecord) record = do_read_record(cache_pathname, false); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { _index->_records.insert(_index->_records.end(), BamCacheIndex::Records::value_type(record->get_source_pathname(), record)); } } @@ -558,7 +558,7 @@ rebuild_index() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); PT(VirtualFileList) contents = vfs->scan_directory(_root); - if (contents == NULL) { + if (contents == nullptr) { util_cat.error() << "Unable to read directory " << _root << ", caching disabled.\n"; set_active(false); @@ -577,7 +577,7 @@ rebuild_index() { Filename pathname(_root, filename); PT(BamCacheRecord) record = do_read_record(pathname, false); - if (record == (BamCacheRecord *)NULL) { + if (record == nullptr) { // Well, it was invalid, so blow it away. if (util_cat.is_debug()) { util_cat.debug() @@ -599,7 +599,7 @@ rebuild_index() { } _index->process_new_records(); - _index_stale_since = time(NULL); + _index_stale_since = time(nullptr); check_cache_size(); flush_index(); } @@ -642,7 +642,7 @@ check_cache_size() { if (_index->_cache_size / 1024 > _max_kbytes) { while (_index->_cache_size / 1024 > _max_kbytes) { PT(BamCacheRecord) record = _index->evict_old_file(); - if (record == NULL) { + if (record == nullptr) { // Never mind; the cache is empty. break; } @@ -666,53 +666,53 @@ check_cache_size() { BamCacheIndex *BamCache:: do_read_index(const Filename &index_pathname) { if (index_pathname.empty()) { - return NULL; + return nullptr; } DatagramInputFile din; if (!din.open(index_pathname)) { util_cat.debug() << "Could not read index file: " << index_pathname << "\n"; - return NULL; + return nullptr; } string head; if (!din.read_header(head, _bam_header.size())) { util_cat.debug() << index_pathname << " is not an index file.\n"; - return NULL; + return nullptr; } if (head != _bam_header) { util_cat.debug() << index_pathname << " is not an index file.\n"; - return NULL; + return nullptr; } BamReader reader(&din); if (!reader.init()) { - return NULL; + return nullptr; } TypedWritable *object = reader.read_object(); - if (object == (TypedWritable *)NULL) { + if (object == nullptr) { util_cat.error() << "Cache index " << index_pathname << " is empty.\n"; - return NULL; + return nullptr; } else if (!object->is_of_type(BamCacheIndex::get_class_type())) { util_cat.error() << "Cache index " << index_pathname << " contains a " << object->get_type() << ", not a BamCacheIndex.\n"; - return NULL; + return nullptr; } BamCacheIndex *index = DCAST(BamCacheIndex, object); if (!reader.resolve()) { util_cat.error() << "Unable to fully resolve cache index file.\n"; - return NULL; + return nullptr; } return index; @@ -767,7 +767,7 @@ find_and_read_record(const Filename &source_pathname, while (true) { PT(BamCacheRecord) record = read_record(source_pathname, cache_filename, pass); - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { add_to_index(record); return record; } @@ -809,7 +809,7 @@ read_record(const Filename &source_pathname, } PT(BamCacheRecord) record = do_read_record(cache_pathname, true); - if (record == (BamCacheRecord *)NULL) { + if (record == nullptr) { // Well, it was invalid, so blow it away, and make a new one. if (util_cat.is_debug()) { util_cat.debug() @@ -832,7 +832,7 @@ read_record(const Filename &source_pathname, << record->get_source_pathname() << ", not " << source_pathname << "\n"; } - return NULL; + return nullptr; } if (!record->has_data()) { @@ -855,7 +855,7 @@ do_read_record(const Filename &cache_pathname, bool read_data) { util_cat.debug() << "Could not read cache file: " << cache_pathname << "\n"; } - return NULL; + return nullptr; } string head; @@ -864,7 +864,7 @@ do_read_record(const Filename &cache_pathname, bool read_data) { util_cat.debug() << cache_pathname << " is not a cache file.\n"; } - return NULL; + return nullptr; } if (head != _bam_header) { @@ -872,21 +872,21 @@ do_read_record(const Filename &cache_pathname, bool read_data) { util_cat.debug() << cache_pathname << " is not a cache file.\n"; } - return NULL; + return nullptr; } BamReader reader(&din); if (!reader.init()) { - return NULL; + return nullptr; } TypedWritable *object = reader.read_object(); - if (object == (TypedWritable *)NULL) { + if (object == nullptr) { if (util_cat.is_debug()) { util_cat.debug() << cache_pathname << " is empty.\n"; } - return NULL; + return nullptr; } else if (!object->is_of_type(BamCacheRecord::get_class_type())) { if (util_cat.is_debug()) { @@ -894,7 +894,7 @@ do_read_record(const Filename &cache_pathname, bool read_data) { << "Cache file " << cache_pathname << " contains a " << object->get_type() << ", not a BamCacheRecord.\n"; } - return NULL; + return nullptr; } PT(BamCacheRecord) record = DCAST(BamCacheRecord, object); @@ -903,7 +903,7 @@ do_read_record(const Filename &cache_pathname, bool read_data) { util_cat.debug() << "Unable to fully resolve cache record in " << cache_pathname << "\n"; } - return NULL; + return nullptr; } // From this point below, we have validated that the selected filename is @@ -937,7 +937,7 @@ do_read_record(const Filename &cache_pathname, bool read_data) { record->_record_size = vfile->get_file_size(&in); // And the last access time is now, duh. - record->_record_access_time = time(NULL); + record->_record_access_time = time(nullptr); return record; } diff --git a/panda/src/putil/bamCacheIndex.cxx b/panda/src/putil/bamCacheIndex.cxx index 31c62ec3a5..889bb2a8ab 100644 --- a/panda/src/putil/bamCacheIndex.cxx +++ b/panda/src/putil/bamCacheIndex.cxx @@ -94,8 +94,8 @@ release_records() { Records::const_iterator ri; for (ri = _records.begin(); ri != _records.end(); ++ri) { BamCacheRecord *record = (*ri).second; - record->_next = NULL; - record->_prev = NULL; + record->_next = nullptr; + record->_prev = nullptr; } _next = this; _prev = this; @@ -110,13 +110,13 @@ PT(BamCacheRecord) BamCacheIndex:: evict_old_file() { if (_next == this) { // Nothing in the cache. - return NULL; + return nullptr; } // The first record in the linked list is the least-recently-used one. PT(BamCacheRecord) record = (BamCacheRecord *)_next; bool removed = remove_record(record->get_source_pathname()); - nassertr(removed, NULL); + nassertr(removed, nullptr); return record; } @@ -249,7 +249,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { int num_records = scan.get_uint32(); _record_vector.reserve(num_records); for (int i = 0; i < num_records; ++i) { - _record_vector.push_back(NULL); + _record_vector.push_back(nullptr); manager->read_pointer(scan); } } diff --git a/panda/src/putil/bamCacheRecord.I b/panda/src/putil/bamCacheRecord.I index 6693b1c694..e5288c03ac 100644 --- a/panda/src/putil/bamCacheRecord.I +++ b/panda/src/putil/bamCacheRecord.I @@ -95,7 +95,7 @@ get_dependent_pathname(int n) const { */ INLINE bool BamCacheRecord:: has_data() const { - return (_ptr != (TypedWritable *)NULL); + return (_ptr != nullptr); } /** @@ -104,12 +104,12 @@ has_data() const { */ INLINE void BamCacheRecord:: clear_data() { - if (_ref_ptr != NULL) { + if (_ref_ptr != nullptr) { unref_delete(_ref_ptr); } - _ptr = NULL; - _ref_ptr = NULL; + _ptr = nullptr; + _ref_ptr = nullptr; } /** @@ -135,7 +135,7 @@ extract_data(TypedWritable *&ptr, ReferenceCount *&ref_ptr) { ptr = _ptr; ref_ptr = _ref_ptr; clear_data(); - return (ptr != (TypedWritable *)NULL); + return (ptr != nullptr); } /** @@ -155,7 +155,7 @@ set_data(TypedWritable *ptr, ReferenceCount *ref_ptr) { clear_data(); _ptr = ptr; _ref_ptr = ref_ptr; - if (_ref_ptr != NULL) { + if (_ref_ptr != nullptr) { _ref_ptr->ref(); } } @@ -186,7 +186,7 @@ set_data(TypedWritableReferenceCount *ptr) { INLINE void BamCacheRecord:: set_data(TypedWritable *ptr, int dummy) { nassertv(dummy == 0); - set_data(ptr, (ReferenceCount *)NULL); + set_data(ptr, nullptr); } /** diff --git a/panda/src/putil/bamCacheRecord.cxx b/panda/src/putil/bamCacheRecord.cxx index 8fabae7326..f732dbcb9e 100644 --- a/panda/src/putil/bamCacheRecord.cxx +++ b/panda/src/putil/bamCacheRecord.cxx @@ -29,8 +29,8 @@ BamCacheRecord() : _recorded_time(0), _record_size(0), _source_timestamp(0), - _ptr(NULL), - _ref_ptr(NULL), + _ptr(nullptr), + _ref_ptr(nullptr), _record_access_time(0) { } @@ -46,8 +46,8 @@ BamCacheRecord(const Filename &source_pathname, _recorded_time(0), _record_size(0), _source_timestamp(0), - _ptr(NULL), - _ref_ptr(NULL), + _ptr(nullptr), + _ref_ptr(nullptr), _record_access_time(0) { } @@ -62,8 +62,8 @@ BamCacheRecord(const BamCacheRecord ©) : _recorded_time(copy._recorded_time), _record_size(copy._record_size), _source_timestamp(copy._source_timestamp), - _ptr(NULL), - _ref_ptr(NULL), + _ptr(nullptr), + _ref_ptr(nullptr), _record_access_time(copy._record_access_time) { } @@ -93,7 +93,7 @@ dependents_unchanged() const { for (fi = _files.begin(); fi != _files.end(); ++fi) { const DependentFile &dfile = (*fi); PT(VirtualFile) file = vfs->get_file(dfile._pathname); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { // No such file. if (dfile._timestamp != 0) { if (util_cat.is_debug()) { @@ -153,7 +153,7 @@ add_dependent_file(const Filename &pathname) { dfile._pathname.make_absolute(); PT(VirtualFile) file = vfs->get_file(dfile._pathname); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { // No such file. dfile._timestamp = 0; dfile._size = 0; @@ -231,7 +231,7 @@ format_timestamp(time_t timestamp) { return " (no date) "; } - time_t now = time(NULL); + time_t now = time(nullptr); struct tm atm; #ifdef _WIN32 localtime_s(&atm, ×tamp); diff --git a/panda/src/putil/bamReader.I b/panda/src/putil/bamReader.I index ece2676956..d660317a71 100644 --- a/panda/src/putil/bamReader.I +++ b/panda/src/putil/bamReader.I @@ -34,7 +34,7 @@ get_source() { */ INLINE const Filename &BamReader:: get_filename() const { - if (_source != (DatagramGenerator *)NULL) { + if (_source != nullptr) { return _source->get_filename(); } static const Filename empty_filename; @@ -64,7 +64,7 @@ set_loader_options(const LoaderOptions &options) { */ INLINE bool BamReader:: is_eof() const { - nassertr(_source != NULL, true); + nassertr(_source != nullptr, true); return _source->is_eof(); } @@ -131,7 +131,7 @@ get_current_minor_ver() const { */ INLINE const FileReference *BamReader:: get_file() { - nassertr(_source != NULL, NULL); + nassertr(_source != nullptr, nullptr); return _source->get_file(); } @@ -141,7 +141,7 @@ get_file() { */ INLINE VirtualFile *BamReader:: get_vfile() { - nassertr(_source != NULL, NULL); + nassertr(_source != nullptr, nullptr); return _source->get_vfile(); } @@ -155,7 +155,7 @@ get_vfile() { */ INLINE streampos BamReader:: get_file_pos() { - nassertr(_source != NULL, 0); + nassertr(_source != nullptr, 0); return _source->get_file_pos(); } @@ -175,7 +175,7 @@ register_factory(TypeHandle handle, WritableFactory::CreateFunc *func, void *use */ INLINE WritableFactory *BamReader:: get_factory() { - if (_factory == (WritableFactory *)NULL) { + if (_factory == nullptr) { create_factory(); } return _factory; @@ -195,7 +195,7 @@ create_factory() { */ INLINE bool BamReader:: get_datagram(Datagram &datagram) { - nassertr(_source != NULL, false); + nassertr(_source != nullptr, false); if (_source->is_error()) { return false; } @@ -221,10 +221,10 @@ AuxData() { INLINE BamReader::CreatedObj:: CreatedObj() : _created(false), - _ptr(NULL), - _ref_ptr(NULL), - _change_this(NULL), - _change_this_ref(NULL) + _ptr(nullptr), + _ref_ptr(nullptr), + _change_this(nullptr), + _change_this_ref(nullptr) { } @@ -233,7 +233,7 @@ CreatedObj() : */ INLINE BamReader::CreatedObj:: ~CreatedObj() { - set_ptr(NULL, NULL); + set_ptr(nullptr, nullptr); } /** @@ -249,7 +249,7 @@ INLINE BamReader::CreatedObj:: INLINE void BamReader::CreatedObj:: set_ptr(TypedWritable *ptr, ReferenceCount *ref_ptr) { if (_ptr != ptr) { - if (_ref_ptr != NULL) { + if (_ref_ptr != nullptr) { nassertv(_ref_ptr != ref_ptr); unref_delete(_ref_ptr); } @@ -257,7 +257,7 @@ set_ptr(TypedWritable *ptr, ReferenceCount *ref_ptr) { _ptr = ptr; _ref_ptr = ref_ptr; - if (_ref_ptr != NULL) { + if (_ref_ptr != nullptr) { _ref_ptr->ref(); } } else { diff --git a/panda/src/putil/bamReader.cxx b/panda/src/putil/bamReader.cxx index eab309c9d6..e6cc5683d6 100644 --- a/panda/src/putil/bamReader.cxx +++ b/panda/src/putil/bamReader.cxx @@ -22,9 +22,9 @@ TypeHandle BamReaderAuxData::_type_handle; -WritableFactory *BamReader::_factory = (WritableFactory*)0L; -BamReader *const BamReader::Null = (BamReader*)0L; -WritableFactory *const BamReader::NullFactory = (WritableFactory*)0L; +WritableFactory *BamReader::_factory = nullptr; +BamReader *const BamReader::Null = nullptr; +WritableFactory *const BamReader::NullFactory = nullptr; BamReader::NewTypes BamReader::_new_types; @@ -43,7 +43,7 @@ BamReader(DatagramGenerator *source) _num_extra_objects = 0; _nesting_level = 0; _now_creating = _created_objs.end(); - _reading_cycler = (PipelineCyclerBase *)NULL; + _reading_cycler = nullptr; _pta_id = -1; _long_object_id = false; _long_pta_id = false; @@ -66,7 +66,7 @@ BamReader:: void BamReader:: set_source(DatagramGenerator *source) { _source = source; - if (_needs_init && _source != NULL) { + if (_needs_init && _source != nullptr) { bool success = init(); nassertv(success); } @@ -81,7 +81,7 @@ set_source(DatagramGenerator *source) { */ bool BamReader:: init() { - nassertr(_source != NULL, false); + nassertr(_source != nullptr, false); nassertr(_needs_init, false); _needs_init = false; Datagram header; @@ -163,7 +163,7 @@ init() { */ void BamReader:: set_aux_data(TypedWritable *obj, const string &name, BamReader::AuxData *data) { - if (data == (void *)NULL) { + if (data == nullptr) { AuxDataTable::iterator ti = _aux_data.find(obj); if (ti != _aux_data.end()) { AuxDataNames &names = (*ti).second; @@ -194,7 +194,7 @@ get_aux_data(TypedWritable *obj, const string &name) const { } } - return NULL; + return nullptr; } @@ -224,7 +224,7 @@ read_object() { ReferenceCount *ref_ptr; if (!read_object(ptr, ref_ptr)) { - return NULL; + return nullptr; } return ptr; @@ -241,8 +241,8 @@ read_object() { */ bool BamReader:: read_object(TypedWritable *&ptr, ReferenceCount *&ref_ptr) { - ptr = NULL; - ref_ptr = NULL; + ptr = nullptr; + ref_ptr = nullptr; nassertr(_num_extra_objects == 0, false); int start_level = _nesting_level; @@ -290,13 +290,13 @@ read_object(TypedWritable *&ptr, ReferenceCount *&ref_ptr) { ref_ptr = created_obj._ref_ptr; if (bam_cat.is_spam()) { - if (ptr != (TypedWritable *)NULL) { + if (ptr != nullptr) { bam_cat.spam() << "Returning object of type " << ptr->get_type() << "\n"; } } - if (created_obj._change_this != NULL || - created_obj._change_this_ref != NULL) { + if (created_obj._change_this != nullptr || + created_obj._change_this_ref != nullptr) { bam_cat.warning() << "Returning pointer to " << ptr->get_type() << " that might change.\n"; @@ -360,10 +360,10 @@ resolve() { any_completed_this_pass = true; // Does the pointer need to change? - if (created_obj._change_this_ref != NULL) { + if (created_obj._change_this_ref != nullptr) { // Reference-counting variant. TypedWritableReferenceCount *object_ref_ptr = (TypedWritableReferenceCount *)object_ptr; - nassertr(created_obj._ref_ptr == NULL || created_obj._ref_ptr == object_ref_ptr, false); + nassertr(created_obj._ref_ptr == nullptr || created_obj._ref_ptr == object_ref_ptr, false); PT(TypedWritableReferenceCount) new_ptr = created_obj._change_this_ref(object_ref_ptr, this); if (new_ptr != object_ref_ptr) { // Also update the reverse @@ -381,10 +381,10 @@ resolve() { _finalize_list.erase(object_ptr); } created_obj.set_ptr(new_ptr, new_ptr); - created_obj._change_this = NULL; - created_obj._change_this_ref = NULL; + created_obj._change_this = nullptr; + created_obj._change_this_ref = nullptr; - } else if (created_obj._change_this != NULL) { + } else if (created_obj._change_this != nullptr) { // Non-reference-counting variant. TypedWritable *new_ptr = created_obj._change_this(object_ptr, this); if (new_ptr != object_ptr) { @@ -403,8 +403,8 @@ resolve() { _finalize_list.erase(object_ptr); } created_obj.set_ptr(new_ptr, new_ptr->as_reference_count()); - created_obj._change_this = NULL; - created_obj._change_this_ref = NULL; + created_obj._change_this = nullptr; + created_obj._change_this_ref = nullptr; } } else { @@ -615,7 +615,7 @@ read_pointer(DatagramIterator &scan) { int object_id = read_object_id(scan); PointerReference &pref = _object_pointers[requestor_id]; - if (_reading_cycler == (PipelineCyclerBase *)NULL) { + if (_reading_cycler == nullptr) { // This is not being read within a read_cdata() call. pref._objects.push_back(object_id); } else { @@ -781,15 +781,15 @@ set_aux_tag(const string &tag, BamReaderAuxData *value) { */ BamReaderAuxData *BamReader:: get_aux_tag(const string &tag) const { - nassertr(_now_creating != _created_objs.end(), NULL); + nassertr(_now_creating != _created_objs.end(), nullptr); int requestor_id = (*_now_creating).first; ObjectPointers::const_iterator opi = _object_pointers.find(requestor_id); - nassertr(opi != _object_pointers.end(), NULL); + nassertr(opi != _object_pointers.end(), nullptr); const PointerReference &pref = (*opi).second; AuxTags::const_iterator ati = pref._aux_tags.find(tag); - nassertr(ati != pref._aux_tags.end(), NULL); + nassertr(ati != pref._aux_tags.end(), nullptr); return (*ati).second; } @@ -804,7 +804,7 @@ get_aux_tag(const string &tag) const { */ void BamReader:: register_finalize(TypedWritable *whom) { - nassertv(whom != (TypedWritable *)NULL); + nassertv(whom != nullptr); if (bam_cat.is_spam()) { bam_cat.spam() @@ -837,7 +837,7 @@ register_change_this(ChangeThisFunc func, TypedWritable *object) { #ifndef NDEBUG // Sanity check the pointer--it should always be the same pointer after we // set it the first time. - if (created_obj._ptr == (TypedWritable *)NULL) { + if (created_obj._ptr == nullptr) { created_obj.set_ptr(object, object->as_reference_count()); } else { // We've previously assigned this pointer, and we should have assigned it @@ -847,7 +847,7 @@ register_change_this(ChangeThisFunc func, TypedWritable *object) { #endif // NDEBUG created_obj._change_this = func; - created_obj._change_this_ref = NULL; + created_obj._change_this_ref = nullptr; } /** @@ -872,7 +872,7 @@ register_change_this(ChangeThisRefFunc func, TypedWritableReferenceCount *object #ifndef NDEBUG // Sanity check the pointer--it should always be the same pointer after we // set it the first time. - if (created_obj._ptr == (TypedWritable *)NULL) { + if (created_obj._ptr == nullptr) { created_obj.set_ptr(object, object); } else { // We've previously assigned this pointer, and we should have assigned it @@ -882,7 +882,7 @@ register_change_this(ChangeThisRefFunc func, TypedWritableReferenceCount *object } #endif // NDEBUG - created_obj._change_this = NULL; + created_obj._change_this = nullptr; created_obj._change_this_ref = func; } @@ -893,7 +893,7 @@ register_change_this(ChangeThisRefFunc func, TypedWritableReferenceCount *object */ void BamReader:: finalize_now(TypedWritable *whom) { - if (whom == (TypedWritable *)NULL) { + if (whom == nullptr) { return; } @@ -927,7 +927,7 @@ finalize_now(TypedWritable *whom) { */ void *BamReader:: get_pta(DatagramIterator &scan) { - nassertr(_pta_id == -1, (void *)NULL); + nassertr(_pta_id == -1, nullptr); int id = read_pta_id(scan); if (id == 0) { @@ -935,7 +935,7 @@ get_pta(DatagramIterator &scan) { // able to differentiate this case from that of a previously-read pointer, // but that's OK because the next data in the Bam file is the length of // the array, which will be zero--indicating an empty or NULL array. - return (void *)NULL; + return nullptr; } PTAMap::iterator pi = _pta_map.find(id); @@ -943,7 +943,7 @@ get_pta(DatagramIterator &scan) { // This is the first time we've encountered this particular ID, meaning we // need to read the data now and register it. _pta_id = id; - return (void *)NULL; + return nullptr; } return (*pi).second; @@ -1155,7 +1155,7 @@ p_read_object() { _created_objs.insert(CreatedObjs::value_type(object_id, new_created_obj)).first; CreatedObj &created_obj = (*oi).second; - if (created_obj._ptr != NULL) { + if (created_obj._ptr != nullptr) { // This object had already existed; thus, we are just receiving an // update for it. @@ -1200,15 +1200,15 @@ p_read_object() { _now_creating = was_creating; // And now we can store the new object pointer in the map. - nassertr(created_obj._ptr == object || created_obj._ptr == NULL, object_id); - if (object == NULL) { - created_obj.set_ptr(NULL, NULL); + nassertr(created_obj._ptr == object || created_obj._ptr == nullptr, object_id); + if (object == nullptr) { + created_obj.set_ptr(nullptr, nullptr); } else { created_obj.set_ptr(object, object->as_reference_count()); } created_obj._created = true; - if (created_obj._change_this_ref != NULL) { + if (created_obj._change_this_ref != nullptr) { // If the pointer is scheduled to change after complete_pointers(), // but we have no entry in _object_pointers for this object (and hence // no plan to call complete_pointers()), then just change the pointer @@ -1218,8 +1218,8 @@ p_read_object() { PT(TypedWritableReferenceCount) object_ref = (*created_obj._change_this_ref)((TypedWritableReferenceCount *)object, this); TypedWritable *new_ptr = object_ref; created_obj.set_ptr(object_ref, object_ref); - created_obj._change_this = NULL; - created_obj._change_this_ref = NULL; + created_obj._change_this = nullptr; + created_obj._change_this_ref = nullptr; // Remove the pointer from the finalize list (the new pointer // presumably doesn't require finalizing). @@ -1229,14 +1229,14 @@ p_read_object() { object = new_ptr; } - } else if (created_obj._change_this != NULL) { + } else if (created_obj._change_this != nullptr) { // Non-reference-counting variant. ObjectPointers::const_iterator ri = _object_pointers.find(object_id); if (ri == _object_pointers.end()) { TypedWritable *new_ptr = (*created_obj._change_this)(object, this); created_obj.set_ptr(new_ptr, new_ptr->as_reference_count()); - created_obj._change_this = NULL; - created_obj._change_this_ref = NULL; + created_obj._change_this = nullptr; + created_obj._change_this_ref = nullptr; if (new_ptr != object) { _finalize_list.erase(object); @@ -1248,7 +1248,7 @@ p_read_object() { _created_objs_by_pointer[created_obj._ptr].push_back(object_id); // Just some sanity checks - if (object == (TypedWritable *)NULL) { + if (object == nullptr) { if (bam_cat.is_debug()) { bam_cat.debug() << "Unable to create an object of type " << type << endl; @@ -1355,7 +1355,7 @@ resolve_object_pointers(TypedWritable *object, int child_id = (*pi); if (child_id == 0) { // A NULL pointer is a NULL pointer. - references.push_back((TypedWritable *)NULL); + references.push_back(nullptr); continue; } @@ -1374,7 +1374,7 @@ resolve_object_pointers(TypedWritable *object, break; } - if (child_obj._change_this != NULL || child_obj._change_this_ref != NULL) { + if (child_obj._change_this != nullptr || child_obj._change_this_ref != nullptr) { // It's been created, but the pointer might still change. is_complete = false; break; @@ -1447,7 +1447,7 @@ resolve_cycler_pointers(PipelineCyclerBase *cycler, if (child_id == 0) { // A NULL pointer is a NULL pointer. - references.push_back((TypedWritable *)NULL); + references.push_back(nullptr); continue; } @@ -1460,7 +1460,7 @@ resolve_cycler_pointers(PipelineCyclerBase *cycler, } const CreatedObj &child_obj = (*oi).second; - if (child_obj._change_this != NULL || child_obj._change_this_ref != NULL) { + if (child_obj._change_this != nullptr || child_obj._change_this_ref != nullptr) { // It's been created, but the pointer might still change. is_complete = false; break; @@ -1513,7 +1513,7 @@ finalize() { Finalize::iterator fi = _finalize_list.begin(); while (fi != _finalize_list.end()) { TypedWritable *object = (*fi); - nassertv(object != (TypedWritable *)NULL); + nassertv(object != nullptr); _finalize_list.erase(fi); if (bam_cat.is_spam()) { bam_cat.spam() @@ -1527,14 +1527,14 @@ finalize() { // Now clear the aux data of all objects, except the NULL object. if (!_aux_data.empty()) { - AuxDataTable::iterator ti = _aux_data.find((TypedWritable *)NULL); + AuxDataTable::iterator ti = _aux_data.find(nullptr); if (ti != _aux_data.end()) { if (_aux_data.size() > 1) { // Move the NULL data to the new table; remove the rest. AuxDataTable new_aux_data; AuxDataTable::iterator nti = - new_aux_data.insert(AuxDataTable::value_type((TypedWritable *)NULL, AuxDataNames())).first; + new_aux_data.insert(AuxDataTable::value_type(nullptr, AuxDataNames())).first; (*nti).second.swap((*ti).second); _aux_data.swap(new_aux_data); } diff --git a/panda/src/putil/bamReader.h b/panda/src/putil/bamReader.h index 14403f6cae..46ec5fd56c 100644 --- a/panda/src/putil/bamReader.h +++ b/panda/src/putil/bamReader.h @@ -42,7 +42,7 @@ #define READ_PTA(Manager, source, Read_func, array) \ { \ void *t; \ - if ((t = Manager->get_pta(source)) == (void*)NULL) \ + if ((t = Manager->get_pta(source)) == nullptr) \ { \ array = Read_func(Manager, source); \ Manager->register_pta(array.get_void_ptr()); \ @@ -115,7 +115,7 @@ public: PUBLISHED: // The primary interface for a caller. - explicit BamReader(DatagramGenerator *source = NULL); + explicit BamReader(DatagramGenerator *source = nullptr); ~BamReader(); void set_source(DatagramGenerator *source); @@ -198,7 +198,7 @@ public: public: INLINE static void register_factory(TypeHandle type, WritableFactory::CreateFunc *func, - void *user_data = NULL); + void *user_data = nullptr); INLINE static WritableFactory *get_factory(); PUBLISHED: diff --git a/panda/src/putil/bamReader_ext.cxx b/panda/src/putil/bamReader_ext.cxx index 444688a654..a224a36037 100644 --- a/panda/src/putil/bamReader_ext.cxx +++ b/panda/src/putil/bamReader_ext.cxx @@ -28,7 +28,7 @@ extern Dtool_PyTypedObject Dtool_TypedWritable; */ static TypedWritable *factory_callback(const FactoryParams ¶ms){ PyObject *func = (PyObject *)params.get_user_data(); - nassertr(func != NULL, NULL); + nassertr(func != nullptr, nullptr); #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) // Use PyGILState to protect this asynchronous call. @@ -51,7 +51,7 @@ static TypedWritable *factory_callback(const FactoryParams ¶ms){ Py_DECREF(py_scan); Py_DECREF(py_manager); - if (result == (PyObject *)NULL) { + if (result == nullptr) { util_cat.error() << "Exception occurred in Python factory function\n"; @@ -59,7 +59,7 @@ static TypedWritable *factory_callback(const FactoryParams ¶ms){ util_cat.error() << "Python factory function returned None\n"; Py_DECREF(result); - result = NULL; + result = nullptr; } #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) @@ -67,15 +67,15 @@ static TypedWritable *factory_callback(const FactoryParams ¶ms){ #endif // Unwrap the returned TypedWritable object. - if (result == (PyObject *)NULL) { - return (TypedWritable *)NULL; + if (result == nullptr) { + return nullptr; } else { - void *object = NULL; + void *object = nullptr; Dtool_Call_ExtractThisPointer(result, Dtool_TypedWritable, &object); TypedWritable *ptr = (TypedWritable *)object; ReferenceCount *ref_count = ptr->as_reference_count(); - if (ref_count != NULL) { + if (ref_count != nullptr) { // If the Python pointer is the last reference to it, make sure that the // object isn't destroyed. We do this by calling unref(), which // decreases the reference count without destroying the object. @@ -109,7 +109,7 @@ get_file_version() const { */ void Extension:: register_factory(TypeHandle handle, PyObject *func) { - nassertv(func != NULL); + nassertv(func != nullptr); if (!PyCallable_Check(func)) { Dtool_Raise_TypeError("second argument to register_factory must be callable"); diff --git a/panda/src/putil/bamWriter.I b/panda/src/putil/bamWriter.I index b2fa51d146..ad8b119edf 100644 --- a/panda/src/putil/bamWriter.I +++ b/panda/src/putil/bamWriter.I @@ -27,7 +27,7 @@ get_target() { */ INLINE const Filename &BamWriter:: get_filename() const { - if (_target != (DatagramSink *)NULL) { + if (_target != nullptr) { return _target->get_filename(); } static const Filename empty_filename; diff --git a/panda/src/putil/bamWriter.cxx b/panda/src/putil/bamWriter.cxx index ac3ac6b8ad..d8aa3e0b30 100644 --- a/panda/src/putil/bamWriter.cxx +++ b/panda/src/putil/bamWriter.cxx @@ -107,12 +107,12 @@ BamWriter:: */ void BamWriter:: set_target(DatagramSink *target) { - if (_target != NULL) { + if (_target != nullptr) { _target->flush(); } _target = target; - if (_needs_init && _target != NULL) { + if (_needs_init && _target != nullptr) { init(); } } @@ -126,7 +126,7 @@ set_target(DatagramSink *target) { */ bool BamWriter:: init() { - nassertr(_target != NULL, false); + nassertr(_target != nullptr, false); nassertr(_needs_init, false); _needs_init = false; @@ -183,7 +183,7 @@ init() { */ bool BamWriter:: write_object(const TypedWritable *object) { - nassertr(_target != NULL, false); + nassertr(_target != nullptr, false); // Increment the _writing_seq, so we can check for newly stale objects // during this operation. @@ -246,7 +246,7 @@ has_object(const TypedWritable *object) const { */ void BamWriter:: flush() { - nassertv(_target != NULL); + nassertv(_target != nullptr); _target->flush(); } @@ -298,7 +298,7 @@ void BamWriter:: write_pointer(Datagram &packet, const TypedWritable *object) { // If the pointer is NULL, we always simply write a zero for an object ID // and leave it at that. - if (object == (const TypedWritable *)NULL) { + if (object == nullptr) { write_object_id(packet, 0); } else { @@ -436,7 +436,7 @@ write_cdata(Datagram &packet, const PipelineCyclerBase &cycler, */ bool BamWriter:: register_pta(Datagram &packet, const void *ptr) { - if (ptr == (const void *)NULL) { + if (ptr == nullptr) { // A zero for the PTA ID indicates a NULL pointer. This is a special // case. write_pta_id(packet, 0); @@ -649,7 +649,7 @@ enqueue_object(const TypedWritable *object) { */ bool BamWriter:: flush_queue() { - nassertr(_target != NULL, false); + nassertr(_target != nullptr, false); // Each object we write may append more to the queue. while (!_object_queue.empty()) { const TypedWritable *object = _object_queue.front(); diff --git a/panda/src/putil/bamWriter.h b/panda/src/putil/bamWriter.h index bcd4a76ce6..b8c53aac38 100644 --- a/panda/src/putil/bamWriter.h +++ b/panda/src/putil/bamWriter.h @@ -62,7 +62,7 @@ */ class EXPCL_PANDA_PUTIL BamWriter : public BamEnums { PUBLISHED: - explicit BamWriter(DatagramSink *target = NULL); + explicit BamWriter(DatagramSink *target = nullptr); ~BamWriter(); void set_target(DatagramSink *target); diff --git a/panda/src/putil/buttonRegistry.I b/panda/src/putil/buttonRegistry.I index b531b444f5..8ce0b2f1ce 100644 --- a/panda/src/putil/buttonRegistry.I +++ b/panda/src/putil/buttonRegistry.I @@ -27,7 +27,7 @@ RegistryNode(ButtonHandle handle, ButtonHandle alias, const string &name) : */ INLINE ButtonRegistry *ButtonRegistry:: ptr() { - if (_global_pointer == (ButtonRegistry *)NULL) { + if (_global_pointer == nullptr) { init_global_pointer(); } return _global_pointer; @@ -39,7 +39,7 @@ ptr() { INLINE string ButtonRegistry:: get_name(ButtonHandle button) const { RegistryNode *rnode = look_up(button); - nassertr(rnode != (RegistryNode *)NULL, ""); + nassertr(rnode != nullptr, ""); return rnode->_name; } @@ -50,6 +50,6 @@ get_name(ButtonHandle button) const { INLINE ButtonHandle ButtonRegistry:: get_alias(ButtonHandle button) const { RegistryNode *rnode = look_up(button); - nassertr(rnode != (RegistryNode *)NULL, ButtonHandle::none()); + nassertr(rnode != nullptr, ButtonHandle::none()); return rnode->_alias; } diff --git a/panda/src/putil/buttonRegistry.cxx b/panda/src/putil/buttonRegistry.cxx index 594a5864fd..2537dcc0dc 100644 --- a/panda/src/putil/buttonRegistry.cxx +++ b/panda/src/putil/buttonRegistry.cxx @@ -21,7 +21,7 @@ // and we must use the arrow syntax to force initialization of the util_cat // category. -ButtonRegistry *ButtonRegistry::_global_pointer = NULL; +ButtonRegistry *ButtonRegistry::_global_pointer = nullptr; /** @@ -52,7 +52,7 @@ register_button(ButtonHandle &button_handle, const string &name, int index = -1; if (ascii_equivalent != '\0') { - if (_handle_registry[ascii_equivalent] == (RegistryNode *)NULL) { + if (_handle_registry[ascii_equivalent] == nullptr) { index = ascii_equivalent; } else { util_cat->error() @@ -73,7 +73,7 @@ register_button(ButtonHandle &button_handle, const string &name, if (index == -1) { // It's not an ASCII equivalent; make up a new number. index = _handle_registry.size(); - _handle_registry.push_back(NULL); + _handle_registry.push_back(nullptr); } ButtonHandle new_handle; @@ -145,7 +145,7 @@ find_button(const string &name) { */ ButtonHandle ButtonRegistry:: find_ascii_button(char ascii_equivalent) const { - if (_handle_registry[ascii_equivalent] == (RegistryNode *)NULL) { + if (_handle_registry[ascii_equivalent] == nullptr) { return ButtonHandle::none(); } return _handle_registry[ascii_equivalent]->_handle; @@ -158,7 +158,7 @@ void ButtonRegistry:: write(ostream &out) const { out << "ASCII equivalents:\n"; for (int i = 1; i < 128; i++) { - if (_handle_registry[i] != (RegistryNode *)NULL) { + if (_handle_registry[i] != nullptr) { char hex[12]; sprintf(hex, "%02x", (unsigned int)i); nassertv(strlen(hex) < 12); @@ -192,7 +192,7 @@ ButtonRegistry() { _handle_registry.reserve(128); int i; for (i = 0; i < 128; i++) { - _handle_registry.push_back(NULL); + _handle_registry.push_back(nullptr); } } @@ -210,14 +210,14 @@ init_global_pointer() { */ ButtonRegistry::RegistryNode *ButtonRegistry:: look_up(ButtonHandle handle) const { - nassertr(handle._index != 0, NULL); + nassertr(handle._index != 0, nullptr); if (handle._index < 0 || handle._index >= (int)_handle_registry.size()) { util_cat->fatal() << "Invalid ButtonHandle index " << handle._index << "! Is memory corrupt?\n"; - return (RegistryNode *)NULL; + return nullptr; } return _handle_registry[handle._index]; diff --git a/panda/src/putil/callbackObject_ext.I b/panda/src/putil/callbackObject_ext.I index 12edcf6b23..536ba2ac97 100644 --- a/panda/src/putil/callbackObject_ext.I +++ b/panda/src/putil/callbackObject_ext.I @@ -20,7 +20,7 @@ INLINE PT(CallbackObject) Extension:: make(PyObject *function) { if (function != Py_None && !PyCallable_Check(function)) { PyErr_SetString(PyExc_TypeError, "expected callable or None"); - return NULL; + return nullptr; } else { return new PythonCallbackObject(function); } diff --git a/panda/src/putil/config_putil.cxx b/panda/src/putil/config_putil.cxx index 5461b73f3f..c3083f306f 100644 --- a/panda/src/putil/config_putil.cxx +++ b/panda/src/putil/config_putil.cxx @@ -103,8 +103,8 @@ ConfigureFn(config_putil) { ConfigVariableSearchPath & get_model_path() { - static ConfigVariableSearchPath *model_path = NULL; - if (model_path == NULL) { + static ConfigVariableSearchPath *model_path = nullptr; + if (model_path == nullptr) { model_path = new ConfigVariableSearchPath ("model-path", PRC_DESC("The default directories to search for all models and general " @@ -116,8 +116,8 @@ get_model_path() { ConfigVariableSearchPath & get_plugin_path() { - static ConfigVariableSearchPath *plugin_path = NULL; - if (plugin_path == NULL) { + static ConfigVariableSearchPath *plugin_path = nullptr; + if (plugin_path == nullptr) { plugin_path = new ConfigVariableSearchPath ("plugin-path", "", PRC_DESC("The directories to search for plugin shared libraries.")); diff --git a/panda/src/putil/copyOnWriteObject.I b/panda/src/putil/copyOnWriteObject.I index 304e7214c5..dccb2ec385 100644 --- a/panda/src/putil/copyOnWriteObject.I +++ b/panda/src/putil/copyOnWriteObject.I @@ -32,7 +32,7 @@ CopyOnWriteObject() #endif #ifdef COW_THREADED _lock_status = LS_unlocked; - _locking_thread = NULL; + _locking_thread = nullptr; #endif // COW_THREADED } @@ -52,7 +52,7 @@ CopyOnWriteObject(const CopyOnWriteObject ©) : #endif #ifdef COW_THREADED _lock_status = LS_unlocked; - _locking_thread = NULL; + _locking_thread = nullptr; #endif // COW_THREADED } diff --git a/panda/src/putil/copyOnWriteObject.cxx b/panda/src/putil/copyOnWriteObject.cxx index 172f354319..e039f12450 100644 --- a/panda/src/putil/copyOnWriteObject.cxx +++ b/panda/src/putil/copyOnWriteObject.cxx @@ -30,7 +30,7 @@ unref() const { bool is_zero = CachedTypedWritableReferenceCount::unref(); if (get_ref_count() == get_cache_ref_count()) { ((CopyOnWriteObject *)this)->_lock_status = LS_unlocked; - ((CopyOnWriteObject *)this)->_locking_thread = NULL; + ((CopyOnWriteObject *)this)->_locking_thread = nullptr; ((CopyOnWriteObject *)this)->_lock_cvar.notify(); } return is_zero; @@ -48,7 +48,7 @@ cache_ref_only() const { CachedTypedWritableReferenceCount::cache_ref_only(); if (get_ref_count() == get_cache_ref_count()) { ((CopyOnWriteObject *)this)->_lock_status = LS_unlocked; - ((CopyOnWriteObject *)this)->_locking_thread = NULL; + ((CopyOnWriteObject *)this)->_locking_thread = nullptr; ((CopyOnWriteObject *)this)->_lock_cvar.notify(); } } diff --git a/panda/src/putil/copyOnWritePointer.I b/panda/src/putil/copyOnWritePointer.I index 9354fe350a..548844ca4e 100644 --- a/panda/src/putil/copyOnWritePointer.I +++ b/panda/src/putil/copyOnWritePointer.I @@ -18,7 +18,7 @@ INLINE CopyOnWritePointer:: CopyOnWritePointer(CopyOnWriteObject *object) : _cow_object(object) { - if (_cow_object != (CopyOnWriteObject *)NULL) { + if (_cow_object != nullptr) { _cow_object->cache_ref(); } } @@ -30,7 +30,7 @@ INLINE CopyOnWritePointer:: CopyOnWritePointer(const CopyOnWritePointer ©) : _cow_object(copy._cow_object) { - if (_cow_object != (CopyOnWriteObject *)NULL) { + if (_cow_object != nullptr) { _cow_object->cache_ref(); } } @@ -49,11 +49,11 @@ operator = (const CopyOnWritePointer ©) { INLINE void CopyOnWritePointer:: operator = (CopyOnWriteObject *object) { if (_cow_object != object) { - if (_cow_object != (CopyOnWriteObject *)NULL) { + if (_cow_object != nullptr) { cache_unref_delete(_cow_object); } _cow_object = object; - if (_cow_object != (CopyOnWriteObject *)NULL) { + if (_cow_object != nullptr) { _cow_object->cache_ref(); } } @@ -64,7 +64,7 @@ operator = (CopyOnWriteObject *object) { */ INLINE CopyOnWritePointer:: ~CopyOnWritePointer() { - if (_cow_object != (CopyOnWriteObject *)NULL) { + if (_cow_object != nullptr) { cache_unref_delete(_cow_object); } } @@ -77,7 +77,7 @@ CopyOnWritePointer(CopyOnWritePointer &&from) noexcept : _cow_object(from._cow_object) { // Steal the other's reference count. - from._cow_object = (CopyOnWriteObject *)NULL; + from._cow_object = nullptr; } /** @@ -89,10 +89,10 @@ CopyOnWritePointer(PointerTo &&from) noexcept : { // Steal the other's reference count, but because it is a regular pointer, // we do need to include the cache reference count. - if (_cow_object != (CopyOnWriteObject *)NULL) { + if (_cow_object != nullptr) { _cow_object->cache_ref_only(); } - from.cheat() = NULL; + from.cheat() = nullptr; } /** @@ -104,9 +104,9 @@ operator = (CopyOnWritePointer &&from) noexcept { if (from._cow_object != _cow_object) { CopyOnWriteObject *old_object = _cow_object; _cow_object = from._cow_object; - from._cow_object = NULL; + from._cow_object = nullptr; - if (old_object != (CopyOnWriteObject *)NULL) { + if (old_object != nullptr) { cache_unref_delete(old_object); } } @@ -124,9 +124,9 @@ operator = (PointerTo &&from) noexcept { // we do need to include the cache reference count. _cow_object = from.p(); _cow_object->cache_ref_only(); - from.cheat() = NULL; + from.cheat() = nullptr; - if (old_object != (CopyOnWriteObject *)NULL) { + if (old_object != nullptr) { cache_unref_delete(old_object); } } @@ -181,8 +181,8 @@ get_read_pointer(Thread *current_thread) const { */ INLINE CopyOnWriteObject *CopyOnWritePointer:: get_write_pointer() { - if (_cow_object == (CopyOnWriteObject *)NULL) { - return NULL; + if (_cow_object == nullptr) { + return nullptr; } if (_cow_object->get_cache_ref_count() > 1) { PT(CopyOnWriteObject) new_object = _cow_object->make_cow_copy(); @@ -210,7 +210,7 @@ get_unsafe_pointer() { */ bool CopyOnWritePointer:: is_null() const { - return (_cow_object == (CopyOnWriteObject *)NULL); + return (_cow_object == nullptr); } /** @@ -218,10 +218,10 @@ is_null() const { */ void CopyOnWritePointer:: clear() { - if (_cow_object != (CopyOnWriteObject *)NULL) { + if (_cow_object != nullptr) { cache_unref_delete(_cow_object); } - _cow_object = NULL; + _cow_object = nullptr; } /** @@ -230,7 +230,7 @@ clear() { */ INLINE bool CopyOnWritePointer:: test_ref_count_integrity() const { - nassertr(_cow_object != (CopyOnWriteObject *)NULL, false); + nassertr(_cow_object != nullptr, false); return _cow_object->test_ref_count_integrity(); } @@ -240,7 +240,7 @@ test_ref_count_integrity() const { */ INLINE bool CopyOnWritePointer:: test_ref_count_nonzero() const { - nassertr(_cow_object != (CopyOnWriteObject *)NULL, false); + nassertr(_cow_object != nullptr, false); return _cow_object->test_ref_count_nonzero(); } @@ -310,10 +310,10 @@ CopyOnWritePointerTo(PointerTo &&from) noexcept { // Steal the other's reference count, but because it is a regular pointer, // we do need to include the cache reference count. _cow_object = from.p(); - if (_cow_object != (CopyOnWriteObject *)NULL) { + if (_cow_object != nullptr) { _cow_object->cache_ref_only(); } - from.cheat() = NULL; + from.cheat() = nullptr; } #endif // CPPPARSER @@ -342,9 +342,9 @@ operator = (PointerTo &&from) noexcept { // we do need to include the cache reference count. _cow_object = from.p(); _cow_object->cache_ref_only(); - from.cheat() = NULL; + from.cheat() = nullptr; - if (old_object != (CopyOnWriteObject *)NULL) { + if (old_object != nullptr) { cache_unref_delete(old_object); } } diff --git a/panda/src/putil/copyOnWritePointer.cxx b/panda/src/putil/copyOnWritePointer.cxx index 5a8f1700b6..35a4aa8da0 100644 --- a/panda/src/putil/copyOnWritePointer.cxx +++ b/panda/src/putil/copyOnWritePointer.cxx @@ -24,8 +24,8 @@ */ CPT(CopyOnWriteObject) CopyOnWritePointer:: get_read_pointer(Thread *current_thread) const { - if (_cow_object == (CopyOnWriteObject *)NULL) { - return NULL; + if (_cow_object == nullptr) { + return nullptr; } MutexHolder holder(_cow_object->_lock_mutex); @@ -60,8 +60,8 @@ get_read_pointer(Thread *current_thread) const { */ PT(CopyOnWriteObject) CopyOnWritePointer:: get_write_pointer() { - if (_cow_object == (CopyOnWriteObject *)NULL) { - return NULL; + if (_cow_object == nullptr) { + return nullptr; } Thread *current_thread = Thread::get_current_thread(); @@ -79,7 +79,7 @@ get_write_pointer() { } if (_cow_object->_lock_status == CopyOnWriteObject::LS_locked_read) { - nassertr(_cow_object->get_ref_count() > _cow_object->get_cache_ref_count(), NULL); + nassertr(_cow_object->get_ref_count() > _cow_object->get_cache_ref_count(), nullptr); if (util_cat.is_debug()) { util_cat.debug() diff --git a/panda/src/putil/copyOnWritePointer.h b/panda/src/putil/copyOnWritePointer.h index a98599361a..24e0ffff64 100644 --- a/panda/src/putil/copyOnWritePointer.h +++ b/panda/src/putil/copyOnWritePointer.h @@ -30,7 +30,7 @@ */ class EXPCL_PANDA_PUTIL CopyOnWritePointer { public: - INLINE CopyOnWritePointer(CopyOnWriteObject *object = NULL); + INLINE CopyOnWritePointer(CopyOnWriteObject *object = nullptr); INLINE CopyOnWritePointer(const CopyOnWritePointer ©); INLINE CopyOnWritePointer(CopyOnWritePointer &&from) noexcept; INLINE CopyOnWritePointer(PointerTo &&from) noexcept; @@ -78,7 +78,7 @@ public: #ifndef CPPPARSER typedef T To; - INLINE CopyOnWritePointerTo(To *object = NULL); + INLINE CopyOnWritePointerTo(To *object = nullptr); INLINE CopyOnWritePointerTo(const CopyOnWritePointerTo ©); INLINE CopyOnWritePointerTo(CopyOnWritePointerTo &&from) noexcept; INLINE CopyOnWritePointerTo(PointerTo &&from) noexcept; diff --git a/panda/src/putil/datagramInputFile.I b/panda/src/putil/datagramInputFile.I index 152aa3505e..0c4ba21cc3 100644 --- a/panda/src/putil/datagramInputFile.I +++ b/panda/src/putil/datagramInputFile.I @@ -18,7 +18,7 @@ INLINE DatagramInputFile:: DatagramInputFile() { _error = false; _read_first_datagram = false; - _in = (istream *)NULL; + _in = nullptr; _owns_in = false; _timestamp = 0; } @@ -46,6 +46,6 @@ open(const Filename &filename) { INLINE istream &DatagramInputFile:: get_stream() { static std::ifstream null_stream; - nassertr(_in != NULL, null_stream); + nassertr(_in != nullptr, null_stream); return *_in; } diff --git a/panda/src/putil/datagramInputFile.cxx b/panda/src/putil/datagramInputFile.cxx index 4fc9b47ffb..466d78006b 100644 --- a/panda/src/putil/datagramInputFile.cxx +++ b/panda/src/putil/datagramInputFile.cxx @@ -38,13 +38,13 @@ open(const FileReference *file) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); _vfile = vfs->get_file(_filename); - if (_vfile == (VirtualFile *)NULL) { + if (_vfile == nullptr) { // No such file. return false; } _timestamp = _vfile->get_timestamp(); _in = _vfile->open_read_file(true); - _owns_in = (_in != (istream *)NULL); + _owns_in = (_in != nullptr); return _owns_in && !_in->fail(); } @@ -80,7 +80,7 @@ close() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->close_read_file(_in); } - _in = (istream *)NULL; + _in = nullptr; _owns_in = false; _file.clear(); @@ -100,10 +100,10 @@ close() { bool DatagramInputFile:: read_header(string &header, size_t num_bytes) { nassertr(!_read_first_datagram, false); - nassertr(_in != (istream *)NULL, false); + nassertr(_in != nullptr, false); char *buffer = (char *)alloca(num_bytes); - nassertr(buffer != (char *)NULL, false); + nassertr(buffer != nullptr, false); _in->read(buffer, num_bytes); if (_in->fail() || _in->eof()) { @@ -121,7 +121,7 @@ read_header(string &header, size_t num_bytes) { */ bool DatagramInputFile:: get_datagram(Datagram &data) { - nassertr(_in != (istream *)NULL, false); + nassertr(_in != nullptr, false); _read_first_datagram = true; // First, get the size of the upcoming datagram. @@ -201,7 +201,7 @@ get_datagram(Datagram &data) { */ bool DatagramInputFile:: save_datagram(SubfileInfo &info) { - nassertr(_in != (istream *)NULL, false); + nassertr(_in != nullptr, false); _read_first_datagram = true; // First, get the size of the upcoming datagram. @@ -219,7 +219,7 @@ save_datagram(SubfileInfo &info) { // If this stream is file-based, we can just point the SubfileInfo directly // into this file. - if (_file != (FileReference *)NULL) { + if (_file != nullptr) { info = SubfileInfo(_file, _in->tellg(), num_bytes); _in->seekg(num_bytes, ios::cur); return true; @@ -279,7 +279,7 @@ save_datagram(SubfileInfo &info) { */ bool DatagramInputFile:: is_eof() { - return _in != (istream *)NULL ? _in->eof() : true; + return _in != nullptr ? _in->eof() : true; } /** @@ -287,7 +287,7 @@ is_eof() { */ bool DatagramInputFile:: is_error() { - if (_in == (istream *)NULL) { + if (_in == nullptr) { return true; } @@ -343,7 +343,7 @@ get_vfile() { */ streampos DatagramInputFile:: get_file_pos() { - if (_in == (istream *)NULL) { + if (_in == nullptr) { return 0; } return _in->tellg(); diff --git a/panda/src/putil/datagramOutputFile.I b/panda/src/putil/datagramOutputFile.I index 54167ae967..5bfee6fc9c 100644 --- a/panda/src/putil/datagramOutputFile.I +++ b/panda/src/putil/datagramOutputFile.I @@ -18,7 +18,7 @@ INLINE DatagramOutputFile:: DatagramOutputFile() { _error = false; _wrote_first_datagram = false; - _out = (ostream *)NULL; + _out = nullptr; _owns_out = false; } @@ -45,6 +45,6 @@ open(const Filename &filename) { INLINE ostream &DatagramOutputFile:: get_stream() { static std::ofstream null_stream; - nassertr(_out != NULL, null_stream); + nassertr(_out != nullptr, null_stream); return *_out; } diff --git a/panda/src/putil/datagramOutputFile.cxx b/panda/src/putil/datagramOutputFile.cxx index cd9a1af2fc..24533ad8b0 100644 --- a/panda/src/putil/datagramOutputFile.cxx +++ b/panda/src/putil/datagramOutputFile.cxx @@ -32,12 +32,12 @@ open(const FileReference *file) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); _vfile = vfs->create_file(_filename); - if (_vfile == (VirtualFile *)NULL) { + if (_vfile == nullptr) { // No such file. return false; } _out = _vfile->open_write_file(true, true); - _owns_out = (_out != (ostream *)NULL); + _owns_out = (_out != nullptr); return _owns_out && !_out->fail(); } @@ -72,7 +72,7 @@ close() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->close_write_file(_out); } - _out = (ostream *)NULL; + _out = nullptr; _owns_out = false; _file.clear(); @@ -90,7 +90,7 @@ close() { */ bool DatagramOutputFile:: write_header(const string &header) { - nassertr(_out != (ostream *)NULL, false); + nassertr(_out != nullptr, false); nassertr(!_wrote_first_datagram, false); _out->write(header.data(), header.size()); @@ -104,7 +104,7 @@ write_header(const string &header) { */ bool DatagramOutputFile:: put_datagram(const Datagram &data) { - nassertr(_out != (ostream *)NULL, false); + nassertr(_out != nullptr, false); _wrote_first_datagram = true; // First, write the size of the upcoming datagram. @@ -137,16 +137,16 @@ put_datagram(const Datagram &data) { */ bool DatagramOutputFile:: copy_datagram(SubfileInfo &result, const Filename &filename) { - nassertr(_out != (ostream *)NULL, false); + nassertr(_out != nullptr, false); _wrote_first_datagram = true; VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); PT(VirtualFile) vfile = vfs->get_file(filename); - if (vfile == NULL) { + if (vfile == nullptr) { return false; } istream *in = vfile->open_read_file(true); - if (in == NULL) { + if (in == nullptr) { return false; } @@ -206,7 +206,7 @@ copy_datagram(SubfileInfo &result, const Filename &filename) { */ bool DatagramOutputFile:: copy_datagram(SubfileInfo &result, const SubfileInfo &source) { - nassertr(_out != (ostream *)NULL, false); + nassertr(_out != nullptr, false); _wrote_first_datagram = true; pifstream in; @@ -261,7 +261,7 @@ copy_datagram(SubfileInfo &result, const SubfileInfo &source) { */ bool DatagramOutputFile:: is_error() { - if (_out == (ostream *)NULL) { + if (_out == nullptr) { return true; } @@ -277,7 +277,7 @@ is_error() { */ void DatagramOutputFile:: flush() { - if (_out != (ostream *)NULL) { + if (_out != nullptr) { _out->flush(); } } @@ -311,7 +311,7 @@ get_file() { */ streampos DatagramOutputFile:: get_file_pos() { - if (_out == (ostream *)NULL) { + if (_out == nullptr) { return 0; } return _out->tellp(); diff --git a/panda/src/putil/factory.h b/panda/src/putil/factory.h index 4520153911..b7751feb30 100644 --- a/panda/src/putil/factory.h +++ b/panda/src/putil/factory.h @@ -50,7 +50,7 @@ public: const FactoryParams ¶ms = FactoryParams()); INLINE void register_factory(TypeHandle handle, CreateFunc *func, - void *user_data = NULL); + void *user_data = nullptr); }; #include "factory.I" diff --git a/panda/src/putil/factoryBase.I b/panda/src/putil/factoryBase.I index 3452a9758c..199d3f8d5a 100644 --- a/panda/src/putil/factoryBase.I +++ b/panda/src/putil/factoryBase.I @@ -23,7 +23,7 @@ INLINE TypedObject *FactoryBase:: make_instance(const string &type_name, const FactoryParams ¶ms) { TypeHandle handle = TypeRegistry::ptr()->find_type(type_name); - nassertr(handle != TypeHandle::none(), NULL); + nassertr(handle != TypeHandle::none(), nullptr); return make_instance(handle, params); } @@ -42,7 +42,7 @@ INLINE TypedObject *FactoryBase:: make_instance_more_general(const string &type_name, const FactoryParams ¶ms) { TypeHandle handle = TypeRegistry::ptr()->find_type(type_name); - nassertr(handle != TypeHandle::none(), NULL); + nassertr(handle != TypeHandle::none(), nullptr); return make_instance_more_general(handle, params); } diff --git a/panda/src/putil/factoryBase.cxx b/panda/src/putil/factoryBase.cxx index d34035177c..bfb803da39 100644 --- a/panda/src/putil/factoryBase.cxx +++ b/panda/src/putil/factoryBase.cxx @@ -37,10 +37,10 @@ FactoryBase:: */ TypedObject *FactoryBase:: make_instance(TypeHandle handle, const FactoryParams ¶ms) { - TypedObject *instance = (TypedObject *)NULL; + TypedObject *instance = nullptr; instance = make_instance_exact(handle, params); - if (instance == (TypedObject *)NULL) { + if (instance == nullptr) { // Can't create an exact instance; try for a derived type. instance = make_instance_more_specific(handle, params); } @@ -49,7 +49,7 @@ make_instance(TypeHandle handle, const FactoryParams ¶ms) { util_cat.debug() << "make_instance(" << handle << ", params) returns " << (void *)instance; - if (instance != (TypedObject *)NULL) { + if (instance != nullptr) { util_cat.debug(false) << ", of type " << instance->get_type(); } @@ -67,15 +67,15 @@ TypedObject *FactoryBase:: make_instance_more_general(TypeHandle handle, const FactoryParams ¶ms) { TypedObject *object = make_instance_exact(handle, params); - if (object == (TypedObject *)NULL) { + if (object == nullptr) { // Recursively search through the entire inheritance tree until we find // something we know about. if (handle.get_num_parent_classes() == 0) { - return NULL; + return nullptr; } int num_parents = handle.get_num_parent_classes(); - for (int i = 0; i < num_parents && object == (TypedObject *)NULL; i++) { + for (int i = 0; i < num_parents && object == nullptr; i++) { object = make_instance_more_general(handle.get_parent_class(i), params); } } @@ -84,7 +84,7 @@ make_instance_more_general(TypeHandle handle, const FactoryParams ¶ms) { util_cat.debug() << "make_instance(" << handle << ", params) returns " << (void *)object; - if (object != (TypedObject *)NULL) { + if (object != nullptr) { util_cat.debug(false) << ", of type " << object->get_type(); } @@ -134,7 +134,7 @@ find_registered_type(TypeHandle handle) { void FactoryBase:: register_factory(TypeHandle handle, BaseCreateFunc *func, void *user_data) { nassertv(handle != TypeHandle::none()); - nassertv(func != (BaseCreateFunc *)NULL); + nassertv(func != nullptr); Creator creator; creator._func = func; @@ -243,11 +243,11 @@ TypedObject *FactoryBase:: make_instance_exact(TypeHandle handle, FactoryParams params) { Creators::const_iterator ci = _creators.find(handle); if (ci == _creators.end()) { - return NULL; + return nullptr; } Creator creator = (*ci).second; - nassertr(creator._func != (BaseCreateFunc *)NULL, NULL); + nassertr(creator._func != nullptr, nullptr); params._user_data = creator._user_data; return (*creator._func)(params); } @@ -267,7 +267,7 @@ make_instance_more_specific(TypeHandle handle, FactoryParams params) { TypeHandle ptype = (*pi); if (ptype.is_derived_from(handle)) { TypedObject *object = make_instance_exact(ptype, params); - if (object != (TypedObject *)NULL) { + if (object != nullptr) { return object; } } @@ -280,14 +280,14 @@ make_instance_more_specific(TypeHandle handle, FactoryParams params) { TypeHandle ctype = (*ci).first; if (ctype.is_derived_from(handle)) { Creator creator = (*ci).second; - nassertr(creator._func != (BaseCreateFunc *)NULL, NULL); + nassertr(creator._func != nullptr, nullptr); params._user_data = creator._user_data; TypedObject *object = (*creator._func)(params); - if (object != (TypedObject *)NULL) { + if (object != nullptr) { return object; } } } - return NULL; + return nullptr; } diff --git a/panda/src/putil/factoryBase.h b/panda/src/putil/factoryBase.h index 6fcfc2f54f..73d0e8c6e5 100644 --- a/panda/src/putil/factoryBase.h +++ b/panda/src/putil/factoryBase.h @@ -56,7 +56,7 @@ public: TypeHandle find_registered_type(TypeHandle handle); - void register_factory(TypeHandle handle, BaseCreateFunc *func, void *user_data = NULL); + void register_factory(TypeHandle handle, BaseCreateFunc *func, void *user_data = nullptr); int get_num_types() const; TypeHandle get_type(int n) const; diff --git a/panda/src/putil/factoryParams.I b/panda/src/putil/factoryParams.I index 04b7d2c634..b62406861a 100644 --- a/panda/src/putil/factoryParams.I +++ b/panda/src/putil/factoryParams.I @@ -17,7 +17,7 @@ * */ INLINE FactoryParams:: -FactoryParams() : _user_data(NULL) { +FactoryParams() : _user_data(nullptr) { } /** @@ -70,8 +70,8 @@ template bool get_param_into(ParamType *&pointer, const FactoryParams ¶ms) { FactoryParam *param = params.get_param_of_type(ParamType::get_class_type()); - if (param == (FactoryParam *)NULL) { - pointer = NULL; + if (param == nullptr) { + pointer = nullptr; return false; } DCAST_INTO_R(pointer, param, false); diff --git a/panda/src/putil/factoryParams.cxx b/panda/src/putil/factoryParams.cxx index 6224f8b94e..362ec097c1 100644 --- a/panda/src/putil/factoryParams.cxx +++ b/panda/src/putil/factoryParams.cxx @@ -18,7 +18,7 @@ */ void FactoryParams:: add_param(FactoryParam *param) { - nassertv(param != (FactoryParam *)NULL); + nassertv(param != nullptr); _params.push_back(param); } @@ -43,7 +43,7 @@ get_num_params() const { */ FactoryParam *FactoryParams:: get_param(int n) const { - nassertr(n >= 0 && n < (int)_params.size(), NULL); + nassertr(n >= 0 && n < (int)_params.size(), nullptr); return DCAST(FactoryParam, _params[n]); } @@ -59,8 +59,8 @@ get_param_of_type(TypeHandle type) const { // First, search for the exact match. for (pi = _params.begin(); pi != _params.end(); ++pi) { FactoryParam *param; - DCAST_INTO_R(param, *pi, NULL); - nassertr(param != (FactoryParam *)NULL, NULL); + DCAST_INTO_R(param, *pi, nullptr); + nassertr(param != nullptr, nullptr); if (param->is_exact_type(type)) { return param; @@ -70,13 +70,13 @@ get_param_of_type(TypeHandle type) const { // Now, search for a derived match. for (pi = _params.begin(); pi != _params.end(); ++pi) { FactoryParam *param; - DCAST_INTO_R(param, *pi, NULL); - nassertr(param != (FactoryParam *)NULL, NULL); + DCAST_INTO_R(param, *pi, nullptr); + nassertr(param != nullptr, nullptr); if (param->is_of_type(type)) { return param; } } - return NULL; + return nullptr; } diff --git a/panda/src/putil/globalPointerRegistry.I b/panda/src/putil/globalPointerRegistry.I index 10dc289e9b..a43f3fd98d 100644 --- a/panda/src/putil/globalPointerRegistry.I +++ b/panda/src/putil/globalPointerRegistry.I @@ -49,7 +49,7 @@ clear_pointer(TypeHandle type) { */ INLINE GlobalPointerRegistry *GlobalPointerRegistry:: get_global_ptr() { - if (_global_ptr == (GlobalPointerRegistry *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new GlobalPointerRegistry; } return _global_ptr; diff --git a/panda/src/putil/globalPointerRegistry.cxx b/panda/src/putil/globalPointerRegistry.cxx index 40e062d9c0..622a666f6e 100644 --- a/panda/src/putil/globalPointerRegistry.cxx +++ b/panda/src/putil/globalPointerRegistry.cxx @@ -34,7 +34,7 @@ ns_get_pointer(TypeHandle type) const { Pointers::const_iterator pi; pi = _pointers.find(type); if (pi == _pointers.end()) { - return (void *)NULL; + return nullptr; } return (*pi).second; @@ -51,7 +51,7 @@ ns_store_pointer(TypeHandle type, void *ptr) { util_cat->error() << "GlobalPointerRegistry::store_pointer() called on empty TypeHandle\n"; } - if (ptr == (void *)NULL) { + if (ptr == nullptr) { util_cat->error() << "Invalid attempt to store a NULL pointer for " << type << "\n"; clear_pointer(type); diff --git a/panda/src/putil/linkedListNode.I b/panda/src/putil/linkedListNode.I index e722108702..faed3b5c96 100644 --- a/panda/src/putil/linkedListNode.I +++ b/panda/src/putil/linkedListNode.I @@ -17,8 +17,8 @@ INLINE LinkedListNode:: LinkedListNode() { #ifndef NDEBUG - _next = NULL; - _prev = NULL; + _next = nullptr; + _prev = nullptr; #endif } @@ -38,7 +38,7 @@ LinkedListNode(bool) { */ INLINE LinkedListNode:: ~LinkedListNode() { - nassertv((_next == NULL && _prev == NULL) || (_next == this && _prev == this)); + nassertv((_next == nullptr && _prev == nullptr) || (_next == this && _prev == this)); } /** @@ -48,7 +48,7 @@ INLINE LinkedListNode:: */ INLINE bool LinkedListNode:: is_on_list() const { - return (_next != NULL); + return (_next != nullptr); } /** @@ -56,13 +56,13 @@ is_on_list() const { */ INLINE void LinkedListNode:: remove_from_list() { - nassertv(_prev != NULL && _next != NULL); + nassertv(_prev != nullptr && _next != nullptr); nassertv(_prev->_next == this && _next->_prev == this); _prev->_next = _next; _next->_prev = _prev; #ifndef NDEBUG - _next = NULL; - _prev = NULL; + _next = nullptr; + _prev = nullptr; #endif } @@ -72,9 +72,9 @@ remove_from_list() { */ INLINE void LinkedListNode:: insert_before(LinkedListNode *node) { - nassertv(node->_prev != NULL && node->_prev->_next == node && node->_next->_prev == node); - nassertv(_prev == (LinkedListNode *)NULL && - _next == (LinkedListNode *)NULL); + nassertv(node->_prev != nullptr && node->_prev->_next == node && node->_next->_prev == node); + nassertv(_prev == nullptr && + _next == nullptr); _prev = node->_prev; _next = node; _prev->_next = this; @@ -87,9 +87,9 @@ insert_before(LinkedListNode *node) { */ INLINE void LinkedListNode:: insert_after(LinkedListNode *node) { - nassertv(node->_prev != NULL && node->_prev->_next == node && node->_next->_prev == node); - nassertv(_prev == (LinkedListNode *)NULL && - _next == (LinkedListNode *)NULL); + nassertv(node->_prev != nullptr && node->_prev->_next == node && node->_next->_prev == node); + nassertv(_prev == nullptr && + _next == nullptr); _next = node->_next; _prev = node; _next->_prev = this; diff --git a/panda/src/putil/load_prc_file.cxx b/panda/src/putil/load_prc_file.cxx index 5663c49038..7da6526c9c 100644 --- a/panda/src/putil/load_prc_file.cxx +++ b/panda/src/putil/load_prc_file.cxx @@ -44,10 +44,10 @@ load_prc_file(const Filename &filename) { vfs->resolve_filename(path, get_model_path()); istream *file = vfs->open_read_file(path, true); - if (file == (istream *)NULL) { + if (file == nullptr) { util_cat.error() << "Unable to open " << path << "\n"; - return NULL; + return nullptr; } util_cat.info() @@ -64,7 +64,7 @@ load_prc_file(const Filename &filename) { util_cat.info() << "Unable to read " << path << "\n"; cp_mgr->delete_explicit_page(page); - return NULL; + return nullptr; } } @@ -94,7 +94,7 @@ load_prc_file_data(const string &name, const string &data) { util_cat.info() << "Unable to read explicit prc data " << name << "\n"; cp_mgr->delete_explicit_page(page); - return NULL; + return nullptr; } } diff --git a/panda/src/putil/loaderOptions.cxx b/panda/src/putil/loaderOptions.cxx index 7f57d77fef..167d977cd7 100644 --- a/panda/src/putil/loaderOptions.cxx +++ b/panda/src/putil/loaderOptions.cxx @@ -29,13 +29,13 @@ LoaderOptions(int flags) : static ConfigVariableBool *preload_textures; static ConfigVariableBool *preload_simple_textures; static ConfigVariableBool *compressed_textures; - if (preload_textures == NULL) { + if (preload_textures == nullptr) { preload_textures = new ConfigVariableBool("preload-textures", true); } - if (preload_simple_textures == NULL) { + if (preload_simple_textures == nullptr) { preload_simple_textures = new ConfigVariableBool("preload-simple-textures", false); } - if (compressed_textures == NULL) { + if (compressed_textures == nullptr) { compressed_textures = new ConfigVariableBool("compressed-textures", false); } diff --git a/panda/src/putil/paramValue.I b/panda/src/putil/paramValue.I index f446b88dad..735e4f2ca4 100644 --- a/panda/src/putil/paramValue.I +++ b/panda/src/putil/paramValue.I @@ -43,7 +43,7 @@ ParamTypedRefCount(const TypedReferenceCount *value) : */ INLINE TypeHandle ParamTypedRefCount:: get_value_type() const { - if (_value == NULL) { + if (_value == nullptr) { return TypeHandle::none(); } else { return _value->get_type(); diff --git a/panda/src/putil/paramValue.cxx b/panda/src/putil/paramValue.cxx index 6937a27faa..309f8885bd 100644 --- a/panda/src/putil/paramValue.cxx +++ b/panda/src/putil/paramValue.cxx @@ -57,7 +57,7 @@ ParamTypedRefCount:: */ void ParamTypedRefCount:: output(ostream &out) const { - if (_value == (TypedReferenceCount *)NULL) { + if (_value == nullptr) { out << "(empty)"; } else { diff --git a/panda/src/putil/pythonCallbackObject.cxx b/panda/src/putil/pythonCallbackObject.cxx index b1917c6e0e..e8ef005c2e 100644 --- a/panda/src/putil/pythonCallbackObject.cxx +++ b/panda/src/putil/pythonCallbackObject.cxx @@ -111,7 +111,7 @@ do_callback(CallbackData *cbdata) { */ void PythonCallbackObject:: do_python_callback(CallbackData *cbdata) { - nassertv(cbdata != NULL); + nassertv(cbdata != nullptr); // Wrap the cbdata up in a Python object, then put it in a tuple, for the // argument list. @@ -124,7 +124,7 @@ do_python_callback(CallbackData *cbdata) { PyObject *result = PythonThread::call_python_func(_function, args); Py_DECREF(args); - if (result == (PyObject *)NULL) { + if (result == nullptr) { if (PyErr_Occurred() != PyExc_SystemExit) { util_cat.error() << "Exception occurred in " << *this << "\n"; diff --git a/panda/src/putil/test_bam.cxx b/panda/src/putil/test_bam.cxx index deef264ce1..a6103d5c5f 100644 --- a/panda/src/putil/test_bam.cxx +++ b/panda/src/putil/test_bam.cxx @@ -79,9 +79,9 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) void Person:: print_relationships(){ nout << "My name is " << _name << endl; - if (_bro != NULL) + if (_bro != nullptr) nout << "My brother is " << _bro->name() << endl; - if (_sis != NULL) + if (_sis != nullptr) nout << "My sister is " << _sis->name() << endl; } @@ -137,9 +137,9 @@ setDaughter(Child* daughter) void Parent:: print_relationships(){ Person::print_relationships(); - if (_son != NULL) + if (_son != nullptr) nout << "My son is " << _son->name() << endl; - if (_daughter != NULL) + if (_daughter != nullptr) nout << "My daughter is " << _daughter->name() << endl; } @@ -197,8 +197,8 @@ setMother(Parent* mom) void Child:: print_relationships(){ Person::print_relationships(); - if (_dad != NULL) + if (_dad != nullptr) nout << "My dad is " << _dad->name() << endl; - if (_mom != NULL) + if (_mom != nullptr) nout << "My mom is " << _mom->name() << endl; } diff --git a/panda/src/putil/test_bam.h b/panda/src/putil/test_bam.h index 557b9ba6b4..b49fca965a 100644 --- a/panda/src/putil/test_bam.h +++ b/panda/src/putil/test_bam.h @@ -54,7 +54,7 @@ private: public: Person() {} Person(const string &name, const sex Gender) : - _name(name), myGender(Gender), _bro((Person*)NULL), _sis((Person*)NULL) { + _name(name), myGender(Gender), _bro(nullptr), _sis(nullptr) { } virtual ~Person() { diff --git a/panda/src/putil/typedWritable.I b/panda/src/putil/typedWritable.I index 21f86f03a4..5940fd9de3 100644 --- a/panda/src/putil/typedWritable.I +++ b/panda/src/putil/typedWritable.I @@ -15,14 +15,14 @@ * */ INLINE TypedWritable:: -TypedWritable() : _bam_writers(NULL) { +TypedWritable() : _bam_writers(nullptr) { } /** * */ INLINE TypedWritable:: -TypedWritable(const TypedWritable &) : _bam_writers(NULL) { +TypedWritable(const TypedWritable &) : _bam_writers(nullptr) { } /** diff --git a/panda/src/putil/typedWritable.cxx b/panda/src/putil/typedWritable.cxx index 7cc9d93cbd..d0e5058538 100644 --- a/panda/src/putil/typedWritable.cxx +++ b/panda/src/putil/typedWritable.cxx @@ -19,7 +19,7 @@ #include "bam.h" TypeHandle TypedWritable::_type_handle; -TypedWritable* const TypedWritable::Null = (TypedWritable*)0L; +TypedWritable* const TypedWritable::Null = nullptr; /** * @@ -30,15 +30,15 @@ TypedWritable:: BamWriterLink *link; do { link = (BamWriterLink *)AtomicAdjust::get_ptr(_bam_writers); - if (link == (BamWriterLink *)NULL) { + if (link == nullptr) { // List is unlocked and empty - no writers to remove. return; } link = (BamWriterLink *)(((uintptr_t)link) & ~(uintptr_t)0x1); } while (link != AtomicAdjust:: - compare_and_exchange_ptr(_bam_writers, (void *)link, (void *)NULL)); + compare_and_exchange_ptr(_bam_writers, (void *)link, nullptr)); - while (link != (BamWriterLink *)NULL) { + while (link != nullptr) { BamWriterLink *next_link = link->_next; link->_writer->object_destructs(this); delete link; @@ -119,7 +119,7 @@ finalize(BamReader *) { */ ReferenceCount *TypedWritable:: as_reference_count() { - return NULL; + return nullptr; } /** @@ -192,7 +192,7 @@ decode_raw_from_bam_stream(TypedWritable *&ptr, ReferenceCount *&ref_ptr, DatagramBuffer buffer(move(data)); - if (reader == NULL) { + if (reader == nullptr) { // Create a local reader. string head; if (!buffer.read_header(head, _bam_header.size())) { @@ -216,7 +216,7 @@ decode_raw_from_bam_stream(TypedWritable *&ptr, ReferenceCount *&ref_ptr, return false; } - if (ref_ptr == NULL) { + if (ref_ptr == nullptr) { // Can't support non-reference-counted objects. return false; } @@ -229,25 +229,25 @@ decode_raw_from_bam_stream(TypedWritable *&ptr, ReferenceCount *&ref_ptr, // Use the existing reader. reader->set_source(&buffer); if (!reader->read_object(ptr, ref_ptr)) { - reader->set_source(NULL); + reader->set_source(nullptr); return false; } if (!reader->resolve()) { - reader->set_source(NULL); + reader->set_source(nullptr); return false; } - if (ref_ptr == NULL) { + if (ref_ptr == nullptr) { // Can't support non-reference-counted objects. - reader->set_source(NULL); + reader->set_source(nullptr); return false; } // This BamReader isn't going away, but we have to balance the unref() // below. ref_ptr->ref(); - reader->set_source(NULL); + reader->set_source(nullptr); } @@ -265,7 +265,7 @@ decode_raw_from_bam_stream(TypedWritable *&ptr, ReferenceCount *&ref_ptr, */ void TypedWritable:: add_bam_writer(BamWriter *writer) { - nassertv(writer != (BamWriter *)NULL); + nassertv(writer != nullptr); BamWriterLink *begin; BamWriterLink *new_link = new BamWriterLink; @@ -289,7 +289,7 @@ add_bam_writer(BamWriter *writer) { */ void TypedWritable:: remove_bam_writer(BamWriter *writer) { - nassertv(writer != (BamWriter *)NULL); + nassertv(writer != nullptr); BamWriterLink *begin; @@ -298,7 +298,7 @@ remove_bam_writer(BamWriter *writer) { do { begin = (BamWriterLink *)AtomicAdjust::get_ptr(_bam_writers); begin = (BamWriterLink *)(((uintptr_t)begin) & ~(uintptr_t)0x1); - if (begin == NULL) { + if (begin == nullptr) { // The list is empty, nothing to remove. return; } @@ -307,21 +307,21 @@ remove_bam_writer(BamWriter *writer) { (void *)((uintptr_t)begin | (uintptr_t)0x1))); // Find the writer in the list. - BamWriterLink *prev_link = (BamWriterLink *)NULL; + BamWriterLink *prev_link = nullptr; BamWriterLink *link = begin; - while (link != NULL && link->_writer != writer) { + while (link != nullptr && link->_writer != writer) { prev_link = link; link = link->_next; } - if (link == (BamWriterLink *)NULL) { + if (link == nullptr) { // Not found. Just unlock and leave. _bam_writers = (void *)begin; return; } - if (prev_link == (BamWriterLink *)NULL) { + if (prev_link == nullptr) { // It's the first link. Replace and unlock in one atomic op. _bam_writers = (void *)link->_next; } else { diff --git a/panda/src/putil/typedWritable.h b/panda/src/putil/typedWritable.h index b13a1991fb..2dbdc3d967 100644 --- a/panda/src/putil/typedWritable.h +++ b/panda/src/putil/typedWritable.h @@ -64,11 +64,11 @@ PUBLISHED: EXTENSION(PyObject *__reduce_persist__(PyObject *self, PyObject *pickler) const); INLINE vector_uchar encode_to_bam_stream() const; - bool encode_to_bam_stream(vector_uchar &data, BamWriter *writer = NULL) const; + bool encode_to_bam_stream(vector_uchar &data, BamWriter *writer = nullptr) const; static bool decode_raw_from_bam_stream(TypedWritable *&ptr, ReferenceCount *&ref_ptr, vector_uchar data, - BamReader *reader = NULL); + BamReader *reader = nullptr); private: void add_bam_writer(BamWriter *writer); diff --git a/panda/src/putil/typedWritable_ext.cxx b/panda/src/putil/typedWritable_ext.cxx index efaaac63fb..c736a6fa14 100644 --- a/panda/src/putil/typedWritable_ext.cxx +++ b/panda/src/putil/typedWritable_ext.cxx @@ -30,7 +30,7 @@ extern Dtool_PyTypedObject Dtool_BamWriter; */ PyObject *Extension:: __reduce__(PyObject *self) const { - return __reduce_persist__(self, NULL); + return __reduce_persist__(self, nullptr); } /** @@ -51,19 +51,19 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { // Check that we have a decode_from_bam_stream python method. If not, we // can't use this interface. PyObject *method = PyObject_GetAttrString(self, "decode_from_bam_stream"); - if (method == NULL) { + if (method == nullptr) { ostringstream stream; stream << "Cannot pickle objects of type " << _this->get_type() << "\n"; string message = stream.str(); PyErr_SetString(PyExc_TypeError, message.c_str()); - return NULL; + return nullptr; } Py_DECREF(method); - BamWriter *writer = NULL; - if (pickler != NULL) { + BamWriter *writer = nullptr; + if (pickler != nullptr) { PyObject *py_writer = PyObject_GetAttrString(pickler, "bamWriter"); - if (py_writer == NULL) { + if (py_writer == nullptr) { // It's OK if there's no bamWriter. PyErr_Clear(); } else { @@ -79,35 +79,35 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { stream << "Could not bamify object of type " << _this->get_type() << "\n"; string message = stream.str(); PyErr_SetString(PyExc_TypeError, message.c_str()); - return NULL; + return nullptr; } // Start by getting this class object. PyObject *this_class = PyObject_Type(self); - if (this_class == NULL) { - return NULL; + if (this_class == nullptr) { + return nullptr; } PyObject *func; - if (writer != NULL) { + if (writer != nullptr) { // The modified pickle support: call the "persistent" version of this // function, which receives the unpickler itself as an additional // parameter. func = find_global_decode(this_class, "py_decode_TypedWritable_from_bam_stream_persist"); - if (func == NULL) { + if (func == nullptr) { PyErr_SetString(PyExc_TypeError, "Couldn't find py_decode_TypedWritable_from_bam_stream_persist()"); Py_DECREF(this_class); - return NULL; + return nullptr; } } else { // The traditional pickle support: call the non-persistent version of this // function. func = find_global_decode(this_class, "py_decode_TypedWritable_from_bam_stream"); - if (func == NULL) { + if (func == nullptr) { PyErr_SetString(PyExc_TypeError, "Couldn't find py_decode_TypedWritable_from_bam_stream()"); Py_DECREF(this_class); - return NULL; + return nullptr; } } @@ -135,15 +135,15 @@ PyObject *Extension:: find_global_decode(PyObject *this_class, const char *func_name) { // Get the module in which BamWriter is defined. PyObject *module_name = PyObject_GetAttrString((PyObject *)&Dtool_BamWriter, "__module__"); - if (module_name != NULL) { + if (module_name != nullptr) { // borrowed reference PyObject *sys_modules = PyImport_GetModuleDict(); - if (sys_modules != NULL) { + if (sys_modules != nullptr) { // borrowed reference PyObject *module = PyDict_GetItem(sys_modules, module_name); - if (module != NULL) { + if (module != nullptr) { PyObject *func = PyObject_GetAttrString(module, (char *)func_name); - if (func != NULL) { + if (func != nullptr) { Py_DECREF(module_name); return func; } @@ -153,15 +153,15 @@ find_global_decode(PyObject *this_class, const char *func_name) { } PyObject *bases = PyObject_GetAttrString(this_class, "__bases__"); - if (bases != NULL) { + if (bases != nullptr) { if (PySequence_Check(bases)) { Py_ssize_t size = PySequence_Size(bases); for (Py_ssize_t i = 0; i < size; ++i) { PyObject *base = PySequence_GetItem(bases, i); - if (base != NULL) { + if (base != nullptr) { PyObject *func = find_global_decode(base, func_name); Py_DECREF(base); - if (func != NULL) { + if (func != nullptr) { Py_DECREF(bases); return func; } @@ -171,7 +171,7 @@ find_global_decode(PyObject *this_class, const char *func_name) { Py_DECREF(bases); } - return NULL; + return nullptr; } /** @@ -197,10 +197,10 @@ py_decode_TypedWritable_from_bam_stream(PyObject *this_class, const vector_uchar PyObject * py_decode_TypedWritable_from_bam_stream_persist(PyObject *pickler, PyObject *this_class, const vector_uchar &data) { - PyObject *py_reader = NULL; - if (pickler != NULL) { + PyObject *py_reader = nullptr; + if (pickler != nullptr) { py_reader = PyObject_GetAttrString(pickler, "bamReader"); - if (py_reader == NULL) { + if (py_reader == nullptr) { // It's OK if there's no bamReader. PyErr_Clear(); } @@ -242,7 +242,7 @@ py_decode_TypedWritable_from_bam_stream_persist(PyObject *pickler, PyObject *thi if (result == Py_None) { Py_DECREF(result); PyErr_SetString(PyExc_ValueError, "Could not unpack bam stream"); - return NULL; + return nullptr; } return result; diff --git a/panda/src/putil/weakKeyHashMap.I b/panda/src/putil/weakKeyHashMap.I index 514818a9be..6801df4ad1 100644 --- a/panda/src/putil/weakKeyHashMap.I +++ b/panda/src/putil/weakKeyHashMap.I @@ -17,8 +17,8 @@ template INLINE WeakKeyHashMap:: WeakKeyHashMap() : - _table(NULL), - _deleted_chain(NULL), + _table(nullptr), + _deleted_chain(nullptr), _table_size(0), _num_entries(0) { @@ -196,8 +196,8 @@ clear() { } _deleted_chain->deallocate(_table, TypeHandle::none()); - _table = NULL; - _deleted_chain = NULL; + _table = nullptr; + _deleted_chain = nullptr; _table_size = 0; _num_entries = 0; } @@ -588,7 +588,7 @@ expand_table() { // Double the table size. size_t old_table_size = old_map._table_size; _table_size = (old_table_size << 1); - nassertv(_table == NULL); + nassertv(_table == nullptr); // We allocate enough bytes for _table_size elements of TableEntry, plus // _table_size more bytes at the end (for the exists array). diff --git a/panda/src/recorder/recorderController.I b/panda/src/recorder/recorderController.I index b6312c0d82..043fb55fb4 100644 --- a/panda/src/recorder/recorderController.I +++ b/panda/src/recorder/recorderController.I @@ -46,7 +46,7 @@ get_random_seed() const { */ INLINE bool RecorderController:: is_recording() const { - return (_writer != (BamWriter *)NULL); + return (_writer != nullptr); } /** @@ -54,7 +54,7 @@ is_recording() const { */ INLINE bool RecorderController:: is_playing() const { - return (_reader != (BamReader *)NULL); + return (_reader != nullptr); } /** @@ -138,7 +138,7 @@ add_recorder(const string &name, RecorderBase *recorder) { */ INLINE bool RecorderController:: has_recorder(const string &name) const { - return (_user_table->get_recorder(name) != (RecorderBase *)NULL); + return (_user_table->get_recorder(name) != nullptr); } /** @@ -153,7 +153,7 @@ has_recorder(const string &name) const { INLINE RecorderBase *RecorderController:: get_recorder(const string &name) const { RecorderBase *recorder = _user_table->get_recorder(name); - if (is_playing() && recorder == (RecorderBase *)NULL) { + if (is_playing() && recorder == nullptr) { recorder = _active_table->get_recorder(name); } return recorder; @@ -178,7 +178,7 @@ remove_recorder(const string &name) { // it now.) if (is_recording() || is_playing()) { RecorderBase *recorder = _user_table->get_recorder(name); - if (recorder != (RecorderBase *)NULL) { + if (recorder != nullptr) { recorder->_flags &= ~(RecorderBase::F_recording | RecorderBase::F_playing); } } @@ -217,7 +217,7 @@ get_frame_tie() const { */ INLINE RecorderController::RecorderFactory *RecorderController:: get_factory() { - if (_factory == (RecorderFactory *)NULL) { + if (_factory == nullptr) { create_factory(); } return _factory; diff --git a/panda/src/recorder/recorderController.cxx b/panda/src/recorder/recorderController.cxx index 364619d5ae..b383402715 100644 --- a/panda/src/recorder/recorderController.cxx +++ b/panda/src/recorder/recorderController.cxx @@ -20,7 +20,7 @@ #include "clockObject.h" TypeHandle RecorderController::_type_handle; -RecorderController::RecorderFactory *RecorderController::_factory = NULL; +RecorderController::RecorderFactory *RecorderController::_factory = nullptr; /** * @@ -29,13 +29,13 @@ RecorderController:: RecorderController() { _clock_offset = 0.0; _frame_offset = 0; - _writer = (BamWriter *)NULL; - _reader = (BamReader *)NULL; + _writer = nullptr; + _reader = nullptr; _frame_tie = true; _user_table = new RecorderTable; _user_table_modified = false; - _file_table = NULL; - _active_table = NULL; + _file_table = nullptr; + _active_table = nullptr; _eof = false; } @@ -132,7 +132,7 @@ begin_playback(const Filename &filename) { // Start out by reading the RecorderHeader. TypedWritable *object = _reader->read_object(); - if (object == (TypedWritable *)NULL || + if (object == nullptr || !object->is_of_type(RecorderHeader::get_class_type())) { recorder_cat.error() << _filename << " does not contain a recorded session.\n"; @@ -151,7 +151,7 @@ begin_playback(const Filename &filename) { // Now read the first frame. _next_frame = read_frame(); - if (_next_frame == (RecorderFrame *)NULL) { + if (_next_frame == nullptr) { recorder_cat.error() << _filename << " does not contain any frames.\n"; close(); @@ -169,16 +169,16 @@ begin_playback(const Filename &filename) { */ void RecorderController:: close() { - if (_writer != (BamWriter *)NULL) { + if (_writer != nullptr) { delete _writer; - _writer = NULL; + _writer = nullptr; // Tell all of our recorders that they're no longer recording. _user_table->clear_flags(RecorderBase::F_recording); } - if (_reader != (BamReader *)NULL) { + if (_reader != nullptr) { delete _reader; - _reader = NULL; + _reader = nullptr; // Tell all of our recorders that they're no longer playing. _active_table->clear_flags(RecorderBase::F_playing); @@ -186,14 +186,14 @@ close() { _dout.close(); _din.close(); - if (_file_table != (RecorderTable *)NULL) { + if (_file_table != nullptr) { delete _file_table; - _file_table = (RecorderTable *)NULL; + _file_table = nullptr; } - if (_active_table != (RecorderTable *)NULL) { + if (_active_table != nullptr) { delete _active_table; - _active_table = (RecorderTable *)NULL; + _active_table = nullptr; } } @@ -231,7 +231,7 @@ play_frame() { double now = global_clock->get_frame_time() - _clock_offset; int frame = global_clock->get_frame_count() - _frame_offset; - while (_next_frame != (RecorderFrame *)NULL) { + while (_next_frame != nullptr) { if (_frame_tie) { if (frame < _next_frame->_frame) { // We haven't reached the next frame yet. @@ -302,9 +302,9 @@ RecorderFrame *RecorderController:: read_frame() { TypedWritable *object = _reader->read_object(); - if (object == (TypedWritable *)NULL || + if (object == nullptr || !object->is_of_type(RecorderFrame::get_class_type())) { - return NULL; + return nullptr; } if (!_reader->resolve()) { diff --git a/panda/src/recorder/recorderFrame.cxx b/panda/src/recorder/recorderFrame.cxx index d53e3d46dc..6b2ea3da10 100644 --- a/panda/src/recorder/recorderFrame.cxx +++ b/panda/src/recorder/recorderFrame.cxx @@ -118,7 +118,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _timestamp = scan.get_float64(); _frame = scan.get_uint32(); _table_changed = scan.get_bool(); - _table = (RecorderTable *)NULL; + _table = nullptr; if (_table_changed) { manager->read_pointer(scan); } diff --git a/panda/src/recorder/recorderTable.I b/panda/src/recorder/recorderTable.I index 6bb2649d97..088c74c52f 100644 --- a/panda/src/recorder/recorderTable.I +++ b/panda/src/recorder/recorderTable.I @@ -46,7 +46,7 @@ operator = (const RecorderTable ©) { */ INLINE void RecorderTable:: add_recorder(const string &name, RecorderBase *recorder) { - nassertv(recorder != (RecorderBase *)NULL); + nassertv(recorder != nullptr); recorder->ref(); std::pair result = @@ -69,7 +69,7 @@ get_recorder(const string &name) const { if (ri != _recorders.end()) { return (*ri).second; } - return NULL; + return nullptr; } /** diff --git a/panda/src/recorder/recorderTable.cxx b/panda/src/recorder/recorderTable.cxx index 6b60d82ada..27fc5ed2c8 100644 --- a/panda/src/recorder/recorderTable.cxx +++ b/panda/src/recorder/recorderTable.cxx @@ -216,7 +216,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { RecorderBase *recorder = RecorderController::get_factory()->make_instance_more_general(type, fparams); - if (recorder == (RecorderBase *)NULL) { + if (recorder == nullptr) { recorder_cat.error() << "Unable to create Recorder of type " << type << "\n"; _error = true; diff --git a/panda/src/recorder/socketStreamRecorder.I b/panda/src/recorder/socketStreamRecorder.I index 90c0585860..520e6f5d40 100644 --- a/panda/src/recorder/socketStreamRecorder.I +++ b/panda/src/recorder/socketStreamRecorder.I @@ -16,7 +16,7 @@ */ INLINE SocketStreamRecorder:: SocketStreamRecorder() : - _stream(NULL), + _stream(nullptr), _owns_stream(false), _closed(true) { @@ -48,7 +48,7 @@ INLINE SocketStreamRecorder:: */ bool SocketStreamRecorder:: send_datagram(const Datagram &dg) { - if (_stream != (SocketStream *)NULL) { + if (_stream != nullptr) { return _stream->send_datagram(dg); } return true; @@ -59,7 +59,7 @@ send_datagram(const Datagram &dg) { */ INLINE bool SocketStreamRecorder:: is_closed() { - if (_stream != (SocketStream *)NULL) { + if (_stream != nullptr) { return _stream->is_closed(); } return is_playing() && _closed; @@ -70,7 +70,7 @@ is_closed() { */ INLINE void SocketStreamRecorder:: close() { - if (_stream != (SocketStream *)NULL) { + if (_stream != nullptr) { _stream->close(); } _closed = true; @@ -81,7 +81,7 @@ close() { */ INLINE void SocketStreamRecorder:: set_collect_tcp(bool collect_tcp) { - if (_stream != (SocketStream *)NULL) { + if (_stream != nullptr) { _stream->set_collect_tcp(collect_tcp); } } @@ -91,7 +91,7 @@ set_collect_tcp(bool collect_tcp) { */ INLINE bool SocketStreamRecorder:: get_collect_tcp() const { - if (_stream != (SocketStream *)NULL) { + if (_stream != nullptr) { return _stream->get_collect_tcp(); } return false; @@ -102,7 +102,7 @@ get_collect_tcp() const { */ INLINE void SocketStreamRecorder:: set_collect_tcp_interval(double interval) { - if (_stream != (SocketStream *)NULL) { + if (_stream != nullptr) { _stream->set_collect_tcp_interval(interval); } } @@ -112,7 +112,7 @@ set_collect_tcp_interval(double interval) { */ INLINE double SocketStreamRecorder:: get_collect_tcp_interval() const { - if (_stream != (SocketStream *)NULL) { + if (_stream != nullptr) { return _stream->get_collect_tcp_interval(); } return 0.0; @@ -123,7 +123,7 @@ get_collect_tcp_interval() const { */ INLINE bool SocketStreamRecorder:: consider_flush() { - if (_stream != (SocketStream *)NULL) { + if (_stream != nullptr) { return _stream->consider_flush(); } return true; @@ -134,7 +134,7 @@ consider_flush() { */ INLINE bool SocketStreamRecorder:: flush() { - if (_stream != (SocketStream *)NULL) { + if (_stream != nullptr) { return _stream->flush(); } return true; diff --git a/panda/src/recorder/socketStreamRecorder.cxx b/panda/src/recorder/socketStreamRecorder.cxx index 6209239044..9c9d66b310 100644 --- a/panda/src/recorder/socketStreamRecorder.cxx +++ b/panda/src/recorder/socketStreamRecorder.cxx @@ -42,7 +42,7 @@ receive_datagram(Datagram &dg) { } else { // If we're not in playback mode, forward the request to the connection. bool got_data = false; - if (_stream != (SocketStream *)NULL) { + if (_stream != nullptr) { got_data = _stream->receive_datagram(dg); } diff --git a/panda/src/rocket/rocketFileInterface.cxx b/panda/src/rocket/rocketFileInterface.cxx index 99ddcd5256..0c3a25fc29 100644 --- a/panda/src/rocket/rocketFileInterface.cxx +++ b/panda/src/rocket/rocketFileInterface.cxx @@ -20,7 +20,7 @@ */ RocketFileInterface:: RocketFileInterface(VirtualFileSystem *vfs) : _vfs(vfs) { - if (_vfs == NULL) { + if (_vfs == nullptr) { _vfs = VirtualFileSystem::get_global_ptr(); } } @@ -35,25 +35,25 @@ Open(const Rocket::Core::String& path) { Filename fn = Filename::from_os_specific(path.CString()); PT(VirtualFile) file = _vfs->get_file(fn); - if (file == NULL) { + if (file == nullptr) { // failed? Try model-path as a Panda-friendly fallback. if (!_vfs->resolve_filename(fn, get_model_path())) { rocket_cat.error() << "Could not resolve " << fn << " along the model-path (currently: " << get_model_path() << ")\n"; - return (Rocket::Core::FileHandle) NULL; + return (Rocket::Core::FileHandle) nullptr; } file = _vfs->get_file(fn); - if (file == NULL) { + if (file == nullptr) { rocket_cat.error() << "Failed to get " << fn << ", found on model-path\n"; - return (Rocket::Core::FileHandle) NULL; + return (Rocket::Core::FileHandle) nullptr; } } istream *str = file->open_read_file(true); - if (str == NULL) { + if (str == nullptr) { rocket_cat.error() << "Failed to open " << fn << " for reading\n"; - return (Rocket::Core::FileHandle) NULL; + return (Rocket::Core::FileHandle) nullptr; } VirtualFileHandle *handle = new VirtualFileHandle; @@ -70,7 +70,7 @@ Open(const Rocket::Core::String& path) { void RocketFileInterface:: Close(Rocket::Core::FileHandle file) { VirtualFileHandle *handle = (VirtualFileHandle*) file; - if (handle == NULL) { + if (handle == nullptr) { return; } @@ -84,7 +84,7 @@ Close(Rocket::Core::FileHandle file) { size_t RocketFileInterface:: Read(void* buffer, size_t size, Rocket::Core::FileHandle file) { VirtualFileHandle *handle = (VirtualFileHandle*) file; - if (handle == NULL) { + if (handle == nullptr) { return 0; } @@ -98,7 +98,7 @@ Read(void* buffer, size_t size, Rocket::Core::FileHandle file) { bool RocketFileInterface:: Seek(Rocket::Core::FileHandle file, long offset, int origin) { VirtualFileHandle *handle = (VirtualFileHandle*) file; - if (handle == NULL) { + if (handle == nullptr) { return false; } @@ -122,7 +122,7 @@ Seek(Rocket::Core::FileHandle file, long offset, int origin) { size_t RocketFileInterface:: Tell(Rocket::Core::FileHandle file) { VirtualFileHandle *handle = (VirtualFileHandle*) file; - if (handle == NULL) { + if (handle == nullptr) { return 0; } @@ -135,7 +135,7 @@ Tell(Rocket::Core::FileHandle file) { size_t RocketFileInterface:: Length(Rocket::Core::FileHandle file) { VirtualFileHandle *handle = (VirtualFileHandle*) file; - if (handle == NULL) { + if (handle == nullptr) { return 0; } diff --git a/panda/src/rocket/rocketFileInterface.h b/panda/src/rocket/rocketFileInterface.h index 8a340136b5..144ccc4563 100644 --- a/panda/src/rocket/rocketFileInterface.h +++ b/panda/src/rocket/rocketFileInterface.h @@ -26,7 +26,7 @@ class VirtualFileSystem; */ class RocketFileInterface : public Rocket::Core::FileInterface { public: - RocketFileInterface(VirtualFileSystem *vfs = NULL); + RocketFileInterface(VirtualFileSystem *vfs = nullptr); virtual ~RocketFileInterface() {}; Rocket::Core::FileHandle Open(const Rocket::Core::String& path); diff --git a/panda/src/rocket/rocketRegion.cxx b/panda/src/rocket/rocketRegion.cxx index ebfcd630c2..fe21d5c6c2 100644 --- a/panda/src/rocket/rocketRegion.cxx +++ b/panda/src/rocket/rocketRegion.cxx @@ -36,7 +36,7 @@ RocketRegion(GraphicsOutput *window, const LVecBase4 &dr_dimensions, // A hack I don't like. libRocket's decorator system has a bug somewhere, // and this seems to be a workaround. - if (Rocket::Core::GetRenderInterface() == NULL) { + if (Rocket::Core::GetRenderInterface() == nullptr) { Rocket::Core::SetRenderInterface(&_interface); } @@ -50,7 +50,7 @@ RocketRegion(GraphicsOutput *window, const LVecBase4 &dr_dimensions, _context = Rocket::Core::CreateContext(context_name.c_str(), dimensions, &_interface); - nassertv(_context != NULL); + nassertv(_context != nullptr); _lens = new OrthographicLens; _lens->set_film_size(dimensions.x, -dimensions.y); @@ -67,10 +67,10 @@ RocketRegion(GraphicsOutput *window, const LVecBase4 &dr_dimensions, RocketRegion:: ~RocketRegion() { if (Rocket::Core::GetRenderInterface() == &_interface) { - Rocket::Core::SetRenderInterface(NULL); + Rocket::Core::SetRenderInterface(nullptr); } - if (_context != NULL) { + if (_context != nullptr) { if (_context->GetReferenceCount() > 1) { _context->RemoveReference(); return; @@ -121,7 +121,7 @@ do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, _lens->set_film_offset(dimensions.x * 0.5, dimensions.y * 0.5); } - if (_input_handler != NULL) { + if (_input_handler != nullptr) { _input_handler->update_context(_context, pl, pb); } else { _context->Update(); @@ -130,7 +130,7 @@ do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, CullTraverser *trav = get_cull_traverser(); trav->set_cull_handler(cull_handler); trav->set_scene(scene_setup, gsg, get_incomplete_render()); - trav->set_view_frustum(NULL); + trav->set_view_frustum(nullptr); _interface.render(_context, trav); diff --git a/panda/src/rocket/rocketRegion_ext.cxx b/panda/src/rocket/rocketRegion_ext.cxx index cb79f467a1..84acb44aa0 100644 --- a/panda/src/rocket/rocketRegion_ext.cxx +++ b/panda/src/rocket/rocketRegion_ext.cxx @@ -44,7 +44,7 @@ get_context() const { (void)e; // Return NULL, which will trigger the exception in Python } - return NULL; + return nullptr; } #endif diff --git a/panda/src/rocket/rocketRenderInterface.cxx b/panda/src/rocket/rocketRenderInterface.cxx index 76e69c6e27..c5ec2eb9a7 100644 --- a/panda/src/rocket/rocketRenderInterface.cxx +++ b/panda/src/rocket/rocketRenderInterface.cxx @@ -35,7 +35,7 @@ */ void RocketRenderInterface:: render(Rocket::Core::Context* context, CullTraverser *trav) { - nassertv(context != NULL); + nassertv(context != nullptr); MutexHolder holder(_lock); _trav = trav; @@ -54,9 +54,9 @@ render(Rocket::Core::Context* context, CullTraverser *trav) { context->Render(); - _trav = NULL; - _net_transform = NULL; - _net_state = NULL; + _trav = nullptr; + _net_transform = nullptr; + _net_state = nullptr; } /** @@ -145,7 +145,7 @@ RenderGeometry(Rocket::Core::Vertex* vertices, Texture *texture = (Texture *)thandle; LVecBase2 tex_scale(1, 1); - if (texture != (Texture *)NULL) { + if (texture != nullptr) { tex_scale = texture->get_tex_scale(); } @@ -153,7 +153,7 @@ RenderGeometry(Rocket::Core::Vertex* vertices, GeomEnums::UH_stream, tex_scale); CPT(RenderState) state; - if (texture != (Texture *)NULL) { + if (texture != nullptr) { state = RenderState::make(TextureAttrib::make(texture)); } else { state = RenderState::make_empty(); @@ -176,7 +176,7 @@ CompileGeometry(Rocket::Core::Vertex* vertices, CompiledGeometry *c = new CompiledGeometry; LVecBase2 tex_scale(1, 1); - if (texture != (Texture *)NULL) { + if (texture != nullptr) { rocket_cat.debug() << "Compiling geom " << c->_geom << " with texture '" << texture->get_name() << "'\n"; @@ -240,7 +240,7 @@ LoadTexture(Rocket::Core::TextureHandle& texture_handle, Filename fn = Filename::from_os_specific(source.CString()); PT(Texture) tex = TexturePool::load_texture(fn, 0, false, options); - if (tex == NULL) { + if (tex == nullptr) { texture_handle = 0; texture_dimensions.x = 0; texture_dimensions.y = 0; @@ -322,7 +322,7 @@ GenerateTexture(Rocket::Core::TextureHandle& texture_handle, void RocketRenderInterface:: ReleaseTexture(Rocket::Core::TextureHandle texture_handle) { Texture *tex = (Texture *)texture_handle; - if (tex != (Texture *)NULL) { + if (tex != nullptr) { unref_delete(tex); } } diff --git a/panda/src/speedtree/config_speedtree.cxx b/panda/src/speedtree/config_speedtree.cxx index b386bcb59a..f820239665 100644 --- a/panda/src/speedtree/config_speedtree.cxx +++ b/panda/src/speedtree/config_speedtree.cxx @@ -300,7 +300,7 @@ public: } void Free(void *block) { - if (block != NULL) { + if (block != nullptr) { PANDA_FREE_ARRAY(block); } } diff --git a/panda/src/speedtree/loaderFileTypeSrt.cxx b/panda/src/speedtree/loaderFileTypeSrt.cxx index 6589e28c10..0f67d2fb96 100644 --- a/panda/src/speedtree/loaderFileTypeSrt.cxx +++ b/panda/src/speedtree/loaderFileTypeSrt.cxx @@ -57,12 +57,12 @@ load_file(const Filename &path, const LoaderOptions &, BamCacheRecord *record) const { if (!path.is_regular_file()) { // Quietly fail if the file doesn't exist. The Loader expects this. - return NULL; + return nullptr; } PT(STTree) tree = new STTree(path); if (!tree->is_valid()) { - return NULL; + return nullptr; } PT(SpeedTreeNode) st = new SpeedTreeNode(path.get_basename()); diff --git a/panda/src/speedtree/loaderFileTypeStf.cxx b/panda/src/speedtree/loaderFileTypeStf.cxx index 8e1e15a2e8..2f568fae3c 100644 --- a/panda/src/speedtree/loaderFileTypeStf.cxx +++ b/panda/src/speedtree/loaderFileTypeStf.cxx @@ -56,7 +56,7 @@ load_file(const Filename &path, const LoaderOptions &options, BamCacheRecord *record) const { if (!path.is_regular_file()) { // Quietly fail if the file doesn't exist. The Loader expects this. - return NULL; + return nullptr; } PT(SpeedTreeNode) st = new SpeedTreeNode(path.get_basename()); diff --git a/panda/src/speedtree/speedTreeNode.I b/panda/src/speedtree/speedTreeNode.I index b095152ee9..0b1b0cd23d 100644 --- a/panda/src/speedtree/speedTreeNode.I +++ b/panda/src/speedtree/speedTreeNode.I @@ -36,7 +36,7 @@ get_num_trees() const { */ INLINE const STTree *SpeedTreeNode:: get_tree(int n) const { - nassertr(n >= 0 && n < (int)_trees.size(), NULL); + nassertr(n >= 0 && n < (int)_trees.size(), nullptr); InstanceList *instance_list = _trees[n]; return instance_list->get_tree(); } @@ -59,7 +59,7 @@ get_instance_list(int n) const { */ INLINE STTree *SpeedTreeNode:: modify_tree(int n) { - nassertr(n >= 0 && n < (int)_trees.size(), NULL); + nassertr(n >= 0 && n < (int)_trees.size(), nullptr); InstanceList *instance_list = _trees[n]; _needs_repopulate = true; return (STTree *)instance_list->get_tree(); @@ -70,7 +70,7 @@ modify_tree(int n) { */ INLINE void SpeedTreeNode:: clear_terrain() { - set_terrain(NULL); + set_terrain(nullptr); } /** @@ -79,7 +79,7 @@ clear_terrain() { */ INLINE bool SpeedTreeNode:: has_terrain() const { - return _terrain != (STTerrain *)NULL; + return _terrain != nullptr; } /** diff --git a/panda/src/speedtree/speedTreeNode.cxx b/panda/src/speedtree/speedTreeNode.cxx index 7cee51229b..da8c036d8e 100644 --- a/panda/src/speedtree/speedTreeNode.cxx +++ b/panda/src/speedtree/speedTreeNode.cxx @@ -247,7 +247,7 @@ get_instance_list(const STTree *tree) const { Trees::const_iterator ti = _trees.find(&ilist); if (ti == _trees.end()) { // The tree was not already present. - static InstanceList empty_list((STTree *)NULL); + static InstanceList empty_list(nullptr); return empty_list; } @@ -408,7 +408,7 @@ add_from_stf(const Filename &stf_filename, const LoaderOptions &options) { } PT(VirtualFile) file = vfs->get_file(fullpath); - if (file == (VirtualFile *)NULL) { + if (file == nullptr) { // No such file. speedtree_cat.error() << "Could not find " << stf_filename << "\n"; @@ -441,7 +441,7 @@ add_from_stf(const Filename &stf_filename, const LoaderOptions &options) { bool SpeedTreeNode:: add_from_stf(istream &in, const Filename &pathname, const LoaderOptions &options, Loader *loader) { - if (loader == NULL) { + if (loader == nullptr) { loader = Loader::get_global_ptr(); } string os_filename; @@ -470,7 +470,7 @@ add_from_stf(istream &in, const Filename &pathname, // search the model-path if necessary). PT(PandaNode) srt_root = loader->load_sync(srt_filename); - if (srt_root != NULL) { + if (srt_root != nullptr) { NodePath srt(srt_root); NodePath srt_np = srt.find("**/+SpeedTreeNode"); if (!srt_np.is_empty()) { @@ -499,7 +499,7 @@ add_from_stf(istream &in, const Filename &pathname, in >> height_min >> height_max >> slope_min >> slope_max; } - if (tree != NULL) { + if (tree != nullptr) { add_instance(tree, STTransform(pos, rad_2_deg(rotate), scale)); } } @@ -552,10 +552,10 @@ setup_terrain(const Filename &terrain_file) { */ void SpeedTreeNode:: set_terrain(STTerrain *terrain) { - _terrain = NULL; + _terrain = nullptr; _needs_repopulate = true; - if (terrain == (STTerrain *)NULL) { + if (terrain == nullptr) { return; } @@ -608,7 +608,7 @@ snap_to_terrain() { InstanceList *instance_list = (*ti); int num_instances = instance_list->get_num_instances(); - if (_terrain != (STTerrain *)NULL) { + if (_terrain != nullptr) { for (int i = 0; i < num_instances; ++i) { STTransform trans = instance_list->get_instance(i); LPoint3 pos = trans.get_pos(); @@ -817,7 +817,7 @@ combine_with(PandaNode *other) { // But, not if they both have a terrain set. if (has_terrain() && gother->has_terrain()) { - return NULL; + return nullptr; } else if (gother->has_terrain()) { set_terrain(gother->get_terrain()); @@ -884,7 +884,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { PStatTimer timer(_cull_speedtree_pcollector); GraphicsStateGuardian *gsg = DCAST(GraphicsStateGuardian, trav->get_gsg()); - nassertr(gsg != (GraphicsStateGuardian *)NULL, true); + nassertr(gsg != nullptr, true); if (!validate_api(gsg)) { return false; } @@ -918,7 +918,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // to disable textures. bool show_textures = true; const TextureAttrib *ta = DCAST(TextureAttrib, state->get_attrib(TextureAttrib::get_class_slot())); - if (ta != (TextureAttrib *)NULL) { + if (ta != nullptr) { show_textures = !ta->has_all_off(); } _forest_render.EnableTexturing(show_textures); @@ -929,19 +929,19 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // direction and color to SpeedTree. We also accumulate the ambient light // colors. LColor ambient_color(0.0f, 0.0f, 0.0f, 0.0f); - DirectionalLight *dlight = NULL; + DirectionalLight *dlight = nullptr; NodePath dlight_np; LColor diffuse_color; int diffuse_priority = 0; const LightAttrib *la = DCAST(LightAttrib, state->get_attrib(LightAttrib::get_class_slot())); - if (la != (LightAttrib *)NULL) { + if (la != nullptr) { for (int i = 0; i < la->get_num_on_lights(); ++i) { NodePath light = la->get_on_light(i); if (!light.is_empty() && light.node()->is_of_type(DirectionalLight::get_class_type())) { // A directional light. DirectionalLight *light_obj = DCAST(DirectionalLight, light.node()); - if (dlight == NULL || light_obj->get_priority() > dlight->get_priority()) { + if (dlight == nullptr || light_obj->get_priority() > dlight->get_priority()) { // Here's the most important directional light. dlight = light_obj; dlight_np = light; @@ -954,7 +954,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { } } - if (dlight != (DirectionalLight *)NULL) { + if (dlight != nullptr) { CPT(TransformState) transform = dlight_np.get_transform(trav->get_scene()->get_scene_root().get_parent()); LVector3 dir = dlight->get_direction() * transform->get_mat(); dir.normalize(); @@ -1021,7 +1021,7 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { // node, so that we can make the appropriate calls into SpeedTree to // render the forest during the actual draw. CullableObject *object = - new CullableObject(NULL, data._state, + new CullableObject(nullptr, data._state, TransformState::make_identity()); object->set_draw_callback(new DrawCallback(this)); trav->get_cull_handler()->record_object(object, trav); @@ -1119,7 +1119,7 @@ write(ostream &out, int indent_level) const { void SpeedTreeNode:: write_error(ostream &out) { const char *error = SpeedTree::CCore::GetError(); - if (error != (const char *)NULL) { + if (error != nullptr) { out << error; } out << "\n"; @@ -1281,7 +1281,7 @@ update_terrain_cells() { int num_cells = (int)cells.size(); for (int ci = 0; ci < num_cells; ++ci) { SpeedTree::CTerrainCell *cell = cells[ci]; - nassertv(cell != NULL && cell->GetVbo() != NULL); + nassertv(cell != nullptr && cell->GetVbo() != nullptr); int cell_yi = cell->Row(); int cell_xi = cell->Col(); // cerr << "populating cell " << cell_xi << " " << cell_yi << "\n"; @@ -1308,7 +1308,7 @@ update_terrain_cells() { bool SpeedTreeNode:: validate_api(GraphicsStateGuardian *gsg) { GraphicsPipe *pipe = gsg->get_pipe(); - nassertr(pipe != (GraphicsPipe *)NULL, true); + nassertr(pipe != nullptr, true); #if defined(SPEEDTREE_OPENGL) static const string compiled_api = "OpenGL"; @@ -1387,7 +1387,7 @@ draw_callback(CallbackData *data) { write_error(speedtree_cat.warning()); // Clear the terrain so we don't keep spamming error messages. - _terrain = NULL; + _terrain = nullptr; } } @@ -1720,9 +1720,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { int num_trees = scan.get_uint32(); _trees.reserve(num_trees); for (int i = 0; i < num_trees; i++) { - InstanceList *instance_list = new InstanceList(NULL); + InstanceList *instance_list = new InstanceList(nullptr); instance_list->fillin(scan, manager); - if (instance_list->get_tree() == (STTree *)NULL) { + if (instance_list->get_tree() == nullptr) { // The tree wasn't successfully loaded. Don't keep it. delete instance_list; } else { @@ -1799,7 +1799,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { Loader *loader = Loader::get_global_ptr(); PT(PandaNode) srt_root = loader->load_sync(srt_filename); - if (srt_root != NULL) { + if (srt_root != nullptr) { NodePath srt(srt_root); NodePath srt_np = srt.find("**/+SpeedTreeNode"); if (!srt_np.is_empty()) { diff --git a/panda/src/speedtree/speedTreeNode.h b/panda/src/speedtree/speedTreeNode.h index 567cb00af9..fb153d2542 100644 --- a/panda/src/speedtree/speedTreeNode.h +++ b/panda/src/speedtree/speedTreeNode.h @@ -123,7 +123,7 @@ PUBLISHED: const LoaderOptions &options = LoaderOptions()); bool add_from_stf(istream &in, const Filename &pathname, const LoaderOptions &options = LoaderOptions(), - Loader *loader = NULL); + Loader *loader = nullptr); bool setup_terrain(const Filename &terrain_file); void set_terrain(STTerrain *terrain); diff --git a/panda/src/speedtree/stBasicTerrain.cxx b/panda/src/speedtree/stBasicTerrain.cxx index 9b84e86ee8..2a6dba22f4 100644 --- a/panda/src/speedtree/stBasicTerrain.cxx +++ b/panda/src/speedtree/stBasicTerrain.cxx @@ -113,7 +113,7 @@ setup_terrain(const Filename &terrain_filename) { } istream *in = vfs->open_read_file(fullpath, true); - if (in == NULL) { + if (in == nullptr) { speedtree_cat.warning() << "Couldn't open " << terrain_filename << "\n"; return false; diff --git a/panda/src/speedtree/stTerrain.cxx b/panda/src/speedtree/stTerrain.cxx index 2f5f226856..fef97b9d0d 100644 --- a/panda/src/speedtree/stTerrain.cxx +++ b/panda/src/speedtree/stTerrain.cxx @@ -62,7 +62,7 @@ clear() { _splat_map = ""; _splat_layers.clear(); - set_vertex_format(NULL); + set_vertex_format(nullptr); } /** @@ -169,7 +169,7 @@ write(ostream &out, int indent_level) const { const SpeedTree::SVertexAttribDesc *STTerrain:: get_st_vertex_format() const { // return SpeedTree::std_vertex_format; - nassertr(!_st_vertex_attribs.empty(), NULL); + nassertr(!_st_vertex_attribs.empty(), nullptr); return &_st_vertex_attribs[0]; } @@ -181,8 +181,8 @@ get_st_vertex_format() const { */ bool STTerrain:: set_vertex_format(const GeomVertexFormat *format) { - if (format == NULL) { - _vertex_format = NULL; + if (format == nullptr) { + _vertex_format = nullptr; _st_vertex_attribs.clear(); _is_valid = false; return true; diff --git a/panda/src/testbed/pgrid.cxx b/panda/src/testbed/pgrid.cxx index e028e6c03c..d93cf64382 100644 --- a/panda/src/testbed/pgrid.cxx +++ b/panda/src/testbed/pgrid.cxx @@ -177,7 +177,7 @@ void get_command_line_filenames(int argc, char *argv[], pvector &static_filenames, GriddedFilenames &gridded_filenames) { - for (int i = 1; i < argc && argv[i] != (char *)NULL; i++) { + for (int i = 1; i < argc && argv[i] != nullptr; i++) { const string &arg = argv[i]; size_t comma = arg.find(','); if (comma == string::npos) { @@ -226,7 +226,7 @@ load_gridded_models(WindowFramework *window, for (fi = filenames.begin(); fi != filenames.end(); ++fi) { GriddedFilename &gf = (*fi); PT(PandaNode) node = loader.load_sync(gf._filename, options); - if (node != (PandaNode *)NULL) { + if (node != nullptr) { gf._model = NodePath(node); grid_count += gf._count; } @@ -252,7 +252,7 @@ load_gridded_models(WindowFramework *window, PN_stdfloat xpos = grid_pos_offset; PN_stdfloat ypos = grid_pos_offset; - srand( (unsigned)time( NULL ) ); + srand( (unsigned)time( nullptr ) ); double now = ClockObject::get_global_clock()->get_frame_time(); int model_count = 0; @@ -273,7 +273,7 @@ load_gridded_models(WindowFramework *window, ++model_count; PT(PandaNode) node = loader.load_sync(gf._filename, options); NodePath model; - if (node == (PandaNode *)NULL) { + if (node == nullptr) { model = gf._model.copy_to(NodePath()); } else { model = NodePath(node); @@ -400,7 +400,7 @@ main(int argc, char **argv) { get_command_line_filenames(argc, argv, static_filenames, gridded_filenames); WindowFramework *window = framework.open_window(); - if (window != (WindowFramework *)NULL) { + if (window != nullptr) { // We've successfully opened a window. window->enable_keyboard(); diff --git a/panda/src/testbed/pview.cxx b/panda/src/testbed/pview.cxx index b5bb629b0c..8d39104d64 100644 --- a/panda/src/testbed/pview.cxx +++ b/panda/src/testbed/pview.cxx @@ -58,8 +58,8 @@ event_W(const Event *, void *) { // shift-W: open a new window on the same scene. // If we already have a window, use the same GSG. - GraphicsPipe *pipe = (GraphicsPipe *)NULL; - GraphicsStateGuardian *gsg = (GraphicsStateGuardian *)NULL; + GraphicsPipe *pipe = nullptr; + GraphicsStateGuardian *gsg = nullptr; if (framework.get_num_windows() > 0) { WindowFramework *old_window = framework.get_window(0); @@ -69,7 +69,7 @@ event_W(const Event *, void *) { } WindowFramework *window = framework.open_window(pipe, gsg); - if (window != (WindowFramework *)NULL) { + if (window != nullptr) { window->enable_keyboard(); window->setup_trackball(); framework.get_models().instance_to(window->get_render()); @@ -87,15 +87,15 @@ event_Enter(const Event *, void *) { // alt-enter: toggle between windowfullscreen in the same scene. // If we already have a window, use the same GSG. - GraphicsPipe *pipe = (GraphicsPipe *)NULL; - GraphicsStateGuardian *gsg = (GraphicsStateGuardian *)NULL; + GraphicsPipe *pipe = nullptr; + GraphicsStateGuardian *gsg = nullptr; WindowProperties props; for (int i = 0; i < framework.get_num_windows(); ++i) { WindowFramework *old_window = framework.get_window(i); GraphicsWindow *win = old_window->get_graphics_window(); - if (win != (GraphicsWindow *)NULL) { + if (win != nullptr) { pipe = win->get_pipe(); gsg = win->get_gsg(); props = win->get_properties(); @@ -109,7 +109,7 @@ event_Enter(const Event *, void *) { int flags = GraphicsPipe::BF_require_window; WindowFramework *window = framework.open_window(props, flags, pipe, gsg); - if (window != (WindowFramework *)NULL) { + if (window != nullptr) { window->enable_keyboard(); window->setup_trackball(); framework.get_models().instance_to(window->get_render()); @@ -125,7 +125,7 @@ event_2(const Event *event, void *) { DCAST_INTO_V(wf, param.get_ptr()); WindowFramework *split = wf->split_window(); - if (split != (WindowFramework *)NULL) { + if (split != nullptr) { split->enable_keyboard(); split->setup_trackball(); framework.get_models().instance_to(split->get_render()); @@ -238,13 +238,13 @@ report_version() { class AdjustCameraClipPlanesTask : public AsyncTask { public: AdjustCameraClipPlanesTask(const string &name, Camera *camera) : - AsyncTask(name), _camera(camera), _lens(camera->get_lens(0)), _sphere(NULL) + AsyncTask(name), _camera(camera), _lens(camera->get_lens(0)), _sphere(nullptr) { NodePath np = framework.get_models(); PT(BoundingVolume) volume = np.get_bounds(); // We expect at least a geometric bounding volume around the world. - nassertv(volume != (BoundingVolume *)NULL); + nassertv(volume != nullptr); nassertv(volume->is_of_type(GeometricBoundingVolume::get_class_type())); CPT(GeometricBoundingVolume) gbv = DCAST(GeometricBoundingVolume, volume); @@ -348,7 +348,7 @@ main(int argc, char **argv) { Filename screenshotfn; bool delete_models = false; bool apply_lighting = false; - PointerTo pipe = NULL; + PointerTo pipe = nullptr; extern char *optarg; extern int optind; @@ -417,8 +417,8 @@ main(int argc, char **argv) { argc -= (optind - 1); argv += (optind - 1); - WindowFramework *window = framework.open_window(pipe, NULL); - if (window != (WindowFramework *)NULL) { + WindowFramework *window = framework.open_window(pipe, nullptr); + if (window != nullptr) { // We've successfully opened a window. NodePath loading_np; @@ -453,7 +453,7 @@ main(int argc, char **argv) { if (delete_models) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - for (int i = 1; i < argc && argv[i] != (char *)NULL; i++) { + for (int i = 1; i < argc && argv[i] != nullptr; i++) { Filename model = Filename::from_os_specific(argv[i]); if (vfs->exists(model)) { nout << "Deleting " << model << "\n"; @@ -489,12 +489,12 @@ main(int argc, char **argv) { framework.get_task_mgr().add(task); framework.enable_default_keys(); - framework.define_key("shift-w", "open a new window", event_W, NULL); - framework.define_key("shift-f", "flatten hierarchy", event_F, NULL); - framework.define_key("alt-enter", "toggle between window/fullscreen", event_Enter, NULL); - framework.define_key("2", "split the window", event_2, NULL); + framework.define_key("shift-w", "open a new window", event_W, nullptr); + framework.define_key("shift-f", "flatten hierarchy", event_F, nullptr); + framework.define_key("alt-enter", "toggle between window/fullscreen", event_Enter, nullptr); + framework.define_key("2", "split the window", event_2, nullptr); if (pview_test_hack) { - framework.define_key("0", "run quick hacky test", event_0, NULL); + framework.define_key("0", "run quick hacky test", event_0, nullptr); } framework.main_loop(); framework.report_frame_rate(nout); diff --git a/panda/src/testbed/test_lod.cxx b/panda/src/testbed/test_lod.cxx index fa62edd785..00e4916ffa 100644 --- a/panda/src/testbed/test_lod.cxx +++ b/panda/src/testbed/test_lod.cxx @@ -54,7 +54,7 @@ main(int argc, char *argv[]) { framework.set_window_title("LOD Test"); WindowFramework *window = framework.open_window(); - if (window != (WindowFramework *)NULL) { + if (window != nullptr) { // We've successfully opened a window. window->enable_keyboard(); @@ -69,7 +69,7 @@ main(int argc, char *argv[]) { // Open another window too. WindowFramework *window2 = framework.open_window(); - if (window2 != (WindowFramework *)NULL) { + if (window2 != nullptr) { window2->enable_keyboard(); window2->setup_trackball(); framework.get_models().instance_to(window2->get_render()); diff --git a/panda/src/testbed/test_texmem.cxx b/panda/src/testbed/test_texmem.cxx index 76f6adfc57..977c1b0209 100644 --- a/panda/src/testbed/test_texmem.cxx +++ b/panda/src/testbed/test_texmem.cxx @@ -102,7 +102,7 @@ main(int argc, char *argv[]) { framework.set_window_title("Panda Viewer"); WindowFramework *window = framework.open_window(); - if (window != (WindowFramework *)NULL) { + if (window != nullptr) { // We've successfully opened a window. window->enable_keyboard(); diff --git a/panda/src/text/config_text.cxx b/panda/src/text/config_text.cxx index 2fff80cd0c..1bdcafcf09 100644 --- a/panda/src/text/config_text.cxx +++ b/panda/src/text/config_text.cxx @@ -146,14 +146,14 @@ ConfigVariableInt text_embed_graphic_key wstring get_text_soft_hyphen_output() { - static wstring *text_soft_hyphen_output = NULL; + static wstring *text_soft_hyphen_output = nullptr; static ConfigVariableString cv("text-soft-hyphen-output", "-", PRC_DESC("This is the string that is output, encoded in the default " "encoding, to represent the hyphen character that is " "introduced when the line is broken at a soft-hyphen key.")); - if (text_soft_hyphen_output == NULL) { + if (text_soft_hyphen_output == nullptr) { TextEncoder encoder; text_soft_hyphen_output = new wstring(encoder.decode_text(cv)); } @@ -169,7 +169,7 @@ ConfigVariableDouble text_hyphen_ratio wstring get_text_never_break_before() { - static wstring *text_never_break_before = NULL; + static wstring *text_never_break_before = nullptr; static ConfigVariableString cv("text-never-break-before", ",.-:?!;", PRC_DESC("This string represents a list of individual characters " @@ -177,7 +177,7 @@ get_text_never_break_before() { "following a forced break. Typically these will be " "punctuation characters.")); - if (text_never_break_before == NULL) { + if (text_never_break_before == nullptr) { TextEncoder encoder; text_never_break_before = new wstring(encoder.decode_text(cv)); } diff --git a/panda/src/text/dynamicTextFont.cxx b/panda/src/text/dynamicTextFont.cxx index f02328009e..42c040c6ed 100644 --- a/panda/src/text/dynamicTextFont.cxx +++ b/panda/src/text/dynamicTextFont.cxx @@ -162,7 +162,7 @@ get_num_pages() const { */ DynamicTextPage *DynamicTextFont:: get_page(int n) const { - nassertr(n >= 0 && n < (int)_pages.size(), (DynamicTextPage *)NULL); + nassertr(n >= 0 && n < (int)_pages.size(), nullptr); return _pages[n]; } @@ -179,7 +179,7 @@ garbage_collect() { Cache::iterator ci; for (ci = _cache.begin(); ci != _cache.end(); ++ci) { const TextGlyph *glyph = (*ci).second; - if (glyph == (TextGlyph *)NULL || glyph->get_ref_count() > 1) { + if (glyph == nullptr || glyph->get_ref_count() > 1) { // Keep this one. new_cache.insert(new_cache.end(), (*ci)); } else { @@ -267,7 +267,7 @@ write(ostream &out, int indent_level) const { bool DynamicTextFont:: get_glyph(int character, CPT(TextGlyph) &glyph) { if (!_is_valid) { - glyph = (TextGlyph *)NULL; + glyph = nullptr; return false; } @@ -487,7 +487,7 @@ determine_tex_format() { CPT(TextGlyph) DynamicTextFont:: make_glyph(int character, FT_Face face, int glyph_index) { if (!load_glyph(face, glyph_index, false)) { - return (TextGlyph *)NULL; + return nullptr; } FT_GlyphSlot slot = face->glyph; @@ -499,7 +499,7 @@ make_glyph(int character, FT_Face face, int glyph_index) { // is the empty bitmap, we return NULL, and use Panda's invalid glyph in // its place. We do this to guarantee that every invalid glyph is visible // as *something*. - return NULL; + return nullptr; } PN_stdfloat advance = slot->advance.x / 64.0; @@ -673,7 +673,7 @@ make_glyph(int character, FT_Face face, int glyph_index) { } DynamicTextPage *page = glyph->get_page(); - if (page != NULL) { + if (page != nullptr) { int bitmap_top = (int)floor(tex_y_orig + outline * _scale_factor + 0.5f); int bitmap_left = (int)floor(tex_x_orig - outline * _scale_factor + 0.5f); @@ -726,7 +726,7 @@ copy_bitmap_to_texture(const FT_Bitmap &bitmap, DynamicTextGlyph *glyph) { for (int yi = 0; yi < (int)bitmap.rows; yi++) { unsigned char *texture_row = glyph->get_row(yi); - nassertv(texture_row != (unsigned char *)NULL); + nassertv(texture_row != nullptr); memcpy(texture_row, buffer_row, bitmap.width); buffer_row += bitmap.pitch; } @@ -737,7 +737,7 @@ copy_bitmap_to_texture(const FT_Bitmap &bitmap, DynamicTextGlyph *glyph) { unsigned char *buffer_row = bitmap.buffer; for (int yi = 0; yi < (int)bitmap.rows; yi++) { unsigned char *texture_row = glyph->get_row(yi); - nassertv(texture_row != (unsigned char *)NULL); + nassertv(texture_row != nullptr); int bit = 0x80; unsigned char *b = buffer_row; @@ -764,7 +764,7 @@ copy_bitmap_to_texture(const FT_Bitmap &bitmap, DynamicTextGlyph *glyph) { unsigned char *buffer_row = bitmap.buffer; for (int yi = 0; yi < (int)bitmap.rows; yi++) { unsigned char *texture_row = glyph->get_row(yi); - nassertv(texture_row != (unsigned char *)NULL); + nassertv(texture_row != nullptr); for (int xi = 0; xi < (int)bitmap.width; xi++) { texture_row[xi] = (int)(buffer_row[xi] * 255) / (bitmap.num_grays - 1); } @@ -788,7 +788,7 @@ copy_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph) { nassertv(glyph->_page->get_num_components() == 1); for (int yi = 0; yi < image.get_y_size(); yi++) { unsigned char *texture_row = glyph->get_row(yi); - nassertv(texture_row != (unsigned char *)NULL); + nassertv(texture_row != nullptr); for (int xi = 0; xi < image.get_x_size(); xi++) { texture_row[xi] = image.get_gray_val(xi, yi); } @@ -853,7 +853,7 @@ blend_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph, for (int yi = 0; yi < image.get_y_size(); yi++) { unsigned char *texture_row = glyph->get_row(yi); - nassertv(texture_row != (unsigned char *)NULL); + nassertv(texture_row != nullptr); for (int xi = 0; xi < image.get_x_size(); xi++) { unsigned char *tr = texture_row + xi; PN_stdfloat t = (PN_stdfloat)image.get_gray(xi, yi); @@ -866,7 +866,7 @@ blend_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph, for (int yi = 0; yi < image.get_y_size(); yi++) { unsigned char *texture_row = glyph->get_row(yi); - nassertv(texture_row != (unsigned char *)NULL); + nassertv(texture_row != nullptr); for (int xi = 0; xi < image.get_x_size(); xi++) { unsigned char *tr = texture_row + xi * 2; PN_stdfloat t = (PN_stdfloat)image.get_gray(xi, yi); @@ -880,7 +880,7 @@ blend_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph, for (int yi = 0; yi < image.get_y_size(); yi++) { unsigned char *texture_row = glyph->get_row(yi); - nassertv(texture_row != (unsigned char *)NULL); + nassertv(texture_row != nullptr); for (int xi = 0; xi < image.get_x_size(); xi++) { unsigned char *tr = texture_row + xi * 3; PN_stdfloat t = (PN_stdfloat)image.get_gray(xi, yi); @@ -895,7 +895,7 @@ blend_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph, for (int yi = 0; yi < image.get_y_size(); yi++) { unsigned char *texture_row = glyph->get_row(yi); - nassertv(texture_row != (unsigned char *)NULL); + nassertv(texture_row != nullptr); for (int xi = 0; xi < image.get_x_size(); xi++) { unsigned char *tr = texture_row + xi * 4; PN_stdfloat t = (PN_stdfloat)image.get_gray(xi, yi); @@ -931,7 +931,7 @@ slot_glyph(int character, int x_size, int y_size, PN_stdfloat advance) { do { DynamicTextPage *page = _pages[pi]; DynamicTextGlyph *glyph = page->slot_glyph(character, x_size, y_size, _texture_margin, advance); - if (glyph != (DynamicTextGlyph *)NULL) { + if (glyph != nullptr) { // Once we found a page to hold the glyph, that becomes our new // preferred page. _preferred_page = pi; @@ -943,7 +943,7 @@ slot_glyph(int character, int x_size, int y_size, PN_stdfloat advance) { text_cat.error() << "Glyph of size " << x_size << " by " << y_size << " pixels won't fit on an empty page.\n"; - return (DynamicTextGlyph *)NULL; + return nullptr; } pi = (pi + 1) % _pages.size(); diff --git a/panda/src/text/dynamicTextGlyph.I b/panda/src/text/dynamicTextGlyph.I index 23e44ee8ce..3f2ebebfe2 100644 --- a/panda/src/text/dynamicTextGlyph.I +++ b/panda/src/text/dynamicTextGlyph.I @@ -32,7 +32,7 @@ DynamicTextGlyph(int character, DynamicTextPage *page, int x, int y, INLINE DynamicTextGlyph:: DynamicTextGlyph(int character, PN_stdfloat advance) : TextGlyph(character, advance), - _page((DynamicTextPage *)NULL), + _page(nullptr), _x(0), _y(0), _x_size(0), _y_size(0), _margin(0) diff --git a/panda/src/text/dynamicTextGlyph.cxx b/panda/src/text/dynamicTextGlyph.cxx index 9727b353f7..7fc2458965 100644 --- a/panda/src/text/dynamicTextGlyph.cxx +++ b/panda/src/text/dynamicTextGlyph.cxx @@ -44,8 +44,8 @@ DynamicTextGlyph:: */ unsigned char *DynamicTextGlyph:: get_row(int y) { - nassertr(y >= 0 && y < _y_size - _margin * 2, (unsigned char *)NULL); - nassertr(_page != (DynamicTextPage *)NULL, (unsigned char *)NULL); + nassertr(y >= 0 && y < _y_size - _margin * 2, nullptr); + nassertr(_page != nullptr, nullptr); // First, offset y by the glyph's start. y += _y + _margin; @@ -66,7 +66,7 @@ get_row(int y) { */ void DynamicTextGlyph:: erase(DynamicTextFont *font) { - nassertv(_page != (DynamicTextPage *)NULL); + nassertv(_page != nullptr); nassertv(_page->has_ram_image()); // The glyph covers the pixels from (_x, _y) over the rectangle (_x_size, @@ -84,7 +84,7 @@ erase(DynamicTextFont *font) { */ bool DynamicTextGlyph:: is_whitespace() const { - return (_page == (DynamicTextPage *)NULL); + return (_page == nullptr); } #endif // HAVE_FREETYPE diff --git a/panda/src/text/dynamicTextPage.cxx b/panda/src/text/dynamicTextPage.cxx index fbe1b93486..b48ba426db 100644 --- a/panda/src/text/dynamicTextPage.cxx +++ b/panda/src/text/dynamicTextPage.cxx @@ -72,7 +72,7 @@ slot_glyph(int character, int x_size, int y_size, int margin, int x, y; if (!find_hole(x, y, x_size, y_size)) { // No room for the glyph. - return (DynamicTextGlyph *)NULL; + return nullptr; } // The glyph can be fit at (x, y). Slot it. @@ -209,7 +209,7 @@ find_hole(int &x, int &y, int x_size, int y_size) const { // Consider the spot at x, y. DynamicTextGlyph *overlap = find_overlap(x, y, x_size, y_size); - if (overlap == (DynamicTextGlyph *)NULL) { + if (overlap == nullptr) { // Hooray! return true; } @@ -245,7 +245,7 @@ find_overlap(int x, int y, int x_size, int y_size) const { } } - return (DynamicTextGlyph *)NULL; + return nullptr; } diff --git a/panda/src/text/fontPool.I b/panda/src/text/fontPool.I index c24906bdcf..d0142579e1 100644 --- a/panda/src/text/fontPool.I +++ b/panda/src/text/fontPool.I @@ -27,7 +27,7 @@ has_font(const string &filename) { */ INLINE bool FontPool:: verify_font(const string &filename) { - return load_font(filename) != (TextFont *)NULL; + return load_font(filename) != nullptr; } /** diff --git a/panda/src/text/fontPool.cxx b/panda/src/text/fontPool.cxx index ac7d476c63..6217be1bae 100644 --- a/panda/src/text/fontPool.cxx +++ b/panda/src/text/fontPool.cxx @@ -21,7 +21,7 @@ #include "loader.h" #include "lightMutexHolder.h" -FontPool *FontPool::_global_ptr = (FontPool *)NULL; +FontPool *FontPool::_global_ptr = nullptr; /** * Lists the contents of the font pool to the indicated output stream. @@ -86,7 +86,7 @@ ns_load_font(const string &str) { if (extension.empty() || extension == "egg" || extension == "bam") { Loader *model_loader = Loader::get_global_ptr(); PT(PandaNode) node = model_loader->load_sync(filename); - if (node != (PandaNode *)NULL) { + if (node != nullptr) { // It is a model. Elevate all the priorities by 1, and make a font out // of it. @@ -104,16 +104,16 @@ ns_load_font(const string &str) { } #ifdef HAVE_FREETYPE - if (font == (TextFont *)NULL || !font->is_valid()) { + if (font == nullptr || !font->is_valid()) { // If we couldn't load the font as a model, try using FreeType to load it // as a font file. font = new DynamicTextFont(filename, face_index); } #endif - if (font == (TextFont *)NULL || !font->is_valid()) { + if (font == nullptr || !font->is_valid()) { // This font was not found or could not be read. - return NULL; + return nullptr; } @@ -263,7 +263,7 @@ lookup_filename(const string &str, string &index_str, */ FontPool *FontPool:: get_ptr() { - if (_global_ptr == (FontPool *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new FontPool; } return _global_ptr; diff --git a/panda/src/text/geomTextGlyph.cxx b/panda/src/text/geomTextGlyph.cxx index 7af3d0d5e0..6a02f2af16 100644 --- a/panda/src/text/geomTextGlyph.cxx +++ b/panda/src/text/geomTextGlyph.cxx @@ -28,7 +28,7 @@ GeomTextGlyph(const TextGlyph *glyph, const GeomVertexData *data) : { // Initially, there is only one glyph in the Geom. There might be // additional Glyphs later when we flatten the graph and call Geom::unify(). - if (glyph != (const TextGlyph *)NULL) { + if (glyph != nullptr) { _glyphs.reserve(1); _glyphs.push_back(glyph); } @@ -61,7 +61,7 @@ GeomTextGlyph:: GeomTextGlyph(const Geom ©, const TextGlyph *glyph) : Geom(copy) { - if (glyph != (const TextGlyph *)NULL) { + if (glyph != nullptr) { _glyphs.reserve(1); _glyphs.push_back(glyph); } @@ -148,7 +148,7 @@ output(ostream &out) const { Glyphs::const_iterator gi; for (gi = _glyphs.begin(); gi != _glyphs.end(); ++gi) { const TextGlyph *glyph = (*gi); - nassertv(glyph != (const TextGlyph *)NULL); + nassertv(glyph != nullptr); out << " " << glyph->get_character(); } out << " ]"; @@ -165,7 +165,7 @@ write(ostream &out, int indent_level) const { Glyphs::const_iterator gi; for (gi = _glyphs.begin(); gi != _glyphs.end(); ++gi) { const TextGlyph *glyph = (*gi); - nassertv(glyph != (const TextGlyph *)NULL); + nassertv(glyph != nullptr); out << " " << glyph->get_character(); } out << " ]\n"; @@ -192,8 +192,8 @@ register_with_read_factory() { */ TypedWritable* GeomTextGlyph:: make_GeomTextGlyph(const FactoryParams ¶ms) { - GeomTextGlyph *me = new GeomTextGlyph((const TextGlyph *)NULL, - (GeomVertexData *)NULL); + GeomTextGlyph *me = new GeomTextGlyph(nullptr, + nullptr); DatagramIterator scan; BamReader *manager; diff --git a/panda/src/text/staticTextFont.cxx b/panda/src/text/staticTextFont.cxx index 2a06033f2f..2f68c2dba8 100644 --- a/panda/src/text/staticTextFont.cxx +++ b/panda/src/text/staticTextFont.cxx @@ -37,7 +37,7 @@ TypeHandle StaticTextFont::_type_handle; */ StaticTextFont:: StaticTextFont(PandaNode *font_def, CoordinateSystem cs) { - nassertv(font_def != (PandaNode *)NULL); + nassertv(font_def != nullptr); _font = font_def; _cs = cs; _glyphs.clear(); @@ -295,10 +295,10 @@ find_characters(PandaNode *root, const RenderState *net_state) { int character = atoi(name.c_str()); CPT(Geom) ch; CPT(Geom) dot; - const RenderState *state = NULL; + const RenderState *state = nullptr; find_character_gsets(root, ch, dot, state, next_net_state); PN_stdfloat width = 0.0; - if (dot != (Geom *)NULL) { + if (dot != nullptr) { // Get the first vertex from the "dot" geoset. This will be the origin // of the next character. GeomVertexReader reader(dot->get_vertex_data(), InternalName::get_vertex()); @@ -313,9 +313,9 @@ find_characters(PandaNode *root, const RenderState *net_state) { CPT(Geom) ch; CPT(Geom) dot; - const RenderState *state = NULL; + const RenderState *state = nullptr; find_character_gsets(root, ch, dot, state, next_net_state); - if (dot != (Geom *)NULL) { + if (dot != nullptr) { // Get the first vertex from the "dot" geoset. This will be the design // size indicator. GeomVertexReader reader(dot->get_vertex_data(), InternalName::get_vertex()); diff --git a/panda/src/text/textAssembler.I b/panda/src/text/textAssembler.I index 5132f78859..3cce3a4ad9 100644 --- a/panda/src/text/textAssembler.I +++ b/panda/src/text/textAssembler.I @@ -296,7 +296,7 @@ get_ypos(int r, int) const { */ INLINE PN_stdfloat TextAssembler:: calc_width(const TextCharacter &tch) { - if (tch._graphic != (TextGraphic *)NULL) { + if (tch._graphic != nullptr) { return calc_width(tch._graphic, tch._cprops->_properties); } else { return calc_width(tch._character, tch._cprops->_properties); @@ -310,7 +310,7 @@ INLINE TextAssembler::TextCharacter:: TextCharacter(wchar_t character, TextAssembler::ComputedProperties *cprops) : _character(character), - _graphic(NULL), + _graphic(nullptr), _cprops(cprops) { } @@ -395,7 +395,7 @@ operator = (const TextAssembler::TextRow ©) { */ INLINE TextAssembler::ComputedProperties:: ComputedProperties(const TextProperties &orig_properties) : - _based_on(NULL), + _based_on(nullptr), _depth(0), _properties(orig_properties) { @@ -420,7 +420,7 @@ ComputedProperties(ComputedProperties *based_on, const wstring &wname, string name = encoder->encode_wtext(wname); const TextProperties *named_props = manager->get_properties_ptr(name); - if (named_props != (TextProperties *)NULL) { + if (named_props != nullptr) { _properties.add_properties(*named_props); } else { text_cat.warning() diff --git a/panda/src/text/textAssembler.cxx b/panda/src/text/textAssembler.cxx index 86fb8c8434..c427be8c79 100644 --- a/panda/src/text/textAssembler.cxx +++ b/panda/src/text/textAssembler.cxx @@ -234,7 +234,7 @@ get_plain_wtext() const { TextString::const_iterator si; for (si = _text_string.begin(); si != _text_string.end(); ++si) { const TextCharacter &tch = (*si); - if (tch._graphic == (TextGraphic *)NULL) { + if (tch._graphic == nullptr) { wtext += tch._character; } else { wtext.push_back(0); @@ -268,7 +268,7 @@ get_wordwrapped_plain_wtext() const { TextString::const_iterator si; for (si = row._string.begin(); si != row._string.end(); ++si) { const TextCharacter &tch = (*si); - if (tch._graphic == (TextGraphic *)NULL) { + if (tch._graphic == nullptr) { wtext += tch._character; } else { wtext.push_back(0); @@ -295,7 +295,7 @@ get_wtext() const { for (si = _text_string.begin(); si != _text_string.end(); ++si) { const TextCharacter &tch = (*si); current_cprops->append_delta(wtext, tch._cprops); - if (tch._graphic == (TextGraphic *)NULL) { + if (tch._graphic == nullptr) { wtext += tch._character; } else { wtext.push_back(text_embed_graphic_key); @@ -341,7 +341,7 @@ get_wordwrapped_wtext() const { for (si = row._string.begin(); si != row._string.end(); ++si) { const TextCharacter &tch = (*si); current_cprops->append_delta(wtext, tch._cprops); - if (tch._graphic == (TextGraphic *)NULL) { + if (tch._graphic == nullptr) { wtext += tch._character; } else { wtext.push_back(text_embed_graphic_key); @@ -519,7 +519,7 @@ assemble_text() { PT(GeomNode) text_geom_node = new GeomNode("text_geom"); text_node->add_child(text_geom_node); - const TextProperties *properties = NULL; + const TextProperties *properties = nullptr; CPT(RenderState) text_state; CPT(RenderState) shadow_state; LVector2 shadow(0); @@ -622,7 +622,7 @@ calc_width(wchar_t character, const TextProperties &properties) { if (character == ' ') { // A space is a special case. TextFont *font = properties.get_font(); - nassertr(font != (TextFont *)NULL, 0.0f); + nassertr(font != nullptr, 0.0f); return font->get_space_advance() * properties.get_glyph_scale() * properties.get_text_scale(); } @@ -639,10 +639,10 @@ calc_width(wchar_t character, const TextProperties &properties) { PN_stdfloat advance = 0.0f; - if (first_glyph != (TextGlyph *)NULL) { + if (first_glyph != nullptr) { advance = first_glyph->get_advance() * advance_scale; } - if (second_glyph != (TextGlyph *)NULL) { + if (second_glyph != nullptr) { advance += second_glyph->get_advance(); } @@ -681,7 +681,7 @@ has_exact_character(wchar_t character, const TextProperties &properties) { } TextFont *font = properties.get_font(); - nassertr(font != (TextFont *)NULL, false); + nassertr(font != nullptr, false); CPT(TextGlyph) glyph; return font->get_glyph(character, glyph); @@ -740,7 +740,7 @@ is_whitespace(wchar_t character, const TextProperties &properties) { TextFont *font = properties.get_font(); - nassertr(font != (TextFont *)NULL, false); + nassertr(font != nullptr, false); CPT(TextGlyph) glyph; if (!font->get_glyph(character, glyph)) { @@ -834,7 +834,7 @@ scan_wtext(TextAssembler::TextString &output_string, // Get the graphic image. const TextGraphic *named_graphic = manager->get_graphic_ptr(graphic_name); - if (named_graphic != (TextGraphic *)NULL) { + if (named_graphic != nullptr) { output_string.push_back(TextCharacter(named_graphic, graphic_wname, current_cprops)); } else { @@ -1107,7 +1107,7 @@ wordwrap_text() { PN_stdfloat TextAssembler:: calc_hyphen_width(const TextCharacter &tch) { TextFont *font = tch._cprops->_properties.get_font(); - nassertr(font != (TextFont *)NULL, 0.0f); + nassertr(font != nullptr, 0.0f); PN_stdfloat hyphen_width = 0.0f; wstring text_soft_hyphen_output = get_text_soft_hyphen_output(); @@ -1284,7 +1284,7 @@ generate_quads(GeomNode *geom_node, const QuadMap &quad_map) { } // We can compute this value much faster than GeomPrimitive can. - tris->set_minmax(0, i - 1, NULL, NULL); + tris->set_minmax(0, i - 1, nullptr, nullptr); PT(GeomTextGlyph) geom = new GeomTextGlyph(vdata); geom->_glyphs.swap(glyphs); @@ -1439,7 +1439,7 @@ assemble_row(TextAssembler::TextRow &row, } TextFont *font = properties->get_font(); - nassertv(font != (TextFont *)NULL); + nassertv(font != nullptr); // We get the row's alignment property from the first character of the row if ((align == TextProperties::A_left) && @@ -1454,7 +1454,7 @@ assemble_row(TextAssembler::TextRow &row, // And the height of the row is the maximum of all the fonts used within // the row. - if (graphic != (TextGraphic *)NULL) { + if (graphic != nullptr) { LVecBase4 frame = graphic->get_frame(); line_height = max(line_height, frame[3] - frame[2]); } else { @@ -1495,7 +1495,7 @@ assemble_row(TextAssembler::TextRow &row, } else if (character == text_soft_hyphen_key) { // And so is the 'soft-hyphen' key character. - } else if (graphic != (TextGraphic *)NULL) { + } else if (graphic != nullptr) { // A special embedded graphic. GlyphPlacement placement; @@ -1574,7 +1574,7 @@ assemble_row(TextAssembler::TextRow &row, // ligatures. GlyphPlacement placement; - placement._glyph = NULL; + placement._glyph = nullptr; placement._scale = glyph_scale; placement._xpos = xpos; placement._ypos = properties->get_glyph_shift(); @@ -1588,11 +1588,11 @@ assemble_row(TextAssembler::TextRow &row, // probably require the bounding volume of the glyph, so go get that. LPoint3 min_vert, max_vert; bool found_any = false; - if (first_glyph != NULL) { + if (first_glyph != nullptr) { first_glyph->calc_tight_bounds(min_vert, max_vert, found_any, current_thread); } - if (second_glyph != NULL) { + if (second_glyph != nullptr) { second_glyph->calc_tight_bounds(min_vert, max_vert, found_any, current_thread); } @@ -1625,7 +1625,7 @@ assemble_row(TextAssembler::TextRow &row, } } - if (first_glyph != (TextGlyph *)NULL) { + if (first_glyph != nullptr) { advance = first_glyph->get_advance() * advance_scale; if (!first_glyph->is_whitespace()) { swap(placement._glyph, first_glyph); @@ -1635,7 +1635,7 @@ assemble_row(TextAssembler::TextRow &row, // Check if there is a second glyph to create a hacky ligature or some // such nonsense. - if (second_glyph != (TextGlyph *)NULL) { + if (second_glyph != nullptr) { placement._xpos += advance * glyph_scale; advance += second_glyph->get_advance(); swap(placement._glyph, second_glyph); @@ -1660,14 +1660,14 @@ assemble_row(TextAssembler::TextRow &row, row_width = xpos; - if (row._eol_cprops != (ComputedProperties *)NULL) { + if (row._eol_cprops != nullptr) { // If there's an _eol_cprops, it represents the cprops of the newline // character that ended the line, which should also contribute towards the // line_height. const TextProperties *properties = &(row._eol_cprops->_properties); TextFont *font = properties->get_font(); - nassertv(font != (TextFont *)NULL); + nassertv(font != nullptr); if (line_height == 0.0f) { PN_stdfloat glyph_scale = properties->get_glyph_scale() * properties->get_text_scale(); @@ -1703,7 +1703,7 @@ shape_buffer(hb_buffer_t *buf, PlacedGlyphs &placed_glyphs, PN_stdfloat &xpos, DynamicTextFont *font = DCAST(DynamicTextFont, properties.get_font()); hb_font_t *hb_font = font->get_hb_font(); - hb_shape(hb_font, buf, NULL, 0); + hb_shape(hb_font, buf, nullptr, 0); PN_stdfloat glyph_scale = properties.get_glyph_scale() * properties.get_text_scale(); PN_stdfloat scale = glyph_scale / (font->get_pixels_per_unit() * font->get_scale_factor() * 64.0); @@ -1825,11 +1825,11 @@ get_character_glyphs(int character, const TextProperties *properties, int &additional_flags, PN_stdfloat &glyph_scale, PN_stdfloat &advance_scale) { TextFont *font = properties->get_font(); - nassertv_always(font != (TextFont *)NULL); + nassertv_always(font != nullptr); got_glyph = false; - glyph = NULL; - second_glyph = NULL; + glyph = nullptr; + second_glyph = nullptr; accent_type = UnicodeLatinMap::AT_none; additional_flags = 0; glyph_scale = 1.0f; @@ -1839,7 +1839,7 @@ get_character_glyphs(int character, const TextProperties *properties, // capital. const UnicodeLatinMap::Entry *map_entry = UnicodeLatinMap::look_up(character); - if (map_entry != NULL) { + if (map_entry != nullptr) { if (properties->get_small_caps() && map_entry->_toupper_character != character) { character = map_entry->_toupper_character; @@ -1849,7 +1849,7 @@ get_character_glyphs(int character, const TextProperties *properties, } got_glyph = font->get_glyph(character, glyph); - if (!got_glyph && map_entry != NULL && map_entry->_ascii_equiv != 0) { + if (!got_glyph && map_entry != nullptr && map_entry->_ascii_equiv != 0) { // If we couldn't find the Unicode glyph, try the ASCII equivalent // (without the accent marks). if (map_entry->_ascii_equiv == 'i') { @@ -1870,7 +1870,7 @@ get_character_glyphs(int character, const TextProperties *properties, // If we still couldn't find it, try the uppercase equivalent. character = map_entry->_toupper_character; map_entry = UnicodeLatinMap::look_up(character); - if (map_entry != NULL) { + if (map_entry != nullptr) { got_glyph = font->get_glyph(map_entry->_ascii_equiv, glyph); } } @@ -2067,7 +2067,7 @@ tack_on_accent(wchar_t accent_mark, TextAssembler::CheesyPosition position, const TextProperties *properties, TextAssembler::GlyphPlacement &placement) const { TextFont *font = properties->get_font(); - nassertr(font != (TextFont *)NULL, false); + nassertr(font != nullptr, false); Thread *current_thread = Thread::get_current_thread(); @@ -2319,14 +2319,14 @@ append_delta(wstring &wtext, TextAssembler::ComputedProperties *other) { if (this != other) { if (_depth > other->_depth) { // Back up a level from this properties. - nassertv(_based_on != NULL); + nassertv(_based_on != nullptr); wtext.push_back(text_pop_properties_key); _based_on->append_delta(wtext, other); } else if (other->_depth > _depth) { // Back up a level from the other properties. - nassertv(other->_based_on != NULL); + nassertv(other->_based_on != nullptr); append_delta(wtext, other->_based_on); wtext.push_back(text_push_properties_key); @@ -2335,7 +2335,7 @@ append_delta(wstring &wtext, TextAssembler::ComputedProperties *other) { } else if (_depth != 0) { // Back up a level from both properties. - nassertv(_based_on != NULL && other->_based_on != NULL); + nassertv(_based_on != nullptr && other->_based_on != nullptr); wtext.push_back(text_pop_properties_key); _based_on->append_delta(wtext, other->_based_on); @@ -2463,7 +2463,7 @@ assign_quad_to(QuadMap &quad_map, const RenderState *state, */ void TextAssembler::GlyphPlacement:: copy_graphic_to(PandaNode *node, const RenderState *state) const { - if (_graphic_model != (PandaNode *)NULL) { + if (_graphic_model != nullptr) { // We need an intermediate node to hold the transform and state. PT(PandaNode) intermediate_node = new PandaNode(""); node->add_child(intermediate_node); @@ -2510,29 +2510,29 @@ GeomCollector(const TextAssembler::GeomCollector ©) : GeomPrimitive *TextAssembler::GeomCollector:: get_primitive(TypeHandle prim_type) { if (prim_type == GeomTriangles::get_class_type()) { - if (_triangles == (GeomPrimitive *)NULL) { + if (_triangles == nullptr) { _triangles = new GeomTriangles(Geom::UH_static); _geom->add_primitive(_triangles); } return _triangles; } else if (prim_type == GeomLines::get_class_type()) { - if (_lines == (GeomPrimitive *)NULL) { + if (_lines == nullptr) { _lines = new GeomLines(Geom::UH_static); _geom->add_primitive(_lines); } return _lines; } else if (prim_type == GeomPoints::get_class_type()) { - if (_points == (GeomPrimitive *)NULL) { + if (_points == nullptr) { _points = new GeomPoints(Geom::UH_static); _geom->add_primitive(_points); } return _points; } - nassertr(false, NULL); - return NULL; + nassertr(false, nullptr); + return nullptr; } /** diff --git a/panda/src/text/textFont.cxx b/panda/src/text/textFont.cxx index add86483bd..866743a5e8 100644 --- a/panda/src/text/textFont.cxx +++ b/panda/src/text/textFont.cxx @@ -86,7 +86,7 @@ write(ostream &out, int indent_level) const { */ TextGlyph *TextFont:: get_invalid_glyph() { - if (_invalid_glyph == (TextGlyph *)NULL) { + if (_invalid_glyph == nullptr) { make_invalid_glyph(); } return _invalid_glyph; diff --git a/panda/src/text/textGlyph.I b/panda/src/text/textGlyph.I index 77b3b943b0..3b8b112f79 100644 --- a/panda/src/text/textGlyph.I +++ b/panda/src/text/textGlyph.I @@ -17,7 +17,7 @@ INLINE TextGlyph:: TextGlyph(int character, PN_stdfloat advance) : _character(character), - _geom((Geom *)NULL), + _geom(nullptr), _advance(advance), _has_quad(false) { @@ -35,10 +35,10 @@ TextGlyph(int character, const Geom *geom, _advance(advance), _has_quad(false) { - if (geom != NULL) { + if (geom != nullptr) { check_quad_geom(); } - if (_state == (RenderState *)NULL) { + if (_state == nullptr) { _state = RenderState::make_empty(); } } diff --git a/panda/src/text/textGlyph.cxx b/panda/src/text/textGlyph.cxx index 0d3de18db6..d68dce6371 100644 --- a/panda/src/text/textGlyph.cxx +++ b/panda/src/text/textGlyph.cxx @@ -51,11 +51,11 @@ get_geom(Geom::UsageHint usage_hint) const { if (_has_quad) { ((TextGlyph *)this)->make_quad_geom(); if (_geom.is_null()) { - return (Geom *)NULL; + return nullptr; } } else { // Nope. - return (Geom *)NULL; + return nullptr; } } @@ -67,7 +67,7 @@ get_geom(Geom::UsageHint usage_hint) const { PT(Geom) new_geom = new GeomTextGlyph(*_geom, this); new_geom->set_usage_hint(usage_hint); const GeomVertexData *vdata = new_geom->get_vertex_data(); - nassertr(vdata != NULL, new_geom); + nassertr(vdata != nullptr, new_geom); if (vdata->get_usage_hint() != usage_hint) { new_geom->modify_vertex_data()->set_usage_hint(usage_hint); } diff --git a/panda/src/text/textNode.I b/panda/src/text/textNode.I index 41758ba28a..dd10624d27 100644 --- a/panda/src/text/textNode.I +++ b/panda/src/text/textNode.I @@ -19,7 +19,7 @@ INLINE PN_stdfloat TextNode:: get_line_height() const { TextFont *font = get_font(); - if (font == (TextFont *)NULL) { + if (font == nullptr) { return 0.0f; } @@ -182,7 +182,7 @@ get_card_color() const { */ INLINE void TextNode:: set_card_texture(Texture *card_texture) { - if (card_texture == (Texture *)NULL) { + if (card_texture == nullptr) { clear_card_texture(); } else { if (!has_card_texture() || _card_texture != card_texture) { @@ -200,7 +200,7 @@ INLINE void TextNode:: clear_card_texture() { if (has_card_texture()) { _flags &= ~F_has_card_texture; - _card_texture = NULL; + _card_texture = nullptr; invalidate_no_measure(); } } diff --git a/panda/src/text/textNode.cxx b/panda/src/text/textNode.cxx index 454c7dd7f3..7e0e687ada 100644 --- a/panda/src/text/textNode.cxx +++ b/panda/src/text/textNode.cxx @@ -174,7 +174,7 @@ TextNode:: PN_stdfloat TextNode:: calc_width(wchar_t character) const { TextFont *font = get_font(); - if (font == (TextFont *)NULL) { + if (font == nullptr) { return 0.0f; } @@ -196,7 +196,7 @@ calc_width(wchar_t character) const { bool TextNode:: has_exact_character(wchar_t character) const { TextFont *font = get_font(); - if (font == (TextFont *)NULL) { + if (font == nullptr) { return false; } @@ -215,7 +215,7 @@ has_exact_character(wchar_t character) const { bool TextNode:: has_character(wchar_t character) const { TextFont *font = get_font(); - if (font == (TextFont *)NULL) { + if (font == nullptr) { return false; } @@ -239,7 +239,7 @@ has_character(wchar_t character) const { bool TextNode:: is_whitespace(wchar_t character) const { TextFont *font = get_font(); - if (font == (TextFont *)NULL) { + if (font == nullptr) { return false; } @@ -272,7 +272,7 @@ output(ostream &out) const { check_rebuild(); int geom_count = 0; - if (_internal_geom != (PandaNode *)NULL) { + if (_internal_geom != nullptr) { geom_count = count_geoms(_internal_geom); } @@ -333,7 +333,7 @@ generate() { } TextFont *font = get_font(); - if (font == (TextFont *)NULL) { + if (font == nullptr) { return root; } @@ -514,7 +514,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, } } if ((attrib_types & SceneGraphReducer::TT_color) != 0) { - if (attribs._color != (const RenderAttrib *)NULL) { + if (attribs._color != nullptr) { const ColorAttrib *ca = DCAST(ColorAttrib, attribs._color); if (ca->get_color_type() == ColorAttrib::T_flat) { const LColor &c = ca->get_color(); @@ -526,7 +526,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, } } if ((attrib_types & SceneGraphReducer::TT_color_scale) != 0) { - if (attribs._color_scale != (const RenderAttrib *)NULL) { + if (attribs._color_scale != nullptr) { const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attribs._color_scale); const LVecBase4 &s = csa->get_scale(); if (s != LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)) { @@ -561,7 +561,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, // Now propagate the attributes down to our already-generated geometry, if // we have any. if ((_flags & F_needs_rebuild) == 0 && - _internal_geom != (PandaNode *)NULL) { + _internal_geom != nullptr) { SceneGraphReducer gr; gr.apply_attribs(_internal_geom, attribs, attrib_types, transformer); } @@ -587,7 +587,7 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, check_rebuild(); - if (_internal_geom != (PandaNode *)NULL) { + if (_internal_geom != nullptr) { _internal_geom->calc_tight_bounds(min_point, max_point, found_any, next_transform, current_thread); } @@ -616,7 +616,7 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, bool TextNode:: cull_callback(CullTraverser *trav, CullTraverserData &data) { check_rebuild(); - if (_internal_geom != (PandaNode *)NULL) { + if (_internal_geom != nullptr) { // Render the text with this node. CullTraverserData next_data(data, _internal_geom); trav->traverse(next_data); @@ -682,7 +682,7 @@ r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state, check_rebuild(); PandaNode *child = _internal_geom; - if (child != (PandaNode *)NULL) { + if (child != nullptr) { CPT(RenderState) child_state = node_state->compose(child->get_state()); child->r_prepare_scene(gsg, child_state, transformer, current_thread); } diff --git a/panda/src/text/textProperties.cxx b/panda/src/text/textProperties.cxx index 341f2385a3..dea089b612 100644 --- a/panda/src/text/textProperties.cxx +++ b/panda/src/text/textProperties.cxx @@ -259,7 +259,7 @@ write(ostream &out, int indent_level) const { << "default properties\n"; } if (has_font()) { - if (get_font() != (TextFont *)NULL) { + if (get_font() != nullptr) { indent(out, indent_level) << "with font " << _font->get_name() << "\n"; } else { @@ -450,7 +450,7 @@ load_default_font() { if (!text_default_font.empty()) { // First, attempt to load the user-specified filename. _default_font = FontPool::load_font(text_default_font.get_value()); - if (_default_font != (TextFont *)NULL && _default_font->is_valid()) { + if (_default_font != nullptr && _default_font->is_valid()) { return; } } @@ -481,7 +481,7 @@ load_default_font() { BamFile bam_file; if (bam_file.open_read(in, "default font stream")) { PT(PandaNode) node = bam_file.read_node(); - if (node != (PandaNode *)NULL) { + if (node != nullptr) { _default_font = new StaticTextFont(node); } } diff --git a/panda/src/text/textPropertiesManager.cxx b/panda/src/text/textPropertiesManager.cxx index 2d8c93fd32..c057196e52 100644 --- a/panda/src/text/textPropertiesManager.cxx +++ b/panda/src/text/textPropertiesManager.cxx @@ -14,7 +14,7 @@ #include "textPropertiesManager.h" #include "indent.h" -TextPropertiesManager *TextPropertiesManager::_global_ptr = (TextPropertiesManager *)NULL; +TextPropertiesManager *TextPropertiesManager::_global_ptr = nullptr; /** * The constructor is not intended to be called directly; there is only one @@ -193,7 +193,7 @@ write(ostream &out, int indent_level) const { */ TextPropertiesManager *TextPropertiesManager:: get_global_ptr() { - if (_global_ptr == (TextPropertiesManager *)NULL) { + if (_global_ptr == nullptr) { _global_ptr = new TextPropertiesManager; } return _global_ptr; @@ -210,7 +210,7 @@ get_properties_ptr(const string &name) { if (pi != _properties.end()) { return &(*pi).second; } - return NULL; + return nullptr; } /** @@ -224,5 +224,5 @@ get_graphic_ptr(const string &name) { if (pi != _graphics.end()) { return &(*pi).second; } - return NULL; + return nullptr; } diff --git a/panda/src/tform/driveInterface.cxx b/panda/src/tform/driveInterface.cxx index f9324ce110..e9adfd8829 100644 --- a/panda/src/tform/driveInterface.cxx +++ b/panda/src/tform/driveInterface.cxx @@ -383,7 +383,7 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, } // Look for keyboard events. - if (required_buttons_match && button_events != (const ButtonEventList *)NULL) { + if (required_buttons_match && button_events != nullptr) { int num_events = button_events->get_num_events(); for (int i = 0; i < num_events; i++) { diff --git a/panda/src/tform/mouseInterfaceNode.cxx b/panda/src/tform/mouseInterfaceNode.cxx index b69a17d06e..22031c4219 100644 --- a/panda/src/tform/mouseInterfaceNode.cxx +++ b/panda/src/tform/mouseInterfaceNode.cxx @@ -117,10 +117,10 @@ watch_button(const ButtonHandle &button) { const ButtonEventList *MouseInterfaceNode:: check_button_events(const DataNodeTransmit &input, bool &required_buttons_match) { - const ButtonEventList *button_events = NULL; + const ButtonEventList *button_events = nullptr; if (input.has_data(_button_events_input)) { - DCAST_INTO_R(button_events, input.get_data(_button_events_input).get_ptr(), NULL); + DCAST_INTO_R(button_events, input.get_data(_button_events_input).get_ptr(), nullptr); button_events->update_mods(_current_button_state); } diff --git a/panda/src/tform/mouseWatcher.I b/panda/src/tform/mouseWatcher.I index 389861e8d9..7d709f252e 100644 --- a/panda/src/tform/mouseWatcher.I +++ b/panda/src/tform/mouseWatcher.I @@ -101,7 +101,7 @@ get_frame() const { */ INLINE bool MouseWatcher:: is_over_region() const { - return get_over_region() != (MouseWatcherRegion *)NULL; + return get_over_region() != nullptr; } /** @@ -109,7 +109,7 @@ is_over_region() const { */ INLINE bool MouseWatcher:: is_over_region(PN_stdfloat x, PN_stdfloat y) const { - return get_over_region(x, y) != (MouseWatcherRegion *)NULL; + return get_over_region(x, y) != nullptr; } /** @@ -117,7 +117,7 @@ is_over_region(PN_stdfloat x, PN_stdfloat y) const { */ INLINE bool MouseWatcher:: is_over_region(const LPoint2 &pos) const { - return get_over_region(pos) != (MouseWatcherRegion *)NULL; + return get_over_region(pos) != nullptr; } /** @@ -391,7 +391,7 @@ get_modifier_buttons() const { INLINE void MouseWatcher:: set_display_region(DisplayRegion *dr) { _display_region = dr; - _button_down_display_region = NULL; + _button_down_display_region = nullptr; } /** @@ -400,8 +400,8 @@ set_display_region(DisplayRegion *dr) { */ INLINE void MouseWatcher:: clear_display_region() { - _display_region = NULL; - _button_down_display_region = NULL; + _display_region = nullptr; + _button_down_display_region = nullptr; } /** @@ -421,7 +421,7 @@ get_display_region() const { */ INLINE bool MouseWatcher:: has_display_region() const { - return (_display_region != (DisplayRegion *)NULL); + return (_display_region != nullptr); } /** diff --git a/panda/src/tform/mouseWatcher.cxx b/panda/src/tform/mouseWatcher.cxx index 30f2c4762e..eac710d414 100644 --- a/panda/src/tform/mouseWatcher.cxx +++ b/panda/src/tform/mouseWatcher.cxx @@ -62,12 +62,12 @@ MouseWatcher(const string &name) : _has_mouse = false; _internal_suppress = 0; - _preferred_region = (MouseWatcherRegion *)NULL; - _preferred_button_down_region = (MouseWatcherRegion *)NULL; + _preferred_region = nullptr; + _preferred_button_down_region = nullptr; _button_down = false; - _eh = (EventHandler *)NULL; - _display_region = (DisplayRegion *)NULL; - _button_down_display_region = (DisplayRegion *)NULL; + _eh = nullptr; + _display_region = nullptr; + _button_down_display_region = nullptr; _frame.set(-1.0f, 1.0f, -1.0f, 1.0f); @@ -109,13 +109,13 @@ remove_region(MouseWatcherRegion *region) { remove_region_from(_current_regions, region); if (region == _preferred_region) { - if (_preferred_region != (MouseWatcherRegion *)NULL) { + if (_preferred_region != nullptr) { exit_region(_preferred_region, MouseWatcherParameter()); } - _preferred_region = (MouseWatcherRegion *)NULL; + _preferred_region = nullptr; } if (region == _preferred_button_down_region) { - _preferred_button_down_region = (MouseWatcherRegion *)NULL; + _preferred_button_down_region = nullptr; } return MouseWatcherBase::do_remove_region(region); @@ -190,13 +190,13 @@ remove_group(MouseWatcherGroup *group) { set_current_regions(only_a); if (has_region_in(both, _preferred_region)) { - if (_preferred_region != (MouseWatcherRegion *)NULL) { + if (_preferred_region != nullptr) { exit_region(_preferred_region, MouseWatcherParameter()); } - _preferred_region = (MouseWatcherRegion *)NULL; + _preferred_region = nullptr; } if (has_region_in(both, _preferred_button_down_region)) { - _preferred_button_down_region = (MouseWatcherRegion *)NULL; + _preferred_button_down_region = nullptr; } #ifndef NDEBUG @@ -268,13 +268,13 @@ replace_group(MouseWatcherGroup *old_group, MouseWatcherGroup *new_group) { any_new_current_regions = true; if (has_region_in(both, _preferred_region)) { - if (_preferred_region != (MouseWatcherRegion *)NULL) { + if (_preferred_region != nullptr) { exit_region(_preferred_region, MouseWatcherParameter()); } - _preferred_region = (MouseWatcherRegion *)NULL; + _preferred_region = nullptr; } if (has_region_in(both, _preferred_button_down_region)) { - _preferred_button_down_region = (MouseWatcherRegion *)NULL; + _preferred_button_down_region = nullptr; } } @@ -343,7 +343,7 @@ get_num_groups() const { MouseWatcherGroup *MouseWatcher:: get_group(int n) const { LightMutexHolder holder(_lock); - nassertr(n >= 0 && n < (int)_groups.size(), NULL); + nassertr(n >= 0 && n < (int)_groups.size(), nullptr); return _groups[n]; } @@ -397,7 +397,7 @@ discard_excess_trail_log() { */ PT(GeomNode) MouseWatcher:: get_trail_node() { - if (_trail_node == 0) { + if (_trail_node == nullptr) { _trail_node = new GeomNode("Mouse Trail Node"); update_trail_node(); } @@ -412,7 +412,7 @@ get_trail_node() { */ void MouseWatcher:: clear_trail_node() { - _trail_node = 0; + _trail_node = nullptr; } /** @@ -420,7 +420,7 @@ clear_trail_node() { */ void MouseWatcher:: update_trail_node() { - if (_trail_node == 0) { + if (_trail_node == nullptr) { return; } _trail_node->remove_all_geoms(); @@ -584,7 +584,7 @@ get_over_regions(MouseWatcher::Regions ®ions, const LPoint2 &pos) const { MouseWatcherRegion *MouseWatcher:: get_preferred_region(const MouseWatcher::Regions ®ions) { if (regions.empty()) { - return (MouseWatcherRegion *)NULL; + return nullptr; } Regions::const_iterator ri; @@ -689,15 +689,15 @@ set_current_regions(MouseWatcher::Regions ®ions) { if (_button_down && new_preferred_region != _preferred_button_down_region) { // If the button's being held down, we're only allowed to select the // preferred button down region. - new_preferred_region = (MouseWatcherRegion *)NULL; + new_preferred_region = nullptr; } if (new_preferred_region != _preferred_region) { - if (_preferred_region != (MouseWatcherRegion *)NULL) { + if (_preferred_region != nullptr) { exit_region(_preferred_region, param); } _preferred_region = new_preferred_region; - if (_preferred_region != (MouseWatcherRegion *)NULL) { + if (_preferred_region != nullptr) { enter_region(_preferred_region, param); } } @@ -729,10 +729,10 @@ clear_current_regions() { _current_regions.clear(); - if (_preferred_region != (MouseWatcherRegion *)NULL) { + if (_preferred_region != nullptr) { _preferred_region->exit_region(param); throw_event_pattern(_leave_pattern, _preferred_region, ButtonHandle::none()); - _preferred_region = (MouseWatcherRegion *)NULL; + _preferred_region = nullptr; } } } @@ -859,7 +859,7 @@ throw_event_pattern(const string &pattern, const MouseWatcherRegion *region, return; } #ifndef NDEBUG - if (region != (MouseWatcherRegion *)NULL) { + if (region != nullptr) { region->test_ref_count_integrity(); } #endif @@ -880,7 +880,7 @@ throw_event_pattern(const string &pattern, const MouseWatcherRegion *region, string cmd = pattern.substr(p + 1, 1); p++; if (cmd == "r") { - if (region != (MouseWatcherRegion *)NULL) { + if (region != nullptr) { event += region->get_name(); } @@ -898,7 +898,7 @@ throw_event_pattern(const string &pattern, const MouseWatcherRegion *region, if (!event.empty()) { throw_event(event, EventParameter(region), EventParameter(button_name)); - if (_eh != (EventHandler*)0L) + if (_eh != nullptr) throw_event_directly(*_eh, event, EventParameter(region), EventParameter(button_name)); } @@ -916,7 +916,7 @@ move() { param.set_modifier_buttons(_mods); param.set_mouse(_mouse); - if (_preferred_button_down_region != (MouseWatcherRegion *)NULL) { + if (_preferred_button_down_region != nullptr) { _preferred_button_down_region->move(param); } } @@ -942,7 +942,7 @@ press(ButtonHandle button, bool keyrepeat) { } _button_down = true; - if (_preferred_button_down_region != (MouseWatcherRegion *)NULL) { + if (_preferred_button_down_region != nullptr) { _preferred_button_down_region->press(param); if (keyrepeat) { throw_event_pattern(_button_repeat_pattern, @@ -956,7 +956,7 @@ press(ButtonHandle button, bool keyrepeat) { } else { // It's a keyboard button; therefore, send the event to every region that // wants keyboard buttons, regardless of the mouse position. - if (_preferred_region != (MouseWatcherRegion *)NULL) { + if (_preferred_region != nullptr) { // Our current region, the one under the mouse, always get all the // keyboard events, even if it doesn't set its keyboard flag. _preferred_region->press(param); @@ -992,7 +992,7 @@ release(ButtonHandle button) { // There is some danger of losing button-up events here. If more than one // button goes down together, we won't detect both of the button-up events // properly. - if (_preferred_button_down_region != (MouseWatcherRegion *)NULL) { + if (_preferred_button_down_region != nullptr) { param.set_outside(_preferred_button_down_region != _preferred_region); _preferred_button_down_region->release(param); throw_event_pattern(_button_up_pattern, @@ -1000,12 +1000,12 @@ release(ButtonHandle button) { } _button_down = false; - _preferred_button_down_region = (MouseWatcherRegion *)NULL; + _preferred_button_down_region = nullptr; } else { // It's a keyboard button; therefore, send the event to every region that // wants keyboard buttons, regardless of the mouse position. - if (_preferred_region != (MouseWatcherRegion *)NULL) { + if (_preferred_region != nullptr) { _preferred_region->release(param); } @@ -1302,7 +1302,7 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, move(); } - if (_display_region != (DisplayRegion *)NULL) { + if (_display_region != nullptr) { // If we've got a display region, constrain the mouse to it. if (constrain_display_region(_display_region, f, p, current_thread)) { set_mouse(f, p); @@ -1348,7 +1348,7 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, // If the mouse is over a particular region, or still considered owned by a // region because of a recent button-down event, that region determines // whether we suppress events below us. - if (_preferred_region != (MouseWatcherRegion *)NULL) { + if (_preferred_region != nullptr) { _internal_suppress |= _preferred_region->get_suppress_flags(); } @@ -1547,9 +1547,9 @@ constrain_display_region(DisplayRegion *display_region, LVecBase2 &f, LVecBase2 &p, Thread *current_thread) { if (!_button_down) { - _button_down_display_region = NULL; + _button_down_display_region = nullptr; } - if (_button_down_display_region != NULL) { + if (_button_down_display_region != nullptr) { // If the button went down over this DisplayRegion, we consider the button // within the same DisplayRegion until it is released (even if it wanders // outside the borders). @@ -1574,7 +1574,7 @@ constrain_display_region(DisplayRegion *display_region, PN_stdfloat x = (f[0] + 1.0f) / 2.0f; PN_stdfloat y = (f[1] + 1.0f) / 2.0f; - if (_button_down_display_region == NULL && + if (_button_down_display_region == nullptr && (x < left || x >= right || y < bottom || y >= top)) { // The mouse is outside the display region. return false; diff --git a/panda/src/tform/mouseWatcherBase.cxx b/panda/src/tform/mouseWatcherBase.cxx index 6d86c384f1..820fb81d90 100644 --- a/panda/src/tform/mouseWatcherBase.cxx +++ b/panda/src/tform/mouseWatcherBase.cxx @@ -119,7 +119,7 @@ find_region(const string &name) const { } } - return (MouseWatcherRegion *)NULL; + return nullptr; } /** @@ -180,7 +180,7 @@ get_region(int n) const { if (n >= 0 && n < (int)_regions.size()) { return _regions[n]; } - return NULL; + return nullptr; } /** @@ -366,7 +366,7 @@ do_update_regions() { */ PandaNode *MouseWatcherBase:: make_viz_region(MouseWatcherRegion *region) { - nassertr(_lock.debug_is_locked(), NULL); + nassertr(_lock.debug_is_locked(), nullptr); LineSegs ls("show_regions"); ls.set_color(_color); diff --git a/panda/src/tform/transform2sg.cxx b/panda/src/tform/transform2sg.cxx index 6adfb944c4..3f7137af56 100644 --- a/panda/src/tform/transform2sg.cxx +++ b/panda/src/tform/transform2sg.cxx @@ -28,7 +28,7 @@ Transform2SG(const string &name) : { _transform_input = define_input("transform", TransformState::get_class_type()); - _node = NULL; + _node = nullptr; } /** @@ -65,7 +65,7 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, if (input.has_data(_transform_input)) { const TransformState *transform; DCAST_INTO_V(transform, input.get_data(_transform_input).get_ptr()); - if (_node != (PandaNode *)NULL) { + if (_node != nullptr) { _node->set_transform(transform, current_thread); } } diff --git a/panda/src/tinydisplay/init.cxx b/panda/src/tinydisplay/init.cxx index 2e11dee3c2..40ca74c31c 100644 --- a/panda/src/tinydisplay/init.cxx +++ b/panda/src/tinydisplay/init.cxx @@ -18,7 +18,7 @@ void glInit(GLContext *c, ZBuffer *zbuffer) v->updated=1; /* lights */ - c->first_light=NULL; + c->first_light=nullptr; c->ambient_light_model=gl_V4_New(0.2, 0.2, 0.2, 1.0f); c->local_light_model=0; c->lighting_enabled=0; @@ -50,7 +50,7 @@ void glInit(GLContext *c, ZBuffer *zbuffer) c->cull_face_enabled=0; /* specular buffer */ - c->specbuf_first = NULL; + c->specbuf_first = nullptr; c->specbuf_used_counter = 0; c->specbuf_num_buffers = 0; diff --git a/panda/src/tinydisplay/specbuf.cxx b/panda/src/tinydisplay/specbuf.cxx index d0c153714e..d058459e80 100644 --- a/panda/src/tinydisplay/specbuf.cxx +++ b/panda/src/tinydisplay/specbuf.cxx @@ -30,7 +30,7 @@ specbuf_get_buffer(GLContext *c, const int shininess_i, found->last_used = c->specbuf_used_counter++; return found; } - if (oldest == NULL || c->specbuf_num_buffers < MAX_SPECULAR_BUFFERS) { + if (oldest == nullptr || c->specbuf_num_buffers < MAX_SPECULAR_BUFFERS) { /* create new buffer */ GLSpecBuf *buf = (GLSpecBuf *)gl_malloc(sizeof(GLSpecBuf)); if (!buf) gl_fatal_error("could not allocate specular buffer"); diff --git a/panda/src/tinydisplay/td_light.cxx b/panda/src/tinydisplay/td_light.cxx index c49b47e4b4..c570e5347c 100644 --- a/panda/src/tinydisplay/td_light.cxx +++ b/panda/src/tinydisplay/td_light.cxx @@ -29,7 +29,7 @@ void gl_shade_vertex(GLContext *c,GLVertex *v) B=m->emission.v[2]+m->ambient.v[2]*c->ambient_light_model.v[2]; A=clampf(m->diffuse.v[3],0,1); - for(l=c->first_light;l!=NULL;l=l->next) { + for(l=c->first_light;l!=nullptr;l=l->next) { PN_stdfloat lR,lB,lG; /* ambient */ diff --git a/panda/src/tinydisplay/tinyGraphicsBuffer.cxx b/panda/src/tinydisplay/tinyGraphicsBuffer.cxx index adeceabd01..95599e9b22 100644 --- a/panda/src/tinydisplay/tinyGraphicsBuffer.cxx +++ b/panda/src/tinydisplay/tinyGraphicsBuffer.cxx @@ -33,7 +33,7 @@ TinyGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, GraphicsOutput *host) : GraphicsBuffer(engine, pipe, name, fb_prop, win_prop, flags, gsg, host) { - _frame_buffer = NULL; + _frame_buffer = nullptr; } /** @@ -52,7 +52,7 @@ TinyGraphicsBuffer:: bool TinyGraphicsBuffer:: begin_frame(FrameMode mode, Thread *current_thread) { begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } @@ -74,7 +74,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void TinyGraphicsBuffer:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { // end_render_texture(); @@ -94,10 +94,10 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void TinyGraphicsBuffer:: close_buffer() { - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { TinyGraphicsStateGuardian *tinygsg; DCAST_INTO_V(tinygsg, _gsg); - tinygsg->_current_frame_buffer = NULL; + tinygsg->_current_frame_buffer = nullptr; _gsg.clear(); } @@ -114,14 +114,14 @@ open_buffer() { TinyGraphicsStateGuardian *tinygsg; if (_gsg == 0) { // There is no old gsg. Create a new one. - tinygsg = new TinyGraphicsStateGuardian(_engine, _pipe, NULL); + tinygsg = new TinyGraphicsStateGuardian(_engine, _pipe, nullptr); _gsg = tinygsg; } else { DCAST_INTO_R(tinygsg, _gsg, false); } create_frame_buffer(); - if (_frame_buffer == NULL) { + if (_frame_buffer == nullptr) { tinydisplay_cat.error() << "Could not create frame buffer.\n"; return false; @@ -144,9 +144,9 @@ open_buffer() { */ void TinyGraphicsBuffer:: create_frame_buffer() { - if (_frame_buffer != NULL) { + if (_frame_buffer != nullptr) { ZB_close(_frame_buffer); - _frame_buffer = NULL; + _frame_buffer = nullptr; } _frame_buffer = ZB_open(get_fb_x_size(), get_fb_y_size(), ZB_MODE_RGBA, 0, 0, 0, 0); diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.I b/panda/src/tinydisplay/tinyGraphicsStateGuardian.I index cac827cf09..efda44e790 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.I +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.I @@ -19,11 +19,11 @@ clear_light_state() { _c->lighting_enabled = false; #ifndef NDEBUG GLLight *gl_light = _c->first_light; - while (gl_light != (GLLight *)NULL) { + while (gl_light != nullptr) { GLLight *next = gl_light->next; - gl_light->next = NULL; + gl_light->next = nullptr; gl_light = next; } #endif // NDEBUG - _c->first_light = NULL; + _c->first_light = nullptr; } diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index 07f7ad4e6b..782d461dc2 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -64,10 +64,10 @@ TinyGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, TinyGraphicsStateGuardian *share_with) : GraphicsStateGuardian(CS_yup_right, engine, pipe) { - _current_frame_buffer = NULL; - _aux_frame_buffer = NULL; - _c = NULL; - _vertices = NULL; + _current_frame_buffer = nullptr; + _aux_frame_buffer = nullptr; + _c = nullptr; + _vertices = nullptr; _vertices_size = 0; } @@ -99,9 +99,9 @@ reset() { _inv_state_mask.clear_bit(LightAttrib::get_class_slot()); _inv_state_mask.clear_bit(ScissorAttrib::get_class_slot()); - if (_c != (GLContext *)NULL) { + if (_c != nullptr) { glClose(_c); - _c = NULL; + _c = nullptr; } _c = (GLContext *)gl_zalloc(sizeof(GLContext)); @@ -142,14 +142,14 @@ reset() { */ void TinyGraphicsStateGuardian:: free_pointers() { - if (_aux_frame_buffer != (ZBuffer *)NULL) { + if (_aux_frame_buffer != nullptr) { ZB_close(_aux_frame_buffer); - _aux_frame_buffer = NULL; + _aux_frame_buffer = nullptr; } - if (_vertices != (GLVertex *)NULL) { + if (_vertices != nullptr) { PANDA_FREE_ARRAY(_vertices); - _vertices = NULL; + _vertices = nullptr; } _vertices_size = 0; } @@ -163,9 +163,9 @@ void TinyGraphicsStateGuardian:: close_gsg() { GraphicsStateGuardian::close_gsg(); - if (_c != (GLContext *)NULL) { + if (_c != nullptr) { glClose(_c); - _c = NULL; + _c = nullptr; } } @@ -245,7 +245,7 @@ clear(DrawableRegion *clearable) { */ void TinyGraphicsStateGuardian:: prepare_display_region(DisplayRegionPipelineReader *dr) { - nassertv(dr != (DisplayRegionPipelineReader *)NULL); + nassertv(dr != nullptr); GraphicsStateGuardian::prepare_display_region(dr); int xmin, ymin, xsize, ysize; @@ -259,10 +259,10 @@ prepare_display_region(DisplayRegionPipelineReader *dr) { ymin = 0; xsize = int(xsize * pixel_factor); ysize = int(ysize * pixel_factor); - if (_aux_frame_buffer == (ZBuffer *)NULL) { + if (_aux_frame_buffer == nullptr) { _aux_frame_buffer = ZB_open(xsize, ysize, ZB_MODE_RGBA, 0, 0, 0, 0); } else if (_aux_frame_buffer->xsize < xsize || _aux_frame_buffer->ysize < ysize) { - ZB_resize(_aux_frame_buffer, NULL, + ZB_resize(_aux_frame_buffer, nullptr, max(_aux_frame_buffer->xsize, xsize), max(_aux_frame_buffer->ysize, ysize)); } @@ -295,12 +295,12 @@ prepare_display_region(DisplayRegionPipelineReader *dr) { */ CPT(TransformState) TinyGraphicsStateGuardian:: calc_projection_mat(const Lens *lens) { - if (lens == (Lens *)NULL) { - return NULL; + if (lens == nullptr) { + return nullptr; } if (!lens->is_linear()) { - return NULL; + return nullptr; } // The projection matrix must always be right-handed Y-up, even if our @@ -481,7 +481,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, if (!GraphicsStateGuardian::begin_draw_primitives(geom_reader, data_reader, force)) { return false; } - nassertr(_data_reader != (GeomVertexDataPipelineReader *)NULL, false); + nassertr(_data_reader != nullptr, false); PStatTimer timer(_draw_transform_pcollector); @@ -557,7 +557,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, while (_vertices_size < num_used_vertices) { _vertices_size *= 2; } - if (_vertices != (GLVertex *)NULL) { + if (_vertices != nullptr) { PANDA_FREE_ARRAY(_vertices); } _vertices = (GLVertex *)PANDA_MALLOC_ARRAY(_vertices_size * sizeof(GLVertex)); @@ -960,7 +960,7 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint8: { uint8_t *index = (uint8_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } for (int i = 0; i < num_vertices; i += 3) { @@ -975,7 +975,7 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint16: { uint16_t *index = (uint16_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } for (int i = 0; i < num_vertices; i += 3) { @@ -990,7 +990,7 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint32: { uint32_t *index = (uint32_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } for (int i = 0; i < num_vertices; i += 3) { @@ -1051,7 +1051,7 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint8: { uint8_t *index = (uint8_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } GLVertex *v0 = &_vertices[index[start] - _min_vertex]; @@ -1076,7 +1076,7 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint16: { uint16_t *index = (uint16_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } GLVertex *v0 = &_vertices[index[start] - _min_vertex]; @@ -1101,7 +1101,7 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint32: { uint32_t *index = (uint32_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } GLVertex *v0 = &_vertices[index[start] - _min_vertex]; @@ -1182,7 +1182,7 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint8: { uint8_t *index = (uint8_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } for (int i = 0; i < num_vertices; i += 2) { @@ -1196,7 +1196,7 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint16: { uint16_t *index = (uint16_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } for (int i = 0; i < num_vertices; i += 2) { @@ -1210,7 +1210,7 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint32: { uint32_t *index = (uint32_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } for (int i = 0; i < num_vertices; i += 2) { @@ -1259,7 +1259,7 @@ draw_points(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint8: { uint8_t *index = (uint8_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } for (int i = 0; i < num_vertices; ++i) { @@ -1272,7 +1272,7 @@ draw_points(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint16: { uint16_t *index = (uint16_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } for (int i = 0; i < num_vertices; ++i) { @@ -1285,7 +1285,7 @@ draw_points(const GeomPrimitivePipelineReader *reader, bool force) { case Geom::NT_uint32: { uint32_t *index = (uint32_t *)reader->get_read_pointer(force); - if (index == NULL) { + if (index == nullptr) { return false; } for (int i = 0; i < num_vertices; ++i) { @@ -1346,7 +1346,7 @@ bool TinyGraphicsStateGuardian:: framebuffer_copy_to_texture(Texture *tex, int view, int z, const DisplayRegion *dr, const RenderBuffer &rb) { - nassertr(tex != NULL && dr != NULL, false); + nassertr(tex != nullptr && dr != nullptr, false); int xo, yo, w, h; dr->get_region_pixels_i(xo, yo, w, h); @@ -1354,7 +1354,7 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, tex->setup_2d_texture(w, h, Texture::T_unsigned_byte, Texture::F_rgba); TextureContext *tc = tex->prepare_now(view, get_prepared_objects(), this); - nassertr(tc != (TextureContext *)NULL, false); + nassertr(tc != nullptr, false); TinyTextureContext *gtc = DCAST(TinyTextureContext, tc); GLTexture *gltex = >c->_gltex; @@ -1394,7 +1394,7 @@ bool TinyGraphicsStateGuardian:: framebuffer_copy_to_ram(Texture *tex, int view, int z, const DisplayRegion *dr, const RenderBuffer &rb) { - nassertr(tex != NULL && dr != NULL, false); + nassertr(tex != nullptr && dr != nullptr, false); int xo, yo, w, h; dr->get_region_pixels_i(xo, yo, w, h); @@ -1610,7 +1610,7 @@ prepare_texture(Texture *tex, int view) { tinydisplay_cat.info() << "Not loading texture " << tex->get_name() << ": " << tex->get_texture_type() << "\n"; - return NULL; + return nullptr; } // Even though the texture might be compressed now, it might have an @@ -1763,7 +1763,7 @@ do_issue_light() { // Handle the diffuse color here, since all lights have this property. GLLight *gl_light = _c->first_light; - nassertv(gl_light != NULL); + nassertv(gl_light != nullptr); const LColor &diffuse = light_obj->get_color(); gl_light->diffuse.v[0] = diffuse[0]; gl_light->diffuse.v[1] = diffuse[1]; @@ -1828,7 +1828,7 @@ bind_light(PointLight *light_obj, const NodePath &light, int light_id) { gl_light->attenuation[2] = att[2]; } - nassertv(gl_light->next == NULL); + nassertv(gl_light->next == nullptr); // Add it to the linked list of active lights. gl_light->next = _c->first_light; @@ -1887,7 +1887,7 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { gl_light->attenuation[2] = 0.0f; } - nassertv(gl_light->next == NULL); + nassertv(gl_light->next == nullptr); // Add it to the linked list of active lights. gl_light->next = _c->first_light; @@ -1914,7 +1914,7 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { gl_light->specular.v[3] = specular[3]; Lens *lens = light_obj->get_lens(); - nassertv(lens != (Lens *)NULL); + nassertv(lens != nullptr); // Position needs to specify x, y, z, and w w == 1 implies non-infinite // position @@ -1952,7 +1952,7 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { gl_light->attenuation[2] = att[2]; } - nassertv(gl_light->next == NULL); + nassertv(gl_light->next == nullptr); // Add it to the linked list of active lights. gl_light->next = _c->first_light; @@ -2104,7 +2104,7 @@ do_issue_material() { const MaterialAttrib *target_material = DCAST(MaterialAttrib, _target_rs->get_attrib_def(MaterialAttrib::get_class_slot())); const Material *material; - if (target_material == (MaterialAttrib *)NULL || + if (target_material == nullptr || target_material->is_off()) { material = ∅ } else { @@ -2148,11 +2148,11 @@ do_issue_texture() { for (int si = 0; si < num_stages; ++si) { TextureStage *stage = _target_texture->get_on_ff_stage(si); Texture *texture = _target_texture->get_on_texture(stage); - nassertv(texture != (Texture *)NULL); + nassertv(texture != nullptr); int view = get_current_tex_view_offset() + stage->get_tex_view_offset(); TextureContext *tc = texture->prepare_now(view, _prepared_objects, this); - if (tc == (TextureContext *)NULL) { + if (tc == nullptr) { // Something wrong with this texture; skip it. return; } @@ -2523,10 +2523,10 @@ bool TinyGraphicsStateGuardian:: upload_simple_texture(TinyTextureContext *gtc) { PStatTimer timer(_load_texture_pcollector); Texture *tex = gtc->get_texture(); - nassertr(tex != (Texture *)NULL, false); + nassertr(tex != nullptr, false); const unsigned char *image_ptr = tex->get_simple_ram_image(); - if (image_ptr == (const unsigned char *)NULL) { + if (image_ptr == nullptr) { return false; } @@ -2615,7 +2615,7 @@ setup_gltex(GLTexture *gltex, int x_size, int y_size, int num_levels) { } if (gltex->total_bytecount != total_bytecount) { - if (gltex->allocated_buffer != NULL) { + if (gltex->allocated_buffer != nullptr) { TinyTextureContext::get_class_type().deallocate_array(gltex->allocated_buffer); } gltex->allocated_buffer = TinyTextureContext::get_class_type().allocate_array(total_bytecount); @@ -2626,7 +2626,7 @@ setup_gltex(GLTexture *gltex, int x_size, int y_size, int num_levels) { char *end_of_buffer = next_buffer + total_bytecount; int level = 0; - ZTextureLevel *dest = NULL; + ZTextureLevel *dest = nullptr; while (level < num_levels) { dest = &gltex->levels[level]; int bytecount = x_size * y_size * 4; @@ -2704,7 +2704,7 @@ copy_lum_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext *gt #endif unsigned int *dpix = (unsigned int *)dest->pixmap; - nassertv(dpix != NULL); + nassertv(dpix != nullptr); const unsigned char *spix = src; int pixel_count = xsize * ysize; while (pixel_count-- > 0) { @@ -2740,7 +2740,7 @@ copy_alpha_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext * #endif unsigned int *dpix = (unsigned int *)dest->pixmap; - nassertv(dpix != NULL); + nassertv(dpix != nullptr); const unsigned char *spix = src; int pixel_count = xsize * ysize; while (pixel_count-- > 0) { @@ -2776,7 +2776,7 @@ copy_one_channel_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureCon #endif unsigned int *dpix = (unsigned int *)dest->pixmap; - nassertv(dpix != NULL); + nassertv(dpix != nullptr); const unsigned char *spix = src; int pixel_count = xsize * ysize; @@ -2841,7 +2841,7 @@ copy_la_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext *gtc #endif unsigned int *dpix = (unsigned int *)dest->pixmap; - nassertv(dpix != NULL); + nassertv(dpix != nullptr); const unsigned char *spix = src; int pixel_count = xsize * ysize; int inc = 2 * cw; @@ -2878,7 +2878,7 @@ copy_rgb_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext *gt #endif unsigned int *dpix = (unsigned int *)dest->pixmap; - nassertv(dpix != NULL); + nassertv(dpix != nullptr); const unsigned char *spix = src; int pixel_count = xsize * ysize; int inc = 3 * cw; @@ -2915,7 +2915,7 @@ copy_rgba_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext *g #endif unsigned int *dpix = (unsigned int *)dest->pixmap; - nassertv(dpix != NULL); + nassertv(dpix != nullptr); const unsigned char *spix = src; int pixel_count = xsize * ysize; int inc = 4 * cw; diff --git a/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx index c1fbe12b67..2e2c517fee 100644 --- a/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx @@ -75,11 +75,11 @@ make_output(const string &name, if (retry == 0) { if (((flags&BF_require_parasite)!=0)|| ((flags&BF_require_window)!=0)) { - return NULL; + return nullptr; } return new TinyGraphicsBuffer(engine, this, name, fb_prop, win_prop, flags, gsg, host); } // Nothing else left to try. - return NULL; + return nullptr; } diff --git a/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx b/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx index cdb1b90f1f..6a55f05b94 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx @@ -86,7 +86,7 @@ create_cg_image(const PNMImage &pnm_image) { bool has_alpha; bool is_grayscale; - CFStringRef color_space_name = NULL; + CFStringRef color_space_name = nullptr; switch (pnm_image.get_color_type()) { case PNMImage::CT_grayscale: color_space_name = kCGColorSpaceGenericGray; @@ -114,13 +114,13 @@ create_cg_image(const PNMImage &pnm_image) { case PNMImage::CT_invalid: // Shouldn't get here. - nassertr(false, NULL); + nassertr(false, nullptr); break; } - nassertr(color_space_name != NULL, NULL); + nassertr(color_space_name != nullptr, nullptr); CGColorSpaceRef color_space = CGColorSpaceCreateWithName(color_space_name); - nassertr(color_space != NULL, NULL); + nassertr(color_space != nullptr, nullptr); CGBitmapInfo bitmap_info = 0; #ifdef PGM_BIGGRAYS @@ -148,17 +148,17 @@ create_cg_image(const PNMImage &pnm_image) { } } } - nassertr((void *)dp == (void *)(char_array + num_bytes), NULL); + nassertr((void *)dp == (void *)(char_array + num_bytes), nullptr); CGDataProviderRef provider = - CGDataProviderCreateWithData(NULL, char_array, num_bytes, release_data); - nassertr(provider != NULL, NULL); + CGDataProviderCreateWithData(nullptr, char_array, num_bytes, release_data); + nassertr(provider != nullptr, nullptr); CGImageRef image = CGImageCreate (width, height, bits_per_component, bits_per_pixel, bytes_per_row, color_space, bitmap_info, provider, - NULL, false, kCGRenderingIntentDefault); - nassertr(image != NULL, NULL); + nullptr, false, kCGRenderingIntentDefault); + nassertr(image != nullptr, nullptr); CGColorSpaceRelease(color_space); CGDataProviderRelease(provider); @@ -192,12 +192,12 @@ make_output(const string &name, bool &precertify) { if (!_is_valid) { - return NULL; + return nullptr; } TinyGraphicsStateGuardian *tinygsg = 0; if (gsg != 0) { - DCAST_INTO_R(tinygsg, gsg, NULL); + DCAST_INTO_R(tinygsg, gsg, nullptr); } // First thing to try: a TinyOsxGraphicsWindow @@ -210,22 +210,22 @@ make_output(const string &name, ((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_color)!=0)|| ((flags&BF_can_bind_every)!=0)) { - return NULL; + return nullptr; } if ((flags & BF_fb_props_optional)==0) { if ((fb_prop.get_aux_rgba() > 0)|| (fb_prop.get_aux_hrgba() > 0)|| (fb_prop.get_aux_float() > 0)) { - return NULL; + return nullptr; } } WindowHandle *window_handle = win_prop.get_parent_window(); - if (window_handle != NULL) { + if (window_handle != nullptr) { tinydisplay_cat.info() << "Got parent_window " << *window_handle << "\n"; #ifdef SUPPORT_SUBPROCESS_WINDOW WindowHandle::OSHandle *os_handle = window_handle->get_os_handle(); - if (os_handle != NULL && + if (os_handle != nullptr && os_handle->is_of_type(NativeWindowHandle::SubprocessHandle::get_class_type())) { return new SubprocessWindow(engine, this, name, fb_prop, win_prop, flags, gsg, host); @@ -240,13 +240,13 @@ make_output(const string &name, if (retry == 1) { if (((flags&BF_require_parasite)!=0)|| ((flags&BF_require_window)!=0)) { - return NULL; + return nullptr; } return new TinyGraphicsBuffer(engine, this, name, fb_prop, win_prop, flags, gsg, host); } // Nothing else left to try. - return NULL; + return nullptr; } #endif // IS_OSX diff --git a/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx b/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx index 6189f61036..7afe0953a4 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx @@ -83,12 +83,12 @@ make_output(const string &name, int retry, bool &precertify) { if (!_is_valid) { - return NULL; + return nullptr; } TinyGraphicsStateGuardian *tinygsg = 0; if (gsg != 0) { - DCAST_INTO_R(tinygsg, gsg, NULL); + DCAST_INTO_R(tinygsg, gsg, nullptr); } // First thing to try: a TinySDLGraphicsWindow @@ -101,14 +101,14 @@ make_output(const string &name, ((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_color)!=0)|| ((flags&BF_can_bind_every)!=0)) { - return NULL; + return nullptr; } return new TinySDLGraphicsWindow(engine, this, name, fb_prop, win_prop, flags, gsg, host); } // Nothing else left to try. - return NULL; + return nullptr; } #endif // HAVE_SDL diff --git a/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx b/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx index 68ab836ec6..d0fe649b79 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx @@ -38,8 +38,8 @@ TinySDLGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, GraphicsOutput *host) : GraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, host) { - _screen = NULL; - _frame_buffer = NULL; + _screen = nullptr; + _frame_buffer = nullptr; _pitch = 0; update_pixel_factor(); @@ -64,7 +64,7 @@ TinySDLGraphicsWindow:: bool TinySDLGraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } @@ -86,7 +86,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void TinySDLGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { // end_render_texture(); @@ -137,7 +137,7 @@ end_flip() { SDL_CreateRGBSurfaceFrom(_frame_buffer->pbuf, _frame_buffer->xsize, _frame_buffer->ysize, 32, _frame_buffer->linesize, 0xff0000, 0x00ff00, 0x0000ff, 0xff000000); SDL_SetAlpha(temp, SDL_RLEACCEL, 0); - SDL_BlitSurface(temp, NULL, _screen, NULL); + SDL_BlitSurface(temp, nullptr, _screen, nullptr); SDL_FreeSurface(temp); } @@ -156,7 +156,7 @@ void TinySDLGraphicsWindow:: process_events() { GraphicsWindow::process_events(); - if (_screen == NULL) { + if (_screen == nullptr) { return; } @@ -203,7 +203,7 @@ process_events() { properties.set_size(evt.resize.w, evt.resize.h); system_changed_properties(properties); _screen = SDL_SetVideoMode(_properties.get_x_size(), _properties.get_y_size(), 32, _flags); - ZB_resize(_frame_buffer, NULL, _properties.get_x_size(), _properties.get_y_size()); + ZB_resize(_frame_buffer, nullptr, _properties.get_x_size(), _properties.get_y_size()); _pitch = _screen->pitch * 32 / _screen->format->BitsPerPixel; break; @@ -272,7 +272,7 @@ open_window() { TinyGraphicsStateGuardian *tinygsg; if (_gsg == 0) { // There is no old gsg. Create a new one. - tinygsg = new TinyGraphicsStateGuardian(_engine, _pipe, NULL); + tinygsg = new TinyGraphicsStateGuardian(_engine, _pipe, nullptr); _gsg = tinygsg; } else { @@ -291,14 +291,14 @@ open_window() { } _screen = SDL_SetVideoMode(_properties.get_x_size(), _properties.get_y_size(), 32, _flags); - if (_screen == NULL) { + if (_screen == nullptr) { tinydisplay_cat.error() << "Video mode set failed.\n"; return false; } create_frame_buffer(); - if (_frame_buffer == NULL) { + if (_frame_buffer == nullptr) { tinydisplay_cat.error() << "Could not create frame buffer.\n"; return false; @@ -320,9 +320,9 @@ open_window() { */ void TinySDLGraphicsWindow:: create_frame_buffer() { - if (_frame_buffer != NULL) { + if (_frame_buffer != nullptr) { ZB_close(_frame_buffer); - _frame_buffer = NULL; + _frame_buffer = nullptr; } int mode; diff --git a/panda/src/tinydisplay/tinyTextureContext.I b/panda/src/tinydisplay/tinyTextureContext.I index ca4f620db1..348c748228 100644 --- a/panda/src/tinydisplay/tinyTextureContext.I +++ b/panda/src/tinydisplay/tinyTextureContext.I @@ -19,6 +19,6 @@ TinyTextureContext(PreparedGraphicsObjects *pgo, Texture *tex, int view) : TextureContext(pgo, tex, view) { _gltex.num_levels = 0; - _gltex.allocated_buffer = NULL; + _gltex.allocated_buffer = nullptr; _gltex.total_bytecount = 0; } diff --git a/panda/src/tinydisplay/tinyTextureContext.cxx b/panda/src/tinydisplay/tinyTextureContext.cxx index 5a3ae3414d..d0207a1379 100644 --- a/panda/src/tinydisplay/tinyTextureContext.cxx +++ b/panda/src/tinydisplay/tinyTextureContext.cxx @@ -22,10 +22,10 @@ TypeHandle TinyTextureContext::_type_handle; TinyTextureContext:: ~TinyTextureContext() { GLTexture *gltex = &_gltex; - if (gltex->allocated_buffer != NULL) { + if (gltex->allocated_buffer != nullptr) { nassertv(gltex->num_levels != 0); get_class_type().deallocate_array(gltex->allocated_buffer); - gltex->allocated_buffer = NULL; + gltex->allocated_buffer = nullptr; gltex->total_bytecount = 0; gltex->num_levels = 0; } else { @@ -48,10 +48,10 @@ evict_lru() { dequeue_lru(); GLTexture *gltex = &_gltex; - if (gltex->allocated_buffer != NULL) { + if (gltex->allocated_buffer != nullptr) { nassertv(gltex->num_levels != 0); get_class_type().deallocate_array(gltex->allocated_buffer); - gltex->allocated_buffer = NULL; + gltex->allocated_buffer = nullptr; gltex->total_bytecount = 0; gltex->num_levels = 0; } else { diff --git a/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx b/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx index 2371d17ba8..6cfb2dc7c7 100644 --- a/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx @@ -73,12 +73,12 @@ make_output(const string &name, bool &precertify) { if (!_is_valid) { - return NULL; + return nullptr; } TinyGraphicsStateGuardian *tinygsg = 0; if (gsg != 0) { - DCAST_INTO_R(tinygsg, gsg, NULL); + DCAST_INTO_R(tinygsg, gsg, nullptr); } // First thing to try: a TinyWinGraphicsWindow @@ -91,13 +91,13 @@ make_output(const string &name, ((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_color)!=0)|| ((flags&BF_can_bind_every)!=0)) { - return NULL; + return nullptr; } if ((flags & BF_fb_props_optional)==0) { if ((fb_prop.get_aux_rgba() > 0)|| (fb_prop.get_aux_hrgba() > 0)|| (fb_prop.get_aux_float() > 0)) { - return NULL; + return nullptr; } } return new TinyWinGraphicsWindow(engine, this, name, fb_prop, win_prop, @@ -108,14 +108,14 @@ make_output(const string &name, if (retry == 1) { if (((flags&BF_require_parasite)!=0)|| ((flags&BF_require_window)!=0)) { - return NULL; + return nullptr; } return new TinyGraphicsBuffer(engine, this, name, fb_prop, win_prop, flags, gsg, host); } // Nothing else left to try. - return NULL; + return nullptr; } #endif // WIN32 diff --git a/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx b/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx index afb7d1f016..85f1776ae5 100644 --- a/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx @@ -39,7 +39,7 @@ TinyWinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, GraphicsOutput *host) : WinGraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, host) { - _frame_buffer = NULL; + _frame_buffer = nullptr; _hdc = (HDC)0; update_pixel_factor(); } @@ -60,7 +60,7 @@ TinyWinGraphicsWindow:: bool TinyWinGraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } @@ -90,7 +90,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void TinyWinGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { // end_render_texture(); @@ -166,10 +166,10 @@ supports_pixel_zoom() const { */ void TinyWinGraphicsWindow:: close_window() { - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { TinyGraphicsStateGuardian *tinygsg; DCAST_INTO_V(tinygsg, _gsg); - tinygsg->_current_frame_buffer = NULL; + tinygsg->_current_frame_buffer = nullptr; _gsg.clear(); } @@ -192,7 +192,7 @@ open_window() { TinyGraphicsStateGuardian *tinygsg; if (_gsg == 0) { // There is no old gsg. Create a new one. - tinygsg = new TinyGraphicsStateGuardian(_engine, _pipe, NULL); + tinygsg = new TinyGraphicsStateGuardian(_engine, _pipe, nullptr); _gsg = tinygsg; } else { DCAST_INTO_R(tinygsg, _gsg, false); @@ -201,7 +201,7 @@ open_window() { _hdc = GetDC(_hWnd); create_frame_buffer(); - if (_frame_buffer == NULL) { + if (_frame_buffer == nullptr) { tinydisplay_cat.error() << "Could not create frame buffer.\n"; return false; @@ -225,8 +225,8 @@ open_window() { void TinyWinGraphicsWindow:: handle_reshape() { WinGraphicsWindow::handle_reshape(); - if (_frame_buffer != NULL) { - ZB_resize(_frame_buffer, NULL, _properties.get_x_size(), _properties.get_y_size()); + if (_frame_buffer != nullptr) { + ZB_resize(_frame_buffer, nullptr, _properties.get_x_size(), _properties.get_y_size()); setup_bitmap_info(); } } @@ -238,7 +238,7 @@ handle_reshape() { bool TinyWinGraphicsWindow:: do_fullscreen_resize(int x_size, int y_size) { bool result = WinGraphicsWindow::do_fullscreen_resize(x_size, y_size); - ZB_resize(_frame_buffer, NULL, _properties.get_x_size(), _properties.get_y_size()); + ZB_resize(_frame_buffer, nullptr, _properties.get_x_size(), _properties.get_y_size()); setup_bitmap_info(); return result; } @@ -248,9 +248,9 @@ do_fullscreen_resize(int x_size, int y_size) { */ void TinyWinGraphicsWindow:: create_frame_buffer() { - if (_frame_buffer != NULL) { + if (_frame_buffer != nullptr) { ZB_close(_frame_buffer); - _frame_buffer = NULL; + _frame_buffer = nullptr; } _frame_buffer = ZB_open(_properties.get_x_size(), _properties.get_y_size(), ZB_MODE_RGBA, 0, 0, 0, 0); diff --git a/panda/src/tinydisplay/tinyXGraphicsPipe.cxx b/panda/src/tinydisplay/tinyXGraphicsPipe.cxx index 9bb2c4c2d6..7bbfbecf79 100644 --- a/panda/src/tinydisplay/tinyXGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyXGraphicsPipe.cxx @@ -72,7 +72,7 @@ make_output(const string &name, bool &precertify) { TinyGraphicsStateGuardian *tinygsg = 0; if (gsg != 0) { - DCAST_INTO_R(tinygsg, gsg, NULL); + DCAST_INTO_R(tinygsg, gsg, nullptr); } // First thing to try: a TinyXGraphicsWindow @@ -88,7 +88,7 @@ make_output(const string &name, ((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_color)!=0)|| ((flags&BF_can_bind_every)!=0)) { - return NULL; + return nullptr; } return new TinyXGraphicsWindow(engine, this, name, fb_prop, win_prop, flags, gsg, host); @@ -101,13 +101,13 @@ make_output(const string &name, if (retry == 1) { if (((flags&BF_require_parasite)!=0)|| ((flags&BF_require_window)!=0)) { - return NULL; + return nullptr; } return new TinyGraphicsBuffer(engine, this, name, fb_prop, win_prop, flags, gsg, host); } // Nothing else left to try. - return NULL; + return nullptr; } #endif // HAVE_X11 diff --git a/panda/src/tinydisplay/tinyXGraphicsWindow.cxx b/panda/src/tinydisplay/tinyXGraphicsWindow.cxx index 7b34ba0fb7..64f1a7c809 100644 --- a/panda/src/tinydisplay/tinyXGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinyXGraphicsWindow.cxx @@ -45,11 +45,11 @@ TinyXGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, GraphicsOutput *host) : x11GraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, host) { - _gc = (GC)NULL; + _gc = (GC)nullptr; - _reduced_frame_buffer = NULL; - _full_frame_buffer = NULL; - _ximage = NULL; + _reduced_frame_buffer = nullptr; + _full_frame_buffer = nullptr; + _ximage = nullptr; update_pixel_factor(); } @@ -58,12 +58,12 @@ TinyXGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, */ TinyXGraphicsWindow:: ~TinyXGraphicsWindow() { - if (_gc != NULL && _display != NULL) { + if (_gc != nullptr && _display != nullptr) { XFreeGC(_display, _gc); } - if (_ximage != NULL) { + if (_ximage != nullptr) { PANDA_FREE_ARRAY(_ximage->data); - _ximage->data = NULL; + _ximage->data = nullptr; XDestroyImage(_ximage); } } @@ -78,12 +78,12 @@ bool TinyXGraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); - if (_xwindow == (X11_Window)NULL) { + if (_xwindow == (X11_Window)nullptr) { return false; } begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } if (_awaiting_configure) { @@ -95,7 +95,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { TinyGraphicsStateGuardian *tinygsg; DCAST_INTO_R(tinygsg, _gsg, false); - if (_reduced_frame_buffer != (ZBuffer *)NULL) { + if (_reduced_frame_buffer != nullptr) { tinygsg->_current_frame_buffer = _reduced_frame_buffer; } else { tinygsg->_current_frame_buffer = _full_frame_buffer; @@ -114,7 +114,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void TinyXGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { // end_render_texture(); @@ -138,12 +138,12 @@ end_frame(FrameMode mode, Thread *current_thread) { */ void TinyXGraphicsWindow:: end_flip() { - if (_xwindow == (X11_Window)NULL || !_flip_ready) { + if (_xwindow == (X11_Window)nullptr || !_flip_ready) { GraphicsWindow::end_flip(); return; } - if (_reduced_frame_buffer != (ZBuffer *)NULL) { + if (_reduced_frame_buffer != nullptr) { // Zoom the reduced buffer onto the full buffer. ZB_zoomFrameBuffer(_full_frame_buffer, 0, 0, _full_frame_buffer->xsize, _full_frame_buffer->ysize, @@ -261,7 +261,7 @@ process_events() { // A normal window may be resized by the user at will. properties.set_size(event.xconfigure.width, event.xconfigure.height); system_changed_properties(properties); - ZB_resize(_full_frame_buffer, NULL, _properties.get_x_size(), _properties.get_y_size()); + ZB_resize(_full_frame_buffer, nullptr, _properties.get_x_size(), _properties.get_y_size()); _pitch = (_full_frame_buffer->xsize * _bytes_per_pixel + 3) & ~3; create_reduced_frame_buffer(); create_ximage(); @@ -377,10 +377,10 @@ process_events() { */ void TinyXGraphicsWindow:: close_window() { - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { TinyGraphicsStateGuardian *tinygsg; DCAST_INTO_V(tinygsg, _gsg); - tinygsg->_current_frame_buffer = NULL; + tinygsg->_current_frame_buffer = nullptr; _gsg.clear(); } @@ -400,7 +400,7 @@ open_window() { TinyGraphicsStateGuardian *tinygsg; if (_gsg == 0) { // There is no old gsg. Create a new one. - tinygsg = new TinyGraphicsStateGuardian(_engine, _pipe, NULL); + tinygsg = new TinyGraphicsStateGuardian(_engine, _pipe, nullptr); _gsg = tinygsg; } else { DCAST_INTO_R(tinygsg, _gsg, false); @@ -478,17 +478,17 @@ open_window() { return false; } - _gc = XCreateGC(_display, _xwindow, 0, NULL); + _gc = XCreateGC(_display, _xwindow, 0, nullptr); create_full_frame_buffer(); - if (_full_frame_buffer == NULL) { + if (_full_frame_buffer == nullptr) { tinydisplay_cat.error() << "Could not create frame buffer.\n"; return false; } create_reduced_frame_buffer(); create_ximage(); - nassertr(_ximage != NULL, false); + nassertr(_ximage != nullptr, false); tinygsg->_current_frame_buffer = _full_frame_buffer; @@ -513,7 +513,7 @@ open_window() { _window_handle = NativeWindowHandle::make_x11(_xwindow); // And tell our parent window that we're now its child. - if (_parent_window_handle != (WindowHandle *)NULL) { + if (_parent_window_handle != nullptr) { _parent_window_handle->attach_child(_window_handle); } @@ -534,9 +534,9 @@ pixel_factor_changed() { */ void TinyXGraphicsWindow:: create_full_frame_buffer() { - if (_full_frame_buffer != NULL) { + if (_full_frame_buffer != nullptr) { ZB_close(_full_frame_buffer); - _full_frame_buffer = NULL; + _full_frame_buffer = nullptr; } int mode; @@ -570,9 +570,9 @@ create_reduced_frame_buffer() { return; } - if (_reduced_frame_buffer != NULL) { + if (_reduced_frame_buffer != nullptr) { ZB_close(_reduced_frame_buffer); - _reduced_frame_buffer = NULL; + _reduced_frame_buffer = nullptr; } int x_size = get_fb_x_size(); @@ -594,11 +594,11 @@ create_reduced_frame_buffer() { */ void TinyXGraphicsWindow:: create_ximage() { - if (_ximage != NULL) { + if (_ximage != nullptr) { PANDA_FREE_ARRAY(_ximage->data); - _ximage->data = NULL; + _ximage->data = nullptr; XDestroyImage(_ximage); - _ximage = NULL; + _ximage = nullptr; } int image_size = _full_frame_buffer->ysize * _pitch; diff --git a/panda/src/tinydisplay/zbuffer.cxx b/panda/src/tinydisplay/zbuffer.cxx index cc25320646..45dbe1b0a2 100644 --- a/panda/src/tinydisplay/zbuffer.cxx +++ b/panda/src/tinydisplay/zbuffer.cxx @@ -34,8 +34,8 @@ ZB_open(int xsize, int ysize, int mode, int size; zb = (ZBuffer *)gl_malloc(sizeof(ZBuffer)); - if (zb == NULL) - return NULL; + if (zb == nullptr) + return nullptr; memset(zb, 0, sizeof(ZBuffer)); /* xsize must be a multiple of 4 */ @@ -68,12 +68,12 @@ ZB_open(int xsize, int ysize, int mode, size = zb->xsize * zb->ysize * sizeof(ZPOINT); zb->zbuf = (ZPOINT *)gl_malloc(size); - if (zb->zbuf == NULL) + if (zb->zbuf == nullptr) goto error; - if (frame_buffer == NULL) { + if (frame_buffer == nullptr) { zb->pbuf = (PIXEL *)gl_malloc(zb->ysize * zb->linesize); - if (zb->pbuf == NULL) { + if (zb->pbuf == nullptr) { gl_free(zb->zbuf); goto error; } @@ -86,7 +86,7 @@ ZB_open(int xsize, int ysize, int mode, return zb; error: gl_free(zb); - return NULL; + return nullptr; } void @@ -107,7 +107,7 @@ void ZB_resize(ZBuffer * zb, void *frame_buffer, int xsize, int ysize) { int size; - nassertv(zb != NULL); + nassertv(zb != nullptr); /* xsize must be a multiple of 4 */ xsize = (xsize + 3) & ~3; @@ -123,7 +123,7 @@ ZB_resize(ZBuffer * zb, void *frame_buffer, int xsize, int ysize) { if (zb->frame_buffer_allocated) gl_free(zb->pbuf); - if (frame_buffer == NULL) { + if (frame_buffer == nullptr) { zb->pbuf = (PIXEL *)gl_malloc(zb->ysize * zb->linesize); zb->frame_buffer_allocated = 1; } else { diff --git a/panda/src/vision/arToolKit.cxx b/panda/src/vision/arToolKit.cxx index 0c68f5cd46..9d990cc26b 100644 --- a/panda/src/vision/arToolKit.cxx +++ b/panda/src/vision/arToolKit.cxx @@ -280,7 +280,7 @@ analyze(Texture *tex, bool do_flip_texture) { CPTA_uchar ri = tex->get_ram_image(); const unsigned char *ram = ri.p(); - if (ram == NULL) { + if (ram == nullptr) { vision_cat.warning() << "No data in texture!\n"; return; } diff --git a/panda/src/vision/openCVTexture.I b/panda/src/vision/openCVTexture.I index d9f5fa6f37..91234c31b6 100644 --- a/panda/src/vision/openCVTexture.I +++ b/panda/src/vision/openCVTexture.I @@ -16,7 +16,7 @@ */ INLINE bool OpenCVTexture::VideoStream:: is_valid() const { - return (_capture != NULL); + return (_capture != nullptr); } /** diff --git a/panda/src/vision/openCVTexture.cxx b/panda/src/vision/openCVTexture.cxx index e0262d01ba..e6deea17ea 100644 --- a/panda/src/vision/openCVTexture.cxx +++ b/panda/src/vision/openCVTexture.cxx @@ -371,7 +371,7 @@ do_read_one(Texture::CData *cdata, int z, int n, int primary_file_num_channels, int alpha_file_channel, const LoaderOptions &options, bool header_only, BamCacheRecord *record) { - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(fullpath); } @@ -479,7 +479,7 @@ register_with_read_factory() { */ OpenCVTexture::VideoStream:: VideoStream() : - _capture(NULL), + _capture(nullptr), _camera_index(-1), _next_frame(0) { @@ -490,7 +490,7 @@ VideoStream() : */ OpenCVTexture::VideoStream:: VideoStream(const OpenCVTexture::VideoStream ©) : - _capture(NULL), + _capture(nullptr), _camera_index(-1) { // Rather than copying the _capture pointer, we must open a new stream that @@ -541,7 +541,7 @@ get_frame_data(int frame, _next_frame = frame + 1; IplImage *image = cvQueryFrame(_capture); - if (image == NULL) { + if (image == nullptr) { return false; } @@ -583,7 +583,7 @@ read(const Filename &filename) { string os_specific = filename.to_os_specific(); _capture = cvCaptureFromFile(os_specific.c_str()); - if (_capture == NULL) { + if (_capture == nullptr) { return false; } _filename = filename; @@ -599,7 +599,7 @@ from_camera(int camera_index) { clear(); _capture = cvCaptureFromCAM(camera_index); - if (_capture == NULL) { + if (_capture == nullptr) { return false; } _camera_index = camera_index; @@ -611,9 +611,9 @@ from_camera(int camera_index) { */ void OpenCVTexture::VideoStream:: clear() { - if (_capture != NULL) { + if (_capture != nullptr) { cvReleaseCapture(&_capture); - _capture = NULL; + _capture = nullptr; } _filename = Filename(); _camera_index = -1; diff --git a/panda/src/vision/webcamVideo.cxx b/panda/src/vision/webcamVideo.cxx index f13587c39b..8badc4eeec 100644 --- a/panda/src/vision/webcamVideo.cxx +++ b/panda/src/vision/webcamVideo.cxx @@ -75,6 +75,6 @@ get_num_options() { PT(WebcamVideo) WebcamVideo:: get_option(int n) { find_all_webcams(); - nassertr((n >= 0) && (n < (int)_all_webcams.size()), NULL); + nassertr((n >= 0) && (n < (int)_all_webcams.size()), nullptr); return _all_webcams[n]; } diff --git a/panda/src/vision/webcamVideoCursorOpenCV.cxx b/panda/src/vision/webcamVideoCursorOpenCV.cxx index 814ad9d5bb..444557fde8 100644 --- a/panda/src/vision/webcamVideoCursorOpenCV.cxx +++ b/panda/src/vision/webcamVideoCursorOpenCV.cxx @@ -35,7 +35,7 @@ WebcamVideoCursorOpenCV(WebcamVideoOpenCV *src) : MovieVideoCursor(src) { _ready = false; _capture = cvCaptureFromCAM(src->_camera_index); - if (_capture != NULL) { + if (_capture != nullptr) { _size_x = (int)cvGetCaptureProperty(_capture, CV_CAP_PROP_FRAME_WIDTH); _size_y = (int)cvGetCaptureProperty(_capture, CV_CAP_PROP_FRAME_HEIGHT); _ready = true; @@ -47,9 +47,9 @@ WebcamVideoCursorOpenCV(WebcamVideoOpenCV *src) : MovieVideoCursor(src) { */ WebcamVideoCursorOpenCV:: ~WebcamVideoCursorOpenCV() { - if (_capture != NULL) { + if (_capture != nullptr) { cvReleaseCapture(&_capture); - _capture = NULL; + _capture = nullptr; } } @@ -59,13 +59,13 @@ WebcamVideoCursorOpenCV:: PT(MovieVideoCursor::Buffer) WebcamVideoCursorOpenCV:: fetch_buffer() { if (!_ready) { - return NULL; + return nullptr; } PT(Buffer) buffer = get_standard_buffer(); unsigned char *dest = buffer->_block; int num_components = get_num_components(); - nassertr(num_components == 3, NULL); + nassertr(num_components == 3, nullptr); int dest_x_pitch = num_components; // Assume component_width == 1 int dest_y_pitch = _size_x * dest_x_pitch; @@ -75,7 +75,7 @@ fetch_buffer() { if (num_components == 3 && x_pitch == 3) { // The easy case--copy the whole thing in, row by row. int copy_bytes = _size_x * dest_x_pitch; - nassertr(copy_bytes <= dest_y_pitch && copy_bytes <= abs(y_pitch), NULL); + nassertr(copy_bytes <= dest_y_pitch && copy_bytes <= abs(y_pitch), nullptr); for (int y = 0; y < _size_y; ++y) { memcpy(dest, r, copy_bytes); @@ -129,7 +129,7 @@ get_frame_data(const unsigned char *&r, nassertr(ready(), false); IplImage *image = cvQueryFrame(_capture); - if (image == NULL) { + if (image == nullptr) { return false; } diff --git a/panda/src/vision/webcamVideoCursorV4L.cxx b/panda/src/vision/webcamVideoCursorV4L.cxx index a78c55135a..853f3e070f 100644 --- a/panda/src/vision/webcamVideoCursorV4L.cxx +++ b/panda/src/vision/webcamVideoCursorV4L.cxx @@ -207,8 +207,8 @@ WebcamVideoCursorV4L(WebcamVideoV4L *src) : MovieVideoCursor(src) { _ready = false; memset(&_format, 0, sizeof(struct v4l2_format)); - _buffers = NULL; - _buflens = NULL; + _buffers = nullptr; + _buflens = nullptr; int mode = O_RDWR; if (!v4l_blocking) { @@ -326,7 +326,7 @@ WebcamVideoCursorV4L(WebcamVideoV4L *src) : MovieVideoCursor(src) { } _buflens[i] = buf.length; - _buffers[i] = mmap (NULL, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, _fd, buf.m.offset); + _buffers[i] = mmap (nullptr, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, _fd, buf.m.offset); if (_buffers[i] == MAP_FAILED) { vision_cat.error() << "Failed to map buffer!\n"; @@ -393,7 +393,7 @@ WebcamVideoCursorV4L:: PT(MovieVideoCursor::Buffer) WebcamVideoCursorV4L:: fetch_buffer() { if (!_ready) { - return NULL; + return nullptr; } PT(Buffer) buffer = get_standard_buffer(); @@ -405,12 +405,12 @@ fetch_buffer() { if (-1 == ioctl(_fd, VIDIOC_DQBUF, &vbuf) && errno != EIO) { if (errno == EAGAIN) { // Simply nothing is available yet. - return NULL; + return nullptr; } vision_cat.error() << "Failed to dequeue buffer!\n"; - return NULL; + return nullptr; } - nassertr(vbuf.index < _bufcount, NULL); + nassertr(vbuf.index < _bufcount, nullptr); size_t bufsize = _buflens[vbuf.index]; size_t old_bpl = _format.fmt.pix.bytesperline; size_t new_bpl = _size_x * _num_components; @@ -435,7 +435,7 @@ fetch_buffer() { _cinfo.src->next_input_byte = buf; if (jpeg_read_header(&_cinfo, TRUE) == JPEG_HEADER_OK) { - if (_cinfo.dc_huff_tbl_ptrs[0] == NULL) { + if (_cinfo.dc_huff_tbl_ptrs[0] == nullptr) { // Many MJPEG streams do not include huffman tables. Remedy this. _cinfo.dc_huff_tbl_ptrs[0] = &dc_luminance_tbl; _cinfo.dc_huff_tbl_ptrs[1] = &dc_chrominance_tbl; @@ -482,7 +482,7 @@ fetch_buffer() { block[i + 2] = ex; } #else - nassertr(false /* Not compiled with JPEG support*/, NULL); + nassertr(false /* Not compiled with JPEG support*/, nullptr); #endif break; } @@ -500,7 +500,7 @@ fetch_buffer() { case V4L2_PIX_FMT_BGR32: case V4L2_PIX_FMT_GREY: // Simplest case: copying every row verbatim. - nassertr(old_bpl == new_bpl, NULL); + nassertr(old_bpl == new_bpl, nullptr); for (size_t row = 0; row < _size_y; ++row) { memcpy(block + (_size_y - row - 1) * new_bpl, buf + row * old_bpl, new_bpl); @@ -509,7 +509,7 @@ fetch_buffer() { case V4L2_PIX_FMT_RGB24: // Swap components. - nassertr(old_bpl == new_bpl, NULL); + nassertr(old_bpl == new_bpl, nullptr); for (size_t row = 0; row < _size_y; ++row) { for (size_t i = 0; i < old_bpl; i += 3) { @@ -520,7 +520,7 @@ fetch_buffer() { case V4L2_PIX_FMT_RGB32: // Swap components. - nassertr(old_bpl == new_bpl, NULL); + nassertr(old_bpl == new_bpl, nullptr); for (size_t row = 0; row < _size_y; ++row) { for (size_t i = 0; i < old_bpl; i += 4) { diff --git a/panda/src/vision/webcamVideoDS.cxx b/panda/src/vision/webcamVideoDS.cxx index 0996070b45..79510cf24d 100644 --- a/panda/src/vision/webcamVideoDS.cxx +++ b/panda/src/vision/webcamVideoDS.cxx @@ -236,18 +236,18 @@ media_fps(AM_MEDIA_TYPE *media) { */ void WebcamVideoDS:: delete_media_type(AM_MEDIA_TYPE *pmt) { - if (pmt == NULL) { + if (pmt == nullptr) { return; } if (pmt->cbFormat != 0) { CoTaskMemFree((PVOID)pmt->pbFormat); pmt->cbFormat = 0; - pmt->pbFormat = NULL; + pmt->pbFormat = nullptr; } - if (pmt->pUnk != NULL) { + if (pmt->pUnk != nullptr) { // Unecessary because pUnk should not be used, but safest. pmt->pUnk->Release(); - pmt->pUnk = NULL; + pmt->pUnk = nullptr; } CoTaskMemFree(pmt); } @@ -272,7 +272,7 @@ bstr_to_string(const BSTR &source) { string WebcamVideoDS:: get_moniker_name(IMoniker *pMoniker) { string res = "Unknown Device"; - IPropertyBag *propBag=NULL; + IPropertyBag *propBag=nullptr; VARIANT name; HRESULT hResult; pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&propBag); VariantInit(&name); @@ -334,25 +334,25 @@ find_all_webcams_ds() { pvector list; - ICreateDevEnum *pCreateDevEnum=NULL; - IEnumMoniker *pEnumMoniker=NULL; - IGraphBuilder *pGraphBuilder=NULL; - ICaptureGraphBuilder2 *pCaptureGraphBuilder2=NULL; - IMoniker *pMoniker=NULL; - IBaseFilter *pBaseFilter=NULL; - IAMStreamConfig *pStreamConfig=NULL; + ICreateDevEnum *pCreateDevEnum=nullptr; + IEnumMoniker *pEnumMoniker=nullptr; + IGraphBuilder *pGraphBuilder=nullptr; + ICaptureGraphBuilder2 *pCaptureGraphBuilder2=nullptr; + IMoniker *pMoniker=nullptr; + IBaseFilter *pBaseFilter=nullptr; + IAMStreamConfig *pStreamConfig=nullptr; HRESULT hResult; ULONG cFetched; - hResult=CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, + hResult=CoCreateInstance(CLSID_FilterGraph, nullptr, CLSCTX_INPROC, IID_IGraphBuilder,(void**)&pGraphBuilder); if (hResult != S_OK) goto cleanup; - hResult=CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC, + hResult=CoCreateInstance(CLSID_CaptureGraphBuilder2, nullptr, CLSCTX_INPROC, IID_ICaptureGraphBuilder2, (void**)&pCaptureGraphBuilder2); if (hResult != S_OK) goto cleanup; hResult = pCaptureGraphBuilder2->SetFiltergraph(pGraphBuilder); if (hResult != S_OK) goto cleanup; - hResult=CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, + hResult=CoCreateInstance(CLSID_SystemDeviceEnum, nullptr, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void**)&pCreateDevEnum); if (hResult != S_OK) goto cleanup; hResult=pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, @@ -367,7 +367,7 @@ find_all_webcams_ds() { hResult = pEnumMoniker->Next(1, &pMoniker, &cFetched); if (hResult != S_OK) break; - hResult = pMoniker->BindToObject(NULL,NULL,IID_IBaseFilter, (void**)&pBaseFilter); + hResult = pMoniker->BindToObject(nullptr,nullptr,IID_IBaseFilter, (void**)&pBaseFilter); if (hResult != S_OK) continue; hResult = pCaptureGraphBuilder2->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pBaseFilter, IID_IAMStreamConfig, (void **)&pStreamConfig); @@ -425,23 +425,23 @@ open() { WebcamVideoCursorDS:: WebcamVideoCursorDS(WebcamVideoDS *src) : MovieVideoCursor(src), - _pGraphBuilder(NULL), - _pCaptureBuilder(NULL), - _pSrcFilter(NULL), - _pStreamConfig(NULL), - _pStreamRenderer(NULL), - _pMediaCtrl(NULL) + _pGraphBuilder(nullptr), + _pCaptureBuilder(nullptr), + _pSrcFilter(nullptr), + _pStreamConfig(nullptr), + _pStreamRenderer(nullptr), + _pMediaCtrl(nullptr) { AM_MEDIA_TYPE mediaType; VIDEOINFOHEADER *pVideoInfo; HRESULT hResult; - hResult=CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, + hResult=CoCreateInstance(CLSID_FilterGraph, nullptr, CLSCTX_INPROC, IID_IGraphBuilder,(void**)&_pGraphBuilder); if(hResult != S_OK) { cleanup(); return; } - hResult=CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC, + hResult=CoCreateInstance(CLSID_CaptureGraphBuilder2, nullptr, CLSCTX_INPROC, IID_ICaptureGraphBuilder2, (void**)&_pCaptureBuilder); if(hResult != S_OK) { cleanup(); return; } @@ -454,8 +454,8 @@ WebcamVideoCursorDS(WebcamVideoDS *src) : cleanup(); return; } cerr << " IID_IMediaControl interface is acquired.\n"; - src->_moniker->BindToObject(NULL,NULL,IID_IBaseFilter, (void**)&_pSrcFilter); - if(_pSrcFilter == NULL) + src->_moniker->BindToObject(nullptr,nullptr,IID_IBaseFilter, (void**)&_pSrcFilter); + if(_pSrcFilter == nullptr) { cerr << " Such capture device is not found.\n"; cleanup(); return; } cerr << " The capture filter is acquired.\n"; @@ -479,7 +479,7 @@ WebcamVideoCursorDS(WebcamVideoDS *src) : cleanup(); return; } - hResult = CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC, IID_PPV_ARGS(&_pSampleGrabber)); + hResult = CoCreateInstance(CLSID_SampleGrabber, nullptr, CLSCTX_INPROC, IID_PPV_ARGS(&_pSampleGrabber)); if(hResult != S_OK) { cerr << " Can not create the sample grabber, maybe qedit.dll is not registered?"; cleanup(); return; } @@ -487,7 +487,7 @@ WebcamVideoCursorDS(WebcamVideoDS *src) : // hResult = CoCreateInstance(CLSID_SampleGrabber,) CComQIPtr< IBaseFilter, // &IID_IBaseFilter > pGrabberFilter(_pSampleGrabber); - IBaseFilter *pGrabberFilter = NULL; + IBaseFilter *pGrabberFilter = nullptr; hResult = _pSampleGrabber->QueryInterface(IID_PPV_ARGS(&pGrabberFilter)); cerr << " IID_IBaseFilter of CLSID_SampleGrabber is acquired.\n"; @@ -507,7 +507,7 @@ WebcamVideoCursorDS(WebcamVideoDS *src) : cerr << " The sample grabber has been added to the graph.\n"; // used to give the video stream somewhere to go to. - hResult = CoCreateInstance(CLSID_NullRenderer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&_pStreamRenderer); + hResult = CoCreateInstance(CLSID_NullRenderer, nullptr, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&_pStreamRenderer); if(hResult != S_OK) { cerr << " Can not create the null renderer."; cleanup(); return; } @@ -566,17 +566,17 @@ WebcamVideoCursorDS(WebcamVideoDS *src) : if(mediaType.cbFormat != 0) { CoTaskMemFree((PVOID)mediaType.pbFormat); mediaType.cbFormat=0; - mediaType.pbFormat=NULL; + mediaType.pbFormat=nullptr; } - if(mediaType.pUnk != NULL) { + if(mediaType.pUnk != nullptr) { mediaType.pUnk->Release(); - mediaType.pUnk=NULL; + mediaType.pUnk=nullptr; } - if(pGrabberFilter != NULL) { + if(pGrabberFilter != nullptr) { pGrabberFilter->Release(); - pGrabberFilter=NULL; + pGrabberFilter=nullptr; } _pSampleGrabber->SetBufferSamples(FALSE); @@ -605,13 +605,13 @@ cleanup() { _pMediaCtrl->Stop(); } - if(_pMediaCtrl) { _pMediaCtrl->Release(); _pMediaCtrl=NULL; } - if(_pCaptureBuilder) { _pCaptureBuilder->Release(); _pCaptureBuilder=NULL; } - if(_pGraphBuilder) { _pGraphBuilder->Release(); _pGraphBuilder=NULL; } - if(_pSampleGrabber) { _pSampleGrabber->Release(); _pSampleGrabber=NULL; } - if(_pStreamRenderer) { _pStreamRenderer->Release(); _pStreamRenderer=NULL; } - if(_pSrcFilter) { _pSrcFilter->Release(); _pSrcFilter=NULL; } - if(_pStreamConfig) { _pStreamConfig->Release(); _pStreamConfig=NULL; } + if(_pMediaCtrl) { _pMediaCtrl->Release(); _pMediaCtrl=nullptr; } + if(_pCaptureBuilder) { _pCaptureBuilder->Release(); _pCaptureBuilder=nullptr; } + if(_pGraphBuilder) { _pGraphBuilder->Release(); _pGraphBuilder=nullptr; } + if(_pSampleGrabber) { _pSampleGrabber->Release(); _pSampleGrabber=nullptr; } + if(_pStreamRenderer) { _pStreamRenderer->Release(); _pStreamRenderer=nullptr; } + if(_pSrcFilter) { _pSrcFilter->Release(); _pSrcFilter=nullptr; } + if(_pStreamConfig) { _pStreamConfig->Release(); _pStreamConfig=nullptr; } } /** @@ -628,7 +628,7 @@ WebcamVideoCursorDS:: PT(MovieVideoCursor::Buffer) WebcamVideoCursorDS:: fetch_buffer() { if (!_ready) { - return NULL; + return nullptr; } Buffer *buffer = get_standard_buffer(); diff --git a/panda/src/vrpn/vrpnClient.cxx b/panda/src/vrpn/vrpnClient.cxx index 1e7ec5abf0..068d7614a0 100644 --- a/panda/src/vrpn/vrpnClient.cxx +++ b/panda/src/vrpn/vrpnClient.cxx @@ -41,7 +41,7 @@ VrpnClient(const string &server_name) : << "\n"; } _connection = vrpn_get_connection_by_name(_server_name.c_str()); - nassertv(_connection != (vrpn_Connection *)NULL); + nassertv(_connection != nullptr); if (!is_valid()) { vrpn_cat.warning() @@ -140,7 +140,7 @@ make_device(TypeHandle device_type, const string &device_name) { return make_dial_device(device_name); } else { - return NULL; + return nullptr; } } @@ -625,7 +625,7 @@ bool VrpnClient:: add_remote_tracker(const string &tracker, int sensor) { vrpn_Tracker_Remote *vrpn_tracker = new vrpn_Tracker_Remote(tracker.c_str(), _connection); - if (vrpn_tracker == (vrpn_Tracker_Remote *)NULL) { + if (vrpn_tracker == nullptr) { return false; } @@ -654,7 +654,7 @@ bool VrpnClient:: add_remote_analog(const string &analog) { vrpn_Analog_Remote *vrpn_analog = new vrpn_Analog_Remote(analog.c_str(), _connection); - if (vrpn_analog == (vrpn_Analog_Remote *)NULL) { + if (vrpn_analog == nullptr) { return false; } @@ -680,7 +680,7 @@ bool VrpnClient:: add_remote_button(const string &button) { vrpn_Button_Remote *vrpn_button = new vrpn_Button_Remote(button.c_str(), _connection); - if (vrpn_button == (vrpn_Button_Remote *)NULL) { + if (vrpn_button == nullptr) { return false; } @@ -706,7 +706,7 @@ bool VrpnClient:: add_remote_dial(const string &dial) { vrpn_Dial_Remote *vrpn_dial = new vrpn_Dial_Remote(dial.c_str(), _connection); - if (vrpn_dial == (vrpn_Dial_Remote *)NULL) { + if (vrpn_dial == nullptr) { return false; } diff --git a/panda/src/wgldisplay/wglGraphicsBuffer.cxx b/panda/src/wgldisplay/wglGraphicsBuffer.cxx index 309533df4b..868ff727b2 100644 --- a/panda/src/wgldisplay/wglGraphicsBuffer.cxx +++ b/panda/src/wgldisplay/wglGraphicsBuffer.cxx @@ -62,7 +62,7 @@ bool wglGraphicsBuffer:: begin_frame(FrameMode mode, Thread *current_thread) { begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } @@ -117,7 +117,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void wglGraphicsBuffer:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { copy_to_textures(); @@ -171,7 +171,7 @@ bind_texture_to_pbuffer() { } } TextureContext *tc = tex->prepare_now(0, _gsg->get_prepared_objects(), _gsg); - nassertv(tc != (TextureContext *)NULL); + nassertv(tc != nullptr); CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), tc); GLenum target = wglgsg->get_texture_target(tex->get_texture_type()); if (target == GL_NONE) { @@ -205,7 +205,7 @@ select_target_tex_page(int page) { wglGraphicsStateGuardian *wglgsg; DCAST_INTO_V(wglgsg, _gsg); - nassertv(wglgsg->_wglSetPbufferAttribARB != NULL); + nassertv(wglgsg->_wglSetPbufferAttribARB != nullptr); static const int max_attrib_list = 64; int iattrib_list[max_attrib_list]; @@ -236,7 +236,7 @@ process_events() { // Handle all the messages on the queue in a row. Some of these might be // for another window, but they will get dispatched appropriately. - while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { + while (PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE)) { process_1_event(); } } @@ -248,7 +248,7 @@ process_events() { */ bool wglGraphicsBuffer:: get_supports_render_texture() const { - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } @@ -262,7 +262,7 @@ get_supports_render_texture() const { */ void wglGraphicsBuffer:: close_buffer() { - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { wglGraphicsStateGuardian *wglgsg; DCAST_INTO_V(wglgsg, _gsg); @@ -294,7 +294,7 @@ open_buffer() { wglGraphicsStateGuardian *wglgsg; if (_gsg == 0) { // There is no old gsg. Create a new one. - wglgsg = new wglGraphicsStateGuardian(_engine, _pipe, NULL); + wglgsg = new wglGraphicsStateGuardian(_engine, _pipe, nullptr); wglgsg->choose_pixel_format(_fb_properties, true); _gsg = wglgsg; } else { @@ -315,12 +315,12 @@ open_buffer() { HDC twindow_dc = wglgsg->get_twindow_dc(); if (twindow_dc == 0) { // If we couldn't make a window, we can't get a GL context. - _gsg = NULL; + _gsg = nullptr; return false; } HGLRC context = wglgsg->get_context(twindow_dc); if (context == 0) { - _gsg = NULL; + _gsg = nullptr; return false; } wglGraphicsPipe::wgl_make_current(twindow_dc, context, @@ -329,7 +329,7 @@ open_buffer() { wglgsg->report_my_gl_errors(); if (!wglgsg->get_fb_properties().verify_hardware_software (_fb_properties,wglgsg->get_gl_renderer())) { - _gsg = NULL; + _gsg = nullptr; return false; } _fb_properties = wglgsg->get_fb_properties(); @@ -340,7 +340,7 @@ open_buffer() { if (!rebuild_bitplanes()) { wglGraphicsPipe::wgl_make_current(0, 0, &_make_current_pcollector); - _gsg = NULL; + _gsg = nullptr; return false; } @@ -366,7 +366,7 @@ release_pbuffer() { _pbuffer_bound->release(wglgsg->get_prepared_objects()); _pbuffer_bound = 0; } - wglGraphicsPipe::wgl_make_current(0, 0, NULL); + wglGraphicsPipe::wgl_make_current(0, 0, nullptr); if (_pbuffer_dc) { wglgsg->_wglReleasePbufferDCARB(_pbuffer, _pbuffer_dc); } @@ -398,7 +398,7 @@ rebuild_bitplanes() { } // Find the texture to bind to the color buffer. - Texture *bindtexture = NULL; + Texture *bindtexture = nullptr; for (int i=0; iget_format() != Texture::F_depth_stencil)) { @@ -530,7 +530,7 @@ void wglGraphicsBuffer:: process_1_event() { MSG msg; - if (!GetMessage(&msg, NULL, 0, 0)) { + if (!GetMessage(&msg, nullptr, 0, 0)) { // WM_QUIT received. We need a cleaner way to deal with this. // DestroyAllWindows(false); exit(msg.wParam); // this will invoke AtExitFn diff --git a/panda/src/wgldisplay/wglGraphicsPipe.cxx b/panda/src/wgldisplay/wglGraphicsPipe.cxx index ee2c2a7522..890c34e19c 100644 --- a/panda/src/wgldisplay/wglGraphicsPipe.cxx +++ b/panda/src/wgldisplay/wglGraphicsPipe.cxx @@ -98,12 +98,12 @@ make_output(const string &name, bool &precertify) { if (!_is_valid) { - return NULL; + return nullptr; } wglGraphicsStateGuardian *wglgsg = 0; if (gsg != 0) { - DCAST_INTO_R(wglgsg, gsg, NULL); + DCAST_INTO_R(wglgsg, gsg, nullptr); } bool support_rtt; @@ -125,13 +125,13 @@ make_output(const string &name, ((flags&BF_can_bind_color)!=0)|| ((flags&BF_can_bind_every)!=0)|| ((flags&BF_can_bind_layered)!=0)) { - return NULL; + return nullptr; } if ((flags & BF_fb_props_optional)==0) { if ((fb_prop.get_aux_rgba() > 0)|| (fb_prop.get_aux_hrgba() > 0)|| (fb_prop.get_aux_float() > 0)) { - return NULL; + return nullptr; } } return new wglGraphicsWindow(engine, this, name, fb_prop, win_prop, @@ -141,9 +141,9 @@ make_output(const string &name, // Second thing to try: a GLGraphicsBuffer if (retry == 1) { - if (!gl_support_fbo || host == NULL || + if (!gl_support_fbo || host == nullptr || (flags & (BF_require_parasite | BF_require_window)) != 0) { - return NULL; + return nullptr; } // Early failure - if we are sure that this buffer WONT meet specs, we can // bail out early. @@ -151,13 +151,13 @@ make_output(const string &name, if (fb_prop.get_indexed_color() || fb_prop.get_back_buffers() > 0 || fb_prop.get_accum_bits() > 0) { - return NULL; + return nullptr; } } - if (wglgsg != NULL && wglgsg->is_valid() && !wglgsg->needs_reset()) { + if (wglgsg != nullptr && wglgsg->is_valid() && !wglgsg->needs_reset()) { if (!wglgsg->_supports_framebuffer_object || - wglgsg->_glDrawBuffers == NULL) { - return NULL; + wglgsg->_glDrawBuffers == nullptr) { + return nullptr; } else { // Early success - if we are sure that this buffer WILL meet specs, we // can precertify it. @@ -174,13 +174,13 @@ make_output(const string &name, if (((flags&BF_require_parasite)!=0)|| ((flags&BF_require_window)!=0)|| ((flags&BF_can_bind_layered)!=0)) { - return NULL; + return nullptr; } if ((wglgsg != 0) && (wglgsg->is_valid()) && (!wglgsg->needs_reset()) && !wglgsg->_supports_pbuffer) { - return NULL; + return nullptr; } if (!support_rtt) { @@ -188,7 +188,7 @@ make_output(const string &name, ((flags&BF_can_bind_every)!=0)) { // If we require Render-to-Texture, but can't be sure we support it, // bail. - return NULL; + return nullptr; } } @@ -198,7 +198,7 @@ make_output(const string &name, if ((fb_prop.get_aux_rgba() > 0)|| (fb_prop.get_aux_rgba() > 0)|| (fb_prop.get_aux_float() > 0)) { - return NULL; + return nullptr; } } // Early success - if we are sure that this buffer WILL meet specs, we can @@ -216,7 +216,7 @@ make_output(const string &name, } // Nothing else left to try. - return NULL; + return nullptr; } /** @@ -227,7 +227,7 @@ make_output(const string &name, */ PT(GraphicsStateGuardian) wglGraphicsPipe:: make_callback_gsg(GraphicsEngine *engine) { - return new wglGraphicsStateGuardian(engine, this, NULL); + return new wglGraphicsStateGuardian(engine, this, nullptr); } diff --git a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx index c957fa7e9e..0d6f78ae1c 100644 --- a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx +++ b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx @@ -32,7 +32,7 @@ wglGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, _share_with(share_with) { _made_context = false; - _context = (HGLRC)NULL; + _context = (HGLRC)nullptr; _twindow = (HWND)0; _twindow_dc = (HDC)0; @@ -46,7 +46,7 @@ wglGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, _supports_wgl_multisample = false; _supports_wgl_render_texture = false; - _wglCreateContextAttribsARB = NULL; + _wglCreateContextAttribsARB = nullptr; get_gamma_table(); atexit(atexit_function); @@ -58,9 +58,9 @@ wglGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, wglGraphicsStateGuardian:: ~wglGraphicsStateGuardian() { release_twindow(); - if (_context != (HGLRC)NULL) { + if (_context != (HGLRC)nullptr) { wglDeleteContext(_context); - _context = (HGLRC)NULL; + _context = (HGLRC)nullptr; } } @@ -268,9 +268,9 @@ choose_pixel_format(const FrameBufferProperties &properties, int best_quality = 0; FrameBufferProperties best_prop; - HDC hdc = GetDC(NULL); + HDC hdc = GetDC(nullptr); - int max_pfnum = DescribePixelFormat(hdc, 1, 0, NULL); + int max_pfnum = DescribePixelFormat(hdc, 1, 0, nullptr); for (int pfnum = 0; pfnumget_share_context(); - if (share_context == NULL) { + if (share_context == nullptr) { // Whoops, the target context hasn't yet made its own context. In that // case, it will share context with us. _share_with->redirect_share_pool(this); @@ -647,7 +647,7 @@ make_context(HDC hdc) { } } - _share_with = (wglGraphicsStateGuardian *)NULL; + _share_with = nullptr; } } @@ -663,10 +663,10 @@ get_share_context() const { if (_made_context) { return _context; } - if (_share_with != (wglGraphicsStateGuardian *)NULL) { + if (_share_with != nullptr) { return _share_with->get_share_context(); } - return NULL; + return nullptr; } /** @@ -680,7 +680,7 @@ get_share_context() const { void wglGraphicsStateGuardian:: redirect_share_pool(wglGraphicsStateGuardian *share_with) { nassertv(!_made_context); - if (_share_with != (wglGraphicsStateGuardian *)NULL) { + if (_share_with != nullptr) { _share_with->redirect_share_pool(share_with); } else { _share_with = share_with; @@ -700,9 +700,9 @@ make_twindow() { DWORD window_style = 0; register_twindow_class(); - HINSTANCE hinstance = GetModuleHandle(NULL); + HINSTANCE hinstance = GetModuleHandle(nullptr); _twindow = CreateWindow(_twindow_class_name, "twindow", window_style, - 0, 0, 1, 1, NULL, NULL, hinstance, 0); + 0, 0, 1, 1, nullptr, nullptr, hinstance, 0); if (!_twindow) { wgldisplay_cat.error() @@ -753,7 +753,7 @@ register_twindow_class() { WNDCLASS wc; - HINSTANCE instance = GetModuleHandle(NULL); + HINSTANCE instance = GetModuleHandle(nullptr); // Clear before filling in window structure! ZeroMemory(&wc, sizeof(WNDCLASS)); @@ -834,7 +834,7 @@ get_gamma_table(void) { get = false; if (_gamma_table_initialized == false) { - HDC hdc = GetDC(NULL); + HDC hdc = GetDC(nullptr); if (hdc) { if (GetDeviceGammaRamp (hdc, (LPVOID) _orignial_gamma_table)) { @@ -842,7 +842,7 @@ get_gamma_table(void) { get = true; } - ReleaseDC (NULL, hdc); + ReleaseDC (nullptr, hdc); } } @@ -855,7 +855,7 @@ get_gamma_table(void) { bool wglGraphicsStateGuardian:: static_set_gamma(bool restore, PN_stdfloat gamma) { bool set; - HDC hdc = GetDC(NULL); + HDC hdc = GetDC(nullptr); set = false; if (hdc) { @@ -872,7 +872,7 @@ static_set_gamma(bool restore, PN_stdfloat gamma) { set = true; } - ReleaseDC (NULL, hdc); + ReleaseDC (nullptr, hdc); } return set; diff --git a/panda/src/wgldisplay/wglGraphicsWindow.cxx b/panda/src/wgldisplay/wglGraphicsWindow.cxx index a2aad595c7..a0cfb1a785 100644 --- a/panda/src/wgldisplay/wglGraphicsWindow.cxx +++ b/panda/src/wgldisplay/wglGraphicsWindow.cxx @@ -56,7 +56,7 @@ bool wglGraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } @@ -99,7 +99,7 @@ void wglGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { copy_to_textures(); @@ -164,7 +164,7 @@ ready_flip() { */ void wglGraphicsWindow:: end_flip() { - if (_hdc != NULL && _flip_ready) { + if (_hdc != nullptr && _flip_ready) { // The documentation on SwapBuffers() is not at all clear on whether the // GL context needs to be current before it can be called. Empirically, // it appears that it is not necessary in many cases, but it definitely is @@ -184,8 +184,8 @@ end_flip() { */ void wglGraphicsWindow:: close_window() { - if (_gsg != (GraphicsStateGuardian *)NULL) { - wglGraphicsPipe::wgl_make_current(_hdc, NULL, &_make_current_pcollector); + if (_gsg != nullptr) { + wglGraphicsPipe::wgl_make_current(_hdc, nullptr, &_make_current_pcollector); _gsg.clear(); } ReleaseDC(_hWnd, _hdc); @@ -208,7 +208,7 @@ open_window() { wglGraphicsStateGuardian *wglgsg; if (_gsg == 0) { // There is no old gsg. Create a new one. - wglgsg = new wglGraphicsStateGuardian(_engine, _pipe, NULL); + wglgsg = new wglGraphicsStateGuardian(_engine, _pipe, nullptr); wglgsg->choose_pixel_format(_fb_properties, false); _gsg = wglgsg; } else { diff --git a/panda/src/windisplay/winDetectDx.h b/panda/src/windisplay/winDetectDx.h index 8a3a9c340e..e350c37564 100644 --- a/panda/src/windisplay/winDetectDx.h +++ b/panda/src/windisplay/winDetectDx.h @@ -72,8 +72,8 @@ static DWORD _GetLastError (char *message_prefix) { error = GetLastError ( ); if (FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER |FORMAT_MESSAGE_FROM_SYSTEM, - NULL, error, MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US ), - (LPTSTR)&ptr,0, NULL)) { + nullptr, error, MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US ), + (LPTSTR)&ptr,0, nullptr)) { cout << "ERROR: "<< message_prefix << " result = " << (char*) ptr << "\n"; LocalFree( ptr ); } @@ -94,11 +94,11 @@ static DWORD print_GetLastError (char *message_prefix) error = GetLastError ( ); if (FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, + nullptr, error, MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US ), (LPTSTR)&ptr, - 0, NULL)) + 0, nullptr)) { cout << "ERROR: "<< message_prefix << " result = " << (char*) ptr << "\n"; LocalFree( ptr ); @@ -153,7 +153,7 @@ static int get_display_information (DisplaySearchParameters &display_search_para window_height = 0; window_bits_per_pixel = 0; total_display_modes = 0; - display_mode_array = NULL; + display_mode_array = nullptr; minimum_width = display_search_parameters._minimum_width; minimum_height = display_search_parameters._minimum_height; @@ -195,7 +195,7 @@ static int get_display_information (DisplaySearchParameters &display_search_para DIRECT_3D direct_3d; direct_3d = Direct3DCreate (D3D_SDK_VERSION); - if (direct_3d != NULL) { + if (direct_3d != nullptr) { DWORD flags; UINT adapter; D3DDEVTYPE device_type; @@ -471,15 +471,15 @@ static int get_display_information (DisplaySearchParameters &display_search_para WNDCLASSEX window_class = { sizeof (WNDCLASSEX), CS_CLASSDC, window_procedure, 0L, 0L, - GetModuleHandle(NULL), NULL, NULL, NULL, NULL, - "class_name", NULL + GetModuleHandle(nullptr), nullptr, nullptr, nullptr, nullptr, + "class_name", nullptr }; RegisterClassEx (&window_class); HWND window_handle; - window_handle = CreateWindow ("class_name", "window_name", WS_DISABLED, 0, 0, width, height, (HWND) NULL, (HMENU) NULL, window_class.hInstance, NULL); - if (window_handle != NULL) { + window_handle = CreateWindow ("class_name", "window_name", WS_DISABLED, 0, 0, width, height, (HWND) nullptr, (HMENU) nullptr, window_class.hInstance, nullptr); + if (window_handle != nullptr) { ShowWindow (window_handle, SW_HIDE); DIRECT_3D_DEVICE direct_3d_device; @@ -538,7 +538,7 @@ static int get_display_information (DisplaySearchParameters &display_search_para D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture_array [total_textures], - NULL); + nullptr); if (texture_result == D3D_OK) { total_textures++; } diff --git a/panda/src/windisplay/winGraphicsPipe.cxx b/panda/src/windisplay/winGraphicsPipe.cxx index 1861c7d303..973567a4aa 100644 --- a/panda/src/windisplay/winGraphicsPipe.cxx +++ b/panda/src/windisplay/winGraphicsPipe.cxx @@ -123,7 +123,7 @@ int update_cpu_frequency_function(int processor_number, DisplayInformation *disp } information_level = ProcessorInformation; - input_buffer = NULL; + input_buffer = nullptr; output_buffer = processor_power_information_array; input_buffer_size = 0; output_buffer_size = sizeof(PROCESSOR_POWER_INFORMATION) * MAXIMUM_PROCESSORS; @@ -162,7 +162,7 @@ count_number_of_cpus(DisplayInformation *display_information) { LPFN_GLPI glpi; glpi = (LPFN_GLPI)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "GetLogicalProcessorInformation"); - if (glpi == NULL) { + if (glpi == nullptr) { windisplay_cat.info() << "GetLogicalProcessorInformation is not supported.\n"; return; @@ -170,17 +170,17 @@ count_number_of_cpus(DisplayInformation *display_information) { // Allocate a buffer to hold the result of the // GetLogicalProcessorInformation call. - PSYSTEM_LOGICAL_PROCESSOR_INFORMATION buffer = NULL; + PSYSTEM_LOGICAL_PROCESSOR_INFORMATION buffer = nullptr; DWORD buffer_length = 0; DWORD rc = glpi(buffer, &buffer_length); while (!rc) { if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - if (buffer != NULL) { + if (buffer != nullptr) { PANDA_FREE_ARRAY(buffer); } buffer = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION)PANDA_MALLOC_ARRAY(buffer_length); - nassertv(buffer != NULL); + nassertv(buffer != nullptr); } else { windisplay_cat.info() << "GetLogicalProcessorInformation failed: " << GetLastError() @@ -225,13 +225,13 @@ WinGraphicsPipe() { _supported_types = OT_window | OT_fullscreen_window; HMODULE user32 = GetModuleHandleA("user32.dll"); - if (user32 != NULL) { + if (user32 != nullptr) { if (dpi_aware) { typedef HRESULT (WINAPI *PFN_SETPROCESSDPIAWARENESS)(Process_DPI_Awareness); PFN_SETPROCESSDPIAWARENESS pfnSetProcessDpiAwareness = (PFN_SETPROCESSDPIAWARENESS)GetProcAddress(user32, "SetProcessDpiAwarenessInternal"); - if (pfnSetProcessDpiAwareness == NULL) { + if (pfnSetProcessDpiAwareness == nullptr) { if (windisplay_cat.is_debug()) { windisplay_cat.debug() << "Unable to find SetProcessDpiAwareness in user32.dll.\n"; } @@ -263,7 +263,7 @@ WinGraphicsPipe() { pvector display_modes; DEVMODE dm{}; dm.dmSize = sizeof(dm); - for (int i = 0; EnumDisplaySettings(NULL, i, &dm) != 0; ++i) { + for (int i = 0; EnumDisplaySettings(nullptr, i, &dm) != 0; ++i) { DisplayMode mode; mode.width = dm.dmPelsWidth; mode.height = dm.dmPelsHeight; diff --git a/panda/src/windisplay/winGraphicsWindow.I b/panda/src/windisplay/winGraphicsWindow.I index 1a51d47988..9a873d9181 100644 --- a/panda/src/windisplay/winGraphicsWindow.I +++ b/panda/src/windisplay/winGraphicsWindow.I @@ -49,7 +49,7 @@ set_cursor_in_window() { INLINE void WinGraphicsWindow:: set_cursor_out_of_window() { if (_cursor_window == this) { - update_cursor_window(NULL); + update_cursor_window(nullptr); } } @@ -74,7 +74,7 @@ get_ime_hwnd() { if (_ime_active) return _ime_hWnd; else - return NULL; + return nullptr; } /** diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index dac15d8c41..bd8244e880 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -44,9 +44,9 @@ TypeHandle WinGraphicsWindow::_type_handle; TypeHandle WinGraphicsWindow::WinWindowHandle::_type_handle; WinGraphicsWindow::WindowHandles WinGraphicsWindow::_window_handles; -WinGraphicsWindow *WinGraphicsWindow::_creating_window = NULL; +WinGraphicsWindow *WinGraphicsWindow::_creating_window = nullptr; -WinGraphicsWindow *WinGraphicsWindow::_cursor_window = NULL; +WinGraphicsWindow *WinGraphicsWindow::_cursor_window = nullptr; bool WinGraphicsWindow::_cursor_hidden = false; RECT WinGraphicsWindow::_mouse_unconfined_cliprect; @@ -103,7 +103,7 @@ WinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, _rcontrol_down = false; _lalt_down = false; _ralt_down = false; - _hparent = NULL; + _hparent = nullptr; _num_touches = 0; } @@ -112,7 +112,7 @@ WinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, */ WinGraphicsWindow:: ~WinGraphicsWindow() { - if (_window_handle != (WindowHandle *)NULL) { + if (_window_handle != nullptr) { DCAST(WinWindowHandle, _window_handle)->clear_window(); } } @@ -229,7 +229,7 @@ process_events() { // Handle all the messages on the queue in a row. Some of these might be // for another window, but they will get dispatched appropriately. - while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { + while (PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE)) { process_1_event(); } } @@ -292,7 +292,7 @@ set_properties_now(WindowProperties &properties) { _cursor = get_cursor(filename); if (_cursor == 0) { - _cursor = LoadCursor(NULL, IDC_ARROW); + _cursor = LoadCursor(nullptr, IDC_ARROW); } if (_cursor_window == this) { @@ -361,7 +361,7 @@ set_properties_now(WindowProperties &properties) { case WindowProperties::M_relative: // not implemented, treat as absolute if (_properties.get_mouse_mode() == WindowProperties::M_confined) { - ClipCursor(NULL); + ClipCursor(nullptr); windisplay_cat.info() << "Unconfining cursor from window\n"; } _properties.set_mouse_mode(WindowProperties::M_absolute); @@ -409,7 +409,7 @@ trigger_flip() { // Now that we've drawn or whatever, invalidate the rectangle so we won't // redraw again until we get the WM_PAINT message. - InvalidateRect(_hWnd, NULL, FALSE); + InvalidateRect(_hWnd, nullptr, FALSE); _got_expose_event = false; if (windisplay_cat.is_spam()) { @@ -449,7 +449,7 @@ open_window() { _cursor = get_cursor(_properties.get_cursor_filename()); } if (_cursor == 0) { - _cursor = LoadCursor(NULL, IDC_ARROW); + _cursor = LoadCursor(nullptr, IDC_ARROW); } bool want_foreground = (!_properties.has_foreground() || _properties.get_foreground()); bool want_minimized = (_properties.has_minimized() && _properties.get_minimized()) && !want_foreground; @@ -461,7 +461,7 @@ open_window() { // it gives us a handle. Warning: this is not thread safe! _creating_window = this; bool opened = open_graphic_window(is_fullscreen()); - _creating_window = (WinGraphicsWindow *)NULL; + _creating_window = nullptr; if (!opened) { return false; @@ -530,7 +530,7 @@ open_window() { _window_handle = new WinWindowHandle(this, *_window_handle); // And tell our parent window that we're now its child. - if (_parent_window_handle != (WindowHandle *)NULL) { + if (_parent_window_handle != nullptr) { _parent_window_handle->attach_child(_window_handle); } @@ -551,7 +551,7 @@ open_window() { } // Register for Win7 touch events. - if (pRegisterTouchWindow != NULL) { + if (pRegisterTouchWindow != nullptr) { pRegisterTouchWindow(_hWnd, 0); } @@ -579,7 +579,7 @@ initialize_input_devices() { add_input_device(device); // Get the number of devices. - if (GetRawInputDeviceList(NULL, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) != 0) { + if (GetRawInputDeviceList(nullptr, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) != 0) { return; } @@ -704,7 +704,7 @@ do_reshape_request(int x_origin, int y_origin, bool has_origin, flags |= SWP_NOMOVE; } - SetWindowPos(_hWnd, NULL, x_origin, y_origin, + SetWindowPos(_hWnd, nullptr, x_origin, y_origin, view_rect.right - view_rect.left, view_rect.bottom - view_rect.top, flags); @@ -801,7 +801,7 @@ do_fullscreen_resize(int x_size, int y_size) { } // this causes WM_SIZE msg to be produced - SetWindowPos(_hWnd, NULL, 0,0, x_size, y_size, + SetWindowPos(_hWnd, nullptr, 0,0, x_size, y_size, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSENDCHANGING); int chg_result = ChangeDisplaySettings(&dm, CDS_FULLSCREEN); @@ -1009,17 +1009,17 @@ open_graphic_window(bool fullscreen) { } const WindowClass &wclass = register_window_class(_properties); - HINSTANCE hinstance = GetModuleHandle(NULL); + HINSTANCE hinstance = GetModuleHandle(nullptr); - _hparent = NULL; + _hparent = nullptr; if (!fullscreen){ WindowHandle *window_handle = _properties.get_parent_window(); - if (window_handle != NULL) { + if (window_handle != nullptr) { windisplay_cat.info() << "Got parent_window " << *window_handle << "\n"; WindowHandle::OSHandle *os_handle = window_handle->get_os_handle(); - if (os_handle != NULL) { + if (os_handle != nullptr) { windisplay_cat.info() << "os_handle type " << os_handle->get_type() << "\n"; @@ -1034,7 +1034,7 @@ open_graphic_window(bool fullscreen) { } _parent_window_handle = window_handle; } else { - _parent_window_handle = NULL; + _parent_window_handle = nullptr; } if (!_hparent) { // This can be a regular window or a fullscreen window @@ -1042,7 +1042,7 @@ open_graphic_window(bool fullscreen) { metrics.x, metrics.y, metrics.width, metrics.height, - NULL, NULL, hinstance, 0); + nullptr, nullptr, hinstance, 0); } else { // This is a regular window with a parent int x_origin = 0; int y_origin = 0; @@ -1056,7 +1056,7 @@ open_graphic_window(bool fullscreen) { WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS , x_origin, y_origin, _properties.get_x_size(), _properties.get_y_size(), - _hparent, NULL, hinstance, 0); + _hparent, nullptr, hinstance, 0); if (_hWnd) { // join our keyboard state with the parents @@ -1151,7 +1151,7 @@ do_fullscreen_enable() { */ bool WinGraphicsWindow:: do_fullscreen_disable() { - int chg_result = ChangeDisplaySettings(NULL, 0x0); + int chg_result = ChangeDisplaySettings(nullptr, 0x0); if (chg_result != DISP_CHANGE_SUCCESSFUL) { windisplay_cat.warning() << "ChangeDisplaySettings failed to restore Windowed mode\n"; @@ -1247,13 +1247,13 @@ track_mouse_leaving(HWND hwnd) { */ void WinGraphicsWindow:: set_focus() { - if (SetFocus(_hWnd) == NULL && GetLastError() != 0) { + if (SetFocus(_hWnd) == nullptr && GetLastError() != 0) { // If the SetFocus() request failed, maybe we're running in the plugin // environment on Vista, with UAC enabled. In this case, we're not // allowed to assign focus to the Panda window for some stupid reason. So // instead, we have to ask the parent window (in the browser process) to // proxy our keyboard events for us. - if (_parent_window_handle != NULL && _window_handle != NULL) { + if (_parent_window_handle != nullptr && _window_handle != nullptr) { _parent_window_handle->request_keyboard_focus(_window_handle); } else { // Otherwise, something is wrong. @@ -1456,7 +1456,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { windisplay_cat.debug() << "WM_WINDOWPOSCHANGED: " << hwnd << ", " << wparam << "\n"; } - if (_hWnd != NULL) { + if (_hWnd != nullptr) { handle_reshape(); } adjust_z_order(); @@ -1466,7 +1466,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { // In response to WM_PAINT, we check to see if there are any update // regions at all; if there are, we declare the window exposed. This is // used to implement !_unexposed_draw. - if (GetUpdateRect(_hWnd, NULL, false)) { + if (GetUpdateRect(_hWnd, nullptr, false)) { if (windisplay_cat.is_spam()) { windisplay_cat.spam() << "Got update regions: " << this << "\n"; @@ -1715,10 +1715,10 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { } if (lparam & GCS_COMPSTR) { - result_size = ImmGetCompositionStringW(hIMC, GCS_CURSORPOS, NULL, 0); + result_size = ImmGetCompositionStringW(hIMC, GCS_CURSORPOS, nullptr, 0); cursor_pos = result_size & 0xffff; - result_size = ImmGetCompositionStringW(hIMC, GCS_DELTASTART, NULL, 0); + result_size = ImmGetCompositionStringW(hIMC, GCS_DELTASTART, nullptr, 0); delta_start = result_size & 0xffff; result_size = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, ime_buffer, ime_buffer_size); size_t num_chars = result_size / sizeof(wchar_t); @@ -1863,12 +1863,12 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { HGLOBAL hglb; char *lptstr; - if (IsClipboardFormatAvailable(CF_TEXT) && OpenClipboard(NULL)) { + if (IsClipboardFormatAvailable(CF_TEXT) && OpenClipboard(nullptr)) { // Maybe we should support CF_UNICODETEXT if it is available too? hglb = GetClipboardData(CF_TEXT); - if (hglb!=NULL) { + if (hglb!=nullptr) { lptstr = (char *) GlobalLock(hglb); - if (lptstr != NULL) { + if (lptstr != nullptr) { char *pChar; for (pChar=lptstr; *pChar; pChar++) { _input_devices[0].keystroke((uchar)*pChar); @@ -2105,7 +2105,7 @@ static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { } // The window wasn't in the map; we must be creating it right now. - if (_creating_window != (WinGraphicsWindow *)NULL) { + if (_creating_window != nullptr) { return _creating_window->window_proc(hwnd, msg, wparam, lparam); } @@ -2121,7 +2121,7 @@ void WinGraphicsWindow:: process_1_event() { MSG msg; - if (!GetMessage(&msg, NULL, 0, 0)) { + if (!GetMessage(&msg, nullptr, 0, 0)) { // WM_QUIT received. We need a cleaner way to deal with this. // DestroyAllWindows(false); exit(msg.wParam); // this will invoke AtExitFn @@ -2155,7 +2155,7 @@ resend_lost_keypresses() { void WinGraphicsWindow:: update_cursor_window(WinGraphicsWindow *to_window) { bool hide_cursor = false; - if (to_window == (WinGraphicsWindow *)NULL) { + if (to_window == nullptr) { // We are leaving a graphics window; we should restore the Win2000 // effects. if (_got_saved_params) { @@ -2237,7 +2237,7 @@ find_acceptable_display_mode(DWORD dwWidth, DWORD dwHeight, DWORD bpp, DEVMODE cur_dm; ZeroMemory(&cur_dm, sizeof(cur_dm)); cur_dm.dmSize = sizeof(cur_dm); - EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &cur_dm); + EnumDisplaySettings(nullptr, ENUM_CURRENT_SETTINGS, &cur_dm); int modenum = 0; int saved_modenum = -1; @@ -2246,7 +2246,7 @@ find_acceptable_display_mode(DWORD dwWidth, DWORD dwHeight, DWORD bpp, ZeroMemory(&dm, sizeof(dm)); dm.dmSize = sizeof(dm); - if (!EnumDisplaySettings(NULL, modenum, &dm)) { + if (!EnumDisplaySettings(nullptr, modenum, &dm)) { break; } @@ -2269,7 +2269,7 @@ find_acceptable_display_mode(DWORD dwWidth, DWORD dwHeight, DWORD bpp, ZeroMemory(&dm, sizeof(dm)); dm.dmSize = sizeof(dm); - if (EnumDisplaySettings(NULL, saved_modenum, &dm)) { + if (EnumDisplaySettings(nullptr, saved_modenum, &dm)) { return true; } } @@ -2290,10 +2290,10 @@ show_error_message(DWORD message_id) { } FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, message_id, + nullptr, message_id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), //The user default language (LPTSTR)&message_buffer, // the weird ptrptr->ptr cast is intentional, see FORMAT_MESSAGE_ALLOCATE_BUFFER - 1024, NULL); + 1024, nullptr); MessageBox(GetDesktopWindow(), message_buffer, _T(errorbox_title), MB_OK); windisplay_cat.fatal() << "System error msg: " << message_buffer << endl; LocalFree(message_buffer); @@ -2636,12 +2636,12 @@ handle_raw_input(HRAWINPUT hraw) { if (hraw == 0) { return; } - if (GetRawInputData(hraw, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER)) == -1) { + if (GetRawInputData(hraw, RID_INPUT, nullptr, &dwSize, sizeof(RAWINPUTHEADER)) == -1) { return; } lpb = (LPBYTE)alloca(sizeof(LPBYTE) * dwSize); - if (lpb == NULL) { + if (lpb == nullptr) { return; } @@ -2755,7 +2755,7 @@ get_icon(const Filename &filename) { Filename os = resolved.to_os_specific(); - HANDLE h = LoadImage(NULL, os.c_str(), + HANDLE h = LoadImage(nullptr, os.c_str(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE); if (h == 0) { windisplay_cat.warning() @@ -2803,7 +2803,7 @@ get_cursor(const Filename &filename) { Filename os = resolved.to_os_specific(); - HANDLE h = LoadImage(NULL, os.c_str(), + HANDLE h = LoadImage(nullptr, os.c_str(), IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE); if (h == 0) { windisplay_cat.warning() @@ -2842,7 +2842,7 @@ register_window_class(const WindowProperties &props) { WNDCLASSW wc; - HINSTANCE instance = GetModuleHandle(NULL); + HINSTANCE instance = GetModuleHandle(nullptr); // Clear before filling in window structure! ZeroMemory(&wc, sizeof(wc)); @@ -2853,7 +2853,7 @@ register_window_class(const WindowProperties &props) { wc.hIcon = wclass._icon; wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - wc.lpszMenuName = NULL; + wc.lpszMenuName = nullptr; wc.lpszClassName = wclass._name.c_str(); if (!RegisterClassW(&wc)) { @@ -2882,7 +2882,7 @@ WinWindowHandle(WinGraphicsWindow *window, const WindowHandle ©) : */ void WinGraphicsWindow::WinWindowHandle:: clear_window() { - _window = NULL; + _window = nullptr; } /** @@ -2891,7 +2891,7 @@ clear_window() { */ void WinGraphicsWindow::WinWindowHandle:: receive_windows_message(unsigned int msg, int wparam, int lparam) { - if (_window != NULL) { + if (_window != nullptr) { _window->receive_windows_message(msg, wparam, lparam); } } @@ -2905,10 +2905,10 @@ void PrintErrorMessage(DWORD msgID) { msgID=GetLastError(); FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL,msgID, + nullptr,msgID, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), //The user default language (LPTSTR) &pMessageBuffer, // the weird ptrptr->ptr cast is intentional, see FORMAT_MESSAGE_ALLOCATE_BUFFER - 1024, NULL); + 1024, nullptr); MessageBox(GetDesktopWindow(),pMessageBuffer,_T(errorbox_title),MB_OK); windisplay_cat.fatal() << "System error msg: " << pMessageBuffer << endl; LocalFree( pMessageBuffer ); @@ -2968,7 +2968,7 @@ void get_client_rect_screen(HWND hwnd, RECT *view_rect) { * */ void WinGraphicsWindow::add_window_proc( const GraphicsWindowProc* wnd_proc ){ - nassertv(wnd_proc != NULL); + nassertv(wnd_proc != nullptr); _window_proc_classes.insert( (GraphicsWindowProc*)wnd_proc ); } @@ -2977,7 +2977,7 @@ void WinGraphicsWindow::add_window_proc( const GraphicsWindowProc* wnd_proc ){ * */ void WinGraphicsWindow::remove_window_proc( const GraphicsWindowProc* wnd_proc ){ - nassertv(wnd_proc != NULL); + nassertv(wnd_proc != nullptr); _window_proc_classes.erase( (GraphicsWindowProc*)wnd_proc ); } diff --git a/panda/src/x11display/x11GraphicsPipe.I b/panda/src/x11display/x11GraphicsPipe.I index fb56700299..a516b2e6a2 100644 --- a/panda/src/x11display/x11GraphicsPipe.I +++ b/panda/src/x11display/x11GraphicsPipe.I @@ -62,7 +62,7 @@ get_hidden_cursor() { */ INLINE bool x11GraphicsPipe:: supports_relative_mouse() const { - return (_XF86DGADirectVideo != NULL); + return (_XF86DGADirectVideo != nullptr); } /** @@ -70,7 +70,7 @@ supports_relative_mouse() const { */ INLINE bool x11GraphicsPipe:: enable_relative_mouse() { - if (_XF86DGADirectVideo != NULL) { + if (_XF86DGADirectVideo != nullptr) { x11display_cat.info() << "Enabling relative mouse using XF86DGA extension\n"; _XF86DGADirectVideo(_display, _screen, XF86DGADirectMouse); return true; @@ -83,7 +83,7 @@ enable_relative_mouse() { */ INLINE void x11GraphicsPipe:: disable_relative_mouse() { - if (_XF86DGADirectVideo != NULL) { + if (_XF86DGADirectVideo != nullptr) { x11display_cat.info() << "Disabling relative mouse using XF86DGA extension\n"; _XF86DGADirectVideo(_display, _screen, 0); } diff --git a/panda/src/x11display/x11GraphicsPipe.cxx b/panda/src/x11display/x11GraphicsPipe.cxx index a0d4e8ffae..494da180da 100644 --- a/panda/src/x11display/x11GraphicsPipe.cxx +++ b/panda/src/x11display/x11GraphicsPipe.cxx @@ -36,7 +36,7 @@ x11GraphicsPipe:: x11GraphicsPipe(const string &display) : _have_xrandr(false), _xcursor_size(-1), - _XF86DGADirectVideo(NULL) { + _XF86DGADirectVideo(nullptr) { string display_spec = display; if (display_spec.empty()) { @@ -60,10 +60,10 @@ x11GraphicsPipe(const string &display) : _is_valid = false; _supported_types = OT_window | OT_buffer | OT_texture_buffer; - _display = NULL; + _display = nullptr; _screen = 0; - _root = (X11_Window)NULL; - _im = (XIM)NULL; + _root = (X11_Window)nullptr; + _im = (XIM)nullptr; _hidden_cursor = None; install_error_handlers(); @@ -82,7 +82,7 @@ x11GraphicsPipe(const string &display) : if (!XSupportsLocale()) { x11display_cat.warning() - << "X does not support locale " << setlocale(LC_ALL, NULL) << "\n"; + << "X does not support locale " << setlocale(LC_ALL, nullptr) << "\n"; } XSetLocaleModifiers(""); @@ -94,20 +94,20 @@ x11GraphicsPipe(const string &display) : // Dynamically load the xf86dga extension. void *xf86dga = dlopen("libXxf86dga.so.1", RTLD_NOW | RTLD_LOCAL); - if (xf86dga != NULL) { + if (xf86dga != nullptr) { pfn_XF86DGAQueryVersion _XF86DGAQueryVersion = (pfn_XF86DGAQueryVersion)dlsym(xf86dga, "XF86DGAQueryVersion"); _XF86DGADirectVideo = (pfn_XF86DGADirectVideo)dlsym(xf86dga, "XF86DGADirectVideo"); int major_ver, minor_ver; - if (_XF86DGAQueryVersion == NULL || _XF86DGADirectVideo == NULL) { + if (_XF86DGAQueryVersion == nullptr || _XF86DGADirectVideo == nullptr) { x11display_cat.warning() << "libXxf86dga.so.1 does not provide required functions; relative mouse mode will not work.\n"; } else if (!_XF86DGAQueryVersion(_display, &major_ver, &minor_ver)) { - _XF86DGADirectVideo = NULL; + _XF86DGADirectVideo = nullptr; } } else { - _XF86DGADirectVideo = NULL; + _XF86DGADirectVideo = nullptr; if (x11display_cat.is_debug()) { x11display_cat.debug() << "cannot dlopen libXxf86dga.so.1; cursor changing will not work.\n"; @@ -116,7 +116,7 @@ x11GraphicsPipe(const string &display) : // Dynamically load the XCursor extension. void *xcursor = dlopen("libXcursor.so.1", RTLD_NOW | RTLD_LOCAL); - if (xcursor != NULL) { + if (xcursor != nullptr) { pfn_XcursorGetDefaultSize _XcursorGetDefaultSize = (pfn_XcursorGetDefaultSize)dlsym(xcursor, "XcursorGetDefaultSize"); _XcursorXcFileLoadImages = (pfn_XcursorXcFileLoadImages)dlsym(xcursor, "XcursorXcFileLoadImages"); _XcursorImagesLoadCursor = (pfn_XcursorImagesLoadCursor)dlsym(xcursor, "XcursorImagesLoadCursor"); @@ -125,10 +125,10 @@ x11GraphicsPipe(const string &display) : _XcursorImageLoadCursor = (pfn_XcursorImageLoadCursor)dlsym(xcursor, "XcursorImageLoadCursor"); _XcursorImageDestroy = (pfn_XcursorImageDestroy)dlsym(xcursor, "XcursorImageDestroy"); - if (_XcursorGetDefaultSize == NULL || _XcursorXcFileLoadImages == NULL || - _XcursorImagesLoadCursor == NULL || _XcursorImagesDestroy == NULL || - _XcursorImageCreate == NULL || _XcursorImageLoadCursor == NULL || - _XcursorImageDestroy == NULL) { + if (_XcursorGetDefaultSize == nullptr || _XcursorXcFileLoadImages == nullptr || + _XcursorImagesLoadCursor == nullptr || _XcursorImagesDestroy == nullptr || + _XcursorImageCreate == nullptr || _XcursorImageLoadCursor == nullptr || + _XcursorImageDestroy == nullptr) { _xcursor_size = -1; x11display_cat.warning() << "libXcursor.so.1 does not provide required functions; cursor changing will not work.\n"; @@ -148,7 +148,7 @@ x11GraphicsPipe(const string &display) : // Dynamically load the XRandr extension. void *xrandr = dlopen("libXrandr.so.2", RTLD_NOW | RTLD_LOCAL); - if (xrandr != NULL) { + if (xrandr != nullptr) { pfn_XRRQueryExtension _XRRQueryExtension = (pfn_XRRQueryExtension)dlsym(xrandr, "XRRQueryExtension"); _XRRSizes = (pfn_XRRSizes)dlsym(xrandr, "XRRSizes"); _XRRRates = (pfn_XRRRates)dlsym(xrandr, "XRRRates"); @@ -156,9 +156,9 @@ x11GraphicsPipe(const string &display) : _XRRConfigCurrentConfiguration = (pfn_XRRConfigCurrentConfiguration)dlsym(xrandr, "XRRConfigCurrentConfiguration"); _XRRSetScreenConfig = (pfn_XRRSetScreenConfig)dlsym(xrandr, "XRRSetScreenConfig"); - if (_XRRQueryExtension == NULL || _XRRSizes == NULL || _XRRRates == NULL || - _XRRGetScreenInfo == NULL || _XRRConfigCurrentConfiguration == NULL || - _XRRSetScreenConfig == NULL) { + if (_XRRQueryExtension == nullptr || _XRRSizes == nullptr || _XRRRates == nullptr || + _XRRGetScreenInfo == nullptr || _XRRConfigCurrentConfiguration == nullptr || + _XRRSetScreenConfig == nullptr) { _have_xrandr = false; x11display_cat.warning() << "libXrandr.so.2 does not provide required functions; resolution setting will not work.\n"; @@ -204,8 +204,8 @@ x11GraphicsPipe(const string &display) : } // Connect to an input method for supporting international text entry. - _im = XOpenIM(_display, NULL, NULL, NULL); - if (_im == (XIM)NULL) { + _im = XOpenIM(_display, nullptr, nullptr, nullptr); + if (_im == (XIM)nullptr) { x11display_cat.warning() << "Couldn't open input method.\n"; } diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index 0a1539bd42..5fb290e315 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -105,9 +105,9 @@ x11GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, DCAST_INTO_V(x11_pipe, _pipe); _display = x11_pipe->get_display(); _screen = x11_pipe->get_screen(); - _xwindow = (X11_Window)NULL; - _ic = (XIC)NULL; - _visual_info = NULL; + _xwindow = (X11_Window)nullptr; + _ic = (XIC)nullptr; + _visual_info = nullptr; _orig_size_id = -1; if (x11_pipe->_have_xrandr) { @@ -189,7 +189,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); begin_frame_spam(mode); - if (_gsg == (GraphicsStateGuardian *)NULL) { + if (_gsg == nullptr) { return false; } if (_awaiting_configure) { @@ -220,7 +220,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { void x11GraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - nassertv(_gsg != (GraphicsStateGuardian *)NULL); + nassertv(_gsg != nullptr); if (mode == FM_render) { // end_render_texture(); @@ -489,7 +489,7 @@ process_events() { */ void x11GraphicsWindow:: set_properties_now(WindowProperties &properties) { - if (_pipe == (GraphicsPipe *)NULL) { + if (_pipe == nullptr) { // If the pipe is null, we're probably closing down. GraphicsWindow::set_properties_now(properties); return; @@ -820,18 +820,18 @@ mouse_mode_relative() { */ void x11GraphicsWindow:: close_window() { - if (_gsg != (GraphicsStateGuardian *)NULL) { + if (_gsg != nullptr) { _gsg.clear(); } - if (_ic != (XIC)NULL) { + if (_ic != (XIC)nullptr) { XDestroyIC(_ic); - _ic = (XIC)NULL; + _ic = (XIC)nullptr; } - if (_xwindow != (X11_Window)NULL) { + if (_xwindow != (X11_Window)nullptr) { XDestroyWindow(_display, _xwindow); - _xwindow = (X11_Window)NULL; + _xwindow = (X11_Window)nullptr; // This may be necessary if we just closed the last X window in an // application, so the server hears the close request. @@ -842,7 +842,7 @@ close_window() { // typecast! if (_orig_size_id != (SizeID) -1) { X11_Window root; - if (_pipe != NULL) { + if (_pipe != nullptr) { x11GraphicsPipe *x11_pipe; DCAST_INTO_V(x11_pipe, _pipe); root = x11_pipe->get_root(); @@ -865,7 +865,7 @@ close_window() { */ bool x11GraphicsWindow:: open_window() { - if (_visual_info == NULL) { + if (_visual_info == nullptr) { // No X visual for this fbconfig; how can we open the window? x11display_cat.error() << "No X visual: cannot open window.\n"; @@ -912,11 +912,11 @@ open_window() { X11_Window parent_window = x11_pipe->get_root(); WindowHandle *window_handle = _properties.get_parent_window(); - if (window_handle != NULL) { + if (window_handle != nullptr) { x11display_cat.info() << "Got parent_window " << *window_handle << "\n"; WindowHandle::OSHandle *os_handle = window_handle->get_os_handle(); - if (os_handle != NULL) { + if (os_handle != nullptr) { x11display_cat.info() << "os_handle type " << os_handle->get_type() << "\n"; @@ -973,13 +973,13 @@ open_window() { // can wait until we have an X server that actually supports these to test // it on. XIM im = x11_pipe->get_im(); - _ic = NULL; + _ic = nullptr; if (im) { _ic = XCreateIC (im, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, - (void*)NULL); - if (_ic == (XIC)NULL) { + nullptr); + if (_ic == (XIC)nullptr) { x11display_cat.warning() << "Couldn't create input context.\n"; } @@ -1009,7 +1009,7 @@ open_window() { _window_handle = NativeWindowHandle::make_x11(_xwindow); // And tell our parent window that we're now its child. - if (_parent_window_handle != (WindowHandle *)NULL) { + if (_parent_window_handle != nullptr) { _parent_window_handle->attach_child(_window_handle); } @@ -1033,7 +1033,7 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { // Name the window if there is a name XTextProperty window_name; - XTextProperty *window_name_p = (XTextProperty *)NULL; + XTextProperty *window_name_p = nullptr; if (properties.has_title()) { const char *name = properties.get_title().c_str(); if (XStringListToTextProperty((char **)&name, 1, &window_name) != 0) { @@ -1043,10 +1043,10 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { // The size hints request a window of a particular size andor a particular // placement onscreen. - XSizeHints *size_hints_p = NULL; + XSizeHints *size_hints_p = nullptr; if (properties.has_origin() || properties.has_size()) { size_hints_p = XAllocSizeHints(); - if (size_hints_p != (XSizeHints *)NULL) { + if (size_hints_p != nullptr) { if (properties.has_origin()) { if (_properties.get_fullscreen()) { size_hints_p->x = 0; @@ -1076,9 +1076,9 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { // The window manager hints include requests to the window manager other // than those specific to window geometry. - XWMHints *wm_hints_p = NULL; + XWMHints *wm_hints_p = nullptr; wm_hints_p = XAllocWMHints(); - if (wm_hints_p != (XWMHints *)NULL) { + if (wm_hints_p != nullptr) { if (properties.has_minimized() && properties.get_minimized()) { wm_hints_p->initial_state = IconicState; } else { @@ -1135,7 +1135,7 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { // For other users, we'll totally punt and just set the window's Class to // "Undecorated", and let the user configure hisher window manager not to // put a border around windows of this class. - XClassHint *class_hints_p = NULL; + XClassHint *class_hints_p = nullptr; if (!x_wm_class.empty()) { // Unless the user wanted to use his own WM_CLASS, of course. class_hints_p = XAllocClassHint(); @@ -1226,15 +1226,15 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { } XSetWMProperties(_display, _xwindow, window_name_p, window_name_p, - NULL, 0, size_hints_p, wm_hints_p, class_hints_p); + nullptr, 0, size_hints_p, wm_hints_p, class_hints_p); - if (size_hints_p != (XSizeHints *)NULL) { + if (size_hints_p != nullptr) { XFree(size_hints_p); } - if (wm_hints_p != (XWMHints *)NULL) { + if (wm_hints_p != nullptr) { XFree(wm_hints_p); } - if (class_hints_p != (XClassHint *)NULL) { + if (class_hints_p != nullptr) { XFree(class_hints_p); } @@ -1417,7 +1417,7 @@ handle_keystroke(XKeyEvent &event) { static const int buffer_size = 256; wchar_t buffer[buffer_size]; Status status; - int len = XwcLookupString(_ic, &event, buffer, buffer_size, NULL, + int len = XwcLookupString(_ic, &event, buffer, buffer_size, nullptr, &status); if (status == XBufferOverflow) { x11display_cat.error() @@ -2133,7 +2133,7 @@ get_cursor(const Filename &filename) { // Open the file through the virtual file system. istream *str = vfs->open_read_file(resolved, true); - if (str == NULL) { + if (str == nullptr) { x11display_cat.warning() << "Could not open cursor file " << filename << "\n"; return None; @@ -2161,7 +2161,7 @@ get_cursor(const Filename &filename) { xcfile.seek = &xcursor_seek; XcursorImages *images = x11_pipe->_XcursorXcFileLoadImages(&xcfile, x11_pipe->_xcursor_size); - if (images != NULL) { + if (images != nullptr) { h = x11_pipe->_XcursorImagesLoadCursor(_display, images); x11_pipe->_XcursorImagesDestroy(images); } @@ -2221,13 +2221,13 @@ read_ico(istream &ico) { size_t colorCount, bitsPerPixel; IcoHeader header; IcoInfoHeader infoHeader; - IcoEntry *entries = NULL; - IcoColor color, *palette = NULL; + IcoEntry *entries = nullptr; + IcoColor color, *palette = nullptr; size_t xorBmpSize, andBmpSize; char *curXor, *curAnd; - char *xorBmp = NULL, *andBmp = NULL; - XcursorImage *image = NULL; + char *xorBmp = nullptr, *andBmp = nullptr; + XcursorImage *image = nullptr; X11_Cursor ret = None; int def_size = x11_pipe->_xcursor_size; @@ -2273,7 +2273,7 @@ read_ico(istream &ico) { size_t num_pixels = (size_t)img.get_x_size() * (size_t)img.get_y_size(); unsigned int *dest = image->pixels; - if (alpha != NULL) { + if (alpha != nullptr) { for (size_t p = 0; p < num_pixels; ++p) { *dest++ = (*alpha << 24U) | (ptr->r << 16U) | (ptr->g << 8U) | (ptr->b); ++ptr; diff --git a/pandatool/src/assimp/assimpLoader.cxx b/pandatool/src/assimp/assimpLoader.cxx index fb383a1b7f..4694e89217 100644 --- a/pandatool/src/assimp/assimpLoader.cxx +++ b/pandatool/src/assimp/assimpLoader.cxx @@ -57,7 +57,7 @@ typedef pvector BoneWeightList; AssimpLoader:: AssimpLoader() : _error (false), - _geoms (NULL) { + _geoms (nullptr) { PandaLogger::set_default(); _importer.SetIOHandler(new PandaIOSystem); @@ -82,11 +82,11 @@ get_extensions(string &ext) const { // The format is like: *.mdc;*.mdl;*.mesh.xml;*.mot char *sub = strtok(aexts.data, ";"); - while (sub != NULL) { + while (sub != nullptr) { ext += sub + 2; - sub = strtok(NULL, ";"); + sub = strtok(nullptr, ";"); - if (sub != NULL) { + if (sub != nullptr) { ext += ' '; } } @@ -102,7 +102,7 @@ read(const Filename &filename) { // I really don't know why we need to flip the winding order, but otherwise // the models I tested with are showing inside out. _scene = _importer.ReadFile(_filename.c_str(), aiProcess_Triangulate | aiProcess_GenUVCoords | aiProcess_FlipWindingOrder); - if (_scene == NULL) { + if (_scene == nullptr) { _error = true; return false; } @@ -117,7 +117,7 @@ read(const Filename &filename) { */ void AssimpLoader:: build_graph() { - nassertv(_scene != NULL); // read() must be called first + nassertv(_scene != nullptr); // read() must be called first nassertv(!_error); // and have succeeded // Protect the import process @@ -145,7 +145,7 @@ build_graph() { } // And now the node structure. - if (_scene->mRootNode != NULL) { + if (_scene->mRootNode != nullptr) { load_node(*_scene->mRootNode, _root); } @@ -178,7 +178,7 @@ find_node(const aiNode &root, const aiString &name) { } } - return NULL; + return nullptr; } /** @@ -215,7 +215,7 @@ load_texture(size_t index) { if (img.read(str, "", ftype)) { ptex->load(img); } else { - ptex = NULL; + ptex = nullptr; } } } else { @@ -255,7 +255,7 @@ load_texture_stage(const aiMaterial &mat, const aiTextureType &ttype, CPT(Textur aiTextureMapMode mapmode; for (size_t i = 0; i < mat.GetTextureCount(ttype); ++i) { - mat.GetTexture(ttype, i, &path, &mapping, NULL, &blend, &op, &mapmode); + mat.GetTexture(ttype, i, &path, &mapping, nullptr, &blend, &op, &mapmode); if (AI_SUCCESS != mat.Get(AI_MATKEY_UVWSRC(ttype, i), uvindex)) { // If there's no texture coordinate set for this texture, assume that @@ -270,12 +270,12 @@ load_texture_stage(const aiMaterial &mat, const aiTextureType &ttype, CPT(Textur if (uvindex > 0) { stage->set_texcoord_name(InternalName::get_texcoord_name(str.str())); } - PT(Texture) ptex = NULL; + PT(Texture) ptex = nullptr; // I'm not sure if this is the right way to handle it, as I couldn't find // much information on embedded textures. if (path.data[0] == '*') { - long num = strtol(path.data + 1, NULL, 10); + long num = strtol(path.data + 1, nullptr, 10); ptex = _textures[num]; } else if (path.length > 0) { @@ -308,7 +308,7 @@ load_texture_stage(const aiMaterial &mat, const aiTextureType &ttype, CPT(Textur ptex = TexturePool::load_texture(fn); } - if (ptex != NULL) { + if (ptex != nullptr) { tattr = DCAST(TextureAttrib, tattr->add_on_stage(stage, ptex)); } } @@ -424,7 +424,7 @@ create_anim_channel(const aiAnimation &anim, AnimBundle *bundle, AnimGroup *pare PT(AnimChannelMatrixXfmTable) group = new AnimChannelMatrixXfmTable(parent, node.mName.C_Str()); // See if there is a channel for this node - aiNodeAnim *node_anim = NULL; + aiNodeAnim *node_anim = nullptr; for (size_t i = 0; i < anim.mNumChannels; ++i) { if (anim.mChannels[i]->mNodeName == node.mName) { node_anim = anim.mChannels[i]; @@ -502,7 +502,7 @@ load_mesh(size_t index) { const aiMesh &mesh = *_scene->mMeshes[index]; // Check if we need to make a Character - PT(Character) character = NULL; + PT(Character) character = nullptr; if (mesh.HasBones()) { assimp_cat.debug() << "Creating character for " << mesh.mName.C_Str() << "\n"; @@ -544,7 +544,7 @@ load_mesh(size_t index) { for (size_t i = 0; i < mesh.mNumBones; ++i) { const aiBone &bone = *mesh.mBones[i]; CharacterJoint *joint = character->find_joint(bone.mName.C_Str()); - if (joint == NULL) { + if (joint == nullptr) { assimp_cat.debug() << "Could not find joint for bone: " << bone.mName.C_Str() << "\n"; continue; diff --git a/pandatool/src/assimp/loaderFileTypeAssimp.cxx b/pandatool/src/assimp/loaderFileTypeAssimp.cxx index b4a667d5fe..3f344b2674 100644 --- a/pandatool/src/assimp/loaderFileTypeAssimp.cxx +++ b/pandatool/src/assimp/loaderFileTypeAssimp.cxx @@ -29,7 +29,7 @@ LoaderFileTypeAssimp() : _loader(new AssimpLoader) { */ LoaderFileTypeAssimp:: ~LoaderFileTypeAssimp() { - if (_loader != NULL) { + if (_loader != nullptr) { delete _loader; } } @@ -81,7 +81,7 @@ load_file(const Filename &path, const LoaderOptions &options, << "Reading " << path << "\n"; if (!_loader->read(path)) { - return NULL; + return nullptr; } _loader->build_graph(); diff --git a/pandatool/src/assimp/pandaIOSystem.cxx b/pandatool/src/assimp/pandaIOSystem.cxx index d64b52466f..ff400bd285 100644 --- a/pandatool/src/assimp/pandaIOSystem.cxx +++ b/pandatool/src/assimp/pandaIOSystem.cxx @@ -73,13 +73,13 @@ Open(const char *file, const char *mode) { if (mode[0] == 'r') { istream *stream = _vfs->open_read_file(file, true); - if (stream == NULL) { - return NULL; + if (stream == nullptr) { + return nullptr; } return new PandaIOStream(*stream); } else { - nassertr(false, NULL); // Not implemented on purpose. - return NULL; + nassertr(false, nullptr); // Not implemented on purpose. + return nullptr; } } diff --git a/pandatool/src/assimp/pandaLogger.cxx b/pandatool/src/assimp/pandaLogger.cxx index cab31e1c06..b6432e132e 100644 --- a/pandatool/src/assimp/pandaLogger.cxx +++ b/pandatool/src/assimp/pandaLogger.cxx @@ -15,7 +15,7 @@ #include "DefaultLogger.hpp" -PandaLogger *PandaLogger::_ptr = NULL; +PandaLogger *PandaLogger::_ptr = nullptr; /** * Makes sure there's a global PandaLogger object and makes sure that it is @@ -23,7 +23,7 @@ PandaLogger *PandaLogger::_ptr = NULL; */ void PandaLogger:: set_default() { - if (_ptr == NULL) { + if (_ptr == nullptr) { _ptr = new PandaLogger; } if (_ptr != Assimp::DefaultLogger::get()) { diff --git a/pandatool/src/bam/bamInfo.cxx b/pandatool/src/bam/bamInfo.cxx index 44d015c2fe..bda00908a5 100644 --- a/pandatool/src/bam/bamInfo.cxx +++ b/pandatool/src/bam/bamInfo.cxx @@ -132,7 +132,7 @@ get_info(const Filename &filename) { Objects objects; TypedWritable *object = bam_file.read_object(); - if (object != (TypedWritable *)NULL && + if (object != nullptr && object->is_exact_type(BamCacheRecord::get_class_type())) { // Here's a special case: if the first object in the file is a // BamCacheRecord, it's a cache data file; in this case, we output the @@ -142,8 +142,8 @@ get_info(const Filename &filename) { object = bam_file.read_object(); } - while (object != (TypedWritable *)NULL || !bam_file.is_eof()) { - if (object != (TypedWritable *)NULL) { + while (object != nullptr || !bam_file.is_eof()) { + if (object != nullptr) { objects.push_back(object); } object = bam_file.read_object(); @@ -271,7 +271,7 @@ describe_session(RecorderHeader *header, const BamInfo::Objects &objects) { */ void BamInfo:: describe_general_object(TypedWritable *object) { - nassertv(object != (TypedWritable *)NULL); + nassertv(object != nullptr); nout << " " << object->get_type() << "\n"; } diff --git a/pandatool/src/bam/bamToEgg.cxx b/pandatool/src/bam/bamToEgg.cxx index 7f70255ce9..96aa14e449 100644 --- a/pandatool/src/bam/bamToEgg.cxx +++ b/pandatool/src/bam/bamToEgg.cxx @@ -59,7 +59,7 @@ run() { Objects objects; TypedWritable *object = bam_file.read_object(); - if (object != (TypedWritable *)NULL && + if (object != nullptr && object->is_exact_type(BamCacheRecord::get_class_type())) { // Here's a special case: if the first object in the file is a // BamCacheRecord, it's really a cache data file and not a true bam file; @@ -68,10 +68,10 @@ run() { object = bam_file.read_object(); } - while (object != (TypedWritable *)NULL || !bam_file.is_eof()) { - if (object != (TypedWritable *)NULL) { + while (object != nullptr || !bam_file.is_eof()) { + if (object != nullptr) { ReferenceCount *ref_ptr = object->as_reference_count(); - if (ref_ptr != NULL) { + if (ref_ptr != nullptr) { ref_ptr->ref(); } objects.push_back(object); diff --git a/pandatool/src/bam/eggToBam.cxx b/pandatool/src/bam/eggToBam.cxx index f6c9bf4b52..7522a70cc6 100644 --- a/pandatool/src/bam/eggToBam.cxx +++ b/pandatool/src/bam/eggToBam.cxx @@ -80,7 +80,7 @@ EggToBam() : "egg geometry tagged as \"hidden\" will be removed from the final " "scene graph; otherwise, it will be preserved (but stashed). The " "default is nonzero, to remove it.", - &EggToBam::dispatch_int, NULL, &_egg_suppress_hidden); + &EggToBam::dispatch_int, nullptr, &_egg_suppress_hidden); add_option ("ls", "", 0, @@ -185,7 +185,7 @@ EggToBam() : "Set it to 'default' to use whatever is specified by the Config.prc " "file. This is a global setting only; individual texture quality " "settings appearing within the egg file will override this.", - &EggToBam::dispatch_string, NULL, &_ctex_quality); + &EggToBam::dispatch_string, nullptr, &_ctex_quality); add_option ("load-display", "display name", 0, @@ -197,7 +197,7 @@ EggToBam() : "Panda can compress textures without loading a display module." #endif // HAVE_SQUISH , - &EggToBam::dispatch_string, NULL, &_load_display); + &EggToBam::dispatch_string, nullptr, &_load_display); redescribe_option ("cs", @@ -257,7 +257,7 @@ run() { } PT(PandaNode) root = load_egg_data(_data); - if (root == (PandaNode *)NULL) { + if (root == nullptr) { nout << "Unable to build scene graph from egg file.\n"; exit(1); } @@ -385,7 +385,7 @@ collect_textures(PandaNode *node) { void EggToBam:: collect_textures(const RenderState *state) { const TextureAttrib *tex_attrib = DCAST(TextureAttrib, state->get_attrib(TextureAttrib::get_class_type())); - if (tex_attrib != (TextureAttrib *)NULL) { + if (tex_attrib != nullptr) { int num_on_stages = tex_attrib->get_num_on_stages(); for (int i = 0; i < num_on_stages; ++i) { _textures.insert(tex_attrib->get_on_texture(tex_attrib->get_on_stage(i))); @@ -448,7 +448,7 @@ make_buffer() { GraphicsPipeSelection *selection = GraphicsPipeSelection::get_global_ptr(); _pipe = selection->make_default_pipe(); - if (_pipe == (GraphicsPipe *)NULL) { + if (_pipe == nullptr) { nout << "Unable to create graphics pipe.\n"; return false; } @@ -473,7 +473,7 @@ make_buffer() { fbprops, winprops, GraphicsPipe::BF_fb_props_optional); _engine->open_windows(); - if (_buffer == (GraphicsOutput *)NULL || !_buffer->is_valid()) { + if (_buffer == nullptr || !_buffer->is_valid()) { nout << "Unable to create graphics window.\n"; return false; } diff --git a/pandatool/src/bam/ptsToBam.cxx b/pandatool/src/bam/ptsToBam.cxx index 941b291105..538022bfbc 100644 --- a/pandatool/src/bam/ptsToBam.cxx +++ b/pandatool/src/bam/ptsToBam.cxx @@ -49,7 +49,7 @@ PtsToBam() : WithOutputFile(true, false, true) "Decimates the point cloud by the indicated divisor. The number of points\n" "added is 1/divisor; numbers larger than 1.0 mean correspondingly fewer\n" "points.", - &PtsToBam::dispatch_double, NULL, &_decimate_divisor); + &PtsToBam::dispatch_double, nullptr, &_decimate_divisor); _decimate_divisor = 1.0; } @@ -172,7 +172,7 @@ process_line(const string &line) { */ void PtsToBam:: add_point(const vector_string &words) { - if (_data == NULL || _data->get_num_rows() >= egg_max_vertices) { + if (_data == nullptr || _data->get_num_rows() >= egg_max_vertices) { open_vertex_data(); } @@ -190,7 +190,7 @@ add_point(const vector_string &words) { */ void PtsToBam:: open_vertex_data() { - if (_data != (GeomVertexData *)NULL) { + if (_data != nullptr) { close_vertex_data(); } CPT(GeomVertexFormat) format = GeomVertexFormat::get_v3(); @@ -203,7 +203,7 @@ open_vertex_data() { */ void PtsToBam:: close_vertex_data() { - if (_data == NULL) { + if (_data == nullptr) { return; } @@ -225,7 +225,7 @@ close_vertex_data() { _gnode->add_geom(geom); - _data = NULL; + _data = nullptr; } int main(int argc, char *argv[]) { diff --git a/pandatool/src/converter/eggToSomethingConverter.I b/pandatool/src/converter/eggToSomethingConverter.I index 5e80c2cad8..5432082413 100644 --- a/pandatool/src/converter/eggToSomethingConverter.I +++ b/pandatool/src/converter/eggToSomethingConverter.I @@ -34,7 +34,7 @@ had_error() const { */ INLINE void EggToSomethingConverter:: clear_egg_data() { - set_egg_data((EggData *)NULL); + set_egg_data(nullptr); } /** diff --git a/pandatool/src/converter/eggToSomethingConverter.cxx b/pandatool/src/converter/eggToSomethingConverter.cxx index f786c81f00..1e1629fe1b 100644 --- a/pandatool/src/converter/eggToSomethingConverter.cxx +++ b/pandatool/src/converter/eggToSomethingConverter.cxx @@ -20,7 +20,7 @@ */ EggToSomethingConverter:: EggToSomethingConverter() { - _egg_data = (EggData *)NULL; + _egg_data = nullptr; _error = false; } @@ -29,7 +29,7 @@ EggToSomethingConverter() { */ EggToSomethingConverter:: EggToSomethingConverter(const EggToSomethingConverter ©) { - _egg_data = (EggData *)NULL; + _egg_data = nullptr; _error = false; } diff --git a/pandatool/src/converter/somethingToEggConverter.I b/pandatool/src/converter/somethingToEggConverter.I index 42e9f4b2cf..a0259bc13d 100644 --- a/pandatool/src/converter/somethingToEggConverter.I +++ b/pandatool/src/converter/somethingToEggConverter.I @@ -370,7 +370,7 @@ get_merge_externals() const { */ INLINE void SomethingToEggConverter:: clear_egg_data() { - set_egg_data((EggData *)NULL); + set_egg_data(nullptr); } /** diff --git a/pandatool/src/converter/somethingToEggConverter.cxx b/pandatool/src/converter/somethingToEggConverter.cxx index fd5a17abf7..58c914b7f5 100644 --- a/pandatool/src/converter/somethingToEggConverter.cxx +++ b/pandatool/src/converter/somethingToEggConverter.cxx @@ -33,7 +33,7 @@ SomethingToEggConverter() { _output_frame_rate = 0.0; _control_flags = 0; _merge_externals = false; - _egg_data = (EggData *)NULL; + _egg_data = nullptr; _error = false; } @@ -46,7 +46,7 @@ SomethingToEggConverter(const SomethingToEggConverter ©) : _path_replace(copy._path_replace), _merge_externals(copy._merge_externals) { - _egg_data = (EggData *)NULL; + _egg_data = nullptr; _error = false; } @@ -116,7 +116,7 @@ get_input_units() { */ PT(PandaNode) SomethingToEggConverter:: convert_to_node(const LoaderOptions &options, const Filename &filename) { - return NULL; + return nullptr; } /** diff --git a/pandatool/src/cvscopy/cvsCopy.cxx b/pandatool/src/cvscopy/cvsCopy.cxx index fdb1d6b85e..cc970748a0 100644 --- a/pandatool/src/cvscopy/cvsCopy.cxx +++ b/pandatool/src/cvscopy/cvsCopy.cxx @@ -26,8 +26,8 @@ CVSCopy() { _key_filename = "Sources.pp"; _cvs_binary = "cvs"; _user_aborted = false; - _model_dir = (CVSSourceDirectory *)NULL; - _map_dir = (CVSSourceDirectory *)NULL; + _model_dir = nullptr; + _map_dir = nullptr; clear_runlines(); add_runline("[opts] file [file ... ]"); @@ -73,7 +73,7 @@ CVSCopy() { "is the ppremake convention, \"Sources.pp\". Other likely candidates " "are \"CVS\" to search a CVS hierarchy, or \".\" to include " "all subdirectories indiscriminately.", - &CVSCopy::dispatch_filename, NULL, &_key_filename); + &CVSCopy::dispatch_filename, nullptr, &_key_filename); add_option ("nc", "", 80, @@ -85,7 +85,7 @@ CVSCopy() { ("cvs", "cvs_binary", 80, "Specify how to run the cvs program for adding newly-created files. " "The default is simply \"cvs\".", - &CVSCopy::dispatch_string, NULL, &_cvs_binary); + &CVSCopy::dispatch_string, nullptr, &_cvs_binary); } /** @@ -212,7 +212,7 @@ post_command_line() { } _model_dir = _tree.find_directory(_model_dirname); - if (_model_dir == (CVSSourceDirectory *)NULL) { + if (_model_dir == nullptr) { if (_got_model_dirname) { nout << "Warning: model directory " << _model_dirname << " is not within the source hierarchy.\n"; @@ -222,7 +222,7 @@ post_command_line() { if (_got_map_dirname) { _map_dir = _tree.find_directory(_map_dirname); - if (_map_dir == (CVSSourceDirectory *)NULL) { + if (_map_dir == nullptr) { nout << "Warning: map directory " << _map_dirname << " is not within the source hierarchy.\n"; } @@ -230,7 +230,7 @@ post_command_line() { } else { _map_dir = _tree.find_relpath("src/maps"); - if (_map_dir == (CVSSourceDirectory *)NULL) { + if (_map_dir == nullptr) { nout << "Warning: no directory " << _tree.get_root_dirname() << "/src/maps.\n"; _map_dir = _model_dir; diff --git a/pandatool/src/cvscopy/cvsSourceDirectory.cxx b/pandatool/src/cvscopy/cvsSourceDirectory.cxx index 02e6a9ced1..9ccacc3afd 100644 --- a/pandatool/src/cvscopy/cvsSourceDirectory.cxx +++ b/pandatool/src/cvscopy/cvsSourceDirectory.cxx @@ -27,7 +27,7 @@ CVSSourceDirectory(CVSSourceTree *tree, CVSSourceDirectory *parent, _parent(parent), _dirname(dirname) { - if (_parent == (CVSSourceDirectory *)NULL) { + if (_parent == nullptr) { _depth = 0; } else { _depth = _parent->_depth + 1; @@ -58,7 +58,7 @@ get_dirname() const { */ Filename CVSSourceDirectory:: get_fullpath() const { - if (_parent == (CVSSourceDirectory *)NULL) { + if (_parent == nullptr) { return _tree->get_root_fullpath(); } return Filename(_parent->get_fullpath(), _dirname); @@ -70,7 +70,7 @@ get_fullpath() const { */ Filename CVSSourceDirectory:: get_path() const { - if (_parent == (CVSSourceDirectory *)NULL) { + if (_parent == nullptr) { return _dirname; } return Filename(_parent->get_path(), _dirname); @@ -93,13 +93,13 @@ get_rel_to(const CVSSourceDirectory *other) const { while (a->_depth > b->_depth) { prefix += "../"; a = a->_parent; - nassertr(a != (CVSSourceDirectory *)NULL, string()); + nassertr(a != nullptr, string()); } while (b->_depth > a->_depth) { postfix = b->_dirname + "/" + postfix; b = b->_parent; - nassertr(b != (CVSSourceDirectory *)NULL, string()); + nassertr(b != nullptr, string()); } while (a != b) { @@ -107,8 +107,8 @@ get_rel_to(const CVSSourceDirectory *other) const { postfix = b->_dirname + "/" + postfix; a = a->_parent; b = b->_parent; - nassertr(a != (CVSSourceDirectory *)NULL, string()); - nassertr(b != (CVSSourceDirectory *)NULL, string()); + nassertr(a != nullptr, string()); + nassertr(b != nullptr, string()); } string result = prefix + postfix; @@ -129,7 +129,7 @@ get_num_children() const { */ CVSSourceDirectory *CVSSourceDirectory:: get_child(int n) const { - nassertr(n >= 0 && n < (int)_children.size(), NULL); + nassertr(n >= 0 && n < (int)_children.size(), nullptr); return _children[n]; } @@ -154,11 +154,11 @@ find_relpath(const string &relpath) { return find_relpath(rest); } else if (first == "..") { - if (_parent != NULL) { + if (_parent != nullptr) { return _parent->find_relpath(rest); } // Tried to back out past the root directory. - return (CVSSourceDirectory *)NULL; + return nullptr; } // Check for a child with the name indicated by first. @@ -170,7 +170,7 @@ find_relpath(const string &relpath) { } // No match. - return (CVSSourceDirectory *)NULL; + return nullptr; } /** @@ -186,12 +186,12 @@ find_dirname(const string &dirname) { Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { CVSSourceDirectory *result = (*ci)->find_dirname(dirname); - if (result != (CVSSourceDirectory *)NULL) { + if (result != nullptr) { return result; } } - return (CVSSourceDirectory *)NULL; + return nullptr; } /** diff --git a/pandatool/src/cvscopy/cvsSourceTree.cxx b/pandatool/src/cvscopy/cvsSourceTree.cxx index 333c4991ad..69b483fa3c 100644 --- a/pandatool/src/cvscopy/cvsSourceTree.cxx +++ b/pandatool/src/cvscopy/cvsSourceTree.cxx @@ -36,7 +36,7 @@ Filename CVSSourceTree::_start_fullpath; */ CVSSourceTree:: CVSSourceTree() { - _root = (CVSSourceDirectory *)NULL; + _root = nullptr; _got_root_fullpath = false; } @@ -45,7 +45,7 @@ CVSSourceTree() { */ CVSSourceTree:: ~CVSSourceTree() { - if (_root != (CVSSourceDirectory *)NULL) { + if (_root != nullptr) { delete _root; } } @@ -67,9 +67,9 @@ set_root(const Filename &root_path) { */ bool CVSSourceTree:: scan(const Filename &key_filename) { - nassertr(_root == (CVSSourceDirectory *)NULL, false); + nassertr(_root == nullptr, false); Filename root_fullpath = get_root_fullpath(); - _root = new CVSSourceDirectory(this, NULL, root_fullpath.get_basename()); + _root = new CVSSourceDirectory(this, nullptr, root_fullpath.get_basename()); return _root->scan(_path, key_filename); } @@ -95,7 +95,7 @@ find_directory(const Filename &path) { if (root_fullpath.length() > fullpath.length() || cmp_nocase(fullpath.substr(0, root_fullpath.length()), root_fullpath) != 0) { // Nope! - return (CVSSourceDirectory *)NULL; + return nullptr; } // The relative name is the part of fullpath not in root_fullpath. @@ -112,7 +112,7 @@ find_directory(const Filename &path) { CVSSourceDirectory *CVSSourceTree:: find_relpath(const string &relpath) { CVSSourceDirectory *result = _root->find_relpath(relpath); - if (result != (CVSSourceDirectory *)NULL) { + if (result != nullptr) { return result; } @@ -129,7 +129,7 @@ find_relpath(const string &relpath) { return _root->find_relpath(rest); } - return (CVSSourceDirectory *)NULL; + return nullptr; } /** @@ -185,7 +185,7 @@ get_root_fullpath() { */ Filename CVSSourceTree:: get_root_dirname() const { - nassertr(_root != (CVSSourceDirectory *)NULL, Filename()); + nassertr(_root != nullptr, Filename()); return _root->get_dirname(); } @@ -407,14 +407,14 @@ ask_any(const string &basename, // relative path from the root (with or without the root's dirname), or // the dirname of the particular directory. CVSSourceDirectory *dir = find_directory(result); - if (dir == (CVSSourceDirectory *)NULL) { + if (dir == nullptr) { dir = find_relpath(result); } - if (dir == (CVSSourceDirectory *)NULL) { + if (dir == nullptr) { dir = find_dirname(result); } - if (dir != (CVSSourceDirectory *)NULL) { + if (dir != nullptr) { // If the file is already in this directory, we must preserve its // existing case. FilePaths::const_iterator pi; @@ -491,7 +491,7 @@ get_start_fullpath() { */ CVSSourceTree::FilePath:: FilePath() : - _dir(NULL) + _dir(nullptr) { } @@ -512,7 +512,7 @@ FilePath(CVSSourceDirectory *dir, const string &basename) : */ bool CVSSourceTree::FilePath:: is_valid() const { - return (_dir != (CVSSourceDirectory *)NULL); + return (_dir != nullptr); } /** @@ -520,7 +520,7 @@ is_valid() const { */ Filename CVSSourceTree::FilePath:: get_path() const { - nassertr(_dir != (CVSSourceDirectory *)NULL, Filename()); + nassertr(_dir != nullptr, Filename()); return Filename(_dir->get_path(), _basename); } @@ -529,7 +529,7 @@ get_path() const { */ Filename CVSSourceTree::FilePath:: get_fullpath() const { - nassertr(_dir != (CVSSourceDirectory *)NULL, Filename()); + nassertr(_dir != nullptr, Filename()); return Filename(_dir->get_fullpath(), _basename); } @@ -539,6 +539,6 @@ get_fullpath() const { */ Filename CVSSourceTree::FilePath:: get_rel_from(const CVSSourceDirectory *other) const { - nassertr(_dir != (CVSSourceDirectory *)NULL, Filename()); + nassertr(_dir != nullptr, Filename()); return Filename(other->get_rel_to(_dir), _basename); } diff --git a/pandatool/src/cvscopy/testCopy.cxx b/pandatool/src/cvscopy/testCopy.cxx index 4947bc8d5c..78010c58bb 100644 --- a/pandatool/src/cvscopy/testCopy.cxx +++ b/pandatool/src/cvscopy/testCopy.cxx @@ -39,7 +39,7 @@ run() { SourceFiles::iterator fi; for (fi = _source_files.begin(); fi != _source_files.end(); ++fi) { CVSSourceDirectory *dest = import(*fi, 0, _model_dir); - if (dest == (CVSSourceDirectory *)NULL) { + if (dest == nullptr) { exit(1); } } diff --git a/pandatool/src/daeegg/daeCharacter.cxx b/pandatool/src/daeegg/daeCharacter.cxx index 31d8db02cb..3b98fa80a7 100644 --- a/pandatool/src/daeegg/daeCharacter.cxx +++ b/pandatool/src/daeegg/daeCharacter.cxx @@ -42,14 +42,14 @@ DaeCharacter(EggGroup *node_group, const FCDControllerInstance *instance) : _node_group(node_group), _name(node_group->get_name()), _instance(instance), - _skin_controller(NULL), - _skin_mesh(NULL) { + _skin_controller(nullptr), + _skin_mesh(nullptr) { _bind_shape_mat = LMatrix4d::ident_mat(); // If it's a skin controller, add the controller joints. const FCDController *controller = (const FCDController *)instance->GetEntity(); - if (controller == NULL) { + if (controller == nullptr) { return; } _skin_mesh = controller->GetBaseGeometry()->GetMesh(); @@ -86,7 +86,7 @@ bind_joints(JointMap &joint_map) { if (ji != joint_map.end()) { Joint &joint = ji->second; - if (joint._character != (DaeCharacter *)NULL) { + if (joint._character != nullptr) { // In some cases, though, multiple controllers share the same joints. // We can't support this without duplicating the joint structure, so // we check if the bind poses are the same. @@ -108,7 +108,7 @@ bind_joints(JointMap &joint_map) { << "Unknown joint sid being referenced: '" << sid << "'\n"; // We still have to add a dummy joint or the index will be off. - _joints.push_back(Joint(NULL, NULL)); + _joints.push_back(Joint(nullptr, nullptr)); } } } @@ -179,7 +179,7 @@ influence_vertex(int index, EggVertex *vertex) { if (jwpair->jointIndex >= 0 && jwpair->jointIndex < (int)_joints.size()) { EggGroup *joint = _joints[jwpair->jointIndex]._group.p(); - if (joint != NULL) { + if (joint != nullptr) { joint->ref_vertex(vertex, jwpair->weight); } } else { @@ -218,7 +218,7 @@ r_collect_keys(FCDSceneNode* node, pset &keys) { FCDTransform *transform = node->GetTransform(t); FCDAnimated *animated = transform->GetAnimated(); - if (animated != NULL) { + if (animated != nullptr) { const FCDAnimationCurveListList &all_curves = animated->GetCurves(); for (size_t ci = 0; ci < all_curves.size(); ++ci) { @@ -243,7 +243,7 @@ r_collect_keys(FCDSceneNode* node, pset &keys) { */ void DaeCharacter:: build_table(EggTable *parent, FCDSceneNode* node, const pset &keys) { - nassertv(node != NULL); + nassertv(node != nullptr); if (!node->IsJoint()) { for (size_t ch = 0; ch < node->GetChildrenCount(); ++ch) { @@ -267,7 +267,7 @@ build_table(EggTable *parent, FCDSceneNode* node, const pset &keys) { for (size_t t = 0; t < node->GetTransformCount(); ++t) { FCDTransform *transform = node->GetTransform(t); FCDAnimated *animated = transform->GetAnimated(); - if (animated != (FCDAnimated *)NULL) { + if (animated != nullptr) { if (animated->HasCurve()) { animateds.push_back(animated); } diff --git a/pandatool/src/daeegg/daeCharacter.h b/pandatool/src/daeegg/daeCharacter.h index 78ff504e2e..76339368c9 100644 --- a/pandatool/src/daeegg/daeCharacter.h +++ b/pandatool/src/daeegg/daeCharacter.h @@ -40,7 +40,7 @@ public: INLINE Joint(EggGroup *group, const FCDSceneNode *scene_node) : _group(group), _scene_node(scene_node), - _character(NULL), + _character(nullptr), _bind_pose(LMatrix4d::ident_mat()) {} LMatrix4d _bind_pose; diff --git a/pandatool/src/daeegg/daeMaterials.cxx b/pandatool/src/daeegg/daeMaterials.cxx index e345c4b6bd..0c15fe819d 100644 --- a/pandatool/src/daeegg/daeMaterials.cxx +++ b/pandatool/src/daeegg/daeMaterials.cxx @@ -45,7 +45,7 @@ DaeMaterials(const FCDGeometryInstance* geometry_instance) { * Adds a material instance. Normally automatically done by constructor. */ void DaeMaterials::add_material_instance(const FCDMaterialInstance* instance) { - nassertv(instance != NULL); + nassertv(instance != nullptr); const string semantic (FROM_FSTRING(instance->GetSemantic())); if (_materials.count(semantic) > 0) { daeegg_cat.warning() << "Ignoring duplicate material with semantic " << semantic << endl; @@ -56,7 +56,7 @@ void DaeMaterials::add_material_instance(const FCDMaterialInstance* instance) { // Load in the uvsets for (size_t vib = 0; vib < instance->GetVertexInputBindingCount(); ++vib) { const FCDMaterialInstanceBindVertexInput* mivib = instance->GetVertexInputBinding(vib); - assert(mivib != NULL); + assert(mivib != nullptr); PT(DaeVertexInputBinding) bvi = new DaeVertexInputBinding(); bvi->_input_set = mivib->inputSet; #if FCOLLADA_VERSION >= 0x00030005 @@ -74,12 +74,12 @@ void DaeMaterials::add_material_instance(const FCDMaterialInstance* instance) { PT_EggMaterial egg_material = new EggMaterial(semantic); pvector egg_textures; const FCDEffect* effect = instance->GetMaterial()->GetEffect(); - if (effect == NULL) { + if (effect == nullptr) { daeegg_cat.debug() << "Ignoring material (semantic: " << semantic << ") without assigned effect" << endl; } else { // Grab the common profile effect const FCDEffectStandard* effect_common = (FCDEffectStandard *)effect->FindProfile(FUDaeProfileType::COMMON); - if (effect_common == NULL) { + if (effect_common == nullptr) { daeegg_cat.info() << "Ignoring effect referenced by material with semantic " << semantic << " because it has no common profile" << endl; } else { @@ -124,7 +124,7 @@ void DaeMaterials:: process_texture_bucket(const string semantic, const FCDEffectStandard* effect_common, FUDaeTextureChannel::Channel bucket, EggTexture::EnvType envtype, EggTexture::Format format) { for (size_t tx = 0; tx < effect_common->GetTextureCount(bucket); ++tx) { const FCDImage* image = effect_common->GetTexture(bucket, tx)->GetImage(); - if (image == NULL) { + if (image == nullptr) { daeegg_cat.warning() << "Texture references a nonexisting image!" << endl; } else { const FCDEffectParameterSampler* sampler = effect_common->GetTexture(bucket, tx)->GetSampler(); @@ -145,7 +145,7 @@ process_texture_bucket(const string semantic, const FCDEffectStandard* effect_co PT_EggTexture egg_texture = new EggTexture(FROM_FSTRING(image->GetDaeId()), texpath.to_os_generic()); // Find a set of UV coordinates const FCDEffectParameterInt* uvset = effect_common->GetTexture(bucket, tx)->GetSet(); - if (uvset != NULL) { + if (uvset != nullptr) { daeegg_cat.debug() << "Texture has uv name '" << FROM_FSTRING(uvset->GetSemantic()) << "'\n"; string uvset_semantic (FROM_FSTRING(uvset->GetSemantic())); @@ -158,7 +158,7 @@ process_texture_bucket(const string semantic, const FCDEffectStandard* effect_co } } // Apply sampler stuff - if (sampler != NULL) { + if (sampler != nullptr) { egg_texture->set_texture_type(convert_texture_type(sampler->GetSamplerType())); egg_texture->set_wrap_u(convert_wrap_mode(sampler->GetWrapS())); if (sampler->GetSamplerType() != FCDEffectParameterSampler::SAMPLER1D) { @@ -187,12 +187,12 @@ process_texture_bucket(const string semantic, const FCDEffectStandard* effect_co */ void DaeMaterials:: process_extra(const string semantic, const FCDExtra* extra) { - if (extra == NULL) return; + if (extra == nullptr) return; const FCDEType* etype = extra->GetDefaultType(); - if (etype == NULL) return; + if (etype == nullptr) return; for (size_t et = 0; et < etype->GetTechniqueCount(); ++et) { const FCDENode* enode = ((const FCDENode*)(etype->GetTechnique(et)))->FindChildNode("double_sided"); - if (enode != NULL) { + if (enode != nullptr) { string content = trim(enode->GetContent()); if (content == "1" || content == "true") { _materials[semantic]->_double_sided = true; diff --git a/pandatool/src/daeegg/daeToEggConverter.cxx b/pandatool/src/daeegg/daeToEggConverter.cxx index 0b3844549f..f054643d7b 100644 --- a/pandatool/src/daeegg/daeToEggConverter.cxx +++ b/pandatool/src/daeegg/daeToEggConverter.cxx @@ -55,9 +55,9 @@ DAEToEggConverter:: DAEToEggConverter() { _unit_name = "meter"; _unit_meters = 1.0; - _document = NULL; - _table = NULL; - _error_handler = NULL; + _document = nullptr; + _table = nullptr; + _error_handler = nullptr; _invert_transparency = false; } @@ -75,7 +75,7 @@ DAEToEggConverter(const DAEToEggConverter ©) : */ DAEToEggConverter:: ~DAEToEggConverter() { - if (_error_handler != NULL) { + if (_error_handler != nullptr) { delete _error_handler; } } @@ -114,7 +114,7 @@ convert_file(const Filename &filename) { // Reset stuff clear_error(); _joints.clear(); - if (_error_handler == NULL) { + if (_error_handler == nullptr) { _error_handler = new FUErrorSimpleHandler; } @@ -126,13 +126,13 @@ convert_file(const Filename &filename) { // Read the file FCollada::Initialize(); _document = FCollada::LoadDocument(filename.to_os_specific().c_str()); - if (_document == NULL) { + if (_document == nullptr) { daeegg_cat.error() << "Failed to load document: " << _error_handler->GetErrorString() << endl; FCollada::Release(); return false; } // Make sure the file uses consistent coordinate system and length - if (_document->GetAsset() != NULL) { + if (_document->GetAsset() != nullptr) { FCDocumentTools::StandardizeUpAxisAndLength(_document); } @@ -142,7 +142,7 @@ convert_file(const Filename &filename) { string model_name = _character_name; FCDSceneNode* visual_scene = _document->GetVisualSceneInstance(); - if (visual_scene != NULL) { + if (visual_scene != nullptr) { if (model_name.empty()) { // By lack of anything better... model_name = FROM_FSTRING(visual_scene->GetName()); @@ -170,7 +170,7 @@ convert_file(const Filename &filename) { const FCDGeometryMesh *mesh = character->_skin_mesh; - if (mesh != NULL) { + if (mesh != nullptr) { PT(DaeMaterials) materials = new DaeMaterials(character->_instance); daeegg_cat.spam() << "Processing mesh for controller\n"; process_mesh(character->_node_group, mesh, materials, character); @@ -183,7 +183,7 @@ convert_file(const Filename &filename) { character->adjust_joints(visual_scene->GetChild(ch), _joints, LMatrix4d::ident_mat()); } - if (scene_group != NULL) { + if (scene_group != nullptr) { // Mark the scene as character. if (get_animation_convert() == AC_chan) { _egg_data->remove_child(scene_group); @@ -342,7 +342,7 @@ get_input_units() { void DAEToEggConverter:: process_asset() { const FCDAsset *asset = _document->GetAsset(); - if (_document->GetAsset() == NULL) { + if (_document->GetAsset() == nullptr) { return; } @@ -368,7 +368,7 @@ process_asset() { // to be a skeleton root. void DAEToEggConverter:: process_node(EggGroupNode *parent, const FCDSceneNode* node, bool forced) { - nassertv(node != NULL); + nassertv(node != nullptr); string node_id = FROM_FSTRING(node->GetDaeId()); daeegg_cat.spam() << "Processing node with ID '" << node_id << "'" << endl; @@ -416,15 +416,15 @@ process_node(EggGroupNode *parent, const FCDSceneNode* node, bool forced) { void DAEToEggConverter:: process_instance(EggGroup *parent, const FCDEntityInstance* instance) { - nassertv(instance != NULL); - nassertv(instance->GetEntity() != NULL); + nassertv(instance != nullptr); + nassertv(instance->GetEntity() != nullptr); // Check what kind of instance this is switch (instance->GetType()) { case FCDEntityInstance::GEOMETRY: { if (get_animation_convert() != AC_chan) { const FCDGeometry* geometry = (const FCDGeometry*) instance->GetEntity(); - assert(geometry != NULL); + assert(geometry != nullptr); if (geometry->IsMesh()) { // Now, handle the mesh. process_mesh(parent, geometry->GetMesh(), new DaeMaterials((const FCDGeometryInstance*) instance)); @@ -466,7 +466,7 @@ void DAEToEggConverter:: process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, DaeMaterials *materials, DaeCharacter *character) { - nassertv(mesh != NULL); + nassertv(mesh != nullptr); daeegg_cat.debug() << "Processing mesh with id " << FROM_FSTRING(mesh->GetDaeId()) << endl; // Create the egg stuff to hold this mesh @@ -481,7 +481,7 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, return; } const FCDGeometrySource* vsource = mesh->FindSourceByType(FUDaeGeometryInput::POSITION); - if (vsource == NULL) { + if (vsource == nullptr) { daeegg_cat.debug() << "Mesh with id " << FROM_FSTRING(mesh->GetDaeId()) << " has no source for POSITION data" << endl; return; } @@ -501,7 +501,7 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, PT(EggGroup) primitiveholder; // If we have materials, make a group for each material. Then, apply the // material's per-group stuff. - if (materials != NULL && (!polygons->GetMaterialSemantic().empty()) && mesh->GetPolygonsCount() > 1) { + if (materials != nullptr && (!polygons->GetMaterialSemantic().empty()) && mesh->GetPolygonsCount() > 1) { // primitiveholder = new EggGroup(FROM_FSTRING(mesh->GetDaeId()) + "." + // material_semantic); primitiveholder = new EggGroup; @@ -511,41 +511,41 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, } primitive_holders[gr] = primitiveholder; // Apply the per-group data of the materials, if we have it. - if (materials != NULL) { + if (materials != nullptr) { materials->apply_to_group(material_semantic, primitiveholder, _invert_transparency); } // Find the position sources const FCDGeometryPolygonsInput* pinput = polygons->FindInput(FUDaeGeometryInput::POSITION); - assert(pinput != NULL); + assert(pinput != nullptr); const uint32* indices = pinput->GetIndices(); // Find the normal sources const FCDGeometrySource* nsource = mesh->FindSourceByType(FUDaeGeometryInput::NORMAL); const FCDGeometryPolygonsInput* ninput = polygons->FindInput(FUDaeGeometryInput::NORMAL); const uint32* nindices; - if (ninput != NULL) nindices = ninput->GetIndices(); + if (ninput != nullptr) nindices = ninput->GetIndices(); // Find texcoord sources const FCDGeometrySource* tcsource = mesh->FindSourceByType(FUDaeGeometryInput::TEXCOORD); const FCDGeometryPolygonsInput* tcinput = polygons->FindInput(FUDaeGeometryInput::TEXCOORD); const uint32* tcindices; - if (tcinput != NULL) tcindices = tcinput->GetIndices(); + if (tcinput != nullptr) tcindices = tcinput->GetIndices(); // Find vcolor sources const FCDGeometrySource* csource = mesh->FindSourceByType(FUDaeGeometryInput::COLOR); const FCDGeometryPolygonsInput* cinput = polygons->FindInput(FUDaeGeometryInput::COLOR); const uint32* cindices; - if (cinput != NULL) cindices = cinput->GetIndices(); + if (cinput != nullptr) cindices = cinput->GetIndices(); // Find binormal sources const FCDGeometrySource* bsource = mesh->FindSourceByType(FUDaeGeometryInput::TEXBINORMAL); const FCDGeometryPolygonsInput* binput = polygons->FindInput(FUDaeGeometryInput::TEXBINORMAL); const uint32* bindices; - if (binput != NULL) bindices = binput->GetIndices(); + if (binput != nullptr) bindices = binput->GetIndices(); // Find tangent sources const FCDGeometrySource* tsource = mesh->FindSourceByType(FUDaeGeometryInput::TEXTANGENT); const FCDGeometryPolygonsInput* tinput = polygons->FindInput(FUDaeGeometryInput::TEXTANGENT); const uint32* tindices; - if (tinput != NULL) tindices = tinput->GetIndices(); + if (tinput != nullptr) tindices = tinput->GetIndices(); // Get a name for potential coordinate sets string tcsetname; - if (materials != NULL && tcinput != NULL) { + if (materials != nullptr && tcinput != nullptr) { if (daeegg_cat.is_debug()) { daeegg_cat.debug() << "Assigning texcoord set " << tcinput->GetSet() @@ -555,7 +555,7 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, FUDaeGeometryInput::TEXCOORD, tcinput->GetSet()); } string tbsetname; - if (materials != NULL && binput != NULL) { + if (materials != nullptr && binput != nullptr) { if (daeegg_cat.is_debug()) { daeegg_cat.debug() << "Assigning texbinormal set " << binput->GetSet() @@ -565,7 +565,7 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, FUDaeGeometryInput::TEXBINORMAL, binput->GetSet()); } string ttsetname; - if (materials != NULL && tinput != NULL) { + if (materials != nullptr && tinput != nullptr) { if (daeegg_cat.is_debug()) { daeegg_cat.debug() << "Assigning textangent set " << tinput->GetSet() @@ -580,19 +580,19 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, const float* data = &vsource->GetData()[indices[ix]*3]; vertex->set_pos(LPoint3d(data[0], data[1], data[2])); - if (character != NULL) { + if (character != nullptr) { // If this is skinned geometry, add the vertex influences. character->influence_vertex(indices[ix], vertex); } // Process the normal - if (nsource != NULL && ninput != NULL) { + if (nsource != nullptr && ninput != nullptr) { assert(nsource->GetStride() == 3); data = &nsource->GetData()[nindices[ix]*3]; vertex->set_normal(LVecBase3d(data[0], data[1], data[2])); } // Process the texcoords - if (tcsource != NULL && tcinput != NULL) { + if (tcsource != nullptr && tcinput != nullptr) { assert(tcsource->GetStride() == 2 || tcsource->GetStride() == 3); data = &tcsource->GetData()[tcindices[ix]*tcsource->GetStride()]; if (tcsource->GetStride() == 2) { @@ -602,7 +602,7 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, } } // Process the color - if (csource != NULL && cinput != NULL) { + if (csource != nullptr && cinput != nullptr) { assert(csource->GetStride() == 3 || csource->GetStride() == 4); if (csource->GetStride() == 3) { data = &csource->GetData()[cindices[ix]*3]; @@ -613,21 +613,21 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, } } // Possibly add a UV object - if ((bsource != NULL && binput != NULL) || (tsource != NULL && tinput != NULL)) { - if (bsource != NULL && binput != NULL) { + if ((bsource != nullptr && binput != nullptr) || (tsource != nullptr && tinput != nullptr)) { + if (bsource != nullptr && binput != nullptr) { assert(bsource->GetStride() == 3); data = &bsource->GetData()[bindices[ix]*3]; PT(EggVertexUV) uv_obj = vertex->modify_uv_obj(tbsetname); - if (uv_obj == NULL) { + if (uv_obj == nullptr) { uv_obj = new EggVertexUV(tbsetname, LTexCoordd()); } uv_obj->set_binormal(LVecBase3d(data[0], data[1], data[2])); } - if (tsource != NULL && tinput != NULL) { + if (tsource != nullptr && tinput != nullptr) { assert(tsource->GetStride() == 3); data = &tsource->GetData()[tindices[ix]*3]; PT(EggVertexUV) uv_obj = vertex->modify_uv_obj(ttsetname); - if (uv_obj == NULL) { + if (uv_obj == nullptr) { uv_obj = new EggVertexUV(ttsetname, LTexCoordd()); } uv_obj->set_tangent(LVecBase3d(data[0], data[1], data[2])); @@ -642,7 +642,7 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, // Now loop through the faces uint32 offset = 0; for (size_t fa = 0; fa < polygons->GetFaceVertexCountCount(); ++fa) { - PT(EggPrimitive) primitive = NULL; + PT(EggPrimitive) primitive = nullptr; // Create a primitive that matches the fcollada type switch (polygons->GetPrimitiveType()) { case FCDGeometryPolygons::LINES: @@ -666,9 +666,9 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, default: daeegg_cat.warning() << "Unsupported primitive type found!" << endl; } - if (primitive != NULL) { + if (primitive != nullptr) { primitive_holders[gr]->add_child(primitive); - if (materials != NULL) { + if (materials != nullptr) { materials->apply_to_primitive(FROM_FSTRING(polygons->GetMaterialSemantic()), primitive); } for (size_t ve = 0; ve < polygons->GetFaceVertexCount(fa); ++ve) { @@ -684,7 +684,7 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, void DAEToEggConverter:: process_spline(EggGroup *parent, const string group_name, FCDGeometrySpline* geometry_spline) { - assert(geometry_spline != NULL); + assert(geometry_spline != nullptr); PT(EggGroup) result = new EggGroup(group_name); parent->add_child(result); // TODO: if its not a nurbs, make it convert between the types @@ -700,7 +700,7 @@ process_spline(EggGroup *parent, const string group_name, FCDGeometrySpline* geo void DAEToEggConverter:: process_spline(EggGroup *parent, const FCDSpline* spline) { - assert(spline != NULL); + assert(spline != nullptr); nassertv(spline->GetSplineType() == FUDaeSplineType::NURBS); // Now load in the nurbs curve to the egg library PT(EggNurbsCurve) nurbs_curve = new EggNurbsCurve(FROM_FSTRING(spline->GetName())); @@ -709,7 +709,7 @@ process_spline(EggGroup *parent, const FCDSpline* spline) { nurbs_curve->setup(0, ((const FCDNURBSSpline*) spline)->GetKnotCount()); for (size_t kn = 0; kn < ((const FCDNURBSSpline*) spline)->GetKnotCount(); ++kn) { const float* knot = ((const FCDNURBSSpline*) spline)->GetKnot(kn); - assert(knot != NULL); + assert(knot != nullptr); nurbs_curve->set_knot(kn, *knot); } for (size_t cv = 0; cv < spline->GetCVCount(); ++cv) { @@ -722,14 +722,14 @@ process_spline(EggGroup *parent, const FCDSpline* spline) { void DAEToEggConverter:: process_controller(EggGroup *parent, const FCDControllerInstance *instance) { - assert(instance != NULL); + assert(instance != nullptr); const FCDController* controller = (const FCDController *)instance->GetEntity(); - assert(controller != NULL); + assert(controller != nullptr); if (get_animation_convert() == AC_none) { // If we're exporting a static mesh, export the base geometry as-is. const FCDGeometryMesh *mesh = controller->GetBaseGeometry()->GetMesh(); - if (mesh != NULL) { + if (mesh != nullptr) { PT(DaeMaterials) materials = new DaeMaterials(instance); daeegg_cat.spam() << "Processing mesh for controller\n"; process_mesh(parent, mesh, materials); @@ -741,9 +741,9 @@ process_controller(EggGroup *parent, const FCDControllerInstance *instance) { } if (controller->IsMorph()) { - assert(controller != NULL); + assert(controller != nullptr); const FCDMorphController* morph_controller = controller->GetMorphController(); - assert(morph_controller != NULL); + assert(morph_controller != nullptr); PT(EggTable) bundle = new EggTable(parent->get_name()); bundle->set_table_type(EggTable::TT_bundle); PT(EggTable) morph = new EggTable("morph"); @@ -752,7 +752,7 @@ process_controller(EggGroup *parent, const FCDControllerInstance *instance) { // Loop through the morph targets. for (size_t mt = 0; mt < morph_controller->GetTargetCount(); ++mt) { const FCDMorphTarget* morph_target = morph_controller->GetTarget(mt); - assert(morph_target != NULL); + assert(morph_target != nullptr); PT(EggSAnimData) target = new EggSAnimData(FROM_FSTRING(morph_target->GetGeometry()->GetName())); if (morph_target->IsAnimated()) { // TODO @@ -766,18 +766,18 @@ process_controller(EggGroup *parent, const FCDControllerInstance *instance) { void DAEToEggConverter:: process_extra(EggGroup *group, const FCDExtra* extra) { - if (extra == NULL) { + if (extra == nullptr) { return; } - nassertv(group != NULL); + nassertv(group != nullptr); const FCDEType* etype = extra->GetDefaultType(); - if (etype == NULL) { + if (etype == nullptr) { return; } const FCDENode* enode = (const FCDENode*) etype->FindTechnique("PANDA3D"); - if (enode == NULL) { + if (enode == nullptr) { return; } @@ -802,8 +802,8 @@ convert_matrix(const FMMatrix44 &matrix) { void DAEToEggConverter:: apply_transform(EggGroup *to, const FCDTransform* from) { - assert(from != NULL); - assert(to != NULL); + assert(from != nullptr); + assert(to != nullptr); // to->set_transform3d(convert_matrix(from->ToMatrix()) * // to->get_transform3d()); switch (from->GetType()) { diff --git a/pandatool/src/daeegg/daeToEggConverter.h b/pandatool/src/daeegg/daeToEggConverter.h index b31d439526..2c1dc234c1 100644 --- a/pandatool/src/daeegg/daeToEggConverter.h +++ b/pandatool/src/daeegg/daeToEggConverter.h @@ -72,7 +72,7 @@ private: void process_node(EggGroupNode *parent, const FCDSceneNode* node, bool forced = false); void process_instance(EggGroup *parent, const FCDEntityInstance* instance); void process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, - DaeMaterials *materials, DaeCharacter *character = NULL); + DaeMaterials *materials, DaeCharacter *character = nullptr); void process_spline(EggGroup *parent, const string group_name, FCDGeometrySpline* geometry_spline); void process_spline(EggGroup *parent, const FCDSpline* spline); void process_controller(EggGroup *parent, const FCDControllerInstance* instance); diff --git a/pandatool/src/daeprogs/eggToDAE.cxx b/pandatool/src/daeprogs/eggToDAE.cxx index dff2286b88..cc3d9facf4 100644 --- a/pandatool/src/daeprogs/eggToDAE.cxx +++ b/pandatool/src/daeprogs/eggToDAE.cxx @@ -41,7 +41,7 @@ EggToDAE() : ("This program converts files from the egg format to the COLLADA " ".dae (Digital Asset Exchange) format."); - _document = NULL; + _document = nullptr; } /** @@ -50,7 +50,7 @@ EggToDAE() : void EggToDAE:: run() { nassertv(has_output_filename()); - nassertv(_data != NULL); + nassertv(_data != nullptr); FCollada::Initialize(); _document = FCollada::NewTopDocument(); @@ -58,8 +58,8 @@ run() { // Add the contributor part to the asset FCDAssetContributor* contributor = _document->GetAsset()->AddContributor(); const char* user_name = getenv("USER"); - if (user_name == NULL) user_name = getenv("USERNAME"); - if (user_name != NULL) contributor->SetAuthor(TO_FSTRING(user_name)); + if (user_name == nullptr) user_name = getenv("USERNAME"); + if (user_name != nullptr) contributor->SetAuthor(TO_FSTRING(user_name)); // contributor->SetSourceData(); char authoring_tool[1024]; snprintf(authoring_tool, 1024, "Panda3D %s eggToDAE converter | FCollada v%d.%02d", PANDA_VERSION_STR, FCOLLADA_VERSION >> 16, FCOLLADA_VERSION & 0xFFFF); @@ -93,7 +93,7 @@ run() { } void EggToDAE::process_node(FCDSceneNode* parent, const PT(EggGroup) node) { - assert(node != NULL); + assert(node != nullptr); FCDSceneNode* scene_node = parent->AddChildNode(); // Set the parameters scene_node->SetDaeId(node->get_name().c_str()); @@ -109,8 +109,8 @@ void EggToDAE::process_node(FCDSceneNode* parent, const PT(EggGroup) node) { } void EggToDAE::apply_transform(FCDSceneNode* to, const PT(EggGroup) from) { - assert(to != NULL); - assert(from != NULL); + assert(to != nullptr); + assert(from != nullptr); for (int co = 0; co < from->get_num_components(); ++co) { switch (from->get_component_type(co)) { case EggTransform::CT_translate2d: diff --git a/pandatool/src/dxf/dxfFile.cxx b/pandatool/src/dxf/dxfFile.cxx index 35772c625f..0637c97d39 100644 --- a/pandatool/src/dxf/dxfFile.cxx +++ b/pandatool/src/dxf/dxfFile.cxx @@ -280,9 +280,9 @@ DXFFile::Color DXFFile::_colors[DXF_num_colors] = { */ DXFFile:: DXFFile() { - _in = NULL; + _in = nullptr; _owns_in = false; - _layer = NULL; + _layer = nullptr; reset_entity(); _color_index = -1; } @@ -308,7 +308,7 @@ process(Filename filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *in = vfs->open_read_file(filename, true); - if (in == (istream *)NULL) { + if (in == nullptr) { return; } process(in, true); @@ -620,7 +620,7 @@ change_section(Section new_section) { */ void DXFFile:: change_layer(const string &layer_name) { - if (_layer == NULL || _layer->get_name() != layer_name) { + if (_layer == nullptr || _layer->get_name() != layer_name) { _layer = _layers.get_layer(layer_name, this); } } diff --git a/pandatool/src/dxfegg/dxfToEggConverter.cxx b/pandatool/src/dxfegg/dxfToEggConverter.cxx index 58f2c7a758..3620f96abd 100644 --- a/pandatool/src/dxfegg/dxfToEggConverter.cxx +++ b/pandatool/src/dxfegg/dxfToEggConverter.cxx @@ -112,11 +112,11 @@ done_entity() { if (_flags & PF_closed) { // it's closed; create a polygon. - nassertv(_layer!=NULL); + nassertv(_layer!=nullptr); ((DXFToEggLayer *)_layer)->add_polygon(this); } else { // It's open; create a series of line segments. - nassertv(_layer!=NULL); + nassertv(_layer!=nullptr); ((DXFToEggLayer *)_layer)->add_line(this); } @@ -130,7 +130,7 @@ done_entity() { _verts.push_back(DXFVertex(_q)); _verts.push_back(DXFVertex(_p)); - nassertv(_layer!=NULL); + nassertv(_layer!=nullptr); ((DXFToEggLayer *)_layer)->add_polygon(this); } } diff --git a/pandatool/src/egg-mkfont/eggMakeFont.cxx b/pandatool/src/egg-mkfont/eggMakeFont.cxx index 024f302199..8ae277126b 100644 --- a/pandatool/src/egg-mkfont/eggMakeFont.cxx +++ b/pandatool/src/egg-mkfont/eggMakeFont.cxx @@ -60,7 +60,7 @@ EggMakeFont() : EggWriter(true, false) { "Specifies the foreground color of the generated texture map. The " "default is white: 1,1,1,1, which leads to the most flexibility " "as the color can be modulated at runtime to any suitable color.", - &EggMakeFont::dispatch_color, NULL, &_fg[0]); + &EggMakeFont::dispatch_color, nullptr, &_fg[0]); add_option ("bg", "r,g,b[,a]", 0, @@ -72,7 +72,7 @@ EggMakeFont() : EggWriter(true, false) { "alpha component; if both colors specify an alpha component of 1 " "(or do not specify an alpha compenent), then the generated images " "will not include an alpha component.", - &EggMakeFont::dispatch_color, NULL, &_bg[0]); + &EggMakeFont::dispatch_color, nullptr, &_bg[0]); add_option ("interior", "r,g,b[,a]", 0, @@ -93,7 +93,7 @@ EggMakeFont() : EggWriter(true, false) { "within square brackets, e.g. '[A-Za-z0-9]'. If this is not specified, " "the default set has all ASCII characters and an assorted set of " "latin-1 characters, diacritics and punctuation marks.", - &EggMakeFont::dispatch_range, NULL, &_range); + &EggMakeFont::dispatch_range, nullptr, &_range); add_option ("extra", "file.egg", 0, @@ -103,7 +103,7 @@ EggMakeFont() : EggWriter(true, false) { "number of a character and should contain one polygon. These groups " "are simply copied into the output egg file as if they were generated " "locally. This option may be repeated.", - &EggMakeFont::dispatch_vector_string, NULL, &_extra_filenames); + &EggMakeFont::dispatch_vector_string, nullptr, &_extra_filenames); add_option ("ppu", "pixels", 0, @@ -112,27 +112,27 @@ EggMakeFont() : EggWriter(true, false) { "10 points of font; see -ps). Setting this number larger results in " "an easier-to-read font, but at the cost of more texture memory. " "The default is 40.", - &EggMakeFont::dispatch_double, NULL, &_pixels_per_unit); + &EggMakeFont::dispatch_double, nullptr, &_pixels_per_unit); add_option ("ps", "size", 0, "Specify the point size of the resulting font. This controls the " "apparent size of the font when it is rendered onscreen. By convention, " "a 10 point font is 1 screen unit high, so the default is 10.", - &EggMakeFont::dispatch_double, NULL, &_point_size); + &EggMakeFont::dispatch_double, nullptr, &_point_size); add_option ("sdf", "", 0, "If this is set, a signed distance field will be generated, which " "results in crisp text even when the text is enlarged or zoomed in.", - &EggMakeFont::dispatch_true, NULL, &_generate_distance_field); + &EggMakeFont::dispatch_true, nullptr, &_generate_distance_field); add_option ("pm", "n", 0, "The number of extra pixels around a single character in the " "generated polygon. This may be a floating-point number. The " "default is 1.", - &EggMakeFont::dispatch_double, NULL, &_poly_margin); + &EggMakeFont::dispatch_double, nullptr, &_poly_margin); add_option ("tm", "n", 0, @@ -140,7 +140,7 @@ EggMakeFont() : EggWriter(true, false) { "This may only be an integer. The default is 2. This is meaningful " "when -nopal is also used; in the normal case, use -pm to control " "both the polygon size and the texture map spacing.", - &EggMakeFont::dispatch_int, NULL, &_tex_margin); + &EggMakeFont::dispatch_int, nullptr, &_tex_margin); add_option ("rm", "n", 0, @@ -149,7 +149,7 @@ EggMakeFont() : EggWriter(true, false) { "generated texture map, only on the generated egg. Use this in order to " "space the characters out in case they appear to be too close together " "when rendered. The default is 0.", - &EggMakeFont::dispatch_double, NULL, &_render_margin); + &EggMakeFont::dispatch_double, nullptr, &_render_margin); add_option ("sf", "factor", 0, @@ -192,7 +192,7 @@ EggMakeFont() : EggWriter(true, false) { "If it is omitted, the default is based on the name of the egg file. " "This is used only if -nopal is specified; in the normal case, " "without -nopal, use -pp instead.", - &EggMakeFont::dispatch_string, NULL, &_output_glyph_pattern); + &EggMakeFont::dispatch_string, nullptr, &_output_glyph_pattern); add_option ("pp", "pattern", 0, @@ -200,20 +200,20 @@ EggMakeFont() : EggWriter(true, false) { "string is effectively passed to egg-palettize as the -tn option, and " "thus should contain %i for the palette index number. This is used " "if -nopal is not specified.", - &EggMakeFont::dispatch_string, NULL, &_output_palette_pattern); + &EggMakeFont::dispatch_string, nullptr, &_output_palette_pattern); add_option ("palsize", "xsize,ysize", 0, "Specify the size of the palette texture images. This is used if " "-nopal is not specified.", - &EggMakeFont::dispatch_int_pair, NULL, _palette_size); + &EggMakeFont::dispatch_int_pair, nullptr, _palette_size); add_option ("face", "index", 0, "Specify the face index of the particular face within the font file " "to use. Some font files contain multiple faces, indexed beginning " "at 0. The default is face 0.", - &EggMakeFont::dispatch_int, NULL, &_face_index); + &EggMakeFont::dispatch_int, nullptr, &_face_index); _fg.set(1.0, 1.0, 1.0, 1.0); _bg.set(1.0, 1.0, 1.0, 0.0); @@ -227,9 +227,9 @@ EggMakeFont() : EggWriter(true, false) { _face_index = 0; _generate_distance_field = false; - _text_maker = NULL; - _vpool = NULL; - _group = NULL; + _text_maker = nullptr; + _vpool = nullptr; + _group = nullptr; } @@ -538,7 +538,7 @@ make_vertex(const LPoint2d &xy) { void EggMakeFont:: add_character(int code) { PNMTextGlyph *glyph = _text_maker->get_glyph(code); - if (glyph == (PNMTextGlyph *)NULL) { + if (glyph == nullptr) { nout << "No definition in font for character " << code << ".\n"; return; } diff --git a/pandatool/src/egg-optchar/eggOptchar.cxx b/pandatool/src/egg-optchar/eggOptchar.cxx index bc1d3058b3..c7027ec9ec 100644 --- a/pandatool/src/egg-optchar/eggOptchar.cxx +++ b/pandatool/src/egg-optchar/eggOptchar.cxx @@ -74,19 +74,19 @@ EggOptchar() { ("keep", "joint[,joint...]", 0, "Keep the named joints (or sliders) in the character, even if they do " "not appear to be needed by the animation.", - &EggOptchar::dispatch_vector_string_comma, NULL, &_keep_components); + &EggOptchar::dispatch_vector_string_comma, nullptr, &_keep_components); add_option ("drop", "joint[,joint...]", 0, "Removes the named joints or sliders, even if they appear to be needed.", - &EggOptchar::dispatch_vector_string_comma, NULL, &_drop_components); + &EggOptchar::dispatch_vector_string_comma, nullptr, &_drop_components); add_option ("expose", "joint[,joint...]", 0, "Expose the named joints by flagging them with a DCS attribute, so " "each one can be found in the scene graph when the character is loaded, " "and objects can be parented to it. This implies -keep.", - &EggOptchar::dispatch_vector_string_comma, NULL, &_expose_components); + &EggOptchar::dispatch_vector_string_comma, nullptr, &_expose_components); add_option ("suppress", "joint[,joint...]", 0, @@ -95,7 +95,7 @@ EggOptchar() { "rigid geometry. The default is to create an implicit node for any " "joint that contains rigid geometry, to take advantage of display " "list and/or vertex buffer caching. This does not imply -keep.", - &EggOptchar::dispatch_vector_string_comma, NULL, &_suppress_components); + &EggOptchar::dispatch_vector_string_comma, nullptr, &_suppress_components); add_option ("flag", "node[,node...][=name]", 0, @@ -107,7 +107,7 @@ EggOptchar() { "joints; the revealed node can be hidden or its attributes changed " "at runtime, but it will be animated by its vertices, not the node, so " "objects parented to this node will not inherit its animation.", - &EggOptchar::dispatch_flag_groups, NULL, &_flag_groups); + &EggOptchar::dispatch_flag_groups, nullptr, &_flag_groups); add_option ("defpose", "anim.egg,frame", 0, @@ -117,7 +117,7 @@ EggOptchar() { "pose will be held by the model in " "the absence of any animation, and need not be the same " "pose in which the model was originally skinned.", - &EggOptchar::dispatch_string, NULL, &_defpose); + &EggOptchar::dispatch_string, nullptr, &_defpose); add_option ("preload", "", 0, @@ -132,7 +132,7 @@ EggOptchar() { "a subset of the component letters hprxyzijkabc is included, the " "operation is restricted to just those components; otherwise the " "entire transform is cleared.", - &EggOptchar::dispatch_name_components, NULL, &_zero_channels); + &EggOptchar::dispatch_name_components, nullptr, &_zero_channels); add_option ("keepall", "", 0, @@ -146,18 +146,18 @@ EggOptchar() { "\"-p joint,\" to reparent a joint to the root. The joint transform " "is recomputed appropriately under its new parent so that the animation " "is not affected (the effect is similar to NodePath::wrt_reparent_to).", - &EggOptchar::dispatch_vector_string_pair, NULL, &_reparent_joints); + &EggOptchar::dispatch_vector_string_pair, nullptr, &_reparent_joints); add_option ("new", "joint,source", 0, "Creates a new joint under the named parent joint. The new " "joint will inherit the same net transform as its parent.", - &EggOptchar::dispatch_vector_string_pair, NULL, &_new_joints); + &EggOptchar::dispatch_vector_string_pair, nullptr, &_new_joints); add_option ("rename", "joint,newjoint", 0, "Renames the indicated joint, if present, to the given name.", - &EggOptchar::dispatch_vector_string_pair, NULL, &_rename_joints); + &EggOptchar::dispatch_vector_string_pair, nullptr, &_rename_joints); if (FFTCompressor::is_compression_available()) { add_option @@ -182,7 +182,7 @@ EggOptchar() { "benefit for eliminating small differences in joint memberships " "between neighboring vertices. The default is 0.01; specifying " "0 means to preserve the original values.", - &EggOptchar::dispatch_double, NULL, &_vref_quantum); + &EggOptchar::dispatch_double, nullptr, &_vref_quantum); add_option ("qa", "quantum[,hprxyzijkabc]", 0, @@ -193,12 +193,12 @@ EggOptchar() { "animation. However, sometimes it is a useful tool for animation " "analysis and comparison. This option may be repeated several times " "to quantize different channels by a different amount.", - &EggOptchar::dispatch_double_components, NULL, &_quantize_anims); + &EggOptchar::dispatch_double_components, nullptr, &_quantize_anims); add_option ("dart", "[default, sync, nosync, or structured]", 0, "change the dart value in the given eggs", - &EggOptchar::dispatch_string, NULL, &_dart_type); + &EggOptchar::dispatch_string, nullptr, &_dart_type); _optimal_hierarchy = false; @@ -381,7 +381,7 @@ dispatch_name_components(const string &opt, const string &arg, void *var) { sp._b = matrix_component_letters; } else { for (string::const_iterator si = sp._b.begin(); si != sp._b.end(); ++si) { - if (strchr(matrix_component_letters, *si) == NULL) { + if (strchr(matrix_component_letters, *si) == nullptr) { nout << "Not a standard matrix component: \"" << *si << "\"\n" << "-" << opt << " requires a joint name followed by a set " << "of component names. The standard component names are \"" @@ -436,7 +436,7 @@ dispatch_double_components(const string &opt, const string &arg, void *var) { sp._b = matrix_component_letters; } else { for (string::const_iterator si = sp._b.begin(); si != sp._b.end(); ++si) { - if (strchr(matrix_component_letters, *si) == NULL) { + if (strchr(matrix_component_letters, *si) == nullptr) { nout << "Not a standard matrix component: \"" << *si << "\"\n" << "-" << opt << " requires a joint name followed by a set " << "of component names. The standard component names are \"" @@ -535,11 +535,11 @@ determine_removed_components() { nout << char_data->get_name() << " has " << num_components << " components.\n"; for (int i = 0; i < num_components; i++) { EggComponentData *comp_data = char_data->get_component(i); - nassertv(comp_data != (EggComponentData *)NULL); + nassertv(comp_data != nullptr); EggOptcharUserData *user_data = DCAST(EggOptcharUserData, comp_data->get_user_data()); - nassertv(user_data != (EggOptcharUserData *)NULL); + nassertv(user_data != nullptr); const string &name = comp_data->get_name(); if (suppress_names.find(name) != suppress_names.end()) { @@ -636,7 +636,7 @@ move_vertices() { joint_data->move_vertices_to(best_joint); // Now we can't remove the joint. - if (best_joint != (EggJointData *)NULL) { + if (best_joint != nullptr) { EggOptcharUserData *best_user_data = DCAST(EggOptcharUserData, best_joint->get_user_data()); best_user_data->_flags &= ~(EggOptcharUserData::F_empty | EggOptcharUserData::F_remove); @@ -673,7 +673,7 @@ process_joints() { if ((user_data->_flags & EggOptcharUserData::F_remove) != 0) { // This joint will be removed, so reparent it to nothing. - joint_data->reparent_to((EggJointData *)NULL); + joint_data->reparent_to(nullptr); // Determine what kind of node it is we're removing, for the user's // information. @@ -740,7 +740,7 @@ find_best_parent(EggJointData *joint_data) const { if ((user_data->_flags & EggOptcharUserData::F_remove) != 0) { // Keep going. - if (joint_data->get_parent() != (EggJointData *)NULL) { + if (joint_data->get_parent() != nullptr) { return find_best_parent(joint_data->get_parent()); } } @@ -755,8 +755,8 @@ find_best_parent(EggJointData *joint_data) const { */ EggJointData *EggOptchar:: find_best_vertex_joint(EggJointData *joint_data) const { - if (joint_data == (EggJointData *)NULL) { - return NULL; + if (joint_data == nullptr) { + return nullptr; } EggOptcharUserData *user_data = @@ -794,11 +794,11 @@ apply_user_reparents() { node_b = char_data->find_joint(p._b); } - if (node_b == (EggJointData *)NULL) { + if (node_b == nullptr) { nout << "No joint named " << p._b << " in " << char_data->get_name() << ".\n"; - } else if (node_a != (EggJointData *)NULL) { + } else if (node_a != nullptr) { nout << "Joint " << p._a << " already exists in " << char_data->get_name() << ".\n"; @@ -823,10 +823,10 @@ apply_user_reparents() { node_b = char_data->find_joint(p._b); } - if (node_b == (EggJointData *)NULL) { + if (node_b == nullptr) { nout << "No joint named " << p._b << " in " << char_data->get_name() << ".\n"; - } else if (node_a == (EggJointData *)NULL) { + } else if (node_a == nullptr) { nout << "No joint named " << p._a << " in " << char_data->get_name() << ".\n"; } else { @@ -869,7 +869,7 @@ zero_channels() { EggCharacterData *char_data = _collection->get_character(ci); EggJointData *joint_data = char_data->find_joint(p._a); - if (joint_data == (EggJointData *)NULL) { + if (joint_data == nullptr) { nout << "No joint named " << p._a << " in " << char_data->get_name() << ".\n"; } else { @@ -900,7 +900,7 @@ quantize_channels() { EggCharacterData *char_data = _collection->get_character(ci); EggJointData *joint_data = char_data->get_root_joint(); - if (joint_data != (EggJointData *)NULL) { + if (joint_data != nullptr) { joint_data->quantize_channels(p._b, p._a); did_anything = true; } @@ -1314,7 +1314,7 @@ rename_joints() { for (ci = 0; ci < num_characters; ++ci) { EggCharacterData *char_data = _collection->get_character(ci); EggJointData *joint = char_data->find_joint(sp._a); - if (joint != (EggJointData *)NULL) { + if (joint != nullptr) { nout << "Renaming joint " << sp._a << " to " << sp._b << "\n"; joint->set_name(sp._b); diff --git a/pandatool/src/egg-palettize/eggPalettize.cxx b/pandatool/src/egg-palettize/eggPalettize.cxx index d01087a9ac..e81290f06c 100644 --- a/pandatool/src/egg-palettize/eggPalettize.cxx +++ b/pandatool/src/egg-palettize/eggPalettize.cxx @@ -571,7 +571,7 @@ run() { // instead. Notify *notify = Notify::ptr(); NotifyCategory *loader_cat = notify->get_category(":loader"); - if (loader_cat != (NotifyCategory *)NULL && + if (loader_cat != nullptr && loader_cat->get_severity() == NS_info) { loader_cat->set_severity(NS_warning); } @@ -639,7 +639,7 @@ run() { } TypedWritable *obj = state_file.read_object(); - if (obj == (TypedWritable *)NULL || !state_file.resolve()) { + if (obj == nullptr || !state_file.resolve()) { nout << FilenameUnifier::make_user_filename(state_filename) << " exists, but appears to be corrupt. Perhaps you " << "should remove it so a new one can be created.\n"; diff --git a/pandatool/src/egg-palettize/txaFileFilter.cxx b/pandatool/src/egg-palettize/txaFileFilter.cxx index 5c673c51a1..980dc7d114 100644 --- a/pandatool/src/egg-palettize/txaFileFilter.cxx +++ b/pandatool/src/egg-palettize/txaFileFilter.cxx @@ -111,7 +111,7 @@ read_txa_file() { // We need to create a global Palettizer object to hold some of the global // properties that may be specified in a txa file. - if (pal == (Palettizer *)NULL) { + if (pal == nullptr) { pal = new Palettizer; } @@ -132,7 +132,7 @@ read_txa_file() { } else { filename.set_text(); istream *ifile = vfs->open_read_file(filename, true); - if (ifile == (istream *)NULL) { + if (ifile == nullptr) { txafile_cat.warning() << "Filename " << filename << " cannot be read.\n"; } else { diff --git a/pandatool/src/egg-qtess/eggQtess.cxx b/pandatool/src/egg-qtess/eggQtess.cxx index 21bc6317fb..fea4d09344 100644 --- a/pandatool/src/egg-qtess/eggQtess.cxx +++ b/pandatool/src/egg-qtess/eggQtess.cxx @@ -37,14 +37,14 @@ EggQtess() { ("f", "filename", 0, "Read the indicated parameter file. Type egg-qtess -H " "to print a description of the parameter file format.", - &EggQtess::dispatch_filename, NULL, &_qtess_filename); + &EggQtess::dispatch_filename, nullptr, &_qtess_filename); add_option ("up", "subdiv", 0, "Specify a uniform subdivision per patch (isoparam). Each NURBS " "surface is made up of N x M patches, each of which is divided " "into subdiv x subdiv quads. A fractional number is allowed.", - &EggQtess::dispatch_double, NULL, &_uniform_per_isoparam); + &EggQtess::dispatch_double, nullptr, &_uniform_per_isoparam); add_option ("us", "subdiv", 0, @@ -52,7 +52,7 @@ EggQtess() { "surface is subdivided into subdiv x subdiv quads, regardless " "of the number of isoparams it has. A fractional number is " "meaningless.", - &EggQtess::dispatch_int, NULL, &_uniform_per_surface); + &EggQtess::dispatch_int, nullptr, &_uniform_per_surface); add_option ("t", "tris", 0, @@ -60,7 +60,7 @@ EggQtess() { "is the total number of triangles for the entire egg file, " "including those surfaces that have already been given an " "explicit tessellation by a parameter file.", - &EggQtess::dispatch_int, NULL, &_total_tris); + &EggQtess::dispatch_int, nullptr, &_total_tris); add_option ("ap", "", 0, @@ -83,7 +83,7 @@ EggQtess() { "-ad. A value of 0 forces placement by curvature only; a very " "large value (like 1000) forces placement by size only. The " "default is 5.0.", - &EggQtess::dispatch_double, NULL, &QtessGlobals::_curvature_ratio); + &EggQtess::dispatch_double, nullptr, &QtessGlobals::_curvature_ratio); add_option ("e", "", 0, diff --git a/pandatool/src/egg-qtess/qtessInputEntry.I b/pandatool/src/egg-qtess/qtessInputEntry.I index 5c8adde257..1386256913 100644 --- a/pandatool/src/egg-qtess/qtessInputEntry.I +++ b/pandatool/src/egg-qtess/qtessInputEntry.I @@ -42,7 +42,7 @@ set_importance(double i) { INLINE void QtessInputEntry:: set_match_uu() { _type = T_match_uu; - _constrain_u = NULL; + _constrain_u = nullptr; } /** @@ -51,7 +51,7 @@ set_match_uu() { INLINE void QtessInputEntry:: set_match_vv() { _type = T_match_vv; - _constrain_v = NULL; + _constrain_v = nullptr; } /** @@ -60,7 +60,7 @@ set_match_vv() { INLINE void QtessInputEntry:: set_match_uv() { _type = T_match_uv; - _constrain_u = NULL; + _constrain_u = nullptr; } /** @@ -69,7 +69,7 @@ set_match_uv() { INLINE void QtessInputEntry:: set_match_vu() { _type = T_match_vu; - _constrain_v = NULL; + _constrain_v = nullptr; } /** @@ -120,7 +120,7 @@ set_num_tris(int nt) { */ INLINE void QtessInputEntry:: set_uv(int u, int v) { - set_uv(u, v, NULL, 0); + set_uv(u, v, nullptr, 0); } /** diff --git a/pandatool/src/egg-qtess/qtessInputEntry.cxx b/pandatool/src/egg-qtess/qtessInputEntry.cxx index e7547e359e..da7e940545 100644 --- a/pandatool/src/egg-qtess/qtessInputEntry.cxx +++ b/pandatool/src/egg-qtess/qtessInputEntry.cxx @@ -222,7 +222,7 @@ match(QtessSurface *surface) { // Similarly for type "matchUU". This indicates that all the surfaces // that match this one must all share the U-tesselation with whichever // surface first matched against the first node name. - if (nni == _node_names.begin() && _constrain_u==NULL) { + if (nni == _node_names.begin() && _constrain_u==nullptr) { // This is the lucky surface that dominates! _constrain_u = surface; } else { @@ -237,7 +237,7 @@ match(QtessSurface *surface) { case T_match_vv: case T_match_vu: // Ditto for "matchVV". - if (nni == _node_names.begin() && _constrain_v==NULL) { + if (nni == _node_names.begin() && _constrain_v==nullptr) { // This is the lucky surface that dominates! _constrain_v = surface; } else { diff --git a/pandatool/src/egg-qtess/qtessSurface.I b/pandatool/src/egg-qtess/qtessSurface.I index cc53d0f403..f603bf830f 100644 --- a/pandatool/src/egg-qtess/qtessSurface.I +++ b/pandatool/src/egg-qtess/qtessSurface.I @@ -24,7 +24,7 @@ get_name() const { */ INLINE bool QtessSurface:: is_valid() const { - return (_nurbs != (NurbsSurfaceEvaluator *)NULL); + return (_nurbs != nullptr); } /** diff --git a/pandatool/src/egg-qtess/qtessSurface.cxx b/pandatool/src/egg-qtess/qtessSurface.cxx index c0bfc175f9..896fd68079 100644 --- a/pandatool/src/egg-qtess/qtessSurface.cxx +++ b/pandatool/src/egg-qtess/qtessSurface.cxx @@ -38,7 +38,7 @@ QtessSurface(EggNurbsSurface *egg_surface) : _importance = 1.0; _importance2 = 1.0; - _match_u = _match_v = NULL; + _match_u = _match_v = nullptr; _tess_u = _tess_v = 0; _got_scores = false; @@ -53,7 +53,7 @@ QtessSurface(EggNurbsSurface *egg_surface) : _min_v = 3; } - if (_nurbs == (NurbsSurfaceEvaluator *)NULL) { + if (_nurbs == nullptr) { _num_u = _num_v = 0; } else { @@ -86,7 +86,7 @@ QtessSurface(EggNurbsSurface *egg_surface) : */ double QtessSurface:: get_score(double ratio) { - if (_nurbs == (NurbsSurfaceEvaluator *)NULL) { + if (_nurbs == nullptr) { return 0.0; } @@ -115,13 +115,13 @@ tesselate() { PT(EggGroup) group = do_uniform_tesselate(tris); PT(EggNode) new_node = group.p(); - if (new_node == (EggNode *)NULL) { + if (new_node == nullptr) { new_node = new EggComment(_egg_surface->get_name(), "Omitted NURBS surface."); tris = 0; } EggGroupNode *parent = _egg_surface->get_parent(); - nassertr(parent != (EggGroupNode *)NULL, 0); + nassertr(parent != nullptr, 0); parent->remove_child(_egg_surface); parent->add_child(new_node); @@ -301,9 +301,9 @@ record_vertex_extras() { */ void QtessSurface:: apply_match() { - if (_match_u != NULL) { + if (_match_u != nullptr) { QtessSurface *m = *_match_u; - if (m == NULL) { + if (m == nullptr) { qtess_cat.warning() << "No surface to match " << get_name() << " to in U.\n"; } else { @@ -322,9 +322,9 @@ apply_match() { } } - if (_match_v != NULL) { + if (_match_v != nullptr) { QtessSurface *m = *_match_v; - if (m == NULL) { + if (m == nullptr) { qtess_cat.warning() << "No surface to match " << get_name() << " in V.\n"; } else { @@ -358,7 +358,7 @@ do_uniform_tesselate(int &tris) const { qtess_cat.debug() << get_name() << " : omit\n"; } - return NULL; + return nullptr; } PT(EggGroup) group = new EggGroup(_egg_surface->get_name()); @@ -416,7 +416,7 @@ do_uniform_tesselate(int &tris) const { n_collection[egg_vertex->get_pos3()].insert(egg_vertex); } } - nassertr((int)new_verts.size() == num_verts, NULL); + nassertr((int)new_verts.size() == num_verts, nullptr); // Now create a bunch of quads. for (vi = 1; vi < num_v; vi++) { @@ -460,7 +460,7 @@ do_uniform_tesselate(int &tris) const { pri != egg_vertex->pref_end(); ++pri) { EggPrimitive *egg_primitive = (*pri); - nassertr(egg_primitive->has_normal(), NULL); + nassertr(egg_primitive->has_normal(), nullptr); normal += egg_primitive->get_normal(); num_polys++; } diff --git a/pandatool/src/eggbase/eggBase.cxx b/pandatool/src/eggbase/eggBase.cxx index 7fa0889610..1ebd65a28e 100644 --- a/pandatool/src/eggbase/eggBase.cxx +++ b/pandatool/src/eggbase/eggBase.cxx @@ -63,24 +63,24 @@ add_normals_options() { add_option ("no", "", 48, "Strip all normals.", - &EggBase::dispatch_normals, NULL, &strip); + &EggBase::dispatch_normals, nullptr, &strip); add_option ("np", "", 48, "Strip existing normals and redefine polygon normals.", - &EggBase::dispatch_normals, NULL, &polygon); + &EggBase::dispatch_normals, nullptr, &polygon); add_option ("nv", "threshold", 48, "Strip existing normals and redefine vertex normals. Consider an edge " "between adjacent polygons to be smooth if the angle between them " "is less than threshold degrees.", - &EggBase::dispatch_normals, NULL, &vertex); + &EggBase::dispatch_normals, nullptr, &vertex); add_option ("nn", "", 48, "Preserve normals exactly as they are. This is the default.", - &EggBase::dispatch_normals, NULL, &preserve); + &EggBase::dispatch_normals, nullptr, &preserve); add_option ("tbn", "name", 48, @@ -90,7 +90,7 @@ add_normals_options() { "above options. The tangent and binormal are used to implement " "bump mapping and related texture-based lighting effects. This option " "may be repeated as necessary to name multiple texture coordinate sets.", - &EggBase::dispatch_vector_string, NULL, &_tbn_names); + &EggBase::dispatch_vector_string, nullptr, &_tbn_names); add_option ("tbnall", "", 48, diff --git a/pandatool/src/eggbase/eggMultiBase.cxx b/pandatool/src/eggbase/eggMultiBase.cxx index cc591d4c18..426b62a956 100644 --- a/pandatool/src/eggbase/eggMultiBase.cxx +++ b/pandatool/src/eggbase/eggMultiBase.cxx @@ -148,13 +148,13 @@ read_egg(const Filename &filename) { if (!data->read(filename)) { // Failure reading. - return (EggData *)NULL; + return nullptr; } if (_noabs && data->original_had_absolute_pathnames()) { nout << filename.get_basename() << " includes absolute pathnames!\n"; - return (EggData *)NULL; + return nullptr; } DSearchPath file_path; @@ -168,7 +168,7 @@ read_egg(const Filename &filename) { if (_force_complete) { if (!data->load_externals()) { - return (EggData *)NULL; + return nullptr; } } diff --git a/pandatool/src/eggbase/eggMultiFilter.cxx b/pandatool/src/eggbase/eggMultiFilter.cxx index 1191d55dea..87900624f6 100644 --- a/pandatool/src/eggbase/eggMultiFilter.cxx +++ b/pandatool/src/eggbase/eggMultiFilter.cxx @@ -135,7 +135,7 @@ handle_args(ProgramBase::Args &args) { Args::const_iterator ai; for (ai = args.begin(); ai != args.end(); ++ai) { PT(EggData) data = read_egg(Filename::from_os_specific(*ai)); - if (data == (EggData *)NULL) { + if (data == nullptr) { // Rather than returning false, we simply exit here, so the ProgramBase // won't try to tell the user how to run the program just because we got // a bad egg file. diff --git a/pandatool/src/eggbase/eggReader.cxx b/pandatool/src/eggbase/eggReader.cxx index e570b8aa9d..428e07710a 100644 --- a/pandatool/src/eggbase/eggReader.cxx +++ b/pandatool/src/eggbase/eggReader.cxx @@ -50,7 +50,7 @@ EggReader() { "which should be self-contained and include only relative pathnames.", &EggReader::dispatch_none, &_noabs); - _tex_type = (PNMFileType *)NULL; + _tex_type = nullptr; _delod = -1.0; _got_tex_dirname = false; @@ -90,7 +90,7 @@ add_texture_options() { "the image format can be determined by the extension, but sometimes " "the extension is insufficient to unambiguously specify an image " "type.", - &EggReader::dispatch_image_type, NULL, &_tex_type); + &EggReader::dispatch_image_type, nullptr, &_tex_type); } /** @@ -111,7 +111,7 @@ add_delod_options(double default_delod) { "a camera at the indicated fixed distance from each LOD. " "Use -delod -1 to keep all the LOD's as they are, which is " "the default.\n", - &EggReader::dispatch_double, NULL, &_delod); + &EggReader::dispatch_double, nullptr, &_delod); } else { add_option @@ -120,7 +120,7 @@ add_delod_options(double default_delod) { "a camera at the indicated fixed distance from each LOD. " "Use -delod -1 to keep all the LOD's as they are. The default value " "is " + format_string(default_delod) + ".", - &EggReader::dispatch_double, NULL, &_delod); + &EggReader::dispatch_double, nullptr, &_delod); } } diff --git a/pandatool/src/eggbase/eggSingleBase.cxx b/pandatool/src/eggbase/eggSingleBase.cxx index b7fc71c45b..a3cda11736 100644 --- a/pandatool/src/eggbase/eggSingleBase.cxx +++ b/pandatool/src/eggbase/eggSingleBase.cxx @@ -40,7 +40,7 @@ EggSingleBase() : */ EggReader *EggSingleBase:: as_reader() { - return (EggReader *)NULL; + return nullptr; } /** @@ -54,7 +54,7 @@ as_reader() { */ EggWriter *EggSingleBase:: as_writer() { - return (EggWriter *)NULL; + return nullptr; } /** diff --git a/pandatool/src/eggbase/eggToSomething.cxx b/pandatool/src/eggbase/eggToSomething.cxx index 942a0d82db..3aa290ee32 100644 --- a/pandatool/src/eggbase/eggToSomething.cxx +++ b/pandatool/src/eggbase/eggToSomething.cxx @@ -93,13 +93,13 @@ add_units_options() { "specified, the vertices in the egg file will be scaled as " "necessary to make the appropriate units conversion; otherwise, " "the vertices will be left as they are.", - &EggToSomething::dispatch_units, NULL, &_input_units); + &EggToSomething::dispatch_units, nullptr, &_input_units); add_option ("uo", "units", 40, "Specify the units of the resulting " + _format_name + " file. Normally, the default units for the format are used.", - &EggToSomething::dispatch_units, NULL, &_output_units); + &EggToSomething::dispatch_units, nullptr, &_output_units); } /** diff --git a/pandatool/src/eggbase/somethingToEgg.cxx b/pandatool/src/eggbase/somethingToEgg.cxx index 4f33599761..6c8017d988 100644 --- a/pandatool/src/eggbase/somethingToEgg.cxx +++ b/pandatool/src/eggbase/somethingToEgg.cxx @@ -89,7 +89,7 @@ add_units_options() { ("ui", "units", 40, "Specify the units of the input " + _format_name + " file. Normally, this can be inferred from the file itself.", - &SomethingToEgg::dispatch_units, NULL, &_input_units); + &SomethingToEgg::dispatch_units, nullptr, &_input_units); add_option ("uo", "units", 40, @@ -97,7 +97,7 @@ add_units_options() { "specified, the vertices in the egg file will be scaled as " "necessary to make the appropriate units conversion; otherwise, " "the vertices will be left as they are.", - &SomethingToEgg::dispatch_units, NULL, &_output_units); + &SomethingToEgg::dispatch_units, nullptr, &_output_units); } /** @@ -111,14 +111,14 @@ add_animation_options() { "converted to egg, if at all. At present, the following keywords " "are supported: none, pose, flip, strobe, model, chan, or both. " "The default is none, which means not to convert animation.", - &SomethingToEgg::dispatch_animation_convert, NULL, &_animation_convert); + &SomethingToEgg::dispatch_animation_convert, nullptr, &_animation_convert); add_option ("cn", "name", 40, "Specifies the name of the animation character. This should match " "between all of the model files and all of the channel files for a " "particular model and its associated channels.", - &SomethingToEgg::dispatch_string, NULL, &_character_name); + &SomethingToEgg::dispatch_string, nullptr, &_character_name); add_option ("sf", "start-frame", 40, diff --git a/pandatool/src/eggcharbase/eggCharacterCollection.I b/pandatool/src/eggcharbase/eggCharacterCollection.I index 0e1c81f62a..fc1f26964d 100644 --- a/pandatool/src/eggcharbase/eggCharacterCollection.I +++ b/pandatool/src/eggcharbase/eggCharacterCollection.I @@ -25,7 +25,7 @@ get_num_eggs() const { */ INLINE EggData *EggCharacterCollection:: get_egg(int i) const { - nassertr(i >= 0 && i < (int)_eggs.size(), (EggData *)NULL); + nassertr(i >= 0 && i < (int)_eggs.size(), nullptr); return _eggs[i]._egg; } @@ -71,7 +71,7 @@ get_num_characters() const { */ INLINE EggCharacterData *EggCharacterCollection:: get_character(int i) const { - nassertr(i >= 0 && i < (int)_characters.size(), (EggCharacterData *)NULL); + nassertr(i >= 0 && i < (int)_characters.size(), nullptr); return _characters[i]; } @@ -81,7 +81,7 @@ get_character(int i) const { INLINE EggCharacterData *EggCharacterCollection:: get_character_by_model_index(int model_index) const { nassertr(model_index >= 0 && model_index < (int)_characters_by_model_index.size(), - (EggCharacterData *)NULL); + nullptr); return _characters_by_model_index[model_index]; } @@ -90,5 +90,5 @@ get_character_by_model_index(int model_index) const { */ INLINE EggCharacterCollection::ModelDescription:: ModelDescription() { - _root_node = (EggObject *)NULL; + _root_node = nullptr; } diff --git a/pandatool/src/eggcharbase/eggCharacterCollection.cxx b/pandatool/src/eggcharbase/eggCharacterCollection.cxx index 2a97862ea6..3dfa5aaee8 100644 --- a/pandatool/src/eggcharbase/eggCharacterCollection.cxx +++ b/pandatool/src/eggcharbase/eggCharacterCollection.cxx @@ -125,7 +125,7 @@ get_character_by_name(const string &character_name) const { } } - return (EggCharacterData *)NULL; + return nullptr; } @@ -617,7 +617,7 @@ rename_char(int i, const string &name) { EggCharacterData *char_data = _characters[i]; if (char_data->get_name() != name) { - nassertv(get_character_by_name(name) == (EggCharacterData *)NULL); + nassertv(get_character_by_name(name) == nullptr); char_data->rename_char(name); } } diff --git a/pandatool/src/eggcharbase/eggCharacterData.I b/pandatool/src/eggcharbase/eggCharacterData.I index 7b19b079b6..7ea131a3ec 100644 --- a/pandatool/src/eggcharbase/eggCharacterData.I +++ b/pandatool/src/eggcharbase/eggCharacterData.I @@ -47,7 +47,7 @@ get_model_index(int n) const { */ INLINE EggNode *EggCharacterData:: get_model_root(int n) const { - nassertr(n >= 0 && n < (int)_models.size(), (EggNode *)NULL); + nassertr(n >= 0 && n < (int)_models.size(), nullptr); return _models[n]._model_root; } @@ -57,7 +57,7 @@ get_model_root(int n) const { */ INLINE EggData *EggCharacterData:: get_egg_data(int n) const { - nassertr(n >= 0 && n < (int)_models.size(), (EggData *)NULL); + nassertr(n >= 0 && n < (int)_models.size(), nullptr); return _models[n]._egg_data; } @@ -108,7 +108,7 @@ get_num_joints() const { */ INLINE EggJointData *EggCharacterData:: get_joint(int n) const { - nassertr(n >= 0 && n < (int)_joints.size(), NULL); + nassertr(n >= 0 && n < (int)_joints.size(), nullptr); return _joints[n]; } @@ -125,7 +125,7 @@ get_num_sliders() const { */ INLINE EggSliderData *EggCharacterData:: get_slider(int n) const { - nassertr(n >= 0 && n < (int)_sliders.size(), NULL); + nassertr(n >= 0 && n < (int)_sliders.size(), nullptr); return _sliders[n]; } @@ -145,6 +145,6 @@ get_num_components() const { */ INLINE EggComponentData *EggCharacterData:: get_component(int n) const { - nassertr(n >= 0 && n < (int)_components.size(), NULL); + nassertr(n >= 0 && n < (int)_components.size(), nullptr); return _components[n]; } diff --git a/pandatool/src/eggcharbase/eggCharacterData.cxx b/pandatool/src/eggcharbase/eggCharacterData.cxx index 6c444e6c91..03cffa7d47 100644 --- a/pandatool/src/eggcharbase/eggCharacterData.cxx +++ b/pandatool/src/eggcharbase/eggCharacterData.cxx @@ -265,7 +265,7 @@ do_reparent() { EggJointData *joint_data = (*si); // Don't bother reporting joints that no longer have a parent, since we // don't care about joints that are now outside the hierarchy. - if (joint_data->get_parent() != (EggJointData *)NULL) { + if (joint_data->get_parent() != nullptr) { nout << "Warning: reparenting " << joint_data->get_name() << " to "; if (joint_data->get_parent() == _root_joint) { @@ -324,7 +324,7 @@ choose_optimal_hierarchy() { } } - if (best_parent != (EggJointData *)NULL && + if (best_parent != nullptr && best_parent != joint_data->_parent) { nout << "best parent for " << joint_data->get_name() << " is " << best_parent->get_name() << "\n"; @@ -345,7 +345,7 @@ find_slider(const string &name) const { return (*si).second; } - return NULL; + return nullptr; } /** diff --git a/pandatool/src/eggcharbase/eggCharacterFilter.cxx b/pandatool/src/eggcharbase/eggCharacterFilter.cxx index aba5834a66..9b23e7804d 100644 --- a/pandatool/src/eggcharbase/eggCharacterFilter.cxx +++ b/pandatool/src/eggcharbase/eggCharacterFilter.cxx @@ -21,7 +21,7 @@ */ EggCharacterFilter:: EggCharacterFilter() : EggMultiFilter(false) { - _collection = (EggCharacterCollection *)NULL; + _collection = nullptr; _force_initial_rest_frame = false; } @@ -31,7 +31,7 @@ EggCharacterFilter() : EggMultiFilter(false) { */ EggCharacterFilter:: ~EggCharacterFilter() { - if (_collection != (EggCharacterCollection *)NULL) { + if (_collection != nullptr) { delete _collection; } } @@ -57,7 +57,7 @@ add_fixrest_option() { */ bool EggCharacterFilter:: post_command_line() { - if (_collection == (EggCharacterCollection *)NULL) { + if (_collection == nullptr) { _collection = make_collection(); } diff --git a/pandatool/src/eggcharbase/eggComponentData.I b/pandatool/src/eggcharbase/eggComponentData.I index f706ab4b5a..e0064948de 100644 --- a/pandatool/src/eggcharbase/eggComponentData.I +++ b/pandatool/src/eggcharbase/eggComponentData.I @@ -29,7 +29,7 @@ get_num_models() const { INLINE bool EggComponentData:: has_model(int model_index) const { if (model_index >= 0 && model_index < (int)_back_pointers.size()) { - return _back_pointers[model_index] != (EggBackPointer *)NULL; + return _back_pointers[model_index] != nullptr; } return false; } @@ -43,5 +43,5 @@ get_model(int model_index) const { if (model_index >= 0 && model_index < (int)_back_pointers.size()) { return _back_pointers[model_index]; } - return (EggBackPointer *)NULL; + return nullptr; } diff --git a/pandatool/src/eggcharbase/eggComponentData.cxx b/pandatool/src/eggcharbase/eggComponentData.cxx index ceea3582a7..6a30bc4969 100644 --- a/pandatool/src/eggcharbase/eggComponentData.cxx +++ b/pandatool/src/eggcharbase/eggComponentData.cxx @@ -39,7 +39,7 @@ EggComponentData:: BackPointers::iterator bpi; for (bpi = _back_pointers.begin(); bpi != _back_pointers.end(); ++bpi) { EggBackPointer *back = (*bpi); - if (back != (EggBackPointer *)NULL) { + if (back != nullptr) { delete back; } } @@ -85,7 +85,7 @@ matches_name(const string &name) const { int EggComponentData:: get_num_frames(int model_index) const { EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { return 0; } return back->get_num_frames(); @@ -98,7 +98,7 @@ get_num_frames(int model_index) const { void EggComponentData:: extend_to(int model_index, int num_frames) const { EggBackPointer *back = get_model(model_index); - nassertv(back != (EggBackPointer *)NULL); + nassertv(back != nullptr); back->extend_to(num_frames); } @@ -109,7 +109,7 @@ extend_to(int model_index, int num_frames) const { double EggComponentData:: get_frame_rate(int model_index) const { EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { return 0.0; } return back->get_frame_rate(); @@ -121,10 +121,10 @@ get_frame_rate(int model_index) const { void EggComponentData:: set_model(int model_index, EggBackPointer *back) { while ((int)_back_pointers.size() <= model_index) { - _back_pointers.push_back((EggBackPointer *)NULL); + _back_pointers.push_back(nullptr); } - if (_back_pointers[model_index] != (EggBackPointer *)NULL) { + if (_back_pointers[model_index] != nullptr) { nout << "Warning: deleting old back pointer.\n"; delete _back_pointers[model_index]; } diff --git a/pandatool/src/eggcharbase/eggJointData.I b/pandatool/src/eggcharbase/eggJointData.I index c6349809ae..ad0b91aee5 100644 --- a/pandatool/src/eggcharbase/eggJointData.I +++ b/pandatool/src/eggcharbase/eggJointData.I @@ -32,7 +32,7 @@ get_num_children() const { */ INLINE EggJointData *EggJointData:: get_child(int n) const { - nassertr(n >= 0 && n < (int)_children.size(), (EggJointData *)NULL); + nassertr(n >= 0 && n < (int)_children.size(), nullptr); return _children[n]; } @@ -43,7 +43,7 @@ get_child(int n) const { INLINE EggJointData *EggJointData:: find_joint(const string &name) { EggJointData *joint = find_joint_exact(name); - if (joint == (EggJointData *)NULL) { + if (joint == nullptr) { joint = find_joint_matches(name); } return joint; diff --git a/pandatool/src/eggcharbase/eggJointData.cxx b/pandatool/src/eggcharbase/eggJointData.cxx index 8104ee1ad7..8197a1ec84 100644 --- a/pandatool/src/eggcharbase/eggJointData.cxx +++ b/pandatool/src/eggcharbase/eggJointData.cxx @@ -33,8 +33,8 @@ EggJointData(EggCharacterCollection *collection, EggCharacterData *char_data) : EggComponentData(collection, char_data) { - _parent = (EggJointData *)NULL; - _new_parent = (EggJointData *)NULL; + _parent = nullptr; + _new_parent = nullptr; _has_rest_frame = false; _rest_frames_differ = false; } @@ -46,7 +46,7 @@ EggJointData(EggCharacterCollection *collection, LMatrix4d EggJointData:: get_frame(int model_index, int n) const { EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { return LMatrix4d::ident_mat(); } @@ -63,7 +63,7 @@ get_frame(int model_index, int n) const { LMatrix4d EggJointData:: get_net_frame(int model_index, int n, EggCharacterDb &db) const { EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { return LMatrix4d::ident_mat(); } @@ -74,7 +74,7 @@ get_net_frame(int model_index, int n, EggCharacterDb &db) const { if (!db.get_matrix(joint, EggCharacterDb::TT_net_frame, n, mat)) { // Compute this frame's net, and stuff it in. mat = get_frame(model_index, n); - if (_parent != (EggJointData *)NULL) { + if (_parent != nullptr) { mat = mat * _parent->get_net_frame(model_index, n, db); } db.set_matrix(joint, EggCharacterDb::TT_net_frame, n, mat); @@ -89,7 +89,7 @@ get_net_frame(int model_index, int n, EggCharacterDb &db) const { LMatrix4d EggJointData:: get_net_frame_inv(int model_index, int n, EggCharacterDb &db) const { EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { return LMatrix4d::ident_mat(); } @@ -139,12 +139,12 @@ void EggJointData:: move_vertices_to(EggJointData *new_owner) { int num_models = get_num_models(); - if (new_owner == (EggJointData *)NULL) { + if (new_owner == nullptr) { for (int model_index = 0; model_index < num_models; model_index++) { if (has_model(model_index)) { EggJointPointer *joint; DCAST_INTO_V(joint, get_model(model_index)); - joint->move_vertices_to((EggJointPointer *)NULL); + joint->move_vertices_to(nullptr); } } } else { @@ -184,7 +184,7 @@ score_reparent_to(EggJointData *new_parent, EggCharacterDb &db) { int num_models = get_num_models(); for (int model_index = 0; model_index < num_models; model_index++) { EggBackPointer *back = get_model(model_index); - if (back != (EggBackPointer *)NULL) { + if (back != nullptr) { EggJointPointer *joint; DCAST_INTO_R(joint, back, false); @@ -195,11 +195,11 @@ score_reparent_to(EggJointData *new_parent, EggCharacterDb &db) { // We already have this parent. transform = LMatrix4d::ident_mat(); - } else if (_parent == (EggJointData *)NULL) { + } else if (_parent == nullptr) { // We are moving from outside the joint hierarchy to within it. transform = new_parent->get_net_frame_inv(model_index, n, db); - } else if (new_parent == (EggJointData *)NULL) { + } else if (new_parent == nullptr) { // We are moving from within the hierarchy to outside it. transform = _parent->get_net_frame(model_index, n, db); @@ -278,7 +278,7 @@ do_rebuild_all(EggCharacterDb &db) { BackPointers::iterator bpi; for (bpi = _back_pointers.begin(); bpi != _back_pointers.end(); ++bpi) { EggBackPointer *back = (*bpi); - if (back != (EggBackPointer *)NULL) { + if (back != nullptr) { EggJointPointer *joint; DCAST_INTO_R(joint, back, false); if (!joint->do_rebuild(db)) { @@ -307,7 +307,7 @@ optimize() { BackPointers::iterator bpi; for (bpi = _back_pointers.begin(); bpi != _back_pointers.end(); ++bpi) { EggBackPointer *back = (*bpi); - if (back != (EggBackPointer *)NULL) { + if (back != nullptr) { EggJointPointer *joint; DCAST_INTO_V(joint, back); joint->optimize(); @@ -330,7 +330,7 @@ expose(EggGroup::DCSType dcs_type) { BackPointers::iterator bpi; for (bpi = _back_pointers.begin(); bpi != _back_pointers.end(); ++bpi) { EggBackPointer *back = (*bpi); - if (back != (EggBackPointer *)NULL) { + if (back != nullptr) { EggJointPointer *joint; DCAST_INTO_V(joint, back); joint->expose(dcs_type); @@ -347,7 +347,7 @@ zero_channels(const string &components) { BackPointers::iterator bpi; for (bpi = _back_pointers.begin(); bpi != _back_pointers.end(); ++bpi) { EggBackPointer *back = (*bpi); - if (back != (EggBackPointer *)NULL) { + if (back != nullptr) { EggJointPointer *joint; DCAST_INTO_V(joint, back); joint->zero_channels(components); @@ -364,7 +364,7 @@ quantize_channels(const string &components, double quantum) { BackPointers::iterator bpi; for (bpi = _back_pointers.begin(); bpi != _back_pointers.end(); ++bpi) { EggBackPointer *back = (*bpi); - if (back != (EggBackPointer *)NULL) { + if (back != nullptr) { EggJointPointer *joint; DCAST_INTO_V(joint, back); joint->quantize_channels(components, quantum); @@ -391,7 +391,7 @@ apply_default_pose(int source_model, int frame) { BackPointers::iterator bpi; for (bpi = _back_pointers.begin(); bpi != _back_pointers.end(); ++bpi) { EggBackPointer *back = (*bpi); - if (back != (EggBackPointer *)NULL) { + if (back != nullptr) { EggJointPointer *joint; DCAST_INTO_V(joint, back); joint->apply_default_pose(source_joint, frame); @@ -411,7 +411,7 @@ apply_default_pose(int source_model, int frame) { */ void EggJointData:: add_back_pointer(int model_index, EggObject *egg_object) { - nassertv(egg_object != (EggObject *)NULL); + nassertv(egg_object != nullptr); if (egg_object->is_of_type(EggGroup::get_class_type())) { // It must be a . EggJointNodePointer *joint = new EggJointNodePointer(egg_object); @@ -488,7 +488,7 @@ calc_new_parent_depth(pset &chain) { if (_got_new_parent_depth) { return false; } - if (_new_parent == (EggJointData *)NULL) { + if (_new_parent == nullptr) { // Here's the top of the new hierarchy. _got_new_parent_depth = true; _new_parent_depth = 0; @@ -537,7 +537,7 @@ do_compute_reparent(int model_index, int n, EggCharacterDb &db) { } EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { // This joint doesn't have any data to modify. _computed_ok = true; return true; @@ -547,11 +547,11 @@ do_compute_reparent(int model_index, int n, EggCharacterDb &db) { DCAST_INTO_R(joint, back, false); LMatrix4d transform; - if (_parent == (EggJointData *)NULL) { + if (_parent == nullptr) { // We are moving from outside the joint hierarchy to within it. transform = _new_parent->get_new_net_frame_inv(model_index, n, db); - } else if (_new_parent == (EggJointData *)NULL) { + } else if (_new_parent == nullptr) { // We are moving from within the hierarchy to outside it. transform = _parent->get_net_frame(model_index, n, db); @@ -577,8 +577,8 @@ bool EggJointData:: do_joint_rebuild(int model_index, EggCharacterDb &db) { bool all_ok = true; - EggJointPointer *parent_joint = NULL; - if (_new_parent != NULL && _new_parent->has_model(model_index)) { + EggJointPointer *parent_joint = nullptr; + if (_new_parent != nullptr && _new_parent->has_model(model_index)) { DCAST_INTO_R(parent_joint, _new_parent->get_model(model_index), false); } @@ -601,8 +601,8 @@ void EggJointData:: do_finish_reparent() { int num_models = get_num_models(); for (int model_index = 0; model_index < num_models; model_index++) { - EggJointPointer *parent_joint = NULL; - if (_new_parent != NULL && _new_parent->has_model(model_index)) { + EggJointPointer *parent_joint = nullptr; + if (_new_parent != nullptr && _new_parent->has_model(model_index)) { DCAST_INTO_V(parent_joint, _new_parent->get_model(model_index)); } @@ -614,7 +614,7 @@ do_finish_reparent() { } _parent = _new_parent; - if (_parent != (EggJointData *)NULL) { + if (_parent != nullptr) { _parent->_children.push_back(this); } } @@ -636,7 +636,7 @@ make_new_joint(const string &name) { for (int i = 0; i < num_models; i++) { if (has_model(i)) { EggJointPointer *joint; - DCAST_INTO_R(joint, get_model(i), NULL); + DCAST_INTO_R(joint, get_model(i), nullptr); EggJointPointer *new_joint = joint->make_new_joint(name); child->set_model(i, new_joint); } @@ -658,12 +658,12 @@ find_joint_exact(const string &name) { return child; } EggJointData *result = child->find_joint_exact(name); - if (result != (EggJointData *)NULL) { + if (result != nullptr) { return result; } } - return (EggJointData *)NULL; + return nullptr; } /** @@ -679,12 +679,12 @@ find_joint_matches(const string &name) { return child; } EggJointData *result = child->find_joint_matches(name); - if (result != (EggJointData *)NULL) { + if (result != nullptr) { return result; } } - return (EggJointData *)NULL; + return nullptr; } /** @@ -698,7 +698,7 @@ is_new_ancestor(EggJointData *child) const { return true; } - if (child->_new_parent == (EggJointData *)NULL) { + if (child->_new_parent == nullptr) { return false; } @@ -714,7 +714,7 @@ const LMatrix4d &EggJointData:: get_new_net_frame(int model_index, int n, EggCharacterDb &db) { if (!_got_new_net_frame) { _new_net_frame = get_new_frame(model_index, n, db); - if (_new_parent != (EggJointData *)NULL) { + if (_new_parent != nullptr) { _new_net_frame = _new_net_frame * _new_parent->get_new_net_frame(model_index, n, db); } _got_new_net_frame = true; @@ -729,7 +729,7 @@ const LMatrix4d &EggJointData:: get_new_net_frame_inv(int model_index, int n, EggCharacterDb &db) { if (!_got_new_net_frame_inv) { _new_net_frame_inv.invert_from(get_new_frame(model_index, n, db)); - if (_new_parent != (EggJointData *)NULL) { + if (_new_parent != nullptr) { _new_net_frame_inv = _new_parent->get_new_net_frame_inv(model_index, n, db) * _new_net_frame_inv; } _got_new_net_frame_inv = true; @@ -747,7 +747,7 @@ get_new_frame(int model_index, int n, EggCharacterDb &db) { do_compute_reparent(model_index, n, db); EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { return LMatrix4d::ident_mat(); } diff --git a/pandatool/src/eggcharbase/eggJointNodePointer.cxx b/pandatool/src/eggcharbase/eggJointNodePointer.cxx index 3ebc85c3d4..4ab8a7227a 100644 --- a/pandatool/src/eggcharbase/eggJointNodePointer.cxx +++ b/pandatool/src/eggcharbase/eggJointNodePointer.cxx @@ -28,7 +28,7 @@ EggJointNodePointer:: EggJointNodePointer(EggObject *object) { _joint = DCAST(EggGroup, object); - if (_joint != (EggGroup *)NULL && _joint->is_joint()) { + if (_joint != nullptr && _joint->is_joint()) { // Quietly insist that the joint has a transform, for neatness. If it // does not, give it the identity transform. if (!_joint->has_transform()) { @@ -83,10 +83,10 @@ set_frame(int n, const LMatrix4d &mat) { */ void EggJointNodePointer:: do_finish_reparent(EggJointPointer *new_parent) { - if (new_parent == (EggJointPointer *)NULL) { + if (new_parent == nullptr) { // No new parent; unparent the joint. EggGroupNode *egg_parent = _joint->get_parent(); - if (egg_parent != (EggGroupNode *)NULL) { + if (egg_parent != nullptr) { egg_parent->remove_child(_joint.p()); egg_parent->steal_children(*_joint); } @@ -107,7 +107,7 @@ do_finish_reparent(EggJointPointer *new_parent) { */ void EggJointNodePointer:: move_vertices_to(EggJointPointer *new_joint) { - if (new_joint == (EggJointPointer *)NULL) { + if (new_joint == nullptr) { _joint->unref_all_vertices(); } else { @@ -150,7 +150,7 @@ do_rebuild(EggCharacterDb &db) { */ void EggJointNodePointer:: expose(EggGroup::DCSType dcs_type) { - if (_joint != (EggGroup *)NULL) { + if (_joint != nullptr) { _joint->set_dcs_type(dcs_type); } } @@ -161,7 +161,7 @@ expose(EggGroup::DCSType dcs_type) { */ void EggJointNodePointer:: apply_default_pose(EggJointPointer *source_joint, int frame) { - if (_joint != (EggGroup *)NULL) { + if (_joint != nullptr) { LMatrix4d pose; if (frame >= 0 && frame < source_joint->get_num_frames()) { pose = source_joint->get_frame(frame); @@ -180,7 +180,7 @@ apply_default_pose(EggJointPointer *source_joint, int frame) { */ bool EggJointNodePointer:: has_vertices() const { - if (_joint != (EggGroup *)NULL) { + if (_joint != nullptr) { return (_joint->vref_size() != 0) || _joint->joint_has_primitives(); } diff --git a/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx b/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx index c81ae1bd1a..130975fc0b 100644 --- a/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx +++ b/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx @@ -26,7 +26,7 @@ EggMatrixTablePointer:: EggMatrixTablePointer(EggObject *object) { _table = DCAST(EggTable, object); - if (_table != (EggTable *)NULL) { + if (_table != nullptr) { // Now search for the child named "xform". This contains the actual table // data. EggGroupNode::iterator ci; @@ -58,7 +58,7 @@ EggMatrixTablePointer(EggObject *object) { */ double EggMatrixTablePointer:: get_frame_rate() const { - if (_xform == (EggXfmSAnim *)NULL || !_xform->has_fps()) { + if (_xform == nullptr || !_xform->has_fps()) { return 0.0; } else { return _xform->get_fps(); @@ -70,7 +70,7 @@ get_frame_rate() const { */ int EggMatrixTablePointer:: get_num_frames() const { - if (_xform == (EggXfmSAnim *)NULL) { + if (_xform == nullptr) { return 0; } else { return _xform->get_num_rows(); @@ -82,7 +82,7 @@ get_num_frames() const { */ void EggMatrixTablePointer:: extend_to(int num_frames) { - nassertv(_xform != (EggXfmSAnim *)NULL); + nassertv(_xform != nullptr); _xform->normalize(); int num_rows = _xform->get_num_rows(); LMatrix4d last_mat; @@ -136,7 +136,7 @@ set_frame(int n, const LMatrix4d &mat) { */ bool EggMatrixTablePointer:: add_frame(const LMatrix4d &mat) { - if (_xform == (EggXfmSAnim *)NULL) { + if (_xform == nullptr) { return false; } @@ -149,10 +149,10 @@ add_frame(const LMatrix4d &mat) { */ void EggMatrixTablePointer:: do_finish_reparent(EggJointPointer *new_parent) { - if (new_parent == (EggJointPointer *)NULL) { + if (new_parent == nullptr) { // No new parent; unparent the joint. EggGroupNode *egg_parent = _table->get_parent(); - if (egg_parent != (EggGroupNode *)NULL) { + if (egg_parent != nullptr) { egg_parent->remove_child(_table.p()); } @@ -184,7 +184,7 @@ do_rebuild(EggCharacterDb &db) { return true; } - if (_xform == (EggXfmSAnim *)NULL) { + if (_xform == nullptr) { return false; } @@ -213,7 +213,7 @@ do_rebuild(EggCharacterDb &db) { */ void EggMatrixTablePointer:: optimize() { - if (_xform != (EggXfmSAnim *)NULL) { + if (_xform != nullptr) { _xform->optimize(); } } @@ -223,7 +223,7 @@ optimize() { */ void EggMatrixTablePointer:: zero_channels(const string &components) { - if (_xform == (EggXfmSAnim *)NULL) { + if (_xform == nullptr) { return; } @@ -233,7 +233,7 @@ zero_channels(const string &components) { for (si = components.begin(); si != components.end(); ++si) { string table_name(1, *si); EggNode *child = _xform->find_child(table_name); - if (child != (EggNode *)NULL) { + if (child != nullptr) { _xform->remove_child(child); } } @@ -245,7 +245,7 @@ zero_channels(const string &components) { */ void EggMatrixTablePointer:: quantize_channels(const string &components, double quantum) { - if (_xform == (EggXfmSAnim *)NULL) { + if (_xform == nullptr) { return; } @@ -255,7 +255,7 @@ quantize_channels(const string &components, double quantum) { for (si = components.begin(); si != components.end(); ++si) { string table_name(1, *si); EggNode *child = _xform->find_child(table_name); - if (child != (EggNode *)NULL && + if (child != nullptr && child->is_of_type(EggSAnimData::get_class_type())) { EggSAnimData *anim = DCAST(EggSAnimData, child); anim->quantize(quantum); @@ -272,7 +272,7 @@ make_new_joint(const string &name) { EggTable *new_table = new EggTable(name); _table->add_child(new_table); CoordinateSystem cs = CS_default; - if (_xform != (EggXfmSAnim *)NULL) { + if (_xform != nullptr) { cs = _xform->get_coordinate_system(); } EggXfmSAnim *new_xform = new EggXfmSAnim("xform", cs); diff --git a/pandatool/src/eggcharbase/eggScalarTablePointer.cxx b/pandatool/src/eggcharbase/eggScalarTablePointer.cxx index da104af2bd..18f4aaaf5c 100644 --- a/pandatool/src/eggcharbase/eggScalarTablePointer.cxx +++ b/pandatool/src/eggcharbase/eggScalarTablePointer.cxx @@ -31,7 +31,7 @@ EggScalarTablePointer(EggObject *object) { */ double EggScalarTablePointer:: get_frame_rate() const { - if (_data == (EggSAnimData *)NULL || !_data->has_fps()) { + if (_data == nullptr || !_data->has_fps()) { return 0.0; } else { return _data->get_fps(); @@ -43,7 +43,7 @@ get_frame_rate() const { */ int EggScalarTablePointer:: get_num_frames() const { - if (_data == (EggSAnimData *)NULL) { + if (_data == nullptr) { return 0; } else { return _data->get_num_rows(); @@ -55,7 +55,7 @@ get_num_frames() const { */ void EggScalarTablePointer:: extend_to(int num_frames) { - nassertv(_data != (EggSAnimData *)NULL); + nassertv(_data != nullptr); int num_rows = _data->get_num_rows(); double last_value; if (num_rows == 0) { diff --git a/pandatool/src/eggcharbase/eggSliderData.cxx b/pandatool/src/eggcharbase/eggSliderData.cxx index d597adcc17..25bbae1140 100644 --- a/pandatool/src/eggcharbase/eggSliderData.cxx +++ b/pandatool/src/eggcharbase/eggSliderData.cxx @@ -40,7 +40,7 @@ EggSliderData(EggCharacterCollection *collection, double EggSliderData:: get_frame(int model_index, int n) const { EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { return 0.0; } @@ -58,7 +58,7 @@ add_back_pointer(int model_index, EggObject *egg_object) { if (egg_object->is_of_type(EggPrimitive::get_class_type())) { // A primitive! EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { back = new EggVertexPointer(egg_object); set_model(model_index, back); } @@ -66,7 +66,7 @@ add_back_pointer(int model_index, EggObject *egg_object) { } else if (egg_object->is_of_type(EggVertex::get_class_type())) { // A vertex! EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { back = new EggVertexPointer(egg_object); set_model(model_index, back); } @@ -74,7 +74,7 @@ add_back_pointer(int model_index, EggObject *egg_object) { } else if (egg_object->is_of_type(EggSAnimData::get_class_type())) { // A slider animation table! Woo hoo! EggBackPointer *back = get_model(model_index); - if (back == (EggBackPointer *)NULL) { + if (back == nullptr) { back = new EggScalarTablePointer(egg_object); set_model(model_index, back); } diff --git a/pandatool/src/eggprogs/eggMakeTube.cxx b/pandatool/src/eggprogs/eggMakeTube.cxx index 37adfd8d59..7017e97dcd 100644 --- a/pandatool/src/eggprogs/eggMakeTube.cxx +++ b/pandatool/src/eggprogs/eggMakeTube.cxx @@ -36,7 +36,7 @@ EggMakeTube() { add_option ("a", "x,y,z", 0, "Specify the first endpoint of the tube.", - &EggWriter::dispatch_double_triple, NULL, _point_a); + &EggWriter::dispatch_double_triple, nullptr, _point_a); add_option ("b", "x,y,z", 0, @@ -47,23 +47,23 @@ EggMakeTube() { ("r", "radius", 0, "Specify the radius of the tube. The tube will extend beyond " "the endpoints in each direction by the amount of radius.", - &EggWriter::dispatch_double, NULL, &_radius); + &EggWriter::dispatch_double, nullptr, &_radius); add_option ("slices", "count", 0, "Specify the number of slices appearing radially around the tube.", - &EggWriter::dispatch_int, NULL, &_num_slices); + &EggWriter::dispatch_int, nullptr, &_num_slices); add_option ("crings", "count", 0, "Specify the number of rings appearing in each endcap of the tube.", - &EggWriter::dispatch_int, NULL, &_num_crings); + &EggWriter::dispatch_int, nullptr, &_num_crings); add_option ("trings", "count", 0, "Specify the number of rings appearing in the cylindrical body " "of the tube.", - &EggWriter::dispatch_int, NULL, &_num_trings); + &EggWriter::dispatch_int, nullptr, &_num_trings); _point_a[0] = 0.0; _point_a[1] = 0.0; @@ -111,8 +111,8 @@ run() { EggVertex *vtx_2; for (ri = 0; ri < _num_crings; ri++) { - vtx_1 = NULL; - vtx_2 = NULL; + vtx_1 = nullptr; + vtx_2 = nullptr; for (si = 0; si <= _num_slices; si++) { EggVertex *vtx_3 = calc_sphere1_vertex(ri, si); EggVertex *vtx_4 = calc_sphere1_vertex(ri + 1, si); @@ -125,8 +125,8 @@ run() { // Now the cylinder sides. if (_length != 0.0) { for (ri = 0; ri < _num_trings; ri++) { - vtx_1 = NULL; - vtx_2 = NULL; + vtx_1 = nullptr; + vtx_2 = nullptr; for (si = 0; si <= _num_slices; si++) { EggVertex *vtx_3 = calc_tube_vertex(ri, si); EggVertex *vtx_4 = calc_tube_vertex(ri + 1, si); @@ -139,8 +139,8 @@ run() { // And the second endcap. for (ri = _num_crings - 1; ri >= 0; ri--) { - vtx_1 = NULL; - vtx_2 = NULL; + vtx_1 = nullptr; + vtx_2 = nullptr; for (si = 0; si <= _num_slices; si++) { EggVertex *vtx_3 = calc_sphere2_vertex(ri + 1, si); EggVertex *vtx_4 = calc_sphere2_vertex(ri, si); @@ -244,7 +244,7 @@ calc_sphere2_vertex(int ri, int si) { */ void EggMakeTube:: add_polygon(EggVertex *a, EggVertex *b, EggVertex *c, EggVertex *d) { - if (a == (EggVertex *)NULL) { + if (a == nullptr) { return; } diff --git a/pandatool/src/eggprogs/eggRename.cxx b/pandatool/src/eggprogs/eggRename.cxx index abde299e2d..532f096dbb 100644 --- a/pandatool/src/eggprogs/eggRename.cxx +++ b/pandatool/src/eggprogs/eggRename.cxx @@ -26,7 +26,7 @@ EggRename() { add_option ("strip_prefix", "name", 0, "strips out the prefix that is put on all nodes, by maya ext. ref", - &EggRename::dispatch_vector_string, NULL, &_strip_prefix); + &EggRename::dispatch_vector_string, nullptr, &_strip_prefix); } /** diff --git a/pandatool/src/eggprogs/eggRetargetAnim.cxx b/pandatool/src/eggprogs/eggRetargetAnim.cxx index f354eb57b9..0c522652e1 100644 --- a/pandatool/src/eggprogs/eggRetargetAnim.cxx +++ b/pandatool/src/eggprogs/eggRetargetAnim.cxx @@ -48,13 +48,13 @@ EggRetargetAnim() { ("r", "file.egg", 0, "Read the reference model from the indicated egg file. All of the " "animations will be retargeted to match the indicated file.", - &EggRetargetAnim::dispatch_filename, NULL, &_reference_filename); + &EggRetargetAnim::dispatch_filename, nullptr, &_reference_filename); add_option ("keep", "joint[,joint...]", 0, "Preserve the full animation on the named joint(s). This is especially " "appropriate for the root joint.", - &EggRetargetAnim::dispatch_vector_string_comma, NULL, &_keep_joints); + &EggRetargetAnim::dispatch_vector_string_comma, nullptr, &_keep_joints); } /** @@ -62,7 +62,7 @@ EggRetargetAnim() { */ void EggRetargetAnim:: run() { - nassertv(_collection != (EggCharacterCollection *)NULL); + nassertv(_collection != nullptr); nassertv(_collection->get_num_eggs() > 0); if (_reference_filename.empty()) { @@ -78,7 +78,7 @@ run() { // Read in the extra egg file that we use for extracting the references out. PT(EggData) reference_egg = read_egg(_reference_filename); - if (reference_egg == (EggData *)NULL) { + if (reference_egg == nullptr) { nout << "Cannot read " << _reference_filename << "\n"; exit(1); } @@ -146,7 +146,7 @@ retarget_anim(EggCharacterData *char_data, EggJointData *joint_data, int num_frames = char_data->get_num_frames(i); EggBackPointer *back = joint_data->get_model(i); - nassertv(back != (EggBackPointer *)NULL); + nassertv(back != nullptr); EggJointPointer *joint; DCAST_INTO_V(joint, back); diff --git a/pandatool/src/eggprogs/eggTextureCards.cxx b/pandatool/src/eggprogs/eggTextureCards.cxx index 03cb811809..bf7032230f 100644 --- a/pandatool/src/eggprogs/eggTextureCards.cxx +++ b/pandatool/src/eggprogs/eggTextureCards.cxx @@ -49,7 +49,7 @@ EggTextureCards() : EggWriter(true, true) { "centered on the origin: -0.5,0.5,-0.5,0.5. Polygons are always created " "on the X-Y plane. If -p is not also specified, all polygons will be " "the same size and shape.", - &EggTextureCards::dispatch_double_quad, NULL, &_polygon_geometry[0]); + &EggTextureCards::dispatch_double_quad, nullptr, &_polygon_geometry[0]); add_option ("p", "xpixels,ypixels", 0, @@ -70,44 +70,44 @@ EggTextureCards() : EggWriter(true, true) { "This option specifies an ignorable suffix in the texture filename(s); " "if this suffix is present, it is not included in the polygon's name. " "This option may be repeated multiple times.", - &EggTextureCards::dispatch_vector_string, NULL, &_suffixes); + &EggTextureCards::dispatch_vector_string, nullptr, &_suffixes); add_option ("c", "r,g,b[,a]", 0, "Specifies the color of each polygon. The default is white: 1,1,1,1.", - &EggTextureCards::dispatch_color, NULL, &_polygon_color[0]); + &EggTextureCards::dispatch_color, nullptr, &_polygon_color[0]); add_option ("wm", "wrap", 0, "Indicates the wrap mode of the texture: \"repeat\", \"clamp\", " "or any of the other modes supported by egg syntax. " "The default is to leave this unspecified.", - &EggTextureCards::dispatch_wrap_mode, NULL, &_wrap_mode); + &EggTextureCards::dispatch_wrap_mode, nullptr, &_wrap_mode); add_option ("wmu", "wrap_u", 0, "Indicates the wrap mode of the texture in the U direction. This " "overrides -wm, if specified.", - &EggTextureCards::dispatch_wrap_mode, NULL, &_wrap_u); + &EggTextureCards::dispatch_wrap_mode, nullptr, &_wrap_u); add_option ("wmv", "wrap_v", 0, "Indicates the wrap mode of the texture in the V direction. This " "overrides -wm, if specified.", - &EggTextureCards::dispatch_wrap_mode, NULL, &_wrap_v); + &EggTextureCards::dispatch_wrap_mode, nullptr, &_wrap_v); add_option ("minf", "filter", 0, "Indicates the minfilter mode of the texture: \"linear\", \"mipmap\", " "or any of the other modes supported by egg syntax. " "The default is to leave this unspecified.", - &EggTextureCards::dispatch_filter_type, NULL, &_minfilter); + &EggTextureCards::dispatch_filter_type, nullptr, &_minfilter); add_option ("magf", "filter", 0, "Indicates the magfilter mode of the texture: \"linear\" or \"nearest\". " "The default is to leave this unspecified.", - &EggTextureCards::dispatch_filter_type, NULL, &_magfilter); + &EggTextureCards::dispatch_filter_type, nullptr, &_magfilter); add_option ("aniso", "degree", 0, @@ -119,37 +119,37 @@ EggTextureCards() : EggWriter(true, true) { ("ql", "[default | fastest | normal | best]", 0, "Specifies the quality level of the texture. This mainly affects " "the tinydisplay software renderer.", - &EggTextureCards::dispatch_quality_level, NULL, &_quality_level); + &EggTextureCards::dispatch_quality_level, nullptr, &_quality_level); add_option ("f", "format", 0, "Indicates the format for all textures: typical choices are \"rgba12\" " "or \"rgb5\" or \"alpha\". The default is to leave this unspecified.", - &EggTextureCards::dispatch_format, NULL, &_format); + &EggTextureCards::dispatch_format, nullptr, &_format); add_option ("f1", "format", 0, "Indicates the format for one-channel textures only. If specified, this " "overrides the format specified by -f.", - &EggTextureCards::dispatch_format, NULL, &_format_1); + &EggTextureCards::dispatch_format, nullptr, &_format_1); add_option ("f2", "format", 0, "Indicates the format for two-channel textures only. If specified, this " "overrides the format specified by -f.", - &EggTextureCards::dispatch_format, NULL, &_format_2); + &EggTextureCards::dispatch_format, nullptr, &_format_2); add_option ("f3", "format", 0, "Indicates the format for three-channel textures only. If specified, this " "overrides the format specified by -f.", - &EggTextureCards::dispatch_format, NULL, &_format_3); + &EggTextureCards::dispatch_format, nullptr, &_format_3); add_option ("f4", "format", 0, "Indicates the format for four-channel textures only. If specified, this " "overrides the format specified by -f.", - &EggTextureCards::dispatch_format, NULL, &_format_4); + &EggTextureCards::dispatch_format, nullptr, &_format_4); add_option ("b", "", 0, @@ -164,7 +164,7 @@ EggTextureCards() : EggWriter(true, true) { "nice side-effect of creating an automatic texture flip that can be " "used directly by applications; use this parameter to specify the " "frame rate of that texture flip.", - &EggTextureCards::dispatch_double, NULL, &_frame_rate); + &EggTextureCards::dispatch_double, nullptr, &_frame_rate); add_option ("noexist", "", 0, diff --git a/pandatool/src/eggprogs/eggToC.cxx b/pandatool/src/eggprogs/eggToC.cxx index 28fcb2f36e..a1f0a4d081 100644 --- a/pandatool/src/eggprogs/eggToC.cxx +++ b/pandatool/src/eggprogs/eggToC.cxx @@ -158,7 +158,7 @@ write_vertex_pool(EggVertexPool *vpool) { << "] = {\n"; for (i = 0; i < highest_index; i++) { EggVertex *vert = vpool->get_vertex(i); - if (vert == (EggVertex *)NULL) { + if (vert == nullptr) { out << " vertex(), /* " << i << " */\n"; } else { LPoint4d p = vert->get_pos4(); @@ -196,7 +196,7 @@ write_vertex_pool(EggVertexPool *vpool) { << "] = {\n"; for (i = 0; i < highest_index; i++) { EggVertex *vert = vpool->get_vertex(i); - if (vert == (EggVertex *)NULL || !vert->has_uv()) { + if (vert == nullptr || !vert->has_uv()) { out << " uv(), /* " << i << " */\n"; } else { LTexCoordd uv = vert->get_uv(); @@ -213,7 +213,7 @@ write_vertex_pool(EggVertexPool *vpool) { << "] = {\n"; for (i = 0; i < highest_index; i++) { EggVertex *vert = vpool->get_vertex(i); - if (vert == (EggVertex *)NULL || !vert->has_normal()) { + if (vert == nullptr || !vert->has_normal()) { out << " normal(), /* " << i << " */\n"; } else { LNormald n = vert->get_normal(); @@ -230,7 +230,7 @@ write_vertex_pool(EggVertexPool *vpool) { << "] = {\n"; for (i = 0; i < highest_index; i++) { EggVertex *vert = vpool->get_vertex(i); - if (vert == (EggVertex *)NULL || !vert->has_color()) { + if (vert == nullptr || !vert->has_color()) { out << " color(), /* " << i << " */\n"; } else { LColor c = vert->get_color(); diff --git a/pandatool/src/eggprogs/eggTopstrip.cxx b/pandatool/src/eggprogs/eggTopstrip.cxx index e0bbcf4e7e..4b0397e065 100644 --- a/pandatool/src/eggprogs/eggTopstrip.cxx +++ b/pandatool/src/eggprogs/eggTopstrip.cxx @@ -44,7 +44,7 @@ EggTopstrip() { ("t", "name", 0, "Specify the name of the 'top' joint, from which to draw the " "animation channels which will be applied to the entire animation.", - &EggTopstrip::dispatch_string, NULL, &_top_joint_name); + &EggTopstrip::dispatch_string, nullptr, &_top_joint_name); add_option ("i", "", 0, @@ -64,13 +64,13 @@ EggTopstrip() { "any combination of the nine token letters: i, j, k represent the " "three scale axes; h, p, r represent rotation; and x, y, z represent " "translation. The default is everything: -s ijkphrxyz.", - &EggTopstrip::dispatch_string, NULL, &_transform_channels); + &EggTopstrip::dispatch_string, nullptr, &_transform_channels); add_option ("r", "file.egg", 0, "Read the animation channel from the indicated egg file. If this " "is not specified, each egg file will supply its own animation channel.", - &EggTopstrip::dispatch_filename, NULL, &_channel_filename); + &EggTopstrip::dispatch_filename, nullptr, &_channel_filename); _invert_transform = true; _transform_channels = "ijkphrxyz"; @@ -81,7 +81,7 @@ EggTopstrip() { */ void EggTopstrip:: run() { - nassertv(_collection != (EggCharacterCollection *)NULL); + nassertv(_collection != nullptr); nassertv(_collection->get_num_eggs() > 0); check_transform_channels(); @@ -97,7 +97,7 @@ run() { if (!_channel_filename.empty()) { // Read in the extra egg file that we use for extracting the channels out. PT(EggData) channel_egg = read_egg(_channel_filename); - if (channel_egg == (EggData *)NULL) { + if (channel_egg == nullptr) { nout << "Cannot read " << _channel_filename << "\n"; exit(1); } @@ -134,7 +134,7 @@ run() { } // Determine which joint we'll use to extract the transform to apply. - EggJointData *top_joint = (EggJointData *)NULL; + EggJointData *top_joint = nullptr; if (_top_joint_name.empty()) { // The default top joint name is the alphabetically first joint in the // top level. @@ -145,7 +145,7 @@ run() { top_joint = root_joint->get_child(0); } else { top_joint = from_char->find_joint(_top_joint_name); - if (top_joint == (EggJointData *)NULL) { + if (top_joint == nullptr) { nout << "Character " << from_char->get_name() << " has no joint named " << _top_joint_name << "\n"; exit(1); @@ -238,7 +238,7 @@ strip_anim(EggCharacterData *char_data, EggJointData *joint_data, int num_frames = max(num_into_frames, num_from_frames); EggBackPointer *back = joint_data->get_model(i); - nassertv(back != (EggBackPointer *)NULL); + nassertv(back != nullptr); EggJointPointer *joint; DCAST_INTO_V(joint, back); diff --git a/pandatool/src/flt/fltBead.cxx b/pandatool/src/flt/fltBead.cxx index bfa5b3f656..8cc21f8c4f 100644 --- a/pandatool/src/flt/fltBead.cxx +++ b/pandatool/src/flt/fltBead.cxx @@ -100,7 +100,7 @@ get_num_transform_steps() const { FltTransformRecord *FltBead:: get_transform_step(int n) { nassertr(n >= 0 && n < (int)_transform_steps.size(), - (FltTransformRecord *)NULL); + nullptr); return _transform_steps[n]; } @@ -111,7 +111,7 @@ get_transform_step(int n) { const FltTransformRecord *FltBead:: get_transform_step(int n) const { nassertr(n >= 0 && n < (int)_transform_steps.size(), - (const FltTransformRecord *)NULL); + nullptr); return _transform_steps[n]; } @@ -172,7 +172,7 @@ extract_record(FltRecordReader &reader) { */ bool FltBead:: extract_ancillary(FltRecordReader &reader) { - FltTransformRecord *step = (FltTransformRecord *)NULL; + FltTransformRecord *step = nullptr; switch (reader.get_opcode()) { case FO_transform_matrix: @@ -214,7 +214,7 @@ extract_ancillary(FltRecordReader &reader) { } // A transform step. - nassertr(step != (FltTransformRecord *)NULL, false); + nassertr(step != nullptr, false); if (!step->extract_record(reader)) { return false; } diff --git a/pandatool/src/flt/fltGeometry.I b/pandatool/src/flt/fltGeometry.I index 3c4fae7918..c584c52003 100644 --- a/pandatool/src/flt/fltGeometry.I +++ b/pandatool/src/flt/fltGeometry.I @@ -34,7 +34,7 @@ get_texture() const { */ INLINE void FltGeometry:: set_texture(FltTexture *texture) { - if (texture == (FltTexture *)NULL) { + if (texture == nullptr) { _texture_index = -1; } else { _header->add_texture(texture); @@ -65,7 +65,7 @@ get_material() const { */ INLINE void FltGeometry:: set_material(FltMaterial *material) { - if (material == (FltMaterial *)NULL) { + if (material == nullptr) { _material_index = -1; } else { _header->add_material(material); diff --git a/pandatool/src/flt/fltHeader.cxx b/pandatool/src/flt/fltHeader.cxx index 3b689fb0fe..e6cd4dbd10 100644 --- a/pandatool/src/flt/fltHeader.cxx +++ b/pandatool/src/flt/fltHeader.cxx @@ -37,7 +37,7 @@ TypeHandle FltHeader::_type_handle; */ FltHeader:: FltHeader(PathReplace *path_replace) : FltBeadID(this) { - if (path_replace == (PathReplace *)NULL) { + if (path_replace == nullptr) { _path_replace = new PathReplace; _path_replace->_path_store = PS_absolute; } else { @@ -191,7 +191,7 @@ read_flt(Filename filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *in = vfs->open_read_file(filename, true); - if (in == (istream *)NULL) { + if (in == nullptr) { assert(!flt_error_abort); return FE_could_not_open; } @@ -425,7 +425,7 @@ get_instance(int instance_index) const { if (mi != _instances.end()) { return (*mi).second; } - return (FltInstanceDefinition *)NULL; + return nullptr; } /** @@ -467,7 +467,7 @@ get_num_vertices() const { */ FltVertex *FltHeader:: get_vertex(int n) const { - nassertr(n >= 0 && n < (int)_vertices.size(), 0); + nassertr(n >= 0 && n < (int)_vertices.size(), nullptr); return _vertices[n]; } @@ -512,7 +512,7 @@ get_vertex_by_offset(int offset) { vi = _vertices_by_offset.find(offset); if (vi == _vertices_by_offset.end()) { nout << "No vertex with offset " << offset << "\n"; - return (FltVertex *)NULL; + return nullptr; } return (*vi).second; } @@ -810,7 +810,7 @@ get_material(int material_index) const { if (mi != _materials.end()) { return (*mi).second; } - return (FltMaterial *)NULL; + return nullptr; } /** @@ -869,7 +869,7 @@ get_texture(int texture_index) const { if (mi != _textures.end()) { return (*mi).second; } - return (FltTexture *)NULL; + return nullptr; } /** @@ -928,7 +928,7 @@ get_light_source(int light_index) const { if (li != _light_sources.end()) { return (*li).second; } - return (FltLightSourceDefinition *)NULL; + return nullptr; } /** @@ -993,7 +993,7 @@ get_num_eyepoints() const { */ FltEyepoint *FltHeader:: get_eyepoint(int n) { - nassertr(n >= 0 && n < get_num_eyepoints(), (FltEyepoint *)NULL); + nassertr(n >= 0 && n < get_num_eyepoints(), nullptr); return &_eyepoints[n]; } @@ -1011,7 +1011,7 @@ get_num_trackplanes() const { */ FltTrackplane *FltHeader:: get_trackplane(int n) { - nassertr(n >= 0 && n < get_num_trackplanes(), (FltTrackplane *)NULL); + nassertr(n >= 0 && n < get_num_trackplanes(), nullptr); return &_trackplanes[n]; } diff --git a/pandatool/src/flt/fltInstanceRef.cxx b/pandatool/src/flt/fltInstanceRef.cxx index 7f0ffd2e67..8622f6180b 100644 --- a/pandatool/src/flt/fltInstanceRef.cxx +++ b/pandatool/src/flt/fltInstanceRef.cxx @@ -45,7 +45,7 @@ void FltInstanceRef:: write(ostream &out, int indent_level) const { indent(out, indent_level) << "instance"; FltInstanceDefinition *def = _header->get_instance(_instance_index); - if (def != (FltInstanceDefinition *)NULL) { + if (def != nullptr) { def->write_children(out, indent_level + 2); indent(out, indent_level) << "}\n"; } else { diff --git a/pandatool/src/flt/fltMesh.cxx b/pandatool/src/flt/fltMesh.cxx index 47506e732a..e77b8636d6 100644 --- a/pandatool/src/flt/fltMesh.cxx +++ b/pandatool/src/flt/fltMesh.cxx @@ -95,7 +95,7 @@ build_record(FltRecordWriter &writer) const { */ FltError FltMesh:: write_ancillary(FltRecordWriter &writer) const { - if (_vpool != (FltLocalVertexPool *)NULL) { + if (_vpool != nullptr) { if (!_vpool->build_record(writer)) { assert(!flt_error_abort); return FE_bad_data; diff --git a/pandatool/src/flt/fltRecord.cxx b/pandatool/src/flt/fltRecord.cxx index 53844f0636..5325259ec6 100644 --- a/pandatool/src/flt/fltRecord.cxx +++ b/pandatool/src/flt/fltRecord.cxx @@ -69,7 +69,7 @@ get_num_children() const { */ FltRecord *FltRecord:: get_child(int n) const { - nassertr(n >= 0 && n < (int)_children.size(), (FltRecord *)NULL); + nassertr(n >= 0 && n < (int)_children.size(), nullptr); return _children[n]; } @@ -104,7 +104,7 @@ get_num_subfaces() const { */ FltRecord *FltRecord:: get_subface(int n) const { - nassertr(n >= 0 && n < (int)_subfaces.size(), (FltRecord *)NULL); + nassertr(n >= 0 && n < (int)_subfaces.size(), nullptr); return _subfaces[n]; } @@ -139,7 +139,7 @@ get_num_extensions() const { */ FltRecord *FltRecord:: get_extension(int n) const { - nassertr(n >= 0 && n < (int)_extensions.size(), (FltRecord *)NULL); + nassertr(n >= 0 && n < (int)_extensions.size(), nullptr); return _extensions[n]; } @@ -178,7 +178,7 @@ get_num_ancillary() const { */ FltRecord *FltRecord:: get_ancillary(int n) const { - nassertr(n >= 0 && n < (int)_ancillary.size(), (FltRecord *)NULL); + nassertr(n >= 0 && n < (int)_ancillary.size(), nullptr); return _ancillary[n]; } diff --git a/pandatool/src/flt/fltRecordReader.cxx b/pandatool/src/flt/fltRecordReader.cxx index b90e911964..f2650fa423 100644 --- a/pandatool/src/flt/fltRecordReader.cxx +++ b/pandatool/src/flt/fltRecordReader.cxx @@ -27,7 +27,7 @@ FltRecordReader(istream &in) : { _opcode = FO_none; _record_length = 0; - _iterator = (DatagramIterator *)NULL; + _iterator = nullptr; _state = S_begin; _next_error = FE_ok; _next_opcode = FO_none; @@ -42,9 +42,9 @@ FltRecordReader(istream &in) : */ FltRecordReader:: ~FltRecordReader() { - if (_iterator != (DatagramIterator *)NULL) { + if (_iterator != nullptr) { delete _iterator; - _iterator = (DatagramIterator *)NULL; + _iterator = nullptr; } } @@ -101,9 +101,9 @@ advance(bool ok_eof) { assert(!flt_error_abort); return FE_read_error; } - if (_iterator != (DatagramIterator *)NULL) { + if (_iterator != nullptr) { delete _iterator; - _iterator = (DatagramIterator *)NULL; + _iterator = nullptr; } if (_next_error == FE_end_of_file) { diff --git a/pandatool/src/flt/fltRecordWriter.cxx b/pandatool/src/flt/fltRecordWriter.cxx index 55ca9fc0d4..df3d904d27 100644 --- a/pandatool/src/flt/fltRecordWriter.cxx +++ b/pandatool/src/flt/fltRecordWriter.cxx @@ -142,7 +142,7 @@ write_instance_def(FltHeader *header, int instance_index) { } FltInstanceDefinition *instance = header->get_instance(instance_index); - if (instance == (FltInstanceDefinition *)NULL) { + if (instance == nullptr) { assert(!flt_error_abort); return FE_undefined_instance; } diff --git a/pandatool/src/flt/fltVertexList.cxx b/pandatool/src/flt/fltVertexList.cxx index 9659a56063..941d35c300 100644 --- a/pandatool/src/flt/fltVertexList.cxx +++ b/pandatool/src/flt/fltVertexList.cxx @@ -38,7 +38,7 @@ get_num_vertices() const { */ FltVertex *FltVertexList:: get_vertex(int n) const { - nassertr(n >= 0 && n < (int)_vertices.size(), 0); + nassertr(n >= 0 && n < (int)_vertices.size(), nullptr); return _vertices[n]; } diff --git a/pandatool/src/fltegg/fltToEggConverter.cxx b/pandatool/src/fltegg/fltToEggConverter.cxx index 0f2b78e268..bd4898b0c5 100644 --- a/pandatool/src/fltegg/fltToEggConverter.cxx +++ b/pandatool/src/fltegg/fltToEggConverter.cxx @@ -353,16 +353,16 @@ convert_face(const FltFace *flt_face, FltToEggLevelState &state) { // Collect the vertices for this primitive. pvector< PT_EggVertex > vertices; - const FltVertexList *vlist = (FltVertexList *)NULL; + const FltVertexList *vlist = nullptr; int num_children = flt_face->get_num_children(); - for (int i = 0; i < num_children && vlist == (FltVertexList *)NULL; i++) { + for (int i = 0; i < num_children && vlist == nullptr; i++) { const FltRecord *child = flt_face->get_child(i); if (child->is_of_type(FltVertexList::get_class_type())) { vlist = DCAST(FltVertexList, child); } } - if (vlist != (FltVertexList *)NULL) { + if (vlist != nullptr) { int num_vertices = vlist->get_num_vertices(); for (int i = 0; i < num_vertices; i++) { FltVertex *flt_vertex = vlist->get_vertex(i); @@ -440,7 +440,7 @@ setup_geometry(const FltGeometry *flt_geom, FltToEggLevelState &state, LColor face_color = flt_geom->get_color(); - if (state._flt_object != (FltObject *)NULL) { + if (state._flt_object != nullptr) { // If we have a FltObject above us, it might also specify a transparency. // This combines with our existing transparency. PN_stdfloat alpha = 1.0 - (state._flt_object->_transparency / 65535.0); diff --git a/pandatool/src/fltegg/fltToEggLevelState.I b/pandatool/src/fltegg/fltToEggLevelState.I index 0a1cef8f43..e5460717a6 100644 --- a/pandatool/src/fltegg/fltToEggLevelState.I +++ b/pandatool/src/fltegg/fltToEggLevelState.I @@ -18,8 +18,8 @@ INLINE FltToEggLevelState:: FltToEggLevelState(FltToEggConverter *converter) : _converter(converter) { - _flt_object = (FltObject *)NULL; - _egg_parent = (EggGroupNode *)NULL; + _flt_object = nullptr; + _egg_parent = nullptr; } /** diff --git a/pandatool/src/fltegg/fltToEggLevelState.cxx b/pandatool/src/fltegg/fltToEggLevelState.cxx index 1fbe548d50..238208527e 100644 --- a/pandatool/src/fltegg/fltToEggLevelState.cxx +++ b/pandatool/src/fltegg/fltToEggLevelState.cxx @@ -39,9 +39,9 @@ FltToEggLevelState:: */ FltToEggLevelState::ParentNodes:: ParentNodes() { - _axial_billboard = (EggGroup *)NULL; - _point_billboard = (EggGroup *)NULL; - _plain = (EggGroup *)NULL; + _axial_billboard = nullptr; + _point_billboard = nullptr; + _plain = nullptr; } /** @@ -82,7 +82,7 @@ get_synthetic_group(const string &name, switch (type) { case FltGeometry::BT_axial: - if (nodes->_axial_billboard == (EggGroupNode *)NULL) { + if (nodes->_axial_billboard == nullptr) { nodes->_axial_billboard = new EggGroup(name); _egg_parent->add_child(nodes->_axial_billboard); nodes->_axial_billboard->set_billboard_type(EggGroup::BT_axis); @@ -94,7 +94,7 @@ get_synthetic_group(const string &name, return nodes->_axial_billboard; case FltGeometry::BT_point: - if (nodes->_point_billboard == (EggGroupNode *)NULL) { + if (nodes->_point_billboard == nullptr) { nodes->_point_billboard = new EggGroup(name); _egg_parent->add_child(nodes->_point_billboard); nodes->_point_billboard->set_billboard_type(EggGroup::BT_point_world_relative); @@ -107,7 +107,7 @@ get_synthetic_group(const string &name, default: // Normally, BT_none, although we've occasionally seen a // value of 3 come in here, whatever that's supposed to mean. - if (nodes->_plain == (EggGroupNode *)NULL) { + if (nodes->_plain == nullptr) { nodes->_plain = new EggGroup(name); _egg_parent->add_child(nodes->_plain); if (!is_identity) { diff --git a/pandatool/src/fltprogs/eggToFlt.cxx b/pandatool/src/fltprogs/eggToFlt.cxx index 90e9d123a3..5ca9224225 100644 --- a/pandatool/src/fltprogs/eggToFlt.cxx +++ b/pandatool/src/fltprogs/eggToFlt.cxx @@ -61,7 +61,7 @@ EggToFlt() : "if this is \"new\", these files will only be generated if they " "do not already exist (even if the properties have changed). " "Specifying \"all\" causes these to be rewritten every time.", - &EggToFlt::dispatch_attr, NULL, &_auto_attr_update); + &EggToFlt::dispatch_attr, nullptr, &_auto_attr_update); // Flt files are always in the z-up coordinate system. Don't confuse the // user with this meaningless option. @@ -489,7 +489,7 @@ get_flt_vertex(EggVertex *egg_vertex, EggNode *context) { flt_vertex->_has_uv = true; } - if (frame != (const LMatrix4d *)NULL) { + if (frame != nullptr) { flt_vertex->_pos = flt_vertex->_pos * (*frame); flt_vertex->_normal = flt_vertex->_normal * LCAST(PN_stdfloat, (*frame)); } diff --git a/pandatool/src/gtk-stats/gtkStats.cxx b/pandatool/src/gtk-stats/gtkStats.cxx index 5f3cf83e82..fad28f1a4b 100644 --- a/pandatool/src/gtk-stats/gtkStats.cxx +++ b/pandatool/src/gtk-stats/gtkStats.cxx @@ -17,7 +17,7 @@ #include "config_pstatclient.h" GtkWidget *main_window; -static GtkStatsServer *server = NULL; +static GtkStatsServer *server = nullptr; static gboolean delete_event(GtkWidget *widget, @@ -61,10 +61,10 @@ main(int argc, char *argv[]) { // Connect the delete and destroy events, so the user can exit the // application by closing the main window. g_signal_connect(G_OBJECT(main_window), "delete_event", - G_CALLBACK(delete_event), NULL); + G_CALLBACK(delete_event), nullptr); g_signal_connect(G_OBJECT(main_window), "destroy", - G_CALLBACK(destroy), NULL); + G_CALLBACK(destroy), nullptr); ostringstream stream; stream << "Listening on port " << pstats_port; @@ -97,7 +97,7 @@ main(int argc, char *argv[]) { gtk_widget_show(main_window); // Set up a timer to poll the pstats every so often. - g_timeout_add(200, timer, NULL); + g_timeout_add(200, timer, nullptr); // Now get lost in the message loop. gtk_main(); diff --git a/pandatool/src/gtk-stats/gtkStatsChartMenu.cxx b/pandatool/src/gtk-stats/gtkStatsChartMenu.cxx index dfed8e1028..5bd5a7691f 100644 --- a/pandatool/src/gtk-stats/gtkStatsChartMenu.cxx +++ b/pandatool/src/gtk-stats/gtkStatsChartMenu.cxx @@ -185,7 +185,7 @@ handle_menu(gpointer data) { const GtkStatsMonitor::MenuDef *menu_def = (GtkStatsMonitor::MenuDef *)data; GtkStatsMonitor *monitor = menu_def->_monitor; - if (monitor == NULL) { + if (monitor == nullptr) { return; } diff --git a/pandatool/src/gtk-stats/gtkStatsGraph.cxx b/pandatool/src/gtk-stats/gtkStatsGraph.cxx index 0c2b21f355..2f1b1e7189 100644 --- a/pandatool/src/gtk-stats/gtkStatsGraph.cxx +++ b/pandatool/src/gtk-stats/gtkStatsGraph.cxx @@ -38,18 +38,18 @@ GtkStatsGraph:: GtkStatsGraph(GtkStatsMonitor *monitor) : _monitor(monitor) { - _parent_window = NULL; - _window = NULL; - _graph_window = NULL; - _scale_area = NULL; + _parent_window = nullptr; + _window = nullptr; + _graph_window = nullptr; + _scale_area = nullptr; GtkWidget *parent_window = monitor->get_window(); GdkDisplay *display = gdk_drawable_get_display(parent_window->window); _hand_cursor = gdk_cursor_new_for_display(display, GDK_HAND2); - _pixmap = 0; - _pixmap_gc = 0; + _pixmap = nullptr; + _pixmap_gc = nullptr; _pixmap_xsize = 0; _pixmap_ysize = 0; @@ -91,7 +91,7 @@ GtkStatsGraph(GtkStatsMonitor *monitor) : G_CALLBACK(motion_notify_event_callback), this); // A Frame to hold the graph. - GtkWidget *graph_frame = gtk_frame_new(NULL); + GtkWidget *graph_frame = gtk_frame_new(nullptr); gtk_frame_set_shadow_type(GTK_FRAME(graph_frame), GTK_SHADOW_IN); gtk_container_add(GTK_CONTAINER(graph_frame), _graph_window); @@ -127,7 +127,7 @@ GtkStatsGraph(GtkStatsMonitor *monitor) : */ GtkStatsGraph:: ~GtkStatsGraph() { - _monitor = (GtkStatsMonitor *)NULL; + _monitor = nullptr; release_pixmap(); Brushes::iterator bi; @@ -138,9 +138,9 @@ GtkStatsGraph:: _label_stack.clear_labels(); - if (_window != (GtkWidget *)NULL) { + if (_window != nullptr) { GtkWidget *window = _window; - _window = NULL; + _window = nullptr; gtk_widget_destroy(window); } } @@ -204,7 +204,7 @@ set_pause(bool pause) { */ void GtkStatsGraph:: user_guide_bars_changed() { - if (_scale_area != NULL) { + if (_scale_area != nullptr) { gtk_widget_queue_draw(_scale_area); } gtk_widget_queue_draw(_graph_window); @@ -224,12 +224,12 @@ clicked_label(int collector_index) { void GtkStatsGraph:: close() { _label_stack.clear_labels(false); - if (_window != (GtkWidget *)NULL) { - _window = NULL; + if (_window != nullptr) { + _window = nullptr; GtkStatsMonitor *monitor = _monitor; - _monitor = (GtkStatsMonitor *)NULL; - if (monitor != (GtkStatsMonitor *)NULL) { + _monitor = nullptr; + if (monitor != nullptr) { monitor->remove_graph(this); } } @@ -328,7 +328,7 @@ handle_motion(GtkWidget *widget, int graph_x, int graph_y) { gdk_window_set_cursor(_window->window, _hand_cursor); } else { - gdk_window_set_cursor(_window->window, NULL); + gdk_window_set_cursor(_window->window, nullptr); } return TRUE; @@ -359,7 +359,7 @@ setup_pixmap(int xsize, int ysize) { */ void GtkStatsGraph:: release_pixmap() { - if (_pixmap != NULL) { + if (_pixmap != nullptr) { g_object_unref(_pixmap); g_object_unref(_pixmap_gc); } @@ -391,7 +391,7 @@ gboolean GtkStatsGraph:: graph_expose_callback(GtkWidget *widget, GdkEventExpose *event, gpointer data) { GtkStatsGraph *self = (GtkStatsGraph *)data; - if (self->_pixmap != NULL) { + if (self->_pixmap != nullptr) { gdk_draw_drawable(self->_graph_window->window, self->_graph_window->style->fg_gc[0], self->_pixmap, 0, 0, 0, 0, diff --git a/pandatool/src/gtk-stats/gtkStatsLabel.cxx b/pandatool/src/gtk-stats/gtkStatsLabel.cxx index e5a81afbfe..cac7be3859 100644 --- a/pandatool/src/gtk-stats/gtkStatsLabel.cxx +++ b/pandatool/src/gtk-stats/gtkStatsLabel.cxx @@ -31,7 +31,7 @@ GtkStatsLabel(GtkStatsMonitor *monitor, GtkStatsGraph *graph, _thread_index(thread_index), _collector_index(collector_index) { - _widget = NULL; + _widget = nullptr; if (use_fullname) { _text = _monitor->get_client_data()->get_collector_fullname(_collector_index); } else { diff --git a/pandatool/src/gtk-stats/gtkStatsMonitor.I b/pandatool/src/gtk-stats/gtkStatsMonitor.I index 71f5b43404..65a5bfbf64 100644 --- a/pandatool/src/gtk-stats/gtkStatsMonitor.I +++ b/pandatool/src/gtk-stats/gtkStatsMonitor.I @@ -19,7 +19,7 @@ MenuDef(int thread_index, int collector_index, bool show_level) : _thread_index(thread_index), _collector_index(collector_index), _show_level(show_level), - _monitor(NULL) + _monitor(nullptr) { } diff --git a/pandatool/src/gtk-stats/gtkStatsMonitor.cxx b/pandatool/src/gtk-stats/gtkStatsMonitor.cxx index fe4926cbc5..1c7a8b1f1f 100644 --- a/pandatool/src/gtk-stats/gtkStatsMonitor.cxx +++ b/pandatool/src/gtk-stats/gtkStatsMonitor.cxx @@ -25,18 +25,18 @@ typedef void vc(); GtkItemFactoryEntry GtkStatsMonitor::menu_entries[] = { - { (gchar *)"/Options", NULL, NULL, 0, (gchar *)"" }, - { (gchar *)"/Options/Units", NULL, NULL, 0, (gchar *)"" }, - { (gchar *)"/Options/Units/ms", NULL, (vc *)&handle_menu_command, MI_time_ms, (gchar *)"" }, - { (gchar *)"/Options/Units/Hz", NULL, (vc *)&handle_menu_command, MI_time_hz, (gchar *)"/Options/Units/ms" }, - { (gchar *)"/Speed", NULL, NULL, 0, (gchar *)"" }, - { (gchar *)"/Speed/1", NULL, (vc *)&handle_menu_command, MI_speed_1, (gchar *)"" }, - { (gchar *)"/Speed/2", NULL, (vc *)&handle_menu_command, MI_speed_2, (gchar *)"/Speed/1" }, - { (gchar *)"/Speed/3", NULL, (vc *)&handle_menu_command, MI_speed_3, (gchar *)"/Speed/1" }, - { (gchar *)"/Speed/6", NULL, (vc *)&handle_menu_command, MI_speed_6, (gchar *)"/Speed/1" }, - { (gchar *)"/Speed/12", NULL, (vc *)&handle_menu_command, MI_speed_12, (gchar *)"/Speed/1" }, - { (gchar *)"/Speed/sep", NULL, NULL, 0, (gchar *)"" }, - { (gchar *)"/Speed/pause", NULL, (vc *)&handle_menu_command, MI_pause, (gchar *)"" }, + { (gchar *)"/Options", nullptr, nullptr, 0, (gchar *)"" }, + { (gchar *)"/Options/Units", nullptr, nullptr, 0, (gchar *)"" }, + { (gchar *)"/Options/Units/ms", nullptr, (vc *)&handle_menu_command, MI_time_ms, (gchar *)"" }, + { (gchar *)"/Options/Units/Hz", nullptr, (vc *)&handle_menu_command, MI_time_hz, (gchar *)"/Options/Units/ms" }, + { (gchar *)"/Speed", nullptr, nullptr, 0, (gchar *)"" }, + { (gchar *)"/Speed/1", nullptr, (vc *)&handle_menu_command, MI_speed_1, (gchar *)"" }, + { (gchar *)"/Speed/2", nullptr, (vc *)&handle_menu_command, MI_speed_2, (gchar *)"/Speed/1" }, + { (gchar *)"/Speed/3", nullptr, (vc *)&handle_menu_command, MI_speed_3, (gchar *)"/Speed/1" }, + { (gchar *)"/Speed/6", nullptr, (vc *)&handle_menu_command, MI_speed_6, (gchar *)"/Speed/1" }, + { (gchar *)"/Speed/12", nullptr, (vc *)&handle_menu_command, MI_speed_12, (gchar *)"/Speed/1" }, + { (gchar *)"/Speed/sep", nullptr, nullptr, 0, (gchar *)"" }, + { (gchar *)"/Speed/pause", nullptr, (vc *)&handle_menu_command, MI_pause, (gchar *)"" }, }; int GtkStatsMonitor::num_menu_entries = sizeof(menu_entries) / sizeof(GtkItemFactoryEntry); @@ -46,8 +46,8 @@ int GtkStatsMonitor::num_menu_entries = sizeof(menu_entries) / sizeof(GtkItemFac */ GtkStatsMonitor:: GtkStatsMonitor(GtkStatsServer *server) : PStatMonitor(server) { - _window = NULL; - _item_factory = NULL; + _window = nullptr; + _item_factory = nullptr; // These will be filled in later when the menu is created. _time_units = 0; @@ -362,7 +362,7 @@ remove_graph(GtkStatsGraph *graph) { */ void GtkStatsMonitor:: create_window() { - if (_window != NULL) { + if (_window != nullptr) { return; } @@ -432,9 +432,9 @@ shutdown() { } _chart_menus.clear(); - if (_window != NULL) { + if (_window != nullptr) { gtk_widget_destroy(_window); - _window = NULL; + _window = nullptr; } #ifdef DEVELOP_GTKSTATS diff --git a/pandatool/src/imageprogs/imageFixHiddenColor.cxx b/pandatool/src/imageprogs/imageFixHiddenColor.cxx index bb56bcc659..a3d176bfb4 100644 --- a/pandatool/src/imageprogs/imageFixHiddenColor.cxx +++ b/pandatool/src/imageprogs/imageFixHiddenColor.cxx @@ -41,19 +41,19 @@ ImageFixHiddenColor() : ImageFilter(true) { "alpha channel on the source image. If this file has an alpha " "channel, that alpha channel is used; otherwise, the grayscale " "value of the image is used.", - &ImageFixHiddenColor::dispatch_filename, NULL, &_alpha_filename); + &ImageFixHiddenColor::dispatch_filename, nullptr, &_alpha_filename); add_option ("opaque", "alpha", 0, "Specifies the minimum alpha value (in the range of 0 to 1) for a " "pixel to be considered fully opaque. The default is 1.", - &ImageFixHiddenColor::dispatch_double, NULL, &_min_opaque_alpha); + &ImageFixHiddenColor::dispatch_double, nullptr, &_min_opaque_alpha); add_option ("transparent", "alpha", 0, "Specifies the maximum alpha value (in the range of 0 to 1) for a " "pixel to be considered fully transparent. The default is 0.", - &ImageFixHiddenColor::dispatch_double, NULL, &_max_transparent_alpha); + &ImageFixHiddenColor::dispatch_double, nullptr, &_max_transparent_alpha); _min_opaque_alpha = 1.0; _max_transparent_alpha = 0.0; diff --git a/pandatool/src/imageprogs/imageInfo.cxx b/pandatool/src/imageprogs/imageInfo.cxx index 175a5dba1d..7cbde06913 100644 --- a/pandatool/src/imageprogs/imageInfo.cxx +++ b/pandatool/src/imageprogs/imageInfo.cxx @@ -29,7 +29,7 @@ ImageInfo() { "Report only images that have a non-power-of-two size in either " "dimension. Images whose dimensions are both a power of two will " "not be mentioned.", - &ImageInfo::dispatch_none, &_report_power_2, NULL); + &ImageInfo::dispatch_none, &_report_power_2, nullptr); } /** diff --git a/pandatool/src/imageprogs/imageResize.cxx b/pandatool/src/imageprogs/imageResize.cxx index ae5a746c1a..f3c51c8554 100644 --- a/pandatool/src/imageprogs/imageResize.cxx +++ b/pandatool/src/imageprogs/imageResize.cxx @@ -29,14 +29,14 @@ ImageResize() : ImageFilter(true) { "Specify the width of the output image in pixels, or as a percentage " "of the original width (if a trailing percent sign is included). " "If this is omitted, the ratio is taken from the ysize parameter.", - &ImageResize::dispatch_size_request, NULL, &_x_size); + &ImageResize::dispatch_size_request, nullptr, &_x_size); add_option ("y", "ysize", 0, "Specify the height of the output image in pixels, or as a percentage " "of the original height (if a trailing percent sign is included). " "If this is omitted, the ratio is taken from the xsize parameter.", - &ImageResize::dispatch_size_request, NULL, &_y_size); + &ImageResize::dispatch_size_request, nullptr, &_y_size); add_option ("g", "radius", 0, @@ -47,7 +47,7 @@ ImageResize() : ImageFilter(true) { ("1", "", 0, "This option is ignored. It is provided only for backward compatibility " "with a previous version of image-resize.", - &ImageResize::dispatch_none, NULL, NULL); + &ImageResize::dispatch_none, nullptr, nullptr); _filter_radius = 1.0; } diff --git a/pandatool/src/imageprogs/imageTrans.cxx b/pandatool/src/imageprogs/imageTrans.cxx index da33516eeb..48bc98c5d2 100644 --- a/pandatool/src/imageprogs/imageTrans.cxx +++ b/pandatool/src/imageprogs/imageTrans.cxx @@ -33,7 +33,7 @@ ImageTrans() : ImageFilter(true) { "l, la, rgb, or rgba, respectively, or any of the keywords r, g, b, or " "a to extract out just the indicated channel as a single grayscale " "image.", - &ImageTrans::dispatch_channels, NULL, &_channels); + &ImageTrans::dispatch_channels, nullptr, &_channels); add_option ("cscale", "r,g,b[,a]", 50, diff --git a/pandatool/src/imageprogs/imageTransformColors.cxx b/pandatool/src/imageprogs/imageTransformColors.cxx index a18629f798..0600956a91 100644 --- a/pandatool/src/imageprogs/imageTransformColors.cxx +++ b/pandatool/src/imageprogs/imageTransformColors.cxx @@ -40,36 +40,36 @@ ImageTransformColors() { "space, instead of the default RGB space. In this mode, the first " "component controls hue, the second controls lightness, and the third " "controls saturation.", - &ImageTransformColors::dispatch_none, &_hls, NULL); + &ImageTransformColors::dispatch_none, &_hls, nullptr); add_option ("range", "min,max", 0, "Compresses the overall dynamic range from 0,1 to min,max. If min,max " "exceed 0,1, the dynamic range is expanded. This doesn't make sense in " "HLS mode.", - &ImageTransformColors::dispatch_range, NULL, &_mat); + &ImageTransformColors::dispatch_range, nullptr, &_mat); add_option ("scale", "r,g,b", 0, "Scales the r,g,b components by the indicated values. In HLS mode, " "the scale is applied to the h,l,s components.", - &ImageTransformColors::dispatch_scale, NULL, &_mat); + &ImageTransformColors::dispatch_scale, nullptr, &_mat); add_option ("add", "r,g,b", 0, "Adds the indicated values to the r,g,b components. In HLS mode, " "the sum is applied to the h,l,s components.", - &ImageTransformColors::dispatch_add, NULL, &_mat); + &ImageTransformColors::dispatch_add, nullptr, &_mat); add_option ("mat4", "m00,m01,m02,m03,m10,m11,m12,m13,m20,m21,m22,m23,m30,m31,m32,m33", 0, "Defines an arbitrary 4x4 RGB matrix.", - &ImageTransformColors::dispatch_mat4, NULL, &_mat); + &ImageTransformColors::dispatch_mat4, nullptr, &_mat); add_option ("mat3", "m00,m01,m02,m10,m11,m12,m20,m21,m22", 0, "Defines an arbitrary 3x3 RGB matrix.", - &ImageTransformColors::dispatch_mat3, NULL, &_mat); + &ImageTransformColors::dispatch_mat3, nullptr, &_mat); add_option ("o", "filename", 50, diff --git a/pandatool/src/lwo/iffInputFile.cxx b/pandatool/src/lwo/iffInputFile.cxx index 17f4225625..e3ffa34044 100644 --- a/pandatool/src/lwo/iffInputFile.cxx +++ b/pandatool/src/lwo/iffInputFile.cxx @@ -24,7 +24,7 @@ TypeHandle IffInputFile::_type_handle; */ IffInputFile:: IffInputFile() { - _input = (istream *)NULL; + _input = nullptr; _owns_istream = false; _eof = true; _unexpected_eof = false; @@ -52,7 +52,7 @@ open_read(Filename filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *in = vfs->open_read_file(filename, true); - if (in == (istream *)NULL) { + if (in == nullptr) { return false; } @@ -211,7 +211,7 @@ get_id() { PT(IffChunk) IffInputFile:: get_chunk() { if (is_eof()) { - return (IffChunk *)NULL; + return nullptr; } IffId id = get_id(); @@ -230,14 +230,14 @@ get_chunk() { nout << "Unexpected EOF on file reading " << *chunk << "\n"; _unexpected_eof = true; } - return (IffChunk *)NULL; + return nullptr; } size_t num_bytes_read = get_bytes_read() - start_point; if (num_bytes_read > length) { nout << *chunk << " read " << num_bytes_read << " instead of " << length << " bytes.\n"; - return (IffChunk *)NULL; + return nullptr; } else if (num_bytes_read < length) { size_t skip_count = length - num_bytes_read; @@ -249,7 +249,7 @@ get_chunk() { } } - return (IffChunk *)NULL; + return nullptr; } /** @@ -261,7 +261,7 @@ get_chunk() { PT(IffChunk) IffInputFile:: get_subchunk(IffChunk *context) { if (is_eof()) { - return (IffChunk *)NULL; + return nullptr; } IffId id = get_id(); @@ -280,14 +280,14 @@ get_subchunk(IffChunk *context) { nout << "Unexpected EOF on file reading " << *chunk << "\n"; _unexpected_eof = true; } - return (IffChunk *)NULL; + return nullptr; } size_t num_bytes_read = get_bytes_read() - start_point; if (num_bytes_read > length) { nout << *chunk << " read " << num_bytes_read << " instead of " << length << " bytes.\n"; - return (IffChunk *)NULL; + return nullptr; } else if (num_bytes_read < length) { size_t skip_count = length - num_bytes_read; @@ -299,7 +299,7 @@ get_subchunk(IffChunk *context) { } } - return (IffChunk *)NULL; + return nullptr; } /** diff --git a/pandatool/src/lwo/lwoGroupChunk.cxx b/pandatool/src/lwo/lwoGroupChunk.cxx index 69cd426f57..a9bb29fbe7 100644 --- a/pandatool/src/lwo/lwoGroupChunk.cxx +++ b/pandatool/src/lwo/lwoGroupChunk.cxx @@ -31,7 +31,7 @@ get_num_chunks() const { */ IffChunk *LwoGroupChunk:: get_chunk(int n) const { - nassertr(n >= 0 && n < (int)_chunks.size(), (IffChunk *)NULL); + nassertr(n >= 0 && n < (int)_chunks.size(), nullptr); return _chunks[n]; } @@ -44,7 +44,7 @@ bool LwoGroupChunk:: read_chunks_iff(IffInputFile *in, size_t stop_at) { while (in->get_bytes_read() < stop_at && !in->is_eof()) { PT(IffChunk) chunk = in->get_chunk(); - if (chunk == (IffChunk *)NULL) { + if (chunk == nullptr) { return false; } _chunks.push_back(chunk); @@ -60,7 +60,7 @@ bool LwoGroupChunk:: read_subchunks_iff(IffInputFile *in, size_t stop_at) { while (in->get_bytes_read() < stop_at && !in->is_eof()) { PT(IffChunk) chunk = in->get_subchunk(this); - if (chunk == (IffChunk *)NULL) { + if (chunk == nullptr) { return false; } _chunks.push_back(chunk); diff --git a/pandatool/src/lwo/lwoPolygons.cxx b/pandatool/src/lwo/lwoPolygons.cxx index 76736c4f41..4e51d3ee26 100644 --- a/pandatool/src/lwo/lwoPolygons.cxx +++ b/pandatool/src/lwo/lwoPolygons.cxx @@ -32,7 +32,7 @@ get_num_polygons() const { */ LwoPolygons::Polygon *LwoPolygons:: get_polygon(int n) const { - nassertr(n >= 0 && n < (int)_polygons.size(), (Polygon *)NULL); + nassertr(n >= 0 && n < (int)_polygons.size(), nullptr); return _polygons[n]; } diff --git a/pandatool/src/lwo/lwoSurfaceBlock.cxx b/pandatool/src/lwo/lwoSurfaceBlock.cxx index c1482bdb7d..76babe281c 100644 --- a/pandatool/src/lwo/lwoSurfaceBlock.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlock.cxx @@ -36,7 +36,7 @@ TypeHandle LwoSurfaceBlock::_type_handle; bool LwoSurfaceBlock:: read_iff(IffInputFile *in, size_t stop_at) { PT(IffChunk) chunk = in->get_subchunk(this); - if (chunk == (IffChunk *)NULL) { + if (chunk == nullptr) { return false; } if (!chunk->is_of_type(LwoSurfaceBlockHeader::get_class_type())) { diff --git a/pandatool/src/lwo/test_lwo.cxx b/pandatool/src/lwo/test_lwo.cxx index b541fb8360..baba598440 100644 --- a/pandatool/src/lwo/test_lwo.cxx +++ b/pandatool/src/lwo/test_lwo.cxx @@ -30,7 +30,7 @@ main(int argc, char *argv[]) { } PT(IffChunk) chunk = in.get_chunk(); - while (chunk != (IffChunk *)NULL) { + while (chunk != nullptr) { nout << "Got chunk type " << chunk->get_type() << ":\n"; chunk->write(nout, 2); chunk = in.get_chunk(); diff --git a/pandatool/src/lwoegg/cLwoLayer.cxx b/pandatool/src/lwoegg/cLwoLayer.cxx index 4794ef1429..7356212545 100644 --- a/pandatool/src/lwoegg/cLwoLayer.cxx +++ b/pandatool/src/lwoegg/cLwoLayer.cxx @@ -39,7 +39,7 @@ void CLwoLayer:: connect_egg() { if (_layer->_parent != -1) { const CLwoLayer *parent = _converter->get_layer(_layer->_parent); - if (parent != (CLwoLayer *)NULL) { + if (parent != nullptr) { parent->_egg_group->add_child(_egg_group.p()); return; } diff --git a/pandatool/src/lwoegg/cLwoPolygons.I b/pandatool/src/lwoegg/cLwoPolygons.I index 691d706324..94908debd9 100644 --- a/pandatool/src/lwoegg/cLwoPolygons.I +++ b/pandatool/src/lwoegg/cLwoPolygons.I @@ -21,6 +21,6 @@ CLwoPolygons(LwoToEggConverter *converter, const LwoPolygons *polygons, _polygons(polygons), _points(points) { - _tags = (LwoTags *)NULL; - _surf_ptags = (LwoPolygonTags *)NULL; + _tags = nullptr; + _surf_ptags = nullptr; } diff --git a/pandatool/src/lwoegg/cLwoPolygons.cxx b/pandatool/src/lwoegg/cLwoPolygons.cxx index ad1f600a04..3f64a6ee83 100644 --- a/pandatool/src/lwoegg/cLwoPolygons.cxx +++ b/pandatool/src/lwoegg/cLwoPolygons.cxx @@ -32,7 +32,7 @@ */ void CLwoPolygons:: add_ptags(const LwoPolygonTags *lwo_ptags, const LwoTags *tags) { - if (_tags != (LwoTags *)NULL && _tags != tags) { + if (_tags != nullptr && _tags != tags) { nout << "Multiple Tags fields in effect on the same polygons.\n"; } _tags = tags; @@ -82,31 +82,31 @@ add_vmad(const LwoDiscontinuousVertexMap *lwo_vmad) { */ CLwoSurface *CLwoPolygons:: get_surface(int polygon_index) const { - if (_surf_ptags == (LwoPolygonTags *)NULL) { + if (_surf_ptags == nullptr) { // No surface definitions. - return (CLwoSurface *)NULL; + return nullptr; } if (!_surf_ptags->has_tag(polygon_index)) { // The polygon isn't tagged. - return (CLwoSurface *)NULL; + return nullptr; } int tag_index = _surf_ptags->get_tag(polygon_index); - if (_tags == (LwoTags *)NULL || tag_index < 0 || + if (_tags == nullptr || tag_index < 0 || tag_index >= _tags->get_num_tags()) { // The tag index is out-of-bounds. nout << "Invalid polygon tag index " << tag_index << "\n"; - return (CLwoSurface *)NULL; + return nullptr; } string tag = _tags->get_tag(tag_index); // Now look up the surface name in the header. CLwoSurface *surface = _converter->get_surface(tag); - if (surface == (CLwoSurface *)NULL) { + if (surface == nullptr) { nout << "Unknown surface " << tag << "\n"; - return (CLwoSurface *)NULL; + return nullptr; } return surface; @@ -182,8 +182,8 @@ make_egg() { */ void CLwoPolygons:: connect_egg() { - nassertv(_points->_layer->_egg_group != (EggGroup *)NULL); - nassertv(_egg_group != (EggGroup *)NULL); + nassertv(_points->_layer->_egg_group != nullptr); + nassertv(_egg_group != nullptr); _points->_layer->_egg_group->steal_children(*_egg_group); } @@ -236,7 +236,7 @@ make_faces() { egg_vertex->set_pos(pos); // Does the vertex used named UV's? - if (surface != (CLwoSurface *)NULL && surface->has_named_uvs()) { + if (surface != nullptr && surface->has_named_uvs()) { string uv_name = surface->get_uv_name(); LPoint2 uv; if (get_uv(uv_name, pindex, vindex, uv)) { @@ -256,7 +256,7 @@ make_faces() { } if (is_valid) { - if (surface != (CLwoSurface *)NULL) { + if (surface != nullptr) { surface->apply_properties(egg_prim, egg_vertices, smooth_angle); } diff --git a/pandatool/src/lwoegg/cLwoSurface.I b/pandatool/src/lwoegg/cLwoSurface.I index 80c4c2c3d6..49c6eaf6bc 100644 --- a/pandatool/src/lwoegg/cLwoSurface.I +++ b/pandatool/src/lwoegg/cLwoSurface.I @@ -28,7 +28,7 @@ get_name() const { */ INLINE bool CLwoSurface:: has_named_uvs() const { - return (_block != (CLwoSurfaceBlock *)NULL && + return (_block != nullptr && _block->_projection_mode == LwoSurfaceBlockProjection::M_uv); } diff --git a/pandatool/src/lwoegg/cLwoSurface.cxx b/pandatool/src/lwoegg/cLwoSurface.cxx index f75932b975..b3a1c78d1d 100644 --- a/pandatool/src/lwoegg/cLwoSurface.cxx +++ b/pandatool/src/lwoegg/cLwoSurface.cxx @@ -39,8 +39,8 @@ CLwoSurface(LwoToEggConverter *converter, const LwoSurface *surface) : _rgb.set(1.0, 1.0, 1.0); _checked_material = false; _checked_texture = false; - _map_uvs = NULL; - _block = (CLwoSurfaceBlock *)NULL; + _map_uvs = nullptr; + _block = nullptr; // Walk through the chunk list, looking for some basic properties. int num_chunks = _surface->get_num_chunks(); @@ -107,7 +107,7 @@ CLwoSurface(LwoToEggConverter *converter, const LwoSurface *surface) : block->_channel_id == IffId("COLR") && block->_enabled) { // Now save the block with the lowest ordinal. - if (_block == (CLwoSurfaceBlock *)NULL) { + if (_block == nullptr) { _block = block; } else if (block->_ordinal < _block->_ordinal) { @@ -146,7 +146,7 @@ CLwoSurface(LwoToEggConverter *converter, const LwoSurface *surface) : */ CLwoSurface:: ~CLwoSurface() { - if (_block != (CLwoSurfaceBlock *)NULL) { + if (_block != nullptr) { delete _block; } } @@ -164,7 +164,7 @@ apply_properties(EggPrimitive *egg_prim, vector_PT_EggVertex &egg_vertices, if (!_surface->_source.empty()) { // This surface is derived from another surface; apply that one first. CLwoSurface *parent = _converter->get_surface(_surface->_source); - if (parent != (CLwoSurface *)NULL && parent != this) { + if (parent != nullptr && parent != this) { parent->apply_properties(egg_prim, egg_vertices, smooth_angle); } } @@ -204,13 +204,13 @@ apply_properties(EggPrimitive *egg_prim, vector_PT_EggVertex &egg_vertices, bool CLwoSurface:: check_texture() { if (_checked_texture) { - return (_egg_texture != (EggTexture *)NULL); + return (_egg_texture != nullptr); } _checked_texture = true; - _egg_texture = (EggTexture *)NULL; - _map_uvs = NULL; + _egg_texture = nullptr; + _map_uvs = nullptr; - if (_block == (CLwoSurfaceBlock *)NULL) { + if (_block == nullptr) { // No texture. Not even a shader block. return false; } @@ -222,7 +222,7 @@ check_texture() { } CLwoClip *clip = _converter->get_clip(clip_index); - if (clip == (CLwoClip *)NULL) { + if (clip == nullptr) { nout << "No clip image with index " << clip_index << "\n"; return false; } @@ -281,10 +281,10 @@ check_texture() { bool CLwoSurface:: check_material() { if (_checked_material) { - return (_egg_material != (EggMaterial *)NULL); + return (_egg_material != nullptr); } _checked_material = true; - _egg_material = (EggMaterial *)NULL; + _egg_material = nullptr; if (!_converter->_make_materials) { // If we aren't making materials, then don't make a material. @@ -336,7 +336,7 @@ check_material() { */ void CLwoSurface:: generate_uvs(vector_PT_EggVertex &egg_vertices) { - if (_map_uvs == NULL) { + if (_map_uvs == nullptr) { return; } diff --git a/pandatool/src/lwoegg/cLwoSurfaceBlock.cxx b/pandatool/src/lwoegg/cLwoSurfaceBlock.cxx index 1902a28377..98d4c502f0 100644 --- a/pandatool/src/lwoegg/cLwoSurfaceBlock.cxx +++ b/pandatool/src/lwoegg/cLwoSurfaceBlock.cxx @@ -45,7 +45,7 @@ CLwoSurfaceBlock(LwoToEggConverter *converter, const LwoSurfaceBlock *block) : _h_wrap = LwoSurfaceBlockWrap::M_repeat; _w_repeat = 1.0; _h_repeat = 1.0; - _tmap = (CLwoSurfaceBlockTMap *)NULL; + _tmap = nullptr; // Scan the chunks in the header. int num_hchunks = _block->_header->get_num_chunks(); @@ -71,7 +71,7 @@ CLwoSurfaceBlock(LwoToEggConverter *converter, const LwoSurfaceBlock *block) : if (chunk->is_of_type(LwoSurfaceBlockTMap::get_class_type())) { const LwoSurfaceBlockTMap *lwo_tmap = DCAST(LwoSurfaceBlockTMap, chunk); - if (_tmap != (CLwoSurfaceBlockTMap *)NULL) { + if (_tmap != nullptr) { nout << "Two TMAP chunks encountered within surface block.\n"; delete _tmap; } @@ -113,7 +113,7 @@ CLwoSurfaceBlock(LwoToEggConverter *converter, const LwoSurfaceBlock *block) : } } - if (_tmap != (CLwoSurfaceBlockTMap *)NULL) { + if (_tmap != nullptr) { _tmap->get_transform(_transform); } @@ -144,7 +144,7 @@ CLwoSurfaceBlock(LwoToEggConverter *converter, const LwoSurfaceBlock *block) : */ CLwoSurfaceBlock:: ~CLwoSurfaceBlock() { - if (_tmap != (CLwoSurfaceBlockTMap *)NULL) { + if (_tmap != nullptr) { delete _tmap; } } diff --git a/pandatool/src/lwoegg/lwoToEggConverter.cxx b/pandatool/src/lwoegg/lwoToEggConverter.cxx index fa94f560be..94aa3b7fe6 100644 --- a/pandatool/src/lwoegg/lwoToEggConverter.cxx +++ b/pandatool/src/lwoegg/lwoToEggConverter.cxx @@ -37,7 +37,7 @@ */ LwoToEggConverter:: LwoToEggConverter() { - _generic_layer = (CLwoLayer *)NULL; + _generic_layer = nullptr; _make_materials = true; } @@ -110,7 +110,7 @@ convert_file(const Filename &filename) { } PT(IffChunk) chunk = in.get_chunk(); - if (chunk == (IffChunk *)NULL) { + if (chunk == nullptr) { nout << "Unable to read " << filename << "\n"; return false; } @@ -162,7 +162,7 @@ get_layer(int number) const { if (number >= 0 && number < (int)_layers.size()) { return _layers[number]; } - return (CLwoLayer *)NULL; + return nullptr; } /** @@ -174,7 +174,7 @@ get_clip(int number) const { if (number >= 0 && number < (int)_clips.size()) { return _clips[number]; } - return (CLwoClip *)NULL; + return nullptr; } /** @@ -188,7 +188,7 @@ get_surface(const string &name) const { if (si != _surfaces.end()) { return (*si).second; } - return (CLwoSurface *)NULL; + return nullptr; } /** @@ -199,15 +199,15 @@ void LwoToEggConverter:: cleanup() { _lwo_header.clear(); - if (_generic_layer != (CLwoLayer *)NULL) { + if (_generic_layer != nullptr) { delete _generic_layer; - _generic_layer = (CLwoLayer *)NULL; + _generic_layer = nullptr; } Layers::iterator li; for (li = _layers.begin(); li != _layers.end(); ++li) { CLwoLayer *layer = (*li); - if (layer != (CLwoLayer *)NULL) { + if (layer != nullptr) { delete layer; } } @@ -216,7 +216,7 @@ cleanup() { Clips::iterator ci; for (ci = _clips.begin(); ci != _clips.end(); ++ci) { CLwoClip *clip = (*ci); - if (clip != (CLwoClip *)NULL) { + if (clip != nullptr) { delete clip; } } @@ -250,11 +250,11 @@ cleanup() { */ void LwoToEggConverter:: collect_lwo() { - CLwoLayer *last_layer = (CLwoLayer *)NULL; - CLwoPoints *last_points = (CLwoPoints *)NULL; - CLwoPolygons *last_polygons = (CLwoPolygons *)NULL; + CLwoLayer *last_layer = nullptr; + CLwoPoints *last_points = nullptr; + CLwoPolygons *last_polygons = nullptr; - const LwoTags *tags = (const LwoTags *)NULL; + const LwoTags *tags = nullptr; int num_chunks = _lwo_header->get_num_chunks(); for (int i = 0; i < num_chunks; i++) { @@ -266,13 +266,13 @@ collect_lwo() { int number = layer->get_number(); slot_layer(number); - if (_layers[number] != (CLwoLayer *)NULL) { + if (_layers[number] != nullptr) { nout << "Warning: multiple layers with number " << number << "\n"; } _layers[number] = layer; last_layer = layer; - last_points = (CLwoPoints *)NULL; - last_polygons = (CLwoPolygons *)NULL; + last_points = nullptr; + last_polygons = nullptr; } else if (chunk->is_of_type(LwoClip::get_class_type())) { const LwoClip *lwo_clip = DCAST(LwoClip, chunk); @@ -281,13 +281,13 @@ collect_lwo() { int index = clip->get_index(); slot_clip(index); - if (_clips[index] != (CLwoClip *)NULL) { + if (_clips[index] != nullptr) { nout << "Warning: multiple clips with index " << index << "\n"; } _clips[index] = clip; } else if (chunk->is_of_type(LwoPoints::get_class_type())) { - if (last_layer == (CLwoLayer *)NULL) { + if (last_layer == nullptr) { last_layer = make_generic_layer(); } @@ -297,7 +297,7 @@ collect_lwo() { last_points = points; } else if (chunk->is_of_type(LwoVertexMap::get_class_type())) { - if (last_points == (CLwoPoints *)NULL) { + if (last_points == nullptr) { nout << "Vertex map chunk encountered without a preceding points chunk.\n"; } else { const LwoVertexMap *lwo_vmap = DCAST(LwoVertexMap, chunk); @@ -305,7 +305,7 @@ collect_lwo() { } } else if (chunk->is_of_type(LwoDiscontinuousVertexMap::get_class_type())) { - if (last_polygons == (CLwoPolygons *)NULL) { + if (last_polygons == nullptr) { nout << "Discontinous vertex map chunk encountered without a preceding polygons chunk.\n"; } else { const LwoDiscontinuousVertexMap *lwo_vmad = DCAST(LwoDiscontinuousVertexMap, chunk); @@ -316,7 +316,7 @@ collect_lwo() { tags = DCAST(LwoTags, chunk); } else if (chunk->is_of_type(LwoPolygons::get_class_type())) { - if (last_points == (CLwoPoints *)NULL) { + if (last_points == nullptr) { nout << "Polygon chunk encountered without a preceding points chunk.\n"; } else { const LwoPolygons *lwo_polygons = DCAST(LwoPolygons, chunk); @@ -327,9 +327,9 @@ collect_lwo() { } } else if (chunk->is_of_type(LwoPolygonTags::get_class_type())) { - if (last_polygons == (CLwoPolygons *)NULL) { + if (last_polygons == nullptr) { nout << "Polygon tags chunk encountered without a preceding polygons chunk.\n"; - } else if (tags == (LwoTags *)NULL) { + } else if (tags == nullptr) { nout << "Polygon tags chunk encountered without a preceding tags chunk.\n"; } else { const LwoPolygonTags *lwo_ptags = DCAST(LwoPolygonTags, chunk); @@ -337,7 +337,7 @@ collect_lwo() { } } else if (chunk->is_of_type(LwoSurface::get_class_type())) { - if (last_layer == (CLwoLayer *)NULL) { + if (last_layer == nullptr) { last_layer = make_generic_layer(); } @@ -358,14 +358,14 @@ collect_lwo() { */ void LwoToEggConverter:: make_egg() { - if (_generic_layer != (CLwoLayer *)NULL) { + if (_generic_layer != nullptr) { _generic_layer->make_egg(); } Layers::iterator li; for (li = _layers.begin(); li != _layers.end(); ++li) { CLwoLayer *layer = (*li); - if (layer != (CLwoLayer *)NULL) { + if (layer != nullptr) { layer->make_egg(); } } @@ -388,14 +388,14 @@ make_egg() { */ void LwoToEggConverter:: connect_egg() { - if (_generic_layer != (CLwoLayer *)NULL) { + if (_generic_layer != nullptr) { _generic_layer->connect_egg(); } Layers::iterator li; for (li = _layers.begin(); li != _layers.end(); ++li) { CLwoLayer *layer = (*li); - if (layer != (CLwoLayer *)NULL) { + if (layer != nullptr) { layer->connect_egg(); } } @@ -421,7 +421,7 @@ void LwoToEggConverter:: slot_layer(int number) { nassertv(number - (int)_layers.size() < 1000); while (number >= (int)_layers.size()) { - _layers.push_back((CLwoLayer *)NULL); + _layers.push_back(nullptr); } nassertv(number >= 0 && number < (int)_layers.size()); } @@ -434,7 +434,7 @@ void LwoToEggConverter:: slot_clip(int number) { nassertv(number - (int)_clips.size() < 1000); while (number >= (int)_clips.size()) { - _clips.push_back((CLwoClip *)NULL); + _clips.push_back(nullptr); } nassertv(number >= 0 && number < (int)_clips.size()); } @@ -447,7 +447,7 @@ slot_clip(int number) { */ CLwoLayer *LwoToEggConverter:: make_generic_layer() { - nassertr(_generic_layer == (CLwoLayer *)NULL, _generic_layer); + nassertr(_generic_layer == nullptr, _generic_layer); PT(LwoLayer) layer = new LwoLayer; layer->make_generic(); diff --git a/pandatool/src/lwoprogs/lwoScan.cxx b/pandatool/src/lwoprogs/lwoScan.cxx index a7fbf46933..5bb0f5a600 100644 --- a/pandatool/src/lwoprogs/lwoScan.cxx +++ b/pandatool/src/lwoprogs/lwoScan.cxx @@ -44,10 +44,10 @@ run() { } PT(IffChunk) chunk = in.get_chunk(); - if (chunk == (IffChunk *)NULL) { + if (chunk == nullptr) { nout << "Unable to read file.\n"; } else { - while (chunk != (IffChunk *)NULL) { + while (chunk != nullptr) { chunk->write(cout, 0); chunk = in.get_chunk(); } diff --git a/pandatool/src/maxegg/maxEgg.cxx b/pandatool/src/maxegg/maxEgg.cxx index 2b77f06767..c76a8e2ecf 100644 --- a/pandatool/src/maxegg/maxEgg.cxx +++ b/pandatool/src/maxegg/maxEgg.cxx @@ -297,7 +297,7 @@ ClassDesc* GetMaxEggPluginDesc() { return &MaxEggPluginDesc; } // Initialize class-static variables Mesh MaxEggPlugin::mesh; short MaxEggPlugin::meshBuilt=0; -HWND MaxEggPlugin::hMaxEggParams = NULL; +HWND MaxEggPlugin::hMaxEggParams = nullptr; IObjParam *MaxEggPlugin::iObjParams; /* MaxEggPluginOptionsDlgProc() - This is the callback function for the @@ -454,9 +454,9 @@ void MaxEggPlugin::EndEditParams( IObjParam *ip, ULONG flags,Animatable *prev) if ( flags&END_EDIT_REMOVEUI ) { ip->UnRegisterDlgWnd(hMaxEggParams); ip->DeleteRollupPage(hMaxEggParams); - hMaxEggParams = NULL; + hMaxEggParams = nullptr; } else { - SetWindowLongPtr( hMaxEggParams, GWLP_USERDATA, NULL ); + SetWindowLongPtr( hMaxEggParams, GWLP_USERDATA, nullptr ); } } @@ -585,8 +585,8 @@ void MaxEggPlugin::DoExport() { } else { _stprintf(cmdLine, _T("pview \"%s\""), eggList[i]->_file_name); } - CreateProcess(NULL, cmdLine, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, - NULL, NULL, &si, &pi); + CreateProcess(nullptr, cmdLine, nullptr, nullptr, FALSE, CREATE_NEW_CONSOLE, + nullptr, nullptr, &si, &pi); pviewed += 1; } } @@ -634,10 +634,10 @@ int MaxEggPluginCreateMouseCallBack::proc(ViewExp *vpt,int msg, int point, int f if (msg==MOUSE_POINT||msg==MOUSE_MOVE) { switch(point) { case 0: - mat.SetTrans(vpt->SnapPoint(m,m,NULL,SNAP_IN_PLANE)); + mat.SetTrans(vpt->SnapPoint(m,m,nullptr,SNAP_IN_PLANE)); break; case 1: - mat.SetTrans(vpt->SnapPoint(m,m,NULL,SNAP_IN_PLANE)); + mat.SetTrans(vpt->SnapPoint(m,m,nullptr,SNAP_IN_PLANE)); if (msg==MOUSE_POINT) return CREATE_STOP; break; } @@ -718,7 +718,7 @@ int MaxEggPlugin::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) gw->setColor( LINE_COLOR, GetSelColor()); else if(!inode->IsFrozen()) gw->setColor( LINE_COLOR, GetUIColor(COLOR_TAPE_OBJ)); - mesh.render( gw, mtl, NULL, COMP_ALL); + mesh.render( gw, mtl, nullptr, COMP_ALL); return 0; } @@ -838,7 +838,7 @@ __declspec( dllexport ) ClassDesc* LibClassDesc(int i) { switch(i) { case 0: return GetMaxEggPluginDesc(); - default: return NULL; + default: return nullptr; } } @@ -855,6 +855,6 @@ TCHAR *GetString(int id) static TCHAR buf[256]; if (hInstance) - return LoadString(hInstance, id, buf, sizeof(buf)) ? buf : NULL; - return NULL; + return LoadString(hInstance, id, buf, sizeof(buf)) ? buf : nullptr; + return nullptr; } diff --git a/pandatool/src/maxegg/maxEgg.h b/pandatool/src/maxegg/maxEgg.h index d10d449a0f..88ae826490 100644 --- a/pandatool/src/maxegg/maxEgg.h +++ b/pandatool/src/maxegg/maxEgg.h @@ -119,7 +119,7 @@ class MaxEggPlugin : public HelperObject void AddEgg(MaxOptionsDialog *newEgg); void RemoveEgg(int i); - MaxOptionsDialog *GetEgg(int i) { return (i >= 0 && i < numEggs) ? eggList[i] : NULL; } + MaxOptionsDialog *GetEgg(int i) { return (i >= 0 && i < numEggs) ? eggList[i] : nullptr; } // Required implimented virtual methods: inherited virtual methods for // Reference-management diff --git a/pandatool/src/maxegg/maxEggLoader.cxx b/pandatool/src/maxegg/maxEggLoader.cxx index ba4c705965..e2747e6dd0 100644 --- a/pandatool/src/maxegg/maxEggLoader.cxx +++ b/pandatool/src/maxegg/maxEggLoader.cxx @@ -637,7 +637,7 @@ bool MaxEggLoader::ConvertEggData(EggData *data, bool merge, bool model, bool an AnimateOff(); _next_tex = 0; - TraverseEggNode(data, NULL); + TraverseEggNode(data, nullptr); for (ci = _mesh_tab.begin(); ci != _mesh_tab.end(); ++ci) { MaxEggMesh *mesh = (*ci); diff --git a/pandatool/src/maxegg/maxNodeDesc.cxx b/pandatool/src/maxegg/maxNodeDesc.cxx index 57a9d7385f..7e0ed3d964 100644 --- a/pandatool/src/maxegg/maxNodeDesc.cxx +++ b/pandatool/src/maxegg/maxNodeDesc.cxx @@ -23,7 +23,7 @@ MaxNodeDesc:: MaxNodeDesc(MaxNodeDesc *parent, INode *max_node) : _parent(parent) { - if (max_node != NULL) { + if (max_node != nullptr) { const TCHAR *max_name = max_node->GetName(); #ifdef _UNICODE char name_mb [1024]; @@ -35,15 +35,15 @@ MaxNodeDesc(MaxNodeDesc *parent, INode *max_node) : #endif } - _max_node = (INode *)NULL; - _egg_group = (EggGroup *)NULL; - _egg_table = (EggTable *)NULL; - _anim = (EggXfmSAnim *)NULL; + _max_node = nullptr; + _egg_group = nullptr; + _egg_table = nullptr; + _anim = nullptr; _joint_type = JT_none; - _joint_entry = NULL; + _joint_entry = nullptr; // Add ourselves to our parent. - if (_parent != (MaxNodeDesc *)NULL) { + if (_parent != nullptr) { _parent->_children.push_back(this); } } @@ -59,7 +59,7 @@ MaxNodeDesc:: */ void MaxNodeDesc:: from_INode(INode *max_node) { - if (_max_node == (INode *)NULL) { + if (_max_node == nullptr) { _max_node = max_node; // This is how I decided to check to see if this max node is a joint. It @@ -78,7 +78,7 @@ from_INode(INode *max_node) { // This node is a joint. _joint_type = JT_node_joint; - if (_parent != (MaxNodeDesc *)NULL) { + if (_parent != nullptr) { _parent->mark_joint_parent(); } } @@ -91,7 +91,7 @@ from_INode(INode *max_node) { */ bool MaxNodeDesc:: has_max_node() const { - return (_max_node != (INode *)NULL); + return (_max_node != nullptr); } /** @@ -100,7 +100,7 @@ has_max_node() const { */ INode *MaxNodeDesc:: get_max_node() const { - nassertr(_max_node != (INode *)NULL, _max_node); + nassertr(_max_node != nullptr, _max_node); return _max_node; } @@ -142,9 +142,9 @@ is_node_joint() const { */ void MaxNodeDesc:: clear_egg() { - _egg_group = (EggGroup *)NULL; - _egg_table = (EggTable *)NULL; - _anim = (EggXfmSAnim *)NULL; + _egg_group = nullptr; + _egg_table = nullptr; + _anim = nullptr; Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { @@ -161,7 +161,7 @@ void MaxNodeDesc:: mark_joint_parent() { if (_joint_type == JT_none) { _joint_type = JT_joint_parent; - if (_parent != (MaxNodeDesc *)NULL) { + if (_parent != nullptr) { _parent->mark_joint_parent(); } } diff --git a/pandatool/src/maxegg/maxNodeDesc.h b/pandatool/src/maxegg/maxNodeDesc.h index 42bb1f4acc..3b45fe0793 100644 --- a/pandatool/src/maxegg/maxNodeDesc.h +++ b/pandatool/src/maxegg/maxNodeDesc.h @@ -21,7 +21,7 @@ */ class MaxNodeDesc : public ReferenceCount, public Namable { public: - MaxNodeDesc(MaxNodeDesc *parent = NULL, INode *max_node = NULL); + MaxNodeDesc(MaxNodeDesc *parent = nullptr, INode *max_node = nullptr); ~MaxNodeDesc(); void from_INode(INode *max_node); diff --git a/pandatool/src/maxegg/maxNodeTree.cxx b/pandatool/src/maxegg/maxNodeTree.cxx index 58f980c281..bb52b887f1 100644 --- a/pandatool/src/maxegg/maxNodeTree.cxx +++ b/pandatool/src/maxegg/maxNodeTree.cxx @@ -21,9 +21,9 @@ MaxNodeTree() { _root = new MaxNodeDesc; _fps = 0.0; _export_mesh = false; - _egg_data = (EggData *)NULL; - _egg_root = (EggGroupNode *)NULL; - _skeleton_node = (EggGroupNode *)NULL; + _egg_data = nullptr; + _egg_root = nullptr; + _skeleton_node = nullptr; } /** @@ -88,7 +88,7 @@ bool MaxNodeTree:: build_complete_hierarchy(INode *root, ULONG *selection_list, int len) { // Get the entire Max scene. - if (root == NULL) { + if (root == nullptr) { // *** Log an error return false; } @@ -117,7 +117,7 @@ get_num_nodes() const { */ MaxNodeDesc *MaxNodeTree:: get_node(int n) const { - nassertr(n >= 0 && n < (int)_nodes.size(), NULL); + nassertr(n >= 0 && n < (int)_nodes.size(), nullptr); return _nodes[n]; } @@ -140,13 +140,13 @@ clear_egg(EggData *egg_data, EggGroupNode *egg_root, */ EggGroup *MaxNodeTree:: get_egg_group(MaxNodeDesc *node_desc) { - nassertr(_egg_root != (EggGroupNode *)NULL, NULL); + nassertr(_egg_root != nullptr, nullptr); - if (node_desc->_egg_group == (EggGroup *)NULL) { + if (node_desc->_egg_group == nullptr) { // We need to make a new group node. EggGroup *egg_group; - nassertr(node_desc->_parent != (MaxNodeDesc *)NULL, NULL); + nassertr(node_desc->_parent != nullptr, nullptr); egg_group = new EggGroup(node_desc->get_name()); if (node_desc->is_joint()) { egg_group->set_group_type(EggGroup::GT_joint); @@ -186,12 +186,12 @@ get_egg_group(MaxNodeDesc *node_desc) { */ EggTable *MaxNodeTree:: get_egg_table(MaxNodeDesc *node_desc) { - nassertr(_skeleton_node != (EggGroupNode *)NULL, NULL); - nassertr(node_desc->is_joint(), NULL); + nassertr(_skeleton_node != nullptr, nullptr); + nassertr(node_desc->is_joint(), nullptr); - if (node_desc->_egg_table == (EggTable *)NULL) { + if (node_desc->_egg_table == nullptr) { // We need to make a new table node. - nassertr(node_desc->_parent != (MaxNodeDesc *)NULL, NULL); + nassertr(node_desc->_parent != nullptr, nullptr); EggTable *egg_table = new EggTable(node_desc->get_name()); node_desc->_anim = new EggXfmSAnim("xform", @@ -256,7 +256,7 @@ r_build_node(INode* max_node) { INode *parent_node; if (max_node->IsRootNode()) { - parent_node = NULL; + parent_node = nullptr; } else { parent_node = max_node->GetParentNode(); } @@ -309,7 +309,7 @@ find_node(INode* max_node) { return (*ni).second; } - return NULL; + return nullptr; } /** diff --git a/pandatool/src/maxegg/maxOptionsDialog.cxx b/pandatool/src/maxegg/maxOptionsDialog.cxx index 556b1a0888..22bfc6b1bc 100644 --- a/pandatool/src/maxegg/maxOptionsDialog.cxx +++ b/pandatool/src/maxegg/maxOptionsDialog.cxx @@ -245,7 +245,7 @@ void RemoveNodeCB::proc(INodeTab &nodeTab) { } MaxEggOptions::MaxEggOptions() { - _max_interface = NULL; + _max_interface = nullptr; _anim_type = MaxEggOptions::AT_model; _start_frame = INT_MIN; _end_frame = INT_MIN; @@ -593,7 +593,7 @@ bool MaxOptionsDialog::UpdateFromUI(HWND hWnd) { _stprintf(_short_name, _T("%.*s..."), sizeof(_short_name)-4, temp); else { _tcscpy(_short_name, temp); - _short_name[_tcslen(_short_name) - 4] = NULL; //Cut off the .egg + _short_name[_tcslen(_short_name) - 4] = nullptr; //Cut off the .egg } _start_frame = newSF; diff --git a/pandatool/src/maxegg/maxToEggConverter.cxx b/pandatool/src/maxegg/maxToEggConverter.cxx index 6e79178fc5..85b909a6e2 100644 --- a/pandatool/src/maxegg/maxToEggConverter.cxx +++ b/pandatool/src/maxegg/maxToEggConverter.cxx @@ -51,7 +51,7 @@ void MaxToEggConverter::reset() { _cur_tref = 0; _current_frame = 0; _textures.clear(); - _egg_data = NULL; + _egg_data = nullptr; } /** @@ -103,7 +103,7 @@ bool MaxToEggConverter::convert(MaxEggOptions *options) { if (_options->_export_whole_scene) { _tree._export_mesh = false; - all_ok = _tree.build_complete_hierarchy(_options->_max_interface->GetRootNode(), NULL, 0); + all_ok = _tree.build_complete_hierarchy(_options->_max_interface->GetRootNode(), nullptr, 0); } else { _tree._export_mesh = true; all_ok = _tree.build_complete_hierarchy(_options->_max_interface->GetRootNode(), &_options->_node_list.front(), _options->_node_list.size()); @@ -211,7 +211,7 @@ convert_char_chan(double start_frame, double end_frame, double frame_inc, // Set the frame rate before we start asking for anim tables to be // created. _tree._fps = output_frame_rate / frame_inc; - _tree.clear_egg(_egg_data, NULL, skeleton_node); + _tree.clear_egg(_egg_data, nullptr, skeleton_node); // Now we can get the animation data by walking through all of the frames, // one at a time, and getting the joint angles at each frame. @@ -241,7 +241,7 @@ convert_char_chan(double start_frame, double end_frame, double frame_inc, get_joint_transform(max_node, node_desc->_parent->get_max_node(), tgroup); } else { - get_joint_transform(max_node, NULL, tgroup); + get_joint_transform(max_node, nullptr, tgroup); } EggXfmSAnim *anim = _tree.get_egg_anim(node_desc); @@ -275,7 +275,7 @@ bool MaxToEggConverter:: convert_hierarchy(EggGroupNode *egg_root) { // int num_nodes = _tree.get_num_nodes(); - _tree.clear_egg(_egg_data, egg_root, NULL); + _tree.clear_egg(_egg_data, egg_root, nullptr); for (int i = 0; i < _tree.get_num_nodes(); i++) { if (!process_model_node(_tree.get_node(i))) { return false; @@ -316,7 +316,7 @@ process_model_node(MaxNodeDesc *node_desc) { } } else { if (state.obj) { - EggGroup *egg_group = NULL; + EggGroup *egg_group = nullptr; TriObject *myMaxTriObject; Mesh max_mesh; // Call the correct exporter based on what type of object this is. @@ -885,7 +885,7 @@ get_vertex_weights(INode *max_node, EggVertexPool *vpool) { MaxNodeDesc *joint_node_desc = _tree.find_joint(bone_node); if (joint_node_desc){ EggGroup *joint = _tree.get_egg_group(joint_node_desc); - if (joint != (EggGroup *)NULL) + if (joint != nullptr) joint->ref_vertex(vert, 1.0f); } } @@ -900,7 +900,7 @@ get_vertex_weights(INode *max_node, EggVertexPool *vpool) { MaxNodeDesc *joint_node_desc = _tree.find_joint(bone_node); if (joint_node_desc){ EggGroup *joint = _tree.get_egg_group(joint_node_desc); - if (joint != (EggGroup *)NULL) + if (joint != nullptr) joint->ref_vertex(vert, weight); } } @@ -936,7 +936,7 @@ get_vertex_weights(INode *max_node, EggVertexPool *vpool) { MaxNodeDesc *joint_node_desc = _tree.find_joint(bone_node); if (joint_node_desc){ EggGroup *joint = _tree.get_egg_group(joint_node_desc); - if (joint != (EggGroup *)NULL) { + if (joint != nullptr) { joint->ref_vertex(vert, weight); } } @@ -1322,7 +1322,7 @@ reparent_decals(EggGroupNode *egg_parent) { // First, walk through all children of this node, looking for the one // decal base, if any. - EggGroup *decal_base = (EggGroup *)NULL; + EggGroup *decal_base = nullptr; pvector decal_children; EggGroupNode::iterator ci; @@ -1331,7 +1331,7 @@ reparent_decals(EggGroupNode *egg_parent) { if (child->is_of_type(EggGroup::get_class_type())) { EggGroup *child_group = (EggGroup *) child; if (child_group->has_object_type("decalbase")) { - if (decal_base != (EggNode *)NULL) { + if (decal_base != nullptr) { // error okflag = false; } @@ -1345,7 +1345,7 @@ reparent_decals(EggGroupNode *egg_parent) { } } - if (decal_base == (EggGroup *)NULL) { + if (decal_base == nullptr) { if (!decal_children.empty()) { // warning } @@ -1388,7 +1388,7 @@ Modifier* MaxToEggConverter::FindSkinModifier (INode* node, const Class_ID &type { // Get object from node. Abort if no object. Object* pObj = node->GetObjectRef(); - if (!pObj) return NULL; + if (!pObj) return nullptr; // Is derived object ? while (pObj->SuperClassID() == GEN_DERIVOB_CLASS_ID) { @@ -1410,5 +1410,5 @@ Modifier* MaxToEggConverter::FindSkinModifier (INode* node, const Class_ID &type } // Not found. - return NULL; + return nullptr; } diff --git a/pandatool/src/maxegg/maxToEggConverter.h b/pandatool/src/maxegg/maxToEggConverter.h index 0225565843..fc2ed1843f 100644 --- a/pandatool/src/maxegg/maxToEggConverter.h +++ b/pandatool/src/maxegg/maxToEggConverter.h @@ -81,7 +81,7 @@ class MaxToEggConverter { void make_polyset(INode *max_node, Mesh *mesh, EggGroup *egg_group, - Shader *default_shader = NULL); + Shader *default_shader = nullptr); Point3 get_max_vertex_normal(Mesh *mesh, int faceNo, int vertNo); VertColor get_max_vertex_color(Mesh *mesh, int FaceNo, int VertexNo); diff --git a/pandatool/src/maxprogs/maxEggImport.cxx b/pandatool/src/maxprogs/maxEggImport.cxx index 8565a612b4..717b877122 100644 --- a/pandatool/src/maxprogs/maxEggImport.cxx +++ b/pandatool/src/maxprogs/maxEggImport.cxx @@ -200,12 +200,12 @@ DoImport(const TCHAR *name, ImpInterface *ii, Interface *i, BOOL suppressPrompts string txt = log.str(); if (txt != "") { - MessageBoxA(NULL, txt.c_str(), "Panda3D Importer", MB_OK); + MessageBoxA(nullptr, txt.c_str(), "Panda3D Importer", MB_OK); } else if (!ok) { - MessageBoxA(NULL, "Import Failed, unknown reason\n", "Panda3D Importer", MB_OK); + MessageBoxA(nullptr, "Import Failed, unknown reason\n", "Panda3D Importer", MB_OK); } - Notify::ptr()->set_ostream_ptr(NULL, false); + Notify::ptr()->set_ostream_ptr(nullptr, false); return 1; } diff --git a/pandatool/src/maya/mayaApi.cxx b/pandatool/src/maya/mayaApi.cxx index 015ce7d4c6..8ec5f9e479 100644 --- a/pandatool/src/maya/mayaApi.cxx +++ b/pandatool/src/maya/mayaApi.cxx @@ -29,7 +29,7 @@ #include // for chdir() #endif -MayaApi *MayaApi::_global_api = (MayaApi *)NULL; +MayaApi *MayaApi::_global_api = nullptr; // We need this bogus object just to force the application to link with // OpenMayaAnim.lib; otherwise, Maya will complain (when compiled on Windows) @@ -125,7 +125,7 @@ MayaApi:: // Maya code. MLibrary::cleanup(); } - _global_api = (MayaApi *)NULL; + _global_api = nullptr; } /** @@ -141,7 +141,7 @@ MayaApi:: */ PT(MayaApi) MayaApi:: open_api(string program_name, bool view_license, bool revertdir) { - if (_global_api == (MayaApi *)NULL) { + if (_global_api == nullptr) { // We need to create a new MayaApi object. if (program_name.empty()) { program_name = ExecutionEnvironment::get_binary_name(); diff --git a/pandatool/src/maya/mayaShader.cxx b/pandatool/src/maya/mayaShader.cxx index f012539b81..78484d0be3 100644 --- a/pandatool/src/maya/mayaShader.cxx +++ b/pandatool/src/maya/mayaShader.cxx @@ -113,7 +113,7 @@ get_color_def(size_t idx) const { if (_color.size() > 0) return _color[idx]; else - return (MayaShaderColorDef *)NULL; + return nullptr; } /** * Returns the overall color of the shader as a single-precision rgba value, diff --git a/pandatool/src/maya/mayaShaderColorDef.cxx b/pandatool/src/maya/mayaShaderColorDef.cxx index ede0bbf0d5..69aa0cd85e 100644 --- a/pandatool/src/maya/mayaShaderColorDef.cxx +++ b/pandatool/src/maya/mayaShaderColorDef.cxx @@ -63,7 +63,7 @@ MayaShaderColorDef() { _opposite = 0; - _color_object = (MObject *)NULL; + _color_object = nullptr; _has_texture = false; _has_flat_color = false; @@ -74,7 +74,7 @@ MayaShaderColorDef() { _interpolate = false; _uvset_name = "map1"; - _map_uvs = NULL; + _map_uvs = nullptr; } /** @@ -128,7 +128,7 @@ MayaShaderColorDef(MayaShaderColorDef ©) { */ MayaShaderColorDef:: ~MayaShaderColorDef() { - if (_color_object != (MObject *)NULL) { + if (_color_object != nullptr) { delete _color_object; } } @@ -169,7 +169,7 @@ has_projection() const { */ LTexCoordd MayaShaderColorDef:: project_uv(const LPoint3d &pos, const LPoint3d ¢roid) const { - nassertr(_map_uvs != NULL, LTexCoordd::zero()); + nassertr(_map_uvs != nullptr, LTexCoordd::zero()); return (this->*_map_uvs)(pos * _projection_matrix, centroid * _projection_matrix); } @@ -205,7 +205,7 @@ write(ostream &out) const { */ bool MayaShaderColorDef:: reset_maya_texture(const Filename &texture) { - if (_color_object != (MObject *)NULL) { + if (_color_object != nullptr) { _has_texture = set_string_attribute(*_color_object, "fileTextureName", texture.to_os_generic()); _texture_filename = texture; @@ -686,7 +686,7 @@ set_projection_type(const string &type) { maya_cat.error() << "Don't know how to handle type " << type << " projections.\n"; _projection_type = PT_off; - _map_uvs = NULL; + _map_uvs = nullptr; } } diff --git a/pandatool/src/maya/mayaShaders.cxx b/pandatool/src/maya/mayaShaders.cxx index a100ad8a4e..7aecbd3d61 100644 --- a/pandatool/src/maya/mayaShaders.cxx +++ b/pandatool/src/maya/mayaShaders.cxx @@ -55,7 +55,7 @@ find_shader_for_node(MObject node, bool legacy_shader) { // The node is not renderable. What are you thinking? maya_cat.error() << node_fn.name().asChar() << " : not a renderable object.\n"; - return (MayaShader *)NULL; + return nullptr; } // instObjGroups is a multi attribute, whatever that means. For now, we'll @@ -69,7 +69,7 @@ find_shader_for_node(MObject node, bool legacy_shader) { // No shading group defined for this object. maya_cat.error() << node_fn.name().asChar() << " : no shading group defined.\n"; - return (MayaShader *)NULL; + return nullptr; } // Now we have a number of ShadingEngines defined, one for each of these @@ -87,7 +87,7 @@ find_shader_for_node(MObject node, bool legacy_shader) { // Well, we didn't find a ShadingEngine after all. Huh. maya_cat.debug() << node_fn.name().asChar() << " : no shading engine found.\n"; - return (MayaShader *)NULL; + return nullptr; } /** @@ -175,7 +175,7 @@ get_num_shaders() const { */ MayaShader *MayaShaders:: get_shader(int n) const { - nassertr(n >= 0 && n < (int)_shaders_in_order.size(), NULL); + nassertr(n >= 0 && n < (int)_shaders_in_order.size(), nullptr); return _shaders_in_order[n]; } diff --git a/pandatool/src/mayaegg/mayaBlendDesc.cxx b/pandatool/src/mayaegg/mayaBlendDesc.cxx index c0977dcb3a..c60ecf515a 100644 --- a/pandatool/src/mayaegg/mayaBlendDesc.cxx +++ b/pandatool/src/mayaegg/mayaBlendDesc.cxx @@ -28,7 +28,7 @@ MayaBlendDesc(MFnBlendShapeDeformer &deformer, int weight_index) : strm << _deformer.name().asChar() << "." << _weight_index; set_name(strm.str()); - _anim = (EggSAnimData *)NULL; + _anim = nullptr; } /** @@ -65,5 +65,5 @@ get_slider() const { */ void MayaBlendDesc:: clear_egg() { - _anim = (EggSAnimData *)NULL; + _anim = nullptr; } diff --git a/pandatool/src/mayaegg/mayaEggLoader.cxx b/pandatool/src/mayaegg/mayaEggLoader.cxx index 82523d122f..6664e54aa0 100644 --- a/pandatool/src/mayaegg/mayaEggLoader.cxx +++ b/pandatool/src/mayaegg/mayaEggLoader.cxx @@ -235,7 +235,7 @@ MayaEggTex *MayaEggLoader::GetTex(EggTexture* etex) { string name = ""; string fn = ""; - if (etex != NULL) { + if (etex != nullptr) { name = etex->get_name(); fn = etex->get_fullpath().to_os_specific(); } @@ -293,7 +293,7 @@ MayaEggTex *MayaEggLoader::GetTex(EggTexture* etex) // [gjeon] to create alpha channel connection LoaderOptions options; PT(Texture) tex = TexturePool::load_texture(etex->get_fullpath(), 0, false, options); - if (((tex != NULL) && (tex->get_num_components() == 4)) + if (((tex != nullptr) && (tex->get_num_components() == 4)) || (etex->get_format() == EggTexture::F_alpha) || (etex->get_format() == EggTexture::F_luminance_alpha)) dgmod.connect(filetex.findPlug("outTransparency"),shader.findPlug("transparency")); @@ -452,7 +452,7 @@ void MayaEggJoint::AssignNames(void) MayaEggJoint *MayaEggLoader::FindJoint(EggGroup *joint) { - if (joint==(EggGroup *)NULL) { + if (joint==nullptr) { if (mayaloader_cat.is_spam()) { mayaloader_cat.spam() << "joint:" << joint->get_name() << " is null: " << endl; } @@ -1286,7 +1286,7 @@ void MayaEggLoader::CreateSkinCluster(MayaEggGeom *M) perror("skinCluster index"); return; } - skinCluster.setWeights(M->_shape_dag_path, component.object(), index, 0.0, false, NULL); + skinCluster.setWeights(M->_shape_dag_path, component.object(), index, 0.0, false, nullptr); } MFloatArray values; @@ -1302,7 +1302,7 @@ void MayaEggLoader::CreateSkinCluster(MayaEggGeom *M) values[vert->_index * joints.size() + joint->_index] = (PN_stdfloat)strength; } } - skinCluster.setWeights(M->_shape_dag_path, component.object(), influenceIndices, values, false, NULL); + skinCluster.setWeights(M->_shape_dag_path, component.object(), influenceIndices, values, false, nullptr); for (unsigned int i=0; ihas_transform()) uvtrans = etex->get_transform2d(); } else { - tex = GetTex(NULL); + tex = GetTex(nullptr); } EggPolygon::const_iterator ci; @@ -1451,7 +1451,7 @@ void MayaEggLoader::TraverseEggNode(EggNode *node, EggGroup *context, string del uvtrans = etex->get_transform2d(); } } else { - tex = GetTex(NULL); + tex = GetTex(nullptr); } surface->_tex = tex; @@ -1614,7 +1614,7 @@ bool MayaEggLoader::ConvertEggData(EggData *data, bool merge, bool model, bool a if (mayaloader_cat.is_debug()) { mayaloader_cat.debug() << "root node: " << data->get_type() << endl; } - TraverseEggNode(data, NULL, ""); + TraverseEggNode(data, nullptr, ""); MStatus status; @@ -1886,15 +1886,15 @@ bool MayaEggLoader::ConvertEggData(EggData *data, bool merge, bool model, bool a MFnAnimCurve mfnAnimCurveSY; MFnAnimCurve mfnAnimCurveSZ; - mfnAnimCurveTX.create(node, attrTX, MFnAnimCurve::kAnimCurveTL, NULL, &status); - mfnAnimCurveTY.create(node, attrTY, MFnAnimCurve::kAnimCurveTL, NULL, &status); - mfnAnimCurveTZ.create(node, attrTZ, MFnAnimCurve::kAnimCurveTL, NULL, &status); - mfnAnimCurveRX.create(node, attrRX, MFnAnimCurve::kAnimCurveTA, NULL, &status); - mfnAnimCurveRY.create(node, attrRY, MFnAnimCurve::kAnimCurveTA, NULL, &status); - mfnAnimCurveRZ.create(node, attrRZ, MFnAnimCurve::kAnimCurveTA, NULL, &status); - mfnAnimCurveSX.create(node, attrSX, MFnAnimCurve::kAnimCurveTU, NULL, &status); - mfnAnimCurveSY.create(node, attrSY, MFnAnimCurve::kAnimCurveTU, NULL, &status); - mfnAnimCurveSZ.create(node, attrSZ, MFnAnimCurve::kAnimCurveTU, NULL, &status); + mfnAnimCurveTX.create(node, attrTX, MFnAnimCurve::kAnimCurveTL, nullptr, &status); + mfnAnimCurveTY.create(node, attrTY, MFnAnimCurve::kAnimCurveTL, nullptr, &status); + mfnAnimCurveTZ.create(node, attrTZ, MFnAnimCurve::kAnimCurveTL, nullptr, &status); + mfnAnimCurveRX.create(node, attrRX, MFnAnimCurve::kAnimCurveTA, nullptr, &status); + mfnAnimCurveRY.create(node, attrRY, MFnAnimCurve::kAnimCurveTA, nullptr, &status); + mfnAnimCurveRZ.create(node, attrRZ, MFnAnimCurve::kAnimCurveTA, nullptr, &status); + mfnAnimCurveSX.create(node, attrSX, MFnAnimCurve::kAnimCurveTU, nullptr, &status); + mfnAnimCurveSY.create(node, attrSY, MFnAnimCurve::kAnimCurveTU, nullptr, &status); + mfnAnimCurveSZ.create(node, attrSZ, MFnAnimCurve::kAnimCurveTU, nullptr, &status); MTransformationMatrix matrix( mMat ); MVector trans = matrix.translation(MSpace::kTransform, &status); @@ -1908,15 +1908,15 @@ bool MayaEggLoader::ConvertEggData(EggData *data, bool merge, bool model, bool a MFnAnimCurve::TangentType tangent = MFnAnimCurve::kTangentClamped; MTime time(_start_frame - 1, _timeUnit); - mfnAnimCurveTX.addKey(time, trans.x, tangent, tangent, NULL, &status); - mfnAnimCurveTY.addKey(time, trans.y, tangent, tangent, NULL, &status); - mfnAnimCurveTZ.addKey(time, trans.z, tangent, tangent, NULL, &status); - mfnAnimCurveRX.addKey(time, rot[0], tangent, tangent, NULL, &status); - mfnAnimCurveRY.addKey(time, rot[1], tangent, tangent, NULL, &status); - mfnAnimCurveRZ.addKey(time, rot[2], tangent, tangent, NULL, &status); - mfnAnimCurveSX.addKey(time, scale[0], tangent, tangent, NULL, &status); - mfnAnimCurveSY.addKey(time, scale[1], tangent, tangent, NULL, &status); - mfnAnimCurveSZ.addKey(time, scale[2], tangent, tangent, NULL, &status); + mfnAnimCurveTX.addKey(time, trans.x, tangent, tangent, nullptr, &status); + mfnAnimCurveTY.addKey(time, trans.y, tangent, tangent, nullptr, &status); + mfnAnimCurveTZ.addKey(time, trans.z, tangent, tangent, nullptr, &status); + mfnAnimCurveRX.addKey(time, rot[0], tangent, tangent, nullptr, &status); + mfnAnimCurveRY.addKey(time, rot[1], tangent, tangent, nullptr, &status); + mfnAnimCurveRZ.addKey(time, rot[2], tangent, tangent, nullptr, &status); + mfnAnimCurveSX.addKey(time, scale[0], tangent, tangent, nullptr, &status); + mfnAnimCurveSY.addKey(time, scale[1], tangent, tangent, nullptr, &status); + mfnAnimCurveSZ.addKey(time, scale[2], tangent, tangent, nullptr, &status); for (int frame = 0; frame < anim->_pool->get_num_rows(); frame++) { @@ -1935,15 +1935,15 @@ bool MayaEggLoader::ConvertEggData(EggData *data, bool merge, bool model, bool a status = matrix.getScale(scale, MSpace::kTransform); time = MTime(frame + _start_frame, _timeUnit); - mfnAnimCurveTX.addKey(time, trans.x, tangent, tangent, NULL, &status); - mfnAnimCurveTY.addKey(time, trans.y, tangent, tangent, NULL, &status); - mfnAnimCurveTZ.addKey(time, trans.z, tangent, tangent, NULL, &status); - mfnAnimCurveRX.addKey(time, rot[0], tangent, tangent, NULL, &status); - mfnAnimCurveRY.addKey(time, rot[1], tangent, tangent, NULL, &status); - mfnAnimCurveRZ.addKey(time, rot[2], tangent, tangent, NULL, &status); - mfnAnimCurveSX.addKey(time, scale[0], tangent, tangent, NULL, &status); - mfnAnimCurveSY.addKey(time, scale[1], tangent, tangent, NULL, &status); - mfnAnimCurveSZ.addKey(time, scale[2], tangent, tangent, NULL, &status); + mfnAnimCurveTX.addKey(time, trans.x, tangent, tangent, nullptr, &status); + mfnAnimCurveTY.addKey(time, trans.y, tangent, tangent, nullptr, &status); + mfnAnimCurveTZ.addKey(time, trans.z, tangent, tangent, nullptr, &status); + mfnAnimCurveRX.addKey(time, rot[0], tangent, tangent, nullptr, &status); + mfnAnimCurveRY.addKey(time, rot[1], tangent, tangent, nullptr, &status); + mfnAnimCurveRZ.addKey(time, rot[2], tangent, tangent, nullptr, &status); + mfnAnimCurveSX.addKey(time, scale[0], tangent, tangent, nullptr, &status); + mfnAnimCurveSY.addKey(time, scale[1], tangent, tangent, nullptr, &status); + mfnAnimCurveSZ.addKey(time, scale[2], tangent, tangent, nullptr, &status); } if (maxFrame < time) { maxFrame = time; diff --git a/pandatool/src/mayaegg/mayaNodeDesc.cxx b/pandatool/src/mayaegg/mayaNodeDesc.cxx index efef4879a8..9049bf2dc8 100644 --- a/pandatool/src/mayaegg/mayaNodeDesc.cxx +++ b/pandatool/src/mayaegg/mayaNodeDesc.cxx @@ -50,17 +50,17 @@ MayaNodeDesc(MayaNodeTree *tree, MayaNodeDesc *parent, const string &name) : _tree(tree), _parent(parent) { - _dag_path = (MDagPath *)NULL; - _egg_group = (EggGroup *)NULL; - _egg_table = (EggTable *)NULL; - _anim = (EggXfmSAnim *)NULL; + _dag_path = nullptr; + _egg_group = nullptr; + _egg_table = nullptr; + _anim = nullptr; _joint_type = JT_none; _is_lod = false; _tagged = false; _joint_tagged = false; // Add ourselves to our parent. - if (_parent != (MayaNodeDesc *)NULL) { + if (_parent != nullptr) { _parent->_children.push_back(this); } } @@ -70,7 +70,7 @@ MayaNodeDesc(MayaNodeTree *tree, MayaNodeDesc *parent, const string &name) : */ MayaNodeDesc:: ~MayaNodeDesc() { - if (_dag_path != (MDagPath *)NULL) { + if (_dag_path != nullptr) { delete _dag_path; } } @@ -82,7 +82,7 @@ void MayaNodeDesc:: from_dag_path(const MDagPath &dag_path, MayaToEggConverter *converter) { MStatus status; - if (_dag_path == (MDagPath *)NULL) { + if (_dag_path == nullptr) { _dag_path = new MDagPath(dag_path); string name; @@ -97,7 +97,7 @@ from_dag_path(const MDagPath &dag_path, MayaToEggConverter *converter) { // This node is a joint, or the user specifically asked to treat it like // a joint. _joint_type = JT_joint; - if (_parent != (MayaNodeDesc *)NULL) { + if (_parent != nullptr) { _parent->mark_joint_parent(); } @@ -120,7 +120,7 @@ from_dag_path(const MDagPath &dag_path, MayaToEggConverter *converter) { if (transform_connected) { _joint_type = JT_joint; - if (_parent != (MayaNodeDesc *)NULL) { + if (_parent != nullptr) { _parent->mark_joint_parent(); } } @@ -146,7 +146,7 @@ from_dag_path(const MDagPath &dag_path, MayaToEggConverter *converter) { */ bool MayaNodeDesc:: has_dag_path() const { - return (_dag_path != (MDagPath *)NULL); + return (_dag_path != nullptr); } /** @@ -155,7 +155,7 @@ has_dag_path() const { */ const MDagPath &MayaNodeDesc:: get_dag_path() const { - nassertr(_dag_path != (MDagPath *)NULL, *_dag_path); + nassertr(_dag_path != nullptr, *_dag_path); return *_dag_path; } @@ -174,7 +174,7 @@ get_num_blend_descs() const { */ MayaBlendDesc *MayaNodeDesc:: get_blend_desc(int n) const { - nassertr(n >= 0 && n < (int)_blend_descs.size(), NULL); + nassertr(n >= 0 && n < (int)_blend_descs.size(), nullptr); return _blend_descs[n]; } @@ -286,11 +286,11 @@ untag_recursively() { bool MayaNodeDesc:: has_object_type(string object_type) const { bool ret = false; - if ((_egg_group != (EggGroup*) NULL) + if ((_egg_group != nullptr) && _egg_group->has_object_type(object_type)) { return true; } - if (_parent != (MayaNodeDesc *)NULL) { + if (_parent != nullptr) { ret |= _parent->has_object_type(object_type); } return ret; @@ -301,9 +301,9 @@ has_object_type(string object_type) const { */ void MayaNodeDesc:: clear_egg() { - _egg_group = (EggGroup *)NULL; - _egg_table = (EggTable *)NULL; - _anim = (EggXfmSAnim *)NULL; + _egg_group = nullptr; + _egg_table = nullptr; + _anim = nullptr; Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { @@ -320,7 +320,7 @@ void MayaNodeDesc:: mark_joint_parent() { if (_joint_type == JT_none) { _joint_type = JT_joint_parent; - if (_parent != (MayaNodeDesc *)NULL) { + if (_parent != nullptr) { _parent->mark_joint_parent(); } } @@ -506,7 +506,7 @@ check_lods() { } // Now consider whether this node is an lodGroup. - if (_dag_path != (MDagPath *)NULL && + if (_dag_path != nullptr && _dag_path->hasFn(MFn::kLodGroup)) { // This node is a parent lodGroup; its children, therefore, are LOD's. MStatus status; diff --git a/pandatool/src/mayaegg/mayaNodeDesc.h b/pandatool/src/mayaegg/mayaNodeDesc.h index 1c28cb1698..bfae4300ce 100644 --- a/pandatool/src/mayaegg/mayaNodeDesc.h +++ b/pandatool/src/mayaegg/mayaNodeDesc.h @@ -40,7 +40,7 @@ class EggXfmSAnim; class MayaNodeDesc : public ReferenceCount, public Namable { public: MayaNodeDesc(MayaNodeTree *tree, - MayaNodeDesc *parent = NULL, const string &name = string()); + MayaNodeDesc *parent = nullptr, const string &name = string()); ~MayaNodeDesc(); void from_dag_path(const MDagPath &dag_path, MayaToEggConverter *converter); diff --git a/pandatool/src/mayaegg/mayaNodeTree.cxx b/pandatool/src/mayaegg/mayaNodeTree.cxx index def22d13b2..32a6281725 100644 --- a/pandatool/src/mayaegg/mayaNodeTree.cxx +++ b/pandatool/src/mayaegg/mayaNodeTree.cxx @@ -41,10 +41,10 @@ MayaNodeTree(MayaToEggConverter *converter) : { _root = new MayaNodeDesc(this); _fps = 0.0; - _egg_data = (EggData *)NULL; - _egg_root = (EggGroupNode *)NULL; - _skeleton_node = (EggGroupNode *)NULL; - _morph_node = (EggGroupNode *)NULL; + _egg_data = nullptr; + _egg_root = nullptr; + _skeleton_node = nullptr; + _morph_node = nullptr; } /** @@ -259,7 +259,7 @@ get_num_nodes() const { */ MayaNodeDesc *MayaNodeTree:: get_node(int n) const { - nassertr(n >= 0 && n < (int)_nodes.size(), NULL); + nassertr(n >= 0 && n < (int)_nodes.size(), nullptr); return _nodes[n]; } @@ -270,10 +270,10 @@ void MayaNodeTree:: clear() { _root = new MayaNodeDesc(this); _fps = 0.0; - _egg_data = (EggData *)NULL; - _egg_root = (EggGroupNode *)NULL; - _skeleton_node = (EggGroupNode *)NULL; - _morph_node = (EggGroupNode *)NULL; + _egg_data = nullptr; + _egg_root = nullptr; + _skeleton_node = nullptr; + _morph_node = nullptr; _nodes_by_path.clear(); _nodes.clear(); } @@ -303,13 +303,13 @@ clear_egg(EggData *egg_data, EggGroupNode *egg_root, */ EggGroup *MayaNodeTree:: get_egg_group(MayaNodeDesc *node_desc) { - nassertr(_egg_root != (EggGroupNode *)NULL, NULL); + nassertr(_egg_root != nullptr, nullptr); - if (node_desc->_egg_group == (EggGroup *)NULL) { + if (node_desc->_egg_group == nullptr) { // We need to make a new group node. EggGroup *egg_group; - nassertr(node_desc->_parent != (MayaNodeDesc *)NULL, NULL); + nassertr(node_desc->_parent != nullptr, nullptr); egg_group = new EggGroup(node_desc->get_name()); if (node_desc->is_joint()) { if (_converter->get_animation_convert() == AC_model || @@ -318,7 +318,7 @@ get_egg_group(MayaNodeDesc *node_desc) { } } - MayaEggGroupUserData *parent_user_data = NULL; + MayaEggGroupUserData *parent_user_data = nullptr; if (node_desc->_parent == _root) { // The parent is the root. @@ -330,7 +330,7 @@ get_egg_group(MayaNodeDesc *node_desc) { parent_egg_group->add_child(egg_group); if (parent_egg_group->has_user_data()) { - DCAST_INTO_R(parent_user_data, parent_egg_group->get_user_data(), NULL); + DCAST_INTO_R(parent_user_data, parent_egg_group->get_user_data(), nullptr); } } @@ -406,7 +406,7 @@ get_egg_group(MayaNodeDesc *node_desc) { // And "vertex-color" and "double-sided" have meaning only to this // converter. MayaEggGroupUserData *user_data; - if (parent_user_data == (MayaEggGroupUserData *)NULL) { + if (parent_user_data == nullptr) { user_data = new MayaEggGroupUserData; } else { // Inherit the flags from above. @@ -443,12 +443,12 @@ get_egg_group(MayaNodeDesc *node_desc) { */ EggTable *MayaNodeTree:: get_egg_table(MayaNodeDesc *node_desc) { - nassertr(_skeleton_node != (EggGroupNode *)NULL, NULL); - nassertr(node_desc->is_joint(), NULL); + nassertr(_skeleton_node != nullptr, nullptr); + nassertr(node_desc->is_joint(), nullptr); - if (node_desc->_egg_table == (EggTable *)NULL) { + if (node_desc->_egg_table == nullptr) { // We need to make a new table node. - nassertr(node_desc->_parent != (MayaNodeDesc *)NULL, NULL); + nassertr(node_desc->_parent != nullptr, nullptr); EggTable *egg_table = new EggTable(node_desc->get_name()); node_desc->_anim = new EggXfmSAnim("xform", _egg_data->get_coordinate_system()); @@ -487,9 +487,9 @@ get_egg_anim(MayaNodeDesc *node_desc) { */ EggSAnimData *MayaNodeTree:: get_egg_slider(MayaBlendDesc *blend_desc) { - nassertr(_morph_node != (EggGroupNode *)NULL, NULL); + nassertr(_morph_node != nullptr, nullptr); - if (blend_desc->_anim == (EggSAnimData *)NULL) { + if (blend_desc->_anim == nullptr) { // We need to make a new anim table. EggSAnimData *egg_anim = new EggSAnimData(blend_desc->get_name()); egg_anim->set_fps(_fps); @@ -553,7 +553,7 @@ get_num_blend_descs() const { */ MayaBlendDesc *MayaNodeTree:: get_blend_desc(int n) const { - nassertr(n >= 0 && n < (int)_blend_descs.size(), NULL); + nassertr(n >= 0 && n < (int)_blend_descs.size(), nullptr); return _blend_descs[n]; } @@ -583,7 +583,7 @@ r_build_node(const string &path) { // Otherwise, we have to create it. Do this recursively, so we create each // node along the path. - MayaNodeDesc *node_desc = NULL; + MayaNodeDesc *node_desc = nullptr; // mayaegg_cat.info() << "path: " << path << endl; if (path.empty()) { @@ -610,7 +610,7 @@ r_build_node(const string &path) { if (node_desc != _root) { MayaNodeDesc *parent_node_desc = r_build_node(parent_path); - if (parent_node_desc == (MayaNodeDesc *)NULL) + if (parent_node_desc == nullptr) mayaegg_cat.info() << "empty parent: " << local_name << endl; node_desc = new MayaNodeDesc(this, parent_node_desc, local_name); _nodes.push_back(node_desc); diff --git a/pandatool/src/mayaegg/mayaToEggConverter.cxx b/pandatool/src/mayaegg/mayaToEggConverter.cxx index ed2a22552b..cefe15e1cc 100644 --- a/pandatool/src/mayaegg/mayaToEggConverter.cxx +++ b/pandatool/src/mayaegg/mayaToEggConverter.cxx @@ -537,7 +537,7 @@ convert_maya() { bool MayaToEggConverter:: open_api(bool revert_directory) { - if (_maya == (MayaApi *)NULL || !_maya->is_valid()) { + if (_maya == nullptr || !_maya->is_valid()) { // maya to egg converter only needs a read license. only egg2maya need // write lisences. _maya = MayaApi::open_api(_program_name, true, revert_directory); @@ -653,7 +653,7 @@ convert_char_chan(double start_frame, double end_frame, double frame_inc, // Set the frame rate before we start asking for anim tables to be created. _tree._fps = output_frame_rate; - _tree.clear_egg(get_egg_data(), NULL, skeleton_node, morph_node); + _tree.clear_egg(get_egg_data(), nullptr, skeleton_node, morph_node); // Now we can get the animation data by walking through all of the frames, // one at a time, and getting the joint angles at each frame. @@ -758,7 +758,7 @@ convert_hierarchy(EggGroupNode *egg_root) { if (_legacy_shader) { mayaegg_cat.info() << "will disable modern Phong shader path. using legacy" << endl; } - _tree.clear_egg(get_egg_data(), egg_root, NULL, NULL); + _tree.clear_egg(get_egg_data(), egg_root, nullptr, nullptr); for (int i = 0; i < num_nodes; i++) { MayaNodeDesc *node = _tree.get_node(i); if (!process_model_node(node)) { @@ -1489,7 +1489,7 @@ make_nurbs_surface(MayaNodeDesc *node_desc, const MDagPath &dag_path, EggNurbsCurve *egg_curve = make_trim_curve(curve, name, egg_group, trim_curve_index); trim_curve_index++; - if (egg_curve != (EggNurbsCurve *)NULL) { + if (egg_curve != nullptr) { egg_loop.push_back(egg_curve); } } @@ -1509,7 +1509,7 @@ make_nurbs_surface(MayaNodeDesc *node_desc, const MDagPath &dag_path, // trim curves have been added. egg_group->add_child(egg_nurbs); - if (shader != (MayaShader *)NULL) { + if (shader != nullptr) { set_shader_attributes(*egg_nurbs, *shader); } @@ -1542,7 +1542,7 @@ make_nurbs_surface(MayaNodeDesc *node_desc, const MDagPath &dag_path, PN_stdfloat weight = weights[maya_vi * num_joints + ji]; if (weight != 0.0f) { EggGroup *joint = joints[ji]; - if (joint != (EggGroup *)NULL) { + if (joint != nullptr) { joint->ref_vertex(vert, weight); } } @@ -1581,13 +1581,13 @@ make_trim_curve(const MFnNurbsCurve &curve, const string &nurbs_name, status = curve.getCVs(cv_array, MSpace::kWorld); if (!status) { status.perror("MFnNurbsCurve::getCVs"); - return (EggNurbsCurve *)NULL; + return nullptr; } MDoubleArray knot_array; status = curve.getKnots(knot_array); if (!status) { status.perror("MFnNurbsCurve::getKnots"); - return (EggNurbsCurve *)NULL; + return nullptr; } /* @@ -1713,7 +1713,7 @@ make_nurbs_curve(const MDagPath &, const MFnNurbsCurve &curve, } } MayaShader *shader = _shaders.find_shader_for_node(curve.object(), _legacy_shader); - if (shader != (MayaShader *)NULL) { + if (shader != nullptr) { set_shader_attributes(*egg_curve, *shader); } } @@ -1838,7 +1838,7 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, // be two diverging paths for any Maya node with a Material (MayaShader) // on it This next bit kicks us out into mayaShader et al. to pull // textures and everything else. - MayaShader *shader = NULL; + MayaShader *shader = nullptr; int index = pi.index(); nassertv(index >= 0 && index < (int)poly_shader_indices.length()); int shader_index = poly_shader_indices[index]; @@ -1850,14 +1850,14 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, _shaders.find_shader_for_shading_engine(engine, _legacy_shader); //head out to the other classes // does this mean if we didn't find a Maya shader give it a default // value anyway? - } else if (default_shader != (MayaShader *)NULL) { + } else if (default_shader != nullptr) { shader = default_shader; } - const MayaShaderColorDef *default_color_def = NULL; + const MayaShaderColorDef *default_color_def = nullptr; // And apply the shader properties to the polygon. - if (shader != (MayaShader *)NULL) { + if (shader != nullptr) { set_shader_attributes(*egg_poly, *shader, true); default_color_def = shader->get_color_def(); } @@ -1874,7 +1874,7 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, // Furthermore, if _always_show_vertex_color is true, we pretend that the // "vertex-color" flag is always set. bool ignore_vertex_color = false; - if ( default_color_def != (MayaShaderColorDef *)NULL) { + if ( default_color_def != nullptr) { ignore_vertex_color = default_color_def->_has_texture && !(egg_vertex_color || _always_show_vertex_color); } @@ -1891,7 +1891,7 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, long i; LPoint3d centroid(0.0, 0.0, 0.0); - if (default_color_def != (MayaShaderColorDef *)NULL && default_color_def->has_projection()) { + if (default_color_def != nullptr && default_color_def->has_projection()) { // If the shader has a projection, we may need to compute the polygon's // centroid to avoid seams at the edges. for (i = 0; i < num_verts; i++) { @@ -1922,7 +1922,7 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, // Go thru all the texture references for this primitive and set uvs if (mayaegg_cat.is_spam()) { - if (shader != (MayaShader *)NULL) { + if (shader != nullptr) { mayaegg_cat.spam() << "shader->_color.size is " << shader->_color.size() << endl; } mayaegg_cat.spam() << "primitive->tref.size is " << egg_poly->get_num_textures() << endl; @@ -1946,7 +1946,7 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, bool project_uv = false; LTexCoordd uv_projection; - if (shader != (MayaShader *)NULL) { + if (shader != nullptr) { for (size_t tj = 0; tj < shader->_all_maps.size(); ++tj) { MayaShaderColorDef *def = shader->_all_maps[tj]; if (def->_uvset_name == uvset_name) { @@ -2082,7 +2082,7 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, PN_stdfloat weight = weights[maya_vi * num_joints + ji]; if (weight != 0.0f) { EggGroup *joint = joints[ji]; - if (joint != (EggGroup *)NULL) { + if (joint != nullptr) { joint->ref_vertex(vert, weight); } } @@ -2614,7 +2614,7 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, // determine if the base texture or any of the top texture need to be rgb // only - MayaShaderColorDef *color_def = NULL; + MayaShaderColorDef *color_def = nullptr; bool is_rgb = false; bool is_decal = false; bool is_interpolate = false; @@ -2644,7 +2644,7 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, is_decal = false; // new decal mode needs an extra dummy layers of textureStage - EggTexture *dummy_tex = (EggTexture *)NULL; + EggTexture *dummy_tex = nullptr; string dummy_uvset_name; // In Maya, a polygon is either textured or colored. The texture, if @@ -2856,7 +2856,7 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, } } } - if (dummy_tex != (EggTexture *)NULL) { + if (dummy_tex != nullptr) { primitive.add_texture(dummy_tex); dummy_tex->set_uv_name(dummy_uvset_name); } @@ -3052,7 +3052,7 @@ reparent_decals(EggGroupNode *egg_parent) { // First, walk through all children of this node, looking for the one decal // base, if any. - EggGroup *decal_base = (EggGroup *)NULL; + EggGroup *decal_base = nullptr; pvector decal_children; EggGroupNode::iterator ci; @@ -3061,7 +3061,7 @@ reparent_decals(EggGroupNode *egg_parent) { if (child->is_of_type(EggGroup::get_class_type())) { EggGroup *child_group = DCAST(EggGroup, child); if (child_group->has_object_type("decalbase")) { - if (decal_base != (EggNode *)NULL) { + if (decal_base != nullptr) { mayaegg_cat.error() << "Two children of " << egg_parent->get_name() << " both have decalbase set: " << decal_base->get_name() @@ -3078,7 +3078,7 @@ reparent_decals(EggGroupNode *egg_parent) { } } - if (decal_base == (EggGroup *)NULL) { + if (decal_base == nullptr) { if (!decal_children.empty()) { mayaegg_cat.warning() << decal_children.front()->get_name() @@ -3146,7 +3146,7 @@ string_transform_type(const string &arg) { */ void MayaToEggConverter:: set_vertex_color(EggVertex &vert, MItMeshPolygon &pi, int vert_index, const MayaShader *shader, const LColor &color) { - if (shader == (MayaShader *)NULL || shader->_legacy_mode) { + if (shader == nullptr || shader->_legacy_mode) { set_vertex_color_legacy(vert, pi, vert_index, shader, color); } else { set_vertex_color_modern(vert, pi, vert_index, shader, color); diff --git a/pandatool/src/mayaegg/mayaToEggConverter.h b/pandatool/src/mayaegg/mayaToEggConverter.h index 6662184bd1..ff9d75e7b9 100644 --- a/pandatool/src/mayaegg/mayaToEggConverter.h +++ b/pandatool/src/mayaegg/mayaToEggConverter.h @@ -131,7 +131,7 @@ private: EggGroup *group); void make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, const MFnMesh &mesh, EggGroup *egg_group, - MayaShader *default_shader = NULL); + MayaShader *default_shader = nullptr); void make_locator(const MDagPath &dag_path, const MFnDagNode &dag_node, EggGroup *egg_group); void make_camera_locator(const MDagPath &dag_path, const MFnDagNode &dag_node, diff --git a/pandatool/src/mayaprogs/mayaPview.cxx b/pandatool/src/mayaprogs/mayaPview.cxx index 286d94ad67..687ec99886 100644 --- a/pandatool/src/mayaprogs/mayaPview.cxx +++ b/pandatool/src/mayaprogs/mayaPview.cxx @@ -128,7 +128,7 @@ doIt(const MArgList &args) { string quoted = string("\"") + bam_filename.get_fullpath() + string("\""); nout << "pview " << pview_args << " " << quoted << "\n"; int retval = _spawnlp(_P_DETACH, "pview", - "pview", pview_args.c_str(), quoted.c_str(), NULL); + "pview", pview_args.c_str(), quoted.c_str(), nullptr); if (retval == -1) { bam_filename.unlink(); MProgressWindow::endProgress(); @@ -146,7 +146,7 @@ doIt(const MArgList &args) { // create a separate PandaFramework for each invocation, even though in // principle we could be sharing one framework for all of them. int argc = 0; - char **argv = NULL; + char **argv = nullptr; PandaFramework framework; framework.open_framework(argc, argv); framework.set_window_title("Panda Viewer"); @@ -154,7 +154,7 @@ doIt(const MArgList &args) { PT(WindowFramework) window; window = framework.open_window(); - if (window == (WindowFramework *)NULL) { + if (window == nullptr) { // Couldn't open a window. nout << "Couldn't open a window!\n"; MProgressWindow::endProgress(); @@ -281,7 +281,7 @@ convert(const NodePath &parent, bool animate) { egg_data->set_coordinate_system(CS_default); PT(PandaNode) result = load_egg_data(egg_data); - if (result == (PandaNode *)NULL) { + if (result == nullptr) { nout << "Unable to load converted egg data.\n"; return false; } diff --git a/pandatool/src/mayaprogs/mayaSavePview.cxx b/pandatool/src/mayaprogs/mayaSavePview.cxx index 60a115c14f..423c7f09da 100644 --- a/pandatool/src/mayaprogs/mayaSavePview.cxx +++ b/pandatool/src/mayaprogs/mayaSavePview.cxx @@ -73,7 +73,7 @@ doIt(const MArgList &args) { // On Windows, we use the spawn function to run pview asynchronously. MString quoted = MString("\"") + filename + MString("\""); int retval = _spawnlp(_P_DETACH, "pview", - "pview", pview_args.asChar(), quoted.asChar(), NULL); + "pview", pview_args.asChar(), quoted.asChar(), nullptr); if (retval == -1) { return MS::kFailure; } diff --git a/pandatool/src/mayaprogs/mayaToEgg.cxx b/pandatool/src/mayaprogs/mayaToEgg.cxx index 5ceb4cf1ee..8d58808a5b 100644 --- a/pandatool/src/mayaprogs/mayaToEgg.cxx +++ b/pandatool/src/mayaprogs/mayaToEgg.cxx @@ -76,7 +76,7 @@ MayaToEgg() : "Specify the fit tolerance for Maya polygon tesselation. The smaller " "the number, the more polygons will be generated. The default is " "0.01.", - &MayaToEgg::dispatch_double, NULL, &_polygon_tolerance); + &MayaToEgg::dispatch_double, nullptr, &_polygon_tolerance); add_option ("bface", "", 0, @@ -130,7 +130,7 @@ MayaToEgg() : "transforms in the egg file. The option may be one of all, model, " "dcs, or none. The default is model, which means only transforms on " "nodes that have the model flag or the dcs flag are preserved.", - &MayaToEgg::dispatch_transform_type, NULL, &_transform_type); + &MayaToEgg::dispatch_transform_type, nullptr, &_transform_type); add_option ("subroot", "name", 0, @@ -140,7 +140,7 @@ MayaToEgg() : "like * or ?). This parameter may be repeated multiple times to name " "multiple roots. If it is omitted altogether, the entire file is " "converted.", - &MayaToEgg::dispatch_vector_string, NULL, &_subroots); + &MayaToEgg::dispatch_vector_string, nullptr, &_subroots); add_option ("subset", "name", 0, @@ -150,7 +150,7 @@ MayaToEgg() : "like * or ?). This parameter may be repeated multiple times to name " "multiple roots. If it is omitted altogether, the entire file is " "converted.", - &MayaToEgg::dispatch_vector_string, NULL, &_subsets); + &MayaToEgg::dispatch_vector_string, nullptr, &_subsets); add_option ("exclude", "name", 0, @@ -159,7 +159,7 @@ MayaToEgg() : "name matches the parameter (which may include globbing characters " "like * or ?). This parameter may be repeated multiple times to name " "multiple roots.", - &MayaToEgg::dispatch_vector_string, NULL, &_excludes); + &MayaToEgg::dispatch_vector_string, nullptr, &_excludes); add_option ("ignore-slider", "name", 0, @@ -168,19 +168,19 @@ MayaToEgg() : "and it will not become a part of the animation. This " "parameter may including globbing characters, and it may be repeated " "as needed.", - &MayaToEgg::dispatch_vector_string, NULL, &_ignore_sliders); + &MayaToEgg::dispatch_vector_string, nullptr, &_ignore_sliders); add_option ("force-joint", "name", 0, "Specifies the name of a DAG node that maya2egg " "should treat as a joint, even if it does not appear to be a Maya joint " "and does not appear to be animated.", - &MayaToEgg::dispatch_vector_string, NULL, &_force_joints); + &MayaToEgg::dispatch_vector_string, nullptr, &_force_joints); add_option ("v", "", 0, "Increase verbosity. More v's means more verbose.", - &MayaToEgg::dispatch_count, NULL, &_verbose); + &MayaToEgg::dispatch_count, nullptr, &_verbose); add_option ("legacy-shaders", "", 0, diff --git a/pandatool/src/mayaprogs/mayaToEgg_server.cxx b/pandatool/src/mayaprogs/mayaToEgg_server.cxx index 30f88f99d0..8b97d920a4 100644 --- a/pandatool/src/mayaprogs/mayaToEgg_server.cxx +++ b/pandatool/src/mayaprogs/mayaToEgg_server.cxx @@ -52,7 +52,7 @@ MayaToEggServer() : "Specify the fit tolerance for Maya polygon tesselation. The smaller " "the number, the more polygons will be generated. The default is " "0.01.", - &MayaToEggServer::dispatch_double, NULL, &_polygon_tolerance); + &MayaToEggServer::dispatch_double, nullptr, &_polygon_tolerance); add_option ("bface", "", 0, @@ -91,7 +91,7 @@ MayaToEggServer() : "transforms in the egg file. The option may be one of all, model, " "dcs, or none. The default is model, which means only transforms on " "nodes that have the model flag or the dcs flag are preserved.", - &MayaToEggServer::dispatch_transform_type, NULL, &_transform_type); + &MayaToEggServer::dispatch_transform_type, nullptr, &_transform_type); add_option ("subroot", "name", 0, @@ -101,7 +101,7 @@ MayaToEggServer() : "like * or ?). This parameter may be repeated multiple times to name " "multiple roots. If it is omitted altogether, the entire file is " "converted.", - &MayaToEggServer::dispatch_vector_string, NULL, &_subroots); + &MayaToEggServer::dispatch_vector_string, nullptr, &_subroots); add_option ("subset", "name", 0, @@ -111,7 +111,7 @@ MayaToEggServer() : "like * or ?). This parameter may be repeated multiple times to name " "multiple roots. If it is omitted altogether, the entire file is " "converted.", - &MayaToEggServer::dispatch_vector_string, NULL, &_subsets); + &MayaToEggServer::dispatch_vector_string, nullptr, &_subsets); add_option ("exclude", "name", 0, @@ -120,7 +120,7 @@ MayaToEggServer() : "name matches the parameter (which may include globbing characters " "like * or ?). This parameter may be repeated multiple times to name " "multiple roots.", - &MayaToEggServer::dispatch_vector_string, NULL, &_excludes); + &MayaToEggServer::dispatch_vector_string, nullptr, &_excludes); add_option ("ignore-slider", "name", 0, @@ -129,19 +129,19 @@ MayaToEggServer() : "and it will not become a part of the animation. This " "parameter may including globbing characters, and it may be repeated " "as needed.", - &MayaToEggServer::dispatch_vector_string, NULL, &_ignore_sliders); + &MayaToEggServer::dispatch_vector_string, nullptr, &_ignore_sliders); add_option ("force-joint", "name", 0, "Specifies the name of a DAG node that maya2egg " "should treat as a joint, even if it does not appear to be a Maya joint " "and does not appear to be animated.", - &MayaToEggServer::dispatch_vector_string, NULL, &_force_joints); + &MayaToEggServer::dispatch_vector_string, nullptr, &_force_joints); add_option ("v", "", 0, "Increase verbosity. More v's means more verbose.", - &MayaToEggServer::dispatch_count, NULL, &_verbose); + &MayaToEggServer::dispatch_count, nullptr, &_verbose); add_option ("legacy-shaders", "", 0, diff --git a/pandatool/src/mayaprogs/mayapath.cxx b/pandatool/src/mayaprogs/mayapath.cxx index 428e4ba128..a82411efe9 100644 --- a/pandatool/src/mayaprogs/mayapath.cxx +++ b/pandatool/src/mayaprogs/mayapath.cxx @@ -133,7 +133,7 @@ get_maya_location(const char *ver, string &loc) { DWORD dtype; DWORD size = 4096; char result[4096 + 1]; - res = RegQueryValueEx(hkey, "MAYA_INSTALL_LOCATION", NULL, &dtype, (LPBYTE)result, &size); + res = RegQueryValueEx(hkey, "MAYA_INSTALL_LOCATION", nullptr, &dtype, (LPBYTE)result, &size); if ((res == ERROR_SUCCESS)&&(dtype == REG_SZ)) { result[size] = 0; loc = result; @@ -222,7 +222,7 @@ main(int argc, char *argv[]) { Filename standard_maya_location; #ifdef MAYAVERSION const char *key = get_version_number(TOSTRING(MAYAVERSION)); - if (key == NULL) { + if (key == nullptr) { cerr << "Unknown Maya version: " << TOSTRING(MAYAVERSION) << "\n"; } else { string loc; @@ -386,7 +386,7 @@ main(int argc, char *argv[]) { #endif if (bin.is_directory()) { const char *path = getenv("PATH"); - if (path == NULL) { + if (path == nullptr) { path = ""; } string putenv_str = "PATH=" + bin.to_os_specific() + sep + path; @@ -398,7 +398,7 @@ main(int argc, char *argv[]) { // And on DYLD_LIBRARY_PATH. if (bin.is_directory()) { const char *path = getenv("DYLD_LIBRARY_PATH"); - if (path == NULL) { + if (path == nullptr) { path = ""; } string sep = ":"; @@ -411,7 +411,7 @@ main(int argc, char *argv[]) { Filename fw_dir = Filename(maya_location, "Frameworks"); if (fw_dir.is_directory()) { const char *path = getenv("DYLD_FALLBACK_FRAMEWORK_PATH"); - if (path == NULL) { + if (path == nullptr) { path = ""; } string sep = ":"; @@ -424,7 +424,7 @@ main(int argc, char *argv[]) { // Linux (or other non-Windows OS) gets it added to LD_LIBRARY_PATH. if (bin.is_directory()) { const char *path = getenv("LD_LIBRARY_PATH"); - if (path == NULL) { + if (path == nullptr) { path = ""; } string sep = ":"; @@ -451,8 +451,8 @@ main(int argc, char *argv[]) { GetStartupInfo(&startup_info); BOOL result = CreateProcess(os_command.c_str(), command_line, - NULL, NULL, true, 0, - NULL, NULL, + nullptr, nullptr, true, 0, + nullptr, nullptr, &startup_info, &process_info); if (result) { diff --git a/pandatool/src/miscprogs/binToC.cxx b/pandatool/src/miscprogs/binToC.cxx index ba41010a60..44eddfb1ac 100644 --- a/pandatool/src/miscprogs/binToC.cxx +++ b/pandatool/src/miscprogs/binToC.cxx @@ -38,7 +38,7 @@ BinToC() : add_option ("n", "name", 0, "Specify the name of the table that is generated.", - &BinToC::dispatch_string, NULL, &_table_name); + &BinToC::dispatch_string, nullptr, &_table_name); add_option ("static", "", 0, diff --git a/pandatool/src/objegg/eggToObjConverter.cxx b/pandatool/src/objegg/eggToObjConverter.cxx index bd359e935a..96505e7f35 100644 --- a/pandatool/src/objegg/eggToObjConverter.cxx +++ b/pandatool/src/objegg/eggToObjConverter.cxx @@ -110,14 +110,14 @@ process(const Filename &filename) { Filename obj_filename = Filename::text_filename(filename); vfs->delete_file(obj_filename); ostream *file = vfs->open_write_file(obj_filename, true, true); - if (file == (ostream *)NULL) { + if (file == nullptr) { return false; } if (egg_precision != 0) { file->precision(egg_precision); } - _current_group = NULL; + _current_group = nullptr; /* (*file) << "\n#\n" @@ -134,7 +134,7 @@ process(const Filename &filename) { write_faces(*file, _egg_data); - bool success = (file != (ostream *)NULL); + bool success = (file != nullptr); vfs->close_write_file(file); return success; @@ -171,7 +171,7 @@ collect_vertices(EggNode *egg_node) { void EggToObjConverter:: write_faces(ostream &out, EggNode *egg_node) { if (egg_node->is_of_type(EggPrimitive::get_class_type())) { - const char *prim_type = NULL; + const char *prim_type = nullptr; if (egg_node->is_of_type(EggPolygon::get_class_type())) { prim_type = "f"; } else if (egg_node->is_of_type(EggPoint::get_class_type())) { @@ -180,7 +180,7 @@ write_faces(ostream &out, EggNode *egg_node) { prim_type = "l"; } - if (prim_type != NULL) { + if (prim_type != nullptr) { write_group_reference(out, egg_node); EggPrimitive *egg_prim = DCAST(EggPrimitive, egg_node); @@ -280,7 +280,7 @@ get_group_name(string &group_name, EggGroupNode *egg_group) { // Now recurse. EggGroupNode *egg_parent = egg_group->get_parent(); - if (egg_parent != NULL) { + if (egg_parent != nullptr) { get_group_name(group_name, egg_parent); } } @@ -379,7 +379,7 @@ write_vertices(ostream &out, const string &prefix, int num_components, int index = (*ui).second; const LVecBase4d &vec = (*ui).first; nassertv(index >= 0 && index < num_vertices); - nassertv(vertices[index] == NULL); + nassertv(vertices[index] == nullptr); vertices[index] = &vec; } diff --git a/pandatool/src/objegg/objToEggConverter.cxx b/pandatool/src/objegg/objToEggConverter.cxx index 5444463a79..05af8ce1a2 100644 --- a/pandatool/src/objegg/objToEggConverter.cxx +++ b/pandatool/src/objegg/objToEggConverter.cxx @@ -135,7 +135,7 @@ convert_to_node(const LoaderOptions &options, const Filename &filename) { delete _current_vertex_data; if (had_error()) { - return NULL; + return nullptr; } return _root_node; @@ -148,7 +148,7 @@ bool ObjToEggConverter:: process(const Filename &filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *strm = vfs->open_read_file(filename, true); - if (strm == NULL) { + if (strm == nullptr) { objegg_cat.error() << "Couldn't read " << filename << "\n"; return false; @@ -448,7 +448,7 @@ process_f(vector_string &words) { PT(EggPolygon) poly = new EggPolygon; for (size_t i = 1; i < words.size(); ++i) { EggVertex *vertex = get_face_vertex(words[i]); - if (vertex == NULL) { + if (vertex == nullptr) { return false; } poly->add_vertex(vertex); @@ -474,7 +474,7 @@ process_g(vector_string &words) { while (i > 1) { --i; EggNode *child = group->find_child(words[i]); - if (child == NULL || !child->is_of_type(EggGroup::get_class_type())) { + if (child == nullptr || !child->is_of_type(EggGroup::get_class_type())) { child = new EggGroup(words[i]); group->add_child(child); } @@ -553,7 +553,7 @@ bool ObjToEggConverter:: process_node(const Filename &filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *strm = vfs->open_read_file(filename, true); - if (strm == NULL) { + if (strm == nullptr) { objegg_cat.error() << "Couldn't read " << filename << "\n"; return false; @@ -734,7 +734,7 @@ bool ObjToEggConverter:: process_g_node(vector_string &words) { _current_vertex_data->close_geom(this); delete _current_vertex_data; - _current_vertex_data = NULL; + _current_vertex_data = nullptr; NodePath np(_root_node); @@ -878,7 +878,7 @@ ObjToEggConverter::VertexData:: VertexData(PandaNode *parent, const string &name) : _parent(parent), _name(name) { - _geom_node = NULL; + _geom_node = nullptr; _v4_given = false; _vt3_given = false; @@ -1090,7 +1090,7 @@ close_geom(const ObjToEggConverter *converter) { PT(Geom) geom = new Geom(vdata); geom->add_primitive(_prim); - if (_geom_node == NULL) { + if (_geom_node == nullptr) { _geom_node = new GeomNode(_name); _parent->add_child(_geom_node); } diff --git a/pandatool/src/palettizer/destTextureImage.cxx b/pandatool/src/palettizer/destTextureImage.cxx index 757772912e..b1b3c1853b 100644 --- a/pandatool/src/palettizer/destTextureImage.cxx +++ b/pandatool/src/palettizer/destTextureImage.cxx @@ -98,7 +98,7 @@ copy_if_stale(const DestTextureImage *other, TextureImage *texture) { // Also check the timestamps. SourceTextureImage *source = texture->get_preferred_source(); - if (source != (SourceTextureImage *)NULL && + if (source != nullptr && source->get_filename().compare_timestamps(get_filename()) > 0) { copy(texture); } diff --git a/pandatool/src/palettizer/eggFile.cxx b/pandatool/src/palettizer/eggFile.cxx index 86e7bb1a6e..1b9e20e9e8 100644 --- a/pandatool/src/palettizer/eggFile.cxx +++ b/pandatool/src/palettizer/eggFile.cxx @@ -41,9 +41,9 @@ TypeHandle EggFile::_type_handle; */ EggFile:: EggFile() { - _data = (EggData *)NULL; + _data = nullptr; _first_txa_match = false; - _default_group = (PaletteGroup *)NULL; + _default_group = nullptr; _is_surprise = true; _is_stale = true; _had_data = false; @@ -100,7 +100,7 @@ get_source_filename() const { */ void EggFile:: scan_textures() { - nassertv(_data != (EggData *)NULL); + nassertv(_data != nullptr); // Extract the set of textures referenced by this egg file. EggTextureCollection tc; @@ -338,7 +338,7 @@ build_cross_links() { for (ti = _textures.begin(); ti != _textures.end(); ++ti) { TextureReference *reference = (*ti); TextureImage *texture = reference->get_texture(); - nassertv(texture != (TextureImage *)NULL); + nassertv(texture != nullptr); texture->note_egg_file(this); // Actually, this may count the same egg file multiple times for a @@ -384,7 +384,7 @@ choose_placements() { TextureReference *reference = (*ti); TextureImage *texture = reference->get_texture(); - if (reference->get_placement() != (TexturePlacement *)NULL && + if (reference->get_placement() != nullptr && texture->get_groups().count(reference->get_placement()->get_group()) != 0) { // The egg file is already using a TexturePlacement that is suitable. // Don't bother changing it. @@ -413,7 +413,7 @@ choose_placements() { // Now get the TexturePlacement object that corresponds to the // placement of this texture into this group. TexturePlacement *placement = texture->get_placement(group); - nassertv(placement != (TexturePlacement *)NULL); + nassertv(placement != nullptr); reference->set_placement(placement); } @@ -427,7 +427,7 @@ choose_placements() { */ bool EggFile:: has_data() const { - return (_data != (EggData *)NULL); + return (_data != nullptr); } /** @@ -445,7 +445,7 @@ had_data() const { */ void EggFile:: update_egg() { - nassertv(_data != (EggData *)NULL); + nassertv(_data != nullptr); Textures::iterator ti; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { @@ -478,7 +478,7 @@ remove_egg() { */ bool EggFile:: read_egg(bool noabs) { - nassertr(_data == (EggData *)NULL, false); + nassertr(_data == nullptr, false); nassertr(!_source_filename.empty(), false); Filename user_source_filename = @@ -551,8 +551,8 @@ read_egg(bool noabs) { */ void EggFile:: release_egg_data() { - if (_data != (EggData *)NULL) { - _data = NULL; + if (_data != nullptr) { + _data = nullptr; } Textures::iterator ti; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { @@ -567,7 +567,7 @@ release_egg_data() { */ bool EggFile:: write_egg() { - nassertr(_data != (EggData *)NULL, false); + nassertr(_data != nullptr, false); nassertr(!_dest_filename.empty(), false); _dest_filename.make_dir(); @@ -591,7 +591,7 @@ void EggFile:: write_description(ostream &out, int indent_level) const { indent(out, indent_level) << get_name() << ": "; if (_explicitly_assigned_groups.empty()) { - if (_default_group != (PaletteGroup *)NULL) { + if (_default_group != nullptr) { out << _default_group->get_name(); } } else { @@ -654,7 +654,7 @@ remove_backstage(EggGroupNode *node) { */ void EggFile:: rescan_textures() { - nassertv(_data != (EggData *)NULL); + nassertv(_data != nullptr); // Extract the set of textures referenced by this egg file. EggTextureCollection tc; @@ -751,7 +751,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { pi += _explicitly_assigned_groups.complete_pointers(p_list + pi, manager); - if (p_list[pi] != (TypedWritable *)NULL) { + if (p_list[pi] != nullptr) { DCAST_INTO_R(_default_group, p_list[pi], pi); } pi++; diff --git a/pandatool/src/palettizer/imageFile.cxx b/pandatool/src/palettizer/imageFile.cxx index 54071d4cb1..eb2409aab6 100644 --- a/pandatool/src/palettizer/imageFile.cxx +++ b/pandatool/src/palettizer/imageFile.cxx @@ -160,7 +160,7 @@ set_filename(PaletteGroup *group, const string &basename) { break; case 'g': - if (group != (PaletteGroup *)NULL) { + if (group != nullptr) { dirname += group->get_dirname(); } break; @@ -199,12 +199,12 @@ set_filename(const string &dirname, const string &basename) { // be truncated at that dot. It is therefore important that the supplied // basename always contains either an extension or a terminating dot. - if (_properties._color_type != (PNMFileType *)NULL) { + if (_properties._color_type != nullptr) { _filename.set_extension (_properties._color_type->get_suggested_extension()); } - if (_properties._alpha_type != (PNMFileType *)NULL) { + if (_properties._alpha_type != nullptr) { _alpha_filename = _filename.get_fullpath_wo_extension() + "_a."; _alpha_filename.set_extension (_properties._alpha_type->get_suggested_extension()); @@ -255,7 +255,7 @@ exists() const { if (!_filename.exists()) { return false; } - if (_properties._alpha_type != (PNMFileType *)NULL && + if (_properties._alpha_type != nullptr && _properties.uses_alpha() && !_alpha_filename.empty()) { if (!_alpha_filename.exists()) { @@ -338,7 +338,7 @@ write(const PNMImage &image) const { nassertr(!_filename.empty(), false); if (!image.has_alpha() || - _properties._alpha_type == (PNMFileType *)NULL) { + _properties._alpha_type == nullptr) { if (!_alpha_filename.empty() && _alpha_filename.exists()) { nout << "Deleting " << FilenameUnifier::make_user_filename(_alpha_filename) << "\n"; _alpha_filename.unlink(); @@ -399,7 +399,7 @@ unlink() { */ void ImageFile:: update_egg_tex(EggTexture *egg_tex) const { - nassertv(egg_tex != (EggTexture *)NULL); + nassertv(egg_tex != nullptr); egg_tex->set_filename(FilenameUnifier::make_egg_filename(_filename)); diff --git a/pandatool/src/palettizer/pal_string_utils.cxx b/pandatool/src/palettizer/pal_string_utils.cxx index 4fd04bbe3f..be747e4106 100644 --- a/pandatool/src/palettizer/pal_string_utils.cxx +++ b/pandatool/src/palettizer/pal_string_utils.cxx @@ -51,8 +51,8 @@ bool parse_image_type_request(const string &word, PNMFileType *&color_type, PNMFileType *&alpha_type) { PNMFileTypeRegistry *registry = PNMFileTypeRegistry::get_global_ptr(); - color_type = (PNMFileType *)NULL; - alpha_type = (PNMFileType *)NULL; + color_type = nullptr; + alpha_type = nullptr; string color_name = word; string alpha_name; @@ -66,7 +66,7 @@ parse_image_type_request(const string &word, PNMFileType *&color_type, if (!color_name.empty()) { color_type = registry->get_type_from_extension(color_name); - if (color_type == (PNMFileType *)NULL) { + if (color_type == nullptr) { nout << "Image file type '" << color_name << "' is unknown.\n"; return false; } @@ -74,7 +74,7 @@ parse_image_type_request(const string &word, PNMFileType *&color_type, if (!alpha_name.empty()) { alpha_type = registry->get_type_from_extension(alpha_name); - if (alpha_type == (PNMFileType *)NULL) { + if (alpha_type == nullptr) { nout << "Image file type '" << alpha_name << "' is unknown.\n"; return false; } diff --git a/pandatool/src/palettizer/paletteImage.cxx b/pandatool/src/palettizer/paletteImage.cxx index 9b664a159d..ee2ae01856 100644 --- a/pandatool/src/palettizer/paletteImage.cxx +++ b/pandatool/src/palettizer/paletteImage.cxx @@ -130,7 +130,7 @@ fillin(DatagramIterator &scan) { */ PaletteImage:: PaletteImage() { - _page = (PalettePage *)NULL; + _page = nullptr; _index = 0; _new_image = false; _got_image = false; @@ -247,7 +247,7 @@ count_coverage() const { for (pi = _placements.begin(); pi != _placements.end(); ++pi) { TexturePlacement *placement = (*pi); TextureImage *texture = placement->get_texture(); - nassertr(texture != (TextureImage *)NULL, 0.0); + nassertr(texture != nullptr, 0.0); int orig_pixels = texture->get_x_size() * @@ -564,7 +564,7 @@ update_image(bool redo_all) { if (texture->is_texture_named()) { SourceTextureImage *source = texture->get_preferred_source(); - if (source != (SourceTextureImage *)NULL && + if (source != nullptr && source->get_filename().compare_timestamps(get_filename()) > 0) { // The source image is newer than the palette image; we need to // regenerate. @@ -581,7 +581,7 @@ update_image(bool redo_all) { if (swapTexture->is_texture_named()) { SourceTextureImage *sourceSwapTexture = swapTexture->get_preferred_source(); - if (sourceSwapTexture != (SourceTextureImage *)NULL && + if (sourceSwapTexture != nullptr && sourceSwapTexture->get_filename().compare_timestamps(get_filename()) > 0) { // The source image is newer than the palette image; we need to // regenerate. @@ -636,7 +636,7 @@ update_image(bool redo_all) { write(_image); - if (pal->_shadow_color_type != (PNMFileType *)NULL) { + if (pal->_shadow_color_type != nullptr) { _shadow_image.write(_image); } @@ -647,7 +647,7 @@ update_image(bool redo_all) { for (si = _swappedImages.begin(); si != _swappedImages.end(); ++si) { PaletteImage *swappedImage = (*si); swappedImage->write(swappedImage->_image); - if (pal->_shadow_color_type != (PNMFileType *)NULL) { + if (pal->_shadow_color_type != nullptr) { swappedImage->_shadow_image.write(swappedImage->_image); } swappedImage->release_image(); @@ -794,7 +794,7 @@ find_hole(int &x, int &y, int x_size, int y_size) const { // Consider the spot at x, y. TexturePlacement *overlap = find_overlap(x, y, x_size, y_size); - if (overlap == (TexturePlacement *)NULL) { + if (overlap == nullptr) { // Hooray! return true; } @@ -831,7 +831,7 @@ find_overlap(int x, int y, int x_size, int y_size) const { } } - return (TexturePlacement *)NULL; + return nullptr; } /** @@ -845,7 +845,7 @@ get_image() { } if (!_new_image) { - if (pal->_shadow_color_type != (PNMFileType *)NULL) { + if (pal->_shadow_color_type != nullptr) { if (_shadow_image.get_filename().exists() && _shadow_image.read(_image)) { _got_image = true; return; @@ -891,7 +891,7 @@ get_swapped_image(int index) { } if (!_new_image) { - if (pal->_shadow_color_type != (PNMFileType *)NULL) { + if (pal->_shadow_color_type != nullptr) { if (_shadow_image.get_filename().exists() && _shadow_image.read(_image)) { _got_image = true; return; @@ -959,7 +959,7 @@ release_image() { void PaletteImage:: remove_image() { unlink(); - if (pal->_shadow_color_type != (PNMFileType *)NULL) { + if (pal->_shadow_color_type != nullptr) { _shadow_image.unlink(); } _new_image = true; @@ -1025,7 +1025,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { index++; } - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_page, p_list[index], index); } index++; diff --git a/pandatool/src/palettizer/palettePage.cxx b/pandatool/src/palettizer/palettePage.cxx index 8c04405927..adc73c660f 100644 --- a/pandatool/src/palettizer/palettePage.cxx +++ b/pandatool/src/palettizer/palettePage.cxx @@ -32,7 +32,7 @@ TypeHandle PalettePage::_type_handle; */ PalettePage:: PalettePage() { - _group = (PaletteGroup *)NULL; + _group = nullptr; } /** @@ -248,7 +248,7 @@ int PalettePage:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritable::complete_pointers(p_list, manager); - if (p_list[pi] != (TypedWritable *)NULL) { + if (p_list[pi] != nullptr) { DCAST_INTO_R(_group, p_list[pi], pi); } pi++; diff --git a/pandatool/src/palettizer/palettizer.cxx b/pandatool/src/palettizer/palettizer.cxx index 633647cb75..3244fd396a 100644 --- a/pandatool/src/palettizer/palettizer.cxx +++ b/pandatool/src/palettizer/palettizer.cxx @@ -29,7 +29,7 @@ #include "bamWriter.h" #include "indent.h" -Palettizer *pal = (Palettizer *)NULL; +Palettizer *pal = nullptr; // This number is written out as the first number to the pi file, to indicate // the version of egg-palettize that wrote it out. This allows us to easily @@ -116,9 +116,9 @@ Palettizer() { _aggressively_clean_mapdir = true; _force_power_2 = true; _color_type = PNMFileTypeRegistry::get_global_ptr()->get_type_from_extension("png"); - _alpha_type = (PNMFileType *)NULL; - _shadow_color_type = (PNMFileType *)NULL; - _shadow_alpha_type = (PNMFileType *)NULL; + _alpha_type = nullptr; + _shadow_color_type = nullptr; + _shadow_alpha_type = nullptr; _pal_x_size = _pal_y_size = 512; _background.set(0.0, 0.0, 0.0, 0.0); _cutout_mode = EggRenderMode::AM_dual; @@ -203,19 +203,19 @@ report_pi() const { << " remap UV's for characters: " << _remap_char_uv << "\n"; cout << " alpha cutouts: " << _cutout_mode << " " << _cutout_ratio << "\n"; - if (_color_type != (PNMFileType *)NULL) { + if (_color_type != nullptr) { cout << " generate image files of type: " << _color_type->get_suggested_extension(); - if (_alpha_type != (PNMFileType *)NULL) { + if (_alpha_type != nullptr) { cout << "," << _alpha_type->get_suggested_extension(); } cout << "\n"; } - if (_shadow_color_type != (PNMFileType *)NULL) { + if (_shadow_color_type != nullptr) { cout << " generate shadow palette files of type: " << _shadow_color_type->get_suggested_extension(); - if (_shadow_alpha_type != (PNMFileType *)NULL) { + if (_shadow_alpha_type != nullptr) { cout << "," << _shadow_alpha_type->get_suggested_extension(); } cout << "\n"; @@ -358,14 +358,14 @@ read_txa_file(istream &txa_file, const string &txa_filename) { } // Also reset _shadow_color_type. - _shadow_color_type = (PNMFileType *)NULL; - _shadow_alpha_type = (PNMFileType *)NULL; + _shadow_color_type = nullptr; + _shadow_alpha_type = nullptr; if (!_txa_file.read(txa_file, txa_filename)) { exit(1); } - if (_color_type == (PNMFileType *)NULL) { + if (_color_type == nullptr) { nout << "No valid output image file type available; cannot run.\n" << "Use :imagetype command in .txa file.\n"; exit(1); @@ -810,7 +810,7 @@ test_palette_group(const string &name) const { return (*gi).second; } - return (PaletteGroup *)NULL; + return nullptr; } /** @@ -981,22 +981,22 @@ int Palettizer:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int index = TypedWritable::complete_pointers(p_list, manager); - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_color_type, p_list[index], index); } index++; - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_alpha_type, p_list[index], index); } index++; - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_shadow_color_type, p_list[index], index); } index++; - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_shadow_alpha_type, p_list[index], index); } index++; diff --git a/pandatool/src/palettizer/sourceTextureImage.cxx b/pandatool/src/palettizer/sourceTextureImage.cxx index df1afec310..aea0046ad1 100644 --- a/pandatool/src/palettizer/sourceTextureImage.cxx +++ b/pandatool/src/palettizer/sourceTextureImage.cxx @@ -28,7 +28,7 @@ TypeHandle SourceTextureImage::_type_handle; */ SourceTextureImage:: SourceTextureImage() { - _texture = (TextureImage *)NULL; + _texture = nullptr; _egg_count = 0; _read_header = false; diff --git a/pandatool/src/palettizer/textureImage.cxx b/pandatool/src/palettizer/textureImage.cxx index fca1307928..f33d01c408 100644 --- a/pandatool/src/palettizer/textureImage.cxx +++ b/pandatool/src/palettizer/textureImage.cxx @@ -38,7 +38,7 @@ TypeHandle TextureImage::_type_handle; */ TextureImage:: TextureImage() { - _preferred_source = (SourceTextureImage *)NULL; + _preferred_source = nullptr; _read_source_image = false; _allow_release_source_image = true; _is_surprise = true; @@ -203,7 +203,7 @@ get_placement(PaletteGroup *group) const { Placement::const_iterator pi; pi = _placement.find(group); if (pi == _placement.end()) { - return (TexturePlacement *)NULL; + return nullptr; } return (*pi).second; @@ -267,7 +267,7 @@ pre_txa_file() { // Get our properties from the actual image for this texture. It's possible // the .txa file will update them further. SourceTextureImage *source = get_preferred_source(); - if (source != (SourceTextureImage *)NULL) { + if (source != nullptr) { _properties = source->get_properties(); } @@ -289,7 +289,7 @@ post_txa_file() { // First, get the actual size of the texture. SourceTextureImage *source = get_preferred_source(); - if (source != (SourceTextureImage *)NULL) { + if (source != nullptr) { if (source->get_size()) { _size_known = true; _x_size = source->get_x_size(); @@ -358,7 +358,7 @@ post_txa_file() { _properties._anisotropic_degree = _request._anisotropic_degree; - if (_properties._color_type == (PNMFileType *)NULL) { + if (_properties._color_type == nullptr) { _properties._color_type = _request._properties._color_type; _properties._alpha_type = _request._properties._alpha_type; } @@ -530,7 +530,7 @@ get_source(const Filename &filename, const Filename &alpha_filename, // Clear out the preferred source image to force us to rederive this next // time someone asks. - _preferred_source = (SourceTextureImage *)NULL; + _preferred_source = nullptr; _read_source_image = false; return source; @@ -543,7 +543,7 @@ get_source(const Filename &filename, const Filename &alpha_filename, */ SourceTextureImage *TextureImage:: get_preferred_source() { - if (_preferred_source != (SourceTextureImage *)NULL) { + if (_preferred_source != nullptr) { return _preferred_source; } @@ -569,7 +569,7 @@ get_preferred_source() { } } - SourceTextureImage *best = (SourceTextureImage *)NULL; + SourceTextureImage *best = nullptr; int best_size = 0; for (si = _sources.begin(); si != _sources.end(); ++si) { @@ -580,7 +580,7 @@ get_preferred_source() { if (source->exists() && source->get_size()) { int source_size = source->get_x_size() * source->get_y_size(); - if (best == (SourceTextureImage *)NULL) { + if (best == nullptr) { best = source; best_size = source_size; @@ -599,14 +599,14 @@ get_preferred_source() { } } - if (best == (SourceTextureImage *)NULL && !_sources.empty()) { + if (best == nullptr && !_sources.empty()) { // If we didn't pick any that pass, it must be that all of them are // unreadable. In this case, it really doesn't matter which one we pick, // but we should at least pick one that has an egg reference, if any of // them do. if (any_referenced) { for (si = _sources.begin(); - si != _sources.end() && best == (SourceTextureImage *)NULL; + si != _sources.end() && best == nullptr; ++si) { SourceTextureImage *source = (*si).second; if (source->get_egg_count() > 0) { @@ -672,7 +672,7 @@ copy_unplaced(bool redo_all) { placement->set_dest(dest); } else { - placement->set_dest((DestTextureImage *)NULL); + placement->set_dest(nullptr); } } @@ -707,7 +707,7 @@ const PNMImage &TextureImage:: read_source_image() { if (!_read_source_image) { SourceTextureImage *source = get_preferred_source(); - if (source != (SourceTextureImage *)NULL) { + if (source != nullptr) { source->read(_source_image); } _read_source_image = true; @@ -752,7 +752,7 @@ void TextureImage:: read_header() { if (!_read_source_image) { SourceTextureImage *source = get_preferred_source(); - if (source != (SourceTextureImage *)NULL) { + if (source != nullptr) { source->read_header(); } } @@ -766,7 +766,7 @@ bool TextureImage:: is_newer_than(const Filename &reference_filename) { if (!_read_source_image) { SourceTextureImage *source = get_preferred_source(); - if (source != (SourceTextureImage *)NULL) { + if (source != nullptr) { const Filename &source_filename = source->get_filename(); return source_filename.compare_timestamps(reference_filename) >= 0; } @@ -874,7 +874,7 @@ write_scale_info(ostream &out, int indent_level) { out << " orig "; - if (source == (SourceTextureImage *)NULL || + if (source == nullptr || !source->is_size_known()) { out << "unknown"; } else { @@ -886,7 +886,7 @@ write_scale_info(ostream &out, int indent_level) { out << " new " << get_x_size() << " " << get_y_size() << " " << get_num_channels(); - if (source != (SourceTextureImage *)NULL && + if (source != nullptr && source->is_size_known()) { double scale = 100.0 * (((double)get_x_size() / (double)source->get_x_size()) + @@ -902,7 +902,7 @@ write_scale_info(ostream &out, int indent_level) { TexturePlacement *placement = (*pi).second; if (placement->get_omit_reason() == OR_none) { PaletteImage *image = placement->get_image(); - nassertv(image != (PaletteImage *)NULL); + nassertv(image != nullptr); indent(out, indent_level + 2) << "placed on " << FilenameUnifier::make_user_filename(image->get_filename()) @@ -914,7 +914,7 @@ write_scale_info(ostream &out, int indent_level) { } else { DestTextureImage *image = placement->get_dest(); - nassertv(image != (DestTextureImage *)NULL); + nassertv(image != nullptr); indent(out, indent_level + 2) << "copied to " << FilenameUnifier::make_user_filename(image->get_filename()); @@ -923,7 +923,7 @@ write_scale_info(ostream &out, int indent_level) { image->get_y_size() != get_y_size())) { out << " at size " << image->get_x_size() << " " << image->get_y_size(); - if (source != (SourceTextureImage *)NULL && + if (source != nullptr && source->is_size_known()) { double scale = 100.0 * (((double)image->get_x_size() / (double)source->get_x_size()) + diff --git a/pandatool/src/palettizer/textureMemoryCounter.cxx b/pandatool/src/palettizer/textureMemoryCounter.cxx index 176461c832..3c3f78b571 100644 --- a/pandatool/src/palettizer/textureMemoryCounter.cxx +++ b/pandatool/src/palettizer/textureMemoryCounter.cxx @@ -53,11 +53,11 @@ reset() { void TextureMemoryCounter:: add_placement(TexturePlacement *placement) { TextureImage *texture = placement->get_texture(); - nassertv(texture != (TextureImage *)NULL); + nassertv(texture != nullptr); if (placement->get_omit_reason() == OR_none) { PaletteImage *image = placement->get_image(); - nassertv(image != (PaletteImage *)NULL); + nassertv(image != nullptr); add_palette(image); int bytes = count_bytes(image, placement->get_placed_x_size(), @@ -67,7 +67,7 @@ add_placement(TexturePlacement *placement) { } else { DestTextureImage *dest = placement->get_dest(); - if (dest != (DestTextureImage *)NULL) { + if (dest != nullptr) { int bytes = count_bytes(dest); add_texture(texture, bytes); diff --git a/pandatool/src/palettizer/texturePlacement.cxx b/pandatool/src/palettizer/texturePlacement.cxx index 2cbea3019c..36331ed233 100644 --- a/pandatool/src/palettizer/texturePlacement.cxx +++ b/pandatool/src/palettizer/texturePlacement.cxx @@ -34,10 +34,10 @@ TypeHandle TexturePlacement::_type_handle; */ TexturePlacement:: TexturePlacement() { - _texture = (TextureImage *)NULL; - _group = (PaletteGroup *)NULL; - _image = (PaletteImage *)NULL; - _dest = (DestTextureImage *)NULL; + _texture = nullptr; + _group = nullptr; + _image = nullptr; + _dest = nullptr; _has_uvs = false; _size_known = false; _is_filled = true; @@ -60,8 +60,8 @@ TexturePlacement(TextureImage *texture, PaletteGroup *group) : _omit_reason = OR_unknown; } - _image = (PaletteImage *)NULL; - _dest = (DestTextureImage *)NULL; + _image = nullptr; + _dest = nullptr; _has_uvs = false; _size_known = false; _is_filled = false; @@ -443,7 +443,7 @@ get_uv_area() const { */ bool TexturePlacement:: is_placed() const { - return _image != (PaletteImage *)NULL; + return _image != nullptr; } /** @@ -451,7 +451,7 @@ is_placed() const { */ PaletteImage *TexturePlacement:: get_image() const { - nassertr(is_placed(), (PaletteImage *)NULL); + nassertr(is_placed(), nullptr); return _image; } @@ -460,7 +460,7 @@ get_image() const { */ PalettePage *TexturePlacement:: get_page() const { - nassertr(is_placed(), (PalettePage *)NULL); + nassertr(is_placed(), nullptr); return _image->get_page(); } @@ -540,9 +540,9 @@ place_at(PaletteImage *image, int x, int y) { */ void TexturePlacement:: force_replace() { - if (_image != (PaletteImage *)NULL) { + if (_image != nullptr) { _image->unplace(this); - _image = (PaletteImage *)NULL; + _image = nullptr; } if (_omit_reason == OR_none) { mark_eggs_stale(); @@ -1031,22 +1031,22 @@ int TexturePlacement:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int index = TypedWritable::complete_pointers(p_list, manager); - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_texture, p_list[index], index); } index++; - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_group, p_list[index], index); } index++; - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_image, p_list[index], index); } index++; - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_dest, p_list[index], index); } index++; diff --git a/pandatool/src/palettizer/textureProperties.cxx b/pandatool/src/palettizer/textureProperties.cxx index c8db745fc8..9538b85165 100644 --- a/pandatool/src/palettizer/textureProperties.cxx +++ b/pandatool/src/palettizer/textureProperties.cxx @@ -38,8 +38,8 @@ TextureProperties() { _magfilter = EggTexture::FT_unspecified; _quality_level = EggTexture::QL_unspecified; _anisotropic_degree = 0; - _color_type = (PNMFileType *)NULL; - _alpha_type = (PNMFileType *)NULL; + _color_type = nullptr; + _alpha_type = nullptr; } /** @@ -222,7 +222,7 @@ update_properties(const TextureProperties &other) { _anisotropic_degree = other._anisotropic_degree; - if (_color_type == (PNMFileType *)NULL) { + if (_color_type == nullptr) { _color_type = other._color_type; _alpha_type = other._alpha_type; } @@ -445,7 +445,7 @@ fully_define() { break; } - if (_color_type == (PNMFileType *)NULL) { + if (_color_type == nullptr) { _color_type = pal->_color_type; _alpha_type = pal->_alpha_type; } @@ -501,7 +501,7 @@ operator < (const TextureProperties &other) const { if (_color_type != other._color_type) { return _color_type < other._color_type; } - if (_color_type != (PNMFileType *)NULL) { + if (_color_type != nullptr) { if (_alpha_type != other._alpha_type) { return _alpha_type < other._alpha_type; } @@ -520,7 +520,7 @@ operator == (const TextureProperties &other) const { _quality_level == other._quality_level && _anisotropic_degree == other._anisotropic_degree && _color_type == other._color_type && - (_color_type == (PNMFileType *)NULL || + (_color_type == nullptr || _alpha_type == other._alpha_type)); } @@ -670,10 +670,10 @@ get_quality_level_string(EggTexture::QualityLevel quality_level) { */ string TextureProperties:: get_type_string(PNMFileType *color_type, PNMFileType *alpha_type) { - if (color_type == (PNMFileType *)NULL) { + if (color_type == nullptr) { return ""; } - if (alpha_type == (PNMFileType *)NULL) { + if (alpha_type == nullptr) { return "c"; } return "a"; @@ -781,12 +781,12 @@ int TextureProperties:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int index = TypedWritable::complete_pointers(p_list, manager); - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_color_type, p_list[index], index); } index++; - if (p_list[index] != (TypedWritable *)NULL) { + if (p_list[index] != nullptr) { DCAST_INTO_R(_alpha_type, p_list[index], index); } index++; diff --git a/pandatool/src/palettizer/textureReference.cxx b/pandatool/src/palettizer/textureReference.cxx index da6a2b626f..7bb869c336 100644 --- a/pandatool/src/palettizer/textureReference.cxx +++ b/pandatool/src/palettizer/textureReference.cxx @@ -42,12 +42,12 @@ TypeHandle TextureReference::_type_handle; */ TextureReference:: TextureReference() { - _egg_file = (EggFile *)NULL; - _egg_tex = (EggTexture *)NULL; + _egg_file = nullptr; + _egg_tex = nullptr; _tex_mat = LMatrix3d::ident_mat(); _inv_tex_mat = LMatrix3d::ident_mat(); - _source_texture = (SourceTextureImage *)NULL; - _placement = (TexturePlacement *)NULL; + _source_texture = nullptr; + _placement = nullptr; _uses_alpha = false; _any_uvs = false; _min_uv.set(0.0, 0.0); @@ -155,8 +155,8 @@ from_egg_quick(const TextureReference &other) { */ void TextureReference:: release_egg_data() { - _egg_tex = NULL; - _egg_data = NULL; + _egg_tex = nullptr; + _egg_data = nullptr; } /** @@ -192,7 +192,7 @@ get_source() const { */ TextureImage *TextureReference:: get_texture() const { - nassertr(_source_texture != (SourceTextureImage *)NULL, (TextureImage *)NULL); + nassertr(_source_texture != nullptr, nullptr); return _source_texture->get_texture(); } @@ -303,12 +303,12 @@ is_equivalent(const TextureReference &other) const { void TextureReference:: set_placement(TexturePlacement *placement) { if (_placement != placement) { - if (_placement != (TexturePlacement *)NULL) { + if (_placement != nullptr) { // Remove our reference from the old placement object. _placement->remove_egg(this); } _placement = placement; - if (_placement != (TexturePlacement *)NULL) { + if (_placement != nullptr) { // Add our reference to the new placement object. _placement->add_egg(this); } @@ -320,7 +320,7 @@ set_placement(TexturePlacement *placement) { */ void TextureReference:: clear_placement() { - set_placement((TexturePlacement *)NULL); + set_placement(nullptr); } /** @@ -338,7 +338,7 @@ get_placement() const { */ void TextureReference:: mark_egg_stale() { - if (_egg_file != (EggFile *)NULL) { + if (_egg_file != nullptr) { _egg_file->mark_stale(); } } @@ -349,12 +349,12 @@ mark_egg_stale() { */ void TextureReference:: update_egg() { - if (_egg_tex == (EggTexture *)NULL) { + if (_egg_tex == nullptr) { // Not much we can do if we don't have an actual egg file to reference. return; } - if (_placement == (TexturePlacement *)NULL) { + if (_placement == nullptr) { // Nor if we don't have an actual placement yet. This is possible if the // egg was assigned to the "null" group, and the texture hasn't been re- // assigned yet. @@ -362,7 +362,7 @@ update_egg() { } TextureImage *texture = get_texture(); - if (texture != (TextureImage *)NULL) { + if (texture != nullptr) { // Make sure the alpha mode is set according to what the texture image // wants. if (texture->has_num_channels() && @@ -406,7 +406,7 @@ update_egg() { // simply have to update the texture reference to the new texture // location. DestTextureImage *dest = _placement->get_dest(); - nassertv(dest != (DestTextureImage *)NULL); + nassertv(dest != nullptr); dest->update_egg_tex(_egg_tex); return; } @@ -415,7 +415,7 @@ update_egg() { // update the texture reference, but also adjust the UV's. In most cases, // we can do this by simply applying a texture matrix to the reference. PaletteImage *image = _placement->get_image(); - nassertv(image != (PaletteImage *)NULL); + nassertv(image != nullptr); image->update_egg_tex(_egg_tex); @@ -447,7 +447,7 @@ update_egg() { */ void TextureReference:: apply_properties_to_source() { - nassertv(_source_texture != (SourceTextureImage *)NULL); + nassertv(_source_texture != nullptr); _source_texture->update_properties(_properties); } @@ -830,17 +830,17 @@ int TextureReference:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritable::complete_pointers(p_list, manager); - if (p_list[pi] != (TypedWritable *)NULL) { + if (p_list[pi] != nullptr) { DCAST_INTO_R(_egg_file, p_list[pi], pi); } pi++; - if (p_list[pi] != (TypedWritable *)NULL) { + if (p_list[pi] != nullptr) { DCAST_INTO_R(_source_texture, p_list[pi], pi); } pi++; - if (p_list[pi] != (TypedWritable *)NULL) { + if (p_list[pi] != nullptr) { DCAST_INTO_R(_placement, p_list[pi], pi); } pi++; diff --git a/pandatool/src/palettizer/txaLine.cxx b/pandatool/src/palettizer/txaLine.cxx index 0d1c655658..51a1532610 100644 --- a/pandatool/src/palettizer/txaLine.cxx +++ b/pandatool/src/palettizer/txaLine.cxx @@ -45,8 +45,8 @@ TxaLine() { _margin = 0; _got_coverage_threshold = false; _coverage_threshold = 0.0; - _color_type = (PNMFileType *)NULL; - _alpha_type = (PNMFileType *)NULL; + _color_type = nullptr; + _alpha_type = nullptr; } /** @@ -259,7 +259,7 @@ parse(const string &line) { } else { // Maybe it's a group name. PaletteGroup *group = pal->test_palette_group(word); - if (group != (PaletteGroup *)NULL) { + if (group != nullptr) { _palette_groups.insert(group); } else { @@ -283,7 +283,7 @@ parse(const string &line) { _quality_level = ql; } else if (word.length() > 2 && word[word.length() - 2] == '_' && - strchr("uv", word[word.length() - 1]) != NULL) { + strchr("uv", word[word.length() - 1]) != nullptr) { // It must be a wrap mode for u or v. string prefix = word.substr(0, word.length() - 2); EggTexture::WrapMode wm = EggTexture::string_wrap_mode(prefix); @@ -408,7 +408,7 @@ match_texture(TextureImage *texture) const { break; case ST_scale: - if (source != (SourceTextureImage *)NULL && source->get_size()) { + if (source != nullptr && source->get_size()) { request._got_size = true; request._x_size = max(1, (int)(source->get_x_size() * _scale / 100.0)); request._y_size = max(1, (int)(source->get_y_size() * _scale / 100.0)); @@ -436,7 +436,7 @@ match_texture(TextureImage *texture) const { request._coverage_threshold = _coverage_threshold; } - if (_color_type != (PNMFileType *)NULL) { + if (_color_type != nullptr) { request._properties._color_type = _color_type; request._properties._alpha_type = _alpha_type; } @@ -599,9 +599,9 @@ output(ostream &out) const { } } - if (_color_type != (PNMFileType *)NULL) { + if (_color_type != nullptr) { out << " " << _color_type->get_suggested_extension(); - if (_alpha_type != (PNMFileType *)NULL) { + if (_alpha_type != nullptr) { out << "," << _alpha_type->get_suggested_extension(); } } diff --git a/pandatool/src/pfmprogs/pfmBba.cxx b/pandatool/src/pfmprogs/pfmBba.cxx index 5456efad27..30804d8fea 100644 --- a/pandatool/src/pfmprogs/pfmBba.cxx +++ b/pandatool/src/pfmprogs/pfmBba.cxx @@ -73,7 +73,7 @@ process_pfm(const Filename &input_filename, PfmFile &file) { if (!bba_filename.empty()) { bba_filename.set_text(); PT(BoundingHexahedron) bounds = file.compute_planar_bounds(LPoint2f(0.5, 0.5), pfm_bba_dist[0], pfm_bba_dist[1], false); - nassertr(bounds != (BoundingHexahedron *)NULL, false); + nassertr(bounds != nullptr, false); pofstream out; if (!bba_filename.open_write(out)) { diff --git a/pandatool/src/pfmprogs/pfmTrans.cxx b/pandatool/src/pfmprogs/pfmTrans.cxx index 123b098768..fdf803b601 100644 --- a/pandatool/src/pfmprogs/pfmTrans.cxx +++ b/pandatool/src/pfmprogs/pfmTrans.cxx @@ -72,7 +72,7 @@ PfmTrans() { ("rotate", "degrees", 0, "Rotates the pfm file the specified number of degrees counterclockwise, " "which must be a multiple of 90.", - &PfmTrans::dispatch_int, NULL, &_rotate); + &PfmTrans::dispatch_int, nullptr, &_rotate); add_option ("mirror_x", "", 0, @@ -231,7 +231,7 @@ process_pfm(const Filename &input_filename, PfmFile &file) { NodePath mesh = vizzer.generate_vis_mesh(PfmVizzer::MF_both); if (_got_vistex_filename) { PT(Texture) tex = TexturePool::load_texture(_vistex_filename); - if (tex == NULL) { + if (tex == nullptr) { nout << "Couldn't find " << _vistex_filename << "\n"; } else { tex->set_minfilter(SamplerState::FT_linear_mipmap_linear); diff --git a/pandatool/src/progbase/programBase.cxx b/pandatool/src/progbase/programBase.cxx index c5440d08f2..e97a536127 100644 --- a/pandatool/src/progbase/programBase.cxx +++ b/pandatool/src/progbase/programBase.cxx @@ -101,7 +101,7 @@ ProgramBase(const string &name) : _name(name) { add_option("h", "", 100, "Display this help page.", - &ProgramBase::handle_help_option, NULL, (void *)this); + &ProgramBase::handle_help_option, nullptr, (void *)this); // It's nice to start with a blank line. nout << "\r"; @@ -114,7 +114,7 @@ ProgramBase:: ~ProgramBase() { // Reset Notify in case any messages get sent after our destruction--our // stream is no longer valid. - Notify::ptr()->set_ostream_ptr(NULL, false); + Notify::ptr()->set_ostream_ptr(nullptr, false); } /** @@ -196,11 +196,11 @@ write_man_page(ostream &out) { // Generate a date string for inclusion into the footer. char date_str[256]; date_str[0] = 0; - time_t current_time = time(NULL); + time_t current_time = time(nullptr); if (current_time != (time_t) -1) { tm *today = localtime(¤t_time); - if (today == NULL || 0 == strftime(date_str, 256, "%d %B %Y", today)) { + if (today == nullptr || 0 == strftime(date_str, 256, "%d %B %Y", today)) { date_str[0] = 0; } } @@ -353,7 +353,7 @@ parse_command_line(int argc, char **argv) { gopt.name = (char *)opt._option.c_str(); gopt.has_arg = (opt._parm_name.empty()) ? no_argument : required_argument; - gopt.flag = (int *)NULL; + gopt.flag = nullptr; // Return an index into the _options_by_index array, offset by 256 so we // don't confuse it with '?'. @@ -379,10 +379,10 @@ parse_command_line(int argc, char **argv) { const struct option *long_opts = &long_options[0]; int flag = - getopt_long_only(argc, argv, short_options.c_str(), long_opts, NULL); + getopt_long_only(argc, argv, short_options.c_str(), long_opts, nullptr); while (flag != EOF) { string arg; - if (optarg != NULL) { + if (optarg != nullptr) { arg = optarg; } @@ -410,13 +410,13 @@ parse_command_line(int argc, char **argv) { const Option &opt = *(*ii).second; bool okflag = true; - if (opt._option_function != (OptionDispatchFunction)NULL) { + if (opt._option_function != (OptionDispatchFunction)nullptr) { okflag = (*opt._option_function)(opt._option, arg, opt._option_data); } - if (opt._option_method != (OptionDispatchMethod)NULL) { + if (opt._option_method != (OptionDispatchMethod)nullptr) { okflag = (*opt._option_method)(this, opt._option, arg, opt._option_data); } - if (opt._bool_var != (bool *)NULL) { + if (opt._bool_var != nullptr) { (*opt._bool_var) = true; } @@ -428,7 +428,7 @@ parse_command_line(int argc, char **argv) { } flag = - getopt_long_only(argc, argv, short_options.c_str(), long_opts, NULL); + getopt_long_only(argc, argv, short_options.c_str(), long_opts, nullptr); } if (!handle_args(remaining_args)) { @@ -609,14 +609,14 @@ add_option(const string &option, const string &parm_name, opt._sequence = ++_next_sequence; opt._description = description; opt._option_function = option_function; - opt._option_method = (OptionDispatchMethod)NULL; + opt._option_method = (OptionDispatchMethod)nullptr; opt._bool_var = bool_var; opt._option_data = option_data; _options_by_name[option] = opt; _sorted_options = false; - if (bool_var != (bool *)NULL) { + if (bool_var != nullptr) { (*bool_var) = false; } } @@ -644,7 +644,7 @@ add_option(const string &option, const string &parm_name, opt._index_group = index_group; opt._sequence = ++_next_sequence; opt._description = description; - opt._option_function = (OptionDispatchFunction)NULL; + opt._option_function = (OptionDispatchFunction)nullptr; opt._option_method = option_method; opt._bool_var = bool_var; opt._option_data = option_data; @@ -652,7 +652,7 @@ add_option(const string &option, const string &parm_name, _options_by_name[option] = opt; _sorted_options = false; - if (bool_var != (bool *)NULL) { + if (bool_var != nullptr) { (*bool_var) = false; } } @@ -712,7 +712,7 @@ add_path_replace_options() { "against each specified method, in the order in which they appear in " "the command line, until the file is found. If the file is not found, " "the last matching prefix is used anyway.", - &ProgramBase::dispatch_path_replace, NULL, _path_replace.p()); + &ProgramBase::dispatch_path_replace, nullptr, _path_replace.p()); add_option ("pp", "dirname", 40, @@ -721,7 +721,7 @@ add_path_replace_options() { "only for relative paths, or for paths that are made relative by a " "-pr replacement string that doesn't begin with a leading slash. " "The model-path is always implicitly searched anyway.", - &ProgramBase::dispatch_search_path, NULL, &(_path_replace->_path)); + &ProgramBase::dispatch_search_path, nullptr, &(_path_replace->_path)); } /** @@ -1194,7 +1194,7 @@ dispatch_image_type(const string &opt, const string &arg, void *var) { (*ip) = reg->get_type_from_extension(arg); - if ((*ip) == (PNMFileType *)NULL) { + if ((*ip) == nullptr) { nout << "Invalid image type for -" << opt << ": " << arg << "\n" << "The following image types are known:\n"; reg->write(nout, 2); diff --git a/pandatool/src/progbase/programBase.h b/pandatool/src/progbase/programBase.h index e6b166172c..d5d1e310a0 100644 --- a/pandatool/src/progbase/programBase.h +++ b/pandatool/src/progbase/programBase.h @@ -68,13 +68,13 @@ protected: void add_option(const string &option, const string &parm_name, int index_group, const string &description, OptionDispatchFunction option_function, - bool *bool_var = (bool *)NULL, - void *option_data = (void *)NULL); + bool *bool_var = nullptr, + void *option_data = nullptr); void add_option(const string &option, const string &parm_name, int index_group, const string &description, OptionDispatchMethod option_method, - bool *bool_var = (bool *)NULL, - void *option_data = (void *)NULL); + bool *bool_var = nullptr, + void *option_data = nullptr); bool redescribe_option(const string &option, const string &description); bool remove_option(const string &option); diff --git a/pandatool/src/progbase/test_prog.cxx b/pandatool/src/progbase/test_prog.cxx index 5123385cc5..289b68c8d7 100644 --- a/pandatool/src/progbase/test_prog.cxx +++ b/pandatool/src/progbase/test_prog.cxx @@ -46,13 +46,13 @@ TestProgram() { add_option ("b", "", 90, "Test option b", - &TestProgram::dispatch_count, NULL, &_count_b); + &TestProgram::dispatch_count, nullptr, &_count_b); _count_b = 0; add_option ("c", "integer_parameter", 90, "This is test option 'c'. It takes an integer parameter.", - &TestProgram::dispatch_int, NULL, &_int_c); + &TestProgram::dispatch_int, nullptr, &_int_c); _int_c = 0; } diff --git a/pandatool/src/progbase/withOutputFile.cxx b/pandatool/src/progbase/withOutputFile.cxx index 7ff8ea60d9..b88dec05d8 100644 --- a/pandatool/src/progbase/withOutputFile.cxx +++ b/pandatool/src/progbase/withOutputFile.cxx @@ -27,7 +27,7 @@ WithOutputFile(bool allow_last_param, bool allow_stdout, _allow_stdout = allow_stdout; _binary_output = binary_output; _got_output_filename = false; - _output_ptr = (ostream *)NULL; + _output_ptr = nullptr; _owns_output_ptr = false; } @@ -48,7 +48,7 @@ WithOutputFile:: */ ostream &WithOutputFile:: get_output() { - if (_output_ptr == (ostream *)NULL) { + if (_output_ptr == nullptr) { if (!_got_output_filename) { // No filename given; use standard output. if (!_allow_stdout) { @@ -108,7 +108,7 @@ close_output() { delete _output_ptr; _owns_output_ptr = false; } - _output_ptr = NULL; + _output_ptr = nullptr; _output_stream.close(); } diff --git a/pandatool/src/pstatserver/pStatClientData.cxx b/pandatool/src/pstatserver/pStatClientData.cxx index 4a3520b63f..77136b7f1d 100644 --- a/pandatool/src/pstatserver/pStatClientData.cxx +++ b/pandatool/src/pstatserver/pStatClientData.cxx @@ -55,9 +55,9 @@ is_alive() const { */ void PStatClientData:: close() { - if (_is_alive && _reader != (PStatReader *)NULL) { + if (_is_alive && _reader != nullptr) { _reader->close(); - _reader = (PStatReader *)NULL; + _reader = nullptr; _is_alive = false; } } @@ -78,7 +78,7 @@ get_num_collectors() const { bool PStatClientData:: has_collector(int index) const { return (index >= 0 && index < (int)_collectors.size() && - _collectors[index]._def != (PStatCollectorDef *)NULL); + _collectors[index]._def != nullptr); } /** @@ -144,7 +144,7 @@ set_collector_has_level(int index, int thread_index, bool flag) { // ancestors. if (flag) { PStatCollectorDef *def = _collectors[index]._def; - if (def != (PStatCollectorDef *)NULL && def->_parent_index != 0) { + if (def != nullptr && def->_parent_index != 0) { if (set_collector_has_level(def->_parent_index, thread_index, flag)) { any_changed = true; } @@ -222,7 +222,7 @@ get_thread_name(int index) const { const PStatThreadData *PStatClientData:: get_thread_data(int index) const { ((PStatClientData *)this)->define_thread(index); - nassertr(index >= 0 && index < (int)_threads.size(), NULL); + nassertr(index >= 0 && index < (int)_threads.size(), nullptr); return _threads[index]._data; } @@ -261,7 +261,7 @@ add_collector(PStatCollectorDef *def) { slot_collector(def->_index); nassertv(def->_index >= 0 && def->_index < (int)_collectors.size()); - if (_collectors[def->_index]._def != (PStatCollectorDef *)NULL) { + if (_collectors[def->_index]._def != nullptr) { // Free the old definition, if any. delete _collectors[def->_index]._def; } @@ -330,7 +330,7 @@ slot_collector(int collector_index) { while ((int)_collectors.size() <= collector_index) { Collector collector; - collector._def = (PStatCollectorDef *)NULL; + collector._def = nullptr; _collectors.push_back(collector); } } @@ -345,7 +345,7 @@ update_toplevel_collectors() { Collectors::const_iterator ci; for (ci = _collectors.begin(); ci != _collectors.end(); ++ci) { PStatCollectorDef *def = (*ci)._def; - if (def != (PStatCollectorDef *)NULL && def->_parent_index == 0) { + if (def != nullptr && def->_parent_index == 0) { _toplevel_collectors.push_back(def->_index); } } diff --git a/pandatool/src/pstatserver/pStatListener.cxx b/pandatool/src/pstatserver/pStatListener.cxx index 417ad5495d..73fe3d3b04 100644 --- a/pandatool/src/pstatserver/pStatListener.cxx +++ b/pandatool/src/pstatserver/pStatListener.cxx @@ -34,7 +34,7 @@ connection_opened(const PT(Connection) &, const NetAddress &address, const PT(Connection) &new_connection) { PStatMonitor *monitor = _manager->make_monitor(); - if (monitor == (PStatMonitor *)NULL) { + if (monitor == nullptr) { nout << "Couldn't create monitor!\n"; return; } diff --git a/pandatool/src/pstatserver/pStatReader.cxx b/pandatool/src/pstatserver/pStatReader.cxx index 7dbab59e74..c302185e0f 100644 --- a/pandatool/src/pstatserver/pStatReader.cxx +++ b/pandatool/src/pstatserver/pStatReader.cxx @@ -272,7 +272,7 @@ void PStatReader:: dequeue_frame_data() { while (!_queued_frame_data.empty()) { const FrameData &data = _queued_frame_data.front(); - nassertv(_client_data != (PStatClientData *)NULL); + nassertv(_client_data != nullptr); // Check to see if any new collectors have level data. int num_levels = data._frame_data->get_num_levels(); diff --git a/pandatool/src/pstatserver/pStatServer.cxx b/pandatool/src/pstatserver/pStatServer.cxx index 1e295ee4f9..23a6a62fda 100644 --- a/pandatool/src/pstatserver/pStatServer.cxx +++ b/pandatool/src/pstatserver/pStatServer.cxx @@ -122,7 +122,7 @@ poll() { */ void PStatServer:: main_loop(bool *interrupt_flag) { - while (interrupt_flag == (bool *)NULL || !*interrupt_flag) { + while (interrupt_flag == nullptr || !*interrupt_flag) { poll(); Thread::sleep(0.1); } diff --git a/pandatool/src/pstatserver/pStatServer.h b/pandatool/src/pstatserver/pStatServer.h index dca7ec2008..50128e4069 100644 --- a/pandatool/src/pstatserver/pStatServer.h +++ b/pandatool/src/pstatserver/pStatServer.h @@ -41,7 +41,7 @@ public: bool listen(int port = -1); void poll(); - void main_loop(bool *interrupt_flag = NULL); + void main_loop(bool *interrupt_flag = nullptr); virtual PStatMonitor *make_monitor()=0; void add_reader(Connection *connection, PStatReader *reader); diff --git a/pandatool/src/pstatserver/pStatThreadData.cxx b/pandatool/src/pstatserver/pStatThreadData.cxx index fd5e3f411b..bef18c8a24 100644 --- a/pandatool/src/pstatserver/pStatThreadData.cxx +++ b/pandatool/src/pstatserver/pStatThreadData.cxx @@ -75,7 +75,7 @@ has_frame(int frame_number) const { int rel_frame = frame_number - _first_frame_number; return (rel_frame >= 0 && rel_frame < (int)_frames.size() && - _frames[rel_frame] != (PStatFrameData *)NULL); + _frames[rel_frame] != nullptr); } /** @@ -91,21 +91,21 @@ get_frame(int frame_number) const { rel_frame = num_frames - 1; } - while (rel_frame >= 0 && _frames[rel_frame] == (PStatFrameData *)NULL) { + while (rel_frame >= 0 && _frames[rel_frame] == nullptr) { rel_frame--; } if (rel_frame < 0) { // No frame data that old. Return the oldest frame we've got. rel_frame = 0; while (rel_frame < num_frames && - _frames[rel_frame] == (PStatFrameData *)NULL) { + _frames[rel_frame] == nullptr) { rel_frame++; } } if (rel_frame >= 0 && rel_frame < num_frames) { PStatFrameData *frame = _frames[rel_frame]; - nassertr(frame != (PStatFrameData *)NULL, _null_frame); + nassertr(frame != nullptr, _null_frame); nassertr(frame->get_start() >= 0.0, _null_frame); return *frame; } @@ -154,14 +154,14 @@ int PStatThreadData:: get_frame_number_at_time(double time, int hint) const { hint -= _first_frame_number; if (hint >= 0 && hint < (int)_frames.size()) { - if (_frames[hint] != (PStatFrameData *)NULL && + if (_frames[hint] != nullptr && _frames[hint]->get_start() <= time) { // The hint might be right. Scan forward from there. int i = hint + 1; while (i < (int)_frames.size() && - (_frames[i] == (PStatFrameData *)NULL || + (_frames[i] == nullptr || _frames[i]->get_start() <= time)) { - if (_frames[i] != (PStatFrameData *)NULL) { + if (_frames[i] != nullptr) { hint = i; } ++i; @@ -175,7 +175,7 @@ get_frame_number_at_time(double time, int hint) const { int i = _frames.size() - 1; while (i >= 0) { const PStatFrameData *frame = _frames[i]; - if (frame != (PStatFrameData *)NULL && frame->get_start() <= time) { + if (frame != nullptr && frame->get_start() <= time) { break; } --i; @@ -259,17 +259,17 @@ get_history() const { */ void PStatThreadData:: record_new_frame(int frame_number, PStatFrameData *frame_data) { - nassertv(frame_data != (PStatFrameData *)NULL); + nassertv(frame_data != nullptr); nassertv(!frame_data->is_empty()); double time = frame_data->get_start(); // First, remove all the old frames that fall outside of our history window. double oldest_allowable_time = time - _history; while (!_frames.empty() && - (_frames.front() == (PStatFrameData *)NULL || + (_frames.front() == nullptr || _frames.front()->is_empty() || _frames.front()->get_start() < oldest_allowable_time)) { - if (_frames.front() != (PStatFrameData *)NULL) { + if (_frames.front() != nullptr) { delete _frames.front(); } _frames.pop_front(); @@ -281,18 +281,18 @@ record_new_frame(int frame_number, PStatFrameData *frame_data) { // get all the frames in order or even at all. if (_frames.empty()) { _first_frame_number = frame_number; - _frames.push_back(NULL); + _frames.push_back(nullptr); } else { while (_first_frame_number + (int)_frames.size() <= frame_number) { - _frames.push_back(NULL); + _frames.push_back(nullptr); } } int index = frame_number - _first_frame_number; nassertv(index >= 0 && index < (int)_frames.size()); - if (_frames[index] != (PStatFrameData *)NULL) { + if (_frames[index] != nullptr) { nout << "Got repeated frame data for frame " << frame_number << "\n"; delete _frames[index]; } @@ -314,7 +314,7 @@ compute_elapsed_frames() { } else { _now_i = _frames.size() - 1; - while (_now_i > 0 && _frames[_now_i] == (PStatFrameData *)NULL) { + while (_now_i > 0 && _frames[_now_i] == nullptr) { _now_i--; } if (_now_i < 0) { @@ -322,7 +322,7 @@ compute_elapsed_frames() { _got_elapsed_frames = false; } else { - nassertv(_frames[_now_i] != (PStatFrameData *)NULL); + nassertv(_frames[_now_i] != nullptr); double now = _frames[_now_i]->get_end(); double then = now - pstats_average_time; @@ -332,7 +332,7 @@ compute_elapsed_frames() { while (old_i >= 0) { const PStatFrameData *frame = _frames[old_i]; - if (frame != (PStatFrameData *)NULL) { + if (frame != nullptr) { if (frame->get_start() > then) { _then_i = old_i; } else { @@ -343,7 +343,7 @@ compute_elapsed_frames() { } nassertv(_then_i >= 0); - nassertv(_frames[_then_i] != (PStatFrameData *)NULL); + nassertv(_frames[_then_i] != nullptr); _got_elapsed_frames = true; _now_i += _first_frame_number; diff --git a/pandatool/src/pstatserver/pStatView.cxx b/pandatool/src/pstatserver/pStatView.cxx index b8d6aa9793..e69959a731 100644 --- a/pandatool/src/pstatserver/pStatView.cxx +++ b/pandatool/src/pstatserver/pStatView.cxx @@ -266,7 +266,7 @@ get_level(int collector) { PStatViewLevel *level = new PStatViewLevel; level->_collector = collector; - level->_parent = NULL; + level->_parent = nullptr; _levels[collector] = level; reset_level(level); @@ -518,7 +518,7 @@ reset_level(PStatViewLevel *level) { int parent_index = _client_data->get_collector_def(level->_collector)._parent_index; - if (level->_parent == (PStatViewLevel *)NULL) { + if (level->_parent == nullptr) { // This level didn't know its parent before, but now it does. PStatViewLevel *parent_level = get_level(parent_index); nassertr(parent_level != level, true); @@ -540,7 +540,7 @@ reset_level(PStatViewLevel *level) { new_parent_level->_children.push_back(level); new_parent_level->sort_children(_client_data); } else { - level->_parent = NULL; + level->_parent = nullptr; } PStatViewLevel::Children::iterator ci = diff --git a/pandatool/src/pstatserver/pStatViewLevel.cxx b/pandatool/src/pstatserver/pStatViewLevel.cxx index 04d962e833..47ed1fae98 100644 --- a/pandatool/src/pstatserver/pStatViewLevel.cxx +++ b/pandatool/src/pstatserver/pStatViewLevel.cxx @@ -77,6 +77,6 @@ get_num_children() const { */ const PStatViewLevel *PStatViewLevel:: get_child(int n) const { - nassertr(n >= 0 && n < (int)_children.size(), NULL); + nassertr(n >= 0 && n < (int)_children.size(), nullptr); return _children[n]; } diff --git a/pandatool/src/ptloader/loaderFileTypePandatool.cxx b/pandatool/src/ptloader/loaderFileTypePandatool.cxx index 0de02c19de..dade132585 100644 --- a/pandatool/src/ptloader/loaderFileTypePandatool.cxx +++ b/pandatool/src/ptloader/loaderFileTypePandatool.cxx @@ -32,7 +32,7 @@ LoaderFileTypePandatool(SomethingToEggConverter *loader, EggToSomethingConverter *saver) : _loader(loader), _saver(saver) { - if (_loader != (SomethingToEggConverter *)NULL) { + if (_loader != nullptr) { _loader->set_merge_externals(true); } } @@ -49,7 +49,7 @@ LoaderFileTypePandatool:: */ string LoaderFileTypePandatool:: get_name() const { - if (_loader != (SomethingToEggConverter *)NULL) { + if (_loader != nullptr) { return _loader->get_name(); } return _saver->get_name(); @@ -60,7 +60,7 @@ get_name() const { */ string LoaderFileTypePandatool:: get_extension() const { - if (_loader != (SomethingToEggConverter *)NULL) { + if (_loader != nullptr) { return _loader->get_extension(); } return _saver->get_extension(); @@ -72,7 +72,7 @@ get_extension() const { */ string LoaderFileTypePandatool:: get_additional_extensions() const { - if (_loader != (SomethingToEggConverter *)NULL) { + if (_loader != nullptr) { return _loader->get_additional_extensions(); } return _saver->get_additional_extensions(); @@ -84,7 +84,7 @@ get_additional_extensions() const { */ bool LoaderFileTypePandatool:: supports_compressed() const { - if (_loader != (SomethingToEggConverter *)NULL) { + if (_loader != nullptr) { return _loader->supports_compressed(); } return _saver->supports_compressed(); @@ -97,7 +97,7 @@ supports_compressed() const { */ bool LoaderFileTypePandatool:: supports_load() const { - return (_loader != NULL); + return (_loader != nullptr); } /** @@ -107,7 +107,7 @@ supports_load() const { */ bool LoaderFileTypePandatool:: supports_save() const { - return (_saver != NULL); + return (_saver != nullptr); } /** @@ -125,11 +125,11 @@ resolve_filename(Filename &path) const { PT(PandaNode) LoaderFileTypePandatool:: load_file(const Filename &path, const LoaderOptions &options, BamCacheRecord *record) const { - if (_loader == NULL) { - return NULL; + if (_loader == nullptr) { + return nullptr; } - if (record != (BamCacheRecord *)NULL) { + if (record != nullptr) { record->add_dependent_file(path); } @@ -205,7 +205,7 @@ load_file(const Filename &path, const LoaderOptions &options, bool LoaderFileTypePandatool:: save_file(const Filename &path, const LoaderOptions &options, PandaNode *node) const { - if (_saver == NULL) { + if (_saver == nullptr) { return false; } diff --git a/pandatool/src/ptloader/loaderFileTypePandatool.h b/pandatool/src/ptloader/loaderFileTypePandatool.h index 3e38e3a8b9..721e7477c3 100644 --- a/pandatool/src/ptloader/loaderFileTypePandatool.h +++ b/pandatool/src/ptloader/loaderFileTypePandatool.h @@ -29,7 +29,7 @@ class EggToSomethingConverter; class EXPCL_PTLOADER LoaderFileTypePandatool : public LoaderFileType { public: LoaderFileTypePandatool(SomethingToEggConverter *loader, - EggToSomethingConverter *saver = NULL); + EggToSomethingConverter *saver = nullptr); virtual ~LoaderFileTypePandatool(); virtual string get_name() const; diff --git a/pandatool/src/softegg/softNodeDesc.cxx b/pandatool/src/softegg/softNodeDesc.cxx index 5be0b79246..86d98ab7db 100644 --- a/pandatool/src/softegg/softNodeDesc.cxx +++ b/pandatool/src/softegg/softNodeDesc.cxx @@ -29,38 +29,38 @@ SoftNodeDesc(SoftNodeDesc *parent, const string &name) : Namable(name), _parent(parent) { - _model = (SAA_Elem *)NULL; - _egg_group = (EggGroup *)NULL; - _egg_table = (EggTable *)NULL; - _anim = (EggXfmSAnim *)NULL; + _model = nullptr; + _egg_group = nullptr; + _egg_table = nullptr; + _anim = nullptr; _joint_type = JT_none; // Add ourselves to our parent. - if (_parent != (SoftNodeDesc *)NULL) { + if (_parent != nullptr) { softegg_cat.spam() << "parent name " << _parent->get_name(); _parent->_children.push_back(this); } // set the _parentJoint to Null - _parentJoint = NULL; + _parentJoint = nullptr; - fullname = NULL; + fullname = nullptr; numTexLoc = 0; numTexGlb = 0; - uScale = NULL; - vScale = NULL; - uOffset = NULL; - vOffset = NULL; + uScale = nullptr; + vScale = nullptr; + uOffset = nullptr; + vOffset = nullptr; valid; uv_swap; // SAA_Boolean visible; - numTexTri = NULL; - textures = NULL; - materials = NULL; - triangles = NULL; + numTexTri = nullptr; + textures = nullptr; + materials = nullptr; + triangles = nullptr; gtype = SAA_GEOM_ORIGINAL; } @@ -140,7 +140,7 @@ force_set_parent(SoftNodeDesc *parent) { */ bool SoftNodeDesc:: has_model() const { - return (_model != (SAA_Elem *)NULL); + return (_model != nullptr); } /** @@ -149,7 +149,7 @@ has_model() const { */ SAA_Elem *SoftNodeDesc:: get_model() const { - nassertr(_model != (SAA_Elem *)NULL, _model); + nassertr(_model != nullptr, _model); return _model; } @@ -190,9 +190,9 @@ is_joint_parent() const { */ void SoftNodeDesc:: clear_egg() { - _egg_group = (EggGroup *)NULL; - _egg_table = (EggTable *)NULL; - _anim = (EggXfmSAnim *)NULL; + _egg_group = nullptr; + _egg_table = nullptr; + _anim = nullptr; Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { @@ -214,7 +214,7 @@ mark_joint_parent() { else softegg_cat.spam() << " ?parent " << get_name() << " joint type " << _joint_type; - if (_parent != (SoftNodeDesc *)NULL) { + if (_parent != nullptr) { _parent->mark_joint_parent(); } softegg_cat.spam() << endl; @@ -249,13 +249,13 @@ check_junk(bool parent_junk) { _joint_type = JT_junk; softegg_cat.spam() << "junk node " << get_name() << endl; } - if ( (strstr(name, "con-") != NULL) || - (strstr(name, "con_") != NULL) || - (strstr(name, "fly_") != NULL) || - (strstr(name, "fly-") != NULL) || - (strstr(name, "camRIG") != NULL) || - (strstr(name, "cam_rig") != NULL) || - (strstr(name, "bars") != NULL) ) + if ( (strstr(name, "con-") != nullptr) || + (strstr(name, "con_") != nullptr) || + (strstr(name, "fly_") != nullptr) || + (strstr(name, "fly-") != nullptr) || + (strstr(name, "camRIG") != nullptr) || + (strstr(name, "cam_rig") != nullptr) || + (strstr(name, "bars") != nullptr) ) { _joint_type = JT_junk; softegg_cat.spam() << "junk node " << get_name() << endl; @@ -286,12 +286,12 @@ is_partial(char *search_prefix) { if (!search_prefix) return false; // if name is search_prefix, return false - if (strstr(name, search_prefix) != NULL) { + if (strstr(name, search_prefix) != nullptr) { softegg_cat.debug() << "matched " << name << " "; return false; } // if name is not search_prefix, look in its parent - if (strstr(name, search_prefix) == NULL) { + if (strstr(name, search_prefix) == nullptr) { softegg_cat.debug() << "node " << name << " "; if (_parent) return _parent->is_partial(search_prefix); @@ -322,13 +322,13 @@ set_parentJoint(SAA_Scene *scene, SoftNodeDesc *lastJoint) { // if already a joint or name has "joint" in it const char *name = get_name().c_str(); - if (is_joint() || isSkeleton || strstr(name, "joint") != NULL) { + if (is_joint() || isSkeleton || strstr(name, "joint") != nullptr) { lastJoint = this; } - if ( _parentJoint && strstr( _parentJoint->get_name().c_str(), "scale" ) != NULL ) { + if ( _parentJoint && strstr( _parentJoint->get_name().c_str(), "scale" ) != nullptr ) { // make sure _parentJoint didn't have the name "joint" in it - if (strstr(_parentJoint->get_name().c_str(), "joint") == NULL) { - _parentJoint = NULL; + if (strstr(_parentJoint->get_name().c_str(), "joint") == nullptr) { + _parentJoint = nullptr; // _parentJoint = lastJoint = NULL; softegg_cat.spam() << "scale joint flag set!\n"; } @@ -464,7 +464,7 @@ get_joint_transform(SAA_Scene *scene, EggGroup *egg_group, EggXfmSAnim *anim, b SAA_Elem *skeletonPart = _model; const char *name = get_name().c_str(); - if ( skeletonPart != NULL ) { + if ( skeletonPart != nullptr ) { PN_stdfloat i,j,k; PN_stdfloat h,p,r; PN_stdfloat x,y,z; @@ -636,7 +636,7 @@ load_poly_model(SAA_Scene *scene, SAA_ModelType type) { TEX_PER_MAT , &textures[i] ); // initialize the array value - texNameArray[i] = NULL; + texNameArray[i] = nullptr; // initialize the repeats uRepeat[i] = vRepeat[i] = 0; @@ -895,12 +895,12 @@ make_vertex_offsets(int numShapes) { int offset; int numCV; char tableName[_MAX_PATH]; - SAA_DVector *shapeVerts = NULL; - SAA_DVector *uniqueVerts = NULL; + SAA_DVector *shapeVerts = nullptr; + SAA_DVector *uniqueVerts = nullptr; SAA_Elem *model = get_model(); SAA_Scene *scene = &stec.scene; - EggVertexPool *vpool = NULL; + EggVertexPool *vpool = nullptr; string vpool_name = get_name() + ".verts"; EggNode *t = stec._tree.get_egg_root()->find_child(vpool_name); if (t) @@ -988,7 +988,7 @@ make_vertex_offsets(int numShapes) { // if change isn't negligible, make a morph vertex entry double total = fabs(dx)+fabs(dy)+fabs(dz); if ( total > 0.00001 ) { - if ( vpool != NULL ) { + if ( vpool != nullptr ) { // create offset LVector3d p(dx, dy, dz); EggMorphVertex *dxyz = new EggMorphVertex(tableName, p); @@ -1011,7 +1011,7 @@ make_vertex_offsets(int numShapes) { void SoftNodeDesc:: make_morph_table( PN_stdfloat time ) { int numShapes; - SAA_Elem *model = NULL; + SAA_Elem *model = nullptr; SAA_AnimInterpType type; SAA_Scene *scene = &stec.scene; @@ -1080,7 +1080,7 @@ make_linear_morph_table(int numShapes, PN_stdfloat time) { // find the morph table associated with this key shape anim = stec.find_morph_table(tableName); - if ( anim != NULL ) { + if ( anim != nullptr ) { if ( i == (int)curveVal ) { if ( curveVal - i == 0 ) { anim->add_data(1.0f ); @@ -1151,7 +1151,7 @@ make_weighted_morph_table(int numShapes, PN_stdfloat time) { // find the morph table associated with this key shape anim = stec.find_morph_table(tableName); - if ( anim != NULL ) { + if ( anim != nullptr ) { anim->add_data(curveVal); softegg_cat.spam() << "adding element " << curveVal << endl; } @@ -1183,7 +1183,7 @@ make_expression_morph_table(int numShapes, PN_stdfloat time) // populate morph table values for this frame // compose track name - track = NULL; + track = nullptr; // find how many expressions for this shape SAA_elementGetNbExpressions( scene, model, track, FALSE, &numExp ); diff --git a/pandatool/src/softegg/softNodeDesc.h b/pandatool/src/softegg/softNodeDesc.h index 8d041377c6..af2060435a 100644 --- a/pandatool/src/softegg/softNodeDesc.h +++ b/pandatool/src/softegg/softNodeDesc.h @@ -42,7 +42,7 @@ class EggXfmSAnim; */ class SoftNodeDesc : public ReferenceCount, public Namable { public: - SoftNodeDesc(SoftNodeDesc *parent=NULL, const string &name = string()); + SoftNodeDesc(SoftNodeDesc *parent=nullptr, const string &name = string()); ~SoftNodeDesc(); void set_parent(SoftNodeDesc *parent); diff --git a/pandatool/src/softegg/softNodeTree.cxx b/pandatool/src/softegg/softNodeTree.cxx index f8dda53d48..a896bce4e0 100644 --- a/pandatool/src/softegg/softNodeTree.cxx +++ b/pandatool/src/softegg/softNodeTree.cxx @@ -30,14 +30,14 @@ */ SoftNodeTree:: SoftNodeTree() { - _root = new SoftNodeDesc(NULL, "----root"); + _root = new SoftNodeDesc(nullptr, "----root"); _root->fullname = "----root"; _fps = 0.0; _use_prefix = 0; - _search_prefix = NULL; - _egg_data = (EggData *)NULL; - _egg_root = (EggGroupNode *)NULL; - _skeleton_node = (EggGroupNode *)NULL; + _search_prefix = nullptr; + _egg_data = nullptr; + _egg_root = nullptr; + _skeleton_node = nullptr; } /** * Given an element, return a copy of the element's name WITHOUT prefix. @@ -91,7 +91,7 @@ GetFullName( SAA_Scene *scene, SAA_Elem *element ) char *SoftNodeTree:: GetModelNoteInfo( SAA_Scene *scene, SAA_Elem *model ) { int size; - char *modelNote = NULL; + char *modelNote = nullptr; SAA_Boolean bigEndian; SAA_elementGetUserDataSize( scene, model, "MNOT", &size ); @@ -106,7 +106,7 @@ GetModelNoteInfo( SAA_Scene *scene, SAA_Elem *model ) { // strip off newline, if present char *eol = (char *)memchr( modelNote, '\n', size ); - if ( eol != NULL) + if ( eol != nullptr) *eol = '\0'; else modelNote[size] = '\0'; @@ -130,7 +130,7 @@ GetRootName( const char *name ) { hyphen = strchr( name, '-' ); len = hyphen-name; - if ( (hyphen != NULL) && len ) { + if ( (hyphen != nullptr) && len ) { root = new char[len+1]; strncpy( root, name, len ); root[len] = '\0'; @@ -164,7 +164,7 @@ build_complete_hierarchy(SAA_Scene &scene, SAA_Database &database) { if ( numModels ) { // allocate array of models models = (SAA_Elem *) new SAA_Elem[numModels]; - if ( models != NULL ) { + if ( models != nullptr ) { if ((status = SAA_sceneGetModels( &scene, numModels, models )) != SI_SUCCESS) { return false; } @@ -200,7 +200,7 @@ build_complete_hierarchy(SAA_Scene &scene, SAA_Database &database) { softegg_cat.spam() << "========================================================\n"; // find _parentJoint for each node - _root->set_parentJoint(&scene, NULL); + _root->set_parentJoint(&scene, nullptr); return all_ok; } @@ -280,7 +280,7 @@ get_num_nodes() const { */ SoftNodeDesc *SoftNodeTree:: get_node(int n) const { - nassertr(n >= 0 && n < (int)_nodes.size(), NULL); + nassertr(n >= 0 && n < (int)_nodes.size(), nullptr); return _nodes[n]; } @@ -292,7 +292,7 @@ get_node(string name) const { NodesByName::const_iterator ni = _nodes_by_name.find(name); if (ni != _nodes_by_name.end()) return (*ni).second; - return NULL; + return nullptr; } /** @@ -314,7 +314,7 @@ clear_egg(EggData *egg_data, EggGroupNode *egg_root, */ EggGroup *SoftNodeTree:: get_egg_group(SoftNodeDesc *node_desc) { - nassertr(_egg_root != (EggGroupNode *)NULL, NULL); + nassertr(_egg_root != nullptr, nullptr); // lets print some relationship softegg_cat.spam() << " group " << node_desc->get_name() << "(" << node_desc->_egg_group << ")"; @@ -324,7 +324,7 @@ get_egg_group(SoftNodeDesc *node_desc) { softegg_cat.spam() << " parent " << node_desc->_parent; softegg_cat.spam() << endl; - if (node_desc->_egg_group == (EggGroup *)NULL) { + if (node_desc->_egg_group == nullptr) { // We need to make a new group node. EggGroup *egg_group; @@ -355,8 +355,8 @@ get_egg_group(SoftNodeDesc *node_desc) { */ EggTable *SoftNodeTree:: get_egg_table(SoftNodeDesc *node_desc) { - nassertr(_skeleton_node != (EggGroupNode *)NULL, NULL); - nassertr(node_desc->is_joint(), NULL); + nassertr(_skeleton_node != nullptr, nullptr); + nassertr(node_desc->is_joint(), nullptr); // lets print some relationship softegg_cat.spam() << " group " << node_desc->get_name() << "(" << node_desc->_egg_group << ")"; @@ -366,7 +366,7 @@ get_egg_table(SoftNodeDesc *node_desc) { softegg_cat.spam() << " parent " << node_desc->_parent; softegg_cat.spam() << endl; - if (node_desc->_egg_table == (EggTable *)NULL) { + if (node_desc->_egg_table == nullptr) { softegg_cat.spam() << "creating a new table\n"; // We need to make a new table node. nassertr(node_desc->_parent != // (SoftNodeDesc *)NULL, NULL); @@ -433,7 +433,7 @@ handle_null(SAA_Scene *scene, SoftNodeDesc *node_desc, const char *node_name) { // check to see if this NULL is used as a skeleton or is animated via // constraint only ( these nodes are tagged by the animator with the // keyword "joint" somewhere in the nodes name) - if ( isSkeleton || (strstr( name, "joint" ) != NULL) ) { + if ( isSkeleton || (strstr( name, "joint" ) != nullptr) ) { // MakeJoint( &scene, lastJoint, lastAnim, model, name ); node_desc->set_joint(); softegg_cat.spam() << " animating Standard null!!!\n"; @@ -466,7 +466,7 @@ build_node(SAA_Scene *scene, SAA_Elem *model) { node_name = name; - SoftNodeDesc *node_desc = r_build_node(NULL, node_name); + SoftNodeDesc *node_desc = r_build_node(nullptr, node_name); node_desc->fullname = fullname; node_desc->set_model(model); @@ -475,7 +475,7 @@ build_node(SAA_Scene *scene, SAA_Elem *model) { // find out what type of node we're dealing with SAA_modelGetType( scene, node_desc->get_model(), &type ); - if (type == SAA_MJNT || isSkeleton || (strstr(node_desc->get_name().c_str(), "joint") != NULL)) + if (type == SAA_MJNT || isSkeleton || (strstr(node_desc->get_name().c_str(), "joint") != nullptr)) node_desc->set_joint(); // treat the MNILL differently, because it needs to detect and set some @@ -514,7 +514,7 @@ build_node(SAA_Scene *scene, SAA_Elem *model) { // find out what type of node we're dealing with SAA_modelGetType( scene, node_child->get_model(), &type ); - if (type == SAA_MJNT || isSkeleton || (strstr(node_child->get_name().c_str(), "joint") != NULL)) + if (type == SAA_MJNT || isSkeleton || (strstr(node_child->get_name().c_str(), "joint") != nullptr)) node_child->set_joint(); // treat the MNILL differently, because it needs to detect and set some diff --git a/pandatool/src/softegg/softToEggConverter.cxx b/pandatool/src/softegg/softToEggConverter.cxx index 41cd0b66b9..3e0ab21ef6 100644 --- a/pandatool/src/softegg/softToEggConverter.cxx +++ b/pandatool/src/softegg/softToEggConverter.cxx @@ -52,15 +52,15 @@ SoftToEggConverter(const string &program_name) : */ _transform_type = TT_model; - database_name = NULL; - scene_name = NULL; - model_name = NULL; - animFileName = NULL; - eggFileName = NULL; - tex_path = NULL; - eggGroupName = NULL; - tex_filename = NULL; - search_prefix = NULL; + database_name = nullptr; + scene_name = nullptr; + model_name = nullptr; + animFileName = nullptr; + eggFileName = nullptr; + tex_path = nullptr; + eggGroupName = nullptr; + tex_filename = nullptr; + search_prefix = nullptr; result = SI_SUCCESS; // skeleton = new EggGroup(); @@ -473,7 +473,7 @@ GetTextureName( SAA_Scene *scene, SAA_Elem *texture ) { strcpy(fileName, tex_path); // do some processing on the name string - char *tmpName = NULL; + char *tmpName = nullptr; tmpName = strrchr(tempName, '/'); if (tmpName) tmpName++; @@ -601,7 +601,7 @@ convert_soft(bool from_selection) { */ bool SoftToEggConverter:: open_api() { - if ((scene_name == NULL && model_name == NULL) || database_name == NULL) { + if ((scene_name == nullptr && model_name == nullptr) || database_name == nullptr) { Usage(); exit( 1 ); } @@ -637,7 +637,7 @@ open_api() { } // if no egg filename specified, make up a name - if ( eggFileName == NULL ) { + if ( eggFileName == nullptr ) { string madeName; string tempName(scene_name); string::size_type end = tempName.find(".dsc"); @@ -651,7 +651,7 @@ open_api() { strcpy(eggFileName, madeName.c_str()); // if no anim filename specified, make up a name - if ( animFileName == NULL ) { + if ( animFileName == nullptr ) { madeName.assign(tempName.substr(0,end)); madeName.insert(madeName.size(), "-chan.egg"); animFileName = new char[strlen(scene_name)+ 10]; @@ -691,7 +691,7 @@ convert_char_model() { */ EggSAnimData *SoftToEggConverter:: find_morph_table(char *name) { - EggSAnimData *anim = NULL; + EggSAnimData *anim = nullptr; MorphTable::iterator mt; for (mt = _morph_table.begin(); mt != _morph_table.end(); ++mt) { anim = (*mt); @@ -742,7 +742,7 @@ convert_char_chan() { _tree._fps = output_frame_rate / frame_inc; // _tree.clear_egg(get_egg_data(), NULL, root_node); - _tree.clear_egg(get_egg_data(), NULL, skeleton_node); + _tree.clear_egg(get_egg_data(), nullptr, skeleton_node); // Now we can get the animation data by walking through all of the frames, // one at a time, and getting the joint angles at each frame. @@ -828,7 +828,7 @@ bool SoftToEggConverter:: convert_hierarchy(EggGroupNode *egg_root) { int num_nodes = _tree.get_num_nodes(); - _tree.clear_egg(get_egg_data(), egg_root, NULL); + _tree.clear_egg(get_egg_data(), egg_root, nullptr); softegg_cat.spam() << "num_nodes = " << num_nodes << endl; for (int i = 0; i < num_nodes; i++) { if (!process_model_node(_tree.get_node(i))) { @@ -846,9 +846,9 @@ convert_hierarchy(EggGroupNode *egg_root) { */ bool SoftToEggConverter:: process_model_node(SoftNodeDesc *node_desc) { - EggGroup *egg_group = NULL; - const char *name = NULL; - char *fullname = NULL; + EggGroup *egg_group = nullptr; + const char *name = nullptr; + char *fullname = nullptr; SAA_ModelType type; name = node_desc->get_name().c_str(); @@ -930,8 +930,8 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { int numShapes; SAA_Boolean valid; SAA_Boolean visible; - PN_stdfloat *uCoords = NULL; - PN_stdfloat *vCoords = NULL; + PN_stdfloat *uCoords = nullptr; + PN_stdfloat *vCoords = nullptr; string name = node_desc->get_name(); SAA_modelGetNodeVisibility( &scene, node_desc->get_model(), &visible ); @@ -984,8 +984,8 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { // Is this a double sided polygon? meaning check for back face flag char *modelNoteStr = _tree.GetModelNoteInfo( &scene, node_desc->get_model() ); - if ( modelNoteStr != NULL ) { - if ( strstr( modelNoteStr, "bface" ) != NULL ) + if ( modelNoteStr != nullptr ) { + if ( strstr( modelNoteStr, "bface" ) != nullptr ) egg_poly->set_bface_flag(TRUE); } @@ -1018,7 +1018,7 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { vCoords = new PN_stdfloat[3]; // read the u & v coords into the arrays - if ( uCoords != NULL && vCoords != NULL) { + if ( uCoords != nullptr && vCoords != nullptr) { for ( i = 0; i < 3; i++ ) uCoords[i] = vCoords[i] = 0.0f; @@ -1044,7 +1044,7 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { } // read the u & v coords into the arrays - if ( uCoords != NULL && vCoords != NULL) { + if ( uCoords != nullptr && vCoords != nullptr) { SAA_triCtrlVertexGetGlobalUVTxtCoords( &scene, node_desc->get_model(), 3, cvertices, node_desc->numTexGlb, node_desc->textures, uCoords, vCoords ); } @@ -1132,7 +1132,7 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { } // Now apply the shader. - if (node_desc->textures != NULL) { + if (node_desc->textures != nullptr) { if (node_desc->numTexLoc && node_desc->numTexTri[idx]) { if (!strstr(node_desc->texNameArray[idx], "noIcon")) set_shader_attributes(node_desc, *egg_poly, idx); @@ -1164,8 +1164,8 @@ make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType ty int numShapes; SAA_Boolean valid; SAA_Boolean visible; - PN_stdfloat *uCoords = NULL; - PN_stdfloat *vCoords = NULL; + PN_stdfloat *uCoords = nullptr; + PN_stdfloat *vCoords = nullptr; string name = node_desc->get_name(); SAA_modelGetNodeVisibility( &scene, node_desc->get_model(), &visible ); @@ -1261,8 +1261,8 @@ make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType ty // Is this a double sided polygon? meaning check for back face flag char *modelNoteStr = _tree.GetModelNoteInfo( &scene, node_desc->get_model() ); - if ( modelNoteStr != NULL ) { - if ( strstr( modelNoteStr, "bface" ) != NULL ) { + if ( modelNoteStr != nullptr ) { + if ( strstr( modelNoteStr, "bface" ) != nullptr ) { eggNurbs->set_bface_flag(TRUE); softegg_cat.spam() << "Set backface flag\n"; } @@ -1303,7 +1303,7 @@ make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType ty softegg_cat.spam() << numVert << " CV's\n"; // get the CV's - SAA_DVector *vertices = NULL; + SAA_DVector *vertices = nullptr; vertices = new SAA_DVector[numVert]; SAA_modelGetVertices( &scene, node_desc->get_model(), node_desc->gtype, 0, numVert, vertices ); @@ -1410,7 +1410,7 @@ make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType ty egg_group->add_child(eggNurbs); // Now apply the shader. - if (node_desc->textures != NULL) { + if (node_desc->textures != nullptr) { if (!strstr(node_desc->texNameArray[0], "noIcon")) set_shader_attributes(node_desc, *eggNurbs, 0); else @@ -1489,7 +1489,7 @@ add_knots( vector &eggKnots, double *knots, int numKnots, SAA_Boolean c int *SoftToEggConverter:: FindClosestTriVert( EggVertexPool *vpool, SAA_DVector *vertices, int numVert ) { int i,j; - int *vertMap = NULL; + int *vertMap = nullptr; int vpoolSize = (int)vpool->size(); PN_stdfloat closestDist; PN_stdfloat thisDist; @@ -1565,7 +1565,7 @@ make_soft_skin() { SAA_ModelType type; SAA_Elem *envelopes; SAA_Elem *model = node_desc->get_model(); - EggGroup *joint = NULL; + EggGroup *joint = nullptr; EggVertexPool *vpool; SAA_skeletonGetNbEnvelopes( &scene, model, &numEnv ); @@ -1579,7 +1579,7 @@ make_soft_skin() { softegg_cat.spam() << "numEnv = " << numEnv << endl; // allocate envelope array envelopes = new SAA_Elem[numEnv]; - if ( envelopes == NULL ) { + if ( envelopes == nullptr ) { softegg_cat.info() << "Out Of Memory" << endl; exit(1); } @@ -1615,13 +1615,13 @@ make_soft_skin() { if ( !hasEnvVertices ) continue; - SAA_SubElem *envVertices = NULL; + SAA_SubElem *envVertices = nullptr; int *numEnvVertices; int i,j,k; numEnvVertices = new int[numEnv]; - if ( numEnvVertices != NULL ) { + if ( numEnvVertices != nullptr ) { SAA_envelopeGetNbCtrlVertices( &scene, model, numEnv, envelopes, numEnvVertices ); int totalEnvVertices = 0; for( i = 0; i < numEnv; i++ ) { @@ -1633,7 +1633,7 @@ make_soft_skin() { continue; envVertices = new SAA_SubElem[totalEnvVertices]; - if ( envVertices != NULL ) { + if ( envVertices != nullptr ) { result = SAA_envelopeGetCtrlVertices( &scene, model, numEnv, envelopes, numEnvVertices, envVertices); if (result != SI_SUCCESS) { @@ -1642,13 +1642,13 @@ make_soft_skin() { } // loop through for each envelope for ( i = 0; i < numEnv; i++ ) { - PN_stdfloat *weights = NULL; + PN_stdfloat *weights = nullptr; int vertArrayOffset = 0; softegg_cat.spam() << "envelope[" << i << "]: "; weights = new PN_stdfloat[numEnvVertices[i]]; if ( weights ) { char *envName; - int *vpoolMap = NULL; + int *vpoolMap = nullptr; for ( j = 0; j < i; j++ ) vertArrayOffset += numEnvVertices[j]; softegg_cat.spam() << "envVertArray offset = " << vertArrayOffset; @@ -1697,7 +1697,7 @@ make_soft_skin() { else softegg_cat.spam() << "OTHER\n"; - int *envVtxIndices = NULL; + int *envVtxIndices = nullptr; envVtxIndices = new int[numEnvVertices[i]]; // Get the envelope vertex indices @@ -1714,7 +1714,7 @@ make_soft_skin() { SAA_modelGetNbVertices( &scene, &envelopes[i], &modelNumVert ); - SAA_DVector *modelVertices = NULL; + SAA_DVector *modelVertices = nullptr; modelVertices = new SAA_DVector[modelNumVert]; // get the model vertices @@ -1723,7 +1723,7 @@ make_soft_skin() { modelVertices ); // create array of global model coords - SAA_DVector *globalModelVertices = NULL; + SAA_DVector *globalModelVertices = nullptr; globalModelVertices = new SAA_DVector[modelNumVert]; PN_stdfloat matrix[4][4]; @@ -1748,7 +1748,7 @@ make_soft_skin() { string vpool_name = s_name + ".verts"; EggNode *t = _tree.get_egg_root()->find_child(vpool_name); if (t) - DCAST_INTO_R(vpool, t, NULL); + DCAST_INTO_R(vpool, t, nullptr); // find the mapping of the vertices that match this envelop if (vpool) { @@ -1841,8 +1841,8 @@ cleanup_soft_skin() continue; SAA_Elem *model = node_desc->get_model(); - EggGroup *joint = NULL; - EggVertexPool *vpool = NULL; + EggGroup *joint = nullptr; + EggVertexPool *vpool = nullptr; SAA_ModelType type; // find out what type of node we're dealing with @@ -1860,7 +1860,7 @@ cleanup_soft_skin() string vpool_name = node_desc->get_name() + ".verts"; EggNode *t = _tree.get_egg_root()->find_child(vpool_name); if (t) - DCAST_INTO_R(vpool, t, NULL); + DCAST_INTO_R(vpool, t, nullptr); if (!vpool) { // softegg_cat.spam() << "couldn't find vpool " << vpool_name << endl; @@ -2014,7 +2014,7 @@ reparent_decals(EggGroupNode *egg_parent) { // First, walk through all children of this node, looking for the one decal // base, if any. - EggGroup *decal_base = (EggGroup *)NULL; + EggGroup *decal_base = nullptr; pvector decal_children; EggGroupNode::iterator ci; @@ -2023,7 +2023,7 @@ reparent_decals(EggGroupNode *egg_parent) { if (child->is_of_type(EggGroup::get_class_type())) { EggGroup *child_group = DCAST(EggGroup, child); if (child_group->has_object_type("decalbase")) { - if (decal_base != (EggNode *)NULL) { + if (decal_base != nullptr) { softegg_cat.error() << "Two children of " << egg_parent->get_name() << " both have decalbase set: " << decal_base->get_name() @@ -2040,7 +2040,7 @@ reparent_decals(EggGroupNode *egg_parent) { } } - if (decal_base == (EggGroup *)NULL) { + if (decal_base == nullptr) { if (!decal_children.empty()) { softegg_cat.warning() << decal_children.front()->get_name() diff --git a/pandatool/src/softprogs/softCVS.cxx b/pandatool/src/softprogs/softCVS.cxx index a49e8ccde4..a0351b854e 100644 --- a/pandatool/src/softprogs/softCVS.cxx +++ b/pandatool/src/softprogs/softCVS.cxx @@ -57,7 +57,7 @@ SoftCVS() { ("cvs", "cvs_binary", 80, "Specify how to run the cvs program for adding newly-created files. " "The default is simply \"cvs\".", - &SoftCVS::dispatch_string, NULL, &_cvs_binary); + &SoftCVS::dispatch_string, nullptr, &_cvs_binary); } diff --git a/pandatool/src/text-stats/textStats.cxx b/pandatool/src/text-stats/textStats.cxx index c5e3c5a11c..9f2929f440 100644 --- a/pandatool/src/text-stats/textStats.cxx +++ b/pandatool/src/text-stats/textStats.cxx @@ -42,20 +42,20 @@ TextStats() { ("p", "port", 0, "Specify the TCP port to listen for connections on. By default, this " "is taken from the pstats-host Config variable.", - &TextStats::dispatch_int, NULL, &_port); + &TextStats::dispatch_int, nullptr, &_port); add_option ("r", "", 0, "Show the raw frame data, in addition to boiling it down to a total " "time per collector.", - &TextStats::dispatch_none, &_show_raw_data, NULL); + &TextStats::dispatch_none, &_show_raw_data, nullptr); add_option ("o", "filename", 0, "Filename where to print. If not given then stderr is being used.", &TextStats::dispatch_string, &_got_outputFileName, &_outputFileName); - _outFile = NULL; + _outFile = nullptr; _port = pstats_port; } diff --git a/pandatool/src/vrml/parse_vrml.cxx b/pandatool/src/vrml/parse_vrml.cxx index dfa2167e7f..1e55b68594 100644 --- a/pandatool/src/vrml/parse_vrml.cxx +++ b/pandatool/src/vrml/parse_vrml.cxx @@ -83,9 +83,9 @@ parse_vrml(Filename filename) { filename.set_text(); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *in = vfs->open_read_file(filename, true); - if (in == (istream *)NULL) { + if (in == nullptr) { nout << "Cannot open " << filename << " for reading.\n"; - return NULL; + return nullptr; } VrmlScene *result = parse_vrml(*in, filename); vfs->close_read_file(in); @@ -100,10 +100,10 @@ VrmlScene * parse_vrml(istream &in, const string &filename) { if (!get_standard_nodes()) { cerr << "Internal error--unable to parse VRML.\n"; - return NULL; + return nullptr; } - VrmlScene *scene = NULL; + VrmlScene *scene = nullptr; VrmlNodeType::pushNameSpace(); vrml_init_parser(in, filename); @@ -126,7 +126,7 @@ main(int argc, char *argv[]) { } VrmlScene *scene = parse_vrml(argv[1]); - if (scene == (VrmlScene *)NULL) { + if (scene == nullptr) { exit(1); } diff --git a/pandatool/src/vrml/vrmlLexer.lxx b/pandatool/src/vrml/vrmlLexer.lxx index e8b1290615..cd913fddc1 100644 --- a/pandatool/src/vrml/vrmlLexer.lxx +++ b/pandatool/src/vrml/vrmlLexer.lxx @@ -50,7 +50,7 @@ static int error_count = 0; static int warning_count = 0; // This is the pointer to the current input stream. -static istream *input_p = NULL; +static istream *input_p = nullptr; // This is the name of the vrml file we're parsing. We keep it so we // can print it out for error messages. @@ -123,7 +123,7 @@ vrmlyywarning(const string &msg) { // stdio FILE pointer. This is flex-specific. static void input_chars(char *buffer, int &result, int max_size) { - nassertv(input_p != NULL); + nassertv(input_p != nullptr); if (*input_p) { input_p->read(buffer, max_size); result = input_p->gcount(); @@ -143,7 +143,7 @@ input_chars(char *buffer, int &result, int max_size) { // Truncate it at the newline. char *end = strchr(current_line, '\n'); - if (end != NULL) { + if (end != nullptr) { *end = '\0'; } } @@ -164,7 +164,7 @@ input_chars(char *buffer, int &result, int max_size) { } int extract_int() { - return strtol(yytext, NULL, 0); + return strtol(yytext, nullptr, 0); } double extract_float() { @@ -275,7 +275,7 @@ idRestChar ([^\x00-\x20\x22\x23\x27\x2b-\x2c\x2e\x5b-\x5d\x7b\x7d]) TO { return TO; } IS { return IS; } ROUTE { return ROUTE; } -NULL { return SFN_NULL; } +nullptr { return SFN_NULL; } eventIn { return EVENTIN; } eventOut { return EVENTOUT; } field { return FIELD; } diff --git a/pandatool/src/vrml/vrmlNode.cxx b/pandatool/src/vrml/vrmlNode.cxx index d21061cd3a..628e09fb31 100644 --- a/pandatool/src/vrml/vrmlNode.cxx +++ b/pandatool/src/vrml/vrmlNode.cxx @@ -39,7 +39,7 @@ get_value(const char *field_name) const { // That field was not defined. Get the default value. const VrmlNodeType::NameTypeRec *field = _type->hasField(field_name); - if (field != NULL) { + if (field != nullptr) { return field->dflt; } diff --git a/pandatool/src/vrml/vrmlNodeType.cxx b/pandatool/src/vrml/vrmlNodeType.cxx index bfe4faf349..923570bd81 100644 --- a/pandatool/src/vrml/vrmlNodeType.cxx +++ b/pandatool/src/vrml/vrmlNodeType.cxx @@ -98,7 +98,7 @@ output_value(ostream &out, const VrmlFieldValue &value, int type, return out << "NULL"; case SFNodeRef::T_unnamed: - nassertr(value._sfnode._p != NULL, out); + nassertr(value._sfnode._p != nullptr, out); value._sfnode._p->output(out, indent); return out; @@ -145,7 +145,7 @@ output_value(ostream &out, const VrmlFieldValue &value, int type, VrmlNodeType::VrmlNodeType(const char *nm) { - nassertv(nm != NULL); + nassertv(nm != nullptr); name = strdup(nm); } @@ -176,7 +176,7 @@ VrmlNodeType::~VrmlNodeType() void VrmlNodeType::addToNameSpace(VrmlNodeType *_type) { - if (find(_type->getName()) != NULL) { + if (find(_type->getName()) != nullptr) { cerr << "PROTO " << _type->getName() << " already defined\n"; return; } @@ -191,7 +191,7 @@ VrmlNodeType::addToNameSpace(VrmlNodeType *_type) void VrmlNodeType::pushNameSpace() { - typeList.push_front(NULL); + typeList.push_front(nullptr); } void @@ -204,7 +204,7 @@ VrmlNodeType::popNameSpace() ++i; typeList.pop_front(); - if (nodeType == NULL) { + if (nodeType == nullptr) { break; } else { @@ -224,11 +224,11 @@ VrmlNodeType::find(const char *_name) plist::iterator i; for (i = typeList.begin(); i != typeList.end(); i++) { const VrmlNodeType *nt = *i; - if (nt != NULL && strcmp(nt->getName(),_name) == 0) { + if (nt != nullptr && strcmp(nt->getName(),_name) == 0) { return nt; } } - return NULL; + return nullptr; } void @@ -268,7 +268,7 @@ VrmlNodeType::add(plist &recs, const char *name, int type, NameTypeRec *r = new NameTypeRec; r->name = strdup(name); r->type = type; - if (dflt != NULL) { + if (dflt != nullptr) { r->dflt = *dflt; } else { memset(&r->dflt, 0, sizeof(r->dflt)); @@ -305,19 +305,19 @@ VrmlNodeType::hasExposedField(const char *name) const base = has(fields, name); sprintf(tmp, "set_%s\n", name); - nassertr(strlen(tmp) < 1000, NULL); + nassertr(strlen(tmp) < 1000, nullptr); set_name = has(eventIns, tmp); sprintf(tmp, "%s_changed\n", name); - nassertr(strlen(tmp) < 1000, NULL); + nassertr(strlen(tmp) < 1000, nullptr); name_changed = has(eventOuts, tmp); - if (base == NULL || set_name == NULL || name_changed == NULL) { - return NULL; + if (base == nullptr || set_name == nullptr || name_changed == nullptr) { + return nullptr; } if (base->type != set_name->type || base->type != name_changed->type) { - return NULL; + return nullptr; } return base; @@ -331,6 +331,6 @@ VrmlNodeType::has(const plist &recs, const char *name) const if (strcmp((*i)->name, name) == 0) return (*i); } - return NULL; + return nullptr; } diff --git a/pandatool/src/vrml/vrmlNodeType.h b/pandatool/src/vrml/vrmlNodeType.h index e455cf99ca..ae259af055 100644 --- a/pandatool/src/vrml/vrmlNodeType.h +++ b/pandatool/src/vrml/vrmlNodeType.h @@ -70,13 +70,13 @@ public: // Routines for adding/getting eventIns/Outs/fields void addEventIn(const char *name, int type, - const VrmlFieldValue *dflt = NULL); + const VrmlFieldValue *dflt = nullptr); void addEventOut(const char *name, int type, - const VrmlFieldValue *dflt = NULL); + const VrmlFieldValue *dflt = nullptr); void addField(const char *name, int type, - const VrmlFieldValue *dflt = NULL); + const VrmlFieldValue *dflt = nullptr); void addExposedField(const char *name, int type, - const VrmlFieldValue *dflt = NULL); + const VrmlFieldValue *dflt = nullptr); typedef struct { char *name; diff --git a/pandatool/src/vrml/vrmlParser.yxx b/pandatool/src/vrml/vrmlParser.yxx index f3984b47fc..d114028828 100644 --- a/pandatool/src/vrml/vrmlParser.yxx +++ b/pandatool/src/vrml/vrmlParser.yxx @@ -73,15 +73,15 @@ std::stack > currentNode; extern int expectToken; // This is where we store the parsed scene. -VrmlScene *parsed_scene = NULL; +VrmlScene *parsed_scene = nullptr; // Some helper routines defined below: static void beginProto(const char *); static void endProto(); -int addField(const char *type, const char *name, const VrmlFieldValue *dflt = NULL); -int addEventIn(const char *type, const char *name, const VrmlFieldValue *dflt = NULL); -int addEventOut(const char *type, const char *name, const VrmlFieldValue *dflt = NULL); -int addExposedField(const char *type, const char *name, const VrmlFieldValue *dflt = NULL); +int addField(const char *type, const char *name, const VrmlFieldValue *dflt = nullptr); +int addEventIn(const char *type, const char *name, const VrmlFieldValue *dflt = nullptr); +int addEventOut(const char *type, const char *name, const VrmlFieldValue *dflt = nullptr); +int addExposedField(const char *type, const char *name, const VrmlFieldValue *dflt = nullptr); int add(void (VrmlNodeType::*func)(const char *, int, const VrmlFieldValue *), const char *typeString, const char *name, const VrmlFieldValue *dflt); @@ -170,7 +170,7 @@ nodeDeclaration: { $$._p = $1; $$._type = SFNodeRef::T_unnamed; - $$._name = NULL; + $$._name = nullptr; } | DEF IDENTIFIER node { @@ -180,7 +180,7 @@ nodeDeclaration: } | USE IDENTIFIER { - $$._p = NULL; + $$._p = nullptr; $$._type = SFNodeRef::T_use; $$._name = $2; } @@ -314,9 +314,9 @@ fieldValue: | SFNODE nodeDeclaration { $$._sfnode = $2; } | SFNODE SFN_NULL { - $$._sfnode._p = NULL; + $$._sfnode._p = nullptr; $$._sfnode._type = SFNodeRef::T_null; - $$._sfnode._name = NULL; + $$._sfnode._name = nullptr; } | MFNODE mfnodeValue { $$._mf = $2; } | IS IDENTIFIER { free($2); } @@ -461,15 +461,15 @@ void enterNode(const char *nodeType) { const VrmlNodeType *t = VrmlNodeType::find(nodeType); - if (t == NULL) { + if (t == nullptr) { char tmp[1000]; sprintf(tmp, "Unknown node type '%s'", nodeType); vrmlyyerror(tmp); } FieldRec *fr = new FieldRec; fr->nodeType = t; - fr->fieldName = NULL; - fr->typeRec = NULL; + fr->fieldName = nullptr; + fr->typeRec = nullptr; currentField.push(fr); VrmlNode *node = new VrmlNode(t); @@ -480,11 +480,11 @@ VrmlNode * exitNode() { FieldRec *fr = currentField.top(); - nassertr(fr != NULL, NULL); + nassertr(fr != nullptr, nullptr); currentField.pop(); VrmlNode *node = currentNode.top(); - nassertr(node != NULL, NULL); + nassertr(node != nullptr, nullptr); currentNode.pop(); // cerr << "Just defined node:\n" << *node << "\n\n"; @@ -497,7 +497,7 @@ void inScript() { FieldRec *fr = currentField.top(); - if (fr->nodeType == NULL || + if (fr->nodeType == nullptr || strcmp(fr->nodeType->getName(), "Script") != 0) { vrmlyyerror("interface declaration outside of Script or prototype"); } @@ -507,11 +507,11 @@ void enterField(const char *fieldName) { FieldRec *fr = currentField.top(); - nassertv(fr != NULL); + nassertv(fr != nullptr); fr->fieldName = fieldName; - fr->typeRec = NULL; - if (fr->nodeType != NULL) { + fr->typeRec = nullptr; + if (fr->nodeType != nullptr) { // enterField is called when parsing eventIn and eventOut IS // declarations, in which case we don't need to do anything special-- // the IS IDENTIFIER will be returned from the lexer normally. @@ -521,7 +521,7 @@ enterField(const char *fieldName) const VrmlNodeType::NameTypeRec *typeRec = fr->nodeType->hasField(fieldName); - if (typeRec != NULL) { + if (typeRec != nullptr) { fr->typeRec = typeRec; // Let the lexer know what field type to expect: expect(typeRec->type); @@ -539,12 +539,12 @@ enterField(const char *fieldName) void storeField(const VrmlFieldValue &value) { FieldRec *fr = currentField.top(); - nassertv(fr != NULL); + nassertv(fr != nullptr); VrmlNode *node = currentNode.top(); - nassertv(node != NULL); + nassertv(node != nullptr); - if (fr->typeRec != NULL) { + if (fr->typeRec != nullptr) { node->_fields.push_back(VrmlNode::Field(fr->typeRec, value)); } } @@ -553,10 +553,10 @@ void exitField() { FieldRec *fr = currentField.top(); - nassertv(fr != NULL); + nassertv(fr != nullptr); - fr->fieldName = NULL; - fr->typeRec = NULL; + fr->fieldName = nullptr; + fr->typeRec = nullptr; } void diff --git a/pandatool/src/vrmlegg/indexedFaceSet.cxx b/pandatool/src/vrmlegg/indexedFaceSet.cxx index 96b5cc9194..35e03857fc 100644 --- a/pandatool/src/vrmlegg/indexedFaceSet.cxx +++ b/pandatool/src/vrmlegg/indexedFaceSet.cxx @@ -65,7 +65,7 @@ void IndexedFaceSet:: get_coord_values() { const VrmlNode *coord = _geometry->get_value("coord")._sfnode._p; - if (coord != NULL) { + if (coord != nullptr) { const MFArray *point = coord->get_value("point")._mf; MFArray::const_iterator ci; for (ci = point->begin(); ci != point->end(); ++ci) { @@ -153,7 +153,7 @@ get_vrml_uvs(const VrmlNode *texCoord_node, bool IndexedFaceSet:: get_colors() { const VrmlNode *color = _geometry->get_value("color")._sfnode._p; - if (color != NULL) { + if (color != nullptr) { // Vertex or face colors. pvector color_list; get_vrml_colors(color, _appearance._transparency, color_list); @@ -223,7 +223,7 @@ get_colors() { bool IndexedFaceSet:: get_normals() { const VrmlNode *normal = _geometry->get_value("normal")._sfnode._p; - if (normal != NULL) { + if (normal != nullptr) { // Vertex or face normals. pvector normal_list; get_vrml_normals(normal, normal_list); @@ -375,7 +375,7 @@ assign_per_vertex_normals() { bool IndexedFaceSet:: get_uvs() { const VrmlNode *texCoord = _geometry->get_value("texCoord")._sfnode._p; - if (texCoord != NULL) { + if (texCoord != nullptr) { // Vertex or face texCoords. pvector uv_list; get_vrml_uvs(texCoord, uv_list); @@ -496,7 +496,7 @@ make_polys(EggVertexPool *vpool, EggGroup *group, poly->set_color(_appearance._color); } - if (_appearance._tex != (EggTexture *)NULL) { + if (_appearance._tex != nullptr) { poly->set_texture(_appearance._tex); } @@ -535,7 +535,7 @@ make_polys(EggVertexPool *vpool, EggGroup *group, void IndexedFaceSet:: compute_normals(EggGroup *group) { const VrmlNode *normal = _geometry->get_value("normal")._sfnode._p; - if (normal == NULL) { + if (normal == nullptr) { // Compute normals. double creaseAngle = _geometry->get_value("creaseAngle")._sffloat; if (creaseAngle == 0.0) { diff --git a/pandatool/src/vrmlegg/vrmlAppearance.cxx b/pandatool/src/vrmlegg/vrmlAppearance.cxx index fff1ec48f2..06f9186c33 100644 --- a/pandatool/src/vrmlegg/vrmlAppearance.cxx +++ b/pandatool/src/vrmlegg/vrmlAppearance.cxx @@ -22,9 +22,9 @@ VRMLAppearance(const VrmlNode *appearance) { _color.set(1.0f, 1.0f, 1.0f, 1.0f); _has_tex_transform = false; - if (appearance != NULL) { + if (appearance != nullptr) { const VrmlNode *material = appearance->get_value("material")._sfnode._p; - if (material != NULL) { + if (material != nullptr) { _has_material = true; const double *c = material->get_value("diffuseColor")._sfvec; _transparency = material->get_value("transparency")._sffloat; @@ -32,7 +32,7 @@ VRMLAppearance(const VrmlNode *appearance) { } const VrmlNode *tex_transform = appearance->get_value("textureTransform")._sfnode._p; - if (tex_transform != NULL) { + if (tex_transform != nullptr) { if (strcmp(tex_transform->_type->getName(), "TextureTransform") == 0) { _has_tex_transform = true; const double *c = tex_transform->get_value("center")._sfvec; @@ -46,7 +46,7 @@ VRMLAppearance(const VrmlNode *appearance) { } const VrmlNode *texture = appearance->get_value("texture")._sfnode._p; - if (texture != NULL) { + if (texture != nullptr) { if (strcmp(texture->_type->getName(), "ImageTexture") == 0) { MFArray *url = texture->get_value("url")._mf; if (!url->empty()) { diff --git a/pandatool/src/vrmlegg/vrmlToEggConverter.cxx b/pandatool/src/vrmlegg/vrmlToEggConverter.cxx index 4083fb0847..150cf6da4c 100644 --- a/pandatool/src/vrmlegg/vrmlToEggConverter.cxx +++ b/pandatool/src/vrmlegg/vrmlToEggConverter.cxx @@ -88,7 +88,7 @@ convert_file(const Filename &filename) { clear_error(); VrmlScene *scene = parse_vrml(filename); - if (scene == (VrmlScene *)NULL) { + if (scene == nullptr) { return false; } @@ -127,8 +127,8 @@ get_all_defs(SFNodeRef &vrml, VRMLToEggConverter::Nodes &nodes) { switch (vrml._type) { case SFNodeRef::T_def: // If this is a node definition, add it to the map. - nassertv(vrml._name != NULL); - nassertv(vrml._p != NULL); + nassertv(vrml._name != nullptr); + nassertv(vrml._p != nullptr); /* This happens too often to bother yelling about it. ni = nodes.find(vrml._name); @@ -142,7 +142,7 @@ get_all_defs(SFNodeRef &vrml, VRMLToEggConverter::Nodes &nodes) { case SFNodeRef::T_use: // If it's a reference, resolve it. - nassertv(vrml._name != NULL); + nassertv(vrml._name != nullptr); ni = nodes.find(vrml._name); if (ni == nodes.end()) { cerr << "Unknown node reference: " << vrml._name << "\n"; @@ -161,7 +161,7 @@ get_all_defs(SFNodeRef &vrml, VRMLToEggConverter::Nodes &nodes) { } VrmlNode *node = vrml._p; - if (node != NULL) { + if (node != nullptr) { VrmlNode::Fields::iterator fi; for (fi = node->_fields.begin(); fi != node->_fields.end(); ++fi) { if ((*fi)._type->type == SFNODE) { @@ -185,7 +185,7 @@ void VRMLToEggConverter:: vrml_node(const SFNodeRef &vrml, EggGroupNode *egg, const LMatrix4d &net_transform) { const VrmlNode *node = vrml._p; - if (node != NULL) { + if (node != nullptr) { // Now add it to the egg file at this point. if (strcmp(node->_type->getName(), "Group") == 0) { vrml_grouping_node(vrml, egg, net_transform, @@ -213,9 +213,9 @@ vrml_grouping_node(const SFNodeRef &vrml, EggGroupNode *egg, (const VrmlNode *node, EggGroup *group, const LMatrix4d &net_transform)) { const VrmlNode *node = vrml._p; - nassertv(node != NULL); + nassertv(node != nullptr); string name; - if (vrml._name != NULL) { + if (vrml._name != nullptr) { name = vrml._name; } @@ -369,7 +369,7 @@ vrml_shape(const VrmlNode *node, EggGroup *group, const LMatrix4d &net_transform) { const VrmlNode *geometry = node->get_value("geometry")._sfnode._p; - if (geometry != NULL) { + if (geometry != nullptr) { VRMLAppearance appearance(node->get_value("appearance")._sfnode._p); if (strcmp(geometry->_type->getName(), "IndexedFaceSet") == 0) { diff --git a/pandatool/src/vrmlprogs/vrmlTrans.cxx b/pandatool/src/vrmlprogs/vrmlTrans.cxx index e03075b0e5..48ed508b93 100644 --- a/pandatool/src/vrmlprogs/vrmlTrans.cxx +++ b/pandatool/src/vrmlprogs/vrmlTrans.cxx @@ -53,7 +53,7 @@ run() { nout << "Reading " << _input_filename << "\n"; VrmlScene *scene = parse_vrml(_input_filename); - if (scene == (VrmlScene *)NULL) { + if (scene == nullptr) { nout << "Unable to read.\n"; exit(1); } diff --git a/pandatool/src/win-stats/winStats.cxx b/pandatool/src/win-stats/winStats.cxx index 5c54535210..0b22e9e0d7 100644 --- a/pandatool/src/win-stats/winStats.cxx +++ b/pandatool/src/win-stats/winStats.cxx @@ -19,7 +19,7 @@ #include static const char *toplevel_class_name = "pstats"; -static WinStatsServer *server = NULL; +static WinStatsServer *server = nullptr; /** * @@ -69,7 +69,7 @@ create_toplevel_window(HINSTANCE application) { HWND toplevel_window = CreateWindow(toplevel_class_name, window_name.c_str(), window_style, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - NULL, NULL, application, 0); + nullptr, nullptr, application, 0); if (!toplevel_window) { nout << "Could not create toplevel window!\n"; exit(1); @@ -79,7 +79,7 @@ create_toplevel_window(HINSTANCE application) { } int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); HWND toplevel_window = create_toplevel_window(application); ShowWindow(toplevel_window, SW_SHOWMINIMIZED); @@ -99,12 +99,12 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { } // Set up a timer to poll the pstats every so often. - SetTimer(toplevel_window, 1, 200, NULL); + SetTimer(toplevel_window, 1, 200, nullptr); // Now get lost in the Windows message loop. MSG msg; int retval; - retval = GetMessage(&msg, NULL, 0, 0); + retval = GetMessage(&msg, nullptr, 0, 0); while (retval != 0) { if (retval == -1) { nout << "Error processing message queue.\n"; @@ -112,7 +112,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { } TranslateMessage(&msg); DispatchMessage(&msg); - retval = GetMessage(&msg, NULL, 0, 0); + retval = GetMessage(&msg, nullptr, 0, 0); } return (0); @@ -123,5 +123,5 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { // doesn't squelch the stderr output. int main(int argc, char *argv[]) { - return WinMain(NULL, NULL, NULL, 0); + return WinMain(nullptr, nullptr, nullptr, 0); } diff --git a/pandatool/src/win-stats/winStatsGraph.cxx b/pandatool/src/win-stats/winStatsGraph.cxx index 393f905909..6eb19583f6 100644 --- a/pandatool/src/win-stats/winStatsGraph.cxx +++ b/pandatool/src/win-stats/winStatsGraph.cxx @@ -30,8 +30,8 @@ WinStatsGraph(WinStatsMonitor *monitor) : { _window = 0; _graph_window = 0; - _sizewe_cursor = LoadCursor(NULL, IDC_SIZEWE); - _hand_cursor = LoadCursor(NULL, IDC_HAND); + _sizewe_cursor = LoadCursor(nullptr, IDC_SIZEWE); + _hand_cursor = LoadCursor(nullptr, IDC_HAND); _bitmap = 0; _bitmap_dc = 0; @@ -59,7 +59,7 @@ WinStatsGraph(WinStatsMonitor *monitor) : */ WinStatsGraph:: ~WinStatsGraph() { - _monitor = (WinStatsMonitor *)NULL; + _monitor = nullptr; release_bitmap(); DeleteObject(_dark_pen); @@ -142,8 +142,8 @@ set_pause(bool pause) { */ void WinStatsGraph:: user_guide_bars_changed() { - InvalidateRect(_window, NULL, TRUE); - InvalidateRect(_graph_window, NULL, TRUE); + InvalidateRect(_window, nullptr, TRUE); + InvalidateRect(_graph_window, nullptr, TRUE); } /** @@ -160,8 +160,8 @@ clicked_label(int collector_index) { void WinStatsGraph:: close() { WinStatsMonitor *monitor = _monitor; - _monitor = (WinStatsMonitor *)NULL; - if (monitor != (WinStatsMonitor *)NULL) { + _monitor = nullptr; + if (monitor != nullptr) { monitor->remove_graph(this); } } @@ -228,7 +228,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { case WM_SIZE: move_label_stack(); - InvalidateRect(hwnd, NULL, TRUE); + InvalidateRect(hwnd, nullptr, TRUE); break; case WM_SIZING: @@ -286,7 +286,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { int16_t x = LOWORD(lparam); _left_margin += (x - _drag_start_x); _drag_start_x = x; - InvalidateRect(hwnd, NULL, TRUE); + InvalidateRect(hwnd, nullptr, TRUE); move_label_stack(); return 0; @@ -294,7 +294,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { int16_t x = LOWORD(lparam); _right_margin += (_drag_start_x - x); _drag_start_x = x; - InvalidateRect(hwnd, NULL, TRUE); + InvalidateRect(hwnd, nullptr, TRUE); return 0; } break; @@ -505,7 +505,7 @@ create_graph_window() { return; } - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); register_graph_window_class(application); string window_title = "graph"; @@ -514,7 +514,7 @@ create_graph_window() { _graph_window = CreateWindow(_graph_window_class_name, window_title.c_str(), window_style, 0, 0, 0, 0, - _window, NULL, application, 0); + _window, nullptr, application, 0); if (!_graph_window) { nout << "Could not create graph window!\n"; exit(1); @@ -539,9 +539,9 @@ register_graph_window_class(HINSTANCE application) { wc.style = CS_DBLCLKS; wc.lpfnWndProc = (WNDPROC)static_graph_window_proc; wc.hInstance = application; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; + wc.hCursor = LoadCursor(nullptr, IDC_ARROW); + wc.hbrBackground = nullptr; + wc.lpszMenuName = nullptr; wc.lpszClassName = _graph_window_class_name; // Reserve space to associate the this pointer with the window. @@ -561,7 +561,7 @@ register_graph_window_class(HINSTANCE application) { LONG WINAPI WinStatsGraph:: static_graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { WinStatsGraph *self = (WinStatsGraph *)GetWindowLongPtr(hwnd, 0); - if (self != (WinStatsGraph *)NULL && self->_graph_window == hwnd) { + if (self != nullptr && self->_graph_window == hwnd) { return self->graph_window_proc(hwnd, msg, wparam, lparam); } else { return DefWindowProc(hwnd, msg, wparam, lparam); diff --git a/pandatool/src/win-stats/winStatsLabel.cxx b/pandatool/src/win-stats/winStatsLabel.cxx index 3886cb8e15..5cd744c501 100644 --- a/pandatool/src/win-stats/winStatsLabel.cxx +++ b/pandatool/src/win-stats/winStatsLabel.cxx @@ -175,7 +175,7 @@ void WinStatsLabel:: set_highlight(bool highlight) { if (_highlight != highlight) { _highlight = highlight; - InvalidateRect(_window, NULL, TRUE); + InvalidateRect(_window, nullptr, TRUE); } } @@ -194,7 +194,7 @@ void WinStatsLabel:: set_mouse_within(bool mouse_within) { if (_mouse_within != mouse_within) { _mouse_within = mouse_within; - InvalidateRect(_window, NULL, TRUE); + InvalidateRect(_window, nullptr, TRUE); } } @@ -207,13 +207,13 @@ create_window(HWND parent_window) { return; } - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); register_window_class(application); _window = CreateWindow(_window_class_name, _text.c_str(), WS_CHILD | WS_CLIPSIBLINGS, 0, 0, 0, 0, - parent_window, NULL, application, 0); + parent_window, nullptr, application, 0); if (!_window) { nout << "Could not create Label window!\n"; exit(1); @@ -238,9 +238,9 @@ register_window_class(HINSTANCE application) { wc.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC)static_window_proc; wc.hInstance = application; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; + wc.hCursor = LoadCursor(nullptr, IDC_ARROW); + wc.hbrBackground = nullptr; + wc.lpszMenuName = nullptr; wc.lpszClassName = _window_class_name; // Reserve space to associate the this pointer with the window. @@ -260,7 +260,7 @@ register_window_class(HINSTANCE application) { LONG WINAPI WinStatsLabel:: static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { WinStatsLabel *self = (WinStatsLabel *)GetWindowLongPtr(hwnd, 0); - if (self != (WinStatsLabel *)NULL && self->_window == hwnd) { + if (self != nullptr && self->_window == hwnd) { return self->window_proc(hwnd, msg, wparam, lparam); } else { return DefWindowProc(hwnd, msg, wparam, lparam); diff --git a/pandatool/src/win-stats/winStatsLabelStack.cxx b/pandatool/src/win-stats/winStatsLabelStack.cxx index c3d8404aa2..063a7780e8 100644 --- a/pandatool/src/win-stats/winStatsLabelStack.cxx +++ b/pandatool/src/win-stats/winStatsLabelStack.cxx @@ -235,13 +235,13 @@ create_window(HWND parent_window) { return; } - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); register_window_class(application); _window = CreateWindow(_window_class_name, "label stack", WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, 0, 0, 0, - parent_window, NULL, application, 0); + parent_window, nullptr, application, 0); if (!_window) { nout << "Could not create Label Stack window!\n"; exit(1); @@ -266,8 +266,8 @@ register_window_class(HINSTANCE application) { wc.style = 0; wc.lpfnWndProc = (WNDPROC)static_window_proc; wc.hInstance = application; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.lpszMenuName = NULL; + wc.hCursor = LoadCursor(nullptr, IDC_ARROW); + wc.lpszMenuName = nullptr; wc.lpszClassName = _window_class_name; // Reserve space to associate the this pointer with the window. @@ -287,7 +287,7 @@ register_window_class(HINSTANCE application) { LONG WINAPI WinStatsLabelStack:: static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { WinStatsLabelStack *self = (WinStatsLabelStack *)GetWindowLongPtr(hwnd, 0); - if (self != (WinStatsLabelStack *)NULL && self->_window == hwnd) { + if (self != nullptr && self->_window == hwnd) { return self->window_proc(hwnd, msg, wparam, lparam); } else { return DefWindowProc(hwnd, msg, wparam, lparam); diff --git a/pandatool/src/win-stats/winStatsMonitor.cxx b/pandatool/src/win-stats/winStatsMonitor.cxx index bb412050df..1b2cedee37 100644 --- a/pandatool/src/win-stats/winStatsMonitor.cxx +++ b/pandatool/src/win-stats/winStatsMonitor.cxx @@ -122,7 +122,7 @@ got_bad_version(int client_major, int client_minor, } string message = str.str(); - MessageBox(NULL, message.c_str(), "Bad version", + MessageBox(nullptr, message.c_str(), "Bad version", MB_OK | MB_ICONINFORMATION | MB_SETFOREGROUND); } @@ -438,7 +438,7 @@ create_window() { return; } - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); register_window_class(application); _menu_bar = CreateMenu(); @@ -459,7 +459,7 @@ create_window() { _window = CreateWindow(_window_class_name, _window_title.c_str(), window_style, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - NULL, _menu_bar, application, 0); + nullptr, _menu_bar, application, 0); if (!_window) { nout << "Could not create monitor window!\n"; exit(1); @@ -497,8 +497,8 @@ setup_options_menu() { mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID | MIIM_CHECKMARKS | MIIM_STATE; mii.fType = MFT_STRING | MFT_RADIOCHECK; - mii.hbmpChecked = NULL; - mii.hbmpUnchecked = NULL; + mii.hbmpChecked = nullptr; + mii.hbmpUnchecked = nullptr; mii.fState = MFS_UNCHECKED; mii.wID = MI_time_ms; mii.dwTypeData = "ms"; @@ -531,8 +531,8 @@ setup_speed_menu() { mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID | MIIM_CHECKMARKS | MIIM_STATE; mii.fType = MFT_STRING | MFT_RADIOCHECK; - mii.hbmpChecked = NULL; - mii.hbmpUnchecked = NULL; + mii.hbmpChecked = nullptr; + mii.hbmpUnchecked = nullptr; mii.fState = MFS_UNCHECKED; mii.wID = MI_speed_1; mii.dwTypeData = "1"; @@ -603,9 +603,9 @@ register_window_class(HINSTANCE application) { wc.style = 0; wc.lpfnWndProc = (WNDPROC)static_window_proc; wc.hInstance = application; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hCursor = LoadCursor(nullptr, IDC_ARROW); wc.hbrBackground = (HBRUSH)COLOR_BACKGROUND; - wc.lpszMenuName = NULL; + wc.lpszMenuName = nullptr; wc.lpszClassName = _window_class_name; // Reserve space to associate the this pointer with the window. @@ -625,7 +625,7 @@ register_window_class(HINSTANCE application) { LONG WINAPI WinStatsMonitor:: static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { WinStatsMonitor *self = (WinStatsMonitor *)GetWindowLongPtr(hwnd, 0); - if (self != (WinStatsMonitor *)NULL && self->_window == hwnd) { + if (self != nullptr && self->_window == hwnd) { return self->window_proc(hwnd, msg, wparam, lparam); } else { return DefWindowProc(hwnd, msg, wparam, lparam); diff --git a/pandatool/src/win-stats/winStatsPianoRoll.cxx b/pandatool/src/win-stats/winStatsPianoRoll.cxx index ef61895a6c..7c81b65fdf 100644 --- a/pandatool/src/win-stats/winStatsPianoRoll.cxx +++ b/pandatool/src/win-stats/winStatsPianoRoll.cxx @@ -171,7 +171,7 @@ draw_bar(int row, int from_x, int to_x) { */ void WinStatsPianoRoll:: end_draw() { - InvalidateRect(_graph_window, NULL, FALSE); + InvalidateRect(_graph_window, nullptr, FALSE); } /** @@ -443,7 +443,7 @@ draw_guide_bar(HDC hdc, const PStatGraph::GuideBar &bar) { SelectObject(hdc, _dark_pen); break; } - MoveToEx(hdc, x, 0, NULL); + MoveToEx(hdc, x, 0, nullptr); LineTo(hdc, x, get_ysize()); } } @@ -497,7 +497,7 @@ create_window() { return; } - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); register_window_class(application); const PStatClientData *client_data = @@ -520,7 +520,7 @@ create_window() { CW_USEDEFAULT, CW_USEDEFAULT, win_rect.right - win_rect.left, win_rect.bottom - win_rect.top, - WinStatsGraph::_monitor->get_window(), NULL, application, 0); + WinStatsGraph::_monitor->get_window(), nullptr, application, 0); if (!_window) { nout << "Could not create PianoRoll window!\n"; exit(1); @@ -550,9 +550,9 @@ register_window_class(HINSTANCE application) { wc.style = 0; wc.lpfnWndProc = (WNDPROC)static_window_proc; wc.hInstance = application; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hCursor = LoadCursor(nullptr, IDC_ARROW); wc.hbrBackground = (HBRUSH)COLOR_BACKGROUND; - wc.lpszMenuName = NULL; + wc.lpszMenuName = nullptr; wc.lpszClassName = _window_class_name; // Reserve space to associate the this pointer with the window. @@ -572,7 +572,7 @@ register_window_class(HINSTANCE application) { LONG WINAPI WinStatsPianoRoll:: static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { WinStatsPianoRoll *self = (WinStatsPianoRoll *)GetWindowLongPtr(hwnd, 0); - if (self != (WinStatsPianoRoll *)NULL && self->_window == hwnd) { + if (self != nullptr && self->_window == hwnd) { return self->window_proc(hwnd, msg, wparam, lparam); } else { return DefWindowProc(hwnd, msg, wparam, lparam); diff --git a/pandatool/src/win-stats/winStatsStripChart.cxx b/pandatool/src/win-stats/winStatsStripChart.cxx index 066673aecd..79411a03d7 100644 --- a/pandatool/src/win-stats/winStatsStripChart.cxx +++ b/pandatool/src/win-stats/winStatsStripChart.cxx @@ -246,7 +246,7 @@ copy_region(int start_x, int end_x, int dest_x) { // Also shift the brush origin over, so we still get proper dithering. _brush_origin += (dest_x - start_x); - SetBrushOrgEx(_bitmap_dc, _brush_origin, 0, NULL); + SetBrushOrgEx(_bitmap_dc, _brush_origin, 0, nullptr); RECT rect = { dest_x, 0, dest_x + end_x - start_x, get_ysize() @@ -596,7 +596,7 @@ move_graph_window(int graph_left, int graph_top, int graph_xsize, int graph_ysiz _left_margin, _top_margin - _check_box_height - 1, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW); - InvalidateRect(_smooth_check_box, NULL, TRUE); + InvalidateRect(_smooth_check_box, nullptr, TRUE); } } @@ -623,7 +623,7 @@ draw_guide_bar(HDC hdc, int from_x, int to_x, SelectObject(hdc, _dark_pen); break; } - MoveToEx(hdc, from_x, y, NULL); + MoveToEx(hdc, from_x, y, nullptr); LineTo(hdc, to_x + 1, y); } } @@ -684,7 +684,7 @@ create_window() { return; } - HINSTANCE application = GetModuleHandle(NULL); + HINSTANCE application = GetModuleHandle(nullptr); register_window_class(application); string window_title = get_title_text(); @@ -703,7 +703,7 @@ create_window() { CW_USEDEFAULT, CW_USEDEFAULT, win_rect.right - win_rect.left, win_rect.bottom - win_rect.top, - WinStatsGraph::_monitor->get_window(), NULL, application, 0); + WinStatsGraph::_monitor->get_window(), nullptr, application, 0); if (!_window) { nout << "Could not create StripChart window!\n"; exit(1); @@ -716,7 +716,7 @@ create_window() { CreateWindow("BUTTON", "", WS_CHILD | BS_AUTOCHECKBOX, 0, 0, _check_box_width, _check_box_height, - _window, NULL, application, 0); + _window, nullptr, application, 0); // Ensure that the window is on top of the stack. SetWindowPos(_window, HWND_TOP, 0, 0, 0, 0, @@ -739,9 +739,9 @@ register_window_class(HINSTANCE application) { wc.style = 0; wc.lpfnWndProc = (WNDPROC)static_window_proc; wc.hInstance = application; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hCursor = LoadCursor(nullptr, IDC_ARROW); wc.hbrBackground = (HBRUSH)COLOR_BACKGROUND; - wc.lpszMenuName = NULL; + wc.lpszMenuName = nullptr; wc.lpszClassName = _window_class_name; // Reserve space to associate the this pointer with the window. @@ -761,7 +761,7 @@ register_window_class(HINSTANCE application) { LONG WINAPI WinStatsStripChart:: static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { WinStatsStripChart *self = (WinStatsStripChart *)GetWindowLongPtr(hwnd, 0); - if (self != (WinStatsStripChart *)NULL && self->_window == hwnd) { + if (self != nullptr && self->_window == hwnd) { return self->window_proc(hwnd, msg, wparam, lparam); } else { return DefWindowProc(hwnd, msg, wparam, lparam); diff --git a/pandatool/src/xfile/xFile.cxx b/pandatool/src/xfile/xFile.cxx index 049fe26780..17fc9f1e34 100644 --- a/pandatool/src/xfile/xFile.cxx +++ b/pandatool/src/xfile/xFile.cxx @@ -69,7 +69,7 @@ read(Filename filename) { filename.set_text(); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); istream *in = vfs->open_read_file(filename, true); - if (in == (istream *)NULL) { + if (in == nullptr) { xfile_cat.error() << "Cannot open " << filename << " for reading.\n"; return false; @@ -171,17 +171,17 @@ write(ostream &out) const { */ XFileTemplate *XFile:: find_template(const string &name) const { - XFileTemplate *standard = (XFileTemplate *)NULL; + XFileTemplate *standard = nullptr; const XFile *standard_templates = get_standard_templates(); if (standard_templates != this) { standard = standard_templates->find_template(name); } XFileNode *child = find_child(name); - if (child != (XFileNode *)NULL && + if (child != nullptr && child->is_of_type(XFileTemplate::get_class_type())) { XFileTemplate *xtemplate = DCAST(XFileTemplate, child); - if (standard != (XFileTemplate *)NULL && xtemplate->matches(standard)) { + if (standard != nullptr && xtemplate->matches(standard)) { // If the template matches a standard template, return the standard // instead. The assumption is that code may expect a certain naming // scheme for the data elements of the standard template, so we want to @@ -200,7 +200,7 @@ find_template(const string &name) const { */ XFileTemplate *XFile:: find_template(const WindowsGuid &guid) const { - XFileTemplate *standard = (XFileTemplate *)NULL; + XFileTemplate *standard = nullptr; const XFile *standard_templates = get_standard_templates(); if (standard_templates != this) { standard = standard_templates->find_template(guid); @@ -211,7 +211,7 @@ find_template(const WindowsGuid &guid) const { if (gi != _nodes_by_guid.end() && (*gi).second->is_of_type(XFileTemplate::get_class_type())) { XFileTemplate *xtemplate = DCAST(XFileTemplate, (*gi).second); - if (standard != (XFileTemplate *)NULL && xtemplate->matches(standard)) { + if (standard != nullptr && xtemplate->matches(standard)) { // If the template matches a standard template, return the standard // instead. The assumption is that code may expect a certain naming // scheme for the data elements of the standard template, so we want to @@ -251,12 +251,12 @@ find_standard_template(const WindowsGuid &guid) { XFileDataNodeTemplate *XFile:: find_data_object(const string &name) const { XFileNode *child = find_descendent(name); - if (child != (XFileNode *)NULL && + if (child != nullptr && child->is_of_type(XFileDataNodeTemplate::get_class_type())) { return DCAST(XFileDataNodeTemplate, child); } - return NULL; + return nullptr; } /** @@ -272,7 +272,7 @@ find_data_object(const WindowsGuid &guid) const { return DCAST(XFileDataNodeTemplate, (*gi).second); } - return NULL; + return nullptr; } /** @@ -438,7 +438,7 @@ write_header(ostream &out) const { */ const XFile *XFile:: get_standard_templates() { - if (_standard_templates == (XFile *)NULL) { + if (_standard_templates == nullptr) { // The standardTemplates.x file has been compiled into this binary. // Extract it out. diff --git a/pandatool/src/xfile/xFileArrayDef.I b/pandatool/src/xfile/xFileArrayDef.I index bb06c75fb8..f231f0c6ba 100644 --- a/pandatool/src/xfile/xFileArrayDef.I +++ b/pandatool/src/xfile/xFileArrayDef.I @@ -17,7 +17,7 @@ INLINE XFileArrayDef:: XFileArrayDef(int fixed_size) : _fixed_size(fixed_size), - _dynamic_size(NULL) + _dynamic_size(nullptr) { } @@ -37,7 +37,7 @@ XFileArrayDef(XFileDataDef *dynamic_size) : */ INLINE bool XFileArrayDef:: is_fixed_size() const { - return (_dynamic_size == (XFileDataDef *)NULL); + return (_dynamic_size == nullptr); } /** @@ -55,6 +55,6 @@ get_fixed_size() const { */ INLINE XFileDataDef *XFileArrayDef:: get_dynamic_size() const { - nassertr(!is_fixed_size(), NULL); + nassertr(!is_fixed_size(), nullptr); return _dynamic_size; } diff --git a/pandatool/src/xfile/xFileArrayDef.cxx b/pandatool/src/xfile/xFileArrayDef.cxx index 7bde81d7e0..da5abf9f51 100644 --- a/pandatool/src/xfile/xFileArrayDef.cxx +++ b/pandatool/src/xfile/xFileArrayDef.cxx @@ -29,7 +29,7 @@ get_size(const XFileNode::PrevData &prev_data) const { XFileNode::PrevData::const_iterator pi; pi = prev_data.find(_dynamic_size); nassertr_always(pi != prev_data.end(), 0); - nassertr((*pi).second != (XFileDataObject *)NULL, 0); + nassertr((*pi).second != nullptr, 0); return (*pi).second->i(); } } diff --git a/pandatool/src/xfile/xFileDataDef.cxx b/pandatool/src/xfile/xFileDataDef.cxx index 4e47187b6a..6c133347ef 100644 --- a/pandatool/src/xfile/xFileDataDef.cxx +++ b/pandatool/src/xfile/xFileDataDef.cxx @@ -175,7 +175,7 @@ repack_data(XFileDataObject *object, break; } - if (data_value != (XFileDataObject *)NULL) { + if (data_value != nullptr) { object->add_element(data_value); prev_data[this] = data_value; } @@ -219,7 +219,7 @@ fill_zero_data(XFileDataObject *object) const { break; } - if (data_value != (XFileDataObject *)NULL) { + if (data_value != nullptr) { object->add_element(data_value); } @@ -270,13 +270,13 @@ PT(XFileDataObject) XFileDataDef:: unpack_integer_value(const XFileParseDataList &parse_data_list, const XFileDataDef::PrevData &prev_data, size_t &index, size_t &sub_index) const { - nassertr(index < parse_data_list._list.size(), NULL); + nassertr(index < parse_data_list._list.size(), nullptr); const XFileParseData &parse_data = parse_data_list._list[index]; PT(XFileDataObject) data_value; if ((parse_data._parse_flags & XFileParseData::PF_int) != 0) { - nassertr(sub_index < parse_data._int_list.size(), NULL); + nassertr(sub_index < parse_data._int_list.size(), nullptr); int value = parse_data._int_list[sub_index]; data_value = new XFileDataObjectInteger(this, value); @@ -301,13 +301,13 @@ PT(XFileDataObject) XFileDataDef:: unpack_double_value(const XFileParseDataList &parse_data_list, const XFileDataDef::PrevData &prev_data, size_t &index, size_t &sub_index) const { - nassertr(index < parse_data_list._list.size(), NULL); + nassertr(index < parse_data_list._list.size(), nullptr); const XFileParseData &parse_data = parse_data_list._list[index]; PT(XFileDataObject) data_value; if ((parse_data._parse_flags & XFileParseData::PF_double) != 0) { - nassertr(sub_index < parse_data._double_list.size(), NULL); + nassertr(sub_index < parse_data._double_list.size(), nullptr); double value = parse_data._double_list[sub_index]; data_value = new XFileDataObjectDouble(this, value); @@ -318,7 +318,7 @@ unpack_double_value(const XFileParseDataList &parse_data_list, } } else if ((parse_data._parse_flags & XFileParseData::PF_int) != 0) { - nassertr(sub_index < parse_data._int_list.size(), NULL); + nassertr(sub_index < parse_data._int_list.size(), nullptr); int value = parse_data._int_list[sub_index]; data_value = new XFileDataObjectDouble(this, value); @@ -343,7 +343,7 @@ PT(XFileDataObject) XFileDataDef:: unpack_string_value(const XFileParseDataList &parse_data_list, const XFileDataDef::PrevData &prev_data, size_t &index, size_t &sub_index) const { - nassertr(index < parse_data_list._list.size(), NULL); + nassertr(index < parse_data_list._list.size(), nullptr); const XFileParseData &parse_data = parse_data_list._list[index]; PT(XFileDataObject) data_value; @@ -373,7 +373,7 @@ unpack_template_value(const XFileParseDataList &parse_data_list, PrevData nested_prev_data(prev_data); if (!_template->repack_data(data_value, parse_data_list, nested_prev_data, index, sub_index)) { - return NULL; + return nullptr; } return data_value.p(); @@ -394,7 +394,7 @@ unpack_value(const XFileParseDataList &parse_data_list, int array_index, if (array_index == (int)_array_def.size()) { if (index >= parse_data_list._list.size()) { xyyerror("Not enough data elements in structure at " + get_name()); - return NULL; + return nullptr; } data_value = (this->*unpack_method)(parse_data_list, prev_data, index, sub_index); @@ -414,7 +414,7 @@ unpack_value(const XFileParseDataList &parse_data_list, int array_index, unpack_value(parse_data_list, array_index + 1, prev_data, index, sub_index, unpack_method); - if (array_element == (XFileDataObject *)NULL) { + if (array_element == nullptr) { return data_value; } data_value->add_element(array_element); @@ -456,7 +456,7 @@ zero_fill_template_value() const { PT(XFileDataObject) data_value = new XFileDataNodeTemplate(get_x_file(), get_name(), _template); if (!_template->fill_zero_data(data_value)) { - return NULL; + return nullptr; } return data_value; @@ -485,8 +485,8 @@ zero_fill_value(int array_index, for (int i = 0; i < array_size; i++) { PT(XFileDataObject) array_element = zero_fill_value(array_index + 1, zero_fill_method); - if (array_element == (XFileDataObject *)NULL) { - return NULL; + if (array_element == nullptr) { + return nullptr; } data_value->add_element(array_element); } diff --git a/pandatool/src/xfile/xFileDataDef.h b/pandatool/src/xfile/xFileDataDef.h index 7d489ceafd..93d85c2b36 100644 --- a/pandatool/src/xfile/xFileDataDef.h +++ b/pandatool/src/xfile/xFileDataDef.h @@ -46,7 +46,7 @@ public: }; INLINE XFileDataDef(XFile *x_file, const string &name, - Type type, XFileTemplate *xtemplate = NULL); + Type type, XFileTemplate *xtemplate = nullptr); virtual ~XFileDataDef(); virtual void clear(); diff --git a/pandatool/src/xfile/xFileDataNodeTemplate.cxx b/pandatool/src/xfile/xFileDataNodeTemplate.cxx index 1e0e153438..9f09cc0583 100644 --- a/pandatool/src/xfile/xFileDataNodeTemplate.cxx +++ b/pandatool/src/xfile/xFileDataNodeTemplate.cxx @@ -205,7 +205,7 @@ get_num_elements() const { */ XFileDataObject *XFileDataNodeTemplate:: get_element(int n) { - nassertr(n >= 0 && n < (int)_nested_elements.size(), NULL); + nassertr(n >= 0 && n < (int)_nested_elements.size(), nullptr); return _nested_elements[n]; } @@ -222,5 +222,5 @@ get_element(const string &name) { xfile_cat.warning() << "\"" << name << "\" not a member of " << _template->get_name() << "\n"; - return NULL; + return nullptr; } diff --git a/pandatool/src/xfile/xFileDataObject.I b/pandatool/src/xfile/xFileDataObject.I index ebe25becc1..e68f383e1c 100644 --- a/pandatool/src/xfile/xFileDataObject.I +++ b/pandatool/src/xfile/xFileDataObject.I @@ -258,7 +258,7 @@ size() const { INLINE const XFileDataObject &XFileDataObject:: operator [] (int n) const { const XFileDataObject *element = ((XFileDataObject *)this)->get_element(n); - nassertr(element != (XFileDataObject *)NULL, *this); + nassertr(element != nullptr, *this); return *element; } @@ -270,7 +270,7 @@ operator [] (int n) const { INLINE const XFileDataObject &XFileDataObject:: operator [] (const string &name) const { const XFileDataObject *element = ((XFileDataObject *)this)->get_element(name); - nassertr(element != (XFileDataObject *)NULL, *this); + nassertr(element != nullptr, *this); return *element; } @@ -281,7 +281,7 @@ operator [] (const string &name) const { INLINE XFileDataObject &XFileDataObject:: operator [] (int n) { XFileDataObject *element = get_element(n); - nassertr(element != (XFileDataObject *)NULL, *this); + nassertr(element != nullptr, *this); return *element; } @@ -293,7 +293,7 @@ operator [] (int n) { INLINE XFileDataObject &XFileDataObject:: operator [] (const string &name) { XFileDataObject *element = get_element(name); - nassertr(element != (XFileDataObject *)NULL, *this); + nassertr(element != nullptr, *this); return *element; } diff --git a/pandatool/src/xfile/xFileDataObject.cxx b/pandatool/src/xfile/xFileDataObject.cxx index e170b901ea..5abfa1e9ab 100644 --- a/pandatool/src/xfile/xFileDataObject.cxx +++ b/pandatool/src/xfile/xFileDataObject.cxx @@ -93,7 +93,7 @@ add_string(const string &string_value) { XFileDataObject &XFileDataObject:: add_Vector(XFile *x_file, const LVecBase3d &vector) { XFileTemplate *xtemplate = XFile::find_standard_template("Vector"); - nassertr(xtemplate != (XFileTemplate *)NULL, *this); + nassertr(xtemplate != nullptr, *this); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(x_file, "", xtemplate); add_element(node); @@ -110,7 +110,7 @@ add_Vector(XFile *x_file, const LVecBase3d &vector) { XFileDataObject &XFileDataObject:: add_MeshFace(XFile *x_file) { XFileTemplate *xtemplate = XFile::find_standard_template("MeshFace"); - nassertr(xtemplate != (XFileTemplate *)NULL, *this); + nassertr(xtemplate != nullptr, *this); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(x_file, "", xtemplate); add_element(node); @@ -125,7 +125,7 @@ add_MeshFace(XFile *x_file) { XFileDataObject &XFileDataObject:: add_IndexedColor(XFile *x_file, int index, const LColor &color) { XFileTemplate *xtemplate = XFile::find_standard_template("IndexedColor"); - nassertr(xtemplate != (XFileTemplate *)NULL, *this); + nassertr(xtemplate != nullptr, *this); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(x_file, "", xtemplate); add_element(node); @@ -143,7 +143,7 @@ add_IndexedColor(XFile *x_file, int index, const LColor &color) { XFileDataObject &XFileDataObject:: add_Coords2d(XFile *x_file, const LVecBase2d &coords) { XFileTemplate *xtemplate = XFile::find_standard_template("Coords2d"); - nassertr(xtemplate != (XFileTemplate *)NULL, *this); + nassertr(xtemplate != nullptr, *this); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(x_file, "", xtemplate); add_element(node); @@ -288,7 +288,7 @@ get_element(int n) { xfile_cat.warning() << "Looking for [" << n << "] within data object of type " << get_type_name() << ", does not support nested objects.\n"; - return NULL; + return nullptr; } /** @@ -300,5 +300,5 @@ get_element(const string &name) { xfile_cat.warning() << "Looking for [\"" << name << "\"] within data object of type " << get_type_name() << ", does not support nested objects.\n"; - return NULL; + return nullptr; } diff --git a/pandatool/src/xfile/xFileDataObject.h b/pandatool/src/xfile/xFileDataObject.h index ac7d8001f3..6b40c5f399 100644 --- a/pandatool/src/xfile/xFileDataObject.h +++ b/pandatool/src/xfile/xFileDataObject.h @@ -29,7 +29,7 @@ class XFileDataDef; */ class XFileDataObject : virtual public ReferenceCount { public: - INLINE XFileDataObject(const XFileDataDef *data_def = NULL); + INLINE XFileDataObject(const XFileDataDef *data_def = nullptr); virtual ~XFileDataObject(); INLINE const XFileDataDef *get_data_def() const; diff --git a/pandatool/src/xfile/xFileDataObjectArray.cxx b/pandatool/src/xfile/xFileDataObjectArray.cxx index 90d9948860..10aa13d5f2 100644 --- a/pandatool/src/xfile/xFileDataObjectArray.cxx +++ b/pandatool/src/xfile/xFileDataObjectArray.cxx @@ -98,6 +98,6 @@ get_num_elements() const { */ XFileDataObject *XFileDataObjectArray:: get_element(int n) { - nassertr(n >= 0 && n < (int)_nested_elements.size(), NULL); + nassertr(n >= 0 && n < (int)_nested_elements.size(), nullptr); return _nested_elements[n]; } diff --git a/pandatool/src/xfile/xFileNode.I b/pandatool/src/xfile/xFileNode.I index b23bea089d..6032a749e2 100644 --- a/pandatool/src/xfile/xFileNode.I +++ b/pandatool/src/xfile/xFileNode.I @@ -34,7 +34,7 @@ get_num_children() const { */ INLINE XFileNode *XFileNode:: get_child(int n) const { - nassertr(n >= 0 && n < (int)_children.size(), NULL); + nassertr(n >= 0 && n < (int)_children.size(), nullptr); return _children[n]; } @@ -55,6 +55,6 @@ get_num_objects() const { */ INLINE XFileDataNode *XFileNode:: get_object(int n) const { - nassertr(n >= 0 && n < (int)_objects.size(), NULL); + nassertr(n >= 0 && n < (int)_objects.size(), nullptr); return _objects[n]; } diff --git a/pandatool/src/xfile/xFileNode.cxx b/pandatool/src/xfile/xFileNode.cxx index 61d9d17d8f..a67c7488d0 100644 --- a/pandatool/src/xfile/xFileNode.cxx +++ b/pandatool/src/xfile/xFileNode.cxx @@ -57,7 +57,7 @@ find_child(const string &name) const { return get_child((*ni).second); } - return NULL; + return nullptr; } /** @@ -96,19 +96,19 @@ find_child_index(const XFileNode *child) const { XFileNode *XFileNode:: find_descendent(const string &name) const { XFileNode *child = find_child(name); - if (child != (XFileNode *)NULL) { + if (child != nullptr) { return child; } Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { XFileNode *child = (*ci)->find_descendent(name); - if (child != (XFileNode *)NULL){ + if (child != nullptr){ return child; } } - return NULL; + return nullptr; } /** @@ -297,7 +297,7 @@ matches(const XFileNode *other) const { XFileDataNode *XFileNode:: add_Mesh(const string &name) { XFileTemplate *xtemplate = XFile::find_standard_template("Mesh"); - nassertr(xtemplate != (XFileTemplate *)NULL, NULL); + nassertr(xtemplate != nullptr, nullptr); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(get_x_file(), name, xtemplate); add_child(node); @@ -312,7 +312,7 @@ add_Mesh(const string &name) { XFileDataNode *XFileNode:: add_MeshNormals(const string &name) { XFileTemplate *xtemplate = XFile::find_standard_template("MeshNormals"); - nassertr(xtemplate != (XFileTemplate *)NULL, NULL); + nassertr(xtemplate != nullptr, nullptr); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(get_x_file(), name, xtemplate); add_child(node); @@ -327,7 +327,7 @@ add_MeshNormals(const string &name) { XFileDataNode *XFileNode:: add_MeshVertexColors(const string &name) { XFileTemplate *xtemplate = XFile::find_standard_template("MeshVertexColors"); - nassertr(xtemplate != (XFileTemplate *)NULL, NULL); + nassertr(xtemplate != nullptr, nullptr); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(get_x_file(), name, xtemplate); add_child(node); @@ -342,7 +342,7 @@ add_MeshVertexColors(const string &name) { XFileDataNode *XFileNode:: add_MeshTextureCoords(const string &name) { XFileTemplate *xtemplate = XFile::find_standard_template("MeshTextureCoords"); - nassertr(xtemplate != (XFileTemplate *)NULL, NULL); + nassertr(xtemplate != nullptr, nullptr); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(get_x_file(), name, xtemplate); add_child(node); @@ -357,7 +357,7 @@ add_MeshTextureCoords(const string &name) { XFileDataNode *XFileNode:: add_MeshMaterialList(const string &name) { XFileTemplate *xtemplate = XFile::find_standard_template("MeshMaterialList"); - nassertr(xtemplate != (XFileTemplate *)NULL, NULL); + nassertr(xtemplate != nullptr, nullptr); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(get_x_file(), name, xtemplate); add_child(node); @@ -374,7 +374,7 @@ add_Material(const string &name, const LColor &face_color, double power, const LRGBColor &specular_color, const LRGBColor &emissive_color) { XFileTemplate *xtemplate = XFile::find_standard_template("Material"); - nassertr(xtemplate != (XFileTemplate *)NULL, NULL); + nassertr(xtemplate != nullptr, nullptr); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(get_x_file(), name, xtemplate); add_child(node); @@ -401,7 +401,7 @@ add_Material(const string &name, const LColor &face_color, XFileDataNode *XFileNode:: add_TextureFilename(const string &name, const Filename &filename) { XFileTemplate *xtemplate = XFile::find_standard_template("TextureFilename"); - nassertr(xtemplate != (XFileTemplate *)NULL, NULL); + nassertr(xtemplate != nullptr, nullptr); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(get_x_file(), name, xtemplate); add_child(node); @@ -418,7 +418,7 @@ add_TextureFilename(const string &name, const Filename &filename) { XFileDataNode *XFileNode:: add_Frame(const string &name) { XFileTemplate *xtemplate = XFile::find_standard_template("Frame"); - nassertr(xtemplate != (XFileTemplate *)NULL, NULL); + nassertr(xtemplate != nullptr, nullptr); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(get_x_file(), name, xtemplate); add_child(node); @@ -434,7 +434,7 @@ XFileDataNode *XFileNode:: add_FrameTransformMatrix(const LMatrix4d &mat) { XFileTemplate *xtemplate = XFile::find_standard_template("FrameTransformMatrix"); - nassertr(xtemplate != (XFileTemplate *)NULL, NULL); + nassertr(xtemplate != nullptr, nullptr); XFileDataNodeTemplate *node = new XFileDataNodeTemplate(get_x_file(), "", xtemplate); add_child(node); diff --git a/pandatool/src/xfile/xFileTemplate.I b/pandatool/src/xfile/xFileTemplate.I index 3d7e52ec61..d56ff28984 100644 --- a/pandatool/src/xfile/xFileTemplate.I +++ b/pandatool/src/xfile/xFileTemplate.I @@ -65,6 +65,6 @@ get_num_options() const { */ INLINE XFileTemplate *XFileTemplate:: get_option(int n) const { - nassertr(n >= 0 && n < (int)_options.size(), NULL); + nassertr(n >= 0 && n < (int)_options.size(), nullptr); return _options[n]; } diff --git a/pandatool/src/xfile/xLexer.lxx b/pandatool/src/xfile/xLexer.lxx index e3d72709b0..614679ff34 100644 --- a/pandatool/src/xfile/xLexer.lxx +++ b/pandatool/src/xfile/xLexer.lxx @@ -34,7 +34,7 @@ static int error_count = 0; static int warning_count = 0; // This is the pointer to the current input stream. -static istream *input_p = NULL; +static istream *input_p = nullptr; // This is the name of the x file we're parsing. We keep it so we // can print it out for error messages. @@ -115,7 +115,7 @@ xyywarning(const string &msg) { // stdio FILE pointer. This is flex-specific. static void input_chars(char *buffer, int &result, int max_size) { - nassertv(input_p != NULL); + nassertv(input_p != nullptr); if (*input_p) { input_p->read(buffer, max_size); result = input_p->gcount(); @@ -136,7 +136,7 @@ input_chars(char *buffer, int &result, int max_size) { // Truncate it at the newline. char *end = strchr(x_current_line, '\n'); - if (end != NULL) { + if (end != nullptr) { *end = '\0'; } } diff --git a/pandatool/src/xfile/xParser.yxx b/pandatool/src/xfile/xParser.yxx index a98f39d177..0f151c70ec 100644 --- a/pandatool/src/xfile/xParser.yxx +++ b/pandatool/src/xfile/xParser.yxx @@ -30,8 +30,8 @@ #define YYINITDEPTH 1000 #define YYMAXDEPTH 1000 -static XFile *x_file = (XFile *)NULL; -static XFileNode *current_node = (XFileNode *)NULL; +static XFile *x_file = nullptr; +static XFileNode *current_node = nullptr; static PT(XFileDataDef) current_data_def; //////////////////////////////////////////////////////////////////// @@ -47,8 +47,8 @@ x_init_parser(istream &in, const string &filename, XFile &file) { void x_cleanup_parser() { - x_file = (XFile *)NULL; - current_node = (XFileNode *)NULL; + x_file = nullptr; + current_node = nullptr; } %} @@ -172,7 +172,7 @@ template_reference: singleword_name optional_multiword_name TOKEN_SEMICOLON { XFileTemplate *xtemplate = x_file->find_template($1); - if (xtemplate == (XFileTemplate *)NULL) { + if (xtemplate == nullptr) { yyerror("Unknown template: " + $1); } else { current_data_def = new XFileDataDef(x_file, $2, XFileDataDef::T_template, xtemplate); @@ -237,7 +237,7 @@ array_data_type: | singleword_name multiword_name { XFileTemplate *xtemplate = x_file->find_template($1); - if (xtemplate == (XFileTemplate *)NULL) { + if (xtemplate == nullptr) { yyerror("Unknown template: " + $1); } else { current_data_def = new XFileDataDef(x_file, $2, XFileDataDef::T_template, xtemplate); @@ -263,7 +263,7 @@ dimension_size: | multiword_name { XFileNode *data_def = current_node->find_child($1); - if (data_def == (XFileNode *)NULL) { + if (data_def == nullptr) { yyerror("Unknown identifier: " + $1); } else { current_data_def->add_array_def(XFileArrayDef(DCAST(XFileDataDef, data_def))); @@ -284,7 +284,7 @@ template_option_part: singleword_name { XFileTemplate *xtemplate = x_file->find_template($1); - if (xtemplate == (XFileTemplate *)NULL) { + if (xtemplate == nullptr) { yyerror("Unknown template: " + $1); } else { DCAST(XFileTemplate, current_node)->add_option(xtemplate); @@ -293,7 +293,7 @@ template_option_part: | singleword_name class_id { XFileTemplate *xtemplate = x_file->find_template($2); - if (xtemplate == (XFileTemplate *)NULL) { + if (xtemplate == nullptr) { yyerror("Unknown template: " + $1); } else { if (xtemplate->get_name() != $1) { @@ -351,7 +351,7 @@ object: XFileTemplate *xtemplate = x_file->find_template($1); $$ = current_node; - if (xtemplate == (XFileTemplate *)NULL) { + if (xtemplate == nullptr) { yyerror("Unknown template: " + $1); } else { XFileDataNodeTemplate *templ = @@ -438,7 +438,7 @@ data_reference: multiword_name { XFileDataNodeTemplate *data_object = x_file->find_data_object($1); - if (data_object == (XFileDataObject *)NULL) { + if (data_object == nullptr) { yyerror("Unknown data_object: " + $1); } @@ -447,7 +447,7 @@ data_reference: | multiword_name class_id { XFileDataNodeTemplate *data_object = x_file->find_data_object($2); - if (data_object == (XFileDataObject *)NULL) { + if (data_object == nullptr) { yyerror("Unknown data_object: " + $1); } else { if (data_object->get_name() != $1) { diff --git a/pandatool/src/xfileegg/xFileAnimationSet.cxx b/pandatool/src/xfileegg/xFileAnimationSet.cxx index 25e9136c94..112b61ba12 100644 --- a/pandatool/src/xfileegg/xFileAnimationSet.cxx +++ b/pandatool/src/xfileegg/xFileAnimationSet.cxx @@ -63,7 +63,7 @@ create_hierarchy(XFileToEggConverter *converter) { const FrameData &table = (*ji).second; EggXfmSAnim *anim_table = get_table(joint_name); - if (anim_table == (EggXfmSAnim *)NULL) { + if (anim_table == nullptr) { xfile_cat.warning() << "Frame " << joint_name << ", named by animation data, not defined.\n"; } else { @@ -81,7 +81,7 @@ create_hierarchy(XFileToEggConverter *converter) { for (ti = _tables.begin(); ti != _tables.end(); ++ti) { EggXfmSAnim *anim_table = (*ti).second._table; EggGroup *joint = (*ti).second._joint; - if (anim_table->empty() && joint != (EggGroup *)NULL) { + if (anim_table->empty() && joint != nullptr) { // If there's no animation data, assign the rest transform. anim_table->add_data(joint->get_transform3d()); } @@ -104,7 +104,7 @@ get_table(const string &joint_name) const { if (ti != _tables.end()) { return (*ti).second._table; } - return NULL; + return nullptr; } /** diff --git a/pandatool/src/xfileegg/xFileMesh.cxx b/pandatool/src/xfileegg/xFileMesh.cxx index 7298ef118b..9ddf66bc0e 100644 --- a/pandatool/src/xfileegg/xFileMesh.cxx +++ b/pandatool/src/xfileegg/xFileMesh.cxx @@ -33,7 +33,7 @@ XFileMesh(CoordinateSystem cs) : _cs(cs) { _has_colors = false; _has_uvs = false; _has_materials = false; - _egg_parent = NULL; + _egg_parent = nullptr; } /** @@ -257,7 +257,7 @@ set_egg_parent(EggGroupNode *egg_parent) { */ bool XFileMesh:: create_polygons(XFileToEggConverter *converter) { - nassertr(_egg_parent != (EggGroupNode *)NULL, false); + nassertr(_egg_parent != nullptr, false); EggVertexPool *vpool = new EggVertexPool(get_name()); _egg_parent->add_child(vpool); @@ -279,7 +279,7 @@ create_polygons(XFileToEggConverter *converter) { continue; } XFileVertex *vertex = _vertices[vertex_index]; - XFileNormal *normal = (XFileNormal *)NULL; + XFileNormal *normal = nullptr; if (normal_index >= 0 && normal_index < (int)_normals.size()) { normal = _normals[normal_index]; @@ -299,7 +299,7 @@ create_polygons(XFileToEggConverter *converter) { temp_vtx.set_uv(uv); } - if (normal != (XFileNormal *)NULL && normal->_has_normal) { + if (normal != nullptr && normal->_has_normal) { temp_vtx.set_normal(normal->_normal); } @@ -318,7 +318,7 @@ create_polygons(XFileToEggConverter *converter) { WeightMap::const_iterator wmi = data._weight_map.find(vertex_index); if (wmi != data._weight_map.end()) { EggGroup *joint = converter->find_joint(data._joint_name); - if (joint != (EggGroup *)NULL) { + if (joint != nullptr) { double weight = (*wmi).second; LMatrix4d mat = data._matrix_offset; mat *= joint->get_node_to_vertex(); @@ -366,7 +366,7 @@ create_polygons(XFileToEggConverter *converter) { WeightMap::const_iterator wmi = data._weight_map.find(vertex_index); if (wmi != data._weight_map.end()) { EggGroup *joint = converter->find_joint(data._joint_name); - if (joint != (EggGroup *)NULL) { + if (joint != nullptr) { double weight = (*wmi).second; joint->ref_vertex(egg_vtx, weight); } @@ -433,7 +433,7 @@ get_num_materials() const { */ XFileMaterial *XFileMesh:: get_material(int n) const { - nassertr(n >= 0 && n < (int)_materials.size(), (XFileMaterial *)NULL); + nassertr(n >= 0 && n < (int)_materials.size(), nullptr); return _materials[n]; } diff --git a/pandatool/src/xfileegg/xFileToEggConverter.cxx b/pandatool/src/xfileegg/xFileToEggConverter.cxx index 5b1c6459af..2f65643c0f 100644 --- a/pandatool/src/xfileegg/xFileToEggConverter.cxx +++ b/pandatool/src/xfileegg/xFileToEggConverter.cxx @@ -34,7 +34,7 @@ XFileToEggConverter() { _make_char = false; _frame_rate = 0.0; _x_file = new XFile(true); - _dart_node = NULL; + _dart_node = nullptr; } /** @@ -46,7 +46,7 @@ XFileToEggConverter(const XFileToEggConverter ©) : _make_char(copy._make_char) { _x_file = new XFile(true); - _dart_node = NULL; + _dart_node = nullptr; } /** @@ -226,9 +226,9 @@ find_joint(const string &joint_name) { ji = _joints.find(joint_name); if (ji != _joints.end()) { EggGroup *joint = (*ji).second; - if (joint == (EggGroup *)NULL) { + if (joint == nullptr) { // An invalid joint detected earlier. - return NULL; + return nullptr; } return joint; @@ -240,9 +240,9 @@ find_joint(const string &joint_name) { xfile_cat.warning() << "Joint name " << joint_name << " in animation data is undefined.\n"; } - _joints[joint_name] = NULL; + _joints[joint_name] = nullptr; - return NULL; + return nullptr; } /** diff --git a/pandatool/src/xfileprogs/xFileToEgg.cxx b/pandatool/src/xfileprogs/xFileToEgg.cxx index fd0c90e77a..d3734fa803 100644 --- a/pandatool/src/xfileprogs/xFileToEgg.cxx +++ b/pandatool/src/xfileprogs/xFileToEgg.cxx @@ -51,7 +51,7 @@ XFileToEgg() : "Specify the frame rate of the resulting animation. If this is " "omitted or 0, the frame rate is inferred from the file itself; but " "note that the file must contain evenly-spaced keyframes.", - &XFileToEgg::dispatch_double, NULL, &_frame_rate); + &XFileToEgg::dispatch_double, nullptr, &_frame_rate); add_option ("anim", "", 0, From a9ffb9630b1556583e805e2fc7d850d5a94af434 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Wed, 30 May 2018 14:49:41 -0600 Subject: [PATCH 231/247] dtool: Generate code using nullptr over NULL/0 --- .../functionWriterPtrFromPython.cxx | 6 +- .../interrogate/functionWriterPtrToPython.cxx | 4 +- dtool/src/interrogate/interfaceMaker.cxx | 9 +- .../src/interrogate/interfaceMakerPython.cxx | 4 +- .../interfaceMakerPythonNative.cxx | 368 +++++++++--------- .../interrogate/interfaceMakerPythonNative.h | 2 +- .../interrogate/interfaceMakerPythonObj.cxx | 26 +- .../interfaceMakerPythonSimple.cxx | 16 +- dtool/src/interrogate/interrogateBuilder.cxx | 4 +- dtool/src/interrogate/interrogate_module.cxx | 22 +- dtool/src/prckeys/makePrcKey.cxx | 2 +- 11 files changed, 230 insertions(+), 233 deletions(-) diff --git a/dtool/src/interrogate/functionWriterPtrFromPython.cxx b/dtool/src/interrogate/functionWriterPtrFromPython.cxx index d39d5f47dd..c27ef1efe5 100644 --- a/dtool/src/interrogate/functionWriterPtrFromPython.cxx +++ b/dtool/src/interrogate/functionWriterPtrFromPython.cxx @@ -64,13 +64,13 @@ write_code(ostream &out) { << _name << "(PyObject *obj, "; ppointer->output_instance(out, "addr", &parser); out << ") {\n" - << " if (obj != (PyObject *)NULL && PyInstance_Check(obj)) {\n" + << " if (obj != nullptr && PyInstance_Check(obj)) {\n" // << " PyClassObject *in_class = ((PyInstanceObject // *)obj)->in_class;\n" << " PyObject *in_dict = ((PyInstanceObject *)obj)->in_dict;\n" - << " if (in_dict != (PyObject *)NULL && PyDict_Check(in_dict)) {\n" + << " if (in_dict != nullptr && PyDict_Check(in_dict)) {\n" << " PyObject *thisobj = PyDict_GetItemString(in_dict, \"this\");\n" - << " if (thisobj != (PyObject *)NULL && PyLong_Check(thisobj)) {\n" + << " if (thisobj != nullptr && PyLong_Check(thisobj)) {\n" << " (*addr) = (" << _pointer_type->get_local_name(&parser) << ")PyLong_AsVoidPtr(thisobj);\n" << " return 1;\n" diff --git a/dtool/src/interrogate/functionWriterPtrToPython.cxx b/dtool/src/interrogate/functionWriterPtrToPython.cxx index 23a8304528..aac2984dbc 100644 --- a/dtool/src/interrogate/functionWriterPtrToPython.cxx +++ b/dtool/src/interrogate/functionWriterPtrToPython.cxx @@ -62,8 +62,8 @@ write_code(ostream &out) { out << ", int caller_manages) {\n" << " PyObject *" << classobj_func << "();\n" << " PyObject *classobj = " << classobj_func << "();\n" - << " PyInstanceObject *instance = (PyInstanceObject *)PyInstance_New(classobj, (PyObject *)NULL, (PyObject *)NULL);\n" - << " if (instance != (PyInstanceObject *)NULL) {\n" + << " PyInstanceObject *instance = (PyInstanceObject *)PyInstance_New(classobj, nullptr, nullptr);\n" + << " if (instance != nullptr) {\n" << " PyObject *thisptr = PyLong_FromVoidPtr((void*)addr);\n" << " PyDict_SetItemString(instance->in_dict, \"this\", thisptr);\n" << " }\n" diff --git a/dtool/src/interrogate/interfaceMaker.cxx b/dtool/src/interrogate/interfaceMaker.cxx index 172b8c1375..69ab181286 100644 --- a/dtool/src/interrogate/interfaceMaker.cxx +++ b/dtool/src/interrogate/interfaceMaker.cxx @@ -755,8 +755,7 @@ manage_return_value(ostream &out, int indent_level, out << " = " << return_expr << ";\n"; indent(out, indent_level) - << "if (" << return_expr << " != (" - << remap->_return_type->get_new_type()->get_local_name(&parser) << ")NULL) {\n"; + << "if (" << return_expr << " != nullptr) {\n"; indent(out, indent_level + 2) << "(" << return_expr << ")->ref();\n"; indent(out, indent_level) @@ -813,8 +812,7 @@ output_ref(ostream &out, int indent_level, FunctionRemap *remap, // attempt to ref it. indent(out, indent_level) - << "if (" << varname << " != (" - << remap->_return_type->get_new_type()->get_local_name(&parser) << ")NULL) {\n"; + << "if (" << varname << " != nullptr) {\n"; indent(out, indent_level + 2) << varname << "->ref();\n"; indent(out, indent_level) @@ -847,8 +845,7 @@ output_unref(ostream &out, int indent_level, FunctionRemap *remap, // attempt to ref it. indent(out, indent_level) - << "if (" << varname << " != (" - << remap->_return_type->get_new_type()->get_local_name(&parser) << ")NULL) {\n"; + << "if (" << varname << " != nullptr) {\n"; if (TypeManager::is_pointer_to_base(remap->_return_type->get_temporary_type())) { // We're sure the reference count won't reach zero since we have it diff --git a/dtool/src/interrogate/interfaceMakerPython.cxx b/dtool/src/interrogate/interfaceMakerPython.cxx index 37125a7e64..31f59c0785 100644 --- a/dtool/src/interrogate/interfaceMakerPython.cxx +++ b/dtool/src/interrogate/interfaceMakerPython.cxx @@ -57,13 +57,13 @@ test_assert(ostream &out, int indent_level) const { indent(out, indent_level + 2) << "notify->clear_assert_failed();\n"; indent(out, indent_level + 2) - << "return (PyObject *)NULL;\n"; + << "return nullptr;\n"; indent(out, indent_level) << "}\n"; indent(out, indent_level) << "if (PyErr_Occurred()) {\n"; indent(out, indent_level + 2) - << "return (PyObject *)NULL;\n"; + << "return nullptr;\n"; indent(out, indent_level) << "}\n"; out << "#endif\n"; diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 13ee124698..5d6c353088 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -738,7 +738,7 @@ write_python_instance(ostream &out, int indent_level, const string &return_expr, // will be grabbing the type index (which would obviously crash when // called on a NULL pointer), so we do it here. indent(out, indent_level) - << "if (" << return_expr << " == NULL) {\n"; + << "if (" << return_expr << " == nullptr) {\n"; indent(out, indent_level) << " Py_INCREF(Py_None);\n"; indent(out, indent_level) @@ -751,7 +751,7 @@ write_python_instance(ostream &out, int indent_level, const string &return_expr, indent(out, indent_level) << " ReferenceCount *rc = " << return_expr << "->as_reference_count();\n"; indent(out, indent_level) - << " bool is_refcount = (rc != (ReferenceCount *)NULL);\n"; + << " bool is_refcount = (rc != nullptr);\n"; indent(out, indent_level) << " if (is_refcount) {\n"; indent(out, indent_level) @@ -862,24 +862,24 @@ write_prototypes(ostream &out_code, ostream *out_h) { if (TypeManager::is_reference_count(type)) { out_code << "inline static bool Dtool_ConstCoerce_" << safe_name << "(PyObject *args, CPT(" << class_name << ") &coerced) {\n" - << " nassertr(Dtool_Ptr_" << safe_name << " != NULL, false);\n" - << " nassertr(Dtool_Ptr_" << safe_name << "->_Dtool_ConstCoerce != NULL, false);\n" + << " nassertr(Dtool_Ptr_" << safe_name << " != nullptr, false);\n" + << " nassertr(Dtool_Ptr_" << safe_name << "->_Dtool_ConstCoerce != nullptr, false);\n" << " return ((bool (*)(PyObject *, CPT(" << class_name << ") &))Dtool_Ptr_" << safe_name << "->_Dtool_ConstCoerce)(args, coerced);\n" << "}\n"; if (has_coerce > 1) { out_code << "inline static bool Dtool_Coerce_" << safe_name << "(PyObject *args, PT(" << class_name << ") &coerced) {\n" - << " nassertr(Dtool_Ptr_" << safe_name << " != NULL, false);\n" - << " nassertr(Dtool_Ptr_" << safe_name << "->_Dtool_Coerce != NULL, false);\n" + << " nassertr(Dtool_Ptr_" << safe_name << " != nullptr, false);\n" + << " nassertr(Dtool_Ptr_" << safe_name << "->_Dtool_Coerce != nullptr, false);\n" << " return ((bool (*)(PyObject *, PT(" << class_name << ") &))Dtool_Ptr_" << safe_name << "->_Dtool_Coerce)(args, coerced);\n" << "}\n"; } } else { out_code << "inline static " << class_name << " *Dtool_Coerce_" << safe_name << "(PyObject *args, " << class_name << " &coerced) {\n" - << " nassertr(Dtool_Ptr_" << safe_name << " != NULL, NULL);\n" - << " nassertr(Dtool_Ptr_" << safe_name << "->_Dtool_Coerce != NULL, NULL);\n" + << " nassertr(Dtool_Ptr_" << safe_name << " != nullptr, nullptr);\n" + << " nassertr(Dtool_Ptr_" << safe_name << "->_Dtool_Coerce != nullptr, nullptr);\n" << " return ((" << class_name << " *(*)(PyObject *, " << class_name << " &))Dtool_Ptr_" << safe_name << "->_Dtool_Coerce)(args, coerced);\n" << "}\n"; } @@ -1096,8 +1096,8 @@ write_class_details(ostream &out, Object *obj) { out << "static void *Dtool_UpcastInterface_" << ClassName << "(PyObject *self, Dtool_PyTypedObject *requested_type) {\n"; out << " Dtool_PyTypedObject *type = DtoolInstance_TYPE(self);\n"; out << " if (type != &Dtool_" << ClassName << ") {\n"; - out << " printf(\"" << ClassName << " ** Bad Source Type-- Requesting Conversion from %s to %s\\n\", Py_TYPE(self)->tp_name, requested_type->_PyType.tp_name); fflush(NULL);\n";; - out << " return NULL;\n"; + out << " printf(\"" << ClassName << " ** Bad Source Type-- Requesting Conversion from %s to %s\\n\", Py_TYPE(self)->tp_name, requested_type->_PyType.tp_name); fflush(nullptr);\n";; + out << " return nullptr;\n"; out << " }\n"; out << "\n"; out << " " << cClassName << " *local_this = (" << cClassName << " *)DtoolInstance_VOID_PTR(self);\n"; @@ -1113,12 +1113,12 @@ write_class_details(ostream &out, Object *obj) { } } - out << " return NULL;\n"; + out << " return nullptr;\n"; out << "}\n\n"; out << "static void *Dtool_DowncastInterface_" << ClassName << "(void *from_this, Dtool_PyTypedObject *from_type) {\n"; - out << " if (from_this == NULL || from_type == NULL) {\n"; - out << " return NULL;\n"; + out << " if (from_this == nullptr || from_type == nullptr) {\n"; + out << " return nullptr;\n"; out << " }\n"; out << " if (from_type == Dtool_Ptr_" << ClassName << ") {\n"; out << " return from_this;\n"; @@ -1131,7 +1131,7 @@ write_class_details(ostream &out, Object *obj) { out << " }\n"; } } - out << " return (void *) NULL;\n"; + out << " return nullptr;\n"; out << "}\n\n"; } } @@ -1225,7 +1225,7 @@ write_sub_module(ostream &out, Object *obj) { _external_imports.insert(TypeManager::resolve_type(wrapped_itype._cpptype)); class_ptr = "Dtool_Ptr_" + class_name; - out << " assert(" << class_ptr << " != NULL);\n"; + out << " assert(" << class_ptr << " != nullptr);\n"; } else { class_ptr = "&Dtool_" + class_name; @@ -1462,7 +1462,7 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { out << " {\"Dtool_AddToDictionary\", &Dtool_AddToDictionary, METH_VARARGS, \"Used to add items into a tp_dict\"},\n"; } - out << " {NULL, NULL, 0, NULL}\n" << "};\n\n"; + out << " {nullptr, nullptr, 0, nullptr}\n" << "};\n\n"; out << "struct LibraryDef " << def->library_name << "_moddef = {python_simple_funcs};\n"; if (out_h != nullptr) { @@ -1486,10 +1486,10 @@ write_module(ostream &out, ostream *out_h, InterrogateModuleDef *def) { << "static struct PyModuleDef python_native_module = {\n" << " PyModuleDef_HEAD_INIT,\n" << " \"" << def->module_name << "\",\n" - << " NULL,\n" + << " nullptr,\n" << " -1,\n" - << " NULL,\n" - << " NULL, NULL, NULL, NULL\n" + << " nullptr,\n" + << " nullptr, nullptr, nullptr, nullptr\n" << "};\n" << "\n" << "#ifdef _WIN32\n" @@ -1501,7 +1501,7 @@ write_module(ostream &out, ostream *out_h, InterrogateModuleDef *def) { << "#endif\n" << "\n" << "PyObject *PyInit_" << def->module_name << "() {\n" - << " LibraryDef *refs[] = {&" << def->library_name << "_moddef, NULL};\n" + << " LibraryDef *refs[] = {&" << def->library_name << "_moddef, nullptr};\n" << " PyObject *module = Dtool_PyModuleInitHelper(refs, &python_native_module);\n" << " Dtool_" << def->library_name << "_BuildInstants(module);\n" << " return module;\n" @@ -1518,7 +1518,7 @@ write_module(ostream &out, ostream *out_h, InterrogateModuleDef *def) { << "#endif\n" << "\n" << "void init" << def->module_name << "() {\n" - << " LibraryDef *refs[] = {&" << def->library_name << "_moddef, NULL};\n" + << " LibraryDef *refs[] = {&" << def->library_name << "_moddef, nullptr};\n" << " PyObject *module = Dtool_PyModuleInitHelper(refs, \"" << def->module_name << "\");\n" << " Dtool_" << def->library_name << "_BuildInstants(module);\n" << "}\n" @@ -1694,18 +1694,18 @@ write_module_class(ostream &out, Object *obj) { if (obj->_protocol_types & Object::PT_make_copy) { if (!got_copy) { - out << " {\"__copy__\", ©_from_make_copy, METH_NOARGS, NULL},\n"; + out << " {\"__copy__\", ©_from_make_copy, METH_NOARGS, nullptr},\n"; got_copy = true; } } else if (obj->_protocol_types & Object::PT_copy_constructor) { if (!got_copy) { - out << " {\"__copy__\", ©_from_copy_constructor, METH_NOARGS, NULL},\n"; + out << " {\"__copy__\", ©_from_copy_constructor, METH_NOARGS, nullptr},\n"; got_copy = true; } } if (got_copy && !got_deepcopy) { - out << " {\"__deepcopy__\", &map_deepcopy_to_copy, METH_VARARGS, NULL},\n"; + out << " {\"__deepcopy__\", &map_deepcopy_to_copy, METH_VARARGS, nullptr},\n"; } MakeSeqs::iterator msi; @@ -1727,14 +1727,14 @@ write_module_class(ostream &out, Object *obj) { string name1 = methodNameFromCppName(seq_name, export_class_name, false); string name2 = methodNameFromCppName(seq_name, export_class_name, true); out << " {\"" << name1 - << "\", (PyCFunction) &" << make_seq->_name << ", " << flags << ", NULL},\n"; + << "\", (PyCFunction) &" << make_seq->_name << ", " << flags << ", nullptr},\n"; if (name1 != name2) { out << " { \"" << name2 - << "\", (PyCFunction) &" << make_seq->_name << ", " << flags << ", NULL},\n"; + << "\", (PyCFunction) &" << make_seq->_name << ", " << flags << ", nullptr},\n"; } } - out << " {NULL, NULL, 0, NULL}\n" + out << " {nullptr, nullptr, 0, nullptr}\n" << "};\n\n"; int num_derivations = obj->_itype.number_of_derivations(); @@ -1792,9 +1792,9 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static PyObject *" << def._wrapper_name << "(PyObject *self) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n\n"; int return_flags = RF_pyobject | RF_err_null; @@ -1812,7 +1812,7 @@ write_module_class(ostream &out, Object *obj) { output_quoted(out, 6, expected_params); out << ");\n"; out << " }\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << "}\n\n"; } break; @@ -1833,19 +1833,19 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static PyObject *" << def._wrapper_name << "(PyObject *self, PyObject *arg) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; if (rfi->second._wrapper_type != WT_one_param) { // WT_binary_operator means we must return NotImplemented, instead // of raising an exception, if the this pointer doesn't match. // This is for things like __sub__, which Python likes to call on // the wrong-type objects. out << " DTOOL_Call_ExtractThisPointerForType(self, &Dtool_" << ClassName << ", (void **)&local_this);\n"; - out << " if (local_this == NULL) {\n"; + out << " if (local_this == nullptr) {\n"; out << " Py_INCREF(Py_NotImplemented);\n"; out << " return Py_NotImplemented;\n"; } else { out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; } out << " }\n"; @@ -1862,7 +1862,7 @@ write_module_class(ostream &out, Object *obj) { output_quoted(out, 6, expected_params); out << ");\n"; out << " }\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; } out << "}\n\n"; } @@ -1876,7 +1876,7 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static int " << def._wrapper_name << "(PyObject *self, PyObject *arg, PyObject *arg2) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return -1;\n"; out << " }\n\n"; @@ -1899,7 +1899,7 @@ write_module_class(ostream &out, Object *obj) { } out << " // Determine whether to call __setattr__ or __delattr__.\n"; - out << " if (arg2 != (PyObject *)NULL) { // __setattr__\n"; + out << " if (arg2 != nullptr) { // __setattr__\n"; if (!setattr_remaps.empty()) { out << " PyObject *args = PyTuple_Pack(2, arg, arg2);\n"; @@ -1956,17 +1956,17 @@ write_module_class(ostream &out, Object *obj) { out << "//////////////////\n"; out << "static PyObject *" << def._wrapper_name << "(PyObject *self, PyObject *arg) {\n"; out << " PyObject *res = PyObject_GenericGetAttr(self, arg);\n"; - out << " if (res != NULL) {\n"; + out << " if (res != nullptr) {\n"; out << " return res;\n"; out << " }\n"; out << " if (_PyErr_OCCURRED() != PyExc_AttributeError) {\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n"; out << " PyErr_Clear();\n\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n\n"; string expected_params; @@ -1975,7 +1975,7 @@ write_module_class(ostream &out, Object *obj) { RF_pyobject | RF_err_null, true); // out << " PyErr_Clear();\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << "}\n\n"; } break; @@ -1988,9 +1988,9 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static PyObject *" << def._wrapper_name << "(PyObject *self, Py_ssize_t index) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n\n"; // This is a getitem or setitem of a sequence type. This means we @@ -1999,7 +1999,7 @@ write_module_class(ostream &out, Object *obj) { // assumption that Python makes). out << " if (index < 0 || index >= (Py_ssize_t) local_this->size()) {\n"; out << " PyErr_SetString(PyExc_IndexError, \"" << ClassName << " index out of range\");\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n"; string expected_params; @@ -2011,7 +2011,7 @@ write_module_class(ostream &out, Object *obj) { output_quoted(out, 6, expected_params); out << ");\n"; out << " }\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << "}\n\n"; } break; @@ -2024,7 +2024,7 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static int " << def._wrapper_name << "(PyObject *self, Py_ssize_t index, PyObject *arg) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return -1;\n"; out << " }\n\n"; @@ -2052,7 +2052,7 @@ write_module_class(ostream &out, Object *obj) { } string expected_params; - out << " if (arg != (PyObject *)NULL) { // __setitem__\n"; + out << " if (arg != nullptr) { // __setitem__\n"; write_function_forset(out, setitem_remaps, 2, 2, expected_params, 4, true, true, AT_single_arg, RF_int, false, true, "index"); out << " } else { // __delitem__\n"; @@ -2078,7 +2078,7 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static Py_ssize_t " << def._wrapper_name << "(PyObject *self) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return -1;\n"; out << " }\n\n"; @@ -2098,7 +2098,7 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static int " << def._wrapper_name << "(PyObject *self, PyObject *arg, PyObject *arg2) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return -1;\n"; out << " }\n\n"; @@ -2121,7 +2121,7 @@ write_module_class(ostream &out, Object *obj) { } string expected_params; - out << " if (arg2 != (PyObject *)NULL) { // __setitem__\n"; + out << " if (arg2 != nullptr) { // __setitem__\n"; out << " PyObject *args = PyTuple_Pack(2, arg, arg2);\n"; write_function_forset(out, setitem_remaps, 2, 2, expected_params, 4, true, true, AT_varargs, RF_int | RF_decref_args, false); @@ -2155,7 +2155,7 @@ write_module_class(ostream &out, Object *obj) { const char *container = ""; if (remap->_has_this) { - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return -1;\n"; out << " }\n\n"; @@ -2183,7 +2183,7 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static int " << def._wrapper_name << "(PyObject *self, Py_buffer *buffer, int flags) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return -1;\n"; out << " }\n\n"; @@ -2252,7 +2252,7 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static void " << def._wrapper_name << "(PyObject *self, Py_buffer *buffer) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return;\n"; out << " }\n\n"; @@ -2336,9 +2336,9 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static PyObject *" << def._wrapper_name << "(PyObject *self, PyObject *arg, PyObject *arg2) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " DTOOL_Call_ExtractThisPointerForType(self, &Dtool_" << ClassName << ", (void **)&local_this);\n"; - out << " if (local_this == NULL) {\n"; + out << " if (local_this == nullptr) {\n"; // WT_ternary_operator means we must return NotImplemented, instead // of raising an exception, if the this pointer doesn't match. This // is for things like __pow__, which Python likes to call on the @@ -2364,7 +2364,7 @@ write_module_class(ostream &out, Object *obj) { string expected_params; - out << " if (arg2 != (PyObject *)NULL && arg2 != Py_None) {\n"; + out << " if (arg2 != nullptr && arg2 != Py_None) {\n"; out << " PyObject *args = PyTuple_Pack(2, arg, arg2);\n"; write_function_forset(out, two_param_remaps, 2, 2, expected_params, 4, true, true, AT_varargs, RF_pyobject | RF_err_null | RF_decref_args, true); @@ -2379,7 +2379,7 @@ write_module_class(ostream &out, Object *obj) { output_quoted(out, 6, expected_params); out << ");\n"; out << " }\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << "}\n\n"; } break; @@ -2399,9 +2399,9 @@ write_module_class(ostream &out, Object *obj) { const char *container = ""; if (remap->_has_this) { - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " DTOOL_Call_ExtractThisPointerForType(self, &Dtool_" << ClassName << ", (void **) &local_this);\n"; - out << " if (local_this == NULL) {\n"; + out << " if (local_this == nullptr) {\n"; out << " return 0;\n"; out << " }\n\n"; container = "local_this"; @@ -2424,7 +2424,7 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static int " << def._wrapper_name << "(PyObject *self, PyObject *arg) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return -1;\n"; out << " }\n\n"; @@ -2451,7 +2451,7 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << " slot " << rfi->second._answer_location << " -> " << fname << "\n"; out << "//////////////////\n"; out << "static Py_hash_t " << def._wrapper_name << "(PyObject *self) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; out << " return -1;\n"; out << " }\n\n"; @@ -2489,9 +2489,9 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << "\n"; out << "//////////////////\n"; out << "static PyObject *Dtool_Repr_" << ClassName << "(PyObject *self) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n\n"; out << " ostringstream os;\n"; if (need_repr == 3) { @@ -2519,9 +2519,9 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << "\n"; out << "//////////////////\n"; out << "static PyObject *Dtool_Str_" << ClassName << "(PyObject *self) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n\n"; out << " ostringstream os;\n"; if (need_str == 2) { @@ -2542,9 +2542,9 @@ write_module_class(ostream &out, Object *obj) { out << "// " << ClassName << "\n"; out << "//////////////////\n"; out << "static PyObject *Dtool_RichCompare_" << ClassName << "(PyObject *self, PyObject *arg, int op) {\n"; - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n\n"; out << " switch (op) {\n"; @@ -2607,7 +2607,7 @@ write_module_class(ostream &out, Object *obj) { out << " if (PyErr_ExceptionMatches(PyExc_TypeError)) {\n"; out << " PyErr_Clear();\n"; out << " } else {\n"; - out << " return (PyObject *)NULL;\n"; + out << " return nullptr;\n"; out << " }\n"; out << " }\n"; out << " switch (op) {\n"; @@ -2654,7 +2654,7 @@ write_module_class(ostream &out, Object *obj) { // string name2 = methodNameFromCppName(ielem.get_name(), "", true); string getter = "&Dtool_" + ClassName + "_" + ielem.get_name() + "_Getter"; - string setter = "NULL"; + string setter = "nullptr"; if (!ielem.is_sequence() && !ielem.is_mapping() && !property->_setter_remaps.empty()) { setter = "&Dtool_" + ClassName + "_" + ielem.get_name() + "_Setter"; } @@ -2666,11 +2666,11 @@ write_module_class(ostream &out, Object *obj) { output_quoted(out, 4, ielem.get_comment()); out << ",\n "; } else { - out << ", NULL, "; + out << ", nullptr, "; } // Extra void* argument; we don't make use of it. - out << "NULL},\n"; + out << "nullptr},\n"; /*if (name1 != name2 && name1 != "__dict__") { // Add alternative spelling. @@ -2682,7 +2682,7 @@ write_module_class(ostream &out, Object *obj) { } if (num_getset != 0) { - out << " {NULL},\n"; + out << " {nullptr},\n"; out << "};\n\n"; } } @@ -2722,7 +2722,7 @@ write_module_class(ostream &out, Object *obj) { write_function_slot(out, 2, slots, "nb_coerce"); out << "#endif\n"; write_function_slot(out, 2, slots, "nb_int"); - out << " 0, // nb_long\n"; // removed in Python 3 + out << " nullptr, // nb_long\n"; // removed in Python 3 write_function_slot(out, 2, slots, "nb_float"); out << "#if PY_MAJOR_VERSION < 3\n"; write_function_slot(out, 2, slots, "nb_oct"); @@ -2769,9 +2769,9 @@ write_module_class(ostream &out, Object *obj) { write_function_slot(out, 2, slots, "sq_concat"); write_function_slot(out, 2, slots, "sq_repeat"); write_function_slot(out, 2, slots, "sq_item"); - out << " 0, // sq_slice\n"; // removed in Python 3 + out << " nullptr, // sq_slice\n"; // removed in Python 3 write_function_slot(out, 2, slots, "sq_ass_item"); - out << " 0, // sq_ass_slice\n"; // removed in Python 3 + out << " nullptr, // sq_ass_slice\n"; // removed in Python 3 write_function_slot(out, 2, slots, "sq_contains"); write_function_slot(out, 2, slots, "sq_inplace_concat"); @@ -2821,7 +2821,7 @@ write_module_class(ostream &out, Object *obj) { // Output the actual PyTypeObject definition. out << "struct Dtool_PyTypedObject Dtool_" << ClassName << " = {\n"; out << " {\n"; - out << " PyVarObject_HEAD_INIT(NULL, 0)\n"; + out << " PyVarObject_HEAD_INIT(nullptr, 0)\n"; // const char *tp_name; out << " \"" << _def->module_name << "." << export_class_name << "\",\n"; // Py_ssize_t tp_basicsize; @@ -2843,16 +2843,16 @@ write_module_class(ostream &out, Object *obj) { if (have_async) { out << " &Dtool_AsyncMethods_" << ClassName << ",\n"; } else { - out << " 0, // tp_as_async\n"; + out << " nullptr, // tp_as_async\n"; } out << "#elif PY_MAJOR_VERSION >= 3\n"; - out << " 0, // tp_reserved\n"; + out << " nullptr, // tp_reserved\n"; out << "#else\n"; if (has_hash_compare) { write_function_slot(out, 4, slots, "tp_compare", "&DTOOL_PyObject_ComparePointers"); } else { - out << " 0, // tp_compare\n"; + out << " nullptr, // tp_compare\n"; } out << "#endif\n"; @@ -2869,20 +2869,20 @@ write_module_class(ostream &out, Object *obj) { if (has_parent_class || (obj->_protocol_types & Object::PT_sequence) != 0) { out << " &Dtool_SequenceMethods_" << ClassName << ",\n"; } else { - out << " 0, // tp_as_sequence\n"; + out << " nullptr, // tp_as_sequence\n"; } // PyMappingMethods *tp_as_mapping; if (has_parent_class || (obj->_protocol_types & Object::PT_mapping) != 0) { out << " &Dtool_MappingMethods_" << ClassName << ",\n"; } else { - out << " 0, // tp_as_mapping\n"; + out << " nullptr, // tp_as_mapping\n"; } // hashfunc tp_hash; if (has_hash_compare) { write_function_slot(out, 4, slots, "tp_hash", "&DTOOL_PyObject_HashPointer"); } else { - out << " 0, // tp_hash\n"; + out << " nullptr, // tp_hash\n"; } // ternaryfunc tp_call; @@ -2906,7 +2906,7 @@ write_module_class(ostream &out, Object *obj) { if (has_parent_class || has_local_getbuffer) { out << " &Dtool_BufferProcs_" << ClassName << ",\n"; } else { - out << " 0, // tp_as_buffer\n"; + out << " nullptr, // tp_as_buffer\n"; } string gcflag; @@ -2934,15 +2934,15 @@ write_module_class(ostream &out, Object *obj) { out << ",\n"; out << "#endif\n"; } else { - out << " 0, // tp_doc\n"; + out << " nullptr, // tp_doc\n"; } // traverseproc tp_traverse; - out << " 0, // tp_traverse\n"; + out << " nullptr, // tp_traverse\n"; //write_function_slot(out, 4, slots, "tp_traverse"); // inquiry tp_clear; - out << " 0, // tp_clear\n"; + out << " nullptr, // tp_clear\n"; //write_function_slot(out, 4, slots, "tp_clear"); // richcmpfunc tp_richcompare; @@ -2953,10 +2953,10 @@ write_module_class(ostream &out, Object *obj) { out << "#if PY_MAJOR_VERSION >= 3\n"; out << " &DTOOL_PyObject_RichCompare,\n"; out << "#else\n"; - out << " 0, // tp_richcompare\n"; + out << " nullptr, // tp_richcompare\n"; out << "#endif\n"; } else { - out << " 0, // tp_richcompare\n"; + out << " nullptr, // tp_richcompare\n"; } // Py_ssize_t tp_weaklistoffset; @@ -2970,19 +2970,19 @@ write_module_class(ostream &out, Object *obj) { // struct PyMethodDef *tp_methods; out << " Dtool_Methods_" << ClassName << ",\n"; // struct PyMemberDef *tp_members; - out << " 0, // tp_members\n"; + out << " nullptr, // tp_members\n"; // struct PyGetSetDef *tp_getset; if (num_getset > 0) { out << " Dtool_Properties_" << ClassName << ",\n"; } else { - out << " 0, // tp_getset\n"; + out << " nullptr, // tp_getset\n"; } // struct _typeobject *tp_base; - out << " 0, // tp_base\n"; + out << " nullptr, // tp_base\n"; // PyObject *tp_dict; - out << " 0, // tp_dict\n"; + out << " nullptr, // tp_dict\n"; // descrgetfunc tp_descr_get; write_function_slot(out, 4, slots, "tp_descr_get"); // descrsetfunc tp_descr_set; @@ -3002,26 +3002,26 @@ write_module_class(ostream &out, Object *obj) { out << " PyObject_Del,\n"; } // inquiry tp_is_gc; - out << " 0, // tp_is_gc\n"; + out << " nullptr, // tp_is_gc\n"; // PyObject *tp_bases; - out << " 0, // tp_bases\n"; + out << " nullptr, // tp_bases\n"; // PyObject *tp_mro; - out << " 0, // tp_mro\n"; + out << " nullptr, // tp_mro\n"; // PyObject *tp_cache; - out << " 0, // tp_cache\n"; + out << " nullptr, // tp_cache\n"; // PyObject *tp_subclasses; - out << " 0, // tp_subclasses\n"; + out << " nullptr, // tp_subclasses\n"; // PyObject *tp_weaklist; - out << " 0, // tp_weaklist\n"; + out << " nullptr, // tp_weaklist\n"; // destructor tp_del; - out << " 0, // tp_del\n"; + out << " nullptr, // tp_del\n"; // unsigned int tp_version_tag out << "#if PY_VERSION_HEX >= 0x02060000\n"; out << " 0, // tp_version_tag\n"; out << "#endif\n"; // destructor tp_finalize out << "#if PY_VERSION_HEX >= 0x03040000\n"; - out << " 0, // tp_finalize\n"; + out << " nullptr, // tp_finalize\n"; out << "#endif\n"; out << " },\n"; @@ -3039,15 +3039,15 @@ write_module_class(ostream &out, Object *obj) { if (has_coerce > 1) { out << " (CoerceFunction)Dtool_Coerce_" << ClassName << ",\n"; } else { - out << " (CoerceFunction)0,\n"; + out << " nullptr,\n"; } } else { - out << " (CoerceFunction)0,\n"; + out << " nullptr,\n"; out << " (CoerceFunction)Dtool_Coerce_" << ClassName << ",\n"; } } else { - out << " (CoerceFunction)0,\n"; - out << " (CoerceFunction)0,\n"; + out << " nullptr,\n"; + out << " nullptr,\n"; } out << "};\n\n"; @@ -3067,14 +3067,14 @@ write_module_class(ostream &out, Object *obj) { if (isExportThisRun(*bi)) { baseargs += ", (PyTypeObject *)&Dtool_" + safe_name; - out << " Dtool_PyModuleClassInit_" << safe_name << "(NULL);\n"; + out << " Dtool_PyModuleClassInit_" << safe_name << "(nullptr);\n"; } else { baseargs += ", (PyTypeObject *)Dtool_Ptr_" + safe_name; - out << " assert(Dtool_Ptr_" << safe_name << " != NULL);\n" - << " assert(Dtool_Ptr_" << safe_name << "->_Dtool_ModuleClassInit != NULL);\n" - << " Dtool_Ptr_" << safe_name << "->_Dtool_ModuleClassInit(NULL);\n"; + out << " assert(Dtool_Ptr_" << safe_name << " != nullptr);\n" + << " assert(Dtool_Ptr_" << safe_name << "->_Dtool_ModuleClassInit != nullptr);\n" + << " Dtool_Ptr_" << safe_name << "->_Dtool_ModuleClassInit(nullptr);\n"; } } @@ -3131,7 +3131,7 @@ write_module_class(ostream &out, Object *obj) { std::string ClassName1 = make_safe_name(nested_obj->_itype.get_scoped_name()); std::string ClassName2 = make_safe_name(nested_obj->_itype.get_name()); out << " // Nested Object " << ClassName1 << ";\n"; - out << " Dtool_PyModuleClassInit_" << ClassName1 << "(NULL);\n"; + out << " Dtool_PyModuleClassInit_" << ClassName1 << "(nullptr);\n"; string name1 = classNameFromCppName(ClassName2, false); string name2 = classNameFromCppName(ClassName2, true); out << " PyDict_SetItemString(dict, \"" << name1 << "\", (PyObject *)&Dtool_" << ClassName1 << ");\n"; @@ -3221,7 +3221,7 @@ write_module_class(ostream &out, Object *obj) { // string name2 = methodNameFromCppName(ielem.get_name(), "", true); string getter = "&Dtool_" + ClassName + "_" + ielem.get_name() + "_Getter"; - string setter = "NULL"; + string setter = "nullptr"; if (!ielem.is_sequence() && !ielem.is_mapping() && !property->_setter_remaps.empty()) { setter = "&Dtool_" + ClassName + "_" + ielem.get_name() + "_Setter"; } @@ -3233,11 +3233,11 @@ write_module_class(ostream &out, Object *obj) { output_quoted(out, 4, ielem.get_comment()); out << ",\n "; } else { - out << ", NULL, "; + out << ", nullptr, "; } // Extra void* argument; we don't make use of it. - out << "NULL};\n"; + out << "nullptr};\n"; out << " PyDict_SetItemString(dict, \"" << name1 << "\", Dtool_NewStaticProperty(&Dtool_" << ClassName << "._PyType, &def_" << name1 << "));\n"; /* Alternative spelling: @@ -3441,7 +3441,7 @@ write_function_for_top(ostream &out, InterfaceMaker::Object *obj, InterfaceMaker output_quoted(out, 2, comment.str()); out << ";\n"; out << "#else\n"; - out << "static const char *" << func->_name << "_comment = NULL;\n"; + out << "static const char *" << func->_name << "_comment = nullptr;\n"; out << "#endif\n\n"; } @@ -3514,7 +3514,7 @@ write_function_for_name(ostream &out, Object *obj, // string class_name = remap->_cpptype->get_simple_name(); // Extract pointer from 'self' parameter. - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; if (all_nonconst) { // All remaps are non-const. Also check that this object isn't const. @@ -3538,7 +3538,7 @@ write_function_for_name(ostream &out, Object *obj, if (args_type == AT_keyword_args && !has_keywords) { // We don't actually take keyword arguments. Make sure we didn't get any. - out << " if (kwds != NULL && PyDict_Size(kwds) > 0) {\n"; + out << " if (kwds != nullptr && PyDict_Size(kwds) > 0) {\n"; out << "#ifdef NDEBUG\n"; error_raise_return(out, 4, return_flags, "TypeError", "function takes no keyword arguments"); out << "#else\n"; @@ -3564,7 +3564,7 @@ write_function_for_name(ostream &out, Object *obj, switch (args_type) { case AT_keyword_args: indent(out, 2) << "int parameter_count = (int)PyTuple_Size(args);\n"; - indent(out, 2) << "if (kwds != NULL) {\n"; + indent(out, 2) << "if (kwds != nullptr) {\n"; indent(out, 2) << " parameter_count += (int)PyDict_Size(kwds);\n"; indent(out, 2) << "}\n"; break; @@ -3623,7 +3623,7 @@ write_function_for_name(ostream &out, Object *obj, if (strip_keyword_args) { // None of the remaps take any keyword arguments, so let's check that // we take none. This saves some checks later on. - indent(out, 4) << "if (kwds == NULL || PyDict_GET_SIZE(kwds) == 0) {\n"; + indent(out, 4) << "if (kwds == nullptr || PyDict_GET_SIZE(kwds) == 0) {\n"; if (min_args == 1 && min_args == 1) { indent(out, 4) << " PyObject *arg = PyTuple_GET_ITEM(args, 0);\n"; write_function_forset(out, mii->second, min_args, max_args, expected_params, 6, @@ -3710,7 +3710,7 @@ write_function_for_name(ostream &out, Object *obj, case AT_keyword_args: out << " if (!Dtool_CheckNoArgs(args, kwds)) {\n"; out << " int parameter_count = (int)PyTuple_Size(args);\n"; - out << " if (kwds != NULL) {\n"; + out << " if (kwds != nullptr) {\n"; out << " parameter_count += (int)PyDict_Size(kwds);\n"; out << " }\n"; break; @@ -3742,7 +3742,7 @@ write_function_for_name(ostream &out, Object *obj, // Check this to be sure, as we handle the case of only 1 keyword arg in // write_function_forset (not using ParseTupleAndKeywords). out << " int parameter_count = (int)PyTuple_Size(args);\n" - " if (kwds != NULL) {\n" + " if (kwds != nullptr) {\n" " parameter_count += (int)PyDict_Size(kwds);\n" " }\n" " if (parameter_count != 1) {\n" @@ -4737,7 +4737,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, extra_convert << "#if PY_VERSION_HEX >= 0x03030000\n" - << "wchar_t *" << param_name << "_str = PyUnicode_AsWideCharString(" << param_name << ", NULL);\n" + << "wchar_t *" << param_name << "_str = PyUnicode_AsWideCharString(" << param_name << ", nullptr);\n" << "#else" << "Py_ssize_t " << param_name << "_len = PyUnicode_GET_SIZE(" << param_name << ");\n" << "wchar_t *" << param_name << "_str = (wchar_t *)alloca(sizeof(wchar_t) * (" + param_name + "_len + 1));\n" @@ -4827,7 +4827,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, << default_value->_str.size() << ";\n"; } } else { - indent(out, indent_level) << "const char *" << param_name << "_str = NULL;\n"; + indent(out, indent_level) << "const char *" << param_name << "_str = nullptr;\n"; indent(out, indent_level) << "Py_ssize_t " << param_name << "_len;\n"; } @@ -4839,11 +4839,11 @@ write_function_instance(ostream &out, FunctionRemap *remap, out << "#else\n"; // NB. PyString_AsStringAndSize also accepts a PyUnicode. indent(out, indent_level) << "if (PyString_AsStringAndSize(arg, (char **)&" << param_name << "_str, &" << param_name << "_len) == -1) {\n"; - indent(out, indent_level + 2) << param_name << "_str = NULL;\n"; + indent(out, indent_level + 2) << param_name << "_str = nullptr;\n"; indent(out, indent_level) << "}\n"; out << "#endif\n"; - extra_param_check << " && " << param_name << "_str != NULL"; + extra_param_check << " && " << param_name << "_str != nullptr"; } else { format_specifiers += "s#"; parameter_list += ", &" + param_name @@ -4862,7 +4862,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, only_pyobjects = false; } else if (TypeManager::is_vector_unsigned_char(type)) { - indent(out, indent_level) << "unsigned char *" << param_name << "_str = NULL;\n"; + indent(out, indent_level) << "unsigned char *" << param_name << "_str = nullptr;\n"; indent(out, indent_level) << "Py_ssize_t " << param_name << "_len;\n"; if (args_type == AT_single_arg) { @@ -5409,7 +5409,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, } else { indent(out, indent_level) << "PyObject *" << param_name; if (is_optional) { - out << " = NULL"; + out << " = nullptr"; } out << ";\n"; format_specifiers += "O"; @@ -5481,16 +5481,16 @@ write_function_instance(ostream &out, FunctionRemap *remap, if (is_optional && maybe_none) { extra_convert << default_expr << ";\n" - << "if (" << param_name << " != NULL && " << param_name << " != Py_None) {\n" + << "if (" << param_name << " != nullptr && " << param_name << " != Py_None) {\n" << " " << param_name << "_this"; } else if (is_optional) { extra_convert << default_expr << ";\n" - << "if (" << param_name << " != NULL) {\n" + << "if (" << param_name << " != nullptr) {\n" << " " << param_name << "_this"; } else if (maybe_none) { extra_convert - << " = NULL;\n" + << " = nullptr;\n" << "if (" << param_name << " != Py_None) {\n" << " " << param_name << "_this"; } @@ -5502,7 +5502,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, extra_convert << "}\n"; } - coerce_call = "(" + param_name + "_this != NULL)"; + coerce_call = "(" + param_name + "_this != nullptr)"; pexpr_string = param_name + "_this"; } @@ -5510,9 +5510,9 @@ write_function_instance(ostream &out, FunctionRemap *remap, if (report_errors) { // We were asked to report any errors. Let's do it. if (is_optional && maybe_none) { - extra_convert << "if (" << param_name << " != NULL && " << param_name << " != Py_None && !" << coerce_call << ") {\n"; + extra_convert << "if (" << param_name << " != nullptr && " << param_name << " != Py_None && !" << coerce_call << ") {\n"; } else if (is_optional) { - extra_convert << "if (" << param_name << " != NULL && !" << coerce_call << ") {\n"; + extra_convert << "if (" << param_name << " != nullptr && !" << coerce_call << ") {\n"; } else if (maybe_none) { extra_convert << "if (" << param_name << " != Py_None && !" << coerce_call << ") {\n"; } else { @@ -5538,10 +5538,10 @@ write_function_instance(ostream &out, FunctionRemap *remap, extra_convert << "}\n"; } else if (is_optional && maybe_none) { - extra_param_check << " && (" << param_name << " == NULL || " << param_name << " == Py_None || " << coerce_call << ")"; + extra_param_check << " && (" << param_name << " == nullptr || " << param_name << " == Py_None || " << coerce_call << ")"; } else if (is_optional) { - extra_param_check << " && (" << param_name << " == NULL || " << coerce_call << ")"; + extra_param_check << " && (" << param_name << " == nullptr || " << coerce_call << ")"; } else if (maybe_none) { extra_param_check << " && (" << param_name << " == Py_None || " << coerce_call << ")"; @@ -5555,16 +5555,16 @@ write_function_instance(ostream &out, FunctionRemap *remap, if (is_optional && maybe_none) { extra_convert << default_expr << ";\n" - << "if (" << param_name << " != NULL && " << param_name << " != Py_None) {\n" + << "if (" << param_name << " != nullptr && " << param_name << " != Py_None) {\n" << " " << param_name << "_this"; } else if (is_optional) { extra_convert << default_expr << ";\n" - << "if (" << param_name << " != NULL) {\n" + << "if (" << param_name << " != nullptr) {\n" << " " << param_name << "_this"; } else if (maybe_none) { extra_convert - << " = NULL;\n" + << " = nullptr;\n" << "if (" << param_name << " != Py_None) {\n" << " " << param_name << "_this"; } @@ -5572,7 +5572,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, // This function does the same thing in this case and is slightly // simpler. But maybe we should just reorganize these functions // entirely? - extra_convert << " = NULL;\n"; + extra_convert << " = nullptr;\n"; int indent_level = (is_optional || maybe_none) ? 2 : 0; indent(extra_convert, indent_level) << "DtoolInstance_GetPointer(" << param_name @@ -5591,15 +5591,15 @@ write_function_instance(ostream &out, FunctionRemap *remap, if (is_optional && maybe_none) { extra_convert << "}\n"; - extra_param_check << " && (" << param_name << " == NULL || " << param_name << " == Py_None || " << param_name << "_this != NULL)"; + extra_param_check << " && (" << param_name << " == nullptr || " << param_name << " == Py_None || " << param_name << "_this != nullptr)"; } else if (is_optional) { extra_convert << "}\n"; - extra_param_check << " && (" << param_name << " == NULL || " << param_name << "_this != NULL)"; + extra_param_check << " && (" << param_name << " == nullptr || " << param_name << "_this != nullptr)"; } else if (maybe_none) { extra_convert << "}\n"; - extra_param_check << " && (" << param_name << " == Py_None || " << param_name << "_this != NULL)"; + extra_param_check << " && (" << param_name << " == Py_None || " << param_name << "_this != nullptr)"; } else { - extra_param_check << " && " << param_name << "_this != NULL"; + extra_param_check << " && " << param_name << "_this != nullptr"; } pexpr_string = param_name + "_this"; @@ -5659,7 +5659,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, // We have to use the more expensive PyArg_ParseTupleAndKeywords. clear_error = true; indent(out, indent_level) - << "static const char *keyword_list[] = {" << keyword_list << ", NULL};\n"; + << "static const char *keyword_list[] = {" << keyword_list << ", nullptr};\n"; indent(out, indent_level) << "if (PyArg_ParseTupleAndKeywords(args, kwds, \"" << format_specifiers << ":" << method_name @@ -5683,7 +5683,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, } else { clear_error = true; indent(out, indent_level) - << "if ((kwds == NULL || PyDict_Size(kwds) == 0) && PyArg_UnpackTuple(args, \"" + << "if ((kwds == nullptr || PyDict_Size(kwds) == 0) && PyArg_UnpackTuple(args, \"" << methodNameFromCppName(remap, "", false) << "\", " << min_num_args << ", " << max_num_args << parameter_list << ")) {\n"; @@ -5692,7 +5692,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, } else { clear_error = true; indent(out, indent_level) - << "if ((kwds == NULL || PyDict_Size(kwds) == 0) && PyArg_ParseTuple(args, \"" + << "if ((kwds == nullptr || PyDict_Size(kwds) == 0) && PyArg_ParseTuple(args, \"" << format_specifiers << ":" << method_name << "\"" << parameter_list << ")) {\n"; } @@ -5789,14 +5789,14 @@ write_function_instance(ostream &out, FunctionRemap *remap, << "PyObject *self = Dtool_new_" << make_safe_name(itype.get_scoped_name()) << "(&" << CLASS_PREFIX << make_safe_name(itype.get_scoped_name()) - << "._PyType, NULL, NULL);\n"; + << "._PyType, nullptr, nullptr);\n"; extra_cleanup << "PyObject_Del(self);\n"; } else { // XXX rdb: this isn't needed, is it, because tp_new already initializes // the instance? indent(out, indent_level) - << "DTool_PyInit_Finalize(self, NULL, &" + << "DTool_PyInit_Finalize(self, nullptr, &" << CLASS_PREFIX << make_safe_name(itype.get_scoped_name()) << ", false, false);\n"; } @@ -5889,7 +5889,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, if (manage_return) { // If a constructor returns NULL, that means allocation failed. if (remap->_return_type->return_value_needs_management()) { - indent(out, indent_level) << "if (return_value == NULL) {\n"; + indent(out, indent_level) << "if (return_value == nullptr) {\n"; if ((return_flags & ~RF_pyobject) == RF_err_null) { // PyErr_NoMemory returns NULL, so allow tail call elimination. indent(out, indent_level) << " return PyErr_NoMemory();\n"; @@ -5990,7 +5990,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, indent(out, indent_level) << " // TypeError raised; continue to next overload type.\n"; indent(out, indent_level) - << "} else if (exception != (PyObject *)NULL) {\n"; + << "} else if (exception != nullptr) {\n"; } if (manage_return) { @@ -6091,8 +6091,8 @@ write_function_instance(ostream &out, FunctionRemap *remap, indent(out, indent_level) << "return Py_None;\n"; } else if (return_flags & RF_preserve_null) { - indent(out, indent_level) << "if (" << return_expr << " == NULL) {\n"; - indent(out, indent_level) << " return NULL;\n"; + indent(out, indent_level) << "if (" << return_expr << " == nullptr) {\n"; + indent(out, indent_level) << " return nullptr;\n"; indent(out, indent_level) << "} else {\n"; pack_return_value(out, indent_level + 2, remap, return_expr, return_flags); indent(out, indent_level) << "}\n"; @@ -6204,7 +6204,7 @@ error_return(ostream &out, int indent_level, int return_flags) { indent(out, indent_level) << "return Py_NotImplemented;\n"; } else if (return_flags & RF_err_null) { - indent(out, indent_level) << "return NULL;\n"; + indent(out, indent_level) << "return nullptr;\n"; } else if (return_flags & RF_err_false) { indent(out, indent_level) << "return false;\n"; @@ -6304,7 +6304,7 @@ pack_return_value(ostream &out, int indent_level, FunctionRemap *remap, indent(out, indent_level); type->output_instance(out, "return_ptr", &parser); out << " = " << return_expr << ";\n"; - indent(out, indent_level) << "return_value.cheat() = NULL;\n"; + indent(out, indent_level) << "return_value.cheat() = nullptr;\n"; return_expr = "return_ptr"; } @@ -6363,9 +6363,9 @@ write_make_seq(ostream &out, Object *obj, const std::string &ClassName, if (make_seq->_length_getter->_has_this) { out << - " " << cClassName << " *local_this = NULL;\n" + " " << cClassName << " *local_this = nullptr;\n" " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n" - " return NULL;\n" + " return nullptr;\n" " }\n" " Py_ssize_t count = (Py_ssize_t)" << remap->get_call_str("local_this", pexprs) << ";\n"; } else { @@ -6391,7 +6391,7 @@ write_make_seq(ostream &out, Object *obj, const std::string &ClassName, switch (elem_getter->_args_type) { case AT_keyword_args: out << " PyTuple_SET_ITEM(&args, 0, index);\n" - " PyObject *value = " << elem_getter->_name << "(self, (PyObject *)&args, NULL);\n"; + " PyObject *value = " << elem_getter->_name << "(self, (PyObject *)&args, nullptr);\n"; break; case AT_varargs: @@ -6404,7 +6404,7 @@ write_make_seq(ostream &out, Object *obj, const std::string &ClassName, break; default: - out << " PyObject *value = " << elem_getter->_name << "(self, NULL);\n"; + out << " PyObject *value = " << elem_getter->_name << "(self, nullptr);\n"; break; } @@ -6421,7 +6421,7 @@ write_make_seq(ostream &out, Object *obj, const std::string &ClassName, out << " if (Dtool_CheckErrorOccurred()) {\n" " Py_DECREF(tuple);\n" - " return NULL;\n" + " return nullptr;\n" " }\n" " return tuple;\n" "}\n" @@ -6454,7 +6454,7 @@ write_getset(ostream &out, Object *obj, Property *property) { "static Py_ssize_t Dtool_" + ClassName + "_" + ielem.get_name() + "_Len(PyObject *self) {\n"; if (property->_length_function->_has_this) { out << - " " << cClassName << " *local_this = NULL;\n" + " " << cClassName << " *local_this = nullptr;\n" " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n" " return -1;\n" " }\n" @@ -6479,9 +6479,9 @@ write_getset(ostream &out, Object *obj, Property *property) { if (property->_has_this) { out << - " " << cClassName << " *local_this = NULL;\n" + " " << cClassName << " *local_this = nullptr;\n" " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n" - " return NULL;\n" + " return nullptr;\n" " }\n"; } @@ -6490,7 +6490,7 @@ write_getset(ostream &out, Object *obj, Property *property) { out << " if (index < 0 || index >= (Py_ssize_t)" << len_remap->get_call_str("local_this", pexprs) << ") {\n"; out << " PyErr_SetString(PyExc_IndexError, \"" << ClassName << "." << ielem.get_name() << "[] index out of range\");\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n"; /*if (property->_has_function != NULL) { @@ -6531,7 +6531,7 @@ write_getset(ostream &out, Object *obj, Property *property) { if (!property->_setter_remaps.empty()) { out << "static int Dtool_" + ClassName + "_" + ielem.get_name() + "_Sequence_Setitem(PyObject *self, Py_ssize_t index, PyObject *arg) {\n"; if (property->_has_this) { - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer_NonConst(self, Dtool_" << ClassName << ", (void **)&local_this, \"" << classNameFromCppName(cClassName, false) << "." << ielem.get_name() << "\")) {\n"; out << " return -1;\n"; @@ -6544,7 +6544,7 @@ write_getset(ostream &out, Object *obj, Property *property) { out << " return -1;\n"; out << " }\n"; - out << " if (arg == (PyObject *)NULL) {\n"; + out << " if (arg == nullptr) {\n"; if (property->_deleter != nullptr) { if (property->_deleter->_has_this) { out << " local_this->" << property->_deleter->_ifunc.get_name() << "(index);\n"; @@ -6603,10 +6603,10 @@ write_getset(ostream &out, Object *obj, Property *property) { if (property->_inserter != nullptr) { out << "static PyObject *Dtool_" + ClassName + "_" + ielem.get_name() + "_Sequence_insert(PyObject *self, size_t index, PyObject *arg) {\n"; if (property->_has_this) { - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer_NonConst(self, Dtool_" << ClassName << ", (void **)&local_this, \"" << classNameFromCppName(cClassName, false) << "." << ielem.get_name() << "\")) {\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n\n"; } @@ -6624,7 +6624,7 @@ write_getset(ostream &out, Object *obj, Property *property) { output_quoted(out, 6, expected_params); out << ");\n"; out << " }\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << "}\n\n"; } } @@ -6653,9 +6653,9 @@ write_getset(ostream &out, Object *obj, Property *property) { if (property->_has_this) { out << - " " << cClassName << " *local_this = NULL;\n" + " " << cClassName << " *local_this = nullptr;\n" " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n" - " return NULL;\n" + " return nullptr;\n" " }\n"; } @@ -6696,7 +6696,7 @@ write_getset(ostream &out, Object *obj, Property *property) { output_quoted(out, 6, expected_params); out << ");\n" " }\n" - " return NULL;\n" + " return nullptr;\n" "}\n\n"; // Write out a setitem if this is not a read-only property. @@ -6709,14 +6709,14 @@ write_getset(ostream &out, Object *obj, Property *property) { if (property->_has_this) { out << - " " << cClassName << " *local_this = NULL;\n" + " " << cClassName << " *local_this = nullptr;\n" " if (!Dtool_Call_ExtractThisPointer_NonConst(self, Dtool_" << ClassName << ", (void **)&local_this, \"" << classNameFromCppName(cClassName, false) << "." << ielem.get_name() << "\")) {\n" " return -1;\n" " }\n\n"; } - out << " if (value == (PyObject *)NULL) {\n"; + out << " if (value == nullptr) {\n"; if (property->_deleter != nullptr) { out << " PyObject *arg = key;\n"; @@ -6789,9 +6789,9 @@ write_getset(ostream &out, Object *obj, Property *property) { if (property->_has_this) { out << - " " << cClassName << " *local_this = NULL;\n" + " " << cClassName << " *local_this = nullptr;\n" " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n" - " return NULL;\n" + " return nullptr;\n" " }\n"; } @@ -6800,7 +6800,7 @@ write_getset(ostream &out, Object *obj, Property *property) { out << " if (index < 0 || index >= (Py_ssize_t)" << len_remap->get_call_str("local_this", pexprs) << ") {\n"; out << " PyErr_SetString(PyExc_IndexError, \"" << ClassName << "." << ielem.get_name() << "[] index out of range\");\n"; - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n"; } @@ -6838,14 +6838,14 @@ write_getset(ostream &out, Object *obj, Property *property) { if (ielem.is_mapping()) { out << "static PyObject *Dtool_" + ClassName + "_" + ielem.get_name() + "_Getter(PyObject *self, void *) {\n"; if (property->_has_this) { - out << " nassertr(self != NULL, NULL);\n"; + out << " nassertr(self != nullptr, nullptr);\n"; } if (property->_setter_remaps.empty()) { out << " Dtool_MappingWrapper *wrap = Dtool_NewMappingWrapper(self, \"" << ClassName << "." << ielem.get_name() << "\");\n"; } else { out << " Dtool_MappingWrapper *wrap = Dtool_NewMutableMappingWrapper(self, \"" << ClassName << "." << ielem.get_name() << "\");\n"; } - out << " if (wrap != NULL) {\n" + out << " if (wrap != nullptr) {\n" " wrap->_getitem_func = &Dtool_" << ClassName << "_" << ielem.get_name() << "_Mapping_Getitem;\n"; if (!property->_setter_remaps.empty()) { out << " if (!DtoolInstance_IS_CONST(self)) {\n"; @@ -6865,18 +6865,18 @@ write_getset(ostream &out, Object *obj, Property *property) { } else if (ielem.is_sequence()) { out << "static PyObject *Dtool_" + ClassName + "_" + ielem.get_name() + "_Getter(PyObject *self, void *) {\n"; if (property->_has_this) { - out << " nassertr(self != NULL, NULL);\n"; + out << " nassertr(self != nullptr, nullptr);\n"; } if (property->_setter_remaps.empty()) { out << " Dtool_SequenceWrapper *wrap = Dtool_NewSequenceWrapper(self, \"" << ClassName << "." << ielem.get_name() << "\");\n" - " if (wrap != NULL) {\n" + " if (wrap != nullptr) {\n" " wrap->_len_func = &Dtool_" << ClassName << "_" << ielem.get_name() << "_Len;\n" " wrap->_getitem_func = &Dtool_" << ClassName << "_" << ielem.get_name() << "_Sequence_Getitem;\n"; } else { out << " Dtool_MutableSequenceWrapper *wrap = Dtool_NewMutableSequenceWrapper(self, \"" << ClassName << "." << ielem.get_name() << "\");\n" - " if (wrap != NULL) {\n" + " if (wrap != nullptr) {\n" " wrap->_len_func = &Dtool_" << ClassName << "_" << ielem.get_name() << "_Len;\n" " wrap->_getitem_func = &Dtool_" << ClassName << "_" << ielem.get_name() << "_Sequence_Getitem;\n"; if (!property->_setter_remaps.empty()) { @@ -6899,14 +6899,14 @@ write_getset(ostream &out, Object *obj, Property *property) { if (remap->_has_this) { if (remap->_const_method) { - out << " const " << cClassName << " *local_this = NULL;\n"; + out << " const " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer(self, Dtool_" << ClassName << ", (void **)&local_this)) {\n"; } else { - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer_NonConst(self, Dtool_" << ClassName << ", (void **)&local_this, \"" << classNameFromCppName(cClassName, false) << "." << ielem.get_name() << "\")) {\n"; } - out << " return NULL;\n"; + out << " return nullptr;\n"; out << " }\n\n"; } @@ -6934,14 +6934,14 @@ write_getset(ostream &out, Object *obj, Property *property) { if (!property->_setter_remaps.empty()) { out << "static int Dtool_" + ClassName + "_" + ielem.get_name() + "_Setter(PyObject *self, PyObject *arg, void *) {\n"; if (remap->_has_this) { - out << " " << cClassName << " *local_this = NULL;\n"; + out << " " << cClassName << " *local_this = nullptr;\n"; out << " if (!Dtool_Call_ExtractThisPointer_NonConst(self, Dtool_" << ClassName << ", (void **)&local_this, \"" << classNameFromCppName(cClassName, false) << "." << ielem.get_name() << "\")) {\n"; out << " return -1;\n"; out << " }\n\n"; } - out << " if (arg == (PyObject *)NULL) {\n"; + out << " if (arg == nullptr) {\n"; if (property->_deleter != nullptr && remap->_has_this) { out << " local_this->" << property->_deleter->_ifunc.get_name() << "();\n" << " return 0;\n"; diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.h b/dtool/src/interrogate/interfaceMakerPythonNative.h index 2c0195fdbf..72421f307a 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.h +++ b/dtool/src/interrogate/interfaceMakerPythonNative.h @@ -132,7 +132,7 @@ private: static bool get_slotted_function_def(Object *obj, Function *func, FunctionRemap *remap, SlottedFunctionDef &def); static void write_function_slot(ostream &out, int indent_level, const SlottedFunctions &slots, - const string &slot, const string &def = "0"); + const string &slot, const string &def = "nullptr"); void write_prototype_for_name(ostream &out, Function *func, const std::string &name); void write_prototype_for(ostream &out, Function *func); diff --git a/dtool/src/interrogate/interfaceMakerPythonObj.cxx b/dtool/src/interrogate/interfaceMakerPythonObj.cxx index 1f76f0cb3b..3f11acb855 100644 --- a/dtool/src/interrogate/interfaceMakerPythonObj.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonObj.cxx @@ -102,17 +102,17 @@ write_module(ostream &out,ostream *out_h, InterrogateModuleDef *def) { << ", METH_VARARGS },\n"; } } - out << " { NULL, NULL }\n" + out << " { nullptr, nullptr }\n" << "};\n\n" << "#if PY_MAJOR_VERSION >= 3\n" << "static struct PyModuleDef python_obj_module = {\n" << " PyModuleDef_HEAD_INIT,\n" << " \"" << def->library_name << "\",\n" - << " NULL,\n" + << " nullptr,\n" << " -1,\n" << " python_obj_funcs,\n" - << " NULL, NULL, NULL, NULL\n" + << " nullptr, nullptr, nullptr, nullptr\n" << "};\n\n" << "#define INIT_FUNC PyObject *PyInit_" << def->library_name << "\n" @@ -185,7 +185,7 @@ write_class_wrapper(ostream &out, InterfaceMaker::Object *object) { << " */\n" << "PyObject *\n" << name << "() {\n" - << " static PyObject *wrapper = (PyObject *)NULL;\n" + << " static PyObject *wrapper = nullptr;\n" << " static PyMethodDef methods[] = {\n"; int methods_size = 0; @@ -216,7 +216,7 @@ write_class_wrapper(ostream &out, InterfaceMaker::Object *object) { out << " };\n" << " static const int class_methods_size = " << class_methods_size << ";\n\n" - << " if (wrapper == (PyObject *)NULL) {\n" + << " if (wrapper == nullptr) {\n" << " int i;\n" << " PyObject *bases = PyTuple_New(0);\n" << " PyObject *dict = PyDict_New();\n" @@ -228,13 +228,13 @@ write_class_wrapper(ostream &out, InterfaceMaker::Object *object) { << " wrapper = PyClass_New(bases, dict, name);\n" << " for (i = 0; i < methods_size; ++i) {\n" << " PyObject *function, *method;\n" - << " function = PyCFunction_New(&methods[i], (PyObject *)NULL);\n" - << " method = PyMethod_New(function, (PyObject *)NULL, wrapper);\n" + << " function = PyCFunction_New(&methods[i], nullptr);\n" + << " method = PyMethod_New(function, nullptr, wrapper);\n" << " PyDict_SetItemString(dict, methods[i].ml_name, method);\n" << " }\n" << " for (i = 0; i < class_methods_size; ++i) {\n" << " PyObject *function;\n" - << " function = PyCFunction_New(&class_methods[i], (PyObject *)NULL);\n" + << " function = PyCFunction_New(&class_methods[i], nullptr);\n" << " PyDict_SetItemString(dict, class_methods[i].ml_name, function);\n" << " }\n" << " }\n" @@ -287,7 +287,7 @@ write_function_for(ostream &out, InterfaceMaker::Function *func) { // different overloaded C++ function signatures. out << " PyErr_SetString(PyExc_TypeError, \"" << expected_params << "\");\n" - << " return (PyObject *)NULL;\n"; + << " return nullptr;\n"; out << "}\n\n"; } @@ -366,7 +366,7 @@ write_function_instance(ostream &out, int indent_level, format_specifiers += "O"; parameter_list += ", &" + param_name; extra_convert += " PyObject *" + param_name + "_long = PyNumber_Long(" + param_name + ");"; - extra_param_check += "|| (" + param_name + "_long == NULL)"; + extra_param_check += "|| (" + param_name + "_long == nullptr)"; pexpr_string = "PyLong_AsUnsignedLongLong(" + param_name + "_long)"; extra_cleanup += " Py_XDECREF(" + param_name + "_long);"; expected_params += "long"; @@ -376,7 +376,7 @@ write_function_instance(ostream &out, int indent_level, format_specifiers += "O"; parameter_list += ", &" + param_name; extra_convert += " PyObject *" + param_name + "_long = PyNumber_Long(" + param_name + ");"; - extra_param_check += "|| (" + param_name + "_long == NULL)"; + extra_param_check += "|| (" + param_name + "_long == nullptr)"; pexpr_string = "PyLong_AsLongLong(" + param_name + "_long)"; extra_cleanup += " Py_XDECREF(" + param_name + "_long);"; expected_params += "long"; @@ -386,7 +386,7 @@ write_function_instance(ostream &out, int indent_level, format_specifiers += "O"; parameter_list += ", &" + param_name; extra_convert += " PyObject *" + param_name + "_uint = PyNumber_Long(" + param_name + ");"; - extra_param_check += "|| (" + param_name + "_uint == NULL)"; + extra_param_check += "|| (" + param_name + "_uint == nullptr)"; pexpr_string = "(unsigned int)PyLong_AsUnsignedLong(" + param_name + "_uint)"; extra_cleanup += " Py_XDECREF(" + param_name + "_uint);"; expected_params += "unsigned int"; @@ -452,7 +452,7 @@ write_function_instance(ostream &out, int indent_level, indent(out, indent_level + 6) << "PyErr_SetString(PyExc_TypeError, \"Invalid parameters.\");\n"; indent(out, indent_level + 6) - << "return (PyObject *)NULL;\n"; + << "return nullptr;\n"; indent(out, indent_level + 4) << "}\n"; } diff --git a/dtool/src/interrogate/interfaceMakerPythonSimple.cxx b/dtool/src/interrogate/interfaceMakerPythonSimple.cxx index b7b5925a8c..8ee9552250 100644 --- a/dtool/src/interrogate/interfaceMakerPythonSimple.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonSimple.cxx @@ -89,17 +89,17 @@ write_module(ostream &out,ostream *out_h, InterrogateModuleDef *def) { << remap->_wrapper_name << ", METH_VARARGS },\n"; } } - out << " { NULL, NULL }\n" + out << " { nullptr, nullptr }\n" << "};\n\n" << "#if PY_MAJOR_VERSION >= 3\n" << "static struct PyModuleDef python_simple_module = {\n" << " PyModuleDef_HEAD_INIT,\n" << " \"" << def->library_name << "\",\n" - << " NULL,\n" + << " nullptr,\n" << " -1,\n" << " python_simple_funcs,\n" - << " NULL, NULL, NULL, NULL\n" + << " nullptr, nullptr, nullptr, nullptr\n" << "};\n\n" << "#define INIT_FUNC PyObject *PyInit_" << def->library_name << "\n" @@ -285,7 +285,7 @@ void InterfaceMakerPythonSimple::write_function_instance(ostream &out, Interface format_specifiers += "O"; parameter_list += ", &" + param_name; extra_convert += " PyObject *" + param_name + "_long = PyNumber_Long(" + param_name + ");"; - extra_param_check += "|| (" + param_name + "_long == NULL)"; + extra_param_check += "|| (" + param_name + "_long == nullptr)"; pexpr_string = "PyLong_AsUnsignedLongLong(" + param_name + "_long)"; extra_cleanup += " Py_XDECREF(" + param_name + "_long);"; @@ -294,7 +294,7 @@ void InterfaceMakerPythonSimple::write_function_instance(ostream &out, Interface format_specifiers += "O"; parameter_list += ", &" + param_name; extra_convert += " PyObject *" + param_name + "_long = PyNumber_Long(" + param_name + ");"; - extra_param_check += "|| (" + param_name + "_long == NULL)"; + extra_param_check += "|| (" + param_name + "_long == nullptr)"; pexpr_string = "PyLong_AsLongLong(" + param_name + "_long)"; extra_cleanup += " Py_XDECREF(" + param_name + "_long);"; @@ -303,7 +303,7 @@ void InterfaceMakerPythonSimple::write_function_instance(ostream &out, Interface format_specifiers += "O"; parameter_list += ", &" + param_name; extra_convert += " PyObject *" + param_name + "_uint = PyNumber_Long(" + param_name + ");"; - extra_param_check += "|| (" + param_name + "_uint == NULL)"; + extra_param_check += "|| (" + param_name + "_uint == nullptr)"; pexpr_string = "(unsigned int)PyLong_AsUnsignedLong(" + param_name + "_uint)"; extra_cleanup += " Py_XDECREF(" + param_name + "_uint);"; @@ -361,7 +361,7 @@ void InterfaceMakerPythonSimple::write_function_instance(ostream &out, Interface out << " " << extra_cleanup << "\n"; } out << " PyErr_SetString(PyExc_TypeError, \"Invalid parameters.\");\n" - << " return (PyObject *)NULL;\n" + << " return nullptr;\n" << " }\n"; } @@ -422,7 +422,7 @@ void InterfaceMakerPythonSimple::write_function_instance(ostream &out, Interface out << " }\n"; - out << " return (PyObject *)NULL;\n"; + out << " return nullptr;\n"; out << "}\n\n"; } diff --git a/dtool/src/interrogate/interrogateBuilder.cxx b/dtool/src/interrogate/interrogateBuilder.cxx index 73ef42fcd0..1e3fdacaa7 100644 --- a/dtool/src/interrogate/interrogateBuilder.cxx +++ b/dtool/src/interrogate/interrogateBuilder.cxx @@ -522,7 +522,7 @@ write_code(ostream &out_code,ostream * out_include, InterrogateModuleDef *def) { out_code << " _in_unique_names,\n" << " " << num_wrappers << ", /* num_unique_names */\n"; } else { - out_code << " (InterrogateUniqueNameDef *)0, /* unique_names */\n" + out_code << " nullptr, /* unique_names */\n" << " 0, /* num_unique_names */\n"; } @@ -530,7 +530,7 @@ write_code(ostream &out_code,ostream * out_include, InterrogateModuleDef *def) { out_code << " _in_fptrs,\n" << " " << num_wrappers << ", /* num_fptrs */\n"; } else { - out_code << " (void **)0, /* fptrs */\n" + out_code << " nullptr, /* fptrs */\n" << " 0, /* num_fptrs */\n"; } diff --git a/dtool/src/interrogate/interrogate_module.cxx b/dtool/src/interrogate/interrogate_module.cxx index dfe8f3a1b5..0fe4534890 100644 --- a/dtool/src/interrogate/interrogate_module.cxx +++ b/dtool/src/interrogate/interrogate_module.cxx @@ -316,10 +316,10 @@ int write_python_table_native(ostream &out) { << "static struct PyModuleDef py_" << library_name << "_module = {\n" << " PyModuleDef_HEAD_INIT,\n" << " \"" << library_name << "\",\n" - << " NULL,\n" + << " nullptr,\n" << " -1,\n" - << " NULL,\n" - << " NULL, NULL, NULL, NULL\n" + << " nullptr,\n" + << " nullptr, nullptr, nullptr, nullptr\n" << "};\n" << "\n" << "PyObject *PyInit_" << library_name << "() {\n"; @@ -346,10 +346,10 @@ int write_python_table_native(ostream &out) { out << "&" << *ii << "_moddef, "; } - out << "NULL};\n" + out << "nullptr};\n" << "\n" << " PyObject *module = Dtool_PyModuleInitHelper(defs, &py_" << library_name << "_module);\n" - << " if (module != NULL) {\n"; + << " if (module != nullptr) {\n"; for (ii = libraries.begin(); ii != libraries.end(); ii++) { out << " Dtool_" << *ii << "_BuildInstants(module);\n"; @@ -393,10 +393,10 @@ int write_python_table_native(ostream &out) { out << "&" << *ii << "_moddef, "; } - out << "NULL};\n" + out << "nullptr};\n" << "\n" << " PyObject *module = Dtool_PyModuleInitHelper(defs, \"" << module_name << "\");\n" - << " if (module != NULL) {\n"; + << " if (module != nullptr) {\n"; for (ii = libraries.begin(); ii != libraries.end(); ii++) { out << " Dtool_" << *ii << "_BuildInstants(module);\n"; @@ -410,7 +410,7 @@ int write_python_table_native(ostream &out) { << " PyErr_SetString(PyExc_ImportError, \"" << module_name << " was " << "compiled for Python \" PY_VERSION \", which is incompatible " << "with Python 3\");\n" - << " return (PyObject *)NULL;\n" + << " return nullptr;\n" << "}\n" << "#endif\n" << "#endif\n" @@ -497,17 +497,17 @@ int write_python_table(ostream &out) { library_name = module_name; } - out << " { NULL, NULL }\n" + out << " { nullptr, nullptr }\n" << "};\n\n" << "#if PY_MAJOR_VERSION >= 3\n" << "static struct PyModuleDef python_module = {\n" << " PyModuleDef_HEAD_INIT,\n" << " \"" << library_name << "\",\n" - << " NULL,\n" + << " nullptr,\n" << " -1,\n" << " python_methods,\n" - << " NULL, NULL, NULL, NULL\n" + << " nullptr, nullptr, nullptr, nullptr\n" << "};\n\n" << "#define INIT_FUNC PyObject *PyInit_" << library_name << "\n" diff --git a/dtool/src/prckeys/makePrcKey.cxx b/dtool/src/prckeys/makePrcKey.cxx index f3ffe9fb44..48b8f62d9c 100644 --- a/dtool/src/prckeys/makePrcKey.cxx +++ b/dtool/src/prckeys/makePrcKey.cxx @@ -188,7 +188,7 @@ write_public_keys(Filename outfile) { out << " { prc_pubkey" << i << "_data, prc_pubkey" << i << "_length, " << generated_time << " },\n"; } else { - out << " { NULL, 0, 0 },\n"; + out << " { nullptr, 0, 0 },\n"; } }; From 5e82671084c9a08d907784fda2e407944fb30730 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Wed, 30 May 2018 16:17:58 -0600 Subject: [PATCH 232/247] general: Do away with TYPENAME macro --- direct/src/dcparser/dcNumericRange.I | 16 +- direct/src/dcparser/dcbase.h | 1 - dtool/src/dtoolbase/dtoolbase_cc.h | 3 - dtool/src/dtoolbase/epvector.h | 2 +- dtool/src/dtoolbase/pallocator.T | 10 +- dtool/src/dtoolbase/pallocator.h | 20 +-- dtool/src/dtoolbase/pdeque.h | 2 +- dtool/src/dtoolbase/plist.h | 10 +- dtool/src/dtoolbase/pmap.h | 28 ++-- dtool/src/dtoolbase/pset.h | 24 +-- .../src/interrogatedb/interrogate_datafile.I | 2 +- panda/src/chan/animChannel.I | 2 +- panda/src/chan/animChannel.h | 2 +- panda/src/chan/animChannelFixed.h | 2 +- panda/src/chan/movingPart.h | 2 +- panda/src/egg/eggMorphList.I | 14 +- panda/src/egg/eggMorphList.h | 6 +- panda/src/express/nodePointerTo.I | 16 +- panda/src/express/nodePointerTo.h | 4 +- panda/src/express/ordered_vector.I | 150 +++++++++--------- panda/src/express/ordered_vector.T | 74 ++++----- panda/src/express/ordered_vector.h | 20 +-- panda/src/express/pointerTo.I | 16 +- panda/src/express/pointerTo.h | 4 +- panda/src/express/pointerToArray.I | 50 +++--- panda/src/express/pointerToArray.h | 54 +++---- panda/src/express/pointerToArrayBase.I | 6 +- panda/src/express/pointerToArrayBase.h | 6 +- panda/src/express/threadSafePointerTo.I | 16 +- panda/src/express/threadSafePointerTo.h | 4 +- panda/src/express/weakPointerTo.I | 18 +-- panda/src/express/weakPointerTo.h | 4 +- panda/src/putil/bitMask.I | 4 +- panda/src/putil/copyOnWritePointer.I | 14 +- panda/src/putil/doubleBitMask.I | 2 +- panda/src/putil/doubleBitMask.h | 2 +- panda/src/putil/iterator_types.h | 4 +- 37 files changed, 305 insertions(+), 309 deletions(-) diff --git a/direct/src/dcparser/dcNumericRange.I b/direct/src/dcparser/dcNumericRange.I index debc9bbcd5..8983204d48 100644 --- a/direct/src/dcparser/dcNumericRange.I +++ b/direct/src/dcparser/dcNumericRange.I @@ -58,7 +58,7 @@ is_in_range(Number num) const { return true; } - TYPENAME Ranges::const_iterator ri; + typename Ranges::const_iterator ri; for (ri = _ranges.begin(); ri != _ranges.end(); ++ri) { if (num >= (*ri)._min && num <= (*ri)._max) { return true; @@ -96,7 +96,7 @@ has_one_value() const { * by the numeric range. */ template -INLINE TYPENAME DCNumericRange::Number DCNumericRange:: +INLINE typename DCNumericRange::Number DCNumericRange:: get_one_value() const { nassertr(has_one_value(), 0); return _ranges[0]._min; @@ -110,7 +110,7 @@ void DCNumericRange:: generate_hash(HashGenerator &hashgen) const { if (!_ranges.empty()) { hashgen.add_int(_ranges.size()); - TYPENAME Ranges::const_iterator ri; + typename Ranges::const_iterator ri; for (ri = _ranges.begin(); ri != _ranges.end(); ++ri) { // We don't account for the fractional part of floating-point ranges // here. Shouldn't be a real issue. @@ -127,7 +127,7 @@ template void DCNumericRange:: output(ostream &out, Number divisor) const { if (!_ranges.empty()) { - TYPENAME Ranges::const_iterator ri; + typename Ranges::const_iterator ri; ri = _ranges.begin(); output_minmax(out, divisor, *ri); ++ri; @@ -151,7 +151,7 @@ output_char(ostream &out, Number divisor) const { } else { if (!_ranges.empty()) { - TYPENAME Ranges::const_iterator ri; + typename Ranges::const_iterator ri; ri = _ranges.begin(); output_minmax_char(out, *ri); ++ri; @@ -187,7 +187,7 @@ add_range(Number min, Number max) { return false; } - TYPENAME Ranges::const_iterator ri; + typename Ranges::const_iterator ri; for (ri = _ranges.begin(); ri != _ranges.end(); ++ri) { if ((min >= (*ri)._min && min <= (*ri)._max) || (max >= (*ri)._min && max <= (*ri)._max) || @@ -227,7 +227,7 @@ get_num_ranges() const { * Returns the minimum value defined by the nth component. */ template -INLINE TYPENAME DCNumericRange::Number DCNumericRange:: +INLINE typename DCNumericRange::Number DCNumericRange:: get_min(int n) const { nassertr(n >= 0 && n < (int)_ranges.size(), 0); return _ranges[n]._min; @@ -237,7 +237,7 @@ get_min(int n) const { * Returns the maximum value defined by the nth component. */ template -INLINE TYPENAME DCNumericRange::Number DCNumericRange:: +INLINE typename DCNumericRange::Number DCNumericRange:: get_max(int n) const { nassertr(n >= 0 && n < (int)_ranges.size(), 0); return _ranges[n]._max; diff --git a/direct/src/dcparser/dcbase.h b/direct/src/dcparser/dcbase.h index 6cf146d848..4f2712f148 100644 --- a/direct/src/dcparser/dcbase.h +++ b/direct/src/dcparser/dcbase.h @@ -61,7 +61,6 @@ #endif #define INLINE inline -#define TYPENAME typename // These symbols are used within the Panda environment for exporting classes // and functions to the scripting language. They're largely meaningless if diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index 8c44ec4429..2aa6dc6252 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -37,7 +37,6 @@ #define INLINE inline #define ALWAYS_INLINE inline -#define TYPENAME typename #define MOVE(x) x #define EXPORT_TEMPLATE_CLASS(expcl, exptp, classname) @@ -78,8 +77,6 @@ typedef int ios_seekdir; #include #include -#define TYPENAME typename - #ifndef HAVE_IOS_TYPEDEFS typedef int ios_openmode; typedef int ios_fmtflags; diff --git a/dtool/src/dtoolbase/epvector.h b/dtool/src/dtoolbase/epvector.h index c3c650d015..78db158f39 100644 --- a/dtool/src/dtoolbase/epvector.h +++ b/dtool/src/dtoolbase/epvector.h @@ -39,7 +39,7 @@ class epvector : public vector > { public: typedef Eigen::aligned_allocator allocator; typedef vector base_class; - typedef TYPENAME base_class::size_type size_type; + typedef typename base_class::size_type size_type; epvector(TypeHandle type_handle = pvector_type_handle) : base_class(allocator()) { } epvector(const epvector ©) : base_class(copy) { } diff --git a/dtool/src/dtoolbase/pallocator.T b/dtool/src/dtoolbase/pallocator.T index 59af0f0ec1..f2776eb39e 100644 --- a/dtool/src/dtoolbase/pallocator.T +++ b/dtool/src/dtoolbase/pallocator.T @@ -20,7 +20,7 @@ pallocator_single(TypeHandle type_handle) noexcept : template INLINE Type *pallocator_single:: -allocate(TYPENAME pallocator_single::size_type n, TYPENAME allocator::const_pointer) { +allocate(typename pallocator_single::size_type n, typename allocator::const_pointer) { TAU_PROFILE("pallocator_single:allocate()", " ", TAU_USER); // This doesn't support allocating arrays. assert(n == 1); @@ -30,7 +30,7 @@ allocate(TYPENAME pallocator_single::size_type n, TYPENAME allocator template INLINE void pallocator_single:: -deallocate(TYPENAME pallocator_single::pointer p, TYPENAME pallocator_single::size_type) { +deallocate(typename pallocator_single::pointer p, typename pallocator_single::size_type) { TAU_PROFILE("pallocator_single:deallocate()", " ", TAU_USER); StaticDeletedChain::deallocate(p, _type_handle); } @@ -44,13 +44,13 @@ pallocator_array(TypeHandle type_handle) noexcept : template INLINE Type *pallocator_array:: -allocate(TYPENAME pallocator_array::size_type n, TYPENAME allocator::const_pointer) { - return (TYPENAME pallocator_array::pointer) +allocate(typename pallocator_array::size_type n, typename allocator::const_pointer) { + return (typename pallocator_array::pointer) ASSUME_ALIGNED(_type_handle.allocate_array(n * sizeof(Type)), MEMORY_HOOK_ALIGNMENT); } template INLINE void pallocator_array:: -deallocate(TYPENAME pallocator_array::pointer p, TYPENAME pallocator_array::size_type) { +deallocate(typename pallocator_array::pointer p, typename pallocator_array::size_type) { _type_handle.deallocate_array((void *)p); } diff --git a/dtool/src/dtoolbase/pallocator.h b/dtool/src/dtoolbase/pallocator.h index 9c27191aa0..daca6fb275 100644 --- a/dtool/src/dtoolbase/pallocator.h +++ b/dtool/src/dtoolbase/pallocator.h @@ -48,11 +48,11 @@ class pallocator_single : public allocator { public: // Nowadays we cannot implicitly inherit typedefs from base classes in a // template class; we must explicitly copy them here. - typedef TYPENAME allocator::pointer pointer; - typedef TYPENAME allocator::reference reference; - typedef TYPENAME allocator::const_pointer const_pointer; - typedef TYPENAME allocator::const_reference const_reference; - typedef TYPENAME allocator::size_type size_type; + typedef typename allocator::pointer pointer; + typedef typename allocator::reference reference; + typedef typename allocator::const_pointer const_pointer; + typedef typename allocator::const_reference const_reference; + typedef typename allocator::size_type size_type; INLINE pallocator_single(TypeHandle type_handle) noexcept; @@ -77,11 +77,11 @@ class pallocator_array : public allocator { public: // Nowadays we cannot implicitly inherit typedefs from base classes in a // template class; we must explicitly copy them here. - typedef TYPENAME allocator::pointer pointer; - typedef TYPENAME allocator::reference reference; - typedef TYPENAME allocator::const_pointer const_pointer; - typedef TYPENAME allocator::const_reference const_reference; - typedef TYPENAME allocator::size_type size_type; + typedef typename allocator::pointer pointer; + typedef typename allocator::reference reference; + typedef typename allocator::const_pointer const_pointer; + typedef typename allocator::const_reference const_reference; + typedef typename allocator::size_type size_type; INLINE pallocator_array(TypeHandle type_handle = TypeHandle::none()) noexcept; diff --git a/dtool/src/dtoolbase/pdeque.h b/dtool/src/dtoolbase/pdeque.h index e3bc33d521..a7de9f5bb0 100644 --- a/dtool/src/dtoolbase/pdeque.h +++ b/dtool/src/dtoolbase/pdeque.h @@ -37,7 +37,7 @@ template class pdeque : public deque > { public: typedef pallocator_array allocator; - typedef TYPENAME deque::size_type size_type; + typedef typename deque::size_type size_type; pdeque(TypeHandle type_handle = pdeque_type_handle) : deque >(allocator(type_handle)) { } pdeque(size_type n, TypeHandle type_handle = pdeque_type_handle) : deque >(n, Type(), allocator(type_handle)) { } pdeque(size_type n, const Type &value, TypeHandle type_handle = pdeque_type_handle) : deque >(n, value, allocator(type_handle)) { } diff --git a/dtool/src/dtoolbase/plist.h b/dtool/src/dtoolbase/plist.h index 978f91cd49..259eb68198 100644 --- a/dtool/src/dtoolbase/plist.h +++ b/dtool/src/dtoolbase/plist.h @@ -38,15 +38,15 @@ class plist : public list > { public: typedef pallocator_single allocator; typedef list base_class; - typedef TYPENAME base_class::size_type size_type; + typedef typename base_class::size_type size_type; plist(TypeHandle type_handle = plist_type_handle) : base_class(allocator(type_handle)) { } plist(size_type n, TypeHandle type_handle = plist_type_handle) : base_class(n, Type(), allocator(type_handle)) { } plist(size_type n, const Type &value, TypeHandle type_handle = plist_type_handle) : base_class(n, value, allocator(type_handle)) { } - typedef TYPENAME base_class::iterator iterator; - typedef TYPENAME base_class::const_iterator const_iterator; - typedef TYPENAME base_class::reverse_iterator reverse_iterator; - typedef TYPENAME base_class::const_reverse_iterator const_reverse_iterator; + typedef typename base_class::iterator iterator; + typedef typename base_class::const_iterator const_iterator; + typedef typename base_class::reverse_iterator reverse_iterator; + typedef typename base_class::const_reverse_iterator const_reverse_iterator; // This exists because libc++'s remove implementation has a bug with Panda's // allocator class. diff --git a/dtool/src/dtoolbase/pmap.h b/dtool/src/dtoolbase/pmap.h index 8ac5be6134..1a53836dd3 100644 --- a/dtool/src/dtoolbase/pmap.h +++ b/dtool/src/dtoolbase/pmap.h @@ -58,33 +58,33 @@ public: pmap(const Compare &comp, TypeHandle type_handle = pmap_type_handle) : base_class(comp, allocator(type_handle)) { } #ifdef USE_TAU - TYPENAME base_class::mapped_type & - operator [] (const TYPENAME base_class::key_type &k) { + typename base_class::mapped_type & + operator [] (const typename base_class::key_type &k) { TAU_PROFILE("pmap::operator [] (const key_type &)", " ", TAU_USER); return base_class::operator [] (k); } - std::pair - insert(const TYPENAME base_class::value_type &x) { + std::pair + insert(const typename base_class::value_type &x) { TAU_PROFILE("pmap::insert(const value_type &)", " ", TAU_USER); return base_class::insert(x); } - TYPENAME base_class::iterator - insert(TYPENAME base_class::iterator position, - const TYPENAME base_class::value_type &x) { + typename base_class::iterator + insert(typename base_class::iterator position, + const typename base_class::value_type &x) { TAU_PROFILE("pmap::insert(iterator, const value_type &)", " ", TAU_USER); return base_class::insert(position, x); } void - erase(TYPENAME base_class::iterator position) { + erase(typename base_class::iterator position) { TAU_PROFILE("pmap::erase(iterator)", " ", TAU_USER); base_class::erase(position); } - TYPENAME base_class::size_type - erase(const TYPENAME base_class::key_type &x) { + typename base_class::size_type + erase(const typename base_class::key_type &x) { TAU_PROFILE("pmap::erase(const key_type &)", " ", TAU_USER); return base_class::erase(x); } @@ -95,14 +95,14 @@ public: base_class::clear(); } - TYPENAME base_class::iterator - find(const TYPENAME base_class::key_type &x) { + typename base_class::iterator + find(const typename base_class::key_type &x) { TAU_PROFILE("pmap::find(const key_type &)", " ", TAU_USER); return base_class::find(x); } - TYPENAME base_class::const_iterator - find(const TYPENAME base_class::key_type &x) const { + typename base_class::const_iterator + find(const typename base_class::key_type &x) const { TAU_PROFILE("pmap::find(const key_type &)", " ", TAU_USER); return base_class::find(x); } diff --git a/dtool/src/dtoolbase/pset.h b/dtool/src/dtoolbase/pset.h index 142c5b3149..1c194dff9b 100644 --- a/dtool/src/dtoolbase/pset.h +++ b/dtool/src/dtoolbase/pset.h @@ -57,27 +57,27 @@ public: pset(const Compare &comp, TypeHandle type_handle = pset_type_handle) : base_class(comp, type_handle) { } #ifdef USE_TAU - std::pair - insert(const TYPENAME base_class::value_type &x) { + std::pair + insert(const typename base_class::value_type &x) { TAU_PROFILE("pset::insert(const value_type &)", " ", TAU_USER); return base_class::insert(x); } - TYPENAME base_class::iterator - insert(TYPENAME base_class::iterator position, - const TYPENAME base_class::value_type &x) { + typename base_class::iterator + insert(typename base_class::iterator position, + const typename base_class::value_type &x) { TAU_PROFILE("pset::insert(iterator, const value_type &)", " ", TAU_USER); return base_class::insert(position, x); } void - erase(TYPENAME base_class::iterator position) { + erase(typename base_class::iterator position) { TAU_PROFILE("pset::erase(iterator)", " ", TAU_USER); base_class::erase(position); } - TYPENAME base_class::size_type - erase(const TYPENAME base_class::key_type &x) { + typename base_class::size_type + erase(const typename base_class::key_type &x) { TAU_PROFILE("pset::erase(const key_type &)", " ", TAU_USER); return base_class::erase(x); } @@ -88,14 +88,14 @@ public: base_class::clear(); } - TYPENAME base_class::iterator - find(const TYPENAME base_class::key_type &x) { + typename base_class::iterator + find(const typename base_class::key_type &x) { TAU_PROFILE("pset::find(x)", " ", TAU_USER); return base_class::find(x); } - TYPENAME base_class::const_iterator - find(const TYPENAME base_class::key_type &x) const { + typename base_class::const_iterator + find(const typename base_class::key_type &x) const { TAU_PROFILE("pset::find(x)", " ", TAU_USER); return base_class::find(x); } diff --git a/dtool/src/interrogatedb/interrogate_datafile.I b/dtool/src/interrogatedb/interrogate_datafile.I index 1e9d0f17e2..ee8d3f38a3 100644 --- a/dtool/src/interrogatedb/interrogate_datafile.I +++ b/dtool/src/interrogatedb/interrogate_datafile.I @@ -19,7 +19,7 @@ template void idf_output_vector(ostream &out, const std::vector &vec) { out << vec.size() << " "; - TYPENAME std::vector::const_iterator vi; + typename std::vector::const_iterator vi; for (vi = vec.begin(); vi != vec.end(); ++vi) { out << (*vi) << " "; } diff --git a/panda/src/chan/animChannel.I b/panda/src/chan/animChannel.I index 6dd73d5240..d776b938e5 100644 --- a/panda/src/chan/animChannel.I +++ b/panda/src/chan/animChannel.I @@ -71,7 +71,7 @@ INLINE AnimChannel:: */ template void AnimChannel:: -get_value(int, TYPENAME AnimChannel::ValueType &) { +get_value(int, typename AnimChannel::ValueType &) { } #endif diff --git a/panda/src/chan/animChannel.h b/panda/src/chan/animChannel.h index 4137196f52..531511660e 100644 --- a/panda/src/chan/animChannel.h +++ b/panda/src/chan/animChannel.h @@ -33,7 +33,7 @@ protected: INLINE AnimChannel(const string &name = ""); INLINE AnimChannel(AnimGroup *parent, const AnimChannel ©); public: - typedef TYPENAME SwitchType::ValueType ValueType; + typedef typename SwitchType::ValueType ValueType; INLINE AnimChannel(AnimGroup *parent, const string &name); INLINE ~AnimChannel(); diff --git a/panda/src/chan/animChannelFixed.h b/panda/src/chan/animChannelFixed.h index 9940f5bdcf..0ad0ff5696 100644 --- a/panda/src/chan/animChannelFixed.h +++ b/panda/src/chan/animChannelFixed.h @@ -28,7 +28,7 @@ template class AnimChannelFixed : public AnimChannel { public: - typedef TYPENAME AnimChannel::ValueType ValueType; + typedef typename AnimChannel::ValueType ValueType; protected: INLINE AnimChannelFixed(AnimGroup *parent, const AnimChannelFixed ©); diff --git a/panda/src/chan/movingPart.h b/panda/src/chan/movingPart.h index 7b3640b981..dd6dc7540b 100644 --- a/panda/src/chan/movingPart.h +++ b/panda/src/chan/movingPart.h @@ -26,7 +26,7 @@ template class MovingPart : public MovingPartBase { public: - typedef TYPENAME SwitchType::ValueType ValueType; + typedef typename SwitchType::ValueType ValueType; typedef AnimChannel ChannelType; protected: diff --git a/panda/src/egg/eggMorphList.I b/panda/src/egg/eggMorphList.I index 5b665247da..deded17c7e 100644 --- a/panda/src/egg/eggMorphList.I +++ b/panda/src/egg/eggMorphList.I @@ -97,7 +97,7 @@ compare_to(const EggMorphList &other, double threshold) const { * */ template -INLINE TYPENAME EggMorphList::iterator EggMorphList:: +INLINE typename EggMorphList::iterator EggMorphList:: begin() { return _morphs.begin(); } @@ -106,7 +106,7 @@ begin() { * */ template -INLINE TYPENAME EggMorphList::const_iterator EggMorphList:: +INLINE typename EggMorphList::const_iterator EggMorphList:: begin() const { return _morphs.begin(); } @@ -115,7 +115,7 @@ begin() const { * */ template -INLINE TYPENAME EggMorphList::iterator EggMorphList:: +INLINE typename EggMorphList::iterator EggMorphList:: end() { return _morphs.end(); } @@ -124,7 +124,7 @@ end() { * */ template -INLINE TYPENAME EggMorphList::const_iterator EggMorphList:: +INLINE typename EggMorphList::const_iterator EggMorphList:: end() const { return _morphs.end(); } @@ -133,7 +133,7 @@ end() const { * */ template -INLINE TYPENAME EggMorphList::size_type EggMorphList:: +INLINE typename EggMorphList::size_type EggMorphList:: size() const { return _morphs.size(); } @@ -155,10 +155,10 @@ empty() const { * to *be* a set, but we cannot export STL sets from a Windows DLL. */ template -pair::iterator, bool> EggMorphList:: +pair::iterator, bool> EggMorphList:: insert(const MorphType &value) { pair result; - TYPENAME Morphs::iterator mi; + typename Morphs::iterator mi; for (mi = _morphs.begin(); mi != _morphs.end(); ++mi) { if ((*mi) == value) { // This value is already present. diff --git a/panda/src/egg/eggMorphList.h b/panda/src/egg/eggMorphList.h index c6e86388ba..581e53d9e9 100644 --- a/panda/src/egg/eggMorphList.h +++ b/panda/src/egg/eggMorphList.h @@ -31,9 +31,9 @@ private: typedef epvector Morphs; public: - typedef TYPENAME Morphs::iterator iterator; - typedef TYPENAME Morphs::const_iterator const_iterator; - typedef TYPENAME Morphs::size_type size_type; + typedef typename Morphs::iterator iterator; + typedef typename Morphs::const_iterator const_iterator; + typedef typename Morphs::size_type size_type; INLINE EggMorphList(); INLINE EggMorphList(const EggMorphList ©); diff --git a/panda/src/express/nodePointerTo.I b/panda/src/express/nodePointerTo.I index c035cd34cf..c8020d0181 100644 --- a/panda/src/express/nodePointerTo.I +++ b/panda/src/express/nodePointerTo.I @@ -62,7 +62,7 @@ operator = (NodePointerTo &&from) noexcept { * */ template -INLINE TYPENAME NodePointerTo::To &NodePointerTo:: +INLINE typename NodePointerTo::To &NodePointerTo:: operator *() const { return *((To *)(this->_void_ptr)); } @@ -73,7 +73,7 @@ operator *() const { * */ template -INLINE TYPENAME NodePointerTo::To *NodePointerTo:: +INLINE typename NodePointerTo::To *NodePointerTo:: operator -> () const { return (To *)(this->_void_ptr); } @@ -99,7 +99,7 @@ operator T *() const { * around compiler problems, particularly for implicit upcasts. */ template -INLINE TYPENAME NodePointerTo::To *NodePointerTo:: +INLINE typename NodePointerTo::To *NodePointerTo:: p() const { return (To *)(this->_void_ptr); } @@ -135,8 +135,8 @@ operator = (const NodePointerTo ©) { */ template INLINE NodeConstPointerTo:: -NodeConstPointerTo(const TYPENAME NodeConstPointerTo::To *ptr) : - NodePointerToBase((TYPENAME NodeConstPointerTo::To *)ptr) +NodeConstPointerTo(const typename NodeConstPointerTo::To *ptr) : + NodePointerToBase((typename NodeConstPointerTo::To *)ptr) { } #endif // CPPPARSER @@ -218,7 +218,7 @@ operator = (NodeConstPointerTo &&from) noexcept { * */ template -INLINE const TYPENAME NodeConstPointerTo::To &NodeConstPointerTo:: +INLINE const typename NodeConstPointerTo::To &NodeConstPointerTo:: operator *() const { return *((To *)(this->_void_ptr)); } @@ -229,7 +229,7 @@ operator *() const { * */ template -INLINE const TYPENAME NodeConstPointerTo::To *NodeConstPointerTo:: +INLINE const typename NodeConstPointerTo::To *NodeConstPointerTo:: operator -> () const { return (To *)(this->_void_ptr); } @@ -256,7 +256,7 @@ operator const T * () const { * work around compiler problems, particularly for implicit upcasts. */ template -INLINE const TYPENAME NodeConstPointerTo::To *NodeConstPointerTo:: +INLINE const typename NodeConstPointerTo::To *NodeConstPointerTo:: p() const { return (To *)(this->_void_ptr); } diff --git a/panda/src/express/nodePointerTo.h b/panda/src/express/nodePointerTo.h index 52ce974879..7b2c189253 100644 --- a/panda/src/express/nodePointerTo.h +++ b/panda/src/express/nodePointerTo.h @@ -28,7 +28,7 @@ public: // By hiding this template from interrogate, we improve compile-time speed // and memory utilization. #ifndef CPPPARSER - typedef TYPENAME NodePointerToBase::To To; + typedef typename NodePointerToBase::To To; INLINE NodePointerTo(To *ptr = nullptr); INLINE NodePointerTo(const NodePointerTo ©); INLINE NodePointerTo(NodePointerTo &&from) noexcept; @@ -59,7 +59,7 @@ public: // By hiding this template from interrogate, we improve compile-time speed // and memory utilization. #ifndef CPPPARSER - typedef TYPENAME NodePointerToBase::To To; + typedef typename NodePointerToBase::To To; INLINE NodeConstPointerTo(const To *ptr = nullptr); INLINE NodeConstPointerTo(const NodePointerTo ©); INLINE NodeConstPointerTo(const NodeConstPointerTo ©); diff --git a/panda/src/express/ordered_vector.I b/panda/src/express/ordered_vector.I index 4f0d5082f0..aedee72232 100644 --- a/panda/src/express/ordered_vector.I +++ b/panda/src/express/ordered_vector.I @@ -37,7 +37,7 @@ ordered_vector(const Compare &compare, TypeHandle type_handle) : * Returns the iterator that marks the first element in the ordered vector. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: +INLINE typename ordered_vector::ITERATOR ordered_vector:: begin() { return _vector.begin(); } @@ -46,7 +46,7 @@ begin() { * Returns the iterator that marks the end of the ordered vector. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: +INLINE typename ordered_vector::ITERATOR ordered_vector:: end() { return _vector.end(); } @@ -56,7 +56,7 @@ end() { * when viewed in reverse order. */ template -INLINE TYPENAME ordered_vector::REVERSE_ITERATOR ordered_vector:: +INLINE typename ordered_vector::REVERSE_ITERATOR ordered_vector:: rbegin() { return _vector.rbegin(); } @@ -66,7 +66,7 @@ rbegin() { * in reverse order. */ template -INLINE TYPENAME ordered_vector::REVERSE_ITERATOR ordered_vector:: +INLINE typename ordered_vector::REVERSE_ITERATOR ordered_vector:: rend() { return _vector.rend(); } @@ -75,7 +75,7 @@ rend() { * Returns the iterator that marks the first element in the ordered vector. */ template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: +INLINE typename ordered_vector::CONST_ITERATOR ordered_vector:: begin() const { return _vector.begin(); } @@ -84,7 +84,7 @@ begin() const { * Returns the iterator that marks the end of the ordered vector. */ template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: +INLINE typename ordered_vector::CONST_ITERATOR ordered_vector:: end() const { return _vector.end(); } @@ -94,7 +94,7 @@ end() const { * when viewed in reverse order. */ template -INLINE TYPENAME ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: +INLINE typename ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: rbegin() const { return _vector.rbegin(); } @@ -104,7 +104,7 @@ rbegin() const { * in reverse order. */ template -INLINE TYPENAME ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: +INLINE typename ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: rend() const { return _vector.rend(); } @@ -113,7 +113,7 @@ rend() const { * Returns the iterator that marks the first element in the ordered vector. */ template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: +INLINE typename ordered_vector::CONST_ITERATOR ordered_vector:: cbegin() const { return _vector.begin(); } @@ -122,7 +122,7 @@ cbegin() const { * Returns the iterator that marks the end of the ordered vector. */ template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: +INLINE typename ordered_vector::CONST_ITERATOR ordered_vector:: cend() const { return _vector.end(); } @@ -132,7 +132,7 @@ cend() const { * when viewed in reverse order. */ template -INLINE TYPENAME ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: +INLINE typename ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: crbegin() const { return _vector.rbegin(); } @@ -142,7 +142,7 @@ crbegin() const { * in reverse order. */ template -INLINE TYPENAME ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: +INLINE typename ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: crend() const { return _vector.rend(); } @@ -151,8 +151,8 @@ crend() const { * Returns the nth element. */ template -INLINE TYPENAME ordered_vector::REFERENCE ordered_vector:: -operator [] (TYPENAME ordered_vector::SIZE_TYPE n) { +INLINE typename ordered_vector::REFERENCE ordered_vector:: +operator [] (typename ordered_vector::SIZE_TYPE n) { return _vector[n]; } @@ -160,8 +160,8 @@ operator [] (TYPENAME ordered_vector::SIZE_TYPE n) { * Returns the nth element. */ template -INLINE TYPENAME ordered_vector::CONST_REFERENCE ordered_vector:: -operator [] (TYPENAME ordered_vector::SIZE_TYPE n) const { +INLINE typename ordered_vector::CONST_REFERENCE ordered_vector:: +operator [] (typename ordered_vector::SIZE_TYPE n) const { return _vector[n]; } @@ -169,7 +169,7 @@ operator [] (TYPENAME ordered_vector::SIZE_TYPE n) const { * Returns a reference to the first element. */ template -INLINE TYPENAME ordered_vector::REFERENCE ordered_vector:: +INLINE typename ordered_vector::REFERENCE ordered_vector:: front() { #ifdef _DEBUG assert(!_vector.empty()); @@ -181,7 +181,7 @@ front() { * Returns a const reference to the first element. */ template -INLINE TYPENAME ordered_vector::CONST_REFERENCE ordered_vector:: +INLINE typename ordered_vector::CONST_REFERENCE ordered_vector:: front() const { #ifdef _DEBUG assert(!_vector.empty()); @@ -193,7 +193,7 @@ front() const { * Returns a reference to the first element. */ template -INLINE TYPENAME ordered_vector::REFERENCE ordered_vector:: +INLINE typename ordered_vector::REFERENCE ordered_vector:: back() { #ifdef _DEBUG assert(!_vector.empty()); @@ -205,7 +205,7 @@ back() { * Returns a const reference to the last element. */ template -INLINE TYPENAME ordered_vector::CONST_REFERENCE ordered_vector:: +INLINE typename ordered_vector::CONST_REFERENCE ordered_vector:: back() const { #ifdef _DEBUG assert(!_vector.empty()); @@ -217,7 +217,7 @@ back() const { * Returns the number of elements in the ordered vector. */ template -INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: +INLINE typename ordered_vector::SIZE_TYPE ordered_vector:: size() const { return _vector.size(); } @@ -227,7 +227,7 @@ size() const { * ordered vector. */ template -INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: +INLINE typename ordered_vector::SIZE_TYPE ordered_vector:: max_size() const { return _vector.max_size(); } @@ -312,8 +312,8 @@ operator >= (const ordered_vector &other) const { * componet is true if the insert operation has taken place. */ template -INLINE pair::ITERATOR, bool> ordered_vector:: -insert_unique(const TYPENAME ordered_vector::VALUE_TYPE &key) { +INLINE pair::ITERATOR, bool> ordered_vector:: +insert_unique(const typename ordered_vector::VALUE_TYPE &key) { TAU_PROFILE("ordered_vector::insert_unique(const value_type &)", " ", TAU_USER); ITERATOR position = find_insert_position(begin(), end(), key); #ifdef NDEBUG @@ -341,8 +341,8 @@ insert_unique(const TYPENAME ordered_vector::VALUE_TYPE &k * The return value is the iterator referencing the new element. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -insert_nonunique(const TYPENAME ordered_vector::VALUE_TYPE &key) { +INLINE typename ordered_vector::ITERATOR ordered_vector:: +insert_nonunique(const typename ordered_vector::VALUE_TYPE &key) { TAU_PROFILE("ordered_vector::insert_nonunique(const value_type &)", " ", TAU_USER); ITERATOR position = find_insert_position(begin(), end(), key); nassertr(position >= begin() && position <= end(), end()); @@ -358,9 +358,9 @@ insert_nonunique(const TYPENAME ordered_vector::VALUE_TYPE * sorting position; no checks are made. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -insert_unverified(TYPENAME ordered_vector::ITERATOR position, - const TYPENAME ordered_vector::VALUE_TYPE &key) { +INLINE typename ordered_vector::ITERATOR ordered_vector:: +insert_unverified(typename ordered_vector::ITERATOR position, + const typename ordered_vector::VALUE_TYPE &key) { TAU_PROFILE("ordered_vector::insert_unverified(iterator, const value_type &)", " ", TAU_USER); ITERATOR result = _vector.insert(position, key); return result; @@ -371,8 +371,8 @@ insert_unverified(TYPENAME ordered_vector::ITERATOR positi * sequential iterator. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -erase(TYPENAME ordered_vector::ITERATOR position) { +INLINE typename ordered_vector::ITERATOR ordered_vector:: +erase(typename ordered_vector::ITERATOR position) { TAU_PROFILE("ordered_vector::erase(iterator)", " ", TAU_USER); SIZE_TYPE count = position - begin(); _vector.erase(position); @@ -384,8 +384,8 @@ erase(TYPENAME ordered_vector::ITERATOR position) { * elements removed. */ template -INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: -erase(const TYPENAME ordered_vector::KEY_TYPE &key) { +INLINE typename ordered_vector::SIZE_TYPE ordered_vector:: +erase(const typename ordered_vector::KEY_TYPE &key) { TAU_PROFILE("ordered_vector::erase(const key_type &)", " ", TAU_USER); pair result = equal_range(key); SIZE_TYPE count = result.second - result.first; @@ -398,8 +398,8 @@ erase(const TYPENAME ordered_vector::KEY_TYPE &key) { */ template INLINE void ordered_vector:: -erase(TYPENAME ordered_vector::ITERATOR first, - TYPENAME ordered_vector::ITERATOR last) { +erase(typename ordered_vector::ITERATOR first, + typename ordered_vector::ITERATOR last) { TAU_PROFILE("ordered_vector::erase(iterator, iterator)", " ", TAU_USER); _vector.erase(first, last); } @@ -420,8 +420,8 @@ clear() { * matching the key, the particular iterator returned is not defined. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -find(const TYPENAME ordered_vector::KEY_TYPE &key) { +INLINE typename ordered_vector::ITERATOR ordered_vector:: +find(const typename ordered_vector::KEY_TYPE &key) { TAU_PROFILE("ordered_vector::find(const key_type &)", " ", TAU_USER); return nci(r_find(begin(), end(), end(), key)); } @@ -432,8 +432,8 @@ find(const TYPENAME ordered_vector::KEY_TYPE &key) { * matching the key, the particular iterator returned is not defined. */ template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -find(const TYPENAME ordered_vector::KEY_TYPE &key) const { +INLINE typename ordered_vector::CONST_ITERATOR ordered_vector:: +find(const typename ordered_vector::KEY_TYPE &key) const { TAU_PROFILE("ordered_vector::find(const key_type &)", " ", TAU_USER); return r_find(begin(), end(), end(), key); } @@ -452,8 +452,8 @@ find(const TYPENAME ordered_vector::KEY_TYPE &key) const { * not necessarily the converse. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -find_particular(const TYPENAME ordered_vector::KEY_TYPE &key) { +INLINE typename ordered_vector::ITERATOR ordered_vector:: +find_particular(const typename ordered_vector::KEY_TYPE &key) { TAU_PROFILE("ordered_vector::find_particular(const key_type &)", " ", TAU_USER); return nci(r_find_particular(begin(), end(), end(), key)); } @@ -469,8 +469,8 @@ find_particular(const TYPENAME ordered_vector::KEY_TYPE &k * is not defined. */ template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -find_particular(const TYPENAME ordered_vector::KEY_TYPE &key) const { +INLINE typename ordered_vector::CONST_ITERATOR ordered_vector:: +find_particular(const typename ordered_vector::KEY_TYPE &key) const { TAU_PROFILE("ordered_vector::find_particular(const key_type &)", " ", TAU_USER); return r_find_particular(begin(), end(), end(), key); } @@ -480,7 +480,7 @@ find_particular(const TYPENAME ordered_vector::KEY_TYPE &k * the vector. */ template -INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: +INLINE typename ordered_vector::SIZE_TYPE ordered_vector:: count(const key_type &key) const { TAU_PROFILE("ordered_vector::count(const key_type &)", " ", TAU_USER); return r_count(begin(), end(), key); @@ -491,8 +491,8 @@ count(const key_type &key) const { * all elements are less than key. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) { +INLINE typename ordered_vector::ITERATOR ordered_vector:: +lower_bound(const typename ordered_vector::KEY_TYPE &key) { TAU_PROFILE("ordered_vector::lower_bound(const key_type &)", " ", TAU_USER); return nci(r_lower_bound(begin(), end(), key)); } @@ -502,8 +502,8 @@ lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) * all elements are less than key. */ template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) const { +INLINE typename ordered_vector::CONST_ITERATOR ordered_vector:: +lower_bound(const typename ordered_vector::KEY_TYPE &key) const { TAU_PROFILE("ordered_vector::lower_bound(const key_type &)", " ", TAU_USER); return r_lower_bound(begin(), end(), key); } @@ -513,8 +513,8 @@ lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) * element is greater than key. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) { +INLINE typename ordered_vector::ITERATOR ordered_vector:: +upper_bound(const typename ordered_vector::KEY_TYPE &key) { TAU_PROFILE("ordered_vector::upper_bound(const key_type &)", " ", TAU_USER); return nci(r_upper_bound(begin(), end(), key)); } @@ -524,8 +524,8 @@ upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) * element is greater than key. */ template -INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) const { +INLINE typename ordered_vector::CONST_ITERATOR ordered_vector:: +upper_bound(const typename ordered_vector::KEY_TYPE &key) const { TAU_PROFILE("ordered_vector::upper_bound(const key_type &)", " ", TAU_USER); return r_upper_bound(begin(), end(), key); } @@ -534,20 +534,20 @@ upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) * Returns the pair (lower_bound(key), upper_bound(key)). */ template -INLINE pair::ITERATOR, TYPENAME ordered_vector::ITERATOR> ordered_vector:: -equal_range(const TYPENAME ordered_vector::KEY_TYPE &key) { +INLINE pair::ITERATOR, typename ordered_vector::ITERATOR> ordered_vector:: +equal_range(const typename ordered_vector::KEY_TYPE &key) { TAU_PROFILE("ordered_vector::equal_range(const key_type &)", " ", TAU_USER); - pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> result; + pair::CONST_ITERATOR, typename ordered_vector::CONST_ITERATOR> result; result = r_equal_range(begin(), end(), key); - return pair::ITERATOR, TYPENAME ordered_vector::ITERATOR>(nci(result.first), nci(result.second)); + return pair::ITERATOR, typename ordered_vector::ITERATOR>(nci(result.first), nci(result.second)); } /** * Returns the pair (lower_bound(key), upper_bound(key)). */ template -INLINE pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> ordered_vector:: -equal_range(const TYPENAME ordered_vector::KEY_TYPE &key) const { +INLINE pair::CONST_ITERATOR, typename ordered_vector::CONST_ITERATOR> ordered_vector:: +equal_range(const typename ordered_vector::KEY_TYPE &key) const { TAU_PROFILE("ordered_vector::equal_range(const key_type &)", " ", TAU_USER); return r_equal_range(begin(), end(), key); } @@ -569,7 +569,7 @@ swap(ordered_vector ©) { */ template INLINE void ordered_vector:: -reserve(TYPENAME ordered_vector::SIZE_TYPE n) { +reserve(typename ordered_vector::SIZE_TYPE n) { TAU_PROFILE("ordered_vector::reserve(size_type)", " ", TAU_USER); _vector.reserve(n); } @@ -666,8 +666,8 @@ resize(SIZE_TYPE n, const VALUE_TYPE &value) { * const flavors of some of these methods. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -nci(TYPENAME ordered_vector::CONST_ITERATOR i) { +INLINE typename ordered_vector::ITERATOR ordered_vector:: +nci(typename ordered_vector::CONST_ITERATOR i) { return begin() + (i - begin()); } @@ -676,10 +676,10 @@ nci(TYPENAME ordered_vector::CONST_ITERATOR i) { * indicated key, and returns the corresponding iterator. */ template -INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -find_insert_position(TYPENAME ordered_vector::ITERATOR first, - TYPENAME ordered_vector::ITERATOR last, - const TYPENAME ordered_vector::KEY_TYPE &key) { +INLINE typename ordered_vector::ITERATOR ordered_vector:: +find_insert_position(typename ordered_vector::ITERATOR first, + typename ordered_vector::ITERATOR last, + const typename ordered_vector::KEY_TYPE &key) { ITERATOR result = r_find_insert_position(first, last, key); return result; } @@ -708,9 +708,9 @@ ov_set(const Compare &compare, TypeHandle type_handle) : * Maps to insert_unique(). */ template -TYPENAME ov_set::ITERATOR ov_set:: -insert(TYPENAME ov_set::ITERATOR position, - const TYPENAME ov_set::VALUE_TYPE &key) { +typename ov_set::ITERATOR ov_set:: +insert(typename ov_set::ITERATOR position, + const typename ov_set::VALUE_TYPE &key) { return ordered_vector::insert_unique(position, key); } @@ -718,8 +718,8 @@ insert(TYPENAME ov_set::ITERATOR position, * Maps to insert_unique(). */ template -INLINE pair::ITERATOR, bool> ov_set:: -insert(const TYPENAME ov_set::VALUE_TYPE &key) { +INLINE pair::ITERATOR, bool> ov_set:: +insert(const typename ov_set::VALUE_TYPE &key) { return ordered_vector::insert_unique(key); } @@ -765,9 +765,9 @@ ov_multiset(const Compare &compare, TypeHandle type_handle) : * Maps to insert_nonunique(). */ template -TYPENAME ov_multiset::ITERATOR ov_multiset:: -insert(TYPENAME ov_multiset::ITERATOR position, - const TYPENAME ov_multiset::VALUE_TYPE &key) { +typename ov_multiset::ITERATOR ov_multiset:: +insert(typename ov_multiset::ITERATOR position, + const typename ov_multiset::VALUE_TYPE &key) { return ordered_vector::insert_nonunique(position, key); } @@ -775,8 +775,8 @@ insert(TYPENAME ov_multiset::ITERATOR position, * Maps to insert_nonunique(). */ template -INLINE TYPENAME ov_multiset::ITERATOR ov_multiset:: -insert(const TYPENAME ov_multiset::VALUE_TYPE &key) { +INLINE typename ov_multiset::ITERATOR ov_multiset:: +insert(const typename ov_multiset::VALUE_TYPE &key) { return ordered_vector::insert_nonunique(key); } diff --git a/panda/src/express/ordered_vector.T b/panda/src/express/ordered_vector.T index e43226a9ee..2d57d0a1d3 100644 --- a/panda/src/express/ordered_vector.T +++ b/panda/src/express/ordered_vector.T @@ -22,9 +22,9 @@ * iterator referencing the original value is returned. */ template -TYPENAME ordered_vector::ITERATOR ordered_vector:: -insert_unique(TYPENAME ordered_vector::ITERATOR position, - const TYPENAME ordered_vector::VALUE_TYPE &key) { +typename ordered_vector::ITERATOR ordered_vector:: +insert_unique(typename ordered_vector::ITERATOR position, + const typename ordered_vector::VALUE_TYPE &key) { TAU_PROFILE("ordered_vector::insert_unique(iterator, const value_type &)", " ", TAU_USER); if (position != end()) { // If we're not inserting at the end, the element we're @@ -67,9 +67,9 @@ insert_unique(TYPENAME ordered_vector::ITERATOR position, * same key to be inserted. */ template -TYPENAME ordered_vector::ITERATOR ordered_vector:: -insert_nonunique(TYPENAME ordered_vector::ITERATOR position, - const TYPENAME ordered_vector::VALUE_TYPE &key) { +typename ordered_vector::ITERATOR ordered_vector:: +insert_nonunique(typename ordered_vector::ITERATOR position, + const typename ordered_vector::VALUE_TYPE &key) { TAU_PROFILE("ordered_vector::insert_nonunique(iterator, const value_type &)", " ", TAU_USER); if (position != end()) { // If we're not inserting at the end, the element we're @@ -145,10 +145,10 @@ verify_list_nonunique() const { * The recursive implementation of find_insert_position(). */ template -TYPENAME ordered_vector::ITERATOR ordered_vector:: -r_find_insert_position(TYPENAME ordered_vector::ITERATOR first, - TYPENAME ordered_vector::ITERATOR last, - const TYPENAME ordered_vector::KEY_TYPE &key) { +typename ordered_vector::ITERATOR ordered_vector:: +r_find_insert_position(typename ordered_vector::ITERATOR first, + typename ordered_vector::ITERATOR last, + const typename ordered_vector::KEY_TYPE &key) { if (first == last) { // The list is empty; the insert position is the last of the list. return last; @@ -171,11 +171,11 @@ r_find_insert_position(TYPENAME ordered_vector::ITERATOR f * The recursive implementation of find(). */ template -TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -r_find(TYPENAME ordered_vector::CONST_ITERATOR first, - TYPENAME ordered_vector::CONST_ITERATOR last, - TYPENAME ordered_vector::CONST_ITERATOR not_found, - const TYPENAME ordered_vector::KEY_TYPE &key) const { +typename ordered_vector::CONST_ITERATOR ordered_vector:: +r_find(typename ordered_vector::CONST_ITERATOR first, + typename ordered_vector::CONST_ITERATOR last, + typename ordered_vector::CONST_ITERATOR not_found, + const typename ordered_vector::KEY_TYPE &key) const { if (first == last) { // The list is empty; the key is not on the list. return not_found; @@ -202,11 +202,11 @@ r_find(TYPENAME ordered_vector::CONST_ITERATOR first, * The recursive implementation of find_particular(). */ template -TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -r_find_particular(TYPENAME ordered_vector::CONST_ITERATOR first, - TYPENAME ordered_vector::CONST_ITERATOR last, - TYPENAME ordered_vector::CONST_ITERATOR not_found, - const TYPENAME ordered_vector::KEY_TYPE &key) const { +typename ordered_vector::CONST_ITERATOR ordered_vector:: +r_find_particular(typename ordered_vector::CONST_ITERATOR first, + typename ordered_vector::CONST_ITERATOR last, + typename ordered_vector::CONST_ITERATOR not_found, + const typename ordered_vector::KEY_TYPE &key) const { if (first == last) { // The list is empty; the key is not on the list. return not_found; @@ -253,10 +253,10 @@ r_find_particular(TYPENAME ordered_vector::CONST_ITERATOR * The recursive implementation of count(). */ template -TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: -r_count(TYPENAME ordered_vector::CONST_ITERATOR first, - TYPENAME ordered_vector::CONST_ITERATOR last, - const TYPENAME ordered_vector::KEY_TYPE &key) const { +typename ordered_vector::SIZE_TYPE ordered_vector:: +r_count(typename ordered_vector::CONST_ITERATOR first, + typename ordered_vector::CONST_ITERATOR last, + const typename ordered_vector::KEY_TYPE &key) const { if (first == last) { // The list is empty; the key is not on the list. @@ -286,10 +286,10 @@ r_count(TYPENAME ordered_vector::CONST_ITERATOR first, * The recursive implementation of lower_bound(). */ template -TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -r_lower_bound(TYPENAME ordered_vector::CONST_ITERATOR first, - TYPENAME ordered_vector::CONST_ITERATOR last, - const TYPENAME ordered_vector::KEY_TYPE &key) const { +typename ordered_vector::CONST_ITERATOR ordered_vector:: +r_lower_bound(typename ordered_vector::CONST_ITERATOR first, + typename ordered_vector::CONST_ITERATOR last, + const typename ordered_vector::KEY_TYPE &key) const { if (first == last) { // The list is empty; the key is not on the list. return last; @@ -317,10 +317,10 @@ r_lower_bound(TYPENAME ordered_vector::CONST_ITERATOR firs * The recursive implementation of upper_bound(). */ template -TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: -r_upper_bound(TYPENAME ordered_vector::CONST_ITERATOR first, - TYPENAME ordered_vector::CONST_ITERATOR last, - const TYPENAME ordered_vector::KEY_TYPE &key) const { +typename ordered_vector::CONST_ITERATOR ordered_vector:: +r_upper_bound(typename ordered_vector::CONST_ITERATOR first, + typename ordered_vector::CONST_ITERATOR last, + const typename ordered_vector::KEY_TYPE &key) const { if (first == last) { // The list is empty; the key is not on the list. return last; @@ -348,11 +348,11 @@ r_upper_bound(TYPENAME ordered_vector::CONST_ITERATOR firs * The recursive implementation of equal_range(). */ template -pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> ordered_vector:: -r_equal_range(TYPENAME ordered_vector::CONST_ITERATOR first, - TYPENAME ordered_vector::CONST_ITERATOR last, - const TYPENAME ordered_vector::KEY_TYPE &key) const { - typedef pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> pair_type; +pair::CONST_ITERATOR, typename ordered_vector::CONST_ITERATOR> ordered_vector:: +r_equal_range(typename ordered_vector::CONST_ITERATOR first, + typename ordered_vector::CONST_ITERATOR last, + const typename ordered_vector::KEY_TYPE &key) const { + typedef pair::CONST_ITERATOR, typename ordered_vector::CONST_ITERATOR> pair_type; if (first == last) { // The list is empty; the key is not on the list. diff --git a/panda/src/express/ordered_vector.h b/panda/src/express/ordered_vector.h index e9e3a03693..651a0c27fb 100644 --- a/panda/src/express/ordered_vector.h +++ b/panda/src/express/ordered_vector.h @@ -105,13 +105,13 @@ public: // Be careful when using the non-const iterators that you do not disturb the // sorted order of the vector, or that if you do, you call sort() when you // are done. - typedef TYPENAME Vector::iterator ITERATOR; - typedef TYPENAME Vector::const_iterator CONST_ITERATOR; - typedef TYPENAME Vector::reverse_iterator REVERSE_ITERATOR; - typedef TYPENAME Vector::const_reverse_iterator CONST_REVERSE_ITERATOR; + typedef typename Vector::iterator ITERATOR; + typedef typename Vector::const_iterator CONST_ITERATOR; + typedef typename Vector::reverse_iterator REVERSE_ITERATOR; + typedef typename Vector::const_reverse_iterator CONST_REVERSE_ITERATOR; - typedef TYPENAME Vector::difference_type DIFFERENCE_TYPE; - typedef TYPENAME Vector::size_type SIZE_TYPE; + typedef typename Vector::difference_type DIFFERENCE_TYPE; + typedef typename Vector::size_type SIZE_TYPE; // Since the #define symbols do not actually expand to the correct names, we // have to re-typedef them so callers can reference them by their correct, @@ -268,8 +268,8 @@ private: template, class Vector = pvector > class ov_set : public ordered_vector { public: - typedef TYPENAME ordered_vector::ITERATOR ITERATOR; - typedef TYPENAME ordered_vector::VALUE_TYPE VALUE_TYPE; + typedef typename ordered_vector::ITERATOR ITERATOR; + typedef typename ordered_vector::VALUE_TYPE VALUE_TYPE; INLINE ov_set(TypeHandle type_handle = ov_set_type_handle); INLINE ov_set(const Compare &compare, @@ -289,8 +289,8 @@ public: template, class Vector = pvector > class ov_multiset : public ordered_vector { public: - typedef TYPENAME ordered_vector::ITERATOR ITERATOR; - typedef TYPENAME ordered_vector::VALUE_TYPE VALUE_TYPE; + typedef typename ordered_vector::ITERATOR ITERATOR; + typedef typename ordered_vector::VALUE_TYPE VALUE_TYPE; INLINE ov_multiset(TypeHandle type_handle = ov_set_type_handle); INLINE ov_multiset(const Compare &compare, diff --git a/panda/src/express/pointerTo.I b/panda/src/express/pointerTo.I index bc71cfbfd9..20e667fa11 100644 --- a/panda/src/express/pointerTo.I +++ b/panda/src/express/pointerTo.I @@ -53,7 +53,7 @@ operator = (PointerTo &&from) noexcept { * */ template -constexpr TYPENAME PointerTo::To &PointerTo:: +constexpr typename PointerTo::To &PointerTo:: operator *() const noexcept { return *((To *)(this->_void_ptr)); } @@ -62,7 +62,7 @@ operator *() const noexcept { * */ template -constexpr TYPENAME PointerTo::To *PointerTo:: +constexpr typename PointerTo::To *PointerTo:: operator -> () const noexcept { return (To *)(this->_void_ptr); } @@ -97,7 +97,7 @@ cheat() { * compiler problems, particularly for implicit upcasts. */ template -constexpr TYPENAME PointerTo::To *PointerTo:: +constexpr typename PointerTo::To *PointerTo:: p() const noexcept { return (To *)(this->_void_ptr); } @@ -127,8 +127,8 @@ operator = (const PointerTo ©) { */ template ALWAYS_INLINE ConstPointerTo:: -ConstPointerTo(const TYPENAME ConstPointerTo::To *ptr) noexcept : - PointerToBase((TYPENAME ConstPointerTo::To *)ptr) +ConstPointerTo(const typename ConstPointerTo::To *ptr) noexcept : + PointerToBase((typename ConstPointerTo::To *)ptr) { } @@ -196,7 +196,7 @@ operator = (ConstPointerTo &&from) noexcept { * */ template -constexpr const TYPENAME ConstPointerTo::To &ConstPointerTo:: +constexpr const typename ConstPointerTo::To &ConstPointerTo:: operator *() const noexcept { return *((To *)(this->_void_ptr)); } @@ -205,7 +205,7 @@ operator *() const noexcept { * */ template -constexpr const TYPENAME ConstPointerTo::To *ConstPointerTo:: +constexpr const typename ConstPointerTo::To *ConstPointerTo:: operator -> () const noexcept { return (To *)(this->_void_ptr); } @@ -240,7 +240,7 @@ cheat() { * around compiler problems, particularly for implicit upcasts. */ template -constexpr const TYPENAME ConstPointerTo::To *ConstPointerTo:: +constexpr const typename ConstPointerTo::To *ConstPointerTo:: p() const noexcept { return (To *)(this->_void_ptr); } diff --git a/panda/src/express/pointerTo.h b/panda/src/express/pointerTo.h index 313ad41a55..1dcf369064 100644 --- a/panda/src/express/pointerTo.h +++ b/panda/src/express/pointerTo.h @@ -68,7 +68,7 @@ template class PointerTo : public PointerToBase { public: - typedef TYPENAME PointerToBase::To To; + typedef typename PointerToBase::To To; PUBLISHED: ALWAYS_INLINE constexpr PointerTo() noexcept = default; ALWAYS_INLINE PointerTo(To *ptr) noexcept; @@ -129,7 +129,7 @@ PUBLISHED: template class ConstPointerTo : public PointerToBase { public: - typedef TYPENAME PointerToBase::To To; + typedef typename PointerToBase::To To; PUBLISHED: ALWAYS_INLINE constexpr ConstPointerTo() noexcept = default; ALWAYS_INLINE ConstPointerTo(const To *ptr) noexcept; diff --git a/panda/src/express/pointerToArray.I b/panda/src/express/pointerToArray.I index bb0946897f..04e943c5fc 100644 --- a/panda/src/express/pointerToArray.I +++ b/panda/src/express/pointerToArray.I @@ -105,7 +105,7 @@ PointerToArray(pvector &&from, TypeHandle type_handle) : * */ template -INLINE TYPENAME PointerToArray::iterator PointerToArray:: +INLINE typename PointerToArray::iterator PointerToArray:: begin() const { if ((this->_void_ptr) == nullptr) { return _empty_array.begin(); @@ -117,7 +117,7 @@ begin() const { * */ template -INLINE TYPENAME PointerToArray::iterator PointerToArray:: +INLINE typename PointerToArray::iterator PointerToArray:: end() const { if ((this->_void_ptr) == nullptr) { return _empty_array.begin(); @@ -129,7 +129,7 @@ end() const { * */ template -INLINE TYPENAME PointerToArray::reverse_iterator PointerToArray:: +INLINE typename PointerToArray::reverse_iterator PointerToArray:: rbegin() const { if ((this->_void_ptr) == nullptr) { return _empty_array.rbegin(); @@ -141,7 +141,7 @@ rbegin() const { * */ template -INLINE TYPENAME PointerToArray::reverse_iterator PointerToArray:: +INLINE typename PointerToArray::reverse_iterator PointerToArray:: rend() const { if ((this->_void_ptr) == nullptr) { return _empty_array.rbegin(); @@ -153,7 +153,7 @@ rend() const { * */ template -INLINE TYPENAME PointerToArray::size_type PointerToArray:: +INLINE typename PointerToArray::size_type PointerToArray:: size() const { return ((this->_void_ptr) == nullptr) ? 0 : ((To *)(this->_void_ptr))->size(); } @@ -162,7 +162,7 @@ size() const { * */ template -INLINE TYPENAME PointerToArray::size_type PointerToArray:: +INLINE typename PointerToArray::size_type PointerToArray:: max_size() const { nassertd((this->_void_ptr) != nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); @@ -184,7 +184,7 @@ empty() const { */ template INLINE void PointerToArray:: -reserve(TYPENAME PointerToArray::size_type n) { +reserve(typename PointerToArray::size_type n) { if ((this->_void_ptr) == nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } @@ -196,7 +196,7 @@ reserve(TYPENAME PointerToArray::size_type n) { */ template INLINE void PointerToArray:: -resize(TYPENAME PointerToArray::size_type n) { +resize(typename PointerToArray::size_type n) { if ((this->_void_ptr) == nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); } @@ -207,7 +207,7 @@ resize(TYPENAME PointerToArray::size_type n) { * */ template -INLINE TYPENAME PointerToArray::size_type PointerToArray:: +INLINE typename PointerToArray::size_type PointerToArray:: capacity() const { nassertr((this->_void_ptr) != nullptr, 0); return ((To *)(this->_void_ptr))->capacity(); @@ -217,7 +217,7 @@ capacity() const { * */ template -INLINE TYPENAME PointerToArray::reference PointerToArray:: +INLINE typename PointerToArray::reference PointerToArray:: front() const { nassertd((this->_void_ptr) != nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); @@ -232,7 +232,7 @@ front() const { * */ template -INLINE TYPENAME PointerToArray::reference PointerToArray:: +INLINE typename PointerToArray::reference PointerToArray:: back() const { nassertd((this->_void_ptr) != nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); @@ -247,7 +247,7 @@ back() const { * */ template -INLINE TYPENAME PointerToArray::iterator PointerToArray:: +INLINE typename PointerToArray::iterator PointerToArray:: insert(iterator position, const Element &x) { if ((this->_void_ptr) == nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); @@ -302,7 +302,7 @@ erase(iterator first, iterator last) { * */ template -INLINE TYPENAME PointerToArray::reference PointerToArray:: +INLINE typename PointerToArray::reference PointerToArray:: operator [](size_type n) const { nassertd((this->_void_ptr) != nullptr) { ((PointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); @@ -318,7 +318,7 @@ operator [](size_type n) const { * */ template -INLINE TYPENAME PointerToArray::reference PointerToArray:: +INLINE typename PointerToArray::reference PointerToArray:: operator [](int n) const { return operator[]((size_type)n); } @@ -728,7 +728,7 @@ ConstPointerToArray(pvector &&from, TypeHandle type_handle) : * */ template -INLINE TYPENAME ConstPointerToArray::iterator ConstPointerToArray:: +INLINE typename ConstPointerToArray::iterator ConstPointerToArray:: begin() const { if ((this->_void_ptr) == nullptr) { return _empty_array.begin(); @@ -740,7 +740,7 @@ begin() const { * */ template -INLINE TYPENAME ConstPointerToArray::iterator ConstPointerToArray:: +INLINE typename ConstPointerToArray::iterator ConstPointerToArray:: end() const { if ((this->_void_ptr) == nullptr) { return _empty_array.begin(); @@ -752,7 +752,7 @@ end() const { * */ template -INLINE TYPENAME ConstPointerToArray::reverse_iterator ConstPointerToArray:: +INLINE typename ConstPointerToArray::reverse_iterator ConstPointerToArray:: rbegin() const { if ((this->_void_ptr) == nullptr) { return _empty_array.rbegin(); @@ -764,7 +764,7 @@ rbegin() const { * */ template -INLINE TYPENAME ConstPointerToArray::reverse_iterator ConstPointerToArray:: +INLINE typename ConstPointerToArray::reverse_iterator ConstPointerToArray:: rend() const { if ((this->_void_ptr) == nullptr) { return _empty_array.rbegin(); @@ -776,7 +776,7 @@ rend() const { * */ template -INLINE TYPENAME ConstPointerToArray::size_type ConstPointerToArray:: +INLINE typename ConstPointerToArray::size_type ConstPointerToArray:: size() const { return ((this->_void_ptr) == nullptr) ? 0 : ((To *)(this->_void_ptr))->size(); } @@ -785,7 +785,7 @@ size() const { * */ template -INLINE TYPENAME ConstPointerToArray::size_type ConstPointerToArray:: +INLINE typename ConstPointerToArray::size_type ConstPointerToArray:: max_size() const { nassertd((this->_void_ptr) != nullptr) { ((ConstPointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); @@ -806,7 +806,7 @@ empty() const { * */ template -INLINE TYPENAME ConstPointerToArray::size_type ConstPointerToArray:: +INLINE typename ConstPointerToArray::size_type ConstPointerToArray:: capacity() const { nassertd((this->_void_ptr) != nullptr) { ((ConstPointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); @@ -818,7 +818,7 @@ capacity() const { * */ template -INLINE TYPENAME ConstPointerToArray::reference ConstPointerToArray:: +INLINE typename ConstPointerToArray::reference ConstPointerToArray:: front() const { nassertd((this->_void_ptr) != nullptr) { ((ConstPointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); @@ -833,7 +833,7 @@ front() const { * */ template -INLINE TYPENAME ConstPointerToArray::reference ConstPointerToArray:: +INLINE typename ConstPointerToArray::reference ConstPointerToArray:: back() const { nassertd((this->_void_ptr) != nullptr) { ((ConstPointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); @@ -849,7 +849,7 @@ back() const { * */ template -INLINE TYPENAME ConstPointerToArray::reference ConstPointerToArray:: +INLINE typename ConstPointerToArray::reference ConstPointerToArray:: operator [](size_type n) const { nassertd((this->_void_ptr) != nullptr) { ((ConstPointerToArray *)this)->reassign(new ReferenceCountedVector(_type_handle)); @@ -865,7 +865,7 @@ operator [](size_type n) const { * */ template -INLINE TYPENAME ConstPointerToArray::reference ConstPointerToArray:: +INLINE typename ConstPointerToArray::reference ConstPointerToArray:: operator [](int n) const { return operator[]((size_type)n); } diff --git a/panda/src/express/pointerToArray.h b/panda/src/express/pointerToArray.h index 1df1193b3c..57c8be2f92 100644 --- a/panda/src/express/pointerToArray.h +++ b/panda/src/express/pointerToArray.h @@ -91,7 +91,7 @@ public: // subset of this class. So we define just the exportable interface here. #ifdef CPPPARSER PUBLISHED: - typedef TYPENAME pvector::size_type size_type; + typedef typename pvector::size_type size_type; INLINE PointerToArray(TypeHandle type_handle = get_type_handle(Element)); INLINE static PointerToArray empty_array(size_type n, TypeHandle type_handle = get_type_handle(Element)); INLINE PointerToArray(const PointerToArray ©); @@ -123,16 +123,16 @@ PUBLISHED: #else // CPPPARSER // This is the actual, complete interface. - typedef TYPENAME PointerToArrayBase::To To; - typedef TYPENAME pvector::value_type value_type; - typedef TYPENAME pvector::reference reference; - typedef TYPENAME pvector::const_reference const_reference; - typedef TYPENAME pvector::iterator iterator; - typedef TYPENAME pvector::const_iterator const_iterator; - typedef TYPENAME pvector::reverse_iterator reverse_iterator; - typedef TYPENAME pvector::const_reverse_iterator const_reverse_iterator; - typedef TYPENAME pvector::difference_type difference_type; - typedef TYPENAME pvector::size_type size_type; + typedef typename PointerToArrayBase::To To; + typedef typename pvector::value_type value_type; + typedef typename pvector::reference reference; + typedef typename pvector::const_reference const_reference; + typedef typename pvector::iterator iterator; + typedef typename pvector::const_iterator const_iterator; + typedef typename pvector::reverse_iterator reverse_iterator; + typedef typename pvector::const_reverse_iterator const_reverse_iterator; + typedef typename pvector::difference_type difference_type; + typedef typename pvector::size_type size_type; public: INLINE PointerToArray(TypeHandle type_handle = get_type_handle(Element)); @@ -150,8 +150,8 @@ public: INLINE iterator begin() const; INLINE iterator end() const; - INLINE TYPENAME PointerToArray::reverse_iterator rbegin() const; - INLINE TYPENAME PointerToArray::reverse_iterator rend() const; + INLINE typename PointerToArray::reverse_iterator rbegin() const; + INLINE typename PointerToArray::reverse_iterator rend() const; // Equality and comparison operators are pointerwise for PointerToArrays, // not elementwise as in vector. @@ -261,7 +261,7 @@ PUBLISHED: INLINE void clear(); - typedef TYPENAME pvector::size_type size_type; + typedef typename pvector::size_type size_type; INLINE size_type size() const; INLINE const Element &get_element(size_type n) const; EXTENSION(const Element &__getitem__(size_type n) const); @@ -279,21 +279,21 @@ PUBLISHED: #else // CPPPARSER // This is the actual, complete interface. - typedef TYPENAME PointerToArrayBase::To To; - typedef TYPENAME pvector::value_type value_type; - typedef TYPENAME pvector::const_reference reference; - typedef TYPENAME pvector::const_reference const_reference; - typedef TYPENAME pvector::const_iterator iterator; - typedef TYPENAME pvector::const_iterator const_iterator; + typedef typename PointerToArrayBase::To To; + typedef typename pvector::value_type value_type; + typedef typename pvector::const_reference reference; + typedef typename pvector::const_reference const_reference; + typedef typename pvector::const_iterator iterator; + typedef typename pvector::const_iterator const_iterator; #if defined(WIN32_VC) || defined(WIN64_VC) // VC++ seems to break the const_reverse_iterator definition somehow. - typedef TYPENAME pvector::reverse_iterator reverse_iterator; + typedef typename pvector::reverse_iterator reverse_iterator; #else - typedef TYPENAME pvector::const_reverse_iterator reverse_iterator; + typedef typename pvector::const_reverse_iterator reverse_iterator; #endif - typedef TYPENAME pvector::const_reverse_iterator const_reverse_iterator; - typedef TYPENAME pvector::difference_type difference_type; - typedef TYPENAME pvector::size_type size_type; + typedef typename pvector::const_reverse_iterator const_reverse_iterator; + typedef typename pvector::difference_type difference_type; + typedef typename pvector::size_type size_type; INLINE ConstPointerToArray(const Element *begin, const Element *end, TypeHandle type_handle = get_type_handle(Element)); INLINE ConstPointerToArray(const PointerToArray ©); @@ -306,8 +306,8 @@ PUBLISHED: INLINE iterator begin() const; INLINE iterator end() const; - INLINE TYPENAME ConstPointerToArray::reverse_iterator rbegin() const; - INLINE TYPENAME ConstPointerToArray::reverse_iterator rend() const; + INLINE typename ConstPointerToArray::reverse_iterator rbegin() const; + INLINE typename ConstPointerToArray::reverse_iterator rend() const; // Equality and comparison operators are pointerwise for PointerToArrays, // not elementwise as in vector. diff --git a/panda/src/express/pointerToArrayBase.I b/panda/src/express/pointerToArrayBase.I index 2b60162abc..a5188040fb 100644 --- a/panda/src/express/pointerToArrayBase.I +++ b/panda/src/express/pointerToArrayBase.I @@ -24,7 +24,7 @@ ReferenceCountedVector(TypeHandle type_handle) : pvector(type_handle) { */ template INLINE ReferenceCountedVector:: -ReferenceCountedVector(TYPENAME ReferenceCountedVector::size_type initial_size, TypeHandle type_handle) : +ReferenceCountedVector(typename ReferenceCountedVector::size_type initial_size, TypeHandle type_handle) : pvector(initial_size, type_handle) { } @@ -53,7 +53,7 @@ ReferenceCountedVector(pvector &&from) : * */ template -INLINE TYPENAME ReferenceCountedVector::size_type ReferenceCountedVector:: +INLINE typename ReferenceCountedVector::size_type ReferenceCountedVector:: size() const { return pvector::size(); } @@ -62,7 +62,7 @@ size() const { * */ template -INLINE TYPENAME ReferenceCountedVector::iterator ReferenceCountedVector:: +INLINE typename ReferenceCountedVector::iterator ReferenceCountedVector:: insert(iterator position, const Element &x) { return pvector::insert(position, x); } diff --git a/panda/src/express/pointerToArrayBase.h b/panda/src/express/pointerToArrayBase.h index 6f6128e26b..3c985ff379 100644 --- a/panda/src/express/pointerToArrayBase.h +++ b/panda/src/express/pointerToArrayBase.h @@ -37,8 +37,8 @@ template class ReferenceCountedVector : public NodeReferenceCount, public pvector { public: - typedef TYPENAME pvector::iterator iterator; - typedef TYPENAME pvector::size_type size_type; + typedef typename pvector::iterator iterator; + typedef typename pvector::size_type size_type; INLINE ReferenceCountedVector(TypeHandle type_handle); INLINE ReferenceCountedVector(size_type initial_size, TypeHandle type_handle); @@ -68,7 +68,7 @@ public: template class PointerToArrayBase : public PointerToBase > { public: - typedef TYPENAME PointerToBase >::To To; + typedef typename PointerToBase >::To To; protected: INLINE PointerToArrayBase(ReferenceCountedVector *ptr); diff --git a/panda/src/express/threadSafePointerTo.I b/panda/src/express/threadSafePointerTo.I index 7525fd4e4c..ef2b8db410 100644 --- a/panda/src/express/threadSafePointerTo.I +++ b/panda/src/express/threadSafePointerTo.I @@ -41,7 +41,7 @@ INLINE ThreadSafePointerTo:: * */ template -INLINE TYPENAME ThreadSafePointerTo::To &ThreadSafePointerTo:: +INLINE typename ThreadSafePointerTo::To &ThreadSafePointerTo:: operator *() const { return *((To *)AtomicAdjust::get_ptr(this->_void_ptr)); } @@ -50,7 +50,7 @@ operator *() const { * */ template -INLINE TYPENAME ThreadSafePointerTo::To *ThreadSafePointerTo:: +INLINE typename ThreadSafePointerTo::To *ThreadSafePointerTo:: operator -> () const { return (To *)AtomicAdjust::get_ptr(this->_void_ptr); } @@ -72,7 +72,7 @@ operator T * () const { * work around compiler problems, particularly for implicit upcasts. */ template -INLINE TYPENAME ThreadSafePointerTo::To *ThreadSafePointerTo:: +INLINE typename ThreadSafePointerTo::To *ThreadSafePointerTo:: p() const { return (To *)AtomicAdjust::get_ptr(this->_void_ptr); } @@ -102,8 +102,8 @@ operator = (const ThreadSafePointerTo ©) { */ template INLINE ThreadSafeConstPointerTo:: -ThreadSafeConstPointerTo(const TYPENAME ThreadSafeConstPointerTo::To *ptr) : - ThreadSafePointerToBase((TYPENAME ThreadSafeConstPointerTo::To *)ptr) +ThreadSafeConstPointerTo(const typename ThreadSafeConstPointerTo::To *ptr) : + ThreadSafePointerToBase((typename ThreadSafeConstPointerTo::To *)ptr) { } @@ -139,7 +139,7 @@ ThreadSafeConstPointerTo(const ThreadSafeConstPointerTo ©) : * */ template -INLINE const TYPENAME ThreadSafeConstPointerTo::To &ThreadSafeConstPointerTo:: +INLINE const typename ThreadSafeConstPointerTo::To &ThreadSafeConstPointerTo:: operator *() const { return *((To *)AtomicAdjust::get_ptr(this->_void_ptr)); } @@ -148,7 +148,7 @@ operator *() const { * */ template -INLINE const TYPENAME ThreadSafeConstPointerTo::To *ThreadSafeConstPointerTo:: +INLINE const typename ThreadSafeConstPointerTo::To *ThreadSafeConstPointerTo:: operator -> () const { return (To *)AtomicAdjust::get_ptr(this->_void_ptr); } @@ -171,7 +171,7 @@ operator const T * () const { * to work around compiler problems, particularly for implicit upcasts. */ template -INLINE const TYPENAME ThreadSafeConstPointerTo::To *ThreadSafeConstPointerTo:: +INLINE const typename ThreadSafeConstPointerTo::To *ThreadSafeConstPointerTo:: p() const { return (To *)AtomicAdjust::get_ptr(this->_void_ptr); } diff --git a/panda/src/express/threadSafePointerTo.h b/panda/src/express/threadSafePointerTo.h index f3801a5669..88699fa23a 100644 --- a/panda/src/express/threadSafePointerTo.h +++ b/panda/src/express/threadSafePointerTo.h @@ -26,7 +26,7 @@ template class ThreadSafePointerTo : public ThreadSafePointerToBase { public: - typedef TYPENAME ThreadSafePointerToBase::To To; + typedef typename ThreadSafePointerToBase::To To; PUBLISHED: INLINE ThreadSafePointerTo(To *ptr = nullptr); INLINE ThreadSafePointerTo(const ThreadSafePointerTo ©); @@ -71,7 +71,7 @@ PUBLISHED: template class ThreadSafeConstPointerTo : public ThreadSafePointerToBase { public: - typedef TYPENAME ThreadSafePointerToBase::To To; + typedef typename ThreadSafePointerToBase::To To; PUBLISHED: INLINE ThreadSafeConstPointerTo(const To *ptr = nullptr); INLINE ThreadSafeConstPointerTo(const ThreadSafePointerTo ©); diff --git a/panda/src/express/weakPointerTo.I b/panda/src/express/weakPointerTo.I index 969d2e7158..c6e570979f 100644 --- a/panda/src/express/weakPointerTo.I +++ b/panda/src/express/weakPointerTo.I @@ -43,7 +43,7 @@ WeakPointerTo(const WeakPointerTo ©) : * */ template -INLINE TYPENAME WeakPointerTo::To &WeakPointerTo:: +INLINE typename WeakPointerTo::To &WeakPointerTo:: operator *() const { assert(!this->was_deleted()); return *((To *)WeakPointerToBase::_void_ptr); @@ -53,7 +53,7 @@ operator *() const { * */ template -INLINE TYPENAME WeakPointerTo::To *WeakPointerTo:: +INLINE typename WeakPointerTo::To *WeakPointerTo:: operator -> () const { assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; @@ -106,7 +106,7 @@ lock() const { * around compiler problems, particularly for implicit upcasts. */ template -INLINE TYPENAME WeakPointerTo::To *WeakPointerTo:: +INLINE typename WeakPointerTo::To *WeakPointerTo:: p() const { assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; @@ -117,7 +117,7 @@ p() const { * deleted. */ template -INLINE TYPENAME WeakPointerTo::To *WeakPointerTo:: +INLINE typename WeakPointerTo::To *WeakPointerTo:: get_orig() const { return (To *)WeakPointerToBase::_void_ptr; } @@ -158,7 +158,7 @@ operator = (const WeakPointerTo ©) { template INLINE WeakConstPointerTo:: WeakConstPointerTo(const To *ptr) : - WeakPointerToBase((TYPENAME WeakConstPointerTo::To *)ptr) + WeakPointerToBase((typename WeakConstPointerTo::To *)ptr) { } @@ -206,7 +206,7 @@ WeakConstPointerTo(const WeakConstPointerTo ©) : * */ template -INLINE const TYPENAME WeakConstPointerTo::To &WeakConstPointerTo:: +INLINE const typename WeakConstPointerTo::To &WeakConstPointerTo:: operator *() const { assert(!this->was_deleted()); return *((To *)WeakPointerToBase::_void_ptr); @@ -216,7 +216,7 @@ operator *() const { * */ template -INLINE const TYPENAME WeakConstPointerTo::To *WeakConstPointerTo:: +INLINE const typename WeakConstPointerTo::To *WeakConstPointerTo:: operator -> () const { assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; @@ -267,7 +267,7 @@ lock() const { * work around compiler problems, particularly for implicit upcasts. */ template -INLINE const TYPENAME WeakConstPointerTo::To *WeakConstPointerTo:: +INLINE const typename WeakConstPointerTo::To *WeakConstPointerTo:: p() const { assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; @@ -278,7 +278,7 @@ p() const { * deleted. */ template -INLINE const TYPENAME WeakConstPointerTo::To *WeakConstPointerTo:: +INLINE const typename WeakConstPointerTo::To *WeakConstPointerTo:: get_orig() const { return (To *)WeakPointerToBase::_void_ptr; } diff --git a/panda/src/express/weakPointerTo.h b/panda/src/express/weakPointerTo.h index ffc1d0dd3a..5834113b7a 100644 --- a/panda/src/express/weakPointerTo.h +++ b/panda/src/express/weakPointerTo.h @@ -28,7 +28,7 @@ template class WeakPointerTo : public WeakPointerToBase { public: - typedef TYPENAME WeakPointerToBase::To To; + typedef typename WeakPointerToBase::To To; PUBLISHED: INLINE WeakPointerTo(To *ptr = nullptr); INLINE WeakPointerTo(const PointerTo ©); @@ -64,7 +64,7 @@ PUBLISHED: template class WeakConstPointerTo : public WeakPointerToBase { public: - typedef TYPENAME WeakPointerToBase::To To; + typedef typename WeakPointerToBase::To To; PUBLISHED: INLINE WeakConstPointerTo(const To *ptr = nullptr); INLINE WeakConstPointerTo(const PointerTo ©); diff --git a/panda/src/putil/bitMask.I b/panda/src/putil/bitMask.I index 39d3a7742d..49e72fc3e7 100644 --- a/panda/src/putil/bitMask.I +++ b/panda/src/putil/bitMask.I @@ -168,7 +168,7 @@ is_all_on() const { * BitMask, shifted to the least-significant position. */ template -INLINE TYPENAME BitMask::WordType BitMask:: +INLINE typename BitMask::WordType BitMask:: extract(int low_bit, int size) const { return (_word >> low_bit) & BitMask::lower_on(size)._word; @@ -242,7 +242,7 @@ set_range_to(bool value, int low_bit, int size) { * Returns the entire BitMask as a single word. */ template -INLINE TYPENAME BitMask::WordType BitMask:: +INLINE typename BitMask::WordType BitMask:: get_word() const { return _word; } diff --git a/panda/src/putil/copyOnWritePointer.I b/panda/src/putil/copyOnWritePointer.I index 548844ca4e..2f5f79b281 100644 --- a/panda/src/putil/copyOnWritePointer.I +++ b/panda/src/putil/copyOnWritePointer.I @@ -357,11 +357,11 @@ operator = (PointerTo &&from) noexcept { * See CopyOnWritePointer::get_read_pointer(). */ template -INLINE CPT(TYPENAME CopyOnWritePointerTo::To) CopyOnWritePointerTo:: +INLINE CPT(typename CopyOnWritePointerTo::To) CopyOnWritePointerTo:: get_read_pointer(Thread *current_thread) const { // This is necessary because we don't currently have a way to cast between // two compatible PointerTo types without losing the reference count. - CPT(TYPENAME CopyOnWritePointerTo::To) to; + CPT(typename CopyOnWritePointerTo::To) to; CPT(CopyOnWriteObject) from = CopyOnWritePointer::get_read_pointer(current_thread); to.cheat() = (const To *)from.p(); from.cheat() = nullptr; @@ -372,7 +372,7 @@ get_read_pointer(Thread *current_thread) const { * See CopyOnWritePointer::get_read_pointer(). */ template -INLINE const TYPENAME CopyOnWritePointerTo::To *CopyOnWritePointerTo:: +INLINE const typename CopyOnWritePointerTo::To *CopyOnWritePointerTo:: get_read_pointer(Thread *current_thread) const { return (const To *)CopyOnWritePointer::get_read_pointer(current_thread); } @@ -385,11 +385,11 @@ get_read_pointer(Thread *current_thread) const { * See CopyOnWritePointer::get_write_pointer(). */ template -INLINE PT(TYPENAME CopyOnWritePointerTo::To) CopyOnWritePointerTo:: +INLINE PT(typename CopyOnWritePointerTo::To) CopyOnWritePointerTo:: get_write_pointer() { // This is necessary because we don't currently have a way to cast between // two compatible PointerTo types without losing the reference count. - PT(TYPENAME CopyOnWritePointerTo::To) to; + PT(typename CopyOnWritePointerTo::To) to; PT(CopyOnWriteObject) from = CopyOnWritePointer::get_write_pointer(); to.cheat() = (To *)from.p(); from.cheat() = nullptr; @@ -400,7 +400,7 @@ get_write_pointer() { * See CopyOnWritePointer::get_write_pointer(). */ template -INLINE TYPENAME CopyOnWritePointerTo::To *CopyOnWritePointerTo:: +INLINE typename CopyOnWritePointerTo::To *CopyOnWritePointerTo:: get_write_pointer() { return (To *)CopyOnWritePointer::get_write_pointer(); } @@ -412,7 +412,7 @@ get_write_pointer() { * See CopyOnWritePointer::get_unsafe_pointer(). */ template -INLINE TYPENAME CopyOnWritePointerTo::To *CopyOnWritePointerTo:: +INLINE typename CopyOnWritePointerTo::To *CopyOnWritePointerTo:: get_unsafe_pointer() { return (To *)(CopyOnWritePointer::get_unsafe_pointer()); } diff --git a/panda/src/putil/doubleBitMask.I b/panda/src/putil/doubleBitMask.I index 001dec7eb3..d99f8d0da0 100644 --- a/panda/src/putil/doubleBitMask.I +++ b/panda/src/putil/doubleBitMask.I @@ -167,7 +167,7 @@ is_all_on() const { * DoubleBitMask, shifted to the least-significant position. */ template -INLINE TYPENAME DoubleBitMask::WordType DoubleBitMask:: +INLINE typename DoubleBitMask::WordType DoubleBitMask:: extract(int low_bit, int size) const { if (low_bit >= half_bits) { return _hi.extract(low_bit - half_bits, size); diff --git a/panda/src/putil/doubleBitMask.h b/panda/src/putil/doubleBitMask.h index de17e6091b..2f1d1c5806 100644 --- a/panda/src/putil/doubleBitMask.h +++ b/panda/src/putil/doubleBitMask.h @@ -27,7 +27,7 @@ template class DoubleBitMask { public: - typedef TYPENAME BMType::WordType WordType; + typedef typename BMType::WordType WordType; PUBLISHED: typedef BMType BitMaskType; diff --git a/panda/src/putil/iterator_types.h b/panda/src/putil/iterator_types.h index 80d8f32882..ec90638237 100644 --- a/panda/src/putil/iterator_types.h +++ b/panda/src/putil/iterator_types.h @@ -24,7 +24,7 @@ template class first_of_pair_iterator : public pair_iterator { public: - typedef TYPENAME pair_iterator::value_type::first_type value_type; + typedef typename pair_iterator::value_type::first_type value_type; first_of_pair_iterator() = default; first_of_pair_iterator(const pair_iterator &init) : pair_iterator(init) { } @@ -42,7 +42,7 @@ public: template class second_of_pair_iterator : public pair_iterator { public: - typedef TYPENAME pair_iterator::value_type::second_type value_type; + typedef typename pair_iterator::value_type::second_type value_type; second_of_pair_iterator() = default; second_of_pair_iterator(const pair_iterator &init) : pair_iterator(init) { } From f0fc6e6d5632faf13eff67b61f5fa44ec32af55d Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 3 Jun 2018 16:56:44 -0600 Subject: [PATCH 233/247] express: Fully qualify std::nullptr_t --- panda/src/express/weakPointerToBase.I | 12 ++++++------ panda/src/express/weakPointerToBase.h | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/panda/src/express/weakPointerToBase.I b/panda/src/express/weakPointerToBase.I index 938196cc33..4b610e34fd 100644 --- a/panda/src/express/weakPointerToBase.I +++ b/panda/src/express/weakPointerToBase.I @@ -297,7 +297,7 @@ operator >= (To *other) const { */ template INLINE bool WeakPointerToBase:: -operator == (nullptr_t) const { +operator == (std::nullptr_t) const { return _void_ptr == nullptr; } @@ -306,7 +306,7 @@ operator == (nullptr_t) const { */ template INLINE bool WeakPointerToBase:: -operator != (nullptr_t) const { +operator != (std::nullptr_t) const { return _void_ptr != nullptr; } @@ -315,7 +315,7 @@ operator != (nullptr_t) const { */ template INLINE bool WeakPointerToBase:: -operator > (nullptr_t) const { +operator > (std::nullptr_t) const { return _void_ptr != nullptr; } @@ -324,7 +324,7 @@ operator > (nullptr_t) const { */ template INLINE bool WeakPointerToBase:: -operator <= (nullptr_t) const { +operator <= (std::nullptr_t) const { return _void_ptr == nullptr; } @@ -333,7 +333,7 @@ operator <= (nullptr_t) const { */ template INLINE bool WeakPointerToBase:: -operator >= (nullptr_t) const { +operator >= (std::nullptr_t) const { return true; } @@ -442,7 +442,7 @@ operator < (const To *other) const { */ template INLINE bool WeakPointerToBase:: -operator < (nullptr_t) const { +operator < (std::nullptr_t) const { return false; } diff --git a/panda/src/express/weakPointerToBase.h b/panda/src/express/weakPointerToBase.h index 20505191e3..34960920ab 100644 --- a/panda/src/express/weakPointerToBase.h +++ b/panda/src/express/weakPointerToBase.h @@ -60,11 +60,11 @@ public: INLINE bool operator <= (To *other) const; INLINE bool operator >= (To *other) const; - INLINE bool operator == (nullptr_t) const; - INLINE bool operator != (nullptr_t) const; - INLINE bool operator > (nullptr_t) const; - INLINE bool operator <= (nullptr_t) const; - INLINE bool operator >= (nullptr_t) const; + INLINE bool operator == (std::nullptr_t) const; + INLINE bool operator != (std::nullptr_t) const; + INLINE bool operator > (std::nullptr_t) const; + INLINE bool operator <= (std::nullptr_t) const; + INLINE bool operator >= (std::nullptr_t) const; INLINE bool operator == (const WeakPointerToBase &other) const; INLINE bool operator != (const WeakPointerToBase &other) const; @@ -79,7 +79,7 @@ public: INLINE bool operator >= (const PointerToBase &other) const; #endif // WIN32_VC INLINE bool operator < (const To *other) const; - INLINE bool operator < (nullptr_t) const; + INLINE bool operator < (std::nullptr_t) const; INLINE bool operator < (const WeakPointerToBase &other) const; INLINE bool operator < (const PointerToBase &other) const; #endif // CPPPARSER From 9fefa1d2e6acbc23b7555b8a83754a169ba783d6 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 3 Jun 2018 17:40:26 -0600 Subject: [PATCH 234/247] interrogate: Fix missing namespace qualification --- dtool/src/interrogate/functionWriters.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dtool/src/interrogate/functionWriters.h b/dtool/src/interrogate/functionWriters.h index 0db121de10..41943c47f7 100644 --- a/dtool/src/interrogate/functionWriters.h +++ b/dtool/src/interrogate/functionWriters.h @@ -42,7 +42,7 @@ protected: } }; - typedef set Writers; + typedef std::set Writers; Writers _writers; }; From be282627a83d2d263cfeb0524c586764999af62c Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 1 Jun 2018 22:02:10 +0200 Subject: [PATCH 235/247] express: make PointerTo directly initializable from nullptr --- dtool/src/interrogate/interfaceMakerPythonNative.cxx | 3 +++ panda/src/express/pointerTo.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 5d6c353088..27151b8cbe 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -5451,6 +5451,9 @@ write_function_instance(ostream &out, FunctionRemap *remap, if (TypeManager::is_reference_count(obj_type)) { // We use a PointerTo to handle the management here. It's cleaner // that way. + if (default_expr == " = 0" || default_expr == " = nullptr") { + default_expr.clear(); + } if (TypeManager::is_const_pointer_to_anything(type)) { extra_convert << "CPT(" << class_name << ") " << param_name << "_this" diff --git a/panda/src/express/pointerTo.h b/panda/src/express/pointerTo.h index 1dcf369064..1f9704c3f3 100644 --- a/panda/src/express/pointerTo.h +++ b/panda/src/express/pointerTo.h @@ -71,6 +71,7 @@ public: typedef typename PointerToBase::To To; PUBLISHED: ALWAYS_INLINE constexpr PointerTo() noexcept = default; + ALWAYS_INLINE explicit constexpr PointerTo(std::nullptr_t) noexcept {} ALWAYS_INLINE PointerTo(To *ptr) noexcept; INLINE PointerTo(const PointerTo ©); @@ -132,6 +133,7 @@ public: typedef typename PointerToBase::To To; PUBLISHED: ALWAYS_INLINE constexpr ConstPointerTo() noexcept = default; + ALWAYS_INLINE explicit constexpr ConstPointerTo(std::nullptr_t) noexcept {} ALWAYS_INLINE ConstPointerTo(const To *ptr) noexcept; INLINE ConstPointerTo(const PointerTo ©); INLINE ConstPointerTo(const ConstPointerTo ©); From 8a9d83b6044ed48e5e151e82eb3de5c464829aa6 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 4 Jun 2018 17:28:13 +0200 Subject: [PATCH 236/247] physx: fix compile error --- panda/src/physx/physxRevoluteJoint.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/panda/src/physx/physxRevoluteJoint.cxx b/panda/src/physx/physxRevoluteJoint.cxx index a969c78cee..43314ba157 100644 --- a/panda/src/physx/physxRevoluteJoint.cxx +++ b/panda/src/physx/physxRevoluteJoint.cxx @@ -242,7 +242,7 @@ set_limits(const PhysxJointLimitDesc &low, const PhysxJointLimitDesc &high) { PhysxMotorDesc PhysxRevoluteJoint:: get_motor() const { - nassertr(_error_type == ET_ok, nullptr); + nassertr(_error_type == ET_ok, PhysxMotorDesc(0)); PhysxMotorDesc value; _ptr->getMotor(value._desc); @@ -255,7 +255,7 @@ get_motor() const { PhysxSpringDesc PhysxRevoluteJoint:: get_spring() const { - nassertr(_error_type == ET_ok, nullptr); + nassertr(_error_type == ET_ok, PhysxSpringDesc(0)); PhysxSpringDesc value; _ptr->getSpring(value._desc); From 5582e174b6b37b66393e0480f0e7c56fc9c2d072 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 4 Jun 2018 17:30:02 +0200 Subject: [PATCH 237/247] cppparser: fix issue with typedefs to forward declared templates I don't know if this is the right solution, but it does fix an issue accessing std::ios::openmode caused by the ios typedef being defined before ios_base is fully specified. --- dtool/src/cppparser/cppIdentifier.cxx | 4 ++-- dtool/src/cppparser/cppScope.cxx | 20 ++++++++++++++------ dtool/src/cppparser/cppScope.h | 3 ++- dtool/src/interrogate/interrogateBuilder.cxx | 4 ++++ 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/dtool/src/cppparser/cppIdentifier.cxx b/dtool/src/cppparser/cppIdentifier.cxx index 8ffb6cefd8..9fd7b500c8 100644 --- a/dtool/src/cppparser/cppIdentifier.cxx +++ b/dtool/src/cppparser/cppIdentifier.cxx @@ -252,7 +252,7 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, } while (i + 1 < (int)_names.size() && scope != nullptr) { - CPPScope *next_scope = scope->find_scope(_names[i].get_name()); + CPPScope *next_scope = scope->find_scope(_names[i].get_name(), global_scope); if (next_scope == nullptr) { if (error_sink != nullptr) { error_sink->error("Symbol " + _names[i].get_name() + @@ -511,7 +511,7 @@ find_scope(CPPScope *current_scope, CPPScope *global_scope, if (scope == nullptr) { return nullptr; } - return scope->find_scope(get_simple_name()); + return scope->find_scope(get_simple_name(), global_scope); } diff --git a/dtool/src/cppparser/cppScope.cxx b/dtool/src/cppparser/cppScope.cxx index 34f2d47c7f..878daa8812 100644 --- a/dtool/src/cppparser/cppScope.cxx +++ b/dtool/src/cppparser/cppScope.cxx @@ -605,7 +605,7 @@ find_type(const string &name, CPPDeclaration::SubstDecl &subst, * */ CPPScope *CPPScope:: -find_scope(const string &name, bool recurse) const { +find_scope(const string &name, CPPScope *global_scope, bool recurse) const { Namespaces::const_iterator ni = _namespaces.find(name); if (ni != _namespaces.end()) { return (*ni).second->get_scope(); @@ -617,13 +617,21 @@ find_scope(const string &name, bool recurse) const { ti = _types.find(name); if (ti != _types.end()) { type = (*ti).second; - // Resolve if this is a typedef or const. + // Resolve if this is a typedef or const, or a TBD type. while (type->get_subtype() == CPPDeclaration::ST_const || - type->get_subtype() == CPPDeclaration::ST_typedef) { + type->get_subtype() == CPPDeclaration::ST_typedef || + type->get_subtype() == CPPDeclaration::ST_tbd) { if (type->as_typedef_type() != nullptr) { type = type->as_typedef_type()->_type; - } else { + } else if (type->as_const_type() != nullptr) { type = type->as_const_type()->_wrapped_around; + } else { + CPPType *new_type = type->resolve_type((CPPScope *)this, global_scope); + if (new_type != type) { + type = new_type; + } else { + break; + } } } @@ -653,14 +661,14 @@ find_scope(const string &name, bool recurse) const { Using::const_iterator ui; for (ui = _using.begin(); ui != _using.end(); ++ui) { - CPPScope *scope = (*ui)->find_scope(name, false); + CPPScope *scope = (*ui)->find_scope(name, global_scope, false); if (scope != nullptr) { return scope; } } if (recurse && _parent_scope != nullptr) { - return _parent_scope->find_scope(name); + return _parent_scope->find_scope(name, global_scope); } return nullptr; diff --git a/dtool/src/cppparser/cppScope.h b/dtool/src/cppparser/cppScope.h index 76539bff3b..d7df06b481 100644 --- a/dtool/src/cppparser/cppScope.h +++ b/dtool/src/cppparser/cppScope.h @@ -87,7 +87,8 @@ public: CPPDeclaration::SubstDecl &subst, CPPScope *global_scope, bool recurse = true) const; - CPPScope *find_scope(const string &name, bool recurse = true) const; + CPPScope *find_scope(const string &name, CPPScope *global_scope, + bool recurse = true) const; CPPScope *find_scope(const string &name, CPPDeclaration::SubstDecl &subst, CPPScope *global_scope, diff --git a/dtool/src/interrogate/interrogateBuilder.cxx b/dtool/src/interrogate/interrogateBuilder.cxx index 1e3fdacaa7..f320a66943 100644 --- a/dtool/src/interrogate/interrogateBuilder.cxx +++ b/dtool/src/interrogate/interrogateBuilder.cxx @@ -2267,6 +2267,10 @@ get_type(CPPType *type, bool global) { return 0; } + if (type->get_subtype() == CPPType::ST_tbd) { + type = type->resolve_type(&parser, &parser); + } + TypeIndex index = 0; // First, check to see if it's already there. From e27cb2dec32bcf30071c844e4ca787d1c7bfd3a8 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 4 Jun 2018 20:15:23 +0200 Subject: [PATCH 238/247] parser-inc: provide various more STL headers and definitions This cuts down on various warnings generated by interrogate. --- dtool/src/dtoolbase/dtoolbase_cc.h | 3 + dtool/src/dtoolutil/config_dtoolutil.N | 1 + dtool/src/parser-inc/algorithm | 7 ++ dtool/src/parser-inc/atomic | 19 +++++ dtool/src/parser-inc/clocale | 1 + dtool/src/parser-inc/cstddef | 7 ++ dtool/src/parser-inc/cstdint | 1 + dtool/src/parser-inc/cstdio | 1 + dtool/src/parser-inc/cstring | 1 + dtool/src/parser-inc/ctime | 1 + dtool/src/parser-inc/cwchar | 8 ++ dtool/src/parser-inc/exception | 10 +++ dtool/src/parser-inc/initializer_list | 2 + dtool/src/parser-inc/iomanip | 6 ++ dtool/src/parser-inc/ios | 106 +++++++++++++++++++++++++ dtool/src/parser-inc/iosfwd | 74 +++++++++++++++++ dtool/src/parser-inc/iostream | 61 +------------- dtool/src/parser-inc/mutex | 28 +++++++ dtool/src/parser-inc/ostream | 12 +++ dtool/src/parser-inc/stdtypedefs.h | 4 +- dtool/src/parser-inc/streambuf | 14 ++++ dtool/src/parser-inc/string | 28 ++++++- dtool/src/parser-inc/utility | 16 ++++ 23 files changed, 350 insertions(+), 61 deletions(-) create mode 100644 dtool/src/parser-inc/atomic create mode 100644 dtool/src/parser-inc/clocale create mode 100644 dtool/src/parser-inc/cstddef create mode 100644 dtool/src/parser-inc/cstdint create mode 100644 dtool/src/parser-inc/cstdio create mode 100644 dtool/src/parser-inc/cstring create mode 100644 dtool/src/parser-inc/ctime create mode 100644 dtool/src/parser-inc/cwchar create mode 100644 dtool/src/parser-inc/exception create mode 100644 dtool/src/parser-inc/iomanip create mode 100644 dtool/src/parser-inc/ios create mode 100644 dtool/src/parser-inc/iosfwd create mode 100644 dtool/src/parser-inc/mutex create mode 100644 dtool/src/parser-inc/ostream create mode 100644 dtool/src/parser-inc/streambuf create mode 100644 dtool/src/parser-inc/utility diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index 2aa6dc6252..db12cc8737 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -33,7 +33,10 @@ #ifdef CPPPARSER #include +#include #include +#include +#include #define INLINE inline #define ALWAYS_INLINE inline diff --git a/dtool/src/dtoolutil/config_dtoolutil.N b/dtool/src/dtoolutil/config_dtoolutil.N index 2577aa3b24..07e763282f 100644 --- a/dtool/src/dtoolutil/config_dtoolutil.N +++ b/dtool/src/dtoolutil/config_dtoolutil.N @@ -3,6 +3,7 @@ forcetype ifstream forcetype fstream forcetype ios_base +forcetype basic_ios forcetype ios forcetype istream forcetype ostream diff --git a/dtool/src/parser-inc/algorithm b/dtool/src/parser-inc/algorithm index 6f409742c2..751a8ec2cb 100644 --- a/dtool/src/parser-inc/algorithm +++ b/dtool/src/parser-inc/algorithm @@ -20,5 +20,12 @@ #ifndef ALGORITHM_H #define ALGORITHM_H +namespace std { + template + constexpr const T &min(const T &a, const T &b); + template + constexpr const T &max(const T &a, const T &b); +} + #endif diff --git a/dtool/src/parser-inc/atomic b/dtool/src/parser-inc/atomic new file mode 100644 index 0000000000..a7e174937b --- /dev/null +++ b/dtool/src/parser-inc/atomic @@ -0,0 +1,19 @@ +#pragma once + +#include + +namespace std { + typedef enum memory_order { + memory_order_relaxed, + memory_order_consume, + memory_order_acquire, + memory_order_release, + memory_order_acq_rel, + memory_order_seq_cst + } memory_order; + + template struct atomic; + template struct atomic; + + struct atomic_flag; +} diff --git a/dtool/src/parser-inc/clocale b/dtool/src/parser-inc/clocale new file mode 100644 index 0000000000..a889a57372 --- /dev/null +++ b/dtool/src/parser-inc/clocale @@ -0,0 +1 @@ +#include diff --git a/dtool/src/parser-inc/cstddef b/dtool/src/parser-inc/cstddef new file mode 100644 index 0000000000..78ed8af5a5 --- /dev/null +++ b/dtool/src/parser-inc/cstddef @@ -0,0 +1,7 @@ +#pragma once + +#include + +namespace std { + enum class byte : unsigned char {}; +} diff --git a/dtool/src/parser-inc/cstdint b/dtool/src/parser-inc/cstdint new file mode 100644 index 0000000000..9a6118bd85 --- /dev/null +++ b/dtool/src/parser-inc/cstdint @@ -0,0 +1 @@ +#include diff --git a/dtool/src/parser-inc/cstdio b/dtool/src/parser-inc/cstdio new file mode 100644 index 0000000000..53c5fdf179 --- /dev/null +++ b/dtool/src/parser-inc/cstdio @@ -0,0 +1 @@ +#include diff --git a/dtool/src/parser-inc/cstring b/dtool/src/parser-inc/cstring new file mode 100644 index 0000000000..3b2f590027 --- /dev/null +++ b/dtool/src/parser-inc/cstring @@ -0,0 +1 @@ +#include diff --git a/dtool/src/parser-inc/ctime b/dtool/src/parser-inc/ctime new file mode 100644 index 0000000000..91fd18715f --- /dev/null +++ b/dtool/src/parser-inc/ctime @@ -0,0 +1 @@ +#include diff --git a/dtool/src/parser-inc/cwchar b/dtool/src/parser-inc/cwchar new file mode 100644 index 0000000000..598c31d9a3 --- /dev/null +++ b/dtool/src/parser-inc/cwchar @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace std { + struct mbstate_t; + typedef int wint_t; +} diff --git a/dtool/src/parser-inc/exception b/dtool/src/parser-inc/exception new file mode 100644 index 0000000000..d48d80620e --- /dev/null +++ b/dtool/src/parser-inc/exception @@ -0,0 +1,10 @@ +#pragma once + +namespace std { + class exception; + class bad_exception; + class nested_exception; + + typedef void (*unexpected_handler)(); + typedef void (*terminate_handler)(); +} diff --git a/dtool/src/parser-inc/initializer_list b/dtool/src/parser-inc/initializer_list index 57a3f7f6c1..289b0e4bf7 100644 --- a/dtool/src/parser-inc/initializer_list +++ b/dtool/src/parser-inc/initializer_list @@ -32,3 +32,5 @@ namespace std { typedef const E* const_iterator; }; } + +#endif diff --git a/dtool/src/parser-inc/iomanip b/dtool/src/parser-inc/iomanip new file mode 100644 index 0000000000..cc19f56b38 --- /dev/null +++ b/dtool/src/parser-inc/iomanip @@ -0,0 +1,6 @@ +#pragma once + +namespace std { + template void setfill(CharT c); + void setw(int); +} diff --git a/dtool/src/parser-inc/ios b/dtool/src/parser-inc/ios new file mode 100644 index 0000000000..4ea9143c4a --- /dev/null +++ b/dtool/src/parser-inc/ios @@ -0,0 +1,106 @@ +#pragma once + +#include + +// We actually want to wrap streampos as streamoff. +#define streampos streamoff + +namespace std { +#ifdef _WIN64 + typedef long long streamoff; + typedef long long streamsize; +#elif defined(_WIN32) + typedef long streamoff; + typedef int streamsize; +#else + typedef long long streamoff; + typedef ptrdiff_t streamsize; +#endif + + // We need to expose one method in each class to force it to publish. + // But we'd like to expose some of these methods anyway, so no + // problem. + class ios_base { + public: + class failure; + class Init; + enum event { + erase_event, + imbue_event, + copyfmt_event, + }; + + ios_base(const ios_base&) = delete; + ios_base &operator = (const ios_base&) = delete; + + __published: + enum seekdir { + beg = 0, + cur = 1, + end = 2, + }; + enum openmode { + }; + // Don't define these lest interrogate get tempted to actually + // substitute in the values, which are implementation-defined. + static const openmode app; + static const openmode binary; + static const openmode in; + static const openmode out; + static const openmode trunc; + protected: + // Force this to be a non-trivial type. + ios_base() {}; + }; + + template > + class basic_ios : public ios_base { + public: + typedef charT char_type; + typedef typename traits::int_type int_type; + typedef typename traits::pos_type pos_type; + typedef typename traits::off_type off_type; + typedef traits traits_type; + + __published: + typedef long fmtflags; + + bool good() const; + bool eof() const; + bool fail() const; + bool bad() const; + void clear(); + + protected: + basic_ios(); + }; + + ios_base &boolalpha(ios_base &str); + ios_base &noboolalpha(ios_base &str); + ios_base &showbase(ios_base &str); + ios_base &noshowbase(ios_base &str); + ios_base &showpoint(ios_base &str); + ios_base &noshowpoint(ios_base &str); + ios_base &showpos(ios_base &str); + ios_base &noshowpos(ios_base &str); + ios_base &skipws(ios_base &str); + ios_base &noskipws(ios_base &str); + ios_base &uppercase(ios_base &str); + ios_base &nouppercase(ios_base &str); + ios_base &unitbuf(ios_base &str); + ios_base &nounitbuf(ios_base &str); + ios_base &internal(ios_base &str); + ios_base &left(ios_base &str); + ios_base &right(ios_base &str); + ios_base &dec(ios_base &str); + ios_base &hex(ios_base &str); + ios_base &oct(ios_base &str); + ios_base &fixed(ios_base &str); + ios_base &scientific(ios_base &str); + ios_base &hexfloat(ios_base &str); + ios_base &defaultfloat(ios_base &str); + + enum class io_errc { + stream = 1 + }; +} diff --git a/dtool/src/parser-inc/iosfwd b/dtool/src/parser-inc/iosfwd new file mode 100644 index 0000000000..176982d433 --- /dev/null +++ b/dtool/src/parser-inc/iosfwd @@ -0,0 +1,74 @@ +#pragma once + +#include +#include +#include + +namespace std { + template class allocator; + + template > class basic_ios; + template > class basic_istream; + template > class basic_ostream; + template > class basic_iostream; + template, class Allocator = allocator > class basic_stringbuf; + + template, class Allocator = allocator > class basic_istringstream; + template, class Allocator = allocator > class basic_ostringstream; + template, class Allocator = allocator > class basic_stringstream; + + template > class basic_filebuf; + template > class basic_ifstream; + template > class basic_ofstream; + template > class basic_fstream; + + template, class Allocator = allocator > class basic_syncbuf; + template, class Allocator = allocator > class basic_osyncstream; + + template > class istreambuf_iterator; + template > class ostreambuf_iterator; + + typedef basic_ios ios; + typedef basic_ios wios; + + //typedef basic_istream istream; + //typedef basic_ostream ostream; + //typedef basic_iostream iostream; + class istream; + class ostream; + class iostream; + + typedef basic_stringbuf stringbuf; + typedef basic_istringstream istringstream; + typedef basic_ostringstream ostringstream; + typedef basic_stringstream stringstream; + + typedef basic_filebuf filebuf; + typedef basic_ifstream ifstream; + typedef basic_ofstream ofstream; + typedef basic_fstream fstream; + + typedef basic_syncbuf syncbuf; + typedef basic_osyncstream osyncstream; + + typedef basic_istream wistream; + typedef basic_ostream wostream; + typedef basic_iostream wiostream; + + typedef basic_stringbuf wstringbuf; + typedef basic_istringstream wistringstream; + typedef basic_ostringstream wostringstream; + typedef basic_stringstream wstringstream; + + typedef basic_filebuf wfilebuf; + typedef basic_ifstream wifstream; + typedef basic_ofstream wofstream; + typedef basic_fstream wfstream; + + typedef basic_syncbuf wsyncbuf; + typedef basic_osyncstream wosyncstream; + + template class fpos; + typedef fpos streampos; + typedef fpos wstreampos; +} diff --git a/dtool/src/parser-inc/iostream b/dtool/src/parser-inc/iostream index 170d1d03f9..a01e208740 100644 --- a/dtool/src/parser-inc/iostream +++ b/dtool/src/parser-inc/iostream @@ -21,64 +21,14 @@ #define IOSTREAM_H #include - -#ifdef _WIN64 -typedef long long streamoff; -typedef long long streamsize; -#elif defined(_WIN32) -typedef long streamoff; -typedef int streamsize; -#else -typedef long long streamoff; -typedef ptrdiff_t streamsize; -#endif +#include +#include +#include // We don't care (much) about the actual definition of the various // iostream classes, but we do need to know the classnames that are // available. -// We need to expose one method in each class to force it to publish. -// But we'd like to expose some of these methods anyway, so no -// problem. -class ios_base { -__published: - enum seekdir { - beg = 0, - cur = 1, - end = 2, - }; - enum openmode { - }; - // Don't define these lest interrogate get tempted to actually - // substitute in the values, which are implementation-defined. - static const openmode app; - static const openmode binary; - static const openmode in; - static const openmode out; - static const openmode trunc; -protected: - // Force this to be a non-trivial type. - ios_base() {}; -private: - ios_base(const ios_base &); -}; -class ios : public ios_base { -__published: - typedef long fmtflags; - - bool good() const; - bool eof() const; - bool fail() const; - bool bad() const; - void clear(); - -protected: - ios(); -}; - -// We actually want to wrap streampos as streamoff. -#define streampos streamoff - class ostream : virtual public ios { __published: ostream(const ostream&) = delete; @@ -130,11 +80,6 @@ __published: void close(); }; -class ostringstream : public ostream {}; -class istringstream : public istream {}; -class stringstream : public iostream {}; -class streambuf {}; - extern istream cin; extern ostream cout; extern ostream cerr; diff --git a/dtool/src/parser-inc/mutex b/dtool/src/parser-inc/mutex new file mode 100644 index 0000000000..b05214e512 --- /dev/null +++ b/dtool/src/parser-inc/mutex @@ -0,0 +1,28 @@ +#pragma once + +namespace std { + class mutex; + class recursive_mutex; + class timed_mutex; + class recursive_timed_mutex; + + struct defer_lock_t { + explicit defer_lock_t() = default; + }; + inline constexpr defer_lock_t defer_lock {}; + + struct try_to_lock_t { + explicit try_to_lock_t() = default; + }; + inline constexpr try_to_lock_t try_to_lock {}; + + struct adopt_lock_t { + explicit adopt_lock_t() = default; + }; + inline constexpr adopt_lock_t adopt_lock {}; + + template class lock_guard; + template class unique_lock; + + struct once_flag; +} diff --git a/dtool/src/parser-inc/ostream b/dtool/src/parser-inc/ostream new file mode 100644 index 0000000000..fb7f7ea51e --- /dev/null +++ b/dtool/src/parser-inc/ostream @@ -0,0 +1,12 @@ +#pragma once + +namespace std { + template + std::basic_ostream &ends(std::basic_ostream &os); + + template + std::basic_ostream &flush(std::basic_ostream &os); + + template + std::basic_ostream &endl(std::basic_ostream &os); +} diff --git a/dtool/src/parser-inc/stdtypedefs.h b/dtool/src/parser-inc/stdtypedefs.h index f971d7e1f2..873ba9425d 100644 --- a/dtool/src/parser-inc/stdtypedefs.h +++ b/dtool/src/parser-inc/stdtypedefs.h @@ -46,7 +46,9 @@ struct timeval; #else #define NULL ((void *)0) #endif -typedef decltype(nullptr) nullptr_t; +namespace std { + typedef decltype(nullptr) nullptr_t; +} // One day, we might extend interrogate to be able to parse this, // but we currently don't need it. diff --git a/dtool/src/parser-inc/streambuf b/dtool/src/parser-inc/streambuf new file mode 100644 index 0000000000..b46f0faef3 --- /dev/null +++ b/dtool/src/parser-inc/streambuf @@ -0,0 +1,14 @@ +#pragma once + +namespace std { + template class char_traits; + template<> class char_traits; + template<> class char_traits; + template<> class char_traits; + template<> class char_traits; + + template > class basic_streambuf; + + typedef basic_streambuf streambuf; + typedef basic_streambuf wstreambuf; +} diff --git a/dtool/src/parser-inc/string b/dtool/src/parser-inc/string index 4ca8f3fa12..d27aaf783f 100644 --- a/dtool/src/parser-inc/string +++ b/dtool/src/parser-inc/string @@ -21,10 +21,34 @@ #define STRING_H #include +#include namespace std { - template - class char_traits; + template struct char_traits; + + template<> struct char_traits { + using char_type = char; + using int_type = int; + using state_type = mbstate_t; + }; + + template<> struct char_traits { + using char_type = char16_t; + using int_type = uint_least16_t; + using state_type = mbstate_t; + }; + + template<> struct char_traits { + using char_type = char32_t; + using int_type = uint_least32_t; + using state_type = mbstate_t; + }; + + template<> struct char_traits { + using char_type = wchar_t; + using int_type = wint_t; + using state_type = mbstate_t; + }; template class basic_string { diff --git a/dtool/src/parser-inc/utility b/dtool/src/parser-inc/utility new file mode 100644 index 0000000000..119814b5c3 --- /dev/null +++ b/dtool/src/parser-inc/utility @@ -0,0 +1,16 @@ +#pragma once + +#include + +namespace std { + template void swap(T &a, T &b); + template void swap(T (&a)[N], T (&b)[N]); + + template struct remove_reference {typedef T type;}; + template struct remove_reference {typedef T type;}; + template struct remove_reference {typedef T type;}; + + template constexpr remove_reference::type &&move(T &&) noexcept; + + template struct pair; +} From f990f816b86050a0e54afff6b7d70ff585d1484b Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 6 Jun 2018 11:27:11 +0200 Subject: [PATCH 239/247] maxegg: fix compilation error due to nullptr misuse --- pandatool/src/maxegg/maxEgg.cxx | 2 +- pandatool/src/maxegg/maxOptionsDialog.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandatool/src/maxegg/maxEgg.cxx b/pandatool/src/maxegg/maxEgg.cxx index c76a8e2ecf..798192e26c 100644 --- a/pandatool/src/maxegg/maxEgg.cxx +++ b/pandatool/src/maxegg/maxEgg.cxx @@ -456,7 +456,7 @@ void MaxEggPlugin::EndEditParams( IObjParam *ip, ULONG flags,Animatable *prev) ip->DeleteRollupPage(hMaxEggParams); hMaxEggParams = nullptr; } else { - SetWindowLongPtr( hMaxEggParams, GWLP_USERDATA, nullptr ); + SetWindowLongPtr( hMaxEggParams, GWLP_USERDATA, 0L ); } } diff --git a/pandatool/src/maxegg/maxOptionsDialog.cxx b/pandatool/src/maxegg/maxOptionsDialog.cxx index 22bfc6b1bc..fdcd46cf3e 100644 --- a/pandatool/src/maxegg/maxOptionsDialog.cxx +++ b/pandatool/src/maxegg/maxOptionsDialog.cxx @@ -593,7 +593,7 @@ bool MaxOptionsDialog::UpdateFromUI(HWND hWnd) { _stprintf(_short_name, _T("%.*s..."), sizeof(_short_name)-4, temp); else { _tcscpy(_short_name, temp); - _short_name[_tcslen(_short_name) - 4] = nullptr; //Cut off the .egg + _short_name[_tcslen(_short_name) - 4] = 0; //Cut off the .egg } _start_frame = newSF; From 036d2c2548ac1627b91cb685677fd9fcb0f153cd Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 6 Jun 2018 11:27:46 +0200 Subject: [PATCH 240/247] parser-inc: properly namespace iostream definitions --- dtool/src/parser-inc/iosfwd | 9 ++-- dtool/src/parser-inc/iostream | 94 ++++++++++++++++++----------------- 2 files changed, 54 insertions(+), 49 deletions(-) diff --git a/dtool/src/parser-inc/iosfwd b/dtool/src/parser-inc/iosfwd index 176982d433..abf62821ea 100644 --- a/dtool/src/parser-inc/iosfwd +++ b/dtool/src/parser-inc/iosfwd @@ -44,9 +44,12 @@ namespace std { typedef basic_stringstream stringstream; typedef basic_filebuf filebuf; - typedef basic_ifstream ifstream; - typedef basic_ofstream ofstream; - typedef basic_fstream fstream; + //typedef basic_ifstream ifstream; + //typedef basic_ofstream ofstream; + //typedef basic_fstream fstream; + class ifstream; + class ofstream; + class fstream; typedef basic_syncbuf syncbuf; typedef basic_osyncstream osyncstream; diff --git a/dtool/src/parser-inc/iostream b/dtool/src/parser-inc/iostream index a01e208740..8bfe91d0aa 100644 --- a/dtool/src/parser-inc/iostream +++ b/dtool/src/parser-inc/iostream @@ -29,59 +29,61 @@ // iostream classes, but we do need to know the classnames that are // available. -class ostream : virtual public ios { -__published: - ostream(const ostream&) = delete; +namespace std { + class ostream : virtual public ios { + __published: + ostream(const ostream&) = delete; - void put(char c); - void flush(); - streampos tellp(); - void seekp(streampos pos); - void seekp(streamoff off, ios_base::seekdir dir); + void put(char c); + void flush(); + streampos tellp(); + void seekp(streampos pos); + void seekp(streamoff off, ios_base::seekdir dir); -protected: - ostream(ostream &&); -}; -class istream : virtual public ios { -__published: - istream(const istream&) = delete; + protected: + ostream(ostream &&); + }; + class istream : virtual public ios { + __published: + istream(const istream&) = delete; - int get(); - streampos tellg(); - void seekg(streampos pos); - void seekg(streamoff off, ios_base::seekdir dir); + int get(); + streampos tellg(); + void seekg(streampos pos); + void seekg(streamoff off, ios_base::seekdir dir); -protected: - istream(istream &&); -}; -class iostream : public istream, public ostream { -__published: - iostream(const iostream&) = delete; + protected: + istream(istream &&); + }; + class iostream : public istream, public ostream { + __published: + iostream(const iostream&) = delete; - void flush(); + void flush(); -protected: - iostream(iostream &&); -}; + protected: + iostream(iostream &&); + }; -class ofstream : public ostream { -__published: - ofstream(); - void close(); -}; -class ifstream : public istream { -__published: - ifstream(); - void close(); -}; -class fstream : public iostream { -__published: - fstream(); - void close(); -}; + class ofstream : public ostream { + __published: + ofstream(); + void close(); + }; + class ifstream : public istream { + __published: + ifstream(); + void close(); + }; + class fstream : public iostream { + __published: + fstream(); + void close(); + }; -extern istream cin; -extern ostream cout; -extern ostream cerr; + extern istream cin; + extern ostream cout; + extern ostream cerr; +} #endif From 3a698e5a81266749ce4ebd7cfad6d47d6efafffa Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 6 Jun 2018 11:48:52 +0200 Subject: [PATCH 241/247] dtoolutil: use std:: qualification when exposing std types --- dtool/src/dtoolutil/config_dtoolutil.N | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/dtool/src/dtoolutil/config_dtoolutil.N b/dtool/src/dtoolutil/config_dtoolutil.N index 07e763282f..2ccd2b4210 100644 --- a/dtool/src/dtoolutil/config_dtoolutil.N +++ b/dtool/src/dtoolutil/config_dtoolutil.N @@ -1,10 +1,10 @@ -forcetype ofstream -forcetype ifstream -forcetype fstream +forcetype std::ofstream +forcetype std::ifstream +forcetype std::fstream -forcetype ios_base -forcetype basic_ios -forcetype ios -forcetype istream -forcetype ostream -forcetype iostream +forcetype std::ios_base +forcetype std::basic_ios +forcetype std::ios +forcetype std::istream +forcetype std::ostream +forcetype std::iostream From c166daf0f3ff8a2c0ca8d912df12457edc994ce4 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 6 Jun 2018 12:17:42 +0200 Subject: [PATCH 242/247] interrogate: fix detection of special std types --- dtool/src/interrogate/typeManager.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dtool/src/interrogate/typeManager.cxx b/dtool/src/interrogate/typeManager.cxx index d1d8b650b0..85161eb69e 100644 --- a/dtool/src/interrogate/typeManager.cxx +++ b/dtool/src/interrogate/typeManager.cxx @@ -965,6 +965,7 @@ is_wstring(CPPType *type) { bool TypeManager:: is_vector_unsigned_char(CPPType *type) { if (type->get_local_name(&parser) == "vector< unsigned char >" || + type->get_local_name(&parser) == "std::vector< unsigned char >" || type->get_local_name(&parser) == "pvector< unsigned char >") { return true; } @@ -1804,7 +1805,9 @@ bool TypeManager::is_ostream(CPPType *type) { return is_ostream(type->as_const_type()->_wrapped_around); case CPPDeclaration::ST_struct: - return (type->get_local_name(&parser) == "ostream"); + return (type->get_local_name(&parser) == "std::ostream" || + type->get_local_name(&parser) == "ostream" || + type->get_local_name(&parser) == "std::basic_ostream< char >"); case CPPDeclaration::ST_typedef: return is_ostream(type->as_typedef_type()->_type); From 4e7edf8a5314cc8fa170eb1c6c8fc6e97bdba26f Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 6 Jun 2018 12:22:31 +0200 Subject: [PATCH 243/247] parser-inc: add missing include to header --- dtool/src/parser-inc/string | 1 + 1 file changed, 1 insertion(+) diff --git a/dtool/src/parser-inc/string b/dtool/src/parser-inc/string index d27aaf783f..841e6fd7c6 100644 --- a/dtool/src/parser-inc/string +++ b/dtool/src/parser-inc/string @@ -22,6 +22,7 @@ #include #include +#include namespace std { template struct char_traits; From e72fab9520d4e809786ddd7d6e1b6da57d546bfa Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 7 Jun 2018 01:46:41 -0600 Subject: [PATCH 244/247] dtoolutil: Add missing declaration for init_libdtoolutil() --- dtool/src/dtoolutil/config_dtoolutil.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dtool/src/dtoolutil/config_dtoolutil.h b/dtool/src/dtoolutil/config_dtoolutil.h index 20e9784c55..2d297937be 100644 --- a/dtool/src/dtoolutil/config_dtoolutil.h +++ b/dtool/src/dtoolutil/config_dtoolutil.h @@ -19,4 +19,6 @@ // Include this so interrogate can find it. #include +extern EXPCL_DTOOL_DTOOLUTIL void init_libdtoolutil(); + #endif From b7f8ddfe35a44169d6912da24c1abff36436527c Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 7 Jun 2018 10:34:47 +0200 Subject: [PATCH 245/247] dxgsg9: fix type mismatch in min() call --- panda/src/dxgsg9/dxShaderContext9.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/dxgsg9/dxShaderContext9.cxx b/panda/src/dxgsg9/dxShaderContext9.cxx index e3992bea5d..c3b1970bd9 100644 --- a/panda/src/dxgsg9/dxShaderContext9.cxx +++ b/panda/src/dxgsg9/dxShaderContext9.cxx @@ -207,7 +207,7 @@ issue_parameters(GSG *gsg, int altered) { // Calculate how many elements to transfer; no more than it expects, // but certainly no more than we have. - int input_size = min(abs(spec._dim[0] * spec._dim[1] * spec._dim[2]), ptr_data->_size); + int input_size = min(abs(spec._dim[0] * spec._dim[1] * spec._dim[2]), (int)ptr_data->_size); CGparameter p = _cg_parameter_map[spec._id._seqno]; switch (ptr_data->_type) { From 4754ba524ca87163d94d6e268ea7543770ac50ee Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Wed, 6 Jun 2018 16:03:15 -0600 Subject: [PATCH 246/247] dtoolbase: Avoid Windows's min/max macros --- dtool/src/dtoolbase/dtoolbase.h | 10 ++++++---- makepanda/makepanda.py | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dtool/src/dtoolbase/dtoolbase.h b/dtool/src/dtoolbase/dtoolbase.h index 1614d05cfd..f21e653695 100644 --- a/dtool/src/dtoolbase/dtoolbase.h +++ b/dtool/src/dtoolbase/dtoolbase.h @@ -60,6 +60,12 @@ #pragma warning (disable : 4577) #endif /* WIN32_VC */ +/* Windows likes to define min() and max() macros, which will conflict with + std::min() and std::max() respectively, unless we do this: */ +#ifdef WIN32 +#define NOMINMAX +#endif + #ifndef __has_builtin #define __has_builtin(x) 0 #endif @@ -198,10 +204,6 @@ typedef struct _object PyObject; #include #endif -#ifdef PHAVE_MINMAX_H -#include -#endif - #ifdef PHAVE_SYS_TIME_H #include #endif diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 4a369a6f72..1b49826a8f 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2310,7 +2310,6 @@ DTOOL_CONFIG=[ ("PHAVE_SYS_MALLOC_H", 'UNDEF', 'UNDEF'), ("PHAVE_ALLOCA_H", 'UNDEF', '1'), ("PHAVE_LOCALE_H", 'UNDEF', '1'), - ("PHAVE_MINMAX_H", '1', 'UNDEF'), ("PHAVE_SSTREAM", '1', '1'), ("PHAVE_NEW", '1', '1'), ("PHAVE_SYS_TYPES_H", '1', '1'), From 7790f8429daee269ccf058d210a1a035cb680a00 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Wed, 6 Jun 2018 00:02:28 -0600 Subject: [PATCH 247/247] general: Fully qualify header references into the std namespace Closes #341 --- contrib/src/ai/aiBehaviors.h | 30 ++--- contrib/src/ai/aiCharacter.h | 4 +- contrib/src/ai/aiWorld.h | 4 +- contrib/src/ai/pathFind.h | 4 +- contrib/src/ai/pathFollow.h | 6 +- contrib/src/rplight/gpuCommand.I | 2 +- contrib/src/rplight/gpuCommand.h | 2 +- contrib/src/rplight/pointerSlotStorage.h | 2 +- contrib/src/rplight/rpLight.I | 2 +- contrib/src/rplight/rpLight.h | 2 +- contrib/src/rplight/shadowAtlas.I | 2 +- contrib/src/rplight/shadowManager.I | 4 +- contrib/src/rplight/tagStateManager.I | 10 +- contrib/src/rplight/tagStateManager.h | 20 +-- direct/src/dcparser/dcArrayParameter.h | 8 +- direct/src/dcparser/dcAtomicField.h | 12 +- direct/src/dcparser/dcClass.I | 2 +- direct/src/dcparser/dcClass.h | 34 ++--- direct/src/dcparser/dcClassParameter.h | 4 +- direct/src/dcparser/dcDeclaration.h | 10 +- direct/src/dcparser/dcField.I | 8 +- direct/src/dcparser/dcField.h | 28 ++-- direct/src/dcparser/dcFile.h | 30 ++--- direct/src/dcparser/dcKeyword.h | 10 +- direct/src/dcparser/dcKeywordList.h | 8 +- direct/src/dcparser/dcLexerDefs.h | 6 +- direct/src/dcparser/dcMolecularField.h | 6 +- direct/src/dcparser/dcNumericRange.I | 14 +- direct/src/dcparser/dcNumericRange.h | 8 +- direct/src/dcparser/dcPackData.I | 4 +- direct/src/dcparser/dcPackData.h | 2 +- direct/src/dcparser/dcPacker.I | 38 +++--- direct/src/dcparser/dcPacker.h | 42 +++--- direct/src/dcparser/dcPackerCatalog.I | 2 +- direct/src/dcparser/dcPackerCatalog.h | 14 +- direct/src/dcparser/dcPackerInterface.I | 2 +- direct/src/dcparser/dcPackerInterface.h | 16 +-- direct/src/dcparser/dcParameter.h | 24 ++-- direct/src/dcparser/dcParserDefs.h | 8 +- direct/src/dcparser/dcSimpleParameter.h | 8 +- direct/src/dcparser/dcSubatomicType.h | 2 +- direct/src/dcparser/dcSwitch.h | 42 +++--- direct/src/dcparser/dcSwitchParameter.h | 10 +- direct/src/dcparser/dcTypedef.h | 10 +- direct/src/dcparser/dcindent.h | 4 +- direct/src/dcparser/hashGenerator.h | 2 +- direct/src/dcparser/primeNumberGenerator.h | 2 +- direct/src/deadrec/smoothMover.h | 4 +- direct/src/directd/directd.h | 20 +-- direct/src/directdServer/directdClient.h | 4 +- direct/src/directdServer/directdServer.h | 4 +- .../src/distributed/cConnectionRepository.I | 2 +- .../src/distributed/cConnectionRepository.h | 8 +- .../distributed/cDistributedSmoothNodeBase.h | 2 +- direct/src/interval/cConstrainHprInterval.h | 4 +- .../src/interval/cConstrainPosHprInterval.h | 4 +- direct/src/interval/cConstrainPosInterval.h | 4 +- .../interval/cConstrainTransformInterval.h | 4 +- direct/src/interval/cConstraintInterval.h | 2 +- direct/src/interval/cInterval.I | 10 +- direct/src/interval/cInterval.h | 22 ++-- direct/src/interval/cIntervalManager.I | 4 +- direct/src/interval/cIntervalManager.h | 10 +- direct/src/interval/cLerpAnimEffectInterval.I | 6 +- direct/src/interval/cLerpAnimEffectInterval.h | 10 +- direct/src/interval/cLerpInterval.I | 2 +- direct/src/interval/cLerpInterval.h | 4 +- direct/src/interval/cLerpNodePathInterval.h | 4 +- direct/src/interval/cMetaInterval.h | 20 +-- direct/src/interval/hideInterval.h | 2 +- direct/src/interval/showInterval.h | 2 +- direct/src/plugin/binaryXml.h | 4 +- direct/src/plugin/fileSpec.I | 8 +- direct/src/plugin/fileSpec.h | 30 ++--- direct/src/plugin/find_root_dir.h | 4 +- direct/src/plugin/handleStream.I | 10 +- direct/src/plugin/handleStream.h | 2 +- direct/src/plugin/handleStreamBuf.h | 2 +- direct/src/plugin/load_plugin.h | 26 ++-- direct/src/plugin/mkdir_complete.h | 8 +- direct/src/plugin/p3dAuthSession.h | 8 +- direct/src/plugin/p3dBoolObject.h | 2 +- direct/src/plugin/p3dCert.h | 14 +- direct/src/plugin/p3dCert_wx.h | 10 +- direct/src/plugin/p3dConcreteSequence.h | 8 +- direct/src/plugin/p3dConcreteStruct.h | 12 +- direct/src/plugin/p3dDownload.I | 2 +- direct/src/plugin/p3dDownload.h | 6 +- direct/src/plugin/p3dFileDownload.I | 2 +- direct/src/plugin/p3dFileDownload.h | 6 +- direct/src/plugin/p3dFileParams.I | 8 +- direct/src/plugin/p3dFileParams.h | 30 ++--- direct/src/plugin/p3dFloatObject.h | 2 +- direct/src/plugin/p3dHost.I | 12 +- direct/src/plugin/p3dHost.h | 84 ++++++------ direct/src/plugin/p3dInstance.I | 4 +- direct/src/plugin/p3dInstance.h | 80 ++++++------ direct/src/plugin/p3dInstanceManager.I | 24 ++-- direct/src/plugin/p3dInstanceManager.h | 122 +++++++++--------- direct/src/plugin/p3dIntObject.h | 2 +- direct/src/plugin/p3dMainObject.h | 22 ++-- direct/src/plugin/p3dMultifileReader.I | 2 +- direct/src/plugin/p3dMultifileReader.h | 18 +-- direct/src/plugin/p3dNoneObject.h | 2 +- direct/src/plugin/p3dObject.h | 34 ++--- direct/src/plugin/p3dOsxSplashWindow.h | 8 +- direct/src/plugin/p3dPackage.I | 22 ++-- direct/src/plugin/p3dPackage.h | 90 ++++++------- direct/src/plugin/p3dPatchFinder.h | 54 ++++---- direct/src/plugin/p3dPatchfileReader.h | 8 +- direct/src/plugin/p3dPythonObject.h | 18 +-- direct/src/plugin/p3dPythonRun.h | 4 +- direct/src/plugin/p3dSession.I | 4 +- direct/src/plugin/p3dSession.h | 32 ++--- direct/src/plugin/p3dSplashWindow.h | 12 +- direct/src/plugin/p3dStringObject.h | 8 +- direct/src/plugin/p3dTemporaryFile.I | 2 +- direct/src/plugin/p3dTemporaryFile.h | 8 +- direct/src/plugin/p3dUndefinedObject.h | 2 +- direct/src/plugin/p3dWinSplashWindow.h | 10 +- direct/src/plugin/p3dX11SplashWindow.h | 20 +-- direct/src/plugin/p3d_plugin_common.h | 6 +- direct/src/plugin/parse_color.h | 2 +- direct/src/plugin/wstring_encode.h | 8 +- direct/src/plugin/xml_helpers.h | 2 +- direct/src/plugin_activex/PPInstance.h | 4 +- direct/src/plugin_npapi/nppanda3d_common.h | 4 +- direct/src/plugin_npapi/ppBrowserObject.h | 8 +- direct/src/plugin_npapi/ppInstance.h | 62 ++++----- direct/src/plugin_npapi/ppPandaObject.h | 2 +- direct/src/plugin_standalone/p3dEmbed.h | 4 +- direct/src/plugin_standalone/panda3d.h | 14 +- direct/src/plugin_standalone/panda3dBase.h | 28 ++-- dtool/src/cppparser/cppArrayType.h | 8 +- dtool/src/cppparser/cppBisonDefs.h | 2 +- .../src/cppparser/cppClassTemplateParameter.h | 2 +- dtool/src/cppparser/cppClosureType.h | 6 +- dtool/src/cppparser/cppCommentBlock.h | 2 +- dtool/src/cppparser/cppConstType.h | 8 +- dtool/src/cppparser/cppDeclaration.h | 14 +- dtool/src/cppparser/cppEnumType.h | 6 +- dtool/src/cppparser/cppExpression.h | 14 +- dtool/src/cppparser/cppExpressionParser.h | 10 +- dtool/src/cppparser/cppExtensionType.h | 10 +- dtool/src/cppparser/cppFile.h | 2 +- dtool/src/cppparser/cppFunctionGroup.h | 8 +- dtool/src/cppparser/cppFunctionType.h | 16 +-- dtool/src/cppparser/cppGlobals.h | 2 +- dtool/src/cppparser/cppIdentifier.h | 22 ++-- dtool/src/cppparser/cppInstance.h | 14 +- dtool/src/cppparser/cppInstanceIdentifier.h | 2 +- dtool/src/cppparser/cppMakeProperty.h | 8 +- dtool/src/cppparser/cppMakeSeq.h | 8 +- dtool/src/cppparser/cppManifest.h | 24 ++-- dtool/src/cppparser/cppNameComponent.h | 16 +-- dtool/src/cppparser/cppNamespace.h | 8 +- dtool/src/cppparser/cppParameterList.h | 8 +- dtool/src/cppparser/cppParser.h | 4 +- dtool/src/cppparser/cppPointerType.h | 8 +- dtool/src/cppparser/cppPreprocessor.h | 80 ++++++------ dtool/src/cppparser/cppReferenceType.h | 8 +- dtool/src/cppparser/cppScope.h | 44 +++---- dtool/src/cppparser/cppSimpleType.h | 4 +- dtool/src/cppparser/cppStructType.h | 12 +- dtool/src/cppparser/cppTBDType.h | 8 +- .../src/cppparser/cppTemplateParameterList.h | 12 +- dtool/src/cppparser/cppTemplateScope.h | 8 +- dtool/src/cppparser/cppToken.h | 8 +- dtool/src/cppparser/cppType.h | 34 ++--- dtool/src/cppparser/cppTypeDeclaration.h | 2 +- dtool/src/cppparser/cppTypeParser.h | 10 +- dtool/src/cppparser/cppTypeProxy.h | 18 +-- dtool/src/cppparser/cppTypedefType.h | 12 +- dtool/src/cppparser/cppUsing.h | 2 +- dtool/src/cppparser/cppVisibility.h | 2 +- dtool/src/dconfig/dconfig.I | 12 +- dtool/src/dconfig/dconfig.h | 10 +- dtool/src/dtoolbase/epvector.h | 4 +- dtool/src/dtoolbase/fakestringstream.h | 16 +-- dtool/src/dtoolbase/indent.I | 12 +- dtool/src/dtoolbase/indent.h | 10 +- dtool/src/dtoolbase/pallocator.T | 4 +- dtool/src/dtoolbase/pallocator.h | 28 ++-- dtool/src/dtoolbase/pdeque.h | 11 +- dtool/src/dtoolbase/plist.h | 4 +- dtool/src/dtoolbase/pmap.h | 34 ++--- dtool/src/dtoolbase/pset.h | 18 +-- dtool/src/dtoolbase/pvector.h | 8 +- dtool/src/dtoolbase/register_type.I | 20 +-- dtool/src/dtoolbase/register_type.h | 24 ++-- dtool/src/dtoolbase/stl_compares.h | 20 ++- dtool/src/dtoolbase/typeHandle.I | 4 +- dtool/src/dtoolbase/typeHandle.h | 8 +- dtool/src/dtoolbase/typeRegistry.h | 18 +-- dtool/src/dtoolbase/typeRegistryNode.h | 4 +- dtool/src/dtoolutil/dSearchPath.I | 4 +- dtool/src/dtoolutil/dSearchPath.h | 20 +-- dtool/src/dtoolutil/executionEnvironment.I | 22 ++-- dtool/src/dtoolutil/executionEnvironment.h | 44 +++---- dtool/src/dtoolutil/filename.I | 78 +++++------ dtool/src/dtoolutil/filename.h | 108 ++++++++-------- dtool/src/dtoolutil/filename_assist.h | 8 +- dtool/src/dtoolutil/globPattern.I | 14 +- dtool/src/dtoolutil/globPattern.h | 36 +++--- dtool/src/dtoolutil/lineStream.I | 4 +- dtool/src/dtoolutil/lineStream.h | 4 +- dtool/src/dtoolutil/lineStreamBuf.I | 2 +- dtool/src/dtoolutil/lineStreamBuf.h | 6 +- dtool/src/dtoolutil/load_dso.h | 4 +- dtool/src/dtoolutil/pandaFileStream.I | 48 +++---- dtool/src/dtoolutil/pandaFileStream.h | 30 ++--- dtool/src/dtoolutil/pandaFileStreamBuf.h | 28 ++-- dtool/src/dtoolutil/pandaSystem.h | 50 +++---- dtool/src/dtoolutil/pfstream.I | 12 +- dtool/src/dtoolutil/pfstream.h | 4 +- dtool/src/dtoolutil/pfstreamBuf.h | 8 +- dtool/src/dtoolutil/stringDecoder.I | 6 +- dtool/src/dtoolutil/stringDecoder.h | 14 +- dtool/src/dtoolutil/string_utils.I | 32 ++--- dtool/src/dtoolutil/string_utils.h | 60 ++++----- dtool/src/dtoolutil/textEncoder.I | 62 ++++----- dtool/src/dtoolutil/textEncoder.h | 62 ++++----- dtool/src/dtoolutil/win32ArgParser.h | 8 +- dtool/src/interrogate/functionRemap.h | 30 ++--- dtool/src/interrogate/functionWriter.h | 8 +- .../interrogate/functionWriterPtrFromPython.h | 4 +- .../interrogate/functionWriterPtrToPython.h | 4 +- dtool/src/interrogate/functionWriters.h | 4 +- dtool/src/interrogate/interfaceMaker.h | 50 +++---- dtool/src/interrogate/interfaceMakerC.h | 16 +-- dtool/src/interrogate/interfaceMakerPython.h | 4 +- .../interrogate/interfaceMakerPythonNative.h | 80 ++++++------ .../src/interrogate/interfaceMakerPythonObj.h | 26 ++-- .../interrogate/interfaceMakerPythonSimple.h | 20 +-- dtool/src/interrogate/interrogate.h | 6 +- dtool/src/interrogate/interrogateBuilder.h | 64 ++++----- dtool/src/interrogate/parameterRemap.h | 10 +- .../parameterRemapBasicStringPtrToString.h | 8 +- .../parameterRemapBasicStringRefToString.h | 8 +- .../parameterRemapBasicStringToString.h | 16 +-- .../parameterRemapConcreteToPointer.h | 4 +- .../parameterRemapConstToNonConst.h | 4 +- .../src/interrogate/parameterRemapEnumToInt.h | 4 +- .../interrogate/parameterRemapHandleToInt.h | 4 +- .../interrogate/parameterRemapPTToPointer.h | 6 +- .../parameterRemapReferenceToConcrete.h | 4 +- .../parameterRemapReferenceToPointer.h | 4 +- dtool/src/interrogate/parameterRemapThis.h | 4 +- .../src/interrogate/parameterRemapToString.h | 8 +- dtool/src/interrogate/typeManager.h | 4 +- .../src/interrogatedb/interrogateComponent.I | 4 +- .../src/interrogatedb/interrogateComponent.h | 14 +- dtool/src/interrogatedb/interrogateDatabase.I | 12 +- dtool/src/interrogatedb/interrogateDatabase.h | 28 ++-- dtool/src/interrogatedb/interrogateElement.I | 12 +- dtool/src/interrogatedb/interrogateElement.h | 16 +-- dtool/src/interrogatedb/interrogateFunction.I | 14 +- dtool/src/interrogatedb/interrogateFunction.h | 24 ++-- .../interrogateFunctionWrapper.I | 24 ++-- .../interrogateFunctionWrapper.h | 28 ++-- dtool/src/interrogatedb/interrogateMakeSeq.I | 12 +- dtool/src/interrogatedb/interrogateMakeSeq.h | 16 +-- dtool/src/interrogatedb/interrogateManifest.I | 10 +- dtool/src/interrogatedb/interrogateManifest.h | 12 +- dtool/src/interrogatedb/interrogateType.I | 36 +++--- dtool/src/interrogatedb/interrogateType.h | 48 +++---- .../src/interrogatedb/interrogate_datafile.I | 4 +- .../src/interrogatedb/interrogate_datafile.h | 12 +- dtool/src/interrogatedb/py_panda.h | 8 +- dtool/src/parser-inc/stdcompare.h | 2 +- dtool/src/prc/androidLogStream.h | 10 +- dtool/src/prc/configDeclaration.I | 12 +- dtool/src/prc/configDeclaration.h | 24 ++-- dtool/src/prc/configFlags.h | 2 +- dtool/src/prc/configPage.I | 8 +- dtool/src/prc/configPage.h | 32 ++--- dtool/src/prc/configPageManager.I | 16 +-- dtool/src/prc/configPageManager.h | 14 +- dtool/src/prc/configVariable.I | 20 +-- dtool/src/prc/configVariable.h | 16 +-- dtool/src/prc/configVariableBase.I | 18 +-- dtool/src/prc/configVariableBase.h | 16 +-- dtool/src/prc/configVariableBool.I | 14 +- dtool/src/prc/configVariableBool.h | 10 +- dtool/src/prc/configVariableCore.I | 8 +- dtool/src/prc/configVariableCore.h | 22 ++-- dtool/src/prc/configVariableDouble.I | 14 +- dtool/src/prc/configVariableDouble.h | 10 +- dtool/src/prc/configVariableEnum.I | 20 +-- dtool/src/prc/configVariableEnum.h | 12 +- dtool/src/prc/configVariableFilename.I | 20 +-- dtool/src/prc/configVariableFilename.h | 18 +-- dtool/src/prc/configVariableInt.I | 14 +- dtool/src/prc/configVariableInt.h | 10 +- dtool/src/prc/configVariableInt64.I | 14 +- dtool/src/prc/configVariableInt64.h | 10 +- dtool/src/prc/configVariableList.I | 24 ++-- dtool/src/prc/configVariableList.h | 16 +-- dtool/src/prc/configVariableManager.I | 4 +- dtool/src/prc/configVariableManager.h | 20 +-- dtool/src/prc/configVariableSearchPath.I | 30 ++--- dtool/src/prc/configVariableSearchPath.h | 24 ++-- dtool/src/prc/configVariableString.I | 30 ++--- dtool/src/prc/configVariableString.h | 28 ++-- dtool/src/prc/encryptStream.I | 22 ++-- dtool/src/prc/encryptStream.h | 26 ++-- dtool/src/prc/encryptStreamBuf.I | 4 +- dtool/src/prc/encryptStreamBuf.h | 16 +-- dtool/src/prc/notifyCategory.I | 22 ++-- dtool/src/prc/notifyCategory.h | 28 ++-- dtool/src/prc/notifyCategoryProxy.I | 14 +- dtool/src/prc/notifyCategoryProxy.h | 18 +-- dtool/src/prc/notifySeverity.h | 4 +- dtool/src/prc/pnotify.I | 2 +- dtool/src/prc/pnotify.h | 32 ++--- dtool/src/prc/streamReader.I | 6 +- dtool/src/prc/streamReader.h | 20 +-- dtool/src/prc/streamWrapper.I | 18 +-- dtool/src/prc/streamWrapper.h | 50 +++---- dtool/src/prc/streamWriter.I | 18 +-- dtool/src/prc/streamWriter.h | 22 ++-- panda/src/android/config_android.h | 2 +- panda/src/android/pnmFileTypeAndroid.h | 14 +- .../src/androiddisplay/androidGraphicsPipe.h | 4 +- .../androiddisplay/androidGraphicsWindow.h | 2 +- .../androiddisplay/config_androiddisplay.h | 4 +- panda/src/audio/audioLoadRequest.I | 4 +- panda/src/audio/audioLoadRequest.h | 6 +- panda/src/audio/audioManager.h | 12 +- panda/src/audio/audioSound.h | 18 +-- panda/src/audio/config_audio.h | 12 +- panda/src/audio/nullAudioManager.h | 4 +- panda/src/audio/nullAudioSound.h | 6 +- panda/src/audiotraits/fmodAudioManager.h | 6 +- panda/src/audiotraits/fmodAudioSound.h | 8 +- panda/src/audiotraits/milesAudioManager.h | 14 +- panda/src/audiotraits/milesAudioSample.h | 4 +- panda/src/audiotraits/milesAudioSequence.h | 2 +- panda/src/audiotraits/milesAudioSound.h | 12 +- panda/src/audiotraits/milesAudioStream.h | 2 +- panda/src/audiotraits/openalAudioManager.h | 8 +- panda/src/audiotraits/openalAudioSound.h | 8 +- panda/src/awesomium/AwMouseAndKeyboard.h | 2 +- panda/src/awesomium/WebBrowserTexture.h | 2 +- panda/src/awesomium/awWebView.h | 2 +- panda/src/bullet/bulletBodyNode.h | 4 +- panda/src/bullet/bulletContactCallbacks.h | 4 +- panda/src/bullet/bulletRigidBodyNode.h | 2 +- panda/src/bullet/bulletTriangleMesh.I | 4 +- panda/src/bullet/bulletTriangleMesh.h | 6 +- panda/src/bullet/bulletWorld.h | 16 +-- panda/src/chan/animBundle.I | 2 +- panda/src/chan/animBundle.h | 6 +- panda/src/chan/animBundleNode.I | 2 +- panda/src/chan/animBundleNode.h | 2 +- panda/src/chan/animChannel.I | 4 +- panda/src/chan/animChannel.h | 8 +- panda/src/chan/animChannelBase.I | 4 +- panda/src/chan/animChannelBase.h | 4 +- panda/src/chan/animChannelFixed.I | 4 +- panda/src/chan/animChannelFixed.h | 4 +- panda/src/chan/animChannelMatrixDynamic.h | 2 +- panda/src/chan/animChannelMatrixFixed.h | 4 +- panda/src/chan/animChannelMatrixXfmTable.h | 4 +- panda/src/chan/animChannelScalarDynamic.h | 2 +- panda/src/chan/animChannelScalarTable.h | 4 +- panda/src/chan/animControl.I | 4 +- panda/src/chan/animControl.h | 12 +- panda/src/chan/animControlCollection.I | 22 ++-- panda/src/chan/animControlCollection.h | 38 +++--- panda/src/chan/animGroup.h | 18 +-- panda/src/chan/animPreloadTable.I | 4 +- panda/src/chan/animPreloadTable.h | 14 +- panda/src/chan/bindAnimRequest.h | 2 +- panda/src/chan/movingPart.I | 4 +- panda/src/chan/movingPart.h | 4 +- panda/src/chan/movingPartBase.h | 8 +- panda/src/chan/movingPartMatrix.I | 2 +- panda/src/chan/movingPartMatrix.h | 2 +- panda/src/chan/movingPartScalar.I | 2 +- panda/src/chan/movingPartScalar.h | 2 +- panda/src/chan/partBundle.h | 22 ++-- panda/src/chan/partBundleNode.I | 2 +- panda/src/chan/partBundleNode.h | 2 +- panda/src/chan/partGroup.I | 2 +- panda/src/chan/partGroup.h | 16 +-- panda/src/chan/partSubset.h | 8 +- panda/src/char/character.h | 10 +- panda/src/char/characterJoint.h | 2 +- panda/src/char/characterJointBundle.h | 2 +- panda/src/char/characterJointEffect.h | 2 +- panda/src/char/characterSlider.h | 2 +- panda/src/char/jointVertexTransform.h | 2 +- panda/src/cocoadisplay/cocoaGraphicsBuffer.h | 2 +- panda/src/cocoadisplay/cocoaGraphicsPipe.h | 4 +- panda/src/cocoadisplay/cocoaGraphicsWindow.h | 2 +- panda/src/collada/colladaBindMaterial.h | 4 +- panda/src/collada/colladaInput.h | 6 +- panda/src/collada/colladaPrimitive.I | 2 +- panda/src/collada/colladaPrimitive.h | 4 +- panda/src/collada/loaderFileTypeDae.h | 6 +- panda/src/collide/collisionBox.h | 2 +- panda/src/collide/collisionEntry.I | 4 +- panda/src/collide/collisionEntry.h | 6 +- panda/src/collide/collisionFloorMesh.h | 4 +- panda/src/collide/collisionGeom.h | 2 +- panda/src/collide/collisionHandlerEvent.I | 24 ++-- panda/src/collide/collisionHandlerEvent.h | 20 +-- panda/src/collide/collisionHandlerQueue.h | 6 +- panda/src/collide/collisionInvSphere.h | 2 +- panda/src/collide/collisionLine.h | 2 +- panda/src/collide/collisionNode.h | 4 +- panda/src/collide/collisionParabola.h | 2 +- panda/src/collide/collisionPlane.h | 2 +- panda/src/collide/collisionPolygon.h | 4 +- panda/src/collide/collisionRay.h | 2 +- panda/src/collide/collisionRecorder.h | 2 +- panda/src/collide/collisionSegment.h | 2 +- panda/src/collide/collisionSolid.h | 6 +- panda/src/collide/collisionSphere.h | 2 +- panda/src/collide/collisionTraverser.h | 8 +- panda/src/collide/collisionTube.h | 2 +- panda/src/collide/collisionVisualizer.h | 4 +- panda/src/cull/cullBinBackToFront.I | 2 +- panda/src/cull/cullBinBackToFront.h | 4 +- panda/src/cull/cullBinFixed.I | 2 +- panda/src/cull/cullBinFixed.h | 4 +- panda/src/cull/cullBinFrontToBack.I | 2 +- panda/src/cull/cullBinFrontToBack.h | 4 +- panda/src/cull/cullBinStateSorted.I | 2 +- panda/src/cull/cullBinStateSorted.h | 4 +- panda/src/cull/cullBinUnsorted.I | 2 +- panda/src/cull/cullBinUnsorted.h | 4 +- panda/src/device/analogNode.h | 4 +- panda/src/device/buttonNode.h | 6 +- panda/src/device/clientAnalogDevice.I | 2 +- panda/src/device/clientAnalogDevice.h | 6 +- panda/src/device/clientBase.h | 8 +- panda/src/device/clientButtonDevice.h | 10 +- panda/src/device/clientDevice.I | 2 +- panda/src/device/clientDevice.h | 12 +- panda/src/device/clientDialDevice.I | 2 +- panda/src/device/clientDialDevice.h | 2 +- panda/src/device/clientTrackerDevice.I | 2 +- panda/src/device/clientTrackerDevice.h | 2 +- panda/src/device/dialNode.h | 2 +- panda/src/device/mouseAndKeyboard.h | 2 +- panda/src/device/trackerNode.h | 2 +- panda/src/device/virtualMouse.h | 2 +- panda/src/dgraph/dataNode.I | 2 +- panda/src/dgraph/dataNode.h | 14 +- panda/src/display/callbackGraphicsWindow.h | 4 +- panda/src/display/displayInformation.h | 10 +- panda/src/display/displayRegion.I | 8 +- panda/src/display/displayRegion.h | 10 +- .../display/displayRegionCullCallbackData.h | 2 +- .../display/displayRegionDrawCallbackData.h | 2 +- panda/src/display/drawableRegion.I | 2 +- panda/src/display/frameBufferProperties.I | 6 +- panda/src/display/frameBufferProperties.h | 6 +- panda/src/display/graphicsBuffer.h | 2 +- panda/src/display/graphicsEngine.I | 6 +- panda/src/display/graphicsEngine.h | 18 +-- panda/src/display/graphicsOutput.I | 32 ++--- panda/src/display/graphicsOutput.h | 20 +-- panda/src/display/graphicsPipe.h | 4 +- panda/src/display/graphicsPipeSelection.h | 16 +-- panda/src/display/graphicsStateGuardian.I | 4 +- panda/src/display/graphicsStateGuardian.h | 12 +- panda/src/display/graphicsThreadingModel.I | 14 +- panda/src/display/graphicsThreadingModel.h | 20 +-- panda/src/display/graphicsWindow.h | 16 +-- panda/src/display/graphicsWindowInputDevice.I | 2 +- panda/src/display/graphicsWindowInputDevice.h | 14 +- .../display/graphicsWindowProcCallbackData.h | 2 +- panda/src/display/nativeWindowHandle.h | 8 +- panda/src/display/parasiteBuffer.h | 2 +- panda/src/display/stereoDisplayRegion.h | 2 +- panda/src/display/subprocessWindow.h | 2 +- panda/src/display/subprocessWindowBuffer.h | 8 +- panda/src/display/windowHandle.h | 8 +- panda/src/display/windowProperties.I | 10 +- panda/src/display/windowProperties.h | 26 ++-- panda/src/distort/nonlinearImager.h | 4 +- panda/src/distort/projectionScreen.I | 4 +- panda/src/distort/projectionScreen.h | 10 +- panda/src/downloader/bioPtr.I | 2 +- panda/src/downloader/bioPtr.h | 4 +- panda/src/downloader/bioStreamBuf.h | 2 +- panda/src/downloader/chunkedStreamBuf.h | 6 +- panda/src/downloader/decompressor.h | 6 +- panda/src/downloader/documentSpec.I | 12 +- panda/src/downloader/documentSpec.h | 12 +- panda/src/downloader/downloadDb.I | 32 ++--- panda/src/downloader/downloadDb.h | 92 ++++++------- panda/src/downloader/extractor.h | 2 +- panda/src/downloader/httpAuthorization.I | 2 +- panda/src/downloader/httpAuthorization.h | 24 ++-- panda/src/downloader/httpBasicAuthorization.h | 8 +- panda/src/downloader/httpChannel.I | 42 +++--- panda/src/downloader/httpChannel.h | 98 +++++++------- panda/src/downloader/httpClient.I | 18 +-- panda/src/downloader/httpClient.h | 76 +++++------ panda/src/downloader/httpCookie.I | 22 ++-- panda/src/downloader/httpCookie.h | 38 +++--- panda/src/downloader/httpDate.I | 10 +- panda/src/downloader/httpDate.h | 14 +- .../src/downloader/httpDigestAuthorization.h | 40 +++--- panda/src/downloader/httpEntityTag.I | 10 +- panda/src/downloader/httpEntityTag.h | 14 +- panda/src/downloader/httpEnum.h | 2 +- panda/src/downloader/identityStreamBuf.h | 2 +- panda/src/downloader/multiplexStream.I | 10 +- panda/src/downloader/multiplexStream.h | 4 +- panda/src/downloader/multiplexStreamBuf.h | 10 +- panda/src/downloader/socketStream.I | 6 +- panda/src/downloader/socketStream.h | 20 +-- panda/src/downloader/stringStream.I | 12 +- panda/src/downloader/stringStream.h | 8 +- panda/src/downloader/stringStreamBuf.h | 6 +- panda/src/downloader/urlSpec.I | 28 ++-- panda/src/downloader/urlSpec.h | 64 ++++----- panda/src/downloader/virtualFileHTTP.h | 10 +- panda/src/downloader/virtualFileMountHTTP.h | 8 +- panda/src/dxgsg9/dxGraphicsStateGuardian9.I | 4 +- panda/src/dxgsg9/dxGraphicsStateGuardian9.h | 4 +- panda/src/dxgsg9/dxInput9.h | 8 +- panda/src/dxgsg9/dxShaderContext9.h | 2 +- panda/src/dxgsg9/dxgsg9base.h | 10 +- panda/src/dxgsg9/wdxGraphicsBuffer9.h | 4 +- panda/src/dxgsg9/wdxGraphicsPipe9.h | 4 +- panda/src/dxgsg9/wdxGraphicsWindow9.h | 2 +- panda/src/dxml/config_dxml.h | 4 +- panda/src/egg/eggAnimData.I | 2 +- panda/src/egg/eggAnimData.h | 2 +- panda/src/egg/eggAnimPreload.I | 2 +- panda/src/egg/eggAnimPreload.h | 4 +- panda/src/egg/eggAttributes.h | 2 +- panda/src/egg/eggBin.h | 2 +- panda/src/egg/eggBinMaker.h | 2 +- panda/src/egg/eggComment.I | 10 +- panda/src/egg/eggComment.h | 14 +- panda/src/egg/eggCompositePrimitive.I | 2 +- panda/src/egg/eggCompositePrimitive.h | 4 +- panda/src/egg/eggCoordinateSystem.h | 2 +- panda/src/egg/eggCurve.I | 2 +- panda/src/egg/eggCurve.h | 6 +- panda/src/egg/eggData.h | 8 +- panda/src/egg/eggExternalReference.h | 6 +- panda/src/egg/eggFilenameNode.I | 2 +- panda/src/egg/eggFilenameNode.h | 4 +- panda/src/egg/eggGroup.I | 22 ++-- panda/src/egg/eggGroup.h | 78 +++++------ panda/src/egg/eggGroupNode.h | 8 +- panda/src/egg/eggGroupUniquifier.h | 8 +- panda/src/egg/eggLine.I | 2 +- panda/src/egg/eggLine.h | 4 +- panda/src/egg/eggMaterial.h | 4 +- panda/src/egg/eggMaterialCollection.h | 2 +- panda/src/egg/eggMesher.h | 2 +- panda/src/egg/eggMesherEdge.I | 2 +- panda/src/egg/eggMesherEdge.h | 6 +- panda/src/egg/eggMesherFanMaker.I | 4 +- panda/src/egg/eggMesherFanMaker.h | 4 +- panda/src/egg/eggMesherStrip.h | 8 +- panda/src/egg/eggMiscFuncs.h | 8 +- panda/src/egg/eggMorph.I | 4 +- panda/src/egg/eggMorph.h | 4 +- panda/src/egg/eggMorphList.I | 6 +- panda/src/egg/eggMorphList.h | 6 +- panda/src/egg/eggNameUniquifier.h | 18 +-- panda/src/egg/eggNamedObject.I | 4 +- panda/src/egg/eggNamedObject.h | 8 +- panda/src/egg/eggNode.I | 2 +- panda/src/egg/eggNode.h | 6 +- panda/src/egg/eggNurbsCurve.I | 2 +- panda/src/egg/eggNurbsCurve.h | 4 +- panda/src/egg/eggNurbsSurface.I | 2 +- panda/src/egg/eggNurbsSurface.h | 4 +- panda/src/egg/eggPatch.I | 2 +- panda/src/egg/eggPatch.h | 4 +- panda/src/egg/eggPoint.I | 2 +- panda/src/egg/eggPoint.h | 4 +- panda/src/egg/eggPolygon.I | 2 +- panda/src/egg/eggPolygon.h | 4 +- panda/src/egg/eggPoolUniquifier.h | 2 +- panda/src/egg/eggPrimitive.I | 8 +- panda/src/egg/eggPrimitive.h | 8 +- panda/src/egg/eggRenderMode.I | 6 +- panda/src/egg/eggRenderMode.h | 26 ++-- panda/src/egg/eggSAnimData.I | 2 +- panda/src/egg/eggSAnimData.h | 4 +- panda/src/egg/eggSurface.I | 2 +- panda/src/egg/eggSurface.h | 2 +- panda/src/egg/eggSwitchCondition.h | 4 +- panda/src/egg/eggTable.I | 2 +- panda/src/egg/eggTable.h | 8 +- panda/src/egg/eggTexture.I | 12 +- panda/src/egg/eggTexture.h | 64 ++++----- panda/src/egg/eggTextureCollection.h | 2 +- panda/src/egg/eggTransform.h | 4 +- panda/src/egg/eggTriangleFan.I | 2 +- panda/src/egg/eggTriangleFan.h | 4 +- panda/src/egg/eggTriangleStrip.I | 2 +- panda/src/egg/eggTriangleStrip.h | 4 +- panda/src/egg/eggVertex.h | 40 +++--- panda/src/egg/eggVertexAux.I | 2 +- panda/src/egg/eggVertexAux.h | 6 +- panda/src/egg/eggVertexPool.h | 4 +- panda/src/egg/eggVertexUV.I | 8 +- panda/src/egg/eggVertexUV.h | 10 +- panda/src/egg/eggXfmAnimData.I | 12 +- panda/src/egg/eggXfmAnimData.h | 18 +-- panda/src/egg/eggXfmSAnim.I | 8 +- panda/src/egg/eggXfmSAnim.h | 18 +-- panda/src/egg/lexerDefs.h | 10 +- panda/src/egg/parserDefs.h | 4 +- panda/src/egg2pg/animBundleMaker.h | 6 +- panda/src/egg2pg/characterMaker.h | 10 +- panda/src/egg2pg/eggBinner.h | 2 +- panda/src/egg2pg/eggLoader.h | 12 +- panda/src/egg2pg/eggSaver.h | 4 +- panda/src/egg2pg/loaderFileTypeEgg.h | 4 +- panda/src/egldisplay/config_egldisplay.h | 4 +- panda/src/egldisplay/eglGraphicsBuffer.h | 2 +- panda/src/egldisplay/eglGraphicsPipe.h | 6 +- panda/src/egldisplay/eglGraphicsPixmap.h | 2 +- panda/src/egldisplay/eglGraphicsWindow.h | 2 +- panda/src/event/asyncFuture.I | 6 +- panda/src/event/asyncFuture.h | 10 +- panda/src/event/asyncTask.I | 6 +- panda/src/event/asyncTask.h | 18 +-- panda/src/event/asyncTaskChain.h | 16 +-- panda/src/event/asyncTaskCollection.h | 8 +- panda/src/event/asyncTaskManager.h | 24 ++-- panda/src/event/asyncTaskSequence.h | 2 +- panda/src/event/buttonEvent.I | 2 +- panda/src/event/buttonEvent.h | 8 +- panda/src/event/buttonEventList.h | 6 +- panda/src/event/event.I | 6 +- panda/src/event/event.h | 12 +- panda/src/event/eventHandler.h | 32 ++--- panda/src/event/eventParameter.I | 14 +- panda/src/event/eventParameter.h | 12 +- panda/src/event/genericAsyncTask.h | 4 +- panda/src/event/pointerEvent.h | 4 +- panda/src/event/pointerEventList.h | 10 +- panda/src/event/pythonTask.h | 2 +- panda/src/event/throw_event.I | 18 +-- panda/src/event/throw_event.h | 18 +-- panda/src/express/checksumHashGenerator.h | 2 +- panda/src/express/compress_string.h | 12 +- panda/src/express/copy_stream.h | 2 +- panda/src/express/datagram.I | 20 +-- panda/src/express/datagram.h | 22 ++-- panda/src/express/datagramGenerator.h | 2 +- panda/src/express/datagramIterator.I | 4 +- panda/src/express/datagramIterator.h | 18 +-- panda/src/express/datagramSink.h | 2 +- panda/src/express/encrypt_string.h | 22 ++-- panda/src/express/error_utils.h | 4 +- panda/src/express/hashVal.I | 10 +- panda/src/express/hashVal.h | 28 ++-- panda/src/express/memoryUsage.h | 2 +- panda/src/express/memoryUsagePointerCounts.I | 4 +- panda/src/express/memoryUsagePointerCounts.h | 6 +- panda/src/express/memoryUsagePointers.h | 6 +- panda/src/express/multifile.I | 34 ++--- panda/src/express/multifile.h | 116 ++++++++--------- panda/src/express/namable.I | 10 +- panda/src/express/namable.h | 12 +- panda/src/express/nodePointerTo.I | 6 +- panda/src/express/nodePointerToBase.I | 2 +- panda/src/express/nodePointerToBase.h | 4 +- panda/src/express/nodeReferenceCount.I | 4 +- panda/src/express/openSSLWrapper.I | 4 +- panda/src/express/openSSLWrapper.h | 4 +- panda/src/express/ordered_vector.I | 22 ++-- panda/src/express/ordered_vector.T | 4 +- panda/src/express/ordered_vector.h | 22 ++-- panda/src/express/password_hash.h | 4 +- panda/src/express/patchfile.I | 2 +- panda/src/express/patchfile.h | 58 ++++----- panda/src/express/pointerTo.I | 12 +- panda/src/express/pointerToArray.I | 44 +++---- panda/src/express/pointerToArray.h | 14 +- panda/src/express/pointerToArrayBase.I | 4 +- panda/src/express/pointerToArray_ext.I | 12 +- panda/src/express/pointerToBase.I | 2 +- panda/src/express/pointerToBase.h | 4 +- panda/src/express/profileTimer.I | 2 +- panda/src/express/profileTimer.h | 8 +- panda/src/express/ramfile.I | 2 +- panda/src/express/ramfile.h | 8 +- panda/src/express/referenceCount.I | 4 +- panda/src/express/subStream.I | 18 +-- panda/src/express/subStream.h | 18 +-- panda/src/express/subStreamBuf.h | 16 +-- panda/src/express/subfileInfo.I | 12 +- panda/src/express/subfileInfo.h | 16 +-- panda/src/express/threadSafePointerToBase.I | 2 +- panda/src/express/threadSafePointerToBase.h | 4 +- panda/src/express/virtualFile.I | 10 +- panda/src/express/virtualFile.h | 46 +++---- panda/src/express/virtualFileComposite.h | 2 +- panda/src/express/virtualFileMount.I | 4 +- panda/src/express/virtualFileMount.h | 34 ++--- .../express/virtualFileMountAndroidAsset.I | 4 +- .../express/virtualFileMountAndroidAsset.h | 18 +-- panda/src/express/virtualFileMountMultifile.h | 8 +- panda/src/express/virtualFileMountRamdisk.I | 6 +- panda/src/express/virtualFileMountRamdisk.h | 38 +++--- panda/src/express/virtualFileMountSystem.h | 20 +-- panda/src/express/virtualFileSimple.h | 26 ++-- panda/src/express/virtualFileSystem.I | 10 +- panda/src/express/virtualFileSystem.h | 42 +++--- panda/src/express/weakPointerToBase.I | 2 +- panda/src/express/weakPointerToBase.h | 4 +- panda/src/express/windowsRegistry.h | 22 ++-- panda/src/express/zStream.I | 14 +- panda/src/express/zStream.h | 12 +- panda/src/express/zStreamBuf.h | 14 +- panda/src/ffmpeg/ffmpegVideoCursor.h | 2 +- panda/src/ffmpeg/ffmpegVirtualFile.h | 6 +- panda/src/framework/pandaFramework.I | 2 +- panda/src/framework/pandaFramework.h | 14 +- panda/src/framework/windowFramework.h | 2 +- panda/src/glstuff/glGraphicsBuffer_src.h | 4 +- .../src/glstuff/glGraphicsStateGuardian_src.I | 32 ++--- .../src/glstuff/glGraphicsStateGuardian_src.h | 28 ++-- panda/src/glstuff/glmisc_src.h | 4 +- panda/src/glxdisplay/glxGraphicsBuffer.h | 2 +- panda/src/glxdisplay/glxGraphicsPipe.h | 6 +- panda/src/glxdisplay/glxGraphicsPixmap.h | 2 +- .../src/glxdisplay/glxGraphicsStateGuardian.h | 4 +- panda/src/glxdisplay/glxGraphicsWindow.h | 2 +- panda/src/gobj/adaptiveLru.h | 14 +- panda/src/gobj/bufferContextChain.h | 2 +- panda/src/gobj/bufferResidencyTracker.h | 4 +- panda/src/gobj/geom.I | 10 +- panda/src/gobj/geom.h | 8 +- panda/src/gobj/geomCacheEntry.I | 4 +- panda/src/gobj/geomCacheEntry.h | 4 +- panda/src/gobj/geomEnums.h | 8 +- panda/src/gobj/geomMunger.h | 2 +- panda/src/gobj/geomPrimitive.I | 6 +- panda/src/gobj/geomPrimitive.h | 6 +- panda/src/gobj/geomVertexAnimationSpec.I | 4 +- panda/src/gobj/geomVertexAnimationSpec.h | 6 +- panda/src/gobj/geomVertexArrayData.I | 22 ++-- panda/src/gobj/geomVertexArrayData.h | 14 +- panda/src/gobj/geomVertexArrayFormat.I | 4 +- panda/src/gobj/geomVertexArrayFormat.h | 10 +- panda/src/gobj/geomVertexColumn.I | 4 +- panda/src/gobj/geomVertexColumn.h | 4 +- panda/src/gobj/geomVertexData.I | 8 +- panda/src/gobj/geomVertexData.h | 18 +-- panda/src/gobj/geomVertexFormat.I | 4 +- panda/src/gobj/geomVertexFormat.h | 8 +- panda/src/gobj/geomVertexReader.h | 6 +- panda/src/gobj/geomVertexRewriter.h | 6 +- panda/src/gobj/geomVertexWriter.I | 4 +- panda/src/gobj/geomVertexWriter.h | 6 +- panda/src/gobj/indexBufferContext.h | 6 +- panda/src/gobj/internalName.I | 18 +-- panda/src/gobj/internalName.h | 36 +++--- panda/src/gobj/lens.I | 8 +- panda/src/gobj/lens.h | 12 +- panda/src/gobj/material.I | 2 +- panda/src/gobj/material.h | 8 +- panda/src/gobj/materialPool.I | 2 +- panda/src/gobj/materialPool.h | 6 +- panda/src/gobj/matrixLens.h | 2 +- panda/src/gobj/orthographicLens.h | 2 +- panda/src/gobj/paramTexture.I | 2 +- panda/src/gobj/paramTexture.h | 4 +- panda/src/gobj/preparedGraphicsObjects.I | 2 +- panda/src/gobj/preparedGraphicsObjects.h | 10 +- panda/src/gobj/samplerContext.h | 6 +- panda/src/gobj/samplerState.h | 26 ++-- panda/src/gobj/savedContext.h | 6 +- panda/src/gobj/shader.I | 20 +-- panda/src/gobj/shader.h | 56 ++++---- panda/src/gobj/shaderBuffer.I | 4 +- panda/src/gobj/shaderBuffer.h | 8 +- panda/src/gobj/simpleAllocator.h | 10 +- panda/src/gobj/simpleLru.h | 14 +- panda/src/gobj/sliderTable.h | 4 +- panda/src/gobj/texture.I | 8 +- panda/src/gobj/texture.h | 110 ++++++++-------- panda/src/gobj/textureCollection.h | 8 +- panda/src/gobj/textureContext.I | 4 +- panda/src/gobj/textureContext.h | 6 +- panda/src/gobj/texturePool.I | 12 +- panda/src/gobj/texturePool.h | 26 ++-- panda/src/gobj/texturePoolFilter.h | 4 +- panda/src/gobj/textureReloadRequest.I | 2 +- panda/src/gobj/textureReloadRequest.h | 2 +- panda/src/gobj/textureStage.I | 10 +- panda/src/gobj/textureStage.h | 24 ++-- panda/src/gobj/textureStagePool.I | 2 +- panda/src/gobj/textureStagePool.h | 12 +- panda/src/gobj/texture_ext.h | 2 +- panda/src/gobj/transformBlend.I | 4 +- panda/src/gobj/transformBlend.h | 6 +- panda/src/gobj/transformBlendTable.h | 4 +- panda/src/gobj/transformTable.h | 4 +- panda/src/gobj/userVertexSlider.h | 2 +- panda/src/gobj/userVertexTransform.I | 2 +- panda/src/gobj/userVertexTransform.h | 8 +- panda/src/gobj/vertexBufferContext.h | 6 +- panda/src/gobj/vertexDataPage.h | 8 +- panda/src/gobj/vertexDataSaveFile.h | 2 +- panda/src/gobj/vertexSlider.I | 4 +- panda/src/gobj/vertexSlider.h | 6 +- panda/src/gobj/vertexTransform.I | 4 +- panda/src/gobj/vertexTransform.h | 6 +- panda/src/gobj/videoTexture.h | 4 +- panda/src/grutil/cardMaker.I | 2 +- panda/src/grutil/cardMaker.h | 2 +- panda/src/grutil/fisheyeMaker.I | 2 +- panda/src/grutil/fisheyeMaker.h | 2 +- panda/src/grutil/frameRateMeter.I | 4 +- panda/src/grutil/frameRateMeter.h | 8 +- panda/src/grutil/geoMipTerrain.I | 8 +- panda/src/grutil/geoMipTerrain.h | 4 +- panda/src/grutil/heightfieldTesselator.I | 2 +- panda/src/grutil/heightfieldTesselator.h | 2 +- panda/src/grutil/lineSegs.h | 2 +- panda/src/grutil/movieTexture.h | 6 +- panda/src/grutil/nodeVertexTransform.h | 2 +- panda/src/grutil/rigidBodyCombiner.h | 2 +- panda/src/grutil/sceneGraphAnalyzerMeter.h | 2 +- panda/src/iphonedisplay/iPhoneGraphicsPipe.h | 4 +- .../src/iphonedisplay/iPhoneGraphicsWindow.h | 2 +- panda/src/linmath/configVariableColor.I | 14 +- panda/src/linmath/configVariableColor.h | 10 +- panda/src/linmath/coordinateSystem.h | 8 +- panda/src/linmath/lmatrix3_ext_src.I | 4 +- panda/src/linmath/lmatrix3_ext_src.h | 2 +- panda/src/linmath/lmatrix3_src.h | 8 +- panda/src/linmath/lmatrix4_ext_src.I | 4 +- panda/src/linmath/lmatrix4_ext_src.h | 2 +- panda/src/linmath/lmatrix4_src.h | 8 +- panda/src/linmath/lpoint2_ext_src.I | 10 +- panda/src/linmath/lpoint2_ext_src.h | 6 +- panda/src/linmath/lpoint2_src.h | 6 +- panda/src/linmath/lpoint3_ext_src.I | 10 +- panda/src/linmath/lpoint3_ext_src.h | 6 +- panda/src/linmath/lpoint3_src.h | 6 +- panda/src/linmath/lpoint4_ext_src.I | 10 +- panda/src/linmath/lpoint4_ext_src.h | 6 +- panda/src/linmath/lpoint4_src.h | 6 +- panda/src/linmath/lquaternion_src.I | 2 +- panda/src/linmath/lquaternion_src.h | 4 +- panda/src/linmath/lvecBase2_ext_src.I | 14 +- panda/src/linmath/lvecBase2_ext_src.h | 6 +- panda/src/linmath/lvecBase2_src.I | 2 +- panda/src/linmath/lvecBase2_src.h | 10 +- panda/src/linmath/lvecBase3_ext_src.I | 14 +- panda/src/linmath/lvecBase3_ext_src.h | 6 +- panda/src/linmath/lvecBase3_src.I | 2 +- panda/src/linmath/lvecBase3_src.h | 10 +- panda/src/linmath/lvecBase4_ext_src.I | 14 +- panda/src/linmath/lvecBase4_ext_src.h | 6 +- panda/src/linmath/lvecBase4_src.I | 2 +- panda/src/linmath/lvecBase4_src.h | 10 +- panda/src/linmath/lvector2_ext_src.I | 10 +- panda/src/linmath/lvector2_ext_src.h | 6 +- panda/src/linmath/lvector2_src.h | 6 +- panda/src/linmath/lvector3_ext_src.I | 10 +- panda/src/linmath/lvector3_ext_src.h | 6 +- panda/src/linmath/lvector3_src.I | 4 +- panda/src/linmath/lvector3_src.h | 6 +- panda/src/linmath/lvector4_ext_src.I | 10 +- panda/src/linmath/lvector4_ext_src.h | 6 +- panda/src/linmath/lvector4_src.h | 6 +- panda/src/mathutil/boundingBox.h | 2 +- panda/src/mathutil/boundingHexahedron.h | 4 +- panda/src/mathutil/boundingLine.h | 2 +- panda/src/mathutil/boundingPlane.h | 2 +- panda/src/mathutil/boundingSphere.h | 2 +- panda/src/mathutil/boundingVolume.I | 2 +- panda/src/mathutil/boundingVolume.h | 12 +- .../src/mathutil/intersectionBoundingVolume.h | 4 +- panda/src/mathutil/omniBoundingVolume.h | 2 +- panda/src/mathutil/parabola_src.h | 8 +- panda/src/mathutil/plane_src.I | 4 +- panda/src/mathutil/plane_src.h | 8 +- panda/src/mathutil/unionBoundingVolume.h | 4 +- panda/src/movies/flacAudioCursor.h | 2 +- panda/src/movies/movieAudio.h | 4 +- panda/src/movies/movieAudioCursor.h | 2 +- panda/src/movies/movieTypeRegistry.h | 14 +- panda/src/movies/movieVideo.h | 2 +- panda/src/movies/opusAudioCursor.h | 6 +- panda/src/movies/userDataAudio.h | 2 +- panda/src/movies/vorbisAudioCursor.h | 6 +- panda/src/movies/wavAudioCursor.h | 8 +- panda/src/nativenet/socket_udp.h | 8 +- panda/src/nativenet/socket_udp_outgoing.h | 8 +- panda/src/net/config_net.h | 2 +- panda/src/net/connection.h | 2 +- panda/src/net/connectionListener.h | 2 +- panda/src/net/connectionManager.h | 26 ++-- panda/src/net/connectionReader.h | 4 +- panda/src/net/connectionWriter.h | 4 +- panda/src/net/datagramTCPHeader.I | 2 +- panda/src/net/datagramTCPHeader.h | 2 +- panda/src/net/datagramUDPHeader.I | 2 +- panda/src/net/datagramUDPHeader.h | 2 +- panda/src/net/datagram_ui.h | 4 +- panda/src/net/netAddress.h | 8 +- panda/src/ode/odeBody.h | 2 +- panda/src/ode/odeGeom.h | 2 +- panda/src/ode/odeJoint.h | 2 +- panda/src/ode/odeMass.h | 2 +- panda/src/ode/odeSpace.I | 4 +- panda/src/ode/odeSpace.h | 8 +- panda/src/ode/odeTriMeshData.h | 6 +- panda/src/osxdisplay/osxGraphicsBuffer.h | 2 +- panda/src/osxdisplay/osxGraphicsPipe.h | 4 +- panda/src/osxdisplay/osxGraphicsWindow.h | 4 +- panda/src/parametrics/curveFitter.I | 2 +- panda/src/parametrics/curveFitter.h | 10 +- panda/src/parametrics/hermiteCurve.h | 16 +-- panda/src/parametrics/nurbsBasisVector.I | 2 +- panda/src/parametrics/nurbsCurve.h | 6 +- panda/src/parametrics/nurbsCurveEvaluator.I | 6 +- panda/src/parametrics/nurbsCurveEvaluator.h | 6 +- panda/src/parametrics/nurbsCurveInterface.h | 8 +- panda/src/parametrics/nurbsSurfaceEvaluator.I | 6 +- panda/src/parametrics/nurbsSurfaceEvaluator.h | 6 +- panda/src/parametrics/nurbsVertex.I | 4 +- panda/src/parametrics/nurbsVertex.h | 4 +- panda/src/parametrics/parametricCurve.h | 6 +- .../parametrics/parametricCurveCollection.I | 2 +- .../parametrics/parametricCurveCollection.h | 10 +- panda/src/parametrics/ropeNode.h | 6 +- panda/src/parametrics/sheetNode.h | 6 +- panda/src/particlesystem/arcEmitter.h | 4 +- panda/src/particlesystem/baseParticle.h | 4 +- .../src/particlesystem/baseParticleEmitter.h | 4 +- .../src/particlesystem/baseParticleFactory.h | 4 +- .../src/particlesystem/baseParticleRenderer.I | 2 +- .../src/particlesystem/baseParticleRenderer.h | 4 +- panda/src/particlesystem/boxEmitter.h | 4 +- .../colorInterpolationManager.I | 6 +- .../colorInterpolationManager.h | 2 +- panda/src/particlesystem/discEmitter.h | 4 +- .../src/particlesystem/geomParticleRenderer.h | 6 +- panda/src/particlesystem/lineEmitter.h | 4 +- .../src/particlesystem/lineParticleRenderer.h | 4 +- panda/src/particlesystem/orientedParticle.h | 4 +- .../particlesystem/orientedParticleFactory.h | 4 +- panda/src/particlesystem/particleSystem.h | 8 +- .../particlesystem/particleSystemManager.h | 6 +- panda/src/particlesystem/pointEmitter.h | 4 +- panda/src/particlesystem/pointParticle.h | 4 +- .../src/particlesystem/pointParticleFactory.h | 4 +- .../particlesystem/pointParticleRenderer.h | 4 +- panda/src/particlesystem/rectangleEmitter.h | 4 +- panda/src/particlesystem/ringEmitter.h | 4 +- .../particlesystem/sparkleParticleRenderer.h | 4 +- .../src/particlesystem/sphereSurfaceEmitter.h | 4 +- .../src/particlesystem/sphereVolumeEmitter.h | 4 +- .../particlesystem/spriteParticleRenderer.h | 20 +-- panda/src/particlesystem/tangentRingEmitter.h | 4 +- panda/src/particlesystem/zSpinParticle.h | 4 +- .../src/particlesystem/zSpinParticleFactory.h | 4 +- panda/src/pgraph/accumulatedAttribs.h | 2 +- panda/src/pgraph/alphaTestAttrib.h | 2 +- panda/src/pgraph/antialiasAttrib.h | 2 +- panda/src/pgraph/attribNodeRegistry.I | 2 +- panda/src/pgraph/attribNodeRegistry.h | 12 +- panda/src/pgraph/audioVolumeAttrib.h | 2 +- panda/src/pgraph/auxBitplaneAttrib.h | 2 +- panda/src/pgraph/auxSceneData.I | 4 +- panda/src/pgraph/auxSceneData.h | 6 +- panda/src/pgraph/bamFile.h | 10 +- panda/src/pgraph/billboardEffect.h | 2 +- panda/src/pgraph/cacheStats.h | 2 +- panda/src/pgraph/camera.I | 4 +- panda/src/pgraph/camera.h | 20 +-- panda/src/pgraph/clipPlaneAttrib.h | 2 +- panda/src/pgraph/colorAttrib.h | 2 +- panda/src/pgraph/colorBlendAttrib.h | 6 +- panda/src/pgraph/colorScaleAttrib.h | 2 +- panda/src/pgraph/colorWriteAttrib.h | 2 +- panda/src/pgraph/compassEffect.h | 2 +- panda/src/pgraph/cullBin.I | 4 +- panda/src/pgraph/cullBin.h | 6 +- panda/src/pgraph/cullBinAttrib.I | 2 +- panda/src/pgraph/cullBinAttrib.h | 8 +- panda/src/pgraph/cullBinManager.I | 18 +-- panda/src/pgraph/cullBinManager.h | 32 ++--- panda/src/pgraph/cullFaceAttrib.h | 2 +- panda/src/pgraph/cullPlanes.h | 2 +- panda/src/pgraph/cullTraverser.I | 2 +- panda/src/pgraph/cullTraverser.h | 4 +- panda/src/pgraph/cullableObject.I | 6 +- panda/src/pgraph/cullableObject.h | 4 +- panda/src/pgraph/depthOffsetAttrib.h | 2 +- panda/src/pgraph/depthTestAttrib.h | 2 +- panda/src/pgraph/depthWriteAttrib.h | 2 +- panda/src/pgraph/findApproxLevelEntry.h | 8 +- panda/src/pgraph/findApproxPath.I | 2 +- panda/src/pgraph/findApproxPath.h | 38 +++--- panda/src/pgraph/fog.h | 8 +- panda/src/pgraph/fogAttrib.h | 2 +- panda/src/pgraph/geomDrawCallbackData.h | 2 +- panda/src/pgraph/geomNode.I | 2 +- panda/src/pgraph/geomNode.h | 8 +- panda/src/pgraph/geomTransformer.h | 4 +- panda/src/pgraph/internalNameCollection.h | 6 +- panda/src/pgraph/lensNode.h | 6 +- panda/src/pgraph/light.h | 6 +- panda/src/pgraph/lightAttrib.h | 4 +- panda/src/pgraph/lightRampAttrib.h | 2 +- panda/src/pgraph/loader.I | 4 +- panda/src/pgraph/loader.h | 12 +- panda/src/pgraph/loaderFileType.h | 6 +- panda/src/pgraph/loaderFileTypeBam.h | 4 +- panda/src/pgraph/loaderFileTypeRegistry.h | 12 +- panda/src/pgraph/logicOpAttrib.h | 4 +- panda/src/pgraph/materialAttrib.h | 2 +- panda/src/pgraph/materialCollection.h | 8 +- panda/src/pgraph/modelLoadRequest.h | 2 +- panda/src/pgraph/modelNode.I | 2 +- panda/src/pgraph/modelNode.h | 2 +- panda/src/pgraph/modelPool.I | 4 +- panda/src/pgraph/modelPool.h | 6 +- panda/src/pgraph/modelRoot.I | 2 +- panda/src/pgraph/modelRoot.h | 2 +- panda/src/pgraph/modelSaveRequest.h | 2 +- panda/src/pgraph/nodePath.I | 90 ++++++------- panda/src/pgraph/nodePath.h | 64 ++++----- panda/src/pgraph/nodePathCollection.h | 10 +- panda/src/pgraph/nodePathComponent.I | 2 +- panda/src/pgraph/nodePathComponent.h | 4 +- panda/src/pgraph/occluderEffect.h | 2 +- panda/src/pgraph/occluderNode.h | 4 +- panda/src/pgraph/pandaNode.I | 24 ++-- panda/src/pgraph/pandaNode.h | 38 +++--- panda/src/pgraph/paramNodePath.h | 2 +- panda/src/pgraph/planeNode.h | 4 +- panda/src/pgraph/polylightEffect.h | 4 +- panda/src/pgraph/polylightNode.h | 4 +- panda/src/pgraph/portalClipper.I | 2 +- panda/src/pgraph/portalNode.h | 6 +- panda/src/pgraph/renderAttrib.h | 10 +- panda/src/pgraph/renderEffect.h | 8 +- panda/src/pgraph/renderEffects.h | 8 +- panda/src/pgraph/renderModeAttrib.h | 2 +- panda/src/pgraph/renderState.h | 10 +- panda/src/pgraph/rescaleNormalAttrib.h | 6 +- panda/src/pgraph/scissorAttrib.h | 2 +- panda/src/pgraph/scissorEffect.h | 2 +- panda/src/pgraph/shadeModelAttrib.h | 2 +- panda/src/pgraph/shaderAttrib.I | 30 ++--- panda/src/pgraph/shaderAttrib.h | 6 +- panda/src/pgraph/shaderPool.I | 2 +- panda/src/pgraph/shaderPool.h | 6 +- panda/src/pgraph/stencilAttrib.h | 2 +- panda/src/pgraph/texGenAttrib.h | 4 +- panda/src/pgraph/texMatrixAttrib.h | 2 +- panda/src/pgraph/texProjectorEffect.h | 2 +- panda/src/pgraph/textureAttrib.h | 2 +- panda/src/pgraph/textureStageCollection.h | 8 +- panda/src/pgraph/transformState.h | 12 +- panda/src/pgraph/transparencyAttrib.h | 2 +- panda/src/pgraph/weakNodePath.I | 2 +- panda/src/pgraph/weakNodePath.h | 4 +- panda/src/pgraph/workingNodePath.I | 4 +- panda/src/pgraph/workingNodePath.h | 4 +- panda/src/pgraphnodes/ambientLight.h | 6 +- panda/src/pgraphnodes/callbackNode.h | 4 +- panda/src/pgraphnodes/computeNode.h | 4 +- panda/src/pgraphnodes/directionalLight.h | 6 +- panda/src/pgraphnodes/fadeLodNode.I | 2 +- panda/src/pgraphnodes/fadeLodNode.h | 10 +- panda/src/pgraphnodes/fadeLodNodeData.h | 2 +- panda/src/pgraphnodes/lightLensNode.h | 8 +- panda/src/pgraphnodes/lightNode.h | 8 +- panda/src/pgraphnodes/lodNode.I | 2 +- panda/src/pgraphnodes/lodNode.h | 6 +- panda/src/pgraphnodes/lodNodeType.h | 4 +- panda/src/pgraphnodes/nodeCullCallbackData.h | 2 +- panda/src/pgraphnodes/pointLight.h | 6 +- panda/src/pgraphnodes/rectangleLight.h | 4 +- panda/src/pgraphnodes/sceneGraphAnalyzer.h | 2 +- panda/src/pgraphnodes/selectiveChildNode.I | 2 +- panda/src/pgraphnodes/selectiveChildNode.h | 2 +- panda/src/pgraphnodes/sequenceNode.I | 2 +- panda/src/pgraphnodes/sequenceNode.h | 4 +- panda/src/pgraphnodes/shaderGenerator.h | 4 +- panda/src/pgraphnodes/sphereLight.h | 4 +- panda/src/pgraphnodes/spotlight.h | 6 +- panda/src/pgraphnodes/switchNode.I | 2 +- panda/src/pgraphnodes/switchNode.h | 2 +- panda/src/pgraphnodes/uvScrollNode.I | 4 +- panda/src/pgraphnodes/uvScrollNode.h | 4 +- panda/src/pgui/pgButton.I | 4 +- panda/src/pgui/pgButton.h | 8 +- panda/src/pgui/pgEntry.I | 52 ++++---- panda/src/pgui/pgEntry.h | 52 ++++---- panda/src/pgui/pgFrameStyle.I | 4 +- panda/src/pgui/pgFrameStyle.h | 6 +- panda/src/pgui/pgItem.I | 46 +++---- panda/src/pgui/pgItem.h | 60 ++++----- panda/src/pgui/pgMouseWatcherParameter.h | 2 +- panda/src/pgui/pgScrollFrame.h | 2 +- panda/src/pgui/pgSliderBar.I | 6 +- panda/src/pgui/pgSliderBar.h | 6 +- panda/src/pgui/pgTop.h | 2 +- panda/src/pgui/pgVirtualFrame.h | 2 +- panda/src/pgui/pgWaitBar.h | 2 +- panda/src/physics/actorNode.h | 4 +- panda/src/physics/angularEulerIntegrator.h | 4 +- panda/src/physics/angularForce.h | 4 +- panda/src/physics/angularIntegrator.h | 4 +- panda/src/physics/angularVectorForce.h | 4 +- panda/src/physics/baseForce.h | 4 +- panda/src/physics/baseIntegrator.h | 8 +- panda/src/physics/config_physics.h | 12 +- panda/src/physics/forceNode.h | 8 +- panda/src/physics/linearControlForce.h | 4 +- panda/src/physics/linearCylinderVortexForce.h | 4 +- panda/src/physics/linearDistanceForce.h | 4 +- panda/src/physics/linearEulerIntegrator.h | 4 +- panda/src/physics/linearForce.h | 4 +- panda/src/physics/linearFrictionForce.h | 4 +- panda/src/physics/linearIntegrator.h | 4 +- panda/src/physics/linearJitterForce.h | 4 +- panda/src/physics/linearNoiseForce.h | 4 +- panda/src/physics/linearRandomForce.h | 4 +- panda/src/physics/linearSinkForce.h | 4 +- panda/src/physics/linearSourceForce.h | 4 +- panda/src/physics/linearUserDefinedForce.h | 4 +- panda/src/physics/linearVectorForce.h | 4 +- panda/src/physics/physical.h | 10 +- panda/src/physics/physicalNode.h | 4 +- panda/src/physics/physicsManager.I | 4 +- panda/src/physics/physicsManager.h | 12 +- panda/src/physics/physicsObject.h | 10 +- panda/src/physics/physicsObjectCollection.h | 4 +- panda/src/physx/physxActor.I | 2 +- panda/src/physx/physxActor.h | 4 +- panda/src/physx/physxActorDesc.h | 2 +- panda/src/physx/physxCcdSkeleton.I | 2 +- panda/src/physx/physxCcdSkeleton.h | 2 +- panda/src/physx/physxCloth.I | 2 +- panda/src/physx/physxCloth.h | 4 +- panda/src/physx/physxClothDesc.h | 2 +- panda/src/physx/physxClothMesh.I | 2 +- panda/src/physx/physxClothMesh.h | 2 +- panda/src/physx/physxController.I | 4 +- panda/src/physx/physxController.h | 2 +- panda/src/physx/physxConvexMesh.I | 2 +- panda/src/physx/physxConvexMesh.h | 2 +- panda/src/physx/physxEnums.h | 4 +- panda/src/physx/physxFileStream.h | 2 +- panda/src/physx/physxForceField.I | 2 +- panda/src/physx/physxForceField.h | 4 +- panda/src/physx/physxForceFieldDesc.h | 2 +- panda/src/physx/physxForceFieldShape.I | 2 +- panda/src/physx/physxForceFieldShape.h | 4 +- panda/src/physx/physxForceFieldShapeDesc.h | 2 +- panda/src/physx/physxForceFieldShapeGroup.I | 2 +- panda/src/physx/physxForceFieldShapeGroup.h | 4 +- .../src/physx/physxForceFieldShapeGroupDesc.h | 2 +- panda/src/physx/physxGroupsMask.h | 4 +- panda/src/physx/physxHeightField.I | 2 +- panda/src/physx/physxHeightField.h | 2 +- panda/src/physx/physxJoint.I | 2 +- panda/src/physx/physxJoint.h | 4 +- panda/src/physx/physxJointDesc.h | 2 +- .../physx/physxLinearInterpolationValues.h | 4 +- panda/src/physx/physxManager.I | 2 +- panda/src/physx/physxManager.h | 2 +- panda/src/physx/physxMask.h | 4 +- panda/src/physx/physxMaterial.I | 2 +- panda/src/physx/physxMaterial.h | 2 +- panda/src/physx/physxMeshPool.h | 2 +- panda/src/physx/physxObject.I | 10 +- panda/src/physx/physxObject.h | 12 +- panda/src/physx/physxObjectCollection.I | 4 +- panda/src/physx/physxObjectCollection.h | 2 +- panda/src/physx/physxScene.I | 2 +- panda/src/physx/physxScene.h | 2 +- panda/src/physx/physxShape.I | 2 +- panda/src/physx/physxShape.h | 4 +- panda/src/physx/physxShapeDesc.h | 2 +- panda/src/physx/physxSoftBody.I | 2 +- panda/src/physx/physxSoftBody.h | 4 +- panda/src/physx/physxSoftBodyDesc.h | 2 +- panda/src/physx/physxSoftBodyMesh.I | 2 +- panda/src/physx/physxSoftBodyMesh.h | 2 +- panda/src/physx/physxTriangleMesh.I | 2 +- panda/src/physx/physxTriangleMesh.h | 2 +- panda/src/physx/physxVehicle.I | 2 +- panda/src/physx/physxVehicle.h | 2 +- panda/src/physx/physxWheel.I | 2 +- panda/src/physx/physxWheel.h | 2 +- panda/src/pipeline/conditionVarDebug.h | 6 +- panda/src/pipeline/conditionVarDirect.h | 6 +- panda/src/pipeline/conditionVarFullDebug.h | 6 +- panda/src/pipeline/conditionVarFullDirect.h | 6 +- panda/src/pipeline/cycleData.h | 6 +- panda/src/pipeline/externalThread.h | 2 +- panda/src/pipeline/genericThread.h | 4 +- panda/src/pipeline/lightMutex.I | 8 +- panda/src/pipeline/lightMutex.h | 2 +- panda/src/pipeline/lightMutexDirect.I | 6 +- panda/src/pipeline/lightMutexDirect.h | 10 +- panda/src/pipeline/lightReMutex.I | 8 +- panda/src/pipeline/lightReMutex.h | 2 +- panda/src/pipeline/lightReMutexDirect.I | 6 +- panda/src/pipeline/lightReMutexDirect.h | 10 +- panda/src/pipeline/mutexDebug.h | 10 +- panda/src/pipeline/mutexDirect.I | 6 +- panda/src/pipeline/mutexDirect.h | 10 +- panda/src/pipeline/pipeline.I | 2 +- panda/src/pipeline/pipeline.h | 2 +- panda/src/pipeline/pipelineCycler.I | 4 +- panda/src/pipeline/pipelineCyclerTrueImpl.h | 2 +- panda/src/pipeline/pmutex.I | 8 +- panda/src/pipeline/pmutex.h | 2 +- panda/src/pipeline/psemaphore.h | 6 +- panda/src/pipeline/pythonThread.h | 2 +- panda/src/pipeline/reMutex.I | 8 +- panda/src/pipeline/reMutex.h | 2 +- panda/src/pipeline/reMutexDirect.I | 6 +- panda/src/pipeline/reMutexDirect.h | 10 +- panda/src/pipeline/thread.I | 10 +- panda/src/pipeline/thread.h | 18 +-- panda/src/pipeline/threadDummyImpl.h | 2 +- panda/src/pipeline/threadPosixImpl.h | 2 +- panda/src/pipeline/threadPriority.h | 8 +- panda/src/pipeline/threadSimpleImpl.I | 2 +- panda/src/pipeline/threadSimpleImpl.h | 4 +- panda/src/pipeline/threadSimpleManager.h | 2 +- panda/src/pipeline/threadWin32Impl.h | 2 +- panda/src/pnmimage/convert_srgb.I | 8 +- panda/src/pnmimage/pfmFile.I | 8 +- panda/src/pnmimage/pfmFile.h | 6 +- panda/src/pnmimage/pnmFileType.h | 14 +- panda/src/pnmimage/pnmFileTypeRegistry.h | 8 +- panda/src/pnmimage/pnmImage.I | 34 ++--- panda/src/pnmimage/pnmImage.h | 4 +- panda/src/pnmimage/pnmImageHeader.I | 4 +- panda/src/pnmimage/pnmImageHeader.h | 26 ++-- panda/src/pnmimage/pnmReader.I | 2 +- panda/src/pnmimage/pnmReader.h | 4 +- panda/src/pnmimage/pnmWriter.I | 2 +- panda/src/pnmimage/pnmWriter.h | 4 +- panda/src/pnmimage/pnmbitio.h | 4 +- panda/src/pnmimage/pnmimage_base.h | 18 +-- .../src/pnmimagetypes/config_pnmimagetypes.h | 8 +- panda/src/pnmimagetypes/pnmFileTypeBMP.h | 18 +-- panda/src/pnmimagetypes/pnmFileTypeEXR.h | 18 +-- panda/src/pnmimagetypes/pnmFileTypeIMG.h | 16 +-- panda/src/pnmimagetypes/pnmFileTypeJPG.h | 18 +-- panda/src/pnmimagetypes/pnmFileTypePNG.h | 18 +-- panda/src/pnmimagetypes/pnmFileTypePNM.h | 18 +-- panda/src/pnmimagetypes/pnmFileTypePfm.h | 18 +-- panda/src/pnmimagetypes/pnmFileTypeSGI.h | 20 +-- .../src/pnmimagetypes/pnmFileTypeSoftImage.h | 18 +-- panda/src/pnmimagetypes/pnmFileTypeStbImage.h | 10 +- panda/src/pnmimagetypes/pnmFileTypeTGA.h | 24 ++-- panda/src/pnmimagetypes/pnmFileTypeTIFF.h | 18 +-- panda/src/pnmtext/freetypeFace.h | 4 +- panda/src/pnmtext/freetypeFont.h | 6 +- panda/src/pnmtext/pnmTextMaker.I | 4 +- panda/src/pnmtext/pnmTextMaker.h | 8 +- panda/src/pstatclient/pStatClient.I | 14 +- panda/src/pstatclient/pStatClient.h | 46 +++---- .../pstatclient/pStatClientControlMessage.h | 6 +- panda/src/pstatclient/pStatClientImpl.I | 4 +- panda/src/pstatclient/pStatClientImpl.h | 12 +- panda/src/pstatclient/pStatCollector.I | 18 +-- panda/src/pstatclient/pStatCollector.h | 16 +-- panda/src/pstatclient/pStatCollectorDef.h | 6 +- .../pstatclient/pStatServerControlMessage.h | 4 +- panda/src/putil/animInterface.I | 4 +- panda/src/putil/animInterface.h | 6 +- panda/src/putil/autoTextureScale.h | 4 +- panda/src/putil/bam.h | 2 +- panda/src/putil/bamCache.h | 10 +- panda/src/putil/bamCacheIndex.h | 4 +- panda/src/putil/bamCacheRecord.h | 12 +- panda/src/putil/bamEnums.h | 10 +- panda/src/putil/bamReader.I | 2 +- panda/src/putil/bamReader.h | 20 +-- panda/src/putil/bitArray.h | 12 +- panda/src/putil/bitMask.I | 10 +- panda/src/putil/bitMask.h | 12 +- panda/src/putil/buttonHandle.I | 2 +- panda/src/putil/buttonHandle.h | 8 +- panda/src/putil/buttonMap.I | 14 +- panda/src/putil/buttonMap.h | 16 +-- panda/src/putil/buttonRegistry.I | 4 +- panda/src/putil/buttonRegistry.h | 16 +-- panda/src/putil/callbackData.h | 4 +- panda/src/putil/callbackObject.h | 4 +- panda/src/putil/clockObject.I | 2 +- panda/src/putil/clockObject.h | 8 +- panda/src/putil/colorSpace.h | 8 +- panda/src/putil/copyOnWriteObject.I | 8 +- panda/src/putil/datagramBuffer.I | 4 +- panda/src/putil/datagramBuffer.h | 4 +- panda/src/putil/datagramInputFile.I | 2 +- panda/src/putil/datagramInputFile.h | 10 +- panda/src/putil/datagramOutputFile.I | 2 +- panda/src/putil/datagramOutputFile.h | 10 +- panda/src/putil/doubleBitMask.I | 10 +- panda/src/putil/doubleBitMask.h | 10 +- panda/src/putil/factory.I | 4 +- panda/src/putil/factory.h | 4 +- panda/src/putil/factoryBase.I | 4 +- panda/src/putil/factoryBase.h | 6 +- panda/src/putil/load_prc_file.h | 2 +- panda/src/putil/loaderOptions.h | 12 +- panda/src/putil/modifierButtons.h | 8 +- panda/src/putil/mouseData.I | 2 +- panda/src/putil/mouseData.h | 4 +- panda/src/putil/nameUniquifier.I | 8 +- panda/src/putil/nameUniquifier.h | 16 +-- panda/src/putil/paramValue.I | 2 +- panda/src/putil/paramValue.h | 12 +- panda/src/putil/simpleHashMap.I | 14 +- panda/src/putil/simpleHashMap.h | 10 +- panda/src/putil/sparseArray.h | 6 +- panda/src/putil/test_bam.h | 10 +- panda/src/putil/uniqueIdAllocator.h | 4 +- panda/src/putil/updateSeq.I | 4 +- panda/src/putil/updateSeq.h | 4 +- panda/src/putil/weakKeyHashMap.I | 6 +- panda/src/putil/weakKeyHashMap.h | 6 +- panda/src/recorder/mouseRecorder.h | 6 +- panda/src/recorder/recorderController.I | 8 +- panda/src/recorder/recorderController.h | 8 +- panda/src/recorder/recorderTable.I | 6 +- panda/src/recorder/recorderTable.h | 10 +- panda/src/rocket/rocketFileInterface.h | 2 +- panda/src/rocket/rocketInputHandler.h | 2 +- panda/src/rocket/rocketRegion.I | 4 +- panda/src/rocket/rocketRegion.h | 6 +- panda/src/speedtree/loaderFileTypeSrt.h | 4 +- panda/src/speedtree/loaderFileTypeStf.h | 4 +- panda/src/speedtree/speedTreeNode.h | 20 +-- panda/src/speedtree/stBasicTerrain.h | 8 +- panda/src/speedtree/stTerrain.h | 6 +- panda/src/speedtree/stTransform.h | 4 +- panda/src/speedtree/stTree.h | 4 +- panda/src/text/config_text.h | 4 +- panda/src/text/dynamicTextFont.I | 6 +- panda/src/text/dynamicTextFont.h | 6 +- panda/src/text/fontPool.I | 12 +- panda/src/text/fontPool.h | 28 ++-- panda/src/text/geomTextGlyph.h | 4 +- panda/src/text/staticTextFont.h | 2 +- panda/src/text/textAssembler.I | 6 +- panda/src/text/textAssembler.h | 26 ++-- panda/src/text/textFont.h | 8 +- panda/src/text/textNode.I | 18 +-- panda/src/text/textNode.h | 30 ++--- panda/src/text/textProperties.I | 6 +- panda/src/text/textProperties.h | 8 +- panda/src/text/textPropertiesManager.h | 28 ++-- panda/src/tform/buttonThrower.I | 36 +++--- panda/src/tform/buttonThrower.h | 62 ++++----- panda/src/tform/driveInterface.h | 2 +- panda/src/tform/mouseInterfaceNode.h | 2 +- panda/src/tform/mouseSubregion.h | 2 +- panda/src/tform/mouseWatcher.I | 32 ++--- panda/src/tform/mouseWatcher.h | 62 ++++----- panda/src/tform/mouseWatcherBase.h | 10 +- panda/src/tform/mouseWatcherParameter.I | 12 +- panda/src/tform/mouseWatcherParameter.h | 14 +- panda/src/tform/mouseWatcherRegion.I | 4 +- panda/src/tform/mouseWatcherRegion.h | 10 +- panda/src/tform/trackball.h | 2 +- panda/src/tform/transform2sg.h | 2 +- panda/src/tinydisplay/tinyGraphicsBuffer.h | 2 +- .../tinydisplay/tinyOffscreenGraphicsPipe.h | 4 +- panda/src/tinydisplay/tinyOsxGraphicsPipe.h | 4 +- panda/src/tinydisplay/tinyOsxGraphicsWindow.h | 2 +- panda/src/tinydisplay/tinySDLGraphicsPipe.h | 4 +- panda/src/tinydisplay/tinySDLGraphicsWindow.h | 2 +- panda/src/tinydisplay/tinyWinGraphicsPipe.h | 4 +- panda/src/tinydisplay/tinyWinGraphicsWindow.h | 2 +- panda/src/tinydisplay/tinyXGraphicsPipe.h | 6 +- panda/src/tinydisplay/tinyXGraphicsWindow.h | 2 +- panda/src/vision/openCVTexture.h | 4 +- panda/src/vision/webcamVideo.I | 6 +- panda/src/vision/webcamVideo.h | 8 +- panda/src/vision/webcamVideoV4L.h | 4 +- panda/src/vrpn/vrpnAnalog.I | 2 +- panda/src/vrpn/vrpnAnalog.h | 12 +- panda/src/vrpn/vrpnAnalogDevice.h | 2 +- panda/src/vrpn/vrpnButton.I | 2 +- panda/src/vrpn/vrpnButton.h | 12 +- panda/src/vrpn/vrpnButtonDevice.h | 2 +- panda/src/vrpn/vrpnClient.I | 16 +-- panda/src/vrpn/vrpnClient.h | 36 +++--- panda/src/vrpn/vrpnDial.I | 2 +- panda/src/vrpn/vrpnDial.h | 12 +- panda/src/vrpn/vrpnDialDevice.h | 2 +- panda/src/vrpn/vrpnTracker.I | 2 +- panda/src/vrpn/vrpnTracker.h | 12 +- panda/src/vrpn/vrpnTrackerDevice.h | 2 +- panda/src/wgldisplay/wglGraphicsBuffer.h | 2 +- panda/src/wgldisplay/wglGraphicsPipe.h | 6 +- panda/src/wgldisplay/wglGraphicsWindow.h | 2 +- panda/src/windisplay/winDetectDx.h | 4 +- panda/src/windisplay/winGraphicsWindow.h | 6 +- panda/src/x11display/x11GraphicsPipe.h | 2 +- panda/src/x11display/x11GraphicsWindow.h | 6 +- pandatool/src/assimp/assimpLoader.h | 2 +- pandatool/src/assimp/loaderFileTypeAssimp.h | 6 +- pandatool/src/assimp/pandaIOStream.h | 4 +- pandatool/src/bam/eggToBam.h | 4 +- pandatool/src/bam/ptsToBam.h | 2 +- .../src/converter/eggToSomethingConverter.h | 6 +- .../src/converter/somethingToEggConverter.I | 4 +- .../src/converter/somethingToEggConverter.h | 12 +- pandatool/src/cvscopy/cvsCopy.h | 12 +- pandatool/src/cvscopy/cvsSourceDirectory.h | 12 +- pandatool/src/cvscopy/cvsSourceTree.h | 26 ++-- pandatool/src/daeegg/daeCharacter.h | 4 +- pandatool/src/daeegg/daeMaterials.h | 14 +- pandatool/src/daeegg/daeToEggConverter.h | 8 +- pandatool/src/daeegg/fcollada_utils.h | 2 +- pandatool/src/dxf/dxfFile.h | 16 +-- pandatool/src/dxf/dxfLayer.h | 2 +- pandatool/src/dxf/dxfLayerMap.h | 4 +- pandatool/src/dxfegg/dxfToEggConverter.h | 6 +- pandatool/src/dxfegg/dxfToEggLayer.h | 2 +- pandatool/src/dxfprogs/eggToDXF.h | 4 +- pandatool/src/dxfprogs/eggToDXFLayer.h | 8 +- pandatool/src/egg-mkfont/eggMakeFont.h | 8 +- pandatool/src/egg-mkfont/rangeDescription.I | 2 +- pandatool/src/egg-mkfont/rangeDescription.h | 12 +- pandatool/src/egg-optchar/eggOptchar.h | 24 ++-- pandatool/src/egg-palettize/eggPalettize.h | 10 +- pandatool/src/egg-qtess/qtessInputEntry.I | 4 +- pandatool/src/egg-qtess/qtessInputEntry.h | 14 +- pandatool/src/egg-qtess/qtessInputFile.h | 2 +- pandatool/src/egg-qtess/qtessSurface.I | 6 +- pandatool/src/egg-qtess/qtessSurface.h | 12 +- pandatool/src/eggbase/eggBase.h | 18 +-- pandatool/src/eggbase/eggConverter.h | 6 +- pandatool/src/eggbase/eggReader.h | 2 +- pandatool/src/eggbase/eggToSomething.h | 4 +- pandatool/src/eggbase/somethingToEgg.h | 8 +- pandatool/src/eggcharbase/eggBackPointer.h | 2 +- .../src/eggcharbase/eggCharacterCollection.h | 16 +-- pandatool/src/eggcharbase/eggCharacterData.I | 4 +- pandatool/src/eggcharbase/eggCharacterData.h | 14 +- pandatool/src/eggcharbase/eggComponentData.h | 8 +- pandatool/src/eggcharbase/eggJointData.I | 2 +- pandatool/src/eggcharbase/eggJointData.h | 14 +- .../src/eggcharbase/eggJointNodePointer.h | 4 +- pandatool/src/eggcharbase/eggJointPointer.h | 6 +- .../src/eggcharbase/eggMatrixTablePointer.h | 8 +- .../src/eggcharbase/eggScalarTablePointer.h | 2 +- pandatool/src/eggcharbase/eggSliderData.h | 2 +- pandatool/src/eggprogs/eggRetargetAnim.h | 2 +- pandatool/src/eggprogs/eggTextureCards.h | 8 +- pandatool/src/eggprogs/eggTopstrip.h | 4 +- pandatool/src/flt/fltBeadID.h | 8 +- pandatool/src/flt/fltError.h | 2 +- pandatool/src/flt/fltExternalReference.h | 6 +- pandatool/src/flt/fltHeader.h | 10 +- pandatool/src/flt/fltInstanceRef.h | 2 +- pandatool/src/flt/fltLightSourceDefinition.h | 2 +- pandatool/src/flt/fltMaterial.h | 2 +- pandatool/src/flt/fltOpcode.h | 2 +- pandatool/src/flt/fltPackedColor.I | 4 +- pandatool/src/flt/fltPackedColor.h | 4 +- pandatool/src/flt/fltRecord.I | 4 +- pandatool/src/flt/fltRecord.h | 16 +-- pandatool/src/flt/fltRecordReader.h | 4 +- pandatool/src/flt/fltRecordWriter.h | 4 +- pandatool/src/flt/fltTexture.h | 6 +- pandatool/src/flt/fltUnsupportedRecord.h | 2 +- pandatool/src/flt/fltVertexList.h | 2 +- pandatool/src/fltegg/fltToEggConverter.h | 6 +- pandatool/src/fltegg/fltToEggLevelState.h | 2 +- pandatool/src/fltprogs/eggToFlt.h | 4 +- pandatool/src/gtk-stats/gtkStatsLabel.h | 2 +- pandatool/src/gtk-stats/gtkStatsMonitor.h | 4 +- pandatool/src/gtk-stats/gtkStatsStripChart.h | 2 +- pandatool/src/imageprogs/imageResize.h | 2 +- pandatool/src/imageprogs/imageTrans.h | 2 +- .../src/imageprogs/imageTransformColors.h | 10 +- pandatool/src/lwo/iffChunk.h | 6 +- pandatool/src/lwo/iffGenericChunk.h | 2 +- pandatool/src/lwo/iffId.I | 4 +- pandatool/src/lwo/iffId.h | 6 +- pandatool/src/lwo/iffInputFile.h | 6 +- pandatool/src/lwo/lwoBoundingBox.h | 2 +- pandatool/src/lwo/lwoClip.h | 2 +- pandatool/src/lwo/lwoDiscontinuousVertexMap.h | 4 +- pandatool/src/lwo/lwoGroupChunk.h | 2 +- pandatool/src/lwo/lwoHeader.h | 2 +- pandatool/src/lwo/lwoLayer.h | 4 +- pandatool/src/lwo/lwoPoints.h | 2 +- pandatool/src/lwo/lwoPolygonTags.h | 2 +- pandatool/src/lwo/lwoPolygons.h | 2 +- pandatool/src/lwo/lwoStillImage.h | 2 +- pandatool/src/lwo/lwoSurface.h | 6 +- pandatool/src/lwo/lwoSurfaceBlock.h | 2 +- pandatool/src/lwo/lwoSurfaceBlockAxis.h | 2 +- pandatool/src/lwo/lwoSurfaceBlockChannel.h | 2 +- pandatool/src/lwo/lwoSurfaceBlockCoordSys.h | 2 +- pandatool/src/lwo/lwoSurfaceBlockEnabled.h | 2 +- pandatool/src/lwo/lwoSurfaceBlockHeader.h | 4 +- pandatool/src/lwo/lwoSurfaceBlockImage.h | 2 +- pandatool/src/lwo/lwoSurfaceBlockOpacity.h | 2 +- pandatool/src/lwo/lwoSurfaceBlockProjection.h | 2 +- pandatool/src/lwo/lwoSurfaceBlockRefObj.h | 4 +- pandatool/src/lwo/lwoSurfaceBlockRepeat.h | 2 +- pandatool/src/lwo/lwoSurfaceBlockTMap.h | 2 +- pandatool/src/lwo/lwoSurfaceBlockTransform.h | 2 +- pandatool/src/lwo/lwoSurfaceBlockVMapName.h | 4 +- pandatool/src/lwo/lwoSurfaceBlockWrap.h | 2 +- pandatool/src/lwo/lwoSurfaceColor.h | 2 +- pandatool/src/lwo/lwoSurfaceParameter.h | 2 +- pandatool/src/lwo/lwoSurfaceSidedness.h | 2 +- pandatool/src/lwo/lwoSurfaceSmoothingAngle.h | 2 +- pandatool/src/lwo/lwoTags.h | 4 +- pandatool/src/lwo/lwoVertexMap.h | 4 +- pandatool/src/lwoegg/cLwoPoints.h | 4 +- pandatool/src/lwoegg/cLwoPolygons.h | 4 +- pandatool/src/lwoegg/cLwoSurface.I | 4 +- pandatool/src/lwoegg/cLwoSurface.h | 4 +- pandatool/src/lwoegg/cLwoSurfaceBlock.h | 4 +- pandatool/src/lwoegg/cLwoSurfaceBlockTMap.h | 2 +- pandatool/src/lwoegg/lwoToEggConverter.h | 8 +- pandatool/src/maxegg/maxToEggConverter.h | 2 +- pandatool/src/maya/mayaApi.h | 4 +- pandatool/src/maya/mayaShader.h | 8 +- pandatool/src/maya/mayaShaderColorDef.h | 16 +-- pandatool/src/maya/mayaShaders.h | 6 +- pandatool/src/maya/maya_funcs.I | 4 +- pandatool/src/maya/maya_funcs.h | 48 +++---- pandatool/src/mayaegg/mayaNodeDesc.h | 6 +- pandatool/src/mayaegg/mayaNodeTree.h | 12 +- pandatool/src/mayaegg/mayaToEggConverter.h | 20 +-- pandatool/src/mayaprogs/mayaCopy.h | 2 +- pandatool/src/mayaprogs/mayaToEgg.h | 2 +- pandatool/src/mayaprogs/mayaToEgg_server.h | 2 +- pandatool/src/miscprogs/binToC.h | 2 +- pandatool/src/objegg/eggToObjConverter.h | 12 +- pandatool/src/objegg/objToEggConverter.h | 20 +-- pandatool/src/palettizer/destTextureImage.h | 4 +- pandatool/src/palettizer/eggFile.h | 8 +- pandatool/src/palettizer/filenameUnifier.h | 2 +- pandatool/src/palettizer/imageFile.h | 8 +- pandatool/src/palettizer/omitReason.h | 2 +- pandatool/src/palettizer/pal_string_utils.h | 4 +- pandatool/src/palettizer/paletteGroup.h | 12 +- pandatool/src/palettizer/paletteGroups.h | 6 +- pandatool/src/palettizer/paletteImage.h | 4 +- pandatool/src/palettizer/palettePage.h | 2 +- pandatool/src/palettizer/palettizer.h | 30 ++--- pandatool/src/palettizer/sourceTextureImage.h | 4 +- pandatool/src/palettizer/textureImage.h | 10 +- .../src/palettizer/textureMemoryCounter.h | 4 +- pandatool/src/palettizer/texturePlacement.h | 4 +- pandatool/src/palettizer/textureProperties.h | 12 +- pandatool/src/palettizer/textureReference.h | 12 +- pandatool/src/palettizer/txaFile.h | 6 +- pandatool/src/palettizer/txaLine.h | 6 +- .../src/pandatoolbase/animationConvert.h | 6 +- pandatool/src/pandatoolbase/distanceUnit.h | 10 +- pandatool/src/pandatoolbase/pathReplace.I | 8 +- pandatool/src/pandatoolbase/pathReplace.h | 16 +-- pandatool/src/pandatoolbase/pathStore.h | 6 +- pandatool/src/pfmprogs/pfmTrans.h | 12 +- pandatool/src/progbase/programBase.I | 2 +- pandatool/src/progbase/programBase.h | 102 +++++++-------- pandatool/src/progbase/withOutputFile.h | 4 +- pandatool/src/progbase/wordWrapStream.h | 2 +- pandatool/src/progbase/wordWrapStreamBuf.h | 4 +- pandatool/src/pstatserver/pStatClientData.h | 10 +- pandatool/src/pstatserver/pStatGraph.I | 8 +- pandatool/src/pstatserver/pStatGraph.h | 18 +-- pandatool/src/pstatserver/pStatMonitor.I | 6 +- pandatool/src/pstatserver/pStatMonitor.h | 16 +-- pandatool/src/pstatserver/pStatReader.h | 4 +- pandatool/src/pstatserver/pStatStripChart.h | 2 +- .../src/ptloader/loaderFileTypePandatool.h | 6 +- pandatool/src/softegg/softNodeDesc.h | 2 +- pandatool/src/softegg/softNodeTree.h | 6 +- pandatool/src/softegg/softToEggConverter.h | 12 +- pandatool/src/softprogs/softCVS.h | 10 +- pandatool/src/softprogs/softFilename.h | 22 ++-- pandatool/src/text-stats/textMonitor.h | 6 +- pandatool/src/text-stats/textStats.h | 4 +- pandatool/src/vrml/parse_vrml.h | 2 +- pandatool/src/vrml/vrmlLexerDefs.h | 6 +- pandatool/src/vrml/vrmlNode.h | 12 +- pandatool/src/vrml/vrmlNodeType.h | 2 +- pandatool/src/vrml/vrmlParserDefs.h | 2 +- pandatool/src/vrmlegg/vrmlToEggConverter.h | 6 +- pandatool/src/win-stats/winStatsLabel.h | 2 +- pandatool/src/win-stats/winStatsMonitor.h | 4 +- pandatool/src/win-stats/winStatsStripChart.h | 2 +- pandatool/src/xfile/windowsGuid.I | 4 +- pandatool/src/xfile/windowsGuid.h | 8 +- pandatool/src/xfile/xFile.h | 16 +-- pandatool/src/xfile/xFileArrayDef.h | 2 +- pandatool/src/xfile/xFileDataDef.I | 2 +- pandatool/src/xfile/xFileDataDef.h | 4 +- pandatool/src/xfile/xFileDataNode.I | 2 +- pandatool/src/xfile/xFileDataNode.h | 8 +- pandatool/src/xfile/xFileDataNodeReference.h | 4 +- pandatool/src/xfile/xFileDataNodeTemplate.h | 10 +- pandatool/src/xfile/xFileDataObject.I | 14 +- pandatool/src/xfile/xFileDataObject.h | 26 ++-- pandatool/src/xfile/xFileDataObjectArray.h | 2 +- pandatool/src/xfile/xFileDataObjectDouble.h | 6 +- pandatool/src/xfile/xFileDataObjectInteger.h | 6 +- pandatool/src/xfile/xFileDataObjectString.h | 14 +- pandatool/src/xfile/xFileNode.h | 32 ++--- pandatool/src/xfile/xFileParseData.h | 6 +- pandatool/src/xfile/xFileTemplate.h | 4 +- pandatool/src/xfile/xLexerDefs.h | 10 +- pandatool/src/xfile/xParserDefs.h | 4 +- pandatool/src/xfileegg/xFileAnimationSet.h | 8 +- pandatool/src/xfileegg/xFileMaterial.h | 2 +- pandatool/src/xfileegg/xFileMesh.h | 12 +- pandatool/src/xfileegg/xFileToEggConverter.h | 16 +-- pandatool/src/xfileprogs/xFileToEgg.h | 2 +- 1637 files changed, 7601 insertions(+), 7604 deletions(-) diff --git a/contrib/src/ai/aiBehaviors.h b/contrib/src/ai/aiBehaviors.h index 6a20876db8..3524a32b63 100644 --- a/contrib/src/ai/aiBehaviors.h +++ b/contrib/src/ai/aiBehaviors.h @@ -28,8 +28,8 @@ class PathFollow; class PathFind; class ObstacleAvoidance; -typedef list > ListFlee; -typedef list > ListEvade; +typedef std::list > ListFlee; +typedef std::list > ListEvade; /** * This class implements all the steering behaviors of the AI framework, such @@ -113,21 +113,21 @@ public: ~AIBehaviors(); bool is_on(_behavior_type bt); - bool is_on(string ai_type); // special cases for pathfollow and pathfinding + bool is_on(std::string ai_type); // special cases for pathfollow and pathfinding bool is_off(_behavior_type bt); - bool is_off(string ai_type); // special cases for pathfollow and pathfinding - void turn_on(string ai_type); - void turn_off(string ai_type); + bool is_off(std::string ai_type); // special cases for pathfollow and pathfinding + void turn_on(std::string ai_type); + void turn_off(std::string ai_type); bool is_conflict(); - void accumulate_force(string force_type, LVecBase3 force); + void accumulate_force(std::string force_type, LVecBase3 force); LVecBase3 calculate_prioritized(); void flock_activate(); LVecBase3 do_flock(); - int char_to_int(string ai_type); + int char_to_int(std::string ai_type); PUBLISHED: void seek(NodePath target_object, float seek_wt = 1.0); @@ -150,21 +150,21 @@ PUBLISHED: void path_follow(float follow_wt); void add_to_path(LVecBase3 pos); - void start_follow(string type = "normal"); + void start_follow(std::string type = "normal"); // should have different function names. void init_path_find(const char* navmesh_filename); - void path_find_to(LVecBase3 pos, string type = "normal"); - void path_find_to(NodePath target, string type = "normal"); + void path_find_to(LVecBase3 pos, std::string type = "normal"); + void path_find_to(NodePath target, std::string type = "normal"); void add_static_obstacle(NodePath obstacle); void add_dynamic_obstacle(NodePath obstacle); - void remove_ai(string ai_type); - void pause_ai(string ai_type); - void resume_ai(string ai_type); + void remove_ai(std::string ai_type); + void pause_ai(std::string ai_type); + void resume_ai(std::string ai_type); - string behavior_status(string ai_type); + std::string behavior_status(std::string ai_type); }; #endif diff --git a/contrib/src/ai/aiCharacter.h b/contrib/src/ai/aiCharacter.h index 30adf21ced..81b3a01210 100644 --- a/contrib/src/ai/aiCharacter.h +++ b/contrib/src/ai/aiCharacter.h @@ -32,7 +32,7 @@ class EXPCL_PANDAAI AICharacter : public ReferenceCount { double _max_force; LVecBase3 _velocity; LVecBase3 _steering_force; - string _name; + std::string _name; double _movt_force; unsigned int _ai_char_flock_id; AIWorld *_world; @@ -63,7 +63,7 @@ PUBLISHED: // This function is used to enable or disable the guides for path finding. void set_pf_guide(bool pf_guide); - explicit AICharacter(string model_name, NodePath model_np, double mass, double movt_force, double max_force); + explicit AICharacter(std::string model_name, NodePath model_np, double mass, double movt_force, double max_force); ~AICharacter(); }; diff --git a/contrib/src/ai/aiWorld.h b/contrib/src/ai/aiWorld.h index 3848e054dc..67576c6745 100644 --- a/contrib/src/ai/aiWorld.h +++ b/contrib/src/ai/aiWorld.h @@ -37,14 +37,14 @@ class EXPCL_PANDAAI AIWorld { std::vector _obstacles; typedef std::vector FlockPool; FlockPool _flock_pool; - void remove_ai_char_from_flock(string name); + void remove_ai_char_from_flock(std::string name); PUBLISHED: AIWorld(NodePath render); ~AIWorld(); void add_ai_char(AICharacter *ai_ch); - void remove_ai_char(string name); + void remove_ai_char(std::string name); void add_flock(Flock *flock); void flock_off(unsigned int flock_id); diff --git a/contrib/src/ai/pathFind.h b/contrib/src/ai/pathFind.h index ffeb50abf0..cd26cc234f 100644 --- a/contrib/src/ai/pathFind.h +++ b/contrib/src/ai/pathFind.h @@ -56,8 +56,8 @@ public: void clear_previous_obstacles(); void set_path_find(const char* navmesh_filename); - void path_find(LVecBase3 pos, string type = "normal"); - void path_find(NodePath target, string type = "normal"); + void path_find(LVecBase3 pos, std::string type = "normal"); + void path_find(NodePath target, std::string type = "normal"); void add_obstacle_to_mesh(NodePath obstacle); void dynamic_avoid(NodePath obstacle); }; diff --git a/contrib/src/ai/pathFollow.h b/contrib/src/ai/pathFollow.h index e2d09a27bc..16b221314e 100644 --- a/contrib/src/ai/pathFollow.h +++ b/contrib/src/ai/pathFollow.h @@ -13,18 +13,18 @@ class EXPCL_PANDAAI PathFollow { public: AICharacter *_ai_char; float _follow_weight; - vector _path; + std::vector _path; int _curr_path_waypoint; bool _start; NodePath _dummy; - string _type; + std::string _type; ClockObject *_myClock; float _time; PathFollow(AICharacter *ai_ch, float follow_wt); ~PathFollow(); void add_to_path(LVecBase3 pos); - void start(string type); + void start(std::string type); void do_follow(); bool check_if_possible(); }; diff --git a/contrib/src/rplight/gpuCommand.I b/contrib/src/rplight/gpuCommand.I index 3531eed2ba..0171442b08 100644 --- a/contrib/src/rplight/gpuCommand.I +++ b/contrib/src/rplight/gpuCommand.I @@ -74,7 +74,7 @@ inline float GPUCommand::convert_int_to_float(int v) const { */ inline void GPUCommand::push_float(float v) { if (_current_index >= GPU_COMMAND_ENTRIES) { - gpucommand_cat.error() << "Out of bounds! Exceeded command size of " << GPU_COMMAND_ENTRIES << endl; + gpucommand_cat.error() << "Out of bounds! Exceeded command size of " << GPU_COMMAND_ENTRIES << std::endl; return; } _data[_current_index++] = v; diff --git a/contrib/src/rplight/gpuCommand.h b/contrib/src/rplight/gpuCommand.h index 7fa784b975..c6d5809b37 100644 --- a/contrib/src/rplight/gpuCommand.h +++ b/contrib/src/rplight/gpuCommand.h @@ -73,7 +73,7 @@ PUBLISHED: inline static bool get_uses_integer_packing(); void write_to(const PTA_uchar &dest, size_t command_index); - void write(ostream &out) const; + void write(std::ostream &out) const; private: diff --git a/contrib/src/rplight/pointerSlotStorage.h b/contrib/src/rplight/pointerSlotStorage.h index 401e133b81..c37102574f 100644 --- a/contrib/src/rplight/pointerSlotStorage.h +++ b/contrib/src/rplight/pointerSlotStorage.h @@ -203,7 +203,7 @@ public: nassertv(slot >= 0 && slot < SIZE); nassertv(_data[slot] == nullptr); // Slot already taken! nassertv(ptr != nullptr); // nullptr passed as argument! - _max_index = max(_max_index, (int)slot); + _max_index = std::max(_max_index, (int)slot); _data[slot] = ptr; _num_entries++; } diff --git a/contrib/src/rplight/rpLight.I b/contrib/src/rplight/rpLight.I index 9b21906310..9cde259478 100644 --- a/contrib/src/rplight/rpLight.I +++ b/contrib/src/rplight/rpLight.I @@ -278,7 +278,7 @@ inline RPLight::LightType RPLight::get_light_type() const { */ inline void RPLight::set_casts_shadows(bool flag) { if (has_slot()) { - cerr << "Light is already attached, can not call set_casts_shadows!" << endl; + std::cerr << "Light is already attached, can not call set_casts_shadows!" << std::endl; return; } _casts_shadows = flag; diff --git a/contrib/src/rplight/rpLight.h b/contrib/src/rplight/rpLight.h index 13665c23ad..1a104f8ac7 100644 --- a/contrib/src/rplight/rpLight.h +++ b/contrib/src/rplight/rpLight.h @@ -122,7 +122,7 @@ protected: LightType _light_type; float _near_plane; - vector _shadow_sources; + std::vector _shadow_sources; }; #include "rpLight.I" diff --git a/contrib/src/rplight/shadowAtlas.I b/contrib/src/rplight/shadowAtlas.I index f48fc451f1..0b1812fa28 100644 --- a/contrib/src/rplight/shadowAtlas.I +++ b/contrib/src/rplight/shadowAtlas.I @@ -118,7 +118,7 @@ inline int ShadowAtlas::get_required_tiles(size_t resolution) const { if (resolution % _tile_size != 0) { shadowatlas_cat.error() << "Resolution " << resolution << " is not a multiple " - << "of the shadow atlas tile size (" << _tile_size << ")!" << endl; + << "of the shadow atlas tile size (" << _tile_size << ")!" << std::endl; return 1; } return resolution / _tile_size; diff --git a/contrib/src/rplight/shadowManager.I b/contrib/src/rplight/shadowManager.I index f5d87c463e..983c044f6f 100644 --- a/contrib/src/rplight/shadowManager.I +++ b/contrib/src/rplight/shadowManager.I @@ -52,7 +52,7 @@ inline void ShadowManager::set_max_updates(size_t max_updates) { nassertv(max_updates >= 0); nassertv(_atlas == nullptr); // ShadowManager was already initialized if (max_updates == 0) { - shadowmanager_cat.warning() << "max_updates set to 0, no shadows will be updated." << endl; + shadowmanager_cat.warning() << "max_updates set to 0, no shadows will be updated." << std::endl; } _max_updates = max_updates; } @@ -170,7 +170,7 @@ inline bool ShadowManager::add_update(const ShadowSource* source) { if (_queued_updates.size() >= _max_updates) { if (shadowmanager_cat.is_debug()) { - shadowmanager_cat.debug() << "cannot update source, out of update slots" << endl; + shadowmanager_cat.debug() << "cannot update source, out of update slots" << std::endl; } return false; } diff --git a/contrib/src/rplight/tagStateManager.I b/contrib/src/rplight/tagStateManager.I index 058832e60d..2da15e4ecd 100644 --- a/contrib/src/rplight/tagStateManager.I +++ b/contrib/src/rplight/tagStateManager.I @@ -35,7 +35,7 @@ * @param source Camera which will be used to render shadows */ inline void TagStateManager:: -register_camera(const string& name, Camera* source) { +register_camera(const std::string& name, Camera* source) { ContainerList::iterator entry = _containers.find(name); nassertv(entry != _containers.end()); register_camera(entry->second, source); @@ -49,7 +49,7 @@ register_camera(const string& name, Camera* source) { * @param source Camera to unregister */ inline void TagStateManager:: -unregister_camera(const string& name, Camera* source) { +unregister_camera(const std::string& name, Camera* source) { ContainerList::iterator entry = _containers.find(name); nassertv(entry != _containers.end()); unregister_camera(entry->second, source); @@ -67,8 +67,8 @@ unregister_camera(const string& name, Camera* source) { * @param sort Determines the sort with which the shader will be applied. */ inline void TagStateManager:: -apply_state(const string& state, NodePath np, Shader* shader, - const string &name, int sort) { +apply_state(const std::string& state, NodePath np, Shader* shader, + const std::string &name, int sort) { ContainerList::iterator entry = _containers.find(state); nassertv(entry != _containers.end()); apply_state(entry->second, np, shader, name, sort); @@ -83,7 +83,7 @@ apply_state(const string& state, NodePath np, Shader* shader, * @return Bit mask of the render pass */ inline BitMask32 TagStateManager:: -get_mask(const string &container_name) { +get_mask(const std::string &container_name) { if (container_name == "gbuffer") { return BitMask32::bit(1); } diff --git a/contrib/src/rplight/tagStateManager.h b/contrib/src/rplight/tagStateManager.h index 6c26e5cbf6..b05e364333 100644 --- a/contrib/src/rplight/tagStateManager.h +++ b/contrib/src/rplight/tagStateManager.h @@ -52,36 +52,36 @@ PUBLISHED: TagStateManager(NodePath main_cam_node); ~TagStateManager(); - inline void apply_state(const string& state, NodePath np, Shader* shader, const string &name, int sort); + inline void apply_state(const std::string& state, NodePath np, Shader* shader, const std::string &name, int sort); void cleanup_states(); - inline void register_camera(const string& state, Camera* source); - inline void unregister_camera(const string& state, Camera* source); - inline BitMask32 get_mask(const string &container_name); + inline void register_camera(const std::string& state, Camera* source); + inline void unregister_camera(const std::string& state, Camera* source); + inline BitMask32 get_mask(const std::string &container_name); private: - typedef vector CameraList; - typedef pmap TagStateList; + typedef std::vector CameraList; + typedef pmap TagStateList; struct StateContainer { CameraList cameras; TagStateList tag_states; - string tag_name; + std::string tag_name; BitMask32 mask; bool write_color; StateContainer() {}; - StateContainer(const string &tag_name, size_t mask, bool write_color) + StateContainer(const std::string &tag_name, size_t mask, bool write_color) : tag_name(tag_name), mask(BitMask32::bit(mask)), write_color(write_color) {}; }; void apply_state(StateContainer& container, NodePath np, Shader* shader, - const string& name, int sort); + const std::string& name, int sort); void cleanup_container_states(StateContainer& container); void register_camera(StateContainer &container, Camera* source); void unregister_camera(StateContainer &container, Camera* source); - typedef pmap ContainerList; + typedef pmap ContainerList; ContainerList _containers; NodePath _main_cam_node; diff --git a/direct/src/dcparser/dcArrayParameter.h b/direct/src/dcparser/dcArrayParameter.h index 10a8f022c2..fd5008fb97 100644 --- a/direct/src/dcparser/dcArrayParameter.h +++ b/direct/src/dcparser/dcArrayParameter.h @@ -46,14 +46,14 @@ public: virtual DCPackerInterface *get_nested_field(int n) const; virtual bool validate_num_nested_fields(int num_nested_fields) const; - virtual void output_instance(ostream &out, bool brief, const string &prename, - const string &name, const string &postname) const; + virtual void output_instance(std::ostream &out, bool brief, const std::string &prename, + const std::string &name, const std::string &postname) const; virtual void generate_hash(HashGenerator &hashgen) const; - virtual void pack_string(DCPackData &pack_data, const string &value, + virtual void pack_string(DCPackData &pack_data, const std::string &value, bool &pack_error, bool &range_error) const; virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const; virtual void unpack_string(const char *data, size_t length, size_t &p, - string &value, bool &pack_error, bool &range_error) const; + std::string &value, bool &pack_error, bool &range_error) const; protected: virtual bool do_check_match(const DCPackerInterface *other) const; diff --git a/direct/src/dcparser/dcAtomicField.h b/direct/src/dcparser/dcAtomicField.h index c002ecf15a..e0d7cee58e 100644 --- a/direct/src/dcparser/dcAtomicField.h +++ b/direct/src/dcparser/dcAtomicField.h @@ -29,7 +29,7 @@ */ class DCAtomicField : public DCField { public: - DCAtomicField(const string &name, DCClass *dclass, bool bogus_field); + DCAtomicField(const std::string &name, DCClass *dclass, bool bogus_field); virtual ~DCAtomicField(); PUBLISHED: @@ -40,17 +40,17 @@ PUBLISHED: DCParameter *get_element(int n) const; // These five methods are deprecated and will be removed soon. - string get_element_default(int n) const; + std::string get_element_default(int n) const; bool has_element_default(int n) const; - string get_element_name(int n) const; + std::string get_element_name(int n) const; DCSubatomicType get_element_type(int n) const; int get_element_divisor(int n) const; public: void add_element(DCParameter *element); - virtual void output(ostream &out, bool brief) const; - virtual void write(ostream &out, bool brief, int indent_level) const; + virtual void output(std::ostream &out, bool brief) const; + virtual void write(std::ostream &out, bool brief, int indent_level) const; virtual void generate_hash(HashGenerator &hashgen) const; virtual DCPackerInterface *get_nested_field(int n) const; @@ -60,7 +60,7 @@ protected: virtual bool do_check_match_atomic_field(const DCAtomicField *other) const; private: - void output_element(ostream &out, bool brief, DCParameter *element) const; + void output_element(std::ostream &out, bool brief, DCParameter *element) const; typedef pvector Elements; Elements _elements; diff --git a/direct/src/dcparser/dcClass.I b/direct/src/dcparser/dcClass.I index a33fe53bc5..edba84f726 100644 --- a/direct/src/dcparser/dcClass.I +++ b/direct/src/dcparser/dcClass.I @@ -22,7 +22,7 @@ get_dc_file() const { /** * Returns the name of this class. */ -INLINE const string &DCClass:: +INLINE const std::string &DCClass:: get_name() const { return _name; } diff --git a/direct/src/dcparser/dcClass.h b/direct/src/dcparser/dcClass.h index 73ad9e43d3..9f7945b372 100644 --- a/direct/src/dcparser/dcClass.h +++ b/direct/src/dcparser/dcClass.h @@ -43,7 +43,7 @@ class DCParameter; */ class DCClass : public DCDeclaration { public: - DCClass(DCFile *dc_file, const string &name, + DCClass(DCFile *dc_file, const std::string &name, bool is_struct, bool bogus_class); ~DCClass(); @@ -53,7 +53,7 @@ PUBLISHED: INLINE DCFile *get_dc_file() const; - INLINE const string &get_name() const; + INLINE const std::string &get_name() const; INLINE int get_number() const; int get_num_parents() const; @@ -65,7 +65,7 @@ PUBLISHED: int get_num_fields() const; DCField *get_field(int n) const; - DCField *get_field_by_name(const string &name) const; + DCField *get_field_by_name(const std::string &name) const; DCField *get_field_by_index(int index_number) const; int get_num_inherited_fields() const; @@ -78,7 +78,7 @@ PUBLISHED: INLINE void start_generate(); INLINE void stop_generate(); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; #ifdef HAVE_PYTHON bool has_class_def() const; @@ -94,9 +94,9 @@ PUBLISHED: void receive_update_all_required(PyObject *distobj, DatagramIterator &di) const; void receive_update_other(PyObject *distobj, DatagramIterator &di) const; - void direct_update(PyObject *distobj, const string &field_name, - const string &value_blob); - void direct_update(PyObject *distobj, const string &field_name, + void direct_update(PyObject *distobj, const std::string &field_name, + const std::string &value_blob); + void direct_update(PyObject *distobj, const std::string &field_name, const Datagram &datagram); bool pack_required_field(Datagram &datagram, PyObject *distobj, const DCField *field) const; @@ -105,11 +105,11 @@ PUBLISHED: - Datagram client_format_update(const string &field_name, + Datagram client_format_update(const std::string &field_name, DOID_TYPE do_id, PyObject *args) const; - Datagram ai_format_update(const string &field_name, DOID_TYPE do_id, + Datagram ai_format_update(const std::string &field_name, DOID_TYPE do_id, CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, PyObject *args) const; - Datagram ai_format_update_msg_type(const string &field_name, DOID_TYPE do_id, + Datagram ai_format_update_msg_type(const std::string &field_name, DOID_TYPE do_id, CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, int msg_type, PyObject *args) const; Datagram ai_format_generate(PyObject *distobj, DOID_TYPE do_id, ZONEID_TYPE parent_id, ZONEID_TYPE zone_id, CHANNEL_TYPE district_channel_id, CHANNEL_TYPE from_channel_id, @@ -120,10 +120,10 @@ PUBLISHED: #endif public: - virtual void output(ostream &out, bool brief) const; - virtual void write(ostream &out, bool brief, int indent_level) const; - void output_instance(ostream &out, bool brief, const string &prename, - const string &name, const string &postname) const; + virtual void output(std::ostream &out, bool brief) const; + virtual void write(std::ostream &out, bool brief, int indent_level) const; + void output_instance(std::ostream &out, bool brief, const std::string &prename, + const std::string &name, const std::string &postname) const; void generate_hash(HashGenerator &hashgen) const; void clear_inherited_fields(); void rebuild_inherited_fields(); @@ -133,7 +133,7 @@ public: void set_number(int number); private: - void shadow_inherited_field(const string &name); + void shadow_inherited_field(const std::string &name); #ifdef WITHIN_PANDA PStatCollector _class_update_pcollector; @@ -144,7 +144,7 @@ private: DCFile *_dc_file; - string _name; + std::string _name; bool _is_struct; bool _bogus_class; int _number; @@ -157,7 +157,7 @@ private: typedef pvector Fields; Fields _fields, _inherited_fields; - typedef pmap FieldsByName; + typedef pmap FieldsByName; FieldsByName _fields_by_name; typedef pmap FieldsByIndex; diff --git a/direct/src/dcparser/dcClassParameter.h b/direct/src/dcparser/dcClassParameter.h index e846d48f88..3657190bf9 100644 --- a/direct/src/dcparser/dcClassParameter.h +++ b/direct/src/dcparser/dcClassParameter.h @@ -39,8 +39,8 @@ PUBLISHED: public: virtual DCPackerInterface *get_nested_field(int n) const; - virtual void output_instance(ostream &out, bool brief, const string &prename, - const string &name, const string &postname) const; + virtual void output_instance(std::ostream &out, bool brief, const std::string &prename, + const std::string &name, const std::string &postname) const; virtual void generate_hash(HashGenerator &hashgen) const; protected: diff --git a/direct/src/dcparser/dcDeclaration.h b/direct/src/dcparser/dcDeclaration.h index 218473aef4..0fd4392ca6 100644 --- a/direct/src/dcparser/dcDeclaration.h +++ b/direct/src/dcparser/dcDeclaration.h @@ -36,15 +36,15 @@ PUBLISHED: virtual DCSwitch *as_switch(); virtual const DCSwitch *as_switch() const; - virtual void output(ostream &out) const; - void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level) const; public: - virtual void output(ostream &out, bool brief) const=0; - virtual void write(ostream &out, bool brief, int indent_level) const=0; + virtual void output(std::ostream &out, bool brief) const=0; + virtual void write(std::ostream &out, bool brief, int indent_level) const=0; }; -INLINE ostream &operator << (ostream &out, const DCDeclaration &decl) { +INLINE std::ostream &operator << (std::ostream &out, const DCDeclaration &decl) { decl.output(out); return out; } diff --git a/direct/src/dcparser/dcField.I b/direct/src/dcparser/dcField.I index 24a14cff08..aabf5cf114 100644 --- a/direct/src/dcparser/dcField.I +++ b/direct/src/dcparser/dcField.I @@ -42,7 +42,7 @@ has_default_value() const { * explicitly set (e.g. has_default_value() returns true), returns that * value; otherwise, returns an implicit default for the field. */ -INLINE const string &DCField:: +INLINE const std::string &DCField:: get_default_value() const { if (_default_value_stale) { ((DCField *)this)->refresh_default_value(); @@ -138,7 +138,7 @@ is_airecv() const { * Write a string representation of this instance to . */ INLINE void DCField:: -output(ostream &out) const { +output(std::ostream &out) const { output(out, true); } @@ -146,7 +146,7 @@ output(ostream &out) const { * Write a string representation of this instance to . */ INLINE void DCField:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { write(out, false, indent_level); } @@ -172,7 +172,7 @@ set_class(DCClass *dclass) { * Establishes a default value for this field. */ INLINE void DCField:: -set_default_value(const string &default_value) { +set_default_value(const std::string &default_value) { _default_value = default_value; _has_default_value = true; _default_value_stale = false; diff --git a/direct/src/dcparser/dcField.h b/direct/src/dcparser/dcField.h index e7f2dbcd3c..6744ea93d4 100644 --- a/direct/src/dcparser/dcField.h +++ b/direct/src/dcparser/dcField.h @@ -37,7 +37,7 @@ class HashGenerator; class DCField : public DCPackerInterface, public DCKeywordList { public: DCField(); - DCField(const string &name, DCClass *dclass); + DCField(const std::string &name, DCClass *dclass); virtual ~DCField(); PUBLISHED: @@ -53,13 +53,13 @@ PUBLISHED: virtual DCParameter *as_parameter(); virtual const DCParameter *as_parameter() const; - string format_data(const string &packed_data, bool show_field_names = true); - string parse_string(const string &formatted_string); + std::string format_data(const std::string &packed_data, bool show_field_names = true); + std::string parse_string(const std::string &formatted_string); - bool validate_ranges(const string &packed_data) const; + bool validate_ranges(const std::string &packed_data) const; INLINE bool has_default_value() const; - INLINE const string &get_default_value() const; + INLINE const std::string &get_default_value() const; INLINE bool is_bogus_field() const; @@ -73,8 +73,8 @@ PUBLISHED: INLINE bool is_ownrecv() const; INLINE bool is_airecv() const; - INLINE void output(ostream &out) const; - INLINE void write(ostream &out, int indent_level) const; + INLINE void output(std::ostream &out) const; + INLINE void write(std::ostream &out, int indent_level) const; #ifdef HAVE_PYTHON bool pack_args(DCPacker &packer, PyObject *sequence) const; @@ -90,18 +90,18 @@ PUBLISHED: #endif public: - virtual void output(ostream &out, bool brief) const=0; - virtual void write(ostream &out, bool brief, int indent_level) const=0; + virtual void output(std::ostream &out, bool brief) const=0; + virtual void write(std::ostream &out, bool brief, int indent_level) const=0; virtual void generate_hash(HashGenerator &hashgen) const; virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const; - virtual void set_name(const string &name); + virtual void set_name(const std::string &name); INLINE void set_number(int number); INLINE void set_class(DCClass *dclass); - INLINE void set_default_value(const string &default_value); + INLINE void set_default_value(const std::string &default_value); #ifdef HAVE_PYTHON - static string get_pystr(PyObject *value); + static std::string get_pystr(PyObject *value); #endif protected: @@ -115,14 +115,14 @@ protected: bool _bogus_field; private: - string _default_value; + std::string _default_value; #ifdef WITHIN_PANDA PStatCollector _field_update_pcollector; #endif }; -INLINE ostream &operator << (ostream &out, const DCField &field) { +INLINE std::ostream &operator << (std::ostream &out, const DCField &field) { field.output(out); return out; } diff --git a/direct/src/dcparser/dcFile.h b/direct/src/dcparser/dcFile.h index 8ad67e1ace..7d7550804f 100644 --- a/direct/src/dcparser/dcFile.h +++ b/direct/src/dcparser/dcFile.h @@ -41,32 +41,32 @@ PUBLISHED: #endif bool read(Filename filename); - bool read(istream &in, const string &filename = string()); + bool read(std::istream &in, const std::string &filename = std::string()); bool write(Filename filename, bool brief) const; - bool write(ostream &out, bool brief) const; + bool write(std::ostream &out, bool brief) const; int get_num_classes() const; DCClass *get_class(int n) const; - DCClass *get_class_by_name(const string &name) const; - DCSwitch *get_switch_by_name(const string &name) const; + DCClass *get_class_by_name(const std::string &name) const; + DCSwitch *get_switch_by_name(const std::string &name) const; DCField *get_field_by_index(int index_number) const; INLINE bool all_objects_valid() const; int get_num_import_modules() const; - string get_import_module(int n) const; + std::string get_import_module(int n) const; int get_num_import_symbols(int n) const; - string get_import_symbol(int n, int i) const; + std::string get_import_symbol(int n, int i) const; int get_num_typedefs() const; DCTypedef *get_typedef(int n) const; - DCTypedef *get_typedef_by_name(const string &name) const; + DCTypedef *get_typedef_by_name(const std::string &name) const; int get_num_keywords() const; const DCKeyword *get_keyword(int n) const; - const DCKeyword *get_keyword_by_name(const string &name) const; + const DCKeyword *get_keyword_by_name(const std::string &name) const; unsigned long get_hash() const; @@ -74,10 +74,10 @@ public: void generate_hash(HashGenerator &hashgen) const; bool add_class(DCClass *dclass); bool add_switch(DCSwitch *dswitch); - void add_import_module(const string &import_module); - void add_import_symbol(const string &import_symbol); + void add_import_module(const std::string &import_module); + void add_import_symbol(const std::string &import_symbol); bool add_typedef(DCTypedef *dtypedef); - bool add_keyword(const string &name); + bool add_keyword(const std::string &name); void add_thing_to_delete(DCDeclaration *decl); void set_new_index_number(DCField *field); @@ -91,13 +91,13 @@ private: typedef pvector Classes; Classes _classes; - typedef pmap ThingsByName; + typedef pmap ThingsByName; ThingsByName _things_by_name; - typedef pvector ImportSymbols; + typedef pvector ImportSymbols; class Import { public: - string _module; + std::string _module; ImportSymbols _symbols; }; @@ -107,7 +107,7 @@ private: typedef pvector Typedefs; Typedefs _typedefs; - typedef pmap TypedefsByName; + typedef pmap TypedefsByName; TypedefsByName _typedefs_by_name; DCKeywordList _keywords; diff --git a/direct/src/dcparser/dcKeyword.h b/direct/src/dcparser/dcKeyword.h index 76c212c093..a82bd1ef0f 100644 --- a/direct/src/dcparser/dcKeyword.h +++ b/direct/src/dcparser/dcKeyword.h @@ -27,22 +27,22 @@ class HashGenerator; */ class DCKeyword : public DCDeclaration { public: - DCKeyword(const string &name, int historical_flag = ~0); + DCKeyword(const std::string &name, int historical_flag = ~0); virtual ~DCKeyword(); PUBLISHED: - const string &get_name() const; + const std::string &get_name() const; public: int get_historical_flag() const; void clear_historical_flag(); - virtual void output(ostream &out, bool brief) const; - virtual void write(ostream &out, bool brief, int indent_level) const; + virtual void output(std::ostream &out, bool brief) const; + virtual void write(std::ostream &out, bool brief, int indent_level) const; void generate_hash(HashGenerator &hashgen) const; private: - const string _name; + const std::string _name; // This flag is only kept for historical reasons, so we can preserve the // file's hash code if no new flags are in use. diff --git a/direct/src/dcparser/dcKeywordList.h b/direct/src/dcparser/dcKeywordList.h index ada61ffaa0..d9905c64db 100644 --- a/direct/src/dcparser/dcKeywordList.h +++ b/direct/src/dcparser/dcKeywordList.h @@ -31,11 +31,11 @@ public: ~DCKeywordList(); PUBLISHED: - bool has_keyword(const string &name) const; + bool has_keyword(const std::string &name) const; bool has_keyword(const DCKeyword *keyword) const; int get_num_keywords() const; const DCKeyword *get_keyword(int n) const; - const DCKeyword *get_keyword_by_name(const string &name) const; + const DCKeyword *get_keyword_by_name(const std::string &name) const; bool compare_keywords(const DCKeywordList &other) const; @@ -45,14 +45,14 @@ public: bool add_keyword(const DCKeyword *keyword); void clear_keywords(); - void output_keywords(ostream &out) const; + void output_keywords(std::ostream &out) const; void generate_hash(HashGenerator &hashgen) const; private: typedef pvector Keywords; Keywords _keywords; - typedef pmap KeywordsByName; + typedef pmap KeywordsByName; KeywordsByName _keywords_by_name; int _flags; diff --git a/direct/src/dcparser/dcLexerDefs.h b/direct/src/dcparser/dcLexerDefs.h index 8c480ad98a..eb6b517045 100644 --- a/direct/src/dcparser/dcLexerDefs.h +++ b/direct/src/dcparser/dcLexerDefs.h @@ -16,14 +16,14 @@ #include "dcbase.h" -void dc_init_lexer(istream &in, const string &filename); +void dc_init_lexer(std::istream &in, const std::string &filename); void dc_start_parameter_value(); void dc_start_parameter_description(); int dc_error_count(); int dc_warning_count(); -void dcyyerror(const string &msg); -void dcyywarning(const string &msg); +void dcyyerror(const std::string &msg); +void dcyywarning(const std::string &msg); int dcyylex(); diff --git a/direct/src/dcparser/dcMolecularField.h b/direct/src/dcparser/dcMolecularField.h index 6d532a1b23..db7d850e00 100644 --- a/direct/src/dcparser/dcMolecularField.h +++ b/direct/src/dcparser/dcMolecularField.h @@ -27,7 +27,7 @@ class DCParameter; */ class DCMolecularField : public DCField { public: - DCMolecularField(const string &name, DCClass *dclass); + DCMolecularField(const std::string &name, DCClass *dclass); PUBLISHED: virtual DCMolecularField *as_molecular_field(); @@ -39,8 +39,8 @@ PUBLISHED: public: void add_atomic(DCAtomicField *atomic); - virtual void output(ostream &out, bool brief) const; - virtual void write(ostream &out, bool brief, int indent_level) const; + virtual void output(std::ostream &out, bool brief) const; + virtual void write(std::ostream &out, bool brief, int indent_level) const; virtual void generate_hash(HashGenerator &hashgen) const; virtual DCPackerInterface *get_nested_field(int n) const; diff --git a/direct/src/dcparser/dcNumericRange.I b/direct/src/dcparser/dcNumericRange.I index 8983204d48..bd41418205 100644 --- a/direct/src/dcparser/dcNumericRange.I +++ b/direct/src/dcparser/dcNumericRange.I @@ -125,7 +125,7 @@ generate_hash(HashGenerator &hashgen) const { */ template void DCNumericRange:: -output(ostream &out, Number divisor) const { +output(std::ostream &out, Number divisor) const { if (!_ranges.empty()) { typename Ranges::const_iterator ri; ri = _ranges.begin(); @@ -145,7 +145,7 @@ output(ostream &out, Number divisor) const { */ template void DCNumericRange:: -output_char(ostream &out, Number divisor) const { +output_char(std::ostream &out, Number divisor) const { if (divisor != 1) { output(out, divisor); @@ -248,7 +248,7 @@ get_max(int n) const { */ template INLINE void DCNumericRange:: -output_minmax(ostream &out, Number divisor, const MinMax &range) const { +output_minmax(std::ostream &out, Number divisor, const MinMax &range) const { if (divisor == 1) { if (range._min == range._max) { out << range._min; @@ -271,12 +271,12 @@ output_minmax(ostream &out, Number divisor, const MinMax &range) const { */ template INLINE void DCNumericRange:: -output_minmax_char(ostream &out, const MinMax &range) const { +output_minmax_char(std::ostream &out, const MinMax &range) const { if (range._min == range._max) { - DCPacker::enquote_string(out, '\'', string(1, range._min)); + DCPacker::enquote_string(out, '\'', std::string(1, range._min)); } else { - DCPacker::enquote_string(out, '\'', string(1, range._min)); + DCPacker::enquote_string(out, '\'', std::string(1, range._min)); out << "-"; - DCPacker::enquote_string(out, '\'', string(1, range._max)); + DCPacker::enquote_string(out, '\'', std::string(1, range._max)); } } diff --git a/direct/src/dcparser/dcNumericRange.h b/direct/src/dcparser/dcNumericRange.h index 6539c05422..b3450f89e4 100644 --- a/direct/src/dcparser/dcNumericRange.h +++ b/direct/src/dcparser/dcNumericRange.h @@ -40,8 +40,8 @@ public: void generate_hash(HashGenerator &hashgen) const; - void output(ostream &out, Number divisor = 1) const; - void output_char(ostream &out, Number divisor = 1) const; + void output(std::ostream &out, Number divisor = 1) const; + void output_char(std::ostream &out, Number divisor = 1) const; public: INLINE void clear(); @@ -60,8 +60,8 @@ private: Number _min; Number _max; }; - INLINE void output_minmax(ostream &out, Number divisor, const MinMax &range) const; - INLINE void output_minmax_char(ostream &out, const MinMax &range) const; + INLINE void output_minmax(std::ostream &out, Number divisor, const MinMax &range) const; + INLINE void output_minmax_char(std::ostream &out, const MinMax &range) const; typedef pvector Ranges; Ranges _ranges; diff --git a/direct/src/dcparser/dcPackData.I b/direct/src/dcparser/dcPackData.I index e1523f09ad..ac68d40313 100644 --- a/direct/src/dcparser/dcPackData.I +++ b/direct/src/dcparser/dcPackData.I @@ -89,9 +89,9 @@ get_rewrite_pointer(size_t position, size_t size) { /** * Returns the data buffer as a string. Also see get_data(). */ -INLINE string DCPackData:: +INLINE std::string DCPackData:: get_string() const { - return string(_buffer, _used_length); + return std::string(_buffer, _used_length); } /** diff --git a/direct/src/dcparser/dcPackData.h b/direct/src/dcparser/dcPackData.h index 99cd0abbd5..7f891a1d5d 100644 --- a/direct/src/dcparser/dcPackData.h +++ b/direct/src/dcparser/dcPackData.h @@ -34,7 +34,7 @@ public: INLINE char *get_rewrite_pointer(size_t position, size_t size); PUBLISHED: - INLINE string get_string() const; + INLINE std::string get_string() const; INLINE size_t get_length() const; public: INLINE const char *get_data() const; diff --git a/direct/src/dcparser/dcPacker.I b/direct/src/dcparser/dcPacker.I index 9bb4607dd6..8c640d77b1 100644 --- a/direct/src/dcparser/dcPacker.I +++ b/direct/src/dcparser/dcPacker.I @@ -123,10 +123,10 @@ get_pack_type() const { * Returns the name of the current field, if it has a name, or the empty * string if the field does not have a name or there is no current field. */ -INLINE string DCPacker:: +INLINE std::string DCPacker:: get_current_field_name() const { if (_current_field == nullptr) { - return string(); + return std::string(); } else { return _current_field->get_name(); } @@ -206,7 +206,7 @@ pack_uint64(uint64_t value) { * Packs the indicated numeric or string value into the stream. */ INLINE void DCPacker:: -pack_string(const string &value) { +pack_string(const std::string &value) { nassertv(_mode == M_pack || _mode == M_repack); if (_current_field == nullptr) { _pack_error = true; @@ -221,7 +221,7 @@ pack_string(const string &value) { * packed field element, or a whole group of field elements at once. */ INLINE void DCPacker:: -pack_literal_value(const string &value) { +pack_literal_value(const std::string &value) { nassertv(_mode == M_pack || _mode == M_repack); if (_current_field == nullptr) { _pack_error = true; @@ -329,9 +329,9 @@ unpack_uint64() { /** * Unpacks the current numeric or string value from the stream. */ -INLINE string DCPacker:: +INLINE std::string DCPacker:: unpack_string() { - string value; + std::string value; nassertr(_mode == M_unpack, value); if (_current_field == nullptr) { _pack_error = true; @@ -349,12 +349,12 @@ unpack_string() { * Returns the literal string that represents the packed value of the current * field, and advances the field pointer. */ -INLINE string DCPacker:: +INLINE std::string DCPacker:: unpack_literal_value() { size_t start = _unpack_p; unpack_skip(); - nassertr(_unpack_p >= start, string()); - return string(_unpack_data + start, _unpack_p - start); + nassertr(_unpack_p >= start, std::string()); + return std::string(_unpack_data + start, _unpack_p - start); } /** @@ -441,7 +441,7 @@ unpack_uint64(uint64_t &value) { * Unpacks the current numeric or string value from the stream. */ INLINE void DCPacker:: -unpack_string(string &value) { +unpack_string(std::string &value) { nassertv(_mode == M_unpack); if (_current_field == nullptr) { _pack_error = true; @@ -458,7 +458,7 @@ unpack_string(string &value) { * field, and advances the field pointer. */ INLINE void DCPacker:: -unpack_literal_value(string &value) { +unpack_literal_value(std::string &value) { size_t start = _unpack_p; unpack_skip(); nassertv(_unpack_p >= start); @@ -536,7 +536,7 @@ get_length() const { /** * Returns the packed data buffer as a string. Also see get_data(). */ -INLINE string DCPacker:: +INLINE std::string DCPacker:: get_string() const { return _pack_data.get_string(); } @@ -556,16 +556,16 @@ get_unpack_length() const { * unpacking; it is separate from the pack data returned by get_string(), * which is filled during packing. Also see get_unpack_data(). */ -INLINE string DCPacker:: +INLINE std::string DCPacker:: get_unpack_string() const { - return string(_unpack_data, _unpack_length); + return std::string(_unpack_data, _unpack_length); } /** * Copies the packed data into the indicated string. Also see get_data(). */ INLINE void DCPacker:: -get_string(string &data) const { +get_string(std::string &data) const { data.assign(_pack_data.get_data(), _pack_data.get_length()); } @@ -722,7 +722,7 @@ raw_pack_float64(double value) { * Packs the data into the buffer between packing sessions. */ INLINE void DCPacker:: -raw_pack_string(const string &value) { +raw_pack_string(const std::string &value) { nassertv(_mode == M_idle); DCPackerInterface::do_pack_uint16(_pack_data.get_write_pointer(2), value.length()); _pack_data.append_data(value.data(), value.length()); @@ -863,9 +863,9 @@ raw_unpack_float64() { /** * Unpacks the data from the buffer between unpacking sessions. */ -INLINE string DCPacker:: +INLINE std::string DCPacker:: raw_unpack_string() { - string value; + std::string value; raw_unpack_string(value); return value; } @@ -958,7 +958,7 @@ raw_unpack_float64(double &value) { * Unpacks the data from the buffer between unpacking sessions. */ INLINE void DCPacker:: -raw_unpack_string(string &value) { +raw_unpack_string(std::string &value) { nassertv(_mode == M_idle && _unpack_data != nullptr); unsigned int string_length = raw_unpack_uint16(); diff --git a/direct/src/dcparser/dcPacker.h b/direct/src/dcparser/dcPacker.h index 380d40600c..9de32ff2cd 100644 --- a/direct/src/dcparser/dcPacker.h +++ b/direct/src/dcparser/dcPacker.h @@ -41,7 +41,7 @@ PUBLISHED: void begin_pack(const DCPackerInterface *root); bool end_pack(); - void set_unpack_data(const string &data); + void set_unpack_data(const std::string &data); public: void set_unpack_data(const char *unpack_data, size_t unpack_length, bool owns_unpack_data); @@ -53,7 +53,7 @@ PUBLISHED: void begin_repack(const DCPackerInterface *root); bool end_repack(); - bool seek(const string &field_name); + bool seek(const std::string &field_name); bool seek(int seek_index); INLINE bool has_nested_fields() const; @@ -64,7 +64,7 @@ PUBLISHED: INLINE const DCPackerInterface *get_current_field() const; INLINE const DCSwitchParameter *get_last_switch() const; INLINE DCPackType get_pack_type() const; - INLINE string get_current_field_name() const; + INLINE std::string get_current_field_name() const; void push(); void pop(); @@ -74,8 +74,8 @@ PUBLISHED: INLINE void pack_uint(unsigned int value); INLINE void pack_int64(int64_t value); INLINE void pack_uint64(uint64_t value); - INLINE void pack_string(const string &value); - INLINE void pack_literal_value(const string &value); + INLINE void pack_string(const std::string &value); + INLINE void pack_literal_value(const std::string &value); void pack_default_value(); INLINE double unpack_double(); @@ -83,8 +83,8 @@ PUBLISHED: INLINE unsigned int unpack_uint(); INLINE int64_t unpack_int64(); INLINE uint64_t unpack_uint64(); - INLINE string unpack_string(); - INLINE string unpack_literal_value(); + INLINE std::string unpack_string(); + INLINE std::string unpack_literal_value(); void unpack_validate(); void unpack_skip(); @@ -96,8 +96,8 @@ public: INLINE void unpack_uint(unsigned int &value); INLINE void unpack_int64(int64_t &value); INLINE void unpack_uint64(uint64_t &value); - INLINE void unpack_string(string &value); - INLINE void unpack_literal_value(string &value); + INLINE void unpack_string(std::string &value); + INLINE void unpack_literal_value(std::string &value); PUBLISHED: @@ -106,10 +106,10 @@ PUBLISHED: PyObject *unpack_object(); #endif - bool parse_and_pack(const string &formatted_object); - bool parse_and_pack(istream &in); - string unpack_and_format(bool show_field_names = true); - void unpack_and_format(ostream &out, bool show_field_names = true); + bool parse_and_pack(const std::string &formatted_object); + bool parse_and_pack(std::istream &in); + std::string unpack_and_format(bool show_field_names = true); + void unpack_and_format(std::ostream &out, bool show_field_names = true); INLINE bool had_parse_error() const; INLINE bool had_pack_error() const; @@ -118,11 +118,11 @@ PUBLISHED: INLINE size_t get_num_unpacked_bytes() const; INLINE size_t get_length() const; - INLINE string get_string() const; + INLINE std::string get_string() const; INLINE size_t get_unpack_length() const; - INLINE string get_unpack_string() const; + INLINE std::string get_unpack_string() const; public: - INLINE void get_string(string &data) const; + INLINE void get_string(std::string &data) const; INLINE const char *get_data() const; INLINE char *take_data(); @@ -147,7 +147,7 @@ PUBLISHED: INLINE void raw_pack_uint32(unsigned int value); INLINE void raw_pack_uint64(uint64_t value); INLINE void raw_pack_float64(double value); - INLINE void raw_pack_string(const string &value); + INLINE void raw_pack_string(const std::string &value); // this is a hack to allw me to get in and out of 32bit Mode Faster need to // agree with channel_type in dcbase.h @@ -164,7 +164,7 @@ PUBLISHED: INLINE unsigned int raw_unpack_uint32(); INLINE uint64_t raw_unpack_uint64(); INLINE double raw_unpack_float64(); - INLINE string raw_unpack_string(); + INLINE std::string raw_unpack_string(); public: INLINE void raw_unpack_int8(int &value); @@ -176,11 +176,11 @@ public: INLINE void raw_unpack_uint32(unsigned int &value); INLINE void raw_unpack_uint64(uint64_t &value); INLINE void raw_unpack_float64(double &value); - INLINE void raw_unpack_string(string &value); + INLINE void raw_unpack_string(std::string &value); public: - static void enquote_string(ostream &out, char quote_mark, const string &str); - static void output_hex_string(ostream &out, const string &str); + static void enquote_string(std::ostream &out, char quote_mark, const std::string &str); + static void output_hex_string(std::ostream &out, const std::string &str); private: INLINE void advance(); diff --git a/direct/src/dcparser/dcPackerCatalog.I b/direct/src/dcparser/dcPackerCatalog.I index 657609927d..1755db75e8 100644 --- a/direct/src/dcparser/dcPackerCatalog.I +++ b/direct/src/dcparser/dcPackerCatalog.I @@ -52,7 +52,7 @@ get_entry(int n) const { * get_entry(). */ int DCPackerCatalog::LiveCatalog:: -find_entry_by_name(const string &name) const { +find_entry_by_name(const std::string &name) const { return _catalog->find_entry_by_name(name); } diff --git a/direct/src/dcparser/dcPackerCatalog.h b/direct/src/dcparser/dcPackerCatalog.h index 71469d6744..c03b1b5fc6 100644 --- a/direct/src/dcparser/dcPackerCatalog.h +++ b/direct/src/dcparser/dcPackerCatalog.h @@ -37,7 +37,7 @@ public: // and its relationship to its parent. class Entry { public: - string _name; + std::string _name; const DCPackerInterface *_field; const DCPackerInterface *_parent; int _field_index; @@ -58,7 +58,7 @@ public: INLINE int get_num_entries() const; INLINE const Entry &get_entry(int n) const; - INLINE int find_entry_by_name(const string &name) const; + INLINE int find_entry_by_name(const std::string &name) const; INLINE int find_entry_by_field(const DCPackerInterface *field) const; private: @@ -71,17 +71,17 @@ public: INLINE int get_num_entries() const; INLINE const Entry &get_entry(int n) const; - int find_entry_by_name(const string &name) const; + int find_entry_by_name(const std::string &name) const; int find_entry_by_field(const DCPackerInterface *field) const; const LiveCatalog *get_live_catalog(const char *data, size_t length) const; void release_live_catalog(const LiveCatalog *live_catalog) const; private: - void add_entry(const string &name, const DCPackerInterface *field, + void add_entry(const std::string &name, const DCPackerInterface *field, const DCPackerInterface *parent, int field_index); - void r_fill_catalog(const string &name_prefix, const DCPackerInterface *field, + void r_fill_catalog(const std::string &name_prefix, const DCPackerInterface *field, const DCPackerInterface *parent, int field_index); void r_fill_live_catalog(LiveCatalog *live_catalog, DCPacker &packer, const DCSwitchParameter *&last_switch) const; @@ -96,7 +96,7 @@ private: typedef pvector Entries; Entries _entries; - typedef pmap EntriesByName; + typedef pmap EntriesByName; EntriesByName _entries_by_name; typedef pmap EntriesByField; @@ -105,7 +105,7 @@ private: typedef pmap SwitchCatalogs; SwitchCatalogs _switch_catalogs; - typedef pmap SwitchPrefixes; + typedef pmap SwitchPrefixes; SwitchPrefixes _switch_prefixes; friend class DCPackerInterface; diff --git a/direct/src/dcparser/dcPackerInterface.I b/direct/src/dcparser/dcPackerInterface.I index a97964bc47..160cc4fdd9 100644 --- a/direct/src/dcparser/dcPackerInterface.I +++ b/direct/src/dcparser/dcPackerInterface.I @@ -14,7 +14,7 @@ /** * Returns the name of this field, or empty string if the field is unnamed. */ -INLINE const string &DCPackerInterface:: +INLINE const std::string &DCPackerInterface:: get_name() const { return _name; } diff --git a/direct/src/dcparser/dcPackerInterface.h b/direct/src/dcparser/dcPackerInterface.h index 0157d3c5ce..171ed3f0ca 100644 --- a/direct/src/dcparser/dcPackerInterface.h +++ b/direct/src/dcparser/dcPackerInterface.h @@ -66,13 +66,13 @@ END_PUBLISH */ class DCPackerInterface { public: - DCPackerInterface(const string &name = string()); + DCPackerInterface(const std::string &name = std::string()); DCPackerInterface(const DCPackerInterface ©); virtual ~DCPackerInterface(); PUBLISHED: - INLINE const string &get_name() const; - int find_seek_index(const string &name) const; + INLINE const std::string &get_name() const; + int find_seek_index(const std::string &name) const; virtual DCField *as_field(); virtual const DCField *as_field() const; @@ -82,10 +82,10 @@ PUBLISHED: virtual const DCClassParameter *as_class_parameter() const; INLINE bool check_match(const DCPackerInterface *other) const; - bool check_match(const string &description, DCFile *dcfile = nullptr) const; + bool check_match(const std::string &description, DCFile *dcfile = nullptr) const; public: - virtual void set_name(const string &name); + virtual void set_name(const std::string &name); INLINE bool has_fixed_byte_size() const; INLINE size_t get_fixed_byte_size() const; INLINE bool has_fixed_structure() const; @@ -111,7 +111,7 @@ public: bool &pack_error, bool &range_error) const; virtual void pack_uint64(DCPackData &pack_data, uint64_t value, bool &pack_error, bool &range_error) const; - virtual void pack_string(DCPackData &pack_data, const string &value, + virtual void pack_string(DCPackData &pack_data, const std::string &value, bool &pack_error, bool &range_error) const; virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const; @@ -126,7 +126,7 @@ public: virtual void unpack_uint64(const char *data, size_t length, size_t &p, uint64_t &value, bool &pack_error, bool &range_error) const; virtual void unpack_string(const char *data, size_t length, size_t &p, - string &value, bool &pack_error, bool &range_error) const; + std::string &value, bool &pack_error, bool &range_error) const; virtual bool unpack_validate(const char *data, size_t length, size_t &p, bool &pack_error, bool &range_error) const; virtual bool unpack_skip(const char *data, size_t length, size_t &p, @@ -184,7 +184,7 @@ private: void make_catalog(); protected: - string _name; + std::string _name; bool _has_fixed_byte_size; size_t _fixed_byte_size; bool _has_fixed_structure; diff --git a/direct/src/dcparser/dcParameter.h b/direct/src/dcparser/dcParameter.h index 6c8ae910a6..59a34dc440 100644 --- a/direct/src/dcparser/dcParameter.h +++ b/direct/src/dcparser/dcParameter.h @@ -60,18 +60,18 @@ public: void set_typedef(const DCTypedef *dtypedef); virtual DCParameter *append_array_specification(const DCUnsignedIntRange &size); - virtual void output(ostream &out, bool brief) const; - virtual void write(ostream &out, bool brief, int indent_level) const; - virtual void output_instance(ostream &out, bool brief, const string &prename, - const string &name, const string &postname) const=0; - virtual void write_instance(ostream &out, bool brief, int indent_level, - const string &prename, const string &name, - const string &postname) const; - void output_typedef_name(ostream &out, bool brief, const string &prename, - const string &name, const string &postname) const; - void write_typedef_name(ostream &out, bool brief, int indent_level, - const string &prename, const string &name, - const string &postname) const; + virtual void output(std::ostream &out, bool brief) const; + virtual void write(std::ostream &out, bool brief, int indent_level) const; + virtual void output_instance(std::ostream &out, bool brief, const std::string &prename, + const std::string &name, const std::string &postname) const=0; + virtual void write_instance(std::ostream &out, bool brief, int indent_level, + const std::string &prename, const std::string &name, + const std::string &postname) const; + void output_typedef_name(std::ostream &out, bool brief, const std::string &prename, + const std::string &name, const std::string &postname) const; + void write_typedef_name(std::ostream &out, bool brief, int indent_level, + const std::string &prename, const std::string &name, + const std::string &postname) const; virtual void generate_hash(HashGenerator &hashgen) const; private: diff --git a/direct/src/dcparser/dcParserDefs.h b/direct/src/dcparser/dcParserDefs.h index fec0ab95a5..da1747ab15 100644 --- a/direct/src/dcparser/dcParserDefs.h +++ b/direct/src/dcparser/dcParserDefs.h @@ -26,10 +26,10 @@ class DCParameter; class DCKeyword; class DCPacker; -void dc_init_parser(istream &in, const string &filename, DCFile &file); -void dc_init_parser_parameter_value(istream &in, const string &filename, +void dc_init_parser(std::istream &in, const std::string &filename, DCFile &file); +void dc_init_parser_parameter_value(std::istream &in, const std::string &filename, DCPacker &packer); -void dc_init_parser_parameter_description(istream &in, const string &filename, +void dc_init_parser_parameter_description(std::istream &in, const std::string &filename, DCFile *file); DCField *dc_get_parameter_description(); void dc_cleanup_parser(); @@ -60,7 +60,7 @@ public: DCParameter *parameter; const DCKeyword *keyword; } u; - string str; + std::string str; }; // The yacc-generated code expects to use the symbol 'YYSTYPE' to refer to the diff --git a/direct/src/dcparser/dcSimpleParameter.h b/direct/src/dcparser/dcSimpleParameter.h index 5e2e39c498..b6da9a8bff 100644 --- a/direct/src/dcparser/dcSimpleParameter.h +++ b/direct/src/dcparser/dcSimpleParameter.h @@ -60,7 +60,7 @@ public: bool &pack_error, bool &range_error) const; virtual void pack_uint64(DCPackData &pack_data, uint64_t value, bool &pack_error, bool &range_error) const; - virtual void pack_string(DCPackData &pack_data, const string &value, + virtual void pack_string(DCPackData &pack_data, const std::string &value, bool &pack_error, bool &range_error) const; virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const; @@ -75,14 +75,14 @@ public: virtual void unpack_uint64(const char *data, size_t length, size_t &p, uint64_t &value, bool &pack_error, bool &range_error) const; virtual void unpack_string(const char *data, size_t length, size_t &p, - string &value, bool &pack_error, bool &range_error) const; + std::string &value, bool &pack_error, bool &range_error) const; virtual bool unpack_validate(const char *data, size_t length, size_t &p, bool &pack_error, bool &range_error) const; virtual bool unpack_skip(const char *data, size_t length, size_t &p, bool &pack_error) const; - virtual void output_instance(ostream &out, bool brief, const string &prename, - const string &name, const string &postname) const; + virtual void output_instance(std::ostream &out, bool brief, const std::string &prename, + const std::string &name, const std::string &postname) const; virtual void generate_hash(HashGenerator &hashgen) const; protected: diff --git a/direct/src/dcparser/dcSubatomicType.h b/direct/src/dcparser/dcSubatomicType.h index 383533857b..03b0f68fd4 100644 --- a/direct/src/dcparser/dcSubatomicType.h +++ b/direct/src/dcparser/dcSubatomicType.h @@ -60,6 +60,6 @@ enum DCSubatomicType { }; END_PUBLISH -ostream &operator << (ostream &out, DCSubatomicType type); +std::ostream &operator << (std::ostream &out, DCSubatomicType type); #endif diff --git a/direct/src/dcparser/dcSwitch.h b/direct/src/dcparser/dcSwitch.h index 77eefdbb6f..17e4e856a2 100644 --- a/direct/src/dcparser/dcSwitch.h +++ b/direct/src/dcparser/dcSwitch.h @@ -29,29 +29,29 @@ class DCField; */ class DCSwitch : public DCDeclaration { public: - DCSwitch(const string &name, DCField *key_parameter); + DCSwitch(const std::string &name, DCField *key_parameter); virtual ~DCSwitch(); PUBLISHED: virtual DCSwitch *as_switch(); virtual const DCSwitch *as_switch() const; - const string &get_name() const; + const std::string &get_name() const; DCField *get_key_parameter() const; int get_num_cases() const; - int get_case_by_value(const string &case_value) const; + int get_case_by_value(const std::string &case_value) const; DCPackerInterface *get_case(int n) const; DCPackerInterface *get_default_case() const; - string get_value(int case_index) const; + std::string get_value(int case_index) const; int get_num_fields(int case_index) const; DCField *get_field(int case_index, int n) const; - DCField *get_field_by_name(int case_index, const string &name) const; + DCField *get_field_by_name(int case_index, const std::string &name) const; public: bool is_field_valid() const; - int add_case(const string &value); + int add_case(const std::string &value); void add_invalid_case(); bool add_default(); bool add_field(DCField *field); @@ -59,13 +59,13 @@ public: const DCPackerInterface *apply_switch(const char *value_data, size_t length) const; - virtual void output(ostream &out, bool brief) const; - virtual void write(ostream &out, bool brief, int indent_level) const; - void output_instance(ostream &out, bool brief, const string &prename, - const string &name, const string &postname) const; - void write_instance(ostream &out, bool brief, int indent_level, - const string &prename, const string &name, - const string &postname) const; + virtual void output(std::ostream &out, bool brief) const; + virtual void write(std::ostream &out, bool brief, int indent_level) const; + void output_instance(std::ostream &out, bool brief, const std::string &prename, + const std::string &name, const std::string &postname) const; + void write_instance(std::ostream &out, bool brief, int indent_level, + const std::string &prename, const std::string &name, + const std::string &postname) const; virtual void generate_hash(HashGenerator &hashgen) const; virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const; @@ -73,19 +73,19 @@ public: public: typedef pvector Fields; - typedef pmap FieldsByName; + typedef pmap FieldsByName; class SwitchFields : public DCPackerInterface { public: - SwitchFields(const string &name); + SwitchFields(const std::string &name); ~SwitchFields(); virtual DCPackerInterface *get_nested_field(int n) const; bool add_field(DCField *field); bool do_check_match_switch_case(const SwitchFields *other) const; - void output(ostream &out, bool brief) const; - void write(ostream &out, bool brief, int indent_level) const; + void output(std::ostream &out, bool brief) const; + void write(std::ostream &out, bool brief, int indent_level) const; protected: virtual bool do_check_match(const DCPackerInterface *other) const; @@ -98,13 +98,13 @@ public: class SwitchCase { public: - SwitchCase(const string &value, SwitchFields *fields); + SwitchCase(const std::string &value, SwitchFields *fields); ~SwitchCase(); bool do_check_match_switch_case(const SwitchCase *other) const; public: - string _value; + std::string _value; SwitchFields *_fields; }; @@ -112,7 +112,7 @@ private: SwitchFields *start_new_case(); private: - string _name; + std::string _name; DCField *_key_parameter; typedef pvector Cases; @@ -137,7 +137,7 @@ private: bool _fields_added; // This map indexes into the _cases vector, above. - typedef pmap CasesByValue; + typedef pmap CasesByValue; CasesByValue _cases_by_value; }; diff --git a/direct/src/dcparser/dcSwitchParameter.h b/direct/src/dcparser/dcSwitchParameter.h index 0303af620f..51b8b673f6 100644 --- a/direct/src/dcparser/dcSwitchParameter.h +++ b/direct/src/dcparser/dcSwitchParameter.h @@ -41,11 +41,11 @@ public: const DCPackerInterface *apply_switch(const char *value_data, size_t length) const; - virtual void output_instance(ostream &out, bool brief, const string &prename, - const string &name, const string &postname) const; - virtual void write_instance(ostream &out, bool brief, int indent_level, - const string &prename, const string &name, - const string &postname) const; + virtual void output_instance(std::ostream &out, bool brief, const std::string &prename, + const std::string &name, const std::string &postname) const; + virtual void write_instance(std::ostream &out, bool brief, int indent_level, + const std::string &prename, const std::string &name, + const std::string &postname) const; virtual void generate_hash(HashGenerator &hashgen) const; virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const; diff --git a/direct/src/dcparser/dcTypedef.h b/direct/src/dcparser/dcTypedef.h index 62797fc8ff..654c8998a8 100644 --- a/direct/src/dcparser/dcTypedef.h +++ b/direct/src/dcparser/dcTypedef.h @@ -26,13 +26,13 @@ class DCParameter; class DCTypedef : public DCDeclaration { public: DCTypedef(DCParameter *parameter, bool implicit = false); - DCTypedef(const string &name); + DCTypedef(const std::string &name); virtual ~DCTypedef(); PUBLISHED: int get_number() const; - const string &get_name() const; - string get_description() const; + const std::string &get_name() const; + std::string get_description() const; bool is_bogus_typedef() const; bool is_implicit_typedef() const; @@ -41,8 +41,8 @@ public: DCParameter *make_new_parameter() const; void set_number(int number); - virtual void output(ostream &out, bool brief) const; - virtual void write(ostream &out, bool brief, int indent_level) const; + virtual void output(std::ostream &out, bool brief) const; + virtual void write(std::ostream &out, bool brief, int indent_level) const; private: DCParameter *_parameter; diff --git a/direct/src/dcparser/dcindent.h b/direct/src/dcparser/dcindent.h index 48cfddb7d7..a14f982199 100644 --- a/direct/src/dcparser/dcindent.h +++ b/direct/src/dcparser/dcindent.h @@ -29,8 +29,8 @@ * stream itself. Useful for indenting a series of lines of text by a given * amount. */ -ostream & -indent(ostream &out, int indent_level); +std::ostream & +indent(std::ostream &out, int indent_level); #endif // WITHIN_PANDA diff --git a/direct/src/dcparser/hashGenerator.h b/direct/src/dcparser/hashGenerator.h index 6137196a39..94031cd2f6 100644 --- a/direct/src/dcparser/hashGenerator.h +++ b/direct/src/dcparser/hashGenerator.h @@ -25,7 +25,7 @@ public: HashGenerator(); void add_int(int num); - void add_string(const string &str); + void add_string(const std::string &str); unsigned long get_hash() const; diff --git a/direct/src/dcparser/primeNumberGenerator.h b/direct/src/dcparser/primeNumberGenerator.h index d66a6f536d..8b24ae6b5c 100644 --- a/direct/src/dcparser/primeNumberGenerator.h +++ b/direct/src/dcparser/primeNumberGenerator.h @@ -22,7 +22,7 @@ #include "vector_int.h" #else -typedef vector vector_int; +typedef std::vector vector_int; #endif /** diff --git a/direct/src/deadrec/smoothMover.h b/direct/src/deadrec/smoothMover.h index aee12bca8e..f456f00518 100644 --- a/direct/src/deadrec/smoothMover.h +++ b/direct/src/deadrec/smoothMover.h @@ -137,8 +137,8 @@ PUBLISHED: INLINE void set_default_to_standing_still(bool flag); INLINE bool get_default_to_standing_still(); - void output(ostream &out) const; - void write(ostream &out) const; + void output(std::ostream &out) const; + void write(std::ostream &out) const; private: void set_smooth_pos(const LPoint3 &pos, const LVecBase3 &hpr, diff --git a/direct/src/directd/directd.h b/direct/src/directd/directd.h index 0623c09b4d..a1f4d34d09 100644 --- a/direct/src/directd/directd.h +++ b/direct/src/directd/directd.h @@ -73,7 +73,7 @@ PUBLISHED: * one command, you should use connect_to(), send_command(), and * disconnect_from(). */ - int client_ready(const string& server_host, int port, const string& cmd); + int client_ready(const std::string& server_host, int port, const std::string& cmd); /** * Tell the server to do the command cmd. cmd is one of the following: @@ -85,7 +85,7 @@ PUBLISHED: * client_ready(), it prefixes "!" for you. A new connection will be created * and closed. */ - int tell_server(const string& server_host, int port, const string& cmd); + int tell_server(const std::string& server_host, int port, const std::string& cmd); /** * Call this function from the client after calling client_ready() @@ -102,7 +102,7 @@ PUBLISHED: * Call this function from the server when import ShowbaseGlobal is nearly * finished. */ - int server_ready(const string& client_host, int port); + int server_ready(const std::string& client_host, int port); /** * Call connect_to from client for each server. returns the port number of @@ -110,28 +110,28 @@ PUBLISHED: * second argument). The return value can be used for the port arguemnt in * disconnect_from(). */ - int connect_to(const string& server_host, int port); + int connect_to(const std::string& server_host, int port); /** * This is the counterpart to connect_to(). Pass the same server_host as for * connect_to(), but pass the return value from connect_to() for the port, not * the port passed to connect_to(). */ - void disconnect_from(const string& server_host, int port); + void disconnect_from(const std::string& server_host, int port); /** * Send the same command string to all current connections. */ - void send_command(const string& cmd); + void send_command(const std::string& cmd); protected: - void start_app(const string& cmd); + void start_app(const std::string& cmd); void kill_app(int index); void kill_all(); - virtual void handle_command(const string& cmd); + virtual void handle_command(const std::string& cmd); void handle_datagram(NetDatagram& datagram); - void send_one_message(const string& host_name, - int port, const string& message); + void send_one_message(const std::string& host_name, + int port, const std::string& message); QueuedConnectionManager _cm; QueuedConnectionReader _reader; diff --git a/direct/src/directdServer/directdClient.h b/direct/src/directdServer/directdClient.h index 9c50908950..8c5dd03fc2 100644 --- a/direct/src/directdServer/directdClient.h +++ b/direct/src/directdServer/directdClient.h @@ -21,8 +21,8 @@ public: DirectDClient(); ~DirectDClient(); - void run_client(const string& host, int port); + void run_client(const std::string& host, int port); protected: - void cli_command(const string& cmd); + void cli_command(const std::string& cmd); }; diff --git a/direct/src/directdServer/directdServer.h b/direct/src/directdServer/directdServer.h index 767f34807a..ec76fff41d 100644 --- a/direct/src/directdServer/directdServer.h +++ b/direct/src/directdServer/directdServer.h @@ -29,6 +29,6 @@ public: void run_server(int port); protected: - void read_command(string& cmd); - virtual void handle_command(const string& cmd); + void read_command(std::string& cmd); + virtual void handle_command(const std::string& cmd); }; diff --git a/direct/src/distributed/cConnectionRepository.I b/direct/src/distributed/cConnectionRepository.I index 16e57ba432..7395a48c2d 100644 --- a/direct/src/distributed/cConnectionRepository.I +++ b/direct/src/distributed/cConnectionRepository.I @@ -220,7 +220,7 @@ get_msg_type() const { * Returns event string that will be thrown if the datagram reader queue * overflows. */ -INLINE const string &CConnectionRepository:: +INLINE const std::string &CConnectionRepository:: get_overflow_event_name() { return _overflow_event_name; } diff --git a/direct/src/distributed/cConnectionRepository.h b/direct/src/distributed/cConnectionRepository.h index 420c995e37..c67d4aad23 100644 --- a/direct/src/distributed/cConnectionRepository.h +++ b/direct/src/distributed/cConnectionRepository.h @@ -122,7 +122,7 @@ PUBLISHED: // INLINE unsigned char get_sec_code() const; BLOCKING INLINE unsigned int get_msg_type() const; - INLINE static const string &get_overflow_event_name(); + INLINE static const std::string &get_overflow_event_name(); BLOCKING bool is_connected(); @@ -161,7 +161,7 @@ private: bool handle_update_field(); bool handle_update_field_owner(); - void describe_message(ostream &out, const string &prefix, + void describe_message(std::ostream &out, const std::string &prefix, const Datagram &dg) const; private: @@ -205,11 +205,11 @@ private: CHANNEL_TYPE _msg_sender; unsigned int _msg_type; - static const string _overflow_event_name; + static const std::string _overflow_event_name; bool _want_message_bundling; unsigned int _bundling_msgs; - typedef std::vector< string > BundledMsgVector; + typedef std::vector< std::string > BundledMsgVector; BundledMsgVector _bundle_msgs; static PStatCollector _update_pcollector; diff --git a/direct/src/distributed/cDistributedSmoothNodeBase.h b/direct/src/distributed/cDistributedSmoothNodeBase.h index d2c43e285c..6c57f6a2bf 100644 --- a/direct/src/distributed/cDistributedSmoothNodeBase.h +++ b/direct/src/distributed/cDistributedSmoothNodeBase.h @@ -69,7 +69,7 @@ private: INLINE void d_setSmPosHpr(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); INLINE void d_setSmPosHprL(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, uint64_t l); - void begin_send_update(DCPacker &packer, const string &field_name); + void begin_send_update(DCPacker &packer, const std::string &field_name); void finish_send_update(DCPacker &packer); enum Flags { diff --git a/direct/src/interval/cConstrainHprInterval.h b/direct/src/interval/cConstrainHprInterval.h index 73c790100d..6338814b7d 100644 --- a/direct/src/interval/cConstrainHprInterval.h +++ b/direct/src/interval/cConstrainHprInterval.h @@ -26,7 +26,7 @@ */ class EXPCL_DIRECT_INTERVAL CConstrainHprInterval : public CConstraintInterval { PUBLISHED: - explicit CConstrainHprInterval(const string &name, double duration, + explicit CConstrainHprInterval(const std::string &name, double duration, const NodePath &node, const NodePath &target, bool wrt, const LVecBase3 hprOffset=LVector3::zero()); @@ -34,7 +34,7 @@ PUBLISHED: INLINE const NodePath &get_target() const; virtual void priv_step(double t); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: NodePath _node; diff --git a/direct/src/interval/cConstrainPosHprInterval.h b/direct/src/interval/cConstrainPosHprInterval.h index 44fedae0f6..a96aa097de 100644 --- a/direct/src/interval/cConstrainPosHprInterval.h +++ b/direct/src/interval/cConstrainPosHprInterval.h @@ -26,7 +26,7 @@ */ class EXPCL_DIRECT_INTERVAL CConstrainPosHprInterval : public CConstraintInterval { PUBLISHED: - explicit CConstrainPosHprInterval(const string &name, double duration, + explicit CConstrainPosHprInterval(const std::string &name, double duration, const NodePath &node, const NodePath &target, bool wrt, const LVecBase3 posOffset=LVector3::zero(), const LVecBase3 hprOffset=LVector3::zero()); @@ -35,7 +35,7 @@ PUBLISHED: INLINE const NodePath &get_target() const; virtual void priv_step(double t); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: NodePath _node; diff --git a/direct/src/interval/cConstrainPosInterval.h b/direct/src/interval/cConstrainPosInterval.h index 1e66d3aca0..edb379559f 100644 --- a/direct/src/interval/cConstrainPosInterval.h +++ b/direct/src/interval/cConstrainPosInterval.h @@ -25,7 +25,7 @@ */ class EXPCL_DIRECT_INTERVAL CConstrainPosInterval : public CConstraintInterval { PUBLISHED: - explicit CConstrainPosInterval(const string &name, double duration, + explicit CConstrainPosInterval(const std::string &name, double duration, const NodePath &node, const NodePath &target, bool wrt, const LVecBase3 posOffset=LVector3::zero()); @@ -33,7 +33,7 @@ PUBLISHED: INLINE const NodePath &get_target() const; virtual void priv_step(double t); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: NodePath _node; diff --git a/direct/src/interval/cConstrainTransformInterval.h b/direct/src/interval/cConstrainTransformInterval.h index a4bb537ec1..41da174670 100644 --- a/direct/src/interval/cConstrainTransformInterval.h +++ b/direct/src/interval/cConstrainTransformInterval.h @@ -24,7 +24,7 @@ */ class EXPCL_DIRECT_INTERVAL CConstrainTransformInterval : public CConstraintInterval { PUBLISHED: - explicit CConstrainTransformInterval(const string &name, double duration, + explicit CConstrainTransformInterval(const std::string &name, double duration, const NodePath &node, const NodePath &target, bool wrt); @@ -32,7 +32,7 @@ PUBLISHED: INLINE const NodePath &get_target() const; virtual void priv_step(double t); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: NodePath _node; diff --git a/direct/src/interval/cConstraintInterval.h b/direct/src/interval/cConstraintInterval.h index 96a47946ec..97a174b51f 100644 --- a/direct/src/interval/cConstraintInterval.h +++ b/direct/src/interval/cConstraintInterval.h @@ -26,7 +26,7 @@ PUBLISHED: bool bogus_variable; public: - CConstraintInterval(const string &name, double duration); + CConstraintInterval(const std::string &name, double duration); public: static TypeHandle get_class_type() { diff --git a/direct/src/interval/cInterval.I b/direct/src/interval/cInterval.I index 7650bddbee..f42fe8e62a 100644 --- a/direct/src/interval/cInterval.I +++ b/direct/src/interval/cInterval.I @@ -14,7 +14,7 @@ /** * Returns the interval's name. */ -INLINE const string &CInterval:: +INLINE const std::string &CInterval:: get_name() const { return _name; } @@ -64,7 +64,7 @@ is_stopped() const { * own. */ INLINE void CInterval:: -set_done_event(const string &event) { +set_done_event(const std::string &event) { _done_event = event; } @@ -73,7 +73,7 @@ set_done_event(const string &event) { * state, whether it is explicitly finished or whether it gets there on its * own. */ -INLINE const string &CInterval:: +INLINE const std::string &CInterval:: get_done_event() const { return _done_event; } @@ -219,8 +219,8 @@ check_started(TypeHandle type, const char *method_name) const { } } -INLINE ostream & -operator << (ostream &out, const CInterval &ival) { +INLINE std::ostream & +operator << (std::ostream &out, const CInterval &ival) { ival.output(out); return out; } diff --git a/direct/src/interval/cInterval.h b/direct/src/interval/cInterval.h index 07672f352f..979dba4547 100644 --- a/direct/src/interval/cInterval.h +++ b/direct/src/interval/cInterval.h @@ -34,11 +34,11 @@ class CIntervalManager; */ class EXPCL_DIRECT_INTERVAL CInterval : public TypedReferenceCount { public: - CInterval(const string &name, double duration, bool open_ended); + CInterval(const std::string &name, double duration, bool open_ended); virtual ~CInterval(); PUBLISHED: - INLINE const string &get_name() const; + INLINE const std::string &get_name() const; INLINE double get_duration() const; INLINE bool get_open_ended() const; @@ -63,8 +63,8 @@ PUBLISHED: INLINE State get_state() const; INLINE bool is_stopped() const; - INLINE void set_done_event(const string &event); - INLINE const string &get_done_event() const; + INLINE void set_done_event(const std::string &event); + INLINE const std::string &get_done_event() const; void set_t(double t); INLINE double get_t() const; @@ -110,8 +110,8 @@ PUBLISHED: virtual void priv_reverse_finalize(); virtual void priv_interrupt(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; void setup_play(double start_time, double end_time, double play_rate, bool do_loop); @@ -147,9 +147,9 @@ protected: State _state; double _curr_t; - string _name; - string _pname; - string _done_event; + std::string _name; + std::string _pname; + std::string _done_event; double _duration; bool _auto_pause; @@ -201,8 +201,8 @@ private: friend class CMetaInterval; }; -INLINE ostream &operator << (ostream &out, const CInterval &ival); -EXPCL_DIRECT_INTERVAL ostream &operator << (ostream &out, CInterval::State state); +INLINE std::ostream &operator << (std::ostream &out, const CInterval &ival); +EXPCL_DIRECT_INTERVAL std::ostream &operator << (std::ostream &out, CInterval::State state); #include "cInterval.I" diff --git a/direct/src/interval/cIntervalManager.I b/direct/src/interval/cIntervalManager.I index 44ca1062cc..c2622fb5e8 100644 --- a/direct/src/interval/cIntervalManager.I +++ b/direct/src/interval/cIntervalManager.I @@ -34,8 +34,8 @@ get_event_queue() const { return _event_queue; } -INLINE ostream & -operator << (ostream &out, const CIntervalManager &ival_mgr) { +INLINE std::ostream & +operator << (std::ostream &out, const CIntervalManager &ival_mgr) { ival_mgr.output(out); return out; } diff --git a/direct/src/interval/cIntervalManager.h b/direct/src/interval/cIntervalManager.h index d4279c25fb..33f3d29ff1 100644 --- a/direct/src/interval/cIntervalManager.h +++ b/direct/src/interval/cIntervalManager.h @@ -45,7 +45,7 @@ PUBLISHED: INLINE EventQueue *get_event_queue() const; int add_c_interval(CInterval *interval, bool external); - int find_c_interval(const string &name) const; + int find_c_interval(const std::string &name) const; CInterval *get_c_interval(int index) const; void remove_c_interval(int index); @@ -58,8 +58,8 @@ PUBLISHED: int get_next_event(); int get_next_removal(); - void output(ostream &out) const; - void write(ostream &out) const; + void output(std::ostream &out) const; + void write(std::ostream &out) const; static CIntervalManager *get_global_ptr(); @@ -79,7 +79,7 @@ private: }; typedef pvector Intervals; Intervals _intervals; - typedef pmap NameIndex; + typedef pmap NameIndex; NameIndex _name_index; typedef vector_int Removed; Removed _removed; @@ -93,7 +93,7 @@ private: static CIntervalManager *_global_ptr; }; -INLINE ostream &operator << (ostream &out, const CInterval &ival_mgr); +INLINE std::ostream &operator << (std::ostream &out, const CInterval &ival_mgr); #include "cIntervalManager.I" diff --git a/direct/src/interval/cLerpAnimEffectInterval.I b/direct/src/interval/cLerpAnimEffectInterval.I index cc9c42adf8..08c48949f2 100644 --- a/direct/src/interval/cLerpAnimEffectInterval.I +++ b/direct/src/interval/cLerpAnimEffectInterval.I @@ -15,7 +15,7 @@ * */ INLINE CLerpAnimEffectInterval:: -CLerpAnimEffectInterval(const string &name, double duration, +CLerpAnimEffectInterval(const std::string &name, double duration, CLerpInterval::BlendType blend_type) : CLerpInterval(name, duration, blend_type) { @@ -30,7 +30,7 @@ CLerpAnimEffectInterval(const string &name, double duration, * for output. */ INLINE void CLerpAnimEffectInterval:: -add_control(AnimControl *control, const string &name, +add_control(AnimControl *control, const std::string &name, float begin_effect, float end_effect) { _controls.push_back(ControlDef(control, name, begin_effect, end_effect)); } @@ -39,7 +39,7 @@ add_control(AnimControl *control, const string &name, * */ INLINE CLerpAnimEffectInterval::ControlDef:: -ControlDef(AnimControl *control, const string &name, +ControlDef(AnimControl *control, const std::string &name, float begin_effect, float end_effect) : _control(control), _name(name), diff --git a/direct/src/interval/cLerpAnimEffectInterval.h b/direct/src/interval/cLerpAnimEffectInterval.h index af657cb7cc..6200ffea9c 100644 --- a/direct/src/interval/cLerpAnimEffectInterval.h +++ b/direct/src/interval/cLerpAnimEffectInterval.h @@ -31,23 +31,23 @@ */ class EXPCL_DIRECT_INTERVAL CLerpAnimEffectInterval : public CLerpInterval { PUBLISHED: - INLINE explicit CLerpAnimEffectInterval(const string &name, double duration, + INLINE explicit CLerpAnimEffectInterval(const std::string &name, double duration, BlendType blend_type); - INLINE void add_control(AnimControl *control, const string &name, + INLINE void add_control(AnimControl *control, const std::string &name, float begin_effect, float end_effect); virtual void priv_step(double t); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: class ControlDef { public: - INLINE ControlDef(AnimControl *control, const string &name, + INLINE ControlDef(AnimControl *control, const std::string &name, float begin_effect, float end_effect); PT(AnimControl) _control; - string _name; + std::string _name; float _begin_effect; float _end_effect; }; diff --git a/direct/src/interval/cLerpInterval.I b/direct/src/interval/cLerpInterval.I index 04b37b438a..c0c101cfc4 100644 --- a/direct/src/interval/cLerpInterval.I +++ b/direct/src/interval/cLerpInterval.I @@ -15,7 +15,7 @@ * */ INLINE CLerpInterval:: -CLerpInterval(const string &name, double duration, +CLerpInterval(const std::string &name, double duration, CLerpInterval::BlendType blend_type) : CInterval(name, duration, true), _blend_type(blend_type) diff --git a/direct/src/interval/cLerpInterval.h b/direct/src/interval/cLerpInterval.h index 7011fd70e9..6587066f04 100644 --- a/direct/src/interval/cLerpInterval.h +++ b/direct/src/interval/cLerpInterval.h @@ -32,13 +32,13 @@ PUBLISHED: }; public: - INLINE CLerpInterval(const string &name, double duration, + INLINE CLerpInterval(const std::string &name, double duration, BlendType blend_type); PUBLISHED: INLINE BlendType get_blend_type() const; - static BlendType string_blend_type(const string &blend_type); + static BlendType string_blend_type(const std::string &blend_type); protected: double compute_delta(double t) const; diff --git a/direct/src/interval/cLerpNodePathInterval.h b/direct/src/interval/cLerpNodePathInterval.h index a134faebf0..d079f8eaa0 100644 --- a/direct/src/interval/cLerpNodePathInterval.h +++ b/direct/src/interval/cLerpNodePathInterval.h @@ -25,7 +25,7 @@ */ class EXPCL_DIRECT_INTERVAL CLerpNodePathInterval : public CLerpInterval { PUBLISHED: - explicit CLerpNodePathInterval(const string &name, double duration, + explicit CLerpNodePathInterval(const std::string &name, double duration, BlendType blend_type, bool bake_in_start, bool fluid, const NodePath &node, const NodePath &other); @@ -68,7 +68,7 @@ PUBLISHED: virtual void priv_reverse_initialize(double t); virtual void priv_reverse_instant(); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: void setup_slerp(); diff --git a/direct/src/interval/cMetaInterval.h b/direct/src/interval/cMetaInterval.h index f1956f4167..40fb03d102 100644 --- a/direct/src/interval/cMetaInterval.h +++ b/direct/src/interval/cMetaInterval.h @@ -31,7 +31,7 @@ */ class EXPCL_DIRECT_INTERVAL CMetaInterval : public CInterval { PUBLISHED: - explicit CMetaInterval(const string &name); + explicit CMetaInterval(const std::string &name); virtual ~CMetaInterval(); enum RelativeStart { @@ -44,20 +44,20 @@ PUBLISHED: INLINE double get_precision() const; void clear_intervals(); - int push_level(const string &name, + int push_level(const std::string &name, double rel_time, RelativeStart rel_to); int add_c_interval(CInterval *c_interval, double rel_time = 0.0f, RelativeStart rel_to = RS_previous_end); - int add_ext_index(int ext_index, const string &name, + int add_ext_index(int ext_index, const std::string &name, double duration, bool open_ended, double rel_time, RelativeStart rel_to); int pop_level(double duration = -1.0); - bool set_interval_start_time(const string &name, double rel_time, + bool set_interval_start_time(const std::string &name, double rel_time, RelativeStart rel_to = RS_level_begin); - double get_interval_start_time(const string &name) const; - double get_interval_end_time(const string &name) const; + double get_interval_start_time(const std::string &name) const; + double get_interval_end_time(const std::string &name) const; enum DefType { DT_c_interval, @@ -86,8 +86,8 @@ PUBLISHED: INLINE EventType get_event_type() const; void pop_event(); - virtual void write(ostream &out, int indent_level) const; - void timeline(ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; + void timeline(std::ostream &out) const; protected: virtual void do_recompute(); @@ -98,7 +98,7 @@ private: DefType _type; PT(CInterval) _c_interval; int _ext_index; - string _ext_name; + std::string _ext_name; double _ext_duration; bool _ext_open_ended; double _rel_time; @@ -159,7 +159,7 @@ private: int get_begin_time(const IntervalDef &def, int level_begin, int previous_begin, int previous_end); - void write_event_desc(ostream &out, const IntervalDef &def, + void write_event_desc(std::ostream &out, const IntervalDef &def, int &extra_indent_level) const; diff --git a/direct/src/interval/hideInterval.h b/direct/src/interval/hideInterval.h index 91cd1a9bda..8428d3ab70 100644 --- a/direct/src/interval/hideInterval.h +++ b/direct/src/interval/hideInterval.h @@ -23,7 +23,7 @@ */ class EXPCL_DIRECT_INTERVAL HideInterval : public CInterval { PUBLISHED: - explicit HideInterval(const NodePath &node, const string &name = string()); + explicit HideInterval(const NodePath &node, const std::string &name = std::string()); virtual void priv_instant(); virtual void priv_reverse_instant(); diff --git a/direct/src/interval/showInterval.h b/direct/src/interval/showInterval.h index bff66d8366..c50db953a2 100644 --- a/direct/src/interval/showInterval.h +++ b/direct/src/interval/showInterval.h @@ -23,7 +23,7 @@ */ class EXPCL_DIRECT_INTERVAL ShowInterval : public CInterval { PUBLISHED: - explicit ShowInterval(const NodePath &node, const string &name = string()); + explicit ShowInterval(const NodePath &node, const std::string &name = std::string()); virtual void priv_instant(); virtual void priv_reverse_instant(); diff --git a/direct/src/plugin/binaryXml.h b/direct/src/plugin/binaryXml.h index 4bdd9d29cf..664c7fb5e6 100644 --- a/direct/src/plugin/binaryXml.h +++ b/direct/src/plugin/binaryXml.h @@ -25,7 +25,7 @@ using namespace std; // but this is a smidge more efficient and gives us more control. void init_xml(); -void write_xml(ostream &out, TiXmlDocument *doc, ostream &logfile); -TiXmlDocument *read_xml(istream &in, ostream &logfile); +void write_xml(std::ostream &out, TiXmlDocument *doc, std::ostream &logfile); +TiXmlDocument *read_xml(std::istream &in, std::ostream &logfile); #endif diff --git a/direct/src/plugin/fileSpec.I b/direct/src/plugin/fileSpec.I index e82e099fb8..22e6f26f81 100644 --- a/direct/src/plugin/fileSpec.I +++ b/direct/src/plugin/fileSpec.I @@ -15,7 +15,7 @@ * Returns the relative path to this file on disk, within the package root * directory. */ -inline const string &FileSpec:: +inline const std::string &FileSpec:: get_filename() const { return _filename; } @@ -25,15 +25,15 @@ get_filename() const { * directory. */ inline void FileSpec:: -set_filename(const string &filename) { +set_filename(const std::string &filename) { _filename = filename; } /** * Returns the full path to this file on disk. */ -inline string FileSpec:: -get_pathname(const string &package_dir) const { +inline std::string FileSpec:: +get_pathname(const std::string &package_dir) const { return package_dir + "/" + _filename; } diff --git a/direct/src/plugin/fileSpec.h b/direct/src/plugin/fileSpec.h index 8dc39aebcf..e393b680fa 100644 --- a/direct/src/plugin/fileSpec.h +++ b/direct/src/plugin/fileSpec.h @@ -33,39 +33,39 @@ public: void load_xml(TiXmlElement *xelement); void store_xml(TiXmlElement *xelement); - inline const string &get_filename() const; - inline void set_filename(const string &filename); - inline string get_pathname(const string &package_dir) const; + inline const std::string &get_filename() const; + inline void set_filename(const std::string &filename); + inline std::string get_pathname(const std::string &package_dir) const; inline size_t get_size() const; inline time_t get_timestamp() const; inline bool has_hash() const; - bool quick_verify(const string &package_dir); - bool quick_verify_pathname(const string &pathname); - bool full_verify(const string &package_dir); + bool quick_verify(const std::string &package_dir); + bool quick_verify_pathname(const std::string &pathname); + bool full_verify(const std::string &package_dir); inline const FileSpec *get_actual_file() const; - const FileSpec *force_get_actual_file(const string &pathname); + const FileSpec *force_get_actual_file(const std::string &pathname); - bool check_hash(const string &pathname) const; - bool read_hash(const string &pathname); - bool read_hash_stream(istream &in); + bool check_hash(const std::string &pathname) const; + bool read_hash(const std::string &pathname); + bool read_hash_stream(std::istream &in); int compare_hash(const FileSpec &other) const; - void write(ostream &out) const; - void output_hash(ostream &out) const; + void write(std::ostream &out) const; + void output_hash(std::ostream &out) const; private: - bool priv_check_hash(const string &pathname, void *stp); + bool priv_check_hash(const std::string &pathname, void *stp); static inline int decode_hexdigit(char c); static inline char encode_hexdigit(int c); static bool decode_hex(unsigned char *dest, const char *source, size_t size); static void encode_hex(char *dest, const unsigned char *source, size_t size); - static void stream_hex(ostream &out, const unsigned char *source, size_t size); + static void stream_hex(std::ostream &out, const unsigned char *source, size_t size); enum { hash_size = 16 }; - string _filename; + std::string _filename; size_t _size; time_t _timestamp; unsigned char _hash[hash_size]; diff --git a/direct/src/plugin/find_root_dir.h b/direct/src/plugin/find_root_dir.h index cdbb25ec91..977a64cc37 100644 --- a/direct/src/plugin/find_root_dir.h +++ b/direct/src/plugin/find_root_dir.h @@ -18,10 +18,10 @@ #include using namespace std; -string find_root_dir(); +std::string find_root_dir(); #ifdef __APPLE__ -string find_osx_root_dir(); +std::string find_osx_root_dir(); #endif // __APPLE__ #endif diff --git a/direct/src/plugin/handleStream.I b/direct/src/plugin/handleStream.I index 5003b98e82..60021cee96 100644 --- a/direct/src/plugin/handleStream.I +++ b/direct/src/plugin/handleStream.I @@ -15,7 +15,7 @@ * */ inline HandleStream:: -HandleStream() : iostream(&_buf) { +HandleStream() : std::iostream(&_buf) { } /** @@ -32,10 +32,10 @@ inline HandleStream:: */ inline void HandleStream:: open_read(FHandle handle) { - clear((ios::iostate)0); + clear((std::ios::iostatetate)0); _buf.open_read(handle); if (!_buf.is_open_read()) { - clear(ios::failbit); + clear(std::ios::failbit); } } @@ -45,10 +45,10 @@ open_read(FHandle handle) { */ inline void HandleStream:: open_write(FHandle handle) { - clear((ios::iostate)0); + clear((std::ios::iostatetate)0); _buf.open_write(handle); if (!_buf.is_open_write()) { - clear(ios::failbit); + clear(std::ios::failbit); } } diff --git a/direct/src/plugin/handleStream.h b/direct/src/plugin/handleStream.h index abe8b0dee3..b28dec5f6a 100644 --- a/direct/src/plugin/handleStream.h +++ b/direct/src/plugin/handleStream.h @@ -21,7 +21,7 @@ * Windows' HANDLE objects, or Posix file descriptors. This is necessary to * map low-level pipes into an iostream for tinyxml. */ -class HandleStream : public iostream { +class HandleStream : public std::iostream { public: inline HandleStream(); inline ~HandleStream(); diff --git a/direct/src/plugin/handleStreamBuf.h b/direct/src/plugin/handleStreamBuf.h index 68486ec69f..19610a0c45 100644 --- a/direct/src/plugin/handleStreamBuf.h +++ b/direct/src/plugin/handleStreamBuf.h @@ -23,7 +23,7 @@ using namespace std; /** * */ -class HandleStreamBuf : public streambuf { +class HandleStreamBuf : public std::streambuf { public: HandleStreamBuf(); virtual ~HandleStreamBuf(); diff --git a/direct/src/plugin/load_plugin.h b/direct/src/plugin/load_plugin.h index b6a41a3f9c..58f160ef7d 100644 --- a/direct/src/plugin/load_plugin.h +++ b/direct/src/plugin/load_plugin.h @@ -59,24 +59,24 @@ extern P3D_request_finish_func *P3D_request_finish_ptr; extern P3D_instance_feed_url_stream_func *P3D_instance_feed_url_stream_ptr; extern P3D_instance_handle_event_func *P3D_instance_handle_event_ptr; -string get_plugin_basename(); +std::string get_plugin_basename(); bool -load_plugin(const string &p3d_plugin_filename, - const string &contents_filename, const string &host_url, - P3D_verify_contents verify_contents, const string &platform, - const string &log_directory, const string &log_basename, +load_plugin(const std::string &p3d_plugin_filename, + const std::string &contents_filename, const std::string &host_url, + P3D_verify_contents verify_contents, const std::string &platform, + const std::string &log_directory, const std::string &log_basename, bool trusted_environment, bool console_environment, - const string &root_dir, const string &host_dir, - const string &start_dir, ostream &logfile); + const std::string &root_dir, const std::string &host_dir, + const std::string &start_dir, std::ostream &logfile); bool -init_plugin(const string &contents_filename, const string &host_url, - P3D_verify_contents verify_contents, const string &platform, - const string &log_directory, const string &log_basename, +init_plugin(const std::string &contents_filename, const std::string &host_url, + P3D_verify_contents verify_contents, const std::string &platform, + const std::string &log_directory, const std::string &log_basename, bool trusted_environment, bool console_environment, - const string &root_dir, const string &host_dir, - const string &start_dir, ostream &logfile); + const std::string &root_dir, const std::string &host_dir, + const std::string &start_dir, std::ostream &logfile); -void unload_plugin(ostream &logfile); +void unload_plugin(std::ostream &logfile); bool is_plugin_loaded(); #endif diff --git a/direct/src/plugin/mkdir_complete.h b/direct/src/plugin/mkdir_complete.h index 9b9521a9bd..5ba165e6be 100644 --- a/direct/src/plugin/mkdir_complete.h +++ b/direct/src/plugin/mkdir_complete.h @@ -18,12 +18,12 @@ #include using namespace std; -bool mkdir_complete(const string &dirname, ostream &logfile); -bool mkfile_complete(const string &dirname, ostream &logfile); +bool mkdir_complete(const std::string &dirname, std::ostream &logfile); +bool mkfile_complete(const std::string &dirname, std::ostream &logfile); #ifdef _WIN32 -bool mkdir_complete_w(const wstring &dirname, ostream &logfile); -bool mkfile_complete_w(const wstring &dirname, ostream &logfile); +bool mkdir_complete_w(const std::wstring &dirname, std::ostream &logfile); +bool mkfile_complete_w(const std::wstring &dirname, std::ostream &logfile); #endif // _WIN32 #endif diff --git a/direct/src/plugin/p3dAuthSession.h b/direct/src/plugin/p3dAuthSession.h index 3df7894279..f37f24d9e3 100644 --- a/direct/src/plugin/p3dAuthSession.h +++ b/direct/src/plugin/p3dAuthSession.h @@ -56,13 +56,13 @@ private: private: P3DInstance *_inst; - string _start_dir; + std::string _start_dir; // This information is passed to create_process(). P3DTemporaryFile *_cert_filename; - string _cert_dir; - string _p3dcert_exe; - string _env; + std::string _cert_dir; + std::string _p3dcert_exe; + std::string _env; #ifdef _WIN32 HANDLE _p3dcert_handle; diff --git a/direct/src/plugin/p3dBoolObject.h b/direct/src/plugin/p3dBoolObject.h index 83a950cb76..85eb0a127c 100644 --- a/direct/src/plugin/p3dBoolObject.h +++ b/direct/src/plugin/p3dBoolObject.h @@ -29,7 +29,7 @@ public: virtual P3D_object_type get_type(); virtual bool get_bool(); virtual int get_int(); - virtual void make_string(string &value); + virtual void make_string(std::string &value); private: bool _value; diff --git a/direct/src/plugin/p3dCert.h b/direct/src/plugin/p3dCert.h index d5dbdd76a4..1583727565 100644 --- a/direct/src/plugin/p3dCert.h +++ b/direct/src/plugin/p3dCert.h @@ -50,9 +50,9 @@ class ViewCertDialog; class AuthDialog : public Fl_Window { public: #ifdef _WIN32 - AuthDialog(const wstring &cert_filename, const wstring &cert_dir); + AuthDialog(const std::wstring &cert_filename, const std::wstring &cert_dir); #else - AuthDialog(const string &cert_filename, const string &cert_dir); + AuthDialog(const std::string &cert_filename, const std::string &cert_dir); #endif virtual ~AuthDialog(); @@ -64,9 +64,9 @@ public: private: #ifdef _WIN32 - void read_cert_file(const wstring &cert_filename); + void read_cert_file(const std::wstring &cert_filename); #else - void read_cert_file(const string &cert_filename); + void read_cert_file(const std::string &cert_filename); #endif void get_friendly_name(); void verify_cert(); @@ -81,9 +81,9 @@ public: private: #ifdef _WIN32 - wstring _cert_dir; + std::wstring _cert_dir; #else - string _cert_dir; + std::string _cert_dir; #endif X509 *_cert; STACK_OF(X509) *_stack; @@ -92,7 +92,7 @@ private: char _text[1024]; char _text_clean[2048]; - string _friendly_name; + std::string _friendly_name; int _verify_result; }; diff --git a/direct/src/plugin/p3dCert_wx.h b/direct/src/plugin/p3dCert_wx.h index 05f0053b74..bced0ec91f 100644 --- a/direct/src/plugin/p3dCert_wx.h +++ b/direct/src/plugin/p3dCert_wx.h @@ -48,8 +48,8 @@ public: virtual bool OnCmdLineParsed(wxCmdLineParser &parser); private: - string _cert_filename; - string _cert_dir; + std::string _cert_filename; + std::string _cert_dir; }; /** @@ -62,7 +62,7 @@ private: */ class AuthDialog : public wxDialog { public: - AuthDialog(const string &cert_filename, const string &cert_dir); + AuthDialog(const std::string &cert_filename, const std::string &cert_dir); virtual ~AuthDialog(); void run_clicked(wxCommandEvent &event); @@ -72,7 +72,7 @@ public: void approve_cert(); private: - void read_cert_file(const string &cert_filename); + void read_cert_file(const std::string &cert_filename); void get_friendly_name(); void verify_cert(); int load_certificates_from_der_ram(X509_STORE *store, @@ -88,7 +88,7 @@ private: // any class wishing to process wxWidgets events must use this macro DECLARE_EVENT_TABLE() - string _cert_dir; + std::string _cert_dir; X509 *_cert; STACK_OF(X509) *_stack; diff --git a/direct/src/plugin/p3dConcreteSequence.h b/direct/src/plugin/p3dConcreteSequence.h index e77b08b823..09b489c5ba 100644 --- a/direct/src/plugin/p3dConcreteSequence.h +++ b/direct/src/plugin/p3dConcreteSequence.h @@ -34,10 +34,10 @@ public: virtual P3D_object_type get_type(); virtual bool get_bool(); - virtual void make_string(string &value); + virtual void make_string(std::string &value); - virtual P3D_object *get_property(const string &property); - virtual bool set_property(const string &property, P3D_object *value); + virtual P3D_object *get_property(const std::string &property); + virtual bool set_property(const std::string &property, P3D_object *value); virtual bool fill_xml(TiXmlElement *xvalue, P3DSession *session); virtual P3D_object **get_object_array(); @@ -49,7 +49,7 @@ public: void append(P3D_object *value); private: - typedef vector Elements; + typedef std::vector Elements; Elements _elements; }; diff --git a/direct/src/plugin/p3dConcreteStruct.h b/direct/src/plugin/p3dConcreteStruct.h index 565bb35ae3..cccd35bbeb 100644 --- a/direct/src/plugin/p3dConcreteStruct.h +++ b/direct/src/plugin/p3dConcreteStruct.h @@ -32,19 +32,19 @@ public: virtual P3D_object_type get_type(); virtual bool get_bool(); - virtual void make_string(string &value); + virtual void make_string(std::string &value); - virtual P3D_object *get_property(const string &property); - virtual bool set_property(const string &property, P3D_object *value); + virtual P3D_object *get_property(const std::string &property); + virtual bool set_property(const std::string &property, P3D_object *value); - virtual bool has_method(const string &method_name); - virtual P3D_object *call(const string &method_name, bool needs_response, + virtual bool has_method(const std::string &method_name); + virtual P3D_object *call(const std::string &method_name, bool needs_response, P3D_object *params[], int num_params); virtual bool fill_xml(TiXmlElement *xvalue, P3DSession *session); private: - typedef map Elements; + typedef std::map Elements; Elements _elements; }; diff --git a/direct/src/plugin/p3dDownload.I b/direct/src/plugin/p3dDownload.I index e32370669c..c248948612 100644 --- a/direct/src/plugin/p3dDownload.I +++ b/direct/src/plugin/p3dDownload.I @@ -14,7 +14,7 @@ /** * Returns the URL that we are querying. */ -const string &P3DDownload:: +const std::string &P3DDownload:: get_url() const { return _url; } diff --git a/direct/src/plugin/p3dDownload.h b/direct/src/plugin/p3dDownload.h index e36d5b19c5..ad2cd872a5 100644 --- a/direct/src/plugin/p3dDownload.h +++ b/direct/src/plugin/p3dDownload.h @@ -32,8 +32,8 @@ public: P3DDownload(const P3DDownload ©); virtual ~P3DDownload(); - void set_url(const string &url); - inline const string &get_url() const; + void set_url(const std::string &url); + inline const std::string &get_url() const; inline void set_instance(P3DInstance *instance); inline P3DInstance *get_instance() const; @@ -78,7 +78,7 @@ protected: private: bool _canceled; int _download_id; - string _url; + std::string _url; P3DInstance *_instance; }; diff --git a/direct/src/plugin/p3dFileDownload.I b/direct/src/plugin/p3dFileDownload.I index 187db8945d..af4e2b1ec8 100644 --- a/direct/src/plugin/p3dFileDownload.I +++ b/direct/src/plugin/p3dFileDownload.I @@ -14,7 +14,7 @@ /** * Returns the filename that we are downloading into. */ -const string &P3DFileDownload:: +const std::string &P3DFileDownload:: get_filename() const { return _filename; } diff --git a/direct/src/plugin/p3dFileDownload.h b/direct/src/plugin/p3dFileDownload.h index f256706ac6..923f8ec0ec 100644 --- a/direct/src/plugin/p3dFileDownload.h +++ b/direct/src/plugin/p3dFileDownload.h @@ -28,8 +28,8 @@ public: P3DFileDownload(); P3DFileDownload(const P3DFileDownload ©); - bool set_filename(const string &filename); - inline const string &get_filename() const; + bool set_filename(const std::string &filename); + inline const std::string &get_filename() const; protected: virtual bool open_file(); @@ -42,7 +42,7 @@ protected: ofstream _file; private: - string _filename; + std::string _filename; }; #include "p3dFileDownload.I" diff --git a/direct/src/plugin/p3dFileParams.I b/direct/src/plugin/p3dFileParams.I index e7eb45788d..8565c47a90 100644 --- a/direct/src/plugin/p3dFileParams.I +++ b/direct/src/plugin/p3dFileParams.I @@ -14,7 +14,7 @@ /** * Returns the filename that was passed to set_p3d_filename(). */ -inline const string &P3DFileParams:: +inline const std::string &P3DFileParams:: get_p3d_filename() const { return _p3d_filename; } @@ -31,7 +31,7 @@ get_p3d_offset() const { /** * Returns the string that was passed to set_p3d_url(). */ -inline const string &P3DFileParams:: +inline const std::string &P3DFileParams:: get_p3d_url() const { return _p3d_url; } @@ -47,7 +47,7 @@ get_num_tokens() const { /** * Returns the keyword of the nth token. */ -inline const string &P3DFileParams:: +inline const std::string &P3DFileParams:: get_token_keyword(int n) const { assert(n >= 0 && n < (int)_tokens.size()); return _tokens[n]._keyword; @@ -56,7 +56,7 @@ get_token_keyword(int n) const { /** * Returns the value of the nth token. */ -inline const string &P3DFileParams:: +inline const std::string &P3DFileParams:: get_token_value(int n) const { assert(n >= 0 && n < (int)_tokens.size()); return _tokens[n]._value; diff --git a/direct/src/plugin/p3dFileParams.h b/direct/src/plugin/p3dFileParams.h index 1cb54d1b3a..53b2630680 100644 --- a/direct/src/plugin/p3dFileParams.h +++ b/direct/src/plugin/p3dFileParams.h @@ -27,38 +27,38 @@ public: P3DFileParams(const P3DFileParams ©); void operator = (const P3DFileParams &other); - void set_p3d_filename(const string &p3d_filename); + void set_p3d_filename(const std::string &p3d_filename); void set_p3d_offset(const int &p3d_offset); - void set_p3d_url(const string &p3d_url); + void set_p3d_url(const std::string &p3d_url); void set_tokens(const P3D_token tokens[], size_t num_tokens); void set_token(const char *keyword, const char *value); void set_args(int argc, const char *argv[]); - inline const string &get_p3d_filename() const; + inline const std::string &get_p3d_filename() const; inline int get_p3d_offset() const; - inline const string &get_p3d_url() const; - string lookup_token(const string &keyword) const; - int lookup_token_int(const string &keyword) const; - bool has_token(const string &keyword) const; + inline const std::string &get_p3d_url() const; + std::string lookup_token(const std::string &keyword) const; + int lookup_token_int(const std::string &keyword) const; + bool has_token(const std::string &keyword) const; inline int get_num_tokens() const; - inline const string &get_token_keyword(int n) const; - inline const string &get_token_value(int n) const; + inline const std::string &get_token_keyword(int n) const; + inline const std::string &get_token_value(int n) const; TiXmlElement *make_xml(); private: class Token { public: - string _keyword; - string _value; + std::string _keyword; + std::string _value; }; - typedef vector Tokens; - typedef vector Args; + typedef std::vector Tokens; + typedef std::vector Args; - string _p3d_filename; + std::string _p3d_filename; int _p3d_offset; - string _p3d_url; + std::string _p3d_url; Tokens _tokens; Args _args; }; diff --git a/direct/src/plugin/p3dFloatObject.h b/direct/src/plugin/p3dFloatObject.h index 1fbb79251b..13f7ba8358 100644 --- a/direct/src/plugin/p3dFloatObject.h +++ b/direct/src/plugin/p3dFloatObject.h @@ -30,7 +30,7 @@ public: virtual bool get_bool(); virtual int get_int(); virtual double get_float(); - virtual void make_string(string &value); + virtual void make_string(std::string &value); private: double _value; diff --git a/direct/src/plugin/p3dHost.I b/direct/src/plugin/p3dHost.I index 27f3e2a8f8..9fb3672205 100644 --- a/direct/src/plugin/p3dHost.I +++ b/direct/src/plugin/p3dHost.I @@ -26,7 +26,7 @@ has_host_dir() const { * bootstrapped; if there is some danger of calling this early in the * initialization process, you should check has_host_dir() first. */ -inline const string &P3DHost:: +inline const std::string &P3DHost:: get_host_dir() const { assert(has_host_dir()); return _host_dir; @@ -36,7 +36,7 @@ get_host_dir() const { * Returns the root URL of this particular host, as passed from the package * file. This is a unique string that identifies each host. */ -inline const string &P3DHost:: +inline const std::string &P3DHost:: get_host_url() const { return _host_url; } @@ -48,7 +48,7 @@ get_host_url() const { * * Also see get_download_url_prefix(). */ -inline const string &P3DHost:: +inline const std::string &P3DHost:: get_host_url_prefix() const { return _host_url_prefix; } @@ -58,7 +58,7 @@ get_host_url_prefix() const { * the contents.xml file. This is often the same as get_host_url_prefix(), * but it may be different in the case of an https server for contents.xml. */ -inline const string &P3DHost:: +inline const std::string &P3DHost:: get_download_url_prefix() const { return _download_url_prefix; } @@ -68,7 +68,7 @@ get_download_url_prefix() const { * url if no descriptive name is provided. This will be available after * read_contents_file() has been called. */ -inline const string &P3DHost:: +inline const std::string &P3DHost:: get_descriptive_name() const { return _descriptive_name; } @@ -101,6 +101,6 @@ get_contents_iseq() const { * contents.xml file (as provided by the server), false otherwise. */ inline bool P3DHost:: -check_contents_hash(const string &pathname) const { +check_contents_hash(const std::string &pathname) const { return _contents_spec.check_hash(pathname); } diff --git a/direct/src/plugin/p3dHost.h b/direct/src/plugin/p3dHost.h index adc66501c7..fd880ccde0 100644 --- a/direct/src/plugin/p3dHost.h +++ b/direct/src/plugin/p3dHost.h @@ -27,84 +27,84 @@ class P3DPackage; */ class P3DHost { private: - P3DHost(const string &host_url, const string &host_dir = ""); + P3DHost(const std::string &host_url, const std::string &host_dir = ""); ~P3DHost(); public: inline bool has_host_dir() const; - inline const string &get_host_dir() const; - inline const string &get_host_url() const; - inline const string &get_host_url_prefix() const; - inline const string &get_download_url_prefix() const; - inline const string &get_descriptive_name() const; + inline const std::string &get_host_dir() const; + inline const std::string &get_host_url() const; + inline const std::string &get_host_url_prefix() const; + inline const std::string &get_download_url_prefix() const; + inline const std::string &get_descriptive_name() const; - P3DHost *get_alt_host(const string &alt_host); + P3DHost *get_alt_host(const std::string &alt_host); inline bool has_contents_file() const; bool has_current_contents_file(P3DInstanceManager *inst_mgr) const; inline int get_contents_iseq() const; - inline bool check_contents_hash(const string &pathname) const; + inline bool check_contents_hash(const std::string &pathname) const; bool read_contents_file(); - bool read_contents_file(const string &contents_filename, bool fresh_download); + bool read_contents_file(const std::string &contents_filename, bool fresh_download); void read_xhost(TiXmlElement *xhost); - P3DPackage *get_package(const string &package_name, - const string &package_version, - const string &package_platform, - const string &package_seq, - const string &alt_host = ""); - bool choose_suitable_platform(string &selected_platform, + P3DPackage *get_package(const std::string &package_name, + const std::string &package_version, + const std::string &package_platform, + const std::string &package_seq, + const std::string &alt_host = ""); + bool choose_suitable_platform(std::string &selected_platform, bool &per_platform, - const string &package_name, - const string &package_version, - const string &package_platform); + const std::string &package_name, + const std::string &package_version, + const std::string &package_platform); bool get_package_desc_file(FileSpec &desc_file, - string &package_seq, + std::string &package_seq, bool &package_solo, - const string &package_name, - const string &package_version, - const string &package_platform); + const std::string &package_name, + const std::string &package_version, + const std::string &package_platform); - void forget_package(P3DPackage *package, const string &alt_host = ""); - void migrate_package_host(P3DPackage *package, const string &alt_host, P3DHost *new_host); + void forget_package(P3DPackage *package, const std::string &alt_host = ""); + void migrate_package_host(P3DPackage *package, const std::string &alt_host, P3DHost *new_host); - void choose_random_mirrors(vector &result, int num_mirrors); - void add_mirror(string mirror_url); + void choose_random_mirrors(std::vector &result, int num_mirrors); + void add_mirror(std::string mirror_url); void uninstall(); private: - void determine_host_dir(const string &host_dir_basename); + void determine_host_dir(const std::string &host_dir_basename); - static string standardize_filename(const string &filename); - static bool copy_file(const string &from_filename, const string &to_filename); - static bool save_xml_file(TiXmlDocument *doc, const string &to_filename); - static int compare_seq(const string &seq_a, const string &seq_b); + static std::string standardize_filename(const std::string &filename); + static bool copy_file(const std::string &from_filename, const std::string &to_filename); + static bool save_xml_file(TiXmlDocument *doc, const std::string &to_filename); + static int compare_seq(const std::string &seq_a, const std::string &seq_b); static int compare_seq_int(const char *&num_a, const char *&num_b); private: - string _host_dir; - string _host_url; - string _host_url_prefix; - string _download_url_prefix; - string _descriptive_name; + std::string _host_dir; + std::string _host_url; + std::string _host_url_prefix; + std::string _download_url_prefix; + std::string _descriptive_name; TiXmlElement *_xcontents; time_t _contents_expiration; int _contents_iseq; FileSpec _contents_spec; - typedef vector Mirrors; + typedef std::vector Mirrors; Mirrors _mirrors; - typedef map AltHosts; + typedef std::map AltHosts; AltHosts _alt_hosts; - typedef vector PlatformPackages; - typedef map PackageMap; - typedef map Packages; + typedef std::vector PlatformPackages; + typedef std::map PackageMap; + typedef std::map Packages; Packages _packages; - typedef vector FailedPackages; + typedef std::vector FailedPackages; FailedPackages _failed_packages; friend class P3DInstanceManager; diff --git a/direct/src/plugin/p3dInstance.I b/direct/src/plugin/p3dInstance.I index 13aacd8b6b..63765832d3 100644 --- a/direct/src/plugin/p3dInstance.I +++ b/direct/src/plugin/p3dInstance.I @@ -42,7 +42,7 @@ get_instance_id() const { * is guaranteed to be unique for each unique session required for different * P3DInstances. */ -inline const string &P3DInstance:: +inline const std::string &P3DInstance:: get_session_key() const { return _session_key; } @@ -56,7 +56,7 @@ get_session_key() const { * Presumably all of the platform-specific packages that are downloaded * subsequently must be of the exact same platform. */ -inline const string &P3DInstance:: +inline const std::string &P3DInstance:: get_session_platform() const { return _session_platform; } diff --git a/direct/src/plugin/p3dInstance.h b/direct/src/plugin/p3dInstance.h index 325e368003..7972ef7fbe 100644 --- a/direct/src/plugin/p3dInstance.h +++ b/direct/src/plugin/p3dInstance.h @@ -56,9 +56,9 @@ public: ~P3DInstance(); void cleanup(); - void set_p3d_url(const string &p3d_url); - void set_p3d_filename(const string &p3d_filename, const int &p3d_offset = 0); - int make_p3d_stream(const string &p3d_url); + void set_p3d_url(const std::string &p3d_url); + void set_p3d_filename(const std::string &p3d_filename, const int &p3d_offset = 0); + int make_p3d_stream(const std::string &p3d_url); inline const P3DFileParams &get_fparams() const; void set_wparams(const P3DWindowParams &wparams); @@ -84,16 +84,16 @@ public: bool handle_event(const P3D_event_data &event); inline int get_instance_id() const; - inline const string &get_session_key() const; - const string &get_log_pathname() const; - inline const string &get_session_platform() const; + inline const std::string &get_session_key() const; + const std::string &get_log_pathname() const; + inline const std::string &get_session_platform() const; inline P3DSession *get_session() const; inline P3D_request_ready_func *get_request_ready_func() const; - void add_package(const string &name, const string &version, - const string &seq, P3DHost *host); + void add_package(const std::string &name, const std::string &version, + const std::string &seq, P3DHost *host); void add_package(P3DPackage *package); void remove_package(P3DPackage *package); bool get_packages_info_ready() const; @@ -161,14 +161,14 @@ private: IT_num_image_types, // Not a real value }; - void priv_set_p3d_filename(const string &p3d_filename, const int &p3d_offset = -1); - void determine_p3d_basename(const string &p3d_url); + void priv_set_p3d_filename(const std::string &p3d_filename, const int &p3d_offset = -1); + void determine_p3d_basename(const std::string &p3d_url); - bool check_matches_origin(const string &origin_match); - bool check_matches_origin_one(const string &origin_match); - bool check_matches_hostname(const string &orig, const string &match); - void separate_components(vector &components, const string &str); - bool check_matches_component(const string &orig, const string &match); + bool check_matches_origin(const std::string &origin_match); + bool check_matches_origin_one(const std::string &origin_match); + bool check_matches_hostname(const std::string &orig, const std::string &match); + void separate_components(std::vector &components, const std::string &str); + bool check_matches_component(const std::string &orig, const std::string &match); void check_p3d_signature(); void mark_p3d_untrusted(); @@ -176,15 +176,15 @@ private: void scan_app_desc_file(TiXmlDocument *doc); void add_panda3d_package(); void add_packages(); - string find_alt_host_url(const string &host_url, const string &alt_host); + std::string find_alt_host_url(const std::string &host_url, const std::string &alt_host); void get_host_info(P3DHost *host); - string get_start_dir_suffix() const; + std::string get_start_dir_suffix() const; void send_browser_script_object(); P3D_request *make_p3d_request(TiXmlElement *xrequest); - void handle_notify_request(const string &message); - void handle_script_request(const string &operation, P3D_object *object, - const string &property_name, P3D_object *value, + void handle_notify_request(const std::string &message); + void handle_script_request(const std::string &operation, P3D_object *object, + const std::string &property_name, P3D_object *value, bool needs_response, int unique_id); void set_failed(); @@ -201,7 +201,7 @@ private: size_t received_data); void report_package_progress(P3DPackage *package, double progress); void report_package_done(P3DPackage *package, bool success); - void set_install_label(const string &install_label); + void set_install_label(const std::string &install_label); void paint_window(); @@ -217,7 +217,7 @@ private: void add_carbon_modifier_flags(unsigned int &swb_flags, int modifiers); void add_cocoa_modifier_flags(unsigned int &swb_flags, int modifiers); - void send_notify(const string &message); + void send_notify(const std::string &message); #ifdef __APPLE__ void alloc_swbuffer(); @@ -228,10 +228,10 @@ private: P3D_request_ready_func *_func; P3D_object *_dom_object; P3DMainObject *_main_object; - string _p3d_basename; - string _origin_protocol; - string _origin_hostname; - string _origin_port; + std::string _p3d_basename; + std::string _origin_protocol; + std::string _origin_hostname; + std::string _origin_port; // We need a list of previous time reports so we can average the predicted // download time over the past few seconds. @@ -240,7 +240,7 @@ private: double _total; double _report_time; }; - typedef deque TimeReports; + typedef std::deque TimeReports; TimeReports _time_reports; double _total_time_reports; @@ -258,7 +258,7 @@ private: bool _use_standard_image; P3DTemporaryFile *_temp_filename; - string _filename; + std::string _filename; P3DSplashWindow::ImagePlacement _image_placement; }; ImageFile _image_files[IT_num_image_types]; @@ -283,11 +283,11 @@ private: P3DPackage *_p3dcert_package; int _instance_id; - string _session_key; - string _log_basename; - string _session_platform; - string _prc_name; - string _start_dir; + std::string _session_key; + std::string _log_basename; + std::string _session_platform; + std::string _prc_name; + std::string _start_dir; bool _hidden; bool _matches_run_origin; bool _matches_script_origin; @@ -301,14 +301,14 @@ private: P3DSession *_session; P3DAuthSession *_auth_session; - string _log_pathname; + std::string _log_pathname; #ifdef __APPLE__ // On OSX, we have to get a copy of the framebuffer data back from the child // process, and draw it to the window, here in the parent process. Crazy! int _shared_fd; size_t _shared_mmap_size; - string _shared_filename; + std::string _shared_filename; SubprocessWindowBuffer *_swbuffer; char *_reversed_buffer; CFDataRef _buffer_data; @@ -323,7 +323,7 @@ private: #endif // __APPLE__ P3DSplashWindow *_splash_window; - string _install_label; + std::string _install_label; bool _instance_window_opened; bool _instance_window_attached; bool _stuff_to_download; @@ -341,7 +341,7 @@ private: // for more than a couple of seconds. bool _show_dl_instance_progress; - typedef vector Packages; + typedef std::vector Packages; Packages _packages; Packages _downloading_packages; int _download_package_index; @@ -357,19 +357,19 @@ private: // it's in the above vector also. P3DPackage *_panda3d_package; - typedef map Downloads; + typedef std::map Downloads; Downloads _downloads; // The _raw_requests queue might be filled up by the read thread, so we // protect it in a lock. LOCK _request_lock; - typedef deque RawRequests; + typedef std::deque RawRequests; RawRequests _raw_requests; bool _requested_stop; // The _baked_requests queue is only touched in the main thread; no lock // needed. - typedef deque BakedRequests; + typedef std::deque BakedRequests; BakedRequests _baked_requests; friend class P3DSession; diff --git a/direct/src/plugin/p3dInstanceManager.I b/direct/src/plugin/p3dInstanceManager.I index 90a13c810a..3241fea0cf 100644 --- a/direct/src/plugin/p3dInstanceManager.I +++ b/direct/src/plugin/p3dInstanceManager.I @@ -73,7 +73,7 @@ get_api_version() const { * PANDA_PACKAGE_HOST_URL, but it might be set to something different by the * -u parameter on the panda3d executable. */ -inline const string &P3DInstanceManager:: +inline const std::string &P3DInstanceManager:: get_host_url() const { return _host_url; } @@ -83,7 +83,7 @@ get_host_url() const { * downloaded and installed. This must be a writable directory or nothing * will work. */ -inline const string &P3DInstanceManager:: +inline const std::string &P3DInstanceManager:: get_root_dir() const { return _root_dir; } @@ -92,7 +92,7 @@ get_root_dir() const { * Returns the directory that the .p3d file should be mounted to and run from. * This is usually the "start" subdirectory of the root_dir. */ -inline const string &P3DInstanceManager:: +inline const std::string &P3DInstanceManager:: get_start_dir() const { return _start_dir; } @@ -102,7 +102,7 @@ get_start_dir() const { * running. This string will be used to determine the appropriate packages to * download. */ -inline const string &P3DInstanceManager:: +inline const std::string &P3DInstanceManager:: get_platform() const { return _platform; } @@ -112,7 +112,7 @@ get_platform() const { * written. This filename will end with a slash, so that full pathnames may * be made by concatenting directly with this string. */ -inline const string &P3DInstanceManager:: +inline const std::string &P3DInstanceManager:: get_temp_directory() const { return _temp_directory; } @@ -122,7 +122,7 @@ get_temp_directory() const { * written. This filename will end with a slash, so that full pathnames may * be made by concatenting directly with this string. */ -inline const string &P3DInstanceManager:: +inline const std::string &P3DInstanceManager:: get_log_directory() const { return _log_directory; } @@ -133,7 +133,7 @@ get_log_directory() const { * different from the session log file(s), which represent the output from a * particular Python session. */ -inline const string &P3DInstanceManager:: +inline const std::string &P3DInstanceManager:: get_log_pathname() const { return _log_pathname; } @@ -187,7 +187,7 @@ get_num_supported_platforms() const { * environment will support, in order of preference--preferred platforms * appear first in the list. */ -inline const string &P3DInstanceManager:: +inline const std::string &P3DInstanceManager:: get_supported_platform(int n) const { return _supported_platforms.at(n); } @@ -230,7 +230,7 @@ get_plugin_official_version() const { * Returns the "distributor" reported by the plugin. This should represent * the entity that built and hosted the plugin. */ -inline const string &P3DInstanceManager:: +inline const std::string &P3DInstanceManager:: get_plugin_distributor() const { return _plugin_distributor; } @@ -240,7 +240,7 @@ get_plugin_distributor() const { * the plugin). This is for reporting purposes only; see get_host_url() for * the URL to contact to actually download content. */ -inline const string &P3DInstanceManager:: +inline const std::string &P3DInstanceManager:: get_coreapi_host_url() const { return _coreapi_host_url; } @@ -261,7 +261,7 @@ get_coreapi_timestamp() const { * not provide a number here. If provided, this will be a string of dot- * separated integers. */ -inline const string &P3DInstanceManager:: +inline const std::string &P3DInstanceManager:: get_coreapi_set_ver() const { return _coreapi_set_ver; } @@ -269,7 +269,7 @@ get_coreapi_set_ver() const { /** * Returns the "super mirror" URL. See p3d_plugin.h. */ -inline const string &P3DInstanceManager:: +inline const std::string &P3DInstanceManager:: get_super_mirror() const { return _super_mirror_url; } diff --git a/direct/src/plugin/p3dInstanceManager.h b/direct/src/plugin/p3dInstanceManager.h index a148c760a2..f175e90aeb 100644 --- a/direct/src/plugin/p3dInstanceManager.h +++ b/direct/src/plugin/p3dInstanceManager.h @@ -47,17 +47,17 @@ private: ~P3DInstanceManager(); public: - bool initialize(int api_version, const string &contents_filename, - const string &host_url, + bool initialize(int api_version, const std::string &contents_filename, + const std::string &host_url, P3D_verify_contents verify_contents, - const string &platform, - const string &log_directory, - const string &log_basename, + const std::string &platform, + const std::string &log_directory, + const std::string &log_basename, bool trusted_environment, bool console_environment, - const string &root_dir = "", - const string &host_dir = "", - const string &start_dir = ""); + const std::string &root_dir = "", + const std::string &host_dir = "", + const std::string &start_dir = ""); inline bool is_initialized() const; inline void reconsider_runtime_environment(); @@ -65,35 +65,35 @@ public: inline void reset_verify_contents(); inline int get_api_version() const; - inline const string &get_host_url() const; - inline const string &get_root_dir() const; - inline const string &get_start_dir() const; - inline const string &get_platform() const; - inline const string &get_temp_directory() const; - inline const string &get_log_directory() const; - inline const string &get_log_pathname() const; + inline const std::string &get_host_url() const; + inline const std::string &get_root_dir() const; + inline const std::string &get_start_dir() const; + inline const std::string &get_platform() const; + inline const std::string &get_temp_directory() const; + inline const std::string &get_log_directory() const; + inline const std::string &get_log_pathname() const; inline bool get_trusted_environment() const; inline bool get_console_environment() const; inline int get_num_supported_platforms() const; - inline const string &get_supported_platform(int n) const; + inline const std::string &get_supported_platform(int n) const; void set_plugin_version(int major, int minor, int sequence, - bool official, const string &distributor, - const string &coreapi_host_url, + bool official, const std::string &distributor, + const std::string &coreapi_host_url, time_t coreapi_timestamp, - const string &coreapi_set_ver); + const std::string &coreapi_set_ver); inline int get_plugin_major_version() const; inline int get_plugin_minor_version() const; inline int get_plugin_sequence_version() const; inline bool get_plugin_official_version() const; - inline const string &get_plugin_distributor() const; - inline const string &get_coreapi_host_url() const; + inline const std::string &get_plugin_distributor() const; + inline const std::string &get_coreapi_host_url() const; inline time_t get_coreapi_timestamp() const; - inline const string &get_coreapi_set_ver() const; + inline const std::string &get_coreapi_set_ver() const; - void set_super_mirror(const string &super_mirror_url); - inline const string &get_super_mirror() const; + void set_super_mirror(const std::string &super_mirror_url); + inline const std::string &get_super_mirror() const; P3DInstance * create_instance(P3D_request_ready_func *func, @@ -101,8 +101,8 @@ public: int argc, const char *argv[], void *user_data); bool set_p3d_filename(P3DInstance *inst, bool is_local, - const string &p3d_filename, const int &p3d_offset); - int make_p3d_stream(P3DInstance *inst, const string &p3d_url); + const std::string &p3d_filename, const int &p3d_offset); + int make_p3d_stream(P3DInstance *inst, const std::string &p3d_url); bool start_instance(P3DInstance *inst); void finish_instance(P3DInstance *inst); P3DAuthSession *authorize_instance(P3DInstance *inst); @@ -112,7 +112,7 @@ public: P3DInstance *check_request(); void wait_request(double timeout); - P3DHost *get_host(const string &host_url); + P3DHost *get_host(const std::string &host_url); void forget_host(P3DHost *host); inline int get_num_instances() const; @@ -126,13 +126,13 @@ public: inline P3D_object *new_none_object(); inline P3D_object *new_bool_object(bool value); - string make_temp_filename(const string &extension); - void release_temp_filename(const string &filename); + std::string make_temp_filename(const std::string &extension); + void release_temp_filename(const std::string &filename); bool find_cert(X509 *cert); void read_certlist(P3DPackage *package); - string get_cert_dir(X509 *cert); - static string cert_to_der(X509 *cert); + std::string get_cert_dir(X509 *cert); + static std::string cert_to_der(X509 *cert); void uninstall_all(); @@ -140,19 +140,19 @@ public: static void delete_global_ptr(); static inline char encode_hexdigit(int c); - static bool scan_directory(const string &dirname, vector &contents); - static bool scan_directory_recursively(const string &dirname, - vector &filename_contents, - vector &dirname_contents, - const string &prefix = ""); - static void delete_directory_recursively(const string &root_dir); - static bool remove_file_from_list(vector &contents, const string &filename); + static bool scan_directory(const std::string &dirname, std::vector &contents); + static bool scan_directory_recursively(const std::string &dirname, + std::vector &filename_contents, + std::vector &dirname_contents, + const std::string &prefix = ""); + static void delete_directory_recursively(const std::string &root_dir); + static bool remove_file_from_list(std::vector &contents, const std::string &filename); - static void append_safe_dir(string &root, const string &basename); + static void append_safe_dir(std::string &root, const std::string &basename); private: void create_runtime_environment(); - static void append_safe_dir_component(string &root, const string &component); + static void append_safe_dir_component(std::string &root, const std::string &component); private: // The notify thread. This thread runs only for the purpose of generating @@ -168,30 +168,30 @@ private: bool _is_initialized; bool _created_runtime_environment; int _api_version; - string _host_url; - string _root_dir; - string _host_dir; - string _start_dir; - string _certs_dir; + std::string _host_url; + std::string _root_dir; + std::string _host_dir; + std::string _start_dir; + std::string _certs_dir; P3D_verify_contents _verify_contents; - string _platform; - string _log_directory; - string _log_basename; - string _log_pathname; - string _temp_directory; + std::string _platform; + std::string _log_directory; + std::string _log_basename; + std::string _log_pathname; + std::string _temp_directory; bool _trusted_environment; bool _console_environment; int _plugin_major_version; int _plugin_minor_version; int _plugin_sequence_version; bool _plugin_official_version; - string _plugin_distributor; - string _coreapi_host_url; + std::string _plugin_distributor; + std::string _coreapi_host_url; time_t _coreapi_timestamp; - string _coreapi_set_ver; - string _super_mirror_url; + std::string _coreapi_set_ver; + std::string _super_mirror_url; - typedef vector SupportedPlatforms; + typedef std::vector SupportedPlatforms; SupportedPlatforms _supported_platforms; P3D_object *_undefined_object; @@ -199,20 +199,20 @@ private: P3D_object *_true_object; P3D_object *_false_object; - typedef set ApprovedCerts; + typedef std::set ApprovedCerts; ApprovedCerts _approved_certs; - typedef set Instances; + typedef std::set Instances; Instances _instances; P3DAuthSession *_auth_session; - typedef map Sessions; + typedef std::map Sessions; Sessions _sessions; - typedef map Hosts; + typedef std::map Hosts; Hosts _hosts; - typedef set TempFilenames; + typedef std::set TempFilenames; TempFilenames _temp_filenames; int _next_temp_filename_counter; @@ -228,7 +228,7 @@ private: THREAD _notify_thread; // This queue of instances that need to send notifications is protected by // _notify_ready's mutex. - typedef vector NotifyInstances; + typedef std::vector NotifyInstances; NotifyInstances _notify_instances; P3DConditionVar _notify_ready; diff --git a/direct/src/plugin/p3dIntObject.h b/direct/src/plugin/p3dIntObject.h index 899e422142..d77c0d689a 100644 --- a/direct/src/plugin/p3dIntObject.h +++ b/direct/src/plugin/p3dIntObject.h @@ -29,7 +29,7 @@ public: virtual P3D_object_type get_type(); virtual bool get_bool(); virtual int get_int(); - virtual void make_string(string &value); + virtual void make_string(std::string &value); private: int _value; diff --git a/direct/src/plugin/p3dMainObject.h b/direct/src/plugin/p3dMainObject.h index 7ed634c44c..fafad0ff16 100644 --- a/direct/src/plugin/p3dMainObject.h +++ b/direct/src/plugin/p3dMainObject.h @@ -45,17 +45,17 @@ public: virtual int get_int(); virtual double get_float(); - virtual void make_string(string &value); + virtual void make_string(std::string &value); - virtual P3D_object *get_property(const string &property); - virtual bool set_property(const string &property, bool needs_response, + virtual P3D_object *get_property(const std::string &property); + virtual bool set_property(const std::string &property, bool needs_response, P3D_object *value); - virtual bool has_method(const string &method_name); - virtual P3D_object *call(const string &method_name, bool needs_response, + virtual bool has_method(const std::string &method_name); + virtual P3D_object *call(const std::string &method_name, bool needs_response, P3D_object *params[], int num_params); - virtual void output(ostream &out); + virtual void output(std::ostream &out); void set_pyobj(P3D_object *pyobj); P3D_object *get_pyobj() const; @@ -68,11 +68,11 @@ private: P3D_object *call_read_game_log(P3D_object *params[], int num_params); P3D_object *call_read_system_log(P3D_object *params[], int num_params); P3D_object *call_read_log(P3D_object *params[], int num_params); - P3D_object *read_log(const string &log_pathname, + P3D_object *read_log(const std::string &log_pathname, P3D_object *params[], int num_params); - void read_log_file(const string &log_pathname, + void read_log_file(const std::string &log_pathname, size_t tail_bytes, size_t head_bytes, - ostringstream &log_data); + std::ostringstream &log_data); P3D_object *call_uninstall(P3D_object *params[], int num_params); private: @@ -80,12 +80,12 @@ private: P3DInstance *_inst; bool _unauth_play; - string _game_log_pathname; + std::string _game_log_pathname; // This map is used to store properties and retrieve until set_pyobj() is // called for the firs ttime. At that point, the properties stored here are // transferred down to the internal PyObject. - typedef map Properties; + typedef std::map Properties; Properties _properties; }; diff --git a/direct/src/plugin/p3dMultifileReader.I b/direct/src/plugin/p3dMultifileReader.I index eb072e0a3b..ff3daf31b8 100644 --- a/direct/src/plugin/p3dMultifileReader.I +++ b/direct/src/plugin/p3dMultifileReader.I @@ -48,7 +48,7 @@ read_uint32() { */ inline size_t P3DMultifileReader::Subfile:: get_last_byte_pos() const { - return max(_index_start + _index_length, _data_start + _data_length) - 1; + return std::max(_index_start + _index_length, _data_start + _data_length) - 1; } /** diff --git a/direct/src/plugin/p3dMultifileReader.h b/direct/src/plugin/p3dMultifileReader.h index 64a788c263..8f80a1f67c 100644 --- a/direct/src/plugin/p3dMultifileReader.h +++ b/direct/src/plugin/p3dMultifileReader.h @@ -27,14 +27,14 @@ class P3DMultifileReader { public: P3DMultifileReader(); - bool open_read(const string &pathname, const int &offset = 0); + bool open_read(const std::string &pathname, const int &offset = 0); inline bool is_open() const; void close(); - bool extract_all(const string &to_dir, P3DPackage *package, + bool extract_all(const std::string &to_dir, P3DPackage *package, P3DPackage::InstallStepThreaded *step); - bool extract_one(ostream &out, const string &filename); + bool extract_one(std::ostream &out, const std::string &filename); class CertRecord { public: @@ -43,16 +43,16 @@ public: inline ~CertRecord(); X509 *_cert; }; - typedef vector CertChain; + typedef std::vector CertChain; int get_num_signatures() const; const CertChain &get_signature(int n) const; private: class Subfile; - bool read_header(const string &pathname); + bool read_header(const std::string &pathname); bool read_index(); - bool extract_subfile(ostream &out, const Subfile &s); + bool extract_subfile(std::ostream &out, const Subfile &s); void check_signatures(); @@ -73,7 +73,7 @@ private: public: inline size_t get_last_byte_pos() const; - string _filename; + std::string _filename; size_t _index_start; size_t _index_length; size_t _data_start; @@ -85,12 +85,12 @@ private: bool _is_open; int _read_offset; - typedef vector Subfiles; + typedef std::vector Subfiles; Subfiles _subfiles; Subfiles _cert_special; size_t _last_data_byte; - typedef vector Certificates; + typedef std::vector Certificates; Certificates _signatures; static const char _header[]; diff --git a/direct/src/plugin/p3dNoneObject.h b/direct/src/plugin/p3dNoneObject.h index e0272f04cb..06fffe89f9 100644 --- a/direct/src/plugin/p3dNoneObject.h +++ b/direct/src/plugin/p3dNoneObject.h @@ -28,7 +28,7 @@ public: public: virtual P3D_object_type get_type(); virtual bool get_bool(); - virtual void make_string(string &value); + virtual void make_string(std::string &value); }; #endif diff --git a/direct/src/plugin/p3dObject.h b/direct/src/plugin/p3dObject.h index 0cedd291ad..8e69e5bec7 100644 --- a/direct/src/plugin/p3dObject.h +++ b/direct/src/plugin/p3dObject.h @@ -39,18 +39,18 @@ public: int get_string(char *buffer, int buffer_length); int get_repr(char *buffer, int buffer_length); - virtual void make_string(string &value)=0; + virtual void make_string(std::string &value)=0; - virtual P3D_object *get_property(const string &property); - virtual bool set_property(const string &property, bool needs_response, + virtual P3D_object *get_property(const std::string &property); + virtual bool set_property(const std::string &property, bool needs_response, P3D_object *value); - virtual bool has_method(const string &method_name); - virtual P3D_object *call(const string &method_name, bool needs_response, + virtual bool has_method(const std::string &method_name); + virtual P3D_object *call(const std::string &method_name, bool needs_response, P3D_object *params[], int num_params); - virtual P3D_object *eval(const string &expression); + virtual P3D_object *eval(const std::string &expression); - virtual void output(ostream &out); + virtual void output(std::ostream &out); virtual bool fill_xml(TiXmlElement *xvalue, P3DSession *session); virtual P3D_object **get_object_array(); virtual int get_object_array_size(); @@ -58,19 +58,19 @@ public: virtual P3DPythonObject *as_python_object(); // Convenience functions. - bool get_bool_property(const string &property); - void set_bool_property(const string &property, bool value); + bool get_bool_property(const std::string &property); + void set_bool_property(const std::string &property, bool value); - int get_int_property(const string &property); - void set_int_property(const string &property, int value); + int get_int_property(const std::string &property); + void set_int_property(const std::string &property, int value); - double get_float_property(const string &property); - void set_float_property(const string &property, double value); + double get_float_property(const std::string &property); + void set_float_property(const std::string &property, double value); - string get_string_property(const string &property); - void set_string_property(const string &property, const string &value); + std::string get_string_property(const std::string &property); + void set_string_property(const std::string &property, const std::string &value); - void set_undefined_property(const string &property); + void set_undefined_property(const std::string &property); public: static P3D_class_definition _object_class; @@ -83,7 +83,7 @@ public: // method to write the output simply. (For classes that inherit only from // P3D_object, we have to use the generic C method defined in // p3d_plugin_common.h, a little clumsier.) -inline ostream &operator << (ostream &out, P3DObject &value) { +inline std::ostream &operator << (std::ostream &out, P3DObject &value) { value.output(out); return out; } diff --git a/direct/src/plugin/p3dOsxSplashWindow.h b/direct/src/plugin/p3dOsxSplashWindow.h index 2a725412eb..9a2a6225bc 100644 --- a/direct/src/plugin/p3dOsxSplashWindow.h +++ b/direct/src/plugin/p3dOsxSplashWindow.h @@ -32,9 +32,9 @@ public: virtual void set_wparams(const P3DWindowParams &wparams); virtual void set_visible(bool visible); - virtual void set_image_filename(const string &image_filename, + virtual void set_image_filename(const std::string &image_filename, ImagePlacement image_placement); - virtual void set_install_label(const string &install_label); + virtual void set_install_label(const std::string &install_label); virtual void set_install_progress(double install_progress, bool is_progress_known, size_t received_data); @@ -50,7 +50,7 @@ private: bool handle_event_osx_cocoa(const P3D_event_data &event); class OsxImageData; - void load_image(OsxImageData &image, const string &image_filename); + void load_image(OsxImageData &image, const std::string &image_filename); bool paint_image(CGContextRef context, const OsxImageData &image); void paint_progress_bar(CGContextRef context); @@ -82,7 +82,7 @@ private: CFDictionaryRef _font_attribs; - string _install_label; + std::string _install_label; double _install_progress; bool _progress_known; size_t _received_data; diff --git a/direct/src/plugin/p3dPackage.I b/direct/src/plugin/p3dPackage.I index 2b5f40ff73..371491f5c2 100644 --- a/direct/src/plugin/p3dPackage.I +++ b/direct/src/plugin/p3dPackage.I @@ -60,7 +60,7 @@ get_host() const { /** * Returns the directory into which this package is installed. */ -inline const string &P3DPackage:: +inline const std::string &P3DPackage:: get_package_dir() const { return _package_dir; } @@ -71,7 +71,7 @@ get_package_dir() const { * will not contain spaces. See also get_package_display_name() for a name * suitable for displaying to the user. */ -inline const string &P3DPackage:: +inline const std::string &P3DPackage:: get_package_name() const { return _package_name; } @@ -79,7 +79,7 @@ get_package_name() const { /** * Returns the version string of this package. */ -inline const string &P3DPackage:: +inline const std::string &P3DPackage:: get_package_version() const { return _package_version; } @@ -87,7 +87,7 @@ get_package_version() const { /** * Returns the platform string of this package. */ -inline const string &P3DPackage:: +inline const std::string &P3DPackage:: get_package_platform() const { return _package_platform; } @@ -95,7 +95,7 @@ get_package_platform() const { /** * Returns the display_name name of this package, as set in the desc file. */ -inline const string &P3DPackage:: +inline const std::string &P3DPackage:: get_package_display_name() const { return _package_display_name; } @@ -114,7 +114,7 @@ get_xconfig() const { * package, the desc file itself represents the entire contents of the * package. */ -inline const string &P3DPackage:: +inline const std::string &P3DPackage:: get_desc_file_pathname() const { return _desc_file_pathname; } @@ -123,7 +123,7 @@ get_desc_file_pathname() const { * Returns the relative path, on the host, of the directory that contains the * desc file (and to which all of the paths in the desc file are relative). */ -inline const string &P3DPackage:: +inline const std::string &P3DPackage:: get_desc_file_dirname() const { return _desc_file_dirname; } @@ -132,7 +132,7 @@ get_desc_file_dirname() const { * Returns the full path to the package's uncompressed archive file. This is * only valid if get_ready() is true and the package is not a "solo" package. */ -inline string P3DPackage:: +inline std::string P3DPackage:: get_archive_file_pathname() const { return _uncompressed_archive.get_pathname(_package_dir); } @@ -154,7 +154,7 @@ get_progress() const { if (_bytes_needed == 0) { return 1.0; } - return min((double)_bytes_done / (double)_bytes_needed, 1.0); + return std::min((double)_bytes_done / (double)_bytes_needed, 1.0); } /** @@ -169,8 +169,8 @@ report_step_progress() { * */ inline P3DPackage::RequiredPackage:: -RequiredPackage(const string &package_name, const string &package_version, - const string &package_seq, P3DHost *host) : +RequiredPackage(const std::string &package_name, const std::string &package_version, + const std::string &package_seq, P3DHost *host) : _package_name(package_name), _package_version(package_version), _package_seq(package_seq), diff --git a/direct/src/plugin/p3dPackage.h b/direct/src/plugin/p3dPackage.h index b65290f836..4d44282c67 100644 --- a/direct/src/plugin/p3dPackage.h +++ b/direct/src/plugin/p3dPackage.h @@ -38,10 +38,10 @@ class P3DTemporaryFile; class P3DPackage { private: P3DPackage(P3DHost *host, - const string &package_name, - const string &package_version, - const string &package_platform, - const string &alt_host); + const std::string &package_name, + const std::string &package_version, + const std::string &package_platform, + const std::string &alt_host); ~P3DPackage(); public: @@ -52,17 +52,17 @@ public: inline bool get_ready() const; inline bool get_failed() const; inline P3DHost *get_host() const; - inline const string &get_package_dir() const; - inline const string &get_package_name() const; - inline const string &get_package_version() const; - inline const string &get_package_platform() const; - inline const string &get_package_display_name() const; - string get_formatted_name() const; + inline const std::string &get_package_dir() const; + inline const std::string &get_package_name() const; + inline const std::string &get_package_version() const; + inline const std::string &get_package_platform() const; + inline const std::string &get_package_display_name() const; + std::string get_formatted_name() const; inline const TiXmlElement *get_xconfig() const; - inline const string &get_desc_file_pathname() const; - inline const string &get_desc_file_dirname() const; - inline string get_archive_file_pathname() const; + inline const std::string &get_desc_file_pathname() const; + inline const std::string &get_desc_file_dirname() const; + inline std::string get_archive_file_pathname() const; void add_instance(P3DInstance *inst); void remove_instance(P3DInstance *inst); @@ -73,7 +73,7 @@ public: TiXmlElement *make_xml(); private: - typedef vector Extracts; + typedef std::vector Extracts; enum DownloadType { DT_contents_file, @@ -82,7 +82,7 @@ private: DT_install_step, }; - typedef vector TryUrls; + typedef std::vector TryUrls; class Download : public P3DFileDownload { public: @@ -123,7 +123,7 @@ private: virtual ~InstallStep(); virtual InstallToken do_step(bool download_finished) = 0; - virtual void output(ostream &out) = 0; + virtual void output(std::ostream &out) = 0; inline double get_effort() const; inline double get_progress() const; @@ -141,10 +141,10 @@ private: virtual ~InstallStepDownloadFile(); virtual InstallToken do_step(bool download_finished); - virtual void output(ostream &out); + virtual void output(std::ostream &out); - string _urlbase; - string _pathname; + std::string _urlbase; + std::string _pathname; FileSpec _file; Download *_download; }; @@ -174,7 +174,7 @@ private: InstallStepUncompressFile(P3DPackage *package, const FileSpec &source, const FileSpec &target, bool verify_target); virtual InstallToken thread_step(); - virtual void output(ostream &out); + virtual void output(std::ostream &out); FileSpec _source; FileSpec _target; @@ -185,7 +185,7 @@ private: public: InstallStepUnpackArchive(P3DPackage *package, size_t unpack_size); virtual InstallToken thread_step(); - virtual void output(ostream &out); + virtual void output(std::ostream &out); }; class InstallStepApplyPatch : public InstallStepThreaded { @@ -195,13 +195,13 @@ private: const FileSpec &source, const FileSpec &target); virtual InstallToken thread_step(); - virtual void output(ostream &out); + virtual void output(std::ostream &out); P3DPatchfileReader _reader; }; - typedef deque InstallPlan; - typedef deque InstallPlans; + typedef std::deque InstallPlan; + typedef std::deque InstallPlans; InstallPlans _install_plans; bool _computed_plan_size; @@ -230,52 +230,52 @@ private: void report_progress(InstallStep *step); void report_info_ready(); void report_done(bool success); - Download *start_download(DownloadType dtype, const string &urlbase, - const string &pathname, const FileSpec &file_spec); + Download *start_download(DownloadType dtype, const std::string &urlbase, + const std::string &pathname, const FileSpec &file_spec); void set_active_download(Download *download); void set_saved_download(Download *download); - bool is_extractable(FileSpec &file, const string &filename) const; + bool is_extractable(FileSpec &file, const std::string &filename) const; bool instance_terminating(P3DInstance *instance); void set_fullname(); public: class RequiredPackage { public: - inline RequiredPackage(const string &package_name, - const string &package_version, - const string &package_seq, + inline RequiredPackage(const std::string &package_name, + const std::string &package_version, + const std::string &package_seq, P3DHost *host); - string _package_name; - string _package_version; - string _package_seq; + std::string _package_name; + std::string _package_version; + std::string _package_seq; P3DHost *_host; }; - typedef vector Requires; + typedef std::vector Requires; Requires _requires; private: P3DHost *_host; int _host_contents_iseq; - string _package_name; - string _package_version; - string _package_platform; + std::string _package_name; + std::string _package_version; + std::string _package_platform; bool _per_platform; int _patch_version; - string _alt_host; + std::string _alt_host; bool _package_solo; - string _package_display_name; - string _package_fullname; - string _package_dir; + std::string _package_display_name; + std::string _package_fullname; + std::string _package_dir; TiXmlElement *_xconfig; P3DTemporaryFile *_temp_contents_file; FileSpec _desc_file; - string _desc_file_dirname; - string _desc_file_basename; - string _desc_file_pathname; + std::string _desc_file_dirname; + std::string _desc_file_basename; + std::string _desc_file_pathname; bool _info_ready; bool _allow_data_download; @@ -284,7 +284,7 @@ private: Download *_active_download; Download *_saved_download; - typedef vector Instances; + typedef std::vector Instances; Instances _instances; FileSpec _compressed_archive; diff --git a/direct/src/plugin/p3dPatchFinder.h b/direct/src/plugin/p3dPatchFinder.h index d3ee7d02b7..f25145a8e3 100644 --- a/direct/src/plugin/p3dPatchFinder.h +++ b/direct/src/plugin/p3dPatchFinder.h @@ -34,26 +34,26 @@ public: class Patchfile; class PackageVersion; - typedef vector Patchfiles; - typedef vector PackageVersionsList; + typedef std::vector Patchfiles; + typedef std::vector PackageVersionsList; // This class is used to index into a map to locate PackageVersion objects, // below. class PackageVersionKey { public: - PackageVersionKey(const string &package_name, - const string &platform, - const string &version, - const string &host_url, + PackageVersionKey(const std::string &package_name, + const std::string &platform, + const std::string &version, + const std::string &host_url, const FileSpec &file); bool operator < (const PackageVersionKey &other) const; - void output(ostream &out) const; + void output(std::ostream &out) const; public: - string _package_name; - string _platform; - string _version; - string _host_url; + std::string _package_name; + std::string _platform; + std::string _version; + std::string _host_url; FileSpec _file; }; @@ -68,12 +68,12 @@ public: const PackageVersionsList &already_visited_in); public: - string _package_name; - string _platform; - string _version; - string _host_url; + std::string _package_name; + std::string _platform; + std::string _version; + std::string _host_url; FileSpec _file; - string _print_name; + std::string _print_name; // The Package object that produces this version if this is the current // form or the base form, respectively. @@ -98,10 +98,10 @@ public: public: Package *_package; - string _package_name; - string _platform; - string _version; - string _host_url; + std::string _package_name; + std::string _platform; + std::string _version; + std::string _host_url; // The patchfile itself FileSpec _file; @@ -132,10 +132,10 @@ public: bool read_desc_file(TiXmlDocument *doc); public: - string _package_name; - string _platform; - string _version; - string _host_url; + std::string _package_name; + std::string _platform; + std::string _version; + std::string _host_url; PackageVersion *_current_pv; PackageVersion *_base_pv; @@ -162,16 +162,16 @@ private: void record_patchfile(Patchfile *patchfile); private: - typedef map PackageVersions; + typedef std::map PackageVersions; PackageVersions _package_versions; - typedef vector Packages; + typedef std::vector Packages; Packages _packages; }; #include "p3dPatchFinder.I" -inline ostream &operator << (ostream &out, const P3DPatchFinder::PackageVersionKey &key) { +inline std::ostream &operator << (std::ostream &out, const P3DPatchFinder::PackageVersionKey &key) { key.output(out); return out; } diff --git a/direct/src/plugin/p3dPatchfileReader.h b/direct/src/plugin/p3dPatchfileReader.h index 1ad097a5ba..1c9501f5d1 100644 --- a/direct/src/plugin/p3dPatchfileReader.h +++ b/direct/src/plugin/p3dPatchfileReader.h @@ -29,7 +29,7 @@ */ class P3DPatchfileReader { public: - P3DPatchfileReader(const string &package_dir, + P3DPatchfileReader(const std::string &package_dir, const FileSpec &patchfile, const FileSpec &source, const FileSpec &target); @@ -45,18 +45,18 @@ public: void close(); private: - bool copy_bytes(istream &in, size_t copy_byte_count); + bool copy_bytes(std::istream &in, size_t copy_byte_count); inline unsigned int read_uint16(); inline unsigned int read_uint32(); inline int read_int32(); private: - string _package_dir; + std::string _package_dir; FileSpec _patchfile; FileSpec _source; FileSpec _target; - string _output_pathname; + std::string _output_pathname; ifstream _patch_in; ifstream _source_in; ofstream _target_out; diff --git a/direct/src/plugin/p3dPythonObject.h b/direct/src/plugin/p3dPythonObject.h index 980617257e..a4f9c5d7d0 100644 --- a/direct/src/plugin/p3dPythonObject.h +++ b/direct/src/plugin/p3dPythonObject.h @@ -35,20 +35,20 @@ public: virtual int get_int(); virtual double get_float(); - virtual void make_string(string &value); + virtual void make_string(std::string &value); - virtual P3D_object *get_property(const string &property); - virtual bool set_property(const string &property, bool needs_response, P3D_object *value); - bool set_property_insecure(const string &property, bool needs_response, + virtual P3D_object *get_property(const std::string &property); + virtual bool set_property(const std::string &property, bool needs_response, P3D_object *value); + bool set_property_insecure(const std::string &property, bool needs_response, P3D_object *value); - virtual bool has_method(const string &method_name); - virtual P3D_object *call(const string &method_name, bool needs_response, + virtual bool has_method(const std::string &method_name); + virtual P3D_object *call(const std::string &method_name, bool needs_response, P3D_object *params[], int num_params); - P3D_object *call_insecure(const string &method_name, bool needs_response, + P3D_object *call_insecure(const std::string &method_name, bool needs_response, P3D_object *params[], int num_params); - virtual void output(ostream &out); + virtual void output(std::ostream &out); virtual bool fill_xml(TiXmlElement *xvalue, P3DSession *session); virtual P3DPythonObject *as_python_object(); @@ -60,7 +60,7 @@ private: P3DSession *_session; int _object_id; - typedef map HasMethod; + typedef std::map HasMethod; HasMethod _has_method; }; diff --git a/direct/src/plugin/p3dPythonRun.h b/direct/src/plugin/p3dPythonRun.h index 17a8e35371..e478670cca 100644 --- a/direct/src/plugin/p3dPythonRun.h +++ b/direct/src/plugin/p3dPythonRun.h @@ -156,10 +156,10 @@ private: int _py_argc; #if PY_MAJOR_VERSION >= 3 wchar_t *_py_argv[2]; - wstring _program_name; + std::wstring _program_name; #else char *_py_argv[2]; - string _program_name; + std::string _program_name; #endif bool _interactive_console; diff --git a/direct/src/plugin/p3dSession.I b/direct/src/plugin/p3dSession.I index 2ab1155788..010a81c172 100644 --- a/direct/src/plugin/p3dSession.I +++ b/direct/src/plugin/p3dSession.I @@ -15,7 +15,7 @@ * Returns a string that uniquely identifies this session. See * P3dInstance::get_session_key(). */ -inline const string &P3DSession:: +inline const std::string &P3DSession:: get_session_key() const { return _session_key; } @@ -25,7 +25,7 @@ get_session_key() const { * started and if it has a log file. Returns empty string if the session * never started or if it lacks a log file. */ -inline const string &P3DSession:: +inline const std::string &P3DSession:: get_log_pathname() const { return _log_pathname; } diff --git a/direct/src/plugin/p3dSession.h b/direct/src/plugin/p3dSession.h index 88db279379..eca5702fd6 100644 --- a/direct/src/plugin/p3dSession.h +++ b/direct/src/plugin/p3dSession.h @@ -39,8 +39,8 @@ public: void shutdown(); - inline const string &get_session_key() const; - inline const string &get_log_pathname() const; + inline const std::string &get_session_key() const; + inline const std::string &get_log_pathname() const; inline bool get_matches_script_origin() const; void start_instance(P3DInstance *inst); @@ -67,7 +67,7 @@ private: void spawn_read_thread(); void join_read_thread(); - static void replace_slashes(string &str); + static void replace_slashes(std::string &str); private: // These methods run only within the read thread. @@ -87,42 +87,42 @@ private: THREAD_CALLBACK_DECLARATION(P3DSession, p3dpython_thread_run); void p3dpython_thread_run(); - static bool get_env(string &value, const string &varname); + static bool get_env(std::string &value, const std::string &varname); void write_env() const; private: int _session_id; - string _session_key; - string _log_pathname; - string _python_root_dir; - string _start_dir; + std::string _session_key; + std::string _log_pathname; + std::string _python_root_dir; + std::string _start_dir; bool _matches_script_origin; bool _keep_user_env; bool _failed; // This information is passed to create_process(), or to // p3dpython_thread_run(). - string _p3dpython_exe; - string _p3dpython_dll; - string _mf_filename; - string _env; + std::string _p3dpython_exe; + std::string _p3dpython_dll; + std::string _mf_filename; + std::string _env; FHandle _input_handle, _output_handle; bool _interactive_console; - typedef map Instances; + typedef std::map Instances; Instances _instances; LOCK _instances_lock; // Commands that are queued up to send down the pipe. Normally these only // accumulate before the python process has been started; after that, // commands are written to the pipe directly. - typedef vector Commands; + typedef std::vector Commands; Commands _commands; // This map keeps track of the P3D_object pointers we have delivered to the // child process. We have to keep each of these until the child process // tells us it's safe to delete them. - typedef map SentObjects; + typedef std::map SentObjects; SentObjects _sent_objects; P3DPackage *_panda3d; @@ -146,7 +146,7 @@ private: bool _p3dpython_running; // The _response_ready mutex protects this structure. - typedef map Responses; + typedef std::map Responses; Responses _responses; P3DConditionVar _response_ready; diff --git a/direct/src/plugin/p3dSplashWindow.h b/direct/src/plugin/p3dSplashWindow.h index 65c7301d7c..4f67b5c1c0 100644 --- a/direct/src/plugin/p3dSplashWindow.h +++ b/direct/src/plugin/p3dSplashWindow.h @@ -60,7 +60,7 @@ public: FW_black = 900 }; - virtual void set_image_filename(const string &image_filename, + virtual void set_image_filename(const std::string &image_filename, ImagePlacement image_placement); void set_fgcolor(int r, int g, int b); void set_bgcolor(int r, int g, int b); @@ -70,11 +70,11 @@ public: void set_bar_bottom(int bottom); void set_bar_width(int width, bool percent=false); void set_bar_height(int height, bool percent=false); - void set_font_family(const string &family); + void set_font_family(const std::string &family); void set_font_size(int size); void set_font_style(FontStyle style); void set_font_weight(int weight); - virtual void set_install_label(const string &install_label); + virtual void set_install_label(const std::string &install_label); virtual void set_install_progress(double install_progress, bool is_progress_known, size_t received_data); @@ -93,8 +93,8 @@ protected: int _width, _height, _num_channels; }; - bool read_image_data(ImageData &image, string &data, - const string &image_filename); + bool read_image_data(ImageData &image, std::string &data, + const std::string &image_filename); void get_bar_placement(int &bar_x, int &bar_y, int &bar_width, int &bar_height); void set_button_range(const ImageData &image); @@ -131,7 +131,7 @@ private: double _bar_width_ratio, _bar_height_ratio; protected: - string _font_family; + std::string _font_family; int _font_size; FontStyle _font_style; int _font_weight; diff --git a/direct/src/plugin/p3dStringObject.h b/direct/src/plugin/p3dStringObject.h index 22366023f7..3e358e56b9 100644 --- a/direct/src/plugin/p3dStringObject.h +++ b/direct/src/plugin/p3dStringObject.h @@ -22,7 +22,7 @@ */ class P3DStringObject : public P3DObject { public: - P3DStringObject(const string &value); + P3DStringObject(const std::string &value); P3DStringObject(const char *data, size_t size); P3DStringObject(const P3DStringObject ©); @@ -31,12 +31,12 @@ public: virtual P3D_object_type get_type(); virtual bool get_bool(); - virtual void make_string(string &value); + virtual void make_string(std::string &value); - virtual void output(ostream &out); + virtual void output(std::ostream &out); private: - string _value; + std::string _value; }; #endif diff --git a/direct/src/plugin/p3dTemporaryFile.I b/direct/src/plugin/p3dTemporaryFile.I index 104fefa420..c1d8eeb7e2 100644 --- a/direct/src/plugin/p3dTemporaryFile.I +++ b/direct/src/plugin/p3dTemporaryFile.I @@ -14,7 +14,7 @@ /** * Returns the temporary filename. */ -inline const string &P3DTemporaryFile:: +inline const std::string &P3DTemporaryFile:: get_filename() const { return _filename; } diff --git a/direct/src/plugin/p3dTemporaryFile.h b/direct/src/plugin/p3dTemporaryFile.h index f4b87df247..57fb6cef5a 100644 --- a/direct/src/plugin/p3dTemporaryFile.h +++ b/direct/src/plugin/p3dTemporaryFile.h @@ -26,16 +26,16 @@ */ class P3DTemporaryFile { public: - P3DTemporaryFile(const string &extension); + P3DTemporaryFile(const std::string &extension); ~P3DTemporaryFile(); - inline const string &get_filename() const; + inline const std::string &get_filename() const; private: - string _filename; + std::string _filename; }; -inline ostream &operator << (ostream &out, P3DTemporaryFile &tfile) { +inline std::ostream &operator << (std::ostream &out, P3DTemporaryFile &tfile) { return out << tfile.get_filename(); } diff --git a/direct/src/plugin/p3dUndefinedObject.h b/direct/src/plugin/p3dUndefinedObject.h index 9ab8189de6..3cba1d73b4 100644 --- a/direct/src/plugin/p3dUndefinedObject.h +++ b/direct/src/plugin/p3dUndefinedObject.h @@ -29,7 +29,7 @@ public: public: virtual P3D_object_type get_type(); virtual bool get_bool(); - virtual void make_string(string &value); + virtual void make_string(std::string &value); }; #endif diff --git a/direct/src/plugin/p3dWinSplashWindow.h b/direct/src/plugin/p3dWinSplashWindow.h index 852d794cb8..713157c921 100644 --- a/direct/src/plugin/p3dWinSplashWindow.h +++ b/direct/src/plugin/p3dWinSplashWindow.h @@ -34,9 +34,9 @@ public: virtual void set_wparams(const P3DWindowParams &wparams); virtual void set_visible(bool visible); - virtual void set_image_filename(const string &image_filename, + virtual void set_image_filename(const std::string &image_filename, ImagePlacement image_placement); - virtual void set_install_label(const string &install_label); + virtual void set_install_label(const std::string &install_label); virtual void set_install_progress(double install_progress, bool is_progress_known, size_t received_data); virtual void request_keyboard_focus(); @@ -75,7 +75,7 @@ private: inline ~WinImageData(); void dump_image(); - string _filename; + std::string _filename; bool _filename_changed; HBITMAP _bitmap; }; @@ -86,14 +86,14 @@ private: WinImageData _button_click_image; bool _got_install; - string _install_label; + std::string _install_label; double _install_progress; bool _progress_known; size_t _received_data; LOCK _install_lock; ButtonState _drawn_bstate; - string _drawn_label; + std::string _drawn_label; double _drawn_progress; bool _drawn_progress_known; size_t _drawn_received_data; diff --git a/direct/src/plugin/p3dX11SplashWindow.h b/direct/src/plugin/p3dX11SplashWindow.h index 892fc6e4cb..72c6ac00d0 100644 --- a/direct/src/plugin/p3dX11SplashWindow.h +++ b/direct/src/plugin/p3dX11SplashWindow.h @@ -34,9 +34,9 @@ public: virtual void set_wparams(const P3DWindowParams &wparams); virtual void set_visible(bool visible); - virtual void set_image_filename(const string &image_filename, + virtual void set_image_filename(const std::string &image_filename, ImagePlacement image_placement); - virtual void set_install_label(const string &install_label); + virtual void set_install_label(const std::string &install_label); virtual void set_install_progress(double install_progress, bool is_progress_known, size_t received_data); @@ -85,12 +85,12 @@ private: void update_image(X11ImageData &image); void compose_image(); - bool scale_image(vector &image0, int &image0_width, int &image0_height, + bool scale_image(std::vector &image0, int &image0_width, int &image0_height, X11ImageData &image); - void compose_two_images(vector &image0, int &image0_width, int &image0_height, - const vector &image1, int image1_width, int image1_height, - const vector &image2, int image2_width, int image2_height); + void compose_two_images(std::vector &image0, int &image0_width, int &image0_height, + const std::vector &image1, int image1_width, int image1_height, + const std::vector &image2, int image2_width, int image2_height); private: // Data members that are stored in the subprocess. @@ -99,9 +99,9 @@ private: inline X11ImageData(); inline ~X11ImageData(); - string _filename; + std::string _filename; bool _filename_changed; - string _data; + std::string _data; }; X11ImageData _background_image; @@ -116,12 +116,12 @@ private: bool _subprocess_continue; bool _own_display; - string _install_label; + std::string _install_label; double _install_progress; bool _progress_known; size_t _received_data; - string _label_text; + std::string _label_text; X11_Display *_display; int _screen; diff --git a/direct/src/plugin/p3d_plugin_common.h b/direct/src/plugin/p3d_plugin_common.h index 538f69f466..748005c48d 100644 --- a/direct/src/plugin/p3d_plugin_common.h +++ b/direct/src/plugin/p3d_plugin_common.h @@ -37,15 +37,15 @@ using namespace std; // Appears in p3dInstanceManager.cxx. -extern ostream *nout_stream; +extern std::ostream *nout_stream; #define nout (*nout_stream) // Appears in p3d_plugin.cxx. extern LOCK _api_lock; // A convenience function for formatting a generic P3D_object to an ostream. -inline ostream & -operator << (ostream &out, P3D_object &value) { +inline std::ostream & +operator << (std::ostream &out, P3D_object &value) { int size = P3D_OBJECT_GET_REPR(&value, nullptr, 0); char *buffer = new char[size]; P3D_OBJECT_GET_REPR(&value, buffer, size); diff --git a/direct/src/plugin/parse_color.h b/direct/src/plugin/parse_color.h index cbbed95e03..ba5dd152a8 100644 --- a/direct/src/plugin/parse_color.h +++ b/direct/src/plugin/parse_color.h @@ -17,6 +17,6 @@ #include using namespace std; -bool parse_color(int &r, int &g, int &b, const string &color); +bool parse_color(int &r, int &g, int &b, const std::string &color); #endif diff --git a/direct/src/plugin/wstring_encode.h b/direct/src/plugin/wstring_encode.h index 8f36f88209..5d5ebab4de 100644 --- a/direct/src/plugin/wstring_encode.h +++ b/direct/src/plugin/wstring_encode.h @@ -21,13 +21,13 @@ using namespace std; // the only place they are needed. (Only Windows requires wstrings for // filenames.) #ifdef _WIN32 -bool wstring_to_string(string &result, const wstring &source); -bool string_to_wstring(wstring &result, const string &source); +bool wstring_to_string(std::string &result, const std::wstring &source); +bool string_to_wstring(std::wstring &result, const std::string &source); // We declare this inline so it won't conflict with the similar function // defined in Panda's textEncoder.h. -inline ostream &operator << (ostream &out, const wstring &str) { - string result; +inline std::ostream &operator << (std::ostream &out, const std::wstring &str) { + std::string result; if (wstring_to_string(result, str)) { out << result; } diff --git a/direct/src/plugin/xml_helpers.h b/direct/src/plugin/xml_helpers.h index ea540bcf7a..d64047f55a 100644 --- a/direct/src/plugin/xml_helpers.h +++ b/direct/src/plugin/xml_helpers.h @@ -16,7 +16,7 @@ #include "get_tinyxml.h" -bool parse_bool_attrib(TiXmlElement *xelem, const string &attrib, +bool parse_bool_attrib(TiXmlElement *xelem, const std::string &attrib, bool default_value); #endif diff --git a/direct/src/plugin_activex/PPInstance.h b/direct/src/plugin_activex/PPInstance.h index 1c80168aea..8b59b6a3ac 100644 --- a/direct/src/plugin_activex/PPInstance.h +++ b/direct/src/plugin_activex/PPInstance.h @@ -81,7 +81,7 @@ protected: bool HandleRequest( P3D_request *request ); static void HandleRequestGetUrl( void *data ); - static int compare_seq(const string &seq_a, const string &seq_b); + static int compare_seq(const std::string &seq_a, const std::string &seq_b); static int compare_seq_int(const char *&num_a, const char *&num_b); void set_failed(); @@ -100,7 +100,7 @@ protected: std::string _download_url_prefix; typedef std::vector Mirrors; Mirrors _mirrors; - string _coreapi_set_ver; + std::string _coreapi_set_ver; FileSpec _coreapi_dll; time_t _contents_expiration; bool _failed; diff --git a/direct/src/plugin_npapi/nppanda3d_common.h b/direct/src/plugin_npapi/nppanda3d_common.h index 512281ea3d..a3bb8f0191 100644 --- a/direct/src/plugin_npapi/nppanda3d_common.h +++ b/direct/src/plugin_npapi/nppanda3d_common.h @@ -33,10 +33,10 @@ using namespace std; // Appears in startup.cxx. -extern ostream *nout_stream; +extern std::ostream *nout_stream; #define nout (*nout_stream) -extern string global_root_dir; +extern std::string global_root_dir; extern bool has_plugin_thread_async_call; #ifdef _WIN32 diff --git a/direct/src/plugin_npapi/ppBrowserObject.h b/direct/src/plugin_npapi/ppBrowserObject.h index 8274ea8f34..3b0835b450 100644 --- a/direct/src/plugin_npapi/ppBrowserObject.h +++ b/direct/src/plugin_npapi/ppBrowserObject.h @@ -32,13 +32,13 @@ public: ~PPBrowserObject(); int get_repr(char *buffer, int buffer_length) const; - P3D_object *get_property(const string &property) const; - bool set_property(const string &property, bool needs_response, + P3D_object *get_property(const std::string &property) const; + bool set_property(const std::string &property, bool needs_response, P3D_object *value); - P3D_object *call(const string &method_name, + P3D_object *call(const std::string &method_name, P3D_object *params[], int num_params) const; - P3D_object *eval(const string &expression) const; + P3D_object *eval(const std::string &expression) const; static void clear_class_definition(); diff --git a/direct/src/plugin_npapi/ppInstance.h b/direct/src/plugin_npapi/ppInstance.h index 86fa9bbf93..f24ebb6443 100644 --- a/direct/src/plugin_npapi/ppInstance.h +++ b/direct/src/plugin_npapi/ppInstance.h @@ -74,38 +74,38 @@ public: void p3dobj_to_variant(NPVariant *result, P3D_object *object); P3D_object *variant_to_p3dobj(const NPVariant *variant); - static void output_np_variant(ostream &out, const NPVariant &result); + static void output_np_variant(std::ostream &out, const NPVariant &result); private: void find_host(TiXmlElement *xcontents); void read_xhost(TiXmlElement *xhost); - void add_mirror(string mirror_url); - void choose_random_mirrors(vector &result, int num_mirrors); + void add_mirror(std::string mirror_url); + void choose_random_mirrors(std::vector &result, int num_mirrors); static void request_ready(P3D_instance *instance); - void start_download(const string &url, PPDownloadRequest *req); - void downloaded_file(PPDownloadRequest *req, const string &filename); - static string get_filename_from_url(const string &url); - void feed_file(PPDownloadRequest *req, const string &filename); + void start_download(const std::string &url, PPDownloadRequest *req); + void downloaded_file(PPDownloadRequest *req, const std::string &filename); + static std::string get_filename_from_url(const std::string &url); + void feed_file(PPDownloadRequest *req, const std::string &filename); void open_p3d_temp_file(); void send_p3d_temp_file_data(); - void downloaded_contents_file(const string &filename); - bool read_contents_file(const string &contents_filename, bool fresh_download); + void downloaded_contents_file(const std::string &filename); + bool read_contents_file(const std::string &contents_filename, bool fresh_download); void get_core_api(); - void downloaded_plugin(const string &filename); + void downloaded_plugin(const std::string &filename); void do_load_plugin(); void create_instance(); void send_window(); void cleanup_window(); - bool copy_file(const string &from_filename, const string &to_filename); + bool copy_file(const std::string &from_filename, const std::string &to_filename); - string lookup_token(const string &keyword) const; - bool has_token(const string &keyword) const; - static int compare_seq(const string &seq_a, const string &seq_b); + std::string lookup_token(const std::string &keyword) const; + bool has_token(const std::string &keyword) const; + static int compare_seq(const std::string &seq_a, const std::string &seq_b); static int compare_seq_int(const char *&num_a, const char *&num_b); void set_failed(); @@ -123,15 +123,15 @@ private: class EventAuxData { public: - wstring _characters; - wstring _characters_im; - wstring _text; + std::wstring _characters; + std::wstring _characters_im; + std::wstring _text; }; #ifdef MACOSX_HAS_EVENT_MODELS static void copy_cocoa_event(P3DCocoaEvent *p3d_event, NPCocoaEvent *np_event, EventAuxData &aux_data); - static const wchar_t *make_ansi_string(wstring &result, NPNSString *ns_string); + static const wchar_t *make_ansi_string(std::wstring &result, NPNSString *ns_string); void handle_cocoa_event(const P3DCocoaEvent *p3d_event); void osx_get_twirl_images(); void osx_release_twirl_images(); @@ -157,24 +157,24 @@ private: unsigned int _npp_mode; P3D_window_handle_type _window_handle_type; P3D_event_type _event_type; - typedef vector Tokens; + typedef std::vector Tokens; Tokens _tokens; // Set from fgcolor & bgcolor. int _fgcolor_r, _fgcolor_b, _fgcolor_g; int _bgcolor_r, _bgcolor_b, _bgcolor_g; - string _root_dir; - string _standard_url_prefix; - string _download_url_prefix; - typedef vector Mirrors; + std::string _root_dir; + std::string _standard_url_prefix; + std::string _download_url_prefix; + typedef std::vector Mirrors; Mirrors _mirrors; // A list of URL's that we will attempt to download the core API from. - typedef vector CoreUrls; + typedef std::vector CoreUrls; CoreUrls _core_urls; - string _coreapi_set_ver; + std::string _coreapi_set_ver; FileSpec _coreapi_dll; time_t _contents_expiration; bool _failed; @@ -199,11 +199,11 @@ private: size_t _current_size; size_t _total_size; ofstream _stream; - string _filename; + std::string _filename; }; bool _got_instance_url; - string _instance_url; + std::string _instance_url; int _p3d_instance_id; StreamTempFile _p3d_temp_file; StreamTempFile _contents_temp_file; @@ -212,14 +212,14 @@ private: // We need to keep a list of the NPStream objects that the instance owns, // because Safari (at least) won't automatically delete all of the // outstanding streams when the instance is destroyed. - typedef vector Streams; + typedef std::vector Streams; Streams _streams; // This class is used for feeding local files (accessed via a "file:" url) // into the core API. class StreamingFileData { public: - StreamingFileData(PPDownloadRequest *req, const string &filename, + StreamingFileData(PPDownloadRequest *req, const std::string &filename, P3D_instance *p3d_inst); ~StreamingFileData(); @@ -235,7 +235,7 @@ private: P3D_instance *_p3d_inst; int _user_id; - string _filename; + std::string _filename; ifstream _file; size_t _file_size; size_t _total_count; @@ -243,7 +243,7 @@ private: THREAD _thread; }; - typedef vector FileDatas; + typedef std::vector FileDatas; static FileDatas _file_datas; bool _use_xembed; diff --git a/direct/src/plugin_npapi/ppPandaObject.h b/direct/src/plugin_npapi/ppPandaObject.h index 762f6a9c94..89a87d02af 100644 --- a/direct/src/plugin_npapi/ppPandaObject.h +++ b/direct/src/plugin_npapi/ppPandaObject.h @@ -49,7 +49,7 @@ private: bool enumerate(NPIdentifier **value, uint32_t *count); private: - static string identifier_to_string(NPIdentifier ident); + static std::string identifier_to_string(NPIdentifier ident); private: diff --git a/direct/src/plugin_standalone/p3dEmbed.h b/direct/src/plugin_standalone/p3dEmbed.h index 98a73ec8fc..7d1da92883 100644 --- a/direct/src/plugin_standalone/p3dEmbed.h +++ b/direct/src/plugin_standalone/p3dEmbed.h @@ -35,9 +35,9 @@ class P3DEmbed : public Panda3DBase { public: P3DEmbed(bool console_environment); - int run_embedded(streampos read_offset, int argc, char *argv[]); + int run_embedded(std::streampos read_offset, int argc, char *argv[]); - streampos _read_offset_check; + std::streampos _read_offset_check; }; #endif diff --git a/direct/src/plugin_standalone/panda3d.h b/direct/src/plugin_standalone/panda3d.h index 8333177bb2..a9b647fc7d 100644 --- a/direct/src/plugin_standalone/panda3d.h +++ b/direct/src/plugin_standalone/panda3d.h @@ -43,7 +43,7 @@ protected: bool read_contents_file(const Filename &contents_filename, bool fresh_download); void find_host(TiXmlElement *xcontents); void read_xhost(TiXmlElement *xhost); - void add_mirror(string mirror_url); + void add_mirror(std::string mirror_url); void choose_random_mirrors(vector_string &result, int num_mirrors); bool get_core_api(); bool download_core_api(); @@ -51,14 +51,14 @@ protected: void usage(); protected: - string _super_mirror_url; - string _host_url_prefix; - string _download_url_prefix; - string _super_mirror_url_prefix; - typedef pvector Mirrors; + std::string _super_mirror_url; + std::string _host_url_prefix; + std::string _download_url_prefix; + std::string _super_mirror_url_prefix; + typedef pvector Mirrors; Mirrors _mirrors; - string _coreapi_set_ver; + std::string _coreapi_set_ver; FileSpec _coreapi_dll; }; diff --git a/direct/src/plugin_standalone/panda3dBase.h b/direct/src/plugin_standalone/panda3dBase.h index fd277ce9ec..3b41aab07c 100644 --- a/direct/src/plugin_standalone/panda3dBase.h +++ b/direct/src/plugin_standalone/panda3dBase.h @@ -45,17 +45,17 @@ protected: void make_parent_window(); P3D_instance * - create_instance(const string &p3d, bool start_instance, + create_instance(const std::string &p3d, bool start_instance, char **args, int num_args, int p3d_offset = 0); void delete_instance(P3D_instance *instance); bool read_p3d_info(const Filename &p3d_filename, int p3d_offset = 0); bool parse_token(const char *arg); bool parse_int_pair(const char *arg, int &x, int &y); - string lookup_token(const string &keyword) const; - static int compare_seq(const string &seq_a, const string &seq_b); + std::string lookup_token(const std::string &keyword) const; + static int compare_seq(const std::string &seq_a, const std::string &seq_b); static int compare_seq_int(const char *&num_a, const char *&num_b); - static bool is_url(const string ¶m); + static bool is_url(const std::string ¶m); void report_downloading_package(P3D_instance *instance); void report_download_complete(P3D_instance *instance); @@ -68,14 +68,14 @@ protected: #endif protected: - string _host_url; - string _root_dir; - string _host_dir; - string _start_dir; - string _log_dirname; - string _log_basename; - string _this_platform; - string _coreapi_platform; + std::string _host_url; + std::string _root_dir; + std::string _host_dir; + std::string _start_dir; + std::string _log_dirname; + std::string _log_basename; + std::string _this_platform; + std::string _coreapi_platform; P3D_verify_contents _verify_contents; time_t _contents_expiration; @@ -101,7 +101,7 @@ protected: class URLGetter { public: URLGetter(P3D_instance *instance, int unique_id, - const URLSpec &url, const string &post_data); + const URLSpec &url, const std::string &post_data); bool run(); inline P3D_instance *get_instance(); @@ -110,7 +110,7 @@ protected: P3D_instance *_instance; int _unique_id; URLSpec _url; - string _post_data; + std::string _post_data; PT(HTTPChannel) _channel; Ramfile _rf; diff --git a/dtool/src/cppparser/cppArrayType.h b/dtool/src/cppparser/cppArrayType.h index 9e2489be72..a0ca28680d 100644 --- a/dtool/src/cppparser/cppArrayType.h +++ b/dtool/src/cppparser/cppArrayType.h @@ -44,12 +44,12 @@ public: virtual bool is_copy_constructible() const; virtual bool is_equivalent(const CPPType &other) const; - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; - virtual void output_instance(ostream &out, int indent_level, + virtual void output_instance(std::ostream &out, int indent_level, CPPScope *scope, - bool complete, const string &prename, - const string &name) const; + bool complete, const std::string &prename, + const std::string &name) const; virtual SubType get_subtype() const; diff --git a/dtool/src/cppparser/cppBisonDefs.h b/dtool/src/cppparser/cppBisonDefs.h index 1ae1caece8..1c7be65b85 100644 --- a/dtool/src/cppparser/cppBisonDefs.h +++ b/dtool/src/cppparser/cppBisonDefs.h @@ -66,7 +66,7 @@ extern CPPPreprocessor *current_lexer; class cppyystype { public: - string str; + std::string str; union { unsigned long long integer; long double real; diff --git a/dtool/src/cppparser/cppClassTemplateParameter.h b/dtool/src/cppparser/cppClassTemplateParameter.h index 5192619ed2..8ff6fe1538 100644 --- a/dtool/src/cppparser/cppClassTemplateParameter.h +++ b/dtool/src/cppparser/cppClassTemplateParameter.h @@ -29,7 +29,7 @@ public: CPPType *default_type = nullptr); virtual bool is_fully_specified() const; - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; virtual SubType get_subtype() const; diff --git a/dtool/src/cppparser/cppClosureType.h b/dtool/src/cppparser/cppClosureType.h index 96ac38ed17..9e11a2f124 100644 --- a/dtool/src/cppparser/cppClosureType.h +++ b/dtool/src/cppparser/cppClosureType.h @@ -35,7 +35,7 @@ public: void operator = (const CPPClosureType ©); struct Capture { - string _name; + std::string _name; CaptureType _type; CPPExpression *_initializer; }; @@ -44,7 +44,7 @@ public: CaptureType _default_capture; - void add_capture(string name, CaptureType type, CPPExpression *initializer = nullptr); + void add_capture(std::string name, CaptureType type, CPPExpression *initializer = nullptr); virtual bool is_fully_specified() const; @@ -52,7 +52,7 @@ public: virtual bool is_copy_constructible() const; virtual bool is_destructible() const; - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; virtual SubType get_subtype() const; virtual CPPClosureType *as_closure_type(); diff --git a/dtool/src/cppparser/cppCommentBlock.h b/dtool/src/cppparser/cppCommentBlock.h index 614012ce61..e31b3b6278 100644 --- a/dtool/src/cppparser/cppCommentBlock.h +++ b/dtool/src/cppparser/cppCommentBlock.h @@ -33,7 +33,7 @@ public: int _col_number; int _last_line; bool _c_style; - string _comment; + std::string _comment; }; typedef std::list CPPComments; diff --git a/dtool/src/cppparser/cppConstType.h b/dtool/src/cppparser/cppConstType.h index ef0943ca13..4f49a94c54 100644 --- a/dtool/src/cppparser/cppConstType.h +++ b/dtool/src/cppparser/cppConstType.h @@ -46,12 +46,12 @@ public: virtual bool is_convertible_to(const CPPType *other) const; virtual bool is_equivalent(const CPPType &other) const; - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; - virtual void output_instance(ostream &out, int indent_level, + virtual void output_instance(std::ostream &out, int indent_level, CPPScope *scope, - bool complete, const string &prename, - const string &name) const; + bool complete, const std::string &prename, + const std::string &name) const; virtual SubType get_subtype() const; diff --git a/dtool/src/cppparser/cppDeclaration.h b/dtool/src/cppparser/cppDeclaration.h index f590f435fa..d472c277fd 100644 --- a/dtool/src/cppparser/cppDeclaration.h +++ b/dtool/src/cppparser/cppDeclaration.h @@ -107,15 +107,15 @@ public: CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink = nullptr) const; - typedef map SubstDecl; + typedef std::map SubstDecl; virtual CPPDeclaration *substitute_decl(SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope); - typedef set Instantiations; + typedef std::set Instantiations; Instantiations _instantiations; - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const=0; virtual SubType get_subtype() const=0; @@ -224,13 +224,13 @@ protected: virtual bool is_less(const CPPDeclaration *other) const; }; -inline ostream & -operator << (ostream &out, const CPPDeclaration &decl) { +inline std::ostream & +operator << (std::ostream &out, const CPPDeclaration &decl) { decl.output(out, 0, nullptr, false); return out; } -ostream & -operator << (ostream &out, const CPPDeclaration::SubstDecl &decl); +std::ostream & +operator << (std::ostream &out, const CPPDeclaration::SubstDecl &decl); #endif diff --git a/dtool/src/cppparser/cppEnumType.h b/dtool/src/cppparser/cppEnumType.h index a218feead4..678e1985c3 100644 --- a/dtool/src/cppparser/cppEnumType.h +++ b/dtool/src/cppparser/cppEnumType.h @@ -39,7 +39,7 @@ public: bool is_scoped() const; CPPType *get_underlying_type(); - CPPInstance *add_element(const string &name, CPPExpression *value, + CPPInstance *add_element(const std::string &name, CPPExpression *value, CPPPreprocessor *preprocessor, const cppyyltype &pos); virtual bool is_incomplete() const; @@ -49,7 +49,7 @@ public: CPPScope *current_scope, CPPScope *global_scope); - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; virtual SubType get_subtype() const; @@ -59,7 +59,7 @@ public: CPPScope *_scope; CPPType *_element_type; - typedef vector Elements; + typedef std::vector Elements; Elements _elements; CPPExpression *_last_value; }; diff --git a/dtool/src/cppparser/cppExpression.h b/dtool/src/cppparser/cppExpression.h index 0f9bc880e4..4482727f53 100644 --- a/dtool/src/cppparser/cppExpression.h +++ b/dtool/src/cppparser/cppExpression.h @@ -73,7 +73,7 @@ public: CPPExpression(bool value); CPPExpression(unsigned long long value); CPPExpression(int value); - CPPExpression(const string &value); + CPPExpression(const std::string &value); CPPExpression(long double value); CPPExpression(CPPIdentifier *ident, CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink = nullptr); @@ -96,7 +96,7 @@ public: static CPPExpression literal(unsigned long long value, CPPInstance *lit_op); static CPPExpression literal(long double value, CPPInstance *lit_op); static CPPExpression literal(CPPExpression *value, CPPInstance *lit_op); - static CPPExpression raw_literal(const string &raw, CPPInstance *lit_op); + static CPPExpression raw_literal(const std::string &raw, CPPInstance *lit_op); static const CPPExpression &get_nullptr(); static const CPPExpression &get_default(); @@ -120,7 +120,7 @@ public: double as_real() const; void *as_pointer() const; bool as_boolean() const; - void output(ostream &out) const; + void output(std::ostream &out) const; ResultType _type; union { @@ -140,14 +140,14 @@ public: CPPScope *current_scope, CPPScope *global_scope); - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; virtual SubType get_subtype() const; virtual CPPExpression *as_expression(); Type _type; - string _str; + std::string _str; union { bool _boolean; unsigned long long _integer; @@ -191,8 +191,8 @@ protected: virtual bool is_less(const CPPDeclaration *other) const; }; -inline ostream & -operator << (ostream &out, const CPPExpression::Result &result) { +inline std::ostream & +operator << (std::ostream &out, const CPPExpression::Result &result) { result.output(out); return out; } diff --git a/dtool/src/cppparser/cppExpressionParser.h b/dtool/src/cppparser/cppExpressionParser.h index f9ef78dafc..9a2cdf67a4 100644 --- a/dtool/src/cppparser/cppExpressionParser.h +++ b/dtool/src/cppparser/cppExpressionParser.h @@ -29,18 +29,18 @@ public: CPPExpressionParser(CPPScope *current_scope, CPPScope *global_scope); ~CPPExpressionParser(); - bool parse_expr(const string &expr); - bool parse_expr(const string &expr, const CPPPreprocessor &filepos); + bool parse_expr(const std::string &expr); + bool parse_expr(const std::string &expr, const CPPPreprocessor &filepos); - void output(ostream &out) const; + void output(std::ostream &out) const; CPPScope *_current_scope; CPPScope *_global_scope; CPPExpression *_expr; }; -inline ostream & -operator << (ostream &out, const CPPExpressionParser &ep) { +inline std::ostream & +operator << (std::ostream &out, const CPPExpressionParser &ep) { ep.output(out); return out; } diff --git a/dtool/src/cppparser/cppExtensionType.h b/dtool/src/cppparser/cppExtensionType.h index 5a44788af2..b47c084c88 100644 --- a/dtool/src/cppparser/cppExtensionType.h +++ b/dtool/src/cppparser/cppExtensionType.h @@ -41,9 +41,9 @@ public: CPPExtensionType(Type type, CPPIdentifier *ident, CPPScope *current_scope, const CPPFile &file); - virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = nullptr) const; - virtual string get_fully_scoped_name() const; + virtual std::string get_simple_name() const; + virtual std::string get_local_name(CPPScope *scope = nullptr) const; + virtual std::string get_fully_scoped_name() const; virtual bool is_incomplete() const; virtual bool is_tbd() const; @@ -64,7 +64,7 @@ public: virtual bool is_equivalent(const CPPType &other) const; - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; virtual SubType get_subtype() const; @@ -75,6 +75,6 @@ public: CPPExpression *_alignment; }; -ostream &operator << (ostream &out, CPPExtensionType::Type type); +std::ostream &operator << (std::ostream &out, CPPExtensionType::Type type); #endif diff --git a/dtool/src/cppparser/cppFile.h b/dtool/src/cppparser/cppFile.h index f3644fce3c..cd049e780f 100644 --- a/dtool/src/cppparser/cppFile.h +++ b/dtool/src/cppparser/cppFile.h @@ -59,7 +59,7 @@ public: mutable bool _pragma_once; }; -inline ostream &operator << (ostream &out, const CPPFile &file) { +inline std::ostream &operator << (std::ostream &out, const CPPFile &file) { return out << file._filename; } diff --git a/dtool/src/cppparser/cppFunctionGroup.h b/dtool/src/cppparser/cppFunctionGroup.h index c33eee3907..3fced8f4ab 100644 --- a/dtool/src/cppparser/cppFunctionGroup.h +++ b/dtool/src/cppparser/cppFunctionGroup.h @@ -28,20 +28,20 @@ class CPPInstance; */ class CPPFunctionGroup : public CPPDeclaration { public: - CPPFunctionGroup(const string &name); + CPPFunctionGroup(const std::string &name); ~CPPFunctionGroup(); CPPType *get_return_type() const; - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; virtual SubType get_subtype() const; virtual CPPFunctionGroup *as_function_group(); - typedef vector Instances; + typedef std::vector Instances; Instances _instances; - string _name; + std::string _name; }; #endif diff --git a/dtool/src/cppparser/cppFunctionType.h b/dtool/src/cppparser/cppFunctionType.h index b6bdff7ac6..83fc3ababd 100644 --- a/dtool/src/cppparser/cppFunctionType.h +++ b/dtool/src/cppparser/cppFunctionType.h @@ -69,18 +69,18 @@ public: virtual bool is_tbd() const; virtual bool is_trivial() const; - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; - void output(ostream &out, int indent_level, CPPScope *scope, + void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete, int num_default_parameters) const; - virtual void output_instance(ostream &out, int indent_level, + virtual void output_instance(std::ostream &out, int indent_level, CPPScope *scope, - bool complete, const string &prename, - const string &name) const; - void output_instance(ostream &out, int indent_level, + bool complete, const std::string &prename, + const std::string &name) const; + void output_instance(std::ostream &out, int indent_level, CPPScope *scope, - bool complete, const string &prename, - const string &name, + bool complete, const std::string &prename, + const std::string &name, int num_default_parameters) const; int get_num_default_parameters() const; diff --git a/dtool/src/cppparser/cppGlobals.h b/dtool/src/cppparser/cppGlobals.h index 9cf4e8711a..39755f18d7 100644 --- a/dtool/src/cppparser/cppGlobals.h +++ b/dtool/src/cppparser/cppGlobals.h @@ -20,7 +20,7 @@ // 64-bit integer, but don't recognize "long long int". To parse (and // generate) code for these compilers, set this string to the 64-bit integer // typename keyword. -extern string cpp_longlong_keyword; +extern std::string cpp_longlong_keyword; #endif diff --git a/dtool/src/cppparser/cppIdentifier.h b/dtool/src/cppparser/cppIdentifier.h index 57daf3b469..8916320450 100644 --- a/dtool/src/cppparser/cppIdentifier.h +++ b/dtool/src/cppparser/cppIdentifier.h @@ -34,11 +34,11 @@ class CPPTemplateParameterList; */ class CPPIdentifier { public: - CPPIdentifier(const string &name, const CPPFile &file = CPPFile()); + CPPIdentifier(const std::string &name, const CPPFile &file = CPPFile()); CPPIdentifier(const CPPNameComponent &name, const CPPFile &file = CPPFile()); - CPPIdentifier(const string &name, const cppyyltype &loc); + CPPIdentifier(const std::string &name, const cppyyltype &loc); CPPIdentifier(const CPPNameComponent &name, const cppyyltype &loc); - void add_name(const string &name); + void add_name(const std::string &name); void add_name(const CPPNameComponent &name); bool operator == (const CPPIdentifier &other) const; @@ -47,9 +47,9 @@ public: bool is_scoped() const; - string get_simple_name() const; - string get_local_name(CPPScope *scope = nullptr) const; - string get_fully_scoped_name() const; + std::string get_simple_name() const; + std::string get_local_name(CPPScope *scope = nullptr) const; + std::string get_fully_scoped_name() const; bool is_fully_specified() const; bool is_tbd() const; @@ -85,17 +85,17 @@ public: CPPScope *current_scope, CPPScope *global_scope); - void output(ostream &out, CPPScope *scope) const; - void output_local_name(ostream &out, CPPScope *scope) const; - void output_fully_scoped_name(ostream &out) const; + void output(std::ostream &out, CPPScope *scope) const; + void output_local_name(std::ostream &out, CPPScope *scope) const; + void output_fully_scoped_name(std::ostream &out) const; - typedef vector Names; + typedef std::vector Names; Names _names; CPPScope *_native_scope; cppyyltype _loc; }; -inline ostream &operator << (ostream &out, const CPPIdentifier &identifier) { +inline std::ostream &operator << (std::ostream &out, const CPPIdentifier &identifier) { identifier.output(out, nullptr); return out; } diff --git a/dtool/src/cppparser/cppInstance.h b/dtool/src/cppparser/cppInstance.h index 137bbe56b7..0cfd4bea43 100644 --- a/dtool/src/cppparser/cppInstance.h +++ b/dtool/src/cppparser/cppInstance.h @@ -73,7 +73,7 @@ public: SC_parameter_pack = 0x40000, }; - CPPInstance(CPPType *type, const string &name, int storage_class = 0); + CPPInstance(CPPType *type, const std::string &name, int storage_class = 0); CPPInstance(CPPType *type, CPPIdentifier *ident, int storage_class = 0); CPPInstance(CPPType *type, CPPInstanceIdentifier *ii, int storage_class, const CPPFile &file); @@ -96,9 +96,9 @@ public: CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink = nullptr) const; - string get_simple_name() const; - string get_local_name(CPPScope *scope = nullptr) const; - string get_fully_scoped_name() const; + std::string get_simple_name() const; + std::string get_local_name(CPPScope *scope = nullptr) const; + std::string get_fully_scoped_name() const; void check_for_constructor(CPPScope *current_scope, CPPScope *global_scope); @@ -112,9 +112,9 @@ public: CPPScope *current_scope, CPPScope *global_scope); - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; - void output(ostream &out, int indent_level, CPPScope *scope, + void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete, int num_default_parameters) const; virtual SubType get_subtype() const; @@ -129,7 +129,7 @@ public: int _bit_width; private: - typedef map Instantiations; + typedef std::map Instantiations; Instantiations _instantiations; }; diff --git a/dtool/src/cppparser/cppInstanceIdentifier.h b/dtool/src/cppparser/cppInstanceIdentifier.h index 582e149e2c..795677513e 100644 --- a/dtool/src/cppparser/cppInstanceIdentifier.h +++ b/dtool/src/cppparser/cppInstanceIdentifier.h @@ -85,7 +85,7 @@ public: CPPExpression *_expr; CPPType *_trailing_return_type; }; - typedef vector Modifiers; + typedef std::vector Modifiers; Modifiers _modifiers; // If not -1, indicates a bitfield diff --git a/dtool/src/cppparser/cppMakeProperty.h b/dtool/src/cppparser/cppMakeProperty.h index d97369fc7d..2967ee3b09 100644 --- a/dtool/src/cppparser/cppMakeProperty.h +++ b/dtool/src/cppparser/cppMakeProperty.h @@ -91,11 +91,11 @@ public: CPPMakeProperty(CPPIdentifier *ident, Type type, CPPScope *current_scope, const CPPFile &file); - virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = nullptr) const; - virtual string get_fully_scoped_name() const; + virtual std::string get_simple_name() const; + virtual std::string get_local_name(CPPScope *scope = nullptr) const; + virtual std::string get_fully_scoped_name() const; - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; virtual SubType get_subtype() const; diff --git a/dtool/src/cppparser/cppMakeSeq.h b/dtool/src/cppparser/cppMakeSeq.h index 9d4eae4261..1db722d9bb 100644 --- a/dtool/src/cppparser/cppMakeSeq.h +++ b/dtool/src/cppparser/cppMakeSeq.h @@ -32,11 +32,11 @@ public: CPPFunctionGroup *element_getter, CPPScope *current_scope, const CPPFile &file); - virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = nullptr) const; - virtual string get_fully_scoped_name() const; + virtual std::string get_simple_name() const; + virtual std::string get_local_name(CPPScope *scope = nullptr) const; + virtual std::string get_fully_scoped_name() const; - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; virtual SubType get_subtype() const; diff --git a/dtool/src/cppparser/cppManifest.h b/dtool/src/cppparser/cppManifest.h index dc5e7701a5..c397a3fb51 100644 --- a/dtool/src/cppparser/cppManifest.h +++ b/dtool/src/cppparser/cppManifest.h @@ -30,18 +30,18 @@ class CPPType; */ class CPPManifest { public: - CPPManifest(const string &args, const cppyyltype &loc); - CPPManifest(const string ¯o, const string &definition); + CPPManifest(const std::string &args, const cppyyltype &loc); + CPPManifest(const std::string ¯o, const std::string &definition); ~CPPManifest(); - static string stringify(const string &source); - string expand(const vector_string &args = vector_string()) const; + static std::string stringify(const std::string &source); + std::string expand(const vector_string &args = vector_string()) const; CPPType *determine_type() const; - void output(ostream &out) const; + void output(std::ostream &out) const; - string _name; + std::string _name; bool _has_parameters; int _num_parameters; int _variadic_param; @@ -54,25 +54,25 @@ public: CPPVisibility _vis; private: - void parse_parameters(const string &args, size_t &p, + void parse_parameters(const std::string &args, size_t &p, vector_string ¶meter_names); - void save_expansion(const string &exp, + void save_expansion(const std::string &exp, const vector_string ¶meter_names); class ExpansionNode { public: ExpansionNode(int parm_number, bool stringify, bool paste); - ExpansionNode(const string &str, bool paste = false); + ExpansionNode(const std::string &str, bool paste = false); int _parm_number; bool _stringify; bool _paste; - string _str; + std::string _str; }; - typedef vector Expansion; + typedef std::vector Expansion; Expansion _expansion; }; -inline ostream &operator << (ostream &out, const CPPManifest &manifest) { +inline std::ostream &operator << (std::ostream &out, const CPPManifest &manifest) { manifest.output(out); return out; } diff --git a/dtool/src/cppparser/cppNameComponent.h b/dtool/src/cppparser/cppNameComponent.h index 9e6981e3d8..cdeb293fca 100644 --- a/dtool/src/cppparser/cppNameComponent.h +++ b/dtool/src/cppparser/cppNameComponent.h @@ -26,31 +26,31 @@ class CPPScope; class CPPNameComponent { public: - CPPNameComponent(const string &name); + CPPNameComponent(const std::string &name); bool operator == (const CPPNameComponent &other) const; bool operator != (const CPPNameComponent &other) const; bool operator < (const CPPNameComponent &other) const; - string get_name() const; - string get_name_with_templ(CPPScope *scope = nullptr) const; + std::string get_name() const; + std::string get_name_with_templ(CPPScope *scope = nullptr) const; CPPTemplateParameterList *get_templ() const; bool empty() const; bool has_templ() const; bool is_tbd() const; - void set_name(const string &name); - void append_name(const string &name); + void set_name(const std::string &name); + void append_name(const std::string &name); void set_templ(CPPTemplateParameterList *templ); - void output(ostream &out) const; + void output(std::ostream &out) const; private: - string _name; + std::string _name; CPPTemplateParameterList *_templ; }; -inline ostream &operator << (ostream &out, const CPPNameComponent &name) { +inline std::ostream &operator << (std::ostream &out, const CPPNameComponent &name) { name.output(out); return out; } diff --git a/dtool/src/cppparser/cppNamespace.h b/dtool/src/cppparser/cppNamespace.h index c0dd98132e..ca4d1dcf04 100644 --- a/dtool/src/cppparser/cppNamespace.h +++ b/dtool/src/cppparser/cppNamespace.h @@ -29,12 +29,12 @@ public: CPPNamespace(CPPIdentifier *ident, CPPScope *scope, const CPPFile &file); - string get_simple_name() const; - string get_local_name(CPPScope *scope = nullptr) const; - string get_fully_scoped_name() const; + std::string get_simple_name() const; + std::string get_local_name(CPPScope *scope = nullptr) const; + std::string get_fully_scoped_name() const; CPPScope *get_scope() const; - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; virtual SubType get_subtype() const; diff --git a/dtool/src/cppparser/cppParameterList.h b/dtool/src/cppparser/cppParameterList.h index 77c7b2b889..a5e5d327e9 100644 --- a/dtool/src/cppparser/cppParameterList.h +++ b/dtool/src/cppparser/cppParameterList.h @@ -49,16 +49,16 @@ public: // This vector contains a list of formal parameters, in order. A parameter // may have an empty identifer name. - typedef vector Parameters; + typedef std::vector Parameters; Parameters _parameters; bool _includes_ellipsis; - void output(ostream &out, CPPScope *scope, bool parameter_names, + void output(std::ostream &out, CPPScope *scope, bool parameter_names, int num_default_parameters = -1) const; }; -inline ostream & -operator << (ostream &out, const CPPParameterList &plist) { +inline std::ostream & +operator << (std::ostream &out, const CPPParameterList &plist) { plist.output(out, nullptr, true); return out; } diff --git a/dtool/src/cppparser/cppParser.h b/dtool/src/cppparser/cppParser.h index f3b4405b7e..82ac2abd08 100644 --- a/dtool/src/cppparser/cppParser.h +++ b/dtool/src/cppparser/cppParser.h @@ -33,8 +33,8 @@ public: bool parse_file(const Filename &filename); - CPPExpression *parse_expr(const string &expr); - CPPType *parse_type(const string &type); + CPPExpression *parse_expr(const std::string &expr); + CPPType *parse_type(const std::string &type); }; /* diff --git a/dtool/src/cppparser/cppPointerType.h b/dtool/src/cppparser/cppPointerType.h index 3fce00b2f5..b5f42c57a2 100644 --- a/dtool/src/cppparser/cppPointerType.h +++ b/dtool/src/cppparser/cppPointerType.h @@ -44,12 +44,12 @@ public: virtual bool is_copy_assignable() const; virtual bool is_equivalent(const CPPType &other) const; - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; - virtual void output_instance(ostream &out, int indent_level, + virtual void output_instance(std::ostream &out, int indent_level, CPPScope *scope, - bool complete, const string &prename, - const string &name) const; + bool complete, const std::string &prename, + const std::string &name) const; virtual SubType get_subtype() const; diff --git a/dtool/src/cppparser/cppPreprocessor.h b/dtool/src/cppparser/cppPreprocessor.h index 02f3715339..3102386fee 100644 --- a/dtool/src/cppparser/cppPreprocessor.h +++ b/dtool/src/cppparser/cppPreprocessor.h @@ -57,10 +57,10 @@ public: int _token_index; #endif - void warning(const string &message); - void warning(const string &message, const YYLTYPE &loc); - void error(const string &message); - void error(const string &message, const YYLTYPE &loc); + void warning(const std::string &message); + void warning(const std::string &message, const YYLTYPE &loc); + void error(const std::string &message); + void error(const std::string &message, const YYLTYPE &loc); void show_line(const YYLTYPE &loc); CPPCommentBlock *get_comment_before(int line, CPPFile file); @@ -69,11 +69,11 @@ public: int get_warning_count() const; int get_error_count() const; - typedef map Manifests; + typedef std::map Manifests; Manifests _manifests; typedef pvector ManifestStack; - map _manifest_stack; + std::map _manifest_stack; pvector _quote_include_kind; DSearchPath _quote_include_path; @@ -82,14 +82,14 @@ public: CPPComments _comments; - typedef set ParsedFiles; + typedef std::set ParsedFiles; ParsedFiles _parsed_files; - typedef set Includes; + typedef std::set Includes; Includes _quote_includes; Includes _angle_includes; - set _explicit_files; + std::set _explicit_files; // This is normally true, to indicate that the preprocessor should decode // identifiers like foo::bar into a single IDENTIFIER, @@ -109,14 +109,14 @@ public: protected: bool init_cpp(const CPPFile &file); - bool init_const_expr(const string &expr); - bool init_type(const string &type); + bool init_const_expr(const std::string &expr); + bool init_type(const std::string &type); bool push_file(const CPPFile &file); - bool push_string(const string &input, bool lock_position); + bool push_string(const std::string &input, bool lock_position); - string expand_manifests(const string &input_expr, bool expand_undefined, + std::string expand_manifests(const std::string &input_expr, bool expand_undefined, const YYLTYPE &loc); - CPPExpression *parse_expr(const string &expr, CPPScope *current_scope, + CPPExpression *parse_expr(const std::string &expr, CPPScope *current_scope, CPPScope *global_scope, const YYLTYPE &loc); private: @@ -130,43 +130,43 @@ private: int skip_digit_separator(int c); int process_directive(int c); - int get_preprocessor_command(int c, string &command); - int get_preprocessor_args(int c, string &args); + int get_preprocessor_command(int c, std::string &command); + int get_preprocessor_args(int c, std::string &args); - void handle_define_directive(const string &args, const YYLTYPE &loc); - void handle_undef_directive(const string &args, const YYLTYPE &loc); - void handle_ifdef_directive(const string &args, const YYLTYPE &loc); - void handle_ifndef_directive(const string &args, const YYLTYPE &loc); - void handle_if_directive(const string &args, const YYLTYPE &loc); - void handle_include_directive(const string &args, const YYLTYPE &loc); - void handle_pragma_directive(const string &args, const YYLTYPE &loc); - void handle_error_directive(const string &args, const YYLTYPE &loc); + void handle_define_directive(const std::string &args, const YYLTYPE &loc); + void handle_undef_directive(const std::string &args, const YYLTYPE &loc); + void handle_ifdef_directive(const std::string &args, const YYLTYPE &loc); + void handle_ifndef_directive(const std::string &args, const YYLTYPE &loc); + void handle_if_directive(const std::string &args, const YYLTYPE &loc); + void handle_include_directive(const std::string &args, const YYLTYPE &loc); + void handle_pragma_directive(const std::string &args, const YYLTYPE &loc); + void handle_error_directive(const std::string &args, const YYLTYPE &loc); void skip_false_if_block(bool consider_elifs); - bool is_manifest_defined(const string &manifest_name); + bool is_manifest_defined(const std::string &manifest_name); bool find_include(Filename &filename, bool angle_quotes, CPPFile::Source &source); CPPToken get_quoted_char(int c); CPPToken get_quoted_string(int c); CPPToken get_identifier(int c); - CPPToken get_literal(int token, YYLTYPE loc, const string &str, + CPPToken get_literal(int token, YYLTYPE loc, const std::string &str, const YYSTYPE &result = YYSTYPE()); CPPToken expand_manifest(const CPPManifest *manifest); - void extract_manifest_args(const string &name, int num_args, + void extract_manifest_args(const std::string &name, int num_args, int va_arg, vector_string &args); - void expand_defined_function(string &expr, size_t q, size_t &p); - void expand_has_include_function(string &expr, size_t q, size_t &p, YYLTYPE loc); - void expand_manifest_inline(string &expr, size_t q, size_t &p, + void expand_defined_function(std::string &expr, size_t q, size_t &p); + void expand_has_include_function(std::string &expr, size_t q, size_t &p, YYLTYPE loc); + void expand_manifest_inline(std::string &expr, size_t q, size_t &p, const CPPManifest *manifest); - void extract_manifest_args_inline(const string &name, int num_args, + void extract_manifest_args_inline(const std::string &name, int num_args, int va_arg, vector_string &args, - const string &expr, size_t &p); + const std::string &expr, size_t &p); CPPToken get_number(int c); - static int check_keyword(const string &name); + static int check_keyword(const std::string &name); int scan_escape_sequence(int c); - string scan_quoted(int c); - string scan_raw(int c); + std::string scan_quoted(int c); + std::string scan_raw(int c); bool should_ignore_manifest(const CPPManifest *manifest) const; bool should_ignore_preprocessor() const; @@ -186,14 +186,14 @@ private: ~InputFile(); bool open(const CPPFile &file); - bool connect_input(const string &input); + bool connect_input(const std::string &input); int get(); int peek(); const CPPManifest *_ignore_manifest; CPPFile _file; - string _input; - istream *_in; + std::string _input; + std::istream *_in; int _line_number; int _col_number; int _next_line_number; @@ -204,7 +204,7 @@ private: // This must be a list and not a vector because we don't have a good copy // constructor defined for InputFile. - typedef list Files; + typedef std::list Files; Files _files; enum State { @@ -222,7 +222,7 @@ private: bool _last_cpp_comment; bool _save_comments; - vector _saved_tokens; + std::vector _saved_tokens; int _warning_count; int _error_count; diff --git a/dtool/src/cppparser/cppReferenceType.h b/dtool/src/cppparser/cppReferenceType.h index 89feba8d2c..273f645377 100644 --- a/dtool/src/cppparser/cppReferenceType.h +++ b/dtool/src/cppparser/cppReferenceType.h @@ -50,12 +50,12 @@ public: virtual bool is_destructible() const; virtual bool is_equivalent(const CPPType &other) const; - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; - virtual void output_instance(ostream &out, int indent_level, + virtual void output_instance(std::ostream &out, int indent_level, CPPScope *scope, - bool complete, const string &prename, - const string &name) const; + bool complete, const std::string &prename, + const std::string &name) const; virtual SubType get_subtype() const; diff --git a/dtool/src/cppparser/cppScope.h b/dtool/src/cppparser/cppScope.h index d7df06b481..44fcc25fef 100644 --- a/dtool/src/cppparser/cppScope.h +++ b/dtool/src/cppparser/cppScope.h @@ -82,28 +82,28 @@ public: CPPScope *current_scope, CPPScope *global_scope) const; - CPPType *find_type(const string &name, bool recurse = true) const; - CPPType *find_type(const string &name, + CPPType *find_type(const std::string &name, bool recurse = true) const; + CPPType *find_type(const std::string &name, CPPDeclaration::SubstDecl &subst, CPPScope *global_scope, bool recurse = true) const; - CPPScope *find_scope(const string &name, CPPScope *global_scope, + CPPScope *find_scope(const std::string &name, CPPScope *global_scope, bool recurse = true) const; - CPPScope *find_scope(const string &name, + CPPScope *find_scope(const std::string &name, CPPDeclaration::SubstDecl &subst, CPPScope *global_scope, bool recurse = true) const; - CPPDeclaration *find_symbol(const string &name, + CPPDeclaration *find_symbol(const std::string &name, bool recurse = true) const; - CPPDeclaration *find_template(const string &name, + CPPDeclaration *find_template(const std::string &name, bool recurse = true) const; - virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = nullptr) const; - virtual string get_fully_scoped_name() const; + virtual std::string get_simple_name() const; + virtual std::string get_local_name(CPPScope *scope = nullptr) const; + virtual std::string get_fully_scoped_name() const; - virtual void output(ostream &out, CPPScope *scope) const; - void write(ostream &out, int indent, CPPScope *scope) const; + virtual void output(std::ostream &out, CPPScope *scope) const; + void write(std::ostream &out, int indent, CPPScope *scope) const; CPPTemplateScope *get_template_scope(); virtual CPPTemplateScope *as_template_scope(); @@ -117,30 +117,30 @@ private: CPPPreprocessor *error_sink = nullptr); public: - typedef vector Declarations; + typedef std::vector Declarations; Declarations _declarations; - typedef map ExtensionTypes; + typedef std::map ExtensionTypes; ExtensionTypes _structs; ExtensionTypes _classes; ExtensionTypes _unions; ExtensionTypes _enums; - typedef map Namespaces; + typedef std::map Namespaces; Namespaces _namespaces; - typedef map Types; + typedef std::map Types; Types _types; - typedef map Variables; + typedef std::map Variables; Variables _variables; Variables _enum_values; - typedef map Functions; + typedef std::map Functions; Functions _functions; - typedef map Templates; + typedef std::map Templates; Templates _templates; CPPNameComponent _name; - typedef set Using; + typedef std::set Using; Using _using; protected: @@ -149,7 +149,7 @@ protected: CPPVisibility _current_vis; private: - typedef map Instantiations; + typedef std::map Instantiations; Instantiations _instantiations; bool _is_fully_specified; @@ -158,8 +158,8 @@ private: bool _subst_decl_recursive_protect; }; -inline ostream & -operator << (ostream &out, const CPPScope &scope) { +inline std::ostream & +operator << (std::ostream &out, const CPPScope &scope) { scope.output(out, nullptr); return out; } diff --git a/dtool/src/cppparser/cppSimpleType.h b/dtool/src/cppparser/cppSimpleType.h index 850353e9eb..a674374502 100644 --- a/dtool/src/cppparser/cppSimpleType.h +++ b/dtool/src/cppparser/cppSimpleType.h @@ -79,9 +79,9 @@ public: virtual bool is_destructible() const; virtual bool is_parameter_expr() const; - virtual string get_preferred_name() const; + virtual std::string get_preferred_name() const; - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; virtual SubType get_subtype() const; diff --git a/dtool/src/cppparser/cppStructType.h b/dtool/src/cppparser/cppStructType.h index fc8a9e45b2..57537b389e 100644 --- a/dtool/src/cppparser/cppStructType.h +++ b/dtool/src/cppparser/cppStructType.h @@ -86,7 +86,7 @@ public: CPPScope *current_scope, CPPScope *global_scope); - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; virtual SubType get_subtype() const; @@ -98,17 +98,17 @@ public: class Base { public: - void output(ostream &out) const; + void output(std::ostream &out) const; CPPType *_base; CPPVisibility _vis; bool _is_virtual; }; - typedef vector Derivation; + typedef std::vector Derivation; Derivation _derivation; - typedef list VFunctions; + typedef std::list VFunctions; void get_virtual_funcs(VFunctions &funcs) const; void get_pure_virtual_funcs(VFunctions &funcs) const; @@ -117,11 +117,11 @@ protected: virtual bool is_less(const CPPDeclaration *other) const; bool _subst_decl_recursive_protect; - typedef vector Proxies; + typedef std::vector Proxies; Proxies _proxies; }; -inline ostream &operator << (ostream &out, const CPPStructType::Base &base) { +inline std::ostream &operator << (std::ostream &out, const CPPStructType::Base &base) { base.output(out); return out; } diff --git a/dtool/src/cppparser/cppTBDType.h b/dtool/src/cppparser/cppTBDType.h index f72833e3ff..beec68adeb 100644 --- a/dtool/src/cppparser/cppTBDType.h +++ b/dtool/src/cppparser/cppTBDType.h @@ -35,15 +35,15 @@ public: virtual bool is_tbd() const; - virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = nullptr) const; - virtual string get_fully_scoped_name() const; + virtual std::string get_simple_name() const; + virtual std::string get_local_name(CPPScope *scope = nullptr) const; + virtual std::string get_fully_scoped_name() const; virtual CPPDeclaration *substitute_decl(SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope); - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; virtual SubType get_subtype() const; diff --git a/dtool/src/cppparser/cppTemplateParameterList.h b/dtool/src/cppparser/cppTemplateParameterList.h index 50b97247ea..d47f8fdd9e 100644 --- a/dtool/src/cppparser/cppTemplateParameterList.h +++ b/dtool/src/cppparser/cppTemplateParameterList.h @@ -33,7 +33,7 @@ class CPPTemplateParameterList { public: CPPTemplateParameterList(); - string get_string() const; + std::string get_string() const; void build_subst_decl(const CPPTemplateParameterList &formal_params, CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) const; @@ -49,15 +49,15 @@ public: CPPScope *current_scope, CPPScope *global_scope); - void output(ostream &out, CPPScope *scope) const; - void write_formal(ostream &out, CPPScope *scope) const; + void output(std::ostream &out, CPPScope *scope) const; + void write_formal(std::ostream &out, CPPScope *scope) const; - typedef vector Parameters; + typedef std::vector Parameters; Parameters _parameters; }; -inline ostream & -operator << (ostream &out, const CPPTemplateParameterList &plist) { +inline std::ostream & +operator << (std::ostream &out, const CPPTemplateParameterList &plist) { plist.output(out, nullptr); return out; } diff --git a/dtool/src/cppparser/cppTemplateScope.h b/dtool/src/cppparser/cppTemplateScope.h index 0cd987145e..8a30b686a5 100644 --- a/dtool/src/cppparser/cppTemplateScope.h +++ b/dtool/src/cppparser/cppTemplateScope.h @@ -44,11 +44,11 @@ public: virtual bool is_fully_specified() const; - virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = nullptr) const; - virtual string get_fully_scoped_name() const; + virtual std::string get_simple_name() const; + virtual std::string get_local_name(CPPScope *scope = nullptr) const; + virtual std::string get_fully_scoped_name() const; - virtual void output(ostream &out, CPPScope *scope) const; + virtual void output(std::ostream &out, CPPScope *scope) const; virtual CPPTemplateScope *as_template_scope(); diff --git a/dtool/src/cppparser/cppToken.h b/dtool/src/cppparser/cppToken.h index 0c14af3171..735ef0aac2 100644 --- a/dtool/src/cppparser/cppToken.h +++ b/dtool/src/cppparser/cppToken.h @@ -25,10 +25,10 @@ class CPPToken { public: CPPToken(int token, int line_number = 0, int col_number = 0, const CPPFile &file = CPPFile(""), - const string &str = string(), + const std::string &str = std::string(), const YYSTYPE &lval = YYSTYPE()); CPPToken(int token, const YYLTYPE &loc, - const string &str = string(), + const std::string &str = std::string(), const YYSTYPE &lval = YYSTYPE()); CPPToken(const CPPToken ©); void operator = (const CPPToken ©); @@ -36,14 +36,14 @@ public: static CPPToken eof(); bool is_eof() const; - void output(ostream &out) const; + void output(std::ostream &out) const; int _token; YYSTYPE _lval; YYLTYPE _lloc; }; -inline ostream &operator << (ostream &out, const CPPToken &token) { +inline std::ostream &operator << (std::ostream &out, const CPPToken &token) { token.output(out); return out; } diff --git a/dtool/src/cppparser/cppType.h b/dtool/src/cppparser/cppType.h index 1bf89db2f5..82f634080c 100644 --- a/dtool/src/cppparser/cppType.h +++ b/dtool/src/cppparser/cppType.h @@ -36,7 +36,7 @@ public: */ class CPPType : public CPPDeclaration { public: - typedef vector Typedefs; + typedef std::vector Typedefs; Typedefs _typedefs; CPPType(const CPPFile &file); @@ -68,46 +68,46 @@ public: CPPType *remove_pointer(); bool has_typedef_name() const; - string get_typedef_name(CPPScope *scope = nullptr) const; + std::string get_typedef_name(CPPScope *scope = nullptr) const; - virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = nullptr) const; - virtual string get_fully_scoped_name() const; - virtual string get_preferred_name() const; + virtual std::string get_simple_name() const; + virtual std::string get_local_name(CPPScope *scope = nullptr) const; + virtual std::string get_fully_scoped_name() const; + virtual std::string get_preferred_name() const; int get_num_alt_names() const; - string get_alt_name(int n) const; + std::string get_alt_name(int n) const; virtual bool is_incomplete() const; virtual bool is_convertible_to(const CPPType *other) const; virtual bool is_equivalent(const CPPType &other) const; - void output_instance(ostream &out, const string &name, + void output_instance(std::ostream &out, const std::string &name, CPPScope *scope) const; - virtual void output_instance(ostream &out, int indent_level, + virtual void output_instance(std::ostream &out, int indent_level, CPPScope *scope, - bool complete, const string &prename, - const string &name) const; + bool complete, const std::string &prename, + const std::string &name) const; virtual CPPType *as_type(); static CPPType *new_type(CPPType *type); - static void record_alt_name_for(const CPPType *type, const string &name); - static string get_preferred_name_for(const CPPType *type); + static void record_alt_name_for(const CPPType *type, const std::string &name); + static std::string get_preferred_name_for(const CPPType *type); CPPTypeDeclaration *_declaration; bool _forcetype; protected: - typedef set Types; + typedef std::set Types; static Types _types; - typedef map PreferredNames; + typedef std::map PreferredNames; static PreferredNames _preferred_names; - typedef vector Names; - typedef map AltNames; + typedef std::vector Names; + typedef std::map AltNames; static AltNames _alt_names; }; diff --git a/dtool/src/cppparser/cppTypeDeclaration.h b/dtool/src/cppparser/cppTypeDeclaration.h index 9fb06debef..cd93ed0fdc 100644 --- a/dtool/src/cppparser/cppTypeDeclaration.h +++ b/dtool/src/cppparser/cppTypeDeclaration.h @@ -31,7 +31,7 @@ public: CPPScope *current_scope, CPPScope *global_scope); - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; virtual SubType get_subtype() const; diff --git a/dtool/src/cppparser/cppTypeParser.h b/dtool/src/cppparser/cppTypeParser.h index af18e0e5b8..4064e84687 100644 --- a/dtool/src/cppparser/cppTypeParser.h +++ b/dtool/src/cppparser/cppTypeParser.h @@ -29,18 +29,18 @@ public: CPPTypeParser(CPPScope *current_scope, CPPScope *global_scope); ~CPPTypeParser(); - bool parse_type(const string &type); - bool parse_type(const string &type, const CPPPreprocessor &filepos); + bool parse_type(const std::string &type); + bool parse_type(const std::string &type, const CPPPreprocessor &filepos); - void output(ostream &out) const; + void output(std::ostream &out) const; CPPScope *_current_scope; CPPScope *_global_scope; CPPType *_type; }; -inline ostream & -operator << (ostream &out, const CPPTypeParser &ep) { +inline std::ostream & +operator << (std::ostream &out, const CPPTypeParser &ep) { ep.output(out); return out; } diff --git a/dtool/src/cppparser/cppTypeProxy.h b/dtool/src/cppparser/cppTypeProxy.h index fcd2ebe178..87d064a3b5 100644 --- a/dtool/src/cppparser/cppTypeProxy.h +++ b/dtool/src/cppparser/cppTypeProxy.h @@ -33,20 +33,20 @@ public: virtual bool is_tbd() const; bool has_typedef_name() const; - string get_typedef_name(CPPScope *scope = nullptr) const; + std::string get_typedef_name(CPPScope *scope = nullptr) const; - virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = nullptr) const; - virtual string get_fully_scoped_name() const; - virtual string get_preferred_name() const; + virtual std::string get_simple_name() const; + virtual std::string get_local_name(CPPScope *scope = nullptr) const; + virtual std::string get_fully_scoped_name() const; + virtual std::string get_preferred_name() const; virtual bool is_incomplete() const; - virtual void output_instance(ostream &out, int indent_level, + virtual void output_instance(std::ostream &out, int indent_level, CPPScope *scope, - bool complete, const string &prename, - const string &name) const; - virtual void output(ostream &out, int indent_level, CPPScope *scope, + bool complete, const std::string &prename, + const std::string &name) const; + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; virtual SubType get_subtype() const; diff --git a/dtool/src/cppparser/cppTypedefType.h b/dtool/src/cppparser/cppTypedefType.h index d3a3ea3245..c8d7ffd6be 100644 --- a/dtool/src/cppparser/cppTypedefType.h +++ b/dtool/src/cppparser/cppTypedefType.h @@ -27,7 +27,7 @@ class CPPInstanceIdentifier; */ class CPPTypedefType : public CPPType { public: - CPPTypedefType(CPPType *type, const string &name, CPPScope *current_scope); + CPPTypedefType(CPPType *type, const std::string &name, CPPScope *current_scope); CPPTypedefType(CPPType *type, CPPIdentifier *ident, CPPScope *current_scope); CPPTypedefType(CPPType *type, CPPInstanceIdentifier *ii, CPPScope *current_scope, const CPPFile &file); @@ -36,9 +36,9 @@ public: CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink = nullptr) const; - virtual string get_simple_name() const; - virtual string get_local_name(CPPScope *scope = nullptr) const; - virtual string get_fully_scoped_name() const; + virtual std::string get_simple_name() const; + virtual std::string get_local_name(CPPScope *scope = nullptr) const; + virtual std::string get_fully_scoped_name() const; virtual bool is_incomplete() const; virtual bool is_tbd() const; @@ -68,7 +68,7 @@ public: virtual bool is_convertible_to(const CPPType *other) const; virtual bool is_equivalent(const CPPType &other) const; - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; virtual SubType get_subtype() const; @@ -83,7 +83,7 @@ protected: virtual bool is_less(const CPPDeclaration *other) const; bool _subst_decl_recursive_protect; - typedef vector Proxies; + typedef std::vector Proxies; Proxies _proxies; }; diff --git a/dtool/src/cppparser/cppUsing.h b/dtool/src/cppparser/cppUsing.h index 0ec72c8ebf..13de9ce855 100644 --- a/dtool/src/cppparser/cppUsing.h +++ b/dtool/src/cppparser/cppUsing.h @@ -28,7 +28,7 @@ class CPPUsing : public CPPDeclaration { public: CPPUsing(CPPIdentifier *ident, bool full_namespace, const CPPFile &file); - virtual void output(ostream &out, int indent_level, CPPScope *scope, + virtual void output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const; virtual SubType get_subtype() const; diff --git a/dtool/src/cppparser/cppVisibility.h b/dtool/src/cppparser/cppVisibility.h index 07d3bfdcb5..7165aaecc1 100644 --- a/dtool/src/cppparser/cppVisibility.h +++ b/dtool/src/cppparser/cppVisibility.h @@ -24,6 +24,6 @@ enum CPPVisibility { V_unknown }; -ostream &operator << (ostream &out, CPPVisibility vis); +std::ostream &operator << (std::ostream &out, CPPVisibility vis); #endif diff --git a/dtool/src/dconfig/dconfig.I b/dtool/src/dconfig/dconfig.I index 0497ffc067..e40db3c2b0 100644 --- a/dtool/src/dconfig/dconfig.I +++ b/dtool/src/dconfig/dconfig.I @@ -12,31 +12,31 @@ */ bool DConfig:: -GetBool(const string &sym, bool def) { +GetBool(const std::string &sym, bool def) { ConfigVariableBool var(sym, def, "DConfig", ConfigFlags::F_dconfig); return var.get_value(); } int DConfig:: -GetInt(const string &sym, int def) { +GetInt(const std::string &sym, int def) { ConfigVariableInt var(sym, def, "DConfig", ConfigFlags::F_dconfig); return var.get_value(); } float DConfig:: -GetFloat(const string &sym, float def) { +GetFloat(const std::string &sym, float def) { ConfigVariableDouble var(sym, (double)def, "DConfig", ConfigFlags::F_dconfig); return (float)var.get_value(); } double DConfig:: -GetDouble(const string &sym, double def) { +GetDouble(const std::string &sym, double def) { ConfigVariableDouble var(sym, def, "DConfig", ConfigFlags::F_dconfig); return var.get_value(); } -string DConfig:: -GetString(const string &sym, const string &def) { +std::string DConfig:: +GetString(const std::string &sym, const std::string &def) { ConfigVariableString var(sym, def, "DConfig", ConfigFlags::F_dconfig); return var.get_value(); } diff --git a/dtool/src/dconfig/dconfig.h b/dtool/src/dconfig/dconfig.h index ede79f596f..fca35685ed 100644 --- a/dtool/src/dconfig/dconfig.h +++ b/dtool/src/dconfig/dconfig.h @@ -32,11 +32,11 @@ */ class EXPCL_DTOOL_DCONFIG DConfig { PUBLISHED: - static INLINE bool GetBool(const string &sym, bool def = false); - static INLINE int GetInt(const string &sym, int def = 0); - static INLINE float GetFloat(const string &sym, float def = 0.); - static INLINE double GetDouble(const string &sym, double def = 0.); - static INLINE string GetString(const string &sym, const string &def = ""); + static INLINE bool GetBool(const std::string &sym, bool def = false); + static INLINE int GetInt(const std::string &sym, int def = 0); + static INLINE float GetFloat(const std::string &sym, float def = 0.); + static INLINE double GetDouble(const std::string &sym, double def = 0.); + static INLINE std::string GetString(const std::string &sym, const std::string &def = ""); }; #include "dconfig.I" diff --git a/dtool/src/dtoolbase/epvector.h b/dtool/src/dtoolbase/epvector.h index 78db158f39..e743ea4060 100644 --- a/dtool/src/dtoolbase/epvector.h +++ b/dtool/src/dtoolbase/epvector.h @@ -35,10 +35,10 @@ * kids. */ template -class epvector : public vector > { +class epvector : public std::vector > { public: typedef Eigen::aligned_allocator allocator; - typedef vector base_class; + typedef std::vector base_class; typedef typename base_class::size_type size_type; epvector(TypeHandle type_handle = pvector_type_handle) : base_class(allocator()) { } diff --git a/dtool/src/dtoolbase/fakestringstream.h b/dtool/src/dtoolbase/fakestringstream.h index 7132d6280e..da2ba6880f 100644 --- a/dtool/src/dtoolbase/fakestringstream.h +++ b/dtool/src/dtoolbase/fakestringstream.h @@ -24,7 +24,7 @@ public: _len = 0; _str = ""; } - fake_istream_buffer(const string &source) { + fake_istream_buffer(const std::string &source) { _len = source.length(); if (_len == 0) { _str = ""; @@ -43,20 +43,20 @@ public: char *_str; }; -class istringstream : public fake_istream_buffer, public istrstream { +class std::istringstream : public fake_istream_buffer, public istrstream { public: - istringstream(const string &input) : + std::istringstream(const std::string &input) : fake_istream_buffer(input), istrstream(_str, _len) { } }; -class ostringstream : public ostrstream { +class std::ostringstream : public ostrstream { public: - string str() { + std::string str() { // We must capture the length before we take the str(). int length = pcount(); char *s = ostrstream::str(); - string result(s, length); + std::string result(s, length); delete[] s; return result; } @@ -67,9 +67,9 @@ public: stringstream() : strstream() { _owns_str = true; } - stringstream(const string &input) : + std::stringstream(const std::string &input) : fake_istream_buffer(input), - strstream(_str, _len, ios::in) + strstream(_str, _len, std::ios::in) { _owns_str = false; } diff --git a/dtool/src/dtoolbase/indent.I b/dtool/src/dtoolbase/indent.I index db990ebe1d..3e612a369b 100644 --- a/dtool/src/dtoolbase/indent.I +++ b/dtool/src/dtoolbase/indent.I @@ -19,9 +19,9 @@ */ template void -write_long_list(ostream &out, int indent_level, +write_long_list(std::ostream &out, int indent_level, InputIterator first, InputIterator last, - string first_prefix, string later_prefix, + std::string first_prefix, std::string later_prefix, int max_col) { if (later_prefix.empty()) { later_prefix = first_prefix; @@ -30,9 +30,9 @@ write_long_list(ostream &out, int indent_level, if (first != last) { // We have to use an intermediate strstream object so we can count the // number of characters the item will have when it is output. - ostringstream item; + std::ostringstream item; item << *first; - string str = item.str(); + std::string str = item.str(); indent(out, indent_level) << first_prefix << str; int col = indent_level + (int)(first_prefix.length() + str.length()); @@ -40,9 +40,9 @@ write_long_list(ostream &out, int indent_level, ++first; while (first != last) { - ostringstream item; + std::ostringstream item; item << *first; - string str = item.str(); + std::string str = item.str(); col += 1 + str.length(); if (col > max_col) { diff --git a/dtool/src/dtoolbase/indent.h b/dtool/src/dtoolbase/indent.h index 93badf5e7d..c012ff1fe3 100644 --- a/dtool/src/dtoolbase/indent.h +++ b/dtool/src/dtoolbase/indent.h @@ -22,8 +22,8 @@ * stream itself. Useful for indenting a series of lines of text by a given * amount. */ -EXPCL_DTOOL_DTOOLBASE ostream & -indent(ostream &out, int indent_level); +EXPCL_DTOOL_DTOOLBASE std::ostream & +indent(std::ostream &out, int indent_level); /** * Writes a list of things to the indicated output stream, with a space @@ -33,10 +33,10 @@ indent(ostream &out, int indent_level); */ template void -write_long_list(ostream &out, int indent_level, +write_long_list(std::ostream &out, int indent_level, InputIterator ifirst, InputIterator ilast, - string first_prefix = "", - string later_prefix = "", + std::string first_prefix = "", + std::string later_prefix = "", int max_col = 72); #include "indent.I" diff --git a/dtool/src/dtoolbase/pallocator.T b/dtool/src/dtoolbase/pallocator.T index f2776eb39e..ed8349debe 100644 --- a/dtool/src/dtoolbase/pallocator.T +++ b/dtool/src/dtoolbase/pallocator.T @@ -20,7 +20,7 @@ pallocator_single(TypeHandle type_handle) noexcept : template INLINE Type *pallocator_single:: -allocate(typename pallocator_single::size_type n, typename allocator::const_pointer) { +allocate(typename pallocator_single::size_type n, typename std::allocator::const_pointer) { TAU_PROFILE("pallocator_single:allocate()", " ", TAU_USER); // This doesn't support allocating arrays. assert(n == 1); @@ -44,7 +44,7 @@ pallocator_array(TypeHandle type_handle) noexcept : template INLINE Type *pallocator_array:: -allocate(typename pallocator_array::size_type n, typename allocator::const_pointer) { +allocate(typename pallocator_array::size_type n, typename std::allocator::const_pointer) { return (typename pallocator_array::pointer) ASSUME_ALIGNED(_type_handle.allocate_array(n * sizeof(Type)), MEMORY_HOOK_ALIGNMENT); } diff --git a/dtool/src/dtoolbase/pallocator.h b/dtool/src/dtoolbase/pallocator.h index daca6fb275..b5158810df 100644 --- a/dtool/src/dtoolbase/pallocator.h +++ b/dtool/src/dtoolbase/pallocator.h @@ -44,15 +44,15 @@ using std::allocator; #else template -class pallocator_single : public allocator { +class pallocator_single : public std::allocator { public: // Nowadays we cannot implicitly inherit typedefs from base classes in a // template class; we must explicitly copy them here. - typedef typename allocator::pointer pointer; - typedef typename allocator::reference reference; - typedef typename allocator::const_pointer const_pointer; - typedef typename allocator::const_reference const_reference; - typedef typename allocator::size_type size_type; + typedef typename std::allocator::pointer pointer; + typedef typename std::allocator::reference reference; + typedef typename std::allocator::const_pointer const_pointer; + typedef typename std::allocator::const_reference const_reference; + typedef typename std::allocator::size_type size_type; INLINE pallocator_single(TypeHandle type_handle) noexcept; @@ -61,7 +61,7 @@ public: INLINE pallocator_single(const pallocator_single ©) noexcept : _type_handle(copy._type_handle) { } - INLINE Type *allocate(size_type n, allocator::const_pointer hint = 0) + INLINE Type *allocate(size_type n, std::allocator::const_pointer hint = 0) RETURNS_ALIGNED(MEMORY_HOOK_ALIGNMENT); INLINE void deallocate(pointer p, size_type n); @@ -73,15 +73,15 @@ public: }; template -class pallocator_array : public allocator { +class pallocator_array : public std::allocator { public: // Nowadays we cannot implicitly inherit typedefs from base classes in a // template class; we must explicitly copy them here. - typedef typename allocator::pointer pointer; - typedef typename allocator::reference reference; - typedef typename allocator::const_pointer const_pointer; - typedef typename allocator::const_reference const_reference; - typedef typename allocator::size_type size_type; + typedef typename std::allocator::pointer pointer; + typedef typename std::allocator::reference reference; + typedef typename std::allocator::const_pointer const_pointer; + typedef typename std::allocator::const_reference const_reference; + typedef typename std::allocator::size_type size_type; INLINE pallocator_array(TypeHandle type_handle = TypeHandle::none()) noexcept; @@ -90,7 +90,7 @@ public: INLINE pallocator_array(const pallocator_array ©) noexcept : _type_handle(copy._type_handle) { } - INLINE Type *allocate(size_type n, allocator::const_pointer hint = 0) + INLINE Type *allocate(size_type n, std::allocator::const_pointer hint = 0) RETURNS_ALIGNED(MEMORY_HOOK_ALIGNMENT); INLINE void deallocate(pointer p, size_type n); diff --git a/dtool/src/dtoolbase/pdeque.h b/dtool/src/dtoolbase/pdeque.h index a7de9f5bb0..b4c71c81eb 100644 --- a/dtool/src/dtoolbase/pdeque.h +++ b/dtool/src/dtoolbase/pdeque.h @@ -19,6 +19,7 @@ #include "register_type.h" #include + #if !defined(USE_STL_ALLOCATOR) || defined(CPPPARSER) // If we're not using custom allocators, just use the standard class // definition. @@ -34,13 +35,13 @@ using std::deque; * allocated memory. */ template -class pdeque : public deque > { +class pdeque : public std::deque > { public: typedef pallocator_array allocator; - typedef typename deque::size_type size_type; - pdeque(TypeHandle type_handle = pdeque_type_handle) : deque >(allocator(type_handle)) { } - pdeque(size_type n, TypeHandle type_handle = pdeque_type_handle) : deque >(n, Type(), allocator(type_handle)) { } - pdeque(size_type n, const Type &value, TypeHandle type_handle = pdeque_type_handle) : deque >(n, value, allocator(type_handle)) { } + typedef typename std::deque::size_type size_type; + pdeque(TypeHandle type_handle = pdeque_type_handle) : std::deque >(allocator(type_handle)) { } + pdeque(size_type n, TypeHandle type_handle = pdeque_type_handle) : std::deque >(n, Type(), allocator(type_handle)) { } + pdeque(size_type n, const Type &value, TypeHandle type_handle = pdeque_type_handle) : std::deque >(n, value, allocator(type_handle)) { } }; #endif // USE_STL_ALLOCATOR diff --git a/dtool/src/dtoolbase/plist.h b/dtool/src/dtoolbase/plist.h index 259eb68198..0ddef3c9f1 100644 --- a/dtool/src/dtoolbase/plist.h +++ b/dtool/src/dtoolbase/plist.h @@ -34,10 +34,10 @@ using std::list; * allocated memory. */ template -class plist : public list > { +class plist : public std::list > { public: typedef pallocator_single allocator; - typedef list base_class; + typedef std::list base_class; typedef typename base_class::size_type size_type; plist(TypeHandle type_handle = plist_type_handle) : base_class(allocator(type_handle)) { } plist(size_type n, TypeHandle type_handle = plist_type_handle) : base_class(n, Type(), allocator(type_handle)) { } diff --git a/dtool/src/dtoolbase/pmap.h b/dtool/src/dtoolbase/pmap.h index 1a53836dd3..0f960ac9d5 100644 --- a/dtool/src/dtoolbase/pmap.h +++ b/dtool/src/dtoolbase/pmap.h @@ -48,11 +48,11 @@ using std::multimap; * purpose is to call the hooks for MemoryUsage to properly track STL- * allocated memory. */ -template > -class pmap : public map > > { +template > +class pmap : public std::map > > { public: - typedef pallocator_single > allocator; - typedef map base_class; + typedef pallocator_single > allocator; + typedef std::map base_class; pmap(TypeHandle type_handle = pmap_type_handle) : base_class(Compare(), allocator(type_handle)) { } pmap(const Compare &comp, TypeHandle type_handle = pmap_type_handle) : base_class(comp, allocator(type_handle)) { } @@ -115,12 +115,12 @@ public: * purpose is to call the hooks for MemoryUsage to properly track STL- * allocated memory. */ -template > -class pmultimap : public multimap > > { +template > +class pmultimap : public std::multimap > > { public: - typedef pallocator_single > allocator; - pmultimap(TypeHandle type_handle = pmap_type_handle) : multimap(Compare(), allocator(type_handle)) { } - pmultimap(const Compare &comp, TypeHandle type_handle = pmap_type_handle) : multimap(comp, allocator(type_handle)) { } + typedef pallocator_single > allocator; + pmultimap(TypeHandle type_handle = pmap_type_handle) : std::multimap(Compare(), allocator(type_handle)) { } + pmultimap(const Compare &comp, TypeHandle type_handle = pmap_type_handle) : std::multimap(comp, allocator(type_handle)) { } }; #ifdef HAVE_STL_HASH @@ -129,11 +129,11 @@ public: * purpose is to call the hooks for MemoryUsage to properly track STL- * allocated memory. */ -template > > -class phash_map : public stdext::hash_map > > { +template > > +class phash_map : public stdext::hash_map > > { public: - phash_map() : stdext::hash_map > >() { } - phash_map(const Compare &comp) : stdext::hash_map > >(comp) { } + phash_map() : stdext::hash_map > >() { } + phash_map(const Compare &comp) : stdext::hash_map > >(comp) { } }; /** @@ -141,11 +141,11 @@ public: * main purpose is to call the hooks for MemoryUsage to properly track STL- * allocated memory. */ -template > > -class phash_multimap : public stdext::hash_multimap > > { +template > > +class phash_multimap : public stdext::hash_multimap > > { public: - phash_multimap() : stdext::hash_multimap > >() { } - phash_multimap(const Compare &comp) : stdext::hash_multimap > >(comp) { } + phash_multimap() : stdext::hash_multimap > >() { } + phash_multimap(const Compare &comp) : stdext::hash_multimap > >(comp) { } }; #else // HAVE_STL_HASH diff --git a/dtool/src/dtoolbase/pset.h b/dtool/src/dtoolbase/pset.h index 1c194dff9b..7b51cf787d 100644 --- a/dtool/src/dtoolbase/pset.h +++ b/dtool/src/dtoolbase/pset.h @@ -48,11 +48,11 @@ using std::multiset; * purpose is to call the hooks for MemoryUsage to properly track STL- * allocated memory. */ -template > -class pset : public set > { +template > +class pset : public std::set > { public: typedef pallocator_single allocator; - typedef set base_class; + typedef std::set base_class; pset(TypeHandle type_handle = pset_type_handle) : base_class(Compare(), allocator(type_handle)) { } pset(const Compare &comp, TypeHandle type_handle = pset_type_handle) : base_class(comp, type_handle) { } @@ -107,12 +107,12 @@ public: * purpose is to call the hooks for MemoryUsage to properly track STL- * allocated memory. */ -template > -class pmultiset : public multiset > { +template > +class pmultiset : public std::multiset > { public: typedef pallocator_single allocator; - pmultiset(TypeHandle type_handle = pset_type_handle) : multiset(Compare(), allocator(type_handle)) { } - pmultiset(const Compare &comp, TypeHandle type_handle = pset_type_handle) : multiset(comp, type_handle) { } + pmultiset(TypeHandle type_handle = pset_type_handle) : std::multiset(Compare(), allocator(type_handle)) { } + pmultiset(const Compare &comp, TypeHandle type_handle = pset_type_handle) : std::multiset(comp, type_handle) { } }; #ifdef HAVE_STL_HASH @@ -121,7 +121,7 @@ public: * purpose is to call the hooks for MemoryUsage to properly track STL- * allocated memory. */ -template > > +template > > class phash_set : public stdext::hash_set > { public: phash_set() : stdext::hash_set >() { } @@ -133,7 +133,7 @@ public: * main purpose is to call the hooks for MemoryUsage to properly track STL- * allocated memory. */ -template > > +template > > class phash_multiset : public stdext::hash_multiset > { public: phash_multiset() : stdext::hash_multiset >() { } diff --git a/dtool/src/dtoolbase/pvector.h b/dtool/src/dtoolbase/pvector.h index 8baf3c49c1..f88b625bca 100644 --- a/dtool/src/dtoolbase/pvector.h +++ b/dtool/src/dtoolbase/pvector.h @@ -41,15 +41,15 @@ using std::vector; * allocated memory. */ template -class pvector : public vector > { +class pvector : public std::vector > { public: typedef pallocator_array allocator; - typedef vector base_class; + typedef std::vector base_class; typedef typename base_class::size_type size_type; explicit pvector(TypeHandle type_handle = pvector_type_handle) : base_class(allocator(type_handle)) { } pvector(const pvector ©) : base_class(copy) { } - pvector(pvector &&from) noexcept : base_class(move(from)) {}; + pvector(pvector &&from) noexcept : base_class(std::move(from)) {}; explicit pvector(size_type n, TypeHandle type_handle = pvector_type_handle) : base_class(n, Type(), allocator(type_handle)) { } explicit pvector(size_type n, const Type &value, TypeHandle type_handle = pvector_type_handle) : base_class(n, value, allocator(type_handle)) { } pvector(const Type *begin, const Type *end, TypeHandle type_handle = pvector_type_handle) : base_class(begin, end, allocator(type_handle)) { } @@ -60,7 +60,7 @@ public: } pvector &operator =(pvector &&from) noexcept { - base_class::operator =(move(from)); + base_class::operator =(std::move(from)); return *this; } }; diff --git a/dtool/src/dtoolbase/register_type.I b/dtool/src/dtoolbase/register_type.I index 9d22794d20..0bd43e1501 100644 --- a/dtool/src/dtoolbase/register_type.I +++ b/dtool/src/dtoolbase/register_type.I @@ -19,18 +19,18 @@ * Register() and record_derivation() yourself. */ INLINE void -register_type(TypeHandle &type_handle, const string &name) { +register_type(TypeHandle &type_handle, const std::string &name) { TypeRegistry::ptr()->register_type(type_handle, name); } INLINE void -register_type(TypeHandle &type_handle, const string &name, +register_type(TypeHandle &type_handle, const std::string &name, TypeHandle parent1) { if (TypeRegistry::ptr()->register_type(type_handle, name)) { TypeRegistry::ptr()->record_derivation(type_handle, parent1); } } INLINE void -register_type(TypeHandle &type_handle, const string &name, +register_type(TypeHandle &type_handle, const std::string &name, TypeHandle parent1, TypeHandle parent2) { if (TypeRegistry::ptr()->register_type(type_handle, name)) { TypeRegistry::ptr()->record_derivation(type_handle, parent1); @@ -38,7 +38,7 @@ register_type(TypeHandle &type_handle, const string &name, } } INLINE void -register_type(TypeHandle &type_handle, const string &name, +register_type(TypeHandle &type_handle, const std::string &name, TypeHandle parent1, TypeHandle parent2, TypeHandle parent3) { if (TypeRegistry::ptr()->register_type(type_handle, name)) { @@ -48,7 +48,7 @@ register_type(TypeHandle &type_handle, const string &name, } } INLINE void -register_type(TypeHandle &type_handle, const string &name, +register_type(TypeHandle &type_handle, const std::string &name, TypeHandle parent1, TypeHandle parent2, TypeHandle parent3, TypeHandle parent4) { if (TypeRegistry::ptr()->register_type(type_handle, name)) { @@ -66,18 +66,18 @@ register_type(TypeHandle &type_handle, const string &name, * reference. */ INLINE TypeHandle -register_dynamic_type(const string &name) { +register_dynamic_type(const std::string &name) { return TypeRegistry::ptr()->register_dynamic_type(name); } INLINE TypeHandle -register_dynamic_type(const string &name, TypeHandle parent1) { +register_dynamic_type(const std::string &name, TypeHandle parent1) { TypeHandle type_handle = TypeRegistry::ptr()->register_dynamic_type(name); TypeRegistry::ptr()->record_derivation(type_handle, parent1); return type_handle; } INLINE TypeHandle -register_dynamic_type(const string &name, +register_dynamic_type(const std::string &name, TypeHandle parent1, TypeHandle parent2) { TypeHandle type_handle = TypeRegistry::ptr()->register_dynamic_type(name); @@ -86,7 +86,7 @@ register_dynamic_type(const string &name, return type_handle; } INLINE TypeHandle -register_dynamic_type(const string &name, +register_dynamic_type(const std::string &name, TypeHandle parent1, TypeHandle parent2, TypeHandle parent3) { TypeHandle type_handle = @@ -97,7 +97,7 @@ register_dynamic_type(const string &name, return type_handle; } INLINE TypeHandle -register_dynamic_type(const string &name, +register_dynamic_type(const std::string &name, TypeHandle parent1, TypeHandle parent2, TypeHandle parent3, TypeHandle parent4) { TypeHandle type_handle = diff --git a/dtool/src/dtoolbase/register_type.h b/dtool/src/dtoolbase/register_type.h index c6b27f2a94..a15cc9ddb1 100644 --- a/dtool/src/dtoolbase/register_type.h +++ b/dtool/src/dtoolbase/register_type.h @@ -27,23 +27,23 @@ * Register() and record_derivation() yourself. */ INLINE void -register_type(TypeHandle &type_handle, const string &name); +register_type(TypeHandle &type_handle, const std::string &name); INLINE void -register_type(TypeHandle &type_handle, const string &name, +register_type(TypeHandle &type_handle, const std::string &name, TypeHandle parent1); INLINE void -register_type(TypeHandle &type_handle, const string &name, +register_type(TypeHandle &type_handle, const std::string &name, TypeHandle parent1, TypeHandle parent2); INLINE void -register_type(TypeHandle &type_handle, const string &name, +register_type(TypeHandle &type_handle, const std::string &name, TypeHandle parent1, TypeHandle parent2, TypeHandle parent3); INLINE void -register_type(TypeHandle &type_handle, const string &name, +register_type(TypeHandle &type_handle, const std::string &name, TypeHandle parent1, TypeHandle parent2, TypeHandle parent3, TypeHandle parent4); @@ -55,22 +55,22 @@ register_type(TypeHandle &type_handle, const string &name, * reference. */ INLINE TypeHandle -register_dynamic_type(const string &name); +register_dynamic_type(const std::string &name); INLINE TypeHandle -register_dynamic_type(const string &name, TypeHandle parent1); +register_dynamic_type(const std::string &name, TypeHandle parent1); INLINE TypeHandle -register_dynamic_type(const string &name, +register_dynamic_type(const std::string &name, TypeHandle parent1, TypeHandle parent2); INLINE TypeHandle -register_dynamic_type(const string &name, +register_dynamic_type(const std::string &name, TypeHandle parent1, TypeHandle parent2, TypeHandle parent3); INLINE TypeHandle -register_dynamic_type(const string &name, +register_dynamic_type(const std::string &name, TypeHandle parent1, TypeHandle parent2, TypeHandle parent3, TypeHandle parent4); @@ -166,12 +166,12 @@ INLINE TypeHandle _get_type_handle(const float *) { } template<> -INLINE TypeHandle _get_type_handle(const string *) { +INLINE TypeHandle _get_type_handle(const std::string *) { return string_type_handle; } template<> -INLINE TypeHandle _get_type_handle(const wstring *) { +INLINE TypeHandle _get_type_handle(const std::wstring *) { return wstring_type_handle; } diff --git a/dtool/src/dtoolbase/stl_compares.h b/dtool/src/dtoolbase/stl_compares.h index 0afffbf9a2..946eab9b64 100644 --- a/dtool/src/dtoolbase/stl_compares.h +++ b/dtool/src/dtoolbase/stl_compares.h @@ -24,9 +24,7 @@ #ifdef HAVE_STL_HASH #include // for hash_compare -using std::less; - -template > +template > class stl_hash_compare : public stdext::hash_compare { public: INLINE bool is_equal(const Key &a, const Key &b) const { @@ -38,10 +36,8 @@ public: #include // for less -using std::less; - // This is declared for the cases in which we don't have STL_HASH available. -template > +template > class stl_hash_compare : public Compare { public: INLINE size_t operator () (const Key &key) const { @@ -122,7 +118,7 @@ public: * size_t typecast operator). It is the same as the system-provided * hash_compare. */ -template > +template > class integer_hash : public stl_hash_compare { public: INLINE static size_t add_hash(size_t start, const Key &key); @@ -132,7 +128,7 @@ public: * This is the default hash_compare class, which assumes the Key is a pointer * value. It is the same as the system-provided hash_compare. */ -class pointer_hash : public stl_hash_compare > { +class pointer_hash : public stl_hash_compare > { public: INLINE static size_t add_hash(size_t start, const void *key); }; @@ -154,7 +150,7 @@ public: * This hash_compare class hashes a string. It assumes the Key is a string or * provides begin() and end() methods that iterate through Key::value_type. */ -template > +template > class sequence_hash : public stl_hash_compare { public: INLINE size_t operator () (const Key &key) const; @@ -168,7 +164,7 @@ public: * This hash_compare class hashes a class object. It assumes the Key provides * a method called get_hash() that returns a size_t. */ -template > +template > class method_hash : public stl_hash_compare { public: INLINE size_t operator () (const Key &key) const; @@ -212,8 +208,8 @@ typedef floating_point_hash float_hash; typedef floating_point_hash double_hash; typedef integer_hash int_hash; typedef integer_hash size_t_hash; -typedef sequence_hash string_hash; -typedef sequence_hash wstring_hash; +typedef sequence_hash string_hash; +typedef sequence_hash wstring_hash; template class indirect_less_hash : public indirect_method_hash > { diff --git a/dtool/src/dtoolbase/typeHandle.I b/dtool/src/dtoolbase/typeHandle.I index c63524c18c..134d85581a 100644 --- a/dtool/src/dtoolbase/typeHandle.I +++ b/dtool/src/dtoolbase/typeHandle.I @@ -84,7 +84,7 @@ get_hash() const { * owns this TypeHandle. It is only used in case the TypeHandle is * inadvertantly undefined. */ -INLINE string TypeHandle:: +INLINE std::string TypeHandle:: get_name(TypedObject *object) const { if ((*this) == TypeHandle::none()) { return "none"; @@ -187,7 +187,7 @@ get_index() const { * */ INLINE void TypeHandle:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name(); } diff --git a/dtool/src/dtoolbase/typeHandle.h b/dtool/src/dtoolbase/typeHandle.h index 03d0cd269c..da66074750 100644 --- a/dtool/src/dtoolbase/typeHandle.h +++ b/dtool/src/dtoolbase/typeHandle.h @@ -108,7 +108,7 @@ PUBLISHED: INLINE int compare_to(const TypeHandle &other) const; INLINE size_t get_hash() const; - INLINE string get_name(TypedObject *object = nullptr) const; + INLINE std::string get_name(TypedObject *object = nullptr) const; INLINE bool is_derived_from(TypeHandle parent, TypedObject *object = nullptr) const; @@ -128,7 +128,7 @@ PUBLISHED: void dec_memory_usage(MemoryClass memory_class, size_t size); INLINE int get_index() const; - INLINE void output(ostream &out) const; + INLINE void output(std::ostream &out) const; constexpr static TypeHandle none() { return TypeHandle(0); } INLINE operator bool () const; @@ -157,12 +157,12 @@ private: // It's handy to be able to output a TypeHandle directly, and see the type // name. -INLINE ostream &operator << (ostream &out, TypeHandle type) { +INLINE std::ostream &operator << (std::ostream &out, TypeHandle type) { type.output(out); return out; } -EXPCL_DTOOL_DTOOLBASE ostream &operator << (ostream &out, TypeHandle::MemoryClass mem_class); +EXPCL_DTOOL_DTOOLBASE std::ostream &operator << (std::ostream &out, TypeHandle::MemoryClass mem_class); // We must include typeRegistry at this point so we can call it from our // inline functions. This is a circular include that is strategically placed diff --git a/dtool/src/dtoolbase/typeRegistry.h b/dtool/src/dtoolbase/typeRegistry.h index 2227782862..dc7df60541 100644 --- a/dtool/src/dtoolbase/typeRegistry.h +++ b/dtool/src/dtoolbase/typeRegistry.h @@ -38,18 +38,18 @@ public: // User code shouldn't generally need to call TypeRegistry::register_type() // or record_derivation() directly; instead, use the register_type // convenience function, defined in register_type.h. - bool register_type(TypeHandle &type_handle, const string &name); + bool register_type(TypeHandle &type_handle, const std::string &name); PUBLISHED: - TypeHandle register_dynamic_type(const string &name); + TypeHandle register_dynamic_type(const std::string &name); void record_derivation(TypeHandle child, TypeHandle parent); - void record_alternate_name(TypeHandle type, const string &name); + void record_alternate_name(TypeHandle type, const std::string &name); - TypeHandle find_type(const string &name) const; + TypeHandle find_type(const std::string &name) const; TypeHandle find_type_by_id(int id) const; - string get_name(TypeHandle type, TypedObject *object) const; + std::string get_name(TypeHandle type, TypedObject *object) const; bool is_derived_from(TypeHandle child, TypeHandle base, TypedObject *child_object); @@ -74,7 +74,7 @@ PUBLISHED: static void reregister_types(); - void write(ostream &out) const; + void write(std::ostream &out) const; // ptr() returns the pointer to the global TypeRegistry object. static INLINE TypeRegistry *ptr(); @@ -94,8 +94,8 @@ private: INLINE void freshen_derivations(); void rebuild_derivations(); - void do_write(ostream &out) const; - void write_node(ostream &out, int indent_level, + void do_write(std::ostream &out) const; + void write_node(std::ostream &out, int indent_level, const TypeRegistryNode *node) const; static INLINE void init_lock(); @@ -103,7 +103,7 @@ private: typedef std::vector HandleRegistry; HandleRegistry _handle_registry; - typedef std::map NameRegistry; + typedef std::map NameRegistry; NameRegistry _name_registry; typedef std::vector RootClasses; diff --git a/dtool/src/dtoolbase/typeRegistryNode.h b/dtool/src/dtoolbase/typeRegistryNode.h index c459d64805..dd888cbf59 100644 --- a/dtool/src/dtoolbase/typeRegistryNode.h +++ b/dtool/src/dtoolbase/typeRegistryNode.h @@ -29,7 +29,7 @@ */ class EXPCL_DTOOL_DTOOLBASE TypeRegistryNode { public: - TypeRegistryNode(TypeHandle handle, const string &name, TypeHandle &ref); + TypeRegistryNode(TypeHandle handle, const std::string &name, TypeHandle &ref); static bool is_derived_from(const TypeRegistryNode *child, const TypeRegistryNode *base); @@ -41,7 +41,7 @@ public: void define_subtree(); TypeHandle _handle; - string _name; + std::string _name; TypeHandle &_ref; typedef std::vector Classes; Classes _parent_classes; diff --git a/dtool/src/dtoolutil/dSearchPath.I b/dtool/src/dtoolutil/dSearchPath.I index 3a958915d6..66055a7466 100644 --- a/dtool/src/dtoolutil/dSearchPath.I +++ b/dtool/src/dtoolutil/dSearchPath.I @@ -48,8 +48,8 @@ find_all_files(const Filename &filename) const { * searches that. */ INLINE Filename DSearchPath:: -search_path(const Filename &filename, const string &path, - const string &separator) { +search_path(const Filename &filename, const std::string &path, + const std::string &separator) { DSearchPath search(path, separator); return search.find_file(filename); } diff --git a/dtool/src/dtoolutil/dSearchPath.h b/dtool/src/dtoolutil/dSearchPath.h index 85184df77c..8cb769c378 100644 --- a/dtool/src/dtoolutil/dSearchPath.h +++ b/dtool/src/dtoolutil/dSearchPath.h @@ -41,8 +41,8 @@ PUBLISHED: INLINE Filename operator [] (size_t n) const; INLINE size_t size() const; - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; public: void add_file(const Filename &file); @@ -53,7 +53,7 @@ PUBLISHED: }; DSearchPath(); - DSearchPath(const string &path, const string &separator = string()); + DSearchPath(const std::string &path, const std::string &separator = std::string()); DSearchPath(const Filename &directory); DSearchPath(const DSearchPath ©); void operator = (const DSearchPath ©); @@ -62,8 +62,8 @@ PUBLISHED: void clear(); void append_directory(const Filename &directory); void prepend_directory(const Filename &directory); - void append_path(const string &path, - const string &separator = string()); + void append_path(const std::string &path, + const std::string &separator = std::string()); void append_path(const DSearchPath &path); void prepend_path(const DSearchPath &path); @@ -78,18 +78,18 @@ PUBLISHED: INLINE Results find_all_files(const Filename &filename) const; INLINE static Filename - search_path(const Filename &filename, const string &path, - const string &separator = string()); + search_path(const Filename &filename, const std::string &path, + const std::string &separator = std::string()); - void output(ostream &out, const string &separator = string()) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out, const std::string &separator = std::string()) const; + void write(std::ostream &out, int indent_level = 0) const; private: typedef pvector Directories; Directories _directories; }; -INLINE ostream &operator << (ostream &out, const DSearchPath &sp) { +INLINE std::ostream &operator << (std::ostream &out, const DSearchPath &sp) { sp.output(out); return out; } diff --git a/dtool/src/dtoolutil/executionEnvironment.I b/dtool/src/dtoolutil/executionEnvironment.I index b1fe554a29..4639ab0a36 100644 --- a/dtool/src/dtoolutil/executionEnvironment.I +++ b/dtool/src/dtoolutil/executionEnvironment.I @@ -15,7 +15,7 @@ * Returns true if the indicated environment variable is defined. */ INLINE bool ExecutionEnvironment:: -has_environment_variable(const string &var) { +has_environment_variable(const std::string &var) { return get_ptr()->ns_has_environment_variable(var); } @@ -23,8 +23,8 @@ has_environment_variable(const string &var) { * Returns the definition of the indicated environment variable, or the empty * string if the variable is undefined. */ -INLINE string ExecutionEnvironment:: -get_environment_variable(const string &var) { +INLINE std::string ExecutionEnvironment:: +get_environment_variable(const std::string &var) { return get_ptr()->ns_get_environment_variable(var); } @@ -32,7 +32,7 @@ get_environment_variable(const string &var) { * Changes the definition of the indicated environment variable. */ INLINE void ExecutionEnvironment:: -set_environment_variable(const string &var, const string &value) { +set_environment_variable(const std::string &var, const std::string &value) { get_ptr()->ns_set_environment_variable(var, value); } @@ -43,7 +43,7 @@ set_environment_variable(const string &var, const string &value) { * will return this new value. */ INLINE void ExecutionEnvironment:: -shadow_environment_variable(const string &var, const string &value) { +shadow_environment_variable(const std::string &var, const std::string &value) { get_ptr()->ns_shadow_environment_variable(var, value); } @@ -52,7 +52,7 @@ shadow_environment_variable(const string &var, const string &value) { * and lets the actual value of the variable show again. */ INLINE void ExecutionEnvironment:: -clear_shadow(const string &var) { +clear_shadow(const std::string &var) { get_ptr()->ns_clear_shadow(var); } @@ -70,7 +70,7 @@ get_num_args() { * .. get_num_args()). The first parameter, n == 0, is the first actual * parameter, not the binary name. */ -INLINE string ExecutionEnvironment:: +INLINE std::string ExecutionEnvironment:: get_arg(size_t n) { return get_ptr()->ns_get_arg(n); } @@ -79,7 +79,7 @@ get_arg(size_t n) { * Returns the name of the binary executable that started this program, if it * can be determined. */ -INLINE string ExecutionEnvironment:: +INLINE std::string ExecutionEnvironment:: get_binary_name() { return get_ptr()->ns_get_binary_name(); } @@ -88,7 +88,7 @@ get_binary_name() { * Returns the name of the libdtool DLL that is used in this program, if it * can be determined. */ -INLINE string ExecutionEnvironment:: +INLINE std::string ExecutionEnvironment:: get_dtool_name() { return get_ptr()->ns_get_dtool_name(); } @@ -97,7 +97,7 @@ get_dtool_name() { * Do not use. */ INLINE void ExecutionEnvironment:: -set_binary_name(const string &name) { +set_binary_name(const std::string &name) { get_ptr()->_binary_name = name; } @@ -105,6 +105,6 @@ set_binary_name(const string &name) { * Do not use. */ INLINE void ExecutionEnvironment:: -set_dtool_name(const string &name) { +set_dtool_name(const std::string &name) { get_ptr()->_dtool_name = name; } diff --git a/dtool/src/dtoolutil/executionEnvironment.h b/dtool/src/dtoolutil/executionEnvironment.h index 7415f19642..0ff0814cdd 100644 --- a/dtool/src/dtoolutil/executionEnvironment.h +++ b/dtool/src/dtoolutil/executionEnvironment.h @@ -31,23 +31,23 @@ private: ExecutionEnvironment(); PUBLISHED: - INLINE static bool has_environment_variable(const string &var); - INLINE static string get_environment_variable(const string &var); - INLINE static void set_environment_variable(const string &var, const string &value); + INLINE static bool has_environment_variable(const std::string &var); + INLINE static std::string get_environment_variable(const std::string &var); + INLINE static void set_environment_variable(const std::string &var, const std::string &value); - INLINE static void shadow_environment_variable(const string &var, const string &value); - INLINE static void clear_shadow(const string &var); + INLINE static void shadow_environment_variable(const std::string &var, const std::string &value); + INLINE static void clear_shadow(const std::string &var); - static string expand_string(const string &str); + static std::string expand_string(const std::string &str); INLINE static size_t get_num_args(); - INLINE static string get_arg(size_t n); + INLINE static std::string get_arg(size_t n); - INLINE static string get_binary_name(); - INLINE static string get_dtool_name(); + INLINE static std::string get_binary_name(); + INLINE static std::string get_dtool_name(); - INLINE static void set_binary_name(const string &name); - INLINE static void set_dtool_name(const string &name); + INLINE static void set_binary_name(const std::string &name); + INLINE static void set_dtool_name(const std::string &name); static Filename get_cwd(); @@ -61,17 +61,17 @@ PUBLISHED: MAKE_PROPERTY(cwd, get_cwd); private: - bool ns_has_environment_variable(const string &var) const; - string ns_get_environment_variable(const string &var) const; - void ns_set_environment_variable(const string &var, const string &value); - void ns_shadow_environment_variable(const string &var, const string &value); - void ns_clear_shadow(const string &var); + bool ns_has_environment_variable(const std::string &var) const; + std::string ns_get_environment_variable(const std::string &var) const; + void ns_set_environment_variable(const std::string &var, const std::string &value); + void ns_shadow_environment_variable(const std::string &var, const std::string &value); + void ns_clear_shadow(const std::string &var); size_t ns_get_num_args() const; - string ns_get_arg(size_t n) const; + std::string ns_get_arg(size_t n) const; - string ns_get_binary_name() const; - string ns_get_dtool_name() const; + std::string ns_get_binary_name() const; + std::string ns_get_dtool_name() const; static ExecutionEnvironment *get_ptr(); @@ -79,14 +79,14 @@ private: void read_args(); private: - typedef map EnvironmentVariables; + typedef std::map EnvironmentVariables; EnvironmentVariables _variables; typedef vector_string CommandArguments; CommandArguments _args; - string _binary_name; - string _dtool_name; + std::string _binary_name; + std::string _dtool_name; static ExecutionEnvironment *_global_ptr; }; diff --git a/dtool/src/dtoolutil/filename.I b/dtool/src/dtoolutil/filename.I index 989d77df98..b23947320f 100644 --- a/dtool/src/dtoolutil/filename.I +++ b/dtool/src/dtoolutil/filename.I @@ -15,7 +15,7 @@ * */ INLINE Filename:: -Filename(const string &filename) { +Filename(const std::string &filename) { _flags = 0; (*this) = filename; } @@ -24,7 +24,7 @@ Filename(const string &filename) { * */ INLINE Filename:: -Filename(const wstring &filename) { +Filename(const std::wstring &filename) { _flags = 0; (*this) = filename; } @@ -58,7 +58,7 @@ Filename(const Filename ©) : * */ INLINE Filename:: -Filename(string &&filename) noexcept : _flags(0) { +Filename(std::string &&filename) noexcept : _flags(0) { (*this) = std::move(filename); } @@ -85,10 +85,10 @@ INLINE Filename:: Filename() : _dirname_end(0), _basename_start(0), - _basename_end(string::npos), - _extension_start(string::npos), - _hash_start(string::npos), - _hash_end(string::npos), + _basename_end(std::string::npos), + _extension_start(std::string::npos), + _hash_start(std::string::npos), + _hash_end(std::string::npos), _flags(0) { } @@ -106,7 +106,7 @@ text_filename(const Filename &filename) { * */ INLINE Filename Filename:: -text_filename(const string &filename) { +text_filename(const std::string &filename) { Filename result(filename); result.set_text(); return result; @@ -126,7 +126,7 @@ binary_filename(const Filename &filename) { * */ INLINE Filename Filename:: -binary_filename(const string &filename) { +binary_filename(const std::string &filename) { Filename result(filename); result.set_binary(); return result; @@ -136,7 +136,7 @@ binary_filename(const string &filename) { * */ INLINE Filename Filename:: -dso_filename(const string &filename) { +dso_filename(const std::string &filename) { Filename result(filename); result.set_type(T_dso); return result; @@ -146,7 +146,7 @@ dso_filename(const string &filename) { * */ INLINE Filename Filename:: -executable_filename(const string &filename) { +executable_filename(const std::string &filename) { Filename result(filename); result.set_type(T_executable); return result; @@ -157,7 +157,7 @@ executable_filename(const string &filename) { * set_pattern(). */ INLINE Filename Filename:: -pattern_filename(const string &filename) { +pattern_filename(const std::string &filename) { Filename result(filename); result.set_pattern(true); return result; @@ -167,7 +167,7 @@ pattern_filename(const string &filename) { * */ INLINE Filename &Filename:: -operator = (const string &filename) { +operator = (const std::string &filename) { _filename = filename; locate_basename(); @@ -180,7 +180,7 @@ operator = (const string &filename) { * */ INLINE Filename &Filename:: -operator = (const wstring &filename) { +operator = (const std::wstring &filename) { TextEncoder encoder; encoder.set_encoding(get_filesystem_encoding()); encoder.set_wtext(filename); @@ -193,7 +193,7 @@ operator = (const wstring &filename) { INLINE Filename &Filename:: operator = (const char *filename) { assert(filename != nullptr); - return (*this) = string(filename); + return (*this) = std::string(filename); } /** @@ -216,7 +216,7 @@ operator = (const Filename ©) { * */ INLINE Filename &Filename:: -operator = (string &&filename) noexcept { +operator = (std::string &&filename) noexcept { _filename = std::move(filename); locate_basename(); @@ -245,7 +245,7 @@ operator = (Filename &&from) noexcept { * */ INLINE Filename:: -operator const string & () const { +operator const std::string & () const { return _filename; } @@ -285,7 +285,7 @@ operator [] (size_t n) const { /** * */ -INLINE string Filename:: +INLINE std::string Filename:: substr(size_t begin) const { return _filename.substr(begin); } @@ -293,7 +293,7 @@ substr(size_t begin) const { /** * */ -INLINE string Filename:: +INLINE std::string Filename:: substr(size_t begin, size_t end) const { return _filename.substr(begin, end); } @@ -304,7 +304,7 @@ substr(size_t begin, size_t end) const { * two parameters. */ INLINE void Filename:: -operator += (const string &other) { +operator += (const std::string &other) { _filename += other; locate_basename(); locate_extension(); @@ -315,7 +315,7 @@ operator += (const string &other) { * Returns a new Filename representing the concatenation of the two filenames. */ INLINE Filename Filename:: -operator + (const string &other) const { +operator + (const std::string &other) const { Filename a(*this); a += other; return a; @@ -334,7 +334,7 @@ operator / (const Filename &other) const { * Returns the entire filename: directory, basename, extension. This is the * same thing returned by the string typecast operator. */ -INLINE string Filename:: +INLINE std::string Filename:: get_fullpath() const { return _filename; } @@ -342,7 +342,7 @@ get_fullpath() const { /** * Returns the entire filename as a wide-character string. */ -INLINE wstring Filename:: +INLINE std::wstring Filename:: get_fullpath_w() const { TextEncoder encoder; encoder.set_encoding(get_filesystem_encoding()); @@ -354,7 +354,7 @@ get_fullpath_w() const { * Returns the directory part of the filename. This is everything in the * filename up to, but not including the rightmost slash. */ -INLINE string Filename:: +INLINE std::string Filename:: get_dirname() const { return _filename.substr(0, _dirname_end); } @@ -363,7 +363,7 @@ get_dirname() const { * Returns the basename part of the filename. This is everything in the * filename after the rightmost slash, including any extensions. */ -INLINE string Filename:: +INLINE std::string Filename:: get_basename() const { return _filename.substr(_basename_start); } @@ -373,7 +373,7 @@ get_basename() const { * Returns the full filename--directory and basename parts--except for the * extension. */ -INLINE string Filename:: +INLINE std::string Filename:: get_fullpath_wo_extension() const { return _filename.substr(0, _basename_end); } @@ -382,9 +382,9 @@ get_fullpath_wo_extension() const { /** * Returns the basename part of the filename, without the file extension. */ -INLINE string Filename:: +INLINE std::string Filename:: get_basename_wo_extension() const { - if (_basename_end == string::npos) { + if (_basename_end == std::string::npos) { return _filename.substr(_basename_start); } else { return _filename.substr(_basename_start, _basename_end - _basename_start); @@ -396,10 +396,10 @@ get_basename_wo_extension() const { * Returns the file extension. This is everything after the rightmost dot, if * there is one, or the empty string if there is not. */ -INLINE string Filename:: +INLINE std::string Filename:: get_extension() const { - if (_extension_start == string::npos) { - return string(); + if (_extension_start == std::string::npos) { + return std::string(); } else { return _filename.substr(_extension_start); } @@ -536,7 +536,7 @@ has_hash() const { * Returns the part of the filename beginning at the hash sequence (if any), * and continuing to the end of the filename. */ -INLINE string Filename:: +INLINE std::string Filename:: get_hash_to_end() const { return _filename.substr(_hash_start); } @@ -569,24 +569,24 @@ is_fully_qualified() const { * */ INLINE bool Filename:: -operator == (const string &other) const { - return (*(string *)this) == other; +operator == (const std::string &other) const { + return (*(std::string *)this) == other; } /** * */ INLINE bool Filename:: -operator != (const string &other) const { - return (*(string *)this) != other; +operator != (const std::string &other) const { + return (*(std::string *)this) != other; } /** * */ INLINE bool Filename:: -operator < (const string &other) const { - return (*(string *)this) < other; +operator < (const std::string &other) const { + return (*(std::string *)this) < other; } /** @@ -616,7 +616,7 @@ __nonzero__() const { * */ INLINE void Filename:: -output(ostream &out) const { +output(std::ostream &out) const { out << _filename; } diff --git a/dtool/src/dtoolutil/filename.h b/dtool/src/dtoolutil/filename.h index 01297dfbee..66b38356a6 100644 --- a/dtool/src/dtoolutil/filename.h +++ b/dtool/src/dtoolutil/filename.h @@ -55,10 +55,10 @@ public: }; INLINE Filename(const char *filename); - INLINE Filename(const string &filename); - INLINE Filename(const wstring &filename); + INLINE Filename(const std::string &filename); + INLINE Filename(const std::wstring &filename); INLINE Filename(const Filename ©); - INLINE Filename(string &&filename) noexcept; + INLINE Filename(std::string &&filename) noexcept; INLINE Filename(Filename &&from) noexcept; PUBLISHED: @@ -75,22 +75,22 @@ PUBLISHED: // or binary file. This is in lieu of calling set_text() or set_binary() or // set_type(). INLINE static Filename text_filename(const Filename &filename); - INLINE static Filename text_filename(const string &filename); + INLINE static Filename text_filename(const std::string &filename); INLINE static Filename binary_filename(const Filename &filename); - INLINE static Filename binary_filename(const string &filename); - INLINE static Filename dso_filename(const string &filename); - INLINE static Filename executable_filename(const string &filename); + INLINE static Filename binary_filename(const std::string &filename); + INLINE static Filename dso_filename(const std::string &filename); + INLINE static Filename executable_filename(const std::string &filename); - INLINE static Filename pattern_filename(const string &filename); + INLINE static Filename pattern_filename(const std::string &filename); - static Filename from_os_specific(const string &os_specific, + static Filename from_os_specific(const std::string &os_specific, Type type = T_general); - static Filename from_os_specific_w(const wstring &os_specific, + static Filename from_os_specific_w(const std::wstring &os_specific, Type type = T_general); - static Filename expand_from(const string &user_string, + static Filename expand_from(const std::string &user_string, Type type = T_general); - static Filename temporary(const string &dirname, const string &prefix, - const string &suffix = string(), + static Filename temporary(const std::string &dirname, const std::string &prefix, + const std::string &suffix = std::string(), Type type = T_general); static const Filename &get_home_directory(); @@ -99,15 +99,15 @@ PUBLISHED: static const Filename &get_common_appdata_directory(); // Assignment is via the = operator. - INLINE Filename &operator = (const string &filename); - INLINE Filename &operator = (const wstring &filename); + INLINE Filename &operator = (const std::string &filename); + INLINE Filename &operator = (const std::wstring &filename); INLINE Filename &operator = (const char *filename); INLINE Filename &operator = (const Filename ©); - INLINE Filename &operator = (string &&filename) noexcept; + INLINE Filename &operator = (std::string &&filename) noexcept; INLINE Filename &operator = (Filename &&from) noexcept; // And retrieval is by any of the classic string operations. - INLINE operator const string & () const; + INLINE operator const std::string & () const; INLINE const char *c_str() const; INLINE bool empty() const; INLINE size_t length() const; @@ -116,29 +116,29 @@ PUBLISHED: EXTENSION(PyObject *__repr__() const); EXTENSION(PyObject *__fspath__() const); - INLINE string substr(size_t begin) const; - INLINE string substr(size_t begin, size_t end) const; - INLINE void operator += (const string &other); - INLINE Filename operator + (const string &other) const; + INLINE std::string substr(size_t begin) const; + INLINE std::string substr(size_t begin, size_t end) const; + INLINE void operator += (const std::string &other); + INLINE Filename operator + (const std::string &other) const; INLINE Filename operator / (const Filename &other) const; // Or, you can use any of these. - INLINE string get_fullpath() const; - INLINE wstring get_fullpath_w() const; - INLINE string get_dirname() const; - INLINE string get_basename() const; - INLINE string get_fullpath_wo_extension() const; - INLINE string get_basename_wo_extension() const; - INLINE string get_extension() const; + INLINE std::string get_fullpath() const; + INLINE std::wstring get_fullpath_w() const; + INLINE std::string get_dirname() const; + INLINE std::string get_basename() const; + INLINE std::string get_fullpath_wo_extension() const; + INLINE std::string get_basename_wo_extension() const; + INLINE std::string get_extension() const; // You can also use any of these to reassign pieces of the filename. - void set_fullpath(const string &s); - void set_dirname(const string &s); - void set_basename(const string &s); - void set_fullpath_wo_extension(const string &s); - void set_basename_wo_extension(const string &s); - void set_extension(const string &s); + void set_fullpath(const std::string &s); + void set_dirname(const std::string &s); + void set_basename(const std::string &s); + void set_fullpath_wo_extension(const std::string &s); + void set_basename_wo_extension(const std::string &s); + void set_extension(const std::string &s); // Setting these flags appropriately is helpful when opening or searching // for a file; it helps the Filename resolve OS-specific conventions (for @@ -159,8 +159,8 @@ PUBLISHED: INLINE bool has_hash() const; Filename get_filename_index(int index) const; - INLINE string get_hash_to_end() const; - void set_hash_to_end(const string &s); + INLINE std::string get_hash_to_end() const; + void set_hash_to_end(const std::string &s); void extract_components(vector_string &components) const; void standardize(); @@ -175,11 +175,11 @@ PUBLISHED: bool make_canonical(); bool make_true_case(); - string to_os_specific() const; - wstring to_os_specific_w() const; - string to_os_generic() const; - string to_os_short_name() const; - string to_os_long_name() const; + std::string to_os_specific() const; + std::wstring to_os_specific_w() const; + std::string to_os_generic() const; + std::string to_os_short_name() const; + std::string to_os_long_name() const; bool exists() const; bool is_regular_file() const; @@ -191,10 +191,10 @@ PUBLISHED: bool other_missing_is_old = true) const; time_t get_timestamp() const; time_t get_access_timestamp() const; - streamsize get_file_size() const; + std::streamsize get_file_size() const; bool resolve_filename(const DSearchPath &searchpath, - const string &default_extension = string()); + const std::string &default_extension = std::string()); bool make_relative_to(Filename directory, bool allow_backups = true); int find_on_searchpath(const DSearchPath &searchpath); @@ -228,31 +228,31 @@ PUBLISHED: bool rmdir() const; // Comparison operators are handy. - INLINE bool operator == (const string &other) const; - INLINE bool operator != (const string &other) const; - INLINE bool operator < (const string &other) const; + INLINE bool operator == (const std::string &other) const; + INLINE bool operator != (const std::string &other) const; + INLINE bool operator < (const std::string &other) const; INLINE int compare_to(const Filename &other) const; INLINE bool __nonzero__() const; int get_hash() const; - INLINE void output(ostream &out) const; + INLINE void output(std::ostream &out) const; INLINE static void set_filesystem_encoding(TextEncoder::Encoding encoding); INLINE static TextEncoder::Encoding get_filesystem_encoding(); public: - bool atomic_compare_and_exchange_contents(string &orig_contents, const string &old_contents, const string &new_contents) const; - bool atomic_read_contents(string &contents) const; + bool atomic_compare_and_exchange_contents(std::string &orig_contents, const std::string &old_contents, const std::string &new_contents) const; + bool atomic_read_contents(std::string &contents) const; protected: void locate_basename(); void locate_extension(); void locate_hash(); - size_t get_common_prefix(const string &other) const; - static int count_slashes(const string &str); + size_t get_common_prefix(const std::string &other) const; + static int count_slashes(const std::string &str); bool r_make_canonical(const Filename &cwd); - string _filename; + std::string _filename; // We'll make these size_t instead of string::size_type to help out // cppParser. size_t _dirname_end; @@ -272,7 +272,7 @@ protected: #ifdef ANDROID public: - static string _internal_data_dir; + static std::string _internal_data_dir; #endif public: @@ -287,7 +287,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const Filename &n) { +INLINE std::ostream &operator << (std::ostream &out, const Filename &n) { n.output(out); return out; } diff --git a/dtool/src/dtoolutil/filename_assist.h b/dtool/src/dtoolutil/filename_assist.h index ff1c91402c..ad4f08ef1d 100644 --- a/dtool/src/dtoolutil/filename_assist.h +++ b/dtool/src/dtoolutil/filename_assist.h @@ -20,10 +20,10 @@ #ifdef IS_OSX -string get_osx_home_directory(); -string get_osx_temp_directory(); -string get_osx_user_appdata_directory(); -string get_osx_common_appdata_directory(); +std::string get_osx_home_directory(); +std::string get_osx_temp_directory(); +std::string get_osx_user_appdata_directory(); +std::string get_osx_common_appdata_directory(); #endif // IS_OSX diff --git a/dtool/src/dtoolutil/globPattern.I b/dtool/src/dtoolutil/globPattern.I index c5d48d4d28..f0ab3a6c0e 100644 --- a/dtool/src/dtoolutil/globPattern.I +++ b/dtool/src/dtoolutil/globPattern.I @@ -15,7 +15,7 @@ * */ INLINE GlobPattern:: -GlobPattern(const string &pattern) : _pattern(pattern) { +GlobPattern(const std::string &pattern) : _pattern(pattern) { _case_sensitive = true; } @@ -69,14 +69,14 @@ operator < (const GlobPattern &other) const { * Changes the pattern string that the GlobPattern object matches. */ INLINE void GlobPattern:: -set_pattern(const string &pattern) { +set_pattern(const std::string &pattern) { _pattern = pattern; } /** * Returns the pattern string that the GlobPattern object matches. */ -INLINE const string &GlobPattern:: +INLINE const std::string &GlobPattern:: get_pattern() const { return _pattern; } @@ -103,14 +103,14 @@ get_case_sensitive() const { * Specifies a set of characters that are not matched by * or ?. */ INLINE void GlobPattern:: -set_nomatch_chars(const string &nomatch_chars) { +set_nomatch_chars(const std::string &nomatch_chars) { _nomatch_chars = nomatch_chars; } /** * Returns the set of characters that are not matched by * or ?. */ -INLINE const string &GlobPattern:: +INLINE const std::string &GlobPattern:: get_nomatch_chars() const { return _nomatch_chars; } @@ -119,7 +119,7 @@ get_nomatch_chars() const { * Returns true if the candidate string matches the pattern, false otherwise. */ INLINE bool GlobPattern:: -matches(const string &candidate) const { +matches(const std::string &candidate) const { return matches_substr(_pattern.begin(), _pattern.end(), candidate.begin(), candidate.end()); } @@ -128,6 +128,6 @@ matches(const string &candidate) const { * */ INLINE void GlobPattern:: -output(ostream &out) const { +output(std::ostream &out) const { out << _pattern; } diff --git a/dtool/src/dtoolutil/globPattern.h b/dtool/src/dtoolutil/globPattern.h index 015bde38f9..27dfb67777 100644 --- a/dtool/src/dtoolutil/globPattern.h +++ b/dtool/src/dtoolutil/globPattern.h @@ -31,7 +31,7 @@ */ class EXPCL_DTOOL_DTOOLUTIL GlobPattern { PUBLISHED: - INLINE GlobPattern(const string &pattern = string()); + INLINE GlobPattern(const std::string &pattern = std::string()); INLINE GlobPattern(const GlobPattern ©); INLINE void operator = (const GlobPattern ©); @@ -39,48 +39,48 @@ PUBLISHED: INLINE bool operator != (const GlobPattern &other) const; INLINE bool operator < (const GlobPattern &other) const; - INLINE void set_pattern(const string &pattern); - INLINE const string &get_pattern() const; + INLINE void set_pattern(const std::string &pattern); + INLINE const std::string &get_pattern() const; MAKE_PROPERTY(pattern, get_pattern, set_pattern); INLINE void set_case_sensitive(bool case_sensitive); INLINE bool get_case_sensitive() const; MAKE_PROPERTY(case_sensitive, get_case_sensitive, set_case_sensitive); - INLINE void set_nomatch_chars(const string &nomatch_chars); - INLINE const string &get_nomatch_chars() const; + INLINE void set_nomatch_chars(const std::string &nomatch_chars); + INLINE const std::string &get_nomatch_chars() const; MAKE_PROPERTY(nomatch_chars, get_nomatch_chars, set_nomatch_chars); - INLINE bool matches(const string &candidate) const; + INLINE bool matches(const std::string &candidate) const; - INLINE void output(ostream &out) const; + INLINE void output(std::ostream &out) const; bool has_glob_characters() const; - string get_const_prefix() const; + std::string get_const_prefix() const; int match_files(vector_string &results, const Filename &cwd = Filename()) const; #ifdef HAVE_PYTHON EXTENSION(PyObject *match_files(const Filename &cwd = Filename()) const); #endif private: - bool matches_substr(string::const_iterator pi, - string::const_iterator pend, - string::const_iterator ci, - string::const_iterator cend) const; + bool matches_substr(std::string::const_iterator pi, + std::string::const_iterator pend, + std::string::const_iterator ci, + std::string::const_iterator cend) const; - bool matches_set(string::const_iterator &pi, - string::const_iterator pend, + bool matches_set(std::string::const_iterator &pi, + std::string::const_iterator pend, char ch) const; - int r_match_files(const Filename &prefix, const string &suffix, + int r_match_files(const Filename &prefix, const std::string &suffix, vector_string &results, const Filename &cwd); - string _pattern; + std::string _pattern; bool _case_sensitive; - string _nomatch_chars; + std::string _nomatch_chars; }; -INLINE ostream &operator << (ostream &out, const GlobPattern &glob) { +INLINE std::ostream &operator << (std::ostream &out, const GlobPattern &glob) { glob.output(out); return out; } diff --git a/dtool/src/dtoolutil/lineStream.I b/dtool/src/dtoolutil/lineStream.I index 67cab26cbe..8fcc880426 100644 --- a/dtool/src/dtoolutil/lineStream.I +++ b/dtool/src/dtoolutil/lineStream.I @@ -15,7 +15,7 @@ * */ INLINE LineStream:: -LineStream() : ostream(&_lsb) { +LineStream() : std::ostream(&_lsb) { } /** @@ -34,7 +34,7 @@ is_text_available() const { * has_newline() to determine whether or not there was an explicit newline * character written following this line. */ -INLINE string LineStream:: +INLINE std::string LineStream:: get_line() { return _lsb.get_line(); } diff --git a/dtool/src/dtoolutil/lineStream.h b/dtool/src/dtoolutil/lineStream.h index 7f9f5eff4a..845e6496ea 100644 --- a/dtool/src/dtoolutil/lineStream.h +++ b/dtool/src/dtoolutil/lineStream.h @@ -28,7 +28,7 @@ * otherwise affected when a line of text is extracted. More text can still * be written to it and continuously extracted. */ -class EXPCL_DTOOL_DTOOLUTIL LineStream : public ostream { +class EXPCL_DTOOL_DTOOLUTIL LineStream : public std::ostream { PUBLISHED: INLINE LineStream(); @@ -37,7 +37,7 @@ PUBLISHED: #endif INLINE bool is_text_available() const; - INLINE string get_line(); + INLINE std::string get_line(); INLINE bool has_newline() const; private: diff --git a/dtool/src/dtoolutil/lineStreamBuf.I b/dtool/src/dtoolutil/lineStreamBuf.I index 339248d2dd..2623afe787 100644 --- a/dtool/src/dtoolutil/lineStreamBuf.I +++ b/dtool/src/dtoolutil/lineStreamBuf.I @@ -34,6 +34,6 @@ has_newline() const { INLINE void LineStreamBuf:: write_chars(const char *start, size_t length) { if (length > 0) { - _data += string(start, length); + _data += std::string(start, length); } } diff --git a/dtool/src/dtoolutil/lineStreamBuf.h b/dtool/src/dtoolutil/lineStreamBuf.h index 7718371a03..967d3f1636 100644 --- a/dtool/src/dtoolutil/lineStreamBuf.h +++ b/dtool/src/dtoolutil/lineStreamBuf.h @@ -23,13 +23,13 @@ * whose contents can be continuously extracted as a sequence of lines of * text. */ -class EXPCL_DTOOL_DTOOLUTIL LineStreamBuf : public streambuf { +class EXPCL_DTOOL_DTOOLUTIL LineStreamBuf : public std::streambuf { public: LineStreamBuf(); virtual ~LineStreamBuf(); INLINE bool is_text_available() const; - string get_line(); + std::string get_line(); INLINE bool has_newline() const; protected: @@ -39,7 +39,7 @@ protected: private: INLINE void write_chars(const char *start, size_t length); - string _data; + std::string _data; bool _has_newline; }; diff --git a/dtool/src/dtoolutil/load_dso.h b/dtool/src/dtoolutil/load_dso.h index 2c0a5d9d24..40d00e579a 100644 --- a/dtool/src/dtoolutil/load_dso.h +++ b/dtool/src/dtoolutil/load_dso.h @@ -31,11 +31,11 @@ unload_dso(void *dso_handle); // Returns the error message from the last failed load_dso() call. -EXPCL_DTOOL_DTOOLUTIL string +EXPCL_DTOOL_DTOOLUTIL std::string load_dso_error(); // Returns a function pointer or other symbol from a loaded library. EXPCL_DTOOL_DTOOLUTIL void * -get_dso_symbol(void *handle, const string &name); +get_dso_symbol(void *handle, const std::string &name); #endif diff --git a/dtool/src/dtoolutil/pandaFileStream.I b/dtool/src/dtoolutil/pandaFileStream.I index a30a5fdcc0..7ee64e9b4e 100644 --- a/dtool/src/dtoolutil/pandaFileStream.I +++ b/dtool/src/dtoolutil/pandaFileStream.I @@ -15,14 +15,14 @@ * */ INLINE IFileStream:: -IFileStream() : istream(&_buf) { +IFileStream() : std::istream(&_buf) { } /** * */ INLINE IFileStream:: -IFileStream(const char *filename, ios::openmode mode) : istream(&_buf) { +IFileStream(const char *filename, std::ios::openmode mode) : std::istream(&_buf) { open(filename, mode); } @@ -38,11 +38,11 @@ INLINE IFileStream:: * */ INLINE void IFileStream:: -open(const char *filename, ios::openmode mode) { +open(const char *filename, std::ios::openmode mode) { clear((ios_iostate)0); _buf.open(filename, mode); if (!_buf.is_open()) { - clear(ios::failbit); + clear(std::ios::failbit); } } @@ -55,11 +55,11 @@ open(const char *filename, ios::openmode mode) { * This function is the Windows-specific variant. */ void IFileStream:: -attach(const char *filename, HANDLE handle, ios::openmode mode) { +attach(const char *filename, HANDLE handle, std::ios::openmode mode) { clear((ios_iostate)0); _buf.attach(filename, handle, mode); if (!_buf.is_open()) { - clear(ios::failbit); + clear(std::ios::failbit); } } #endif // _WIN32 @@ -73,11 +73,11 @@ attach(const char *filename, HANDLE handle, ios::openmode mode) { * This function is the Posix-specific variant. */ void IFileStream:: -attach(const char *filename, int fd, ios::openmode mode) { +attach(const char *filename, int fd, std::ios::openmode mode) { clear((ios_iostate)0); _buf.attach(filename, fd, mode); if (!_buf.is_open()) { - clear(ios::failbit); + clear(std::ios::failbit); } } #endif // _WIN32 @@ -94,14 +94,14 @@ close() { * */ INLINE OFileStream:: -OFileStream() : ostream(&_buf) { +OFileStream() : std::ostream(&_buf) { } /** * */ INLINE OFileStream:: -OFileStream(const char *filename, ios::openmode mode) : ostream(&_buf) { +OFileStream(const char *filename, std::ios::openmode mode) : std::ostream(&_buf) { open(filename, mode); } @@ -117,11 +117,11 @@ INLINE OFileStream:: * */ INLINE void OFileStream:: -open(const char *filename, ios::openmode mode) { +open(const char *filename, std::ios::openmode mode) { clear((ios_iostate)0); _buf.open(filename, mode); if (!_buf.is_open()) { - clear(ios::failbit); + clear(std::ios::failbit); } } @@ -134,11 +134,11 @@ open(const char *filename, ios::openmode mode) { * This function is the Windows-specific variant. */ void OFileStream:: -attach(const char *filename, HANDLE handle, ios::openmode mode) { +attach(const char *filename, HANDLE handle, std::ios::openmode mode) { clear((ios_iostate)0); _buf.attach(filename, handle, mode); if (!_buf.is_open()) { - clear(ios::failbit); + clear(std::ios::failbit); } } #endif // _WIN32 @@ -152,11 +152,11 @@ attach(const char *filename, HANDLE handle, ios::openmode mode) { * This function is the Posix-specific variant. */ void OFileStream:: -attach(const char *filename, int fd, ios::openmode mode) { +attach(const char *filename, int fd, std::ios::openmode mode) { clear((ios_iostate)0); _buf.attach(filename, fd, mode); if (!_buf.is_open()) { - clear(ios::failbit); + clear(std::ios::failbit); } } #endif // _WIN32 @@ -173,14 +173,14 @@ close() { * */ INLINE FileStream:: -FileStream() : iostream(&_buf) { +FileStream() : std::iostream(&_buf) { } /** * */ INLINE FileStream:: -FileStream(const char *filename, ios::openmode mode) : iostream(&_buf) { +FileStream(const char *filename, std::ios::openmode mode) : std::iostream(&_buf) { open(filename, mode); } @@ -196,11 +196,11 @@ INLINE FileStream:: * */ INLINE void FileStream:: -open(const char *filename, ios::openmode mode) { +open(const char *filename, std::ios::openmode mode) { clear((ios_iostate)0); _buf.open(filename, mode); if (!_buf.is_open()) { - clear(ios::failbit); + clear(std::ios::failbit); } } @@ -213,11 +213,11 @@ open(const char *filename, ios::openmode mode) { * This function is the Windows-specific variant. */ void FileStream:: -attach(const char *filename, HANDLE handle, ios::openmode mode) { +attach(const char *filename, HANDLE handle, std::ios::openmode mode) { clear((ios_iostate)0); _buf.attach(filename, handle, mode); if (!_buf.is_open()) { - clear(ios::failbit); + clear(std::ios::failbit); } } #endif // _WIN32 @@ -231,11 +231,11 @@ attach(const char *filename, HANDLE handle, ios::openmode mode) { * This function is the Posix-specific variant. */ void FileStream:: -attach(const char *filename, int fd, ios::openmode mode) { +attach(const char *filename, int fd, std::ios::openmode mode) { clear((ios_iostate)0); _buf.attach(filename, fd, mode); if (!_buf.is_open()) { - clear(ios::failbit); + clear(std::ios::failbit); } } #endif // _WIN32 diff --git a/dtool/src/dtoolutil/pandaFileStream.h b/dtool/src/dtoolutil/pandaFileStream.h index 462e3ce160..4d565f8ac2 100644 --- a/dtool/src/dtoolutil/pandaFileStream.h +++ b/dtool/src/dtoolutil/pandaFileStream.h @@ -26,19 +26,19 @@ * simple-threading implementation (using this interface will block only the * current thread, rather than the entire process, on I/O waits). */ -class EXPCL_DTOOL_DTOOLUTIL IFileStream : public istream { +class EXPCL_DTOOL_DTOOLUTIL IFileStream : public std::istream { PUBLISHED: INLINE IFileStream(); - INLINE explicit IFileStream(const char *filename, ios::openmode mode = ios::in); + INLINE explicit IFileStream(const char *filename, std::ios::openmode mode = std::ios::in); INLINE ~IFileStream(); - INLINE void open(const char *filename, ios::openmode mode = ios::in); + INLINE void open(const char *filename, std::ios::openmode mode = std::ios::in); public: #ifdef _WIN32 - INLINE void attach(const char *filename, HANDLE handle, ios::openmode mode = ios::in); + INLINE void attach(const char *filename, HANDLE handle, std::ios::openmode mode = std::ios::in); #else - INLINE void attach(const char *filename, int fd, ios::openmode mode = ios::in); + INLINE void attach(const char *filename, int fd, std::ios::openmode mode = std::ios::in); #endif PUBLISHED: @@ -54,19 +54,19 @@ private: * simple-threading implementation (using this interface will block only the * current thread, rather than the entire process, on I/O waits). */ -class EXPCL_DTOOL_DTOOLUTIL OFileStream : public ostream { +class EXPCL_DTOOL_DTOOLUTIL OFileStream : public std::ostream { PUBLISHED: INLINE OFileStream(); - INLINE explicit OFileStream(const char *filename, ios::openmode mode = ios::out); + INLINE explicit OFileStream(const char *filename, std::ios::openmode mode = std::ios::out); INLINE ~OFileStream(); - INLINE void open(const char *filename, ios::openmode mode = ios::out); + INLINE void open(const char *filename, std::ios::openmode mode = std::ios::out); public: #ifdef _WIN32 - INLINE void attach(const char *filename, HANDLE handle, ios::openmode mode = ios::out); + INLINE void attach(const char *filename, HANDLE handle, std::ios::openmode mode = std::ios::out); #else - INLINE void attach(const char *filename, int fd, ios::openmode mode = ios::out); + INLINE void attach(const char *filename, int fd, std::ios::openmode mode = std::ios::out); #endif PUBLISHED: @@ -83,19 +83,19 @@ private: * will block only the current thread, rather than the entire process, on I/O * waits). */ -class EXPCL_DTOOL_DTOOLUTIL FileStream : public iostream { +class EXPCL_DTOOL_DTOOLUTIL FileStream : public std::iostream { PUBLISHED: INLINE FileStream(); - INLINE explicit FileStream(const char *filename, ios::openmode mode = ios::in); + INLINE explicit FileStream(const char *filename, std::ios::openmode mode = std::ios::in); INLINE ~FileStream(); - INLINE void open(const char *filename, ios::openmode mode = ios::in); + INLINE void open(const char *filename, std::ios::openmode mode = std::ios::in); public: #ifdef _WIN32 - INLINE void attach(const char *filename, HANDLE handle, ios::openmode mode); + INLINE void attach(const char *filename, HANDLE handle, std::ios::openmode mode); #else - INLINE void attach(const char *filename, int fd, ios::openmode mode); + INLINE void attach(const char *filename, int fd, std::ios::openmode mode); #endif PUBLISHED: diff --git a/dtool/src/dtoolutil/pandaFileStreamBuf.h b/dtool/src/dtoolutil/pandaFileStreamBuf.h index 9ab6f84082..623aec6521 100644 --- a/dtool/src/dtoolutil/pandaFileStreamBuf.h +++ b/dtool/src/dtoolutil/pandaFileStreamBuf.h @@ -28,16 +28,16 @@ /** * The streambuf object that implements pifstream and pofstream. */ -class EXPCL_DTOOL_DTOOLUTIL PandaFileStreamBuf : public streambuf { +class EXPCL_DTOOL_DTOOLUTIL PandaFileStreamBuf : public std::streambuf { public: PandaFileStreamBuf(); virtual ~PandaFileStreamBuf(); - void open(const char *filename, ios::openmode mode); + void open(const char *filename, std::ios::openmode mode); #ifdef _WIN32 - void attach(const char *filename, HANDLE handle, ios::openmode mode); + void attach(const char *filename, HANDLE handle, std::ios::openmode mode); #else - void attach(const char *filename, int fd, ios::openmode mode); + void attach(const char *filename, int fd, std::ios::openmode mode); #endif bool is_open() const; @@ -53,8 +53,8 @@ public: static NewlineMode _newline_mode; protected: - virtual streampos seekoff(streamoff off, ios_seekdir dir, ios_openmode which); - virtual streampos seekpos(streampos pos, ios_openmode which); + virtual std::streampos seekoff(std::streamoff off, ios_seekdir dir, ios_openmode which); + virtual std::streampos seekpos(std::streampos pos, ios_openmode which); virtual int overflow(int c); virtual int sync(); @@ -78,9 +78,9 @@ private: const char *source, size_t source_length); private: - string _filename; + std::string _filename; bool _is_open; - ios::openmode _open_mode; + std::ios::openmode _open_mode; char _last_read_nl; @@ -91,15 +91,15 @@ private: #endif // _WIN32 char *_buffer; - streampos _ppos; - streampos _gpos; + std::streampos _ppos; + std::streampos _gpos; }; -EXPCL_DTOOL_DTOOLUTIL ostream & -operator << (ostream &out, PandaFileStreamBuf::NewlineMode newline_mode); +EXPCL_DTOOL_DTOOLUTIL std::ostream & +operator << (std::ostream &out, PandaFileStreamBuf::NewlineMode newline_mode); -EXPCL_DTOOL_DTOOLUTIL istream & -operator >> (istream &in, PandaFileStreamBuf::NewlineMode &newline_mode); +EXPCL_DTOOL_DTOOLUTIL std::istream & +operator >> (std::istream &in, PandaFileStreamBuf::NewlineMode &newline_mode); #endif // USE_PANDAFILESTREAM diff --git a/dtool/src/dtoolutil/pandaSystem.h b/dtool/src/dtoolutil/pandaSystem.h index c5adae4898..712b61e834 100644 --- a/dtool/src/dtoolutil/pandaSystem.h +++ b/dtool/src/dtoolutil/pandaSystem.h @@ -29,10 +29,10 @@ protected: ~PandaSystem(); PUBLISHED: - static string get_version_string(); - static string get_package_version_string(); - static string get_package_host_url(); - static string get_p3d_coreapi_version_string(); + static std::string get_version_string(); + static std::string get_package_version_string(); + static std::string get_package_host_url(); + static std::string get_p3d_coreapi_version_string(); static int get_major_version(); static int get_minor_version(); @@ -41,12 +41,12 @@ PUBLISHED: static int get_memory_alignment(); - static string get_distributor(); - static string get_compiler(); - static string get_build_date(); - static string get_git_commit(); + static std::string get_distributor(); + static std::string get_compiler(); + static std::string get_build_date(); + static std::string get_git_commit(); - static string get_platform(); + static std::string get_platform(); MAKE_PROPERTY(version_string, get_version_string); MAKE_PROPERTY(major_version, get_major_version); @@ -63,41 +63,41 @@ PUBLISHED: MAKE_PROPERTY(platform, get_platform); - bool has_system(const string &system) const; + bool has_system(const std::string &system) const; size_t get_num_systems() const; - string get_system(size_t n) const; + std::string get_system(size_t n) const; MAKE_SEQ(get_systems, get_num_systems, get_system); MAKE_SEQ_PROPERTY(systems, get_num_systems, get_system); - string get_system_tag(const string &system, const string &tag) const; + std::string get_system_tag(const std::string &system, const std::string &tag) const; - void add_system(const string &system); - void set_system_tag(const string &system, const string &tag, - const string &value); + void add_system(const std::string &system); + void set_system_tag(const std::string &system, const std::string &tag, + const std::string &value); bool heap_trim(size_t pad); - void output(ostream &out) const; - void write(ostream &out) const; + void output(std::ostream &out) const; + void write(std::ostream &out) const; static PandaSystem *get_global_ptr(); private: void reset_system_names(); - void set_package_version_string(const string &package_version_string); - void set_package_host_url(const string &package_host_url); + void set_package_version_string(const std::string &package_version_string); + void set_package_host_url(const std::string &package_host_url); - typedef pmap SystemTags; - typedef pmap Systems; - typedef pvector SystemNames; + typedef pmap SystemTags; + typedef pmap Systems; + typedef pvector SystemNames; Systems _systems; SystemNames _system_names; bool _system_names_dirty; - string _package_version_string; - string _package_host_url; + std::string _package_version_string; + std::string _package_host_url; static PandaSystem *_global_ptr; @@ -115,7 +115,7 @@ private: friend class ConfigPageManager; }; -inline ostream &operator << (ostream &out, const PandaSystem &ps) { +inline std::ostream &operator << (std::ostream &out, const PandaSystem &ps) { ps.output(out); return out; } diff --git a/dtool/src/dtoolutil/pfstream.I b/dtool/src/dtoolutil/pfstream.I index c72a433453..4941f29ca2 100644 --- a/dtool/src/dtoolutil/pfstream.I +++ b/dtool/src/dtoolutil/pfstream.I @@ -12,7 +12,7 @@ */ INLINE IPipeStream::IPipeStream(const std::string cmd) - : istream(&_psb), _psb(PipeStreamBuf::Input) { + : std::istream(&_psb), _psb(PipeStreamBuf::Input) { _psb.command(cmd); } @@ -21,12 +21,12 @@ INLINE void IPipeStream::flush(void) { } INLINE IPipeStream::IPipeStream(void) - : istream(&_psb), _psb(PipeStreamBuf::Input) { - cerr << "should never call default constructor of IPipeStream" << endl; + : std::istream(&_psb), _psb(PipeStreamBuf::Input) { + std::cerr << "should never call default constructor of IPipeStream" << std::endl; } INLINE OPipeStream::OPipeStream(const std::string cmd) - : ostream(&_psb), _psb(PipeStreamBuf::Output) { + : std::ostream(&_psb), _psb(PipeStreamBuf::Output) { _psb.command(cmd); } @@ -35,6 +35,6 @@ INLINE void OPipeStream::flush(void) { } INLINE OPipeStream::OPipeStream(void) - : ostream(&_psb), _psb(PipeStreamBuf::Output) { - cerr << "should never call default constructor of OPipeStream" << endl; + : std::ostream(&_psb), _psb(PipeStreamBuf::Output) { + std::cerr << "should never call default constructor of OPipeStream" << std::endl; } diff --git a/dtool/src/dtoolutil/pfstream.h b/dtool/src/dtoolutil/pfstream.h index 6beccc16ca..e296655337 100644 --- a/dtool/src/dtoolutil/pfstream.h +++ b/dtool/src/dtoolutil/pfstream.h @@ -16,7 +16,7 @@ #include "pfstreamBuf.h" -class EXPCL_DTOOL_DTOOLUTIL IPipeStream : public istream { +class EXPCL_DTOOL_DTOOLUTIL IPipeStream : public std::istream { public: INLINE IPipeStream(const std::string); @@ -32,7 +32,7 @@ private: INLINE IPipeStream(); }; -class EXPCL_DTOOL_DTOOLUTIL OPipeStream : public ostream { +class EXPCL_DTOOL_DTOOLUTIL OPipeStream : public std::ostream { public: INLINE OPipeStream(const std::string); diff --git a/dtool/src/dtoolutil/pfstreamBuf.h b/dtool/src/dtoolutil/pfstreamBuf.h index ad0c132f0f..50875b2179 100644 --- a/dtool/src/dtoolutil/pfstreamBuf.h +++ b/dtool/src/dtoolutil/pfstreamBuf.h @@ -41,7 +41,7 @@ #endif // WIN_PIPE_CALLS -class EXPCL_DTOOL_DTOOLUTIL PipeStreamBuf : public streambuf { +class EXPCL_DTOOL_DTOOLUTIL PipeStreamBuf : public std::streambuf { public: enum Direction { Input, Output }; @@ -49,7 +49,7 @@ public: virtual ~PipeStreamBuf(void); void flush(); - void command(const string); + void command(const std::string); protected: virtual int overflow(int c); @@ -59,13 +59,13 @@ private: void init_pipe(); bool is_open() const; bool eof_pipe() const; - bool open_pipe(const string &cmd); + bool open_pipe(const std::string &cmd); void close_pipe(); size_t write_pipe(const char *data, size_t len); size_t read_pipe(char *data, size_t len); Direction _dir; - string _line_buffer; + std::string _line_buffer; #ifndef WIN_PIPE_CALLS FILE *_pipe; diff --git a/dtool/src/dtoolutil/stringDecoder.I b/dtool/src/dtoolutil/stringDecoder.I index 8ac51f52c6..f7a3b14701 100644 --- a/dtool/src/dtoolutil/stringDecoder.I +++ b/dtool/src/dtoolutil/stringDecoder.I @@ -15,7 +15,7 @@ * */ INLINE StringDecoder:: -StringDecoder(const string &input) : _input(input) { +StringDecoder(const std::string &input) : _input(input) { _p = 0; _eof = false; } @@ -46,12 +46,12 @@ test_eof() { * */ INLINE StringUtf8Decoder:: -StringUtf8Decoder(const string &input) : StringDecoder(input) { +StringUtf8Decoder(const std::string &input) : StringDecoder(input) { } /** * */ INLINE StringUnicodeDecoder:: -StringUnicodeDecoder(const string &input) : StringDecoder(input) { +StringUnicodeDecoder(const std::string &input) : StringDecoder(input) { } diff --git a/dtool/src/dtoolutil/stringDecoder.h b/dtool/src/dtoolutil/stringDecoder.h index 62c97cbe9e..c0b2534ee2 100644 --- a/dtool/src/dtoolutil/stringDecoder.h +++ b/dtool/src/dtoolutil/stringDecoder.h @@ -23,22 +23,22 @@ */ class EXPCL_DTOOL_DTOOLUTIL StringDecoder { public: - INLINE StringDecoder(const string &input); + INLINE StringDecoder(const std::string &input); virtual ~StringDecoder(); virtual int get_next_character(); INLINE bool is_eof(); - static void set_notify_ptr(ostream *ptr); - static ostream *get_notify_ptr(); + static void set_notify_ptr(std::ostream *ptr); + static std::ostream *get_notify_ptr(); protected: INLINE bool test_eof(); - string _input; + std::string _input; size_t _p; bool _eof; - static ostream *_notify_ptr; + static std::ostream *_notify_ptr; }; /** @@ -46,7 +46,7 @@ protected: */ class StringUtf8Decoder : public StringDecoder { public: - INLINE StringUtf8Decoder(const string &input); + INLINE StringUtf8Decoder(const std::string &input); virtual int get_next_character(); }; @@ -57,7 +57,7 @@ public: */ class StringUnicodeDecoder : public StringDecoder { public: - INLINE StringUnicodeDecoder(const string &input); + INLINE StringUnicodeDecoder(const std::string &input); virtual int get_next_character(); }; diff --git a/dtool/src/dtoolutil/string_utils.I b/dtool/src/dtoolutil/string_utils.I index f7878c3ba8..1861e86ffa 100644 --- a/dtool/src/dtoolutil/string_utils.I +++ b/dtool/src/dtoolutil/string_utils.I @@ -12,38 +12,38 @@ */ template -INLINE string +INLINE std::string format_string(const Thing &thing) { - ostringstream str; + std::ostringstream str; str << thing; return str.str(); } -INLINE string -format_string(const string &value) { +INLINE std::string +format_string(const std::string &value) { return value; } -INLINE string +INLINE std::string format_string(bool value) { - return string(value ? "true" : "false"); + return std::string(value ? "true" : "false"); } -INLINE string +INLINE std::string format_string(float value) { char buffer[32]; pdtoa((double)value, buffer); - return string(buffer); + return std::string(buffer); } -INLINE string +INLINE std::string format_string(double value) { char buffer[32]; pdtoa(value, buffer); - return string(buffer); + return std::string(buffer); } -INLINE string +INLINE std::string format_string(unsigned int value) { char buffer[11]; char *p = buffer + 10; @@ -53,10 +53,10 @@ format_string(unsigned int value) { value /= 10; } while (value > 0); - return string(p); + return std::string(p); } -INLINE string +INLINE std::string format_string(int value) { char buffer[12]; char *p = buffer + 11; @@ -76,10 +76,10 @@ format_string(int value) { } while (value > 0); } - return string(p); + return std::string(p); } -INLINE string +INLINE std::string format_string(int64_t value) { char buffer[21]; char *p = buffer + 20; @@ -99,5 +99,5 @@ format_string(int64_t value) { } while (value > 0); } - return string(p); + return std::string(p); } diff --git a/dtool/src/dtoolutil/string_utils.h b/dtool/src/dtoolutil/string_utils.h index 37f7679efe..01f7616fa9 100644 --- a/dtool/src/dtoolutil/string_utils.h +++ b/dtool/src/dtoolutil/string_utils.h @@ -22,58 +22,58 @@ // Case-insensitive string comparison, from Stroustrup's C++ third edition. // Works like strcmp(). -EXPCL_DTOOL_DTOOLUTIL int cmp_nocase(const string &s, const string &s2); +EXPCL_DTOOL_DTOOLUTIL int cmp_nocase(const std::string &s, const std::string &s2); // Similar, except it also accepts hyphen and underscore as equivalent. -EXPCL_DTOOL_DTOOLUTIL int cmp_nocase_uh(const string &s, const string &s2); +EXPCL_DTOOL_DTOOLUTIL int cmp_nocase_uh(const std::string &s, const std::string &s2); // Returns the string converted to lowercase. -EXPCL_DTOOL_DTOOLUTIL string downcase(const string &s); +EXPCL_DTOOL_DTOOLUTIL std::string downcase(const std::string &s); // Returns the string converted to uppercase. -EXPCL_DTOOL_DTOOLUTIL string upcase(const string &s); +EXPCL_DTOOL_DTOOLUTIL std::string upcase(const std::string &s); // Separates the string into words according to whitespace. -EXPCL_DTOOL_DTOOLUTIL int extract_words(const string &str, vector_string &words); -EXPCL_DTOOL_DTOOLUTIL int extract_words(const wstring &str, pvector &words); +EXPCL_DTOOL_DTOOLUTIL int extract_words(const std::string &str, vector_string &words); +EXPCL_DTOOL_DTOOLUTIL int extract_words(const std::wstring &str, pvector &words); // Separates the string into words according to the indicated delimiters. -EXPCL_DTOOL_DTOOLUTIL void tokenize(const string &str, vector_string &words, - const string &delimiters, +EXPCL_DTOOL_DTOOLUTIL void tokenize(const std::string &str, vector_string &words, + const std::string &delimiters, bool discard_repeated_delimiters = false); -EXPCL_DTOOL_DTOOLUTIL void tokenize(const wstring &str, pvector &words, - const wstring &delimiters, +EXPCL_DTOOL_DTOOLUTIL void tokenize(const std::wstring &str, pvector &words, + const std::wstring &delimiters, bool discard_repeated_delimiters = false); // Trims leading andor trailing whitespace from the string. -EXPCL_DTOOL_DTOOLUTIL string trim_left(const string &str); -EXPCL_DTOOL_DTOOLUTIL wstring trim_left(const wstring &str); -EXPCL_DTOOL_DTOOLUTIL string trim_right(const string &str); -EXPCL_DTOOL_DTOOLUTIL wstring trim_right(const wstring &str); -EXPCL_DTOOL_DTOOLUTIL string trim(const string &str); -EXPCL_DTOOL_DTOOLUTIL wstring trim(const wstring &str); +EXPCL_DTOOL_DTOOLUTIL std::string trim_left(const std::string &str); +EXPCL_DTOOL_DTOOLUTIL std::wstring trim_left(const std::wstring &str); +EXPCL_DTOOL_DTOOLUTIL std::string trim_right(const std::string &str); +EXPCL_DTOOL_DTOOLUTIL std::wstring trim_right(const std::wstring &str); +EXPCL_DTOOL_DTOOLUTIL std::string trim(const std::string &str); +EXPCL_DTOOL_DTOOLUTIL std::wstring trim(const std::wstring &str); // Functions to parse numeric values out of a string. -EXPCL_DTOOL_DTOOLUTIL int string_to_int(const string &str, string &tail); -EXPCL_DTOOL_DTOOLUTIL bool string_to_int(const string &str, int &result); -EXPCL_DTOOL_DTOOLUTIL double string_to_double(const string &str, string &tail); -EXPCL_DTOOL_DTOOLUTIL bool string_to_double(const string &str, double &result); -EXPCL_DTOOL_DTOOLUTIL bool string_to_float(const string &str, float &result); -EXPCL_DTOOL_DTOOLUTIL bool string_to_stdfloat(const string &str, PN_stdfloat &result); +EXPCL_DTOOL_DTOOLUTIL int string_to_int(const std::string &str, std::string &tail); +EXPCL_DTOOL_DTOOLUTIL bool string_to_int(const std::string &str, int &result); +EXPCL_DTOOL_DTOOLUTIL double string_to_double(const std::string &str, std::string &tail); +EXPCL_DTOOL_DTOOLUTIL bool string_to_double(const std::string &str, double &result); +EXPCL_DTOOL_DTOOLUTIL bool string_to_float(const std::string &str, float &result); +EXPCL_DTOOL_DTOOLUTIL bool string_to_stdfloat(const std::string &str, PN_stdfloat &result); // Convenience function to make a string from anything that has an ostream // operator. template -INLINE string format_string(const Thing &thing); +INLINE std::string format_string(const Thing &thing); // Fast specializations for some primitive types. -INLINE string format_string(const string &value); -INLINE string format_string(bool value); -INLINE string format_string(float value); -INLINE string format_string(double value); -INLINE string format_string(unsigned int value); -INLINE string format_string(int value); -INLINE string format_string(int64_t value); +INLINE std::string format_string(const std::string &value); +INLINE std::string format_string(bool value); +INLINE std::string format_string(float value); +INLINE std::string format_string(double value); +INLINE std::string format_string(unsigned int value); +INLINE std::string format_string(int value); +INLINE std::string format_string(int64_t value); #include "string_utils.I" diff --git a/dtool/src/dtoolutil/textEncoder.I b/dtool/src/dtoolutil/textEncoder.I index c46c03c0de..e07f489ab0 100644 --- a/dtool/src/dtoolutil/textEncoder.I +++ b/dtool/src/dtoolutil/textEncoder.I @@ -86,7 +86,7 @@ get_default_encoding() { * decoded version of the string. */ INLINE void TextEncoder:: -set_text(const string &text) { +set_text(const std::string &text) { if (!has_text() || _text != text) { _text = text; _flags = (_flags | F_got_text) & ~F_got_wtext; @@ -100,7 +100,7 @@ set_text(const string &text) { * whichever encoding is specified by set_encoding(). */ INLINE void TextEncoder:: -set_text(const string &text, TextEncoder::Encoding encoding) { +set_text(const std::string &text, TextEncoder::Encoding encoding) { set_wtext(decode_text(text, encoding)); } @@ -109,8 +109,8 @@ set_text(const string &text, TextEncoder::Encoding encoding) { */ INLINE void TextEncoder:: clear_text() { - _text = string(); - _wtext = wstring(); + _text = std::string(); + _wtext = std::wstring(); _flags |= (F_got_text | F_got_wtext); } @@ -129,7 +129,7 @@ has_text() const { /** * Returns the current text, as encoded via the current encoding system. */ -INLINE string TextEncoder:: +INLINE std::string TextEncoder:: get_text() const { if ((_flags & F_got_text) == 0) { ((TextEncoder *)this)->_text = encode_wtext(_wtext); @@ -141,7 +141,7 @@ get_text() const { /** * Returns the current text, as encoded via the indicated encoding system. */ -INLINE string TextEncoder:: +INLINE std::string TextEncoder:: get_text(TextEncoder::Encoding encoding) const { return encode_wtext(get_wtext(), encoding); } @@ -150,7 +150,7 @@ get_text(TextEncoder::Encoding encoding) const { * Appends the indicates string to the end of the stored text. */ INLINE void TextEncoder:: -append_text(const string &text) { +append_text(const std::string &text) { _text = get_text() + text; _flags = (_flags | F_got_text) & ~F_got_wtext; } @@ -161,7 +161,7 @@ append_text(const string &text) { */ INLINE void TextEncoder:: append_unicode_char(int character) { - _wtext = get_wtext() + wstring(1, (wchar_t)character); + _wtext = get_wtext() + std::wstring(1, (wchar_t)character); _flags = (_flags | F_got_wtext) & ~F_got_text; } @@ -207,7 +207,7 @@ set_unicode_char(size_t index, int character) { * Returns the nth char of the stored text, as a one-, two-, or three-byte * encoded string. */ -INLINE string TextEncoder:: +INLINE std::string TextEncoder:: get_encoded_char(size_t index) const { return get_encoded_char(index, get_encoding()); } @@ -216,9 +216,9 @@ get_encoded_char(size_t index) const { * Returns the nth char of the stored text, as a one-, two-, or three-byte * encoded string. */ -INLINE string TextEncoder:: +INLINE std::string TextEncoder:: get_encoded_char(size_t index, TextEncoder::Encoding encoding) const { - wstring wch(1, (wchar_t)get_unicode_char(index)); + std::wstring wch(1, (wchar_t)get_unicode_char(index)); return encode_wtext(wch, encoding); } @@ -235,7 +235,7 @@ get_encoded_char(size_t index, TextEncoder::Encoding encoding) const { * will be converted to ASCII, and the nonconvertible characters will remain * encoded in the encoding specified by set_encoding(). */ -INLINE string TextEncoder:: +INLINE std::string TextEncoder:: get_text_as_ascii() const { return encode_wtext(get_wtext_as_ascii()); } @@ -246,8 +246,8 @@ get_text_as_ascii() const { * and returns the newly encoded string. This does not change or affect any * properties on the TextEncoder itself. */ -INLINE string TextEncoder:: -reencode_text(const string &text, TextEncoder::Encoding from, +INLINE std::string TextEncoder:: +reencode_text(const std::string &text, TextEncoder::Encoding from, TextEncoder::Encoding to) { return encode_wtext(decode_text(text, from), to); } @@ -368,8 +368,8 @@ unicode_tolower(int character) { * Converts the string to uppercase, assuming the string is encoded in the * default encoding. */ -INLINE string TextEncoder:: -upper(const string &source) { +INLINE std::string TextEncoder:: +upper(const std::string &source) { return upper(source, get_default_encoding()); } @@ -377,8 +377,8 @@ upper(const string &source) { * Converts the string to uppercase, assuming the string is encoded in the * indicated encoding. */ -INLINE string TextEncoder:: -upper(const string &source, TextEncoder::Encoding encoding) { +INLINE std::string TextEncoder:: +upper(const std::string &source, TextEncoder::Encoding encoding) { TextEncoder encoder; encoder.set_encoding(encoding); encoder.set_text(source); @@ -390,8 +390,8 @@ upper(const string &source, TextEncoder::Encoding encoding) { * Converts the string to lowercase, assuming the string is encoded in the * default encoding. */ -INLINE string TextEncoder:: -lower(const string &source) { +INLINE std::string TextEncoder:: +lower(const std::string &source) { return lower(source, get_default_encoding()); } @@ -399,8 +399,8 @@ lower(const string &source) { * Converts the string to lowercase, assuming the string is encoded in the * indicated encoding. */ -INLINE string TextEncoder:: -lower(const string &source, TextEncoder::Encoding encoding) { +INLINE std::string TextEncoder:: +lower(const std::string &source, TextEncoder::Encoding encoding) { TextEncoder encoder; encoder.set_encoding(encoding); encoder.set_text(source); @@ -414,7 +414,7 @@ lower(const string &source, TextEncoder::Encoding encoding) { * encoded version of the string. */ INLINE void TextEncoder:: -set_wtext(const wstring &wtext) { +set_wtext(const std::wstring &wtext) { if (!has_text() || _wtext != wtext) { _wtext = wtext; _flags = (_flags | F_got_wtext) & ~F_got_text; @@ -425,7 +425,7 @@ set_wtext(const wstring &wtext) { * Returns the text associated with the TextEncoder, as a wide-character * string. */ -INLINE const wstring &TextEncoder:: +INLINE const std::wstring &TextEncoder:: get_wtext() const { if ((_flags & F_got_wtext) == 0) { ((TextEncoder *)this)->_wtext = decode_text(_text); @@ -438,7 +438,7 @@ get_wtext() const { * Appends the indicates string to the end of the stored wide-character text. */ INLINE void TextEncoder:: -append_wtext(const wstring &wtext) { +append_wtext(const std::wstring &wtext) { _wtext = get_wtext() + wtext; _flags = (_flags | F_got_wtext) & ~F_got_text; } @@ -447,8 +447,8 @@ append_wtext(const wstring &wtext) { * Encodes a wide-text string into a single-char string, according to the * current encoding. */ -INLINE string TextEncoder:: -encode_wtext(const wstring &wtext) const { +INLINE std::string TextEncoder:: +encode_wtext(const std::wstring &wtext) const { return encode_wtext(wtext, _encoding); } @@ -456,16 +456,16 @@ encode_wtext(const wstring &wtext) const { * Returns the given wstring decoded to a single-byte string, via the current * encoding system. */ -INLINE wstring TextEncoder:: -decode_text(const string &text) const { +INLINE std::wstring TextEncoder:: +decode_text(const std::string &text) const { return decode_text(text, _encoding); } /** * Uses the current default encoding to output the wstring. */ -INLINE ostream & -operator << (ostream &out, const wstring &str) { +INLINE std::ostream & +operator << (std::ostream &out, const std::wstring &str) { TextEncoder encoder; encoder.set_wtext(str); out << encoder.get_text(); diff --git a/dtool/src/dtoolutil/textEncoder.h b/dtool/src/dtoolutil/textEncoder.h index 3f57ed4c7f..a7eaf395ff 100644 --- a/dtool/src/dtoolutil/textEncoder.h +++ b/dtool/src/dtoolutil/textEncoder.h @@ -48,26 +48,26 @@ PUBLISHED: INLINE static Encoding get_default_encoding(); MAKE_PROPERTY(default_encoding, get_default_encoding, set_default_encoding); - INLINE void set_text(const string &text); - INLINE void set_text(const string &text, Encoding encoding); + INLINE void set_text(const std::string &text); + INLINE void set_text(const std::string &text, Encoding encoding); INLINE void clear_text(); INLINE bool has_text() const; void make_upper(); void make_lower(); - INLINE string get_text() const; - INLINE string get_text(Encoding encoding) const; - INLINE void append_text(const string &text); + INLINE std::string get_text() const; + INLINE std::string get_text(Encoding encoding) const; + INLINE void append_text(const std::string &text); INLINE void append_unicode_char(int character); INLINE size_t get_num_chars() const; INLINE int get_unicode_char(size_t index) const; INLINE void set_unicode_char(size_t index, int character); - INLINE string get_encoded_char(size_t index) const; - INLINE string get_encoded_char(size_t index, Encoding encoding) const; - INLINE string get_text_as_ascii() const; + INLINE std::string get_encoded_char(size_t index) const; + INLINE std::string get_encoded_char(size_t index, Encoding encoding) const; + INLINE std::string get_text_as_ascii() const; - INLINE static string reencode_text(const string &text, Encoding from, Encoding to); + INLINE static std::string reencode_text(const std::string &text, Encoding from, Encoding to); INLINE static bool unicode_isalpha(int character); INLINE static bool unicode_isdigit(int character); @@ -78,52 +78,52 @@ PUBLISHED: INLINE static int unicode_toupper(int character); INLINE static int unicode_tolower(int character); - INLINE static string upper(const string &source); - INLINE static string upper(const string &source, Encoding encoding); - INLINE static string lower(const string &source); - INLINE static string lower(const string &source, Encoding encoding); + INLINE static std::string upper(const std::string &source); + INLINE static std::string upper(const std::string &source, Encoding encoding); + INLINE static std::string lower(const std::string &source); + INLINE static std::string lower(const std::string &source, Encoding encoding); // Direct support for wide-character strings. Now publishable with the new // wstring support in interrogate. - INLINE void set_wtext(const wstring &wtext); - INLINE const wstring &get_wtext() const; - INLINE void append_wtext(const wstring &text); - wstring get_wtext_as_ascii() const; + INLINE void set_wtext(const std::wstring &wtext); + INLINE const std::wstring &get_wtext() const; + INLINE void append_wtext(const std::wstring &text); + std::wstring get_wtext_as_ascii() const; bool is_wtext() const; - static string encode_wchar(wchar_t ch, Encoding encoding); - INLINE string encode_wtext(const wstring &wtext) const; - static string encode_wtext(const wstring &wtext, Encoding encoding); - INLINE wstring decode_text(const string &text) const; - static wstring decode_text(const string &text, Encoding encoding); + static std::string encode_wchar(wchar_t ch, Encoding encoding); + INLINE std::string encode_wtext(const std::wstring &wtext) const; + static std::string encode_wtext(const std::wstring &wtext, Encoding encoding); + INLINE std::wstring decode_text(const std::string &text) const; + static std::wstring decode_text(const std::string &text, Encoding encoding); private: enum Flags { F_got_text = 0x0001, F_got_wtext = 0x0002, }; - static wstring decode_text_impl(StringDecoder &decoder); + static std::wstring decode_text_impl(StringDecoder &decoder); int _flags; Encoding _encoding; - string _text; - wstring _wtext; + std::string _text; + std::wstring _wtext; static Encoding _default_encoding; }; -EXPCL_DTOOL_DTOOLUTIL ostream & -operator << (ostream &out, TextEncoder::Encoding encoding); -EXPCL_DTOOL_DTOOLUTIL istream & -operator >> (istream &in, TextEncoder::Encoding &encoding); +EXPCL_DTOOL_DTOOLUTIL std::ostream & +operator << (std::ostream &out, TextEncoder::Encoding encoding); +EXPCL_DTOOL_DTOOLUTIL std::istream & +operator >> (std::istream &in, TextEncoder::Encoding &encoding); // We'll define the output operator for wstring here, too. Presumably this // will not be automatically defined by any system libraries. // This function is declared inline to minimize the risk of link conflicts // should another third-party module also define the same output operator. -INLINE EXPCL_DTOOL_DTOOLUTIL ostream & -operator << (ostream &out, const wstring &str); +INLINE EXPCL_DTOOL_DTOOLUTIL std::ostream & +operator << (std::ostream &out, const std::wstring &str); #include "textEncoder.I" diff --git a/dtool/src/dtoolutil/win32ArgParser.h b/dtool/src/dtoolutil/win32ArgParser.h index b7d427a81f..b4cfdecbf9 100644 --- a/dtool/src/dtoolutil/win32ArgParser.h +++ b/dtool/src/dtoolutil/win32ArgParser.h @@ -37,8 +37,8 @@ public: void clear(); - void set_command_line(const string &command_line); - void set_command_line(const wstring &command_line); + void set_command_line(const std::string &command_line); + void set_command_line(const std::wstring &command_line); void set_system_command_line(); char **get_argv(); @@ -47,9 +47,9 @@ public: static bool do_glob(); private: - string parse_quoted_arg(const char *&p); + std::string parse_quoted_arg(const char *&p); void parse_unquoted_arg(const char *&p); - void save_arg(const string &arg); + void save_arg(const std::string &arg); typedef vector_string Args; Args _args; diff --git a/dtool/src/interrogate/functionRemap.h b/dtool/src/interrogate/functionRemap.h index 7c12f65c3d..61ce48bcb6 100644 --- a/dtool/src/interrogate/functionRemap.h +++ b/dtool/src/interrogate/functionRemap.h @@ -48,19 +48,19 @@ public: InterfaceMaker *interface_maker); ~FunctionRemap(); - string get_parameter_name(int n) const; - string call_function(ostream &out, int indent_level, - bool convert_result, const string &container) const; - string call_function(ostream &out, int indent_level, - bool convert_result, const string &container, + std::string get_parameter_name(int n) const; + std::string call_function(std::ostream &out, int indent_level, + bool convert_result, const std::string &container) const; + std::string call_function(std::ostream &out, int indent_level, + bool convert_result, const std::string &container, const vector_string &pexprs) const; - void write_orig_prototype(ostream &out, int indent_level, bool local=false, + void write_orig_prototype(std::ostream &out, int indent_level, bool local=false, int num_default_args=0) const; FunctionWrapperIndex make_wrapper_entry(FunctionIndex function_index); - string get_call_str(const string &container, const vector_string &pexprs) const; + std::string get_call_str(const std::string &container, const vector_string &pexprs) const; int get_min_num_args() const; int get_max_num_args() const; @@ -68,7 +68,7 @@ public: class Parameter { public: bool _has_name; - string _name; + std::string _name; ParameterRemap *_remap; }; @@ -118,12 +118,12 @@ public: Type _type; int _flags; int _args_type; - string _expression; - string _function_signature; - string _hash; - string _unique_name; - string _reported_name; - string _wrapper_name; + std::string _expression; + std::string _function_signature; + std::string _hash; + std::string _unique_name; + std::string _reported_name; + std::string _wrapper_name; FunctionWrapperIndex _wrapper_index; bool _return_value_needs_management; @@ -138,7 +138,7 @@ public: bool _is_valid; private: - string get_parameter_expr(size_t n, const vector_string &pexprs) const; + std::string get_parameter_expr(size_t n, const vector_string &pexprs) const; bool setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_maker); }; diff --git a/dtool/src/interrogate/functionWriter.h b/dtool/src/interrogate/functionWriter.h index 11d4c90252..da2930ae0e 100644 --- a/dtool/src/interrogate/functionWriter.h +++ b/dtool/src/interrogate/functionWriter.h @@ -26,14 +26,14 @@ public: FunctionWriter(); virtual ~FunctionWriter(); - const string &get_name() const; + const std::string &get_name() const; virtual int compare_to(const FunctionWriter &other) const; - virtual void write_prototype(ostream &out); - virtual void write_code(ostream &out); + virtual void write_prototype(std::ostream &out); + virtual void write_code(std::ostream &out); protected: - string _name; + std::string _name; }; #endif diff --git a/dtool/src/interrogate/functionWriterPtrFromPython.h b/dtool/src/interrogate/functionWriterPtrFromPython.h index 36f59fa955..ca74f1dfdc 100644 --- a/dtool/src/interrogate/functionWriterPtrFromPython.h +++ b/dtool/src/interrogate/functionWriterPtrFromPython.h @@ -28,8 +28,8 @@ public: FunctionWriterPtrFromPython(CPPType *type); virtual ~FunctionWriterPtrFromPython(); - virtual void write_prototype(ostream &out); - virtual void write_code(ostream &out); + virtual void write_prototype(std::ostream &out); + virtual void write_code(std::ostream &out); CPPType *get_type() const; CPPType *get_pointer_type() const; diff --git a/dtool/src/interrogate/functionWriterPtrToPython.h b/dtool/src/interrogate/functionWriterPtrToPython.h index d36e025da1..f563d4fccb 100644 --- a/dtool/src/interrogate/functionWriterPtrToPython.h +++ b/dtool/src/interrogate/functionWriterPtrToPython.h @@ -27,8 +27,8 @@ public: FunctionWriterPtrToPython(CPPType *type); virtual ~FunctionWriterPtrToPython(); - virtual void write_prototype(ostream &out); - virtual void write_code(ostream &out); + virtual void write_prototype(std::ostream &out); + virtual void write_code(std::ostream &out); CPPType *get_pointer_type() const; private: diff --git a/dtool/src/interrogate/functionWriters.h b/dtool/src/interrogate/functionWriters.h index 41943c47f7..2da07ecd9c 100644 --- a/dtool/src/interrogate/functionWriters.h +++ b/dtool/src/interrogate/functionWriters.h @@ -31,8 +31,8 @@ public: FunctionWriter *add_writer(FunctionWriter *writer); - void write_prototypes(ostream &out); - void write_code(ostream &out); + void write_prototypes(std::ostream &out); + void write_code(std::ostream &out); protected: class IndirectCompareTo { diff --git a/dtool/src/interrogate/interfaceMaker.h b/dtool/src/interrogate/interfaceMaker.h index 620f42d275..e439105ea1 100644 --- a/dtool/src/interrogate/interfaceMaker.h +++ b/dtool/src/interrogate/interfaceMaker.h @@ -51,12 +51,12 @@ public: virtual void generate_wrappers(); - virtual void write_includes(ostream &out); - virtual void write_prototypes(ostream &out, ostream *out_h); - virtual void write_functions(ostream &out); - virtual void write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) {}; + virtual void write_includes(std::ostream &out); + virtual void write_prototypes(std::ostream &out, std::ostream *out_h); + virtual void write_functions(std::ostream &out); + virtual void write_module_support(std::ostream &out, std::ostream *out_h, InterrogateModuleDef *def) {}; - virtual void write_module(ostream &out, ostream *out_h, InterrogateModuleDef *def); + virtual void write_module(std::ostream &out, std::ostream *out_h, InterrogateModuleDef *def); virtual ParameterRemap *remap_parameter(CPPType *struct_type, CPPType *param_type); @@ -66,7 +66,7 @@ public: void get_function_remaps(std::vector &remaps); - static ostream &indent(ostream &out, int indent_level); + static std::ostream &indent(std::ostream &out, int indent_level); public: // This contains information about the number of arguments that the wrapping @@ -92,12 +92,12 @@ public: class Function { public: - Function(const string &name, + Function(const std::string &name, const InterrogateType &itype, const InterrogateFunction &ifunc); ~Function(); - string _name; + std::string _name; const InterrogateType &_itype; const InterrogateFunction &_ifunc; typedef std::vector Remaps; @@ -112,10 +112,10 @@ public: class MakeSeq { public: - MakeSeq(const string &name, const InterrogateMakeSeq &imake_seq); + MakeSeq(const std::string &name, const InterrogateMakeSeq &imake_seq); const InterrogateMakeSeq &_imake_seq; - string _name; + std::string _name; Function *_length_getter; Function *_element_getter; }; @@ -144,7 +144,7 @@ public: ~Object(); void check_protocols(); - bool is_static_method(const string &name); + bool is_static_method(const std::string &name); const InterrogateType &_itype; Functions _constructors; @@ -165,7 +165,7 @@ public: typedef std::map Objects; Objects _objects; - typedef std::map WrappersByHash; + typedef std::map WrappersByHash; WrappersByHash _wrappers_by_hash; virtual FunctionRemap * @@ -173,12 +173,12 @@ public: const InterrogateFunction &ifunc, CPPInstance *cppfunc, int num_default_parameters); - virtual string + virtual std::string get_wrapper_name(const InterrogateType &itype, const InterrogateFunction &ifunc, FunctionIndex func_index); - virtual string get_wrapper_prefix(); - virtual string get_unique_prefix(); + virtual std::string get_wrapper_prefix(); + virtual std::string get_unique_prefix(); Function * record_function(const InterrogateType &itype, FunctionIndex func_index); @@ -192,19 +192,19 @@ public: void hash_function_signature(FunctionRemap *remap); - string - manage_return_value(ostream &out, int indent_level, - FunctionRemap *remap, const string &return_expr) const; + std::string + manage_return_value(std::ostream &out, int indent_level, + FunctionRemap *remap, const std::string &return_expr) const; void - delete_return_value(ostream &out, int indent_level, - FunctionRemap *remap, const string &return_expr) const; + delete_return_value(std::ostream &out, int indent_level, + FunctionRemap *remap, const std::string &return_expr) const; - void output_ref(ostream &out, int indent_level, FunctionRemap *remap, - const string &varname) const; - void output_unref(ostream &out, int indent_level, FunctionRemap *remap, - const string &varname) const; - void write_spam_message(ostream &out, FunctionRemap *remap) const; + void output_ref(std::ostream &out, int indent_level, FunctionRemap *remap, + const std::string &varname) const; + void output_unref(std::ostream &out, int indent_level, FunctionRemap *remap, + const std::string &varname) const; + void write_spam_message(std::ostream &out, FunctionRemap *remap) const; protected: InterrogateModuleDef *_def; diff --git a/dtool/src/interrogate/interfaceMakerC.h b/dtool/src/interrogate/interfaceMakerC.h index 5eaf276815..91c8ef68bf 100644 --- a/dtool/src/interrogate/interfaceMakerC.h +++ b/dtool/src/interrogate/interfaceMakerC.h @@ -30,27 +30,27 @@ public: InterfaceMakerC(InterrogateModuleDef *def); virtual ~InterfaceMakerC(); - virtual void write_prototypes(ostream &out,ostream *out_h); - virtual void write_functions(ostream &out); + virtual void write_prototypes(std::ostream &out,std::ostream *out_h); + virtual void write_functions(std::ostream &out); virtual ParameterRemap *remap_parameter(CPPType *struct_type, CPPType *param_type); virtual bool synthesize_this_parameter(); protected: - virtual string get_wrapper_prefix(); - virtual string get_unique_prefix(); + virtual std::string get_wrapper_prefix(); + virtual std::string get_unique_prefix(); virtual void record_function_wrapper(InterrogateFunction &ifunc, FunctionWrapperIndex wrapper_index); private: - void write_prototype_for(ostream &out, Function *func); - void write_function_for(ostream &out, Function *func); - void write_function_instance(ostream &out, Function *func, + void write_prototype_for(std::ostream &out, Function *func); + void write_function_for(std::ostream &out, Function *func); + void write_function_instance(std::ostream &out, Function *func, FunctionRemap *remap); - void write_function_header(ostream &out, Function *func, + void write_function_header(std::ostream &out, Function *func, FunctionRemap *remap, bool newline); }; diff --git a/dtool/src/interrogate/interfaceMakerPython.h b/dtool/src/interrogate/interfaceMakerPython.h index 2d9bb84376..612e9ced17 100644 --- a/dtool/src/interrogate/interfaceMakerPython.h +++ b/dtool/src/interrogate/interfaceMakerPython.h @@ -30,10 +30,10 @@ protected: InterfaceMakerPython(InterrogateModuleDef *def); public: - virtual void write_includes(ostream &out); + virtual void write_includes(std::ostream &out); protected: - virtual void test_assert(ostream &out, int indent_level) const; + virtual void test_assert(std::ostream &out, int indent_level) const; }; #endif diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.h b/dtool/src/interrogate/interfaceMakerPythonNative.h index 72421f307a..00374397c9 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.h +++ b/dtool/src/interrogate/interfaceMakerPythonNative.h @@ -31,17 +31,17 @@ public: virtual ~InterfaceMakerPythonNative(); - virtual void write_prototypes(ostream &out, ostream *out_h); - void write_prototypes_class(ostream &out, ostream *out_h, Object *obj) ; - void write_prototypes_class_external(ostream &out, Object *obj); + virtual void write_prototypes(std::ostream &out, std::ostream *out_h); + void write_prototypes_class(std::ostream &out, std::ostream *out_h, Object *obj) ; + void write_prototypes_class_external(std::ostream &out, Object *obj); - virtual void write_functions(ostream &out); + virtual void write_functions(std::ostream &out); - virtual void write_module(ostream &out, ostream *out_h, InterrogateModuleDef *def); - virtual void write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def); + virtual void write_module(std::ostream &out, std::ostream *out_h, InterrogateModuleDef *def); + virtual void write_module_support(std::ostream &out, std::ostream *out_h, InterrogateModuleDef *def); - void write_module_class(ostream &out, Object *cls); - virtual void write_sub_module(ostream &out, Object *obj); + void write_module_class(std::ostream &out, Object *cls); + virtual void write_sub_module(std::ostream &out, Object *obj); virtual bool synthesize_this_parameter(); virtual bool separate_overloading(); @@ -50,8 +50,8 @@ public: Property *record_property(const InterrogateType &itype, ElementIndex element_index); protected: - virtual string get_wrapper_prefix(); - virtual string get_unique_prefix(); + virtual std::string get_wrapper_prefix(); + virtual std::string get_unique_prefix(); virtual void record_function_wrapper(InterrogateFunction &ifunc, FunctionWrapperIndex wrapper_index); @@ -119,67 +119,67 @@ private: class SlottedFunctionDef { public: - string _answer_location; + std::string _answer_location; WrapperType _wrapper_type; int _min_version; - string _wrapper_name; - set _remaps; + std::string _wrapper_name; + std::set _remaps; bool _keep_method; }; - typedef std::map SlottedFunctions; + typedef std::map SlottedFunctions; static bool get_slotted_function_def(Object *obj, Function *func, FunctionRemap *remap, SlottedFunctionDef &def); - static void write_function_slot(ostream &out, int indent_level, + static void write_function_slot(std::ostream &out, int indent_level, const SlottedFunctions &slots, - const string &slot, const string &def = "nullptr"); + const std::string &slot, const std::string &def = "nullptr"); - void write_prototype_for_name(ostream &out, Function *func, const std::string &name); - void write_prototype_for(ostream &out, Function *func); - void write_function_for_top(ostream &out, Object *obj, Function *func); + void write_prototype_for_name(std::ostream &out, Function *func, const std::string &name); + void write_prototype_for(std::ostream &out, Function *func); + void write_function_for_top(std::ostream &out, Object *obj, Function *func); - void write_function_for_name(ostream &out, Object *obj, + void write_function_for_name(std::ostream &out, Object *obj, const Function::Remaps &remaps, - const std::string &name, string &expected_params, + const std::string &name, std::string &expected_params, bool coercion_allowed, ArgsType args_type, int return_flags); - void write_coerce_constructor(ostream &out, Object *obj, bool is_const); + void write_coerce_constructor(std::ostream &out, Object *obj, bool is_const); int collapse_default_remaps(std::map > &map_sets, int max_required_args); - void write_function_forset(ostream &out, + void write_function_forset(std::ostream &out, const std::set &remaps, int min_num_args, int max_num_args, - string &expected_params, int indent_level, + std::string &expected_params, int indent_level, bool coercion_allowed, bool report_errors, ArgsType args_type, int return_flags, bool check_exceptions = true, bool verify_const = true, - const string &first_expr = string()); + const std::string &first_expr = std::string()); - void write_function_instance(ostream &out, FunctionRemap *remap, + void write_function_instance(std::ostream &out, FunctionRemap *remap, int min_num_args, int max_num_args, - string &expected_params, int indent_level, + std::string &expected_params, int indent_level, bool coercion_allowed, bool report_errors, ArgsType args_type, int return_flags, bool check_exceptions = true, - const string &first_pexpr = string()); + const std::string &first_pexpr = std::string()); - void error_return(ostream &out, int indent_level, int return_flags); - void error_raise_return(ostream &out, int indent_level, int return_flags, - const string &exc_type, const string &message, - const string &format_args = ""); - void pack_return_value(ostream &out, int indent_level, FunctionRemap *remap, + void error_return(std::ostream &out, int indent_level, int return_flags); + void error_raise_return(std::ostream &out, int indent_level, int return_flags, + const std::string &exc_type, const std::string &message, + const std::string &format_args = ""); + void pack_return_value(std::ostream &out, int indent_level, FunctionRemap *remap, std::string return_expr, int return_flags); - void write_make_seq(ostream &out, Object *obj, const std::string &ClassName, + void write_make_seq(std::ostream &out, Object *obj, const std::string &ClassName, const std::string &cClassName, MakeSeq *make_seq); - void write_getset(ostream &out, Object *obj, Property *property); + void write_getset(std::ostream &out, Object *obj, Property *property); - void write_class_prototypes(ostream &out) ; - void write_class_declarations(ostream &out, ostream *out_h, Object *obj); - void write_class_details(ostream &out, Object *obj); + void write_class_prototypes(std::ostream &out) ; + void write_class_declarations(std::ostream &out, std::ostream *out_h, Object *obj); + void write_class_details(std::ostream &out, Object *obj); public: bool is_remap_legal(FunctionRemap *remap); @@ -204,14 +204,14 @@ public: void get_valid_child_classes(std::map &answer, CPPStructType *inclass, const std::string &upcast_seed = "", bool can_downcast = true); bool DoesInheritFromIsClass(const CPPStructType * inclass, const std::string &name); bool IsPandaTypedObject(CPPStructType * inclass) { return DoesInheritFromIsClass(inclass,"TypedObject"); }; - void write_python_instance(ostream &out, int indent_level, const std::string &return_expr, bool owns_memory, const InterrogateType &itype, bool is_const); + void write_python_instance(std::ostream &out, int indent_level, const std::string &return_expr, bool owns_memory, const InterrogateType &itype, bool is_const); bool has_get_class_type_function(CPPType *type); bool has_init_type_function(CPPType *type); int NeedsAStrFunction(const InterrogateType &itype_class); int NeedsAReprFunction(const InterrogateType &itype_class); bool NeedsARichCompareFunction(const InterrogateType &itype_class); - void output_quoted(ostream &out, int indent_level, const std::string &str, + void output_quoted(std::ostream &out, int indent_level, const std::string &str, bool first_line=true); // stash the forward declarations for this compile pass.. diff --git a/dtool/src/interrogate/interfaceMakerPythonObj.h b/dtool/src/interrogate/interfaceMakerPythonObj.h index df2263f8d7..be7e0d9913 100644 --- a/dtool/src/interrogate/interfaceMakerPythonObj.h +++ b/dtool/src/interrogate/interfaceMakerPythonObj.h @@ -37,32 +37,32 @@ public: InterfaceMakerPythonObj(InterrogateModuleDef *def); virtual ~InterfaceMakerPythonObj(); - virtual void write_prototypes(ostream &out,ostream *out_h); - virtual void write_functions(ostream &out); + virtual void write_prototypes(std::ostream &out,std::ostream *out_h); + virtual void write_functions(std::ostream &out); - virtual void write_module(ostream &out,ostream *out_h, InterrogateModuleDef *def); + virtual void write_module(std::ostream &out,std::ostream *out_h, InterrogateModuleDef *def); virtual bool synthesize_this_parameter(); - static string get_builder_name(CPPType *struct_type); + static std::string get_builder_name(CPPType *struct_type); protected: - virtual string get_wrapper_prefix(); + virtual std::string get_wrapper_prefix(); private: - void write_class_wrapper(ostream &out, Object *object); - void write_prototype_for(ostream &out, Function *func); - void write_function_for(ostream &out, Function *func); - void write_function_instance(ostream &out, int indent_level, Function *func, - FunctionRemap *remap, string &expected_params); + void write_class_wrapper(std::ostream &out, Object *object); + void write_prototype_for(std::ostream &out, Function *func); + void write_function_for(std::ostream &out, Function *func); + void write_function_instance(std::ostream &out, int indent_level, Function *func, + FunctionRemap *remap, std::string &expected_params); - void pack_return_value(ostream &out, int indent_level, - FunctionRemap *remap, string return_expr); + void pack_return_value(std::ostream &out, int indent_level, + FunctionRemap *remap, std::string return_expr); FunctionWriterPtrFromPython *get_ptr_from_python(CPPType *type); FunctionWriterPtrToPython *get_ptr_to_python(CPPType *type); - typedef map PtrConverter; + typedef std::map PtrConverter; PtrConverter _from_python; PtrConverter _to_python; }; diff --git a/dtool/src/interrogate/interfaceMakerPythonSimple.h b/dtool/src/interrogate/interfaceMakerPythonSimple.h index 0b17df3688..18cfc4d590 100644 --- a/dtool/src/interrogate/interfaceMakerPythonSimple.h +++ b/dtool/src/interrogate/interfaceMakerPythonSimple.h @@ -35,29 +35,29 @@ public: InterfaceMakerPythonSimple(InterrogateModuleDef *def); virtual ~InterfaceMakerPythonSimple(); - virtual void write_prototypes(ostream &out,ostream *out_h); - virtual void write_functions(ostream &out); + virtual void write_prototypes(std::ostream &out,std::ostream *out_h); + virtual void write_functions(std::ostream &out); - virtual void write_module(ostream &out,ostream *out_h, InterrogateModuleDef *def); + virtual void write_module(std::ostream &out,std::ostream *out_h, InterrogateModuleDef *def); virtual bool synthesize_this_parameter(); protected: - virtual string get_wrapper_prefix(); - virtual string get_unique_prefix(); + virtual std::string get_wrapper_prefix(); + virtual std::string get_unique_prefix(); virtual void record_function_wrapper(InterrogateFunction &ifunc, FunctionWrapperIndex wrapper_index); private: - void write_prototype_for(ostream &out, Function *func); - void write_function_for(ostream &out, Function *func); - void write_function_instance(ostream &out, Function *func, + void write_prototype_for(std::ostream &out, Function *func); + void write_function_for(std::ostream &out, Function *func); + void write_function_instance(std::ostream &out, Function *func, FunctionRemap *remap); - void pack_return_value(ostream &out, int indent_level, - FunctionRemap *remap, string return_expr); + void pack_return_value(std::ostream &out, int indent_level, + FunctionRemap *remap, std::string return_expr); }; #endif diff --git a/dtool/src/interrogate/interrogate.h b/dtool/src/interrogate/interrogate.h index 80b55c4e8f..a40a1ed26e 100644 --- a/dtool/src/interrogate/interrogate.h +++ b/dtool/src/interrogate/interrogate.h @@ -25,7 +25,7 @@ extern CPPParser parser; // A few global variables that control the interrogate process. extern Filename output_code_filename; extern Filename output_data_filename; -extern string output_data_basename; +extern std::string output_data_basename; extern bool output_module_specific; extern bool output_function_pointers; extern bool output_function_names; @@ -44,7 +44,7 @@ extern bool generate_spam; extern bool left_inheritance_requires_upcast; extern bool mangle_names; extern CPPVisibility min_vis; -extern string library_name; -extern string module_name; +extern std::string library_name; +extern std::string module_name; #endif diff --git a/dtool/src/interrogate/interrogateBuilder.h b/dtool/src/interrogate/interrogateBuilder.h index 68bcb4b131..1b182d3f56 100644 --- a/dtool/src/interrogate/interrogateBuilder.h +++ b/dtool/src/interrogate/interrogateBuilder.h @@ -52,37 +52,37 @@ class InterfaceMaker; */ class InterrogateBuilder { public: - void add_source_file(const string &filename); - void read_command_file(istream &in); - void do_command(const string &command, const string ¶ms); + void add_source_file(const std::string &filename); + void read_command_file(std::istream &in); + void do_command(const std::string &command, const std::string ¶ms); void build(); - void write_code(ostream &out_code, ostream *out_include, InterrogateModuleDef *def); + void write_code(std::ostream &out_code, std::ostream *out_include, InterrogateModuleDef *def); InterrogateModuleDef *make_module_def(int file_identifier); - static string clean_identifier(const string &name); - static string descope(const string &name); + static std::string clean_identifier(const std::string &name); + static std::string descope(const std::string &name); FunctionIndex get_destructor_for(CPPType *type); - string get_preferred_name(CPPType *type); - static string hash_string(const string &name, int shift_offset); + std::string get_preferred_name(CPPType *type); + static std::string hash_string(const std::string &name, int shift_offset); TypeIndex get_type(CPPType *type, bool global); public: - typedef std::set Commands; - typedef std::map CommandParams; + typedef std::set Commands; + typedef std::map CommandParams; void insert_param_list(InterrogateBuilder::Commands &commands, - const string ¶ms); + const std::string ¶ms); - bool in_forcetype(const string &name) const; - string in_renametype(const string &name) const; - bool in_ignoretype(const string &name) const; - string in_defconstruct(const string &name) const; - bool in_ignoreinvolved(const string &name) const; + bool in_forcetype(const std::string &name) const; + std::string in_renametype(const std::string &name) const; + bool in_ignoretype(const std::string &name) const; + std::string in_defconstruct(const std::string &name) const; + bool in_ignoreinvolved(const std::string &name) const; bool in_ignoreinvolved(CPPType *type) const; - bool in_ignorefile(const string &name) const; - bool in_ignoremember(const string &name) const; - bool in_noinclude(const string &name) const; - bool should_include(const string &filename) const; + bool in_ignorefile(const std::string &name) const; + bool in_ignoremember(const std::string &name) const; + bool in_noinclude(const std::string &name) const; + bool should_include(const std::string &filename) const; bool is_inherited_published(CPPInstance *function, CPPStructType *struct_type); @@ -96,18 +96,18 @@ public: ElementIndex scan_element(CPPInstance *element, CPPStructType *struct_type, CPPScope *scope); - FunctionIndex get_getter(CPPType *expr_type, string expression, + FunctionIndex get_getter(CPPType *expr_type, std::string expression, CPPStructType *struct_type, CPPScope *scope, CPPInstance *element); - FunctionIndex get_setter(CPPType *expr_type, string expression, + FunctionIndex get_setter(CPPType *expr_type, std::string expression, CPPStructType *struct_type, CPPScope *scope, CPPInstance *element); FunctionIndex get_cast_function(CPPType *to_type, CPPType *from_type, - const string &prefix); + const std::string &prefix); FunctionIndex - get_function(CPPInstance *function, string description, + get_function(CPPInstance *function, std::string description, CPPStructType *struct_type, CPPScope *scope, - int flags, const string &expression = string()); + int flags, const std::string &expression = std::string()); ElementIndex get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CPPScope *scope); @@ -133,19 +133,19 @@ public: void define_extension_type(InterrogateType &itype, CPPExtensionType *cpptype); - static string trim_blanks(const string &str); + static std::string trim_blanks(const std::string &str); - typedef std::map TypesByName; - typedef std::map FunctionsByName; - typedef std::map MakeSeqsByName; - typedef std::map PropertiesByName; + typedef std::map TypesByName; + typedef std::map FunctionsByName; + typedef std::map MakeSeqsByName; + typedef std::map PropertiesByName; TypesByName _types_by_name; FunctionsByName _functions_by_name; MakeSeqsByName _make_seqs_by_name; PropertiesByName _properties_by_name; - typedef std::map IncludeFiles; + typedef std::map IncludeFiles; IncludeFiles _include_files; Commands _forcetype; @@ -157,7 +157,7 @@ public: Commands _ignoremember; Commands _noinclude; - string _library_hash_name; + std::string _library_hash_name; friend class FunctionRemap; }; diff --git a/dtool/src/interrogate/parameterRemap.h b/dtool/src/interrogate/parameterRemap.h index 1e34fd0a8f..9ae351e29c 100644 --- a/dtool/src/interrogate/parameterRemap.h +++ b/dtool/src/interrogate/parameterRemap.h @@ -47,11 +47,11 @@ public: INLINE CPPExpression *get_default_value() const; INLINE void set_default_value(CPPExpression *expr); - virtual void pass_parameter(ostream &out, const string &variable_name); - virtual string prepare_return_expr(ostream &out, int indent_level, - const string &expression); - virtual string get_return_expr(const string &expression); - virtual string temporary_to_return(const string &temporary); + virtual void pass_parameter(std::ostream &out, const std::string &variable_name); + virtual std::string prepare_return_expr(std::ostream &out, int indent_level, + const std::string &expression); + virtual std::string get_return_expr(const std::string &expression); + virtual std::string temporary_to_return(const std::string &temporary); virtual bool return_value_needs_management(); virtual FunctionIndex get_return_value_destructor(); virtual bool return_value_should_be_simple(); diff --git a/dtool/src/interrogate/parameterRemapBasicStringPtrToString.h b/dtool/src/interrogate/parameterRemapBasicStringPtrToString.h index e034d8ebad..c0c385af5e 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringPtrToString.h +++ b/dtool/src/interrogate/parameterRemapBasicStringPtrToString.h @@ -25,8 +25,8 @@ class ParameterRemapBasicStringPtrToString : public ParameterRemapToString { public: ParameterRemapBasicStringPtrToString(CPPType *orig_type); - virtual void pass_parameter(ostream &out, const string &variable_name); - virtual string get_return_expr(const string &expression); + virtual void pass_parameter(std::ostream &out, const std::string &variable_name); + virtual std::string get_return_expr(const std::string &expression); }; /** @@ -36,8 +36,8 @@ class ParameterRemapBasicWStringPtrToWString : public ParameterRemapToWString { public: ParameterRemapBasicWStringPtrToWString(CPPType *orig_type); - virtual void pass_parameter(ostream &out, const string &variable_name); - virtual string get_return_expr(const string &expression); + virtual void pass_parameter(std::ostream &out, const std::string &variable_name); + virtual std::string get_return_expr(const std::string &expression); }; #endif diff --git a/dtool/src/interrogate/parameterRemapBasicStringRefToString.h b/dtool/src/interrogate/parameterRemapBasicStringRefToString.h index 65c6bc23fc..546e5aad97 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringRefToString.h +++ b/dtool/src/interrogate/parameterRemapBasicStringRefToString.h @@ -25,8 +25,8 @@ class ParameterRemapBasicStringRefToString : public ParameterRemapToString { public: ParameterRemapBasicStringRefToString(CPPType *orig_type); - virtual void pass_parameter(ostream &out, const string &variable_name); - virtual string get_return_expr(const string &expression); + virtual void pass_parameter(std::ostream &out, const std::string &variable_name); + virtual std::string get_return_expr(const std::string &expression); }; /** @@ -36,8 +36,8 @@ class ParameterRemapBasicWStringRefToWString : public ParameterRemapToWString { public: ParameterRemapBasicWStringRefToWString(CPPType *orig_type); - virtual void pass_parameter(ostream &out, const string &variable_name); - virtual string get_return_expr(const string &expression); + virtual void pass_parameter(std::ostream &out, const std::string &variable_name); + virtual std::string get_return_expr(const std::string &expression); }; #endif diff --git a/dtool/src/interrogate/parameterRemapBasicStringToString.h b/dtool/src/interrogate/parameterRemapBasicStringToString.h index 57d1a5624e..d27da23796 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringToString.h +++ b/dtool/src/interrogate/parameterRemapBasicStringToString.h @@ -25,10 +25,10 @@ class ParameterRemapBasicStringToString : public ParameterRemapToString { public: ParameterRemapBasicStringToString(CPPType *orig_type); - virtual void pass_parameter(ostream &out, const string &variable_name); - virtual string prepare_return_expr(ostream &out, int indent_level, - const string &expression); - virtual string get_return_expr(const string &expression); + virtual void pass_parameter(std::ostream &out, const std::string &variable_name); + virtual std::string prepare_return_expr(std::ostream &out, int indent_level, + const std::string &expression); + virtual std::string get_return_expr(const std::string &expression); }; /** @@ -38,10 +38,10 @@ class ParameterRemapBasicWStringToWString : public ParameterRemapToWString { public: ParameterRemapBasicWStringToWString(CPPType *orig_type); - virtual void pass_parameter(ostream &out, const string &variable_name); - virtual string prepare_return_expr(ostream &out, int indent_level, - const string &expression); - virtual string get_return_expr(const string &expression); + virtual void pass_parameter(std::ostream &out, const std::string &variable_name); + virtual std::string prepare_return_expr(std::ostream &out, int indent_level, + const std::string &expression); + virtual std::string get_return_expr(const std::string &expression); }; #endif diff --git a/dtool/src/interrogate/parameterRemapConcreteToPointer.h b/dtool/src/interrogate/parameterRemapConcreteToPointer.h index 50c9bbab2e..2e69597712 100644 --- a/dtool/src/interrogate/parameterRemapConcreteToPointer.h +++ b/dtool/src/interrogate/parameterRemapConcreteToPointer.h @@ -26,8 +26,8 @@ class ParameterRemapConcreteToPointer : public ParameterRemap { public: ParameterRemapConcreteToPointer(CPPType *orig_type); - virtual void pass_parameter(ostream &out, const string &variable_name); - virtual string get_return_expr(const string &expression); + virtual void pass_parameter(std::ostream &out, const std::string &variable_name); + virtual std::string get_return_expr(const std::string &expression); virtual bool return_value_needs_management(); virtual FunctionIndex get_return_value_destructor(); virtual bool return_value_should_be_simple(); diff --git a/dtool/src/interrogate/parameterRemapConstToNonConst.h b/dtool/src/interrogate/parameterRemapConstToNonConst.h index d952e26167..ee376764e1 100644 --- a/dtool/src/interrogate/parameterRemapConstToNonConst.h +++ b/dtool/src/interrogate/parameterRemapConstToNonConst.h @@ -27,8 +27,8 @@ class ParameterRemapConstToNonConst : public ParameterRemap { public: ParameterRemapConstToNonConst(CPPType *orig_type); - virtual void pass_parameter(ostream &out, const string &variable_name); - virtual string get_return_expr(const string &expression); + virtual void pass_parameter(std::ostream &out, const std::string &variable_name); + virtual std::string get_return_expr(const std::string &expression); }; #endif diff --git a/dtool/src/interrogate/parameterRemapEnumToInt.h b/dtool/src/interrogate/parameterRemapEnumToInt.h index f3a33bc631..a74951bcaa 100644 --- a/dtool/src/interrogate/parameterRemapEnumToInt.h +++ b/dtool/src/interrogate/parameterRemapEnumToInt.h @@ -26,8 +26,8 @@ class ParameterRemapEnumToInt : public ParameterRemap { public: ParameterRemapEnumToInt(CPPType *orig_type); - virtual void pass_parameter(ostream &out, const string &variable_name); - virtual string get_return_expr(const string &expression); + virtual void pass_parameter(std::ostream &out, const std::string &variable_name); + virtual std::string get_return_expr(const std::string &expression); private: CPPType *_enum_type; diff --git a/dtool/src/interrogate/parameterRemapHandleToInt.h b/dtool/src/interrogate/parameterRemapHandleToInt.h index 840a768180..32c2016300 100644 --- a/dtool/src/interrogate/parameterRemapHandleToInt.h +++ b/dtool/src/interrogate/parameterRemapHandleToInt.h @@ -30,8 +30,8 @@ class ParameterRemapHandleToInt : public ParameterRemap { public: ParameterRemapHandleToInt(CPPType *orig_type); - virtual void pass_parameter(ostream &out, const string &variable_name); - virtual string get_return_expr(const string &expression); + virtual void pass_parameter(std::ostream &out, const std::string &variable_name); + virtual std::string get_return_expr(const std::string &expression); }; #endif diff --git a/dtool/src/interrogate/parameterRemapPTToPointer.h b/dtool/src/interrogate/parameterRemapPTToPointer.h index e92bd5b5e8..5c59f075b9 100644 --- a/dtool/src/interrogate/parameterRemapPTToPointer.h +++ b/dtool/src/interrogate/parameterRemapPTToPointer.h @@ -29,9 +29,9 @@ class ParameterRemapPTToPointer : public ParameterRemap { public: ParameterRemapPTToPointer(CPPType *orig_type); - virtual void pass_parameter(ostream &out, const string &variable_name); - virtual string get_return_expr(const string &expression); - virtual string temporary_to_return(const string &temporary); + virtual void pass_parameter(std::ostream &out, const std::string &variable_name); + virtual std::string get_return_expr(const std::string &expression); + virtual std::string temporary_to_return(const std::string &temporary); private: CPPType *_pointer_type; diff --git a/dtool/src/interrogate/parameterRemapReferenceToConcrete.h b/dtool/src/interrogate/parameterRemapReferenceToConcrete.h index 47ac919a39..12c7ef27bd 100644 --- a/dtool/src/interrogate/parameterRemapReferenceToConcrete.h +++ b/dtool/src/interrogate/parameterRemapReferenceToConcrete.h @@ -27,8 +27,8 @@ class ParameterRemapReferenceToConcrete : public ParameterRemap { public: ParameterRemapReferenceToConcrete(CPPType *orig_type); - virtual void pass_parameter(ostream &out, const string &variable_name); - virtual string get_return_expr(const string &expression); + virtual void pass_parameter(std::ostream &out, const std::string &variable_name); + virtual std::string get_return_expr(const std::string &expression); }; #endif diff --git a/dtool/src/interrogate/parameterRemapReferenceToPointer.h b/dtool/src/interrogate/parameterRemapReferenceToPointer.h index 3e6d4bd87d..6ee71d86c5 100644 --- a/dtool/src/interrogate/parameterRemapReferenceToPointer.h +++ b/dtool/src/interrogate/parameterRemapReferenceToPointer.h @@ -26,8 +26,8 @@ class ParameterRemapReferenceToPointer : public ParameterRemap { public: ParameterRemapReferenceToPointer(CPPType *orig_type); - virtual void pass_parameter(ostream &out, const string &variable_name); - virtual string get_return_expr(const string &expression); + virtual void pass_parameter(std::ostream &out, const std::string &variable_name); + virtual std::string get_return_expr(const std::string &expression); }; #endif diff --git a/dtool/src/interrogate/parameterRemapThis.h b/dtool/src/interrogate/parameterRemapThis.h index 31204684b1..3d13b66717 100644 --- a/dtool/src/interrogate/parameterRemapThis.h +++ b/dtool/src/interrogate/parameterRemapThis.h @@ -27,8 +27,8 @@ class ParameterRemapThis : public ParameterRemap { public: ParameterRemapThis(CPPType *type, bool is_const); - virtual void pass_parameter(ostream &out, const string &variable_name); - virtual string get_return_expr(const string &expression); + virtual void pass_parameter(std::ostream &out, const std::string &variable_name); + virtual std::string get_return_expr(const std::string &expression); virtual bool is_this(); }; diff --git a/dtool/src/interrogate/parameterRemapToString.h b/dtool/src/interrogate/parameterRemapToString.h index b41369f9c0..5eed97d731 100644 --- a/dtool/src/interrogate/parameterRemapToString.h +++ b/dtool/src/interrogate/parameterRemapToString.h @@ -30,8 +30,8 @@ class ParameterRemapToString : public ParameterRemap { public: ParameterRemapToString(CPPType *orig_type); - virtual void pass_parameter(ostream &out, const string &variable_name); - virtual string get_return_expr(const string &expression); + virtual void pass_parameter(std::ostream &out, const std::string &variable_name); + virtual std::string get_return_expr(const std::string &expression); virtual bool new_type_is_atomic_string(); }; @@ -48,8 +48,8 @@ class ParameterRemapToWString : public ParameterRemap { public: ParameterRemapToWString(CPPType *orig_type); - virtual void pass_parameter(ostream &out, const string &variable_name); - virtual string get_return_expr(const string &expression); + virtual void pass_parameter(std::ostream &out, const std::string &variable_name); + virtual std::string get_return_expr(const std::string &expression); virtual bool new_type_is_atomic_string(); }; diff --git a/dtool/src/interrogate/typeManager.h b/dtool/src/interrogate/typeManager.h index 6d259b01ff..d507e947ef 100644 --- a/dtool/src/interrogate/typeManager.h +++ b/dtool/src/interrogate/typeManager.h @@ -139,10 +139,10 @@ public: static CPPType *get_void_type(); static CPPType *get_int_type(); - static string get_function_signature(CPPInstance *function, + static std::string get_function_signature(CPPInstance *function, int num_default_parameters = 0); - static string get_function_name(CPPInstance *function); + static std::string get_function_name(CPPInstance *function); static bool has_protected_destructor(CPPType *type); diff --git a/dtool/src/interrogatedb/interrogateComponent.I b/dtool/src/interrogatedb/interrogateComponent.I index dc401c7945..dddbb421fb 100644 --- a/dtool/src/interrogatedb/interrogateComponent.I +++ b/dtool/src/interrogatedb/interrogateComponent.I @@ -98,7 +98,7 @@ has_name() const { /** * */ -INLINE const string &InterrogateComponent:: +INLINE const std::string &InterrogateComponent:: get_name() const { return _name; } @@ -114,7 +114,7 @@ get_num_alt_names() const { /** * */ -INLINE const string &InterrogateComponent:: +INLINE const std::string &InterrogateComponent:: get_alt_name(int n) const { if (n >= 0 && n < (int)_alt_names.size()) { return _alt_names[n]; diff --git a/dtool/src/interrogatedb/interrogateComponent.h b/dtool/src/interrogatedb/interrogateComponent.h index 0d8a39595d..2555769756 100644 --- a/dtool/src/interrogatedb/interrogateComponent.h +++ b/dtool/src/interrogatedb/interrogateComponent.h @@ -40,22 +40,22 @@ public: INLINE const char *get_module_name() const; INLINE bool has_name() const; - INLINE const string &get_name() const; + INLINE const std::string &get_name() const; INLINE int get_num_alt_names() const; - INLINE const string &get_alt_name(int n) const; + INLINE const std::string &get_alt_name(int n) const; - void output(ostream &out) const; - void input(istream &in); + void output(std::ostream &out) const; + void input(std::istream &in); protected: - static string _empty_string; + static std::string _empty_string; private: InterrogateModuleDef *_def; - string _name; + std::string _name; - typedef std::vector Strings; + typedef std::vector Strings; Strings _alt_names; friend class InterrogateBuilder; diff --git a/dtool/src/interrogatedb/interrogateDatabase.I b/dtool/src/interrogatedb/interrogateDatabase.I index 91493a1772..cf15d962bf 100644 --- a/dtool/src/interrogatedb/interrogateDatabase.I +++ b/dtool/src/interrogatedb/interrogateDatabase.I @@ -27,7 +27,7 @@ check_latest() { * name, or 0 if no type has this name. */ INLINE TypeIndex InterrogateDatabase:: -lookup_type_by_name(const string &name) { +lookup_type_by_name(const std::string &name) { check_latest(); return lookup(name, _types_by_name, LT_type_name, &InterrogateDatabase::freshen_types_by_name); @@ -38,7 +38,7 @@ lookup_type_by_name(const string &name) { * scoped name, or 0 if no type has this name. */ INLINE TypeIndex InterrogateDatabase:: -lookup_type_by_scoped_name(const string &name) { +lookup_type_by_scoped_name(const std::string &name) { check_latest(); return lookup(name, _types_by_scoped_name, LT_type_scoped_name, &InterrogateDatabase::freshen_types_by_scoped_name); @@ -49,7 +49,7 @@ lookup_type_by_scoped_name(const string &name) { * true name, or 0 if no type has this name. */ INLINE TypeIndex InterrogateDatabase:: -lookup_type_by_true_name(const string &name) { +lookup_type_by_true_name(const std::string &name) { check_latest(); return lookup(name, _types_by_true_name, LT_type_true_name, &InterrogateDatabase::freshen_types_by_true_name); @@ -60,7 +60,7 @@ lookup_type_by_true_name(const string &name) { * given name, or 0 if no manifest has this name. */ INLINE ManifestIndex InterrogateDatabase:: -lookup_manifest_by_name(const string &name) { +lookup_manifest_by_name(const std::string &name) { check_latest(); return lookup(name, _manifests_by_name, LT_manifest_name, &InterrogateDatabase::freshen_manifests_by_name); @@ -71,7 +71,7 @@ lookup_manifest_by_name(const string &name) { * given name, or 0 if no element has this name. */ INLINE ElementIndex InterrogateDatabase:: -lookup_element_by_name(const string &name) { +lookup_element_by_name(const std::string &name) { check_latest(); return lookup(name, _elements_by_name, LT_element_name, &InterrogateDatabase::freshen_elements_by_name); @@ -82,7 +82,7 @@ lookup_element_by_name(const string &name) { * given scoped name, or 0 if no element has this name. */ INLINE ElementIndex InterrogateDatabase:: -lookup_element_by_scoped_name(const string &name) { +lookup_element_by_scoped_name(const std::string &name) { check_latest(); return lookup(name, _elements_by_scoped_name, LT_element_scoped_name, &InterrogateDatabase::freshen_elements_by_scoped_name); diff --git a/dtool/src/interrogatedb/interrogateDatabase.h b/dtool/src/interrogatedb/interrogateDatabase.h index 182e35798f..9c60b0318e 100644 --- a/dtool/src/interrogatedb/interrogateDatabase.h +++ b/dtool/src/interrogatedb/interrogateDatabase.h @@ -65,18 +65,18 @@ public: const InterrogateElement &get_element(ElementIndex element); const InterrogateMakeSeq &get_make_seq(MakeSeqIndex element); - INLINE TypeIndex lookup_type_by_name(const string &name); - INLINE TypeIndex lookup_type_by_scoped_name(const string &name); - INLINE TypeIndex lookup_type_by_true_name(const string &name); - INLINE ManifestIndex lookup_manifest_by_name(const string &name); - INLINE ElementIndex lookup_element_by_name(const string &name); - INLINE ElementIndex lookup_element_by_scoped_name(const string &name); + INLINE TypeIndex lookup_type_by_name(const std::string &name); + INLINE TypeIndex lookup_type_by_scoped_name(const std::string &name); + INLINE TypeIndex lookup_type_by_true_name(const std::string &name); + INLINE ManifestIndex lookup_manifest_by_name(const std::string &name); + INLINE ElementIndex lookup_element_by_name(const std::string &name); + INLINE ElementIndex lookup_element_by_scoped_name(const std::string &name); void remove_type(TypeIndex type); void *get_fptr(FunctionWrapperIndex wrapper); - FunctionWrapperIndex get_wrapper_by_unique_name(const string &unique_name); + FunctionWrapperIndex get_wrapper_by_unique_name(const std::string &unique_name); static int get_file_major_version(); static int get_file_minor_version(); @@ -106,14 +106,14 @@ public: int remap_indices(int first_index); int remap_indices(int first_index, IndexRemapper &remap); - void write(ostream &out, InterrogateModuleDef *def) const; - bool read(istream &in, InterrogateModuleDef *def); + void write(std::ostream &out, InterrogateModuleDef *def) const; + bool read(std::istream &in, InterrogateModuleDef *def); private: INLINE void check_latest(); void load_latest(); - bool read_new(istream &in, InterrogateModuleDef *def); + bool read_new(std::istream &in, InterrogateModuleDef *def); void merge_from(const InterrogateDatabase &other); bool find_module(FunctionWrapperIndex wrapper, @@ -121,7 +121,7 @@ private: int binary_search_module(int begin, int end, FunctionIndex function); int binary_search_wrapper_hash(InterrogateUniqueNameDef *begin, InterrogateUniqueNameDef *end, - const string &wrapper_hash_name); + const std::string &wrapper_hash_name); // This data is loaded from the various database files. typedef std::map TypeMap; @@ -154,7 +154,7 @@ private: // with. typedef std::vector Modules; Modules _modules; - typedef std::map ModulesByHash; + typedef std::map ModulesByHash; ModulesByHash _modules_by_hash; // This records the set of database files that are still to be loaded. @@ -174,7 +174,7 @@ private: }; int _lookups_fresh; - typedef std::map Lookup; + typedef std::map Lookup; Lookup _types_by_name; Lookup _types_by_scoped_name; Lookup _types_by_true_name; @@ -189,7 +189,7 @@ private: void freshen_elements_by_name(); void freshen_elements_by_scoped_name(); - int lookup(const string &name, + int lookup(const std::string &name, Lookup &lookup, LookupType type, void (InterrogateDatabase::*freshen)()); diff --git a/dtool/src/interrogatedb/interrogateElement.I b/dtool/src/interrogatedb/interrogateElement.I index 914aba2327..93e6889b16 100644 --- a/dtool/src/interrogatedb/interrogateElement.I +++ b/dtool/src/interrogatedb/interrogateElement.I @@ -80,7 +80,7 @@ has_scoped_name() const { /** * */ -INLINE const string &InterrogateElement:: +INLINE const std::string &InterrogateElement:: get_scoped_name() const { return _scoped_name; } @@ -96,7 +96,7 @@ has_comment() const { /** * */ -INLINE const string &InterrogateElement:: +INLINE const std::string &InterrogateElement:: get_comment() const { return _comment; } @@ -246,14 +246,14 @@ is_mapping() const { } -INLINE ostream & -operator << (ostream &out, const InterrogateElement &element) { +INLINE std::ostream & +operator << (std::ostream &out, const InterrogateElement &element) { element.output(out); return out; } -INLINE istream & -operator >> (istream &in, InterrogateElement &element) { +INLINE std::istream & +operator >> (std::istream &in, InterrogateElement &element) { element.input(in); return in; } diff --git a/dtool/src/interrogatedb/interrogateElement.h b/dtool/src/interrogatedb/interrogateElement.h index b3ba755fac..e3d55569f0 100644 --- a/dtool/src/interrogatedb/interrogateElement.h +++ b/dtool/src/interrogatedb/interrogateElement.h @@ -34,10 +34,10 @@ public: INLINE bool is_global() const; INLINE bool has_scoped_name() const; - INLINE const string &get_scoped_name() const; + INLINE const std::string &get_scoped_name() const; INLINE bool has_comment() const; - INLINE const string &get_comment() const; + INLINE const std::string &get_comment() const; INLINE TypeIndex get_type() const; INLINE bool has_getter() const; @@ -58,8 +58,8 @@ public: INLINE FunctionIndex get_length_function() const; INLINE bool is_mapping() const; - void output(ostream &out) const; - void input(istream &in); + void output(std::ostream &out) const; + void input(std::istream &in); void remap_indices(const IndexRemapper &remap); @@ -78,8 +78,8 @@ private: }; int _flags; - string _scoped_name; - string _comment; + std::string _scoped_name; + std::string _comment; TypeIndex _type; FunctionIndex _length_function; FunctionIndex _getter; @@ -95,8 +95,8 @@ private: friend class InterrogateBuilder; }; -INLINE ostream &operator << (ostream &out, const InterrogateElement &element); -INLINE istream &operator >> (istream &in, InterrogateElement &element); +INLINE std::ostream &operator << (std::ostream &out, const InterrogateElement &element); +INLINE std::istream &operator >> (std::istream &in, InterrogateElement &element); #include "interrogateElement.I" diff --git a/dtool/src/interrogatedb/interrogateFunction.I b/dtool/src/interrogatedb/interrogateFunction.I index c394c8ac6f..3834e60782 100644 --- a/dtool/src/interrogatedb/interrogateFunction.I +++ b/dtool/src/interrogatedb/interrogateFunction.I @@ -73,7 +73,7 @@ has_scoped_name() const { /** * */ -INLINE const string &InterrogateFunction:: +INLINE const std::string &InterrogateFunction:: get_scoped_name() const { return _scoped_name; } @@ -89,7 +89,7 @@ has_comment() const { /** * */ -INLINE const string &InterrogateFunction:: +INLINE const std::string &InterrogateFunction:: get_comment() const { return _comment; } @@ -105,7 +105,7 @@ has_prototype() const { /** * */ -INLINE const string &InterrogateFunction:: +INLINE const std::string &InterrogateFunction:: get_prototype() const { return _prototype; } @@ -149,14 +149,14 @@ get_python_wrapper(int n) const { } -INLINE ostream & -operator << (ostream &out, const InterrogateFunction &function) { +INLINE std::ostream & +operator << (std::ostream &out, const InterrogateFunction &function) { function.output(out); return out; } -INLINE istream & -operator >> (istream &in, InterrogateFunction &function) { +INLINE std::istream & +operator >> (std::istream &in, InterrogateFunction &function) { function.input(in); return in; } diff --git a/dtool/src/interrogatedb/interrogateFunction.h b/dtool/src/interrogatedb/interrogateFunction.h index cf92aa15dc..1e3a251032 100644 --- a/dtool/src/interrogatedb/interrogateFunction.h +++ b/dtool/src/interrogatedb/interrogateFunction.h @@ -41,13 +41,13 @@ public: INLINE TypeIndex get_class() const; INLINE bool has_scoped_name() const; - INLINE const string &get_scoped_name() const; + INLINE const std::string &get_scoped_name() const; INLINE bool has_comment() const; - INLINE const string &get_comment() const; + INLINE const std::string &get_comment() const; INLINE bool has_prototype() const; - INLINE const string &get_prototype() const; + INLINE const std::string &get_prototype() const; INLINE int number_of_c_wrappers() const; INLINE FunctionWrapperIndex get_c_wrapper(int n) const; @@ -55,8 +55,8 @@ public: INLINE int number_of_python_wrappers() const; INLINE FunctionWrapperIndex get_python_wrapper(int n) const; - void output(ostream &out) const; - void input(istream &in); + void output(std::ostream &out) const; + void input(std::istream &in); void remap_indices(const IndexRemapper &remap); @@ -73,9 +73,9 @@ private: }; int _flags; - string _scoped_name; - string _comment; - string _prototype; + std::string _scoped_name; + std::string _comment; + std::string _prototype; TypeIndex _class; typedef std::vector Wrappers; @@ -92,9 +92,9 @@ public: // This must be a pointer, rather than a concrete map, so we don't risk // trying to create a map in one DLL and access it in another. Silly // Windows. - typedef std::map Instances; + typedef std::map Instances; Instances *_instances; - string _expression; + std::string _expression; friend class InterrogateBuilder; friend class InterfaceMakerC; @@ -103,8 +103,8 @@ public: friend class FunctionRemap; }; -INLINE ostream &operator << (ostream &out, const InterrogateFunction &function); -INLINE istream &operator >> (istream &in, InterrogateFunction &function); +INLINE std::ostream &operator << (std::ostream &out, const InterrogateFunction &function); +INLINE std::istream &operator >> (std::istream &in, InterrogateFunction &function); #include "interrogateFunction.I" diff --git a/dtool/src/interrogatedb/interrogateFunctionWrapper.I b/dtool/src/interrogatedb/interrogateFunctionWrapper.I index 955800e5c1..d636e32ebf 100644 --- a/dtool/src/interrogatedb/interrogateFunctionWrapper.I +++ b/dtool/src/interrogatedb/interrogateFunctionWrapper.I @@ -128,9 +128,9 @@ parameter_has_name(int n) const { /** * */ -INLINE const string &InterrogateFunctionWrapper:: +INLINE const std::string &InterrogateFunctionWrapper:: parameter_get_name(int n) const { - static string bogus_string; + static std::string bogus_string; if (n >= 0 && n < (int)_parameters.size()) { return _parameters[n]._name; } @@ -151,7 +151,7 @@ parameter_is_this(int n) const { /** * */ -INLINE const string &InterrogateFunctionWrapper:: +INLINE const std::string &InterrogateFunctionWrapper:: get_unique_name() const { return _unique_name; } @@ -167,31 +167,31 @@ has_comment() const { /** * */ -INLINE const string &InterrogateFunctionWrapper:: +INLINE const std::string &InterrogateFunctionWrapper:: get_comment() const { return _comment; } -INLINE ostream & -operator << (ostream &out, const InterrogateFunctionWrapper &wrapper) { +INLINE std::ostream & +operator << (std::ostream &out, const InterrogateFunctionWrapper &wrapper) { wrapper.output(out); return out; } -INLINE istream & -operator >> (istream &in, InterrogateFunctionWrapper &wrapper) { +INLINE std::istream & +operator >> (std::istream &in, InterrogateFunctionWrapper &wrapper) { wrapper.input(in); return in; } -INLINE ostream & -operator << (ostream &out, const InterrogateFunctionWrapper::Parameter &p) { +INLINE std::ostream & +operator << (std::ostream &out, const InterrogateFunctionWrapper::Parameter &p) { p.output(out); return out; } -INLINE istream & -operator >> (istream &in, InterrogateFunctionWrapper::Parameter &p) { +INLINE std::istream & +operator >> (std::istream &in, InterrogateFunctionWrapper::Parameter &p) { p.input(in); return in; } diff --git a/dtool/src/interrogatedb/interrogateFunctionWrapper.h b/dtool/src/interrogatedb/interrogateFunctionWrapper.h index ff80d930b9..43b01a9a79 100644 --- a/dtool/src/interrogatedb/interrogateFunctionWrapper.h +++ b/dtool/src/interrogatedb/interrogateFunctionWrapper.h @@ -43,16 +43,16 @@ public: INLINE int number_of_parameters() const; INLINE TypeIndex parameter_get_type(int n) const; INLINE bool parameter_has_name(int n) const; - INLINE const string ¶meter_get_name(int n) const; + INLINE const std::string ¶meter_get_name(int n) const; INLINE bool parameter_is_this(int n) const; - INLINE const string &get_unique_name() const; + INLINE const std::string &get_unique_name() const; INLINE bool has_comment() const; - INLINE const string &get_comment() const; + INLINE const std::string &get_comment() const; - void output(ostream &out) const; - void input(istream &in); + void output(std::ostream &out) const; + void input(std::istream &in); void remap_indices(const IndexRemapper &remap); @@ -72,8 +72,8 @@ private: FunctionIndex _function; TypeIndex _return_type; FunctionIndex _return_value_destructor; - string _unique_name; - string _comment; + std::string _unique_name; + std::string _comment; public: // This nested class must be declared public just so we can declare the @@ -81,12 +81,12 @@ public: // Arguably a compiler bug, but what can you do. class Parameter { public: - void output(ostream &out) const; - void input(istream &in); + void output(std::ostream &out) const; + void input(std::istream &in); int _parameter_flags; TypeIndex _type; - string _name; + std::string _name; }; private: @@ -97,11 +97,11 @@ private: friend class FunctionRemap; }; -INLINE ostream &operator << (ostream &out, const InterrogateFunctionWrapper &wrapper); -INLINE istream &operator >> (istream &in, InterrogateFunctionWrapper &wrapper); +INLINE std::ostream &operator << (std::ostream &out, const InterrogateFunctionWrapper &wrapper); +INLINE std::istream &operator >> (std::istream &in, InterrogateFunctionWrapper &wrapper); -INLINE ostream &operator << (ostream &out, const InterrogateFunctionWrapper::Parameter &p); -INLINE istream &operator >> (istream &in, InterrogateFunctionWrapper::Parameter &p); +INLINE std::ostream &operator << (std::ostream &out, const InterrogateFunctionWrapper::Parameter &p); +INLINE std::istream &operator >> (std::istream &in, InterrogateFunctionWrapper::Parameter &p); #include "interrogateFunctionWrapper.I" diff --git a/dtool/src/interrogatedb/interrogateMakeSeq.I b/dtool/src/interrogatedb/interrogateMakeSeq.I index dde5247912..82e01761ea 100644 --- a/dtool/src/interrogatedb/interrogateMakeSeq.I +++ b/dtool/src/interrogatedb/interrogateMakeSeq.I @@ -53,7 +53,7 @@ has_scoped_name() const { /** * */ -INLINE const string &InterrogateMakeSeq:: +INLINE const std::string &InterrogateMakeSeq:: get_scoped_name() const { return _scoped_name; } @@ -69,7 +69,7 @@ has_comment() const { /** * */ -INLINE const string &InterrogateMakeSeq:: +INLINE const std::string &InterrogateMakeSeq:: get_comment() const { return _comment; } @@ -90,14 +90,14 @@ get_element_getter() const { return _element_getter; } -INLINE ostream & -operator << (ostream &out, const InterrogateMakeSeq &make_seq) { +INLINE std::ostream & +operator << (std::ostream &out, const InterrogateMakeSeq &make_seq) { make_seq.output(out); return out; } -INLINE istream & -operator >> (istream &in, InterrogateMakeSeq &make_seq) { +INLINE std::istream & +operator >> (std::istream &in, InterrogateMakeSeq &make_seq) { make_seq.input(in); return in; } diff --git a/dtool/src/interrogatedb/interrogateMakeSeq.h b/dtool/src/interrogatedb/interrogateMakeSeq.h index b65a32b27e..5d6e1858b2 100644 --- a/dtool/src/interrogatedb/interrogateMakeSeq.h +++ b/dtool/src/interrogatedb/interrogateMakeSeq.h @@ -30,30 +30,30 @@ public: INLINE void operator = (const InterrogateMakeSeq ©); INLINE bool has_scoped_name() const; - INLINE const string &get_scoped_name() const; + INLINE const std::string &get_scoped_name() const; INLINE bool has_comment() const; - INLINE const string &get_comment() const; + INLINE const std::string &get_comment() const; INLINE FunctionIndex get_length_getter() const; INLINE FunctionIndex get_element_getter() const; - void output(ostream &out) const; - void input(istream &in); + void output(std::ostream &out) const; + void input(std::istream &in); void remap_indices(const IndexRemapper &remap); private: - string _scoped_name; - string _comment; + std::string _scoped_name; + std::string _comment; FunctionIndex _length_getter; FunctionIndex _element_getter; friend class InterrogateBuilder; }; -INLINE ostream &operator << (ostream &out, const InterrogateMakeSeq &make_seq); -INLINE istream &operator >> (istream &in, InterrogateMakeSeq &make_seq); +INLINE std::ostream &operator << (std::ostream &out, const InterrogateMakeSeq &make_seq); +INLINE std::istream &operator >> (std::istream &in, InterrogateMakeSeq &make_seq); #include "interrogateMakeSeq.I" diff --git a/dtool/src/interrogatedb/interrogateManifest.I b/dtool/src/interrogatedb/interrogateManifest.I index 877b28a98e..2aedf8a682 100644 --- a/dtool/src/interrogatedb/interrogateManifest.I +++ b/dtool/src/interrogatedb/interrogateManifest.I @@ -49,7 +49,7 @@ operator = (const InterrogateManifest ©) { /** * */ -INLINE const string &InterrogateManifest:: +INLINE const std::string &InterrogateManifest:: get_definition() const { return _definition; } @@ -103,14 +103,14 @@ get_int_value() const { } -INLINE ostream & -operator << (ostream &out, const InterrogateManifest &manifest) { +INLINE std::ostream & +operator << (std::ostream &out, const InterrogateManifest &manifest) { manifest.output(out); return out; } -INLINE istream & -operator >> (istream &in, InterrogateManifest &manifest) { +INLINE std::istream & +operator >> (std::istream &in, InterrogateManifest &manifest) { manifest.input(in); return in; } diff --git a/dtool/src/interrogatedb/interrogateManifest.h b/dtool/src/interrogatedb/interrogateManifest.h index 37ec3696b4..a038cc0ce1 100644 --- a/dtool/src/interrogatedb/interrogateManifest.h +++ b/dtool/src/interrogatedb/interrogateManifest.h @@ -29,7 +29,7 @@ public: INLINE InterrogateManifest(const InterrogateManifest ©); INLINE void operator = (const InterrogateManifest ©); - INLINE const string &get_definition() const; + INLINE const std::string &get_definition() const; INLINE bool has_type() const; INLINE TypeIndex get_type() const; INLINE bool has_getter() const; @@ -37,8 +37,8 @@ public: INLINE bool has_int_value() const; INLINE int get_int_value() const; - void output(ostream &out) const; - void input(istream &in); + void output(std::ostream &out) const; + void input(std::istream &in); void remap_indices(const IndexRemapper &remap); @@ -50,7 +50,7 @@ private: }; int _flags; - string _definition; + std::string _definition; int _int_value; TypeIndex _type; FunctionIndex _getter; @@ -58,8 +58,8 @@ private: friend class InterrogateBuilder; }; -INLINE ostream &operator << (ostream &out, const InterrogateManifest &manifest); -INLINE istream &operator >> (istream &in, InterrogateManifest &manifest); +INLINE std::ostream &operator << (std::ostream &out, const InterrogateManifest &manifest); +INLINE std::istream &operator >> (std::istream &in, InterrogateManifest &manifest); #include "interrogateManifest.I" diff --git a/dtool/src/interrogatedb/interrogateType.I b/dtool/src/interrogatedb/interrogateType.I index 840fdb18f3..c8a4d601b2 100644 --- a/dtool/src/interrogatedb/interrogateType.I +++ b/dtool/src/interrogatedb/interrogateType.I @@ -31,7 +31,7 @@ has_scoped_name() const { /** * */ -INLINE const string &InterrogateType:: +INLINE const std::string &InterrogateType:: get_scoped_name() const { return _scoped_name; } @@ -47,7 +47,7 @@ has_true_name() const { /** * */ -INLINE const string &InterrogateType:: +INLINE const std::string &InterrogateType:: get_true_name() const { return _true_name; } @@ -63,7 +63,7 @@ has_comment() const { /** * */ -INLINE const string &InterrogateType:: +INLINE const std::string &InterrogateType:: get_comment() const { return _comment; } @@ -224,7 +224,7 @@ number_of_enum_values() const { /** * */ -INLINE const string &InterrogateType:: +INLINE const std::string &InterrogateType:: get_enum_value_name(int n) const { if (n >= 0 && n < (int)_enum_values.size()) { return _enum_values[n]._name; @@ -235,7 +235,7 @@ get_enum_value_name(int n) const { /** * */ -INLINE const string &InterrogateType:: +INLINE const std::string &InterrogateType:: get_enum_value_scoped_name(int n) const { if (n >= 0 && n < (int)_enum_values.size()) { return _enum_values[n]._scoped_name; @@ -246,7 +246,7 @@ get_enum_value_scoped_name(int n) const { /** * */ -INLINE const string &InterrogateType:: +INLINE const std::string &InterrogateType:: get_enum_value_comment(int n) const { if (n >= 0 && n < (int)_enum_values.size()) { return _enum_values[n]._comment; @@ -547,38 +547,38 @@ get_nested_type(int n) const { } } -INLINE ostream & -operator << (ostream &out, const InterrogateType &type) { +INLINE std::ostream & +operator << (std::ostream &out, const InterrogateType &type) { type.output(out); return out; } -INLINE istream & -operator >> (istream &in, InterrogateType &type) { +INLINE std::istream & +operator >> (std::istream &in, InterrogateType &type) { type.input(in); return in; } -INLINE ostream & -operator << (ostream &out, const InterrogateType::Derivation &d) { +INLINE std::ostream & +operator << (std::ostream &out, const InterrogateType::Derivation &d) { d.output(out); return out; } -INLINE istream & -operator >> (istream &in, InterrogateType::Derivation &d) { +INLINE std::istream & +operator >> (std::istream &in, InterrogateType::Derivation &d) { d.input(in); return in; } -INLINE ostream & -operator << (ostream &out, const InterrogateType::EnumValue &ev) { +INLINE std::ostream & +operator << (std::ostream &out, const InterrogateType::EnumValue &ev) { ev.output(out); return out; } -INLINE istream & -operator >> (istream &in, InterrogateType::EnumValue &ev) { +INLINE std::istream & +operator >> (std::istream &in, InterrogateType::EnumValue &ev) { ev.input(in); return in; } diff --git a/dtool/src/interrogatedb/interrogateType.h b/dtool/src/interrogatedb/interrogateType.h index f5b3b49065..0e6ade73d4 100644 --- a/dtool/src/interrogatedb/interrogateType.h +++ b/dtool/src/interrogatedb/interrogateType.h @@ -36,13 +36,13 @@ public: INLINE bool is_global() const; INLINE bool has_scoped_name() const; - INLINE const string &get_scoped_name() const; + INLINE const std::string &get_scoped_name() const; INLINE bool has_true_name() const; - INLINE const string &get_true_name() const; + INLINE const std::string &get_true_name() const; INLINE bool has_comment() const; - INLINE const string &get_comment() const; + INLINE const std::string &get_comment() const; INLINE bool is_nested() const; INLINE TypeIndex get_outer_class() const; @@ -67,9 +67,9 @@ public: INLINE bool is_enum() const; INLINE bool is_scoped_enum() const; INLINE int number_of_enum_values() const; - INLINE const string &get_enum_value_name(int n) const; - INLINE const string &get_enum_value_scoped_name(int n) const; - INLINE const string &get_enum_value_comment(int n) const; + INLINE const std::string &get_enum_value_name(int n) const; + INLINE const std::string &get_enum_value_scoped_name(int n) const; + INLINE const std::string &get_enum_value_comment(int n) const; INLINE int get_enum_value(int n) const; INLINE bool is_struct() const; @@ -109,8 +109,8 @@ public: INLINE TypeIndex get_nested_type(int n) const; void merge_with(const InterrogateType &other); - void output(ostream &out) const; - void input(istream &in); + void output(std::ostream &out) const; + void input(std::istream &in); void remap_indices(const IndexRemapper &remap); @@ -146,9 +146,9 @@ private: public: int _flags; - string _scoped_name; - string _true_name; - string _comment; + std::string _scoped_name; + std::string _true_name; + std::string _comment; TypeIndex _outer_class; AtomicToken _atomic_token; TypeIndex _wrapped_type; @@ -178,8 +178,8 @@ public: // Arguably a compiler bug, but what can you do. class Derivation { public: - void output(ostream &out) const; - void input(istream &in); + void output(std::ostream &out) const; + void input(std::istream &in); int _flags; TypeIndex _base; @@ -195,12 +195,12 @@ public: // This nested class must also be public, for the same reason. class EnumValue { public: - void output(ostream &out) const; - void input(istream &in); + void output(std::ostream &out) const; + void input(std::istream &in); - string _name; - string _scoped_name; - string _comment; + std::string _name; + std::string _scoped_name; + std::string _comment; int _value; }; @@ -223,14 +223,14 @@ public: friend class InterrogateBuilder; }; -INLINE ostream &operator << (ostream &out, const InterrogateType &type); -INLINE istream &operator >> (istream &in, InterrogateType &type); +INLINE std::ostream &operator << (std::ostream &out, const InterrogateType &type); +INLINE std::istream &operator >> (std::istream &in, InterrogateType &type); -INLINE ostream &operator << (ostream &out, const InterrogateType::Derivation &d); -INLINE istream &operator >> (istream &in, InterrogateType::Derivation &d); +INLINE std::ostream &operator << (std::ostream &out, const InterrogateType::Derivation &d); +INLINE std::istream &operator >> (std::istream &in, InterrogateType::Derivation &d); -INLINE ostream &operator << (ostream &out, const InterrogateType::EnumValue &d); -INLINE istream &operator >> (istream &in, InterrogateType::EnumValue &d); +INLINE std::ostream &operator << (std::ostream &out, const InterrogateType::EnumValue &d); +INLINE std::istream &operator >> (std::istream &in, InterrogateType::EnumValue &d); #include "interrogateType.I" diff --git a/dtool/src/interrogatedb/interrogate_datafile.I b/dtool/src/interrogatedb/interrogate_datafile.I index ee8d3f38a3..cb020861e2 100644 --- a/dtool/src/interrogatedb/interrogate_datafile.I +++ b/dtool/src/interrogatedb/interrogate_datafile.I @@ -17,7 +17,7 @@ */ template void -idf_output_vector(ostream &out, const std::vector &vec) { +idf_output_vector(std::ostream &out, const std::vector &vec) { out << vec.size() << " "; typename std::vector::const_iterator vi; for (vi = vec.begin(); vi != vec.end(); ++vi) { @@ -33,7 +33,7 @@ idf_output_vector(ostream &out, const std::vector &vec) { */ template void -idf_input_vector(istream &in, std::vector &vec) { +idf_input_vector(std::istream &in, std::vector &vec) { int length; in >> length; if (in.fail()) { diff --git a/dtool/src/interrogatedb/interrogate_datafile.h b/dtool/src/interrogatedb/interrogate_datafile.h index 7442d8ce81..8432123fdf 100644 --- a/dtool/src/interrogatedb/interrogate_datafile.h +++ b/dtool/src/interrogatedb/interrogate_datafile.h @@ -20,17 +20,17 @@ #include "dtoolbase.h" #include -void idf_output_string(ostream &out, const string &str, char whitespace = ' '); -void idf_input_string(istream &in, string &str); +void idf_output_string(std::ostream &out, const std::string &str, char whitespace = ' '); +void idf_input_string(std::istream &in, std::string &str); -void idf_output_string(ostream &out, const char *str, char whitespace = ' '); -void idf_input_string(istream &in, const char *&str); +void idf_output_string(std::ostream &out, const char *str, char whitespace = ' '); +void idf_input_string(std::istream &in, const char *&str); template -void idf_output_vector(ostream &out, const std::vector &vec); +void idf_output_vector(std::ostream &out, const std::vector &vec); template -void idf_input_vector(istream &in, std::vector &vec); +void idf_input_vector(std::istream &in, std::vector &vec); #include "interrogate_datafile.I" diff --git a/dtool/src/interrogatedb/py_panda.h b/dtool/src/interrogatedb/py_panda.h index ffa6de94c8..ed6d063e03 100644 --- a/dtool/src/interrogatedb/py_panda.h +++ b/dtool/src/interrogatedb/py_panda.h @@ -130,7 +130,7 @@ static void Dtool_FreeInstance_##CLASS_NAME(PyObject *self) {\ static void Dtool_FreeInstance_##CLASS_NAME(PyObject *self) {\ if (DtoolInstance_VOID_PTR(self) != nullptr) {\ if (((Dtool_PyInstDef *)self)->_memory_rules) {\ - cerr << "Detected leak for " << #CLASS_NAME \ + std::cerr << "Detected leak for " << #CLASS_NAME \ << " which interrogate cannot delete.\n"; \ }\ }\ @@ -180,10 +180,10 @@ static void Dtool_FreeInstance_##CLASS_NAME(PyObject *self) {\ // forward declared of typed object. We rely on the fact that typed objects // are uniquly defined by an integer. -EXPCL_INTERROGATEDB void RegisterNamedClass(const string &name, Dtool_PyTypedObject &otype); +EXPCL_INTERROGATEDB void RegisterNamedClass(const std::string &name, Dtool_PyTypedObject &otype); EXPCL_INTERROGATEDB void RegisterRuntimeTypedClass(Dtool_PyTypedObject &otype); -EXPCL_INTERROGATEDB Dtool_PyTypedObject *LookupNamedClass(const string &name); +EXPCL_INTERROGATEDB Dtool_PyTypedObject *LookupNamedClass(const std::string &name); EXPCL_INTERROGATEDB Dtool_PyTypedObject *LookupRuntimeTypedClass(TypeHandle handle); EXPCL_INTERROGATEDB Dtool_PyTypedObject *Dtool_RuntimeTypeDtoolType(int type); @@ -193,7 +193,7 @@ EXPCL_INTERROGATEDB Dtool_PyTypedObject *Dtool_RuntimeTypeDtoolType(int type); */ EXPCL_INTERROGATEDB void DTOOL_Call_ExtractThisPointerForType(PyObject *self, Dtool_PyTypedObject *classdef, void **answer); -EXPCL_INTERROGATEDB void *DTOOL_Call_GetPointerThisClass(PyObject *self, Dtool_PyTypedObject *classdef, int param, const string &function_name, bool const_ok, bool report_errors); +EXPCL_INTERROGATEDB void *DTOOL_Call_GetPointerThisClass(PyObject *self, Dtool_PyTypedObject *classdef, int param, const std::string &function_name, bool const_ok, bool report_errors); EXPCL_INTERROGATEDB void *DTOOL_Call_GetPointerThis(PyObject *self); diff --git a/dtool/src/parser-inc/stdcompare.h b/dtool/src/parser-inc/stdcompare.h index 09c0b7d388..bbcc1bf694 100644 --- a/dtool/src/parser-inc/stdcompare.h +++ b/dtool/src/parser-inc/stdcompare.h @@ -24,7 +24,7 @@ class less { public: }; -template > +template > class hash_compare { public: }; diff --git a/dtool/src/prc/androidLogStream.h b/dtool/src/prc/androidLogStream.h index a565a348a3..aa50c8d7af 100644 --- a/dtool/src/prc/androidLogStream.h +++ b/dtool/src/prc/androidLogStream.h @@ -25,9 +25,9 @@ /** * This is a type of ostream that writes each line to the Android log. */ -class AndroidLogStream : public ostream { +class AndroidLogStream : public std::ostream { private: - class AndroidLogStreamBuf : public streambuf { + class AndroidLogStreamBuf : public std::streambuf { public: AndroidLogStreamBuf(int priority); virtual ~AndroidLogStreamBuf(); @@ -40,15 +40,15 @@ private: void write_char(char c); int _priority; - string _tag; - string _data; + std::string _tag; + std::string _data; }; AndroidLogStream(int priority); public: virtual ~AndroidLogStream(); - static ostream &out(NotifySeverity severity); + static std::ostream &out(NotifySeverity severity); }; #endif // ANDROID diff --git a/dtool/src/prc/configDeclaration.I b/dtool/src/prc/configDeclaration.I index a93fbdab10..670f49e38a 100644 --- a/dtool/src/prc/configDeclaration.I +++ b/dtool/src/prc/configDeclaration.I @@ -49,7 +49,7 @@ get_variable() const { * text defined for the variable in the .prc file (or passed to * ConfigPage::make_declaration()). */ -INLINE const string &ConfigDeclaration:: +INLINE const std::string &ConfigDeclaration:: get_string_value() const { return _string_value; } @@ -58,7 +58,7 @@ get_string_value() const { * Changes the value assigned to this variable. */ INLINE void ConfigDeclaration:: -set_string_value(const string &string_value) { +set_string_value(const std::string &string_value) { _string_value = string_value; _got_words = false; invalidate_cache(); @@ -145,12 +145,12 @@ has_double_word(size_t n) const { * Returns the string value of the nth word of the declaration's value, or * empty string if there is no nth value. See also has_string_word(). */ -INLINE string ConfigDeclaration:: +INLINE std::string ConfigDeclaration:: get_string_word(size_t n) const { if (has_string_word(n)) { return _words[n]._str; } - return string(); + return std::string(); } /** @@ -225,8 +225,8 @@ get_decl_seq() const { return _decl_seq; } -INLINE ostream & -operator << (ostream &out, const ConfigDeclaration &decl) { +INLINE std::ostream & +operator << (std::ostream &out, const ConfigDeclaration &decl) { decl.output(out); return out; } diff --git a/dtool/src/prc/configDeclaration.h b/dtool/src/prc/configDeclaration.h index 1e6c50ee12..38129670d5 100644 --- a/dtool/src/prc/configDeclaration.h +++ b/dtool/src/prc/configDeclaration.h @@ -33,7 +33,7 @@ class ConfigVariableCore; class EXPCL_DTOOL_PRC ConfigDeclaration : public ConfigFlags { private: ConfigDeclaration(ConfigPage *page, ConfigVariableCore *variable, - const string &string_value, int decl_seq); + const std::string &string_value, int decl_seq); ~ConfigDeclaration(); public: @@ -45,8 +45,8 @@ PUBLISHED: MAKE_PROPERTY(page, get_page); MAKE_PROPERTY(variable, get_variable); - INLINE const string &get_string_value() const; - INLINE void set_string_value(const string &value); + INLINE const std::string &get_string_value() const; + INLINE void set_string_value(const std::string &value); INLINE size_t get_num_words() const; @@ -56,13 +56,13 @@ PUBLISHED: INLINE bool has_int64_word(size_t n) const; INLINE bool has_double_word(size_t n) const; - INLINE string get_string_word(size_t n) const; + INLINE std::string get_string_word(size_t n) const; INLINE bool get_bool_word(size_t n) const; INLINE int get_int_word(size_t n) const; INLINE int64_t get_int64_word(size_t n) const; INLINE double get_double_word(size_t n) const; - void set_string_word(size_t n, const string &value); + void set_string_word(size_t n, const std::string &value); void set_bool_word(size_t n, bool value); void set_int_word(size_t n, int value); void set_int64_word(size_t n, int64_t value); @@ -70,12 +70,12 @@ PUBLISHED: INLINE int get_decl_seq() const; - void output(ostream &out) const; - void write(ostream &out) const; + void output(std::ostream &out) const; + void write(std::ostream &out) const; public: - static size_t extract_words(const string &str, vector_string &words); - static string downcase(const string &s); + static size_t extract_words(const std::string &str, vector_string &words); + static std::string downcase(const std::string &s); private: void get_words(); @@ -87,7 +87,7 @@ private: private: ConfigPage *_page; ConfigVariableCore *_variable; - string _string_value; + std::string _string_value; int _decl_seq; enum WordFlags { @@ -103,7 +103,7 @@ private: class Word { public: - string _str; + std::string _str; bool _bool; int _int; int64_t _int_64; @@ -118,7 +118,7 @@ private: friend class ConfigPage; }; -INLINE ostream &operator << (ostream &out, const ConfigDeclaration &decl); +INLINE std::ostream &operator << (std::ostream &out, const ConfigDeclaration &decl); #include "configDeclaration.I" diff --git a/dtool/src/prc/configFlags.h b/dtool/src/prc/configFlags.h index 23dfd3fb30..f4b95757d6 100644 --- a/dtool/src/prc/configFlags.h +++ b/dtool/src/prc/configFlags.h @@ -67,7 +67,7 @@ private: static TVOLATILE AtomicAdjust::Integer _global_modified; }; -ostream &operator << (ostream &out, ConfigFlags::ValueType type); +std::ostream &operator << (std::ostream &out, ConfigFlags::ValueType type); #include "configFlags.I" diff --git a/dtool/src/prc/configPage.I b/dtool/src/prc/configPage.I index e4ed5ccf60..2624f6a60b 100644 --- a/dtool/src/prc/configPage.I +++ b/dtool/src/prc/configPage.I @@ -33,7 +33,7 @@ operator < (const ConfigPage &other) const { * Returns the name of the page. If the page was loaded from a .prc file, * this is usually the filename. */ -INLINE const string &ConfigPage:: +INLINE const std::string &ConfigPage:: get_name() const { return _name; } @@ -109,7 +109,7 @@ set_trust_level(int trust_level) { * Returns the raw binary signature that was found in the prc file, if any. * This method is probably not terribly useful for most applications. */ -INLINE const string &ConfigPage:: +INLINE const std::string &ConfigPage:: get_signature() const { return _signature; } @@ -124,8 +124,8 @@ make_dirty() { _trust_level = 0; } -INLINE ostream & -operator << (ostream &out, const ConfigPage &page) { +INLINE std::ostream & +operator << (std::ostream &out, const ConfigPage &page) { page.output(out); return out; } diff --git a/dtool/src/prc/configPage.h b/dtool/src/prc/configPage.h index e6cdb9ed0d..8dd0d822c1 100644 --- a/dtool/src/prc/configPage.h +++ b/dtool/src/prc/configPage.h @@ -29,7 +29,7 @@ class ConfigVariableCore; */ class EXPCL_DTOOL_PRC ConfigPage { private: - ConfigPage(const string &name, bool implicit_load, int page_seq); + ConfigPage(const std::string &name, bool implicit_load, int page_seq); ~ConfigPage(); public: @@ -39,7 +39,7 @@ PUBLISHED: static ConfigPage *get_default_page(); static ConfigPage *get_local_page(); - INLINE const string &get_name() const; + INLINE const std::string &get_name() const; MAKE_PROPERTY(name, get_name); INLINE bool is_special() const; @@ -54,38 +54,38 @@ PUBLISHED: INLINE int get_page_seq() const; INLINE int get_trust_level() const; INLINE void set_trust_level(int trust_level); - INLINE const string &get_signature() const; + INLINE const std::string &get_signature() const; MAKE_PROPERTY(page_seq, get_page_seq); MAKE_PROPERTY(trust_level, get_trust_level, set_trust_level); MAKE_PROPERTY(signature, get_signature); void clear(); - bool read_prc(istream &in); - bool read_encrypted_prc(istream &in, const string &password); + bool read_prc(std::istream &in); + bool read_encrypted_prc(std::istream &in, const std::string &password); - ConfigDeclaration *make_declaration(const string &variable, const string &value); - ConfigDeclaration *make_declaration(ConfigVariableCore *variable, const string &value); + ConfigDeclaration *make_declaration(const std::string &variable, const std::string &value); + ConfigDeclaration *make_declaration(ConfigVariableCore *variable, const std::string &value); bool delete_declaration(ConfigDeclaration *decl); size_t get_num_declarations() const; const ConfigDeclaration *get_declaration(size_t n) const; ConfigDeclaration *modify_declaration(size_t n); - string get_variable_name(size_t n) const; - string get_string_value(size_t n) const; + std::string get_variable_name(size_t n) const; + std::string get_string_value(size_t n) const; bool is_variable_used(size_t n) const; MAKE_SEQ_PROPERTY(declarations, get_num_declarations, modify_declaration); - void output(ostream &out) const; - void output_brief_signature(ostream &out) const; - void write(ostream &out) const; + void output(std::ostream &out) const; + void output_brief_signature(std::ostream &out) const; + void write(std::ostream &out) const; private: INLINE void make_dirty(); - void read_prc_line(const string &line); + void read_prc_line(const std::string &line); static unsigned int hex_digit(unsigned char digit); - string _name; + std::string _name; bool _implicit_load; int _page_seq; int _sort; @@ -95,7 +95,7 @@ private: typedef std::vector Declarations; Declarations _declarations; - string _signature; + std::string _signature; #ifdef HAVE_OPENSSL // This maintains the hash of the prc file as we are scanning it, so we can @@ -109,7 +109,7 @@ private: friend class ConfigPageManager; }; -INLINE ostream &operator << (ostream &out, const ConfigPage &page); +INLINE std::ostream &operator << (std::ostream &out, const ConfigPage &page); #include "configPage.I" diff --git a/dtool/src/prc/configPageManager.I b/dtool/src/prc/configPageManager.I index cd95cce50f..30e6c64950 100644 --- a/dtool/src/prc/configPageManager.I +++ b/dtool/src/prc/configPageManager.I @@ -60,9 +60,9 @@ get_num_prc_patterns() const { * Returns the nth filename pattern that will be considered a match as a valid * config file. See get_num_prc_patterns(). */ -INLINE string ConfigPageManager:: +INLINE std::string ConfigPageManager:: get_prc_pattern(size_t n) const { - nassertr(n < _prc_patterns.size(), string()); + nassertr(n < _prc_patterns.size(), std::string()); return _prc_patterns[n].get_pattern(); } @@ -80,9 +80,9 @@ get_num_prc_encrypted_patterns() const { * Returns the nth filename pattern that will be considered a match as a valid * encrypted config file. See get_num_prc_encrypted_patterns(). */ -INLINE string ConfigPageManager:: +INLINE std::string ConfigPageManager:: get_prc_encrypted_pattern(size_t n) const { - nassertr(n < _prc_patterns.size(), string()); + nassertr(n < _prc_patterns.size(), std::string()); return _prc_encrypted_patterns[n].get_pattern(); } @@ -100,9 +100,9 @@ get_num_prc_executable_patterns() const { * Returns the nth filename pattern that will be considered a match as a valid * executable-style config file. See get_num_prc_executable_patterns(). */ -INLINE string ConfigPageManager:: +INLINE std::string ConfigPageManager:: get_prc_executable_pattern(size_t n) const { - nassertr(n < _prc_patterns.size(), string()); + nassertr(n < _prc_patterns.size(), std::string()); return _prc_executable_patterns[n].get_pattern(); } @@ -169,8 +169,8 @@ check_sort_pages() const { } } -INLINE ostream & -operator << (ostream &out, const ConfigPageManager &pageMgr) { +INLINE std::ostream & +operator << (std::ostream &out, const ConfigPageManager &pageMgr) { pageMgr.output(out); return out; } diff --git a/dtool/src/prc/configPageManager.h b/dtool/src/prc/configPageManager.h index dd6acc3f99..5afba59796 100644 --- a/dtool/src/prc/configPageManager.h +++ b/dtool/src/prc/configPageManager.h @@ -41,15 +41,15 @@ PUBLISHED: INLINE DSearchPath &get_search_path(); INLINE size_t get_num_prc_patterns() const; - INLINE string get_prc_pattern(size_t n) const; + INLINE std::string get_prc_pattern(size_t n) const; INLINE size_t get_num_prc_encrypted_patterns() const; - INLINE string get_prc_encrypted_pattern(size_t n) const; + INLINE std::string get_prc_encrypted_pattern(size_t n) const; INLINE size_t get_num_prc_executable_patterns() const; - INLINE string get_prc_executable_pattern(size_t n) const; + INLINE std::string get_prc_executable_pattern(size_t n) const; - ConfigPage *make_explicit_page(const string &name); + ConfigPage *make_explicit_page(const std::string &name); bool delete_explicit_page(ConfigPage *page); INLINE size_t get_num_implicit_pages() const; @@ -58,8 +58,8 @@ PUBLISHED: INLINE size_t get_num_explicit_pages() const; INLINE ConfigPage *get_explicit_page(size_t n) const; - void output(ostream &out) const; - void write(ostream &out) const; + void output(std::ostream &out) const; + void write(std::ostream &out) const; static ConfigPageManager *get_global_ptr(); @@ -110,7 +110,7 @@ private: static ConfigPageManager *_global_ptr; }; -INLINE ostream &operator << (ostream &out, const ConfigPageManager &pageMgr); +INLINE std::ostream &operator << (std::ostream &out, const ConfigPageManager &pageMgr); #include "configPageManager.I" diff --git a/dtool/src/prc/configVariable.I b/dtool/src/prc/configVariable.I index 92842ab0dd..53d73ff4c8 100644 --- a/dtool/src/prc/configVariable.I +++ b/dtool/src/prc/configVariable.I @@ -16,7 +16,7 @@ * ConfigVariableFoo derived class. */ INLINE ConfigVariable:: -ConfigVariable(const string &name, ConfigVariable::ValueType value_type) : +ConfigVariable(const std::string &name, ConfigVariable::ValueType value_type) : ConfigVariableBase(name, value_type) { } @@ -26,8 +26,8 @@ ConfigVariable(const string &name, ConfigVariable::ValueType value_type) : * ConfigVariableFoo derived class. */ INLINE ConfigVariable:: -ConfigVariable(const string &name, ConfigVariable::ValueType value_type, - const string &description, int flags) : +ConfigVariable(const std::string &name, ConfigVariable::ValueType value_type, + const std::string &description, int flags) : ConfigVariableBase(name, value_type, description, flags) { } @@ -38,7 +38,7 @@ ConfigVariable(const string &name, ConfigVariable::ValueType value_type, * ConfigVariable of a specific type, without having to know what type it is. */ INLINE ConfigVariable:: -ConfigVariable(const string &name) : +ConfigVariable(const std::string &name) : ConfigVariableBase(name, VT_undefined) { _core->set_used(); @@ -64,9 +64,9 @@ get_default_value() const { /** * Returns the toplevel value of the variable, formatted as a string. */ -INLINE const string &ConfigVariable:: +INLINE const std::string &ConfigVariable:: get_string_value() const { - nassertr(is_constructed(), *new string()); + nassertr(is_constructed(), *new std::string()); const ConfigDeclaration *decl = _core->get_declaration(0); return decl->get_string_value(); } @@ -77,7 +77,7 @@ get_string_value() const { * clear_local_value() is called. */ INLINE void ConfigVariable:: -set_string_value(const string &string_value) { +set_string_value(const std::string &string_value) { nassertv(is_constructed()); _core->make_local_value()->set_string_value(string_value); } @@ -163,9 +163,9 @@ has_double_word(size_t n) const { * Returns the string value of the nth word of the variable's value, or empty * string if there is no nth value. See also has_string_word(). */ -INLINE string ConfigVariable:: +INLINE std::string ConfigVariable:: get_string_word(size_t n) const { - nassertr(is_constructed(), string()); + nassertr(is_constructed(), std::string()); const ConfigDeclaration *decl = _core->get_declaration(0); return decl->get_string_word(n); } @@ -219,7 +219,7 @@ get_double_word(size_t n) const { * words. */ INLINE void ConfigVariable:: -set_string_word(size_t n, const string &value) { +set_string_word(size_t n, const std::string &value) { nassertv(is_constructed()); _core->make_local_value()->set_string_word(n, value); } diff --git a/dtool/src/prc/configVariable.h b/dtool/src/prc/configVariable.h index c4f6d20527..c07f12e453 100644 --- a/dtool/src/prc/configVariable.h +++ b/dtool/src/prc/configVariable.h @@ -30,16 +30,16 @@ */ class EXPCL_DTOOL_PRC ConfigVariable : public ConfigVariableBase { protected: - INLINE ConfigVariable(const string &name, ValueType type); - INLINE ConfigVariable(const string &name, ValueType type, - const string &description, int flags); + INLINE ConfigVariable(const std::string &name, ValueType type); + INLINE ConfigVariable(const std::string &name, ValueType type, + const std::string &description, int flags); PUBLISHED: - INLINE explicit ConfigVariable(const string &name); + INLINE explicit ConfigVariable(const std::string &name); INLINE ~ConfigVariable(); - INLINE const string &get_string_value() const; - INLINE void set_string_value(const string &value); + INLINE const std::string &get_string_value() const; + INLINE void set_string_value(const std::string &value); INLINE void clear_value(); INLINE size_t get_num_words() const; @@ -53,13 +53,13 @@ protected: INLINE bool has_int64_word(size_t n) const; INLINE bool has_double_word(size_t n) const; - INLINE string get_string_word(size_t n) const; + INLINE std::string get_string_word(size_t n) const; INLINE bool get_bool_word(size_t n) const; INLINE int get_int_word(size_t n) const; INLINE int64_t get_int64_word(size_t n) const; INLINE double get_double_word(size_t n) const; - INLINE void set_string_word(size_t n, const string &value); + INLINE void set_string_word(size_t n, const std::string &value); INLINE void set_bool_word(size_t n, bool value); INLINE void set_int_word(size_t n, int value); INLINE void set_int64_word(size_t n, int64_t value); diff --git a/dtool/src/prc/configVariableBase.I b/dtool/src/prc/configVariableBase.I index 29bf58f72a..e57bceeb21 100644 --- a/dtool/src/prc/configVariableBase.I +++ b/dtool/src/prc/configVariableBase.I @@ -16,7 +16,7 @@ * ConfigVariableFoo derived class. */ INLINE ConfigVariableBase:: -ConfigVariableBase(const string &name, +ConfigVariableBase(const std::string &name, ConfigVariableBase::ValueType value_type) : _core(ConfigVariableManager::get_global_ptr()->make_variable(name)) { @@ -35,9 +35,9 @@ INLINE ConfigVariableBase:: /** * Returns the name of the variable. */ -INLINE const string &ConfigVariableBase:: +INLINE const std::string &ConfigVariableBase:: get_name() const { - nassertr(_core != nullptr, *new string()); + nassertr(_core != nullptr, *new std::string()); return _core->get_name(); } @@ -54,9 +54,9 @@ get_value_type() const { /** * Returns the brief description of this variable, if it has been defined. */ -INLINE const string &ConfigVariableBase:: +INLINE const std::string &ConfigVariableBase:: get_description() const { - nassertr(_core != nullptr, *new string()); + nassertr(_core != nullptr, *new std::string()); return _core->get_description(); } @@ -151,7 +151,7 @@ has_value() const { * */ INLINE void ConfigVariableBase:: -output(ostream &out) const { +output(std::ostream &out) const { nassertv(_core != nullptr); _core->output(out); } @@ -160,13 +160,13 @@ output(ostream &out) const { * */ INLINE void ConfigVariableBase:: -write(ostream &out) const { +write(std::ostream &out) const { nassertv(_core != nullptr); _core->write(out); } -INLINE ostream & -operator << (ostream &out, const ConfigVariableBase &variable) { +INLINE std::ostream & +operator << (std::ostream &out, const ConfigVariableBase &variable) { variable.output(out); return out; } diff --git a/dtool/src/prc/configVariableBase.h b/dtool/src/prc/configVariableBase.h index 8bc51a7431..ac256f1e8d 100644 --- a/dtool/src/prc/configVariableBase.h +++ b/dtool/src/prc/configVariableBase.h @@ -44,16 +44,16 @@ */ class EXPCL_DTOOL_PRC ConfigVariableBase : public ConfigFlags { protected: - INLINE ConfigVariableBase(const string &name, ValueType type); - ConfigVariableBase(const string &name, ValueType type, - const string &description, int flags); + INLINE ConfigVariableBase(const std::string &name, ValueType type); + ConfigVariableBase(const std::string &name, ValueType type, + const std::string &description, int flags); INLINE ~ConfigVariableBase(); PUBLISHED: - INLINE const string &get_name() const; + INLINE const std::string &get_name() const; INLINE ValueType get_value_type() const; - INLINE const string &get_description() const; + INLINE const std::string &get_description() const; INLINE int get_flags() const; INLINE bool is_closed() const; INLINE int get_trust_level() const; @@ -70,8 +70,8 @@ PUBLISHED: INLINE bool has_local_value() const; INLINE bool has_value() const; - INLINE void output(ostream &out) const; - INLINE void write(ostream &out) const; + INLINE void output(std::ostream &out) const; + INLINE void write(std::ostream &out) const; protected: void record_unconstructed() const; @@ -83,7 +83,7 @@ protected: static Unconstructed *_unconstructed; }; -INLINE ostream &operator << (ostream &out, const ConfigVariableBase &variable); +INLINE std::ostream &operator << (std::ostream &out, const ConfigVariableBase &variable); #include "configVariableBase.I" diff --git a/dtool/src/prc/configVariableBool.I b/dtool/src/prc/configVariableBool.I index 25c9e833f1..8551815e67 100644 --- a/dtool/src/prc/configVariableBool.I +++ b/dtool/src/prc/configVariableBool.I @@ -15,7 +15,7 @@ * */ INLINE ConfigVariableBool:: -ConfigVariableBool(const string &name) : +ConfigVariableBool(const std::string &name) : ConfigVariable(name, VT_bool), _local_modified(initial_invalid_cache()) { @@ -26,12 +26,12 @@ ConfigVariableBool(const string &name) : * */ INLINE ConfigVariableBool:: -ConfigVariableBool(const string &name, bool default_value, - const string &description, int flags) : +ConfigVariableBool(const std::string &name, bool default_value, + const std::string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, VT_bool, description, flags), #else - ConfigVariable(name, VT_bool, string(), flags), + ConfigVariable(name, VT_bool, std::string(), flags), #endif _local_modified(initial_invalid_cache()) { @@ -43,12 +43,12 @@ ConfigVariableBool(const string &name, bool default_value, * */ INLINE ConfigVariableBool:: -ConfigVariableBool(const string &name, const string &default_value, - const string &description, int flags) : +ConfigVariableBool(const std::string &name, const std::string &default_value, + const std::string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, VT_bool, description, flags), #else - ConfigVariable(name, VT_bool, string(), flags), + ConfigVariable(name, VT_bool, std::string(), flags), #endif _local_modified(initial_invalid_cache()) { diff --git a/dtool/src/prc/configVariableBool.h b/dtool/src/prc/configVariableBool.h index c955b6b16f..c2c4da14c7 100644 --- a/dtool/src/prc/configVariableBool.h +++ b/dtool/src/prc/configVariableBool.h @@ -22,11 +22,11 @@ */ class EXPCL_DTOOL_PRC ConfigVariableBool : public ConfigVariable { PUBLISHED: - INLINE ConfigVariableBool(const string &name); - INLINE ConfigVariableBool(const string &name, bool default_value, - const string &description = string(), int flags = 0); - INLINE ConfigVariableBool(const string &name, const string &default_value, - const string &description = string(), int flags = 0); + INLINE ConfigVariableBool(const std::string &name); + INLINE ConfigVariableBool(const std::string &name, bool default_value, + const std::string &description = std::string(), int flags = 0); + INLINE ConfigVariableBool(const std::string &name, const std::string &default_value, + const std::string &description = std::string(), int flags = 0); INLINE void operator = (bool value); ALWAYS_INLINE operator bool () const; diff --git a/dtool/src/prc/configVariableCore.I b/dtool/src/prc/configVariableCore.I index 95f8829a2a..4cb0d05108 100644 --- a/dtool/src/prc/configVariableCore.I +++ b/dtool/src/prc/configVariableCore.I @@ -14,7 +14,7 @@ /** * Returns the name of the variable. */ -INLINE const string &ConfigVariableCore:: +INLINE const std::string &ConfigVariableCore:: get_name() const { return _name; } @@ -40,7 +40,7 @@ get_value_type() const { /** * Returns the brief description of this variable, if it has been defined. */ -INLINE const string &ConfigVariableCore:: +INLINE const std::string &ConfigVariableCore:: get_description() const { return _description; } @@ -208,8 +208,8 @@ check_sort_declarations() const { } } -INLINE ostream & -operator << (ostream &out, const ConfigVariableCore &variable) { +INLINE std::ostream & +operator << (std::ostream &out, const ConfigVariableCore &variable) { variable.output(out); return out; } diff --git a/dtool/src/prc/configVariableCore.h b/dtool/src/prc/configVariableCore.h index 6e8ce7ace9..8849cc401b 100644 --- a/dtool/src/prc/configVariableCore.h +++ b/dtool/src/prc/configVariableCore.h @@ -33,16 +33,16 @@ class ConfigDeclaration; */ class EXPCL_DTOOL_PRC ConfigVariableCore : public ConfigFlags { private: - ConfigVariableCore(const string &name); - ConfigVariableCore(const ConfigVariableCore &templ, const string &name); + ConfigVariableCore(const std::string &name); + ConfigVariableCore(const ConfigVariableCore &templ, const std::string &name); ~ConfigVariableCore(); PUBLISHED: - INLINE const string &get_name() const; + INLINE const std::string &get_name() const; INLINE bool is_used() const; INLINE ValueType get_value_type() const; - INLINE const string &get_description() const; + INLINE const std::string &get_description() const; INLINE int get_flags() const; INLINE bool is_closed() const; INLINE int get_trust_level() const; @@ -51,8 +51,8 @@ PUBLISHED: void set_value_type(ValueType value_type); void set_flags(int flags); - void set_description(const string &description); - void set_default_value(const string &default_value); + void set_description(const std::string &description); + void set_default_value(const std::string &default_value); INLINE void set_used(); ConfigDeclaration *make_local_value(); @@ -77,8 +77,8 @@ PUBLISHED: MAKE_SEQ(get_unique_references, get_num_unique_references, get_unique_reference); MAKE_SEQ_PROPERTY(declarations, get_num_declarations, get_declaration); - void output(ostream &out) const; - void write(ostream &out) const; + void output(std::ostream &out) const; + void write(std::ostream &out) const; MAKE_PROPERTY(name, get_name); MAKE_PROPERTY(used, is_used); @@ -102,10 +102,10 @@ private: void sort_declarations(); private: - string _name; + std::string _name; bool _is_used; ValueType _value_type; - string _description; + std::string _description; int _flags; ConfigDeclaration *_default_value; ConfigDeclaration *_local_value; @@ -122,7 +122,7 @@ private: friend class ConfigVariableManager; }; -INLINE ostream &operator << (ostream &out, const ConfigVariableCore &variable); +INLINE std::ostream &operator << (std::ostream &out, const ConfigVariableCore &variable); #include "configVariableCore.I" diff --git a/dtool/src/prc/configVariableDouble.I b/dtool/src/prc/configVariableDouble.I index e93f39830e..3075591c0f 100644 --- a/dtool/src/prc/configVariableDouble.I +++ b/dtool/src/prc/configVariableDouble.I @@ -15,7 +15,7 @@ * */ INLINE ConfigVariableDouble:: -ConfigVariableDouble(const string &name) : +ConfigVariableDouble(const std::string &name) : ConfigVariable(name, VT_double), _local_modified(initial_invalid_cache()) { @@ -26,12 +26,12 @@ ConfigVariableDouble(const string &name) : * */ INLINE ConfigVariableDouble:: -ConfigVariableDouble(const string &name, double default_value, - const string &description, int flags) : +ConfigVariableDouble(const std::string &name, double default_value, + const std::string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, ConfigVariableCore::VT_double, description, flags), #else - ConfigVariable(name, ConfigVariableCore::VT_double, string(), flags), + ConfigVariable(name, ConfigVariableCore::VT_double, std::string(), flags), #endif _local_modified(initial_invalid_cache()) { @@ -43,12 +43,12 @@ ConfigVariableDouble(const string &name, double default_value, * */ INLINE ConfigVariableDouble:: -ConfigVariableDouble(const string &name, const string &default_value, - const string &description, int flags) : +ConfigVariableDouble(const std::string &name, const std::string &default_value, + const std::string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, ConfigVariableCore::VT_double, description, flags), #else - ConfigVariable(name, ConfigVariableCore::VT_double, string(), flags), + ConfigVariable(name, ConfigVariableCore::VT_double, std::string(), flags), #endif _local_modified(initial_invalid_cache()) { diff --git a/dtool/src/prc/configVariableDouble.h b/dtool/src/prc/configVariableDouble.h index 49e9585475..12332016ec 100644 --- a/dtool/src/prc/configVariableDouble.h +++ b/dtool/src/prc/configVariableDouble.h @@ -23,12 +23,12 @@ */ class EXPCL_DTOOL_PRC ConfigVariableDouble : public ConfigVariable { PUBLISHED: - INLINE ConfigVariableDouble(const string &name); - INLINE ConfigVariableDouble(const string &name, double default_value, - const string &description = string(), + INLINE ConfigVariableDouble(const std::string &name); + INLINE ConfigVariableDouble(const std::string &name, double default_value, + const std::string &description = std::string(), int flags = 0); - INLINE ConfigVariableDouble(const string &name, const string &default_value, - const string &description = string(), + INLINE ConfigVariableDouble(const std::string &name, const std::string &default_value, + const std::string &description = std::string(), int flags = 0); INLINE void operator = (double value); diff --git a/dtool/src/prc/configVariableEnum.I b/dtool/src/prc/configVariableEnum.I index 6ae9327119..a13076e794 100644 --- a/dtool/src/prc/configVariableEnum.I +++ b/dtool/src/prc/configVariableEnum.I @@ -16,12 +16,12 @@ */ template INLINE ConfigVariableEnum:: -ConfigVariableEnum(const string &name, EnumType default_value, - const string &description, int flags) : +ConfigVariableEnum(const std::string &name, EnumType default_value, + const std::string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, ConfigVariableCore::VT_enum, description, flags), #else - ConfigVariable(name, ConfigVariableCore::VT_enum, string(), flags), + ConfigVariable(name, ConfigVariableCore::VT_enum, std::string(), flags), #endif _got_default_value(true), _default_value(default_value), @@ -36,12 +36,12 @@ ConfigVariableEnum(const string &name, EnumType default_value, */ template INLINE ConfigVariableEnum:: -ConfigVariableEnum(const string &name, const string &default_value, - const string &description, int flags) : +ConfigVariableEnum(const std::string &name, const std::string &default_value, + const std::string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, ConfigVariableCore::VT_enum, description, flags), #else - ConfigVariable(name, ConfigVariableCore::VT_enum, string(), flags), + ConfigVariable(name, ConfigVariableCore::VT_enum, std::string(), flags), #endif _got_default_value(true), _default_value(parse_string(default_value)), @@ -159,8 +159,8 @@ set_word(size_t n, EnumType value) { */ template INLINE EnumType ConfigVariableEnum:: -parse_string(const string &value) const { - istringstream strm(value); +parse_string(const std::string &value) const { + std::istringstream strm(value); EnumType result; strm >> result; return result; @@ -172,9 +172,9 @@ parse_string(const string &value) const { * operator. */ template -INLINE string ConfigVariableEnum:: +INLINE std::string ConfigVariableEnum:: format_enum(EnumType value) const { - ostringstream strm; + std::ostringstream strm; strm << value; return strm.str(); } diff --git a/dtool/src/prc/configVariableEnum.h b/dtool/src/prc/configVariableEnum.h index 81f5c91a09..80aaf23b65 100644 --- a/dtool/src/prc/configVariableEnum.h +++ b/dtool/src/prc/configVariableEnum.h @@ -30,11 +30,11 @@ template class ConfigVariableEnum : public ConfigVariable { public: - INLINE ConfigVariableEnum(const string &name, EnumType default_value, - const string &description = string(), + INLINE ConfigVariableEnum(const std::string &name, EnumType default_value, + const std::string &description = std::string(), int flags = 0); - INLINE ConfigVariableEnum(const string &name, const string &default_value, - const string &description = string(), + INLINE ConfigVariableEnum(const std::string &name, const std::string &default_value, + const std::string &description = std::string(), int flags = 0); INLINE ~ConfigVariableEnum(); @@ -54,8 +54,8 @@ public: INLINE void set_word(size_t n, EnumType value); private: - INLINE EnumType parse_string(const string &value) const; - INLINE string format_enum(EnumType value) const; + INLINE EnumType parse_string(const std::string &value) const; + INLINE std::string format_enum(EnumType value) const; private: bool _got_default_value; diff --git a/dtool/src/prc/configVariableFilename.I b/dtool/src/prc/configVariableFilename.I index 8e6ca228b3..51013ddfcf 100644 --- a/dtool/src/prc/configVariableFilename.I +++ b/dtool/src/prc/configVariableFilename.I @@ -15,7 +15,7 @@ * */ INLINE ConfigVariableFilename:: -ConfigVariableFilename(const string &name) : +ConfigVariableFilename(const std::string &name) : ConfigVariable(name, VT_filename), _local_modified(initial_invalid_cache()) { @@ -26,12 +26,12 @@ ConfigVariableFilename(const string &name) : * */ INLINE ConfigVariableFilename:: -ConfigVariableFilename(const string &name, const Filename &default_value, - const string &description, int flags) : +ConfigVariableFilename(const std::string &name, const Filename &default_value, + const std::string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, VT_filename, description, flags), #else - ConfigVariable(name, VT_filename, string(), flags), + ConfigVariable(name, VT_filename, std::string(), flags), #endif _local_modified(initial_invalid_cache()) { @@ -93,7 +93,7 @@ operator [] (size_t n) const { * same thing returned by the string typecast operator, so this function is a * little redundant. */ -INLINE string ConfigVariableFilename:: +INLINE std::string ConfigVariableFilename:: get_fullpath() const { return get_ref_value().get_fullpath(); } @@ -102,7 +102,7 @@ get_fullpath() const { * Returns the directory part of the filename. This is everything in the * filename up to, but not including the rightmost slash. */ -INLINE string ConfigVariableFilename:: +INLINE std::string ConfigVariableFilename:: get_dirname() const { return get_ref_value().get_dirname(); } @@ -111,7 +111,7 @@ get_dirname() const { * Returns the basename part of the filename. This is everything in the * filename after the rightmost slash, including any extensions. */ -INLINE string ConfigVariableFilename:: +INLINE std::string ConfigVariableFilename:: get_basename() const { return get_ref_value().get_basename(); } @@ -121,7 +121,7 @@ get_basename() const { * Returns the full filename--directory and basename parts--except for the * extension. */ -INLINE string ConfigVariableFilename:: +INLINE std::string ConfigVariableFilename:: get_fullpath_wo_extension() const { return get_ref_value().get_fullpath_wo_extension(); } @@ -130,7 +130,7 @@ get_fullpath_wo_extension() const { /** * Returns the basename part of the filename, without the file extension. */ -INLINE string ConfigVariableFilename:: +INLINE std::string ConfigVariableFilename:: get_basename_wo_extension() const { return get_ref_value().get_basename_wo_extension(); } @@ -140,7 +140,7 @@ get_basename_wo_extension() const { * Returns the file extension. This is everything after the rightmost dot, if * there is one, or the empty string if there is not. */ -INLINE string ConfigVariableFilename:: +INLINE std::string ConfigVariableFilename:: get_extension() const { return get_ref_value().get_extension(); } diff --git a/dtool/src/prc/configVariableFilename.h b/dtool/src/prc/configVariableFilename.h index 6feb82a24a..7537e22117 100644 --- a/dtool/src/prc/configVariableFilename.h +++ b/dtool/src/prc/configVariableFilename.h @@ -26,9 +26,9 @@ */ class EXPCL_DTOOL_PRC ConfigVariableFilename : public ConfigVariable { PUBLISHED: - INLINE ConfigVariableFilename(const string &name); - INLINE ConfigVariableFilename(const string &name, const Filename &default_value, - const string &description = string(), int flags = 0); + INLINE ConfigVariableFilename(const std::string &name); + INLINE ConfigVariableFilename(const std::string &name, const Filename &default_value, + const std::string &description = std::string(), int flags = 0); INLINE void operator = (const Filename &value); INLINE operator const Filename &() const; @@ -39,12 +39,12 @@ PUBLISHED: INLINE size_t length() const; INLINE char operator [] (size_t n) const; - INLINE string get_fullpath() const; - INLINE string get_dirname() const; - INLINE string get_basename() const; - INLINE string get_fullpath_wo_extension() const; - INLINE string get_basename_wo_extension() const; - INLINE string get_extension() const; + INLINE std::string get_fullpath() const; + INLINE std::string get_dirname() const; + INLINE std::string get_basename() const; + INLINE std::string get_fullpath_wo_extension() const; + INLINE std::string get_basename_wo_extension() const; + INLINE std::string get_extension() const; // Comparison operators are handy. INLINE bool operator == (const Filename &other) const; diff --git a/dtool/src/prc/configVariableInt.I b/dtool/src/prc/configVariableInt.I index bdafa4b817..f341070b77 100644 --- a/dtool/src/prc/configVariableInt.I +++ b/dtool/src/prc/configVariableInt.I @@ -15,7 +15,7 @@ * */ INLINE ConfigVariableInt:: -ConfigVariableInt(const string &name) : +ConfigVariableInt(const std::string &name) : ConfigVariable(name, VT_int), _local_modified(initial_invalid_cache()) { @@ -26,12 +26,12 @@ ConfigVariableInt(const string &name) : * */ INLINE ConfigVariableInt:: -ConfigVariableInt(const string &name, int default_value, - const string &description, int flags) : +ConfigVariableInt(const std::string &name, int default_value, + const std::string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, ConfigVariableCore::VT_int, description, flags), #else - ConfigVariable(name, ConfigVariableCore::VT_int, string(), flags), + ConfigVariable(name, ConfigVariableCore::VT_int, std::string(), flags), #endif _local_modified(initial_invalid_cache()) { @@ -43,12 +43,12 @@ ConfigVariableInt(const string &name, int default_value, * */ INLINE ConfigVariableInt:: -ConfigVariableInt(const string &name, const string &default_value, - const string &description, int flags) : +ConfigVariableInt(const std::string &name, const std::string &default_value, + const std::string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, ConfigVariableCore::VT_int, description, flags), #else - ConfigVariable(name, ConfigVariableCore::VT_int, string(), flags), + ConfigVariable(name, ConfigVariableCore::VT_int, std::string(), flags), #endif _local_modified(initial_invalid_cache()) { diff --git a/dtool/src/prc/configVariableInt.h b/dtool/src/prc/configVariableInt.h index 0156bed21a..9d87fe3344 100644 --- a/dtool/src/prc/configVariableInt.h +++ b/dtool/src/prc/configVariableInt.h @@ -23,12 +23,12 @@ */ class EXPCL_DTOOL_PRC ConfigVariableInt : public ConfigVariable { PUBLISHED: - INLINE ConfigVariableInt(const string &name); - INLINE ConfigVariableInt(const string &name, int default_value, - const string &description = string(), + INLINE ConfigVariableInt(const std::string &name); + INLINE ConfigVariableInt(const std::string &name, int default_value, + const std::string &description = std::string(), int flags = 0); - INLINE ConfigVariableInt(const string &name, const string &default_value, - const string &description = string(), + INLINE ConfigVariableInt(const std::string &name, const std::string &default_value, + const std::string &description = std::string(), int flags = 0); INLINE void operator = (int value); diff --git a/dtool/src/prc/configVariableInt64.I b/dtool/src/prc/configVariableInt64.I index 534905b0e8..a86fcc296e 100644 --- a/dtool/src/prc/configVariableInt64.I +++ b/dtool/src/prc/configVariableInt64.I @@ -15,7 +15,7 @@ * */ INLINE ConfigVariableInt64:: -ConfigVariableInt64(const string &name) : +ConfigVariableInt64(const std::string &name) : ConfigVariable(name, VT_int64), _local_modified(initial_invalid_cache()) { @@ -26,12 +26,12 @@ ConfigVariableInt64(const string &name) : * */ INLINE ConfigVariableInt64:: -ConfigVariableInt64(const string &name, int64_t default_value, - const string &description, int flags) : +ConfigVariableInt64(const std::string &name, int64_t default_value, + const std::string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, ConfigVariableCore::VT_int64, description, flags), #else - ConfigVariable(name, ConfigVariableCore::VT_int64, string(), flags), + ConfigVariable(name, ConfigVariableCore::VT_int64, std::string(), flags), #endif _local_modified(initial_invalid_cache()) { @@ -43,12 +43,12 @@ ConfigVariableInt64(const string &name, int64_t default_value, * */ INLINE ConfigVariableInt64:: -ConfigVariableInt64(const string &name, const string &default_value, - const string &description, int flags) : +ConfigVariableInt64(const std::string &name, const std::string &default_value, + const std::string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, ConfigVariableCore::VT_int64, description, flags), #else - ConfigVariable(name, ConfigVariableCore::VT_int64, string(), flags), + ConfigVariable(name, ConfigVariableCore::VT_int64, std::string(), flags), #endif _local_modified(initial_invalid_cache()) { diff --git a/dtool/src/prc/configVariableInt64.h b/dtool/src/prc/configVariableInt64.h index 14d02e2ee9..a88f2272d8 100644 --- a/dtool/src/prc/configVariableInt64.h +++ b/dtool/src/prc/configVariableInt64.h @@ -24,12 +24,12 @@ */ class EXPCL_DTOOL_PRC ConfigVariableInt64 : public ConfigVariable { PUBLISHED: - INLINE ConfigVariableInt64(const string &name); - INLINE ConfigVariableInt64(const string &name, int64_t default_value, - const string &description = string(), + INLINE ConfigVariableInt64(const std::string &name); + INLINE ConfigVariableInt64(const std::string &name, int64_t default_value, + const std::string &description = std::string(), int flags = 0); - INLINE ConfigVariableInt64(const string &name, const string &default_value, - const string &description = string(), + INLINE ConfigVariableInt64(const std::string &name, const std::string &default_value, + const std::string &description = std::string(), int flags = 0); INLINE void operator = (int64_t value); diff --git a/dtool/src/prc/configVariableList.I b/dtool/src/prc/configVariableList.I index a3e96c5a17..606d8d47fd 100644 --- a/dtool/src/prc/configVariableList.I +++ b/dtool/src/prc/configVariableList.I @@ -22,12 +22,12 @@ INLINE ConfigVariableList:: * */ INLINE ConfigVariableList:: -ConfigVariableList(const string &name, - const string &description, int flags) : +ConfigVariableList(const std::string &name, + const std::string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariableBase(name, VT_list, description, flags) #else - ConfigVariableBase(name, VT_list, string(), flags) + ConfigVariableBase(name, VT_list, std::string(), flags) #endif { // A list variable implicitly defines a default value of the empty string. @@ -51,14 +51,14 @@ get_num_values() const { /** * Returns the nth value of the variable. */ -INLINE string ConfigVariableList:: +INLINE std::string ConfigVariableList:: get_string_value(size_t n) const { - nassertr(_core != nullptr, string()); + nassertr(_core != nullptr, std::string()); const ConfigDeclaration *decl = _core->get_trusted_reference(n); if (decl != nullptr) { return decl->get_string_value(); } - return string(); + return std::string(); } /** @@ -73,14 +73,14 @@ get_num_unique_values() const { /** * Returns the nth unique value of the variable. */ -INLINE string ConfigVariableList:: +INLINE std::string ConfigVariableList:: get_unique_value(size_t n) const { - nassertr(_core != nullptr, string()); + nassertr(_core != nullptr, std::string()); const ConfigDeclaration *decl = _core->get_unique_reference(n); if (decl != nullptr) { return decl->get_string_value(); } - return string(); + return std::string(); } /** @@ -96,13 +96,13 @@ size() const { * operator returns the list of unique values, and so the maximum range is * get_num_unique_values(). */ -INLINE string ConfigVariableList:: +INLINE std::string ConfigVariableList:: operator [] (size_t n) const { return get_unique_value(n); } -INLINE ostream & -operator << (ostream &out, const ConfigVariableList &variable) { +INLINE std::ostream & +operator << (std::ostream &out, const ConfigVariableList &variable) { variable.output(out); return out; } diff --git a/dtool/src/prc/configVariableList.h b/dtool/src/prc/configVariableList.h index ca639a94ae..188b33c5fb 100644 --- a/dtool/src/prc/configVariableList.h +++ b/dtool/src/prc/configVariableList.h @@ -30,25 +30,25 @@ */ class EXPCL_DTOOL_PRC ConfigVariableList : public ConfigVariableBase { PUBLISHED: - INLINE ConfigVariableList(const string &name, - const string &description = string(), + INLINE ConfigVariableList(const std::string &name, + const std::string &description = std::string(), int flags = 0); INLINE ~ConfigVariableList(); INLINE size_t get_num_values() const; - INLINE string get_string_value(size_t n) const; + INLINE std::string get_string_value(size_t n) const; INLINE size_t get_num_unique_values() const; - INLINE string get_unique_value(size_t n) const; + INLINE std::string get_unique_value(size_t n) const; INLINE size_t size() const; - INLINE string operator [] (size_t n) const; + INLINE std::string operator [] (size_t n) const; - void output(ostream &out) const; - void write(ostream &out) const; + void output(std::ostream &out) const; + void write(std::ostream &out) const; }; -INLINE ostream &operator << (ostream &out, const ConfigVariableList &variable); +INLINE std::ostream &operator << (std::ostream &out, const ConfigVariableList &variable); #include "configVariableList.I" diff --git a/dtool/src/prc/configVariableManager.I b/dtool/src/prc/configVariableManager.I index 6c92874e9c..d0c1633c27 100644 --- a/dtool/src/prc/configVariableManager.I +++ b/dtool/src/prc/configVariableManager.I @@ -28,8 +28,8 @@ get_variable(size_t n) const { return _variables[n]; } -INLINE ostream & -operator << (ostream &out, const ConfigVariableManager &variableMgr) { +INLINE std::ostream & +operator << (std::ostream &out, const ConfigVariableManager &variableMgr) { variableMgr.output(out); return out; } diff --git a/dtool/src/prc/configVariableManager.h b/dtool/src/prc/configVariableManager.h index 818c5a8f3d..22c0c6e3f5 100644 --- a/dtool/src/prc/configVariableManager.h +++ b/dtool/src/prc/configVariableManager.h @@ -34,26 +34,26 @@ protected: ~ConfigVariableManager(); PUBLISHED: - ConfigVariableCore *make_variable(const string &name); - ConfigVariableCore *make_variable_template(const string &pattern, + ConfigVariableCore *make_variable(const std::string &name); + ConfigVariableCore *make_variable_template(const std::string &pattern, ConfigFlags::ValueType type, - const string &default_value, - const string &description = string(), + const std::string &default_value, + const std::string &description = std::string(), int flags = 0); INLINE size_t get_num_variables() const; INLINE ConfigVariableCore *get_variable(size_t n) const; MAKE_SEQ(get_variables, get_num_variables, get_variable); - string get_variable_name(size_t n) const; + std::string get_variable_name(size_t n) const; bool is_variable_used(size_t n) const; MAKE_SEQ_PROPERTY(variables, get_num_variables, get_variable); - void output(ostream &out) const; - void write(ostream &out) const; + void output(std::ostream &out) const; + void write(std::ostream &out) const; - void write_prc_variables(ostream &out) const; + void write_prc_variables(std::ostream &out) const; void list_unused_variables() const; void list_variables() const; @@ -70,7 +70,7 @@ private: typedef std::vector Variables; Variables _variables; - typedef std::map VariablesByName; + typedef std::map VariablesByName; VariablesByName _variables_by_name; typedef std::map VariableTemplates; @@ -79,7 +79,7 @@ private: static ConfigVariableManager *_global_ptr; }; -INLINE ostream &operator << (ostream &out, const ConfigVariableManager &variableMgr); +INLINE std::ostream &operator << (std::ostream &out, const ConfigVariableManager &variableMgr); #include "configVariableManager.I" diff --git a/dtool/src/prc/configVariableSearchPath.I b/dtool/src/prc/configVariableSearchPath.I index c9294f119e..46e542e24c 100644 --- a/dtool/src/prc/configVariableSearchPath.I +++ b/dtool/src/prc/configVariableSearchPath.I @@ -15,12 +15,12 @@ * */ INLINE ConfigVariableSearchPath:: -ConfigVariableSearchPath(const string &name, - const string &description, int flags) : +ConfigVariableSearchPath(const std::string &name, + const std::string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariableBase(name, VT_search_path, description, flags), #else - ConfigVariableBase(name, VT_search_path, string(), flags), + ConfigVariableBase(name, VT_search_path, std::string(), flags), #endif _default_value(Filename(".")), _local_modified(initial_invalid_cache()) @@ -38,13 +38,13 @@ ConfigVariableSearchPath(const string &name, * */ INLINE ConfigVariableSearchPath:: -ConfigVariableSearchPath(const string &name, +ConfigVariableSearchPath(const std::string &name, const DSearchPath &default_value, - const string &description, int flags) : + const std::string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariableBase(name, VT_search_path, description, flags), #else - ConfigVariableBase(name, VT_search_path, string(), flags), + ConfigVariableBase(name, VT_search_path, std::string(), flags), #endif _default_value(default_value), _local_modified(initial_invalid_cache()) @@ -62,13 +62,13 @@ ConfigVariableSearchPath(const string &name, * */ INLINE ConfigVariableSearchPath:: -ConfigVariableSearchPath(const string &name, - const string &default_value, - const string &description, int flags) : +ConfigVariableSearchPath(const std::string &name, + const std::string &default_value, + const std::string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariableBase(name, VT_search_path, description, flags), #else - ConfigVariableBase(name, VT_search_path, string(), flags), + ConfigVariableBase(name, VT_search_path, std::string(), flags), #endif _default_value(Filename(default_value)), _local_modified(initial_invalid_cache()) @@ -169,7 +169,7 @@ prepend_directory(const Filename &directory) { * search list. */ INLINE void ConfigVariableSearchPath:: -append_path(const string &path, const string &separator) { +append_path(const std::string &path, const std::string &separator) { _postfix.append_path(path, separator); _local_modified = initial_invalid_cache(); } @@ -256,7 +256,7 @@ find_all_files(const Filename &filename) const { * */ INLINE void ConfigVariableSearchPath:: -output(ostream &out) const { +output(std::ostream &out) const { get_value().output(out); } @@ -264,12 +264,12 @@ output(ostream &out) const { * */ INLINE void ConfigVariableSearchPath:: -write(ostream &out) const { +write(std::ostream &out) const { get_value().write(out); } -INLINE ostream & -operator << (ostream &out, const ConfigVariableSearchPath &variable) { +INLINE std::ostream & +operator << (std::ostream &out, const ConfigVariableSearchPath &variable) { variable.output(out); return out; } diff --git a/dtool/src/prc/configVariableSearchPath.h b/dtool/src/prc/configVariableSearchPath.h index 4dfe1b0fcf..02a4fd65c3 100644 --- a/dtool/src/prc/configVariableSearchPath.h +++ b/dtool/src/prc/configVariableSearchPath.h @@ -35,16 +35,16 @@ */ class EXPCL_DTOOL_PRC ConfigVariableSearchPath : public ConfigVariableBase { PUBLISHED: - INLINE ConfigVariableSearchPath(const string &name, - const string &description = string(), + INLINE ConfigVariableSearchPath(const std::string &name, + const std::string &description = std::string(), int flags = 0); - INLINE ConfigVariableSearchPath(const string &name, + INLINE ConfigVariableSearchPath(const std::string &name, const DSearchPath &default_value, - const string &description, + const std::string &description, int flags = 0); - INLINE ConfigVariableSearchPath(const string &name, - const string &default_value, - const string &description, + INLINE ConfigVariableSearchPath(const std::string &name, + const std::string &default_value, + const std::string &description, int flags = 0); INLINE ~ConfigVariableSearchPath(); @@ -59,8 +59,8 @@ PUBLISHED: INLINE void clear(); INLINE void append_directory(const Filename &directory); INLINE void prepend_directory(const Filename &directory); - INLINE void append_path(const string &path, - const string &separator = string()); + INLINE void append_path(const std::string &path, + const std::string &separator = std::string()); INLINE void append_path(const DSearchPath &path); INLINE void prepend_path(const DSearchPath &path); @@ -75,8 +75,8 @@ PUBLISHED: DSearchPath::Results &results) const; INLINE DSearchPath::Results find_all_files(const Filename &filename) const; - INLINE void output(ostream &out) const; - INLINE void write(ostream &out) const; + INLINE void output(std::ostream &out) const; + INLINE void write(std::ostream &out) const; private: void reload_search_path(); @@ -88,7 +88,7 @@ private: DSearchPath _cache; }; -INLINE ostream &operator << (ostream &out, const ConfigVariableSearchPath &variable); +INLINE std::ostream &operator << (std::ostream &out, const ConfigVariableSearchPath &variable); #include "configVariableSearchPath.I" diff --git a/dtool/src/prc/configVariableString.I b/dtool/src/prc/configVariableString.I index fcdb301e2a..d72c48cb8c 100644 --- a/dtool/src/prc/configVariableString.I +++ b/dtool/src/prc/configVariableString.I @@ -15,7 +15,7 @@ * */ INLINE ConfigVariableString:: -ConfigVariableString(const string &name) : +ConfigVariableString(const std::string &name) : ConfigVariable(name, VT_string), _local_modified(initial_invalid_cache()) { @@ -26,12 +26,12 @@ ConfigVariableString(const string &name) : * */ INLINE ConfigVariableString:: -ConfigVariableString(const string &name, const string &default_value, - const string &description, int flags) : +ConfigVariableString(const std::string &name, const std::string &default_value, + const std::string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, VT_string, description, flags), #else - ConfigVariable(name, VT_string, string(), flags), + ConfigVariable(name, VT_string, std::string(), flags), #endif _local_modified(initial_invalid_cache()) { @@ -43,7 +43,7 @@ ConfigVariableString(const string &name, const string &default_value, * Reassigns the variable's local value. */ INLINE void ConfigVariableString:: -operator = (const string &value) { +operator = (const std::string &value) { set_value(value); } @@ -51,7 +51,7 @@ operator = (const string &value) { * Returns the variable's value. */ INLINE ConfigVariableString:: -operator const string & () const { +operator const std::string & () const { return get_value(); } @@ -92,7 +92,7 @@ operator [] (size_t n) const { * */ INLINE bool ConfigVariableString:: -operator == (const string &other) const { +operator == (const std::string &other) const { return get_value() == other; } @@ -100,7 +100,7 @@ operator == (const string &other) const { * */ INLINE bool ConfigVariableString:: -operator != (const string &other) const { +operator != (const std::string &other) const { return get_value() != other; } @@ -108,7 +108,7 @@ operator != (const string &other) const { * */ INLINE bool ConfigVariableString:: -operator < (const string &other) const { +operator < (const std::string &other) const { return get_value() < other; } @@ -116,14 +116,14 @@ operator < (const string &other) const { * Reassigns the variable's local value. */ INLINE void ConfigVariableString:: -set_value(const string &value) { +set_value(const std::string &value) { set_string_value(value); } /** * Returns the variable's value. */ -INLINE const string &ConfigVariableString:: +INLINE const std::string &ConfigVariableString:: get_value() const { TAU_PROFILE("const string &ConfigVariableString::get_value() const", " ", TAU_USER); if (!is_cache_valid(_local_modified)) { @@ -135,19 +135,19 @@ get_value() const { /** * Returns the variable's default value. */ -INLINE string ConfigVariableString:: +INLINE std::string ConfigVariableString:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); if (decl != nullptr) { return decl->get_string_value(); } - return string(); + return std::string(); } /** * Returns the variable's nth value. */ -INLINE string ConfigVariableString:: +INLINE std::string ConfigVariableString:: get_word(size_t n) const { return get_string_word(n); } @@ -157,6 +157,6 @@ get_word(size_t n) const { * variable's overall value. */ INLINE void ConfigVariableString:: -set_word(size_t n, const string &value) { +set_word(size_t n, const std::string &value) { set_string_word(n, value); } diff --git a/dtool/src/prc/configVariableString.h b/dtool/src/prc/configVariableString.h index 0b6d615667..d2b5b38b78 100644 --- a/dtool/src/prc/configVariableString.h +++ b/dtool/src/prc/configVariableString.h @@ -22,12 +22,12 @@ */ class EXPCL_DTOOL_PRC ConfigVariableString : public ConfigVariable { PUBLISHED: - INLINE ConfigVariableString(const string &name); - INLINE ConfigVariableString(const string &name, const string &default_value, - const string &description = string(), int flags = 0); + INLINE ConfigVariableString(const std::string &name); + INLINE ConfigVariableString(const std::string &name, const std::string &default_value, + const std::string &description = std::string(), int flags = 0); - INLINE void operator = (const string &value); - INLINE operator const string & () const; + INLINE void operator = (const std::string &value); + INLINE operator const std::string & () const; // These methods help the ConfigVariableString act like a C++ string object. INLINE const char *c_str() const; @@ -36,25 +36,25 @@ PUBLISHED: INLINE char operator [] (size_t n) const; // Comparison operators are handy. - INLINE bool operator == (const string &other) const; - INLINE bool operator != (const string &other) const; - INLINE bool operator < (const string &other) const; + INLINE bool operator == (const std::string &other) const; + INLINE bool operator != (const std::string &other) const; + INLINE bool operator < (const std::string &other) const; - INLINE void set_value(const string &value); - INLINE const string &get_value() const; - INLINE string get_default_value() const; + INLINE void set_value(const std::string &value); + INLINE const std::string &get_value() const; + INLINE std::string get_default_value() const; MAKE_PROPERTY(value, get_value, set_value); MAKE_PROPERTY(default_value, get_default_value); - INLINE string get_word(size_t n) const; - INLINE void set_word(size_t n, const string &value); + INLINE std::string get_word(size_t n) const; + INLINE void set_word(size_t n, const std::string &value); private: void reload_cache(); private: AtomicAdjust::Integer _local_modified; - string _cache; + std::string _cache; }; #include "configVariableString.I" diff --git a/dtool/src/prc/encryptStream.I b/dtool/src/prc/encryptStream.I index bad15bd7e7..f93e6c01a3 100644 --- a/dtool/src/prc/encryptStream.I +++ b/dtool/src/prc/encryptStream.I @@ -15,15 +15,15 @@ * */ INLINE IDecryptStream:: -IDecryptStream() : istream(&_buf) { +IDecryptStream() : std::istream(&_buf) { } /** * */ INLINE IDecryptStream:: -IDecryptStream(istream *source, bool owns_source, - const string &password) : istream(&_buf) { +IDecryptStream(std::istream *source, bool owns_source, + const std::string &password) : std::istream(&_buf) { open(source, owns_source, password); } @@ -31,7 +31,7 @@ IDecryptStream(istream *source, bool owns_source, * */ INLINE IDecryptStream &IDecryptStream:: -open(istream *source, bool owns_source, const string &password) { +open(std::istream *source, bool owns_source, const std::string &password) { clear((ios_iostate)0); _buf.open_read(source, owns_source, password); return *this; @@ -50,7 +50,7 @@ close() { /** * Returns the encryption algorithm that was read from the stream. */ -INLINE const string &IDecryptStream:: +INLINE const std::string &IDecryptStream:: get_algorithm() const { return _buf.get_algorithm(); } @@ -76,15 +76,15 @@ get_iteration_count() const { * */ INLINE OEncryptStream:: -OEncryptStream() : ostream(&_buf) { +OEncryptStream() : std::ostream(&_buf) { } /** * */ INLINE OEncryptStream:: -OEncryptStream(ostream *dest, bool owns_dest, const string &password) : - ostream(&_buf) +OEncryptStream(std::ostream *dest, bool owns_dest, const std::string &password) : + std::ostream(&_buf) { open(dest, owns_dest, password); } @@ -93,7 +93,7 @@ OEncryptStream(ostream *dest, bool owns_dest, const string &password) : * */ INLINE OEncryptStream &OEncryptStream:: -open(ostream *dest, bool owns_dest, const string &password) { +open(std::ostream *dest, bool owns_dest, const std::string &password) { clear((ios_iostate)0); _buf.open_write(dest, owns_dest, password); return *this; @@ -112,7 +112,7 @@ close() { /** * Returns the encryption algorithm that was read from the stream. */ -INLINE const string &OEncryptStream:: +INLINE const std::string &OEncryptStream:: get_algorithm() const { return _buf.get_algorithm(); } @@ -143,7 +143,7 @@ get_iteration_count() const { * code, but open() will fail. */ INLINE void OEncryptStream:: -set_algorithm(const string &algorithm) { +set_algorithm(const std::string &algorithm) { _buf.set_algorithm(algorithm); } diff --git a/dtool/src/prc/encryptStream.h b/dtool/src/prc/encryptStream.h index 540d4b3209..94deaeb62e 100644 --- a/dtool/src/prc/encryptStream.h +++ b/dtool/src/prc/encryptStream.h @@ -31,21 +31,21 @@ * * Seeking is not supported. */ -class EXPCL_DTOOL_PRC IDecryptStream : public istream { +class EXPCL_DTOOL_PRC IDecryptStream : public std::istream { PUBLISHED: INLINE IDecryptStream(); - INLINE explicit IDecryptStream(istream *source, bool owns_source, - const string &password); + INLINE explicit IDecryptStream(std::istream *source, bool owns_source, + const std::string &password); #if _MSC_VER >= 1800 INLINE IDecryptStream(const IDecryptStream ©) = delete; #endif - INLINE IDecryptStream &open(istream *source, bool owns_source, - const string &password); + INLINE IDecryptStream &open(std::istream *source, bool owns_source, + const std::string &password); INLINE IDecryptStream &close(); - INLINE const string &get_algorithm() const; + INLINE const std::string &get_algorithm() const; INLINE int get_key_length() const; INLINE int get_iteration_count() const; @@ -66,27 +66,27 @@ private: * * Seeking is not supported. */ -class EXPCL_DTOOL_PRC OEncryptStream : public ostream { +class EXPCL_DTOOL_PRC OEncryptStream : public std::ostream { PUBLISHED: INLINE OEncryptStream(); - INLINE explicit OEncryptStream(ostream *dest, bool owns_dest, - const string &password); + INLINE explicit OEncryptStream(std::ostream *dest, bool owns_dest, + const std::string &password); #if _MSC_VER >= 1800 INLINE OEncryptStream(const OEncryptStream ©) = delete; #endif - INLINE OEncryptStream &open(ostream *dest, bool owns_dest, - const string &password); + INLINE OEncryptStream &open(std::ostream *dest, bool owns_dest, + const std::string &password); INLINE OEncryptStream &close(); public: - INLINE const string &get_algorithm() const; + INLINE const std::string &get_algorithm() const; INLINE int get_key_length() const; INLINE int get_iteration_count() const; PUBLISHED: - INLINE void set_algorithm(const string &algorithm); + INLINE void set_algorithm(const std::string &algorithm); INLINE void set_key_length(int key_length); INLINE void set_iteration_count(int iteration_count); diff --git a/dtool/src/prc/encryptStreamBuf.I b/dtool/src/prc/encryptStreamBuf.I index 88537ca09e..cbf9f59470 100644 --- a/dtool/src/prc/encryptStreamBuf.I +++ b/dtool/src/prc/encryptStreamBuf.I @@ -21,7 +21,7 @@ * code, but open_write() will fail. */ INLINE void EncryptStreamBuf:: -set_algorithm(const string &algorithm) { +set_algorithm(const std::string &algorithm) { _algorithm = algorithm; } @@ -29,7 +29,7 @@ set_algorithm(const string &algorithm) { * Returns the encryption algorithm that was specified by set_algorithm(), or * was read from the stream by the last successful open_read(). */ -INLINE const string &EncryptStreamBuf:: +INLINE const std::string &EncryptStreamBuf:: get_algorithm() const { return _algorithm; } diff --git a/dtool/src/prc/encryptStreamBuf.h b/dtool/src/prc/encryptStreamBuf.h index 8a812f1701..7bc4db5199 100644 --- a/dtool/src/prc/encryptStreamBuf.h +++ b/dtool/src/prc/encryptStreamBuf.h @@ -24,19 +24,19 @@ typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX; /** * The streambuf object that implements IDecompressStream and OCompressStream. */ -class EXPCL_DTOOL_PRC EncryptStreamBuf : public streambuf { +class EXPCL_DTOOL_PRC EncryptStreamBuf : public std::streambuf { public: EncryptStreamBuf(); virtual ~EncryptStreamBuf(); - void open_read(istream *source, bool owns_source, const string &password); + void open_read(std::istream *source, bool owns_source, const std::string &password); void close_read(); - void open_write(ostream *dest, bool owns_dest, const string &password); + void open_write(std::ostream *dest, bool owns_dest, const std::string &password); void close_write(); - INLINE void set_algorithm(const string &algorithm); - INLINE const string &get_algorithm() const; + INLINE void set_algorithm(const std::string &algorithm); + INLINE const std::string &get_algorithm() const; INLINE void set_key_length(int key_length); INLINE int get_key_length() const; @@ -54,13 +54,13 @@ private: void write_chars(const char *start, size_t length); private: - istream *_source; + std::istream *_source; bool _owns_source; - ostream *_dest; + std::ostream *_dest; bool _owns_dest; - string _algorithm; + std::string _algorithm; int _key_length; int _iteration_count; diff --git a/dtool/src/prc/notifyCategory.I b/dtool/src/prc/notifyCategory.I index 62a332b388..5793917d91 100644 --- a/dtool/src/prc/notifyCategory.I +++ b/dtool/src/prc/notifyCategory.I @@ -14,7 +14,7 @@ /** * */ -INLINE string NotifyCategory:: +INLINE std::string NotifyCategory:: get_fullname() const { return _fullname; } @@ -22,7 +22,7 @@ get_fullname() const { /** * */ -INLINE string NotifyCategory:: +INLINE std::string NotifyCategory:: get_basename() const { return _basename; } @@ -49,7 +49,7 @@ set_severity(NotifySeverity severity) { _severity = severity; #else // enforce the no-debug, no-spam rule. - _severity = max(severity, NS_info); + _severity = std::max(severity, NS_info); #endif invalidate_cache(); } @@ -139,7 +139,7 @@ is_fatal() const { /** * A shorthand way to write out(NS_spam). */ -INLINE ostream &NotifyCategory:: +INLINE std::ostream &NotifyCategory:: spam(bool prefix) const { #if defined(NOTIFY_DEBUG) return out(NS_spam, prefix); @@ -151,7 +151,7 @@ spam(bool prefix) const { /** * A shorthand way to write out(NS_debug). */ -INLINE ostream &NotifyCategory:: +INLINE std::ostream &NotifyCategory:: debug(bool prefix) const { #if defined(NOTIFY_DEBUG) return out(NS_debug, prefix); @@ -163,7 +163,7 @@ debug(bool prefix) const { /** * A shorthand way to write out(NS_info). */ -INLINE ostream &NotifyCategory:: +INLINE std::ostream &NotifyCategory:: info(bool prefix) const { return out(NS_info, prefix); } @@ -171,7 +171,7 @@ info(bool prefix) const { /** * A shorthand way to write out(NS_warning). */ -INLINE ostream &NotifyCategory:: +INLINE std::ostream &NotifyCategory:: warning(bool prefix) const { return out(NS_warning, prefix); } @@ -179,7 +179,7 @@ warning(bool prefix) const { /** * A shorthand way to write out(NS_error). */ -INLINE ostream &NotifyCategory:: +INLINE std::ostream &NotifyCategory:: error(bool prefix) const { return out(NS_error, prefix); } @@ -187,12 +187,12 @@ error(bool prefix) const { /** * A shorthand way to write out(NS_fatal). */ -INLINE ostream &NotifyCategory:: +INLINE std::ostream &NotifyCategory:: fatal(bool prefix) const { return out(NS_fatal, prefix); } -INLINE ostream & -operator << (ostream &out, const NotifyCategory &cat) { +INLINE std::ostream & +operator << (std::ostream &out, const NotifyCategory &cat) { return out << cat.get_fullname(); } diff --git a/dtool/src/prc/notifyCategory.h b/dtool/src/prc/notifyCategory.h index 5ef3712208..f3e99b09ba 100644 --- a/dtool/src/prc/notifyCategory.h +++ b/dtool/src/prc/notifyCategory.h @@ -31,12 +31,12 @@ */ class EXPCL_DTOOL_PRC NotifyCategory : public MemoryBase, public ConfigFlags { private: - NotifyCategory(const string &fullname, const string &basename, + NotifyCategory(const std::string &fullname, const std::string &basename, NotifyCategory *parent); PUBLISHED: - INLINE string get_fullname() const; - INLINE string get_basename() const; + INLINE std::string get_fullname() const; + INLINE std::string get_basename() const; INLINE NotifySeverity get_severity() const; INLINE void set_severity(NotifySeverity severity); MAKE_PROPERTY(fullname, get_fullname); @@ -63,13 +63,13 @@ PUBLISHED: INLINE bool is_error() const; INLINE bool is_fatal() const; - ostream &out(NotifySeverity severity, bool prefix = true) const; - INLINE ostream &spam(bool prefix = true) const; - INLINE ostream &debug(bool prefix = true) const; - INLINE ostream &info(bool prefix = true) const; - INLINE ostream &warning(bool prefix = true) const; - INLINE ostream &error(bool prefix = true) const; - INLINE ostream &fatal(bool prefix = true) const; + std::ostream &out(NotifySeverity severity, bool prefix = true) const; + INLINE std::ostream &spam(bool prefix = true) const; + INLINE std::ostream &debug(bool prefix = true) const; + INLINE std::ostream &info(bool prefix = true) const; + INLINE std::ostream &warning(bool prefix = true) const; + INLINE std::ostream &error(bool prefix = true) const; + INLINE std::ostream &fatal(bool prefix = true) const; size_t get_num_children() const; NotifyCategory *get_child(size_t i) const; @@ -79,13 +79,13 @@ PUBLISHED: static void set_server_delta(long delta); private: - string get_config_name() const; + std::string get_config_name() const; void update_severity_cache(); static bool get_notify_timestamp(); static bool get_check_debug_notify_protect(); - string _fullname; - string _basename; + std::string _fullname; + std::string _basename; NotifyCategory *_parent; ConfigVariableEnum _severity; typedef std::vector Children; @@ -99,7 +99,7 @@ private: friend class Notify; }; -INLINE ostream &operator << (ostream &out, const NotifyCategory &cat); +INLINE std::ostream &operator << (std::ostream &out, const NotifyCategory &cat); #include "notifyCategory.I" diff --git a/dtool/src/prc/notifyCategoryProxy.I b/dtool/src/prc/notifyCategoryProxy.I index 501090a6d4..eaca9b6e33 100644 --- a/dtool/src/prc/notifyCategoryProxy.I +++ b/dtool/src/prc/notifyCategoryProxy.I @@ -138,7 +138,7 @@ is_fatal() { * */ template -INLINE ostream &NotifyCategoryProxy:: +INLINE std::ostream &NotifyCategoryProxy:: out(NotifySeverity severity, bool prefix) { return get_unsafe_ptr()->out(severity, prefix); } @@ -147,7 +147,7 @@ out(NotifySeverity severity, bool prefix) { * */ template -INLINE ostream &NotifyCategoryProxy:: +INLINE std::ostream &NotifyCategoryProxy:: spam(bool prefix) { return get_unsafe_ptr()->spam(prefix); } @@ -156,7 +156,7 @@ spam(bool prefix) { * */ template -INLINE ostream &NotifyCategoryProxy:: +INLINE std::ostream &NotifyCategoryProxy:: debug(bool prefix) { return get_unsafe_ptr()->debug(prefix); } @@ -165,7 +165,7 @@ debug(bool prefix) { * */ template -INLINE ostream &NotifyCategoryProxy:: +INLINE std::ostream &NotifyCategoryProxy:: info(bool prefix) { return get_unsafe_ptr()->info(prefix); } @@ -174,7 +174,7 @@ info(bool prefix) { * */ template -INLINE ostream &NotifyCategoryProxy:: +INLINE std::ostream &NotifyCategoryProxy:: warning(bool prefix) { return get_unsafe_ptr()->warning(prefix); } @@ -183,7 +183,7 @@ warning(bool prefix) { * */ template -INLINE ostream &NotifyCategoryProxy:: +INLINE std::ostream &NotifyCategoryProxy:: error(bool prefix) { return get_unsafe_ptr()->error(prefix); } @@ -192,7 +192,7 @@ error(bool prefix) { * */ template -INLINE ostream &NotifyCategoryProxy:: +INLINE std::ostream &NotifyCategoryProxy:: fatal(bool prefix) { return get_unsafe_ptr()->fatal(prefix); } diff --git a/dtool/src/prc/notifyCategoryProxy.h b/dtool/src/prc/notifyCategoryProxy.h index eaa83a8282..06f38ec804 100644 --- a/dtool/src/prc/notifyCategoryProxy.h +++ b/dtool/src/prc/notifyCategoryProxy.h @@ -83,13 +83,13 @@ public: INLINE bool is_error(); INLINE bool is_fatal(); - INLINE ostream &out(NotifySeverity severity, bool prefix = true); - INLINE ostream &spam(bool prefix = true); - INLINE ostream &debug(bool prefix = true); - INLINE ostream &info(bool prefix = true); - INLINE ostream &warning(bool prefix = true); - INLINE ostream &error(bool prefix = true); - INLINE ostream &fatal(bool prefix = true); + INLINE std::ostream &out(NotifySeverity severity, bool prefix = true); + INLINE std::ostream &spam(bool prefix = true); + INLINE std::ostream &debug(bool prefix = true); + INLINE std::ostream &info(bool prefix = true); + INLINE std::ostream &warning(bool prefix = true); + INLINE std::ostream &error(bool prefix = true); + INLINE std::ostream &fatal(bool prefix = true); // The same functions as above, when accessed using proxy->function() // syntax, call get_safe_ptr(). These can be used safely either in static- @@ -103,7 +103,7 @@ private: }; template -INLINE ostream &operator << (ostream &out, NotifyCategoryProxy &proxy) { +INLINE std::ostream &operator << (std::ostream &out, NotifyCategoryProxy &proxy) { return out << proxy->get_fullname(); } @@ -159,7 +159,7 @@ INLINE ostream &operator << (ostream &out, NotifyCategoryProxy &pro } \ NotifyCategory *NotifyCategoryGetCategory_ ## basename:: \ get_category() { \ - return Notify::ptr()->get_category(string(actual_name), parent_category); \ + return Notify::ptr()->get_category(std::string(actual_name), parent_category); \ } #define NotifyCategoryDef(basename, parent_category) \ NotifyCategoryDefName(basename, #basename, parent_category); diff --git a/dtool/src/prc/notifySeverity.h b/dtool/src/prc/notifySeverity.h index d16cdb89d8..f44e79ba55 100644 --- a/dtool/src/prc/notifySeverity.h +++ b/dtool/src/prc/notifySeverity.h @@ -28,8 +28,8 @@ enum NotifySeverity { }; END_PUBLISH -EXPCL_DTOOL_PRC ostream &operator << (ostream &out, NotifySeverity severity); -EXPCL_DTOOL_PRC istream &operator >> (istream &in, NotifySeverity &severity); +EXPCL_DTOOL_PRC std::ostream &operator << (std::ostream &out, NotifySeverity severity); +EXPCL_DTOOL_PRC std::istream &operator >> (std::istream &in, NotifySeverity &severity); #endif diff --git a/dtool/src/prc/pnotify.I b/dtool/src/prc/pnotify.I index 1cdea86f2d..4a1730acf5 100644 --- a/dtool/src/prc/pnotify.I +++ b/dtool/src/prc/pnotify.I @@ -34,7 +34,7 @@ has_assert_failed() const { * Returns the error message that corresponds to the assertion that most * recently failed. */ -INLINE const string &Notify:: +INLINE const std::string &Notify:: get_assert_error_message() const { return _assert_error_message; } diff --git a/dtool/src/prc/pnotify.h b/dtool/src/prc/pnotify.h index 90cdb24a5d..6fe488862e 100644 --- a/dtool/src/prc/pnotify.h +++ b/dtool/src/prc/pnotify.h @@ -35,8 +35,8 @@ PUBLISHED: Notify(); ~Notify(); - void set_ostream_ptr(ostream *ostream_ptr, bool delete_later); - ostream *get_ostream_ptr() const; + void set_ostream_ptr(std::ostream *ostream_ptr, bool delete_later); + std::ostream *get_ostream_ptr() const; typedef bool AssertHandler(const char *expression, int line, const char *source_file); @@ -47,45 +47,45 @@ PUBLISHED: AssertHandler *get_assert_handler() const; INLINE bool has_assert_failed() const; - INLINE const string &get_assert_error_message() const; + INLINE const std::string &get_assert_error_message() const; INLINE void clear_assert_failed(); NotifyCategory *get_top_category(); - NotifyCategory *get_category(const string &basename, + NotifyCategory *get_category(const std::string &basename, NotifyCategory *parent_category); - NotifyCategory *get_category(const string &basename, - const string &parent_fullname); - NotifyCategory *get_category(const string &fullname); + NotifyCategory *get_category(const std::string &basename, + const std::string &parent_fullname); + NotifyCategory *get_category(const std::string &fullname); - static ostream &out(); - static ostream &null(); - static void write_string(const string &str); + static std::ostream &out(); + static std::ostream &null(); + static void write_string(const std::string &str); static Notify *ptr(); public: static ios_fmtflags get_literal_flag(); - bool assert_failure(const string &expression, int line, + bool assert_failure(const std::string &expression, int line, const char *source_file); bool assert_failure(const char *expression, int line, const char *source_file); - static NotifySeverity string_severity(const string &string); + static NotifySeverity string_severity(const std::string &string); void config_initialized(); private: - ostream *_ostream_ptr; + std::ostream *_ostream_ptr; bool _owns_ostream_ptr; - ostream *_null_ostream_ptr; + std::ostream *_null_ostream_ptr; AssertHandler *_assert_handler; bool _assert_failed; - string _assert_error_message; + std::string _assert_error_message; // This shouldn't be a pmap, since it might be invoked before we initialize // the global malloc pointers. - typedef std::map Categories; + typedef std::map Categories; Categories _categories; static Notify *_global_ptr; diff --git a/dtool/src/prc/streamReader.I b/dtool/src/prc/streamReader.I index 8f96aa85f4..e15953aeba 100644 --- a/dtool/src/prc/streamReader.I +++ b/dtool/src/prc/streamReader.I @@ -15,7 +15,7 @@ * */ INLINE StreamReader:: -StreamReader(istream &in) : +StreamReader(std::istream &in) : _in(&in), _owns_stream(false) { @@ -26,7 +26,7 @@ StreamReader(istream &in) : * StreamReader destructs. */ INLINE StreamReader:: -StreamReader(istream *in, bool owns_stream) : +StreamReader(std::istream *in, bool owns_stream) : _in(in), _owns_stream(owns_stream) { @@ -67,7 +67,7 @@ INLINE StreamReader:: /** * Returns the stream in use. */ -INLINE istream *StreamReader:: +INLINE std::istream *StreamReader:: get_istream() const { return _in; } diff --git a/dtool/src/prc/streamReader.h b/dtool/src/prc/streamReader.h index 1643dd4a9c..a317f0a783 100644 --- a/dtool/src/prc/streamReader.h +++ b/dtool/src/prc/streamReader.h @@ -27,15 +27,15 @@ */ class EXPCL_DTOOL_PRC StreamReader { public: - INLINE StreamReader(istream &in); + INLINE StreamReader(std::istream &in); PUBLISHED: - INLINE explicit StreamReader(istream *in, bool owns_stream); + INLINE explicit StreamReader(std::istream *in, bool owns_stream); INLINE StreamReader(const StreamReader ©); INLINE void operator = (const StreamReader ©); INLINE ~StreamReader(); - INLINE istream *get_istream() const; - MAKE_PROPERTY(istream, get_istream); + INLINE std::istream *get_istream() const; + MAKE_PROPERTY(std::istream, get_istream); BLOCKING INLINE bool get_bool(); BLOCKING INLINE int8_t get_int8(); @@ -59,10 +59,10 @@ PUBLISHED: BLOCKING INLINE float get_be_float32(); BLOCKING INLINE PN_float64 get_be_float64(); - BLOCKING string get_string(); - BLOCKING string get_string32(); - BLOCKING string get_z_string(); - BLOCKING string get_fixed_string(size_t size); + BLOCKING std::string get_string(); + BLOCKING std::string get_string32(); + BLOCKING std::string get_z_string(); + BLOCKING std::string get_fixed_string(size_t size); BLOCKING void skip_bytes(size_t size); BLOCKING size_t extract_bytes(unsigned char *into, size_t size); @@ -73,10 +73,10 @@ PUBLISHED: public: BLOCKING vector_uchar extract_bytes(size_t size); - BLOCKING string readline(); + BLOCKING std::string readline(); private: - istream *_in; + std::istream *_in; bool _owns_stream; }; diff --git a/dtool/src/prc/streamWrapper.I b/dtool/src/prc/streamWrapper.I index a6438e318e..0f9d65d414 100644 --- a/dtool/src/prc/streamWrapper.I +++ b/dtool/src/prc/streamWrapper.I @@ -62,7 +62,7 @@ release() { * */ INLINE IStreamWrapper:: -IStreamWrapper(istream *stream, bool owns_pointer) : +IStreamWrapper(std::istream *stream, bool owns_pointer) : _istream(stream), _owns_pointer(owns_pointer) { @@ -72,7 +72,7 @@ IStreamWrapper(istream *stream, bool owns_pointer) : * */ INLINE IStreamWrapper:: -IStreamWrapper(istream &stream) : +IStreamWrapper(std::istream &stream) : _istream(&stream), _owns_pointer(false) { @@ -81,7 +81,7 @@ IStreamWrapper(istream &stream) : /** * Returns the istream this object is wrapping. */ -INLINE istream *IStreamWrapper:: +INLINE std::istream *IStreamWrapper:: get_istream() const { return _istream; } @@ -103,7 +103,7 @@ get() { * */ INLINE OStreamWrapper:: -OStreamWrapper(ostream *stream, bool owns_pointer, bool stringstream_hack) : +OStreamWrapper(std::ostream *stream, bool owns_pointer, bool stringstream_hack) : _ostream(stream), _owns_pointer(owns_pointer) #ifdef WIN32_VC @@ -116,7 +116,7 @@ OStreamWrapper(ostream *stream, bool owns_pointer, bool stringstream_hack) : * */ INLINE OStreamWrapper:: -OStreamWrapper(ostream &stream) : +OStreamWrapper(std::ostream &stream) : _ostream(&stream), _owns_pointer(false) #ifdef WIN32_VC @@ -128,7 +128,7 @@ OStreamWrapper(ostream &stream) : /** * Returns the ostream this object is wrapping. */ -INLINE ostream *OStreamWrapper:: +INLINE std::ostream *OStreamWrapper:: get_ostream() const { return _ostream; } @@ -151,7 +151,7 @@ put(char c) { * */ INLINE StreamWrapper:: -StreamWrapper(iostream *stream, bool owns_pointer, bool stringstream_hack) : +StreamWrapper(std::iostream *stream, bool owns_pointer, bool stringstream_hack) : IStreamWrapper(stream, false), OStreamWrapper(stream, false, stringstream_hack), _iostream(stream), @@ -163,7 +163,7 @@ StreamWrapper(iostream *stream, bool owns_pointer, bool stringstream_hack) : * */ INLINE StreamWrapper:: -StreamWrapper(iostream &stream) : +StreamWrapper(std::iostream &stream) : IStreamWrapper(&stream, false), OStreamWrapper(&stream, false), _iostream(&stream), @@ -174,7 +174,7 @@ StreamWrapper(iostream &stream) : /** * Returns the iostream this object is wrapping. */ -INLINE iostream *StreamWrapper:: +INLINE std::iostream *StreamWrapper:: get_iostream() const { return _iostream; } diff --git a/dtool/src/prc/streamWrapper.h b/dtool/src/prc/streamWrapper.h index 62e57fa9e1..b5a4d5bf72 100644 --- a/dtool/src/prc/streamWrapper.h +++ b/dtool/src/prc/streamWrapper.h @@ -48,24 +48,24 @@ private: */ class EXPCL_DTOOL_PRC IStreamWrapper : virtual public StreamWrapperBase { public: - INLINE IStreamWrapper(istream *stream, bool owns_pointer); + INLINE IStreamWrapper(std::istream *stream, bool owns_pointer); PUBLISHED: - INLINE explicit IStreamWrapper(istream &stream); + INLINE explicit IStreamWrapper(std::istream &stream); ~IStreamWrapper(); - INLINE istream *get_istream() const; - MAKE_PROPERTY(istream, get_istream); + INLINE std::istream *get_istream() const; + MAKE_PROPERTY(std::istream, get_istream); public: - void read(char *buffer, streamsize num_bytes); - void read(char *buffer, streamsize num_bytes, streamsize &read_bytes); - void read(char *buffer, streamsize num_bytes, streamsize &read_bytes, bool &eof); - void seek_read(streamsize pos, char *buffer, streamsize num_bytes, streamsize &read_bytes, bool &eof); + void read(char *buffer, std::streamsize num_bytes); + void read(char *buffer, std::streamsize num_bytes, std::streamsize &read_bytes); + void read(char *buffer, std::streamsize num_bytes, std::streamsize &read_bytes, bool &eof); + void seek_read(std::streamsize pos, char *buffer, std::streamsize num_bytes, std::streamsize &read_bytes, bool &eof); INLINE int get(); - streamsize seek_gpos_eof(); + std::streamsize seek_gpos_eof(); private: - istream *_istream; + std::istream *_istream; bool _owns_pointer; }; @@ -75,24 +75,24 @@ private: */ class EXPCL_DTOOL_PRC OStreamWrapper : virtual public StreamWrapperBase { public: - INLINE OStreamWrapper(ostream *stream, bool owns_pointer, bool stringstream_hack = false); + INLINE OStreamWrapper(std::ostream *stream, bool owns_pointer, bool stringstream_hack = false); PUBLISHED: - INLINE explicit OStreamWrapper(ostream &stream); + INLINE explicit OStreamWrapper(std::ostream &stream); ~OStreamWrapper(); - INLINE ostream *get_ostream() const; - MAKE_PROPERTY(ostream, get_ostream); + INLINE std::ostream *get_ostream() const; + MAKE_PROPERTY(std::ostream, get_ostream); public: - void write(const char *buffer, streamsize num_bytes); - void write(const char *buffer, streamsize num_bytes, bool &fail); - void seek_write(streamsize pos, const char *buffer, streamsize num_bytes, bool &fail); - void seek_eof_write(const char *buffer, streamsize num_bytes, bool &fail); + void write(const char *buffer, std::streamsize num_bytes); + void write(const char *buffer, std::streamsize num_bytes, bool &fail); + void seek_write(std::streamsize pos, const char *buffer, std::streamsize num_bytes, bool &fail); + void seek_eof_write(const char *buffer, std::streamsize num_bytes, bool &fail); INLINE bool put(char c); - streamsize seek_ppos_eof(); + std::streamsize seek_ppos_eof(); private: - ostream *_ostream; + std::ostream *_ostream; bool _owns_pointer; // This flag is necessary to work around a weird quirk in the MSVS C++ @@ -111,16 +111,16 @@ private: */ class EXPCL_DTOOL_PRC StreamWrapper : public IStreamWrapper, public OStreamWrapper { public: - INLINE StreamWrapper(iostream *stream, bool owns_pointer, bool stringstream_hack = false); + INLINE StreamWrapper(std::iostream *stream, bool owns_pointer, bool stringstream_hack = false); PUBLISHED: - INLINE explicit StreamWrapper(iostream &stream); + INLINE explicit StreamWrapper(std::iostream &stream); ~StreamWrapper(); - INLINE iostream *get_iostream() const; - MAKE_PROPERTY(iostream, get_iostream); + INLINE std::iostream *get_iostream() const; + MAKE_PROPERTY(std::iostream, get_iostream); private: - iostream *_iostream; + std::iostream *_iostream; bool _owns_pointer; }; diff --git a/dtool/src/prc/streamWriter.I b/dtool/src/prc/streamWriter.I index 8bbe23af62..b2485d3fc7 100644 --- a/dtool/src/prc/streamWriter.I +++ b/dtool/src/prc/streamWriter.I @@ -15,7 +15,7 @@ * */ INLINE StreamWriter:: -StreamWriter(ostream &out) : +StreamWriter(std::ostream &out) : #ifdef HAVE_PYTHON softspace(0), #endif @@ -28,7 +28,7 @@ StreamWriter(ostream &out) : * */ INLINE StreamWriter:: -StreamWriter(ostream *out, bool owns_stream) : +StreamWriter(std::ostream *out, bool owns_stream) : #ifdef HAVE_PYTHON softspace(0), #endif @@ -75,7 +75,7 @@ INLINE StreamWriter:: /** * Returns the stream in use. */ -INLINE ostream *StreamWriter:: +INLINE std::ostream *StreamWriter:: get_ostream() const { return _out; } @@ -265,7 +265,7 @@ add_be_float64(PN_float64 value) { * followed by n bytes. */ INLINE void StreamWriter:: -add_string(const string &str) { +add_string(const std::string &str) { // The max sendable length for a string is 2^16. nassertv(str.length() <= (uint16_t)0xffff); @@ -280,7 +280,7 @@ add_string(const string &str) { * Adds a variable-length string to the stream, using a 32-bit length field. */ INLINE void StreamWriter:: -add_string32(const string &str) { +add_string32(const std::string &str) { // Strings always are preceded by their length add_uint32((uint32_t)str.length()); @@ -292,7 +292,7 @@ add_string32(const string &str) { * Adds a variable-length string to the stream, as a NULL-terminated string. */ INLINE void StreamWriter:: -add_z_string(string str) { +add_z_string(std::string str) { // We must not have any nested null characters in the string. size_t null_pos = str.find('\0'); // Add the string (sans the null character). @@ -308,7 +308,7 @@ add_z_string(string str) { * greater than the requested size, this will silently truncate the string. */ INLINE void StreamWriter:: -add_fixed_string(const string &str, size_t size) { +add_fixed_string(const std::string &str, size_t size) { if (str.length() < size) { append_data(str); pad_bytes(size - str.length()); @@ -330,7 +330,7 @@ append_data(const void *data, size_t size) { * Appends some more raw data to the end of the streamWriter. */ INLINE void StreamWriter:: -append_data(const string &data) { +append_data(const std::string &data) { append_data(data.data(), data.length()); } @@ -347,6 +347,6 @@ flush() { * to sys.stderr and/or sys.stdout in Python. */ INLINE void StreamWriter:: -write(const string &data) { +write(const std::string &data) { append_data(data.data(), data.length()); } diff --git a/dtool/src/prc/streamWriter.h b/dtool/src/prc/streamWriter.h index b39db968c0..cc00ef9ce3 100644 --- a/dtool/src/prc/streamWriter.h +++ b/dtool/src/prc/streamWriter.h @@ -28,15 +28,15 @@ */ class EXPCL_DTOOL_PRC StreamWriter { public: - INLINE StreamWriter(ostream &out); + INLINE StreamWriter(std::ostream &out); PUBLISHED: - INLINE explicit StreamWriter(ostream *out, bool owns_stream); + INLINE explicit StreamWriter(std::ostream *out, bool owns_stream); INLINE StreamWriter(const StreamWriter ©); INLINE void operator = (const StreamWriter ©); INLINE ~StreamWriter(); - INLINE ostream *get_ostream() const; - MAKE_PROPERTY(ostream, get_ostream); + INLINE std::ostream *get_ostream() const; + MAKE_PROPERTY(std::ostream, get_ostream); BLOCKING INLINE void add_bool(bool value); BLOCKING INLINE void add_int8(int8_t value); @@ -62,24 +62,24 @@ PUBLISHED: BLOCKING INLINE void add_be_float32(float value); BLOCKING INLINE void add_be_float64(PN_float64 value); - BLOCKING INLINE void add_string(const string &str); - BLOCKING INLINE void add_string32(const string &str); - BLOCKING INLINE void add_z_string(string str); - BLOCKING INLINE void add_fixed_string(const string &str, size_t size); + BLOCKING INLINE void add_string(const std::string &str); + BLOCKING INLINE void add_string32(const std::string &str); + BLOCKING INLINE void add_z_string(std::string str); + BLOCKING INLINE void add_fixed_string(const std::string &str, size_t size); BLOCKING void pad_bytes(size_t size); EXTENSION(void append_data(PyObject *data)); BLOCKING INLINE void flush(); - BLOCKING INLINE void write(const string &str); + BLOCKING INLINE void write(const std::string &str); public: BLOCKING INLINE void append_data(const void *data, size_t size); - BLOCKING INLINE void append_data(const string &data); + BLOCKING INLINE void append_data(const std::string &data); private: - ostream *_out; + std::ostream *_out; bool _owns_stream; #ifdef HAVE_PYTHON diff --git a/panda/src/android/config_android.h b/panda/src/android/config_android.h index 2224dbd065..4935db0718 100644 --- a/panda/src/android/config_android.h +++ b/panda/src/android/config_android.h @@ -39,6 +39,6 @@ extern jclass jni_BitmapFactory_Options; extern jfieldID jni_BitmapFactory_Options_outWidth; extern jfieldID jni_BitmapFactory_Options_outHeight; -EXPORT_CLASS void android_show_toast(ANativeActivity *activity, const string &message, int duration); +EXPORT_CLASS void android_show_toast(ANativeActivity *activity, const std::string &message, int duration); #endif diff --git a/panda/src/android/pnmFileTypeAndroid.h b/panda/src/android/pnmFileTypeAndroid.h index d872c58578..3501f31239 100644 --- a/panda/src/android/pnmFileTypeAndroid.h +++ b/panda/src/android/pnmFileTypeAndroid.h @@ -38,21 +38,21 @@ public: PNMFileTypeAndroid(CompressFormat format); - virtual string get_name() const; + virtual std::string get_name() const; virtual int get_num_extensions() const; - virtual string get_extension(int n) const; + virtual std::string get_extension(int n) const; virtual bool has_magic_number() const; - virtual PNMReader *make_reader(istream *file, bool owns_file = true, - const string &magic_number = string()); - virtual PNMWriter *make_writer(ostream *file, bool owns_file = true); + virtual PNMReader *make_reader(std::istream *file, bool owns_file = true, + const std::string &magic_number = std::string()); + virtual PNMWriter *make_writer(std::ostream *file, bool owns_file = true); public: class Reader : public PNMReader { public: - Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number); + Reader(PNMFileType *type, std::istream *file, bool owns_file, std::string magic_number); virtual ~Reader(); virtual void prepare_read(); @@ -69,7 +69,7 @@ public: class Writer : public PNMWriter { public: - Writer(PNMFileType *type, ostream *file, bool owns_file, + Writer(PNMFileType *type, std::ostream *file, bool owns_file, CompressFormat format); virtual int write_data(xel *array, xelval *alpha); diff --git a/panda/src/androiddisplay/androidGraphicsPipe.h b/panda/src/androiddisplay/androidGraphicsPipe.h index cead149963..8767f1ee23 100644 --- a/panda/src/androiddisplay/androidGraphicsPipe.h +++ b/panda/src/androiddisplay/androidGraphicsPipe.h @@ -42,14 +42,14 @@ public: AndroidGraphicsPipe(); virtual ~AndroidGraphicsPipe(); - virtual string get_interface_name() const; + virtual std::string get_interface_name() const; static PT(GraphicsPipe) pipe_constructor(); public: virtual PreferredWindowThread get_preferred_window_thread() const; protected: - virtual PT(GraphicsOutput) make_output(const string &name, + virtual PT(GraphicsOutput) make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/androiddisplay/androidGraphicsWindow.h b/panda/src/androiddisplay/androidGraphicsWindow.h index 3d1ca79946..0842b18f2b 100644 --- a/panda/src/androiddisplay/androidGraphicsWindow.h +++ b/panda/src/androiddisplay/androidGraphicsWindow.h @@ -33,7 +33,7 @@ struct android_app; class AndroidGraphicsWindow : public GraphicsWindow { public: AndroidGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/androiddisplay/config_androiddisplay.h b/panda/src/androiddisplay/config_androiddisplay.h index 29c5c3417c..78c42211c0 100644 --- a/panda/src/androiddisplay/config_androiddisplay.h +++ b/panda/src/androiddisplay/config_androiddisplay.h @@ -31,12 +31,12 @@ NotifyCategoryDecl(androiddisplay, EXPCL_PANDAGLES2, EXPTP_PANDAGLES2); extern EXPCL_PANDAGLES2 void init_libandroiddisplay(); - extern EXPCL_PANDAGLES2 const string get_egl_error_string(int error); + extern EXPCL_PANDAGLES2 const std::string get_egl_error_string(int error); #else NotifyCategoryDecl(androiddisplay, EXPCL_PANDAGLES, EXPTP_PANDAGLES); extern EXPCL_PANDAGLES void init_libandroiddisplay(); - extern EXPCL_PANDAGLES const string get_egl_error_string(int error); + extern EXPCL_PANDAGLES const std::string get_egl_error_string(int error); #endif #endif diff --git a/panda/src/audio/audioLoadRequest.I b/panda/src/audio/audioLoadRequest.I index 647692315d..019501aa77 100644 --- a/panda/src/audio/audioLoadRequest.I +++ b/panda/src/audio/audioLoadRequest.I @@ -16,7 +16,7 @@ * to begin an asynchronous load. */ INLINE AudioLoadRequest:: -AudioLoadRequest(AudioManager *audio_manager, const string &filename, +AudioLoadRequest(AudioManager *audio_manager, const std::string &filename, bool positional) : _audio_manager(audio_manager), _filename(filename), @@ -36,7 +36,7 @@ get_audio_manager() const { /** * Returns the filename associated with this asynchronous AudioLoadRequest. */ -INLINE const string &AudioLoadRequest:: +INLINE const std::string &AudioLoadRequest:: get_filename() const { return _filename; } diff --git a/panda/src/audio/audioLoadRequest.h b/panda/src/audio/audioLoadRequest.h index 6d0e59bf4c..1c07098b91 100644 --- a/panda/src/audio/audioLoadRequest.h +++ b/panda/src/audio/audioLoadRequest.h @@ -33,11 +33,11 @@ public: PUBLISHED: INLINE explicit AudioLoadRequest(AudioManager *audio_manager, - const string &filename, + const std::string &filename, bool positional); INLINE AudioManager *get_audio_manager() const; - INLINE const string &get_filename() const; + INLINE const std::string &get_filename() const; INLINE bool get_positional() const; INLINE bool is_ready() const; @@ -48,7 +48,7 @@ protected: private: PT(AudioManager) _audio_manager; - string _filename; + std::string _filename; bool _positional; public: diff --git a/panda/src/audio/audioManager.h b/panda/src/audio/audioManager.h index 3d69b26519..2ee14f10cb 100644 --- a/panda/src/audio/audioManager.h +++ b/panda/src/audio/audioManager.h @@ -86,7 +86,7 @@ PUBLISHED: virtual bool is_valid() = 0; // Get a sound: - virtual PT(AudioSound) get_sound(const string& file_name, bool positional = false, int mode=SM_heuristic) = 0; + virtual PT(AudioSound) get_sound(const std::string& file_name, bool positional = false, int mode=SM_heuristic) = 0; virtual PT(AudioSound) get_sound(MovieAudio *source, bool positional = false, int mode=SM_heuristic) = 0; PT(AudioSound) get_null_sound(); @@ -95,7 +95,7 @@ PUBLISHED: // doesn't break any connection between AudioSounds that have already given // by get_sound() from this manager. It's only affecting whether the // AudioManager keeps a copy of the sound in its poolcache. - virtual void uncache_sound(const string& file_name) = 0; + virtual void uncache_sound(const std::string& file_name) = 0; virtual void clear_cache() = 0; virtual void set_cache_limit(unsigned int count) = 0; virtual unsigned int get_cache_limit() const = 0; @@ -175,8 +175,8 @@ PUBLISHED: static Filename get_dls_pathname(); MAKE_PROPERTY(dls_pathname, get_dls_pathname); - virtual void output(ostream &out) const; - virtual void write(ostream &out) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out) const; // set_speaker_configuration is a Miles only method. virtual void set_speaker_configuration(LVecBase3 *speaker1, LVecBase3 *speaker2=nullptr, LVecBase3 *speaker3=nullptr, LVecBase3 *speaker4=nullptr, LVecBase3 *speaker5=nullptr, LVecBase3 *speaker6=nullptr, LVecBase3 *speaker7=nullptr, LVecBase3 *speaker8=nullptr, LVecBase3 *speaker9=nullptr); @@ -214,8 +214,8 @@ private: static TypeHandle _type_handle; }; -inline ostream & -operator << (ostream &out, const AudioManager &mgr) { +inline std::ostream & +operator << (std::ostream &out, const AudioManager &mgr) { mgr.output(out); return out; } diff --git a/panda/src/audio/audioSound.h b/panda/src/audio/audioSound.h index 357df8ad11..e348ad4daf 100644 --- a/panda/src/audio/audioSound.h +++ b/panda/src/audio/audioSound.h @@ -74,11 +74,11 @@ PUBLISHED: // Set (or clear) the event that will be thrown when the sound finishes // playing. To clear the event, pass an empty string. - virtual void set_finished_event(const string& event) = 0; - virtual const string& get_finished_event() const = 0; + virtual void set_finished_event(const std::string& event) = 0; + virtual const std::string& get_finished_event() const = 0; // There is no set_name(), this is intentional. - virtual const string& get_name() const = 0; + virtual const std::string& get_name() const = 0; // return: playing time in seconds. virtual PN_stdfloat length() const = 0; @@ -123,8 +123,8 @@ PUBLISHED: enum SoundStatus { BAD, READY, PLAYING }; virtual SoundStatus status() const = 0; - virtual void output(ostream &out) const; - virtual void write(ostream &out) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out) const; protected: AudioSound(); @@ -149,15 +149,15 @@ private: static TypeHandle _type_handle; }; -inline ostream & -operator << (ostream &out, const AudioSound &sound) { +inline std::ostream & +operator << (std::ostream &out, const AudioSound &sound) { sound.output(out); return out; } #include "audioSound.I" -EXPCL_PANDA_AUDIO ostream & -operator << (ostream &out, AudioSound::SoundStatus status); +EXPCL_PANDA_AUDIO std::ostream & +operator << (std::ostream &out, AudioSound::SoundStatus status); #endif /* __AUDIOSOUND_H__ */ diff --git a/panda/src/audio/config_audio.h b/panda/src/audio/config_audio.h index bb84a9bf2d..47853ac143 100644 --- a/panda/src/audio/config_audio.h +++ b/panda/src/audio/config_audio.h @@ -52,8 +52,8 @@ enum FmodSpeakerMode { FSM_unspecified }; -EXPCL_PANDA_AUDIO ostream &operator << (ostream &out, FmodSpeakerMode sm); -EXPCL_PANDA_AUDIO istream &operator >> (istream &in, FmodSpeakerMode &sm); +EXPCL_PANDA_AUDIO std::ostream &operator << (std::ostream &out, FmodSpeakerMode sm); +EXPCL_PANDA_AUDIO std::istream &operator >> (std::istream &in, FmodSpeakerMode &sm); extern EXPCL_PANDA_AUDIO ConfigVariableInt fmod_number_of_sound_channels; extern EXPCL_PANDA_AUDIO ConfigVariableBool fmod_use_surround_sound; @@ -84,7 +84,7 @@ extern EXPCL_PANDA_AUDIO ConfigVariableInt audio_output_channels; // Non-release build: #define audio_debug(msg) \ if (audio_cat.is_debug()) { \ - audio_cat->debug() << msg << endl; \ + audio_cat->debug() << msg << std::endl; \ } else {} #else //][ // Release build: @@ -92,12 +92,12 @@ extern EXPCL_PANDA_AUDIO ConfigVariableInt audio_output_channels; #endif //] #define audio_info(msg) \ - audio_cat->info() << msg << endl + audio_cat->info() << msg << std::endl #define audio_warning(msg) \ - audio_cat->warning() << msg << endl + audio_cat->warning() << msg << std::endl #define audio_error(msg) \ - audio_cat->error() << msg << endl + audio_cat->error() << msg << std::endl #endif /* __CONFIG_AUDIO_H__ */ diff --git a/panda/src/audio/nullAudioManager.h b/panda/src/audio/nullAudioManager.h index cebf6ab08a..9a8ff921e4 100644 --- a/panda/src/audio/nullAudioManager.h +++ b/panda/src/audio/nullAudioManager.h @@ -29,9 +29,9 @@ public: virtual bool is_valid(); - virtual PT(AudioSound) get_sound(const string&, bool positional = false, int mode=SM_heuristic); + virtual PT(AudioSound) get_sound(const std::string&, bool positional = false, int mode=SM_heuristic); virtual PT(AudioSound) get_sound(MovieAudio *sound, bool positional = false, int mode=SM_heuristic); - virtual void uncache_sound(const string&); + virtual void uncache_sound(const std::string&); virtual void clear_cache(); virtual void set_cache_limit(unsigned int); virtual unsigned int get_cache_limit() const; diff --git a/panda/src/audio/nullAudioSound.h b/panda/src/audio/nullAudioSound.h index 87ef0c9b95..d388493132 100644 --- a/panda/src/audio/nullAudioSound.h +++ b/panda/src/audio/nullAudioSound.h @@ -52,10 +52,10 @@ public: void set_active(bool); bool get_active() const; - void set_finished_event(const string& event); - const string& get_finished_event() const; + void set_finished_event(const std::string& event); + const std::string& get_finished_event() const; - const string& get_name() const; + const std::string& get_name() const; PN_stdfloat length() const; diff --git a/panda/src/audiotraits/fmodAudioManager.h b/panda/src/audiotraits/fmodAudioManager.h index 751385e5a7..6af6448079 100644 --- a/panda/src/audiotraits/fmodAudioManager.h +++ b/panda/src/audiotraits/fmodAudioManager.h @@ -88,7 +88,7 @@ public: virtual bool is_valid(); - virtual PT(AudioSound) get_sound(const string&, bool positional = false, int mode=SM_heuristic); + virtual PT(AudioSound) get_sound(const std::string&, bool positional = false, int mode=SM_heuristic); virtual PT(AudioSound) get_sound(MovieAudio *, bool positional = false, int mode=SM_heuristic); virtual int get_speaker_setup(); @@ -146,7 +146,7 @@ public: virtual void set_concurrent_sound_limit(unsigned int limit = 0); virtual unsigned int get_concurrent_sound_limit() const; virtual void reduce_sounds_playing_to(unsigned int count); - virtual void uncache_sound(const string&); + virtual void uncache_sound(const std::string&); virtual void clear_cache(); virtual void set_cache_limit(unsigned int count); virtual unsigned int get_cache_limit() const; @@ -177,7 +177,7 @@ private: FMOD_VECTOR _up; // DLS info for MIDI files - string _dlsname; + std::string _dlsname; FMOD_CREATESOUNDEXINFO _midi_info; bool _is_valid; diff --git a/panda/src/audiotraits/fmodAudioSound.h b/panda/src/audiotraits/fmodAudioSound.h index c77664ab61..8d0ad4408c 100644 --- a/panda/src/audiotraits/fmodAudioSound.h +++ b/panda/src/audiotraits/fmodAudioSound.h @@ -106,7 +106,7 @@ class EXPCL_FMOD_AUDIO FmodAudioSound : public AudioSound { void set_play_rate(PN_stdfloat play_rate=1.0f); PN_stdfloat get_play_rate() const; - const string &get_name() const; + const std::string &get_name() const; // return: playing time in seconds. PN_stdfloat length() const; @@ -132,8 +132,8 @@ class EXPCL_FMOD_AUDIO FmodAudioSound : public AudioSound { bool get_active() const; void finished(); - void set_finished_event(const string& event); - const string& get_finished_event() const; + void set_finished_event(const std::string& event); + const std::string& get_finished_event() const; private: PT(FmodAudioManager) _manager; @@ -175,7 +175,7 @@ class EXPCL_FMOD_AUDIO FmodAudioSound : public AudioSound { bool _paused; PN_stdfloat _start_time; - string _finished_event; + std::string _finished_event; // This reference-counting pointer is set to this while the sound is // playing, and cleared when we get an indication that the sound has diff --git a/panda/src/audiotraits/milesAudioManager.h b/panda/src/audiotraits/milesAudioManager.h index 51fb16b527..e203609fb7 100644 --- a/panda/src/audiotraits/milesAudioManager.h +++ b/panda/src/audiotraits/milesAudioManager.h @@ -42,9 +42,9 @@ public: virtual bool is_valid(); - virtual PT(AudioSound) get_sound(const string &file_name, bool positional = false, int mode=SM_heuristic); + virtual PT(AudioSound) get_sound(const std::string &file_name, bool positional = false, int mode=SM_heuristic); virtual PT(AudioSound) get_sound(MovieAudio *sound, bool positional = false, int mode=SM_heuristic); - virtual void uncache_sound(const string &file_name); + virtual void uncache_sound(const std::string &file_name); virtual void clear_cache(); virtual void set_cache_limit(unsigned int count); virtual unsigned int get_cache_limit() const; @@ -83,8 +83,8 @@ public: virtual PN_stdfloat audio_3d_get_drop_off_factor() const; virtual void set_speaker_configuration(LVecBase3 *speaker1, LVecBase3 *speaker2=nullptr, LVecBase3 *speaker3=nullptr, LVecBase3 *speaker4=nullptr, LVecBase3 *speaker5=nullptr, LVecBase3 *speaker6=nullptr, LVecBase3 *speaker7=nullptr, LVecBase3 *speaker8=nullptr, LVecBase3 *speaker9=nullptr); - virtual void output(ostream &out) const; - virtual void write(ostream &out) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out) const; private: bool do_is_valid(); @@ -94,7 +94,7 @@ private: void start_service_stream(HSTREAM stream); void stop_service_stream(HSTREAM stream); - void most_recently_used(const string &path); + void most_recently_used(const std::string &path); void uncache_a_sound(); void starting_sound(MilesAudioSound *audio); @@ -130,7 +130,7 @@ private: bool _has_length; PN_stdfloat _length; // in seconds. }; - typedef pmap SoundMap; + typedef pmap SoundMap; SoundMap _sounds; typedef pset AudioSet; @@ -142,7 +142,7 @@ private: SoundsPlaying _sounds_playing; // The Least Recently Used mechanism: - typedef pdeque LRU; + typedef pdeque LRU; LRU _lru; // State: PN_stdfloat _volume; diff --git a/panda/src/audiotraits/milesAudioSample.h b/panda/src/audiotraits/milesAudioSample.h index 6e976fa212..22f5e5d457 100644 --- a/panda/src/audiotraits/milesAudioSample.h +++ b/panda/src/audiotraits/milesAudioSample.h @@ -30,7 +30,7 @@ class EXPCL_MILES_AUDIO MilesAudioSample : public MilesAudioSound { private: MilesAudioSample(MilesAudioManager *manager, MilesAudioManager::SoundData *sd, - const string &file_name); + const std::string &file_name); public: virtual ~MilesAudioSample(); @@ -49,7 +49,7 @@ public: virtual AudioSound::SoundStatus status() const; virtual void cleanup(); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; // 3D spatialized sound support. Spatialized sound was originally added for // FMOD, so there are parts of the interface in the Miles implementation diff --git a/panda/src/audiotraits/milesAudioSequence.h b/panda/src/audiotraits/milesAudioSequence.h index 8f01a037fd..2386c6d17b 100644 --- a/panda/src/audiotraits/milesAudioSequence.h +++ b/panda/src/audiotraits/milesAudioSequence.h @@ -29,7 +29,7 @@ class EXPCL_MILES_AUDIO MilesAudioSequence : public MilesAudioSound { private: MilesAudioSequence(MilesAudioManager *manager, MilesAudioManager::SoundData *sd, - const string &file_name); + const std::string &file_name); public: virtual ~MilesAudioSequence(); diff --git a/panda/src/audiotraits/milesAudioSound.h b/panda/src/audiotraits/milesAudioSound.h index 46c6aa74c3..c44584d69a 100644 --- a/panda/src/audiotraits/milesAudioSound.h +++ b/panda/src/audiotraits/milesAudioSound.h @@ -26,7 +26,7 @@ */ class EXPCL_MILES_AUDIO MilesAudioSound : public AudioSound { protected: - MilesAudioSound(MilesAudioManager *manager, const string &file_name); + MilesAudioSound(MilesAudioManager *manager, const std::string &file_name); public: virtual void set_loop(bool loop=true); @@ -44,16 +44,16 @@ public: virtual void set_active(bool active=true); virtual bool get_active() const; - virtual void set_finished_event(const string &event); - virtual const string &get_finished_event() const; + virtual void set_finished_event(const std::string &event); + virtual const std::string &get_finished_event() const; - virtual const string &get_name() const; + virtual const std::string &get_name() const; virtual void cleanup(); protected: PT(MilesAudioManager) _manager; - string _file_name; + std::string _file_name; PN_stdfloat _volume; // 0..1.0 PN_stdfloat _balance; // -1..1 @@ -72,7 +72,7 @@ protected: // This is the string that throw_event() will throw when the sound finishes // playing. It is not triggered when the sound is stopped with stop(). // Note: no longer implemented. - string _finished_event; + std::string _finished_event; // This is set whenever we call set_time(). Calling play() will respect // this if it is set, and then reset it. diff --git a/panda/src/audiotraits/milesAudioStream.h b/panda/src/audiotraits/milesAudioStream.h index 8050f513cf..42bda6b6ab 100644 --- a/panda/src/audiotraits/milesAudioStream.h +++ b/panda/src/audiotraits/milesAudioStream.h @@ -28,7 +28,7 @@ */ class EXPCL_MILES_AUDIO MilesAudioStream : public MilesAudioSound { private: - MilesAudioStream(MilesAudioManager *manager, const string &file_name, + MilesAudioStream(MilesAudioManager *manager, const std::string &file_name, const Filename &path); public: diff --git a/panda/src/audiotraits/openalAudioManager.h b/panda/src/audiotraits/openalAudioManager.h index 1e16e4000b..8fe8a8f3f3 100644 --- a/panda/src/audiotraits/openalAudioManager.h +++ b/panda/src/audiotraits/openalAudioManager.h @@ -51,10 +51,10 @@ class EXPCL_OPENAL_AUDIO OpenALAudioManager : public AudioManager { virtual bool is_valid(); - virtual PT(AudioSound) get_sound(const string&, bool positional = false, int mode=SM_heuristic); + virtual PT(AudioSound) get_sound(const std::string&, bool positional = false, int mode=SM_heuristic); virtual PT(AudioSound) get_sound(MovieAudio *sound, bool positional = false, int mode=SM_heuristic); - virtual void uncache_sound(const string&); + virtual void uncache_sound(const std::string&); virtual void clear_cache(); virtual void set_cache_limit(unsigned int count); virtual unsigned int get_cache_limit() const; @@ -114,7 +114,7 @@ class EXPCL_OPENAL_AUDIO OpenALAudioManager : public AudioManager { virtual void update(); private: - string select_audio_device(); + std::string select_audio_device(); void make_current() const; @@ -175,7 +175,7 @@ private: }; - typedef phash_map SampleCache; + typedef phash_map SampleCache; SampleCache _sample_cache; typedef phash_set SoundsPlaying; diff --git a/panda/src/audiotraits/openalAudioSound.h b/panda/src/audiotraits/openalAudioSound.h index e10f4f179a..3c1feda08a 100644 --- a/panda/src/audiotraits/openalAudioSound.h +++ b/panda/src/audiotraits/openalAudioSound.h @@ -72,10 +72,10 @@ public: // This is the string that throw_event() will throw when the sound finishes // playing. It is not triggered when the sound is stopped with stop(). - void set_finished_event(const string& event); - const string& get_finished_event() const; + void set_finished_event(const std::string& event); + const std::string& get_finished_event() const; - const string &get_name() const; + const std::string &get_name() const; // return: playing time in seconds. PN_stdfloat length() const; @@ -177,7 +177,7 @@ private: // This is the string that throw_event() will throw when the sound finishes // playing. It is not triggered when the sound is stopped with stop(). - string _finished_event; + std::string _finished_event; Filename _basename; diff --git a/panda/src/awesomium/AwMouseAndKeyboard.h b/panda/src/awesomium/AwMouseAndKeyboard.h index 2a70904523..e338939001 100644 --- a/panda/src/awesomium/AwMouseAndKeyboard.h +++ b/panda/src/awesomium/AwMouseAndKeyboard.h @@ -32,7 +32,7 @@ protected: int _button_events_output; PUBLISHED: - AwMouseAndKeyboard(const string &name); + AwMouseAndKeyboard(const std::string &name); protected: // Inherited from DataNode diff --git a/panda/src/awesomium/WebBrowserTexture.h b/panda/src/awesomium/WebBrowserTexture.h index 112f8399da..3c9e6aaa08 100644 --- a/panda/src/awesomium/WebBrowserTexture.h +++ b/panda/src/awesomium/WebBrowserTexture.h @@ -37,7 +37,7 @@ protected: private: WebBrowserTexture(const WebBrowserTexture ©); PUBLISHED: - WebBrowserTexture(const string &name, AwWebView* aw_web_view = nullptr); + WebBrowserTexture(const std::string &name, AwWebView* aw_web_view = nullptr); virtual ~WebBrowserTexture(); diff --git a/panda/src/awesomium/awWebView.h b/panda/src/awesomium/awWebView.h index 5a5550c4ee..ad5c9d223c 100644 --- a/panda/src/awesomium/awWebView.h +++ b/panda/src/awesomium/awWebView.h @@ -63,7 +63,7 @@ PUBLISHED: // VC7 linker doesn't like wstring from VS2008, hence using the all regular // string version - void loadURL2(const string& url, const string& frameName ="", const string& username="" , const string& password=""); + void loadURL2(const std::string& url, const std::string& frameName ="", const std::string& username="" , const std::string& password=""); // VC7 linker doesn't like wstring from VS2008, hence using the all regular // string version diff --git a/panda/src/bullet/bulletBodyNode.h b/panda/src/bullet/bulletBodyNode.h index 55f8583938..90578eb62b 100644 --- a/panda/src/bullet/bulletBodyNode.h +++ b/panda/src/bullet/bulletBodyNode.h @@ -150,8 +150,8 @@ public: virtual bool safe_to_combine_children() const; virtual bool safe_to_flatten_below() const; - virtual void output(ostream &out) const; - virtual void do_output(ostream &out) const; + virtual void output(std::ostream &out) const; + virtual void do_output(std::ostream &out) const; protected: void set_collision_flag(int flag, bool value); diff --git a/panda/src/bullet/bulletContactCallbacks.h b/panda/src/bullet/bulletContactCallbacks.h index e368e6ee0c..e9891fda8a 100644 --- a/panda/src/bullet/bulletContactCallbacks.h +++ b/panda/src/bullet/bulletContactCallbacks.h @@ -61,7 +61,7 @@ contact_added_callback(btManifoldPoint &cp, PT(PandaNode) node1 = (PandaNode *)obj1->getUserPointer(); #endif - bullet_cat.debug() << "contact added: " << cp.m_userPersistentData << endl; + bullet_cat.debug() << "contact added: " << cp.m_userPersistentData << std::endl; // Gather persistent data UserPersistentData *data = new UserPersistentData(); @@ -124,7 +124,7 @@ contact_processed_callback(btManifoldPoint &cp, static bool contact_destroyed_callback(void *userPersistentData) { - bullet_cat.debug() << "contact removed: " << userPersistentData << endl; + bullet_cat.debug() << "contact removed: " << userPersistentData << std::endl; UserPersistentData *data = (UserPersistentData *)userPersistentData; diff --git a/panda/src/bullet/bulletRigidBodyNode.h b/panda/src/bullet/bulletRigidBodyNode.h index 641fdc9fd9..d0e11da6cf 100644 --- a/panda/src/bullet/bulletRigidBodyNode.h +++ b/panda/src/bullet/bulletRigidBodyNode.h @@ -106,7 +106,7 @@ PUBLISHED: public: virtual btCollisionObject *get_object() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; void do_sync_p2b(); void do_sync_b2p(); diff --git a/panda/src/bullet/bulletTriangleMesh.I b/panda/src/bullet/bulletTriangleMesh.I index 33b9b9bf47..acce8e7cfc 100644 --- a/panda/src/bullet/bulletTriangleMesh.I +++ b/panda/src/bullet/bulletTriangleMesh.I @@ -22,8 +22,8 @@ ptr() const { /** * */ -INLINE ostream & -operator << (ostream &out, const BulletTriangleMesh &obj) { +INLINE std::ostream & +operator << (std::ostream &out, const BulletTriangleMesh &obj) { obj.output(out); return out; } diff --git a/panda/src/bullet/bulletTriangleMesh.h b/panda/src/bullet/bulletTriangleMesh.h index 27c0598b13..e3ce0805ad 100644 --- a/panda/src/bullet/bulletTriangleMesh.h +++ b/panda/src/bullet/bulletTriangleMesh.h @@ -51,8 +51,8 @@ PUBLISHED: size_t get_num_triangles() const; PN_stdfloat get_welding_distance() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; public: size_t get_num_vertices() const; @@ -112,7 +112,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const BulletTriangleMesh &obj); +INLINE std::ostream &operator << (std::ostream &out, const BulletTriangleMesh &obj); #include "bulletTriangleMesh.I" diff --git a/panda/src/bullet/bulletWorld.h b/panda/src/bullet/bulletWorld.h index 35a2c8c634..9c709c1e91 100644 --- a/panda/src/bullet/bulletWorld.h +++ b/panda/src/bullet/bulletWorld.h @@ -305,15 +305,15 @@ private: static TypeHandle _type_handle; }; -EXPCL_PANDABULLET ostream & -operator << (ostream &out, BulletWorld::BroadphaseAlgorithm algorithm); -EXPCL_PANDABULLET istream & -operator >> (istream &in, BulletWorld::BroadphaseAlgorithm &algorithm); +EXPCL_PANDABULLET std::ostream & +operator << (std::ostream &out, BulletWorld::BroadphaseAlgorithm algorithm); +EXPCL_PANDABULLET std::istream & +operator >> (std::istream &in, BulletWorld::BroadphaseAlgorithm &algorithm); -EXPCL_PANDABULLET ostream & -operator << (ostream &out, BulletWorld::FilterAlgorithm algorithm); -EXPCL_PANDABULLET istream & -operator >> (istream &in, BulletWorld::FilterAlgorithm &algorithm); +EXPCL_PANDABULLET std::ostream & +operator << (std::ostream &out, BulletWorld::FilterAlgorithm algorithm); +EXPCL_PANDABULLET std::istream & +operator >> (std::istream &in, BulletWorld::FilterAlgorithm &algorithm); #include "bulletWorld.I" diff --git a/panda/src/chan/animBundle.I b/panda/src/chan/animBundle.I index 2859273786..c52608f852 100644 --- a/panda/src/chan/animBundle.I +++ b/panda/src/chan/animBundle.I @@ -15,7 +15,7 @@ * */ INLINE AnimBundle:: -AnimBundle(const string &name, PN_stdfloat fps, int num_frames) : AnimGroup(name) { +AnimBundle(const std::string &name, PN_stdfloat fps, int num_frames) : AnimGroup(name) { _fps = fps; _num_frames = num_frames; _root = this; diff --git a/panda/src/chan/animBundle.h b/panda/src/chan/animBundle.h index 799d262ab8..659f15e58c 100644 --- a/panda/src/chan/animBundle.h +++ b/panda/src/chan/animBundle.h @@ -31,14 +31,14 @@ protected: AnimBundle(AnimGroup *parent, const AnimBundle ©); PUBLISHED: - INLINE explicit AnimBundle(const string &name, PN_stdfloat fps, int num_frames); + INLINE explicit AnimBundle(const std::string &name, PN_stdfloat fps, int num_frames); PT(AnimBundle) copy_bundle() const; INLINE double get_base_frame_rate() const; INLINE int get_num_frames() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: INLINE AnimBundle(); @@ -77,7 +77,7 @@ private: static TypeHandle _type_handle; }; -inline ostream &operator <<(ostream &out, const AnimBundle &bundle) { +inline std::ostream &operator <<(std::ostream &out, const AnimBundle &bundle) { bundle.output(out); return out; } diff --git a/panda/src/chan/animBundleNode.I b/panda/src/chan/animBundleNode.I index b7ac18c818..ced5541dbe 100644 --- a/panda/src/chan/animBundleNode.I +++ b/panda/src/chan/animBundleNode.I @@ -17,7 +17,7 @@ * the appropriate type, and pass it up to this constructor. */ INLINE AnimBundleNode:: -AnimBundleNode(const string &name, AnimBundle *bundle) : +AnimBundleNode(const std::string &name, AnimBundle *bundle) : PandaNode(name), _bundle(bundle) { diff --git a/panda/src/chan/animBundleNode.h b/panda/src/chan/animBundleNode.h index 38df110191..fbf9dcbbe2 100644 --- a/panda/src/chan/animBundleNode.h +++ b/panda/src/chan/animBundleNode.h @@ -28,7 +28,7 @@ */ class EXPCL_PANDA_CHAN AnimBundleNode : public PandaNode { PUBLISHED: - INLINE explicit AnimBundleNode(const string &name, AnimBundle *bundle); + INLINE explicit AnimBundleNode(const std::string &name, AnimBundle *bundle); protected: INLINE AnimBundleNode(); diff --git a/panda/src/chan/animChannel.I b/panda/src/chan/animChannel.I index d776b938e5..412f21c684 100644 --- a/panda/src/chan/animChannel.I +++ b/panda/src/chan/animChannel.I @@ -26,7 +26,7 @@ TypeHandle AnimChannel::_type_handle; */ template INLINE AnimChannel:: -AnimChannel(const string &name) +AnimChannel(const std::string &name) : AnimChannelBase(name) { } @@ -48,7 +48,7 @@ AnimChannel(AnimGroup *parent, const AnimChannel ©) : */ template INLINE AnimChannel:: -AnimChannel(AnimGroup *parent, const string &name) +AnimChannel(AnimGroup *parent, const std::string &name) : AnimChannelBase(parent, name) { } diff --git a/panda/src/chan/animChannel.h b/panda/src/chan/animChannel.h index 531511660e..eb024ea31e 100644 --- a/panda/src/chan/animChannel.h +++ b/panda/src/chan/animChannel.h @@ -30,12 +30,12 @@ protected: // The default constructor is protected: don't try to create an AnimChannel // without a parent. To create an AnimChannel hierarchy, you must first // create an AnimBundle, and use that to create any subsequent children. - INLINE AnimChannel(const string &name = ""); + INLINE AnimChannel(const std::string &name = ""); INLINE AnimChannel(AnimGroup *parent, const AnimChannel ©); public: typedef typename SwitchType::ValueType ValueType; - INLINE AnimChannel(AnimGroup *parent, const string &name); + INLINE AnimChannel(AnimGroup *parent, const std::string &name); INLINE ~AnimChannel(); PUBLISHED: @@ -81,7 +81,7 @@ public: static const char *get_channel_type_name() { return "AnimChannelMatrix"; } static const char *get_fixed_channel_type_name() { return "AnimChannelFixed"; } static const char *get_part_type_name() { return "MovingPart"; } - static void output_value(ostream &out, const ValueType &value); + static void output_value(std::ostream &out, const ValueType &value); static void write_datagram(Datagram &dest, ValueType& me) { @@ -103,7 +103,7 @@ public: static const char *get_channel_type_name() { return "AnimChannelScalar"; } static const char *get_fixed_channel_type_name() { return "AnimChannelScalarFixed"; } static const char *get_part_type_name() { return "MovingPart"; } - static void output_value(ostream &out, ValueType value) { + static void output_value(std::ostream &out, ValueType value) { out << value; } static void write_datagram(Datagram &dest, ValueType& me) diff --git a/panda/src/chan/animChannelBase.I b/panda/src/chan/animChannelBase.I index dbe24dcc9d..0e86c51027 100644 --- a/panda/src/chan/animChannelBase.I +++ b/panda/src/chan/animChannelBase.I @@ -17,7 +17,7 @@ * created as part of a hierarchy. */ INLINE AnimChannelBase:: -AnimChannelBase(const string &name) +AnimChannelBase(const std::string &name) : AnimGroup(name) { _last_frame = -1; @@ -40,7 +40,7 @@ AnimChannelBase(AnimGroup *parent, const AnimChannelBase ©) : * in the previously-created hierarchy. */ INLINE AnimChannelBase:: -AnimChannelBase(AnimGroup *parent, const string &name) +AnimChannelBase(AnimGroup *parent, const std::string &name) : AnimGroup(parent, name) { _last_frame = -1; diff --git a/panda/src/chan/animChannelBase.h b/panda/src/chan/animChannelBase.h index c3512db282..71493de31d 100644 --- a/panda/src/chan/animChannelBase.h +++ b/panda/src/chan/animChannelBase.h @@ -32,11 +32,11 @@ protected: // The default constructor is protected: don't try to create an AnimChannel // without a parent. To create an AnimChannel hierarchy, you must first // create an AnimBundle, and use that to create any subsequent children. - INLINE AnimChannelBase(const string &name = ""); + INLINE AnimChannelBase(const std::string &name = ""); INLINE AnimChannelBase(AnimGroup *parent, const AnimChannelBase ©); public: - INLINE AnimChannelBase(AnimGroup *parent, const string &name); + INLINE AnimChannelBase(AnimGroup *parent, const std::string &name); virtual bool has_changed(int last_frame, double last_frac, int this_frame, double this_frac); diff --git a/panda/src/chan/animChannelFixed.I b/panda/src/chan/animChannelFixed.I index 9c71438b86..c430366945 100644 --- a/panda/src/chan/animChannelFixed.I +++ b/panda/src/chan/animChannelFixed.I @@ -32,7 +32,7 @@ AnimChannelFixed(AnimGroup *parent, const AnimChannelFixed ©) : */ template INLINE AnimChannelFixed:: -AnimChannelFixed(const string &name, const ValueType &value) +AnimChannelFixed(const std::string &name, const ValueType &value) : AnimChannel(name), _value(value) { } @@ -63,7 +63,7 @@ get_value(int, ValueType &value) { */ template void AnimChannelFixed:: -output(ostream &out) const { +output(std::ostream &out) const { AnimChannel::output(out); out << " = " << _value; } diff --git a/panda/src/chan/animChannelFixed.h b/panda/src/chan/animChannelFixed.h index 0ad0ff5696..a2317d257b 100644 --- a/panda/src/chan/animChannelFixed.h +++ b/panda/src/chan/animChannelFixed.h @@ -34,13 +34,13 @@ protected: INLINE AnimChannelFixed(AnimGroup *parent, const AnimChannelFixed ©); public: - INLINE AnimChannelFixed(const string &name, const ValueType &value); + INLINE AnimChannelFixed(const std::string &name, const ValueType &value); virtual bool has_changed(int last_frame, double last_frac, int this_frame, double this_frac); virtual void get_value(int frame, ValueType &value); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; ValueType _value; diff --git a/panda/src/chan/animChannelMatrixDynamic.h b/panda/src/chan/animChannelMatrixDynamic.h index 8cd9d38904..589b2e7a10 100644 --- a/panda/src/chan/animChannelMatrixDynamic.h +++ b/panda/src/chan/animChannelMatrixDynamic.h @@ -36,7 +36,7 @@ protected: AnimChannelMatrixDynamic(AnimGroup *parent, const AnimChannelMatrixDynamic ©); public: - AnimChannelMatrixDynamic(const string &name); + AnimChannelMatrixDynamic(const std::string &name); virtual bool has_changed(int last_frame, double last_frac, int this_frame, double this_frac); diff --git a/panda/src/chan/animChannelMatrixFixed.h b/panda/src/chan/animChannelMatrixFixed.h index eb34c78321..8b6e06c8ab 100644 --- a/panda/src/chan/animChannelMatrixFixed.h +++ b/panda/src/chan/animChannelMatrixFixed.h @@ -28,7 +28,7 @@ protected: AnimChannelMatrixFixed(AnimGroup *parent, const AnimChannelMatrixFixed ©); public: - AnimChannelMatrixFixed(const string &name, const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale); + AnimChannelMatrixFixed(const std::string &name, const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale); virtual bool has_changed(int last_frame, double last_frac, int this_frame, double this_frac); @@ -40,7 +40,7 @@ public: virtual void get_pos(int frame, LVecBase3 &pos); virtual void get_shear(int frame, LVecBase3 &shear); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: LVecBase3 _pos, _hpr, _scale; diff --git a/panda/src/chan/animChannelMatrixXfmTable.h b/panda/src/chan/animChannelMatrixXfmTable.h index e3a81a7b2a..a5923e59c0 100644 --- a/panda/src/chan/animChannelMatrixXfmTable.h +++ b/panda/src/chan/animChannelMatrixXfmTable.h @@ -34,7 +34,7 @@ protected: AnimChannelMatrixXfmTable(AnimGroup *parent, const AnimChannelMatrixXfmTable ©); PUBLISHED: - explicit AnimChannelMatrixXfmTable(AnimGroup *parent, const string &name); + explicit AnimChannelMatrixXfmTable(AnimGroup *parent, const std::string &name); virtual ~AnimChannelMatrixXfmTable(); public: @@ -60,7 +60,7 @@ PUBLISHED: INLINE void clear_table(char table_id); public: - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; protected: virtual AnimGroup *make_copy(AnimGroup *parent) const; diff --git a/panda/src/chan/animChannelScalarDynamic.h b/panda/src/chan/animChannelScalarDynamic.h index 72828d968d..ab009a4f1f 100644 --- a/panda/src/chan/animChannelScalarDynamic.h +++ b/panda/src/chan/animChannelScalarDynamic.h @@ -36,7 +36,7 @@ protected: AnimChannelScalarDynamic(AnimGroup *parent, const AnimChannelScalarDynamic ©); public: - AnimChannelScalarDynamic(const string &name); + AnimChannelScalarDynamic(const std::string &name); virtual bool has_changed(int last_frame, double last_frac, int this_frame, double this_frac); diff --git a/panda/src/chan/animChannelScalarTable.h b/panda/src/chan/animChannelScalarTable.h index 2d706b9e7c..e150d8d82e 100644 --- a/panda/src/chan/animChannelScalarTable.h +++ b/panda/src/chan/animChannelScalarTable.h @@ -31,7 +31,7 @@ protected: AnimChannelScalarTable(AnimGroup *parent, const AnimChannelScalarTable ©); public: - AnimChannelScalarTable(AnimGroup *parent, const string &name); + AnimChannelScalarTable(AnimGroup *parent, const std::string &name); virtual bool has_changed(int last_frame, double last_frac, int this_frame, double this_frac); @@ -45,7 +45,7 @@ PUBLISHED: INLINE void clear_table(); public: - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; protected: virtual AnimGroup *make_copy(AnimGroup *parent) const; diff --git a/panda/src/chan/animControl.I b/panda/src/chan/animControl.I index 4c493dd943..dd85c9cdea 100644 --- a/panda/src/chan/animControl.I +++ b/panda/src/chan/animControl.I @@ -88,8 +88,8 @@ get_anim_model() const { return _anim_model; } -INLINE ostream & -operator << (ostream &out, const AnimControl &control) { +INLINE std::ostream & +operator << (std::ostream &out, const AnimControl &control) { control.output(out); return out; } diff --git a/panda/src/chan/animControl.h b/panda/src/chan/animControl.h index 09b5e203a1..bee9f7223b 100644 --- a/panda/src/chan/animControl.h +++ b/panda/src/chan/animControl.h @@ -37,7 +37,7 @@ class AnimChannelBase; */ class EXPCL_PANDA_CHAN AnimControl : public TypedReferenceCount, public AnimInterface, public Namable { public: - AnimControl(const string &name, PartBundle *part, + AnimControl(const std::string &name, PartBundle *part, double frame_rate, int num_frames); void setup_anim(PartBundle *part, AnimBundle *anim, int channel_index, const BitArray &bound_joints); @@ -50,8 +50,8 @@ PUBLISHED: INLINE bool is_pending() const; void wait_pending(); INLINE bool has_anim() const; - void set_pending_done_event(const string &done_event); - string get_pending_done_event() const; + void set_pending_done_event(const std::string &done_event); + std::string get_pending_done_event() const; PartBundle *get_part() const; INLINE AnimBundle *get_anim() const; @@ -61,7 +61,7 @@ PUBLISHED: INLINE void set_anim_model(PandaNode *model); INLINE PandaNode *get_anim_model() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; public: // The following functions aren't really part of the public interface; @@ -75,7 +75,7 @@ protected: private: bool _pending; - string _pending_done_event; + std::string _pending_done_event; Mutex _pending_lock; // protects the above two. ConditionVarFull _pending_cvar; // signals when _pending goes true. @@ -118,7 +118,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const AnimControl &control); +INLINE std::ostream &operator << (std::ostream &out, const AnimControl &control); #include "animControl.I" diff --git a/panda/src/chan/animControlCollection.I b/panda/src/chan/animControlCollection.I index 2492c3ad03..d103140992 100644 --- a/panda/src/chan/animControlCollection.I +++ b/panda/src/chan/animControlCollection.I @@ -15,7 +15,7 @@ * Starts the named animation playing. */ INLINE bool AnimControlCollection:: -play(const string &anim_name) { +play(const std::string &anim_name) { AnimControl *control = find_anim(anim_name); if (control == nullptr) { return false; @@ -29,7 +29,7 @@ play(const string &anim_name) { * Starts the named animation playing. */ INLINE bool AnimControlCollection:: -play(const string &anim_name, double from, double to) { +play(const std::string &anim_name, double from, double to) { AnimControl *control = find_anim(anim_name); if (control == nullptr) { return false; @@ -43,7 +43,7 @@ play(const string &anim_name, double from, double to) { * Starts the named animation looping. */ INLINE bool AnimControlCollection:: -loop(const string &anim_name, bool restart) { +loop(const std::string &anim_name, bool restart) { AnimControl *control = find_anim(anim_name); if (control == nullptr) { return false; @@ -57,7 +57,7 @@ loop(const string &anim_name, bool restart) { * Starts the named animation looping. */ INLINE bool AnimControlCollection:: -loop(const string &anim_name, bool restart, double from, double to) { +loop(const std::string &anim_name, bool restart, double from, double to) { AnimControl *control = find_anim(anim_name); if (control == nullptr) { return false; @@ -71,7 +71,7 @@ loop(const string &anim_name, bool restart, double from, double to) { * Stops the named animation. */ INLINE bool AnimControlCollection:: -stop(const string &anim_name) { +stop(const std::string &anim_name) { AnimControl *control = find_anim(anim_name); if (control == nullptr) { return false; @@ -85,7 +85,7 @@ stop(const string &anim_name) { * Sets to a particular frame in the named animation. */ INLINE bool AnimControlCollection:: -pose(const string &anim_name, double frame) { +pose(const std::string &anim_name, double frame) { AnimControl *control = find_anim(anim_name); if (control == nullptr) { return false; @@ -100,7 +100,7 @@ pose(const string &anim_name, double frame) { * not found. */ INLINE int AnimControlCollection:: -get_frame(const string &anim_name) const { +get_frame(const std::string &anim_name) const { AnimControl *control = find_anim(anim_name); if (control == nullptr) { return 0; @@ -123,7 +123,7 @@ get_frame() const { * Returns true if the named animation is currently playing, false otherwise. */ INLINE bool AnimControlCollection:: -is_playing(const string &anim_name) const { +is_playing(const std::string &anim_name) const { AnimControl *control = find_anim(anim_name); if (control == nullptr) { return false; @@ -148,7 +148,7 @@ is_playing() const { * animation is not found. */ INLINE int AnimControlCollection:: -get_num_frames(const string &anim_name) const { +get_num_frames(const std::string &anim_name) const { AnimControl *control = find_anim(anim_name); if (control == nullptr) { return 0; @@ -167,8 +167,8 @@ get_num_frames() const { return _last_started_control->get_num_frames(); } -INLINE ostream & -operator << (ostream &out, const AnimControlCollection &collection) { +INLINE std::ostream & +operator << (std::ostream &out, const AnimControlCollection &collection) { collection.output(out); return out; } diff --git a/panda/src/chan/animControlCollection.h b/panda/src/chan/animControlCollection.h index 74db2fea86..4467520e54 100644 --- a/panda/src/chan/animControlCollection.h +++ b/panda/src/chan/animControlCollection.h @@ -35,13 +35,13 @@ PUBLISHED: AnimControlCollection(); ~AnimControlCollection(); - void store_anim(AnimControl *control, const string &name); - AnimControl *find_anim(const string &name) const; - bool unbind_anim(const string &name); + void store_anim(AnimControl *control, const std::string &name); + AnimControl *find_anim(const std::string &name) const; + bool unbind_anim(const std::string &name); int get_num_anims() const; AnimControl *get_anim(int n) const; - string get_anim_name(int n) const; + std::string get_anim_name(int n) const; MAKE_SEQ(get_anims, get_num_anims, get_anim); MAKE_SEQ(get_anim_names, get_num_anims, get_anim_name); @@ -50,12 +50,12 @@ PUBLISHED: // The following functions are convenience functions that vector directly // into the AnimControl's functionality by anim name. - INLINE bool play(const string &anim_name); - INLINE bool play(const string &anim_name, double from, double to); - INLINE bool loop(const string &anim_name, bool restart); - INLINE bool loop(const string &anim_name, bool restart, double from, double to); - INLINE bool stop(const string &anim_name); - INLINE bool pose(const string &anim_name, double frame); + INLINE bool play(const std::string &anim_name); + INLINE bool play(const std::string &anim_name, double from, double to); + INLINE bool loop(const std::string &anim_name, bool restart); + INLINE bool loop(const std::string &anim_name, bool restart, double from, double to); + INLINE bool stop(const std::string &anim_name); + INLINE bool pose(const std::string &anim_name, double frame); // These functions operate on all anims at once. void play_all(); @@ -65,36 +65,36 @@ PUBLISHED: bool stop_all(); void pose_all(double frame); - INLINE int get_frame(const string &anim_name) const; + INLINE int get_frame(const std::string &anim_name) const; INLINE int get_frame() const; - INLINE int get_num_frames(const string &anim_name) const; + INLINE int get_num_frames(const std::string &anim_name) const; INLINE int get_num_frames() const; - INLINE bool is_playing(const string &anim_name) const; + INLINE bool is_playing(const std::string &anim_name) const; INLINE bool is_playing() const; - string which_anim_playing() const; + std::string which_anim_playing() const; - void output(ostream &out) const; - void write(ostream &out) const; + void output(std::ostream &out) const; + void write(std::ostream &out) const; private: class ControlDef { public: - string _name; + std::string _name; PT(AnimControl) _control; }; typedef pvector Controls; Controls _controls; - typedef pmap ControlsByName; + typedef pmap ControlsByName; ControlsByName _controls_by_name; AnimControl *_last_started_control; }; -INLINE ostream &operator << (ostream &out, const AnimControlCollection &collection); +INLINE std::ostream &operator << (std::ostream &out, const AnimControlCollection &collection); #include "animControlCollection.I" diff --git a/panda/src/chan/animGroup.h b/panda/src/chan/animGroup.h index 50067213d8..cc3fdb3394 100644 --- a/panda/src/chan/animGroup.h +++ b/panda/src/chan/animGroup.h @@ -32,20 +32,20 @@ class FactoryParams; */ class EXPCL_PANDA_CHAN AnimGroup : public TypedWritableReferenceCount, public Namable { protected: - AnimGroup(const string &name = ""); + AnimGroup(const std::string &name = ""); AnimGroup(AnimGroup *parent, const AnimGroup ©); PUBLISHED: // This is the normal AnimGroup constructor. - explicit AnimGroup(AnimGroup *parent, const string &name); + explicit AnimGroup(AnimGroup *parent, const std::string &name); virtual ~AnimGroup(); int get_num_children() const; AnimGroup *get_child(int n) const; MAKE_SEQ(get_children, get_num_children, get_child); - AnimGroup *get_child_named(const string &name) const; - AnimGroup *find_child(const string &name) const; + AnimGroup *get_child_named(const std::string &name) const; + AnimGroup *find_child(const std::string &name) const; void sort_descendants(); MAKE_SEQ_PROPERTY(children, get_num_children, get_child); @@ -54,11 +54,11 @@ public: virtual TypeHandle get_value_type() const; PUBLISHED: - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; protected: - void write_descendants(ostream &out, int indent_level) const; + void write_descendants(std::ostream &out, int indent_level) const; virtual AnimGroup *make_copy(AnimGroup *parent) const; PT(AnimGroup) copy_subtree(AnimGroup *parent) const; @@ -80,7 +80,7 @@ protected: void fillin(DatagramIterator& scan, BamReader* manager); private: - typedef pvector< string > frozenJoints; + typedef pvector< std::string > frozenJoints; int _num_children; public: @@ -102,7 +102,7 @@ private: static TypeHandle _type_handle; }; -inline ostream &operator << (ostream &out, const AnimGroup &anim) { +inline std::ostream &operator << (std::ostream &out, const AnimGroup &anim) { anim.output(out); return out; } diff --git a/panda/src/chan/animPreloadTable.I b/panda/src/chan/animPreloadTable.I index a2555c5a9d..fc996c2859 100644 --- a/panda/src/chan/animPreloadTable.I +++ b/panda/src/chan/animPreloadTable.I @@ -29,9 +29,9 @@ operator < (const AnimRecord &other) const { /** * Returns the basename stored for the nth animation record. See find_anim(). */ -INLINE string AnimPreloadTable:: +INLINE std::string AnimPreloadTable:: get_basename(int n) const { - nassertr(n >= 0 && n < (int)_anims.size(), string()); + nassertr(n >= 0 && n < (int)_anims.size(), std::string()); consider_sort(); return _anims[n]._basename; } diff --git a/panda/src/chan/animPreloadTable.h b/panda/src/chan/animPreloadTable.h index 123cd00eb4..e4fd64915b 100644 --- a/panda/src/chan/animPreloadTable.h +++ b/panda/src/chan/animPreloadTable.h @@ -39,7 +39,7 @@ public: INLINE AnimRecord(); INLINE bool operator < (const AnimRecord &other) const; - string _basename; + std::string _basename; PN_stdfloat _base_frame_rate; int _num_frames; }; @@ -52,19 +52,19 @@ PUBLISHED: virtual ~AnimPreloadTable(); int get_num_anims() const; - int find_anim(const string &basename) const; + int find_anim(const std::string &basename) const; - INLINE string get_basename(int n) const; + INLINE std::string get_basename(int n) const; INLINE PN_stdfloat get_base_frame_rate(int n) const; INLINE int get_num_frames(int n) const; void clear_anims(); void remove_anim(int n); - void add_anim(const string &basename, PN_stdfloat base_frame_rate, int num_frames); + void add_anim(const std::string &basename, PN_stdfloat base_frame_rate, int num_frames); void add_anims_from(const AnimPreloadTable *other); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; private: INLINE void consider_sort() const; @@ -101,7 +101,7 @@ private: static TypeHandle _type_handle; }; -inline ostream &operator << (ostream &out, const AnimPreloadTable &anim) { +inline std::ostream &operator << (std::ostream &out, const AnimPreloadTable &anim) { anim.output(out); return out; } diff --git a/panda/src/chan/bindAnimRequest.h b/panda/src/chan/bindAnimRequest.h index 1c555de10a..f3d0314b6a 100644 --- a/panda/src/chan/bindAnimRequest.h +++ b/panda/src/chan/bindAnimRequest.h @@ -30,7 +30,7 @@ public: ALLOC_DELETED_CHAIN(BindAnimRequest); PUBLISHED: - explicit BindAnimRequest(const string &name, + explicit BindAnimRequest(const std::string &name, const Filename &filename, const LoaderOptions &options, Loader *loader, diff --git a/panda/src/chan/movingPart.I b/panda/src/chan/movingPart.I index 8b988d9422..9b0d35e9c8 100644 --- a/panda/src/chan/movingPart.I +++ b/panda/src/chan/movingPart.I @@ -43,7 +43,7 @@ MovingPart(const MovingPart ©) : */ template INLINE MovingPart:: -MovingPart(PartGroup *parent, const string &name, +MovingPart(PartGroup *parent, const std::string &name, const ValueType &default_value) : MovingPartBase(parent, name), _value(default_value), @@ -87,7 +87,7 @@ make_default_channel() const { */ template void MovingPart:: -output_value(ostream &out) const { +output_value(std::ostream &out) const { SwitchType::output_value(out, _value); } diff --git a/panda/src/chan/movingPart.h b/panda/src/chan/movingPart.h index dd6dc7540b..8673a271d6 100644 --- a/panda/src/chan/movingPart.h +++ b/panda/src/chan/movingPart.h @@ -33,12 +33,12 @@ protected: INLINE MovingPart(const MovingPart ©); public: - INLINE MovingPart(PartGroup *parent, const string &name, + INLINE MovingPart(PartGroup *parent, const std::string &name, const ValueType &default_value); virtual TypeHandle get_value_type() const; virtual AnimChannelBase *make_default_channel() const; - virtual void output_value(ostream &out) const; + virtual void output_value(std::ostream &out) const; ValueType _value; ValueType _default_value; diff --git a/panda/src/chan/movingPartBase.h b/panda/src/chan/movingPartBase.h index 3618cbfd19..c7b09c8acf 100644 --- a/panda/src/chan/movingPartBase.h +++ b/panda/src/chan/movingPartBase.h @@ -33,7 +33,7 @@ protected: INLINE MovingPartBase(const MovingPartBase ©); public: - MovingPartBase(PartGroup *parent, const string &name); + MovingPartBase(PartGroup *parent, const std::string &name); PUBLISHED: INLINE int get_max_bound() const; @@ -47,9 +47,9 @@ PUBLISHED: virtual bool clear_forced_channel(); virtual AnimChannelBase *get_forced_channel() const; - virtual void write(ostream &out, int indent_level) const; - virtual void write_with_value(ostream &out, int indent_level) const; - virtual void output_value(ostream &out) const=0; + virtual void write(std::ostream &out, int indent_level) const; + virtual void write_with_value(std::ostream &out, int indent_level) const; + virtual void output_value(std::ostream &out) const=0; public: virtual bool do_update(PartBundle *root, const CycleData *root_cdata, diff --git a/panda/src/chan/movingPartMatrix.I b/panda/src/chan/movingPartMatrix.I index a545f9f9fa..f9432b312e 100644 --- a/panda/src/chan/movingPartMatrix.I +++ b/panda/src/chan/movingPartMatrix.I @@ -24,7 +24,7 @@ MovingPartMatrix(const MovingPartMatrix ©) : * */ INLINE MovingPartMatrix:: -MovingPartMatrix(PartGroup *parent, const string &name, +MovingPartMatrix(PartGroup *parent, const std::string &name, const LMatrix4 &default_value) : MovingPart(parent, name, default_value) { } diff --git a/panda/src/chan/movingPartMatrix.h b/panda/src/chan/movingPartMatrix.h index 3c232e63d0..364686555a 100644 --- a/panda/src/chan/movingPartMatrix.h +++ b/panda/src/chan/movingPartMatrix.h @@ -31,7 +31,7 @@ protected: INLINE MovingPartMatrix(const MovingPartMatrix ©); public: - INLINE MovingPartMatrix(PartGroup *parent, const string &name, + INLINE MovingPartMatrix(PartGroup *parent, const std::string &name, const LMatrix4 &default_value); virtual ~MovingPartMatrix(); diff --git a/panda/src/chan/movingPartScalar.I b/panda/src/chan/movingPartScalar.I index e49a542575..1b585746e4 100644 --- a/panda/src/chan/movingPartScalar.I +++ b/panda/src/chan/movingPartScalar.I @@ -24,7 +24,7 @@ MovingPartScalar(const MovingPartScalar ©) : * */ INLINE MovingPartScalar:: -MovingPartScalar(PartGroup *parent, const string &name, +MovingPartScalar(PartGroup *parent, const std::string &name, const PN_stdfloat &default_value) : MovingPart(parent, name, default_value) { } diff --git a/panda/src/chan/movingPartScalar.h b/panda/src/chan/movingPartScalar.h index 90bd049ee5..d05e58f4e7 100644 --- a/panda/src/chan/movingPartScalar.h +++ b/panda/src/chan/movingPartScalar.h @@ -30,7 +30,7 @@ protected: INLINE MovingPartScalar(const MovingPartScalar ©); public: - INLINE MovingPartScalar(PartGroup *parent, const string &name, + INLINE MovingPartScalar(PartGroup *parent, const std::string &name, const PN_stdfloat &default_value = 0); virtual ~MovingPartScalar(); diff --git a/panda/src/chan/partBundle.h b/panda/src/chan/partBundle.h index 80ddb4122d..7a611a80de 100644 --- a/panda/src/chan/partBundle.h +++ b/panda/src/chan/partBundle.h @@ -55,7 +55,7 @@ protected: PartBundle(const PartBundle ©); PUBLISHED: - explicit PartBundle(const string &name = ""); + explicit PartBundle(const std::string &name = ""); virtual PartGroup *make_copy() const; INLINE CPT(AnimPreloadTable) get_anim_preload() const; @@ -123,8 +123,8 @@ PUBLISHED: INLINE void set_control_effect(AnimControl *control, PN_stdfloat effect); INLINE PN_stdfloat get_control_effect(AnimControl *control) const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; PT(AnimControl) bind_anim(AnimBundle *anim, int hierarchy_match_flags = 0, @@ -136,11 +136,11 @@ PUBLISHED: bool allow_async); void wait_pending(); - bool freeze_joint(const string &joint_name, const TransformState *transform); - bool freeze_joint(const string &joint_name, const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale); - bool freeze_joint(const string &joint_name, PN_stdfloat value); - bool control_joint(const string &joint_name, PandaNode *node); - bool release_joint(const string &joint_name); + bool freeze_joint(const std::string &joint_name, const TransformState *transform); + bool freeze_joint(const std::string &joint_name, const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale); + bool freeze_joint(const std::string &joint_name, PN_stdfloat value); + bool control_joint(const std::string &joint_name, PandaNode *node); + bool release_joint(const std::string &joint_name); bool update(); bool force_update(); @@ -243,13 +243,13 @@ private: friend class MovingPartScalar; }; -inline ostream &operator <<(ostream &out, const PartBundle &bundle) { +inline std::ostream &operator <<(std::ostream &out, const PartBundle &bundle) { bundle.output(out); return out; } -ostream &operator <<(ostream &out, PartBundle::BlendType blend_type); -istream &operator >>(istream &in, PartBundle::BlendType &blend_type); +std::ostream &operator <<(std::ostream &out, PartBundle::BlendType blend_type); +std::istream &operator >>(std::istream &in, PartBundle::BlendType &blend_type); #include "partBundle.I" diff --git a/panda/src/chan/partBundleNode.I b/panda/src/chan/partBundleNode.I index 721e930bd9..e9da42359c 100644 --- a/panda/src/chan/partBundleNode.I +++ b/panda/src/chan/partBundleNode.I @@ -17,7 +17,7 @@ * the appropriate type, and pass it up to this constructor. */ INLINE PartBundleNode:: -PartBundleNode(const string &name, PartBundle *bundle) : +PartBundleNode(const std::string &name, PartBundle *bundle) : PandaNode(name) { add_bundle(bundle); diff --git a/panda/src/chan/partBundleNode.h b/panda/src/chan/partBundleNode.h index 231c1175ee..6cb98638d1 100644 --- a/panda/src/chan/partBundleNode.h +++ b/panda/src/chan/partBundleNode.h @@ -34,7 +34,7 @@ */ class EXPCL_PANDA_CHAN PartBundleNode : public PandaNode { PUBLISHED: - INLINE explicit PartBundleNode(const string &name, PartBundle *bundle); + INLINE explicit PartBundleNode(const std::string &name, PartBundle *bundle); protected: INLINE PartBundleNode(); diff --git a/panda/src/chan/partGroup.I b/panda/src/chan/partGroup.I index 4b1c166bad..250cd195eb 100644 --- a/panda/src/chan/partGroup.I +++ b/panda/src/chan/partGroup.I @@ -16,7 +16,7 @@ * You should normally use the non-default constructor, below. */ INLINE PartGroup:: -PartGroup(const string &name) : +PartGroup(const std::string &name) : Namable(name), _children(get_class_type()) { diff --git a/panda/src/chan/partGroup.h b/panda/src/chan/partGroup.h index ae5f919b7c..0dd9f8c7dd 100644 --- a/panda/src/chan/partGroup.h +++ b/panda/src/chan/partGroup.h @@ -55,12 +55,12 @@ protected: // The default constructor is protected: don't try to create a PartGroup // without a parent. To create a PartGroup hierarchy, you must first create // a PartBundle, and use that as the parent of any subsequent children. - INLINE PartGroup(const string &name = ""); + INLINE PartGroup(const std::string &name = ""); INLINE PartGroup(const PartGroup ©); PUBLISHED: // This is the normal PartGroup constructor. - explicit PartGroup(PartGroup *parent, const string &name); + explicit PartGroup(PartGroup *parent, const std::string &name); virtual ~PartGroup(); virtual bool is_character_joint() const; @@ -71,8 +71,8 @@ PUBLISHED: PartGroup *get_child(int n) const; MAKE_SEQ(get_children, get_num_children, get_child); - PartGroup *get_child_named(const string &name) const; - PartGroup *find_child(const string &name) const; + PartGroup *get_child_named(const std::string &name) const; + PartGroup *find_child(const std::string &name) const; void sort_descendants(); MAKE_SEQ_PROPERTY(children, get_num_children, get_child); @@ -84,8 +84,8 @@ PUBLISHED: virtual bool clear_forced_channel(); virtual AnimChannelBase *get_forced_channel() const; - virtual void write(ostream &out, int indent_level) const; - virtual void write_with_value(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; + virtual void write_with_value(std::ostream &out, int indent_level) const; public: virtual TypeHandle get_value_type() const; @@ -101,8 +101,8 @@ public: virtual void determine_effective_channels(const CycleData *root_cdata); protected: - void write_descendants(ostream &out, int indent_level) const; - void write_descendants_with_value(ostream &out, int indent_level) const; + void write_descendants(std::ostream &out, int indent_level) const; + void write_descendants_with_value(std::ostream &out, int indent_level) const; virtual void pick_channel_index(plist &holes, int &next) const; virtual void bind_hierarchy(AnimGroup *anim, int channel_index, diff --git a/panda/src/chan/partSubset.h b/panda/src/chan/partSubset.h index 93e7bda47f..853849c5ea 100644 --- a/panda/src/chan/partSubset.h +++ b/panda/src/chan/partSubset.h @@ -33,11 +33,11 @@ PUBLISHED: void append(const PartSubset &other); - void output(ostream &out) const; + void output(std::ostream &out) const; bool is_include_empty() const; - bool matches_include(const string &joint_name) const; - bool matches_exclude(const string &joint_name) const; + bool matches_include(const std::string &joint_name) const; + bool matches_exclude(const std::string &joint_name) const; private: typedef pvector Joints; @@ -45,7 +45,7 @@ private: Joints _exclude_joints; }; -INLINE ostream &operator << (ostream &out, const PartSubset &subset) { +INLINE std::ostream &operator << (std::ostream &out, const PartSubset &subset) { subset.output(out); return out; } diff --git a/panda/src/char/character.h b/panda/src/char/character.h index 80492df93c..a7c6c79f13 100644 --- a/panda/src/char/character.h +++ b/panda/src/char/character.h @@ -40,7 +40,7 @@ protected: Character(const Character ©, bool copy_bundles); PUBLISHED: - explicit Character(const string &name); + explicit Character(const std::string &name); virtual ~Character(); public: @@ -68,11 +68,11 @@ PUBLISHED: PN_stdfloat delay_factor); void clear_lod_animation(); - CharacterJoint *find_joint(const string &name) const; - CharacterSlider *find_slider(const string &name) const; + CharacterJoint *find_joint(const std::string &name) const; + CharacterSlider *find_slider(const std::string &name) const; - void write_parts(ostream &out) const; - void write_part_values(ostream &out) const; + void write_parts(std::ostream &out) const; + void write_part_values(std::ostream &out) const; void update_to_now(); void update(); diff --git a/panda/src/char/characterJoint.h b/panda/src/char/characterJoint.h index 5da83def66..83d155f184 100644 --- a/panda/src/char/characterJoint.h +++ b/panda/src/char/characterJoint.h @@ -36,7 +36,7 @@ protected: PUBLISHED: explicit CharacterJoint(Character *character, PartBundle *root, - PartGroup *parent, const string &name, + PartGroup *parent, const std::string &name, const LMatrix4 &default_value); virtual ~CharacterJoint(); diff --git a/panda/src/char/characterJointBundle.h b/panda/src/char/characterJointBundle.h index 4c68fb9b3d..e1c93e1842 100644 --- a/panda/src/char/characterJointBundle.h +++ b/panda/src/char/characterJointBundle.h @@ -30,7 +30,7 @@ protected: INLINE CharacterJointBundle(const CharacterJointBundle ©); PUBLISHED: - explicit CharacterJointBundle(const string &name = ""); + explicit CharacterJointBundle(const std::string &name = ""); virtual ~CharacterJointBundle(); PUBLISHED: diff --git a/panda/src/char/characterJointEffect.h b/panda/src/char/characterJointEffect.h index 372013df54..8b6e11e923 100644 --- a/panda/src/char/characterJointEffect.h +++ b/panda/src/char/characterJointEffect.h @@ -45,7 +45,7 @@ public: virtual bool safe_to_transform() const; virtual bool safe_to_combine() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; virtual bool has_cull_callback() const; virtual void cull_callback(CullTraverser *trav, CullTraverserData &data, diff --git a/panda/src/char/characterSlider.h b/panda/src/char/characterSlider.h index fe7e38945e..3c347af12b 100644 --- a/panda/src/char/characterSlider.h +++ b/panda/src/char/characterSlider.h @@ -31,7 +31,7 @@ protected: CharacterSlider(const CharacterSlider ©); PUBLISHED: - explicit CharacterSlider(PartGroup *parent, const string &name); + explicit CharacterSlider(PartGroup *parent, const std::string &name); virtual ~CharacterSlider(); virtual PartGroup *make_copy() const; diff --git a/panda/src/char/jointVertexTransform.h b/panda/src/char/jointVertexTransform.h index 1be097eba6..ee8b3aafa6 100644 --- a/panda/src/char/jointVertexTransform.h +++ b/panda/src/char/jointVertexTransform.h @@ -44,7 +44,7 @@ PUBLISHED: virtual void mult_matrix(LMatrix4 &result, const LMatrix4 &previous) const; virtual void accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: PT(CharacterJoint) _joint; diff --git a/panda/src/cocoadisplay/cocoaGraphicsBuffer.h b/panda/src/cocoadisplay/cocoaGraphicsBuffer.h index ab666b6f75..3167d2c02f 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsBuffer.h +++ b/panda/src/cocoadisplay/cocoaGraphicsBuffer.h @@ -24,7 +24,7 @@ class CocoaGraphicsBuffer : public GLGraphicsBuffer { public: CocoaGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/cocoadisplay/cocoaGraphicsPipe.h b/panda/src/cocoadisplay/cocoaGraphicsPipe.h index 6f2f863e9c..cc8c8142d5 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsPipe.h +++ b/panda/src/cocoadisplay/cocoaGraphicsPipe.h @@ -40,14 +40,14 @@ public: INLINE CGDirectDisplayID get_display_id() const; - virtual string get_interface_name() const; + virtual std::string get_interface_name() const; static PT(GraphicsPipe) pipe_constructor(); public: virtual PreferredWindowThread get_preferred_window_thread() const; protected: - virtual PT(GraphicsOutput) make_output(const string &name, + virtual PT(GraphicsOutput) make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.h b/panda/src/cocoadisplay/cocoaGraphicsWindow.h index de2bd8d61c..353212f056 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.h +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.h @@ -30,7 +30,7 @@ class CocoaGraphicsWindow : public GraphicsWindow { public: CocoaGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/collada/colladaBindMaterial.h b/panda/src/collada/colladaBindMaterial.h index 18cf5b80a8..2c56f77c78 100644 --- a/panda/src/collada/colladaBindMaterial.h +++ b/panda/src/collada/colladaBindMaterial.h @@ -29,13 +29,13 @@ class domInstance_material; class ColladaBindMaterial { public: CPT(RenderState) get_material(const ColladaPrimitive *prim) const; - CPT(RenderState) get_material(const string &symbol) const; + CPT(RenderState) get_material(const std::string &symbol) const; void load_bind_material(domBind_material &bind_mat); void load_instance_material(domInstance_material &inst); private: - pmap _states; + pmap _states; }; #endif diff --git a/panda/src/collada/colladaInput.h b/panda/src/collada/colladaInput.h index 53629ecf8d..7df605c73c 100644 --- a/panda/src/collada/colladaInput.h +++ b/panda/src/collada/colladaInput.h @@ -52,8 +52,8 @@ public: INLINE unsigned int get_offset() const; private: - ColladaInput(const string &semantic); - ColladaInput(const string &semantic, unsigned int set); + ColladaInput(const std::string &semantic); + ColladaInput(const std::string &semantic, unsigned int set); bool read_data(domSource &source); void write_data(GeomVertexData *vdata, int start_row, domP &p, unsigned int stride, unsigned int offset) const; @@ -67,7 +67,7 @@ private: unsigned int _num_bound_params; unsigned int _offset; - string _semantic; + std::string _semantic; bool _have_set; unsigned int _set; }; diff --git a/panda/src/collada/colladaPrimitive.I b/panda/src/collada/colladaPrimitive.I index 697e028f39..e97263f280 100644 --- a/panda/src/collada/colladaPrimitive.I +++ b/panda/src/collada/colladaPrimitive.I @@ -34,7 +34,7 @@ get_geom() const { * Returns the name of this primitive's material, or the empty string if none * was assigned. */ -INLINE const string &ColladaPrimitive:: +INLINE const std::string &ColladaPrimitive:: get_material() const { return _material; } diff --git a/panda/src/collada/colladaPrimitive.h b/panda/src/collada/colladaPrimitive.h index 740329e020..075bce7f73 100644 --- a/panda/src/collada/colladaPrimitive.h +++ b/panda/src/collada/colladaPrimitive.h @@ -48,7 +48,7 @@ public: unsigned int write_data(GeomVertexData *vdata, int start_row, domP &p); INLINE PT(Geom) get_geom() const; - INLINE const string &get_material() const; + INLINE const std::string &get_material() const; private: ColladaPrimitive(GeomPrimitive *prim, daeTArray > &inputs); @@ -63,7 +63,7 @@ private: PT(Geom) _geom; PT(GeomVertexData) _vdata; PT(GeomPrimitive) _gprim; - string _material; + std::string _material; }; #include "colladaPrimitive.I" diff --git a/panda/src/collada/loaderFileTypeDae.h b/panda/src/collada/loaderFileTypeDae.h index 4cb79a81f9..e762564b86 100644 --- a/panda/src/collada/loaderFileTypeDae.h +++ b/panda/src/collada/loaderFileTypeDae.h @@ -25,9 +25,9 @@ class EXPCL_COLLADA LoaderFileTypeDae : public LoaderFileType { public: LoaderFileTypeDae(); - virtual string get_name() const; - virtual string get_extension() const; - virtual string get_additional_extensions() const; + virtual std::string get_name() const; + virtual std::string get_extension() const; + virtual std::string get_additional_extensions() const; virtual bool supports_compressed() const; virtual PT(PandaNode) load_file(const Filename &path, const LoaderOptions &options, diff --git a/panda/src/collide/collisionBox.h b/panda/src/collide/collisionBox.h index c5bb22be88..0888d7e4da 100644 --- a/panda/src/collide/collisionBox.h +++ b/panda/src/collide/collisionBox.h @@ -46,7 +46,7 @@ public: virtual PStatCollector &get_volume_pcollector(); virtual PStatCollector &get_test_pcollector(); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; INLINE static void flush_level(); void setup_box(); diff --git a/panda/src/collide/collisionEntry.I b/panda/src/collide/collisionEntry.I index 8187ca7a9c..41a591c90e 100644 --- a/panda/src/collide/collisionEntry.I +++ b/panda/src/collide/collisionEntry.I @@ -360,8 +360,8 @@ test_intersection(CollisionHandler *record, } } -INLINE ostream & -operator << (ostream &out, const CollisionEntry &entry) { +INLINE std::ostream & +operator << (std::ostream &out, const CollisionEntry &entry) { entry.output(out); return out; } diff --git a/panda/src/collide/collisionEntry.h b/panda/src/collide/collisionEntry.h index 558a6afa70..03d39c03d5 100644 --- a/panda/src/collide/collisionEntry.h +++ b/panda/src/collide/collisionEntry.h @@ -90,8 +90,8 @@ PUBLISHED: LPoint3 &contact_pos, LVector3 &contact_normal) const; - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; PUBLISHED: MAKE_PROPERTY(from_solid, get_from); @@ -170,7 +170,7 @@ private: friend class CollisionHandlerFluidPusher; }; -INLINE ostream &operator << (ostream &out, const CollisionEntry &entry); +INLINE std::ostream &operator << (std::ostream &out, const CollisionEntry &entry); #include "collisionEntry.I" diff --git a/panda/src/collide/collisionFloorMesh.h b/panda/src/collide/collisionFloorMesh.h index 44e9d18e32..9304b79e11 100644 --- a/panda/src/collide/collisionFloorMesh.h +++ b/panda/src/collide/collisionFloorMesh.h @@ -69,8 +69,8 @@ public: virtual PStatCollector &get_volume_pcollector(); virtual PStatCollector &get_test_pcollector(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; INLINE static void flush_level(); diff --git a/panda/src/collide/collisionGeom.h b/panda/src/collide/collisionGeom.h index 20e736dba4..ba63263f26 100644 --- a/panda/src/collide/collisionGeom.h +++ b/panda/src/collide/collisionGeom.h @@ -38,7 +38,7 @@ public: virtual PStatCollector &get_volume_pcollector(); virtual PStatCollector &get_test_pcollector(); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: static PStatCollector _volume_pcollector; diff --git a/panda/src/collide/collisionHandlerEvent.I b/panda/src/collide/collisionHandlerEvent.I index 28efe50dcc..d5b6327c69 100644 --- a/panda/src/collide/collisionHandlerEvent.I +++ b/panda/src/collide/collisionHandlerEvent.I @@ -73,7 +73,7 @@ clear_in_patterns() { * longer detected, the out_pattern event is thrown. */ INLINE void CollisionHandlerEvent:: -add_in_pattern(const string &in_pattern) { +add_in_pattern(const std::string &in_pattern) { _in_patterns.push_back(in_pattern); } @@ -82,7 +82,7 @@ add_in_pattern(const string &in_pattern) { * have previously been set with the indicated pattern. */ INLINE void CollisionHandlerEvent:: -set_in_pattern(const string &in_pattern) { +set_in_pattern(const std::string &in_pattern) { clear_in_patterns(); add_in_pattern(in_pattern); } @@ -99,9 +99,9 @@ get_num_in_patterns() const { * Returns the nth pattern string that indicates how the event names are * generated for each collision detected. See add_in_pattern(). */ -INLINE string CollisionHandlerEvent:: +INLINE std::string CollisionHandlerEvent:: get_in_pattern(int n) const { - nassertr(n >= 0 && n < (int)_in_patterns.size(), string()); + nassertr(n >= 0 && n < (int)_in_patterns.size(), std::string()); return _in_patterns[n]; } @@ -126,7 +126,7 @@ clear_again_patterns() { * longer detected, the out_pattern event is thrown. */ INLINE void CollisionHandlerEvent:: -add_again_pattern(const string &again_pattern) { +add_again_pattern(const std::string &again_pattern) { _again_patterns.push_back(again_pattern); } @@ -135,7 +135,7 @@ add_again_pattern(const string &again_pattern) { * have previously been set with the indicated pattern. */ INLINE void CollisionHandlerEvent:: -set_again_pattern(const string &again_pattern) { +set_again_pattern(const std::string &again_pattern) { clear_again_patterns(); add_again_pattern(again_pattern); } @@ -152,9 +152,9 @@ get_num_again_patterns() const { * Returns the nth pattern string that indicates how the event names are * generated for each collision detected. See add_again_pattern(). */ -INLINE string CollisionHandlerEvent:: +INLINE std::string CollisionHandlerEvent:: get_again_pattern(int n) const { - nassertr(n >= 0 && n < (int)_again_patterns.size(), string()); + nassertr(n >= 0 && n < (int)_again_patterns.size(), std::string()); return _again_patterns[n]; } @@ -177,7 +177,7 @@ clear_out_patterns() { * longer detected, the out_pattern event is thrown. */ INLINE void CollisionHandlerEvent:: -add_out_pattern(const string &out_pattern) { +add_out_pattern(const std::string &out_pattern) { _out_patterns.push_back(out_pattern); } @@ -186,7 +186,7 @@ add_out_pattern(const string &out_pattern) { * have previously been set with the indicated pattern. */ INLINE void CollisionHandlerEvent:: -set_out_pattern(const string &out_pattern) { +set_out_pattern(const std::string &out_pattern) { clear_out_patterns(); add_out_pattern(out_pattern); } @@ -203,8 +203,8 @@ get_num_out_patterns() const { * Returns the nth pattern string that indicates how the event names are * generated for each collision detected. See add_out_pattern(). */ -INLINE string CollisionHandlerEvent:: +INLINE std::string CollisionHandlerEvent:: get_out_pattern(int n) const { - nassertr(n >= 0 && n < (int)_out_patterns.size(), string()); + nassertr(n >= 0 && n < (int)_out_patterns.size(), std::string()); return _out_patterns[n]; } diff --git a/panda/src/collide/collisionHandlerEvent.h b/panda/src/collide/collisionHandlerEvent.h index a1240882d6..808ee888c5 100644 --- a/panda/src/collide/collisionHandlerEvent.h +++ b/panda/src/collide/collisionHandlerEvent.h @@ -40,24 +40,24 @@ public: PUBLISHED: INLINE void clear_in_patterns(); - INLINE void add_in_pattern(const string &in_pattern); - INLINE void set_in_pattern(const string &in_pattern); + INLINE void add_in_pattern(const std::string &in_pattern); + INLINE void set_in_pattern(const std::string &in_pattern); INLINE int get_num_in_patterns() const; - INLINE string get_in_pattern(int n) const; + INLINE std::string get_in_pattern(int n) const; MAKE_SEQ(get_in_patterns, get_num_in_patterns, get_in_pattern); INLINE void clear_again_patterns(); - INLINE void add_again_pattern(const string &again_pattern); - INLINE void set_again_pattern(const string &again_pattern); + INLINE void add_again_pattern(const std::string &again_pattern); + INLINE void set_again_pattern(const std::string &again_pattern); INLINE int get_num_again_patterns() const; - INLINE string get_again_pattern(int n) const; + INLINE std::string get_again_pattern(int n) const; MAKE_SEQ(get_again_patterns, get_num_again_patterns, get_again_pattern); INLINE void clear_out_patterns(); - INLINE void add_out_pattern(const string &out_pattern); - INLINE void set_out_pattern(const string &out_pattern); + INLINE void add_out_pattern(const std::string &out_pattern); + INLINE void set_out_pattern(const std::string &out_pattern); INLINE int get_num_out_patterns() const; - INLINE string get_out_pattern(int n) const; + INLINE std::string get_out_pattern(int n) const; MAKE_SEQ(get_out_patterns, get_num_out_patterns, get_out_pattern); MAKE_SEQ_PROPERTY(in_patterns, get_num_in_patterns, get_in_pattern); @@ -69,7 +69,7 @@ PUBLISHED: protected: void throw_event_for(const vector_string &patterns, CollisionEntry *entry); - void throw_event_pattern(const string &pattern, CollisionEntry *entry); + void throw_event_pattern(const std::string &pattern, CollisionEntry *entry); vector_string _in_patterns; vector_string _again_patterns; diff --git a/panda/src/collide/collisionHandlerQueue.h b/panda/src/collide/collisionHandlerQueue.h index 0651b545c7..cfef93c540 100644 --- a/panda/src/collide/collisionHandlerQueue.h +++ b/panda/src/collide/collisionHandlerQueue.h @@ -42,8 +42,8 @@ PUBLISHED: MAKE_SEQ(get_entries, get_num_entries, get_entry); MAKE_SEQ_PROPERTY(entries, get_num_entries, get_entry); - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; private: typedef pvector< PT(CollisionEntry) > Entries; @@ -67,7 +67,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const CollisionHandlerQueue &chq) { +INLINE std::ostream &operator << (std::ostream &out, const CollisionHandlerQueue &chq) { chq.output(out); return out; } diff --git a/panda/src/collide/collisionInvSphere.h b/panda/src/collide/collisionInvSphere.h index ffc9628a5b..fe8b43b10d 100644 --- a/panda/src/collide/collisionInvSphere.h +++ b/panda/src/collide/collisionInvSphere.h @@ -42,7 +42,7 @@ public: virtual PStatCollector &get_volume_pcollector(); virtual PStatCollector &get_test_pcollector(); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual PT(BoundingVolume) compute_internal_bounds() const; diff --git a/panda/src/collide/collisionLine.h b/panda/src/collide/collisionLine.h index 71904192de..d2a0236046 100644 --- a/panda/src/collide/collisionLine.h +++ b/panda/src/collide/collisionLine.h @@ -36,7 +36,7 @@ public: virtual PT(CollisionEntry) test_intersection(const CollisionEntry &entry) const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual void fill_viz_geom(); diff --git a/panda/src/collide/collisionNode.h b/panda/src/collide/collisionNode.h index e9a61b404d..8dd46f6a28 100644 --- a/panda/src/collide/collisionNode.h +++ b/panda/src/collide/collisionNode.h @@ -29,7 +29,7 @@ */ class EXPCL_PANDA_COLLIDE CollisionNode : public PandaNode { PUBLISHED: - explicit CollisionNode(const string &name); + explicit CollisionNode(const std::string &name); protected: CollisionNode(const CollisionNode ©); @@ -46,7 +46,7 @@ public: virtual bool is_renderable() const; virtual bool is_collision_node() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; PUBLISHED: INLINE void set_collide_mask(CollideMask mask); diff --git a/panda/src/collide/collisionParabola.h b/panda/src/collide/collisionParabola.h index 2f72518ac4..c09a932938 100644 --- a/panda/src/collide/collisionParabola.h +++ b/panda/src/collide/collisionParabola.h @@ -48,7 +48,7 @@ public: virtual PStatCollector &get_volume_pcollector(); virtual PStatCollector &get_test_pcollector(); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; PUBLISHED: INLINE void set_parabola(const LParabola ¶bola); diff --git a/panda/src/collide/collisionPlane.h b/panda/src/collide/collisionPlane.h index 4130cf2151..bc7602ba8b 100644 --- a/panda/src/collide/collisionPlane.h +++ b/panda/src/collide/collisionPlane.h @@ -42,7 +42,7 @@ public: virtual PStatCollector &get_volume_pcollector(); virtual PStatCollector &get_test_pcollector(); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; INLINE static void flush_level(); diff --git a/panda/src/collide/collisionPolygon.h b/panda/src/collide/collisionPolygon.h index 464c0e73b6..1ef095fd92 100644 --- a/panda/src/collide/collisionPolygon.h +++ b/panda/src/collide/collisionPolygon.h @@ -74,8 +74,8 @@ public: virtual PStatCollector &get_volume_pcollector(); virtual PStatCollector &get_test_pcollector(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; INLINE static void flush_level(); diff --git a/panda/src/collide/collisionRay.h b/panda/src/collide/collisionRay.h index d317761906..99b7446ced 100644 --- a/panda/src/collide/collisionRay.h +++ b/panda/src/collide/collisionRay.h @@ -42,7 +42,7 @@ public: virtual void xform(const LMatrix4 &mat); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; PUBLISHED: INLINE void set_origin(const LPoint3 &origin); diff --git a/panda/src/collide/collisionRecorder.h b/panda/src/collide/collisionRecorder.h index a9ceefa250..08a254122c 100644 --- a/panda/src/collide/collisionRecorder.h +++ b/panda/src/collide/collisionRecorder.h @@ -35,7 +35,7 @@ public: virtual ~CollisionRecorder(); PUBLISHED: - void output(ostream &out) const; + void output(std::ostream &out) const; public: virtual void begin_traversal(); diff --git a/panda/src/collide/collisionSegment.h b/panda/src/collide/collisionSegment.h index 429eff426d..705855b791 100644 --- a/panda/src/collide/collisionSegment.h +++ b/panda/src/collide/collisionSegment.h @@ -46,7 +46,7 @@ public: virtual void xform(const LMatrix4 &mat); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; PUBLISHED: INLINE void set_point_a(const LPoint3 &a); diff --git a/panda/src/collide/collisionSolid.h b/panda/src/collide/collisionSolid.h index 4f80cb922a..6b2914e954 100644 --- a/panda/src/collide/collisionSolid.h +++ b/panda/src/collide/collisionSolid.h @@ -89,8 +89,8 @@ public: virtual PStatCollector &get_test_pcollector(); PUBLISHED: - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; protected: INLINE bool do_is_tangible() const; @@ -183,7 +183,7 @@ private: friend class CollisionBox; }; -INLINE ostream &operator << (ostream &out, const CollisionSolid &cs) { +INLINE std::ostream &operator << (std::ostream &out, const CollisionSolid &cs) { cs.output(out); return out; } diff --git a/panda/src/collide/collisionSphere.h b/panda/src/collide/collisionSphere.h index 04fa9c4e83..8337644b42 100644 --- a/panda/src/collide/collisionSphere.h +++ b/panda/src/collide/collisionSphere.h @@ -44,7 +44,7 @@ public: virtual PStatCollector &get_volume_pcollector(); virtual PStatCollector &get_test_pcollector(); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; INLINE static void flush_level(); diff --git a/panda/src/collide/collisionTraverser.h b/panda/src/collide/collisionTraverser.h index 5f5ebe0b13..8a6c912aaf 100644 --- a/panda/src/collide/collisionTraverser.h +++ b/panda/src/collide/collisionTraverser.h @@ -44,7 +44,7 @@ class CollisionEntry; */ class EXPCL_PANDA_COLLIDE CollisionTraverser : public Namable { PUBLISHED: - explicit CollisionTraverser(const string &name = "ctrav"); + explicit CollisionTraverser(const std::string &name = "ctrav"); ~CollisionTraverser(); INLINE void set_respect_prev_transform(bool flag); @@ -76,8 +76,8 @@ PUBLISHED: void hide_collisions(); #endif // DO_COLLISION_RECORDING - void output(ostream &out) const; - void write(ostream &out, int indent_level) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level) const; private: typedef pvector LevelStatesSingle; @@ -163,7 +163,7 @@ private: friend class SortByColliderSort; }; -INLINE ostream &operator << (ostream &out, const CollisionTraverser &trav) { +INLINE std::ostream &operator << (std::ostream &out, const CollisionTraverser &trav) { trav.output(out); return out; } diff --git a/panda/src/collide/collisionTube.h b/panda/src/collide/collisionTube.h index 52701193eb..1742e24927 100644 --- a/panda/src/collide/collisionTube.h +++ b/panda/src/collide/collisionTube.h @@ -48,7 +48,7 @@ public: virtual PStatCollector &get_volume_pcollector(); virtual PStatCollector &get_test_pcollector(); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; INLINE static void flush_level(); diff --git a/panda/src/collide/collisionVisualizer.h b/panda/src/collide/collisionVisualizer.h index 88491c4e26..2fb2cb40b2 100644 --- a/panda/src/collide/collisionVisualizer.h +++ b/panda/src/collide/collisionVisualizer.h @@ -34,7 +34,7 @@ */ class EXPCL_PANDA_COLLIDE CollisionVisualizer : public PandaNode, public CollisionRecorder { PUBLISHED: - explicit CollisionVisualizer(const string &name); + explicit CollisionVisualizer(const std::string &name); CollisionVisualizer(const CollisionVisualizer ©); virtual ~CollisionVisualizer(); @@ -55,7 +55,7 @@ public: virtual PandaNode *make_copy() const; virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data); virtual bool is_renderable() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; // from parent class CollisionRecorder. virtual void begin_traversal(); diff --git a/panda/src/cull/cullBinBackToFront.I b/panda/src/cull/cullBinBackToFront.I index 4e77012ac5..fd66f8437b 100644 --- a/panda/src/cull/cullBinBackToFront.I +++ b/panda/src/cull/cullBinBackToFront.I @@ -15,7 +15,7 @@ * */ INLINE CullBinBackToFront:: -CullBinBackToFront(const string &name, GraphicsStateGuardianBase *gsg, +CullBinBackToFront(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) : CullBin(name, BT_back_to_front, gsg, draw_region_pcollector) { diff --git a/panda/src/cull/cullBinBackToFront.h b/panda/src/cull/cullBinBackToFront.h index 515fafc1a5..cfef2f4267 100644 --- a/panda/src/cull/cullBinBackToFront.h +++ b/panda/src/cull/cullBinBackToFront.h @@ -30,12 +30,12 @@ */ class EXPCL_PANDA_CULL CullBinBackToFront : public CullBin { public: - INLINE CullBinBackToFront(const string &name, + INLINE CullBinBackToFront(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); virtual ~CullBinBackToFront(); - static CullBin *make_bin(const string &name, + static CullBin *make_bin(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); diff --git a/panda/src/cull/cullBinFixed.I b/panda/src/cull/cullBinFixed.I index 117512283d..4d35e242a3 100644 --- a/panda/src/cull/cullBinFixed.I +++ b/panda/src/cull/cullBinFixed.I @@ -15,7 +15,7 @@ * */ INLINE CullBinFixed:: -CullBinFixed(const string &name, GraphicsStateGuardianBase *gsg, +CullBinFixed(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) : CullBin(name, BT_fixed, gsg, draw_region_pcollector) { diff --git a/panda/src/cull/cullBinFixed.h b/panda/src/cull/cullBinFixed.h index f2d1c8fd07..337283e2b3 100644 --- a/panda/src/cull/cullBinFixed.h +++ b/panda/src/cull/cullBinFixed.h @@ -32,12 +32,12 @@ */ class EXPCL_PANDA_CULL CullBinFixed : public CullBin { public: - INLINE CullBinFixed(const string &name, + INLINE CullBinFixed(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); virtual ~CullBinFixed(); - static CullBin *make_bin(const string &name, + static CullBin *make_bin(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); diff --git a/panda/src/cull/cullBinFrontToBack.I b/panda/src/cull/cullBinFrontToBack.I index 4605e5e6ef..83c0ab4651 100644 --- a/panda/src/cull/cullBinFrontToBack.I +++ b/panda/src/cull/cullBinFrontToBack.I @@ -15,7 +15,7 @@ * */ INLINE CullBinFrontToBack:: -CullBinFrontToBack(const string &name, GraphicsStateGuardianBase *gsg, +CullBinFrontToBack(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) : CullBin(name, BT_front_to_back, gsg, draw_region_pcollector) { diff --git a/panda/src/cull/cullBinFrontToBack.h b/panda/src/cull/cullBinFrontToBack.h index 6ee0d4424a..b9ba66c043 100644 --- a/panda/src/cull/cullBinFrontToBack.h +++ b/panda/src/cull/cullBinFrontToBack.h @@ -31,12 +31,12 @@ */ class EXPCL_PANDA_CULL CullBinFrontToBack : public CullBin { public: - INLINE CullBinFrontToBack(const string &name, + INLINE CullBinFrontToBack(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); virtual ~CullBinFrontToBack(); - static CullBin *make_bin(const string &name, + static CullBin *make_bin(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); diff --git a/panda/src/cull/cullBinStateSorted.I b/panda/src/cull/cullBinStateSorted.I index 1bdb99112f..1a1637bdf4 100644 --- a/panda/src/cull/cullBinStateSorted.I +++ b/panda/src/cull/cullBinStateSorted.I @@ -15,7 +15,7 @@ * */ INLINE CullBinStateSorted:: -CullBinStateSorted(const string &name, GraphicsStateGuardianBase *gsg, +CullBinStateSorted(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) : CullBin(name, BT_state_sorted, gsg, draw_region_pcollector), _objects(get_class_type()) diff --git a/panda/src/cull/cullBinStateSorted.h b/panda/src/cull/cullBinStateSorted.h index 6f20882135..f97e41fa48 100644 --- a/panda/src/cull/cullBinStateSorted.h +++ b/panda/src/cull/cullBinStateSorted.h @@ -34,12 +34,12 @@ */ class EXPCL_PANDA_CULL CullBinStateSorted : public CullBin { public: - INLINE CullBinStateSorted(const string &name, + INLINE CullBinStateSorted(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); virtual ~CullBinStateSorted(); - static CullBin *make_bin(const string &name, + static CullBin *make_bin(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); diff --git a/panda/src/cull/cullBinUnsorted.I b/panda/src/cull/cullBinUnsorted.I index f9a8d37dc0..2e000b72f0 100644 --- a/panda/src/cull/cullBinUnsorted.I +++ b/panda/src/cull/cullBinUnsorted.I @@ -15,7 +15,7 @@ * */ INLINE CullBinUnsorted:: -CullBinUnsorted(const string &name, GraphicsStateGuardianBase *gsg, +CullBinUnsorted(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) : CullBin(name, BT_unsorted, gsg, draw_region_pcollector) { diff --git a/panda/src/cull/cullBinUnsorted.h b/panda/src/cull/cullBinUnsorted.h index 0c682155d8..2dcf60a85f 100644 --- a/panda/src/cull/cullBinUnsorted.h +++ b/panda/src/cull/cullBinUnsorted.h @@ -26,12 +26,12 @@ */ class EXPCL_PANDA_CULL CullBinUnsorted : public CullBin { public: - INLINE CullBinUnsorted(const string &name, + INLINE CullBinUnsorted(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); ~CullBinUnsorted(); - static CullBin *make_bin(const string &name, + static CullBin *make_bin(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); diff --git a/panda/src/device/analogNode.h b/panda/src/device/analogNode.h index d62eaa0d3b..11626e0ae8 100644 --- a/panda/src/device/analogNode.h +++ b/panda/src/device/analogNode.h @@ -38,7 +38,7 @@ */ class EXPCL_PANDA_DEVICE AnalogNode : public DataNode { PUBLISHED: - explicit AnalogNode(ClientBase *client, const string &device_name); + explicit AnalogNode(ClientBase *client, const std::string &device_name); virtual ~AnalogNode(); INLINE bool is_valid() const; @@ -54,7 +54,7 @@ PUBLISHED: INLINE bool is_output_flipped(int channel) const; public: - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; private: class OutputData { diff --git a/panda/src/device/buttonNode.h b/panda/src/device/buttonNode.h index 6fce65a9e0..02b141fbbf 100644 --- a/panda/src/device/buttonNode.h +++ b/panda/src/device/buttonNode.h @@ -34,7 +34,7 @@ */ class EXPCL_PANDA_DEVICE ButtonNode : public DataNode { PUBLISHED: - explicit ButtonNode(ClientBase *client, const string &device_name); + explicit ButtonNode(ClientBase *client, const std::string &device_name); virtual ~ButtonNode(); INLINE bool is_valid() const; @@ -48,8 +48,8 @@ PUBLISHED: INLINE bool is_button_known(int index) const; public: - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; private: PT(ClientButtonDevice) _button; diff --git a/panda/src/device/clientAnalogDevice.I b/panda/src/device/clientAnalogDevice.I index aad2deafd4..d392d46aba 100644 --- a/panda/src/device/clientAnalogDevice.I +++ b/panda/src/device/clientAnalogDevice.I @@ -25,7 +25,7 @@ AnalogState() : * */ INLINE ClientAnalogDevice:: -ClientAnalogDevice(ClientBase *client, const string &device_name): +ClientAnalogDevice(ClientBase *client, const std::string &device_name): ClientDevice(client, get_class_type(), device_name) { } diff --git a/panda/src/device/clientAnalogDevice.h b/panda/src/device/clientAnalogDevice.h index 95040f49a4..436b399240 100644 --- a/panda/src/device/clientAnalogDevice.h +++ b/panda/src/device/clientAnalogDevice.h @@ -28,7 +28,7 @@ */ class EXPCL_PANDA_DEVICE ClientAnalogDevice : public ClientDevice { protected: - INLINE ClientAnalogDevice(ClientBase *client, const string &device_name); + INLINE ClientAnalogDevice(ClientBase *client, const std::string &device_name); public: INLINE int get_num_controls() const; @@ -37,8 +37,8 @@ public: INLINE double get_control_state(int index) const; INLINE bool is_control_known(int index) const; - virtual void write(ostream &out, int indent_level = 0) const; - void write_controls(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level = 0) const; + void write_controls(std::ostream &out, int indent_level) const; private: void ensure_control_index(int index); diff --git a/panda/src/device/clientBase.h b/panda/src/device/clientBase.h index d7ee1cf605..f32b526172 100644 --- a/panda/src/device/clientBase.h +++ b/panda/src/device/clientBase.h @@ -57,20 +57,20 @@ PUBLISHED: public: PT(ClientDevice) get_device(TypeHandle device_type, - const string &device_name); + const std::string &device_name); protected: virtual PT(ClientDevice) make_device(TypeHandle device_type, - const string &device_name)=0; + const std::string &device_name)=0; virtual bool disconnect_device(TypeHandle device_type, - const string &device_name, + const std::string &device_name, ClientDevice *device); virtual void do_poll(); private: - typedef pmap DevicesByName; + typedef pmap DevicesByName; typedef pmap Devices; Devices _devices; diff --git a/panda/src/device/clientButtonDevice.h b/panda/src/device/clientButtonDevice.h index 3c7a285e36..3b089b707b 100644 --- a/panda/src/device/clientButtonDevice.h +++ b/panda/src/device/clientButtonDevice.h @@ -31,7 +31,7 @@ */ class EXPCL_PANDA_DEVICE ClientButtonDevice : public ClientDevice { protected: - ClientButtonDevice(ClientBase *client, const string &device_name); + ClientButtonDevice(ClientBase *client, const std::string &device_name); public: INLINE int get_num_buttons() const; @@ -45,11 +45,11 @@ public: INLINE ButtonEventList *get_button_events() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; - void output_buttons(ostream &out) const; - void write_buttons(ostream &out, int indent_level) const; + void output_buttons(std::ostream &out) const; + void write_buttons(std::ostream &out, int indent_level) const; private: void ensure_button_index(int index); diff --git a/panda/src/device/clientDevice.I b/panda/src/device/clientDevice.I index c4e1e5a7b7..84edaf594f 100644 --- a/panda/src/device/clientDevice.I +++ b/panda/src/device/clientDevice.I @@ -44,7 +44,7 @@ get_device_type() const { * Returns the device name reported to the ClientBase. This has some * implementation-defined meaning to identify particular devices. */ -INLINE const string &ClientDevice:: +INLINE const std::string &ClientDevice:: get_device_name() const { return _device_name; } diff --git a/panda/src/device/clientDevice.h b/panda/src/device/clientDevice.h index d8424e9a1f..0e2ad03778 100644 --- a/panda/src/device/clientDevice.h +++ b/panda/src/device/clientDevice.h @@ -32,14 +32,14 @@ class ClientBase; class EXPCL_PANDA_DEVICE ClientDevice : public TypedReferenceCount { protected: ClientDevice(ClientBase *client, TypeHandle device_type, - const string &device_name); + const std::string &device_name); public: virtual ~ClientDevice(); INLINE ClientBase *get_client() const; INLINE TypeHandle get_device_type() const; - INLINE const string &get_device_name() const; + INLINE const std::string &get_device_name() const; INLINE bool is_connected() const; void disconnect(); @@ -48,13 +48,13 @@ public: INLINE void acquire(); INLINE void unlock(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; private: ClientBase *_client; TypeHandle _device_type; - string _device_name; + std::string _device_name; bool _is_connected; #ifdef OLD_HAVE_IPC @@ -81,7 +81,7 @@ private: friend class ClientBase; }; -INLINE ostream &operator <<(ostream &out, const ClientDevice &device) { +INLINE std::ostream &operator <<(std::ostream &out, const ClientDevice &device) { device.output(out); return out; } diff --git a/panda/src/device/clientDialDevice.I b/panda/src/device/clientDialDevice.I index bf7fc3bca7..b0360ec63b 100644 --- a/panda/src/device/clientDialDevice.I +++ b/panda/src/device/clientDialDevice.I @@ -25,7 +25,7 @@ DialState() : * */ INLINE ClientDialDevice:: -ClientDialDevice(ClientBase *client, const string &device_name): +ClientDialDevice(ClientBase *client, const std::string &device_name): ClientDevice(client, get_class_type(), device_name) { } diff --git a/panda/src/device/clientDialDevice.h b/panda/src/device/clientDialDevice.h index 0da5604583..ec1c929abf 100644 --- a/panda/src/device/clientDialDevice.h +++ b/panda/src/device/clientDialDevice.h @@ -29,7 +29,7 @@ */ class EXPCL_PANDA_DEVICE ClientDialDevice : public ClientDevice { protected: - INLINE ClientDialDevice(ClientBase *client, const string &device_name); + INLINE ClientDialDevice(ClientBase *client, const std::string &device_name); public: INLINE int get_num_dials() const; diff --git a/panda/src/device/clientTrackerDevice.I b/panda/src/device/clientTrackerDevice.I index 030c4eea47..f4be74fc4d 100644 --- a/panda/src/device/clientTrackerDevice.I +++ b/panda/src/device/clientTrackerDevice.I @@ -15,7 +15,7 @@ * */ INLINE ClientTrackerDevice:: -ClientTrackerDevice(ClientBase *client, const string &device_name): +ClientTrackerDevice(ClientBase *client, const std::string &device_name): ClientDevice(client, get_class_type(), device_name) { } diff --git a/panda/src/device/clientTrackerDevice.h b/panda/src/device/clientTrackerDevice.h index 468ed342f5..bd134a5e4c 100644 --- a/panda/src/device/clientTrackerDevice.h +++ b/panda/src/device/clientTrackerDevice.h @@ -25,7 +25,7 @@ */ class EXPCL_PANDA_DEVICE ClientTrackerDevice : public ClientDevice { protected: - INLINE ClientTrackerDevice(ClientBase *client, const string &device_name); + INLINE ClientTrackerDevice(ClientBase *client, const std::string &device_name); public: INLINE const TrackerData &get_data() const; diff --git a/panda/src/device/dialNode.h b/panda/src/device/dialNode.h index 13e2083efc..6fb65e7763 100644 --- a/panda/src/device/dialNode.h +++ b/panda/src/device/dialNode.h @@ -33,7 +33,7 @@ */ class EXPCL_PANDA_DEVICE DialNode : public DataNode { PUBLISHED: - explicit DialNode(ClientBase *client, const string &device_name); + explicit DialNode(ClientBase *client, const std::string &device_name); virtual ~DialNode(); INLINE bool is_valid() const; diff --git a/panda/src/device/mouseAndKeyboard.h b/panda/src/device/mouseAndKeyboard.h index 24a6efe07a..15f7544fb8 100644 --- a/panda/src/device/mouseAndKeyboard.h +++ b/panda/src/device/mouseAndKeyboard.h @@ -40,7 +40,7 @@ */ class EXPCL_PANDA_DEVICE MouseAndKeyboard : public DataNode { PUBLISHED: - explicit MouseAndKeyboard(GraphicsWindow *window, int device, const string &name); + explicit MouseAndKeyboard(GraphicsWindow *window, int device, const std::string &name); void set_source(GraphicsWindow *window, int device); PT(GraphicsWindow) get_source_window() const; diff --git a/panda/src/device/trackerNode.h b/panda/src/device/trackerNode.h index 628422324b..29e88047bb 100644 --- a/panda/src/device/trackerNode.h +++ b/panda/src/device/trackerNode.h @@ -31,7 +31,7 @@ */ class EXPCL_PANDA_DEVICE TrackerNode : public DataNode { PUBLISHED: - explicit TrackerNode(ClientBase *client, const string &device_name); + explicit TrackerNode(ClientBase *client, const std::string &device_name); explicit TrackerNode(ClientTrackerDevice *device); virtual ~TrackerNode(); diff --git a/panda/src/device/virtualMouse.h b/panda/src/device/virtualMouse.h index 037180305d..2afa1b8d72 100644 --- a/panda/src/device/virtualMouse.h +++ b/panda/src/device/virtualMouse.h @@ -31,7 +31,7 @@ */ class EXPCL_PANDA_DEVICE VirtualMouse : public DataNode { PUBLISHED: - explicit VirtualMouse(const string &name); + explicit VirtualMouse(const std::string &name); void set_mouse_pos(int x, int y); void set_window_size(int width, int height); diff --git a/panda/src/dgraph/dataNode.I b/panda/src/dgraph/dataNode.I index b9bcbb2fa1..a466de9d24 100644 --- a/panda/src/dgraph/dataNode.I +++ b/panda/src/dgraph/dataNode.I @@ -15,7 +15,7 @@ * */ INLINE DataNode:: -DataNode(const string &name) : +DataNode(const std::string &name) : PandaNode(name) { } diff --git a/panda/src/dgraph/dataNode.h b/panda/src/dgraph/dataNode.h index 0f5e52b0fc..7386b52b9a 100644 --- a/panda/src/dgraph/dataNode.h +++ b/panda/src/dgraph/dataNode.h @@ -51,7 +51,7 @@ class DataNodeTransmit; */ class EXPCL_PANDA_DGRAPH DataNode : public PandaNode { PUBLISHED: - INLINE explicit DataNode(const string &name); + INLINE explicit DataNode(const std::string &name); protected: INLINE DataNode(const DataNode ©); @@ -66,13 +66,13 @@ public: INLINE int get_num_outputs() const; PUBLISHED: - void write_inputs(ostream &out) const; - void write_outputs(ostream &out) const; - void write_connections(ostream &out) const; + void write_inputs(std::ostream &out) const; + void write_outputs(std::ostream &out) const; + void write_connections(std::ostream &out) const; protected: - int define_input(const string &name, TypeHandle data_type); - int define_output(const string &name, TypeHandle data_type); + int define_input(const std::string &name, TypeHandle data_type); + int define_output(const std::string &name, TypeHandle data_type); protected: // Inherited from PandaNode @@ -92,7 +92,7 @@ private: int _index; }; - typedef pmap Wires; + typedef pmap Wires; Wires _input_wires; Wires _output_wires; diff --git a/panda/src/display/callbackGraphicsWindow.h b/panda/src/display/callbackGraphicsWindow.h index a676dff9f4..fc7d8310f5 100644 --- a/panda/src/display/callbackGraphicsWindow.h +++ b/panda/src/display/callbackGraphicsWindow.h @@ -27,7 +27,7 @@ class EXPCL_PANDA_DISPLAY CallbackGraphicsWindow : public GraphicsWindow { protected: CallbackGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -179,7 +179,7 @@ PUBLISHED: INLINE CallbackObject *get_render_callback() const; GraphicsWindowInputDevice &get_input_device(int device); - int create_input_device(const string &name); + int create_input_device(const std::string &name); public: virtual bool begin_frame(FrameMode mode, Thread *current_thread); diff --git a/panda/src/display/displayInformation.h b/panda/src/display/displayInformation.h index 919e400741..2869c8320a 100644 --- a/panda/src/display/displayInformation.h +++ b/panda/src/display/displayInformation.h @@ -27,7 +27,7 @@ PUBLISHED: bool operator == (const DisplayMode &other) const; bool operator != (const DisplayMode &other) const; - void output(ostream &out) const; + void output(std::ostream &out) const; }; /** @@ -94,8 +94,8 @@ PUBLISHED: int get_driver_date_day(); int get_driver_date_year(); - const string &get_cpu_vendor_string() const; - const string &get_cpu_brand_string() const; + const std::string &get_cpu_vendor_string() const; + const std::string &get_cpu_brand_string() const; unsigned int get_cpu_version_information(); unsigned int get_cpu_brand_index(); @@ -155,8 +155,8 @@ public: int _driver_date_year; - string _cpu_vendor_string; - string _cpu_brand_string; + std::string _cpu_vendor_string; + std::string _cpu_brand_string; unsigned int _cpu_version_information; unsigned int _cpu_brand_index; diff --git a/panda/src/display/displayRegion.I b/panda/src/display/displayRegion.I index fa1c698c0a..96f2383bf9 100644 --- a/panda/src/display/displayRegion.I +++ b/panda/src/display/displayRegion.I @@ -479,8 +479,8 @@ INLINE void DisplayRegion:: set_cull_result(PT(CullResult) cull_result, PT(SceneSetup) scene_setup, Thread *current_thread) { CDCullWriter cdata(_cycler_cull, true, current_thread); - cdata->_cull_result = move(cull_result); - cdata->_scene_setup = move(scene_setup); + cdata->_cull_result = std::move(cull_result); + cdata->_scene_setup = std::move(scene_setup); } /** @@ -863,8 +863,8 @@ get_pixel_height(int i) const { return _cdata->_regions[i]._pixels[3] - _cdata->_regions[i]._pixels[2]; } -INLINE ostream & -operator << (ostream &out, const DisplayRegion &dr) { +INLINE std::ostream & +operator << (std::ostream &out, const DisplayRegion &dr) { dr.output(out); return out; } diff --git a/panda/src/display/displayRegion.h b/panda/src/display/displayRegion.h index 7599f17c9d..e97829be2c 100644 --- a/panda/src/display/displayRegion.h +++ b/panda/src/display/displayRegion.h @@ -150,13 +150,13 @@ PUBLISHED: INLINE LVecBase2i get_pixel_size(int i = 0) const; MAKE_PROPERTY(pixel_size, get_pixel_size); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; static Filename make_screenshot_filename( - const string &prefix = "screenshot"); - Filename save_screenshot_default(const string &prefix = "screenshot"); + const std::string &prefix = "screenshot"); + Filename save_screenshot_default(const std::string &prefix = "screenshot"); bool save_screenshot( - const Filename &filename, const string &image_comment = ""); + const Filename &filename, const std::string &image_comment = ""); bool get_screenshot(PNMImage &image); PT(Texture) get_screenshot(); @@ -371,7 +371,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const DisplayRegion &dr); +INLINE std::ostream &operator << (std::ostream &out, const DisplayRegion &dr); #include "displayRegion.I" diff --git a/panda/src/display/displayRegionCullCallbackData.h b/panda/src/display/displayRegionCullCallbackData.h index bb78dbc9c9..c8830a52c9 100644 --- a/panda/src/display/displayRegionCullCallbackData.h +++ b/panda/src/display/displayRegionCullCallbackData.h @@ -29,7 +29,7 @@ public: DisplayRegionCullCallbackData(CullHandler *cull_handler, SceneSetup *scene_setup); PUBLISHED: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; INLINE CullHandler *get_cull_handler() const; INLINE SceneSetup *get_scene_setup() const; diff --git a/panda/src/display/displayRegionDrawCallbackData.h b/panda/src/display/displayRegionDrawCallbackData.h index bbdfdc99b3..feea6034b6 100644 --- a/panda/src/display/displayRegionDrawCallbackData.h +++ b/panda/src/display/displayRegionDrawCallbackData.h @@ -29,7 +29,7 @@ public: DisplayRegionDrawCallbackData(CullResult *cull_result, SceneSetup *scene_setup); PUBLISHED: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; INLINE CullResult *get_cull_result() const; INLINE SceneSetup *get_scene_setup() const; diff --git a/panda/src/display/drawableRegion.I b/panda/src/display/drawableRegion.I index 677a345683..71fc1658cc 100644 --- a/panda/src/display/drawableRegion.I +++ b/panda/src/display/drawableRegion.I @@ -242,7 +242,7 @@ INLINE void DrawableRegion:: update_pixel_factor() { PN_stdfloat new_pixel_factor; if (supports_pixel_zoom()) { - new_pixel_factor = (PN_stdfloat)1 / sqrt(max(_pixel_zoom, (PN_stdfloat)1.0)); + new_pixel_factor = (PN_stdfloat)1 / sqrt(std::max(_pixel_zoom, (PN_stdfloat)1.0)); } else { new_pixel_factor = 1; } diff --git a/panda/src/display/frameBufferProperties.I b/panda/src/display/frameBufferProperties.I index 70c809c64b..5b6453af24 100644 --- a/panda/src/display/frameBufferProperties.I +++ b/panda/src/display/frameBufferProperties.I @@ -38,8 +38,8 @@ is_stereo() const { /** * */ -INLINE ostream & -operator << (ostream &out, const FrameBufferProperties &properties) { +INLINE std::ostream & +operator << (std::ostream &out, const FrameBufferProperties &properties) { properties.output(out); return out; } @@ -57,7 +57,7 @@ get_depth_bits() const { */ INLINE int FrameBufferProperties:: get_color_bits() const { - return max(_property[FBP_color_bits], + return std::max(_property[FBP_color_bits], _property[FBP_red_bits] + _property[FBP_green_bits] + _property[FBP_blue_bits]); diff --git a/panda/src/display/frameBufferProperties.h b/panda/src/display/frameBufferProperties.h index 67e0c50d1e..152f2dccc7 100644 --- a/panda/src/display/frameBufferProperties.h +++ b/panda/src/display/frameBufferProperties.h @@ -155,7 +155,7 @@ PUBLISHED: void set_all_specified(); bool subsumes(const FrameBufferProperties &other) const; void add_properties(const FrameBufferProperties &other); - void output(ostream &out) const; + void output(std::ostream &out) const; void set_one_bit_per_channel(); INLINE bool is_stereo() const; @@ -165,13 +165,13 @@ PUBLISHED: bool is_basic() const; int get_aux_mask() const; int get_buffer_mask() const; - bool verify_hardware_software(const FrameBufferProperties &props, const string &renderer) const; + bool verify_hardware_software(const FrameBufferProperties &props, const std::string &renderer) const; bool setup_color_texture(Texture *tex) const; bool setup_depth_texture(Texture *tex) const; }; -INLINE ostream &operator << (ostream &out, const FrameBufferProperties &properties); +INLINE std::ostream &operator << (std::ostream &out, const FrameBufferProperties &properties); #include "frameBufferProperties.I" diff --git a/panda/src/display/graphicsBuffer.h b/panda/src/display/graphicsBuffer.h index caff1d9284..5c7e833f57 100644 --- a/panda/src/display/graphicsBuffer.h +++ b/panda/src/display/graphicsBuffer.h @@ -28,7 +28,7 @@ class EXPCL_PANDA_DISPLAY GraphicsBuffer : public GraphicsOutput { protected: GraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/display/graphicsEngine.I b/panda/src/display/graphicsEngine.I index 326d073a0c..d0a4769a21 100644 --- a/panda/src/display/graphicsEngine.I +++ b/panda/src/display/graphicsEngine.I @@ -104,7 +104,7 @@ close_gsg(GraphicsPipe *pipe, GraphicsStateGuardian *gsg) { * sharing of resources. */ INLINE GraphicsOutput *GraphicsEngine:: -make_buffer(GraphicsOutput *host, const string &name, +make_buffer(GraphicsOutput *host, const std::string &name, int sort, int x_size, int y_size) { GraphicsOutput *result = make_output(host->get_pipe(), name, sort, FrameBufferProperties(), @@ -130,7 +130,7 @@ make_buffer(GraphicsOutput *host, const string &name, * the first parameter. */ INLINE GraphicsOutput *GraphicsEngine:: -make_buffer(GraphicsStateGuardian *gsg, const string &name, +make_buffer(GraphicsStateGuardian *gsg, const std::string &name, int sort, int x_size, int y_size) { FrameBufferProperties fb_props = FrameBufferProperties::get_default(); fb_props.set_back_buffers(0); @@ -152,7 +152,7 @@ make_buffer(GraphicsStateGuardian *gsg, const string &name, * Syntactic shorthand for make_buffer. */ INLINE GraphicsOutput *GraphicsEngine:: -make_parasite(GraphicsOutput *host, const string &name, +make_parasite(GraphicsOutput *host, const std::string &name, int sort, int x_size, int y_size) { GraphicsOutput *result = make_output(host->get_pipe(), name, sort, FrameBufferProperties(), diff --git a/panda/src/display/graphicsEngine.h b/panda/src/display/graphicsEngine.h index 867afdfb40..667490b3d3 100644 --- a/panda/src/display/graphicsEngine.h +++ b/panda/src/display/graphicsEngine.h @@ -75,7 +75,7 @@ PUBLISHED: MAKE_PROPERTY(default_loader, get_default_loader, set_default_loader); GraphicsOutput *make_output(GraphicsPipe *pipe, - const string &name, int sort, + const std::string &name, int sort, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, GraphicsStateGuardian *gsg = nullptr, @@ -83,13 +83,13 @@ PUBLISHED: // Syntactic shorthand versions of make_output INLINE GraphicsOutput *make_buffer(GraphicsOutput *host, - const string &name, int sort, + const std::string &name, int sort, int x_size, int y_size); INLINE GraphicsOutput *make_buffer(GraphicsStateGuardian *gsg, - const string &name, int sort, + const std::string &name, int sort, int x_size, int y_size); INLINE GraphicsOutput *make_parasite(GraphicsOutput *host, - const string &name, int sort, + const std::string &name, int sort, int x_size, int y_size); bool add_window(GraphicsOutput *window, int sort); @@ -176,7 +176,7 @@ private: void auto_adjust_capabilities(GraphicsStateGuardian *gsg); #ifdef DO_PSTATS - typedef map CyclerTypeCounters; + typedef std::map CyclerTypeCounters; CyclerTypeCounters _all_cycler_types; CyclerTypeCounters _dirty_cycler_types; static void pstats_count_cycler_type(TypeHandle type, int count, void *data); @@ -262,7 +262,7 @@ private: class WindowRenderer { public: - WindowRenderer(const string &name); + WindowRenderer(const std::string &name); void add_gsg(GraphicsStateGuardian *gsg); void add_window(Windows &wlist, GraphicsOutput *window); @@ -293,7 +293,7 @@ private: class RenderThread : public Thread, public WindowRenderer { public: - RenderThread(const string &name, GraphicsEngine *engine); + RenderThread(const std::string &name, GraphicsEngine *engine); virtual void thread_main(); GraphicsEngine *_engine; @@ -310,7 +310,7 @@ private: bool _result; }; - WindowRenderer *get_window_renderer(const string &name, int pipeline_stage); + WindowRenderer *get_window_renderer(const std::string &name, int pipeline_stage); Pipeline *_pipeline; Windows _windows; @@ -322,7 +322,7 @@ private: pvector _new_windows; WindowRenderer _app; - typedef pmap Threads; + typedef pmap Threads; Threads _threads; GraphicsThreadingModel _threading_model; bool _auto_flip; diff --git a/panda/src/display/graphicsOutput.I b/panda/src/display/graphicsOutput.I index bc0e866f7d..c94c83f54c 100644 --- a/panda/src/display/graphicsOutput.I +++ b/panda/src/display/graphicsOutput.I @@ -48,7 +48,7 @@ get_engine() const { /** * Returns the name that was passed to the GraphicsOutput constructor. */ -INLINE const string &GraphicsOutput:: +INLINE const std::string &GraphicsOutput:: get_name() const { return _name; } @@ -167,8 +167,8 @@ get_y_size() const { */ INLINE LVecBase2i GraphicsOutput:: get_fb_size() const { - return LVecBase2i(max(int(_size.get_x() * get_pixel_factor()), 1), - max(int(_size.get_y() * get_pixel_factor()), 1)); + return LVecBase2i(std::max(int(_size.get_x() * get_pixel_factor()), 1), + std::max(int(_size.get_y() * get_pixel_factor()), 1)); } /** @@ -178,7 +178,7 @@ get_fb_size() const { */ INLINE int GraphicsOutput:: get_fb_x_size() const { - return max(int(_size.get_x() * get_pixel_factor()), 1); + return std::max(int(_size.get_x() * get_pixel_factor()), 1); } /** @@ -188,7 +188,7 @@ get_fb_x_size() const { */ INLINE int GraphicsOutput:: get_fb_y_size() const { - return max(int(_size.get_y() * get_pixel_factor()), 1); + return std::max(int(_size.get_y() * get_pixel_factor()), 1); } /** @@ -200,8 +200,8 @@ INLINE LVecBase2i GraphicsOutput:: get_sbs_left_size() const { PN_stdfloat left_w = _sbs_left_dimensions[1] - _sbs_left_dimensions[0]; PN_stdfloat left_h = _sbs_left_dimensions[3] - _sbs_left_dimensions[2]; - return LVecBase2i(max(int(_size.get_x() * left_w), 1), - max(int(_size.get_y() * left_h), 1)); + return LVecBase2i(std::max(int(_size.get_x() * left_w), 1), + std::max(int(_size.get_y() * left_h), 1)); } /** @@ -212,7 +212,7 @@ get_sbs_left_size() const { INLINE int GraphicsOutput:: get_sbs_left_x_size() const { PN_stdfloat left_w = _sbs_left_dimensions[1] - _sbs_left_dimensions[0]; - return max(int(_size.get_x() * left_w), 1); + return std::max(int(_size.get_x() * left_w), 1); } /** @@ -223,7 +223,7 @@ get_sbs_left_x_size() const { INLINE int GraphicsOutput:: get_sbs_left_y_size() const { PN_stdfloat left_h = _sbs_left_dimensions[3] - _sbs_left_dimensions[2]; - return max(int(_size.get_y() * left_h), 1); + return std::max(int(_size.get_y() * left_h), 1); } /** @@ -235,8 +235,8 @@ INLINE LVecBase2i GraphicsOutput:: get_sbs_right_size() const { PN_stdfloat right_w = _sbs_right_dimensions[1] - _sbs_right_dimensions[0]; PN_stdfloat right_h = _sbs_right_dimensions[3] - _sbs_right_dimensions[2]; - return LVecBase2i(max(int(_size.get_x() * right_w), 1), - max(int(_size.get_y() * right_h), 1)); + return LVecBase2i(std::max(int(_size.get_x() * right_w), 1), + std::max(int(_size.get_y() * right_h), 1)); } /** @@ -247,7 +247,7 @@ get_sbs_right_size() const { INLINE int GraphicsOutput:: get_sbs_right_x_size() const { PN_stdfloat right_w = _sbs_right_dimensions[1] - _sbs_right_dimensions[0]; - return max(int(_size.get_x() * right_w), 1); + return std::max(int(_size.get_x() * right_w), 1); } /** @@ -258,7 +258,7 @@ get_sbs_right_x_size() const { INLINE int GraphicsOutput:: get_sbs_right_y_size() const { PN_stdfloat right_h = _sbs_right_dimensions[3] - _sbs_right_dimensions[2]; - return max(int(_size.get_y() * right_h), 1); + return std::max(int(_size.get_y() * right_h), 1); } /** @@ -602,7 +602,7 @@ get_overlay_display_region() const { * screenshot-extension All other % strings in strftime(). */ INLINE Filename GraphicsOutput:: -make_screenshot_filename(const string &prefix) { +make_screenshot_filename(const std::string &prefix) { return DisplayRegion::make_screenshot_filename(prefix); } @@ -612,7 +612,7 @@ make_screenshot_filename(const string &prefix) { * generated by make_screenshot_filename(). */ INLINE Filename GraphicsOutput:: -save_screenshot_default(const string &prefix) { +save_screenshot_default(const std::string &prefix) { return _overlay_display_region->save_screenshot_default(prefix); } @@ -623,7 +623,7 @@ save_screenshot_default(const string &prefix) { * jpg allows comments). Returns true on success, false on failure. */ INLINE bool GraphicsOutput:: -save_screenshot(const Filename &filename, const string &image_comment) { +save_screenshot(const Filename &filename, const std::string &image_comment) { return _overlay_display_region->save_screenshot(filename, image_comment); } diff --git a/panda/src/display/graphicsOutput.h b/panda/src/display/graphicsOutput.h index c5ddb10ff0..acd41e8289 100644 --- a/panda/src/display/graphicsOutput.h +++ b/panda/src/display/graphicsOutput.h @@ -64,7 +64,7 @@ class EXPCL_PANDA_DISPLAY GraphicsOutput : public GraphicsOutputBase, public Dra protected: GraphicsOutput(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, GraphicsStateGuardian *gsg, @@ -113,7 +113,7 @@ PUBLISHED: INLINE GraphicsStateGuardian *get_gsg() const; INLINE GraphicsPipe *get_pipe() const; INLINE GraphicsEngine *get_engine() const; - INLINE const string &get_name() const; + INLINE const std::string &get_name() const; MAKE_PROPERTY(gsg, get_gsg); MAKE_PROPERTY(pipe, get_pipe); MAKE_PROPERTY(engine, get_engine); @@ -224,19 +224,19 @@ PUBLISHED: MAKE_SEQ_PROPERTY(active_display_regions, get_num_active_display_regions, get_active_display_region); GraphicsOutput *make_texture_buffer( - const string &name, int x_size, int y_size, + const std::string &name, int x_size, int y_size, Texture *tex = nullptr, bool to_ram = false, FrameBufferProperties *fbp = nullptr); - GraphicsOutput *make_cube_map(const string &name, int size, + GraphicsOutput *make_cube_map(const std::string &name, int size, NodePath &camera_rig, DrawMask camera_mask = PandaNode::get_all_camera_mask(), bool to_ram = false, FrameBufferProperties *fbp = nullptr); INLINE static Filename make_screenshot_filename( - const string &prefix = "screenshot"); + const std::string &prefix = "screenshot"); INLINE Filename save_screenshot_default( - const string &prefix = "screenshot"); + const std::string &prefix = "screenshot"); INLINE bool save_screenshot( - const Filename &filename, const string &image_comment = ""); + const Filename &filename, const std::string &image_comment = ""); INLINE bool get_screenshot(PNMImage &image); INLINE PT(Texture) get_screenshot(); @@ -314,7 +314,7 @@ private: INLINE void determine_display_regions() const; void do_determine_display_regions(CData *cdata); - static unsigned int parse_color_mask(const string &word); + static unsigned int parse_color_mask(const std::string &word); protected: PT(GraphicsStateGuardian) _gsg; @@ -323,7 +323,7 @@ protected: PT(GraphicsOutput) _host; FrameBufferProperties _fb_properties; bool _stereo; - string _name; + std::string _name; bool _flip_ready; int _target_tex_page; int _target_tex_view; @@ -431,7 +431,7 @@ private: friend class DisplayRegion; }; -EXPCL_PANDA_DISPLAY ostream &operator << (ostream &out, GraphicsOutput::FrameMode mode); +EXPCL_PANDA_DISPLAY std::ostream &operator << (std::ostream &out, GraphicsOutput::FrameMode mode); #include "graphicsOutput.I" diff --git a/panda/src/display/graphicsPipe.h b/panda/src/display/graphicsPipe.h index 032da4b1cd..ef3a3b8496 100644 --- a/panda/src/display/graphicsPipe.h +++ b/panda/src/display/graphicsPipe.h @@ -99,7 +99,7 @@ PUBLISHED: virtual void lookup_cpu_data(); - virtual string get_interface_name() const=0; + virtual std::string get_interface_name() const=0; MAKE_PROPERTY(interface_name, get_interface_name); public: @@ -117,7 +117,7 @@ public: protected: virtual void close_gsg(GraphicsStateGuardian *gsg); - virtual PT(GraphicsOutput) make_output(const string &name, + virtual PT(GraphicsOutput) make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/display/graphicsPipeSelection.h b/panda/src/display/graphicsPipeSelection.h index d1dc5b641e..c3b61317e9 100644 --- a/panda/src/display/graphicsPipeSelection.h +++ b/panda/src/display/graphicsPipeSelection.h @@ -42,10 +42,10 @@ PUBLISHED: MAKE_SEQ_PROPERTY(pipe_types, get_num_pipe_types, get_pipe_type); void print_pipe_types() const; - PT(GraphicsPipe) make_pipe(const string &type_name, - const string &module_name = string()); + PT(GraphicsPipe) make_pipe(const std::string &type_name, + const std::string &module_name = std::string()); PT(GraphicsPipe) make_pipe(TypeHandle type); - PT(GraphicsPipe) make_module_pipe(const string &module_name); + PT(GraphicsPipe) make_module_pipe(const std::string &module_name); PT(GraphicsPipe) make_default_pipe(); INLINE int get_num_aux_modules() const; @@ -60,15 +60,15 @@ public: private: INLINE void load_default_module() const; void do_load_default_module(); - TypeHandle load_named_module(const string &name); + TypeHandle load_named_module(const std::string &name); class LoadedModule { public: - string _module_name; + std::string _module_name; void *_module_handle; TypeHandle _default_pipe_type; }; - typedef pmap LoadedModules; + typedef pmap LoadedModules; LoadedModules _loaded_modules; LightMutex _loaded_modules_lock; @@ -84,8 +84,8 @@ private: typedef vector_string DisplayModules; DisplayModules _display_modules; - string _default_display_module; - string _default_pipe_name; + std::string _default_display_module; + std::string _default_pipe_name; bool _default_module_loaded; static GraphicsPipeSelection *_global_ptr; diff --git a/panda/src/display/graphicsStateGuardian.I b/panda/src/display/graphicsStateGuardian.I index 9f36616a95..f14a0fb087 100644 --- a/panda/src/display/graphicsStateGuardian.I +++ b/panda/src/display/graphicsStateGuardian.I @@ -258,7 +258,7 @@ get_max_vertices_per_primitive() const { INLINE int GraphicsStateGuardian:: get_max_texture_stages() const { if (max_texture_stages > 0) { - return min(_max_texture_stages, (int)max_texture_stages); + return std::min(_max_texture_stages, (int)max_texture_stages); } return _max_texture_stages; } @@ -695,7 +695,7 @@ get_timer_queries_active() const { INLINE int GraphicsStateGuardian:: get_max_color_targets() const { if (max_color_targets > 0) { - return min(_max_color_targets, (int)max_color_targets); + return std::min(_max_color_targets, (int)max_color_targets); } return _max_color_targets; } diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index 8e0e8d8489..c64bbe692a 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -228,7 +228,7 @@ PUBLISHED: MAKE_PROPERTY(shader_model, get_shader_model, set_shader_model); virtual int get_supported_geom_rendering() const; - virtual bool get_supports_cg_profile(const string &name) const; + virtual bool get_supports_cg_profile(const std::string &name) const; INLINE bool get_color_scale_via_lighting() const; INLINE bool get_alpha_scale_via_texture() const; @@ -267,11 +267,11 @@ PUBLISHED: #endif PUBLISHED: - virtual bool has_extension(const string &extension) const; + virtual bool has_extension(const std::string &extension) const; - virtual string get_driver_vendor(); - virtual string get_driver_renderer(); - virtual string get_driver_version(); + virtual std::string get_driver_vendor(); + virtual std::string get_driver_renderer(); + virtual std::string get_driver_version(); virtual int get_driver_version_major(); virtual int get_driver_version_minor(); virtual int get_driver_shader_version_major(); @@ -760,7 +760,7 @@ private: friend class GraphicsEngine; }; -EXPCL_PANDA_DISPLAY ostream &operator << (ostream &out, GraphicsStateGuardian::ShaderModel sm); +EXPCL_PANDA_DISPLAY std::ostream &operator << (std::ostream &out, GraphicsStateGuardian::ShaderModel sm); #include "graphicsStateGuardian.I" diff --git a/panda/src/display/graphicsThreadingModel.I b/panda/src/display/graphicsThreadingModel.I index bfd0161518..98707b16cb 100644 --- a/panda/src/display/graphicsThreadingModel.I +++ b/panda/src/display/graphicsThreadingModel.I @@ -39,7 +39,7 @@ operator = (const GraphicsThreadingModel ©) { /** * Returns the name of the thread that will handle culling in this model. */ -INLINE const string &GraphicsThreadingModel:: +INLINE const std::string &GraphicsThreadingModel:: get_cull_name() const { return _cull_name; } @@ -50,7 +50,7 @@ get_cull_name() const { * this only has an effect on newly-opened windows. */ INLINE void GraphicsThreadingModel:: -set_cull_name(const string &cull_name) { +set_cull_name(const std::string &cull_name) { _cull_name = cull_name; update_stages(); } @@ -69,7 +69,7 @@ get_cull_stage() const { * Returns the name of the thread that will handle sending the actual graphics * primitives to the graphics API in this model. */ -INLINE const string &GraphicsThreadingModel:: +INLINE const std::string &GraphicsThreadingModel:: get_draw_name() const { return _draw_name; } @@ -80,7 +80,7 @@ get_draw_name() const { * this only has an effect on newly-opened windows. */ INLINE void GraphicsThreadingModel:: -set_draw_name(const string &draw_name) { +set_draw_name(const std::string &draw_name) { _draw_name = draw_name; update_stages(); } @@ -140,12 +140,12 @@ is_default() const { * */ INLINE void GraphicsThreadingModel:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_model(); } -INLINE ostream & -operator << (ostream &out, const GraphicsThreadingModel &threading_model) { +INLINE std::ostream & +operator << (std::ostream &out, const GraphicsThreadingModel &threading_model) { threading_model.output(out); return out; } diff --git a/panda/src/display/graphicsThreadingModel.h b/panda/src/display/graphicsThreadingModel.h index 7d189250df..7f0cf519af 100644 --- a/panda/src/display/graphicsThreadingModel.h +++ b/panda/src/display/graphicsThreadingModel.h @@ -22,17 +22,17 @@ */ class EXPCL_PANDA_DISPLAY GraphicsThreadingModel { PUBLISHED: - GraphicsThreadingModel(const string &model = string()); + GraphicsThreadingModel(const std::string &model = std::string()); INLINE GraphicsThreadingModel(const GraphicsThreadingModel ©); INLINE void operator = (const GraphicsThreadingModel ©); - string get_model() const; - INLINE const string &get_cull_name() const; - INLINE void set_cull_name(const string &cull_name); + std::string get_model() const; + INLINE const std::string &get_cull_name() const; + INLINE void set_cull_name(const std::string &cull_name); INLINE int get_cull_stage() const; - INLINE const string &get_draw_name() const; - INLINE void set_draw_name(const string &cull_name); + INLINE const std::string &get_draw_name() const; + INLINE void set_draw_name(const std::string &cull_name); INLINE int get_draw_stage() const; INLINE bool get_cull_sorting() const; @@ -40,20 +40,20 @@ PUBLISHED: INLINE bool is_single_threaded() const; INLINE bool is_default() const; - INLINE void output(ostream &out) const; + INLINE void output(std::ostream &out) const; private: void update_stages(); private: - string _cull_name; + std::string _cull_name; int _cull_stage; - string _draw_name; + std::string _draw_name; int _draw_stage; bool _cull_sorting; }; -INLINE ostream &operator << (ostream &out, const GraphicsThreadingModel &threading_model); +INLINE std::ostream &operator << (std::ostream &out, const GraphicsThreadingModel &threading_model); #include "graphicsThreadingModel.I" diff --git a/panda/src/display/graphicsWindow.h b/panda/src/display/graphicsWindow.h index 86986f52c4..e41dad65ba 100644 --- a/panda/src/display/graphicsWindow.h +++ b/panda/src/display/graphicsWindow.h @@ -41,7 +41,7 @@ class EXPCL_PANDA_DISPLAY GraphicsWindow : public GraphicsOutput { protected: GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -65,12 +65,12 @@ PUBLISHED: MAKE_PROPERTY(rejected_properties, get_rejected_properties); MAKE_PROPERTY(closed, is_closed); - void set_window_event(const string &window_event); - string get_window_event() const; + void set_window_event(const std::string &window_event); + std::string get_window_event() const; MAKE_PROPERTY(window_event, get_window_event, set_window_event); - void set_close_request_event(const string &close_request_event); - string get_close_request_event() const; + void set_close_request_event(const std::string &close_request_event); + std::string get_close_request_event() const; MAKE_PROPERTY(close_request_event, get_close_request_event, set_close_request_event); INLINE void set_unexposed_draw(bool unexposed_draw); @@ -82,7 +82,7 @@ PUBLISHED: // Mouse and keyboard routines int get_num_input_devices() const; - string get_input_device_name(int device) const; + std::string get_input_device_name(int device) const; MAKE_SEQ(get_input_device_names, get_num_input_devices, get_input_device_name); bool has_pointer(int device) const; bool has_keyboard(int device) const; @@ -161,8 +161,8 @@ private: WindowProperties _requested_properties; WindowProperties _rejected_properties; - string _window_event; - string _close_request_event; + std::string _window_event; + std::string _close_request_event; bool _unexposed_draw; #ifdef HAVE_PYTHON diff --git a/panda/src/display/graphicsWindowInputDevice.I b/panda/src/display/graphicsWindowInputDevice.I index 2d69d042d9..446dca6ab6 100644 --- a/panda/src/display/graphicsWindowInputDevice.I +++ b/panda/src/display/graphicsWindowInputDevice.I @@ -23,7 +23,7 @@ GraphicsWindowInputDevice() { /** * */ -INLINE string GraphicsWindowInputDevice:: +INLINE std::string GraphicsWindowInputDevice:: get_name() const { LightMutexHolder holder(_lock); return _name; diff --git a/panda/src/display/graphicsWindowInputDevice.h b/panda/src/display/graphicsWindowInputDevice.h index 5cdff54f29..b570b5f384 100644 --- a/panda/src/display/graphicsWindowInputDevice.h +++ b/panda/src/display/graphicsWindowInputDevice.h @@ -38,19 +38,19 @@ class GraphicsWindow; */ class EXPCL_PANDA_DISPLAY GraphicsWindowInputDevice { private: - GraphicsWindowInputDevice(GraphicsWindow *host, const string &name, int flags); + GraphicsWindowInputDevice(GraphicsWindow *host, const std::string &name, int flags); public: - static GraphicsWindowInputDevice pointer_only(GraphicsWindow *host, const string &name); - static GraphicsWindowInputDevice keyboard_only(GraphicsWindow *host, const string &name); - static GraphicsWindowInputDevice pointer_and_keyboard(GraphicsWindow *host, const string &name); + static GraphicsWindowInputDevice pointer_only(GraphicsWindow *host, const std::string &name); + static GraphicsWindowInputDevice keyboard_only(GraphicsWindow *host, const std::string &name); + static GraphicsWindowInputDevice pointer_and_keyboard(GraphicsWindow *host, const std::string &name); INLINE GraphicsWindowInputDevice(); GraphicsWindowInputDevice(const GraphicsWindowInputDevice ©); void operator = (const GraphicsWindowInputDevice ©); ~GraphicsWindowInputDevice(); - INLINE string get_name() const; + INLINE std::string get_name() const; INLINE bool has_pointer() const; INLINE bool has_keyboard() const; @@ -87,7 +87,7 @@ PUBLISHED: void button_resume_down(ButtonHandle button, double time); void button_up(ButtonHandle button, double time); void keystroke(int keycode, double time); - void candidate(const wstring &candidate_string, size_t highlight_start, + void candidate(const std::wstring &candidate_string, size_t highlight_start, size_t highlight_end, size_t cursor_pos); void focus_lost(double time); void raw_button_down(ButtonHandle button, double time); @@ -115,7 +115,7 @@ private: GraphicsWindow *_host; - string _name; + std::string _name; int _flags; int _device_index; int _event_sequence; diff --git a/panda/src/display/graphicsWindowProcCallbackData.h b/panda/src/display/graphicsWindowProcCallbackData.h index d417a3595e..23ae66d9c7 100644 --- a/panda/src/display/graphicsWindowProcCallbackData.h +++ b/panda/src/display/graphicsWindowProcCallbackData.h @@ -39,7 +39,7 @@ public: #endif PUBLISHED: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; #ifdef WIN32 INLINE uintptr_t get_hwnd() const; diff --git a/panda/src/display/nativeWindowHandle.h b/panda/src/display/nativeWindowHandle.h index da6096533a..1ee6fec43a 100644 --- a/panda/src/display/nativeWindowHandle.h +++ b/panda/src/display/nativeWindowHandle.h @@ -56,7 +56,7 @@ public: public: INLINE IntHandle(size_t handle); virtual size_t get_int_handle() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; INLINE size_t get_handle() const; @@ -84,7 +84,7 @@ public: class EXPCL_PANDA_DISPLAY SubprocessHandle : public OSHandle { public: INLINE SubprocessHandle(const Filename &filename); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; INLINE const Filename &get_filename() const; @@ -114,7 +114,7 @@ public: public: INLINE X11Handle(X11_Window handle); virtual size_t get_int_handle() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; INLINE X11_Window get_handle() const; @@ -146,7 +146,7 @@ public: public: INLINE WinHandle(HWND handle); virtual size_t get_int_handle() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; INLINE HWND get_handle() const; diff --git a/panda/src/display/parasiteBuffer.h b/panda/src/display/parasiteBuffer.h index 421b932584..3c197c068e 100644 --- a/panda/src/display/parasiteBuffer.h +++ b/panda/src/display/parasiteBuffer.h @@ -42,7 +42,7 @@ */ class EXPCL_PANDA_DISPLAY ParasiteBuffer : public GraphicsOutput { public: - ParasiteBuffer(GraphicsOutput *host, const string &name, + ParasiteBuffer(GraphicsOutput *host, const std::string &name, int x_size, int y_size, int flags); PUBLISHED: diff --git a/panda/src/display/stereoDisplayRegion.h b/panda/src/display/stereoDisplayRegion.h index b1d27bd361..940d793f4b 100644 --- a/panda/src/display/stereoDisplayRegion.h +++ b/panda/src/display/stereoDisplayRegion.h @@ -58,7 +58,7 @@ PUBLISHED: virtual void set_cull_traverser(CullTraverser *trav); virtual void set_target_tex_page(int page); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; virtual PT(PandaNode) make_cull_result_graph(); INLINE DisplayRegion *get_left_eye(); diff --git a/panda/src/display/subprocessWindow.h b/panda/src/display/subprocessWindow.h index 8065721f42..1339b8f90d 100644 --- a/panda/src/display/subprocessWindow.h +++ b/panda/src/display/subprocessWindow.h @@ -45,7 +45,7 @@ class SubprocessWindow : public GraphicsWindow { public: SubprocessWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/display/subprocessWindowBuffer.h b/panda/src/display/subprocessWindowBuffer.h index e0d52a7f4a..2cadcee8f5 100644 --- a/panda/src/display/subprocessWindowBuffer.h +++ b/panda/src/display/subprocessWindowBuffer.h @@ -41,16 +41,16 @@ private: public: static SubprocessWindowBuffer *new_buffer(int &fd, size_t &mmap_size, - string &filename, + std::string &filename, int x_size, int y_size); static void destroy_buffer(int fd, size_t mmap_size, - const string &filename, + const std::string &filename, SubprocessWindowBuffer *buffer); static SubprocessWindowBuffer *open_buffer(int &fd, size_t &mmap_size, - const string &filename); + const std::string &filename); static void close_buffer(int fd, size_t mmap_size, - const string &filename, + const std::string &filename, SubprocessWindowBuffer *buffer); bool verify_magic_number() const; diff --git a/panda/src/display/windowHandle.h b/panda/src/display/windowHandle.h index 1679e3d95f..7089aa8e28 100644 --- a/panda/src/display/windowHandle.h +++ b/panda/src/display/windowHandle.h @@ -47,7 +47,7 @@ PUBLISHED: size_t get_int_handle() const; - void output(ostream &out) const; + void output(std::ostream &out) const; public: // Callbacks for communication with the parent window. @@ -67,7 +67,7 @@ PUBLISHED: PUBLISHED: virtual ~OSHandle(); virtual size_t get_int_handle() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; public: static TypeHandle get_class_type() { @@ -112,12 +112,12 @@ private: #include "windowHandle.I" -INLINE ostream &operator << (ostream &out, const WindowHandle &handle) { +INLINE std::ostream &operator << (std::ostream &out, const WindowHandle &handle) { handle.output(out); return out; } -INLINE ostream &operator << (ostream &out, const WindowHandle::OSHandle &handle) { +INLINE std::ostream &operator << (std::ostream &out, const WindowHandle::OSHandle &handle) { handle.output(out); return out; } diff --git a/panda/src/display/windowProperties.I b/panda/src/display/windowProperties.I index f9af047b54..d134ea2be5 100644 --- a/panda/src/display/windowProperties.I +++ b/panda/src/display/windowProperties.I @@ -182,7 +182,7 @@ clear_size() { * Specifies the title that should be assigned to the window. */ INLINE void WindowProperties:: -set_title(const string &title) { +set_title(const std::string &title) { _title = title; _specified |= S_title; } @@ -190,7 +190,7 @@ set_title(const string &title) { /** * Returns the window's title. */ -INLINE const string &WindowProperties:: +INLINE const std::string &WindowProperties:: get_title() const { nassertr(has_title(), _title); return _title; @@ -210,7 +210,7 @@ has_title() const { INLINE void WindowProperties:: clear_title() { _specified &= ~S_title; - _title = string(); + _title = std::string(); } /** @@ -730,8 +730,8 @@ clear_parent_window() { } -INLINE ostream & -operator << (ostream &out, const WindowProperties &properties) { +INLINE std::ostream & +operator << (std::ostream &out, const WindowProperties &properties) { properties.output(out); return out; } diff --git a/panda/src/display/windowProperties.h b/panda/src/display/windowProperties.h index dd6ba5185c..68ba4e7f1d 100644 --- a/panda/src/display/windowProperties.h +++ b/panda/src/display/windowProperties.h @@ -86,8 +86,8 @@ PUBLISHED: MAKE_PROPERTY2(mouse_mode, has_mouse_mode, get_mouse_mode, set_mouse_mode, clear_mouse_mode); - INLINE void set_title(const string &title); - INLINE const string &get_title() const; + INLINE void set_title(const std::string &title); + INLINE const std::string &get_title() const; INLINE bool has_title() const; INLINE void clear_title(); MAKE_PROPERTY2(title, has_title, get_title, set_title, clear_title); @@ -175,7 +175,7 @@ PUBLISHED: void add_properties(const WindowProperties &other); - void output(ostream &out) const; + void output(std::ostream &out) const; private: // This bitmask indicates which of the parameters in the properties @@ -216,7 +216,7 @@ private: LPoint2i _origin; LVector2i _size; MouseMode _mouse_mode; - string _title; + std::string _title; Filename _cursor_filename; Filename _icon_filename; ZOrder _z_order; @@ -226,18 +226,18 @@ private: static WindowProperties *_default_properties; }; -EXPCL_PANDA_DISPLAY ostream & -operator << (ostream &out, WindowProperties::ZOrder z_order); -EXPCL_PANDA_DISPLAY istream & -operator >> (istream &in, WindowProperties::ZOrder &z_order); +EXPCL_PANDA_DISPLAY std::ostream & +operator << (std::ostream &out, WindowProperties::ZOrder z_order); +EXPCL_PANDA_DISPLAY std::istream & +operator >> (std::istream &in, WindowProperties::ZOrder &z_order); -EXPCL_PANDA_DISPLAY ostream & -operator << (ostream &out, WindowProperties::MouseMode mode); -EXPCL_PANDA_DISPLAY istream & -operator >> (istream &in, WindowProperties::MouseMode &mode); +EXPCL_PANDA_DISPLAY std::ostream & +operator << (std::ostream &out, WindowProperties::MouseMode mode); +EXPCL_PANDA_DISPLAY std::istream & +operator >> (std::istream &in, WindowProperties::MouseMode &mode); -INLINE ostream &operator << (ostream &out, const WindowProperties &properties); +INLINE std::ostream &operator << (std::ostream &out, const WindowProperties &properties); #include "windowProperties.I" diff --git a/panda/src/distort/nonlinearImager.h b/panda/src/distort/nonlinearImager.h index 621ad0d139..aa07854df7 100644 --- a/panda/src/distort/nonlinearImager.h +++ b/panda/src/distort/nonlinearImager.h @@ -84,7 +84,7 @@ PUBLISHED: ~NonlinearImager(); int add_screen(ProjectionScreen *screen); - int add_screen(const NodePath &screen, const string &name); + int add_screen(const NodePath &screen, const std::string &name); int find_screen(const NodePath &screen) const; void remove_screen(int index); void remove_all_screens(); @@ -146,7 +146,7 @@ private: public: NodePath _screen; PT(ProjectionScreen) _screen_node; - string _name; + std::string _name; PT(GraphicsOutput) _buffer; NodePath _source_camera; int _tex_width, _tex_height; diff --git a/panda/src/distort/projectionScreen.I b/panda/src/distort/projectionScreen.I index b1fa41f7f5..2ff54cfeb5 100644 --- a/panda/src/distort/projectionScreen.I +++ b/panda/src/distort/projectionScreen.I @@ -67,7 +67,7 @@ get_undist_lut() const { * stages of the multitexture pipeline. */ INLINE void ProjectionScreen:: -set_texcoord_name(const string &texcoord_name) { +set_texcoord_name(const std::string &texcoord_name) { _texcoord_name = InternalName::get_texcoord_name(texcoord_name); _stale = true; } @@ -76,7 +76,7 @@ set_texcoord_name(const string &texcoord_name) { * Returns the name of the texture coordinates that will be generated by this * particular ProjectionScreen, as set by set_texcoord_name(). */ -INLINE string ProjectionScreen:: +INLINE std::string ProjectionScreen:: get_texcoord_name() const { return _texcoord_name->get_name(); } diff --git a/panda/src/distort/projectionScreen.h b/panda/src/distort/projectionScreen.h index 86f9484379..ef90ebb070 100644 --- a/panda/src/distort/projectionScreen.h +++ b/panda/src/distort/projectionScreen.h @@ -47,7 +47,7 @@ class WorkingNodePath; */ class EXPCL_PANDAFX ProjectionScreen : public PandaNode { PUBLISHED: - explicit ProjectionScreen(const string &name = ""); + explicit ProjectionScreen(const std::string &name = ""); virtual ~ProjectionScreen(); protected: @@ -67,16 +67,16 @@ PUBLISHED: INLINE const PfmFile &get_undist_lut() const; PT(GeomNode) generate_screen(const NodePath &projector, - const string &screen_name, + const std::string &screen_name, int num_x_verts, int num_y_verts, PN_stdfloat distance, PN_stdfloat fill_ratio); - void regenerate_screen(const NodePath &projector, const string &screen_name, + void regenerate_screen(const NodePath &projector, const std::string &screen_name, int num_x_verts, int num_y_verts, PN_stdfloat distance, PN_stdfloat fill_ratio); PT(PandaNode) make_flat_mesh(const NodePath &this_np, const NodePath &camera); - INLINE void set_texcoord_name(const string &texcoord_name); - INLINE string get_texcoord_name() const; + INLINE void set_texcoord_name(const std::string &texcoord_name); + INLINE std::string get_texcoord_name() const; INLINE void set_invert_uvs(bool invert_uvs); INLINE bool get_invert_uvs() const; diff --git a/panda/src/downloader/bioPtr.I b/panda/src/downloader/bioPtr.I index a1e1f13e1d..7d1e2b04dc 100644 --- a/panda/src/downloader/bioPtr.I +++ b/panda/src/downloader/bioPtr.I @@ -61,7 +61,7 @@ get_bio() const { /** * Returns the name of the server we are (or should be) connected to. */ -INLINE const string &BioPtr:: +INLINE const std::string &BioPtr:: get_server_name() const { return _server_name; } diff --git a/panda/src/downloader/bioPtr.h b/panda/src/downloader/bioPtr.h index 090ae20608..d0c2e88b9d 100644 --- a/panda/src/downloader/bioPtr.h +++ b/panda/src/downloader/bioPtr.h @@ -57,12 +57,12 @@ public: INLINE void set_bio(BIO *bio); INLINE BIO *get_bio() const; - INLINE const string &get_server_name() const; + INLINE const std::string &get_server_name() const; INLINE int get_port() const; private: BIO *_bio; - string _server_name; + std::string _server_name; int _port; struct sockaddr_storage _addr; socklen_t _addrlen; diff --git a/panda/src/downloader/bioStreamBuf.h b/panda/src/downloader/bioStreamBuf.h index 0378d9db65..b588105e69 100644 --- a/panda/src/downloader/bioStreamBuf.h +++ b/panda/src/downloader/bioStreamBuf.h @@ -25,7 +25,7 @@ /** * The streambuf object that implements IBioStream. */ -class EXPCL_PANDAEXPRESS BioStreamBuf : public streambuf { +class EXPCL_PANDAEXPRESS BioStreamBuf : public std::streambuf { public: BioStreamBuf(); virtual ~BioStreamBuf(); diff --git a/panda/src/downloader/chunkedStreamBuf.h b/panda/src/downloader/chunkedStreamBuf.h index 675914772c..fbcde6797d 100644 --- a/panda/src/downloader/chunkedStreamBuf.h +++ b/panda/src/downloader/chunkedStreamBuf.h @@ -26,7 +26,7 @@ /** * The streambuf object that implements IChunkedStream. */ -class ChunkedStreamBuf : public streambuf { +class ChunkedStreamBuf : public std::streambuf { // No need to export from DLL. public: ChunkedStreamBuf(); @@ -43,13 +43,13 @@ protected: private: size_t read_chars(char *start, size_t length); - bool http_getline(string &str); + bool http_getline(std::string &str); PT(BioStreamPtr) _source; size_t _chunk_remaining; bool _done; bool _wanted_nonblocking; - string _working_getline; + std::string _working_getline; ISocketStream::ReadState _read_state; PT(HTTPChannel) _doc; diff --git a/panda/src/downloader/decompressor.h b/panda/src/downloader/decompressor.h index fe15352355..414dca6687 100644 --- a/panda/src/downloader/decompressor.h +++ b/panda/src/downloader/decompressor.h @@ -48,9 +48,9 @@ private: Filename _source_filename; - istream *_source; - istream *_decompress; - ostream *_dest; + std::istream *_source; + std::istream *_decompress; + std::ostream *_dest; size_t _source_length; }; diff --git a/panda/src/downloader/documentSpec.I b/panda/src/downloader/documentSpec.I index aeb962671d..3077ac2848 100644 --- a/panda/src/downloader/documentSpec.I +++ b/panda/src/downloader/documentSpec.I @@ -25,7 +25,7 @@ DocumentSpec() { * */ INLINE DocumentSpec:: -DocumentSpec(const string &url) : +DocumentSpec(const std::string &url) : _url(url) { _request_mode = RM_any; @@ -262,16 +262,16 @@ get_cache_control() const { return _cache_control; } -INLINE istream & -operator >> (istream &in, DocumentSpec &doc) { +INLINE std::istream & +operator >> (std::istream &in, DocumentSpec &doc) { if (!doc.input(in)) { - in.clear(ios::failbit | in.rdstate()); + in.clear(std::ios::failbit | in.rdstate()); } return in; } -INLINE ostream & -operator << (ostream &out, const DocumentSpec &doc) { +INLINE std::ostream & +operator << (std::ostream &out, const DocumentSpec &doc) { doc.output(out); return out; } diff --git a/panda/src/downloader/documentSpec.h b/panda/src/downloader/documentSpec.h index 8fd205ef9b..c9328f56a6 100644 --- a/panda/src/downloader/documentSpec.h +++ b/panda/src/downloader/documentSpec.h @@ -30,7 +30,7 @@ class EXPCL_PANDAEXPRESS DocumentSpec { PUBLISHED: INLINE DocumentSpec(); - INLINE DocumentSpec(const string &url); + INLINE DocumentSpec(const std::string &url); INLINE DocumentSpec(const URLSpec &url); INLINE DocumentSpec(const DocumentSpec ©); INLINE void operator = (const DocumentSpec ©); @@ -72,9 +72,9 @@ PUBLISHED: INLINE void set_cache_control(CacheControl cache_control); INLINE CacheControl get_cache_control() const; - bool input(istream &in); - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + bool input(std::istream &in); + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; PUBLISHED: MAKE_PROPERTY(url, get_url, set_url); @@ -98,8 +98,8 @@ private: int _flags; }; -INLINE istream &operator >> (istream &in, DocumentSpec &doc); -INLINE ostream &operator << (ostream &out, const DocumentSpec &doc); +INLINE std::istream &operator >> (std::istream &in, DocumentSpec &doc); +INLINE std::ostream &operator << (std::ostream &out, const DocumentSpec &doc); #include "documentSpec.I" diff --git a/panda/src/downloader/downloadDb.I b/panda/src/downloader/downloadDb.I index a97e1d7595..f2312be537 100644 --- a/panda/src/downloader/downloadDb.I +++ b/panda/src/downloader/downloadDb.I @@ -30,7 +30,7 @@ get_server_num_multifiles() const { /** * */ -INLINE string DownloadDb:: +INLINE std::string DownloadDb:: get_client_multifile_name(int index) const { return _client_db.get_multifile_name(index); } @@ -38,7 +38,7 @@ get_client_multifile_name(int index) const { /** * */ -INLINE string DownloadDb:: +INLINE std::string DownloadDb:: get_server_multifile_name(int index) const { return _server_db.get_multifile_name(index); } @@ -48,7 +48,7 @@ get_server_multifile_name(int index) const { * */ INLINE Phase DownloadDb:: -get_client_multifile_phase(string mfname) const { +get_client_multifile_phase(std::string mfname) const { return (_client_db.get_multifile_record_named(mfname))->_phase; } @@ -56,7 +56,7 @@ get_client_multifile_phase(string mfname) const { * */ INLINE Phase DownloadDb:: -get_server_multifile_phase(string mfname) const { +get_server_multifile_phase(std::string mfname) const { return (_server_db.get_multifile_record_named(mfname))->_phase; } @@ -66,7 +66,7 @@ get_server_multifile_phase(string mfname) const { * */ INLINE int DownloadDb:: -get_client_multifile_size(string mfname) const { +get_client_multifile_size(std::string mfname) const { return (_client_db.get_multifile_record_named(mfname))->_size; } @@ -74,7 +74,7 @@ get_client_multifile_size(string mfname) const { * */ INLINE void DownloadDb:: -set_client_multifile_size(string mfname, int size) { +set_client_multifile_size(std::string mfname, int size) { (_client_db.get_multifile_record_named(mfname))->_size = size; write_client_db(_client_db._filename); } @@ -84,7 +84,7 @@ set_client_multifile_size(string mfname, int size) { * */ INLINE int DownloadDb:: -set_client_multifile_delta_size(string mfname, int size) { +set_client_multifile_delta_size(std::string mfname, int size) { (_client_db.get_multifile_record_named(mfname))->_size += size; write_client_db(_client_db._filename); // Return the new total @@ -97,7 +97,7 @@ set_client_multifile_delta_size(string mfname, int size) { * */ INLINE int DownloadDb:: -get_server_multifile_size(string mfname) const { +get_server_multifile_size(std::string mfname) const { return (_server_db.get_multifile_record_named(mfname))->_size; } @@ -106,7 +106,7 @@ get_server_multifile_size(string mfname) const { * */ INLINE void DownloadDb:: -set_server_multifile_size(string mfname, int size) { +set_server_multifile_size(std::string mfname, int size) { (_server_db.get_multifile_record_named(mfname))->_size = size; } @@ -115,7 +115,7 @@ set_server_multifile_size(string mfname, int size) { * */ INLINE void DownloadDb:: -set_client_multifile_incomplete(string mfname) { +set_client_multifile_incomplete(std::string mfname) { (_client_db.get_multifile_record_named(mfname))->_status = Status_incomplete; write_client_db(_client_db._filename); } @@ -124,7 +124,7 @@ set_client_multifile_incomplete(string mfname) { * */ INLINE void DownloadDb:: -set_client_multifile_complete(string mfname) { +set_client_multifile_complete(std::string mfname) { (_client_db.get_multifile_record_named(mfname))->_status = Status_complete; write_client_db(_client_db._filename); } @@ -133,7 +133,7 @@ set_client_multifile_complete(string mfname) { * */ INLINE void DownloadDb:: -set_client_multifile_decompressed(string mfname) { +set_client_multifile_decompressed(std::string mfname) { (_client_db.get_multifile_record_named(mfname))->_status = Status_decompressed; write_client_db(_client_db._filename); } @@ -142,7 +142,7 @@ set_client_multifile_decompressed(string mfname) { * */ INLINE void DownloadDb:: -set_client_multifile_extracted(string mfname) { +set_client_multifile_extracted(std::string mfname) { (_client_db.get_multifile_record_named(mfname))->_status = Status_extracted; write_client_db(_client_db._filename); } @@ -151,14 +151,14 @@ set_client_multifile_extracted(string mfname) { * */ INLINE int DownloadDb:: -get_server_num_files(string mfname) const { +get_server_num_files(std::string mfname) const { return (_server_db.get_multifile_record_named(mfname))->get_num_files(); } /** * */ -INLINE string DownloadDb:: -get_server_file_name(string mfname, int index) const { +INLINE std::string DownloadDb:: +get_server_file_name(std::string mfname, int index) const { return (_server_db.get_multifile_record_named(mfname))->get_file_name(index); } diff --git a/panda/src/downloader/downloadDb.h b/panda/src/downloader/downloadDb.h index b7f206c3b6..f879098811 100644 --- a/panda/src/downloader/downloadDb.h +++ b/panda/src/downloader/downloadDb.h @@ -76,9 +76,9 @@ PUBLISHED: explicit DownloadDb(Filename &server_file, Filename &client_file); ~DownloadDb(); - void output(ostream &out) const; - void write(ostream &out) const; - void write_version_map(ostream &out) const; + void output(std::ostream &out) const; + void write(std::ostream &out) const; + void write_version_map(std::ostream &out) const; // Write a database file bool write_client_db(Filename &file); @@ -87,56 +87,56 @@ PUBLISHED: INLINE int get_client_num_multifiles() const; INLINE int get_server_num_multifiles() const; - INLINE string get_client_multifile_name(int index) const; - INLINE string get_server_multifile_name(int index) const; + INLINE std::string get_client_multifile_name(int index) const; + INLINE std::string get_server_multifile_name(int index) const; - INLINE int get_client_multifile_size(string mfname) const; - INLINE void set_client_multifile_size(string mfname, int size); - INLINE int set_client_multifile_delta_size(string mfname, int size); - INLINE int get_server_multifile_size(string mfname) const; - INLINE void set_server_multifile_size(string mfname, int size); + INLINE int get_client_multifile_size(std::string mfname) const; + INLINE void set_client_multifile_size(std::string mfname, int size); + INLINE int set_client_multifile_delta_size(std::string mfname, int size); + INLINE int get_server_multifile_size(std::string mfname) const; + INLINE void set_server_multifile_size(std::string mfname, int size); - INLINE Phase get_client_multifile_phase(string mfname) const; - INLINE Phase get_server_multifile_phase(string mfname) const; + INLINE Phase get_client_multifile_phase(std::string mfname) const; + INLINE Phase get_server_multifile_phase(std::string mfname) const; - INLINE void set_client_multifile_incomplete(string mfname); - INLINE void set_client_multifile_complete(string mfname); - INLINE void set_client_multifile_decompressed(string mfname); - INLINE void set_client_multifile_extracted(string mfname); + INLINE void set_client_multifile_incomplete(std::string mfname); + INLINE void set_client_multifile_complete(std::string mfname); + INLINE void set_client_multifile_decompressed(std::string mfname); + INLINE void set_client_multifile_extracted(std::string mfname); - INLINE int get_server_num_files(string mfname) const; - INLINE string get_server_file_name(string mfname, int index) const; + INLINE int get_server_num_files(std::string mfname) const; + INLINE std::string get_server_file_name(std::string mfname, int index) const; // Queries from the Launcher - bool client_multifile_exists(string mfname) const; - bool client_multifile_complete(string mfname) const; - bool client_multifile_decompressed(string mfname) const; - bool client_multifile_extracted(string mfname) const; + bool client_multifile_exists(std::string mfname) const; + bool client_multifile_complete(std::string mfname) const; + bool client_multifile_decompressed(std::string mfname) const; + bool client_multifile_extracted(std::string mfname) const; // Ask what version (told with the hash) this multifile is - HashVal get_client_multifile_hash(string mfname) const; - void set_client_multifile_hash(string mfname, HashVal val); - HashVal get_server_multifile_hash(string mfname) const; - void set_server_multifile_hash(string mfname, HashVal val); + HashVal get_client_multifile_hash(std::string mfname) const; + void set_client_multifile_hash(std::string mfname, HashVal val); + HashVal get_server_multifile_hash(std::string mfname) const; + void set_server_multifile_hash(std::string mfname, HashVal val); // Operations on multifiles - void delete_client_multifile(string mfname); - void add_client_multifile(string server_mfname); - void expand_client_multifile(string mfname); + void delete_client_multifile(std::string mfname); + void add_client_multifile(std::string server_mfname); + void expand_client_multifile(std::string mfname); // Server side operations to create multifile records void create_new_server_db(); - void server_add_multifile(string mfname, Phase phase, int size, int status); - void server_add_file(string mfname, string fname); + void server_add_multifile(std::string mfname, Phase phase, int size, int status); + void server_add_file(std::string mfname, std::string fname); public: class EXPCL_PANDAEXPRESS FileRecord : public ReferenceCount { public: FileRecord(); - FileRecord(string name); - void write(ostream &out) const; - string _name; + FileRecord(std::string name); + void write(std::ostream &out) const; + std::string _name; }; typedef pvector< PT(FileRecord) > FileRecords; @@ -144,14 +144,14 @@ public: class EXPCL_PANDAEXPRESS MultifileRecord : public ReferenceCount { public: MultifileRecord(); - MultifileRecord(string name, Phase phase, int size, int status); - void write(ostream &out) const; + MultifileRecord(std::string name, Phase phase, int size, int status); + void write(std::ostream &out) const; int get_num_files() const; - string get_file_name(int index) const; - bool file_exists(string fname) const; - PT(FileRecord) get_file_record_named(string fname) const; + std::string get_file_name(int index) const; + bool file_exists(std::string fname) const; + PT(FileRecord) get_file_record_named(std::string fname) const; void add_file_record(PT(FileRecord) fr); - string _name; + std::string _name; Phase _phase; int _size; int _status; @@ -165,11 +165,11 @@ public: class EXPCL_PANDAEXPRESS Db { public: Db(); - void write(ostream &out) const; + void write(std::ostream &out) const; int get_num_multifiles() const; - string get_multifile_name(int index) const; - bool multifile_exists(string mfname) const; - PT(MultifileRecord) get_multifile_record_named(string mfname) const; + std::string get_multifile_name(int index) const; + bool multifile_exists(std::string mfname) const; + PT(MultifileRecord) get_multifile_record_named(std::string mfname) const; void add_multifile_record(PT(MultifileRecord) mfr); int parse_header(Datagram dg); int parse_record_header(Datagram dg); @@ -179,7 +179,7 @@ public: bool write(StreamWriter &sw, bool want_server_info); Filename _filename; MultifileRecords _mfile_records; - bool write_header(ostream &write_stream); + bool write_header(std::ostream &write_stream); bool write_bogus_header(StreamWriter &sw); private: int32_t _header_length; @@ -218,7 +218,7 @@ protected: VersionMap _versions; }; -INLINE ostream &operator << (ostream &out, const DownloadDb &dldb) { +INLINE std::ostream &operator << (std::ostream &out, const DownloadDb &dldb) { dldb.output(out); return out; } diff --git a/panda/src/downloader/extractor.h b/panda/src/downloader/extractor.h index 0747eed350..b69b11c0f2 100644 --- a/panda/src/downloader/extractor.h +++ b/panda/src/downloader/extractor.h @@ -71,7 +71,7 @@ private: size_t _subfile_pos; size_t _subfile_length; size_t _total_bytes_extracted; - istream *_read; + std::istream *_read; pofstream _write; Filename _subfile_filename; }; diff --git a/panda/src/downloader/httpAuthorization.I b/panda/src/downloader/httpAuthorization.I index bc105214df..5c00fa3724 100644 --- a/panda/src/downloader/httpAuthorization.I +++ b/panda/src/downloader/httpAuthorization.I @@ -16,7 +16,7 @@ * supplied string that may have meaning to the user, and describes the * general collection of things protected by this password. */ -const string &HTTPAuthorization:: +const std::string &HTTPAuthorization:: get_realm() const { return _realm; } diff --git a/panda/src/downloader/httpAuthorization.h b/panda/src/downloader/httpAuthorization.h index 4ac0457242..fcc08103e3 100644 --- a/panda/src/downloader/httpAuthorization.h +++ b/panda/src/downloader/httpAuthorization.h @@ -35,8 +35,8 @@ class URLSpec; */ class EXPCL_PANDAEXPRESS HTTPAuthorization : public ReferenceCount { public: - typedef pmap Tokens; - typedef pmap AuthenticationSchemes; + typedef pmap Tokens; + typedef pmap AuthenticationSchemes; protected: HTTPAuthorization(const Tokens &tokens, const URLSpec &url, @@ -44,28 +44,28 @@ protected: public: virtual ~HTTPAuthorization(); - virtual const string &get_mechanism() const=0; + virtual const std::string &get_mechanism() const=0; virtual bool is_valid(); - INLINE const string &get_realm() const; + INLINE const std::string &get_realm() const; INLINE const vector_string &get_domain() const; - virtual string generate(HTTPEnum::Method method, const string &request_path, - const string &username, const string &body)=0; + virtual std::string generate(HTTPEnum::Method method, const std::string &request_path, + const std::string &username, const std::string &body)=0; static void parse_authentication_schemes(AuthenticationSchemes &schemes, - const string &field_value); + const std::string &field_value); static URLSpec get_canonical_url(const URLSpec &url); - static string base64_encode(const string &s); - static string base64_decode(const string &s); + static std::string base64_encode(const std::string &s); + static std::string base64_decode(const std::string &s); protected: - static size_t scan_quoted_or_unquoted_string(string &result, - const string &source, + static size_t scan_quoted_or_unquoted_string(std::string &result, + const std::string &source, size_t start); protected: - string _realm; + std::string _realm; vector_string _domain; }; diff --git a/panda/src/downloader/httpBasicAuthorization.h b/panda/src/downloader/httpBasicAuthorization.h index 2d18a29a25..92e85bb3ab 100644 --- a/panda/src/downloader/httpBasicAuthorization.h +++ b/panda/src/downloader/httpBasicAuthorization.h @@ -36,12 +36,12 @@ public: bool is_proxy); virtual ~HTTPBasicAuthorization(); - virtual const string &get_mechanism() const; - virtual string generate(HTTPEnum::Method method, const string &request_path, - const string &username, const string &body); + virtual const std::string &get_mechanism() const; + virtual std::string generate(HTTPEnum::Method method, const std::string &request_path, + const std::string &username, const std::string &body); private: - static const string _mechanism; + static const std::string _mechanism; }; #include "httpBasicAuthorization.I" diff --git a/panda/src/downloader/httpChannel.I b/panda/src/downloader/httpChannel.I index 1a254e478a..1fdd7e32f2 100644 --- a/panda/src/downloader/httpChannel.I +++ b/panda/src/downloader/httpChannel.I @@ -76,7 +76,7 @@ get_http_version() const { * Returns the HTTP version number returned by the server, formatted as a * string, e.g. "HTTP/1.1". */ -INLINE const string &HTTPChannel:: +INLINE const std::string &HTTPChannel:: get_http_version_string() const { return _http_version_string; } @@ -103,7 +103,7 @@ get_status_code() const { * presented to the user to request an associated username and password (which * then should be stored in HTTPClient::set_username()). */ -INLINE const string &HTTPChannel:: +INLINE const std::string &HTTPChannel:: get_www_realm() const { return _www_realm; } @@ -114,7 +114,7 @@ get_www_realm() const { * string may be presented to the user to request an associated username and * password (which then should be stored in HTTPClient::set_username()). */ -INLINE const string &HTTPChannel:: +INLINE const std::string &HTTPChannel:: get_proxy_realm() const { return _proxy_realm; } @@ -431,14 +431,14 @@ get_max_updates_per_second() const { * different types of content, such as JSON. */ INLINE void HTTPChannel:: -set_content_type(string content_type) { +set_content_type(std::string content_type) { _content_type = content_type; } /** * Returns the value of the Content-Type header. */ -INLINE string HTTPChannel:: +INLINE std::string HTTPChannel:: get_content_type() const { return _content_type; } @@ -555,7 +555,7 @@ preserve_status() { */ INLINE void HTTPChannel:: clear_extra_headers() { - _send_extra_headers = string(); + _send_extra_headers = std::string(); } /** @@ -568,7 +568,7 @@ clear_extra_headers() { * request. */ INLINE void HTTPChannel:: -send_extra_header(const string &key, const string &value) { +send_extra_header(const std::string &key, const std::string &value) { _send_extra_headers += key; _send_extra_headers += ": "; _send_extra_headers += value; @@ -581,7 +581,7 @@ send_extra_header(const string &key, const string &value) { */ INLINE bool HTTPChannel:: get_document(const DocumentSpec &url) { - begin_request(HTTPEnum::M_get, url, string(), false, 0, 0); + begin_request(HTTPEnum::M_get, url, std::string(), false, 0, 0); while (run()) { } return is_valid(); @@ -596,7 +596,7 @@ get_document(const DocumentSpec &url) { */ INLINE bool HTTPChannel:: get_subdocument(const DocumentSpec &url, size_t first_byte, size_t last_byte) { - begin_request(HTTPEnum::M_get, url, string(), false, first_byte, last_byte); + begin_request(HTTPEnum::M_get, url, std::string(), false, first_byte, last_byte); while (run()) { } return is_valid(); @@ -610,7 +610,7 @@ get_subdocument(const DocumentSpec &url, size_t first_byte, size_t last_byte) { */ INLINE bool HTTPChannel:: get_header(const DocumentSpec &url) { - begin_request(HTTPEnum::M_head, url, string(), false, 0, 0); + begin_request(HTTPEnum::M_head, url, std::string(), false, 0, 0); while (run()) { } return is_valid(); @@ -620,7 +620,7 @@ get_header(const DocumentSpec &url) { * Posts form data to a particular URL and retrieves the response. */ INLINE bool HTTPChannel:: -post_form(const DocumentSpec &url, const string &body) { +post_form(const DocumentSpec &url, const std::string &body) { begin_request(HTTPEnum::M_post, url, body, false, 0, 0); while (run()) { } @@ -632,7 +632,7 @@ post_form(const DocumentSpec &url, const string &body) { * the server allows this. */ INLINE bool HTTPChannel:: -put_document(const DocumentSpec &url, const string &body) { +put_document(const DocumentSpec &url, const std::string &body) { begin_request(HTTPEnum::M_put, url, body, false, 0, 0); while (run()) { } @@ -644,7 +644,7 @@ put_document(const DocumentSpec &url, const string &body) { */ INLINE bool HTTPChannel:: delete_document(const DocumentSpec &url) { - begin_request(HTTPEnum::M_delete, url, string(), false, 0, 0); + begin_request(HTTPEnum::M_delete, url, std::string(), false, 0, 0); while (run()) { } return is_valid(); @@ -656,7 +656,7 @@ delete_document(const DocumentSpec &url) { */ INLINE bool HTTPChannel:: get_trace(const DocumentSpec &url) { - begin_request(HTTPEnum::M_trace, url, string(), false, 0, 0); + begin_request(HTTPEnum::M_trace, url, std::string(), false, 0, 0); while (run()) { } return is_valid(); @@ -671,7 +671,7 @@ get_trace(const DocumentSpec &url) { */ INLINE bool HTTPChannel:: connect_to(const DocumentSpec &url) { - begin_request(HTTPEnum::M_connect, url, string(), false, 0, 0); + begin_request(HTTPEnum::M_connect, url, std::string(), false, 0, 0); while (run()) { } return is_connection_ready(); @@ -683,7 +683,7 @@ connect_to(const DocumentSpec &url) { */ INLINE bool HTTPChannel:: get_options(const DocumentSpec &url) { - begin_request(HTTPEnum::M_options, url, string(), false, 0, 0); + begin_request(HTTPEnum::M_options, url, std::string(), false, 0, 0); while (run()) { } return is_valid(); @@ -700,7 +700,7 @@ get_options(const DocumentSpec &url) { */ INLINE void HTTPChannel:: begin_get_document(const DocumentSpec &url) { - begin_request(HTTPEnum::M_get, url, string(), true, 0, 0); + begin_request(HTTPEnum::M_get, url, std::string(), true, 0, 0); } /** @@ -713,7 +713,7 @@ begin_get_document(const DocumentSpec &url) { INLINE void HTTPChannel:: begin_get_subdocument(const DocumentSpec &url, size_t first_byte, size_t last_byte) { - begin_request(HTTPEnum::M_get, url, string(), true, first_byte, last_byte); + begin_request(HTTPEnum::M_get, url, std::string(), true, first_byte, last_byte); } /** @@ -722,7 +722,7 @@ begin_get_subdocument(const DocumentSpec &url, size_t first_byte, */ INLINE void HTTPChannel:: begin_get_header(const DocumentSpec &url) { - begin_request(HTTPEnum::M_head, url, string(), true, 0, 0); + begin_request(HTTPEnum::M_head, url, std::string(), true, 0, 0); } /** @@ -735,7 +735,7 @@ begin_get_header(const DocumentSpec &url) { * interim, or your form data may not get posted. */ INLINE void HTTPChannel:: -begin_post_form(const DocumentSpec &url, const string &body) { +begin_post_form(const DocumentSpec &url, const std::string &body) { begin_request(HTTPEnum::M_post, url, body, true, 0, 0); } @@ -753,7 +753,7 @@ begin_post_form(const DocumentSpec &url, const string &body) { */ INLINE void HTTPChannel:: begin_connect_to(const DocumentSpec &url) { - begin_request(HTTPEnum::M_connect, url, string(), true, 0, 0); + begin_request(HTTPEnum::M_connect, url, std::string(), true, 0, 0); } /** diff --git a/panda/src/downloader/httpChannel.h b/panda/src/downloader/httpChannel.h index 7de0e17e83..758fc95394 100644 --- a/panda/src/downloader/httpChannel.h +++ b/panda/src/downloader/httpChannel.h @@ -100,13 +100,13 @@ PUBLISHED: INLINE const URLSpec &get_url() const; INLINE const DocumentSpec &get_document_spec() const; INLINE HTTPEnum::HTTPVersion get_http_version() const; - INLINE const string &get_http_version_string() const; + INLINE const std::string &get_http_version_string() const; INLINE int get_status_code() const; - string get_status_string() const; - INLINE const string &get_www_realm() const; - INLINE const string &get_proxy_realm() const; + std::string get_status_string() const; + INLINE const std::string &get_www_realm() const; + INLINE const std::string &get_proxy_realm() const; INLINE const URLSpec &get_redirect() const; - string get_header_value(const string &key) const; + std::string get_header_value(const std::string &key) const; INLINE int get_num_redirect_steps() const; INLINE const URLSpec &get_redirect_step(int n) const; @@ -143,11 +143,11 @@ PUBLISHED: INLINE void set_max_updates_per_second(double max_updates_per_second); INLINE double get_max_updates_per_second() const; - INLINE void set_content_type(string content_type); - INLINE string get_content_type() const; + INLINE void set_content_type(std::string content_type); + INLINE std::string get_content_type() const; INLINE void set_expected_file_size(size_t file_size); - streamsize get_file_size() const; + std::streamsize get_file_size() const; INLINE bool is_file_size_known() const; INLINE size_t get_first_byte_requested() const; @@ -155,20 +155,20 @@ PUBLISHED: INLINE size_t get_first_byte_delivered() const; INLINE size_t get_last_byte_delivered() const; - void write_headers(ostream &out) const; + void write_headers(std::ostream &out) const; INLINE void reset(); INLINE void preserve_status(); INLINE void clear_extra_headers(); - INLINE void send_extra_header(const string &key, const string &value); + INLINE void send_extra_header(const std::string &key, const std::string &value); BLOCKING INLINE bool get_document(const DocumentSpec &url); BLOCKING INLINE bool get_subdocument(const DocumentSpec &url, size_t first_byte, size_t last_byte); BLOCKING INLINE bool get_header(const DocumentSpec &url); - BLOCKING INLINE bool post_form(const DocumentSpec &url, const string &body); - BLOCKING INLINE bool put_document(const DocumentSpec &url, const string &body); + BLOCKING INLINE bool post_form(const DocumentSpec &url, const std::string &body); + BLOCKING INLINE bool put_document(const DocumentSpec &url, const std::string &body); BLOCKING INLINE bool delete_document(const DocumentSpec &url); BLOCKING INLINE bool get_trace(const DocumentSpec &url); BLOCKING INLINE bool connect_to(const DocumentSpec &url); @@ -178,16 +178,16 @@ PUBLISHED: INLINE void begin_get_subdocument(const DocumentSpec &url, size_t first_byte, size_t last_byte); INLINE void begin_get_header(const DocumentSpec &url); - INLINE void begin_post_form(const DocumentSpec &url, const string &body); + INLINE void begin_post_form(const DocumentSpec &url, const std::string &body); bool run(); INLINE void begin_connect_to(const DocumentSpec &url); ISocketStream *open_read_body(); - void close_read_body(istream *stream) const; + void close_read_body(std::istream *stream) const; BLOCKING bool download_to_file(const Filename &filename, bool subdocument_resumes = true); BLOCKING bool download_to_ram(Ramfile *ramfile, bool subdocument_resumes = true); - BLOCKING bool download_to_stream(ostream *strm, bool subdocument_resumes = true); + BLOCKING bool download_to_stream(std::ostream *strm, bool subdocument_resumes = true); SocketStream *get_connection(); INLINE size_t get_bytes_downloaded() const; @@ -195,7 +195,7 @@ PUBLISHED: INLINE bool is_download_complete() const; public: - static string downcase(const string &s); + static std::string downcase(const std::string &s); void body_stream_destructs(ISocketStream *stream); private: @@ -227,7 +227,7 @@ private: bool run_download_to_stream(); void begin_request(HTTPEnum::Method method, const DocumentSpec &url, - const string &body, bool nonblocking, + const std::string &body, bool nonblocking, size_t first_byte, size_t last_byte); void reconsider_proxy(); void reset_for_new_request(); @@ -235,32 +235,32 @@ private: void finished_body(bool has_trailer); bool open_download_file(); - bool server_getline(string &str); - bool server_getline_failsafe(string &str); - bool server_get(string &str, size_t num_bytes); - bool server_get_failsafe(string &str, size_t num_bytes); - bool server_send(const string &str, bool secret); - bool parse_http_response(const string &line); + bool server_getline(std::string &str); + bool server_getline_failsafe(std::string &str); + bool server_get(std::string &str, size_t num_bytes); + bool server_get_failsafe(std::string &str, size_t num_bytes); + bool server_send(const std::string &str, bool secret); + bool parse_http_response(const std::string &line); bool parse_http_header(); - bool parse_content_range(const string &content_range); + bool parse_content_range(const std::string &content_range); void check_socket(); void check_preapproved_server_certificate(X509 *cert, bool &cert_preapproved, bool &cert_name_preapproved) const; bool validate_server_name(X509 *cert); - static bool match_cert_name(const string &cert_name, const string &hostname); - static string get_x509_name_component(X509_NAME *name, int nid); + static bool match_cert_name(const std::string &cert_name, const std::string &hostname); + static std::string get_x509_name_component(X509_NAME *name, int nid); void make_header(); void make_proxy_request_text(); void make_request_text(); void reset_url(const URLSpec &old_url, const URLSpec &new_url); - void store_header_field(const string &field_name, const string &field_value); + void store_header_field(const std::string &field_name, const std::string &field_value); #ifndef NDEBUG - static void show_send(const string &message); + static void show_send(const std::string &message); #endif void reset_download_to(); @@ -304,7 +304,7 @@ private: public: INLINE StatusEntry(); int _status_code; - string _status_string; + std::string _status_string; }; typedef pvector Proxies; typedef pvector StatusList; @@ -331,15 +331,15 @@ private: int _bytes_per_update; bool _nonblocking; bool _wanted_nonblocking; - string _send_extra_headers; + std::string _send_extra_headers; DocumentSpec _document_spec; DocumentSpec _request; HTTPEnum::Method _method; - string request_path; - string _header; - string _body; - string _content_type; + std::string request_path; + std::string _header; + std::string _body; + std::string _content_type; bool _want_ssl; bool _proxy_serves_document; bool _proxy_tunnel_now; @@ -360,21 +360,21 @@ private: bool _subdocument_resumes; Filename _download_to_filename; Ramfile *_download_to_ramfile; - ostream *_download_to_stream; + std::ostream *_download_to_stream; int _read_index; HTTPEnum::HTTPVersion _http_version; - string _http_version_string; + std::string _http_version_string; StatusEntry _status_entry; URLSpec _redirect; - string _proxy_realm; - string _proxy_username; + std::string _proxy_realm; + std::string _proxy_username; PT(HTTPAuthorization) _proxy_auth; - string _www_realm; - string _www_username; + std::string _www_realm; + std::string _www_username; PT(HTTPAuthorization) _www_auth; // What type of response do we get to our HTTP request? @@ -388,7 +388,7 @@ private: ResponseType _response_type; // Not a phash_map, to maintain sorted order. - typedef pmap Headers; + typedef pmap Headers; Headers _headers; size_t _expected_file_size; @@ -410,17 +410,17 @@ private: double _started_connecting_time; double _sent_request_time; bool _started_download; - string _proxy_header; - string _proxy_request_text; - string _request_text; - string _working_get; + std::string _proxy_header; + std::string _proxy_request_text; + std::string _request_text; + std::string _working_get; size_t _sent_so_far; - string _current_field_name; - string _current_field_value; + std::string _current_field_name; + std::string _current_field_value; ISocketStream *_body_stream; bool _owns_body_stream; BIO *_sbio; - string _cipher_list; + std::string _cipher_list; pvector _redirect_trail; int _last_status_code; double _last_run_time; @@ -450,7 +450,7 @@ private: friend class HTTPClient; }; -ostream &operator << (ostream &out, HTTPChannel::State state); +std::ostream &operator << (std::ostream &out, HTTPChannel::State state); #include "httpChannel.I" diff --git a/panda/src/downloader/httpClient.I b/panda/src/downloader/httpClient.I index 15047431c2..33b9432f3d 100644 --- a/panda/src/downloader/httpClient.I +++ b/panda/src/downloader/httpClient.I @@ -40,7 +40,7 @@ get_try_all_direct() const { INLINE void HTTPClient:: set_client_certificate_filename(const Filename &filename) { _client_certificate_filename = filename; - _client_certificate_pem = string(); + _client_certificate_pem = std::string(); unload_client_certificate(); } @@ -51,7 +51,7 @@ set_client_certificate_filename(const Filename &filename) { * client certificate. */ INLINE void HTTPClient:: -set_client_certificate_pem(const string &pem) { +set_client_certificate_pem(const std::string &pem) { _client_certificate_pem = pem; _client_certificate_filename = Filename(); unload_client_certificate(); @@ -62,7 +62,7 @@ set_client_certificate_pem(const string &pem) { * named by set_client_certificate_filename() or set_client_certificate_pem(). */ INLINE void HTTPClient:: -set_client_certificate_passphrase(const string &passphrase) { +set_client_certificate_passphrase(const std::string &passphrase) { _client_certificate_passphrase = passphrase; unload_client_certificate(); } @@ -116,7 +116,7 @@ get_verify_ssl() const { * to use the built-in OpenSSL default value. */ INLINE void HTTPClient:: -set_cipher_list(const string &cipher_list) { +set_cipher_list(const std::string &cipher_list) { _cipher_list = cipher_list; } @@ -124,7 +124,7 @@ set_cipher_list(const string &cipher_list) { * Returns the set of ciphers as set by set_cipher_list(). See * set_cipher_list(). */ -INLINE const string &HTTPClient:: +INLINE const std::string &HTTPClient:: get_cipher_list() const { return _cipher_list; } @@ -134,8 +134,8 @@ get_cipher_list() const { * as a convenient place to publish it for access by the scripting language; * C++ code should probably use HTTPAuthorization directly. */ -INLINE string HTTPClient:: -base64_encode(const string &s) { +INLINE std::string HTTPClient:: +base64_encode(const std::string &s) { return HTTPAuthorization::base64_encode(s); } @@ -144,7 +144,7 @@ base64_encode(const string &s) { * as a convenient place to publish it for access by the scripting language; * C++ code should probably use HTTPAuthorization directly. */ -INLINE string HTTPClient:: -base64_decode(const string &s) { +INLINE std::string HTTPClient:: +base64_decode(const std::string &s) { return HTTPAuthorization::base64_decode(s); } diff --git a/panda/src/downloader/httpClient.h b/panda/src/downloader/httpClient.h index 1efab58460..d8f78d57b4 100644 --- a/panda/src/downloader/httpClient.h +++ b/panda/src/downloader/httpClient.h @@ -62,24 +62,24 @@ PUBLISHED: static void init_random_seed(); - void set_proxy_spec(const string &proxy_spec); - string get_proxy_spec() const; + void set_proxy_spec(const std::string &proxy_spec); + std::string get_proxy_spec() const; - void set_direct_host_spec(const string &direct_host_spec); - string get_direct_host_spec() const; + void set_direct_host_spec(const std::string &direct_host_spec); + std::string get_direct_host_spec() const; INLINE void set_try_all_direct(bool try_all_direct); INLINE bool get_try_all_direct() const; void clear_proxy(); - void add_proxy(const string &scheme, const URLSpec &proxy); + void add_proxy(const std::string &scheme, const URLSpec &proxy); void clear_direct_host(); - void add_direct_host(const string &hostname); + void add_direct_host(const std::string &hostname); - string get_proxies_for_url(const URLSpec &url) const; + std::string get_proxies_for_url(const URLSpec &url) const; - void set_username(const string &server, const string &realm, const string &username); - string get_username(const string &server, const string &realm) const; + void set_username(const std::string &server, const std::string &realm, const std::string &username); + std::string get_username(const std::string &server, const std::string &realm) const; void set_cookie(const HTTPCookie &cookie); bool clear_cookie(const HTTPCookie &cookie); @@ -88,24 +88,24 @@ PUBLISHED: HTTPCookie get_cookie(const HTTPCookie &cookie) const; void copy_cookies_from(const HTTPClient &other); - void write_cookies(ostream &out) const; - void send_cookies(ostream &out, const URLSpec &url); + void write_cookies(std::ostream &out) const; + void send_cookies(std::ostream &out, const URLSpec &url); INLINE void set_client_certificate_filename(const Filename &filename); - INLINE void set_client_certificate_pem(const string &pem); - INLINE void set_client_certificate_passphrase(const string &passphrase); + INLINE void set_client_certificate_pem(const std::string &pem); + INLINE void set_client_certificate_passphrase(const std::string &passphrase); bool load_client_certificate(); bool add_preapproved_server_certificate_filename(const URLSpec &url, const Filename &filename); - bool add_preapproved_server_certificate_pem(const URLSpec &url, const string &pem); - bool add_preapproved_server_certificate_name(const URLSpec &url, const string &name); + bool add_preapproved_server_certificate_pem(const URLSpec &url, const std::string &pem); + bool add_preapproved_server_certificate_name(const URLSpec &url, const std::string &name); void clear_preapproved_server_certificates(const URLSpec &url); void clear_all_preapproved_server_certificates(); INLINE void set_http_version(HTTPEnum::HTTPVersion version); INLINE HTTPEnum::HTTPVersion get_http_version() const; - string get_http_version_string() const; - static HTTPEnum::HTTPVersion parse_http_version_string(const string &version); + std::string get_http_version_string() const; + static HTTPEnum::HTTPVersion parse_http_version_string(const std::string &version); bool load_certificates(const Filename &filename); @@ -118,16 +118,16 @@ PUBLISHED: INLINE void set_verify_ssl(VerifySSL verify_ssl); INLINE VerifySSL get_verify_ssl() const; - INLINE void set_cipher_list(const string &cipher_list); - INLINE const string &get_cipher_list() const; + INLINE void set_cipher_list(const std::string &cipher_list); + INLINE const std::string &get_cipher_list() const; PT(HTTPChannel) make_channel(bool persistent_connection); - BLOCKING PT(HTTPChannel) post_form(const URLSpec &url, const string &body); + BLOCKING PT(HTTPChannel) post_form(const URLSpec &url, const std::string &body); BLOCKING PT(HTTPChannel) get_document(const URLSpec &url); BLOCKING PT(HTTPChannel) get_header(const URLSpec &url); - INLINE static string base64_encode(const string &s); - INLINE static string base64_decode(const string &s); + INLINE static std::string base64_encode(const std::string &s); + INLINE static std::string base64_decode(const std::string &s); static HTTPClient *get_global_ptr(); @@ -140,27 +140,27 @@ private: void check_preapproved_server_certificate(const URLSpec &url, X509 *cert, bool &cert_preapproved, bool &cert_name_preapproved) const; - bool get_proxies_for_scheme(const string &scheme, + bool get_proxies_for_scheme(const std::string &scheme, pvector &proxies) const; - void add_http_username(const string &http_username); - string select_username(const URLSpec &url, bool is_proxy, - const string &realm) const; + void add_http_username(const std::string &http_username); + std::string select_username(const URLSpec &url, bool is_proxy, + const std::string &realm) const; HTTPAuthorization *select_auth(const URLSpec &url, bool is_proxy, - const string &last_realm); + const std::string &last_realm); PT(HTTPAuthorization) generate_auth(const URLSpec &url, bool is_proxy, - const string &challenge); + const std::string &challenge); void unload_client_certificate(); - static X509_NAME *parse_x509_name(const string &source); + static X509_NAME *parse_x509_name(const std::string &source); static bool x509_name_subset(X509_NAME *name_a, X509_NAME *name_b); - static void split_whitespace(string &a, string &b, const string &c); + static void split_whitespace(std::string &a, std::string &b, const std::string &c); typedef pvector Proxies; - typedef pmap ProxiesByScheme; + typedef pmap ProxiesByScheme; ProxiesByScheme _proxies_by_scheme; typedef pvector DirectHosts; DirectHosts _direct_hosts; @@ -168,17 +168,17 @@ private: HTTPEnum::HTTPVersion _http_version; VerifySSL _verify_ssl; - string _cipher_list; + std::string _cipher_list; - typedef pmap Usernames; + typedef pmap Usernames; Usernames _usernames; - typedef pmap Realms; + typedef pmap Realms; class Domain { public: Realms _realms; }; - typedef pmap Domains; + typedef pmap Domains; Domains _proxy_domains, _www_domains; // Not a phash_set, since we want this to be maintained in order. @@ -186,8 +186,8 @@ private: Cookies _cookies; Filename _client_certificate_filename; - string _client_certificate_pem; - string _client_certificate_passphrase; + std::string _client_certificate_pem; + std::string _client_certificate_passphrase; SSL_CTX *_ssl_ctx; bool _client_certificate_loaded; @@ -204,7 +204,7 @@ private: ServerCertNames _cert_names; }; - typedef pmap PreapprovedServerCerts; + typedef pmap PreapprovedServerCerts; PreapprovedServerCerts _preapproved_server_certs; static PT(HTTPClient) _global_ptr; diff --git a/panda/src/downloader/httpCookie.I b/panda/src/downloader/httpCookie.I index 163e34652d..6116f6722c 100644 --- a/panda/src/downloader/httpCookie.I +++ b/panda/src/downloader/httpCookie.I @@ -26,7 +26,7 @@ HTTPCookie() : * the string with this constructor. */ INLINE HTTPCookie:: -HTTPCookie(const string &format, const URLSpec &url) { +HTTPCookie(const std::string &format, const URLSpec &url) { parse_set_cookie(format, url); } @@ -36,7 +36,7 @@ HTTPCookie(const string &format, const URLSpec &url) { * the HTTPClient. */ INLINE HTTPCookie:: -HTTPCookie(const string &name, const string &path, const string &domain) : +HTTPCookie(const std::string &name, const std::string &path, const std::string &domain) : _name(name), _path(path), _domain(domain), @@ -55,7 +55,7 @@ INLINE HTTPCookie:: * */ INLINE void HTTPCookie:: -set_name(const string &name) { +set_name(const std::string &name) { _name = name; } @@ -63,7 +63,7 @@ set_name(const string &name) { * Returns the name of the cookie. This is the key value specified by the * server. */ -INLINE const string &HTTPCookie:: +INLINE const std::string &HTTPCookie:: get_name() const { return _name; } @@ -72,7 +72,7 @@ get_name() const { * */ INLINE void HTTPCookie:: -set_value(const string &value) { +set_value(const std::string &value) { _value = value; } @@ -80,7 +80,7 @@ set_value(const string &value) { * Returns the value of the cookie. This is the arbitrary string associated * with the cookie's name, as specified by the server. */ -INLINE const string &HTTPCookie:: +INLINE const std::string &HTTPCookie:: get_value() const { return _value; } @@ -89,14 +89,14 @@ get_value() const { * */ INLINE void HTTPCookie:: -set_domain(const string &domain) { +set_domain(const std::string &domain) { _domain = domain; } /** * */ -INLINE const string &HTTPCookie:: +INLINE const std::string &HTTPCookie:: get_domain() const { return _domain; } @@ -105,7 +105,7 @@ get_domain() const { * */ INLINE void HTTPCookie:: -set_path(const string &path) { +set_path(const std::string &path) { _path = path; } @@ -113,7 +113,7 @@ set_path(const string &path) { * Returns the prefix of the URL paths on the server for which this cookie * will be sent. */ -INLINE const string &HTTPCookie:: +INLINE const std::string &HTTPCookie:: get_path() const { return _path; } @@ -177,7 +177,7 @@ is_expired(const HTTPDate &now) const { return _expires.is_valid() && _expires < now; } -INLINE ostream &operator << (ostream &out, const HTTPCookie &cookie) { +INLINE std::ostream &operator << (std::ostream &out, const HTTPCookie &cookie) { cookie.output(out); return out; } diff --git a/panda/src/downloader/httpCookie.h b/panda/src/downloader/httpCookie.h index af460ec3c2..5a8e49eda8 100644 --- a/panda/src/downloader/httpCookie.h +++ b/panda/src/downloader/httpCookie.h @@ -32,22 +32,22 @@ class EXPCL_PANDAEXPRESS HTTPCookie { PUBLISHED: INLINE HTTPCookie(); - INLINE explicit HTTPCookie(const string &format, const URLSpec &url); - INLINE explicit HTTPCookie(const string &name, const string &path, - const string &domain); + INLINE explicit HTTPCookie(const std::string &format, const URLSpec &url); + INLINE explicit HTTPCookie(const std::string &name, const std::string &path, + const std::string &domain); INLINE ~HTTPCookie(); - INLINE void set_name(const string &name); - INLINE const string &get_name() const; + INLINE void set_name(const std::string &name); + INLINE const std::string &get_name() const; - INLINE void set_value(const string &value); - INLINE const string &get_value() const; + INLINE void set_value(const std::string &value); + INLINE const std::string &get_value() const; - INLINE void set_domain(const string &domain); - INLINE const string &get_domain() const; + INLINE void set_domain(const std::string &domain); + INLINE const std::string &get_domain() const; - INLINE void set_path(const string &path); - INLINE const string &get_path() const; + INLINE void set_path(const std::string &path); + INLINE const std::string &get_path() const; INLINE void set_expires(const HTTPDate &expires); INLINE void clear_expires(); @@ -60,24 +60,24 @@ PUBLISHED: bool operator < (const HTTPCookie &other) const; void update_from(const HTTPCookie &other); - bool parse_set_cookie(const string &format, const URLSpec &url); + bool parse_set_cookie(const std::string &format, const URLSpec &url); INLINE bool is_expired(const HTTPDate &now = HTTPDate::now()) const; bool matches_url(const URLSpec &url) const; - void output(ostream &out) const; + void output(std::ostream &out) const; private: - bool parse_cookie_param(const string ¶m, bool first_param); + bool parse_cookie_param(const std::string ¶m, bool first_param); - string _name; - string _value; - string _path; - string _domain; + std::string _name; + std::string _value; + std::string _path; + std::string _domain; HTTPDate _expires; bool _secure; }; -INLINE ostream &operator << (ostream &out, const HTTPCookie &cookie); +INLINE std::ostream &operator << (std::ostream &out, const HTTPCookie &cookie); #include "httpCookie.I" diff --git a/panda/src/downloader/httpDate.I b/panda/src/downloader/httpDate.I index 67aefbccb3..defbb73c4c 100644 --- a/panda/src/downloader/httpDate.I +++ b/panda/src/downloader/httpDate.I @@ -147,16 +147,16 @@ operator - (const HTTPDate &other) const { } -INLINE istream & -operator >> (istream &in, HTTPDate &date) { +INLINE std::istream & +operator >> (std::istream &in, HTTPDate &date) { if (!date.input(in)) { - in.clear(ios::failbit | in.rdstate()); + in.clear(std::ios::failbit | in.rdstate()); } return in; } -INLINE ostream & -operator << (ostream &out, const HTTPDate &date) { +INLINE std::ostream & +operator << (std::ostream &out, const HTTPDate &date) { date.output(out); return out; } diff --git a/panda/src/downloader/httpDate.h b/panda/src/downloader/httpDate.h index 9d6011336a..15950a854b 100644 --- a/panda/src/downloader/httpDate.h +++ b/panda/src/downloader/httpDate.h @@ -28,14 +28,14 @@ class EXPCL_PANDAEXPRESS HTTPDate { PUBLISHED: INLINE HTTPDate(); INLINE HTTPDate(time_t time); - HTTPDate(const string &format); + HTTPDate(const std::string &format); INLINE HTTPDate(const HTTPDate ©); INLINE void operator = (const HTTPDate ©); INLINE static HTTPDate now(); INLINE bool is_valid() const; - string get_string() const; + std::string get_string() const; INLINE time_t get_time() const; INLINE bool operator == (const HTTPDate &other) const; @@ -51,17 +51,17 @@ PUBLISHED: INLINE HTTPDate operator - (int seconds) const; INLINE int operator - (const HTTPDate &other) const; - bool input(istream &in); - void output(ostream &out) const; + bool input(std::istream &in); + void output(std::ostream &out) const; private: - static string get_token(const string &str, size_t &pos); + static std::string get_token(const std::string &str, size_t &pos); time_t _time; }; -INLINE istream &operator >> (istream &in, HTTPDate &date); -INLINE ostream &operator << (ostream &out, const HTTPDate &date); +INLINE std::istream &operator >> (std::istream &in, HTTPDate &date); +INLINE std::ostream &operator << (std::ostream &out, const HTTPDate &date); #include "httpDate.I" diff --git a/panda/src/downloader/httpDigestAuthorization.h b/panda/src/downloader/httpDigestAuthorization.h index a3b8c7147a..ecd2ab3024 100644 --- a/panda/src/downloader/httpDigestAuthorization.h +++ b/panda/src/downloader/httpDigestAuthorization.h @@ -35,11 +35,11 @@ public: bool is_proxy); virtual ~HTTPDigestAuthorization(); - virtual const string &get_mechanism() const; + virtual const std::string &get_mechanism() const; virtual bool is_valid(); - virtual string generate(HTTPEnum::Method method, const string &request_path, - const string &username, const string &body); + virtual std::string generate(HTTPEnum::Method method, const std::string &request_path, + const std::string &username, const std::string &body); public: enum Algorithm { @@ -55,37 +55,37 @@ public: }; private: - static int match_qop_token(const string &token); + static int match_qop_token(const std::string &token); - string calc_request_digest(const string &username, const string &password, + std::string calc_request_digest(const std::string &username, const std::string &password, HTTPEnum::Method method, - const string &request_path, const string &body); - string calc_h(const string &data) const; - string calc_kd(const string &secret, const string &data) const; - string get_a1(const string &username, const string &password); - string get_a2(HTTPEnum::Method method, const string &request_path, - const string &body); - string get_hex_nonce_count() const; + const std::string &request_path, const std::string &body); + std::string calc_h(const std::string &data) const; + std::string calc_kd(const std::string &secret, const std::string &data) const; + std::string get_a1(const std::string &username, const std::string &password); + std::string get_a2(HTTPEnum::Method method, const std::string &request_path, + const std::string &body); + std::string get_hex_nonce_count() const; - static string calc_md5(const string &source); + static std::string calc_md5(const std::string &source); INLINE static char hexdigit(int value); - string _cnonce; - string _nonce; + std::string _cnonce; + std::string _nonce; int _nonce_count; - string _opaque; + std::string _opaque; Algorithm _algorithm; - string _a1; + std::string _a1; int _qop; Qop _chosen_qop; - static const string _mechanism; + static const std::string _mechanism; }; -ostream &operator << (ostream &out, HTTPDigestAuthorization::Algorithm algorithm); -ostream &operator << (ostream &out, HTTPDigestAuthorization::Qop qop); +std::ostream &operator << (std::ostream &out, HTTPDigestAuthorization::Algorithm algorithm); +std::ostream &operator << (std::ostream &out, HTTPDigestAuthorization::Qop qop); #include "httpDigestAuthorization.I" diff --git a/panda/src/downloader/httpEntityTag.I b/panda/src/downloader/httpEntityTag.I index d713302da2..3cdee7d4f3 100644 --- a/panda/src/downloader/httpEntityTag.I +++ b/panda/src/downloader/httpEntityTag.I @@ -24,7 +24,7 @@ HTTPEntityTag() { * tag string. */ INLINE HTTPEntityTag:: -HTTPEntityTag(bool weak, const string &tag) : +HTTPEntityTag(bool weak, const std::string &tag) : _weak(weak), _tag(tag) { @@ -63,7 +63,7 @@ is_weak() const { /** * Returns the tag as a literal string. */ -INLINE const string &HTTPEntityTag:: +INLINE const std::string &HTTPEntityTag:: get_tag() const { return _tag; } @@ -131,13 +131,13 @@ compare_to(const HTTPEntityTag &other) const { * */ INLINE void HTTPEntityTag:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_string(); } -INLINE ostream & -operator << (ostream &out, const HTTPEntityTag &entityTag) { +INLINE std::ostream & +operator << (std::ostream &out, const HTTPEntityTag &entityTag) { entityTag.output(out); return out; } diff --git a/panda/src/downloader/httpEntityTag.h b/panda/src/downloader/httpEntityTag.h index 280ce9d0c9..bf1a144946 100644 --- a/panda/src/downloader/httpEntityTag.h +++ b/panda/src/downloader/httpEntityTag.h @@ -24,14 +24,14 @@ class EXPCL_PANDAEXPRESS HTTPEntityTag { PUBLISHED: INLINE HTTPEntityTag(); - HTTPEntityTag(const string &text); - INLINE HTTPEntityTag(bool weak, const string &tag); + HTTPEntityTag(const std::string &text); + INLINE HTTPEntityTag(bool weak, const std::string &tag); INLINE HTTPEntityTag(const HTTPEntityTag ©); INLINE void operator = (const HTTPEntityTag ©); INLINE bool is_weak() const; - INLINE const string &get_tag() const; - string get_string() const; + INLINE const std::string &get_tag() const; + std::string get_string() const; INLINE bool strong_equiv(const HTTPEntityTag &other) const; INLINE bool weak_equiv(const HTTPEntityTag &other) const; @@ -41,14 +41,14 @@ PUBLISHED: INLINE bool operator < (const HTTPEntityTag &other) const; INLINE int compare_to(const HTTPEntityTag &other) const; - INLINE void output(ostream &out) const; + INLINE void output(std::ostream &out) const; private: bool _weak; - string _tag; + std::string _tag; }; -INLINE ostream &operator << (ostream &out, const HTTPEntityTag &url); +INLINE std::ostream &operator << (std::ostream &out, const HTTPEntityTag &url); #include "httpEntityTag.I" diff --git a/panda/src/downloader/httpEnum.h b/panda/src/downloader/httpEnum.h index 587c5b8b28..81ec9f0243 100644 --- a/panda/src/downloader/httpEnum.h +++ b/panda/src/downloader/httpEnum.h @@ -47,7 +47,7 @@ PUBLISHED: }; }; -ostream &operator << (ostream &out, HTTPEnum::Method method); +std::ostream &operator << (std::ostream &out, HTTPEnum::Method method); #endif // HAVE_OPENSSL diff --git a/panda/src/downloader/identityStreamBuf.h b/panda/src/downloader/identityStreamBuf.h index f9d00a6626..548e946999 100644 --- a/panda/src/downloader/identityStreamBuf.h +++ b/panda/src/downloader/identityStreamBuf.h @@ -28,7 +28,7 @@ class HTTPChannel; /** * The streambuf object that implements IIdentityStream. */ -class EXPCL_PANDAEXPRESS IdentityStreamBuf : public streambuf { +class EXPCL_PANDAEXPRESS IdentityStreamBuf : public std::streambuf { public: IdentityStreamBuf(); virtual ~IdentityStreamBuf(); diff --git a/panda/src/downloader/multiplexStream.I b/panda/src/downloader/multiplexStream.I index 2a99a110d3..aff3d4a064 100644 --- a/panda/src/downloader/multiplexStream.I +++ b/panda/src/downloader/multiplexStream.I @@ -15,8 +15,8 @@ * */ INLINE MultiplexStream:: -MultiplexStream() : ostream(&_msb) { - setf(ios::unitbuf); +MultiplexStream() : std::ostream(&_msb) { + setf(std::ios::unitbuf); } /** @@ -24,7 +24,7 @@ MultiplexStream() : ostream(&_msb) { * will receive whatever data is sent to the pipe. */ INLINE void MultiplexStream:: -add_ostream(ostream *out, bool delete_later) { +add_ostream(std::ostream *out, bool delete_later) { _msb.add_output(MultiplexStreamBuf::BT_none, MultiplexStreamBuf::OT_ostream, out, nullptr, delete_later); @@ -49,7 +49,7 @@ INLINE void MultiplexStream:: add_standard_output() { _msb.add_output(MultiplexStreamBuf::BT_none, MultiplexStreamBuf::OT_ostream, - &cout, nullptr, false); + &std::cout, nullptr, false); } /** @@ -64,7 +64,7 @@ add_file(Filename file) { delete out; return false; } - out->setf(ios::unitbuf); + out->setf(std::ios::unitbuf); _msb.add_output(MultiplexStreamBuf::BT_line, MultiplexStreamBuf::OT_ostream, diff --git a/panda/src/downloader/multiplexStream.h b/panda/src/downloader/multiplexStream.h index cf421860cf..d47c2cf118 100644 --- a/panda/src/downloader/multiplexStream.h +++ b/panda/src/downloader/multiplexStream.h @@ -28,7 +28,7 @@ * a disk file or to system logging utilities. It's a very handy thing to set * Notify to refer to when running in batch mode. */ -class EXPCL_PANDAEXPRESS MultiplexStream : public ostream { +class EXPCL_PANDAEXPRESS MultiplexStream : public std::ostream { PUBLISHED: INLINE MultiplexStream(); @@ -36,7 +36,7 @@ PUBLISHED: INLINE MultiplexStream(const MultiplexStream ©) = delete; #endif - INLINE void add_ostream(ostream *out, bool delete_later = false); + INLINE void add_ostream(std::ostream *out, bool delete_later = false); INLINE bool add_stdio_file(FILE *file, bool close_when_done); INLINE void add_standard_output(); INLINE bool add_file(Filename file); diff --git a/panda/src/downloader/multiplexStreamBuf.h b/panda/src/downloader/multiplexStreamBuf.h index 0e440f6ab1..24ec97cfb6 100644 --- a/panda/src/downloader/multiplexStreamBuf.h +++ b/panda/src/downloader/multiplexStreamBuf.h @@ -24,7 +24,7 @@ * Used by MultiplexStream to implement an ostream that sends what is written * to it to any number of additional sources, like other ostreams. */ -class EXPCL_PANDAEXPRESS MultiplexStreamBuf : public streambuf { +class EXPCL_PANDAEXPRESS MultiplexStreamBuf : public std::streambuf { public: MultiplexStreamBuf(); virtual ~MultiplexStreamBuf(); @@ -41,7 +41,7 @@ public: }; void add_output(BufferType buffer_type, OutputType output_type, - ostream *out = nullptr, + std::ostream *out = nullptr, FILE *fout = nullptr, bool owns_obj = false); @@ -58,11 +58,11 @@ private: class Output { public: void close(); - void write_string(const string &str); + void write_string(const std::string &str); BufferType _buffer_type; OutputType _output_type; - ostream *_out; + std::ostream *_out; FILE *_fout; bool _owns_obj; }; @@ -71,7 +71,7 @@ private: Outputs _outputs; MutexImpl _lock; - string _line_buffer; + std::string _line_buffer; }; #include "multiplexStreamBuf.I" diff --git a/panda/src/downloader/socketStream.I b/panda/src/downloader/socketStream.I index 8ac4914567..800ed89499 100644 --- a/panda/src/downloader/socketStream.I +++ b/panda/src/downloader/socketStream.I @@ -161,7 +161,7 @@ flush() { * */ INLINE ISocketStream:: -ISocketStream(streambuf *buf) : istream(buf), SSReader(this) { +ISocketStream(std::streambuf *buf) : std::istream(buf), SSReader(this) { _channel = nullptr; } @@ -169,7 +169,7 @@ ISocketStream(streambuf *buf) : istream(buf), SSReader(this) { * */ INLINE OSocketStream:: -OSocketStream(streambuf *buf) : ostream(buf), SSWriter(this) { +OSocketStream(std::streambuf *buf) : std::ostream(buf), SSWriter(this) { } /** @@ -185,7 +185,7 @@ flush() { * */ INLINE SocketStream:: -SocketStream(streambuf *buf) : iostream(buf), SSReader(this), SSWriter(this) { +SocketStream(std::streambuf *buf) : std::iostream(buf), SSReader(this), SSWriter(this) { } /** diff --git a/panda/src/downloader/socketStream.h b/panda/src/downloader/socketStream.h index 84ce907a5e..b98e76927f 100644 --- a/panda/src/downloader/socketStream.h +++ b/panda/src/downloader/socketStream.h @@ -38,7 +38,7 @@ class HTTPChannel; */ class EXPCL_PANDAEXPRESS SSReader { public: - SSReader(istream *stream); + SSReader(std::istream *stream); virtual ~SSReader(); PUBLISHED: @@ -53,7 +53,7 @@ PUBLISHED: private: bool do_receive_datagram(Datagram &dg); - istream *_istream; + std::istream *_istream; size_t _data_expected; vector_uchar _data_so_far; int _tcp_header_size; @@ -88,7 +88,7 @@ private: */ class EXPCL_PANDAEXPRESS SSWriter { public: - SSWriter(ostream *stream); + SSWriter(std::ostream *stream); virtual ~SSWriter(); PUBLISHED: @@ -109,7 +109,7 @@ PUBLISHED: INLINE bool flush(); private: - ostream *_ostream; + std::ostream *_ostream; bool _collect_tcp; double _collect_tcp_interval; double _queued_data_start; @@ -122,9 +122,9 @@ private: * after an eof condition to check whether the socket has been closed, or * whether more data may be available later. */ -class EXPCL_PANDAEXPRESS ISocketStream : public istream, public SSReader { +class EXPCL_PANDAEXPRESS ISocketStream : public std::istream, public SSReader { public: - INLINE ISocketStream(streambuf *buf); + INLINE ISocketStream(std::streambuf *buf); virtual ~ISocketStream(); #if _MSC_VER >= 1800 @@ -156,9 +156,9 @@ private: * check whether the socket has been closed, or whether more data may be sent * later. */ -class EXPCL_PANDAEXPRESS OSocketStream : public ostream, public SSWriter { +class EXPCL_PANDAEXPRESS OSocketStream : public std::ostream, public SSWriter { public: - INLINE OSocketStream(streambuf *buf); + INLINE OSocketStream(std::streambuf *buf); #if _MSC_VER >= 1800 INLINE OSocketStream(const OSocketStream ©) = delete; @@ -175,9 +175,9 @@ PUBLISHED: * A base class for iostreams that read and write to a (possibly non-blocking) * socket. */ -class EXPCL_PANDAEXPRESS SocketStream : public iostream, public SSReader, public SSWriter { +class EXPCL_PANDAEXPRESS SocketStream : public std::iostream, public SSReader, public SSWriter { public: - INLINE SocketStream(streambuf *buf); + INLINE SocketStream(std::streambuf *buf); #if _MSC_VER >= 1800 INLINE SocketStream(const SocketStream ©) = delete; diff --git a/panda/src/downloader/stringStream.I b/panda/src/downloader/stringStream.I index 6e1b173c40..7d1e59fc8f 100644 --- a/panda/src/downloader/stringStream.I +++ b/panda/src/downloader/stringStream.I @@ -15,7 +15,7 @@ * */ INLINE StringStream:: -StringStream() : iostream(&_buf) { +StringStream() : std::iostream(&_buf) { } /** @@ -23,7 +23,7 @@ StringStream() : iostream(&_buf) { * data. */ INLINE StringStream:: -StringStream(const string &source) : iostream(&_buf) { +StringStream(const std::string &source) : std::iostream(&_buf) { set_data(source); } @@ -47,21 +47,21 @@ get_data_size() { /** * Returns the contents of the data stream as a string. */ -INLINE string StringStream:: +INLINE std::string StringStream:: get_data() { flush(); const vector_uchar &data = _buf.get_data(); if (!data.empty()) { - return string((char *)&data[0], data.size()); + return std::string((char *)&data[0], data.size()); } - return string(); + return std::string(); } /** * Replaces the contents of the data stream. This implicitly reseeks to 0. */ INLINE void StringStream:: -set_data(const string &data) { +set_data(const std::string &data) { _buf.clear(); if (!data.empty()) { set_data((const unsigned char *)data.data(), data.size()); diff --git a/panda/src/downloader/stringStream.h b/panda/src/downloader/stringStream.h index 2075f817fd..b5b835ed17 100644 --- a/panda/src/downloader/stringStream.h +++ b/panda/src/downloader/stringStream.h @@ -24,9 +24,9 @@ * buffer, which can be retrieved and/or set as a string in Python 2 or a * bytes object in Python 3. */ -class EXPCL_PANDAEXPRESS StringStream : public iostream { +class EXPCL_PANDAEXPRESS StringStream : public std::iostream { public: - INLINE StringStream(const string &source); + INLINE StringStream(const std::string &source); PUBLISHED: EXTENSION(StringStream(PyObject *source)); @@ -46,8 +46,8 @@ PUBLISHED: public: #ifndef CPPPARSER - INLINE string get_data(); - INLINE void set_data(const string &data); + INLINE std::string get_data(); + INLINE void set_data(const std::string &data); void set_data(const unsigned char *data, size_t size); #endif diff --git a/panda/src/downloader/stringStreamBuf.h b/panda/src/downloader/stringStreamBuf.h index 9ddff66ae7..64df6ba99b 100644 --- a/panda/src/downloader/stringStreamBuf.h +++ b/panda/src/downloader/stringStreamBuf.h @@ -22,7 +22,7 @@ * to a memory buffer, whose contents can be appended to or extracted at any * time by application code. */ -class EXPCL_PANDAEXPRESS StringStreamBuf : public streambuf { +class EXPCL_PANDAEXPRESS StringStreamBuf : public std::streambuf { public: StringStreamBuf(); virtual ~StringStreamBuf(); @@ -36,8 +36,8 @@ public: void write_chars(const char *start, size_t length); protected: - virtual streampos seekoff(streamoff off, ios_seekdir dir, ios_openmode which); - virtual streampos seekpos(streampos pos, ios_openmode which); + virtual std::streampos seekoff(std::streamoff off, ios_seekdir dir, ios_openmode which); + virtual std::streampos seekpos(std::streampos pos, ios_openmode which); virtual int overflow(int c); virtual int sync(); diff --git a/panda/src/downloader/urlSpec.I b/panda/src/downloader/urlSpec.I index 7af6f4339b..083b2ca9f5 100644 --- a/panda/src/downloader/urlSpec.I +++ b/panda/src/downloader/urlSpec.I @@ -15,7 +15,7 @@ * */ INLINE URLSpec:: -URLSpec(const string &url, bool server_name_expected) { +URLSpec(const std::string &url, bool server_name_expected) { set_url(url, server_name_expected); } @@ -23,7 +23,7 @@ URLSpec(const string &url, bool server_name_expected) { * */ INLINE void URLSpec:: -operator = (const string &url) { +operator = (const std::string &url) { set_url(url); } @@ -115,7 +115,7 @@ has_query() const { * Returns the authority specified by the URL (this includes username, server, * and/or port), or empty string if no authority is specified. */ -INLINE string URLSpec:: +INLINE std::string URLSpec:: get_authority() const { return _url.substr(_username_start, _port_end - _username_start); } @@ -125,7 +125,7 @@ get_authority() const { * a password, e.g. "username:password", although putting a password on the * URL is probably a bad idea. */ -INLINE string URLSpec:: +INLINE std::string URLSpec:: get_username() const { return _url.substr(_username_start, _username_end - _username_start); } @@ -134,7 +134,7 @@ get_username() const { * Returns the server name specified by the URL, if any. In case of an IPv6 * address, does not include the enclosing brackets. */ -INLINE string URLSpec:: +INLINE std::string URLSpec:: get_server() const { return _url.substr(_server_start, _server_end - _server_start); } @@ -144,7 +144,7 @@ get_server() const { * no port is specified. Compare this with get_port(), which returns a * default port number if no port is specified. */ -INLINE string URLSpec:: +INLINE std::string URLSpec:: get_port_str() const { return _url.substr(_port_start, _port_end - _port_start); } @@ -153,7 +153,7 @@ get_port_str() const { * Returns the query specified by the URL, or empty string if no query is * specified. */ -INLINE string URLSpec:: +INLINE std::string URLSpec:: get_query() const { return _url.substr(_query_start); } @@ -180,7 +180,7 @@ is_ssl() const { /** * Returns the complete URL specification. */ -INLINE const string &URLSpec:: +INLINE const std::string &URLSpec:: get_url() const { return _url; } @@ -189,7 +189,7 @@ get_url() const { * */ INLINE URLSpec:: -operator const string & () const { +operator const std::string & () const { return _url; } @@ -244,16 +244,16 @@ operator [] (size_t n) const { return _url[n]; } -INLINE istream & -operator >> (istream &in, URLSpec &url) { +INLINE std::istream & +operator >> (std::istream &in, URLSpec &url) { if (!url.input(in)) { - in.clear(ios::failbit | in.rdstate()); + in.clear(std::ios::failbit | in.rdstate()); } return in; } -INLINE ostream & -operator << (ostream &out, const URLSpec &url) { +INLINE std::ostream & +operator << (std::ostream &out, const URLSpec &url) { url.output(out); return out; } diff --git a/panda/src/downloader/urlSpec.h b/panda/src/downloader/urlSpec.h index 592fe22087..7477f4d6cd 100644 --- a/panda/src/downloader/urlSpec.h +++ b/panda/src/downloader/urlSpec.h @@ -28,9 +28,9 @@ class Filename; class EXPCL_PANDAEXPRESS URLSpec { PUBLISHED: URLSpec(); - INLINE URLSpec(const string &url, bool server_name_expected = false); + INLINE URLSpec(const std::string &url, bool server_name_expected = false); URLSpec(const URLSpec &url, const Filename &path); - INLINE void operator = (const string &url); + INLINE void operator = (const std::string &url); INLINE bool operator == (const URLSpec &other) const; INLINE bool operator != (const URLSpec &other) const; @@ -46,35 +46,35 @@ PUBLISHED: INLINE bool has_path() const; INLINE bool has_query() const; - string get_scheme() const; - INLINE string get_authority() const; - INLINE string get_username() const; - INLINE string get_server() const; - INLINE string get_port_str() const; + std::string get_scheme() const; + INLINE std::string get_authority() const; + INLINE std::string get_username() const; + INLINE std::string get_server() const; + INLINE std::string get_port_str() const; uint16_t get_port() const; - string get_server_and_port() const; + std::string get_server_and_port() const; bool is_default_port() const; - static int get_default_port_for_scheme(const string &scheme); - string get_path() const; - INLINE string get_query() const; - string get_path_and_query() const; + static int get_default_port_for_scheme(const std::string &scheme); + std::string get_path() const; + INLINE std::string get_query() const; + std::string get_path_and_query() const; INLINE bool is_ssl() const; - INLINE const string &get_url() const; + INLINE const std::string &get_url() const; - void set_scheme(const string &scheme); - void set_authority(const string &authority); - void set_username(const string &username); - void set_server(const string &server); - void set_port(const string &port); + void set_scheme(const std::string &scheme); + void set_authority(const std::string &authority); + void set_username(const std::string &username); + void set_server(const std::string &server); + void set_port(const std::string &port); void set_port(uint16_t port); - void set_server_and_port(const string &server_and_port); - void set_path(const string &path); - void set_query(const string &query); + void set_server_and_port(const std::string &server_and_port); + void set_path(const std::string &path); + void set_query(const std::string &query); - void set_url(const string &url, bool server_name_expected = false); + void set_url(const std::string &url, bool server_name_expected = false); - INLINE operator const string & () const; + INLINE operator const std::string & () const; INLINE const char *c_str() const; INLINE bool empty() const; INLINE operator bool() const; @@ -82,13 +82,13 @@ PUBLISHED: INLINE size_t size() const; INLINE char operator [] (size_t n) const; - bool input(istream &in); - void output(ostream &out) const; + bool input(std::istream &in); + void output(std::ostream &out) const; - static string quote(const string &source, const string &safe = "/"); - static string quote_plus(const string &source, const string &safe = "/"); - static string unquote(const string &source); - static string unquote_plus(const string &source); + static std::string quote(const std::string &source, const std::string &safe = "/"); + static std::string quote_plus(const std::string &source, const std::string &safe = "/"); + static std::string unquote(const std::string &source); + static std::string unquote_plus(const std::string &source); MAKE_PROPERTY(scheme, get_scheme, set_scheme); MAKE_PROPERTY(authority, get_authority, set_authority); @@ -113,7 +113,7 @@ private: F_has_query = 0x0040, }; - string _url; + std::string _url; uint16_t _port; int _flags; @@ -129,8 +129,8 @@ private: size_t _query_start; }; -INLINE istream &operator >> (istream &in, URLSpec &url); -INLINE ostream &operator << (ostream &out, const URLSpec &url); +INLINE std::istream &operator >> (std::istream &in, URLSpec &url); +INLINE std::ostream &operator << (std::ostream &out, const URLSpec &url); #include "urlSpec.I" diff --git a/panda/src/downloader/virtualFileHTTP.h b/panda/src/downloader/virtualFileHTTP.h index 7b5426566c..a440bf7452 100644 --- a/panda/src/downloader/virtualFileHTTP.h +++ b/panda/src/downloader/virtualFileHTTP.h @@ -45,15 +45,15 @@ public: virtual bool is_regular_file() const; INLINE bool is_implicit_pz_file() const; - virtual istream *open_read_file(bool auto_unwrap) const; + virtual std::istream *open_read_file(bool auto_unwrap) const; virtual bool was_read_successful() const; - virtual streamsize get_file_size(istream *stream) const; - virtual streamsize get_file_size() const; + virtual std::streamsize get_file_size(std::istream *stream) const; + virtual std::streamsize get_file_size() const; virtual time_t get_timestamp() const; private: - bool fetch_file(ostream *buffer_stream) const; - istream *return_file(istream *buffer_stream, bool auto_unwrap) const; + bool fetch_file(std::ostream *buffer_stream) const; + std::istream *return_file(std::istream *buffer_stream, bool auto_unwrap) const; VirtualFileMountHTTP *_mount; Filename _local_filename; diff --git a/panda/src/downloader/virtualFileMountHTTP.h b/panda/src/downloader/virtualFileMountHTTP.h index 996905a913..4724ad5175 100644 --- a/panda/src/downloader/virtualFileMountHTTP.h +++ b/panda/src/downloader/virtualFileMountHTTP.h @@ -48,15 +48,15 @@ public: virtual bool is_directory(const Filename &file) const; virtual bool is_regular_file(const Filename &file) const; - virtual istream *open_read_file(const Filename &file) const; - virtual streamsize get_file_size(const Filename &file, istream *stream) const; - virtual streamsize get_file_size(const Filename &file) const; + virtual std::istream *open_read_file(const Filename &file) const; + virtual std::streamsize get_file_size(const Filename &file, std::istream *stream) const; + virtual std::streamsize get_file_size(const Filename &file) const; virtual time_t get_timestamp(const Filename &file) const; virtual bool scan_directory(vector_string &contents, const Filename &dir) const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; PT(HTTPChannel) get_channel(); void recycle_channel(HTTPChannel *channel); diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.I b/panda/src/dxgsg9/dxGraphicsStateGuardian9.I index 51846fd33c..7e08862b2d 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.I +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.I @@ -86,7 +86,7 @@ get_texture_wrap_mode(SamplerState::WrapMode wm) { case SamplerState::WM_border_color: return D3DTADDRESS_BORDER; } - dxgsg9_cat.error() << "Invalid Texture::Mode value" << endl; + dxgsg9_cat.error() << "Invalid Texture::Mode value" << std::endl; return D3DTADDRESS_WRAP; } @@ -103,7 +103,7 @@ get_fog_mode_type(Fog::Mode m) { case Fog::M_exponential_squared: return D3DFOG_EXP2; } - dxgsg9_cat.error() << "Invalid Fog::Mode value" << endl; + dxgsg9_cat.error() << "Invalid Fog::Mode value" << std::endl; return D3DFOG_EXP; } diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h index 5a5c3b3359..66b2fb82d5 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h @@ -166,7 +166,7 @@ public: static void atexit_function(void); static void set_cg_device(LPDIRECT3DDEVICE9 cg_device); - virtual bool get_supports_cg_profile(const string &name) const; + virtual bool get_supports_cg_profile(const std::string &name) const; protected: @@ -366,7 +366,7 @@ protected: bool _supports_stream_offset; - list _graphics_buffer_list; + std::list _graphics_buffer_list; int _supports_gamma_calibration; diff --git a/panda/src/dxgsg9/dxInput9.h b/panda/src/dxgsg9/dxInput9.h index 77f3f31a37..9614a2627d 100644 --- a/panda/src/dxgsg9/dxInput9.h +++ b/panda/src/dxgsg9/dxInput9.h @@ -16,8 +16,8 @@ #define DIRECTINPUT_VERSION 0x900 #include -typedef vector DI_DeviceInfos; -typedef vector DI_DeviceObjInfos; +typedef std::vector DI_DeviceInfos; +typedef std::vector DI_DeviceObjInfos; class DInput9Info { public: @@ -33,8 +33,8 @@ public: DI_DeviceInfos _DevInfos; // arrays for all created devices. Should probably put these together in a // struct, along with the data fmt info - vector _DeviceList; - vector _DevCaps; + std::vector _DeviceList; + std::vector _DevCaps; }; #endif diff --git a/panda/src/dxgsg9/dxShaderContext9.h b/panda/src/dxgsg9/dxShaderContext9.h index 8f0a543e50..b637cb0a81 100644 --- a/panda/src/dxgsg9/dxShaderContext9.h +++ b/panda/src/dxgsg9/dxShaderContext9.h @@ -79,7 +79,7 @@ public: int _num_bound_streams; // FOR DEBUGGING - string _name; + std::string _name; private: #ifdef HAVE_CG diff --git a/panda/src/dxgsg9/dxgsg9base.h b/panda/src/dxgsg9/dxgsg9base.h index 359b9fa2a1..b0e2b9dfef 100644 --- a/panda/src/dxgsg9/dxgsg9base.h +++ b/panda/src/dxgsg9/dxgsg9base.h @@ -56,9 +56,9 @@ #ifndef D3DERRORSTRING #ifdef NDEBUG -#define D3DERRORSTRING(HRESULT) " at (" << __FILE__ << ":" << __LINE__ << "), hr=" << DX_GET_ERROR_STRING_FUNC(HRESULT) << endl // leave out descriptions to shrink release build +#define D3DERRORSTRING(HRESULT) " at (" << __FILE__ << ":" << __LINE__ << "), hr=" << DX_GET_ERROR_STRING_FUNC(HRESULT) << std::endl // leave out descriptions to shrink release build #else -#define D3DERRORSTRING(HRESULT) " at (" << __FILE__ << ":" << __LINE__ << "), hr=" << DX_GET_ERROR_STRING_FUNC(HRESULT) << ": " << DX_GET_ERROR_DESCRIPTION_FUNC(HRESULT) << endl +#define D3DERRORSTRING(HRESULT) " at (" << __FILE__ << ":" << __LINE__ << "), hr=" << DX_GET_ERROR_STRING_FUNC(HRESULT) << ": " << DX_GET_ERROR_DESCRIPTION_FUNC(HRESULT) << std::endl #endif #endif @@ -103,7 +103,7 @@ typedef DWORD DXShaderHandle; ULONG refcnt; \ if(IS_VALID_PTR(OBJECT)) { \ refcnt = (OBJECT)->Release(); \ - MODULE##_cat.debug() << DBGSTR << " released, refcnt = " << refcnt << " at " << __FILE__ << ":" << __LINE__ << endl; \ + MODULE##_cat.debug() << DBGSTR << " released, refcnt = " << refcnt << " at " << __FILE__ << ":" << __LINE__ << std::endl; \ if((bDoDownToZero) && (refcnt>0)) { \ MODULE##_cat.warning() << DBGSTR << " released but still has a non-zero refcnt(" << refcnt << "), multi-releasing it down to zero!\n"; \ do { \ @@ -112,11 +112,11 @@ typedef DWORD DXShaderHandle; } \ (OBJECT) = nullptr; \ } else { \ - MODULE##_cat.debug() << DBGSTR << " not released, ptr == NULL" << endl; \ + MODULE##_cat.debug() << DBGSTR << " not released, ptr == NULL" << std::endl; \ }} #define PRINT_REFCNT(MODULE,p) { ULONG refcnt; (p)->AddRef(); refcnt=(p)->Release(); \ - MODULE##_cat.debug() << #p << " has refcnt = " << refcnt << " at " << __FILE__ << ":" << __LINE__ << endl; } + MODULE##_cat.debug() << #p << " has refcnt = " << refcnt << " at " << __FILE__ << ":" << __LINE__ << std::endl; } #else #define RELEASE(OBJECT,MODULE,DBGSTR,bDoDownToZero) { \ diff --git a/panda/src/dxgsg9/wdxGraphicsBuffer9.h b/panda/src/dxgsg9/wdxGraphicsBuffer9.h index d603a73bf6..747307642b 100644 --- a/panda/src/dxgsg9/wdxGraphicsBuffer9.h +++ b/panda/src/dxgsg9/wdxGraphicsBuffer9.h @@ -29,7 +29,7 @@ class EXPCL_PANDADX wdxGraphicsBuffer9 : public GraphicsBuffer { public: wdxGraphicsBuffer9(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -74,7 +74,7 @@ private: int _backing_sizey; wdxGraphicsBuffer9 *_shared_depth_buffer; - list _shared_depth_buffer_list; + std::list _shared_depth_buffer_list; wdxGraphicsBuffer9 **_this; diff --git a/panda/src/dxgsg9/wdxGraphicsPipe9.h b/panda/src/dxgsg9/wdxGraphicsPipe9.h index 9c06d1476e..2d9eea18b0 100644 --- a/panda/src/dxgsg9/wdxGraphicsPipe9.h +++ b/panda/src/dxgsg9/wdxGraphicsPipe9.h @@ -29,7 +29,7 @@ public: wdxGraphicsPipe9(); virtual ~wdxGraphicsPipe9(); - virtual string get_interface_name() const; + virtual std::string get_interface_name() const; static PT(GraphicsPipe) pipe_constructor(); virtual PT(GraphicsDevice) make_device(void *scrn); @@ -50,7 +50,7 @@ public: bool special_check_fullscreen_resolution(DXScreenData &scrn, UINT x_size,UINT y_size); protected: - virtual PT(GraphicsOutput) make_output(const string &name, + virtual PT(GraphicsOutput) make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/dxgsg9/wdxGraphicsWindow9.h b/panda/src/dxgsg9/wdxGraphicsWindow9.h index 9bbe8b5eed..391fb9d7e9 100644 --- a/panda/src/dxgsg9/wdxGraphicsWindow9.h +++ b/panda/src/dxgsg9/wdxGraphicsWindow9.h @@ -28,7 +28,7 @@ class wdxGraphicsPipe9; class EXPCL_PANDADX wdxGraphicsWindow9 : public WinGraphicsWindow { public: wdxGraphicsWindow9(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/dxml/config_dxml.h b/panda/src/dxml/config_dxml.h index ca2113f678..7129db67de 100644 --- a/panda/src/dxml/config_dxml.h +++ b/panda/src/dxml/config_dxml.h @@ -35,8 +35,8 @@ extern EXPCL_PANDA_DXML void init_libdxml(); class TiXmlDocument; class TiXmlNode; BEGIN_PUBLISH -EXPCL_PANDA_DXML TiXmlDocument *read_xml_stream(istream &in); -EXPCL_PANDA_DXML void write_xml_stream(ostream &out, TiXmlDocument *doc); +EXPCL_PANDA_DXML TiXmlDocument *read_xml_stream(std::istream &in); +EXPCL_PANDA_DXML void write_xml_stream(std::ostream &out, TiXmlDocument *doc); EXPCL_PANDA_DXML void print_xml(TiXmlNode *xnode); EXPCL_PANDA_DXML void print_xml_to_file(const Filename &filename, TiXmlNode *xnode); END_PUBLISH diff --git a/panda/src/egg/eggAnimData.I b/panda/src/egg/eggAnimData.I index aec67eb1a3..20b6c6d62c 100644 --- a/panda/src/egg/eggAnimData.I +++ b/panda/src/egg/eggAnimData.I @@ -17,7 +17,7 @@ * */ INLINE EggAnimData:: -EggAnimData(const string &name) : EggNode(name) { +EggAnimData(const std::string &name) : EggNode(name) { _has_fps = false; } diff --git a/panda/src/egg/eggAnimData.h b/panda/src/egg/eggAnimData.h index 1548f3f0b7..05bdc3669a 100644 --- a/panda/src/egg/eggAnimData.h +++ b/panda/src/egg/eggAnimData.h @@ -29,7 +29,7 @@ */ class EXPCL_PANDAEGG EggAnimData : public EggNode { PUBLISHED: - INLINE explicit EggAnimData(const string &name = ""); + INLINE explicit EggAnimData(const std::string &name = ""); INLINE EggAnimData(const EggAnimData ©); INLINE EggAnimData &operator = (const EggAnimData ©); diff --git a/panda/src/egg/eggAnimPreload.I b/panda/src/egg/eggAnimPreload.I index 7cfb879347..a13a42ba3d 100644 --- a/panda/src/egg/eggAnimPreload.I +++ b/panda/src/egg/eggAnimPreload.I @@ -15,7 +15,7 @@ * */ INLINE EggAnimPreload:: -EggAnimPreload(const string &name) : EggNode(name) { +EggAnimPreload(const std::string &name) : EggNode(name) { _has_fps = false; _has_num_frames = false; } diff --git a/panda/src/egg/eggAnimPreload.h b/panda/src/egg/eggAnimPreload.h index 9dc2352e5f..577901cac5 100644 --- a/panda/src/egg/eggAnimPreload.h +++ b/panda/src/egg/eggAnimPreload.h @@ -23,7 +23,7 @@ */ class EXPCL_PANDAEGG EggAnimPreload : public EggNode { PUBLISHED: - INLINE explicit EggAnimPreload(const string &name = ""); + INLINE explicit EggAnimPreload(const std::string &name = ""); INLINE EggAnimPreload(const EggAnimPreload ©); INLINE EggAnimPreload &operator = (const EggAnimPreload ©); @@ -37,7 +37,7 @@ PUBLISHED: INLINE bool has_num_frames() const; INLINE int get_num_frames() const; - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; private: double _fps; diff --git a/panda/src/egg/eggAttributes.h b/panda/src/egg/eggAttributes.h index 02e9c112ac..1ff0833d7e 100644 --- a/panda/src/egg/eggAttributes.h +++ b/panda/src/egg/eggAttributes.h @@ -51,7 +51,7 @@ PUBLISHED: INLINE bool matches_color(const EggAttributes &other) const; INLINE void copy_color(const EggAttributes &other); - void write(ostream &out, int indent_level) const; + void write(std::ostream &out, int indent_level) const; INLINE bool sorts_less_than(const EggAttributes &other) const; int compare_to(const EggAttributes &other) const; diff --git a/panda/src/egg/eggBin.h b/panda/src/egg/eggBin.h index 3553f467fb..e069a44af1 100644 --- a/panda/src/egg/eggBin.h +++ b/panda/src/egg/eggBin.h @@ -25,7 +25,7 @@ */ class EXPCL_PANDAEGG EggBin : public EggGroup { PUBLISHED: - explicit EggBin(const string &name = ""); + explicit EggBin(const std::string &name = ""); EggBin(const EggGroup ©); EggBin(const EggBin ©); diff --git a/panda/src/egg/eggBinMaker.h b/panda/src/egg/eggBinMaker.h index 2e3da3418f..06590cd0c4 100644 --- a/panda/src/egg/eggBinMaker.h +++ b/panda/src/egg/eggBinMaker.h @@ -177,7 +177,7 @@ PUBLISHED: virtual bool collapse_group(const EggGroup *group, int bin_number); - virtual string + virtual std::string get_bin_name(int bin_number, const EggNode *child); virtual PT(EggBin) diff --git a/panda/src/egg/eggComment.I b/panda/src/egg/eggComment.I index cd26e3b12d..ac99fb54e9 100644 --- a/panda/src/egg/eggComment.I +++ b/panda/src/egg/eggComment.I @@ -15,7 +15,7 @@ * */ INLINE EggComment:: -EggComment(const string &node_name, const string &comment) +EggComment(const std::string &node_name, const std::string &comment) : EggNode(node_name), _comment(comment) { } @@ -31,7 +31,7 @@ EggComment(const EggComment ©) : EggNode(copy), _comment(copy._comment) { * */ INLINE EggComment &EggComment:: -operator = (const string &comment) { +operator = (const std::string &comment) { _comment = comment; return *this; } @@ -51,7 +51,7 @@ operator = (const EggComment ©) { * */ INLINE EggComment:: -operator const string & () const { +operator const std::string & () const { return _comment; } @@ -60,7 +60,7 @@ operator const string & () const { * */ INLINE void EggComment:: -set_comment(const string &comment) { +set_comment(const std::string &comment) { _comment = comment; } @@ -68,7 +68,7 @@ set_comment(const string &comment) { /** * */ -INLINE string EggComment:: +INLINE std::string EggComment:: get_comment() const { return _comment; } diff --git a/panda/src/egg/eggComment.h b/panda/src/egg/eggComment.h index 63d5eb82d8..491ecdf6ba 100644 --- a/panda/src/egg/eggComment.h +++ b/panda/src/egg/eggComment.h @@ -23,26 +23,26 @@ */ class EXPCL_PANDAEGG EggComment : public EggNode { PUBLISHED: - INLINE explicit EggComment(const string &node_name, const string &comment); + INLINE explicit EggComment(const std::string &node_name, const std::string &comment); INLINE EggComment(const EggComment ©); // You can use the string operators to directly set and manipulate the // comment. - INLINE EggComment &operator = (const string &comment); + INLINE EggComment &operator = (const std::string &comment); INLINE EggComment &operator = (const EggComment ©); - INLINE operator const string & () const; + INLINE operator const std::string & () const; // Or, you can set and get it explicitly. - INLINE void set_comment(const string &comment); - INLINE string get_comment() const; + INLINE void set_comment(const std::string &comment); + INLINE std::string get_comment() const; - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; private: - string _comment; + std::string _comment; public: diff --git a/panda/src/egg/eggCompositePrimitive.I b/panda/src/egg/eggCompositePrimitive.I index 9a0d054100..0288f62d97 100644 --- a/panda/src/egg/eggCompositePrimitive.I +++ b/panda/src/egg/eggCompositePrimitive.I @@ -15,7 +15,7 @@ * */ INLINE EggCompositePrimitive:: -EggCompositePrimitive(const string &name) : EggPrimitive(name) { +EggCompositePrimitive(const std::string &name) : EggPrimitive(name) { } /** diff --git a/panda/src/egg/eggCompositePrimitive.h b/panda/src/egg/eggCompositePrimitive.h index 9b5e0fa58d..4cde1084bf 100644 --- a/panda/src/egg/eggCompositePrimitive.h +++ b/panda/src/egg/eggCompositePrimitive.h @@ -25,7 +25,7 @@ */ class EXPCL_PANDAEGG EggCompositePrimitive : public EggPrimitive { PUBLISHED: - INLINE explicit EggCompositePrimitive(const string &name = ""); + INLINE explicit EggCompositePrimitive(const std::string &name = ""); INLINE EggCompositePrimitive(const EggCompositePrimitive ©); INLINE EggCompositePrimitive &operator = (const EggCompositePrimitive ©); virtual ~EggCompositePrimitive(); @@ -56,7 +56,7 @@ protected: virtual bool do_triangulate(EggGroupNode *container) const; - void write_body(ostream &out, int indent_level) const; + void write_body(std::ostream &out, int indent_level) const; private: typedef pvector Components; diff --git a/panda/src/egg/eggCoordinateSystem.h b/panda/src/egg/eggCoordinateSystem.h index bf8469b375..0d4575a708 100644 --- a/panda/src/egg/eggCoordinateSystem.h +++ b/panda/src/egg/eggCoordinateSystem.h @@ -34,7 +34,7 @@ PUBLISHED: INLINE void set_value(CoordinateSystem value); INLINE CoordinateSystem get_value() const; - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; private: CoordinateSystem _value; diff --git a/panda/src/egg/eggCurve.I b/panda/src/egg/eggCurve.I index e8a665fcda..2fe86edf6d 100644 --- a/panda/src/egg/eggCurve.I +++ b/panda/src/egg/eggCurve.I @@ -15,7 +15,7 @@ * */ INLINE EggCurve:: -EggCurve(const string &name) : EggPrimitive(name) { +EggCurve(const std::string &name) : EggPrimitive(name) { _subdiv = 0; _type = CT_none; } diff --git a/panda/src/egg/eggCurve.h b/panda/src/egg/eggCurve.h index 6ea17bc77a..6bbcb64ea5 100644 --- a/panda/src/egg/eggCurve.h +++ b/panda/src/egg/eggCurve.h @@ -23,7 +23,7 @@ */ class EXPCL_PANDAEGG EggCurve : public EggPrimitive { PUBLISHED: - INLINE explicit EggCurve(const string &name = ""); + INLINE explicit EggCurve(const std::string &name = ""); INLINE EggCurve(const EggCurve ©); INLINE EggCurve &operator = (const EggCurve ©); @@ -40,7 +40,7 @@ PUBLISHED: INLINE void set_curve_type(CurveType type); INLINE CurveType get_curve_type() const; - static CurveType string_curve_type(const string &string); + static CurveType string_curve_type(const std::string &string); private: int _subdiv; @@ -65,7 +65,7 @@ private: static TypeHandle _type_handle; }; -ostream &operator << (ostream &out, EggCurve::CurveType t); +std::ostream &operator << (std::ostream &out, EggCurve::CurveType t); #include "eggCurve.I" diff --git a/panda/src/egg/eggData.h b/panda/src/egg/eggData.h index 5544f28d60..4b49ba5f90 100644 --- a/panda/src/egg/eggData.h +++ b/panda/src/egg/eggData.h @@ -43,8 +43,8 @@ PUBLISHED: static bool resolve_egg_filename(Filename &egg_filename, const DSearchPath &searchpath = DSearchPath()); - bool read(Filename filename, string display_name = string()); - bool read(istream &in); + bool read(Filename filename, std::string display_name = std::string()); + bool read(std::istream &in); void merge(EggData &other); bool load_externals(const DSearchPath &searchpath = DSearchPath()); @@ -53,7 +53,7 @@ PUBLISHED: int collapse_equivalent_materials(); bool write_egg(Filename filename); - bool write_egg(ostream &out); + bool write_egg(std::ostream &out); INLINE void set_auto_resolve_externals(bool resolve); INLINE bool get_auto_resolve_externals() const; @@ -73,7 +73,7 @@ PUBLISHED: INLINE void strip_normals(); protected: - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; private: void post_read(); diff --git a/panda/src/egg/eggExternalReference.h b/panda/src/egg/eggExternalReference.h index 799c794bd1..ff4f332740 100644 --- a/panda/src/egg/eggExternalReference.h +++ b/panda/src/egg/eggExternalReference.h @@ -24,13 +24,13 @@ */ class EXPCL_PANDAEGG EggExternalReference : public EggFilenameNode { PUBLISHED: - explicit EggExternalReference(const string &node_name, const string &filename); + explicit EggExternalReference(const std::string &node_name, const std::string &filename); EggExternalReference(const EggExternalReference ©); EggExternalReference &operator = (const EggExternalReference ©); - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; - virtual string get_default_extension() const; + virtual std::string get_default_extension() const; public: diff --git a/panda/src/egg/eggFilenameNode.I b/panda/src/egg/eggFilenameNode.I index d2aecbb943..c368becdaa 100644 --- a/panda/src/egg/eggFilenameNode.I +++ b/panda/src/egg/eggFilenameNode.I @@ -22,7 +22,7 @@ EggFilenameNode() { * */ INLINE EggFilenameNode:: -EggFilenameNode(const string &node_name, const Filename &filename) : +EggFilenameNode(const std::string &node_name, const Filename &filename) : EggNode(node_name), _filename(filename), _fullpath(filename) diff --git a/panda/src/egg/eggFilenameNode.h b/panda/src/egg/eggFilenameNode.h index 46734f6a24..3eda6ace36 100644 --- a/panda/src/egg/eggFilenameNode.h +++ b/panda/src/egg/eggFilenameNode.h @@ -27,11 +27,11 @@ class EXPCL_PANDAEGG EggFilenameNode : public EggNode { PUBLISHED: INLINE EggFilenameNode(); - INLINE explicit EggFilenameNode(const string &node_name, const Filename &filename); + INLINE explicit EggFilenameNode(const std::string &node_name, const Filename &filename); INLINE EggFilenameNode(const EggFilenameNode ©); INLINE EggFilenameNode &operator = (const EggFilenameNode ©); - virtual string get_default_extension() const; + virtual std::string get_default_extension() const; INLINE const Filename &get_filename() const; INLINE void set_filename(const Filename &filename); diff --git a/panda/src/egg/eggGroup.I b/panda/src/egg/eggGroup.I index 4575966733..7809867047 100644 --- a/panda/src/egg/eggGroup.I +++ b/panda/src/egg/eggGroup.I @@ -127,7 +127,7 @@ get_cs_type() const { * */ INLINE void EggGroup:: -set_collision_name(const string &collision_name) { +set_collision_name(const std::string &collision_name) { _collision_name = collision_name; } @@ -150,7 +150,7 @@ has_collision_name() const { /** * */ -INLINE const string &EggGroup:: +INLINE const std::string &EggGroup:: get_collision_name() const { return _collision_name; } @@ -259,7 +259,7 @@ get_switch_fps() const { * */ INLINE void EggGroup:: -add_object_type(const string &object_type) { +add_object_type(const std::string &object_type) { _object_types.push_back(object_type); } @@ -282,9 +282,9 @@ get_num_object_types() const { /** * */ -INLINE string EggGroup:: +INLINE std::string EggGroup:: get_object_type(int index) const { - nassertr(index >= 0 && index < (int)_object_types.size(), string()); + nassertr(index >= 0 && index < (int)_object_types.size(), std::string()); return _object_types[index]; } @@ -717,7 +717,7 @@ get_lod() const { * of any one key's value. */ INLINE void EggGroup:: -set_tag(const string &key, const string &value) { +set_tag(const std::string &key, const std::string &value) { _tag_data[key] = value; } @@ -726,14 +726,14 @@ set_tag(const string &key, const string &value) { * the particular key, if any. If no value has been previously set, returns * the empty string. */ -INLINE string EggGroup:: -get_tag(const string &key) const { +INLINE std::string EggGroup:: +get_tag(const std::string &key) const { TagData::const_iterator ti; ti = _tag_data.find(key); if (ti != _tag_data.end()) { return (*ti).second; } - return string(); + return std::string(); } /** @@ -742,7 +742,7 @@ get_tag(const string &key) const { * set. */ INLINE bool EggGroup:: -has_tag(const string &key) const { +has_tag(const std::string &key) const { TagData::const_iterator ti; ti = _tag_data.find(key); return (ti != _tag_data.end()); @@ -753,7 +753,7 @@ has_tag(const string &key) const { * call to clear_tag(), has_tag() will return false for the indicated key. */ INLINE void EggGroup:: -clear_tag(const string &key) { +clear_tag(const std::string &key) { _tag_data.erase(key); } diff --git a/panda/src/egg/eggGroup.h b/panda/src/egg/eggGroup.h index 1266e42a49..bc4d095150 100644 --- a/panda/src/egg/eggGroup.h +++ b/panda/src/egg/eggGroup.h @@ -34,7 +34,7 @@ class EXPCL_PANDAEGG EggGroup : public EggGroupNode, public EggRenderMode, public EggTransform { PUBLISHED: typedef pmap VertexRef; - typedef pmap TagData; + typedef pmap TagData; // These bits are all stored somewhere in _flags. enum GroupType { @@ -132,20 +132,20 @@ PUBLISHED: BO_one_minus_alpha_scale, }; - explicit EggGroup(const string &name = ""); + explicit EggGroup(const std::string &name = ""); EggGroup(const EggGroup ©); EggGroup &operator = (const EggGroup ©); ~EggGroup(); - virtual void write(ostream &out, int indent_level) const; - void write_billboard_flags(ostream &out, int indent_level) const; - void write_collide_flags(ostream &out, int indent_level) const; - void write_model_flags(ostream &out, int indent_level) const; - void write_switch_flags(ostream &out, int indent_level) const; - void write_object_types(ostream &out, int indent_level) const; - void write_decal_flags(ostream &out, int indent_level) const; - void write_tags(ostream &out, int indent_level) const; - void write_render_mode(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; + void write_billboard_flags(std::ostream &out, int indent_level) const; + void write_collide_flags(std::ostream &out, int indent_level) const; + void write_model_flags(std::ostream &out, int indent_level) const; + void write_switch_flags(std::ostream &out, int indent_level) const; + void write_object_types(std::ostream &out, int indent_level) const; + void write_decal_flags(std::ostream &out, int indent_level) const; + void write_tags(std::ostream &out, int indent_level) const; + void write_render_mode(std::ostream &out, int indent_level) const; virtual bool is_joint() const; @@ -177,10 +177,10 @@ PUBLISHED: INLINE void set_collide_flags(int flags); INLINE CollideFlags get_collide_flags() const; - INLINE void set_collision_name(const string &collision_name); + INLINE void set_collision_name(const std::string &collision_name); INLINE void clear_collision_name(); INLINE bool has_collision_name() const; - INLINE const string &get_collision_name() const; + INLINE const std::string &get_collision_name() const; INLINE void set_dcs_type(DCSType type); INLINE DCSType get_dcs_type() const; @@ -195,13 +195,13 @@ PUBLISHED: INLINE void set_switch_fps(double fps); INLINE double get_switch_fps() const; - INLINE void add_object_type(const string &object_type); + INLINE void add_object_type(const std::string &object_type); INLINE void clear_object_types(); INLINE int get_num_object_types() const; - INLINE string get_object_type(int index) const; + INLINE std::string get_object_type(int index) const; MAKE_SEQ(get_object_types, get_num_object_types, get_object_type); - bool has_object_type(const string &object_type) const; - bool remove_object_type(const string &object_type); + bool has_object_type(const std::string &object_type) const; + bool remove_object_type(const std::string &object_type); INLINE void set_model_flag(bool flag); INLINE bool get_model_flag() const; @@ -263,10 +263,10 @@ PUBLISHED: INLINE bool has_lod() const; INLINE const EggSwitchCondition &get_lod() const; - INLINE void set_tag(const string &key, const string &value); - INLINE string get_tag(const string &key) const; - INLINE bool has_tag(const string &key) const; - INLINE void clear_tag(const string &key); + INLINE void set_tag(const std::string &key, const std::string &value); + INLINE std::string get_tag(const std::string &key) const; + INLINE bool has_tag(const std::string &key) const; + INLINE void clear_tag(const std::string &key); INLINE const EggTransform &get_default_pose() const; INLINE EggTransform &modify_default_pose(); @@ -355,20 +355,20 @@ PUBLISHED: void remove_group_ref(int n); void clear_group_refs(); - static GroupType string_group_type(const string &strval); - static DartType string_dart_type(const string &strval); - static DCSType string_dcs_type(const string &strval); - static BillboardType string_billboard_type(const string &strval); - static CollisionSolidType string_cs_type(const string &strval); - static CollideFlags string_collide_flags(const string &strval); - static BlendMode string_blend_mode(const string &strval); - static BlendOperand string_blend_operand(const string &strval); + static GroupType string_group_type(const std::string &strval); + static DartType string_dart_type(const std::string &strval); + static DCSType string_dcs_type(const std::string &strval); + static BillboardType string_billboard_type(const std::string &strval); + static CollisionSolidType string_cs_type(const std::string &strval); + static CollideFlags string_collide_flags(const std::string &strval); + static BlendMode string_blend_mode(const std::string &strval); + static BlendOperand string_blend_operand(const std::string &strval); public: virtual EggTransform *as_transform(); protected: - void write_vertex_ref(ostream &out, int indent_level) const; + void write_vertex_ref(std::ostream &out, int indent_level) const; virtual bool egg_start_parse_body(); virtual void adjust_under(); virtual void r_transform(const LMatrix4d &mat, const LMatrix4d &inv, @@ -417,7 +417,7 @@ private: LColor _blend_color; LPoint3d _billboard_center; vector_string _object_types; - string _collision_name; + std::string _collision_name; double _fps; PT(EggSwitchCondition) _lod; TagData _tag_data; @@ -459,14 +459,14 @@ private: static TypeHandle _type_handle; }; -ostream &operator << (ostream &out, EggGroup::GroupType t); -ostream &operator << (ostream &out, EggGroup::DartType t); -ostream &operator << (ostream &out, EggGroup::DCSType t); -ostream &operator << (ostream &out, EggGroup::BillboardType t); -ostream &operator << (ostream &out, EggGroup::CollisionSolidType t); -ostream &operator << (ostream &out, EggGroup::CollideFlags t); -ostream &operator << (ostream &out, EggGroup::BlendMode t); -ostream &operator << (ostream &out, EggGroup::BlendOperand t); +std::ostream &operator << (std::ostream &out, EggGroup::GroupType t); +std::ostream &operator << (std::ostream &out, EggGroup::DartType t); +std::ostream &operator << (std::ostream &out, EggGroup::DCSType t); +std::ostream &operator << (std::ostream &out, EggGroup::BillboardType t); +std::ostream &operator << (std::ostream &out, EggGroup::CollisionSolidType t); +std::ostream &operator << (std::ostream &out, EggGroup::CollideFlags t); +std::ostream &operator << (std::ostream &out, EggGroup::BlendMode t); +std::ostream &operator << (std::ostream &out, EggGroup::BlendOperand t); #include "eggGroup.I" diff --git a/panda/src/egg/eggGroupNode.h b/panda/src/egg/eggGroupNode.h index 85956cd32b..b8e361e97e 100644 --- a/panda/src/egg/eggGroupNode.h +++ b/panda/src/egg/eggGroupNode.h @@ -58,12 +58,12 @@ private: // Here begins the actual public interface to EggGroupNode. PUBLISHED: - explicit EggGroupNode(const string &name = "") : EggNode(name) { } + explicit EggGroupNode(const std::string &name = "") : EggNode(name) { } EggGroupNode(const EggGroupNode ©); EggGroupNode &operator = (const EggGroupNode ©); virtual ~EggGroupNode(); - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; // The EggGroupNode itself appears to be an STL container of pointers to // EggNodes. The set of children is read-only, however, except through the @@ -114,7 +114,7 @@ PUBLISHED: PT(EggNode) remove_child(EggNode *node); void steal_children(EggGroupNode &other); - EggNode *find_child(const string &name) const; + EggNode *find_child(const std::string &name) const; bool has_absolute_pathnames() const; void resolve_filenames(const DSearchPath &searchpath); @@ -219,7 +219,7 @@ private: INLINE bool operator < (const TBNVertexValue &other) const; LVertexd _pos; LNormald _normal; - string _uv_name; + std::string _uv_name; LTexCoordd _uv; bool _facing; }; diff --git a/panda/src/egg/eggGroupUniquifier.h b/panda/src/egg/eggGroupUniquifier.h index af9e3b8f77..cacabcb06e 100644 --- a/panda/src/egg/eggGroupUniquifier.h +++ b/panda/src/egg/eggGroupUniquifier.h @@ -27,10 +27,10 @@ class EXPCL_PANDAEGG EggGroupUniquifier : public EggNameUniquifier { PUBLISHED: explicit EggGroupUniquifier(bool filter_names = true); - virtual string get_category(EggNode *node); - virtual string filter_name(EggNode *node); - virtual string generate_name(EggNode *node, - const string &category, int index); + virtual std::string get_category(EggNode *node); + virtual std::string filter_name(EggNode *node); + virtual std::string generate_name(EggNode *node, + const std::string &category, int index); private: bool _filter_names; diff --git a/panda/src/egg/eggLine.I b/panda/src/egg/eggLine.I index 39e894e798..6892c34db0 100644 --- a/panda/src/egg/eggLine.I +++ b/panda/src/egg/eggLine.I @@ -15,7 +15,7 @@ * */ INLINE EggLine:: -EggLine(const string &name) : +EggLine(const std::string &name) : EggCompositePrimitive(name), _has_thick(false) { diff --git a/panda/src/egg/eggLine.h b/panda/src/egg/eggLine.h index 4e5eef098c..09ce5a22c8 100644 --- a/panda/src/egg/eggLine.h +++ b/panda/src/egg/eggLine.h @@ -24,14 +24,14 @@ */ class EXPCL_PANDAEGG EggLine : public EggCompositePrimitive { PUBLISHED: - INLINE explicit EggLine(const string &name = ""); + INLINE explicit EggLine(const std::string &name = ""); INLINE EggLine(const EggLine ©); INLINE EggLine &operator = (const EggLine ©); virtual ~EggLine(); virtual EggLine *make_copy() const override; - virtual void write(ostream &out, int indent_level) const override; + virtual void write(std::ostream &out, int indent_level) const override; INLINE bool has_thick() const; INLINE double get_thick() const; diff --git a/panda/src/egg/eggMaterial.h b/panda/src/egg/eggMaterial.h index c1008ae95c..19dc055185 100644 --- a/panda/src/egg/eggMaterial.h +++ b/panda/src/egg/eggMaterial.h @@ -25,10 +25,10 @@ */ class EXPCL_PANDAEGG EggMaterial : public EggNode { PUBLISHED: - explicit EggMaterial(const string &mref_name); + explicit EggMaterial(const std::string &mref_name); EggMaterial(const EggMaterial ©); - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; enum Equivalence { E_attributes = 0x001, diff --git a/panda/src/egg/eggMaterialCollection.h b/panda/src/egg/eggMaterialCollection.h index 1041f2f668..bc712704a8 100644 --- a/panda/src/egg/eggMaterialCollection.h +++ b/panda/src/egg/eggMaterialCollection.h @@ -90,7 +90,7 @@ PUBLISHED: EggMaterial *create_unique_material(const EggMaterial ©, int eq); // Find a material with a particular MRef name. - EggMaterial *find_mref(const string &mref_name) const; + EggMaterial *find_mref(const std::string &mref_name) const; private: Materials _materials; diff --git a/panda/src/egg/eggMesher.h b/panda/src/egg/eggMesher.h index 740b0d38cc..5d1a3e0070 100644 --- a/panda/src/egg/eggMesher.h +++ b/panda/src/egg/eggMesher.h @@ -36,7 +36,7 @@ public: void mesh(EggGroupNode *group, bool flat_shaded); - void write(ostream &out) const; + void write(std::ostream &out) const; bool _consider_fans; bool _retesselate_coplanar; diff --git a/panda/src/egg/eggMesherEdge.I b/panda/src/egg/eggMesherEdge.I index abad388cc0..dbd37f0b70 100644 --- a/panda/src/egg/eggMesherEdge.I +++ b/panda/src/egg/eggMesherEdge.I @@ -58,7 +58,7 @@ matches(const EggMesherEdge &other) const { */ INLINE EggMesherEdge *EggMesherEdge:: common_ptr() { - return min(this, _opposite); + return std::min(this, _opposite); } /** diff --git a/panda/src/egg/eggMesherEdge.h b/panda/src/egg/eggMesherEdge.h index 82975bd7fb..5ef30c1c69 100644 --- a/panda/src/egg/eggMesherEdge.h +++ b/panda/src/egg/eggMesherEdge.h @@ -47,7 +47,7 @@ public: INLINE double compute_length(const EggVertexPool *vertex_pool) const; INLINE LVecBase3d compute_box(const EggVertexPool *vertex_pool) const; - void output(ostream &out) const; + void output(std::ostream &out) const; int _vi_a, _vi_b; @@ -56,8 +56,8 @@ public: EggMesherEdge *_opposite; }; -INLINE ostream & -operator << (ostream &out, const EggMesherEdge &edge) { +INLINE std::ostream & +operator << (std::ostream &out, const EggMesherEdge &edge) { edge.output(out); return out; } diff --git a/panda/src/egg/eggMesherFanMaker.I b/panda/src/egg/eggMesherFanMaker.I index 3bca4a4560..357708c27f 100644 --- a/panda/src/egg/eggMesherFanMaker.I +++ b/panda/src/egg/eggMesherFanMaker.I @@ -66,8 +66,8 @@ is_coplanar_with(const EggMesherFanMaker &other) const { egg_coplanar_threshold); } -INLINE ostream & -operator << (ostream &out, const EggMesherFanMaker &fm) { +INLINE std::ostream & +operator << (std::ostream &out, const EggMesherFanMaker &fm) { fm.output(out); return out; } diff --git a/panda/src/egg/eggMesherFanMaker.h b/panda/src/egg/eggMesherFanMaker.h index fcfc65b879..f320b2858b 100644 --- a/panda/src/egg/eggMesherFanMaker.h +++ b/panda/src/egg/eggMesherFanMaker.h @@ -57,7 +57,7 @@ public: Edges::iterator edge_begin, Edges::iterator edge_end, EggGroupNode *unrolled_tris); - void output(ostream &out) const; + void output(std::ostream &out) const; int _vertex; Edges _edges; @@ -66,7 +66,7 @@ public: EggMesher *_mesher; }; -INLINE ostream &operator << (ostream &out, const EggMesherFanMaker &fm); +INLINE std::ostream &operator << (std::ostream &out, const EggMesherFanMaker &fm); #include "eggMesherFanMaker.I" diff --git a/panda/src/egg/eggMesherStrip.h b/panda/src/egg/eggMesherStrip.h index d8a40e3558..6064388ce0 100644 --- a/panda/src/egg/eggMesherStrip.h +++ b/panda/src/egg/eggMesherStrip.h @@ -76,7 +76,7 @@ public: EggMesherStrip &back, const EggVertexPool *vertex_pool); int count_neighbors() const; - void output_neighbors(ostream &out) const; + void output_neighbors(std::ostream &out) const; INLINE bool is_coplanar_with(const EggMesherStrip &other, PN_stdfloat threshold) const; INLINE PN_stdfloat coplanarity(const EggMesherStrip &other) const; @@ -115,7 +115,7 @@ public: bool pick_sheet_mate(const EggMesherStrip &a_strip, const EggMesherStrip &b_strip) const; - void output(ostream &out) const; + void output(std::ostream &out) const; typedef plist Prims; typedef plist Edges; @@ -144,8 +144,8 @@ public: bool _flat_shaded; }; -INLINE ostream & -operator << (ostream &out, const EggMesherStrip &strip) { +INLINE std::ostream & +operator << (std::ostream &out, const EggMesherStrip &strip) { strip.output(out); return out; } diff --git a/panda/src/egg/eggMiscFuncs.h b/panda/src/egg/eggMiscFuncs.h index c157e7c9c9..6d51d6abc0 100644 --- a/panda/src/egg/eggMiscFuncs.h +++ b/panda/src/egg/eggMiscFuncs.h @@ -27,8 +27,8 @@ * any characters special to egg, writes quotation marks around it. If * always_quote is true, writes quotation marks regardless. */ -ostream & -enquote_string(ostream &out, const string &str, +std::ostream & +enquote_string(std::ostream &out, const std::string &str, int indent_level = 0, bool always_quote = false); @@ -38,13 +38,13 @@ enquote_string(ostream &out, const string &str, * A helper function to write out a 3x3 transform matrix. */ void -write_transform(ostream &out, const LMatrix3d &mat, int indent_level); +write_transform(std::ostream &out, const LMatrix3d &mat, int indent_level); /** * A helper function to write out a 4x4 transform matrix. */ void -write_transform(ostream &out, const LMatrix4d &mat, int indent_level); +write_transform(std::ostream &out, const LMatrix4d &mat, int indent_level); #include "eggMiscFuncs.I" diff --git a/panda/src/egg/eggMorph.I b/panda/src/egg/eggMorph.I index 6b39b2a13e..c49f36306f 100644 --- a/panda/src/egg/eggMorph.I +++ b/panda/src/egg/eggMorph.I @@ -16,7 +16,7 @@ */ template INLINE EggMorph:: -EggMorph(const string &name, const Parameter &offset) +EggMorph(const std::string &name, const Parameter &offset) : Namable(name), _offset(offset) { } @@ -89,7 +89,7 @@ compare_to(const EggMorph &other, double threshold) const { */ template INLINE void EggMorph:: -output(ostream &out, const string &tag, int num_dimensions) const { +output(std::ostream &out, const std::string &tag, int num_dimensions) const { out << tag << " " << get_name() << " {"; for (int i = 0; i < num_dimensions; ++i) { out << " " << MAYBE_ZERO(_offset[i]); diff --git a/panda/src/egg/eggMorph.h b/panda/src/egg/eggMorph.h index f58a5f56b8..482b612a6e 100644 --- a/panda/src/egg/eggMorph.h +++ b/panda/src/egg/eggMorph.h @@ -29,7 +29,7 @@ template class EggMorph : public Namable { public: - INLINE EggMorph(const string &name, const Parameter &offset); + INLINE EggMorph(const std::string &name, const Parameter &offset); INLINE void set_offset(const Parameter &offset); INLINE const Parameter &get_offset() const; @@ -39,7 +39,7 @@ public: INLINE int compare_to(const EggMorph &other, double threshold) const; - INLINE void output(ostream &out, const string &tag, + INLINE void output(std::ostream &out, const std::string &tag, int num_dimensions) const; private: diff --git a/panda/src/egg/eggMorphList.I b/panda/src/egg/eggMorphList.I index deded17c7e..0a2f337550 100644 --- a/panda/src/egg/eggMorphList.I +++ b/panda/src/egg/eggMorphList.I @@ -155,9 +155,9 @@ empty() const { * to *be* a set, but we cannot export STL sets from a Windows DLL. */ template -pair::iterator, bool> EggMorphList:: +std::pair::iterator, bool> EggMorphList:: insert(const MorphType &value) { - pair result; + std::pair result; typename Morphs::iterator mi; for (mi = _morphs.begin(); mi != _morphs.end(); ++mi) { if ((*mi) == value) { @@ -189,7 +189,7 @@ clear() { */ template void EggMorphList:: -write(ostream &out, int indent_level, const string &tag, +write(std::ostream &out, int indent_level, const std::string &tag, int num_dimensions) const { const_iterator i; diff --git a/panda/src/egg/eggMorphList.h b/panda/src/egg/eggMorphList.h index 581e53d9e9..0c890e54f2 100644 --- a/panda/src/egg/eggMorphList.h +++ b/panda/src/egg/eggMorphList.h @@ -53,11 +53,11 @@ public: INLINE size_type size() const; INLINE bool empty() const; - pair insert(const MorphType &value); + std::pair insert(const MorphType &value); INLINE void clear(); - void write(ostream &out, int indent_level, - const string &tag, int num_dimensions) const; + void write(std::ostream &out, int indent_level, + const std::string &tag, int num_dimensions) const; private: Morphs _morphs; diff --git a/panda/src/egg/eggNameUniquifier.h b/panda/src/egg/eggNameUniquifier.h index 72a05698f6..ff0c17c00f 100644 --- a/panda/src/egg/eggNameUniquifier.h +++ b/panda/src/egg/eggNameUniquifier.h @@ -65,19 +65,19 @@ PUBLISHED: void uniquify(EggNode *node); - EggNode *get_node(const string &category, const string &name) const; - bool has_name(const string &category, const string &name) const; - bool add_name(const string &category, const string &name, + EggNode *get_node(const std::string &category, const std::string &name) const; + bool has_name(const std::string &category, const std::string &name) const; + bool add_name(const std::string &category, const std::string &name, EggNode *node = nullptr); - virtual string get_category(EggNode *node)=0; - virtual string filter_name(EggNode *node); - virtual string generate_name(EggNode *node, - const string &category, int index); + virtual std::string get_category(EggNode *node)=0; + virtual std::string filter_name(EggNode *node); + virtual std::string generate_name(EggNode *node, + const std::string &category, int index); private: - typedef pmap UsedNames; - typedef pmap Categories; + typedef pmap UsedNames; + typedef pmap Categories; Categories _categories; int _index; diff --git a/panda/src/egg/eggNamedObject.I b/panda/src/egg/eggNamedObject.I index 6227e51696..77bb78194f 100644 --- a/panda/src/egg/eggNamedObject.I +++ b/panda/src/egg/eggNamedObject.I @@ -15,7 +15,7 @@ * */ INLINE EggNamedObject:: -EggNamedObject(const string &name) : Namable(name) { +EggNamedObject(const std::string &name) : Namable(name) { } @@ -37,7 +37,7 @@ operator = (const EggNamedObject ©) { return *this; } -INLINE ostream &operator << (ostream &out, const EggNamedObject &n) { +INLINE std::ostream &operator << (std::ostream &out, const EggNamedObject &n) { n.output(out); return out; } diff --git a/panda/src/egg/eggNamedObject.h b/panda/src/egg/eggNamedObject.h index 140c989237..0b3588d87b 100644 --- a/panda/src/egg/eggNamedObject.h +++ b/panda/src/egg/eggNamedObject.h @@ -25,14 +25,14 @@ */ class EXPCL_PANDAEGG EggNamedObject : public EggObject, public Namable { PUBLISHED: - INLINE explicit EggNamedObject(const string &name = ""); + INLINE explicit EggNamedObject(const std::string &name = ""); INLINE EggNamedObject(const EggNamedObject ©); INLINE EggNamedObject &operator = (const EggNamedObject ©); - void output(ostream &out) const; + void output(std::ostream &out) const; public: - void write_header(ostream &out, int indent_level, + void write_header(std::ostream &out, int indent_level, const char *egg_keyword) const; @@ -55,7 +55,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const EggNamedObject &n); +INLINE std::ostream &operator << (std::ostream &out, const EggNamedObject &n); #include "eggNamedObject.I" diff --git a/panda/src/egg/eggNode.I b/panda/src/egg/eggNode.I index 596d61b826..4022139ea5 100644 --- a/panda/src/egg/eggNode.I +++ b/panda/src/egg/eggNode.I @@ -15,7 +15,7 @@ * */ INLINE EggNode:: -EggNode(const string &name) : EggNamedObject(name) { +EggNode(const std::string &name) : EggNamedObject(name) { _parent = nullptr; _depth = 0; _under_flags = 0; diff --git a/panda/src/egg/eggNode.h b/panda/src/egg/eggNode.h index f4a5df934f..05191dabc5 100644 --- a/panda/src/egg/eggNode.h +++ b/panda/src/egg/eggNode.h @@ -34,7 +34,7 @@ class EggTextureCollection; */ class EXPCL_PANDAEGG EggNode : public EggNamedObject { PUBLISHED: - INLINE explicit EggNode(const string &name = ""); + INLINE explicit EggNode(const std::string &name = ""); INLINE EggNode(const EggNode ©); INLINE EggNode &operator = (const EggNode ©); @@ -78,8 +78,8 @@ PUBLISHED: virtual bool determine_indexed(); virtual bool determine_decal(); - virtual void write(ostream &out, int indent_level) const=0; - bool parse_egg(const string &egg_syntax); + virtual void write(std::ostream &out, int indent_level) const=0; + bool parse_egg(const std::string &egg_syntax); #ifdef _DEBUG void test_under_integrity() const; diff --git a/panda/src/egg/eggNurbsCurve.I b/panda/src/egg/eggNurbsCurve.I index f426541d55..60f16cc9ca 100644 --- a/panda/src/egg/eggNurbsCurve.I +++ b/panda/src/egg/eggNurbsCurve.I @@ -15,7 +15,7 @@ * */ INLINE EggNurbsCurve:: -EggNurbsCurve(const string &name) : EggCurve(name) { +EggNurbsCurve(const std::string &name) : EggCurve(name) { _order = 0; } diff --git a/panda/src/egg/eggNurbsCurve.h b/panda/src/egg/eggNurbsCurve.h index b6b5bc4b55..dd62f6c5ab 100644 --- a/panda/src/egg/eggNurbsCurve.h +++ b/panda/src/egg/eggNurbsCurve.h @@ -25,7 +25,7 @@ */ class EXPCL_PANDAEGG EggNurbsCurve : public EggCurve { PUBLISHED: - INLINE explicit EggNurbsCurve(const string &name = ""); + INLINE explicit EggNurbsCurve(const std::string &name = ""); INLINE EggNurbsCurve(const EggNurbsCurve ©); INLINE EggNurbsCurve &operator = (const EggNurbsCurve ©); @@ -50,7 +50,7 @@ PUBLISHED: INLINE double get_knot(int k) const; MAKE_SEQ(get_knots, get_num_knots, get_knot); - virtual void write(ostream &out, int indent_level) const override; + virtual void write(std::ostream &out, int indent_level) const override; MAKE_PROPERTY(order, get_order, set_order); MAKE_PROPERTY(degree, get_degree); diff --git a/panda/src/egg/eggNurbsSurface.I b/panda/src/egg/eggNurbsSurface.I index 1a23a6074a..cced43e69d 100644 --- a/panda/src/egg/eggNurbsSurface.I +++ b/panda/src/egg/eggNurbsSurface.I @@ -15,7 +15,7 @@ * */ INLINE EggNurbsSurface:: -EggNurbsSurface(const string &name) : EggSurface(name) { +EggNurbsSurface(const std::string &name) : EggSurface(name) { _u_order = 0; _v_order = 0; } diff --git a/panda/src/egg/eggNurbsSurface.h b/panda/src/egg/eggNurbsSurface.h index ffadc3cab7..46d9c86357 100644 --- a/panda/src/egg/eggNurbsSurface.h +++ b/panda/src/egg/eggNurbsSurface.h @@ -32,7 +32,7 @@ PUBLISHED: typedef Loops Trim; typedef plist Trims; - INLINE explicit EggNurbsSurface(const string &name = ""); + INLINE explicit EggNurbsSurface(const std::string &name = ""); INLINE EggNurbsSurface(const EggNurbsSurface ©); INLINE EggNurbsSurface &operator = (const EggNurbsSurface ©); @@ -75,7 +75,7 @@ PUBLISHED: MAKE_SEQ(get_v_knots, get_num_v_knots, get_v_knot); INLINE EggVertex *get_cv(int ui, int vi) const; - virtual void write(ostream &out, int indent_level) const override; + virtual void write(std::ostream &out, int indent_level) const override; public: Curves _curves_on_surface; diff --git a/panda/src/egg/eggPatch.I b/panda/src/egg/eggPatch.I index b75db18d2d..7356ec98ef 100644 --- a/panda/src/egg/eggPatch.I +++ b/panda/src/egg/eggPatch.I @@ -15,7 +15,7 @@ * */ INLINE EggPatch:: -EggPatch(const string &name) : EggPrimitive(name) { +EggPatch(const std::string &name) : EggPrimitive(name) { } /** diff --git a/panda/src/egg/eggPatch.h b/panda/src/egg/eggPatch.h index 9e93d0ec80..67c94c100a 100644 --- a/panda/src/egg/eggPatch.h +++ b/panda/src/egg/eggPatch.h @@ -24,13 +24,13 @@ */ class EXPCL_PANDAEGG EggPatch : public EggPrimitive { PUBLISHED: - INLINE explicit EggPatch(const string &name = ""); + INLINE explicit EggPatch(const std::string &name = ""); INLINE EggPatch(const EggPatch ©); INLINE EggPatch &operator = (const EggPatch ©); virtual EggPatch *make_copy() const override; - virtual void write(ostream &out, int indent_level) const override; + virtual void write(std::ostream &out, int indent_level) const override; public: static TypeHandle get_class_type() { diff --git a/panda/src/egg/eggPoint.I b/panda/src/egg/eggPoint.I index 6fa3e252ef..722e6b7cc5 100644 --- a/panda/src/egg/eggPoint.I +++ b/panda/src/egg/eggPoint.I @@ -15,7 +15,7 @@ * */ INLINE EggPoint:: -EggPoint(const string &name) : +EggPoint(const std::string &name) : EggPrimitive(name), _flags(0), _thick(1.0) diff --git a/panda/src/egg/eggPoint.h b/panda/src/egg/eggPoint.h index 96e8b63fe6..fc1ed8d24c 100644 --- a/panda/src/egg/eggPoint.h +++ b/panda/src/egg/eggPoint.h @@ -24,7 +24,7 @@ */ class EXPCL_PANDAEGG EggPoint : public EggPrimitive { PUBLISHED: - INLINE explicit EggPoint(const string &name = ""); + INLINE explicit EggPoint(const std::string &name = ""); INLINE EggPoint(const EggPoint ©); INLINE EggPoint &operator = (const EggPoint ©); @@ -42,7 +42,7 @@ PUBLISHED: virtual bool cleanup() override; - virtual void write(ostream &out, int indent_level) const override; + virtual void write(std::ostream &out, int indent_level) const override; private: enum Flags { diff --git a/panda/src/egg/eggPolygon.I b/panda/src/egg/eggPolygon.I index 69b6d4b7fe..08811e3f7f 100644 --- a/panda/src/egg/eggPolygon.I +++ b/panda/src/egg/eggPolygon.I @@ -15,7 +15,7 @@ * */ INLINE EggPolygon:: -EggPolygon(const string &name) : EggPrimitive(name) { +EggPolygon(const std::string &name) : EggPrimitive(name) { } /** diff --git a/panda/src/egg/eggPolygon.h b/panda/src/egg/eggPolygon.h index e5be0e25f0..3629537814 100644 --- a/panda/src/egg/eggPolygon.h +++ b/panda/src/egg/eggPolygon.h @@ -23,7 +23,7 @@ */ class EXPCL_PANDAEGG EggPolygon : public EggPrimitive { PUBLISHED: - INLINE explicit EggPolygon(const string &name = ""); + INLINE explicit EggPolygon(const std::string &name = ""); INLINE EggPolygon(const EggPolygon ©); INLINE EggPolygon &operator = (const EggPolygon ©); @@ -39,7 +39,7 @@ PUBLISHED: INLINE bool triangulate_into(EggGroupNode *container, bool convex_also) const; PT(EggPolygon) triangulate_in_place(bool convex_also); - virtual void write(ostream &out, int indent_level) const override; + virtual void write(std::ostream &out, int indent_level) const override; private: bool decomp_concave(EggGroupNode *container, int asum, int x, int y) const; diff --git a/panda/src/egg/eggPoolUniquifier.h b/panda/src/egg/eggPoolUniquifier.h index 0fb7d1b9d5..8fa0c328d0 100644 --- a/panda/src/egg/eggPoolUniquifier.h +++ b/panda/src/egg/eggPoolUniquifier.h @@ -27,7 +27,7 @@ class EXPCL_PANDAEGG EggPoolUniquifier : public EggNameUniquifier { PUBLISHED: EggPoolUniquifier(); - virtual string get_category(EggNode *node); + virtual std::string get_category(EggNode *node); public: static TypeHandle get_class_type() { diff --git a/panda/src/egg/eggPrimitive.I b/panda/src/egg/eggPrimitive.I index c90c983001..13e994acce 100644 --- a/panda/src/egg/eggPrimitive.I +++ b/panda/src/egg/eggPrimitive.I @@ -15,7 +15,7 @@ * */ INLINE EggPrimitive:: -EggPrimitive(const string &name): EggNode(name) { +EggPrimitive(const std::string &name): EggNode(name) { _bface = false; _connected_shading = S_unknown; } @@ -67,13 +67,13 @@ INLINE EggPrimitive:: * Presently, this is defined as the primitive name itself, unless it begins * with a digit. */ -INLINE string EggPrimitive:: +INLINE std::string EggPrimitive:: get_sort_name() const { - const string &name = get_name(); + const std::string &name = get_name(); if (!name.empty() && !isdigit(name[0])) { return name; } - return string(); + return std::string(); } /** diff --git a/panda/src/egg/eggPrimitive.h b/panda/src/egg/eggPrimitive.h index 9ec9d9cf79..d461762382 100644 --- a/panda/src/egg/eggPrimitive.h +++ b/panda/src/egg/eggPrimitive.h @@ -67,7 +67,7 @@ PUBLISHED: S_per_vertex }; - INLINE explicit EggPrimitive(const string &name = ""); + INLINE explicit EggPrimitive(const std::string &name = ""); INLINE EggPrimitive(const EggPrimitive ©); INLINE EggPrimitive &operator = (const EggPrimitive ©); INLINE ~EggPrimitive(); @@ -82,7 +82,7 @@ PUBLISHED: virtual EggRenderMode *determine_draw_order(); virtual EggRenderMode *determine_bin(); - INLINE string get_sort_name() const; + INLINE std::string get_sort_name() const; virtual Shading get_shading() const; INLINE void clear_connected_shading(); @@ -191,7 +191,7 @@ PUBLISHED: MAKE_SEQ_PROPERTY(vertices, get_num_vertices, get_vertex, set_vertex, remove_vertex, insert_vertex); MAKE_PROPERTY(pool, get_pool); - virtual void write(ostream &out, int indent_level) const=0; + virtual void write(std::ostream &out, int indent_level) const=0; #ifdef _DEBUG void test_vref_integrity() const; @@ -209,7 +209,7 @@ protected: virtual void prepare_remove_vertex(EggVertex *vertex, int i, int n); protected: - void write_body(ostream &out, int indent_level) const; + void write_body(std::ostream &out, int indent_level) const; virtual bool egg_start_parse_body(); virtual void r_transform(const LMatrix4d &mat, const LMatrix4d &inv, diff --git a/panda/src/egg/eggRenderMode.I b/panda/src/egg/eggRenderMode.I index 10d40d01fb..ee21aabf34 100644 --- a/panda/src/egg/eggRenderMode.I +++ b/panda/src/egg/eggRenderMode.I @@ -186,7 +186,7 @@ clear_draw_order() { * CullTraverser) in use for this to work. See also set_draw_order(). */ INLINE void EggRenderMode:: -set_bin(const string &bin) { +set_bin(const std::string &bin) { _bin = bin; } @@ -194,7 +194,7 @@ set_bin(const string &bin) { * Returns the bin name that has been set for this particular object, if any. * See set_bin(). */ -INLINE string EggRenderMode:: +INLINE std::string EggRenderMode:: get_bin() const { return _bin; } @@ -214,7 +214,7 @@ has_bin() const { */ INLINE void EggRenderMode:: clear_bin() { - _bin = string(); + _bin = std::string(); } /** diff --git a/panda/src/egg/eggRenderMode.h b/panda/src/egg/eggRenderMode.h index 66d9a6c645..db18e5d47d 100644 --- a/panda/src/egg/eggRenderMode.h +++ b/panda/src/egg/eggRenderMode.h @@ -34,7 +34,7 @@ PUBLISHED: INLINE EggRenderMode(const EggRenderMode ©); EggRenderMode &operator = (const EggRenderMode ©); - void write(ostream &out, int indent_level) const; + void write(std::ostream &out, int indent_level) const; enum AlphaMode { // Specifies implementation of transparency. AM_unspecified, @@ -83,8 +83,8 @@ PUBLISHED: INLINE bool has_draw_order() const; INLINE void clear_draw_order(); - INLINE void set_bin(const string &bin); - INLINE string get_bin() const; + INLINE void set_bin(const std::string &bin); + INLINE std::string get_bin() const; INLINE bool has_bin() const; INLINE void clear_bin(); @@ -93,10 +93,10 @@ PUBLISHED: INLINE bool operator != (const EggRenderMode &other) const; bool operator < (const EggRenderMode &other) const; - static AlphaMode string_alpha_mode(const string &string); - static DepthWriteMode string_depth_write_mode(const string &string); - static DepthTestMode string_depth_test_mode(const string &string); - static VisibilityMode string_visibility_mode(const string &string); + static AlphaMode string_alpha_mode(const std::string &string); + static DepthWriteMode string_depth_write_mode(const std::string &string); + static DepthTestMode string_depth_test_mode(const std::string &string); + static VisibilityMode string_visibility_mode(const std::string &string); private: AlphaMode _alpha_mode; @@ -107,7 +107,7 @@ private: bool _has_depth_offset; int _draw_order; bool _has_draw_order; - string _bin; + std::string _bin; public: @@ -122,12 +122,12 @@ private: static TypeHandle _type_handle; }; -EXPCL_PANDAEGG ostream &operator << (ostream &out, EggRenderMode::AlphaMode mode); -EXPCL_PANDAEGG istream &operator >> (istream &in, EggRenderMode::AlphaMode &mode); +EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggRenderMode::AlphaMode mode); +EXPCL_PANDAEGG std::istream &operator >> (std::istream &in, EggRenderMode::AlphaMode &mode); -EXPCL_PANDAEGG ostream &operator << (ostream &out, EggRenderMode::DepthWriteMode mode); -EXPCL_PANDAEGG ostream &operator << (ostream &out, EggRenderMode::DepthTestMode mode); -EXPCL_PANDAEGG ostream &operator << (ostream &out, EggRenderMode::VisibilityMode mode); +EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggRenderMode::DepthWriteMode mode); +EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggRenderMode::DepthTestMode mode); +EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggRenderMode::VisibilityMode mode); #include "eggRenderMode.I" diff --git a/panda/src/egg/eggSAnimData.I b/panda/src/egg/eggSAnimData.I index 866fdd753a..e1fe187d54 100644 --- a/panda/src/egg/eggSAnimData.I +++ b/panda/src/egg/eggSAnimData.I @@ -15,7 +15,7 @@ * */ INLINE EggSAnimData:: -EggSAnimData(const string &name) : EggAnimData(name) { +EggSAnimData(const std::string &name) : EggAnimData(name) { } diff --git a/panda/src/egg/eggSAnimData.h b/panda/src/egg/eggSAnimData.h index 2862b94622..681716f6b0 100644 --- a/panda/src/egg/eggSAnimData.h +++ b/panda/src/egg/eggSAnimData.h @@ -24,7 +24,7 @@ */ class EXPCL_PANDAEGG EggSAnimData : public EggAnimData { PUBLISHED: - INLINE explicit EggSAnimData(const string &name = ""); + INLINE explicit EggSAnimData(const std::string &name = ""); INLINE EggSAnimData(const EggSAnimData ©); INLINE EggSAnimData &operator = (const EggSAnimData ©); @@ -34,7 +34,7 @@ PUBLISHED: void optimize(); - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; public: diff --git a/panda/src/egg/eggSurface.I b/panda/src/egg/eggSurface.I index f7856d3ec7..e03d790408 100644 --- a/panda/src/egg/eggSurface.I +++ b/panda/src/egg/eggSurface.I @@ -15,7 +15,7 @@ * */ INLINE EggSurface:: -EggSurface(const string &name) : EggPrimitive(name) { +EggSurface(const std::string &name) : EggPrimitive(name) { _u_subdiv = 0; _v_subdiv = 0; } diff --git a/panda/src/egg/eggSurface.h b/panda/src/egg/eggSurface.h index 3085cb1c48..ca6994f7ba 100644 --- a/panda/src/egg/eggSurface.h +++ b/panda/src/egg/eggSurface.h @@ -23,7 +23,7 @@ */ class EXPCL_PANDAEGG EggSurface : public EggPrimitive { PUBLISHED: - INLINE explicit EggSurface(const string &name = ""); + INLINE explicit EggSurface(const std::string &name = ""); INLINE EggSurface(const EggSurface ©); INLINE EggSurface &operator = (const EggSurface ©); diff --git a/panda/src/egg/eggSwitchCondition.h b/panda/src/egg/eggSwitchCondition.h index a1d16db2ca..35d1c16cc3 100644 --- a/panda/src/egg/eggSwitchCondition.h +++ b/panda/src/egg/eggSwitchCondition.h @@ -29,7 +29,7 @@ class EXPCL_PANDAEGG EggSwitchCondition : public EggObject { PUBLISHED: virtual EggSwitchCondition *make_copy() const=0; - virtual void write(ostream &out, int indent_level) const=0; + virtual void write(std::ostream &out, int indent_level) const=0; virtual void transform(const LMatrix4d &mat)=0; @@ -64,7 +64,7 @@ PUBLISHED: const LPoint3d ¢er, double fade = 0.0); virtual EggSwitchCondition *make_copy() const; - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; virtual void transform(const LMatrix4d &mat); diff --git a/panda/src/egg/eggTable.I b/panda/src/egg/eggTable.I index 33fe8b343a..d5822455ff 100644 --- a/panda/src/egg/eggTable.I +++ b/panda/src/egg/eggTable.I @@ -15,7 +15,7 @@ * */ INLINE EggTable:: -EggTable(const string &name) : EggGroupNode(name) { +EggTable(const std::string &name) : EggGroupNode(name) { _type = TT_table; } diff --git a/panda/src/egg/eggTable.h b/panda/src/egg/eggTable.h index e2a55d7a3e..a2f627f555 100644 --- a/panda/src/egg/eggTable.h +++ b/panda/src/egg/eggTable.h @@ -32,7 +32,7 @@ PUBLISHED: TT_bundle, }; - INLINE explicit EggTable(const string &name = ""); + INLINE explicit EggTable(const std::string &name = ""); INLINE EggTable(const EggTable ©); INLINE EggTable &operator = (const EggTable ©); @@ -40,9 +40,9 @@ PUBLISHED: INLINE TableType get_table_type() const; bool has_transform() const; - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; - static TableType string_table_type(const string &string); + static TableType string_table_type(const std::string &string); protected: virtual void r_transform(const LMatrix4d &mat, const LMatrix4d &inv, @@ -71,7 +71,7 @@ private: static TypeHandle _type_handle; }; -ostream &operator << (ostream &out, EggTable::TableType t); +std::ostream &operator << (std::ostream &out, EggTable::TableType t); #include "eggTable.I" diff --git a/panda/src/egg/eggTexture.I b/panda/src/egg/eggTexture.I index 6380934886..7a71261e31 100644 --- a/panda/src/egg/eggTexture.I +++ b/panda/src/egg/eggTexture.I @@ -376,7 +376,7 @@ get_quality_level() const { * Each different TextureStage in the world must be uniquely named. */ INLINE void EggTexture:: -set_stage_name(const string &stage_name) { +set_stage_name(const std::string &stage_name) { _stage_name = stage_name; _flags |= F_has_stage_name; } @@ -386,7 +386,7 @@ set_stage_name(const string &stage_name) { */ INLINE void EggTexture:: clear_stage_name() { - _stage_name = string(); + _stage_name = std::string(); _flags &= ~F_has_stage_name; } @@ -403,7 +403,7 @@ has_stage_name() const { * Returns the stage name that has been specified for this texture, or the * tref name if no texture stage has explicitly been specified. */ -INLINE const string &EggTexture:: +INLINE const std::string &EggTexture:: get_stage_name() const { return has_stage_name() ? _stage_name : get_name(); } @@ -526,7 +526,7 @@ get_border_color() const { * texture coordinates will be used. */ INLINE void EggTexture:: -set_uv_name(const string &uv_name) { +set_uv_name(const std::string &uv_name) { if (uv_name == "default" || uv_name.empty()) { clear_uv_name(); } else { @@ -541,7 +541,7 @@ set_uv_name(const string &uv_name) { */ INLINE void EggTexture:: clear_uv_name() { - _uv_name = string(); + _uv_name = std::string(); _flags &= ~F_has_uv_name; } @@ -558,7 +558,7 @@ has_uv_name() const { * Returns the texcoord name that has been specified for this texture, or the * empty string if no texcoord name has explicitly been specified. */ -INLINE const string &EggTexture:: +INLINE const std::string &EggTexture:: get_uv_name() const { return _uv_name; } diff --git a/panda/src/egg/eggTexture.h b/panda/src/egg/eggTexture.h index 174b7c99db..e20c19b9cc 100644 --- a/panda/src/egg/eggTexture.h +++ b/panda/src/egg/eggTexture.h @@ -29,12 +29,12 @@ */ class EXPCL_PANDAEGG EggTexture : public EggFilenameNode, public EggRenderMode, public EggTransform { PUBLISHED: - explicit EggTexture(const string &tref_name, const Filename &filename); + explicit EggTexture(const std::string &tref_name, const Filename &filename); EggTexture(const EggTexture ©); EggTexture &operator = (const EggTexture ©); virtual ~EggTexture(); - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; enum Equivalence { E_basename = 0x001, @@ -219,10 +219,10 @@ PUBLISHED: INLINE void set_quality_level(QualityLevel quality_level); INLINE QualityLevel get_quality_level() const; - INLINE void set_stage_name(const string &stage_name); + INLINE void set_stage_name(const std::string &stage_name); INLINE void clear_stage_name(); INLINE bool has_stage_name() const; - INLINE const string &get_stage_name() const; + INLINE const std::string &get_stage_name() const; INLINE void set_priority(int priority); INLINE void clear_priority(); @@ -239,10 +239,10 @@ PUBLISHED: INLINE bool has_border_color() const; INLINE const LColor &get_border_color() const; - INLINE void set_uv_name(const string &uv_name); + INLINE void set_uv_name(const std::string &uv_name); INLINE void clear_uv_name(); INLINE bool has_uv_name() const; - INLINE const string &get_uv_name() const; + INLINE const std::string &get_uv_name() const; INLINE void set_rgb_scale(int rgb_scale); INLINE void clear_rgb_scale(); @@ -297,17 +297,17 @@ PUBLISHED: bool multitexture_over(EggTexture *other); INLINE int get_multitexture_sort() const; - static TextureType string_texture_type(const string &string); - static Format string_format(const string &string); - static CompressionMode string_compression_mode(const string &string); - static WrapMode string_wrap_mode(const string &string); - static FilterType string_filter_type(const string &string); - static EnvType string_env_type(const string &string); - static CombineMode string_combine_mode(const string &string); - static CombineSource string_combine_source(const string &string); - static CombineOperand string_combine_operand(const string &string); - static TexGen string_tex_gen(const string &string); - static QualityLevel string_quality_level(const string &string); + static TextureType string_texture_type(const std::string &string); + static Format string_format(const std::string &string); + static CompressionMode string_compression_mode(const std::string &string); + static WrapMode string_wrap_mode(const std::string &string); + static FilterType string_filter_type(const std::string &string); + static EnvType string_env_type(const std::string &string); + static CombineMode string_combine_mode(const std::string &string); + static CombineSource string_combine_source(const std::string &string); + static CombineOperand string_combine_operand(const std::string &string); + static TexGen string_tex_gen(const std::string &string); + static QualityLevel string_quality_level(const std::string &string); PUBLISHED: MAKE_PROPERTY(texture_type, get_texture_type, set_texture_type); @@ -396,11 +396,11 @@ private: int _num_views; TexGen _tex_gen; QualityLevel _quality_level; - string _stage_name; + std::string _stage_name; int _priority; LColor _color; LColor _border_color; - string _uv_name; + std::string _uv_name; int _rgb_scale; int _alpha_scale; int _flags; @@ -466,22 +466,22 @@ public: int _eq; }; -INLINE ostream &operator << (ostream &out, const EggTexture &n) { +INLINE std::ostream &operator << (std::ostream &out, const EggTexture &n) { return out << n.get_filename(); } -EXPCL_PANDAEGG ostream &operator << (ostream &out, EggTexture::TextureType texture_type); -EXPCL_PANDAEGG ostream &operator << (ostream &out, EggTexture::Format format); -EXPCL_PANDAEGG ostream &operator << (ostream &out, EggTexture::CompressionMode mode); -EXPCL_PANDAEGG ostream &operator << (ostream &out, EggTexture::WrapMode mode); -EXPCL_PANDAEGG ostream &operator << (ostream &out, EggTexture::FilterType type); -EXPCL_PANDAEGG ostream &operator << (ostream &out, EggTexture::EnvType type); -EXPCL_PANDAEGG ostream &operator << (ostream &out, EggTexture::CombineMode cm); -EXPCL_PANDAEGG ostream &operator << (ostream &out, EggTexture::CombineChannel cc); -EXPCL_PANDAEGG ostream &operator << (ostream &out, EggTexture::CombineSource cs); -EXPCL_PANDAEGG ostream &operator << (ostream &out, EggTexture::CombineOperand co); -EXPCL_PANDAEGG ostream &operator << (ostream &out, EggTexture::TexGen tex_gen); -EXPCL_PANDAEGG ostream &operator << (ostream &out, EggTexture::QualityLevel quality_level); +EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::TextureType texture_type); +EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::Format format); +EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::CompressionMode mode); +EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::WrapMode mode); +EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::FilterType type); +EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::EnvType type); +EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::CombineMode cm); +EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::CombineChannel cc); +EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::CombineSource cs); +EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::CombineOperand co); +EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::TexGen tex_gen); +EXPCL_PANDAEGG std::ostream &operator << (std::ostream &out, EggTexture::QualityLevel quality_level); #include "eggTexture.I" diff --git a/panda/src/egg/eggTextureCollection.h b/panda/src/egg/eggTextureCollection.h index e5276eef5c..db9f64ae93 100644 --- a/panda/src/egg/eggTextureCollection.h +++ b/panda/src/egg/eggTextureCollection.h @@ -98,7 +98,7 @@ PUBLISHED: EggTexture *create_unique_texture(const EggTexture ©, int eq); // Find a texture with a particular TRef name. - EggTexture *find_tref(const string &tref_name) const; + EggTexture *find_tref(const std::string &tref_name) const; // Find a texture with a particular filename. EggTexture *find_filename(const Filename &filename) const; diff --git a/panda/src/egg/eggTransform.h b/panda/src/egg/eggTransform.h index 857617ff43..9a6b95b434 100644 --- a/panda/src/egg/eggTransform.h +++ b/panda/src/egg/eggTransform.h @@ -82,8 +82,8 @@ PUBLISHED: INLINE const LMatrix3d &get_component_mat3(int n) const; INLINE const LMatrix4d &get_component_mat4(int n) const; - void write(ostream &out, int indent_level, - const string &label) const; + void write(std::ostream &out, int indent_level, + const std::string &label) const; protected: void internal_clear_transform(); diff --git a/panda/src/egg/eggTriangleFan.I b/panda/src/egg/eggTriangleFan.I index 367b956e9e..d2ddbbdeb3 100644 --- a/panda/src/egg/eggTriangleFan.I +++ b/panda/src/egg/eggTriangleFan.I @@ -15,7 +15,7 @@ * */ INLINE EggTriangleFan:: -EggTriangleFan(const string &name) : EggCompositePrimitive(name) { +EggTriangleFan(const std::string &name) : EggCompositePrimitive(name) { } /** diff --git a/panda/src/egg/eggTriangleFan.h b/panda/src/egg/eggTriangleFan.h index 6435650284..d8a1c7807f 100644 --- a/panda/src/egg/eggTriangleFan.h +++ b/panda/src/egg/eggTriangleFan.h @@ -24,14 +24,14 @@ */ class EXPCL_PANDAEGG EggTriangleFan : public EggCompositePrimitive { PUBLISHED: - INLINE explicit EggTriangleFan(const string &name = ""); + INLINE explicit EggTriangleFan(const std::string &name = ""); INLINE EggTriangleFan(const EggTriangleFan ©); INLINE EggTriangleFan &operator = (const EggTriangleFan ©); virtual ~EggTriangleFan(); virtual EggTriangleFan *make_copy() const override; - virtual void write(ostream &out, int indent_level) const override; + virtual void write(std::ostream &out, int indent_level) const override; virtual void apply_first_attribute() override; protected: diff --git a/panda/src/egg/eggTriangleStrip.I b/panda/src/egg/eggTriangleStrip.I index 4fcb25b907..5e2e5bd33a 100644 --- a/panda/src/egg/eggTriangleStrip.I +++ b/panda/src/egg/eggTriangleStrip.I @@ -15,7 +15,7 @@ * */ INLINE EggTriangleStrip:: -EggTriangleStrip(const string &name) : EggCompositePrimitive(name) { +EggTriangleStrip(const std::string &name) : EggCompositePrimitive(name) { } /** diff --git a/panda/src/egg/eggTriangleStrip.h b/panda/src/egg/eggTriangleStrip.h index fa371d4185..728b6e2e30 100644 --- a/panda/src/egg/eggTriangleStrip.h +++ b/panda/src/egg/eggTriangleStrip.h @@ -24,14 +24,14 @@ */ class EXPCL_PANDAEGG EggTriangleStrip : public EggCompositePrimitive { PUBLISHED: - INLINE explicit EggTriangleStrip(const string &name = ""); + INLINE explicit EggTriangleStrip(const std::string &name = ""); INLINE EggTriangleStrip(const EggTriangleStrip ©); INLINE EggTriangleStrip &operator = (const EggTriangleStrip ©); virtual ~EggTriangleStrip(); virtual EggTriangleStrip *make_copy() const override; - virtual void write(ostream &out, int indent_level) const override; + virtual void write(std::ostream &out, int indent_level) const override; protected: virtual int get_num_lead_vertices() const override; diff --git a/panda/src/egg/eggVertex.h b/panda/src/egg/eggVertex.h index 4bbbd773d1..4c2cc2e36d 100644 --- a/panda/src/egg/eggVertex.h +++ b/panda/src/egg/eggVertex.h @@ -40,8 +40,8 @@ class EXPCL_PANDAEGG EggVertex : public EggObject, public EggAttributes { public: typedef pset GroupRef; typedef pmultiset PrimitiveRef; - typedef pmap< string, PT(EggVertexUV) > UVMap; - typedef pmap< string, PT(EggVertexAux) > AuxMap; + typedef pmap< std::string, PT(EggVertexUV) > UVMap; + typedef pmap< std::string, PT(EggVertexAux) > AuxMap; typedef second_of_pair_iterator uv_iterator; typedef uv_iterator const_uv_iterator; @@ -85,26 +85,26 @@ PUBLISHED: INLINE LTexCoordd get_uv() const; INLINE void set_uv(const LTexCoordd &texCoord); INLINE void clear_uv(); - bool has_uv(const string &name) const; - bool has_uvw(const string &name) const; - LTexCoordd get_uv(const string &name) const; - const LTexCoord3d &get_uvw(const string &name) const; - void set_uv(const string &name, const LTexCoordd &texCoord); - void set_uvw(const string &name, const LTexCoord3d &texCoord); - const EggVertexUV *get_uv_obj(const string &name) const; - EggVertexUV *modify_uv_obj(const string &name); + bool has_uv(const std::string &name) const; + bool has_uvw(const std::string &name) const; + LTexCoordd get_uv(const std::string &name) const; + const LTexCoord3d &get_uvw(const std::string &name) const; + void set_uv(const std::string &name, const LTexCoordd &texCoord); + void set_uvw(const std::string &name, const LTexCoord3d &texCoord); + const EggVertexUV *get_uv_obj(const std::string &name) const; + EggVertexUV *modify_uv_obj(const std::string &name); void set_uv_obj(EggVertexUV *vertex_uv); - void clear_uv(const string &name); + void clear_uv(const std::string &name); INLINE bool has_aux() const; INLINE void clear_aux(); - bool has_aux(const string &name) const; - const LVecBase4d &get_aux(const string &name) const; - void set_aux(const string &name, const LVecBase4d &aux); - const EggVertexAux *get_aux_obj(const string &name) const; - EggVertexAux *modify_aux_obj(const string &name); + bool has_aux(const std::string &name) const; + const LVecBase4d &get_aux(const std::string &name) const; + void set_aux(const std::string &name, const LVecBase4d &aux); + const EggVertexAux *get_aux_obj(const std::string &name) const; + EggVertexAux *modify_aux_obj(const std::string &name); void set_aux_obj(EggVertexAux *vertex_aux); - void clear_aux(const string &name); + void clear_aux(const std::string &name); static PT(EggVertex) make_average(const EggVertex *first, const EggVertex *second); @@ -126,7 +126,7 @@ PUBLISHED: INLINE void set_external_index2(int external_index2); INLINE int get_external_index2() const; - void write(ostream &out, int indent_level) const; + void write(std::ostream &out, int indent_level) const; INLINE bool sorts_less_than(const EggVertex &other) const; int compare_to(const EggVertex &other) const; @@ -160,7 +160,7 @@ PUBLISHED: void test_pref_integrity() const { } #endif // _DEBUG - void output(ostream &out) const; + void output(std::ostream &out) const; EggMorphVertexList _dxyzs; @@ -201,7 +201,7 @@ private: friend class EggPrimitive; }; -INLINE ostream &operator << (ostream &out, const EggVertex &vert) { +INLINE std::ostream &operator << (std::ostream &out, const EggVertex &vert) { vert.output(out); return out; } diff --git a/panda/src/egg/eggVertexAux.I b/panda/src/egg/eggVertexAux.I index 40a41e26ac..0ff1966d46 100644 --- a/panda/src/egg/eggVertexAux.I +++ b/panda/src/egg/eggVertexAux.I @@ -15,7 +15,7 @@ * */ INLINE void EggVertexAux:: -set_name(const string &name) { +set_name(const std::string &name) { Namable::set_name(name); } diff --git a/panda/src/egg/eggVertexAux.h b/panda/src/egg/eggVertexAux.h index b0338cdec3..20c80dd531 100644 --- a/panda/src/egg/eggVertexAux.h +++ b/panda/src/egg/eggVertexAux.h @@ -29,12 +29,12 @@ */ class EXPCL_PANDAEGG EggVertexAux : public EggNamedObject { PUBLISHED: - explicit EggVertexAux(const string &name, const LVecBase4d &aux); + explicit EggVertexAux(const std::string &name, const LVecBase4d &aux); EggVertexAux(const EggVertexAux ©); EggVertexAux &operator = (const EggVertexAux ©); virtual ~EggVertexAux(); - INLINE void set_name(const string &name); + INLINE void set_name(const std::string &name); INLINE const LVecBase4d &get_aux() const; INLINE void set_aux(const LVecBase4d &aux); @@ -42,7 +42,7 @@ PUBLISHED: static PT(EggVertexAux) make_average(const EggVertexAux *first, const EggVertexAux *second); - void write(ostream &out, int indent_level) const; + void write(std::ostream &out, int indent_level) const; int compare_to(const EggVertexAux &other) const; private: diff --git a/panda/src/egg/eggVertexPool.h b/panda/src/egg/eggVertexPool.h index 2b44ad38d2..dd8672abb4 100644 --- a/panda/src/egg/eggVertexPool.h +++ b/panda/src/egg/eggVertexPool.h @@ -65,7 +65,7 @@ public: // Here begins the actual public interface to EggVertexPool. PUBLISHED: - explicit EggVertexPool(const string &name); + explicit EggVertexPool(const std::string &name); EggVertexPool(const EggVertexPool ©); ~EggVertexPool(); @@ -129,7 +129,7 @@ PUBLISHED: void transform(const LMatrix4d &mat); void sort_by_external_index(); - void write(ostream &out, int indent_level) const; + void write(std::ostream &out, int indent_level) const; protected: virtual void r_transform(const LMatrix4d &mat, const LMatrix4d &inv, diff --git a/panda/src/egg/eggVertexUV.I b/panda/src/egg/eggVertexUV.I index 4eb9983d21..05f6f8609f 100644 --- a/panda/src/egg/eggVertexUV.I +++ b/panda/src/egg/eggVertexUV.I @@ -16,10 +16,10 @@ * Usually this is the same string that is input, but for historical reasons * the texture coordinate name "default" is mapped to the empty string. */ -INLINE string EggVertexUV:: -filter_name(const string &name) { +INLINE std::string EggVertexUV:: +filter_name(const std::string &name) { if (name == "default") { - return string(); + return std::string(); } return name; } @@ -28,7 +28,7 @@ filter_name(const string &name) { * */ INLINE void EggVertexUV:: -set_name(const string &name) { +set_name(const std::string &name) { Namable::set_name(filter_name(name)); } diff --git a/panda/src/egg/eggVertexUV.h b/panda/src/egg/eggVertexUV.h index 21b6e5b7c2..2483432aa9 100644 --- a/panda/src/egg/eggVertexUV.h +++ b/panda/src/egg/eggVertexUV.h @@ -28,14 +28,14 @@ */ class EXPCL_PANDAEGG EggVertexUV : public EggNamedObject { PUBLISHED: - explicit EggVertexUV(const string &name, const LTexCoordd &uv); - explicit EggVertexUV(const string &name, const LTexCoord3d &uvw); + explicit EggVertexUV(const std::string &name, const LTexCoordd &uv); + explicit EggVertexUV(const std::string &name, const LTexCoord3d &uvw); EggVertexUV(const EggVertexUV ©); EggVertexUV &operator = (const EggVertexUV ©); virtual ~EggVertexUV(); - INLINE static string filter_name(const string &name); - INLINE void set_name(const string &name); + INLINE static std::string filter_name(const std::string &name); + INLINE void set_name(const std::string &name); INLINE int get_num_dimensions() const; INLINE bool has_w() const; @@ -59,7 +59,7 @@ PUBLISHED: void transform(const LMatrix4d &mat); - void write(ostream &out, int indent_level) const; + void write(std::ostream &out, int indent_level) const; int compare_to(const EggVertexUV &other) const; EggMorphTexCoordList _duvs; diff --git a/panda/src/egg/eggXfmAnimData.I b/panda/src/egg/eggXfmAnimData.I index 41bbaaa103..92a888a3c6 100644 --- a/panda/src/egg/eggXfmAnimData.I +++ b/panda/src/egg/eggXfmAnimData.I @@ -15,7 +15,7 @@ * */ INLINE EggXfmAnimData:: -EggXfmAnimData(const string &name, CoordinateSystem cs) : EggAnimData(name) { +EggXfmAnimData(const std::string &name, CoordinateSystem cs) : EggAnimData(name) { _coordsys = cs; } @@ -50,7 +50,7 @@ operator = (const EggXfmAnimData ©) { * */ INLINE void EggXfmAnimData:: -set_order(const string &order) { +set_order(const std::string &order) { _order = order; } @@ -73,7 +73,7 @@ has_order() const { /** * */ -INLINE const string &EggXfmAnimData:: +INLINE const std::string &EggXfmAnimData:: get_order() const { if (has_order()) { return _order; @@ -87,7 +87,7 @@ get_order() const { * the order string must be set to in order to use set_value() or add_data() * successfully. */ -INLINE const string &EggXfmAnimData:: +INLINE const std::string &EggXfmAnimData:: get_standard_order() { return EggXfmSAnim::get_standard_order(); } @@ -97,7 +97,7 @@ get_standard_order() { * */ INLINE void EggXfmAnimData:: -set_contents(const string &contents) { +set_contents(const std::string &contents) { _contents = contents; } @@ -120,7 +120,7 @@ has_contents() const { /** * */ -INLINE const string &EggXfmAnimData:: +INLINE const std::string &EggXfmAnimData:: get_contents() const { return _contents; } diff --git a/panda/src/egg/eggXfmAnimData.h b/panda/src/egg/eggXfmAnimData.h index dac7762931..412b586b73 100644 --- a/panda/src/egg/eggXfmAnimData.h +++ b/panda/src/egg/eggXfmAnimData.h @@ -28,23 +28,23 @@ */ class EXPCL_PANDAEGG EggXfmAnimData : public EggAnimData { PUBLISHED: - INLINE explicit EggXfmAnimData(const string &name = "", + INLINE explicit EggXfmAnimData(const std::string &name = "", CoordinateSystem cs = CS_default); EggXfmAnimData(const EggXfmSAnim &convert_from); INLINE EggXfmAnimData(const EggXfmAnimData ©); INLINE EggXfmAnimData &operator = (const EggXfmAnimData ©); - INLINE void set_order(const string &order); + INLINE void set_order(const std::string &order); INLINE void clear_order(); INLINE bool has_order() const; - INLINE const string &get_order() const; - INLINE static const string &get_standard_order(); + INLINE const std::string &get_order() const; + INLINE static const std::string &get_standard_order(); - INLINE void set_contents(const string &contents); + INLINE void set_contents(const std::string &contents); INLINE void clear_contents(); INLINE bool has_contents() const; - INLINE const string &get_contents() const; + INLINE const std::string &get_contents() const; INLINE CoordinateSystem get_coordinate_system() const; @@ -55,7 +55,7 @@ PUBLISHED: void get_value(int row, LMatrix4d &mat) const; virtual bool is_anim_matrix() const; - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; protected: virtual void r_transform(const LMatrix4d &mat, const LMatrix4d &inv, @@ -63,8 +63,8 @@ protected: virtual void r_mark_coordsys(CoordinateSystem cs); private: - string _order; - string _contents; + std::string _order; + std::string _contents; CoordinateSystem _coordsys; public: diff --git a/panda/src/egg/eggXfmSAnim.I b/panda/src/egg/eggXfmSAnim.I index a16a7ef2cb..62ba430096 100644 --- a/panda/src/egg/eggXfmSAnim.I +++ b/panda/src/egg/eggXfmSAnim.I @@ -15,7 +15,7 @@ * */ INLINE EggXfmSAnim:: -EggXfmSAnim(const string &name, CoordinateSystem cs) : EggGroupNode(name) { +EggXfmSAnim(const std::string &name, CoordinateSystem cs) : EggGroupNode(name) { _has_fps = false; _coordsys = cs; } @@ -88,7 +88,7 @@ get_fps() const { * */ INLINE void EggXfmSAnim:: -set_order(const string &order) { +set_order(const std::string &order) { _order = order; } @@ -111,7 +111,7 @@ has_order() const { /** * */ -INLINE const string &EggXfmSAnim:: +INLINE const std::string &EggXfmSAnim:: get_order() const { if (has_order()) { return _order; @@ -125,7 +125,7 @@ get_order() const { * the order string must be set to in order to use set_value() or add_data() * successfully. */ -INLINE const string &EggXfmSAnim:: +INLINE const std::string &EggXfmSAnim:: get_standard_order() { return _standard_order; } diff --git a/panda/src/egg/eggXfmSAnim.h b/panda/src/egg/eggXfmSAnim.h index eae0349559..508f0cd67d 100644 --- a/panda/src/egg/eggXfmSAnim.h +++ b/panda/src/egg/eggXfmSAnim.h @@ -27,7 +27,7 @@ class EggXfmAnimData; */ class EXPCL_PANDAEGG EggXfmSAnim : public EggGroupNode { PUBLISHED: - INLINE explicit EggXfmSAnim(const string &name = "", + INLINE explicit EggXfmSAnim(const std::string &name = "", CoordinateSystem cs = CS_default); EggXfmSAnim(const EggXfmAnimData &convert_from); @@ -39,11 +39,11 @@ PUBLISHED: INLINE bool has_fps() const; INLINE double get_fps() const; - INLINE void set_order(const string &order); + INLINE void set_order(const std::string &order); INLINE void clear_order(); INLINE bool has_order() const; - INLINE const string &get_order() const; - INLINE static const string &get_standard_order(); + INLINE const std::string &get_order() const; + INLINE static const std::string &get_standard_order(); INLINE CoordinateSystem get_coordinate_system() const; @@ -57,18 +57,18 @@ PUBLISHED: INLINE void clear_data(); bool add_data(const LMatrix4d &mat); - void add_component_data(const string &component_name, double value); + void add_component_data(const std::string &component_name, double value); void add_component_data(int component, double value); virtual bool is_anim_matrix() const; - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; static void compose_with_order(LMatrix4d &mat, const LVecBase3d &scale, const LVecBase3d &shear, const LVecBase3d &hpr, const LVecBase3d &trans, - const string &order, + const std::string &order, CoordinateSystem cs); protected: @@ -84,10 +84,10 @@ private: private: double _fps; bool _has_fps; - string _order; + std::string _order; CoordinateSystem _coordsys; - static const string _standard_order; + static const std::string _standard_order; public: diff --git a/panda/src/egg/lexerDefs.h b/panda/src/egg/lexerDefs.h index 0337830028..4e39cb0b10 100644 --- a/panda/src/egg/lexerDefs.h +++ b/panda/src/egg/lexerDefs.h @@ -20,18 +20,18 @@ #include -void egg_init_lexer(istream &in, const string &filename); +void egg_init_lexer(std::istream &in, const std::string &filename); void egg_start_group_body(); void egg_start_texture_body(); void egg_start_primitive_body(); int egg_error_count(); int egg_warning_count(); -void eggyyerror(const string &msg); -void eggyyerror(ostringstream &strm); +void eggyyerror(const std::string &msg); +void eggyyerror(std::ostringstream &strm); -void eggyywarning(const string &msg); -void eggyywarning(ostringstream &strm); +void eggyywarning(const std::string &msg); +void eggyywarning(std::ostringstream &strm); int eggyylex(); diff --git a/panda/src/egg/parserDefs.h b/panda/src/egg/parserDefs.h index b0938d567d..df91568015 100644 --- a/panda/src/egg/parserDefs.h +++ b/panda/src/egg/parserDefs.h @@ -29,7 +29,7 @@ class LightMutex; extern LightMutex egg_lock; -void egg_init_parser(istream &in, const string &filename, +void egg_init_parser(std::istream &in, const std::string &filename, EggObject *tos, EggGroupNode *egg_top_node); void egg_cleanup_parser(); @@ -44,7 +44,7 @@ class EXPCL_PANDAEGG EggTokenType { public: double _number; unsigned long _ulong; - string _string; + std::string _string; PT(EggObject) _egg; PTA_double _number_list; }; diff --git a/panda/src/egg2pg/animBundleMaker.h b/panda/src/egg2pg/animBundleMaker.h index fa95030718..62a8e1f7bf 100644 --- a/panda/src/egg2pg/animBundleMaker.h +++ b/panda/src/egg2pg/animBundleMaker.h @@ -45,13 +45,13 @@ private: void build_hierarchy(EggTable *egg_table, AnimGroup *parent); AnimChannelScalarTable * - create_s_channel(EggSAnimData *egg_anim, const string &name, + create_s_channel(EggSAnimData *egg_anim, const std::string &name, AnimGroup *parent); AnimChannelMatrixXfmTable * - create_xfm_channel(EggNode *egg_node, const string &name, + create_xfm_channel(EggNode *egg_node, const std::string &name, AnimGroup *parent); AnimChannelMatrixXfmTable * - create_xfm_channel(EggXfmSAnim *egg_anim, const string &name, + create_xfm_channel(EggXfmSAnim *egg_anim, const std::string &name, AnimGroup *parent); PN_stdfloat _fps; diff --git a/panda/src/egg2pg/characterMaker.h b/panda/src/egg2pg/characterMaker.h index b2309c0be7..466f890f36 100644 --- a/panda/src/egg2pg/characterMaker.h +++ b/panda/src/egg2pg/characterMaker.h @@ -48,14 +48,14 @@ public: Character *make_node(); - string get_name() const; + std::string get_name() const; PartGroup *egg_to_part(EggNode *egg_node) const; VertexTransform *egg_to_transform(EggNode *egg_node); int egg_to_index(EggNode *egg_node) const; - PandaNode *part_to_node(PartGroup *part, const string &name) const; + PandaNode *part_to_node(PartGroup *part, const std::string &name) const; - int create_slider(const string &name); - VertexSlider *egg_to_slider(const string &name); + int create_slider(const std::string &name); + VertexSlider *egg_to_slider(const std::string &name); private: CharacterJointBundle *make_bundle(); @@ -78,7 +78,7 @@ private: VertexTransforms _vertex_transforms; PT(VertexTransform) _identity_transform; - typedef pmap VertexSliders; + typedef pmap VertexSliders; VertexSliders _vertex_sliders; EggLoader &_loader; diff --git a/panda/src/egg2pg/eggBinner.h b/panda/src/egg2pg/eggBinner.h index a259e522d9..a7e3c10894 100644 --- a/panda/src/egg2pg/eggBinner.h +++ b/panda/src/egg2pg/eggBinner.h @@ -47,7 +47,7 @@ public: virtual int get_bin_number(const EggNode *node); - virtual string + virtual std::string get_bin_name(int bin_number, const EggNode *child); virtual bool diff --git a/panda/src/egg2pg/eggLoader.h b/panda/src/egg2pg/eggLoader.h index 504028432e..aa36475e05 100644 --- a/panda/src/egg2pg/eggLoader.h +++ b/panda/src/egg2pg/eggLoader.h @@ -147,7 +147,7 @@ private: CharacterMaker *character_maker); void record_morph (GeomVertexArrayFormat *array_format, - CharacterMaker *character_maker, const string &morph_name, + CharacterMaker *character_maker, const std::string &morph_name, InternalName *column_name, int num_components); void make_primitive(const EggRenderState *render_state, @@ -200,11 +200,11 @@ private: void apply_deferred_nodes(PandaNode *node, const DeferredNodeProperty &prop); bool expand_all_object_types(EggNode *egg_node); - bool expand_object_types(EggGroup *egg_group, const pset &expanded, - const pvector &expanded_history); - bool do_expand_object_type(EggGroup *egg_group, const pset &expanded, - const pvector &expanded_history, - const string &object_type); + bool expand_object_types(EggGroup *egg_group, const pset &expanded, + const pvector &expanded_history); + bool do_expand_object_type(EggGroup *egg_group, const pset &expanded, + const pvector &expanded_history, + const std::string &object_type); static TextureStage::CombineMode get_combine_mode(const EggTexture *egg_tex, diff --git a/panda/src/egg2pg/eggSaver.h b/panda/src/egg2pg/eggSaver.h index bd2905398f..8041d346cc 100644 --- a/panda/src/egg2pg/eggSaver.h +++ b/panda/src/egg2pg/eggSaver.h @@ -59,7 +59,7 @@ PUBLISHED: INLINE EggData *get_egg_data() const; private: - typedef pmap > > CharacterJointMap; + typedef pmap > > CharacterJointMap; void convert_node(const WorkingNodePath &node_path, EggGroupNode *egg_parent, bool has_decal, CharacterJointMap *joint_map); @@ -95,7 +95,7 @@ private: bool apply_node_properties(EggGroup *egg_group, PandaNode *node, bool allow_backstage = true); bool apply_state_properties(EggRenderMode *egg_render_mode, const RenderState *state); bool apply_tags(EggGroup *egg_group, PandaNode *node); - bool apply_tag(EggGroup *egg_group, PandaNode *node, const string &tag); + bool apply_tag(EggGroup *egg_group, PandaNode *node, const std::string &tag); EggMaterial *get_egg_material(Material *tex); EggTexture *get_egg_texture(Texture *tex); diff --git a/panda/src/egg2pg/loaderFileTypeEgg.h b/panda/src/egg2pg/loaderFileTypeEgg.h index b1c9c00e7b..a0ca9474ed 100644 --- a/panda/src/egg2pg/loaderFileTypeEgg.h +++ b/panda/src/egg2pg/loaderFileTypeEgg.h @@ -25,8 +25,8 @@ class EXPCL_PANDAEGG LoaderFileTypeEgg : public LoaderFileType { public: LoaderFileTypeEgg(); - virtual string get_name() const; - virtual string get_extension() const; + virtual std::string get_name() const; + virtual std::string get_extension() const; virtual bool supports_compressed() const; virtual bool supports_load() const; diff --git a/panda/src/egldisplay/config_egldisplay.h b/panda/src/egldisplay/config_egldisplay.h index 2df5bcc1f4..40e30893b8 100644 --- a/panda/src/egldisplay/config_egldisplay.h +++ b/panda/src/egldisplay/config_egldisplay.h @@ -31,12 +31,12 @@ NotifyCategoryDecl(egldisplay, EXPCL_PANDAGLES2, EXPTP_PANDAGLES2); extern EXPCL_PANDAGLES2 void init_libegldisplay(); - extern EXPCL_PANDAGLES2 const string get_egl_error_string(int error); + extern EXPCL_PANDAGLES2 const std::string get_egl_error_string(int error); #else NotifyCategoryDecl(egldisplay, EXPCL_PANDAGLES, EXPTP_PANDAGLES); extern EXPCL_PANDAGLES void init_libegldisplay(); - extern EXPCL_PANDAGLES const string get_egl_error_string(int error); + extern EXPCL_PANDAGLES const std::string get_egl_error_string(int error); #endif #endif diff --git a/panda/src/egldisplay/eglGraphicsBuffer.h b/panda/src/egldisplay/eglGraphicsBuffer.h index 7bed62cb83..68697ef94c 100644 --- a/panda/src/egldisplay/eglGraphicsBuffer.h +++ b/panda/src/egldisplay/eglGraphicsBuffer.h @@ -25,7 +25,7 @@ class eglGraphicsBuffer : public GraphicsBuffer { public: eglGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/egldisplay/eglGraphicsPipe.h b/panda/src/egldisplay/eglGraphicsPipe.h index aea34925e6..aebd9c70e1 100644 --- a/panda/src/egldisplay/eglGraphicsPipe.h +++ b/panda/src/egldisplay/eglGraphicsPipe.h @@ -44,14 +44,14 @@ class eglGraphicsWindow; */ class eglGraphicsPipe : public x11GraphicsPipe { public: - eglGraphicsPipe(const string &display = string()); + eglGraphicsPipe(const std::string &display = std::string()); virtual ~eglGraphicsPipe(); - virtual string get_interface_name() const; + virtual std::string get_interface_name() const; static PT(GraphicsPipe) pipe_constructor(); protected: - virtual PT(GraphicsOutput) make_output(const string &name, + virtual PT(GraphicsOutput) make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/egldisplay/eglGraphicsPixmap.h b/panda/src/egldisplay/eglGraphicsPixmap.h index cbd132c1ac..ed7e7f90e9 100644 --- a/panda/src/egldisplay/eglGraphicsPixmap.h +++ b/panda/src/egldisplay/eglGraphicsPixmap.h @@ -27,7 +27,7 @@ class eglGraphicsPixmap : public GraphicsBuffer { public: eglGraphicsPixmap(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/egldisplay/eglGraphicsWindow.h b/panda/src/egldisplay/eglGraphicsWindow.h index 508365cc65..7647605fd3 100644 --- a/panda/src/egldisplay/eglGraphicsWindow.h +++ b/panda/src/egldisplay/eglGraphicsWindow.h @@ -25,7 +25,7 @@ class eglGraphicsWindow : public x11GraphicsWindow { public: eglGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/event/asyncFuture.I b/panda/src/event/asyncFuture.I index 960ce56b49..bc46e17c9b 100644 --- a/panda/src/event/asyncFuture.I +++ b/panda/src/event/asyncFuture.I @@ -44,7 +44,7 @@ cancelled() const { * a coroutine task that exits with an exception. */ INLINE void AsyncFuture:: -set_done_event(const string &done_event) { +set_done_event(const std::string &done_event) { nassertv(!done()); _done_event = done_event; } @@ -53,7 +53,7 @@ set_done_event(const string &done_event) { * Returns the event name that will be triggered when the future finishes. * See set_done_event(). */ -INLINE const string &AsyncFuture:: +INLINE const std::string &AsyncFuture:: get_done_event() const { return _done_event; } @@ -129,7 +129,7 @@ gather(Futures futures) { } else if (futures.size() == 1) { return futures[0].p(); } else { - return (AsyncFuture *)new AsyncGatheringFuture(move(futures)); + return (AsyncFuture *)new AsyncGatheringFuture(std::move(futures)); } } diff --git a/panda/src/event/asyncFuture.h b/panda/src/event/asyncFuture.h index 5349ced637..27cab7b585 100644 --- a/panda/src/event/asyncFuture.h +++ b/panda/src/event/asyncFuture.h @@ -70,15 +70,15 @@ PUBLISHED: virtual bool cancel(); - INLINE void set_done_event(const string &done_event); - INLINE const string &get_done_event() const; + INLINE void set_done_event(const std::string &done_event); + INLINE const std::string &get_done_event() const; MAKE_PROPERTY(done_event, get_done_event, set_done_event); EXTENSION(PyObject *add_done_callback(PyObject *self, PyObject *fn)); EXTENSION(static PyObject *gather(PyObject *args)); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; BLOCKING void wait(); BLOCKING void wait(double timeout); @@ -125,7 +125,7 @@ protected: PT(ReferenceCount) _result_ref; AtomicAdjust::Integer _future_state; - string _done_event; + std::string _done_event; // Tasks and gathering futures waiting for this one to complete. Futures _waiting; @@ -152,7 +152,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const AsyncFuture &fut) { +INLINE std::ostream &operator << (std::ostream &out, const AsyncFuture &fut) { fut.output(out); return out; }; diff --git a/panda/src/event/asyncTask.I b/panda/src/event/asyncTask.I index 869b0b33f7..c9cdbeb179 100644 --- a/panda/src/event/asyncTask.I +++ b/panda/src/event/asyncTask.I @@ -131,7 +131,7 @@ get_start_frame() const { */ INLINE void AsyncTask:: clear_name() { - set_name(string()); + set_name(std::string()); } /** @@ -147,7 +147,7 @@ get_task_id() const { * Returns the AsyncTaskChain on which this task will be running. Each task * chain runs tasks independently of the others. */ -INLINE const string &AsyncTask:: +INLINE const std::string &AsyncTask:: get_task_chain() const { return _chain_name; } @@ -176,7 +176,7 @@ get_priority() const { * returns S_inactive). */ INLINE void AsyncTask:: -set_done_event(const string &done_event) { +set_done_event(const std::string &done_event) { nassertv(_state == S_inactive); _done_event = done_event; } diff --git a/panda/src/event/asyncTask.h b/panda/src/event/asyncTask.h index e36c3c8324..f5871ae2f2 100644 --- a/panda/src/event/asyncTask.h +++ b/panda/src/event/asyncTask.h @@ -31,7 +31,7 @@ class AsyncTaskChain; */ class EXPCL_PANDA_EVENT AsyncTask : public AsyncFuture, public Namable { public: - AsyncTask(const string &name = string()); + AsyncTask(const std::string &name = std::string()); ALLOC_DELETED_CHAIN(AsyncTask); PUBLISHED: @@ -76,14 +76,14 @@ PUBLISHED: INLINE int get_start_frame() const; int get_elapsed_frames() const; - void set_name(const string &name); + void set_name(const std::string &name); INLINE void clear_name(); - string get_name_prefix() const; + std::string get_name_prefix() const; INLINE AtomicAdjust::Integer get_task_id() const; - void set_task_chain(const string &chain_name); - INLINE const string &get_task_chain() const; + void set_task_chain(const std::string &chain_name); + INLINE const std::string &get_task_chain() const; void set_sort(int sort); INLINE int get_sort() const; @@ -91,13 +91,13 @@ PUBLISHED: void set_priority(int priority); INLINE int get_priority() const; - INLINE void set_done_event(const string &done_event); + INLINE void set_done_event(const std::string &done_event); INLINE double get_dt() const; INLINE double get_max_dt() const; INLINE double get_average_dt() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: void jump_to_task_chain(AsyncTaskManager *manager); @@ -113,7 +113,7 @@ protected: protected: AtomicAdjust::Integer _task_id; - string _chain_name; + std::string _chain_name; double _delay; bool _has_delay; double _wake_time; @@ -163,7 +163,7 @@ private: friend class AsyncTaskSequence; }; -INLINE ostream &operator << (ostream &out, const AsyncTask &task) { +INLINE std::ostream &operator << (std::ostream &out, const AsyncTask &task) { task.output(out); return out; }; diff --git a/panda/src/event/asyncTaskChain.h b/panda/src/event/asyncTaskChain.h index 5f81f6c3dd..c211b30c85 100644 --- a/panda/src/event/asyncTaskChain.h +++ b/panda/src/event/asyncTaskChain.h @@ -49,7 +49,7 @@ class AsyncTaskManager; */ class EXPCL_PANDA_EVENT AsyncTaskChain : public TypedReferenceCount, public Namable { public: - AsyncTaskChain(AsyncTaskManager *manager, const string &name); + AsyncTaskChain(AsyncTaskManager *manager, const std::string &name); ~AsyncTaskChain(); PUBLISHED: @@ -88,8 +88,8 @@ PUBLISHED: void poll(); double get_next_wake_time() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; protected: class AsyncTaskChainThread; @@ -115,15 +115,15 @@ protected: void cleanup_pickup_mode(); INLINE double do_get_next_wake_time() const; static INLINE double get_wake_time(AsyncTask *task); - void do_output(ostream &out) const; - void do_write(ostream &out, int indent_level) const; + void do_output(std::ostream &out) const; + void do_write(std::ostream &out, int indent_level) const; - void write_task_line(ostream &out, int indent_level, AsyncTask *task, double now) const; + void write_task_line(std::ostream &out, int indent_level, AsyncTask *task, double now) const; protected: class AsyncTaskChainThread : public Thread { public: - AsyncTaskChainThread(const string &name, AsyncTaskChain *chain); + AsyncTaskChainThread(const std::string &name, AsyncTaskChain *chain); virtual void thread_main(); AsyncTaskChain *_chain; @@ -220,7 +220,7 @@ private: friend class AsyncTaskSortWakeTime; }; -INLINE ostream &operator << (ostream &out, const AsyncTaskChain &chain) { +INLINE std::ostream &operator << (std::ostream &out, const AsyncTaskChain &chain) { chain.output(out); return out; }; diff --git a/panda/src/event/asyncTaskCollection.h b/panda/src/event/asyncTaskCollection.h index 70918bc49f..a2334df839 100644 --- a/panda/src/event/asyncTaskCollection.h +++ b/panda/src/event/asyncTaskCollection.h @@ -39,7 +39,7 @@ PUBLISHED: bool has_task(AsyncTask *task) const; void clear(); - AsyncTask *find_task(const string &name) const; + AsyncTask *find_task(const std::string &name) const; size_t get_num_tasks() const; AsyncTask *get_task(size_t index) const; @@ -50,15 +50,15 @@ PUBLISHED: INLINE void operator += (const AsyncTaskCollection &other); INLINE AsyncTaskCollection operator + (const AsyncTaskCollection &other) const; - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; private: typedef PTA(PT(AsyncTask)) AsyncTasks; AsyncTasks _tasks; }; -INLINE ostream &operator << (ostream &out, const AsyncTaskCollection &col) { +INLINE std::ostream &operator << (std::ostream &out, const AsyncTaskCollection &col) { col.output(out); return out; } diff --git a/panda/src/event/asyncTaskManager.h b/panda/src/event/asyncTaskManager.h index d843508de7..69711ab6f6 100644 --- a/panda/src/event/asyncTaskManager.h +++ b/panda/src/event/asyncTaskManager.h @@ -47,7 +47,7 @@ */ class EXPCL_PANDA_EVENT AsyncTaskManager : public TypedReferenceCount, public Namable { PUBLISHED: - explicit AsyncTaskManager(const string &name); + explicit AsyncTaskManager(const std::string &name); BLOCKING virtual ~AsyncTaskManager(); BLOCKING void cleanup(); @@ -59,15 +59,15 @@ PUBLISHED: int get_num_task_chains() const; AsyncTaskChain *get_task_chain(int n) const; MAKE_SEQ(get_task_chains, get_num_task_chains, get_task_chain); - AsyncTaskChain *make_task_chain(const string &name); - AsyncTaskChain *find_task_chain(const string &name); - BLOCKING bool remove_task_chain(const string &name); + AsyncTaskChain *make_task_chain(const std::string &name); + AsyncTaskChain *find_task_chain(const std::string &name); + BLOCKING bool remove_task_chain(const std::string &name); void add(AsyncTask *task); bool has_task(AsyncTask *task) const; - AsyncTask *find_task(const string &name) const; - AsyncTaskCollection find_tasks(const string &name) const; + AsyncTask *find_task(const std::string &name) const; + AsyncTaskCollection find_tasks(const std::string &name) const; AsyncTaskCollection find_tasks_matching(const GlobPattern &pattern) const; bool remove(AsyncTask *task); @@ -90,21 +90,21 @@ PUBLISHED: double get_next_wake_time() const; MAKE_PROPERTY(next_wake_time, get_next_wake_time); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; INLINE static AsyncTaskManager *get_global_ptr(); protected: - AsyncTaskChain *do_make_task_chain(const string &name); - AsyncTaskChain *do_find_task_chain(const string &name); + AsyncTaskChain *do_make_task_chain(const std::string &name); + AsyncTaskChain *do_find_task_chain(const std::string &name); INLINE void add_task_by_name(AsyncTask *task); void remove_task_by_name(AsyncTask *task); bool do_has_task(AsyncTask *task) const; - virtual void do_output(ostream &out) const; + virtual void do_output(std::ostream &out) const; private: static void make_global_ptr(); @@ -159,7 +159,7 @@ private: friend class PythonTask; }; -INLINE ostream &operator << (ostream &out, const AsyncTaskManager &manager) { +INLINE std::ostream &operator << (std::ostream &out, const AsyncTaskManager &manager) { manager.output(out); return out; }; diff --git a/panda/src/event/asyncTaskSequence.h b/panda/src/event/asyncTaskSequence.h index de0127a1d8..3d1c4cc450 100644 --- a/panda/src/event/asyncTaskSequence.h +++ b/panda/src/event/asyncTaskSequence.h @@ -32,7 +32,7 @@ class AsyncTaskManager; */ class EXPCL_PANDA_EVENT AsyncTaskSequence : public AsyncTask, public AsyncTaskCollection { PUBLISHED: - explicit AsyncTaskSequence(const string &name); + explicit AsyncTaskSequence(const std::string &name); virtual ~AsyncTaskSequence(); ALLOC_DELETED_CHAIN(AsyncTaskSequence); diff --git a/panda/src/event/buttonEvent.I b/panda/src/event/buttonEvent.I index 41bea9f2d5..f082a4bee9 100644 --- a/panda/src/event/buttonEvent.I +++ b/panda/src/event/buttonEvent.I @@ -55,7 +55,7 @@ ButtonEvent(int keycode, double time) : * */ INLINE ButtonEvent:: -ButtonEvent(const wstring &candidate_string, size_t highlight_start, +ButtonEvent(const std::wstring &candidate_string, size_t highlight_start, size_t highlight_end, size_t cursor_pos) : _button(ButtonHandle::none()), _keycode(0), diff --git a/panda/src/event/buttonEvent.h b/panda/src/event/buttonEvent.h index d2e2b82176..e839924c48 100644 --- a/panda/src/event/buttonEvent.h +++ b/panda/src/event/buttonEvent.h @@ -87,7 +87,7 @@ public: INLINE ButtonEvent(); INLINE ButtonEvent(ButtonHandle button, Type type, double time = ClockObject::get_global_clock()->get_frame_time()); INLINE ButtonEvent(int keycode, double time = ClockObject::get_global_clock()->get_frame_time()); - INLINE ButtonEvent(const wstring &candidate_string, size_t highlight_start, + INLINE ButtonEvent(const std::wstring &candidate_string, size_t highlight_start, size_t highlight_end, size_t cursor_pos); INLINE ButtonEvent(const ButtonEvent ©); INLINE void operator = (const ButtonEvent ©); @@ -98,7 +98,7 @@ public: INLINE bool update_mods(ModifierButtons &mods) const; - void output(ostream &out) const; + void output(std::ostream &out) const; void write_datagram(Datagram &dg) const; void read_datagram(DatagramIterator &scan); @@ -112,7 +112,7 @@ public: int _keycode; // _candidate_string will be filled in if type is T_candidate. - wstring _candidate_string; + std::wstring _candidate_string; size_t _highlight_start; size_t _highlight_end; size_t _cursor_pos; @@ -127,7 +127,7 @@ public: double _time; }; -INLINE ostream &operator << (ostream &out, const ButtonEvent &be) { +INLINE std::ostream &operator << (std::ostream &out, const ButtonEvent &be) { be.output(out); return out; } diff --git a/panda/src/event/buttonEventList.h b/panda/src/event/buttonEventList.h index d4f097f98d..c9d9479490 100644 --- a/panda/src/event/buttonEventList.h +++ b/panda/src/event/buttonEventList.h @@ -44,8 +44,8 @@ public: void add_events(const ButtonEventList &other); void update_mods(ModifierButtons &mods) const; - virtual void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; private: typedef pvector Events; @@ -79,7 +79,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const ButtonEventList &buttonlist) { +INLINE std::ostream &operator << (std::ostream &out, const ButtonEventList &buttonlist) { buttonlist.output(out); return out; } diff --git a/panda/src/event/event.I b/panda/src/event/event.I index dd2b0e95f6..fd60e3e10f 100644 --- a/panda/src/event/event.I +++ b/panda/src/event/event.I @@ -15,7 +15,7 @@ * */ INLINE void Event:: -set_name(const string &name) { +set_name(const std::string &name) { _name = name; } @@ -39,13 +39,13 @@ has_name() const { /** * */ -INLINE const string &Event:: +INLINE const std::string &Event:: get_name() const { return _name; } -INLINE ostream &operator << (ostream &out, const Event &n) { +INLINE std::ostream &operator << (std::ostream &out, const Event &n) { n.output(out); return out; } diff --git a/panda/src/event/event.h b/panda/src/event/event.h index 383329e233..beb13f0b11 100644 --- a/panda/src/event/event.h +++ b/panda/src/event/event.h @@ -32,15 +32,15 @@ class EventReceiver; */ class EXPCL_PANDA_EVENT Event : public TypedReferenceCount { PUBLISHED: - Event(const string &event_name, EventReceiver *receiver = nullptr); + Event(const std::string &event_name, EventReceiver *receiver = nullptr); Event(const Event ©); void operator = (const Event ©); ~Event(); - INLINE void set_name(const string &name); + INLINE void set_name(const std::string &name); INLINE void clear_name(); INLINE bool has_name() const; - INLINE const string &get_name() const; + INLINE const std::string &get_name() const; void add_parameter(const EventParameter &obj); @@ -53,7 +53,7 @@ PUBLISHED: void set_receiver(EventReceiver *receiver); void clear_receiver(); - void output(ostream &out) const; + void output(std::ostream &out) const; MAKE_PROPERTY(name, get_name, set_name); MAKE_SEQ_PROPERTY(parameters, get_num_parameters, get_parameter); @@ -65,7 +65,7 @@ protected: EventReceiver *_receiver; private: - string _name; + std::string _name; public: static TypeHandle get_class_type() { @@ -85,7 +85,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const Event &n); +INLINE std::ostream &operator << (std::ostream &out, const Event &n); #include "event.I" diff --git a/panda/src/event/eventHandler.h b/panda/src/event/eventHandler.h index cefba2710f..8e616f1581 100644 --- a/panda/src/event/eventHandler.h +++ b/panda/src/event/eventHandler.h @@ -44,29 +44,29 @@ PUBLISHED: explicit EventHandler(EventQueue *ev_queue); ~EventHandler() {} - AsyncFuture *get_future(const string &event_name); + AsyncFuture *get_future(const std::string &event_name); void process_events(); virtual void dispatch_event(const Event *event); - void write(ostream &out) const; + void write(std::ostream &out) const; INLINE static EventHandler *get_global_event_handler(EventQueue *queue = nullptr); public: - bool add_hook(const string &event_name, EventFunction *function); - bool add_hook(const string &event_name, EventCallbackFunction *function, + bool add_hook(const std::string &event_name, EventFunction *function); + bool add_hook(const std::string &event_name, EventCallbackFunction *function, void *data); - bool has_hook(const string &event_name) const; - bool has_hook(const string &event_name, EventFunction *function) const; - bool has_hook(const string &event_name, EventCallbackFunction *function, + bool has_hook(const std::string &event_name) const; + bool has_hook(const std::string &event_name, EventFunction *function) const; + bool has_hook(const std::string &event_name, EventCallbackFunction *function, void *data) const; - bool remove_hook(const string &event_name, EventFunction *function); - bool remove_hook(const string &event_name, EventCallbackFunction *function, + bool remove_hook(const std::string &event_name, EventFunction *function); + bool remove_hook(const std::string &event_name, EventCallbackFunction *function, void *data); - bool remove_hooks(const string &event_name); + bool remove_hooks(const std::string &event_name); bool remove_hooks_with(void *data); void remove_all_hooks(); @@ -74,11 +74,11 @@ public: protected: typedef pset Functions; - typedef pmap Hooks; - typedef pair CallbackFunction; + typedef pmap Hooks; + typedef std::pair CallbackFunction; typedef pset CallbackFunctions; - typedef pmap CallbackHooks; - typedef pmap Futures; + typedef pmap CallbackHooks; + typedef pmap Futures; Hooks _hooks; CallbackHooks _cbhooks; @@ -89,8 +89,8 @@ protected: static void make_global_event_handler(); private: - void write_hook(ostream &out, const Hooks::value_type &hook) const; - void write_cbhook(ostream &out, const CallbackHooks::value_type &hook) const; + void write_hook(std::ostream &out, const Hooks::value_type &hook) const; + void write_cbhook(std::ostream &out, const CallbackHooks::value_type &hook) const; public: diff --git a/panda/src/event/eventParameter.I b/panda/src/event/eventParameter.I index 1aa1888017..1d3d168344 100644 --- a/panda/src/event/eventParameter.I +++ b/panda/src/event/eventParameter.I @@ -55,13 +55,13 @@ EventParameter(double value) : _ptr(new EventStoreDouble(value)) { } * Defines an EventParameter that stores a string value. */ INLINE EventParameter:: -EventParameter(const string &value) : _ptr(new EventStoreString(value)) { } +EventParameter(const std::string &value) : _ptr(new EventStoreString(value)) { } /** * Defines an EventParameter that stores a wstring value. */ INLINE EventParameter:: -EventParameter(const wstring &value) : _ptr(new EventStoreWstring(value)) { } +EventParameter(const std::wstring &value) : _ptr(new EventStoreWstring(value)) { } /** @@ -158,7 +158,7 @@ is_string() const { * Retrieves the value stored in the EventParameter. It is only valid to call * this if is_string() has already returned true. */ -INLINE string EventParameter:: +INLINE std::string EventParameter:: get_string_value() const { nassertr(is_string(), ""); return ((const EventStoreString *)_ptr.p())->get_value(); @@ -179,9 +179,9 @@ is_wstring() const { * Retrieves the value stored in the EventParameter. It is only valid to call * this if is_wstring() has already returned true. */ -INLINE wstring EventParameter:: +INLINE std::wstring EventParameter:: get_wstring_value() const { - nassertr(is_wstring(), wstring()); + nassertr(is_wstring(), std::wstring()); return ((const EventStoreWstring *)_ptr.p())->get_value(); } @@ -220,8 +220,8 @@ get_ptr() const { return _ptr; } -INLINE ostream & -operator << (ostream &out, const EventParameter ¶m) { +INLINE std::ostream & +operator << (std::ostream &out, const EventParameter ¶m) { param.output(out); return out; } diff --git a/panda/src/event/eventParameter.h b/panda/src/event/eventParameter.h index 8519c3c4d6..5f817fc149 100644 --- a/panda/src/event/eventParameter.h +++ b/panda/src/event/eventParameter.h @@ -40,8 +40,8 @@ PUBLISHED: INLINE EventParameter(const TypedReferenceCount *ptr); INLINE EventParameter(int value); INLINE EventParameter(double value); - INLINE EventParameter(const string &value); - INLINE EventParameter(const wstring &value); + INLINE EventParameter(const std::string &value); + INLINE EventParameter(const std::wstring &value); INLINE EventParameter(const EventParameter ©); INLINE EventParameter &operator = (const EventParameter ©); @@ -57,22 +57,22 @@ PUBLISHED: INLINE bool is_double() const; INLINE double get_double_value() const; INLINE bool is_string() const; - INLINE string get_string_value() const; + INLINE std::string get_string_value() const; INLINE bool is_wstring() const; - INLINE wstring get_wstring_value() const; + INLINE std::wstring get_wstring_value() const; INLINE bool is_typed_ref_count() const; INLINE TypedReferenceCount *get_typed_ref_count_value() const; INLINE TypedWritableReferenceCount *get_ptr() const; - void output(ostream &out) const; + void output(std::ostream &out) const; private: PT(TypedWritableReferenceCount) _ptr; }; -INLINE ostream &operator << (ostream &out, const EventParameter ¶m); +INLINE std::ostream &operator << (std::ostream &out, const EventParameter ¶m); typedef ParamTypedRefCount EventStoreTypedRefCount; diff --git a/panda/src/event/genericAsyncTask.h b/panda/src/event/genericAsyncTask.h index 6530a8112a..f35d780e3b 100644 --- a/panda/src/event/genericAsyncTask.h +++ b/panda/src/event/genericAsyncTask.h @@ -29,8 +29,8 @@ public: typedef void BirthFunc(GenericAsyncTask *task, void *user_data); typedef void DeathFunc(GenericAsyncTask *task, bool clean_exit, void *user_data); - GenericAsyncTask(const string &name = string()); - GenericAsyncTask(const string &name, TaskFunc *function, void *user_data); + GenericAsyncTask(const std::string &name = std::string()); + GenericAsyncTask(const std::string &name, TaskFunc *function, void *user_data); ALLOC_DELETED_CHAIN(GenericAsyncTask); INLINE void set_function(TaskFunc *function); diff --git a/panda/src/event/pointerEvent.h b/panda/src/event/pointerEvent.h index f69d8d4223..d98cc99989 100644 --- a/panda/src/event/pointerEvent.h +++ b/panda/src/event/pointerEvent.h @@ -34,7 +34,7 @@ public: INLINE bool operator != (const PointerEvent &other) const; INLINE bool operator < (const PointerEvent &other) const; - void output(ostream &out) const; + void output(std::ostream &out) const; void write_datagram(Datagram &dg) const; void read_datagram(DatagramIterator &scan); @@ -52,7 +52,7 @@ public: double _time; }; -INLINE ostream &operator << (ostream &out, const PointerEvent &pe) { +INLINE std::ostream &operator << (std::ostream &out, const PointerEvent &pe) { pe.output(out); return out; } diff --git a/panda/src/event/pointerEventList.h b/panda/src/event/pointerEventList.h index 7c2400c769..b9daf9ca4d 100644 --- a/panda/src/event/pointerEventList.h +++ b/panda/src/event/pointerEventList.h @@ -52,17 +52,17 @@ PUBLISHED: bool encircles(int x, int y) const; double total_turns(double sec) const; - double match_pattern(const string &pattern, double rot, double seglen); + double match_pattern(const std::string &pattern, double rot, double seglen); public: INLINE PointerEventList(const PointerEventList ©); INLINE void operator = (const PointerEventList ©); - virtual void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; private: - void parse_pattern(const string &ascpat, vector_double &pattern); + void parse_pattern(const std::string &ascpat, vector_double &pattern); typedef pdeque Events; Events _events; @@ -84,7 +84,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const PointerEventList &pointerlist) { +INLINE std::ostream &operator << (std::ostream &out, const PointerEventList &pointerlist) { pointerlist.output(out); return out; } diff --git a/panda/src/event/pythonTask.h b/panda/src/event/pythonTask.h index 33dde9af0a..3771d46d8b 100644 --- a/panda/src/event/pythonTask.h +++ b/panda/src/event/pythonTask.h @@ -28,7 +28,7 @@ */ class PythonTask final : public AsyncTask { PUBLISHED: - PythonTask(PyObject *function = Py_None, const string &name = string()); + PythonTask(PyObject *function = Py_None, const std::string &name = std::string()); virtual ~PythonTask(); ALLOC_DELETED_CHAIN(PythonTask); diff --git a/panda/src/event/throw_event.I b/panda/src/event/throw_event.I index 303b356dad..bf3618d38a 100644 --- a/panda/src/event/throw_event.I +++ b/panda/src/event/throw_event.I @@ -17,12 +17,12 @@ throw_event(const CPT_Event &event) { } INLINE void -throw_event(const string &event_name) { +throw_event(const std::string &event_name) { EventQueue::get_global_event_queue()->queue_event(new Event(event_name)); } INLINE void -throw_event(const string &event_name, +throw_event(const std::string &event_name, const EventParameter &p1) { Event *event = new Event(event_name); event->add_parameter(p1); @@ -30,7 +30,7 @@ throw_event(const string &event_name, } INLINE void -throw_event(const string &event_name, +throw_event(const std::string &event_name, const EventParameter &p1, const EventParameter &p2) { Event *event = new Event(event_name); @@ -40,7 +40,7 @@ throw_event(const string &event_name, } INLINE void -throw_event(const string &event_name, +throw_event(const std::string &event_name, const EventParameter &p1, const EventParameter &p2, const EventParameter &p3) { @@ -52,7 +52,7 @@ throw_event(const string &event_name, } INLINE void -throw_event(const string &event_name, +throw_event(const std::string &event_name, const EventParameter &p1, const EventParameter &p2, const EventParameter &p3, @@ -74,13 +74,13 @@ throw_event_directly(EventHandler& handler, INLINE void throw_event_directly(EventHandler& handler, - const string &event_name) { + const std::string &event_name) { handler.dispatch_event(new Event(event_name)); } INLINE void throw_event_directly(EventHandler& handler, - const string &event_name, + const std::string &event_name, const EventParameter &p1) { Event *event = new Event(event_name); event->add_parameter(p1); @@ -89,7 +89,7 @@ throw_event_directly(EventHandler& handler, INLINE void throw_event_directly(EventHandler& handler, - const string &event_name, + const std::string &event_name, const EventParameter &p1, const EventParameter &p2) { Event *event = new Event(event_name); @@ -100,7 +100,7 @@ throw_event_directly(EventHandler& handler, INLINE void throw_event_directly(EventHandler& handler, - const string &event_name, + const std::string &event_name, const EventParameter &p1, const EventParameter &p2, const EventParameter &p3) { diff --git a/panda/src/event/throw_event.h b/panda/src/event/throw_event.h index d1d2554c3a..435a959d64 100644 --- a/panda/src/event/throw_event.h +++ b/panda/src/event/throw_event.h @@ -22,17 +22,17 @@ // A handful of convenience functions to throw events. INLINE void throw_event(const CPT_Event &event); -INLINE void throw_event(const string &event_name); -INLINE void throw_event(const string &event_name, +INLINE void throw_event(const std::string &event_name); +INLINE void throw_event(const std::string &event_name, const EventParameter &p1); -INLINE void throw_event(const string &event_name, +INLINE void throw_event(const std::string &event_name, const EventParameter &p1, const EventParameter &p2); -INLINE void throw_event(const string &event_name, +INLINE void throw_event(const std::string &event_name, const EventParameter &p1, const EventParameter &p2, const EventParameter &p3); -INLINE void throw_event(const string &event_name, +INLINE void throw_event(const std::string &event_name, const EventParameter &p1, const EventParameter &p2, const EventParameter &p3, @@ -43,16 +43,16 @@ INLINE void throw_event(const string &event_name, INLINE void throw_event_directly(EventHandler& handler, const CPT_Event &event); INLINE void throw_event_directly(EventHandler& handler, - const string &event_name); + const std::string &event_name); INLINE void throw_event_directly(EventHandler& handler, - const string &event_name, + const std::string &event_name, const EventParameter &p1); INLINE void throw_event_directly(EventHandler& handler, - const string &event_name, + const std::string &event_name, const EventParameter &p1, const EventParameter &p2); INLINE void throw_event_directly(EventHandler& handler, - const string &event_name, + const std::string &event_name, const EventParameter &p1, const EventParameter &p2, const EventParameter &p3); diff --git a/panda/src/express/checksumHashGenerator.h b/panda/src/express/checksumHashGenerator.h index d1ee27afa3..c809230565 100644 --- a/panda/src/express/checksumHashGenerator.h +++ b/panda/src/express/checksumHashGenerator.h @@ -29,7 +29,7 @@ public: INLINE void add_fp(float num, float threshold); INLINE void add_fp(double num, double threshold); INLINE void add_pointer(void *ptr); - void add_string(const string &str); + void add_string(const std::string &str); }; #include "checksumHashGenerator.I" diff --git a/panda/src/express/compress_string.h b/panda/src/express/compress_string.h index 433f1dd3e6..3fdbc4b258 100644 --- a/panda/src/express/compress_string.h +++ b/panda/src/express/compress_string.h @@ -22,11 +22,11 @@ BEGIN_PUBLISH -EXPCL_PANDAEXPRESS string -compress_string(const string &source, int compression_level); +EXPCL_PANDAEXPRESS std::string +compress_string(const std::string &source, int compression_level); -EXPCL_PANDAEXPRESS string -decompress_string(const string &source); +EXPCL_PANDAEXPRESS std::string +decompress_string(const std::string &source); EXPCL_PANDAEXPRESS bool compress_file(const Filename &source, const Filename &dest, int compression_level); @@ -34,9 +34,9 @@ EXPCL_PANDAEXPRESS bool decompress_file(const Filename &source, const Filename &dest); EXPCL_PANDAEXPRESS bool -compress_stream(istream &source, ostream &dest, int compression_level); +compress_stream(std::istream &source, std::ostream &dest, int compression_level); EXPCL_PANDAEXPRESS bool -decompress_stream(istream &source, ostream &dest); +decompress_stream(std::istream &source, std::ostream &dest); END_PUBLISH diff --git a/panda/src/express/copy_stream.h b/panda/src/express/copy_stream.h index b501bb682e..d93e00fa69 100644 --- a/panda/src/express/copy_stream.h +++ b/panda/src/express/copy_stream.h @@ -18,7 +18,7 @@ BEGIN_PUBLISH EXPCL_PANDAEXPRESS bool -copy_stream(istream &source, ostream &dest); +copy_stream(std::istream &source, std::ostream &dest); END_PUBLISH #endif diff --git a/panda/src/express/datagram.I b/panda/src/express/datagram.I index 98f5fcea14..98b71820e5 100644 --- a/panda/src/express/datagram.I +++ b/panda/src/express/datagram.I @@ -43,7 +43,7 @@ Datagram(const void *data, size_t size) : */ INLINE Datagram:: Datagram(vector_uchar data) : - _data(move(data)), + _data(std::move(data)), #ifdef STDFLOAT_DOUBLE _stdfloat_double(true) #else @@ -241,7 +241,7 @@ add_be_float64(PN_float64 value) { * followed by n bytes. */ INLINE void Datagram:: -add_string(const string &str) { +add_string(const std::string &str) { // The max sendable length for a string is 2^16. nassertv(str.length() <= (uint16_t)0xffff); @@ -257,7 +257,7 @@ add_string(const string &str) { * to allow very long strings. */ INLINE void Datagram:: -add_string32(const string &str) { +add_string32(const std::string &str) { // Strings always are preceded by their length add_uint32((uint32_t)str.length()); @@ -269,7 +269,7 @@ add_string32(const string &str) { * Adds a variable-length string to the datagram, as a NULL-terminated string. */ INLINE void Datagram:: -add_z_string(const string &str) { +add_z_string(const std::string &str) { // We must not have any nested null characters in the string. size_t null_pos = str.find('\0'); // Add the string (sans the null character). @@ -285,7 +285,7 @@ add_z_string(const string &str) { * greater than the requested size, this will silently truncate the string. */ INLINE void Datagram:: -add_fixed_string(const string &str, size_t size) { +add_fixed_string(const std::string &str, size_t size) { if (str.length() < size) { append_data(str.data(), str.length()); pad_bytes(size - str.length()); @@ -306,13 +306,13 @@ append_data(const vector_uchar &data) { /** * Returns the datagram's data as a string. */ -INLINE string Datagram:: +INLINE std::string Datagram:: get_message() const { // Silly special case for gcc 3.2, which can't tolerate string(NULL, 0). if (_data.size() == 0) { - return string(); + return std::string(); } else { - return string((const char *)_data.p(), _data.size()); + return std::string((const char *)_data.p(), _data.size()); } } @@ -474,11 +474,11 @@ generic_write_datagram(Datagram &dest, double value) { } INLINE void -generic_write_datagram(Datagram &dest, const string &value) { +generic_write_datagram(Datagram &dest, const std::string &value) { dest.add_string(value); } INLINE void -generic_write_datagram(Datagram &dest, const wstring &value) { +generic_write_datagram(Datagram &dest, const std::wstring &value) { dest.add_wstring(value); } diff --git a/panda/src/express/datagram.h b/panda/src/express/datagram.h index 7cf50368fc..a865c6bec6 100644 --- a/panda/src/express/datagram.h +++ b/panda/src/express/datagram.h @@ -48,7 +48,7 @@ PUBLISHED: Datagram &operator = (Datagram &&from) noexcept = default; virtual void clear(); - void dump_hex(ostream &out, unsigned int indent=0) const; + void dump_hex(std::ostream &out, unsigned int indent=0) const; INLINE void add_bool(bool value); INLINE void add_int8(int8_t value); @@ -75,11 +75,11 @@ PUBLISHED: INLINE void add_be_float32(PN_float32 value); INLINE void add_be_float64(PN_float64 value); - INLINE void add_string(const string &str); - INLINE void add_string32(const string &str); - INLINE void add_z_string(const string &str); - INLINE void add_fixed_string(const string &str, size_t size); - void add_wstring(const wstring &str); + INLINE void add_string(const std::string &str); + INLINE void add_string32(const std::string &str); + INLINE void add_z_string(const std::string &str); + INLINE void add_fixed_string(const std::string &str, size_t size); + void add_wstring(const std::wstring &str); void pad_bytes(size_t size); void append_data(const void *data, size_t size); @@ -87,7 +87,7 @@ PUBLISHED: void assign(const void *data, size_t size); - INLINE string get_message() const; + INLINE std::string get_message() const; INLINE vector_uchar __bytes__() const; INLINE const void *get_data() const; INLINE size_t get_length() const; @@ -104,8 +104,8 @@ PUBLISHED: INLINE bool operator != (const Datagram &other) const; INLINE bool operator < (const Datagram &other) const; - void output(ostream &out) const; - void write(ostream &out, unsigned int indent=0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, unsigned int indent=0) const; private: PTA_uchar _data; @@ -145,9 +145,9 @@ generic_write_datagram(Datagram &dest, float value); INLINE void generic_write_datagram(Datagram &dest, double value); INLINE void -generic_write_datagram(Datagram &dest, const string &value); +generic_write_datagram(Datagram &dest, const std::string &value); INLINE void -generic_write_datagram(Datagram &dest, const wstring &value); +generic_write_datagram(Datagram &dest, const std::wstring &value); #include "datagram.I" diff --git a/panda/src/express/datagramGenerator.h b/panda/src/express/datagramGenerator.h index 8d46f9df80..621cb73517 100644 --- a/panda/src/express/datagramGenerator.h +++ b/panda/src/express/datagramGenerator.h @@ -41,7 +41,7 @@ PUBLISHED: virtual time_t get_timestamp() const; virtual const FileReference *get_file(); virtual VirtualFile *get_vfile(); - virtual streampos get_file_pos(); + virtual std::streampos get_file_pos(); }; #include "datagramGenerator.I" diff --git a/panda/src/express/datagramIterator.I b/panda/src/express/datagramIterator.I index 33af92539f..763850b60c 100644 --- a/panda/src/express/datagramIterator.I +++ b/panda/src/express/datagramIterator.I @@ -477,11 +477,11 @@ generic_read_datagram(double &result, DatagramIterator &source) { } INLINE void -generic_read_datagram(string &result, DatagramIterator &source) { +generic_read_datagram(std::string &result, DatagramIterator &source) { result = source.get_string(); } INLINE void -generic_read_datagram(wstring &result, DatagramIterator &source) { +generic_read_datagram(std::wstring &result, DatagramIterator &source) { result = source.get_wstring(); } diff --git a/panda/src/express/datagramIterator.h b/panda/src/express/datagramIterator.h index ec76be3f07..60a893f477 100644 --- a/panda/src/express/datagramIterator.h +++ b/panda/src/express/datagramIterator.h @@ -55,11 +55,11 @@ PUBLISHED: INLINE PN_float32 get_be_float32(); INLINE PN_float64 get_be_float64(); - string get_string(); - string get_string32(); - string get_z_string(); - string get_fixed_string(size_t size); - wstring get_wstring(); + std::string get_string(); + std::string get_string32(); + std::string get_z_string(); + std::string get_fixed_string(size_t size); + std::wstring get_wstring(); INLINE void skip_bytes(size_t size); vector_uchar extract_bytes(size_t size); @@ -71,8 +71,8 @@ PUBLISHED: INLINE const Datagram &get_datagram() const; INLINE size_t get_current_index() const; - void output(ostream &out) const; - void write(ostream &out, unsigned int indent=0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, unsigned int indent=0) const; private: const Datagram *_datagram; @@ -104,9 +104,9 @@ generic_read_datagram(float &result, DatagramIterator &source); INLINE void generic_read_datagram(double &result, DatagramIterator &source); INLINE void -generic_read_datagram(string &result, DatagramIterator &source); +generic_read_datagram(std::string &result, DatagramIterator &source); INLINE void -generic_read_datagram(wstring &result, DatagramIterator &source); +generic_read_datagram(std::wstring &result, DatagramIterator &source); #include "datagramIterator.I" diff --git a/panda/src/express/datagramSink.h b/panda/src/express/datagramSink.h index c72cf7595d..04d19dfaec 100644 --- a/panda/src/express/datagramSink.h +++ b/panda/src/express/datagramSink.h @@ -39,7 +39,7 @@ PUBLISHED: virtual const Filename &get_filename(); virtual const FileReference *get_file(); - virtual streampos get_file_pos(); + virtual std::streampos get_file_pos(); MAKE_PROPERTY(filename, get_filename); MAKE_PROPERTY(file, get_file); diff --git a/panda/src/express/encrypt_string.h b/panda/src/express/encrypt_string.h index 4e0d12bafb..317c9231c8 100644 --- a/panda/src/express/encrypt_string.h +++ b/panda/src/express/encrypt_string.h @@ -22,26 +22,26 @@ BEGIN_PUBLISH -EXPCL_PANDAEXPRESS string -encrypt_string(const string &source, const string &password, - const string &algorithm = string(), int key_length = -1, +EXPCL_PANDAEXPRESS std::string +encrypt_string(const std::string &source, const std::string &password, + const std::string &algorithm = std::string(), int key_length = -1, int iteration_count = -1); -EXPCL_PANDAEXPRESS string -decrypt_string(const string &source, const string &password); +EXPCL_PANDAEXPRESS std::string +decrypt_string(const std::string &source, const std::string &password); EXPCL_PANDAEXPRESS bool -encrypt_file(const Filename &source, const Filename &dest, const string &password, - const string &algorithm = string(), int key_length = -1, +encrypt_file(const Filename &source, const Filename &dest, const std::string &password, + const std::string &algorithm = std::string(), int key_length = -1, int iteration_count = -1); EXPCL_PANDAEXPRESS bool -decrypt_file(const Filename &source, const Filename &dest, const string &password); +decrypt_file(const Filename &source, const Filename &dest, const std::string &password); EXPCL_PANDAEXPRESS bool -encrypt_stream(istream &source, ostream &dest, const string &password, - const string &algorithm = string(), int key_length = -1, +encrypt_stream(std::istream &source, std::ostream &dest, const std::string &password, + const std::string &algorithm = std::string(), int key_length = -1, int iteration_count = -1); EXPCL_PANDAEXPRESS bool -decrypt_stream(istream &source, ostream &dest, const string &password); +decrypt_stream(std::istream &source, std::ostream &dest, const std::string &password); END_PUBLISH diff --git a/panda/src/express/error_utils.h b/panda/src/express/error_utils.h index 10ed4d4bd8..161a2482fe 100644 --- a/panda/src/express/error_utils.h +++ b/panda/src/express/error_utils.h @@ -74,11 +74,11 @@ enum ErrorUtilCode { EU_error_zlib = -80, }; -EXPCL_PANDAEXPRESS string error_to_text(ErrorUtilCode err); +EXPCL_PANDAEXPRESS std::string error_to_text(ErrorUtilCode err); EXPCL_PANDAEXPRESS int get_write_error(); #ifdef HAVE_NET -EXPCL_PANDAEXPRESS string handle_socket_error(); +EXPCL_PANDAEXPRESS std::string handle_socket_error(); EXPCL_PANDAEXPRESS int get_network_error(); #endif diff --git a/panda/src/express/hashVal.I b/panda/src/express/hashVal.I index 6519915034..2f78f5254a 100644 --- a/panda/src/express/hashVal.I +++ b/panda/src/express/hashVal.I @@ -100,7 +100,7 @@ merge_with(const HashVal &other) { * Outputs the HashVal as four unsigned decimal integers. */ INLINE void HashVal:: -output_dec(ostream &out) const { +output_dec(std::ostream &out) const { out << _hv[0] << " " << _hv[1] << " " << _hv[2] << " " << _hv[3]; } @@ -108,7 +108,7 @@ output_dec(ostream &out) const { * Inputs the HashVal as four unsigned decimal integers. */ INLINE void HashVal:: -input_dec(istream &in) { +input_dec(std::istream &in) { in >> _hv[0] >> _hv[1] >> _hv[2] >> _hv[3]; } @@ -116,7 +116,7 @@ input_dec(istream &in) { * */ INLINE void HashVal:: -output(ostream &out) const { +output(std::ostream &out) const { output_hex(out); } @@ -181,7 +181,7 @@ hash_ramfile(const Ramfile &ramfile) { * functionality) available. */ INLINE void HashVal:: -hash_string(const string &data) { +hash_string(const std::string &data) { hash_buffer(data.data(), data.length()); } @@ -221,7 +221,7 @@ fromhex(char digit) { } -INLINE ostream &operator << (ostream &out, const HashVal &hv) { +INLINE std::ostream &operator << (std::ostream &out, const HashVal &hv) { hv.output(out); return out; } diff --git a/panda/src/express/hashVal.h b/panda/src/express/hashVal.h index a4b3754614..eebff3eaff 100644 --- a/panda/src/express/hashVal.h +++ b/panda/src/express/hashVal.h @@ -40,20 +40,20 @@ PUBLISHED: INLINE void merge_with(const HashVal &other); - INLINE void output_dec(ostream &out) const; - INLINE void input_dec(istream &in); - void output_hex(ostream &out) const; - void input_hex(istream &in); - void output_binary(ostream &out) const; - void input_binary(istream &in); + INLINE void output_dec(std::ostream &out) const; + INLINE void input_dec(std::istream &in); + void output_hex(std::ostream &out) const; + void input_hex(std::istream &in); + void output_binary(std::ostream &out) const; + void input_binary(std::istream &in); - INLINE void output(ostream &out) const; + INLINE void output(std::ostream &out) const; - string as_dec() const; - bool set_from_dec(const string &text); + std::string as_dec() const; + bool set_from_dec(const std::string &text); - string as_hex() const; - bool set_from_hex(const string &text); + std::string as_hex() const; + bool set_from_hex(const std::string &text); vector_uchar as_bin() const; bool set_from_bin(const vector_uchar &text); @@ -65,9 +65,9 @@ PUBLISHED: #ifdef HAVE_OPENSSL bool hash_file(const Filename &filename); - bool hash_stream(istream &stream); + bool hash_stream(std::istream &stream); INLINE void hash_ramfile(const Ramfile &ramfile); - INLINE void hash_string(const string &data); + INLINE void hash_string(const std::string &data); INLINE void hash_bytes(const pvector &data); void hash_buffer(const char *buffer, int length); #endif // HAVE_OPENSSL @@ -81,7 +81,7 @@ private: uint32_t _hv[4]; }; -INLINE ostream &operator << (ostream &out, const HashVal &hv); +INLINE std::ostream &operator << (std::ostream &out, const HashVal &hv); #include "hashVal.I" diff --git a/panda/src/express/memoryUsage.h b/panda/src/express/memoryUsage.h index cd72581704..4e33ef3766 100644 --- a/panda/src/express/memoryUsage.h +++ b/panda/src/express/memoryUsage.h @@ -179,7 +179,7 @@ private: private: // Cannot use a pmap, since that would be recursive! - typedef map Counts; + typedef std::map Counts; Counts _counts; }; TypeHistogram _trend_types; diff --git a/panda/src/express/memoryUsagePointerCounts.I b/panda/src/express/memoryUsagePointerCounts.I index 79aeba084c..0c4f97ae78 100644 --- a/panda/src/express/memoryUsagePointerCounts.I +++ b/panda/src/express/memoryUsagePointerCounts.I @@ -98,8 +98,8 @@ operator < (const MemoryUsagePointerCounts &other) const { return false; } -INLINE ostream & -operator << (ostream &out, const MemoryUsagePointerCounts &c) { +INLINE std::ostream & +operator << (std::ostream &out, const MemoryUsagePointerCounts &c) { c.output(out); return out; } diff --git a/panda/src/express/memoryUsagePointerCounts.h b/panda/src/express/memoryUsagePointerCounts.h index 2d95052ad8..b0a1820a44 100644 --- a/panda/src/express/memoryUsagePointerCounts.h +++ b/panda/src/express/memoryUsagePointerCounts.h @@ -32,7 +32,7 @@ public: INLINE void clear(); void add_info(MemoryInfo *info); - void output(ostream &out) const; + void output(std::ostream &out) const; INLINE bool is_size_unknown() const; INLINE size_t get_size() const; @@ -41,7 +41,7 @@ public: INLINE bool operator < (const MemoryUsagePointerCounts &other) const; private: - static void output_bytes(ostream &out, size_t size); + static void output_bytes(std::ostream &out, size_t size); private: int _count; @@ -49,7 +49,7 @@ private: size_t _size; }; -INLINE ostream &operator << (ostream &out, const MemoryUsagePointerCounts &c); +INLINE std::ostream &operator << (std::ostream &out, const MemoryUsagePointerCounts &c); #include "memoryUsagePointerCounts.I" diff --git a/panda/src/express/memoryUsagePointers.h b/panda/src/express/memoryUsagePointers.h index 344c2edc6b..526efec7c8 100644 --- a/panda/src/express/memoryUsagePointers.h +++ b/panda/src/express/memoryUsagePointers.h @@ -47,7 +47,7 @@ PUBLISHED: MAKE_SEQ(get_typed_pointers, get_num_pointers, get_typed_pointer); TypeHandle get_type(size_t n) const; - string get_type_name(size_t n) const; + std::string get_type_name(size_t n) const; double get_age(size_t n) const; #ifdef DO_MEMORY_USAGE @@ -56,7 +56,7 @@ PUBLISHED: void clear(); - void output(ostream &out) const; + void output(std::ostream &out) const; private: void add_entry(ReferenceCount *ref_ptr, TypedObject *typed_ptr, @@ -86,7 +86,7 @@ private: friend class MemoryUsage; }; -INLINE ostream &operator << (ostream &out, const MemoryUsagePointers &mup) { +INLINE std::ostream &operator << (std::ostream &out, const MemoryUsagePointers &mup) { mup.output(out); return out; } diff --git a/panda/src/express/multifile.I b/panda/src/express/multifile.I index aa10b223f1..128eb5297e 100644 --- a/panda/src/express/multifile.I +++ b/panda/src/express/multifile.I @@ -143,7 +143,7 @@ get_encryption_flag() const { * implicit call to flush(). */ INLINE void Multifile:: -set_encryption_password(const string &encryption_password) { +set_encryption_password(const std::string &encryption_password) { if (_encryption_password != encryption_password) { if (!_new_subfiles.empty()) { flush(); @@ -156,7 +156,7 @@ set_encryption_password(const string &encryption_password) { * Returns the password that will be used to encrypt subfiles subsequently * added to the multifile. See set_encryption_password(). */ -INLINE const string &Multifile:: +INLINE const std::string &Multifile:: get_encryption_password() const { return _encryption_password; } @@ -176,7 +176,7 @@ get_encryption_password() const { * flush(). */ INLINE void Multifile:: -set_encryption_algorithm(const string &encryption_algorithm) { +set_encryption_algorithm(const std::string &encryption_algorithm) { if (_encryption_algorithm != encryption_algorithm) { if (!_new_subfiles.empty()) { flush(); @@ -189,7 +189,7 @@ set_encryption_algorithm(const string &encryption_algorithm) { * Returns the encryption algorithm that was specified by * set_encryption_algorithm(). */ -INLINE const string &Multifile:: +INLINE const std::string &Multifile:: get_encryption_algorithm() const { return _encryption_algorithm; } @@ -268,7 +268,7 @@ get_encryption_iteration_count() const { * reduced in size after this operation, until the next call to repack(). */ INLINE bool Multifile:: -remove_subfile(const string &subfile_name) { +remove_subfile(const std::string &subfile_name) { int index = find_subfile(subfile_name); if (index >= 0) { remove_subfile(index); @@ -292,16 +292,16 @@ read_subfile(int index) { * Returns a string with the first n bytes written to a Multifile, to identify * it as a Multifile. */ -INLINE string Multifile:: +INLINE std::string Multifile:: get_magic_number() { - return string(_header, _header_size); + return std::string(_header, _header_size); } /** * Returns the string that preceded the Multifile header on the file, if any. * See set_header_prefix(). */ -INLINE const string &Multifile:: +INLINE const std::string &Multifile:: get_header_prefix() const { return _header_prefix; } @@ -310,9 +310,9 @@ get_header_prefix() const { * Converts a size_t address read from the file to a streampos byte address * within the file. */ -INLINE streampos Multifile:: +INLINE std::streampos Multifile:: word_to_streampos(size_t word) const { - return (streampos)word * (streampos)_scale_factor; + return (std::streampos)word * (std::streampos)_scale_factor; } /** @@ -320,16 +320,16 @@ word_to_streampos(size_t word) const { * suitable for writing to the file. */ INLINE size_t Multifile:: -streampos_to_word(streampos fpos) const { - return (size_t)((fpos + (streampos)_scale_factor - (streampos)1) / (streampos)_scale_factor); +streampos_to_word(std::streampos fpos) const { + return (size_t)((fpos + (std::streampos)_scale_factor - (std::streampos)1) / (std::streampos)_scale_factor); } /** * Rounds the streampos byte address up to the next multiple of _scale_factor. * Only multiples of _scale_factor may be written to the file. */ -INLINE streampos Multifile:: -normalize_streampos(streampos fpos) const { +INLINE std::streampos Multifile:: +normalize_streampos(std::streampos fpos) const { return word_to_streampos(streampos_to_word(fpos)); } @@ -418,8 +418,8 @@ is_cert_special() const { * contributes to this Subfile, either in the index record or in the subfile * data. */ -INLINE streampos Multifile::Subfile:: +INLINE std::streampos Multifile::Subfile:: get_last_byte_pos() const { - return max(_index_start + (streampos)_index_length, - _data_start + (streampos)_data_length) - (streampos)1; + return std::max(_index_start + (std::streampos)_index_length, + _data_start + (std::streampos)_data_length) - (std::streampos)1; } diff --git a/panda/src/express/multifile.h b/panda/src/express/multifile.h index ad0296055c..5ea0ce46e4 100644 --- a/panda/src/express/multifile.h +++ b/panda/src/express/multifile.h @@ -43,12 +43,12 @@ PUBLISHED: Multifile &operator = (const Multifile ©) = delete; PUBLISHED: - BLOCKING bool open_read(const Filename &multifile_name, const streampos &offset = 0); - BLOCKING bool open_read(IStreamWrapper *multifile_stream, bool owns_pointer = false, const streampos &offset = 0); + BLOCKING bool open_read(const Filename &multifile_name, const std::streampos &offset = 0); + BLOCKING bool open_read(IStreamWrapper *multifile_stream, bool owns_pointer = false, const std::streampos &offset = 0); BLOCKING bool open_write(const Filename &multifile_name); - BLOCKING bool open_write(ostream *multifile_stream, bool owns_pointer = false); + BLOCKING bool open_write(std::ostream *multifile_stream, bool owns_pointer = false); BLOCKING bool open_read_write(const Filename &multifile_name); - BLOCKING bool open_read_write(iostream *multifile_stream, bool owns_pointer = false); + BLOCKING bool open_read_write(std::iostream *multifile_stream, bool owns_pointer = false); BLOCKING void close(); INLINE const Filename &get_multifile_name() const; @@ -68,37 +68,37 @@ PUBLISHED: INLINE void set_encryption_flag(bool flag); INLINE bool get_encryption_flag() const; - INLINE void set_encryption_password(const string &encryption_password); - INLINE const string &get_encryption_password() const; + INLINE void set_encryption_password(const std::string &encryption_password); + INLINE const std::string &get_encryption_password() const; - INLINE void set_encryption_algorithm(const string &encryption_algorithm); - INLINE const string &get_encryption_algorithm() const; + INLINE void set_encryption_algorithm(const std::string &encryption_algorithm); + INLINE const std::string &get_encryption_algorithm() const; INLINE void set_encryption_key_length(int encryption_key_length); INLINE int get_encryption_key_length() const; INLINE void set_encryption_iteration_count(int encryption_iteration_count); INLINE int get_encryption_iteration_count() const; - string add_subfile(const string &subfile_name, const Filename &filename, + std::string add_subfile(const std::string &subfile_name, const Filename &filename, int compression_level); - string add_subfile(const string &subfile_name, istream *subfile_data, + std::string add_subfile(const std::string &subfile_name, std::istream *subfile_data, int compression_level); - string update_subfile(const string &subfile_name, const Filename &filename, + std::string update_subfile(const std::string &subfile_name, const Filename &filename, int compression_level); #ifdef HAVE_OPENSSL bool add_signature(const Filename &certificate, const Filename &chain, const Filename &pkey, - const string &password = ""); + const std::string &password = ""); bool add_signature(const Filename &composite, - const string &password = ""); + const std::string &password = ""); int get_num_signatures() const; - string get_signature_subject_name(int n) const; - string get_signature_friendly_name(int n) const; - string get_signature_public_key(int n) const; - void print_signature_certificate(int n, ostream &out) const; - void write_signature_certificate(int n, ostream &out) const; + std::string get_signature_subject_name(int n) const; + std::string get_signature_friendly_name(int n) const; + std::string get_signature_public_key(int n) const; + void print_signature_certificate(int n, std::ostream &out) const; + void write_signature_certificate(int n, std::ostream &out) const; int validate_signature_certificate(int n) const; #endif // HAVE_OPENSSL @@ -107,13 +107,13 @@ PUBLISHED: BLOCKING bool repack(); int get_num_subfiles() const; - int find_subfile(const string &subfile_name) const; - bool has_directory(const string &subfile_name) const; + int find_subfile(const std::string &subfile_name) const; + bool has_directory(const std::string &subfile_name) const; bool scan_directory(vector_string &contents, - const string &subfile_name) const; + const std::string &subfile_name) const; void remove_subfile(int index); - INLINE bool remove_subfile(const string &subfile_name); - const string &get_subfile_name(int index) const; + INLINE bool remove_subfile(const std::string &subfile_name); + const std::string &get_subfile_name(int index) const; MAKE_SEQ(get_subfile_names, get_num_subfiles, get_subfile_name); size_t get_subfile_length(int index) const; time_t get_subfile_timestamp(int index) const; @@ -121,25 +121,25 @@ PUBLISHED: bool is_subfile_encrypted(int index) const; bool is_subfile_text(int index) const; - streampos get_index_end() const; - streampos get_subfile_internal_start(int index) const; + std::streampos get_index_end() const; + std::streampos get_subfile_internal_start(int index) const; size_t get_subfile_internal_length(int index) const; BLOCKING INLINE vector_uchar read_subfile(int index); - BLOCKING istream *open_read_subfile(int index); - BLOCKING static void close_read_subfile(istream *stream); + BLOCKING std::istream *open_read_subfile(int index); + BLOCKING static void close_read_subfile(std::istream *stream); BLOCKING bool extract_subfile(int index, const Filename &filename); - BLOCKING bool extract_subfile_to(int index, ostream &out); + BLOCKING bool extract_subfile_to(int index, std::ostream &out); BLOCKING bool compare_subfile(int index, const Filename &filename); - void output(ostream &out) const; - void ls(ostream &out = cout) const; + void output(std::ostream &out) const; + void ls(std::ostream &out = std::cout) const; - static INLINE string get_magic_number(); + static INLINE std::string get_magic_number(); MAKE_PROPERTY(magic_number, get_magic_number); - void set_header_prefix(const string &header_prefix); - INLINE const string &get_header_prefix() const; + void set_header_prefix(const std::string &header_prefix); + INLINE const std::string &get_header_prefix() const; public: #ifdef HAVE_OPENSSL @@ -158,7 +158,7 @@ public: const CertChain &get_signature(int n) const; #endif // HAVE_OPENSSL - bool read_subfile(int index, string &result); + bool read_subfile(int index, std::string &result); bool read_subfile(int index, pvector &result); private: @@ -176,28 +176,28 @@ private: public: INLINE Subfile(); INLINE bool operator < (const Subfile &other) const; - streampos read_index(istream &read, streampos fpos, + std::streampos read_index(std::istream &read, std::streampos fpos, Multifile *multfile); - streampos write_index(ostream &write, streampos fpos, + std::streampos write_index(std::ostream &write, std::streampos fpos, Multifile *multifile); - streampos write_data(ostream &write, istream *read, streampos fpos, + std::streampos write_data(std::ostream &write, std::istream *read, std::streampos fpos, Multifile *multifile); - void rewrite_index_data_start(ostream &write, Multifile *multifile); - void rewrite_index_flags(ostream &write); + void rewrite_index_data_start(std::ostream &write, Multifile *multifile); + void rewrite_index_flags(std::ostream &write); INLINE bool is_deleted() const; INLINE bool is_index_invalid() const; INLINE bool is_data_invalid() const; INLINE bool is_cert_special() const; - INLINE streampos get_last_byte_pos() const; + INLINE std::streampos get_last_byte_pos() const; - string _name; - streampos _index_start; + std::string _name; + std::streampos _index_start; size_t _index_length; - streampos _data_start; + std::streampos _data_start; size_t _data_length; size_t _uncompressed_length; time_t _timestamp; - istream *_source; + std::istream *_source; Filename _source_filename; int _flags; int _compression_level; // Not preserved on disk. @@ -206,14 +206,14 @@ private: #endif }; - INLINE streampos word_to_streampos(size_t word) const; - INLINE size_t streampos_to_word(streampos fpos) const; - INLINE streampos normalize_streampos(streampos fpos) const; - streampos pad_to_streampos(streampos fpos); + INLINE std::streampos word_to_streampos(size_t word) const; + INLINE size_t streampos_to_word(std::streampos fpos) const; + INLINE std::streampos normalize_streampos(std::streampos fpos) const; + std::streampos pad_to_streampos(std::streampos fpos); void add_new_subfile(Subfile *subfile, int compression_level); - istream *open_read_subfile(Subfile *subfile); - string standardize_subfile_name(const string &subfile_name) const; + std::istream *open_read_subfile(Subfile *subfile); + std::string standardize_subfile_name(const std::string &subfile_name) const; void clear_subfiles(); bool read_index(); @@ -235,13 +235,13 @@ private: Certificates _signatures; #endif - streampos _offset; + std::streampos _offset; IStreamWrapper *_read; - ostream *_write; + std::ostream *_write; bool _owns_stream; - streampos _next_index; - streampos _last_index; - streampos _last_data_byte; + std::streampos _next_index; + std::streampos _last_index; + std::streampos _last_data_byte; bool _needs_repack; time_t _timestamp; @@ -251,8 +251,8 @@ private: size_t _new_scale_factor; bool _encryption_flag; - string _encryption_password; - string _encryption_algorithm; + std::string _encryption_password; + std::string _encryption_algorithm; int _encryption_key_length; int _encryption_iteration_count; @@ -262,7 +262,7 @@ private: pfstream _read_write_file; StreamWrapper _read_write_filew; Filename _multifile_name; - string _header_prefix; + std::string _header_prefix; int _file_major_ver; int _file_minor_ver; diff --git a/panda/src/express/namable.I b/panda/src/express/namable.I index 75aa846087..d7060ce1c9 100644 --- a/panda/src/express/namable.I +++ b/panda/src/express/namable.I @@ -15,7 +15,7 @@ * */ INLINE Namable:: -Namable(const string &initial_name) : +Namable(const std::string &initial_name) : _name(initial_name) { } @@ -24,7 +24,7 @@ Namable(const string &initial_name) : * */ INLINE void Namable:: -set_name(const string &name) { +set_name(const std::string &name) { _name = name; } @@ -48,7 +48,7 @@ has_name() const { /** * */ -INLINE const string &Namable:: +INLINE const std::string &Namable:: get_name() const { return _name; } @@ -58,12 +58,12 @@ get_name() const { * stream; most Namable derivatives will probably redefine this. */ INLINE void Namable:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name(); } -INLINE ostream &operator << (ostream &out, const Namable &n) { +INLINE std::ostream &operator << (std::ostream &out, const Namable &n) { n.output(out); return out; } diff --git a/panda/src/express/namable.h b/panda/src/express/namable.h index 19a712d9d3..7dc42d089b 100644 --- a/panda/src/express/namable.h +++ b/panda/src/express/namable.h @@ -25,20 +25,20 @@ */ class EXPCL_PANDAEXPRESS Namable : public MemoryBase { PUBLISHED: - INLINE explicit Namable(const string &initial_name = ""); + INLINE explicit Namable(const std::string &initial_name = ""); - INLINE void set_name(const string &name); + INLINE void set_name(const std::string &name); INLINE void clear_name(); INLINE bool has_name() const; - INLINE const string &get_name() const; + INLINE const std::string &get_name() const; MAKE_PROPERTY(name, get_name, set_name); // In the absence of any definition to the contrary, outputting a Namable // will write out its name. - INLINE void output(ostream &out) const; + INLINE void output(std::ostream &out) const; private: - string _name; + std::string _name; public: static TypeHandle get_class_type() { @@ -52,7 +52,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const Namable &n); +INLINE std::ostream &operator << (std::ostream &out, const Namable &n); /** * An STL function object for sorting an array of pointers to Namables into diff --git a/panda/src/express/nodePointerTo.I b/panda/src/express/nodePointerTo.I index c8020d0181..6d5d3bd669 100644 --- a/panda/src/express/nodePointerTo.I +++ b/panda/src/express/nodePointerTo.I @@ -52,7 +52,7 @@ NodePointerTo(NodePointerTo &&from) noexcept : template INLINE NodePointerTo &NodePointerTo:: operator = (NodePointerTo &&from) noexcept { - this->reassign(move(from)); + this->reassign(std::move(from)); return *this; } #endif // CPPPARSER @@ -196,7 +196,7 @@ NodeConstPointerTo(NodeConstPointerTo &&from) noexcept : template INLINE NodeConstPointerTo &NodeConstPointerTo:: operator = (NodePointerTo &&from) noexcept { - this->reassign(move(from)); + this->reassign(std::move(from)); return *this; } #endif // CPPPARSER @@ -208,7 +208,7 @@ operator = (NodePointerTo &&from) noexcept { template INLINE NodeConstPointerTo &NodeConstPointerTo:: operator = (NodeConstPointerTo &&from) noexcept { - this->reassign(move(from)); + this->reassign(std::move(from)); return *this; } #endif // CPPPARSER diff --git a/panda/src/express/nodePointerToBase.I b/panda/src/express/nodePointerToBase.I index 40c9eb6506..48a7fe3fff 100644 --- a/panda/src/express/nodePointerToBase.I +++ b/panda/src/express/nodePointerToBase.I @@ -134,7 +134,7 @@ clear() { */ template INLINE void NodePointerToBase:: -output(ostream &out) const { +output(std::ostream &out) const { out << _void_ptr; if (_void_ptr != nullptr) { out << ":" << ((To *)_void_ptr)->get_node_ref_count() << "/" diff --git a/panda/src/express/nodePointerToBase.h b/panda/src/express/nodePointerToBase.h index 0b28a5c6bc..d4ddd7caad 100644 --- a/panda/src/express/nodePointerToBase.h +++ b/panda/src/express/nodePointerToBase.h @@ -49,11 +49,11 @@ protected: PUBLISHED: INLINE void clear(); - void output(ostream &out) const; + void output(std::ostream &out) const; }; template -INLINE ostream &operator <<(ostream &out, const NodePointerToBase &pointer) { +INLINE std::ostream &operator <<(std::ostream &out, const NodePointerToBase &pointer) { pointer.output(out); return out; } diff --git a/panda/src/express/nodeReferenceCount.I b/panda/src/express/nodeReferenceCount.I index 4f963476f7..d87bc982d8 100644 --- a/panda/src/express/nodeReferenceCount.I +++ b/panda/src/express/nodeReferenceCount.I @@ -215,9 +215,9 @@ void NodeRefCountObj:: init_type() { #if defined(HAVE_RTTI) && !defined(__EDG__) // If we have RTTI, we can determine the name of the base type. - string base_name = typeid(Base).name(); + std::string base_name = typeid(Base).name(); #else - string base_name = "unknown"; + std::string base_name = "unknown"; #endif TypeHandle base_type = register_dynamic_type(base_name); diff --git a/panda/src/express/openSSLWrapper.I b/panda/src/express/openSSLWrapper.I index 3d5cf81999..a8b8e396a6 100644 --- a/panda/src/express/openSSLWrapper.I +++ b/panda/src/express/openSSLWrapper.I @@ -21,7 +21,7 @@ * with certificates received from an untrusted source. */ INLINE int OpenSSLWrapper:: -load_certificates_from_pem_ram(const string &data) { +load_certificates_from_pem_ram(const std::string &data) { return load_certificates_from_pem_ram(data.data(), data.size()); } @@ -35,6 +35,6 @@ load_certificates_from_pem_ram(const string &data) { * with certificates received from an untrusted source. */ INLINE int OpenSSLWrapper:: -load_certificates_from_der_ram(const string &data) { +load_certificates_from_der_ram(const std::string &data) { return load_certificates_from_der_ram(data.data(), data.size()); } diff --git a/panda/src/express/openSSLWrapper.h b/panda/src/express/openSSLWrapper.h index 306039e1c0..134bc28ccb 100644 --- a/panda/src/express/openSSLWrapper.h +++ b/panda/src/express/openSSLWrapper.h @@ -54,8 +54,8 @@ PUBLISHED: int load_certificates_from_pem_ram(const char *data, size_t data_size); int load_certificates_from_der_ram(const char *data, size_t data_size); - INLINE int load_certificates_from_pem_ram(const string &data); - INLINE int load_certificates_from_der_ram(const string &data); + INLINE int load_certificates_from_pem_ram(const std::string &data); + INLINE int load_certificates_from_der_ram(const std::string &data); X509_STORE *get_x509_store(); diff --git a/panda/src/express/ordered_vector.I b/panda/src/express/ordered_vector.I index aedee72232..d55a0b98b6 100644 --- a/panda/src/express/ordered_vector.I +++ b/panda/src/express/ordered_vector.I @@ -312,25 +312,25 @@ operator >= (const ordered_vector &other) const { * componet is true if the insert operation has taken place. */ template -INLINE pair::ITERATOR, bool> ordered_vector:: +INLINE std::pair::ITERATOR, bool> ordered_vector:: insert_unique(const typename ordered_vector::VALUE_TYPE &key) { TAU_PROFILE("ordered_vector::insert_unique(const value_type &)", " ", TAU_USER); ITERATOR position = find_insert_position(begin(), end(), key); #ifdef NDEBUG - pair bogus_result(end(), false); + std::pair bogus_result(end(), false); nassertr(position >= begin() && position <= end(), bogus_result); #endif // If there's already an equivalent key in the vector, it's at *(position - // 1). if (position != begin() && !_compare(*(position - 1), key)) { - pair result(position - 1, false); + std::pair result(position - 1, false); nassertr(!_compare(key, *(position - 1)), result); return result; } ITERATOR result = _vector.insert(position, key); - return pair(result, true); + return std::pair(result, true); } /** @@ -387,7 +387,7 @@ template INLINE typename ordered_vector::SIZE_TYPE ordered_vector:: erase(const typename ordered_vector::KEY_TYPE &key) { TAU_PROFILE("ordered_vector::erase(const key_type &)", " ", TAU_USER); - pair result = equal_range(key); + std::pair result = equal_range(key); SIZE_TYPE count = result.second - result.first; erase(result.first, result.second); return count; @@ -534,19 +534,19 @@ upper_bound(const typename ordered_vector::KEY_TYPE &key) * Returns the pair (lower_bound(key), upper_bound(key)). */ template -INLINE pair::ITERATOR, typename ordered_vector::ITERATOR> ordered_vector:: +INLINE std::pair::ITERATOR, typename ordered_vector::ITERATOR> ordered_vector:: equal_range(const typename ordered_vector::KEY_TYPE &key) { TAU_PROFILE("ordered_vector::equal_range(const key_type &)", " ", TAU_USER); - pair::CONST_ITERATOR, typename ordered_vector::CONST_ITERATOR> result; + std::pair::CONST_ITERATOR, typename ordered_vector::CONST_ITERATOR> result; result = r_equal_range(begin(), end(), key); - return pair::ITERATOR, typename ordered_vector::ITERATOR>(nci(result.first), nci(result.second)); + return std::pair::ITERATOR, typename ordered_vector::ITERATOR>(nci(result.first), nci(result.second)); } /** * Returns the pair (lower_bound(key), upper_bound(key)). */ template -INLINE pair::CONST_ITERATOR, typename ordered_vector::CONST_ITERATOR> ordered_vector:: +INLINE std::pair::CONST_ITERATOR, typename ordered_vector::CONST_ITERATOR> ordered_vector:: equal_range(const typename ordered_vector::KEY_TYPE &key) const { TAU_PROFILE("ordered_vector::equal_range(const key_type &)", " ", TAU_USER); return r_equal_range(begin(), end(), key); @@ -625,7 +625,7 @@ template INLINE void ordered_vector:: push_back(value_type &&key) { TAU_PROFILE("ordered_vector::push_back()", " ", TAU_USER); - _vector.push_back(move(key)); + _vector.push_back(std::move(key)); } /** @@ -718,7 +718,7 @@ insert(typename ov_set::ITERATOR position, * Maps to insert_unique(). */ template -INLINE pair::ITERATOR, bool> ov_set:: +INLINE std::pair::ITERATOR, bool> ov_set:: insert(const typename ov_set::VALUE_TYPE &key) { return ordered_vector::insert_unique(key); } diff --git a/panda/src/express/ordered_vector.T b/panda/src/express/ordered_vector.T index 2d57d0a1d3..f41109dab1 100644 --- a/panda/src/express/ordered_vector.T +++ b/panda/src/express/ordered_vector.T @@ -348,11 +348,11 @@ r_upper_bound(typename ordered_vector::CONST_ITERATOR firs * The recursive implementation of equal_range(). */ template -pair::CONST_ITERATOR, typename ordered_vector::CONST_ITERATOR> ordered_vector:: +std::pair::CONST_ITERATOR, typename ordered_vector::CONST_ITERATOR> ordered_vector:: r_equal_range(typename ordered_vector::CONST_ITERATOR first, typename ordered_vector::CONST_ITERATOR last, const typename ordered_vector::KEY_TYPE &key) const { - typedef pair::CONST_ITERATOR, typename ordered_vector::CONST_ITERATOR> pair_type; + typedef std::pair::CONST_ITERATOR, typename ordered_vector::CONST_ITERATOR> pair_type; if (first == last) { // The list is empty; the key is not on the list. diff --git a/panda/src/express/ordered_vector.h b/panda/src/express/ordered_vector.h index 651a0c27fb..1a4869b91a 100644 --- a/panda/src/express/ordered_vector.h +++ b/panda/src/express/ordered_vector.h @@ -19,15 +19,15 @@ // memory foot pront and user time by a bunch on pc cygwin from 3 minutes to // 17 seconds ?? really need to explore interigate to figure out what is going // on .. -template, class Vector = pvector > class ov_multiset +template, class Vector = pvector > class ov_multiset { }; -template, class Vector = pvector > class ov_set +template, class Vector = pvector > class ov_set { }; -template, class Vector = pvector > class ordered_vector +template, class Vector = pvector > class ordered_vector { }; @@ -91,7 +91,7 @@ template, class Vector = pvector > cla * * (4) Random access into the set is easy with the [] operator. */ -template, class Vector = pvector > +template, class Vector = pvector > class ordered_vector { public: // Typedefs @@ -179,7 +179,7 @@ public: // Insert operations. ITERATOR insert_unique(ITERATOR position, const VALUE_TYPE &key); ITERATOR insert_nonunique(ITERATOR position, const VALUE_TYPE &key); - INLINE pair insert_unique(const VALUE_TYPE &key); + INLINE std::pair insert_unique(const VALUE_TYPE &key); INLINE ITERATOR insert_nonunique(const VALUE_TYPE &key); INLINE ITERATOR insert_unverified(ITERATOR position, const VALUE_TYPE &key); @@ -200,8 +200,8 @@ public: INLINE CONST_ITERATOR lower_bound(const KEY_TYPE &key) const; INLINE ITERATOR upper_bound(const KEY_TYPE &key); INLINE CONST_ITERATOR upper_bound(const KEY_TYPE &key) const; - INLINE pair equal_range(const KEY_TYPE &key); - INLINE pair equal_range(const KEY_TYPE &key) const; + INLINE std::pair equal_range(const KEY_TYPE &key); + INLINE std::pair equal_range(const KEY_TYPE &key) const; // Special operations. INLINE void swap(ordered_vector &other); @@ -235,7 +235,7 @@ private: const KEY_TYPE &key) const; CONST_ITERATOR r_upper_bound(CONST_ITERATOR first, CONST_ITERATOR last, const KEY_TYPE &key) const; - pair + std::pair r_equal_range(CONST_ITERATOR first, CONST_ITERATOR last, const KEY_TYPE &key) const; @@ -265,7 +265,7 @@ private: * A specialization of ordered_vector that emulates a standard STL set: one * copy of each element is allowed. */ -template, class Vector = pvector > +template, class Vector = pvector > class ov_set : public ordered_vector { public: typedef typename ordered_vector::ITERATOR ITERATOR; @@ -276,7 +276,7 @@ public: TypeHandle type_handle = ov_set_type_handle); INLINE ITERATOR insert(ITERATOR position, const VALUE_TYPE &key0); - INLINE pair insert(const VALUE_TYPE &key0); + INLINE std::pair insert(const VALUE_TYPE &key0); INLINE void sort(); INLINE bool verify_list() const; @@ -286,7 +286,7 @@ public: * A specialization of ordered_vector that emulates a standard STL set: many * copies of each element are allowed. */ -template, class Vector = pvector > +template, class Vector = pvector > class ov_multiset : public ordered_vector { public: typedef typename ordered_vector::ITERATOR ITERATOR; diff --git a/panda/src/express/password_hash.h b/panda/src/express/password_hash.h index 8006d8d9ea..a1af7e8b26 100644 --- a/panda/src/express/password_hash.h +++ b/panda/src/express/password_hash.h @@ -22,8 +22,8 @@ BEGIN_PUBLISH -EXPCL_PANDAEXPRESS string password_hash(const string &password, - const string &salt, +EXPCL_PANDAEXPRESS std::string password_hash(const std::string &password, + const std::string &salt, int iters, int keylen); END_PUBLISH diff --git a/panda/src/express/patchfile.I b/panda/src/express/patchfile.I index 600c7e92ca..bea1547c28 100644 --- a/panda/src/express/patchfile.I +++ b/panda/src/express/patchfile.I @@ -21,7 +21,7 @@ INLINE PN_stdfloat Patchfile:: get_progress() const { if (!_initiated) { express_cat.warning() - << "Patchfile::get_progress() - Patch has not been initiated" << endl; + << "Patchfile::get_progress() - Patch has not been initiated" << std::endl; return 0.0f; } nassertr(_total_bytes_to_process > 0, 0.0f); diff --git a/panda/src/express/patchfile.h b/panda/src/express/patchfile.h index c32c1d59e7..6e40d65aee 100644 --- a/panda/src/express/patchfile.h +++ b/panda/src/express/patchfile.h @@ -88,49 +88,49 @@ private: uint32_t calc_match_length(const char* buf1, const char* buf2, uint32_t max_length, uint32_t min_length); - void emit_ADD(ostream &write_stream, uint32_t length, const char* buffer); - void emit_COPY(ostream &write_stream, uint32_t length, uint32_t COPY_pos); - void emit_add_and_copy(ostream &write_stream, + void emit_ADD(std::ostream &write_stream, uint32_t length, const char* buffer); + void emit_COPY(std::ostream &write_stream, uint32_t length, uint32_t COPY_pos); + void emit_add_and_copy(std::ostream &write_stream, uint32_t add_length, const char *add_buffer, uint32_t copy_length, uint32_t copy_pos); - void cache_add_and_copy(ostream &write_stream, + void cache_add_and_copy(std::ostream &write_stream, uint32_t add_length, const char *add_buffer, uint32_t copy_length, uint32_t copy_pos); - void cache_flush(ostream &write_stream); + void cache_flush(std::ostream &write_stream); - void write_header(ostream &write_stream, - istream &stream_orig, istream &stream_new); - void write_terminator(ostream &write_stream); + void write_header(std::ostream &write_stream, + std::istream &stream_orig, std::istream &stream_new); + void write_terminator(std::ostream &write_stream); - bool compute_file_patches(ostream &write_stream, + bool compute_file_patches(std::ostream &write_stream, uint32_t offset_orig, uint32_t offset_new, - istream &stream_orig, istream &stream_new); - bool compute_mf_patches(ostream &write_stream, + std::istream &stream_orig, std::istream &stream_new); + bool compute_mf_patches(std::ostream &write_stream, uint32_t offset_orig, uint32_t offset_new, - istream &stream_orig, istream &stream_new); + std::istream &stream_orig, std::istream &stream_new); #ifdef HAVE_TAR class TarSubfile { public: inline bool operator < (const TarSubfile &other) const { return _name < other._name; } - string _name; - streampos _header_start; - streampos _data_start; - streampos _data_end; - streampos _end; + std::string _name; + std::streampos _header_start; + std::streampos _data_start; + std::streampos _data_end; + std::streampos _end; }; typedef ov_set TarDef; - bool read_tar(TarDef &tar, istream &stream); - bool compute_tar_patches(ostream &write_stream, + bool read_tar(TarDef &tar, std::istream &stream); + bool compute_tar_patches(std::ostream &write_stream, uint32_t offset_orig, uint32_t offset_new, - istream &stream_orig, istream &stream_new, + std::istream &stream_orig, std::istream &stream_new, TarDef &tar_orig, TarDef &tar_new); // Because this is static, we can only call read_tar() one at a time--no // threads, please. - static istream *_tar_istream; + static std::istream *_tar_istream; static int tar_openfunc(const char *filename, int oflags, ...); static int tar_closefunc(int fd); @@ -139,15 +139,15 @@ private: #endif // HAVE_TAR bool do_compute_patches(const Filename &file_orig, const Filename &file_new, - ostream &write_stream, + std::ostream &write_stream, uint32_t offset_orig, uint32_t offset_new, - istream &stream_orig, istream &stream_new); + std::istream &stream_orig, std::istream &stream_new); - bool patch_subfile(ostream &write_stream, + bool patch_subfile(std::ostream &write_stream, uint32_t offset_orig, uint32_t offset_new, const Filename &filename, - IStreamWrapper &stream_orig, streampos orig_start, streampos orig_end, - IStreamWrapper &stream_new, streampos new_start, streampos new_end); + IStreamWrapper &stream_orig, std::streampos orig_start, std::streampos orig_end, + IStreamWrapper &stream_new, std::streampos new_start, std::streampos new_end); static const uint32_t _HASH_BITS; static const uint32_t _HASHTABLESIZE; @@ -164,7 +164,7 @@ private: uint32_t _add_pos; uint32_t _last_copy_pos; - string _cache_add_data; + std::string _cache_add_data; uint32_t _cache_copy_start; uint32_t _cache_copy_length; @@ -183,9 +183,9 @@ private: uint32_t _total_bytes_to_process; uint32_t _total_bytes_processed; - istream *_patch_stream; + std::istream *_patch_stream; pofstream _write_stream; - istream *_origfile_stream; + std::istream *_origfile_stream; Filename _patch_file; Filename _orig_file; diff --git a/panda/src/express/pointerTo.I b/panda/src/express/pointerTo.I index 20e667fa11..e0f8c85046 100644 --- a/panda/src/express/pointerTo.I +++ b/panda/src/express/pointerTo.I @@ -35,7 +35,7 @@ PointerTo(const PointerTo ©) : template INLINE PointerTo:: PointerTo(PointerTo &&from) noexcept : - PointerToBase(move(from)) + PointerToBase(std::move(from)) { } @@ -45,7 +45,7 @@ PointerTo(PointerTo &&from) noexcept : template INLINE PointerTo &PointerTo:: operator = (PointerTo &&from) noexcept { - this->reassign(move(from)); + this->reassign(std::move(from)); return *this; } @@ -158,7 +158,7 @@ ConstPointerTo(const ConstPointerTo ©) : template INLINE ConstPointerTo:: ConstPointerTo(PointerTo &&from) noexcept : - PointerToBase(move(from)) + PointerToBase(std::move(from)) { } @@ -168,7 +168,7 @@ ConstPointerTo(PointerTo &&from) noexcept : template INLINE ConstPointerTo:: ConstPointerTo(ConstPointerTo &&from) noexcept : - PointerToBase(move(from)) + PointerToBase(std::move(from)) { } @@ -178,7 +178,7 @@ ConstPointerTo(ConstPointerTo &&from) noexcept : template INLINE ConstPointerTo &ConstPointerTo:: operator = (PointerTo &&from) noexcept { - this->reassign(move(from)); + this->reassign(std::move(from)); return *this; } @@ -188,7 +188,7 @@ operator = (PointerTo &&from) noexcept { template INLINE ConstPointerTo &ConstPointerTo:: operator = (ConstPointerTo &&from) noexcept { - this->reassign(move(from)); + this->reassign(std::move(from)); return *this; } diff --git a/panda/src/express/pointerToArray.I b/panda/src/express/pointerToArray.I index 04e943c5fc..5fb560b695 100644 --- a/panda/src/express/pointerToArray.I +++ b/panda/src/express/pointerToArray.I @@ -85,7 +85,7 @@ PointerToArray(const Element *begin, const Element *end, TypeHandle type_handle) template INLINE PointerToArray:: PointerToArray(PointerToArray &&from) noexcept : - PointerToArrayBase(move(from)), + PointerToArrayBase(std::move(from)), _type_handle(from._type_handle) { } @@ -96,7 +96,7 @@ PointerToArray(PointerToArray &&from) noexcept : template INLINE PointerToArray:: PointerToArray(pvector &&from, TypeHandle type_handle) : - PointerToArrayBase(new ReferenceCountedVector(move(from))), + PointerToArrayBase(new ReferenceCountedVector(std::move(from))), _type_handle(type_handle) { } @@ -443,7 +443,7 @@ set_element(size_type n, const Element &value) { * string. */ template -INLINE string PointerToArray:: +INLINE std::string PointerToArray:: get_data() const { return get_subdata(0, size()); } @@ -457,7 +457,7 @@ get_data() const { */ template INLINE void PointerToArray:: -set_data(const string &data) { +set_data(const std::string &data) { set_subdata(0, size(), data); } @@ -469,12 +469,12 @@ set_data(const string &data) { * through element (n + count - 1)--as a block of raw data in a string. */ template -INLINE string PointerToArray:: +INLINE std::string PointerToArray:: get_subdata(size_type n, size_type count) const { - n = min(n, size()); - count = max(count, n); - count = min(count, size() - n); - return string((const char *)(p() + n), sizeof(Element) * count); + n = std::min(n, size()); + count = std::max(count, n); + count = std::min(count, size() - n); + return std::string((const char *)(p() + n), sizeof(Element) * count); } /** @@ -489,7 +489,7 @@ get_subdata(size_type n, size_type count) const { */ template INLINE void PointerToArray:: -set_subdata(size_type n, size_type count, const string &data) { +set_subdata(size_type n, size_type count, const std::string &data) { nassertv((data.length() % sizeof(Element)) == 0); nassertv(n <= size() && n + count <= size()); if ((this->_void_ptr) == nullptr) { @@ -631,7 +631,7 @@ template INLINE PointerToArray &PointerToArray:: operator = (PointerToArray &&from) noexcept { _type_handle = from._type_handle; - ((PointerToArray *)this)->reassign(move(from)); + ((PointerToArray *)this)->reassign(std::move(from)); return *this; } @@ -697,7 +697,7 @@ ConstPointerToArray(const ConstPointerToArray ©) : template INLINE ConstPointerToArray:: ConstPointerToArray(PointerToArray &&from) noexcept : - PointerToArrayBase(move(from)), + PointerToArrayBase(std::move(from)), _type_handle(from._type_handle) { } @@ -708,7 +708,7 @@ ConstPointerToArray(PointerToArray &&from) noexcept : template INLINE ConstPointerToArray:: ConstPointerToArray(ConstPointerToArray &&from) noexcept : - PointerToArrayBase(move(from)), + PointerToArrayBase(std::move(from)), _type_handle(from._type_handle) { } @@ -719,7 +719,7 @@ ConstPointerToArray(ConstPointerToArray &&from) noexcept : template INLINE ConstPointerToArray:: ConstPointerToArray(pvector &&from, TypeHandle type_handle) : - PointerToArrayBase(new ReferenceCountedVector(move(from))), + PointerToArrayBase(new ReferenceCountedVector(std::move(from))), _type_handle(type_handle) { } @@ -950,7 +950,7 @@ get_element(size_type n) const { * string. */ template -INLINE string ConstPointerToArray:: +INLINE std::string ConstPointerToArray:: get_data() const { return get_subdata(0, size()); } @@ -963,12 +963,12 @@ get_data() const { * through element (n + count - 1)--as a block of raw data in a string. */ template -INLINE string ConstPointerToArray:: +INLINE std::string ConstPointerToArray:: get_subdata(size_type n, size_type count) const { - n = min(n, size()); - count = max(count, n); - count = min(count, size() - n); - return string((const char *)(p() + n), sizeof(Element) * count); + n = std::min(n, size()); + count = std::max(count, n); + count = std::min(count, size() - n); + return std::string((const char *)(p() + n), sizeof(Element) * count); } /** @@ -1085,7 +1085,7 @@ template INLINE ConstPointerToArray &ConstPointerToArray:: operator = (PointerToArray &&from) noexcept { _type_handle = from._type_handle; - ((ConstPointerToArray *)this)->reassign(move(from)); + ((ConstPointerToArray *)this)->reassign(std::move(from)); return *this; } @@ -1096,7 +1096,7 @@ template INLINE ConstPointerToArray &ConstPointerToArray:: operator = (ConstPointerToArray &&from) noexcept { _type_handle = from._type_handle; - ((ConstPointerToArray *)this)->reassign(move(from)); + ((ConstPointerToArray *)this)->reassign(std::move(from)); return *this; } diff --git a/panda/src/express/pointerToArray.h b/panda/src/express/pointerToArray.h index 57c8be2f92..7ff07a5ef1 100644 --- a/panda/src/express/pointerToArray.h +++ b/panda/src/express/pointerToArray.h @@ -110,7 +110,7 @@ PUBLISHED: EXTENSION(PyObject *get_data() const); EXTENSION(void set_data(PyObject *data)); EXTENSION(PyObject *get_subdata(size_type n, size_type count) const); - INLINE void set_subdata(size_type n, size_type count, const string &data); + INLINE void set_subdata(size_type n, size_type count, const std::string &data); INLINE int get_ref_count() const; INLINE int get_node_ref_count() const; @@ -196,10 +196,10 @@ public: // Methods to help out Python and other high-level languages. INLINE const Element &get_element(size_type n) const; INLINE void set_element(size_type n, const Element &value); - INLINE string get_data() const; - INLINE void set_data(const string &data); - INLINE string get_subdata(size_type n, size_type count) const; - INLINE void set_subdata(size_type n, size_type count, const string &data); + INLINE std::string get_data() const; + INLINE void set_data(const std::string &data); + INLINE std::string get_subdata(size_type n, size_type count) const; + INLINE void set_subdata(size_type n, size_type count, const std::string &data); // These functions are only to be used in Reading through BamReader. They // are designed to work in pairs, so that you register what is returned by @@ -336,8 +336,8 @@ PUBLISHED: // Methods to help out Python and other high-level languages. INLINE const Element &get_element(size_type n) const; - INLINE string get_data() const; - INLINE string get_subdata(size_type n, size_type count) const; + INLINE std::string get_data() const; + INLINE std::string get_subdata(size_type n, size_type count) const; INLINE int get_ref_count() const; INLINE void ref() const; diff --git a/panda/src/express/pointerToArrayBase.I b/panda/src/express/pointerToArrayBase.I index a5188040fb..d22b113ac5 100644 --- a/panda/src/express/pointerToArrayBase.I +++ b/panda/src/express/pointerToArrayBase.I @@ -45,7 +45,7 @@ ReferenceCountedVector(const Element *begin, const Element *end, TypeHandle type template INLINE ReferenceCountedVector:: ReferenceCountedVector(pvector &&from) : - pvector(move(from)) + pvector(std::move(from)) { } @@ -138,7 +138,7 @@ PointerToArrayBase(const PointerToArrayBase ©) : template INLINE PointerToArrayBase:: PointerToArrayBase(PointerToArrayBase &&from) noexcept : - PointerToBase >(move(from)) + PointerToBase >(std::move(from)) { } diff --git a/panda/src/express/pointerToArray_ext.I b/panda/src/express/pointerToArray_ext.I index eedb92d3f4..ee4c10e155 100644 --- a/panda/src/express/pointerToArray_ext.I +++ b/panda/src/express/pointerToArray_ext.I @@ -248,9 +248,9 @@ set_data(PyObject *data) { template INLINE PyObject *Extension >:: get_subdata(size_t n, size_t count) const { - n = min(n, this->_this->size()); - count = max(count, n); - count = min(count, this->_this->size() - n); + n = std::min(n, this->_this->size()); + count = std::max(count, n); + count = std::min(count, this->_this->size() - n); #if PY_MAJOR_VERSION >= 3 return PyBytes_FromStringAndSize((char *)(this->_this->p() + n), sizeof(Element) * count); #else @@ -293,9 +293,9 @@ get_data() const { template INLINE PyObject *Extension >:: get_subdata(size_t n, size_t count) const { - n = min(n, this->_this->size()); - count = max(count, n); - count = min(count, this->_this->size() - n); + n = std::min(n, this->_this->size()); + count = std::max(count, n); + count = std::min(count, this->_this->size() - n); #if PY_MAJOR_VERSION >= 3 return PyBytes_FromStringAndSize((char *)(this->_this->p() + n), sizeof(Element) * count); #else diff --git a/panda/src/express/pointerToBase.I b/panda/src/express/pointerToBase.I index acd3123394..e6e749f1f4 100644 --- a/panda/src/express/pointerToBase.I +++ b/panda/src/express/pointerToBase.I @@ -176,7 +176,7 @@ clear() { */ template INLINE void PointerToBase:: -output(ostream &out) const { +output(std::ostream &out) const { out << _void_ptr; if (_void_ptr != nullptr) { out << ":" << ((To *)_void_ptr)->get_ref_count(); diff --git a/panda/src/express/pointerToBase.h b/panda/src/express/pointerToBase.h index 4ac546993c..057a465454 100644 --- a/panda/src/express/pointerToBase.h +++ b/panda/src/express/pointerToBase.h @@ -49,11 +49,11 @@ protected: PUBLISHED: ALWAYS_INLINE void clear(); - void output(ostream &out) const; + void output(std::ostream &out) const; }; template -INLINE ostream &operator <<(ostream &out, const PointerToBase &pointer) { +INLINE std::ostream &operator <<(std::ostream &out, const PointerToBase &pointer) { pointer.output(out); return out; } diff --git a/panda/src/express/profileTimer.I b/panda/src/express/profileTimer.I index 107f86f6af..bd5102e6de 100644 --- a/panda/src/express/profileTimer.I +++ b/panda/src/express/profileTimer.I @@ -28,7 +28,7 @@ getTime() { INLINE void ProfileTimer:: mark(const char* tag) { if (!_entries) { - cerr << "ProfileTimer::mark !_entries" << endl; + std::cerr << "ProfileTimer::mark !_entries" << std::endl; exit(1); } if (_entryCount < _maxEntries-1) { diff --git a/panda/src/express/profileTimer.h b/panda/src/express/profileTimer.h index 94eb39bd01..6a2daae21a 100644 --- a/panda/src/express/profileTimer.h +++ b/panda/src/express/profileTimer.h @@ -54,10 +54,10 @@ PUBLISHED: // Don't call any of the following during timing: (Because they are slow, // not because anything will break). double getTotalTime() const; - static void consolidateAllTo(ostream &out=cout); - void consolidateTo(ostream &out=cout) const; - static void printAllTo(ostream &out=cout); - void printTo(ostream &out=cout) const; + static void consolidateAllTo(std::ostream &out=std::cout); + void consolidateTo(std::ostream &out=std::cout) const; + static void printAllTo(std::ostream &out=std::cout); + void printTo(std::ostream &out=std::cout) const; public: /* diff --git a/panda/src/express/ramfile.I b/panda/src/express/ramfile.I index 797eab3c1b..cd045a3d3d 100644 --- a/panda/src/express/ramfile.I +++ b/panda/src/express/ramfile.I @@ -41,7 +41,7 @@ tell() const { * Returns the entire buffer contents as a string, regardless of the current * data pointer. */ -INLINE const string &Ramfile:: +INLINE const std::string &Ramfile:: get_data() const { return _data; } diff --git a/panda/src/express/ramfile.h b/panda/src/express/ramfile.h index a4dbd17727..0d7c031fcc 100644 --- a/panda/src/express/ramfile.h +++ b/panda/src/express/ramfile.h @@ -37,12 +37,12 @@ PUBLISHED: INLINE void clear(); public: - string read(size_t length); - string readline(); - INLINE const string &get_data() const; + std::string read(size_t length); + std::string readline(); + INLINE const std::string &get_data() const; size_t _pos; - string _data; + std::string _data; friend class Extension; }; diff --git a/panda/src/express/referenceCount.I b/panda/src/express/referenceCount.I index da0ede4a73..bb4ac1fc18 100644 --- a/panda/src/express/referenceCount.I +++ b/panda/src/express/referenceCount.I @@ -411,9 +411,9 @@ void RefCountObj:: init_type() { #if defined(HAVE_RTTI) && !defined(__EDG__) // If we have RTTI, we can determine the name of the base type. - string base_name = typeid(Base).name(); + std::string base_name = typeid(Base).name(); #else - string base_name = "unknown"; + std::string base_name = "unknown"; #endif TypeHandle base_type = register_dynamic_type(base_name); diff --git a/panda/src/express/subStream.I b/panda/src/express/subStream.I index 0749a4012a..30f8ecce60 100644 --- a/panda/src/express/subStream.I +++ b/panda/src/express/subStream.I @@ -15,14 +15,14 @@ * */ INLINE ISubStream:: -ISubStream() : istream(&_buf) { +ISubStream() : std::istream(&_buf) { } /** * */ INLINE ISubStream:: -ISubStream(IStreamWrapper *source, streampos start, streampos end) : istream(&_buf) { +ISubStream(IStreamWrapper *source, std::streampos start, std::streampos end) : std::istream(&_buf) { open(source, start, end); } @@ -36,7 +36,7 @@ ISubStream(IStreamWrapper *source, streampos start, streampos end) : istream(&_b * end of the source stream. */ INLINE ISubStream &ISubStream:: -open(IStreamWrapper *source, streampos start, streampos end) { +open(IStreamWrapper *source, std::streampos start, std::streampos end) { clear((ios_iostate)0); _buf.open(source, nullptr, start, end, false); return *this; @@ -56,14 +56,14 @@ close() { * */ INLINE OSubStream:: -OSubStream() : ostream(&_buf) { +OSubStream() : std::ostream(&_buf) { } /** * */ INLINE OSubStream:: -OSubStream(OStreamWrapper *dest, streampos start, streampos end, bool append) : ostream(&_buf) { +OSubStream(OStreamWrapper *dest, std::streampos start, std::streampos end, bool append) : std::ostream(&_buf) { open(dest, start, end, append); } @@ -77,7 +77,7 @@ OSubStream(OStreamWrapper *dest, streampos start, streampos end, bool append) : * end of the dest stream. */ INLINE OSubStream &OSubStream:: -open(OStreamWrapper *dest, streampos start, streampos end, bool append) { +open(OStreamWrapper *dest, std::streampos start, std::streampos end, bool append) { clear((ios_iostate)0); _buf.open(nullptr, dest, start, end, append); return *this; @@ -97,14 +97,14 @@ close() { * */ INLINE SubStream:: -SubStream() : iostream(&_buf) { +SubStream() : std::iostream(&_buf) { } /** * */ INLINE SubStream:: -SubStream(StreamWrapper *nested, streampos start, streampos end, bool append) : iostream(&_buf) { +SubStream(StreamWrapper *nested, std::streampos start, std::streampos end, bool append) : std::iostream(&_buf) { open(nested, start, end, append); } @@ -117,7 +117,7 @@ SubStream(StreamWrapper *nested, streampos start, streampos end, bool append) : * of the nested stream. */ INLINE SubStream &SubStream:: -open(StreamWrapper *nested, streampos start, streampos end, bool append) { +open(StreamWrapper *nested, std::streampos start, std::streampos end, bool append) { clear((ios_iostate)0); _buf.open(nested, nested, start, end, append); return *this; diff --git a/panda/src/express/subStream.h b/panda/src/express/subStream.h index 3d071b9c7f..84d8a8a460 100644 --- a/panda/src/express/subStream.h +++ b/panda/src/express/subStream.h @@ -27,16 +27,16 @@ * The source stream must be one that we can randomly seek within. The * resulting ISubStream will also support arbitrary seeks. */ -class EXPCL_PANDAEXPRESS ISubStream : public istream { +class EXPCL_PANDAEXPRESS ISubStream : public std::istream { PUBLISHED: INLINE ISubStream(); - INLINE explicit ISubStream(IStreamWrapper *source, streampos start, streampos end); + INLINE explicit ISubStream(IStreamWrapper *source, std::streampos start, std::streampos end); #if _MSC_VER >= 1800 INLINE ISubStream(const ISubStream ©) = delete; #endif - INLINE ISubStream &open(IStreamWrapper *source, streampos start, streampos end); + INLINE ISubStream &open(IStreamWrapper *source, std::streampos start, std::streampos end); INLINE ISubStream &close(); private: @@ -52,16 +52,16 @@ private: * The dest stream must be one that we can randomly seek within. The * resulting OSubStream will also support arbitrary seeks. */ -class EXPCL_PANDAEXPRESS OSubStream : public ostream { +class EXPCL_PANDAEXPRESS OSubStream : public std::ostream { PUBLISHED: INLINE OSubStream(); - INLINE explicit OSubStream(OStreamWrapper *dest, streampos start, streampos end, bool append = false); + INLINE explicit OSubStream(OStreamWrapper *dest, std::streampos start, std::streampos end, bool append = false); #if _MSC_VER >= 1800 INLINE OSubStream(const OSubStream ©) = delete; #endif - INLINE OSubStream &open(OStreamWrapper *dest, streampos start, streampos end, bool append = false); + INLINE OSubStream &open(OStreamWrapper *dest, std::streampos start, std::streampos end, bool append = false); INLINE OSubStream &close(); private: @@ -71,16 +71,16 @@ private: /** * Combined ISubStream and OSubStream for bidirectional I/O. */ -class EXPCL_PANDAEXPRESS SubStream : public iostream { +class EXPCL_PANDAEXPRESS SubStream : public std::iostream { PUBLISHED: INLINE SubStream(); - INLINE explicit SubStream(StreamWrapper *nested, streampos start, streampos end, bool append = false); + INLINE explicit SubStream(StreamWrapper *nested, std::streampos start, std::streampos end, bool append = false); #if _MSC_VER >= 1800 INLINE SubStream(const SubStream ©) = delete; #endif - INLINE SubStream &open(StreamWrapper *nested, streampos start, streampos end, bool append = false); + INLINE SubStream &open(StreamWrapper *nested, std::streampos start, std::streampos end, bool append = false); INLINE SubStream &close(); private: diff --git a/panda/src/express/subStreamBuf.h b/panda/src/express/subStreamBuf.h index bfa94e2e6e..260f849098 100644 --- a/panda/src/express/subStreamBuf.h +++ b/panda/src/express/subStreamBuf.h @@ -20,16 +20,16 @@ /** * The streambuf object that implements ISubStream. */ -class EXPCL_PANDAEXPRESS SubStreamBuf : public streambuf { +class EXPCL_PANDAEXPRESS SubStreamBuf : public std::streambuf { public: SubStreamBuf(); virtual ~SubStreamBuf(); - void open(IStreamWrapper *source, OStreamWrapper *dest, streampos start, streampos end, bool append); + void open(IStreamWrapper *source, OStreamWrapper *dest, std::streampos start, std::streampos end, bool append); void close(); - virtual streampos seekoff(streamoff off, ios_seekdir dir, ios_openmode which); - virtual streampos seekpos(streampos pos, ios_openmode which); + virtual std::streampos seekoff(std::streamoff off, ios_seekdir dir, ios_openmode which); + virtual std::streampos seekpos(std::streampos pos, ios_openmode which); protected: virtual int overflow(int c); @@ -39,11 +39,11 @@ protected: private: IStreamWrapper *_source; OStreamWrapper *_dest; - streampos _start; - streampos _end; + std::streampos _start; + std::streampos _end; bool _append; - streampos _gpos; - streampos _ppos; + std::streampos _gpos; + std::streampos _ppos; char *_buffer; }; diff --git a/panda/src/express/subfileInfo.I b/panda/src/express/subfileInfo.I index d488537b60..a0a7826f97 100644 --- a/panda/src/express/subfileInfo.I +++ b/panda/src/express/subfileInfo.I @@ -25,7 +25,7 @@ SubfileInfo() : * */ INLINE SubfileInfo:: -SubfileInfo(const FileReference *file, streampos start, streamsize size) : +SubfileInfo(const FileReference *file, std::streampos start, std::streamsize size) : _file(file), _start(start), _size(size) @@ -36,7 +36,7 @@ SubfileInfo(const FileReference *file, streampos start, streamsize size) : * */ INLINE SubfileInfo:: -SubfileInfo(const Filename &filename, streampos start, streamsize size) : +SubfileInfo(const Filename &filename, std::streampos start, std::streamsize size) : _file(new FileReference(filename)), _start(start), _size(size) @@ -96,7 +96,7 @@ get_filename() const { /** * Returns the offset within the file at which this file data begins. */ -INLINE streampos SubfileInfo:: +INLINE std::streampos SubfileInfo:: get_start() const { return _start; } @@ -105,13 +105,13 @@ get_start() const { * Returns the number of consecutive bytes, beginning at get_start(), that * correspond to this file data. */ -INLINE streamsize SubfileInfo:: +INLINE std::streamsize SubfileInfo:: get_size() const { return _size; } -INLINE ostream & -operator << (ostream &out, const SubfileInfo &info) { +INLINE std::ostream & +operator << (std::ostream &out, const SubfileInfo &info) { info.output(out); return out; } diff --git a/panda/src/express/subfileInfo.h b/panda/src/express/subfileInfo.h index de2f85fa3e..7faa59c1e6 100644 --- a/panda/src/express/subfileInfo.h +++ b/panda/src/express/subfileInfo.h @@ -26,8 +26,8 @@ class EXPCL_PANDAEXPRESS SubfileInfo { PUBLISHED: INLINE SubfileInfo(); - INLINE explicit SubfileInfo(const FileReference *file, streampos start, streamsize size); - INLINE explicit SubfileInfo(const Filename &filename, streampos start, streamsize size); + INLINE explicit SubfileInfo(const FileReference *file, std::streampos start, std::streamsize size); + INLINE explicit SubfileInfo(const Filename &filename, std::streampos start, std::streamsize size); INLINE SubfileInfo(const SubfileInfo ©); INLINE void operator = (const SubfileInfo ©); @@ -35,18 +35,18 @@ PUBLISHED: INLINE const FileReference *get_file() const; INLINE const Filename &get_filename() const; - INLINE streampos get_start() const; - INLINE streamsize get_size() const; + INLINE std::streampos get_start() const; + INLINE std::streamsize get_size() const; - void output(ostream &out) const; + void output(std::ostream &out) const; private: CPT(FileReference) _file; - streampos _start; - streamsize _size; + std::streampos _start; + std::streamsize _size; }; -INLINE ostream &operator << (ostream &out, const SubfileInfo &info); +INLINE std::ostream &operator << (std::ostream &out, const SubfileInfo &info); #include "subfileInfo.I" diff --git a/panda/src/express/threadSafePointerToBase.I b/panda/src/express/threadSafePointerToBase.I index d00bcf1dbc..bee16180b1 100644 --- a/panda/src/express/threadSafePointerToBase.I +++ b/panda/src/express/threadSafePointerToBase.I @@ -124,7 +124,7 @@ clear() { */ template INLINE void ThreadSafePointerToBase:: -output(ostream &out) const { +output(std::ostream &out) const { out << _void_ptr; if (_void_ptr != nullptr) { out << ":" << ((To *)_void_ptr)->get_ref_count(); diff --git a/panda/src/express/threadSafePointerToBase.h b/panda/src/express/threadSafePointerToBase.h index 78c6d75cca..764e538d2b 100644 --- a/panda/src/express/threadSafePointerToBase.h +++ b/panda/src/express/threadSafePointerToBase.h @@ -49,11 +49,11 @@ protected: PUBLISHED: INLINE void clear(); - void output(ostream &out) const; + void output(std::ostream &out) const; }; template -INLINE ostream &operator <<(ostream &out, const ThreadSafePointerToBase &pointer) { +INLINE std::ostream &operator <<(std::ostream &out, const ThreadSafePointerToBase &pointer) { pointer.output(out); return out; } diff --git a/panda/src/express/virtualFile.I b/panda/src/express/virtualFile.I index f9fee3c999..64fa9f7d00 100644 --- a/panda/src/express/virtualFile.I +++ b/panda/src/express/virtualFile.I @@ -31,9 +31,9 @@ get_original_filename() const { /** * Returns the entire contents of the file as a string. */ -INLINE string VirtualFile:: +INLINE std::string VirtualFile:: read_file(bool auto_unwrap) const { - string result; + std::string result; read_file(result, auto_unwrap); return result; } @@ -42,7 +42,7 @@ read_file(bool auto_unwrap) const { * Writes the entire contents of the file as a string, if it is writable. */ INLINE bool VirtualFile:: -write_file(const string &data, bool auto_wrap) { +write_file(const std::string &data, bool auto_wrap) { return write_file((const unsigned char *)data.data(), data.size(), auto_wrap); } @@ -57,8 +57,8 @@ set_original_filename(const Filename &filename) { } -INLINE ostream & -operator << (ostream &out, const VirtualFile &file) { +INLINE std::ostream & +operator << (std::ostream &out, const VirtualFile &file) { file.output(out); return out; } diff --git a/panda/src/express/virtualFile.h b/panda/src/express/virtualFile.h index 5322fce670..6bab505a43 100644 --- a/panda/src/express/virtualFile.h +++ b/panda/src/express/virtualFile.h @@ -52,51 +52,51 @@ PUBLISHED: BLOCKING PT(VirtualFileList) scan_directory() const; - void output(ostream &out) const; - BLOCKING void ls(ostream &out = cout) const; - BLOCKING void ls_all(ostream &out = cout) const; + void output(std::ostream &out) const; + BLOCKING void ls(std::ostream &out = std::cout) const; + BLOCKING void ls_all(std::ostream &out = std::cout) const; EXTENSION(PyObject *read_file(bool auto_unwrap) const); - BLOCKING virtual istream *open_read_file(bool auto_unwrap) const; - BLOCKING virtual void close_read_file(istream *stream) const; + BLOCKING virtual std::istream *open_read_file(bool auto_unwrap) const; + BLOCKING virtual void close_read_file(std::istream *stream) const; virtual bool was_read_successful() const; EXTENSION(PyObject *write_file(PyObject *data, bool auto_wrap)); - BLOCKING virtual ostream *open_write_file(bool auto_wrap, bool truncate); - BLOCKING virtual ostream *open_append_file(); - BLOCKING virtual void close_write_file(ostream *stream); + BLOCKING virtual std::ostream *open_write_file(bool auto_wrap, bool truncate); + BLOCKING virtual std::ostream *open_append_file(); + BLOCKING virtual void close_write_file(std::ostream *stream); - BLOCKING virtual iostream *open_read_write_file(bool truncate); - BLOCKING virtual iostream *open_read_append_file(); - BLOCKING virtual void close_read_write_file(iostream *stream); + BLOCKING virtual std::iostream *open_read_write_file(bool truncate); + BLOCKING virtual std::iostream *open_read_append_file(); + BLOCKING virtual void close_read_write_file(std::iostream *stream); - BLOCKING virtual streamsize get_file_size(istream *stream) const; - BLOCKING virtual streamsize get_file_size() const; + BLOCKING virtual std::streamsize get_file_size(std::istream *stream) const; + BLOCKING virtual std::streamsize get_file_size() const; BLOCKING virtual time_t get_timestamp() const; virtual bool get_system_info(SubfileInfo &info); public: - virtual bool atomic_compare_and_exchange_contents(string &orig_contents, const string &old_contents, const string &new_contents); - virtual bool atomic_read_contents(string &contents) const; + virtual bool atomic_compare_and_exchange_contents(std::string &orig_contents, const std::string &old_contents, const std::string &new_contents); + virtual bool atomic_read_contents(std::string &contents) const; - INLINE string read_file(bool auto_unwrap) const; - INLINE bool write_file(const string &data, bool auto_wrap); + INLINE std::string read_file(bool auto_unwrap) const; + INLINE bool write_file(const std::string &data, bool auto_wrap); INLINE void set_original_filename(const Filename &filename); - bool read_file(string &result, bool auto_unwrap) const; + bool read_file(std::string &result, bool auto_unwrap) const; virtual bool read_file(pvector &result, bool auto_unwrap) const; virtual bool write_file(const unsigned char *data, size_t data_size, bool auto_wrap); - static bool simple_read_file(istream *stream, pvector &result); - static bool simple_read_file(istream *stream, pvector &result, size_t max_bytes); + static bool simple_read_file(std::istream *stream, pvector &result); + static bool simple_read_file(std::istream *stream, pvector &result, size_t max_bytes); protected: virtual bool scan_local_directory(VirtualFileList *file_list, - const ov_set &mount_points) const; + const ov_set &mount_points) const; private: - void r_ls_all(ostream &out, const Filename &root) const; + void r_ls_all(std::ostream &out, const Filename &root) const; Filename _original_filename; @@ -121,7 +121,7 @@ private: friend class VirtualFileComposite; }; -INLINE ostream &operator << (ostream &out, const VirtualFile &file); +INLINE std::ostream &operator << (std::ostream &out, const VirtualFile &file); #include "virtualFile.I" diff --git a/panda/src/express/virtualFileComposite.h b/panda/src/express/virtualFileComposite.h index d7e39ed302..3d76b96168 100644 --- a/panda/src/express/virtualFileComposite.h +++ b/panda/src/express/virtualFileComposite.h @@ -38,7 +38,7 @@ public: protected: virtual bool scan_local_directory(VirtualFileList *file_list, - const ov_set &mount_points) const; + const ov_set &mount_points) const; private: VirtualFileSystem *_file_system; diff --git a/panda/src/express/virtualFileMount.I b/panda/src/express/virtualFileMount.I index f1195a49ef..31da104cf8 100644 --- a/panda/src/express/virtualFileMount.I +++ b/panda/src/express/virtualFileMount.I @@ -49,8 +49,8 @@ get_mount_flags() const { } -INLINE ostream & -operator << (ostream &out, const VirtualFileMount &mount) { +INLINE std::ostream & +operator << (std::ostream &out, const VirtualFileMount &mount) { mount.output(out); return out; } diff --git a/panda/src/express/virtualFileMount.h b/panda/src/express/virtualFileMount.h index 47b36b52f1..f192b268ce 100644 --- a/panda/src/express/virtualFileMount.h +++ b/panda/src/express/virtualFileMount.h @@ -58,33 +58,33 @@ public: virtual bool write_file(const Filename &file, bool do_compress, const unsigned char *data, size_t data_size); - virtual istream *open_read_file(const Filename &file) const=0; - istream *open_read_file(const Filename &file, bool do_uncompress) const; - virtual void close_read_file(istream *stream) const; + virtual std::istream *open_read_file(const Filename &file) const=0; + std::istream *open_read_file(const Filename &file, bool do_uncompress) const; + virtual void close_read_file(std::istream *stream) const; - virtual ostream *open_write_file(const Filename &file, bool truncate); - ostream *open_write_file(const Filename &file, bool do_compress, bool truncate); - virtual ostream *open_append_file(const Filename &file); - virtual void close_write_file(ostream *stream); + virtual std::ostream *open_write_file(const Filename &file, bool truncate); + std::ostream *open_write_file(const Filename &file, bool do_compress, bool truncate); + virtual std::ostream *open_append_file(const Filename &file); + virtual void close_write_file(std::ostream *stream); - virtual iostream *open_read_write_file(const Filename &file, bool truncate); - virtual iostream *open_read_append_file(const Filename &file); - virtual void close_read_write_file(iostream *stream); + virtual std::iostream *open_read_write_file(const Filename &file, bool truncate); + virtual std::iostream *open_read_append_file(const Filename &file); + virtual void close_read_write_file(std::iostream *stream); - virtual streamsize get_file_size(const Filename &file, istream *stream) const=0; - virtual streamsize get_file_size(const Filename &file) const=0; + virtual std::streamsize get_file_size(const Filename &file, std::istream *stream) const=0; + virtual std::streamsize get_file_size(const Filename &file) const=0; virtual time_t get_timestamp(const Filename &file) const=0; virtual bool get_system_info(const Filename &file, SubfileInfo &info); virtual bool scan_directory(vector_string &contents, const Filename &dir) const=0; - virtual bool atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents, const string &old_contents, const string &new_contents); - virtual bool atomic_read_contents(const Filename &file, string &contents) const; + virtual bool atomic_compare_and_exchange_contents(const Filename &file, std::string &orig_contents, const std::string &old_contents, const std::string &new_contents); + virtual bool atomic_read_contents(const Filename &file, std::string &contents) const; PUBLISHED: - virtual void output(ostream &out) const; - virtual void write(ostream &out) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out) const; protected: VirtualFileSystem *_file_system; @@ -112,7 +112,7 @@ private: friend class VirtualFileSystem; }; -INLINE ostream &operator << (ostream &out, const VirtualFileMount &mount); +INLINE std::ostream &operator << (std::ostream &out, const VirtualFileMount &mount); #include "virtualFileMount.I" diff --git a/panda/src/express/virtualFileMountAndroidAsset.I b/panda/src/express/virtualFileMountAndroidAsset.I index 7a96300d99..c3079e04ee 100644 --- a/panda/src/express/virtualFileMountAndroidAsset.I +++ b/panda/src/express/virtualFileMountAndroidAsset.I @@ -15,7 +15,7 @@ * */ VirtualFileMountAndroidAsset:: -VirtualFileMountAndroidAsset(AAssetManager *mgr, const string &apk_path) : +VirtualFileMountAndroidAsset(AAssetManager *mgr, const std::string &apk_path) : _asset_mgr(mgr), _apk_path(apk_path) { } @@ -25,5 +25,5 @@ VirtualFileMountAndroidAsset(AAssetManager *mgr, const string &apk_path) : */ INLINE VirtualFileMountAndroidAsset::AssetStream:: AssetStream(AAsset *asset) : - istream(new VirtualFileMountAndroidAsset::AssetStreamBuf(asset)) { + std::istream(new VirtualFileMountAndroidAsset::AssetStreamBuf(asset)) { } diff --git a/panda/src/express/virtualFileMountAndroidAsset.h b/panda/src/express/virtualFileMountAndroidAsset.h index 792db38ffc..650180f7eb 100644 --- a/panda/src/express/virtualFileMountAndroidAsset.h +++ b/panda/src/express/virtualFileMountAndroidAsset.h @@ -29,7 +29,7 @@ */ class EXPCL_PANDAEXPRESS VirtualFileMountAndroidAsset : public VirtualFileMount { PUBLISHED: - INLINE VirtualFileMountAndroidAsset(AAssetManager *mgr, const string &apk_path); + INLINE VirtualFileMountAndroidAsset(AAssetManager *mgr, const std::string &apk_path); virtual ~VirtualFileMountAndroidAsset(); public: @@ -42,9 +42,9 @@ public: virtual bool read_file(const Filename &file, bool do_uncompress, pvector &result) const; - virtual istream *open_read_file(const Filename &file) const; - virtual streamsize get_file_size(const Filename &file, istream *stream) const; - virtual streamsize get_file_size(const Filename &file) const; + virtual std::istream *open_read_file(const Filename &file) const; + virtual std::streamsize get_file_size(const Filename &file, std::istream *stream) const; + virtual std::streamsize get_file_size(const Filename &file) const; virtual time_t get_timestamp(const Filename &file) const; virtual bool get_system_info(const Filename &file, SubfileInfo &info); @@ -53,21 +53,21 @@ public: private: AAssetManager *_asset_mgr; - string _apk_path; + std::string _apk_path; - class AssetStream : public istream { + class AssetStream : public std::istream { public: INLINE AssetStream(AAsset *asset); virtual ~AssetStream(); }; - class AssetStreamBuf : public streambuf { + class AssetStreamBuf : public std::streambuf { public: AssetStreamBuf(AAsset *asset); virtual ~AssetStreamBuf(); - virtual streampos seekoff(streamoff off, ios_seekdir dir, ios_openmode which); - virtual streampos seekpos(streampos pos, ios_openmode which); + virtual std::streampos seekoff(std::streamoff off, ios_seekdir dir, ios_openmode which); + virtual std::streampos seekpos(std::streampos pos, ios_openmode which); protected: virtual int underflow(); diff --git a/panda/src/express/virtualFileMountMultifile.h b/panda/src/express/virtualFileMountMultifile.h index d82b29af4d..3676990042 100644 --- a/panda/src/express/virtualFileMountMultifile.h +++ b/panda/src/express/virtualFileMountMultifile.h @@ -38,16 +38,16 @@ public: virtual bool read_file(const Filename &file, bool do_uncompress, pvector &result) const; - virtual istream *open_read_file(const Filename &file) const; - virtual streamsize get_file_size(const Filename &file, istream *stream) const; - virtual streamsize get_file_size(const Filename &file) const; + virtual std::istream *open_read_file(const Filename &file) const; + virtual std::streamsize get_file_size(const Filename &file, std::istream *stream) const; + virtual std::streamsize get_file_size(const Filename &file) const; virtual time_t get_timestamp(const Filename &file) const; virtual bool get_system_info(const Filename &file, SubfileInfo &info); virtual bool scan_directory(vector_string &contents, const Filename &dir) const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: PT(Multifile) _multifile; diff --git a/panda/src/express/virtualFileMountRamdisk.I b/panda/src/express/virtualFileMountRamdisk.I index b943f8bb51..27c07c4dce 100644 --- a/panda/src/express/virtualFileMountRamdisk.I +++ b/panda/src/express/virtualFileMountRamdisk.I @@ -15,7 +15,7 @@ * */ INLINE VirtualFileMountRamdisk::FileBase:: -FileBase(const string &basename) : _basename(basename), _timestamp(time(nullptr)) { +FileBase(const std::string &basename) : _basename(basename), _timestamp(time(nullptr)) { } /** @@ -30,7 +30,7 @@ operator < (const FileBase &other) const { * */ INLINE VirtualFileMountRamdisk::File:: -File(const string &basename) : +File(const std::string &basename) : FileBase(basename), _wrapper(&_data, false, true) { @@ -40,5 +40,5 @@ File(const string &basename) : * */ INLINE VirtualFileMountRamdisk::Directory:: -Directory(const string &basename) : FileBase(basename) { +Directory(const std::string &basename) : FileBase(basename) { } diff --git a/panda/src/express/virtualFileMountRamdisk.h b/panda/src/express/virtualFileMountRamdisk.h index 9812746534..0175f2682c 100644 --- a/panda/src/express/virtualFileMountRamdisk.h +++ b/panda/src/express/virtualFileMountRamdisk.h @@ -42,23 +42,23 @@ public: virtual bool is_regular_file(const Filename &file) const; virtual bool is_writable(const Filename &file) const; - virtual istream *open_read_file(const Filename &file) const; - virtual ostream *open_write_file(const Filename &file, bool truncate); - virtual ostream *open_append_file(const Filename &file); - virtual iostream *open_read_write_file(const Filename &file, bool truncate); - virtual iostream *open_read_append_file(const Filename &file); + virtual std::istream *open_read_file(const Filename &file) const; + virtual std::ostream *open_write_file(const Filename &file, bool truncate); + virtual std::ostream *open_append_file(const Filename &file); + virtual std::iostream *open_read_write_file(const Filename &file, bool truncate); + virtual std::iostream *open_read_append_file(const Filename &file); - virtual streamsize get_file_size(const Filename &file, istream *stream) const; - virtual streamsize get_file_size(const Filename &file) const; + virtual std::streamsize get_file_size(const Filename &file, std::istream *stream) const; + virtual std::streamsize get_file_size(const Filename &file) const; virtual time_t get_timestamp(const Filename &file) const; virtual bool scan_directory(vector_string &contents, const Filename &dir) const; - virtual bool atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents, const string &old_contents, const string &new_contents); - virtual bool atomic_read_contents(const Filename &file, string &contents) const; + virtual bool atomic_compare_and_exchange_contents(const Filename &file, std::string &orig_contents, const std::string &old_contents, const std::string &new_contents); + virtual bool atomic_read_contents(const Filename &file, std::string &contents) const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: class FileBase; @@ -67,13 +67,13 @@ private: class FileBase : public TypedReferenceCount { public: - INLINE FileBase(const string &basename); + INLINE FileBase(const std::string &basename); virtual ~FileBase(); INLINE bool operator < (const FileBase &other) const; virtual bool is_directory() const; - string _basename; + std::string _basename; time_t _timestamp; public: @@ -96,9 +96,9 @@ private: class File : public FileBase { public: - INLINE File(const string &basename); + INLINE File(const std::string &basename); - stringstream _data; + std::stringstream _data; StreamWrapper _wrapper; public: @@ -123,14 +123,14 @@ private: class Directory : public FileBase { public: - INLINE Directory(const string &basename); + INLINE Directory(const std::string &basename); virtual bool is_directory() const; - PT(FileBase) do_find_file(const string &filename) const; - PT(File) do_create_file(const string &filename); - PT(Directory) do_make_directory(const string &filename); - PT(FileBase) do_delete_file(const string &filename); + PT(FileBase) do_find_file(const std::string &filename) const; + PT(File) do_create_file(const std::string &filename); + PT(Directory) do_make_directory(const std::string &filename); + PT(FileBase) do_delete_file(const std::string &filename); bool do_scan_directory(vector_string &contents) const; Files _files; diff --git a/panda/src/express/virtualFileMountSystem.h b/panda/src/express/virtualFileMountSystem.h index 2854c32ae0..69761b1df7 100644 --- a/panda/src/express/virtualFileMountSystem.h +++ b/panda/src/express/virtualFileMountSystem.h @@ -38,24 +38,24 @@ public: virtual bool is_regular_file(const Filename &file) const; virtual bool is_writable(const Filename &file) const; - virtual istream *open_read_file(const Filename &file) const; - virtual ostream *open_write_file(const Filename &file, bool truncate); - virtual ostream *open_append_file(const Filename &file); - virtual iostream *open_read_write_file(const Filename &file, bool truncate); - virtual iostream *open_read_append_file(const Filename &file); + virtual std::istream *open_read_file(const Filename &file) const; + virtual std::ostream *open_write_file(const Filename &file, bool truncate); + virtual std::ostream *open_append_file(const Filename &file); + virtual std::iostream *open_read_write_file(const Filename &file, bool truncate); + virtual std::iostream *open_read_append_file(const Filename &file); - virtual streamsize get_file_size(const Filename &file, istream *stream) const; - virtual streamsize get_file_size(const Filename &file) const; + virtual std::streamsize get_file_size(const Filename &file, std::istream *stream) const; + virtual std::streamsize get_file_size(const Filename &file) const; virtual time_t get_timestamp(const Filename &file) const; virtual bool get_system_info(const Filename &file, SubfileInfo &info); virtual bool scan_directory(vector_string &contents, const Filename &dir) const; - virtual bool atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents, const string &old_contents, const string &new_contents); - virtual bool atomic_read_contents(const Filename &file, string &contents) const; + virtual bool atomic_compare_and_exchange_contents(const Filename &file, std::string &orig_contents, const std::string &old_contents, const std::string &new_contents); + virtual bool atomic_read_contents(const Filename &file, std::string &contents) const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: Filename _physical_filename; diff --git a/panda/src/express/virtualFileSimple.h b/panda/src/express/virtualFileSimple.h index c0f1da1fc7..671d435f44 100644 --- a/panda/src/express/virtualFileSimple.h +++ b/panda/src/express/virtualFileSimple.h @@ -45,30 +45,30 @@ PUBLISHED: virtual bool rename_file(VirtualFile *new_file); virtual bool copy_file(VirtualFile *new_file); - virtual istream *open_read_file(bool auto_unwrap) const; - virtual void close_read_file(istream *stream) const; - virtual ostream *open_write_file(bool auto_wrap, bool truncate); - virtual ostream *open_append_file(); - virtual void close_write_file(ostream *stream); - virtual iostream *open_read_write_file(bool truncate); - virtual iostream *open_read_append_file(); - virtual void close_read_write_file(iostream *stream); + virtual std::istream *open_read_file(bool auto_unwrap) const; + virtual void close_read_file(std::istream *stream) const; + virtual std::ostream *open_write_file(bool auto_wrap, bool truncate); + virtual std::ostream *open_append_file(); + virtual void close_write_file(std::ostream *stream); + virtual std::iostream *open_read_write_file(bool truncate); + virtual std::iostream *open_read_append_file(); + virtual void close_read_write_file(std::iostream *stream); - virtual streamsize get_file_size(istream *stream) const; - virtual streamsize get_file_size() const; + virtual std::streamsize get_file_size(std::istream *stream) const; + virtual std::streamsize get_file_size() const; virtual time_t get_timestamp() const; virtual bool get_system_info(SubfileInfo &info); public: - virtual bool atomic_compare_and_exchange_contents(string &orig_contents, const string &old_contents, const string &new_contents); - virtual bool atomic_read_contents(string &contents) const; + virtual bool atomic_compare_and_exchange_contents(std::string &orig_contents, const std::string &old_contents, const std::string &new_contents); + virtual bool atomic_read_contents(std::string &contents) const; virtual bool read_file(pvector &result, bool auto_unwrap) const; virtual bool write_file(const unsigned char *data, size_t data_size, bool auto_wrap); protected: virtual bool scan_local_directory(VirtualFileList *file_list, - const ov_set &mount_points) const; + const ov_set &mount_points) const; private: VirtualFileMount *_mount; diff --git a/panda/src/express/virtualFileSystem.I b/panda/src/express/virtualFileSystem.I index b2f86e17bb..cd9e9d8a03 100644 --- a/panda/src/express/virtualFileSystem.I +++ b/panda/src/express/virtualFileSystem.I @@ -93,11 +93,11 @@ ls_all(const Filename &filename) const { * than vfs-implicit-pz, which will automatically decompress a file if the * extension .pz is *not* given. */ -INLINE string VirtualFileSystem:: +INLINE std::string VirtualFileSystem:: read_file(const Filename &filename, bool auto_unwrap) const { - string result; + std::string result; bool okflag = read_file(filename, result, auto_unwrap); - nassertr(okflag, string()); + nassertr(okflag, std::string()); return result; } @@ -109,7 +109,7 @@ read_file(const Filename &filename, bool auto_unwrap) const { * compressed while writing. */ INLINE bool VirtualFileSystem:: -write_file(const Filename &filename, const string &data, bool auto_wrap) { +write_file(const Filename &filename, const std::string &data, bool auto_wrap) { return write_file(filename, (const unsigned char *)data.data(), data.size(), auto_wrap); } @@ -124,7 +124,7 @@ write_file(const Filename &filename, const string &data, bool auto_wrap) { * extension .pz is *not* given. */ INLINE bool VirtualFileSystem:: -read_file(const Filename &filename, string &result, bool auto_unwrap) const { +read_file(const Filename &filename, std::string &result, bool auto_unwrap) const { PT(VirtualFile) file = get_file(filename, false); return (file != nullptr && file->read_file(result, auto_unwrap)); } diff --git a/panda/src/express/virtualFileSystem.h b/panda/src/express/virtualFileSystem.h index e1d7e6fd37..7da00d4249 100644 --- a/panda/src/express/virtualFileSystem.h +++ b/panda/src/express/virtualFileSystem.h @@ -48,9 +48,9 @@ PUBLISHED: BLOCKING bool mount(Multifile *multifile, const Filename &mount_point, int flags); BLOCKING bool mount(const Filename &physical_filename, const Filename &mount_point, - int flags, const string &password = ""); + int flags, const std::string &password = ""); BLOCKING bool mount_loop(const Filename &virtual_filename, const Filename &mount_point, - int flags, const string &password = ""); + int flags, const std::string &password = ""); bool mount(VirtualFileMount *mount, const Filename &mount_point, int flags); BLOCKING int unmount(Multifile *multifile); BLOCKING int unmount(const Filename &physical_filename); @@ -78,7 +78,7 @@ PUBLISHED: BLOCKING bool copy_file(const Filename &orig_filename, const Filename &new_filename); BLOCKING bool resolve_filename(Filename &filename, const DSearchPath &searchpath, - const string &default_extension = string()) const; + const std::string &default_extension = std::string()) const; BLOCKING int find_all_files(const Filename &filename, const DSearchPath &searchpath, DSearchPath::Results &results) const; @@ -91,42 +91,42 @@ PUBLISHED: INLINE void ls(const Filename &filename) const; INLINE void ls_all(const Filename &filename) const; - void write(ostream &out) const; + void write(std::ostream &out) const; static VirtualFileSystem *get_global_ptr(); EXTENSION(PyObject *read_file(const Filename &filename, bool auto_unwrap) const); - BLOCKING istream *open_read_file(const Filename &filename, bool auto_unwrap) const; - BLOCKING static void close_read_file(istream *stream); + BLOCKING std::istream *open_read_file(const Filename &filename, bool auto_unwrap) const; + BLOCKING static void close_read_file(std::istream *stream); EXTENSION(PyObject *write_file(const Filename &filename, PyObject *data, bool auto_wrap)); - BLOCKING ostream *open_write_file(const Filename &filename, bool auto_wrap, bool truncate); - BLOCKING ostream *open_append_file(const Filename &filename); - BLOCKING static void close_write_file(ostream *stream); + BLOCKING std::ostream *open_write_file(const Filename &filename, bool auto_wrap, bool truncate); + BLOCKING std::ostream *open_append_file(const Filename &filename); + BLOCKING static void close_write_file(std::ostream *stream); - BLOCKING iostream *open_read_write_file(const Filename &filename, bool truncate); - BLOCKING iostream *open_read_append_file(const Filename &filename); - BLOCKING static void close_read_write_file(iostream *stream); + BLOCKING std::iostream *open_read_write_file(const Filename &filename, bool truncate); + BLOCKING std::iostream *open_read_append_file(const Filename &filename); + BLOCKING static void close_read_write_file(std::iostream *stream); public: // We provide Python versions of these as efficient extension methods, // above. - BLOCKING INLINE string read_file(const Filename &filename, bool auto_unwrap) const; - BLOCKING INLINE bool write_file(const Filename &filename, const string &data, bool auto_wrap); + BLOCKING INLINE std::string read_file(const Filename &filename, bool auto_unwrap) const; + BLOCKING INLINE bool write_file(const Filename &filename, const std::string &data, bool auto_wrap); - bool atomic_compare_and_exchange_contents(const Filename &filename, string &orig_contents, const string &old_contents, const string &new_contents); - bool atomic_read_contents(const Filename &filename, string &contents) const; + bool atomic_compare_and_exchange_contents(const Filename &filename, std::string &orig_contents, const std::string &old_contents, const std::string &new_contents); + bool atomic_read_contents(const Filename &filename, std::string &contents) const; - INLINE bool read_file(const Filename &filename, string &result, bool auto_unwrap) const; + INLINE bool read_file(const Filename &filename, std::string &result, bool auto_unwrap) const; INLINE bool read_file(const Filename &filename, pvector &result, bool auto_unwrap) const; INLINE bool write_file(const Filename &filename, const unsigned char *data, size_t data_size, bool auto_wrap); void scan_mount_points(vector_string &names, const Filename &path) const; - static void parse_options(const string &options, - int &flags, string &password); - static void parse_option(const string &option, - int &flags, string &password); + static void parse_options(const std::string &options, + int &flags, std::string &password); + static void parse_option(const std::string &option, + int &flags, std::string &password); public: // These flags are passed to do_get_file() and diff --git a/panda/src/express/weakPointerToBase.I b/panda/src/express/weakPointerToBase.I index 4b610e34fd..30690458be 100644 --- a/panda/src/express/weakPointerToBase.I +++ b/panda/src/express/weakPointerToBase.I @@ -505,7 +505,7 @@ refresh() const { */ template INLINE void WeakPointerToBase:: -output(ostream &out) const { +output(std::ostream &out) const { out << _void_ptr; if (was_deleted()) { out << ":deleted"; diff --git a/panda/src/express/weakPointerToBase.h b/panda/src/express/weakPointerToBase.h index 34960920ab..b1267c448a 100644 --- a/panda/src/express/weakPointerToBase.h +++ b/panda/src/express/weakPointerToBase.h @@ -88,11 +88,11 @@ PUBLISHED: INLINE void clear(); INLINE void refresh() const; - void output(ostream &out) const; + void output(std::ostream &out) const; }; template -INLINE ostream &operator <<(ostream &out, const WeakPointerToBase &pointer) { +INLINE std::ostream &operator <<(std::ostream &out, const WeakPointerToBase &pointer) { pointer.output(out); return out; } diff --git a/panda/src/express/windowsRegistry.h b/panda/src/express/windowsRegistry.h index d8fa951234..215b8217c8 100644 --- a/panda/src/express/windowsRegistry.h +++ b/panda/src/express/windowsRegistry.h @@ -33,27 +33,27 @@ PUBLISHED: rl_user = 1 }; - static bool set_string_value(const string &key, const string &name, - const string &value, RegLevel rl = rl_machine); - static bool set_int_value(const string &key, const string &name, int value, RegLevel rl = rl_machine); + static bool set_string_value(const std::string &key, const std::string &name, + const std::string &value, RegLevel rl = rl_machine); + static bool set_int_value(const std::string &key, const std::string &name, int value, RegLevel rl = rl_machine); enum Type { T_none, T_int, T_string, }; - static Type get_key_type(const string &key, const string &name, RegLevel rl = rl_machine); - static string get_string_value(const string &key, const string &name, - const string &default_value, RegLevel rl = rl_machine); - static int get_int_value(const string &key, const string &name, + static Type get_key_type(const std::string &key, const std::string &name, RegLevel rl = rl_machine); + static std::string get_string_value(const std::string &key, const std::string &name, + const std::string &default_value, RegLevel rl = rl_machine); + static int get_int_value(const std::string &key, const std::string &name, int default_value, RegLevel rl = rl_machine); private: - static bool do_set(const string &key, const string &name, + static bool do_set(const std::string &key, const std::string &name, int data_type, const void *data, int data_length, const RegLevel rl); - static bool do_get(const string &key, const string &name, - int &data_type, string &data, const RegLevel rl); - static string format_message(int error_code); + static bool do_get(const std::string &key, const std::string &name, + int &data_type, std::string &data, const RegLevel rl); + static std::string format_message(int error_code); }; #endif // WIN32_VC diff --git a/panda/src/express/zStream.I b/panda/src/express/zStream.I index 6385b26e67..6442d03037 100644 --- a/panda/src/express/zStream.I +++ b/panda/src/express/zStream.I @@ -15,14 +15,14 @@ * */ INLINE IDecompressStream:: -IDecompressStream() : istream(&_buf) { +IDecompressStream() : std::istream(&_buf) { } /** * */ INLINE IDecompressStream:: -IDecompressStream(istream *source, bool owns_source) : istream(&_buf) { +IDecompressStream(std::istream *source, bool owns_source) : std::istream(&_buf) { open(source, owns_source); } @@ -30,7 +30,7 @@ IDecompressStream(istream *source, bool owns_source) : istream(&_buf) { * */ INLINE IDecompressStream &IDecompressStream:: -open(istream *source, bool owns_source) { +open(std::istream *source, bool owns_source) { clear((ios_iostate)0); _buf.open_read(source, owns_source); return *this; @@ -51,15 +51,15 @@ close() { * */ INLINE OCompressStream:: -OCompressStream() : ostream(&_buf) { +OCompressStream() : std::ostream(&_buf) { } /** * */ INLINE OCompressStream:: -OCompressStream(ostream *dest, bool owns_dest, int compression_level) : - ostream(&_buf) +OCompressStream(std::ostream *dest, bool owns_dest, int compression_level) : + std::ostream(&_buf) { open(dest, owns_dest, compression_level); } @@ -68,7 +68,7 @@ OCompressStream(ostream *dest, bool owns_dest, int compression_level) : * */ INLINE OCompressStream &OCompressStream:: -open(ostream *dest, bool owns_dest, int compression_level) { +open(std::ostream *dest, bool owns_dest, int compression_level) { clear((ios_iostate)0); _buf.open_write(dest, owns_dest, compression_level); return *this; diff --git a/panda/src/express/zStream.h b/panda/src/express/zStream.h index b5fcd2d7a5..08c1301c9b 100644 --- a/panda/src/express/zStream.h +++ b/panda/src/express/zStream.h @@ -31,16 +31,16 @@ * * Seeking is not supported. */ -class EXPCL_PANDAEXPRESS IDecompressStream : public istream { +class EXPCL_PANDAEXPRESS IDecompressStream : public std::istream { PUBLISHED: INLINE IDecompressStream(); - INLINE explicit IDecompressStream(istream *source, bool owns_source); + INLINE explicit IDecompressStream(std::istream *source, bool owns_source); #if _MSC_VER >= 1800 INLINE IDecompressStream(const IDecompressStream ©) = delete; #endif - INLINE IDecompressStream &open(istream *source, bool owns_source); + INLINE IDecompressStream &open(std::istream *source, bool owns_source); INLINE IDecompressStream &close(); private: @@ -57,17 +57,17 @@ private: * * Seeking is not supported. */ -class EXPCL_PANDAEXPRESS OCompressStream : public ostream { +class EXPCL_PANDAEXPRESS OCompressStream : public std::ostream { PUBLISHED: INLINE OCompressStream(); - INLINE explicit OCompressStream(ostream *dest, bool owns_dest, + INLINE explicit OCompressStream(std::ostream *dest, bool owns_dest, int compression_level = 6); #if _MSC_VER >= 1800 INLINE OCompressStream(const OCompressStream ©) = delete; #endif - INLINE OCompressStream &open(ostream *dest, bool owns_dest, + INLINE OCompressStream &open(std::ostream *dest, bool owns_dest, int compression_level = 6); INLINE OCompressStream &close(); diff --git a/panda/src/express/zStreamBuf.h b/panda/src/express/zStreamBuf.h index a034a76d6c..e4cb77bf04 100644 --- a/panda/src/express/zStreamBuf.h +++ b/panda/src/express/zStreamBuf.h @@ -24,19 +24,19 @@ /** * The streambuf object that implements IDecompressStream and OCompressStream. */ -class EXPCL_PANDAEXPRESS ZStreamBuf : public streambuf { +class EXPCL_PANDAEXPRESS ZStreamBuf : public std::streambuf { public: ZStreamBuf(); virtual ~ZStreamBuf(); - void open_read(istream *source, bool owns_source); + void open_read(std::istream *source, bool owns_source); void close_read(); - void open_write(ostream *dest, bool owns_dest, int compression_level); + void open_write(std::ostream *dest, bool owns_dest, int compression_level); void close_write(); - virtual streampos seekoff(streamoff off, ios_seekdir dir, ios_openmode which); - virtual streampos seekpos(streampos pos, ios_openmode which); + virtual std::streampos seekoff(std::streamoff off, ios_seekdir dir, ios_openmode which); + virtual std::streampos seekpos(std::streampos pos, ios_openmode which); protected: virtual int overflow(int c); @@ -49,10 +49,10 @@ private: void show_zlib_error(const char *function, int error_code, z_stream &z); private: - istream *_source; + std::istream *_source; bool _owns_source; - ostream *_dest; + std::ostream *_dest; bool _owns_dest; z_stream _z_source; diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.h b/panda/src/ffmpeg/ffmpegVideoCursor.h index b37637a0b0..58d63eb6ba 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.h +++ b/panda/src/ffmpeg/ffmpegVideoCursor.h @@ -100,7 +100,7 @@ private: void cleanup(); Filename _filename; - string _sync_name; + std::string _sync_name; int _max_readahead_frames; ThreadPriority _thread_priority; PT(GenericThread) _thread; diff --git a/panda/src/ffmpeg/ffmpegVirtualFile.h b/panda/src/ffmpeg/ffmpegVirtualFile.h index 197320d4dc..3e7bd4f796 100644 --- a/panda/src/ffmpeg/ffmpegVirtualFile.h +++ b/panda/src/ffmpeg/ffmpegVirtualFile.h @@ -58,9 +58,9 @@ private: private: AVIOContext *_io_context; AVFormatContext *_format_context; - streampos _start; - streamsize _size; - istream *_in; + std::streampos _start; + std::streamsize _size; + std::istream *_in; pifstream _file_in; bool _owns_in; int _buffer_size; diff --git a/panda/src/framework/pandaFramework.I b/panda/src/framework/pandaFramework.I index d17bc8dad7..24e6bc3644 100644 --- a/panda/src/framework/pandaFramework.I +++ b/panda/src/framework/pandaFramework.I @@ -57,7 +57,7 @@ get_task_mgr() { * Specifies the title that is set for all subsequently created windows. */ INLINE void PandaFramework:: -set_window_title(const string &title) { +set_window_title(const std::string &title) { _window_title = title; } diff --git a/panda/src/framework/pandaFramework.h b/panda/src/framework/pandaFramework.h index 01c50ae8d0..ef570a6c96 100644 --- a/panda/src/framework/pandaFramework.h +++ b/panda/src/framework/pandaFramework.h @@ -51,12 +51,12 @@ public: NodePath get_mouse(GraphicsOutput *window); void remove_mouse(const GraphicsOutput *window); - void define_key(const string &event_name, - const string &description, + void define_key(const std::string &event_name, + const std::string &description, EventHandler::EventCallbackFunction *function, void *data); - INLINE void set_window_title(const string &title); + INLINE void set_window_title(const std::string &title); virtual void get_default_window_props(WindowProperties &props); WindowFramework *open_window(); @@ -77,7 +77,7 @@ public: NodePath &get_models(); - void report_frame_rate(ostream &out) const; + void report_frame_rate(std::ostream &out) const; void reset_frame_rate(); void set_wireframe(bool enable); @@ -163,7 +163,7 @@ private: bool _is_open; bool _made_default_pipe; - string _window_title; + std::string _window_title; PT(GraphicsPipe) _default_pipe; PT(GraphicsEngine) _engine; @@ -200,8 +200,8 @@ private: class KeyDefinition { public: - string _event_name; - string _description; + std::string _event_name; + std::string _description; }; typedef pvector KeyDefinitions; KeyDefinitions _key_definitions; diff --git a/panda/src/framework/windowFramework.h b/panda/src/framework/windowFramework.h index c7745b0fea..b6e93041eb 100644 --- a/panda/src/framework/windowFramework.h +++ b/panda/src/framework/windowFramework.h @@ -147,7 +147,7 @@ private: void destroy_anim_controls(); void update_anim_controls(); - void setup_shuttle_button(const string &label, int index, + void setup_shuttle_button(const std::string &label, int index, EventHandler::EventCallbackFunction *func); void back_button(); void pause_button(); diff --git a/panda/src/glstuff/glGraphicsBuffer_src.h b/panda/src/glstuff/glGraphicsBuffer_src.h index 31f7c91912..c383a0a5d4 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.h +++ b/panda/src/glstuff/glGraphicsBuffer_src.h @@ -50,7 +50,7 @@ class EXPCL_GL CLP(GraphicsBuffer) : public GraphicsBuffer { public: CLP(GraphicsBuffer)(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -135,7 +135,7 @@ protected: UpdateSeq _last_textures_seq; CLP(GraphicsBuffer) *_shared_depth_buffer; - list _shared_depth_buffer_list; + std::list _shared_depth_buffer_list; PStatCollector _bind_texture_pcollector; PStatCollector _generate_mipmap_pcollector; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.I b/panda/src/glstuff/glGraphicsStateGuardian_src.I index 5ce7902917..bdb9db6eb5 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.I +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.I @@ -93,7 +93,7 @@ clear_my_errors(int line, const char *source_file) { /** * Returns the GL vendor string reported by the driver. */ -INLINE const string &CLP(GraphicsStateGuardian):: +INLINE const std::string &CLP(GraphicsStateGuardian):: get_gl_vendor() const { return _gl_vendor; } @@ -101,7 +101,7 @@ get_gl_vendor() const { /** * Returns the GL renderer string reported by the driver. */ -INLINE const string &CLP(GraphicsStateGuardian):: +INLINE const std::string &CLP(GraphicsStateGuardian):: get_gl_renderer() const { return _gl_renderer; } @@ -109,7 +109,7 @@ get_gl_renderer() const { /** * Returns the GL version string reported by the driver. */ -INLINE const string &CLP(GraphicsStateGuardian):: +INLINE const std::string &CLP(GraphicsStateGuardian):: get_gl_version() const { return _gl_version; } @@ -174,7 +174,7 @@ maybe_gl_finish() const { * otherwise. The extension name is case-sensitive. */ INLINE bool CLP(GraphicsStateGuardian):: -has_extension(const string &extension) const { +has_extension(const std::string &extension) const { bool has_ext = (_extensions.find(extension) != _extensions.end()); #ifndef NDEBUG if (GLCAT.is_debug()) { @@ -491,13 +491,13 @@ enable_stencil_test(bool val) { if (val) { #ifdef GSG_VERBOSE GLCAT.spam() - << "glEnable(GL_STENCIL_TEST)" << endl; + << "glEnable(GL_STENCIL_TEST)" << std::endl; #endif glEnable(GL_STENCIL_TEST); } else { #ifdef GSG_VERBOSE GLCAT.spam() - << "glDisable(GL_STENCIL_TEST)" << endl; + << "glDisable(GL_STENCIL_TEST)" << std::endl; #endif glDisable(GL_STENCIL_TEST); } @@ -514,13 +514,13 @@ enable_blend(bool val) { if (val) { #ifdef GSG_VERBOSE GLCAT.spam() - << "glEnable(GL_BLEND)" << endl; + << "glEnable(GL_BLEND)" << std::endl; #endif glEnable(GL_BLEND); } else { #ifdef GSG_VERBOSE GLCAT.spam() - << "glDisable(GL_BLEND)" << endl; + << "glDisable(GL_BLEND)" << std::endl; #endif glDisable(GL_BLEND); } @@ -537,13 +537,13 @@ enable_depth_test(bool val) { if (val) { #ifdef GSG_VERBOSE GLCAT.spam() - << "glEnable(GL_DEPTH_TEST)" << endl; + << "glEnable(GL_DEPTH_TEST)" << std::endl; #endif glEnable(GL_DEPTH_TEST); } else { #ifdef GSG_VERBOSE GLCAT.spam() - << "glDisable(GL_DEPTH_TEST)" << endl; + << "glDisable(GL_DEPTH_TEST)" << std::endl; #endif glDisable(GL_DEPTH_TEST); } @@ -561,13 +561,13 @@ enable_fog(bool val) { if (val) { #ifdef GSG_VERBOSE GLCAT.spam() - << "glEnable(GL_FOG)" << endl; + << "glEnable(GL_FOG)" << std::endl; #endif glEnable(GL_FOG); } else { #ifdef GSG_VERBOSE GLCAT.spam() - << "glDisable(GL_FOG)" << endl; + << "glDisable(GL_FOG)" << std::endl; #endif glDisable(GL_FOG); } @@ -586,13 +586,13 @@ enable_alpha_test(bool val) { if (val) { #ifdef GSG_VERBOSE GLCAT.spam() - << "glEnable(GL_ALPHA_TEST)" << endl; + << "glEnable(GL_ALPHA_TEST)" << std::endl; #endif glEnable(GL_ALPHA_TEST); } else { #ifdef GSG_VERBOSE GLCAT.spam() - << "glDisable(GL_ALPHA_TEST)" << endl; + << "glDisable(GL_ALPHA_TEST)" << std::endl; #endif glDisable(GL_ALPHA_TEST); } @@ -610,7 +610,7 @@ enable_polygon_offset(bool val) { if (val) { #ifdef GSG_VERBOSE GLCAT.spam() - << "glEnable(GL_POLYGON_OFFSET_*)" << endl; + << "glEnable(GL_POLYGON_OFFSET_*)" << std::endl; #endif glEnable(GL_POLYGON_OFFSET_FILL); // glEnable(GL_POLYGON_OFFSET_LINE); not widely supported anyway @@ -618,7 +618,7 @@ enable_polygon_offset(bool val) { } else { #ifdef GSG_VERBOSE GLCAT.spam() - << "glDisable(GL_POLYGON_OFFSET_*)" << endl; + << "glDisable(GL_POLYGON_OFFSET_*)" << std::endl; #endif glDisable(GL_POLYGON_OFFSET_FILL); // glDisable(GL_POLYGON_OFFSET_LINE); not widely supported anyway diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index 15ecebe439..5c29d4bcad 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -261,9 +261,9 @@ public: virtual ~CLP(GraphicsStateGuardian)(); // #--- Zhao Nov2011 - virtual string get_driver_vendor(); - virtual string get_driver_renderer(); - virtual string get_driver_version(); + virtual std::string get_driver_vendor(); + virtual std::string get_driver_renderer(); + virtual std::string get_driver_version(); virtual int get_driver_version_major(); virtual int get_driver_version_minor(); virtual int get_driver_shader_version_major(); @@ -411,9 +411,9 @@ public: INLINE bool clear_errors(int line, const char *source_file); INLINE void clear_my_errors(int line, const char *source_file); - INLINE const string &get_gl_vendor() const; - INLINE const string &get_gl_renderer() const; - INLINE const string &get_gl_version() const; + INLINE const std::string &get_gl_vendor() const; + INLINE const std::string &get_gl_renderer() const; + INLINE const std::string &get_gl_version() const; INLINE int get_gl_version_major() const; INLINE int get_gl_version_minor() const; INLINE bool has_fixed_function_pipeline() const; @@ -422,7 +422,7 @@ public: const TransformState *transform); void bind_fbo(GLuint fbo); - virtual bool get_supports_cg_profile(const string &name) const; + virtual bool get_supports_cg_profile(const std::string &name) const; void finish(); protected: @@ -466,14 +466,14 @@ protected: static bool report_errors_loop(int line, const char *source_file, GLenum error_code, int &error_count); - static string get_error_string(GLenum error_code); - string show_gl_string(const string &name, GLenum id); + static std::string get_error_string(GLenum error_code); + std::string show_gl_string(const std::string &name, GLenum id); virtual void query_gl_version(); void query_glsl_version(); void save_extensions(const char *extensions); virtual void get_extra_extensions(); void report_extensions() const; - INLINE virtual bool has_extension(const string &extension) const; + INLINE virtual bool has_extension(const std::string &extension) const; INLINE bool is_at_least_gl_version(int major_version, int minor_version) const; INLINE bool is_at_least_gles_version(int major_version, int minor_version) const; void *get_extension_func(const char *name); @@ -728,14 +728,14 @@ protected: bool _supports_depth32; #endif - string _gl_vendor; - string _gl_renderer; - string _gl_version; + std::string _gl_vendor; + std::string _gl_renderer; + std::string _gl_version; int _gl_version_major, _gl_version_minor; // #--- Zhao Nov2011 int _gl_shadlang_ver_major, _gl_shadlang_ver_minor; - pset _extensions; + pset _extensions; #ifndef OPENGLES // True for non-compatibility GL 3.2+ contexts. diff --git a/panda/src/glstuff/glmisc_src.h b/panda/src/glstuff/glmisc_src.h index fb8040828f..5ba0b35d20 100644 --- a/panda/src/glstuff/glmisc_src.h +++ b/panda/src/glstuff/glmisc_src.h @@ -87,8 +87,8 @@ extern EXPCL_GL void CLP(init_classes)(); #if !defined(WIN32) && defined(GSG_VERBOSE) -ostream &output_gl_enum(ostream &out, GLenum v); -INLINE ostream &operator << (ostream &out, GLenum v) { +std::ostream &output_gl_enum(std::ostream &out, GLenum v); +INLINE std::ostream &operator << (std::ostream &out, GLenum v) { return output_gl_enum(out, v); } #endif diff --git a/panda/src/glxdisplay/glxGraphicsBuffer.h b/panda/src/glxdisplay/glxGraphicsBuffer.h index e14a329db0..0ccbd6007b 100644 --- a/panda/src/glxdisplay/glxGraphicsBuffer.h +++ b/panda/src/glxdisplay/glxGraphicsBuffer.h @@ -25,7 +25,7 @@ class glxGraphicsBuffer : public GraphicsBuffer { public: glxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/glxdisplay/glxGraphicsPipe.h b/panda/src/glxdisplay/glxGraphicsPipe.h index 25ff9a7fd1..1d08297ab2 100644 --- a/panda/src/glxdisplay/glxGraphicsPipe.h +++ b/panda/src/glxdisplay/glxGraphicsPipe.h @@ -75,14 +75,14 @@ class FrameBufferProperties; */ class glxGraphicsPipe : public x11GraphicsPipe { public: - glxGraphicsPipe(const string &display = string()); + glxGraphicsPipe(const std::string &display = std::string()); virtual ~glxGraphicsPipe() {}; - virtual string get_interface_name() const; + virtual std::string get_interface_name() const; static PT(GraphicsPipe) pipe_constructor(); protected: - virtual PT(GraphicsOutput) make_output(const string &name, + virtual PT(GraphicsOutput) make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/glxdisplay/glxGraphicsPixmap.h b/panda/src/glxdisplay/glxGraphicsPixmap.h index 7c724d4d71..9cc542fbcc 100644 --- a/panda/src/glxdisplay/glxGraphicsPixmap.h +++ b/panda/src/glxdisplay/glxGraphicsPixmap.h @@ -28,7 +28,7 @@ class glxGraphicsPixmap : public GraphicsBuffer { public: glxGraphicsPixmap(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.h b/panda/src/glxdisplay/glxGraphicsStateGuardian.h index 7d31b6d8a9..4470f00d0b 100644 --- a/panda/src/glxdisplay/glxGraphicsStateGuardian.h +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.h @@ -131,8 +131,8 @@ protected: private: void query_glx_extensions(); - void show_glx_client_string(const string &name, int id); - void show_glx_server_string(const string &name, int id); + void show_glx_client_string(const std::string &name, int id); + void show_glx_server_string(const std::string &name, int id); void choose_temp_visual(const FrameBufferProperties &properties); void init_temp_context(); void destroy_temp_xwindow(); diff --git a/panda/src/glxdisplay/glxGraphicsWindow.h b/panda/src/glxdisplay/glxGraphicsWindow.h index d89ab1552b..4c583c186c 100644 --- a/panda/src/glxdisplay/glxGraphicsWindow.h +++ b/panda/src/glxdisplay/glxGraphicsWindow.h @@ -27,7 +27,7 @@ class glxGraphicsWindow : public x11GraphicsWindow { public: glxGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/gobj/adaptiveLru.h b/panda/src/gobj/adaptiveLru.h index 4729f63f2c..e01fa02bfb 100644 --- a/panda/src/gobj/adaptiveLru.h +++ b/panda/src/gobj/adaptiveLru.h @@ -44,7 +44,7 @@ public: */ class EXPCL_PANDA_GOBJ AdaptiveLru : public Namable { PUBLISHED: - explicit AdaptiveLru(const string &name, size_t max_size); + explicit AdaptiveLru(const std::string &name, size_t max_size); ~AdaptiveLru(); INLINE size_t get_total_size() const; @@ -58,8 +58,8 @@ PUBLISHED: INLINE bool validate(); - void output(ostream &out) const; - void write(ostream &out, int indent_level) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level) const; // The following methods are specific to AdaptiveLru, and do not exist in // the SimpleLru implementation. In most cases, the defaults will be @@ -153,8 +153,8 @@ PUBLISHED: virtual void evict_lru(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; // Not defined in SimpleLruPage. unsigned int get_num_frames() const; @@ -179,12 +179,12 @@ private: friend class AdaptiveLru; }; -inline ostream &operator << (ostream &out, const AdaptiveLru &lru) { +inline std::ostream &operator << (std::ostream &out, const AdaptiveLru &lru) { lru.output(out); return out; } -inline ostream &operator << (ostream &out, const AdaptiveLruPage &page) { +inline std::ostream &operator << (std::ostream &out, const AdaptiveLruPage &page) { page.output(out); return out; } diff --git a/panda/src/gobj/bufferContextChain.h b/panda/src/gobj/bufferContextChain.h index a9943fddbf..b995c2e583 100644 --- a/panda/src/gobj/bufferContextChain.h +++ b/panda/src/gobj/bufferContextChain.h @@ -40,7 +40,7 @@ public: void take_from(BufferContextChain &other); - void write(ostream &out, int indent_level) const; + void write(std::ostream &out, int indent_level) const; private: INLINE void adjust_bytes(int delta); diff --git a/panda/src/gobj/bufferResidencyTracker.h b/panda/src/gobj/bufferResidencyTracker.h index 973d249d41..d3714cd232 100644 --- a/panda/src/gobj/bufferResidencyTracker.h +++ b/panda/src/gobj/bufferResidencyTracker.h @@ -31,7 +31,7 @@ class BufferContext; */ class EXPCL_PANDA_GOBJ BufferResidencyTracker { public: - BufferResidencyTracker(const string &pgo_name, const string &type_name); + BufferResidencyTracker(const std::string &pgo_name, const std::string &type_name); ~BufferResidencyTracker(); void begin_frame(Thread *current_thread); @@ -43,7 +43,7 @@ public: INLINE BufferContextChain &get_inactive_resident(); INLINE BufferContextChain &get_active_resident(); - void write(ostream &out, int indent_level) const; + void write(std::ostream &out, int indent_level) const; private: void move_inactive(BufferContextChain &inactive, BufferContextChain &active); diff --git a/panda/src/gobj/geom.I b/panda/src/gobj/geom.I index 81a545d6b6..94469ec77c 100644 --- a/panda/src/gobj/geom.I +++ b/panda/src/gobj/geom.I @@ -448,8 +448,8 @@ CacheKey(const CacheKey ©) : */ INLINE Geom::CacheKey:: CacheKey(CacheKey &&from) noexcept : - _source_data(move(from._source_data)), - _modifier(move(from._modifier)) + _source_data(std::move(from._source_data)), + _modifier(std::move(from._modifier)) { } @@ -497,7 +497,7 @@ CacheEntry(Geom *source, const Geom::CacheKey &key) : INLINE Geom::CacheEntry:: CacheEntry(Geom *source, Geom::CacheKey &&key) noexcept : _source(source), - _key(move(key)) + _key(std::move(key)) { } @@ -696,8 +696,8 @@ prepare_now(PreparedGraphicsObjects *prepared_objects, return ((Geom *)_object)->prepare_now(prepared_objects, gsg); } -INLINE ostream & -operator << (ostream &out, const Geom &obj) { +INLINE std::ostream & +operator << (std::ostream &out, const Geom &obj) { obj.output(out); return out; } diff --git a/panda/src/gobj/geom.h b/panda/src/gobj/geom.h index 41ac95adea..833ac3cd83 100644 --- a/panda/src/gobj/geom.h +++ b/panda/src/gobj/geom.h @@ -140,8 +140,8 @@ PUBLISHED: INLINE void clear_bounds(); MAKE_PROPERTY(bounds_type, get_bounds_type, set_bounds_type); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; void clear_cache(); void clear_cache_stage(Thread *current_thread); @@ -275,7 +275,7 @@ public: ALLOC_DELETED_CHAIN(CacheEntry); virtual void evict_callback(); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; Geom *_source; // A back pointer to the containing Geom CacheKey _key; @@ -450,7 +450,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const Geom &obj); +INLINE std::ostream &operator << (std::ostream &out, const Geom &obj); #include "geom.I" diff --git a/panda/src/gobj/geomCacheEntry.I b/panda/src/gobj/geomCacheEntry.I index 6d9f2dd2cc..0529d0f5cb 100644 --- a/panda/src/gobj/geomCacheEntry.I +++ b/panda/src/gobj/geomCacheEntry.I @@ -51,8 +51,8 @@ insert_before(GeomCacheEntry *node) { node->_prev = this; } -INLINE ostream & -operator << (ostream &out, const GeomCacheEntry &entry) { +INLINE std::ostream & +operator << (std::ostream &out, const GeomCacheEntry &entry) { entry.output(out); return out; } diff --git a/panda/src/gobj/geomCacheEntry.h b/panda/src/gobj/geomCacheEntry.h index 85f1dfb106..ff79d096c2 100644 --- a/panda/src/gobj/geomCacheEntry.h +++ b/panda/src/gobj/geomCacheEntry.h @@ -38,7 +38,7 @@ public: PT(GeomCacheEntry) erase(); virtual void evict_callback(); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: int _last_frame_used; @@ -65,7 +65,7 @@ private: friend class GeomCacheManager; }; -INLINE ostream &operator << (ostream &out, const GeomCacheEntry &entry); +INLINE std::ostream &operator << (std::ostream &out, const GeomCacheEntry &entry); #include "geomCacheEntry.I" diff --git a/panda/src/gobj/geomEnums.h b/panda/src/gobj/geomEnums.h index 80af6d0ea2..b9a19138eb 100644 --- a/panda/src/gobj/geomEnums.h +++ b/panda/src/gobj/geomEnums.h @@ -220,9 +220,9 @@ PUBLISHED: }; }; -EXPCL_PANDA_GOBJ ostream &operator << (ostream &out, GeomEnums::UsageHint usage_hint); -EXPCL_PANDA_GOBJ istream &operator >> (istream &in, GeomEnums::UsageHint &usage_hint); -EXPCL_PANDA_GOBJ ostream &operator << (ostream &out, GeomEnums::NumericType numeric_type); -EXPCL_PANDA_GOBJ ostream &operator << (ostream &out, GeomEnums::Contents contents); +EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, GeomEnums::UsageHint usage_hint); +EXPCL_PANDA_GOBJ std::istream &operator >> (std::istream &in, GeomEnums::UsageHint &usage_hint); +EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, GeomEnums::NumericType numeric_type); +EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, GeomEnums::Contents contents); #endif diff --git a/panda/src/gobj/geomMunger.h b/panda/src/gobj/geomMunger.h index 840057539d..00105108bf 100644 --- a/panda/src/gobj/geomMunger.h +++ b/panda/src/gobj/geomMunger.h @@ -109,7 +109,7 @@ private: private: class CacheEntry : public GeomCacheEntry { public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; PT(GeomMunger) _munger; }; diff --git a/panda/src/gobj/geomPrimitive.I b/panda/src/gobj/geomPrimitive.I index 061a49c527..0984dbecb3 100644 --- a/panda/src/gobj/geomPrimitive.I +++ b/panda/src/gobj/geomPrimitive.I @@ -445,7 +445,7 @@ CData(const GeomPrimitive::CData ©) : INLINE GeomPrimitivePipelineReader:: GeomPrimitivePipelineReader(CPT(GeomPrimitive) object, Thread *current_thread) : - _object(move(object)), + _object(std::move(object)), _current_thread(current_thread), #ifndef CPPPARSER _cdata(_object->_cycler.read_unlocked(current_thread)), @@ -667,8 +667,8 @@ draw(GraphicsStateGuardianBase *gsg, bool force) const { return _object->draw(gsg, this, force); } -INLINE ostream & -operator << (ostream &out, const GeomPrimitive &obj) { +INLINE std::ostream & +operator << (std::ostream &out, const GeomPrimitive &obj) { obj.output(out); return out; } diff --git a/panda/src/gobj/geomPrimitive.h b/panda/src/gobj/geomPrimitive.h index 50cb5695aa..b8012507b8 100644 --- a/panda/src/gobj/geomPrimitive.h +++ b/panda/src/gobj/geomPrimitive.h @@ -147,8 +147,8 @@ PUBLISHED: INLINE bool check_valid(const GeomVertexData *vertex_data) const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; PUBLISHED: /* @@ -408,7 +408,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const GeomPrimitive &obj); +INLINE std::ostream &operator << (std::ostream &out, const GeomPrimitive &obj); #include "geomPrimitive.I" diff --git a/panda/src/gobj/geomVertexAnimationSpec.I b/panda/src/gobj/geomVertexAnimationSpec.I index eb32efb5eb..0942ce5d78 100644 --- a/panda/src/gobj/geomVertexAnimationSpec.I +++ b/panda/src/gobj/geomVertexAnimationSpec.I @@ -150,8 +150,8 @@ compare_to(const GeomVertexAnimationSpec &other) const { return 0; } -INLINE ostream & -operator << (ostream &out, const GeomVertexAnimationSpec &animation) { +INLINE std::ostream & +operator << (std::ostream &out, const GeomVertexAnimationSpec &animation) { animation.output(out); return out; } diff --git a/panda/src/gobj/geomVertexAnimationSpec.h b/panda/src/gobj/geomVertexAnimationSpec.h index ddd94866a5..c377dd9f94 100644 --- a/panda/src/gobj/geomVertexAnimationSpec.h +++ b/panda/src/gobj/geomVertexAnimationSpec.h @@ -53,7 +53,7 @@ PUBLISHED: INLINE void set_panda(); INLINE void set_hardware(int num_transforms, bool indexed_transforms); - void output(ostream &out) const; + void output(std::ostream &out) const; public: INLINE bool operator < (const GeomVertexAnimationSpec &other) const; @@ -72,8 +72,8 @@ private: bool _indexed_transforms; }; -INLINE ostream & -operator << (ostream &out, const GeomVertexAnimationSpec &animation); +INLINE std::ostream & +operator << (std::ostream &out, const GeomVertexAnimationSpec &animation); #include "geomVertexAnimationSpec.I" diff --git a/panda/src/gobj/geomVertexArrayData.I b/panda/src/gobj/geomVertexArrayData.I index a4b3f51397..d573489ba6 100644 --- a/panda/src/gobj/geomVertexArrayData.I +++ b/panda/src/gobj/geomVertexArrayData.I @@ -240,9 +240,9 @@ CData(UsageHint usage_hint) : */ INLINE GeomVertexArrayData::CData:: CData(GeomVertexArrayData::CData &&from) noexcept : - _usage_hint(move(from._usage_hint)), - _buffer(move(from._buffer)), - _modified(move(from._modified)), + _usage_hint(std::move(from._usage_hint)), + _buffer(std::move(from._buffer)), + _modified(std::move(from._modified)), _rw_lock("GeomVertexArrayData::CData::_rw_lock") { } @@ -518,10 +518,10 @@ prepare_now(PreparedGraphicsObjects *prepared_objects, * a string. This is primarily for the benefit of high-level languages such * as Python. */ -INLINE string GeomVertexArrayDataHandle:: +INLINE std::string GeomVertexArrayDataHandle:: get_data() const { mark_used(); - return string((const char *)_cdata->_buffer.get_read_pointer(true), _cdata->_buffer.get_size()); + return std::string((const char *)_cdata->_buffer.get_read_pointer(true), _cdata->_buffer.get_size()); } /** @@ -529,12 +529,12 @@ get_data() const { * formatted as a string. This is primarily for the benefit of high-level * languages such as Python. */ -INLINE string GeomVertexArrayDataHandle:: +INLINE std::string GeomVertexArrayDataHandle:: get_subdata(size_t start, size_t size) const { mark_used(); - start = min(start, _cdata->_buffer.get_size()); - size = min(size, _cdata->_buffer.get_size() - start); - return string((const char *)_cdata->_buffer.get_read_pointer(true) + start, size); + start = std::min(start, _cdata->_buffer.get_size()); + size = std::min(size, _cdata->_buffer.get_size() - start); + return std::string((const char *)_cdata->_buffer.get_read_pointer(true) + start, size); } /** @@ -545,8 +545,8 @@ mark_used() const { _object->mark_used(); } -INLINE ostream & -operator << (ostream &out, const GeomVertexArrayData &obj) { +INLINE std::ostream & +operator << (std::ostream &out, const GeomVertexArrayData &obj) { obj.output(out); return out; } diff --git a/panda/src/gobj/geomVertexArrayData.h b/panda/src/gobj/geomVertexArrayData.h index 264c9a1971..40935563e5 100644 --- a/panda/src/gobj/geomVertexArrayData.h +++ b/panda/src/gobj/geomVertexArrayData.h @@ -92,8 +92,8 @@ PUBLISHED: MAKE_PROPERTY(data_size_bytes, get_data_size_bytes); MAKE_PROPERTY(modified, get_modified); - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; INLINE bool request_resident(Thread *current_thread = Thread::get_current_thread()) const; @@ -316,10 +316,10 @@ PUBLISHED: PyObject *buffer, size_t from_start, size_t from_size)); - INLINE string get_data() const; - void set_data(const string &data); - INLINE string get_subdata(size_t start, size_t size) const; - void set_subdata(size_t start, size_t size, const string &data); + INLINE std::string get_data() const; + void set_data(const std::string &data); + INLINE std::string get_subdata(size_t start, size_t size) const; + void set_subdata(size_t start, size_t size, const std::string &data); INLINE void mark_used() const; @@ -350,7 +350,7 @@ private: friend class GeomVertexArrayData; }; -INLINE ostream &operator << (ostream &out, const GeomVertexArrayData &obj); +INLINE std::ostream &operator << (std::ostream &out, const GeomVertexArrayData &obj); #include "geomVertexArrayData.I" diff --git a/panda/src/gobj/geomVertexArrayFormat.I b/panda/src/gobj/geomVertexArrayFormat.I index 94e62b109b..10fb6b8329 100644 --- a/panda/src/gobj/geomVertexArrayFormat.I +++ b/panda/src/gobj/geomVertexArrayFormat.I @@ -160,8 +160,8 @@ consider_sort_columns() const { } } -INLINE ostream & -operator << (ostream &out, const GeomVertexArrayFormat &obj) { +INLINE std::ostream & +operator << (std::ostream &out, const GeomVertexArrayFormat &obj) { obj.output(out); return out; } diff --git a/panda/src/gobj/geomVertexArrayFormat.h b/panda/src/gobj/geomVertexArrayFormat.h index fbd697fe3a..2cb8aa5f14 100644 --- a/panda/src/gobj/geomVertexArrayFormat.h +++ b/panda/src/gobj/geomVertexArrayFormat.h @@ -113,12 +113,12 @@ PUBLISHED: bool is_data_subset_of(const GeomVertexArrayFormat &other) const; int count_unused_space() const; - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; - void write_with_data(ostream &out, int indent_level, + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; + void write_with_data(std::ostream &out, int indent_level, const GeomVertexArrayData *array_data) const; - string get_format_string(bool pad = true) const; + std::string get_format_string(bool pad = true) const; public: int compare_to(const GeomVertexArrayFormat &other) const; @@ -192,7 +192,7 @@ private: friend class GeomVertexFormat; }; -INLINE ostream &operator << (ostream &out, const GeomVertexArrayFormat &obj); +INLINE std::ostream &operator << (std::ostream &out, const GeomVertexArrayFormat &obj); #include "geomVertexArrayFormat.I" diff --git a/panda/src/gobj/geomVertexColumn.I b/panda/src/gobj/geomVertexColumn.I index c9e4a2fb8a..b382071eac 100644 --- a/panda/src/gobj/geomVertexColumn.I +++ b/panda/src/gobj/geomVertexColumn.I @@ -300,8 +300,8 @@ operator < (const GeomVertexColumn &other) const { return 0; } -INLINE ostream & -operator << (ostream &out, const GeomVertexColumn &obj) { +INLINE std::ostream & +operator << (std::ostream &out, const GeomVertexColumn &obj) { obj.output(out); return out; } diff --git a/panda/src/gobj/geomVertexColumn.h b/panda/src/gobj/geomVertexColumn.h index 6e31233946..1ff36b3eda 100644 --- a/panda/src/gobj/geomVertexColumn.h +++ b/panda/src/gobj/geomVertexColumn.h @@ -69,7 +69,7 @@ PUBLISHED: void set_start(int start); void set_column_alignment(int column_alignment); - void output(ostream &out) const; + void output(std::ostream &out) const; public: INLINE bool is_packed_argb() const; @@ -433,7 +433,7 @@ private: friend class GeomVertexWriter; }; -INLINE ostream &operator << (ostream &out, const GeomVertexColumn &obj); +INLINE std::ostream &operator << (std::ostream &out, const GeomVertexColumn &obj); #include "geomVertexColumn.I" diff --git a/panda/src/gobj/geomVertexData.I b/panda/src/gobj/geomVertexData.I index 6575397fa2..dd1d800309 100644 --- a/panda/src/gobj/geomVertexData.I +++ b/panda/src/gobj/geomVertexData.I @@ -15,7 +15,7 @@ * Returns the name passed to the constructor, if any. This name is reported * on the PStats graph for vertex computations. */ -INLINE const string &GeomVertexData:: +INLINE const std::string &GeomVertexData:: get_name() const { return _name; } @@ -476,7 +476,7 @@ unpack_ufloat_c(uint32_t data) { INLINE int GeomVertexData:: add_transform(TransformTable *table, const VertexTransform *transform, TransformMap &already_added) { - pair result = already_added.insert(TransformMap::value_type(transform, table->get_num_transforms())); + std::pair result = already_added.insert(TransformMap::value_type(transform, table->get_num_transforms())); if (result.second) { table->add_transform(transform); @@ -886,8 +886,8 @@ get_array_writer(size_t i) const { return _array_writers[i]; } -INLINE ostream & -operator << (ostream &out, const GeomVertexData &obj) { +INLINE std::ostream & +operator << (std::ostream &out, const GeomVertexData &obj) { obj.output(out); return out; } diff --git a/panda/src/gobj/geomVertexData.h b/panda/src/gobj/geomVertexData.h index 806f5887d3..52d177e5e2 100644 --- a/panda/src/gobj/geomVertexData.h +++ b/panda/src/gobj/geomVertexData.h @@ -72,7 +72,7 @@ protected: virtual PT(CopyOnWriteObject) make_cow_copy(); PUBLISHED: - explicit GeomVertexData(const string &name, + explicit GeomVertexData(const std::string &name, const GeomVertexFormat *format, UsageHint usage_hint); GeomVertexData(const GeomVertexData ©); @@ -84,8 +84,8 @@ PUBLISHED: int compare_to(const GeomVertexData &other) const; - INLINE const string &get_name() const; - void set_name(const string &name); + INLINE const std::string &get_name() const; + void set_name(const std::string &name); MAKE_PROPERTY(name, get_name, set_name); INLINE UsageHint get_usage_hint() const; @@ -164,9 +164,9 @@ PUBLISHED: replace_column(InternalName *name, int num_components, NumericType numeric_type, Contents contents) const; - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; - void describe_vertex(ostream &out, int row) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; + void describe_vertex(std::ostream &out, int row) const; void clear_cache(); void clear_cache_stage(); @@ -206,7 +206,7 @@ private: TransformMap &already_added); private: - string _name; + std::string _name; typedef pvector< COWPT(GeomVertexArrayData) > Arrays; @@ -263,7 +263,7 @@ public: ALLOC_DELETED_CHAIN(CacheEntry); virtual void evict_callback(); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; GeomVertexData *_source; // A back pointer to the containing data. CacheKey _key; @@ -546,7 +546,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const GeomVertexData &obj); +INLINE std::ostream &operator << (std::ostream &out, const GeomVertexData &obj); #include "geomVertexData.I" diff --git a/panda/src/gobj/geomVertexFormat.I b/panda/src/gobj/geomVertexFormat.I index 680f779447..a6f85e57ff 100644 --- a/panda/src/gobj/geomVertexFormat.I +++ b/panda/src/gobj/geomVertexFormat.I @@ -11,8 +11,8 @@ * @date 2005-03-07 */ -INLINE ostream & -operator << (ostream &out, const GeomVertexFormat &obj) { +INLINE std::ostream & +operator << (std::ostream &out, const GeomVertexFormat &obj) { obj.output(out); return out; } diff --git a/panda/src/gobj/geomVertexFormat.h b/panda/src/gobj/geomVertexFormat.h index 6e4f668436..82eec7f8a9 100644 --- a/panda/src/gobj/geomVertexFormat.h +++ b/panda/src/gobj/geomVertexFormat.h @@ -129,9 +129,9 @@ PUBLISHED: MAKE_MAP_PROPERTY(columns, has_column, get_column); MAKE_MAP_KEYS_SEQ(columns, get_num_columns, get_column_name); - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; - void write_with_data(ostream &out, int indent_level, + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; + void write_with_data(std::ostream &out, int indent_level, const GeomVertexData *data) const; INLINE static const GeomVertexFormat *get_empty(); @@ -289,7 +289,7 @@ private: friend class GeomMunger; }; -INLINE ostream &operator << (ostream &out, const GeomVertexFormat &obj); +INLINE std::ostream &operator << (std::ostream &out, const GeomVertexFormat &obj); #include "geomVertexFormat.I" diff --git a/panda/src/gobj/geomVertexReader.h b/panda/src/gobj/geomVertexReader.h index f657975a63..beb92b017e 100644 --- a/panda/src/gobj/geomVertexReader.h +++ b/panda/src/gobj/geomVertexReader.h @@ -119,7 +119,7 @@ PUBLISHED: INLINE const LVecBase3i &get_data3i(); INLINE const LVecBase4i &get_data4i(); - void output(ostream &out) const; + void output(std::ostream &out) const; protected: INLINE GeomVertexColumn::Packer *get_packer() const; @@ -162,8 +162,8 @@ private: #endif }; -INLINE ostream & -operator << (ostream &out, const GeomVertexReader &reader) { +INLINE std::ostream & +operator << (std::ostream &out, const GeomVertexReader &reader) { reader.output(out); return out; } diff --git a/panda/src/gobj/geomVertexRewriter.h b/panda/src/gobj/geomVertexRewriter.h index d9291ea06a..2ed1699522 100644 --- a/panda/src/gobj/geomVertexRewriter.h +++ b/panda/src/gobj/geomVertexRewriter.h @@ -65,11 +65,11 @@ PUBLISHED: INLINE int get_start_row() const; INLINE bool is_at_end() const; - void output(ostream &out) const; + void output(std::ostream &out) const; }; -INLINE ostream & -operator << (ostream &out, const GeomVertexRewriter &rewriter) { +INLINE std::ostream & +operator << (std::ostream &out, const GeomVertexRewriter &rewriter) { rewriter.output(out); return out; } diff --git a/panda/src/gobj/geomVertexWriter.I b/panda/src/gobj/geomVertexWriter.I index cc25e79531..b55fdd5f4a 100644 --- a/panda/src/gobj/geomVertexWriter.I +++ b/panda/src/gobj/geomVertexWriter.I @@ -1382,13 +1382,13 @@ inc_add_pointer() { _handle = nullptr; GeomVertexDataPipelineWriter writer(_vertex_data, true, _current_thread); writer.check_array_writers(); - writer.set_num_rows(max(write_row + 1, writer.get_num_rows())); + writer.set_num_rows(std::max(write_row + 1, writer.get_num_rows())); _handle = writer.get_array_writer(_array); } else { // Otherwise, we can get away with modifying only the one array we're // using. - _handle->set_num_rows(max(write_row + 1, _handle->get_num_rows())); + _handle->set_num_rows(std::max(write_row + 1, _handle->get_num_rows())); } set_pointer(write_row); diff --git a/panda/src/gobj/geomVertexWriter.h b/panda/src/gobj/geomVertexWriter.h index aaedaf565b..f50b0e1596 100644 --- a/panda/src/gobj/geomVertexWriter.h +++ b/panda/src/gobj/geomVertexWriter.h @@ -174,7 +174,7 @@ PUBLISHED: INLINE void add_data4i(int a, int b, int c, int d); INLINE void add_data4i(const LVecBase4i &data); - void output(ostream &out) const; + void output(std::ostream &out) const; protected: INLINE GeomVertexColumn::Packer *get_packer() const; @@ -219,8 +219,8 @@ private: #endif }; -INLINE ostream & -operator << (ostream &out, const GeomVertexWriter &writer) { +INLINE std::ostream & +operator << (std::ostream &out, const GeomVertexWriter &writer) { writer.output(out); return out; } diff --git a/panda/src/gobj/indexBufferContext.h b/panda/src/gobj/indexBufferContext.h index 4e3019c507..6b2004fac2 100644 --- a/panda/src/gobj/indexBufferContext.h +++ b/panda/src/gobj/indexBufferContext.h @@ -46,8 +46,8 @@ public: INLINE void mark_loaded(const GeomPrimitivePipelineReader *reader); INLINE void mark_unloaded(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; private: // This cannot be a PT(GeomPrimitive), because the data and the GSG both own @@ -75,7 +75,7 @@ private: friend class PreparedGraphicsObjects; }; -inline ostream &operator << (ostream &out, const IndexBufferContext &context) { +inline std::ostream &operator << (std::ostream &out, const IndexBufferContext &context) { context.output(out); return out; } diff --git a/panda/src/gobj/internalName.I b/panda/src/gobj/internalName.I index 644ed998d3..4773faeb14 100644 --- a/panda/src/gobj/internalName.I +++ b/panda/src/gobj/internalName.I @@ -22,7 +22,7 @@ * handled transparently. */ INLINE PT(InternalName) InternalName:: -make(const string &name) { +make(const std::string &name) { return get_root()->append(name); } @@ -63,7 +63,7 @@ get_parent() const { * Return the name represented by just this particular InternalName object, * ignoring its parents names. This is everything after the rightmost dot. */ -INLINE const string &InternalName:: +INLINE const std::string &InternalName:: get_basename() const { return _basename; } @@ -136,7 +136,7 @@ get_tangent() { * coordinate set. */ INLINE PT(InternalName) InternalName:: -get_tangent_name(const string &name) { +get_tangent_name(const std::string &name) { return get_tangent()->append(name); } @@ -161,7 +161,7 @@ get_binormal() { * named texture coordinate set. */ INLINE PT(InternalName) InternalName:: -get_binormal_name(const string &name) { +get_binormal_name(const std::string &name) { return get_binormal()->append(name); } @@ -185,7 +185,7 @@ get_texcoord() { * set in a TextureStage. */ INLINE PT(InternalName) InternalName:: -get_texcoord_name(const string &name) { +get_texcoord_name(const std::string &name) { return get_texcoord()->append(name); } @@ -298,7 +298,7 @@ get_transform_index() { * column it applies to. */ INLINE PT(InternalName) InternalName:: -get_morph(InternalName *column, const string &slider) { +get_morph(InternalName *column, const std::string &slider) { // This actually returns "column.morph.slider", although that's just an // implementation detail--as long as it returns a consistent, unique name // for each combination of column and slider, everything is good. @@ -369,8 +369,8 @@ get_view() { /** * */ -INLINE ostream & -operator << (ostream &out, const InternalName &tcn) { +INLINE std::ostream & +operator << (std::ostream &out, const InternalName &tcn) { tcn.output(out); return out; } @@ -407,7 +407,7 @@ CPT_InternalName(const ConstPointerTo ©) : * */ INLINE CPT_InternalName:: -CPT_InternalName(const string &name) : +CPT_InternalName(const std::string &name) : ConstPointerTo(InternalName::make(name)) { } diff --git a/panda/src/gobj/internalName.h b/panda/src/gobj/internalName.h index 1c8b942a5b..729ec15ab8 100644 --- a/panda/src/gobj/internalName.h +++ b/panda/src/gobj/internalName.h @@ -37,10 +37,10 @@ class FactoryParams; */ class EXPCL_PANDA_GOBJ InternalName final : public TypedWritableReferenceCount { private: - InternalName(InternalName *parent, const string &basename); + InternalName(InternalName *parent, const std::string &basename); public: - INLINE static PT(InternalName) make(const string &name); + INLINE static PT(InternalName) make(const std::string &name); template INLINE static PT(InternalName) make(const char (&literal)[N]); @@ -49,24 +49,24 @@ PUBLISHED: virtual ~InternalName(); virtual bool unref() const; - static PT(InternalName) make(const string &name, int index); - PT(InternalName) append(const string &basename); + static PT(InternalName) make(const std::string &name, int index); + PT(InternalName) append(const std::string &basename); INLINE InternalName *get_parent() const; - string get_name() const; - string join(const string &sep) const; - INLINE const string &get_basename() const; + std::string get_name() const; + std::string join(const std::string &sep) const; + INLINE const std::string &get_basename() const; MAKE_PROPERTY(parent, get_parent); MAKE_PROPERTY(name, get_name); MAKE_PROPERTY(basename, get_basename); - int find_ancestor(const string &basename) const; + int find_ancestor(const std::string &basename) const; const InternalName *get_ancestor(int n) const; const InternalName *get_top() const; - string get_net_basename(int n) const; + std::string get_net_basename(int n) const; - void output(ostream &out) const; + void output(std::ostream &out) const; // Some predefined built-in names. INLINE static PT(InternalName) get_root(); @@ -74,11 +74,11 @@ PUBLISHED: INLINE static PT(InternalName) get_vertex(); INLINE static PT(InternalName) get_normal(); INLINE static PT(InternalName) get_tangent(); - INLINE static PT(InternalName) get_tangent_name(const string &name); + INLINE static PT(InternalName) get_tangent_name(const std::string &name); INLINE static PT(InternalName) get_binormal(); - INLINE static PT(InternalName) get_binormal_name(const string &name); + INLINE static PT(InternalName) get_binormal_name(const std::string &name); INLINE static PT(InternalName) get_texcoord(); - INLINE static PT(InternalName) get_texcoord_name(const string &name); + INLINE static PT(InternalName) get_texcoord_name(const std::string &name); INLINE static PT(InternalName) get_color(); INLINE static PT(InternalName) get_rotate(); INLINE static PT(InternalName) get_size(); @@ -86,7 +86,7 @@ PUBLISHED: INLINE static PT(InternalName) get_transform_blend(); INLINE static PT(InternalName) get_transform_weight(); INLINE static PT(InternalName) get_transform_index(); - INLINE static PT(InternalName) get_morph(InternalName *column, const string &slider); + INLINE static PT(InternalName) get_morph(InternalName *column, const std::string &slider); INLINE static PT(InternalName) get_index(); INLINE static PT(InternalName) get_world(); INLINE static PT(InternalName) get_camera(); @@ -113,9 +113,9 @@ public: private: PT(InternalName) _parent; - string _basename; + std::string _basename; - typedef phash_map NameTable; + typedef phash_map NameTable; NameTable _name_table; LightMutex _name_table_lock; @@ -182,7 +182,7 @@ private: template<> INLINE void PointerToBase::update_type(To *ptr) {} -INLINE ostream &operator << (ostream &out, const InternalName &tcn); +INLINE std::ostream &operator << (std::ostream &out, const InternalName &tcn); /** * This is a const pointer to an InternalName, and should be used in lieu of a @@ -201,7 +201,7 @@ public: INLINE CPT_InternalName(PointerTo &&from) noexcept; INLINE CPT_InternalName(const ConstPointerTo ©); INLINE CPT_InternalName(ConstPointerTo &&from) noexcept; - INLINE CPT_InternalName(const string &name); + INLINE CPT_InternalName(const std::string &name); template INLINE CPT_InternalName(const char (&literal)[N]); diff --git a/panda/src/gobj/lens.I b/panda/src/gobj/lens.I index 337b60ab0c..91fb6e7170 100644 --- a/panda/src/gobj/lens.I +++ b/panda/src/gobj/lens.I @@ -142,7 +142,7 @@ project(const LPoint3 &point3d, LPoint3 &point2d) const { * to automatically track changes to camera fov, etc. in the application. */ INLINE void Lens:: -set_change_event(const string &event) { +set_change_event(const std::string &event) { CDWriter cdata(_cycler, true); cdata->_change_event = event; } @@ -151,7 +151,7 @@ set_change_event(const string &event) { * Returns the name of the event that will be generated whenever any * properties of this particular Lens have changed. */ -INLINE const string &Lens:: +INLINE const std::string &Lens:: get_change_event() const { CDReader cdata(_cycler); return cdata->_change_event; @@ -709,8 +709,8 @@ do_set_near_far(CData *cdata, PN_stdfloat near_distance, PN_stdfloat far_distanc do_throw_change_event(cdata); } -INLINE ostream & -operator << (ostream &out, const Lens &lens) { +INLINE std::ostream & +operator << (std::ostream &out, const Lens &lens) { lens.output(out); return out; } diff --git a/panda/src/gobj/lens.h b/panda/src/gobj/lens.h index f695d36558..b0ac72d907 100644 --- a/panda/src/gobj/lens.h +++ b/panda/src/gobj/lens.h @@ -64,8 +64,8 @@ PUBLISHED: INLINE bool project(const LPoint3 &point3d, LPoint3 &point2d) const; INLINE bool project(const LPoint3 &point3d, LPoint2 &point2d) const; - INLINE void set_change_event(const string &event); - INLINE const string &get_change_event() const; + INLINE void set_change_event(const std::string &event); + INLINE const std::string &get_change_event() const; MAKE_PROPERTY(change_event, get_change_event, set_change_event); void set_coordinate_system(CoordinateSystem cs); @@ -182,8 +182,8 @@ PUBLISHED: INLINE const LMatrix4 &get_lens_mat() const; INLINE const LMatrix4 &get_lens_mat_inv() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; INLINE UpdateSeq get_last_change() const; @@ -322,7 +322,7 @@ protected: void clear(); - string _change_event; + std::string _change_event; UpdateSeq _last_change; CoordinateSystem _cs; @@ -399,7 +399,7 @@ private: static TypeHandle _type_handle; }; -EXPCL_PANDA_GOBJ INLINE ostream &operator << (ostream &out, const Lens &lens); +EXPCL_PANDA_GOBJ INLINE std::ostream &operator << (std::ostream &out, const Lens &lens); #include "lens.I" diff --git a/panda/src/gobj/material.I b/panda/src/gobj/material.I index 777a555200..b9e30ba262 100644 --- a/panda/src/gobj/material.I +++ b/panda/src/gobj/material.I @@ -15,7 +15,7 @@ * */ INLINE Material:: -Material(const string &name) : Namable(name) { +Material(const std::string &name) : Namable(name) { _base_color.set(1.0f, 1.0f, 1.0f, 1.0f); _ambient.set(1.0f, 1.0f, 1.0f, 1.0f); _diffuse.set(1.0f, 1.0f, 1.0f, 1.0f); diff --git a/panda/src/gobj/material.h b/panda/src/gobj/material.h index 17344df46a..5835a81ae3 100644 --- a/panda/src/gobj/material.h +++ b/panda/src/gobj/material.h @@ -41,7 +41,7 @@ class FactoryParams; */ class EXPCL_PANDA_GOBJ Material : public TypedWritableReferenceCount, public Namable { PUBLISHED: - INLINE explicit Material(const string &name = ""); + INLINE explicit Material(const std::string &name = ""); INLINE Material(const Material ©); void operator = (const Material ©); INLINE ~Material(); @@ -100,8 +100,8 @@ PUBLISHED: int compare_to(const Material &other) const; - void output(ostream &out) const; - void write(ostream &out, int indent) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent) const; INLINE bool is_attrib_locked() const; INLINE void set_attrib_lock(); @@ -186,7 +186,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const Material &m) { +INLINE std::ostream &operator << (std::ostream &out, const Material &m) { m.output(out); return out; } diff --git a/panda/src/gobj/materialPool.I b/panda/src/gobj/materialPool.I index 6d6726bde6..271bda6fa8 100644 --- a/panda/src/gobj/materialPool.I +++ b/panda/src/gobj/materialPool.I @@ -63,7 +63,7 @@ garbage_collect() { * Lists the contents of the material pool to the indicated output stream. */ INLINE void MaterialPool:: -list_contents(ostream &out) { +list_contents(std::ostream &out) { get_global_ptr()->ns_list_contents(out); } diff --git a/panda/src/gobj/materialPool.h b/panda/src/gobj/materialPool.h index e5a0775b0b..d4cc1cc67b 100644 --- a/panda/src/gobj/materialPool.h +++ b/panda/src/gobj/materialPool.h @@ -40,9 +40,9 @@ PUBLISHED: INLINE static void release_all_materials(); INLINE static int garbage_collect(); - INLINE static void list_contents(ostream &out); + INLINE static void list_contents(std::ostream &out); - static void write(ostream &out); + static void write(std::ostream &out); private: INLINE MaterialPool(); @@ -52,7 +52,7 @@ private: void ns_release_all_materials(); int ns_garbage_collect(); - void ns_list_contents(ostream &out) const; + void ns_list_contents(std::ostream &out) const; static MaterialPool *get_global_ptr(); diff --git a/panda/src/gobj/matrixLens.h b/panda/src/gobj/matrixLens.h index 0b4f068b88..e5d1d1a688 100644 --- a/panda/src/gobj/matrixLens.h +++ b/panda/src/gobj/matrixLens.h @@ -52,7 +52,7 @@ public: virtual PT(Lens) make_copy() const; virtual bool is_linear() const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; protected: virtual void do_compute_projection_mat(Lens::CData *lens_cdata); diff --git a/panda/src/gobj/orthographicLens.h b/panda/src/gobj/orthographicLens.h index 8798d4d8e7..da150fa681 100644 --- a/panda/src/gobj/orthographicLens.h +++ b/panda/src/gobj/orthographicLens.h @@ -40,7 +40,7 @@ public: virtual bool is_linear() const; virtual bool is_orthographic() const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; protected: virtual bool do_extrude_depth(const CData *cdata, const LPoint3 &point2d, diff --git a/panda/src/gobj/paramTexture.I b/panda/src/gobj/paramTexture.I index c25c71ca28..c8235778e8 100644 --- a/panda/src/gobj/paramTexture.I +++ b/panda/src/gobj/paramTexture.I @@ -55,7 +55,7 @@ INLINE ParamTextureImage:: ParamTextureImage(Texture *tex, bool read, bool write, int z, int n) : _texture(tex), _access(0), - _bind_level(min(n, 127)), + _bind_level(std::min(n, 127)), _bind_layer(z) { if (read) { diff --git a/panda/src/gobj/paramTexture.h b/panda/src/gobj/paramTexture.h index d78ceb06b9..fb9b2a5a81 100644 --- a/panda/src/gobj/paramTexture.h +++ b/panda/src/gobj/paramTexture.h @@ -37,7 +37,7 @@ PUBLISHED: MAKE_PROPERTY(texture, get_texture); MAKE_PROPERTY(sampler, get_sampler); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: PT(Texture) _texture; @@ -106,7 +106,7 @@ PUBLISHED: MAKE_PROPERTY(bind_level, get_bind_level); MAKE_PROPERTY2(bind_layer, get_bind_layered, get_bind_layer); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: PT(Texture) _texture; diff --git a/panda/src/gobj/preparedGraphicsObjects.I b/panda/src/gobj/preparedGraphicsObjects.I index 6cc6daf914..a37a447489 100644 --- a/panda/src/gobj/preparedGraphicsObjects.I +++ b/panda/src/gobj/preparedGraphicsObjects.I @@ -16,7 +16,7 @@ * arbitrary name that serves mainly to uniquify the context for PStats * reporting. */ -INLINE const string &PreparedGraphicsObjects:: +INLINE const std::string &PreparedGraphicsObjects:: get_name() const { return _name; } diff --git a/panda/src/gobj/preparedGraphicsObjects.h b/panda/src/gobj/preparedGraphicsObjects.h index 3d673b615b..77ee91eca3 100644 --- a/panda/src/gobj/preparedGraphicsObjects.h +++ b/panda/src/gobj/preparedGraphicsObjects.h @@ -61,12 +61,12 @@ public: ~PreparedGraphicsObjects(); PUBLISHED: - INLINE const string &get_name() const; + INLINE const std::string &get_name() const; void set_graphics_memory_limit(size_t limit); INLINE size_t get_graphics_memory_limit() const; - void show_graphics_memory_lru(ostream &out) const; - void show_residency_trackers(ostream &out) const; + void show_graphics_memory_lru(std::ostream &out) const; + void show_residency_trackers(std::ostream &out) const; INLINE void release_all(); INLINE int get_num_queued() const; @@ -215,7 +215,7 @@ public: void end_frame(Thread *current_thread); private: - static string init_name(); + static std::string init_name(); private: typedef phash_set Textures; @@ -261,7 +261,7 @@ private: size_t &buffer_cache_size); ReMutex _lock; - string _name; + std::string _name; Textures _prepared_textures, _released_textures; EnqueuedTextures _enqueued_textures; PreparedSamplers _prepared_samplers; diff --git a/panda/src/gobj/samplerContext.h b/panda/src/gobj/samplerContext.h index edb684c4b4..bf47b98b84 100644 --- a/panda/src/gobj/samplerContext.h +++ b/panda/src/gobj/samplerContext.h @@ -35,8 +35,8 @@ class EXPCL_PANDA_GOBJ SamplerContext : public SavedContext, public SimpleLruPag public: INLINE SamplerContext(const SamplerState &sampler); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; public: static TypeHandle get_class_type() { @@ -58,7 +58,7 @@ private: friend class PreparedGraphicsObjects; }; -inline ostream &operator << (ostream &out, const SamplerContext &context) { +inline std::ostream &operator << (std::ostream &out, const SamplerContext &context) { context.output(out); return out; } diff --git a/panda/src/gobj/samplerState.h b/panda/src/gobj/samplerState.h index 2236092b81..bef695cd83 100644 --- a/panda/src/gobj/samplerState.h +++ b/panda/src/gobj/samplerState.h @@ -126,11 +126,11 @@ PUBLISHED: INLINE bool uses_mipmaps() const; INLINE static bool is_mipmap(FilterType type); - static string format_filter_type(FilterType ft); - static FilterType string_filter_type(const string &str); + static std::string format_filter_type(FilterType ft); + static FilterType string_filter_type(const std::string &str); - static string format_wrap_mode(WrapMode wm); - static WrapMode string_wrap_mode(const string &str); + static std::string format_wrap_mode(WrapMode wm); + static WrapMode string_wrap_mode(const std::string &str); INLINE bool operator == (const SamplerState &other) const; INLINE bool operator != (const SamplerState &other) const; @@ -146,8 +146,8 @@ PUBLISHED: public: int compare_to(const SamplerState &other) const; - void output(ostream &out) const; - void write(ostream &out, int indent) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent) const; private: LColor _border_color; @@ -194,28 +194,28 @@ extern EXPCL_PANDA_GOBJ ConfigVariableEnum texture_min extern EXPCL_PANDA_GOBJ ConfigVariableEnum texture_magfilter; extern EXPCL_PANDA_GOBJ ConfigVariableInt texture_anisotropic_degree; -INLINE ostream &operator << (ostream &out, const SamplerState &m) { +INLINE std::ostream &operator << (std::ostream &out, const SamplerState &m) { m.output(out); return out; } -INLINE ostream &operator << (ostream &out, SamplerState::FilterType ft) { +INLINE std::ostream &operator << (std::ostream &out, SamplerState::FilterType ft) { return out << SamplerState::format_filter_type(ft); } -INLINE istream &operator >> (istream &in, SamplerState::FilterType &ft) { - string word; +INLINE std::istream &operator >> (std::istream &in, SamplerState::FilterType &ft) { + std::string word; in >> word; ft = SamplerState::string_filter_type(word); return in; } -INLINE ostream &operator << (ostream &out, SamplerState::WrapMode wm) { +INLINE std::ostream &operator << (std::ostream &out, SamplerState::WrapMode wm) { return out << SamplerState::format_wrap_mode(wm); } -INLINE istream &operator >> (istream &in, SamplerState::WrapMode &wm) { - string word; +INLINE std::istream &operator >> (std::istream &in, SamplerState::WrapMode &wm) { + std::string word; in >> word; wm = SamplerState::string_wrap_mode(word); return in; diff --git a/panda/src/gobj/savedContext.h b/panda/src/gobj/savedContext.h index 1e5a28594e..6c2db6aec8 100644 --- a/panda/src/gobj/savedContext.h +++ b/panda/src/gobj/savedContext.h @@ -27,8 +27,8 @@ class EXPCL_PANDA_GOBJ SavedContext : public TypedObject { public: INLINE SavedContext(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; PUBLISHED: static TypeHandle get_class_type() { @@ -49,7 +49,7 @@ private: static TypeHandle _type_handle; }; -inline ostream &operator << (ostream &out, const SavedContext &context) { +inline std::ostream &operator << (std::ostream &out, const SavedContext &context) { context.output(out); return out; } diff --git a/panda/src/gobj/shader.I b/panda/src/gobj/shader.I index 080fd46860..3a671a5f9f 100644 --- a/panda/src/gobj/shader.I +++ b/panda/src/gobj/shader.I @@ -85,7 +85,7 @@ set_filename(ShaderType type, const Filename &filename) { /** * Return the Shader's text for the given shader type. */ -INLINE const string &Shader:: +INLINE const std::string &Shader:: get_text(ShaderType type) const { if (_text._separate) { nassertr(type != ST_none || !_text._shared.empty(), _text._shared); @@ -694,9 +694,9 @@ read_datagram(DatagramIterator &scan) { * */ INLINE Shader::ShaderFile:: -ShaderFile(string shared) : +ShaderFile(std::string shared) : _separate(false), - _shared(move(shared)) + _shared(std::move(shared)) { } @@ -704,14 +704,14 @@ ShaderFile(string shared) : * */ INLINE Shader::ShaderFile:: -ShaderFile(string vertex, string fragment, string geometry, - string tess_control, string tess_evaluation) : +ShaderFile(std::string vertex, std::string fragment, std::string geometry, + std::string tess_control, std::string tess_evaluation) : _separate(true), - _vertex(move(vertex)), - _fragment(move(fragment)), - _geometry(move(geometry)), - _tess_control(move(tess_control)), - _tess_evaluation(move(tess_evaluation)) + _vertex(std::move(vertex)), + _fragment(std::move(fragment)), + _geometry(std::move(geometry)), + _tess_control(std::move(tess_control)), + _tess_evaluation(std::move(tess_evaluation)) { } diff --git a/panda/src/gobj/shader.h b/panda/src/gobj/shader.h index 07e1e8b46e..52b1904c4d 100644 --- a/panda/src/gobj/shader.h +++ b/panda/src/gobj/shader.h @@ -84,7 +84,7 @@ PUBLISHED: }; static PT(Shader) load(const Filename &file, ShaderLanguage lang = SL_none); - static PT(Shader) make(string body, ShaderLanguage lang = SL_none); + static PT(Shader) make(std::string body, ShaderLanguage lang = SL_none); static PT(Shader) load(ShaderLanguage lang, const Filename &vertex, const Filename &fragment, const Filename &geometry = "", @@ -92,15 +92,15 @@ PUBLISHED: const Filename &tess_evaluation = ""); static PT(Shader) load_compute(ShaderLanguage lang, const Filename &fn); static PT(Shader) make(ShaderLanguage lang, - string vertex, string fragment, - string geometry = "", - string tess_control = "", - string tess_evaluation = ""); - static PT(Shader) make_compute(ShaderLanguage lang, string body); + std::string vertex, std::string fragment, + std::string geometry = "", + std::string tess_control = "", + std::string tess_evaluation = ""); + static PT(Shader) make_compute(ShaderLanguage lang, std::string body); INLINE Filename get_filename(ShaderType type = ST_none) const; INLINE void set_filename(ShaderType type, const Filename &filename); - INLINE const string &get_text(ShaderType type = ST_none) const; + INLINE const std::string &get_text(ShaderType type = ST_none) const; INLINE bool get_error_flag() const; INLINE ShaderLanguage get_language() const; @@ -327,7 +327,7 @@ public: }; struct ShaderArgId { - string _name; + std::string _name; ShaderType _type; int _seqno; }; @@ -464,9 +464,9 @@ public: class ShaderFile : public ReferenceCount { public: INLINE ShaderFile() {}; - INLINE ShaderFile(string shared); - INLINE ShaderFile(string vertex, string fragment, string geometry, - string tess_control, string tess_evaluation); + INLINE ShaderFile(std::string shared); + INLINE ShaderFile(std::string vertex, std::string fragment, std::string geometry, + std::string tess_control, std::string tess_evaluation); INLINE void write_datagram(Datagram &dg) const; INLINE void read_datagram(DatagramIterator &source); @@ -475,13 +475,13 @@ public: public: bool _separate; - string _shared; - string _vertex; - string _fragment; - string _geometry; - string _tess_control; - string _tess_evaluation; - string _compute; + std::string _shared; + std::string _vertex; + std::string _fragment; + std::string _geometry; + std::string _tess_control; + std::string _tess_evaluation; + std::string _compute; }; public: @@ -489,12 +489,12 @@ public: // implementations that need to do so. Don't use them when you use separate // shader programs. void parse_init(); - void parse_line(string &result, bool rt, bool lt); - void parse_upto(string &result, string pattern, bool include); - void parse_rest(string &result); + void parse_line(std::string &result, bool rt, bool lt); + void parse_upto(std::string &result, std::string pattern, bool include); + void parse_rest(std::string &result); bool parse_eof(); - void cp_report_error(ShaderArgInfo &arg, const string &msg); + void cp_report_error(ShaderArgInfo &arg, const std::string &msg); bool cp_errchk_parameter_words(ShaderArgInfo &arg, int len); bool cp_errchk_parameter_in(ShaderArgInfo &arg); bool cp_errchk_parameter_ptr(ShaderArgInfo &p); @@ -506,7 +506,7 @@ public: vector_string &pieces, int &next); bool cp_parse_delimiter(ShaderArgInfo &arg, vector_string &pieces, int &next); - string cp_parse_non_delimiter(vector_string &pieces, int &next); + std::string cp_parse_non_delimiter(vector_string &pieces, int &next); bool cp_parse_coord_sys(ShaderArgInfo &arg, vector_string &pieces, int &next, ShaderMatSpec &spec, bool fromflag); @@ -524,7 +524,7 @@ public: void clear_parameters(); void set_compiled(unsigned int format, const char *data, size_t length); - bool get_compiled(unsigned int &format, string &binary) const; + bool get_compiled(unsigned int &format, std::string &binary) const; private: #ifdef HAVE_CG @@ -593,7 +593,7 @@ protected: PT(BamCacheRecord) _record; bool _cache_compiled_shader; unsigned int _compiled_format; - string _compiled_binary; + std::string _compiled_binary; static ShaderCaps _default_caps; static int _shaders_generated; @@ -615,10 +615,10 @@ private: Shader(ShaderLanguage lang); bool read(const ShaderFile &sfile, BamCacheRecord *record = nullptr); - bool do_read_source(string &into, const Filename &fn, BamCacheRecord *record); - bool r_preprocess_source(ostream &out, const Filename &fn, + bool do_read_source(std::string &into, const Filename &fn, BamCacheRecord *record); + bool r_preprocess_source(std::ostream &out, const Filename &fn, const Filename &source_dir, - set &open_files, + std::set &open_files, BamCacheRecord *record, int depth = 0); bool check_modified() const; diff --git a/panda/src/gobj/shaderBuffer.I b/panda/src/gobj/shaderBuffer.I index 8e328e933e..3d76a9c2a2 100644 --- a/panda/src/gobj/shaderBuffer.I +++ b/panda/src/gobj/shaderBuffer.I @@ -16,7 +16,7 @@ * parameters cannot be modified, but this may change in the future. */ INLINE ShaderBuffer:: -ShaderBuffer(const string &name, uint64_t size, UsageHint usage_hint) : +ShaderBuffer(const std::string &name, uint64_t size, UsageHint usage_hint) : Namable(name), _data_size_bytes(size), _usage_hint(usage_hint), @@ -28,7 +28,7 @@ ShaderBuffer(const string &name, uint64_t size, UsageHint usage_hint) : * parameters cannot be modified, but this may change in the future. */ INLINE ShaderBuffer:: -ShaderBuffer(const string &name, pvector initial_data, UsageHint usage_hint) : +ShaderBuffer(const std::string &name, pvector initial_data, UsageHint usage_hint) : Namable(name), _data_size_bytes(initial_data.size()), _usage_hint(usage_hint), diff --git a/panda/src/gobj/shaderBuffer.h b/panda/src/gobj/shaderBuffer.h index 53c110048b..70270fb0d3 100644 --- a/panda/src/gobj/shaderBuffer.h +++ b/panda/src/gobj/shaderBuffer.h @@ -34,15 +34,15 @@ private: PUBLISHED: ~ShaderBuffer(); - INLINE explicit ShaderBuffer(const string &name, uint64_t size, UsageHint usage_hint); - INLINE explicit ShaderBuffer(const string &name, pvector initial_data, UsageHint usage_hint); + INLINE explicit ShaderBuffer(const std::string &name, uint64_t size, UsageHint usage_hint); + INLINE explicit ShaderBuffer(const std::string &name, pvector initial_data, UsageHint usage_hint); public: INLINE uint64_t get_data_size_bytes() const; INLINE UsageHint get_usage_hint() const; INLINE const unsigned char *get_initial_data() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; PUBLISHED: MAKE_PROPERTY(data_size_bytes, get_data_size_bytes); @@ -92,7 +92,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const ShaderBuffer &m) { +INLINE std::ostream &operator << (std::ostream &out, const ShaderBuffer &m) { m.output(out); return out; } diff --git a/panda/src/gobj/simpleAllocator.h b/panda/src/gobj/simpleAllocator.h index 7793fdc3fe..9e4cb7661b 100644 --- a/panda/src/gobj/simpleAllocator.h +++ b/panda/src/gobj/simpleAllocator.h @@ -41,8 +41,8 @@ PUBLISHED: INLINE SimpleAllocatorBlock *get_first_block() const; - void output(ostream &out) const; - void write(ostream &out) const; + void output(std::ostream &out) const; + void write(std::ostream &out) const; protected: SimpleAllocatorBlock *do_alloc(size_t size); @@ -106,7 +106,7 @@ PUBLISHED: INLINE SimpleAllocatorBlock *get_next_block() const; - void output(ostream &out) const; + void output(std::ostream &out) const; protected: INLINE void do_free(); @@ -121,12 +121,12 @@ private: friend class SimpleAllocator; }; -INLINE ostream &operator << (ostream &out, const SimpleAllocator &obj) { +INLINE std::ostream &operator << (std::ostream &out, const SimpleAllocator &obj) { obj.output(out); return out; } -INLINE ostream &operator << (ostream &out, const SimpleAllocatorBlock &obj) { +INLINE std::ostream &operator << (std::ostream &out, const SimpleAllocatorBlock &obj) { obj.output(out); return out; } diff --git a/panda/src/gobj/simpleLru.h b/panda/src/gobj/simpleLru.h index 0eaaced1c8..5a712d8ffc 100644 --- a/panda/src/gobj/simpleLru.h +++ b/panda/src/gobj/simpleLru.h @@ -27,7 +27,7 @@ class SimpleLruPage; */ class EXPCL_PANDA_GOBJ SimpleLru : public LinkedListNode, public Namable { PUBLISHED: - explicit SimpleLru(const string &name, size_t max_size); + explicit SimpleLru(const std::string &name, size_t max_size); ~SimpleLru(); INLINE size_t get_total_size() const; @@ -41,8 +41,8 @@ PUBLISHED: INLINE bool validate(); - void output(ostream &out) const; - void write(ostream &out, int indent_level) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level) const; public: static LightMutex &_global_lock; @@ -83,8 +83,8 @@ PUBLISHED: virtual void evict_lru(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; private: SimpleLru *_lru; @@ -94,12 +94,12 @@ private: friend class SimpleLru; }; -inline ostream &operator << (ostream &out, const SimpleLru &lru) { +inline std::ostream &operator << (std::ostream &out, const SimpleLru &lru) { lru.output(out); return out; } -inline ostream &operator << (ostream &out, const SimpleLruPage &page) { +inline std::ostream &operator << (std::ostream &out, const SimpleLruPage &page) { page.output(out); return out; } diff --git a/panda/src/gobj/sliderTable.h b/panda/src/gobj/sliderTable.h index 9cc939c678..69d982112d 100644 --- a/panda/src/gobj/sliderTable.h +++ b/panda/src/gobj/sliderTable.h @@ -60,7 +60,7 @@ PUBLISHED: void remove_slider(size_t n); size_t add_slider(const VertexSlider *slider, const SparseArray &rows); - void write(ostream &out) const; + void write(std::ostream &out) const; private: void do_register(); @@ -132,7 +132,7 @@ private: friend class VertexSlider; }; -INLINE ostream &operator << (ostream &out, const SliderTable &obj); +INLINE std::ostream &operator << (std::ostream &out, const SliderTable &obj); #include "sliderTable.I" diff --git a/panda/src/gobj/texture.I b/panda/src/gobj/texture.I index 17023fce5c..c766c5b82d 100644 --- a/panda/src/gobj/texture.I +++ b/panda/src/gobj/texture.I @@ -2147,7 +2147,7 @@ rescale_texture() { * power-2. */ INLINE bool Texture:: -adjust_this_size(int &x_size, int &y_size, const string &name, +adjust_this_size(int &x_size, int &y_size, const std::string &name, bool for_padding) const { CDReader cdata(_cycler); return do_adjust_this_size(cdata, x_size, y_size, name, for_padding); @@ -2385,7 +2385,7 @@ get_half_float(const unsigned char *&p) { */ INLINE bool Texture:: is_txo_filename(const Filename &fullpath) { - string extension = fullpath.get_extension(); + std::string extension = fullpath.get_extension(); #ifdef HAVE_ZLIB if (extension == "pz" || extension == "gz") { extension = Filename(fullpath.get_basename_wo_extension()).get_extension(); @@ -2400,7 +2400,7 @@ is_txo_filename(const Filename &fullpath) { */ INLINE bool Texture:: is_dds_filename(const Filename &fullpath) { - string extension = fullpath.get_extension(); + std::string extension = fullpath.get_extension(); #ifdef HAVE_ZLIB if (extension == "pz" || extension == "gz") { extension = Filename(fullpath.get_basename_wo_extension()).get_extension(); @@ -2415,7 +2415,7 @@ is_dds_filename(const Filename &fullpath) { */ INLINE bool Texture:: is_ktx_filename(const Filename &fullpath) { - string extension = fullpath.get_extension(); + std::string extension = fullpath.get_extension(); #ifdef HAVE_ZLIB if (extension == "pz" || extension == "gz") { extension = Filename(fullpath.get_basename_wo_extension()).get_extension(); diff --git a/panda/src/gobj/texture.h b/panda/src/gobj/texture.h index 7e7f5ad57f..852f618c81 100644 --- a/panda/src/gobj/texture.h +++ b/panda/src/gobj/texture.h @@ -222,7 +222,7 @@ PUBLISHED: }; PUBLISHED: - explicit Texture(const string &name = string()); + explicit Texture(const std::string &name = std::string()); protected: Texture(const Texture ©); @@ -286,11 +286,11 @@ PUBLISHED: BLOCKING INLINE bool write(const Filename &fullpath, int z, int n, bool write_pages, bool write_mipmaps); - BLOCKING bool read_txo(istream &in, const string &filename = ""); - BLOCKING static PT(Texture) make_from_txo(istream &in, const string &filename = ""); - BLOCKING bool write_txo(ostream &out, const string &filename = "") const; - BLOCKING bool read_dds(istream &in, const string &filename = "", bool header_only = false); - BLOCKING bool read_ktx(istream &in, const string &filename = "", bool header_only = false); + BLOCKING bool read_txo(std::istream &in, const std::string &filename = ""); + BLOCKING static PT(Texture) make_from_txo(std::istream &in, const std::string &filename = ""); + BLOCKING bool write_txo(std::ostream &out, const std::string &filename = "") const; + BLOCKING bool read_dds(std::istream &in, const std::string &filename = "", bool header_only = false); + BLOCKING bool read_ktx(std::istream &in, const std::string &filename = "", bool header_only = false); BLOCKING INLINE bool load(const PNMImage &pnmimage, const LoaderOptions &options = LoaderOptions()); BLOCKING INLINE bool load(const PNMImage &pnmimage, int z, int n, const LoaderOptions &options = LoaderOptions()); @@ -443,17 +443,17 @@ PUBLISHED: INLINE CPTA_uchar get_ram_image(); INLINE CompressionMode get_ram_image_compression() const; INLINE CPTA_uchar get_uncompressed_ram_image(); - CPTA_uchar get_ram_image_as(const string &requested_format); + CPTA_uchar get_ram_image_as(const std::string &requested_format); INLINE PTA_uchar modify_ram_image(); INLINE PTA_uchar make_ram_image(); #ifndef CPPPARSER INLINE void set_ram_image(CPTA_uchar image, CompressionMode compression = CM_off, size_t page_size = 0); - void set_ram_image_as(CPTA_uchar image, const string &provided_format); + void set_ram_image_as(CPTA_uchar image, const std::string &provided_format); #else EXTEND void set_ram_image(PyObject *image, CompressionMode compression = CM_off, size_t page_size = 0); - EXTEND void set_ram_image_as(PyObject *image, const string &provided_format); + EXTEND void set_ram_image_as(PyObject *image, const std::string &provided_format); #endif INLINE void clear_ram_image(); INLINE void set_keep_ram_image(bool keep_ram_image); @@ -533,13 +533,13 @@ PUBLISHED: bool release(PreparedGraphicsObjects *prepared_objects); int release_all(); - void write(ostream &out, int indent_level) const; + void write(std::ostream &out, int indent_level) const; size_t estimate_texture_memory() const; - void set_aux_data(const string &key, TypedReferenceCount *aux_data); - void clear_aux_data(const string &key); - TypedReferenceCount *get_aux_data(const string &key) const; + void set_aux_data(const std::string &key, TypedReferenceCount *aux_data); + void clear_aux_data(const std::string &key); + TypedReferenceCount *get_aux_data(const std::string &key) const; MAKE_MAP_PROPERTY(aux_data, get_aux_data, get_aux_data, set_aux_data, clear_aux_data); @@ -593,23 +593,23 @@ PUBLISHED: static int down_to_power_2(int value); void consider_rescale(PNMImage &pnmimage); - static void consider_rescale(PNMImage &pnmimage, const string &name, AutoTextureScale auto_texture_scale = ATS_unspecified); + static void consider_rescale(PNMImage &pnmimage, const std::string &name, AutoTextureScale auto_texture_scale = ATS_unspecified); INLINE bool rescale_texture(); - static string format_texture_type(TextureType tt); - static TextureType string_texture_type(const string &str); + static std::string format_texture_type(TextureType tt); + static TextureType string_texture_type(const std::string &str); - static string format_component_type(ComponentType ct); - static ComponentType string_component_type(const string &str); + static std::string format_component_type(ComponentType ct); + static ComponentType string_component_type(const std::string &str); - static string format_format(Format f); - static Format string_format(const string &str); + static std::string format_format(Format f); + static Format string_format(const std::string &str); - static string format_compression_mode(CompressionMode cm); - static CompressionMode string_compression_mode(const string &str); + static std::string format_compression_mode(CompressionMode cm); + static CompressionMode string_compression_mode(const std::string &str); - static string format_quality_level(QualityLevel tql); - static QualityLevel string_quality_level(const string &str); + static std::string format_quality_level(QualityLevel tql); + static QualityLevel string_quality_level(const std::string &str); public: void texture_uploaded(); @@ -626,9 +626,9 @@ public: static bool has_binary_alpha(Format format); static bool is_srgb(Format format); - static bool adjust_size(int &x_size, int &y_size, const string &name, + static bool adjust_size(int &x_size, int &y_size, const std::string &name, bool for_padding, AutoTextureScale auto_texture_scale = ATS_unspecified); - INLINE bool adjust_this_size(int &x_size, int &y_size, const string &name, + INLINE bool adjust_this_size(int &x_size, int &y_size, const std::string &name, bool for_padding) const; virtual void ensure_loader_type(const Filename &filename); @@ -647,7 +647,7 @@ protected: // pointer representing that lock); generally, they also avoid adjusting the // _properties_modified and _image_modified semaphores. virtual bool do_adjust_this_size(const CData *cdata, - int &x_size, int &y_size, const string &name, + int &x_size, int &y_size, const std::string &name, bool for_padding) const; virtual bool do_read(CData *cdata, @@ -661,19 +661,19 @@ protected: const LoaderOptions &options, bool header_only, BamCacheRecord *record); virtual bool do_load_one(CData *cdata, - const PNMImage &pnmimage, const string &name, + const PNMImage &pnmimage, const std::string &name, int z, int n, const LoaderOptions &options); virtual bool do_load_one(CData *cdata, - const PfmFile &pfm, const string &name, + const PfmFile &pfm, const std::string &name, int z, int n, const LoaderOptions &options); virtual bool do_load_sub_image(CData *cdata, const PNMImage &image, int x, int y, int z, int n); bool do_read_txo_file(CData *cdata, const Filename &fullpath); - bool do_read_txo(CData *cdata, istream &in, const string &filename); + bool do_read_txo(CData *cdata, std::istream &in, const std::string &filename); bool do_read_dds_file(CData *cdata, const Filename &fullpath, bool header_only); - bool do_read_dds(CData *cdata, istream &in, const string &filename, bool header_only); + bool do_read_dds(CData *cdata, std::istream &in, const std::string &filename, bool header_only); bool do_read_ktx_file(CData *cdata, const Filename &fullpath, bool header_only); - bool do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only); + bool do_read_ktx(CData *cdata, std::istream &in, const std::string &filename, bool header_only); bool do_write(CData *cdata, const Filename &fullpath, int z, int n, bool write_pages, bool write_mipmaps); @@ -681,7 +681,7 @@ protected: bool do_store_one(CData *cdata, PNMImage &pnmimage, int z, int n); bool do_store_one(CData *cdata, PfmFile &pfm, int z, int n); bool do_write_txo_file(const CData *cdata, const Filename &fullpath) const; - bool do_write_txo(const CData *cdata, ostream &out, const string &filename) const; + bool do_write_txo(const CData *cdata, std::ostream &out, const std::string &filename) const; virtual CData *unlocked_ensure_ram_image(bool allow_compression); virtual void do_reload_ram_image(CData *cdata, bool allow_compression); @@ -810,44 +810,44 @@ private: CPTA_uchar image, size_t page_size, int z); static PTA_uchar read_dds_level_bgr8(Texture *tex, CData *cdata, const DDSHeader &header, - int n, istream &in); + int n, std::istream &in); static PTA_uchar read_dds_level_rgb8(Texture *tex, CData *cdata, const DDSHeader &header, - int n, istream &in); + int n, std::istream &in); static PTA_uchar read_dds_level_abgr8(Texture *tex, CData *cdata, const DDSHeader &header, - int n, istream &in); + int n, std::istream &in); static PTA_uchar read_dds_level_rgba8(Texture *tex, CData *cdata, const DDSHeader &header, - int n, istream &in); + int n, std::istream &in); static PTA_uchar read_dds_level_abgr16(Texture *tex, CData *cdata, const DDSHeader &header, - int n, istream &in); + int n, std::istream &in); static PTA_uchar read_dds_level_abgr32(Texture *tex, CData *cdata, const DDSHeader &header, - int n, istream &in); + int n, std::istream &in); static PTA_uchar read_dds_level_raw(Texture *tex, CData *cdata, const DDSHeader &header, - int n, istream &in); + int n, std::istream &in); static PTA_uchar read_dds_level_generic_uncompressed(Texture *tex, CData *cdata, const DDSHeader &header, - int n, istream &in); + int n, std::istream &in); static PTA_uchar read_dds_level_luminance_uncompressed(Texture *tex, CData *cdata, const DDSHeader &header, - int n, istream &in); + int n, std::istream &in); static PTA_uchar read_dds_level_bc1(Texture *tex, CData *cdata, const DDSHeader &header, - int n, istream &in); + int n, std::istream &in); static PTA_uchar read_dds_level_bc2(Texture *tex, CData *cdata, const DDSHeader &header, - int n, istream &in); + int n, std::istream &in); static PTA_uchar read_dds_level_bc3(Texture *tex, CData *cdata, const DDSHeader &header, - int n, istream &in); + int n, std::istream &in); static PTA_uchar read_dds_level_bc4(Texture *tex, CData *cdata, const DDSHeader &header, - int n, istream &in); + int n, std::istream &in); static PTA_uchar read_dds_level_bc5(Texture *tex, CData *cdata, const DDSHeader &header, - int n, istream &in); + int n, std::istream &in); void clear_prepared(int view, PreparedGraphicsObjects *prepared_objects); - static void consider_downgrade(PNMImage &pnmimage, int num_channels, const string &name); + static void consider_downgrade(PNMImage &pnmimage, int num_channels, const std::string &name); static bool compare_images(const PNMImage &a, const PNMImage &b); @@ -1058,7 +1058,7 @@ protected: private: // The auxiliary data is not recorded to a bam file. - typedef pmap AuxData; + typedef pmap AuxData; AuxData _aux_data; static AutoTextureScale _textures_power_2; @@ -1108,13 +1108,13 @@ private: extern EXPCL_PANDA_GOBJ ConfigVariableEnum texture_quality_level; -EXPCL_PANDA_GOBJ ostream &operator << (ostream &out, Texture::TextureType tt); -EXPCL_PANDA_GOBJ ostream &operator << (ostream &out, Texture::ComponentType ct); -EXPCL_PANDA_GOBJ ostream &operator << (ostream &out, Texture::Format f); +EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, Texture::TextureType tt); +EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, Texture::ComponentType ct); +EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, Texture::Format f); -EXPCL_PANDA_GOBJ ostream &operator << (ostream &out, Texture::CompressionMode cm); -EXPCL_PANDA_GOBJ ostream &operator << (ostream &out, Texture::QualityLevel tql); -EXPCL_PANDA_GOBJ istream &operator >> (istream &in, Texture::QualityLevel &tql); +EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, Texture::CompressionMode cm); +EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, Texture::QualityLevel tql); +EXPCL_PANDA_GOBJ std::istream &operator >> (std::istream &in, Texture::QualityLevel &tql); #include "texture.I" diff --git a/panda/src/gobj/textureCollection.h b/panda/src/gobj/textureCollection.h index 4cf0872708..5250d94a17 100644 --- a/panda/src/gobj/textureCollection.h +++ b/panda/src/gobj/textureCollection.h @@ -43,7 +43,7 @@ PUBLISHED: void clear(); void reserve(size_t num); - Texture *find_texture(const string &name) const; + Texture *find_texture(const std::string &name) const; int get_num_textures() const; Texture *get_texture(int index) const; @@ -57,15 +57,15 @@ PUBLISHED: INLINE void append(Texture *texture); INLINE void extend(const TextureCollection &other); - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; private: typedef PTA(PT(Texture)) Textures; Textures _textures; }; -INLINE ostream &operator << (ostream &out, const TextureCollection &col) { +INLINE std::ostream &operator << (std::ostream &out, const TextureCollection &col) { col.output(out); return out; } diff --git a/panda/src/gobj/textureContext.I b/panda/src/gobj/textureContext.I index b5d3712ad8..fa947755d0 100644 --- a/panda/src/gobj/textureContext.I +++ b/panda/src/gobj/textureContext.I @@ -123,7 +123,7 @@ mark_loaded() { // _data_size_bytes = _data->get_texture_size_bytes(); _properties_modified = _texture->get_properties_modified(); _image_modified = _texture->get_image_modified(); - update_modified(max(_properties_modified, _image_modified)); + update_modified(std::max(_properties_modified, _image_modified)); // Assume the texture is now resident. set_resident(true); @@ -137,7 +137,7 @@ INLINE void TextureContext:: mark_simple_loaded() { _properties_modified = _texture->get_properties_modified(); _simple_image_modified = _texture->get_simple_image_modified(); - update_modified(max(_properties_modified, _simple_image_modified)); + update_modified(std::max(_properties_modified, _simple_image_modified)); // The texture's not exactly resident now, but some part of it is. set_resident(true); diff --git a/panda/src/gobj/textureContext.h b/panda/src/gobj/textureContext.h index 813cd37dd9..c7ae367ccc 100644 --- a/panda/src/gobj/textureContext.h +++ b/panda/src/gobj/textureContext.h @@ -56,8 +56,8 @@ public: INLINE void mark_unloaded(); INLINE void mark_needs_reload(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; private: // This cannot be a PT(Texture), because the texture and the GSG both own @@ -88,7 +88,7 @@ private: friend class PreparedGraphicsObjects; }; -inline ostream &operator << (ostream &out, const TextureContext &context) { +inline std::ostream &operator << (std::ostream &out, const TextureContext &context) { context.output(out); return out; } diff --git a/panda/src/gobj/texturePool.I b/panda/src/gobj/texturePool.I index d8b1e96c9d..6ff48f14d3 100644 --- a/panda/src/gobj/texturePool.I +++ b/panda/src/gobj/texturePool.I @@ -200,7 +200,7 @@ garbage_collect() { * Lists the contents of the texture pool to the indicated output stream. */ INLINE void TexturePool:: -list_contents(ostream &out) { +list_contents(std::ostream &out) { get_global_ptr()->ns_list_contents(out); } @@ -209,7 +209,7 @@ list_contents(ostream &out) { */ INLINE void TexturePool:: list_contents() { - get_global_ptr()->ns_list_contents(cout); + get_global_ptr()->ns_list_contents(std::cout); } /** @@ -218,7 +218,7 @@ list_contents() { * if it is not. */ INLINE Texture *TexturePool:: -find_texture(const string &name) { +find_texture(const std::string &name) { return get_global_ptr()->ns_find_texture(name); } @@ -227,7 +227,7 @@ find_texture(const string &name) { * name (which may contain wildcards). */ INLINE TextureCollection TexturePool:: -find_all_textures(const string &name) { +find_all_textures(const std::string &name) { return get_global_ptr()->ns_find_all_textures(name); } @@ -245,7 +245,7 @@ set_fake_texture_image(const Filename &filename) { */ INLINE void TexturePool:: clear_fake_texture_image() { - set_fake_texture_image(string()); + set_fake_texture_image(std::string()); } /** @@ -272,6 +272,6 @@ get_fake_texture_image() { * register_texture_type(). */ PT(Texture) TexturePool:: -make_texture(const string &extension) { +make_texture(const std::string &extension) { return get_global_ptr()->ns_make_texture(extension); } diff --git a/panda/src/gobj/texturePool.h b/panda/src/gobj/texturePool.h index 2f0866cf3f..866374ec96 100644 --- a/panda/src/gobj/texturePool.h +++ b/panda/src/gobj/texturePool.h @@ -68,27 +68,27 @@ PUBLISHED: INLINE static int garbage_collect(); - INLINE static void list_contents(ostream &out); + INLINE static void list_contents(std::ostream &out); INLINE static void list_contents(); - INLINE static Texture *find_texture(const string &name); - INLINE static TextureCollection find_all_textures(const string &name = "*"); + INLINE static Texture *find_texture(const std::string &name); + INLINE static TextureCollection find_all_textures(const std::string &name = "*"); INLINE static void set_fake_texture_image(const Filename &filename); INLINE static void clear_fake_texture_image(); INLINE static bool has_fake_texture_image(); INLINE static const Filename &get_fake_texture_image(); - INLINE static PT(Texture) make_texture(const string &extension); + INLINE static PT(Texture) make_texture(const std::string &extension); - static void write(ostream &out); + static void write(std::ostream &out); public: typedef Texture::MakeTextureFunc MakeTextureFunc; - void register_texture_type(MakeTextureFunc *func, const string &extensions); + void register_texture_type(MakeTextureFunc *func, const std::string &extensions); void register_filter(TexturePoolFilter *filter); - MakeTextureFunc *get_texture_type(const string &extension) const; - void write_texture_types(ostream &out, int indent_level) const; + MakeTextureFunc *get_texture_type(const std::string &extension) const; + void write_texture_types(std::ostream &out, int indent_level) const; static TexturePool *get_global_ptr(); @@ -122,10 +122,10 @@ private: void ns_release_texture(Texture *texture); void ns_release_all_textures(); int ns_garbage_collect(); - void ns_list_contents(ostream &out) const; - Texture *ns_find_texture(const string &name) const; - TextureCollection ns_find_all_textures(const string &name) const; - PT(Texture) ns_make_texture(const string &extension) const; + void ns_list_contents(std::ostream &out) const; + Texture *ns_find_texture(const std::string &name) const; + TextureCollection ns_find_all_textures(const std::string &name) const; + PT(Texture) ns_make_texture(const std::string &extension) const; void resolve_filename(Filename &new_filename, const Filename &orig_filename, bool read_mipmaps, const LoaderOptions &options); @@ -159,7 +159,7 @@ private: PT(Texture) _normalization_cube_map; PT(Texture) _alpha_scale_map; - typedef pmap TypeRegistry; + typedef pmap TypeRegistry; TypeRegistry _type_registry; typedef pvector FilterRegistry; diff --git a/panda/src/gobj/texturePoolFilter.h b/panda/src/gobj/texturePoolFilter.h index 019b66fa9f..69a5278ff7 100644 --- a/panda/src/gobj/texturePoolFilter.h +++ b/panda/src/gobj/texturePoolFilter.h @@ -51,7 +51,7 @@ public: const LoaderOptions &options); virtual PT(Texture) post_load(Texture *tex); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; public: static TypeHandle get_class_type() { @@ -71,7 +71,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const TexturePoolFilter &filter) { +INLINE std::ostream &operator << (std::ostream &out, const TexturePoolFilter &filter) { filter.output(out); return out; } diff --git a/panda/src/gobj/textureReloadRequest.I b/panda/src/gobj/textureReloadRequest.I index a4e4e6fd7b..1b958ac6ef 100644 --- a/panda/src/gobj/textureReloadRequest.I +++ b/panda/src/gobj/textureReloadRequest.I @@ -16,7 +16,7 @@ * load_async(), to begin an asynchronous load. */ INLINE TextureReloadRequest:: -TextureReloadRequest(const string &name, +TextureReloadRequest(const std::string &name, PreparedGraphicsObjects *pgo, Texture *texture, bool allow_compressed) : AsyncTask(name), diff --git a/panda/src/gobj/textureReloadRequest.h b/panda/src/gobj/textureReloadRequest.h index 1e97c99ea2..625ac3ce3e 100644 --- a/panda/src/gobj/textureReloadRequest.h +++ b/panda/src/gobj/textureReloadRequest.h @@ -33,7 +33,7 @@ public: ALLOC_DELETED_CHAIN(TextureReloadRequest); PUBLISHED: - INLINE explicit TextureReloadRequest(const string &name, + INLINE explicit TextureReloadRequest(const std::string &name, PreparedGraphicsObjects *pgo, Texture *texture, bool allow_compressed); diff --git a/panda/src/gobj/textureStage.I b/panda/src/gobj/textureStage.I index dd8e24bce2..a6d26d8600 100644 --- a/panda/src/gobj/textureStage.I +++ b/panda/src/gobj/textureStage.I @@ -22,7 +22,7 @@ TextureStage(const TextureStage ©) { /** * Returns the name of this texture stage */ -INLINE const string &TextureStage:: +INLINE const std::string &TextureStage:: get_name() const { return _name; } @@ -31,7 +31,7 @@ get_name() const { * Changes the name of this texture stage */ INLINE void TextureStage:: -set_name(const string &name) { +set_name(const std::string &name) { _name = name; } @@ -121,7 +121,7 @@ set_texcoord_name(InternalName *name) { * any number of associated UV sets, each of which must have a unique name. */ INLINE void TextureStage:: -set_texcoord_name(const string &name) { +set_texcoord_name(const std::string &name) { set_texcoord_name(InternalName::get_texcoord_name(name)); } @@ -733,8 +733,8 @@ update_color_flags() { } } -INLINE ostream & -operator << (ostream &out, const TextureStage &ts) { +INLINE std::ostream & +operator << (std::ostream &out, const TextureStage &ts) { ts.output(out); return out; } diff --git a/panda/src/gobj/textureStage.h b/panda/src/gobj/textureStage.h index 2414e72991..5635f1e65a 100644 --- a/panda/src/gobj/textureStage.h +++ b/panda/src/gobj/textureStage.h @@ -34,7 +34,7 @@ class FactoryParams; */ class EXPCL_PANDA_GOBJ TextureStage : public TypedWritableReferenceCount { PUBLISHED: - explicit TextureStage(const string &name); + explicit TextureStage(const std::string &name); INLINE TextureStage(const TextureStage ©); void operator = (const TextureStage ©); @@ -97,8 +97,8 @@ PUBLISHED: CO_one_minus_src_alpha, }; - INLINE void set_name(const string &name); - INLINE const string &get_name() const; + INLINE void set_name(const std::string &name); + INLINE const std::string &get_name() const; INLINE void set_sort(int sort); INLINE int get_sort() const; @@ -107,7 +107,7 @@ PUBLISHED: INLINE int get_priority() const; INLINE void set_texcoord_name(InternalName *name); - INLINE void set_texcoord_name(const string &texcoord_name); + INLINE void set_texcoord_name(const std::string &texcoord_name); INLINE InternalName *get_texcoord_name() const; INLINE InternalName *get_tangent_name() const; INLINE InternalName *get_binormal_name() const; @@ -179,8 +179,8 @@ PUBLISHED: int compare_to(const TextureStage &other) const; - void write(ostream &out) const; - void output(ostream &out) const; + void write(std::ostream &out) const; + void output(std::ostream &out) const; INLINE static TextureStage *get_default(); @@ -216,7 +216,7 @@ private: static bool operand_valid_for_rgb(CombineOperand co); static bool operand_valid_for_alpha(CombineOperand co); - string _name; + std::string _name; int _sort; int _priority; PT(InternalName) _texcoord_name; @@ -283,12 +283,12 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const TextureStage &ts); +INLINE std::ostream &operator << (std::ostream &out, const TextureStage &ts); -EXPCL_PANDA_GOBJ ostream &operator << (ostream &out, TextureStage::Mode mode); -EXPCL_PANDA_GOBJ ostream &operator << (ostream &out, TextureStage::CombineMode cm); -EXPCL_PANDA_GOBJ ostream &operator << (ostream &out, TextureStage::CombineSource cs); -EXPCL_PANDA_GOBJ ostream &operator << (ostream &out, TextureStage::CombineOperand co); +EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, TextureStage::Mode mode); +EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, TextureStage::CombineMode cm); +EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, TextureStage::CombineSource cs); +EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, TextureStage::CombineOperand co); #include "textureStage.I" diff --git a/panda/src/gobj/textureStagePool.I b/panda/src/gobj/textureStagePool.I index a88d5e1561..3023116285 100644 --- a/panda/src/gobj/textureStagePool.I +++ b/panda/src/gobj/textureStagePool.I @@ -87,6 +87,6 @@ garbage_collect() { * Lists the contents of the TextureStage pool to the indicated output stream. */ INLINE void TextureStagePool:: -list_contents(ostream &out) { +list_contents(std::ostream &out) { get_global_ptr()->ns_list_contents(out); } diff --git a/panda/src/gobj/textureStagePool.h b/panda/src/gobj/textureStagePool.h index 4db775251d..3e654d50cb 100644 --- a/panda/src/gobj/textureStagePool.h +++ b/panda/src/gobj/textureStagePool.h @@ -46,8 +46,8 @@ PUBLISHED: MAKE_PROPERTY(mode, get_mode, set_mode); INLINE static int garbage_collect(); - INLINE static void list_contents(ostream &out); - static void write(ostream &out); + INLINE static void list_contents(std::ostream &out); + static void write(std::ostream &out); private: TextureStagePool(); @@ -60,7 +60,7 @@ private: Mode ns_get_mode(); int ns_garbage_collect(); - void ns_list_contents(ostream &out) const; + void ns_list_contents(std::ostream &out) const; static TextureStagePool *get_global_ptr(); @@ -75,14 +75,14 @@ private: typedef pmap > StagesByProperties; StagesByProperties _stages_by_properties; - typedef pmap StagesByName; + typedef pmap StagesByName; StagesByName _stages_by_name; Mode _mode; }; -EXPCL_PANDA_GOBJ ostream &operator << (ostream &out, TextureStagePool::Mode mode); -EXPCL_PANDA_GOBJ istream &operator >> (istream &in, TextureStagePool::Mode &mode); +EXPCL_PANDA_GOBJ std::ostream &operator << (std::ostream &out, TextureStagePool::Mode mode); +EXPCL_PANDA_GOBJ std::istream &operator >> (std::istream &in, TextureStagePool::Mode &mode); #include "textureStagePool.I" diff --git a/panda/src/gobj/texture_ext.h b/panda/src/gobj/texture_ext.h index d33fce24ef..b4f0559b08 100644 --- a/panda/src/gobj/texture_ext.h +++ b/panda/src/gobj/texture_ext.h @@ -31,7 +31,7 @@ class Extension : public ExtensionBase { public: void set_ram_image(PyObject *image, Texture::CompressionMode compression = Texture::CM_off, size_t page_size = 0); - void set_ram_image_as(PyObject *image, const string &provided_format); + void set_ram_image_as(PyObject *image, const std::string &provided_format); }; #endif // HAVE_PYTHON diff --git a/panda/src/gobj/transformBlend.I b/panda/src/gobj/transformBlend.I index aed8e95ca7..092e9bbeec 100644 --- a/panda/src/gobj/transformBlend.I +++ b/panda/src/gobj/transformBlend.I @@ -376,8 +376,8 @@ CData(const TransformBlend::CData ©) : { } -INLINE ostream & -operator << (ostream &out, const TransformBlend &obj) { +INLINE std::ostream & +operator << (std::ostream &out, const TransformBlend &obj) { obj.output(out); return out; } diff --git a/panda/src/gobj/transformBlend.h b/panda/src/gobj/transformBlend.h index 45b5793294..3adcb73128 100644 --- a/panda/src/gobj/transformBlend.h +++ b/panda/src/gobj/transformBlend.h @@ -86,8 +86,8 @@ PUBLISHED: INLINE UpdateSeq get_modified(Thread *current_thread = Thread::get_current_thread()) const; MAKE_PROPERTY(modified, get_modified); - void output(ostream &out) const; - void write(ostream &out, int indent_level) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level) const; private: class CData; @@ -145,7 +145,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const TransformBlend &obj); +INLINE std::ostream &operator << (std::ostream &out, const TransformBlend &obj); #include "transformBlend.I" diff --git a/panda/src/gobj/transformBlendTable.h b/panda/src/gobj/transformBlendTable.h index 55d628d349..644fbbb9b9 100644 --- a/panda/src/gobj/transformBlendTable.h +++ b/panda/src/gobj/transformBlendTable.h @@ -68,7 +68,7 @@ PUBLISHED: INLINE const SparseArray &get_rows() const; INLINE SparseArray &modify_rows(); - void write(ostream &out, int indent_level) const; + void write(std::ostream &out, int indent_level) const; MAKE_SEQ_PROPERTY(blends, get_num_blends, get_blend, set_blend, remove_blend); MAKE_PROPERTY(modified, get_modified); @@ -156,7 +156,7 @@ private: friend class VertexTransform; }; -INLINE ostream &operator << (ostream &out, const TransformBlendTable &obj); +INLINE std::ostream &operator << (std::ostream &out, const TransformBlendTable &obj); #include "transformBlendTable.I" diff --git a/panda/src/gobj/transformTable.h b/panda/src/gobj/transformTable.h index b55e4106df..8d77777dbb 100644 --- a/panda/src/gobj/transformTable.h +++ b/panda/src/gobj/transformTable.h @@ -55,7 +55,7 @@ PUBLISHED: void remove_transform(size_t n); size_t add_transform(const VertexTransform *transform); - void write(ostream &out) const; + void write(std::ostream &out) const; MAKE_PROPERTY(registered, is_registered); MAKE_PROPERTY(modified, get_modified); @@ -121,7 +121,7 @@ private: friend class VertexTransform; }; -INLINE ostream &operator << (ostream &out, const TransformTable &obj); +INLINE std::ostream &operator << (std::ostream &out, const TransformTable &obj); #include "transformTable.I" diff --git a/panda/src/gobj/userVertexSlider.h b/panda/src/gobj/userVertexSlider.h index aadeafd893..574e6bc6b7 100644 --- a/panda/src/gobj/userVertexSlider.h +++ b/panda/src/gobj/userVertexSlider.h @@ -30,7 +30,7 @@ class FactoryParams; */ class EXPCL_PANDA_GOBJ UserVertexSlider : public VertexSlider { PUBLISHED: - explicit UserVertexSlider(const string &name); + explicit UserVertexSlider(const std::string &name); explicit UserVertexSlider(const InternalName *name); INLINE void set_slider(PN_stdfloat slider); diff --git a/panda/src/gobj/userVertexTransform.I b/panda/src/gobj/userVertexTransform.I index 3b6d7b046a..3ac9204cca 100644 --- a/panda/src/gobj/userVertexTransform.I +++ b/panda/src/gobj/userVertexTransform.I @@ -14,7 +14,7 @@ /** * Returns the name passed to the constructor. Completely arbitrary. */ -INLINE const string &UserVertexTransform:: +INLINE const std::string &UserVertexTransform:: get_name() const { return _name; } diff --git a/panda/src/gobj/userVertexTransform.h b/panda/src/gobj/userVertexTransform.h index 377dff2a17..356d4f823a 100644 --- a/panda/src/gobj/userVertexTransform.h +++ b/panda/src/gobj/userVertexTransform.h @@ -30,17 +30,17 @@ class FactoryParams; */ class EXPCL_PANDA_GOBJ UserVertexTransform : public VertexTransform { PUBLISHED: - explicit UserVertexTransform(const string &name); + explicit UserVertexTransform(const std::string &name); - INLINE const string &get_name() const; + INLINE const std::string &get_name() const; INLINE void set_matrix(const LMatrix4 &matrix); virtual void get_matrix(LMatrix4 &matrix) const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: - string _name; + std::string _name; // This is the data that must be cycled between pipeline stages. class EXPCL_PANDA_GOBJ CData : public CycleData { diff --git a/panda/src/gobj/vertexBufferContext.h b/panda/src/gobj/vertexBufferContext.h index 76956aa8d2..69f02e0ed7 100644 --- a/panda/src/gobj/vertexBufferContext.h +++ b/panda/src/gobj/vertexBufferContext.h @@ -47,8 +47,8 @@ public: INLINE void mark_loaded(const GeomVertexArrayDataHandle *reader); INLINE void mark_unloaded(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; private: // This cannot be a PT(GeomVertexArrayData), because the data and the GSG @@ -77,7 +77,7 @@ private: friend class PreparedGraphicsObjects; }; -inline ostream &operator << (ostream &out, const VertexBufferContext &context) { +inline std::ostream &operator << (std::ostream &out, const VertexBufferContext &context) { context.output(out); return out; } diff --git a/panda/src/gobj/vertexDataPage.h b/panda/src/gobj/vertexDataPage.h index 24cc6af7d0..bceca6adea 100644 --- a/panda/src/gobj/vertexDataPage.h +++ b/panda/src/gobj/vertexDataPage.h @@ -74,8 +74,8 @@ PUBLISHED: static void stop_threads(); static void flush_threads(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; public: INLINE unsigned char *get_page_data(bool force); @@ -114,7 +114,7 @@ private: class PageThreadManager; class EXPCL_PANDA_GOBJ PageThread : public Thread { public: - PageThread(PageThreadManager *manager, const string &name); + PageThread(PageThreadManager *manager, const std::string &name); protected: virtual void thread_main(); @@ -228,7 +228,7 @@ private: friend class VertexDataBook; }; -inline ostream &operator << (ostream &out, const VertexDataPage &page) { +inline std::ostream &operator << (std::ostream &out, const VertexDataPage &page) { page.output(out); return out; } diff --git a/panda/src/gobj/vertexDataSaveFile.h b/panda/src/gobj/vertexDataSaveFile.h index d71708227a..56eac67ee3 100644 --- a/panda/src/gobj/vertexDataSaveFile.h +++ b/panda/src/gobj/vertexDataSaveFile.h @@ -35,7 +35,7 @@ class VertexDataSaveBlock; */ class EXPCL_PANDA_GOBJ VertexDataSaveFile : public SimpleAllocator { public: - VertexDataSaveFile(const Filename &directory, const string &prefix, + VertexDataSaveFile(const Filename &directory, const std::string &prefix, size_t max_size); ~VertexDataSaveFile(); diff --git a/panda/src/gobj/vertexSlider.I b/panda/src/gobj/vertexSlider.I index 2d48a56e29..faad108d69 100644 --- a/panda/src/gobj/vertexSlider.I +++ b/panda/src/gobj/vertexSlider.I @@ -47,8 +47,8 @@ CData(const VertexSlider::CData ©) : { } -INLINE ostream & -operator << (ostream &out, const VertexSlider &obj) { +INLINE std::ostream & +operator << (std::ostream &out, const VertexSlider &obj) { obj.output(out); return out; } diff --git a/panda/src/gobj/vertexSlider.h b/panda/src/gobj/vertexSlider.h index 7c3c135292..649fab72fb 100644 --- a/panda/src/gobj/vertexSlider.h +++ b/panda/src/gobj/vertexSlider.h @@ -47,8 +47,8 @@ PUBLISHED: MAKE_PROPERTY(slider, get_slider); MAKE_PROPERTY(modified, get_modified); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; protected: void mark_modified(Thread *current_thread); @@ -106,7 +106,7 @@ private: friend class SliderTable; }; -INLINE ostream &operator << (ostream &out, const VertexSlider &obj); +INLINE std::ostream &operator << (std::ostream &out, const VertexSlider &obj); #include "vertexSlider.I" diff --git a/panda/src/gobj/vertexTransform.I b/panda/src/gobj/vertexTransform.I index cf7830c296..57fd7dd939 100644 --- a/panda/src/gobj/vertexTransform.I +++ b/panda/src/gobj/vertexTransform.I @@ -48,8 +48,8 @@ CData(const VertexTransform::CData ©) : { } -INLINE ostream & -operator << (ostream &out, const VertexTransform &obj) { +INLINE std::ostream & +operator << (std::ostream &out, const VertexTransform &obj) { obj.output(out); return out; } diff --git a/panda/src/gobj/vertexTransform.h b/panda/src/gobj/vertexTransform.h index ff106bf56e..86a663c9b3 100644 --- a/panda/src/gobj/vertexTransform.h +++ b/panda/src/gobj/vertexTransform.h @@ -44,8 +44,8 @@ PUBLISHED: INLINE UpdateSeq get_modified(Thread *current_thread = Thread::get_current_thread()) const; MAKE_PROPERTY(modified, get_modified); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; static UpdateSeq get_next_modified(Thread *current_thread); INLINE static UpdateSeq get_global_modified(Thread *current_thread); @@ -107,7 +107,7 @@ private: friend class TransformTable; }; -INLINE ostream &operator << (ostream &out, const VertexTransform &obj); +INLINE std::ostream &operator << (std::ostream &out, const VertexTransform &obj); #include "vertexTransform.I" diff --git a/panda/src/gobj/videoTexture.h b/panda/src/gobj/videoTexture.h index 755bc763c1..b9a0b4540e 100644 --- a/panda/src/gobj/videoTexture.h +++ b/panda/src/gobj/videoTexture.h @@ -27,7 +27,7 @@ */ class EXPCL_PANDA_GOBJ VideoTexture : public Texture, public AnimInterface { protected: - VideoTexture(const string &name); + VideoTexture(const std::string &name); VideoTexture(const VideoTexture ©); PUBLISHED: @@ -53,7 +53,7 @@ protected: virtual bool do_can_reload(const Texture::CData *cdata) const; virtual bool do_adjust_this_size(const Texture::CData *cdata, - int &x_size, int &y_size, const string &name, + int &x_size, int &y_size, const std::string &name, bool for_padding) const; virtual void consider_update(); diff --git a/panda/src/grutil/cardMaker.I b/panda/src/grutil/cardMaker.I index c10991e92d..b960808ca0 100644 --- a/panda/src/grutil/cardMaker.I +++ b/panda/src/grutil/cardMaker.I @@ -15,7 +15,7 @@ * */ INLINE CardMaker:: -CardMaker(const string &name) : Namable(name) { +CardMaker(const std::string &name) : Namable(name) { reset(); } diff --git a/panda/src/grutil/cardMaker.h b/panda/src/grutil/cardMaker.h index ff8e6e2eb6..426fc2d5c5 100644 --- a/panda/src/grutil/cardMaker.h +++ b/panda/src/grutil/cardMaker.h @@ -28,7 +28,7 @@ */ class EXPCL_PANDA_GRUTIL CardMaker : public Namable { PUBLISHED: - INLINE explicit CardMaker(const string &name); + INLINE explicit CardMaker(const std::string &name); INLINE ~CardMaker(); void reset(); diff --git a/panda/src/grutil/fisheyeMaker.I b/panda/src/grutil/fisheyeMaker.I index c567e9e43e..54085a23e0 100644 --- a/panda/src/grutil/fisheyeMaker.I +++ b/panda/src/grutil/fisheyeMaker.I @@ -15,7 +15,7 @@ * */ INLINE FisheyeMaker:: -FisheyeMaker(const string &name) : Namable(name) { +FisheyeMaker(const std::string &name) : Namable(name) { reset(); } diff --git a/panda/src/grutil/fisheyeMaker.h b/panda/src/grutil/fisheyeMaker.h index d6bb5b7a73..83aa118ac3 100644 --- a/panda/src/grutil/fisheyeMaker.h +++ b/panda/src/grutil/fisheyeMaker.h @@ -33,7 +33,7 @@ class GeomVertexWriter; */ class EXPCL_PANDA_GRUTIL FisheyeMaker : public Namable { PUBLISHED: - INLINE explicit FisheyeMaker(const string &name); + INLINE explicit FisheyeMaker(const std::string &name); INLINE ~FisheyeMaker(); void reset(); diff --git a/panda/src/grutil/frameRateMeter.I b/panda/src/grutil/frameRateMeter.I index 744ed17d49..02877fa226 100644 --- a/panda/src/grutil/frameRateMeter.I +++ b/panda/src/grutil/frameRateMeter.I @@ -56,7 +56,7 @@ get_update_interval() const { * per second. */ INLINE void FrameRateMeter:: -set_text_pattern(const string &text_pattern) { +set_text_pattern(const std::string &text_pattern) { _text_pattern = text_pattern; Thread *current_thread = Thread::get_current_thread(); do_update(current_thread); @@ -65,7 +65,7 @@ set_text_pattern(const string &text_pattern) { /** * Returns the sprintf() pattern that is used to format the text. */ -INLINE const string &FrameRateMeter:: +INLINE const std::string &FrameRateMeter:: get_text_pattern() const { return _text_pattern; } diff --git a/panda/src/grutil/frameRateMeter.h b/panda/src/grutil/frameRateMeter.h index 2e3f657819..5faa692a43 100644 --- a/panda/src/grutil/frameRateMeter.h +++ b/panda/src/grutil/frameRateMeter.h @@ -36,7 +36,7 @@ class ClockObject; */ class EXPCL_PANDA_GRUTIL FrameRateMeter : public TextNode { PUBLISHED: - explicit FrameRateMeter(const string &name); + explicit FrameRateMeter(const std::string &name); virtual ~FrameRateMeter(); void setup_window(GraphicsOutput *window); @@ -48,8 +48,8 @@ PUBLISHED: INLINE void set_update_interval(double update_interval); INLINE double get_update_interval() const; - INLINE void set_text_pattern(const string &text_pattern); - INLINE const string &get_text_pattern() const; + INLINE void set_text_pattern(const std::string &text_pattern); + INLINE const std::string &get_text_pattern() const; INLINE void set_clock_object(ClockObject *clock_object); INLINE ClockObject *get_clock_object() const; @@ -70,7 +70,7 @@ private: bool _show_milliseconds; double _update_interval; double _last_update; - string _text_pattern; + std::string _text_pattern; ClockObject *_clock_object; PN_stdfloat _last_aspect_ratio; diff --git a/panda/src/grutil/geoMipTerrain.I b/panda/src/grutil/geoMipTerrain.I index eb41d492fc..7eeeddab7a 100644 --- a/panda/src/grutil/geoMipTerrain.I +++ b/panda/src/grutil/geoMipTerrain.I @@ -17,7 +17,7 @@ * */ INLINE GeoMipTerrain:: -GeoMipTerrain(const string &name) { +GeoMipTerrain(const std::string &name) { _root = NodePath(name); _root_flattened = false; _xsize = 0; @@ -425,7 +425,7 @@ set_color_map(const Texture *tex) { } INLINE bool GeoMipTerrain:: -set_color_map(const string &path) { +set_color_map(const std::string &path) { return set_color_map(Filename(path)); } @@ -479,8 +479,8 @@ get_border_stitching() { */ INLINE double GeoMipTerrain:: get_pixel_value(int x, int y) { - x = max(min(x,int(_xsize-1)),0); - y = max(min(y,int(_ysize-1)),0); + x = std::max(std::min(x,int(_xsize-1)),0); + y = std::max(std::min(y,int(_ysize-1)),0); if (_heightfield.is_grayscale()) { return double(_heightfield.get_bright(x, y)); } else { diff --git a/panda/src/grutil/geoMipTerrain.h b/panda/src/grutil/geoMipTerrain.h index cc68450419..0d0ce94da0 100644 --- a/panda/src/grutil/geoMipTerrain.h +++ b/panda/src/grutil/geoMipTerrain.h @@ -35,7 +35,7 @@ */ class EXPCL_PANDA_GRUTIL GeoMipTerrain : public TypedObject { PUBLISHED: - INLINE explicit GeoMipTerrain(const string &name); + INLINE explicit GeoMipTerrain(const std::string &name); INLINE ~GeoMipTerrain(); INLINE PNMImage &heightfield(); @@ -46,7 +46,7 @@ PUBLISHED: PNMFileType *type = nullptr); INLINE bool set_color_map(const PNMImage &image); INLINE bool set_color_map(const Texture *image); - INLINE bool set_color_map(const string &path); + INLINE bool set_color_map(const std::string &path); INLINE bool has_color_map() const; INLINE void clear_color_map(); void calc_ambient_occlusion(PN_stdfloat radius = 32, PN_stdfloat contrast = 2.0f, PN_stdfloat brightness = 0.75f); diff --git a/panda/src/grutil/heightfieldTesselator.I b/panda/src/grutil/heightfieldTesselator.I index dee41354a1..7bab2b0a45 100644 --- a/panda/src/grutil/heightfieldTesselator.I +++ b/panda/src/grutil/heightfieldTesselator.I @@ -15,7 +15,7 @@ * */ INLINE HeightfieldTesselator:: -HeightfieldTesselator(const string &name) : Namable(name) { +HeightfieldTesselator(const std::string &name) : Namable(name) { _poly_count = 10000; _visibility_radius = 32768; _focal_x = 0; diff --git a/panda/src/grutil/heightfieldTesselator.h b/panda/src/grutil/heightfieldTesselator.h index cd39245e7b..f2d358a82f 100644 --- a/panda/src/grutil/heightfieldTesselator.h +++ b/panda/src/grutil/heightfieldTesselator.h @@ -57,7 +57,7 @@ class EXPCL_PANDA_GRUTIL HeightfieldTesselator : public Namable { PUBLISHED: - INLINE explicit HeightfieldTesselator(const string &name); + INLINE explicit HeightfieldTesselator(const std::string &name); INLINE ~HeightfieldTesselator(); INLINE PNMImage &heightfield(); diff --git a/panda/src/grutil/lineSegs.h b/panda/src/grutil/lineSegs.h index 174467da31..08bc56ab0e 100644 --- a/panda/src/grutil/lineSegs.h +++ b/panda/src/grutil/lineSegs.h @@ -32,7 +32,7 @@ */ class EXPCL_PANDA_GRUTIL LineSegs : public Namable { PUBLISHED: - explicit LineSegs(const string &name = "lines"); + explicit LineSegs(const std::string &name = "lines"); ~LineSegs(); void reset(); diff --git a/panda/src/grutil/movieTexture.h b/panda/src/grutil/movieTexture.h index ab4d549b86..c1721f4320 100644 --- a/panda/src/grutil/movieTexture.h +++ b/panda/src/grutil/movieTexture.h @@ -32,7 +32,7 @@ */ class EXPCL_PANDA_GRUTIL MovieTexture : public Texture { PUBLISHED: - explicit MovieTexture(const string &name); + explicit MovieTexture(const std::string &name); explicit MovieTexture(MovieVideo *video); MovieTexture(const MovieTexture ©) = delete; virtual ~MovieTexture(); @@ -91,7 +91,7 @@ protected: virtual bool do_can_reload(const Texture::CData *cdata) const; virtual bool do_adjust_this_size(const Texture::CData *cdata, - int &x_size, int &y_size, const string &name, + int &x_size, int &y_size, const std::string &name, bool for_padding) const; virtual bool do_read_one(Texture::CData *cdata, @@ -100,7 +100,7 @@ protected: const LoaderOptions &options, bool header_only, BamCacheRecord *record); virtual bool do_load_one(Texture::CData *cdata, - const PNMImage &pnmimage, const string &name, + const PNMImage &pnmimage, const std::string &name, int z, int n, const LoaderOptions &options); bool do_load_one(Texture::CData *cdata, PT(MovieVideoCursor) color, PT(MovieVideoCursor) alpha, diff --git a/panda/src/grutil/nodeVertexTransform.h b/panda/src/grutil/nodeVertexTransform.h index 55bb0bc6bf..12b8b11667 100644 --- a/panda/src/grutil/nodeVertexTransform.h +++ b/panda/src/grutil/nodeVertexTransform.h @@ -38,7 +38,7 @@ PUBLISHED: virtual void get_matrix(LMatrix4 &matrix) const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: CPT(PandaNode) _node; diff --git a/panda/src/grutil/rigidBodyCombiner.h b/panda/src/grutil/rigidBodyCombiner.h index fca66e0031..f1694f49b0 100644 --- a/panda/src/grutil/rigidBodyCombiner.h +++ b/panda/src/grutil/rigidBodyCombiner.h @@ -43,7 +43,7 @@ class NodePath; */ class EXPCL_PANDA_GRUTIL RigidBodyCombiner : public PandaNode { PUBLISHED: - explicit RigidBodyCombiner(const string &name); + explicit RigidBodyCombiner(const std::string &name); protected: RigidBodyCombiner(const RigidBodyCombiner ©); virtual PandaNode *make_copy() const; diff --git a/panda/src/grutil/sceneGraphAnalyzerMeter.h b/panda/src/grutil/sceneGraphAnalyzerMeter.h index a20066d9d7..148aa37022 100644 --- a/panda/src/grutil/sceneGraphAnalyzerMeter.h +++ b/panda/src/grutil/sceneGraphAnalyzerMeter.h @@ -38,7 +38,7 @@ class ClockObject; */ class EXPCL_PANDA_GRUTIL SceneGraphAnalyzerMeter : public TextNode { PUBLISHED: - explicit SceneGraphAnalyzerMeter(const string &name, PandaNode *node); + explicit SceneGraphAnalyzerMeter(const std::string &name, PandaNode *node); virtual ~SceneGraphAnalyzerMeter(); void setup_window(GraphicsOutput *window); diff --git a/panda/src/iphonedisplay/iPhoneGraphicsPipe.h b/panda/src/iphonedisplay/iPhoneGraphicsPipe.h index 24418bda12..12405bcbbc 100644 --- a/panda/src/iphonedisplay/iPhoneGraphicsPipe.h +++ b/panda/src/iphonedisplay/iPhoneGraphicsPipe.h @@ -33,14 +33,14 @@ public: IPhoneGraphicsPipe(); virtual ~IPhoneGraphicsPipe(); - virtual string get_interface_name() const; + virtual std::string get_interface_name() const; static PT(GraphicsPipe) pipe_constructor(); virtual PreferredWindowThread get_preferred_window_thread() const; void rotate_windows(); protected: - virtual PT(GraphicsOutput) make_output(const string &name, + virtual PT(GraphicsOutput) make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/iphonedisplay/iPhoneGraphicsWindow.h b/panda/src/iphonedisplay/iPhoneGraphicsWindow.h index 7a73a70302..6da377b18d 100644 --- a/panda/src/iphonedisplay/iPhoneGraphicsWindow.h +++ b/panda/src/iphonedisplay/iPhoneGraphicsWindow.h @@ -28,7 +28,7 @@ class IPhoneGraphicsWindow : public GraphicsWindow { public: IPhoneGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/linmath/configVariableColor.I b/panda/src/linmath/configVariableColor.I index c600d7246b..751d7f415a 100644 --- a/panda/src/linmath/configVariableColor.I +++ b/panda/src/linmath/configVariableColor.I @@ -15,7 +15,7 @@ * */ INLINE ConfigVariableColor:: -ConfigVariableColor(const string &name) : +ConfigVariableColor(const std::string &name) : ConfigVariable(name, VT_color), _local_modified(initial_invalid_cache()), _cache(0, 0, 0, 1) @@ -27,12 +27,12 @@ ConfigVariableColor(const string &name) : * */ INLINE ConfigVariableColor:: -ConfigVariableColor(const string &name, const LColor &default_value, - const string &description, int flags) : +ConfigVariableColor(const std::string &name, const LColor &default_value, + const std::string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, ConfigVariableCore::VT_color, description, flags), #else - ConfigVariable(name, ConfigVariableCore::VT_color, string(), flags), + ConfigVariable(name, ConfigVariableCore::VT_color, std::string(), flags), #endif _local_modified(initial_invalid_cache()), _cache(0, 0, 0, 1) @@ -45,12 +45,12 @@ ConfigVariableColor(const string &name, const LColor &default_value, * */ INLINE ConfigVariableColor:: -ConfigVariableColor(const string &name, const string &default_value, - const string &description, int flags) : +ConfigVariableColor(const std::string &name, const std::string &default_value, + const std::string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, ConfigVariableCore::VT_color, description, flags), #else - ConfigVariable(name, ConfigVariableCore::VT_color, string(), flags), + ConfigVariable(name, ConfigVariableCore::VT_color, std::string(), flags), #endif _local_modified(initial_invalid_cache()), _cache(0, 0, 0, 1) diff --git a/panda/src/linmath/configVariableColor.h b/panda/src/linmath/configVariableColor.h index 380644a57a..fba5330e26 100644 --- a/panda/src/linmath/configVariableColor.h +++ b/panda/src/linmath/configVariableColor.h @@ -34,12 +34,12 @@ */ class EXPCL_PANDA_LINMATH ConfigVariableColor : public ConfigVariable { PUBLISHED: - INLINE ConfigVariableColor(const string &name); - INLINE ConfigVariableColor(const string &name, const LColor &default_value, - const string &description = string(), + INLINE ConfigVariableColor(const std::string &name); + INLINE ConfigVariableColor(const std::string &name, const LColor &default_value, + const std::string &description = std::string(), int flags = 0); - INLINE ConfigVariableColor(const string &name, const string &default_value, - const string &description = string(), + INLINE ConfigVariableColor(const std::string &name, const std::string &default_value, + const std::string &description = std::string(), int flags = 0); INLINE void operator = (const LColor &value); diff --git a/panda/src/linmath/coordinateSystem.h b/panda/src/linmath/coordinateSystem.h index ba40f3d2b0..313645a35e 100644 --- a/panda/src/linmath/coordinateSystem.h +++ b/panda/src/linmath/coordinateSystem.h @@ -38,16 +38,16 @@ enum CoordinateSystem { }; EXPCL_PANDA_LINMATH CoordinateSystem get_default_coordinate_system(); -EXPCL_PANDA_LINMATH CoordinateSystem parse_coordinate_system_string(const string &str); -EXPCL_PANDA_LINMATH string format_coordinate_system(CoordinateSystem cs); +EXPCL_PANDA_LINMATH CoordinateSystem parse_coordinate_system_string(const std::string &str); +EXPCL_PANDA_LINMATH std::string format_coordinate_system(CoordinateSystem cs); EXPCL_PANDA_LINMATH bool is_right_handed(CoordinateSystem cs = CS_default); END_PUBLISH #define IS_LEFT_HANDED_COORDSYSTEM(cs) ((cs==CS_zup_left) || (cs==CS_yup_left)) -EXPCL_PANDA_LINMATH ostream &operator << (ostream &out, CoordinateSystem cs); -EXPCL_PANDA_LINMATH istream &operator >> (istream &in, CoordinateSystem &cs); +EXPCL_PANDA_LINMATH std::ostream &operator << (std::ostream &out, CoordinateSystem cs); +EXPCL_PANDA_LINMATH std::istream &operator >> (std::istream &in, CoordinateSystem &cs); #endif diff --git a/panda/src/linmath/lmatrix3_ext_src.I b/panda/src/linmath/lmatrix3_ext_src.I index a58a57c155..0d92b37aa4 100644 --- a/panda/src/linmath/lmatrix3_ext_src.I +++ b/panda/src/linmath/lmatrix3_ext_src.I @@ -37,9 +37,9 @@ __reduce__(PyObject *self) const { /** * */ -INLINE_LINMATH string Extension:: +INLINE_LINMATH std::string Extension:: __repr__() const { - ostringstream out; + std::ostringstream out; out << "LMatrix3" << FLOATTOKEN << "(" << MAYBE_ZERO(_this->_m(0, 0)) << ", " << MAYBE_ZERO(_this->_m(0, 1)) << ", " diff --git a/panda/src/linmath/lmatrix3_ext_src.h b/panda/src/linmath/lmatrix3_ext_src.h index 34828c9133..6c4894c69f 100644 --- a/panda/src/linmath/lmatrix3_ext_src.h +++ b/panda/src/linmath/lmatrix3_ext_src.h @@ -19,7 +19,7 @@ template<> class Extension : public ExtensionBase { public: INLINE_LINMATH PyObject *__reduce__(PyObject *self) const; - INLINE_LINMATH string __repr__() const; + INLINE_LINMATH std::string __repr__() const; }; #include "lmatrix3_ext_src.I" diff --git a/panda/src/linmath/lmatrix3_src.h b/panda/src/linmath/lmatrix3_src.h index fa01ef2c27..399508ed5f 100644 --- a/panda/src/linmath/lmatrix3_src.h +++ b/panda/src/linmath/lmatrix3_src.h @@ -285,9 +285,9 @@ PUBLISHED: INLINE_LINMATH bool almost_equal(const FLOATNAME(LMatrix3) &other) const; - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; - EXTENSION(INLINE_LINMATH string __repr__() const); + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; + EXTENSION(INLINE_LINMATH std::string __repr__() const); INLINE_LINMATH void generate_hash(ChecksumHashGenerator &hashgen) const; void generate_hash( @@ -327,7 +327,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const FLOATNAME(LMatrix3) &mat) { +INLINE std::ostream &operator << (std::ostream &out, const FLOATNAME(LMatrix3) &mat) { mat.output(out); return out; } diff --git a/panda/src/linmath/lmatrix4_ext_src.I b/panda/src/linmath/lmatrix4_ext_src.I index 928ce1c837..68a2741bbb 100644 --- a/panda/src/linmath/lmatrix4_ext_src.I +++ b/panda/src/linmath/lmatrix4_ext_src.I @@ -38,9 +38,9 @@ __reduce__(PyObject *self) const { /** * */ -INLINE_LINMATH string Extension:: +INLINE_LINMATH std::string Extension:: __repr__() const { - ostringstream out; + std::ostringstream out; out << "LMatrix4" << FLOATTOKEN << "(" << MAYBE_ZERO(_this->_m(0, 0)) << ", " << MAYBE_ZERO(_this->_m(0, 1)) << ", " diff --git a/panda/src/linmath/lmatrix4_ext_src.h b/panda/src/linmath/lmatrix4_ext_src.h index 65dfe8bb20..768be01526 100644 --- a/panda/src/linmath/lmatrix4_ext_src.h +++ b/panda/src/linmath/lmatrix4_ext_src.h @@ -19,7 +19,7 @@ template<> class Extension : public ExtensionBase { public: INLINE_LINMATH PyObject *__reduce__(PyObject *self) const; - INLINE_LINMATH string __repr__() const; + INLINE_LINMATH std::string __repr__() const; }; #include "lmatrix4_ext_src.I" diff --git a/panda/src/linmath/lmatrix4_src.h b/panda/src/linmath/lmatrix4_src.h index de2d2fbf78..4d749cddd5 100644 --- a/panda/src/linmath/lmatrix4_src.h +++ b/panda/src/linmath/lmatrix4_src.h @@ -263,9 +263,9 @@ PUBLISHED: FLOATTYPE threshold) const; INLINE_LINMATH bool almost_equal(const FLOATNAME(LMatrix4) &other) const; - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; - EXTENSION(INLINE_LINMATH string __repr__() const); + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; + EXTENSION(INLINE_LINMATH std::string __repr__() const); INLINE_LINMATH void generate_hash(ChecksumHashGenerator &hashgen) const; void generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE scale) const; @@ -363,7 +363,7 @@ private: }; -INLINE ostream &operator << (ostream &out, const FLOATNAME(LMatrix4) &mat) { +INLINE std::ostream &operator << (std::ostream &out, const FLOATNAME(LMatrix4) &mat) { mat.output(out); return out; } diff --git a/panda/src/linmath/lpoint2_ext_src.I b/panda/src/linmath/lpoint2_ext_src.I index 371017955d..acfa098501 100644 --- a/panda/src/linmath/lpoint2_ext_src.I +++ b/panda/src/linmath/lpoint2_ext_src.I @@ -14,9 +14,9 @@ /** * */ -INLINE_LINMATH string Extension:: +INLINE_LINMATH std::string Extension:: __repr__() const { - ostringstream out; + std::ostringstream out; out << "LPoint2" << FLOATTOKEN << "(" << MAYBE_ZERO(_this->_v(0)) << ", " << MAYBE_ZERO(_this->_v(1)) << ")"; @@ -27,7 +27,7 @@ __repr__() const { * This is used to implement swizzle masks. */ INLINE_LINMATH PyObject *Extension:: -__getattr__(PyObject *self, const string &attr_name) const { +__getattr__(PyObject *self, const std::string &attr_name) const { #ifndef CPPPARSER extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint2); extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint3); @@ -35,7 +35,7 @@ __getattr__(PyObject *self, const string &attr_name) const { #endif // Validate the attribute name. - for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { + for (std::string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it != 'x' && *it != 'y') { return Dtool_Raise_AttributeError(self, attr_name.c_str()); } @@ -75,7 +75,7 @@ __getattr__(PyObject *self, const string &attr_name) const { * This is used to implement write masks. */ INLINE_LINMATH int Extension:: -__setattr__(PyObject *self, const string &attr_name, PyObject *assign) { +__setattr__(PyObject *self, const std::string &attr_name, PyObject *assign) { // Upcall to LVecBase2. return invoke_extension(_this).__setattr__(self, attr_name, assign); } diff --git a/panda/src/linmath/lpoint2_ext_src.h b/panda/src/linmath/lpoint2_ext_src.h index 78fa18cfa9..27eadd1bdf 100644 --- a/panda/src/linmath/lpoint2_ext_src.h +++ b/panda/src/linmath/lpoint2_ext_src.h @@ -18,9 +18,9 @@ template<> class Extension : public ExtensionBase { public: - INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const; - INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign); - INLINE_LINMATH string __repr__() const; + INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const; + INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign); + INLINE_LINMATH std::string __repr__() const; }; #include "lpoint2_ext_src.I" diff --git a/panda/src/linmath/lpoint2_src.h b/panda/src/linmath/lpoint2_src.h index fef5c791f9..070fc13086 100644 --- a/panda/src/linmath/lpoint2_src.h +++ b/panda/src/linmath/lpoint2_src.h @@ -22,8 +22,8 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LPoint2)(FLOATTYPE fill_value); INLINE_LINMATH FLOATNAME(LPoint2)(FLOATTYPE x, FLOATTYPE y); - EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const); - EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign)); + EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const); + EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign)); INLINE_LINMATH static const FLOATNAME(LPoint2) &zero(); INLINE_LINMATH static const FLOATNAME(LPoint2) &unit_x(); @@ -51,7 +51,7 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LPoint2) project(const FLOATNAME(LVecBase2) &onto) const; #endif - EXTENSION(INLINE_LINMATH string __repr__() const); + EXTENSION(INLINE_LINMATH std::string __repr__() const); public: static TypeHandle get_class_type() { diff --git a/panda/src/linmath/lpoint3_ext_src.I b/panda/src/linmath/lpoint3_ext_src.I index e695988177..95cb1dbdd3 100644 --- a/panda/src/linmath/lpoint3_ext_src.I +++ b/panda/src/linmath/lpoint3_ext_src.I @@ -14,9 +14,9 @@ /** * */ -INLINE_LINMATH string Extension:: +INLINE_LINMATH std::string Extension:: __repr__() const { - ostringstream out; + std::ostringstream out; out << "LPoint3" << FLOATTOKEN << "(" << MAYBE_ZERO(_this->_v(0)) << ", " << MAYBE_ZERO(_this->_v(1)) << ", " @@ -28,7 +28,7 @@ __repr__() const { * This is used to implement swizzle masks. */ INLINE_LINMATH PyObject *Extension:: -__getattr__(PyObject *self, const string &attr_name) const { +__getattr__(PyObject *self, const std::string &attr_name) const { #ifndef CPPPARSER extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint2); extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint3); @@ -36,7 +36,7 @@ __getattr__(PyObject *self, const string &attr_name) const { #endif // Validate the attribute name. - for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { + for (std::string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'x' || *it > 'z') { return Dtool_Raise_AttributeError(self, attr_name.c_str()); } @@ -76,7 +76,7 @@ __getattr__(PyObject *self, const string &attr_name) const { * This is used to implement write masks. */ INLINE_LINMATH int Extension:: -__setattr__(PyObject *self, const string &attr_name, PyObject *assign) { +__setattr__(PyObject *self, const std::string &attr_name, PyObject *assign) { // Upcall to LVecBase2. return invoke_extension(_this).__setattr__(self, attr_name, assign); } diff --git a/panda/src/linmath/lpoint3_ext_src.h b/panda/src/linmath/lpoint3_ext_src.h index f5aa413ec8..3c820d3a45 100644 --- a/panda/src/linmath/lpoint3_ext_src.h +++ b/panda/src/linmath/lpoint3_ext_src.h @@ -18,9 +18,9 @@ template<> class Extension : public ExtensionBase { public: - INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const; - INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign); - INLINE_LINMATH string __repr__() const; + INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const; + INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign); + INLINE_LINMATH std::string __repr__() const; }; #include "lpoint3_ext_src.I" diff --git a/panda/src/linmath/lpoint3_src.h b/panda/src/linmath/lpoint3_src.h index 5089e81c9e..3510aa329e 100644 --- a/panda/src/linmath/lpoint3_src.h +++ b/panda/src/linmath/lpoint3_src.h @@ -26,8 +26,8 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LPoint3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z); INLINE_LINMATH FLOATNAME(LPoint3)(const FLOATNAME(LVecBase2) ©, FLOATTYPE z); - EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const); - EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign)); + EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const); + EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign)); INLINE_LINMATH static const FLOATNAME(LPoint3) &zero(); INLINE_LINMATH static const FLOATNAME(LPoint3) &unit_x(); @@ -74,7 +74,7 @@ PUBLISHED: FLOATTYPE up, CoordinateSystem cs = CS_default); - EXTENSION(INLINE_LINMATH string __repr__() const); + EXTENSION(INLINE_LINMATH std::string __repr__() const); public: static TypeHandle get_class_type() { diff --git a/panda/src/linmath/lpoint4_ext_src.I b/panda/src/linmath/lpoint4_ext_src.I index bef1b1d012..e4101b5ed9 100644 --- a/panda/src/linmath/lpoint4_ext_src.I +++ b/panda/src/linmath/lpoint4_ext_src.I @@ -14,9 +14,9 @@ /** * */ -INLINE_LINMATH string Extension:: +INLINE_LINMATH std::string Extension:: __repr__() const { - ostringstream out; + std::ostringstream out; out << "LPoint4" << FLOATTOKEN << "(" << MAYBE_ZERO(_this->_v(0)) << ", " << MAYBE_ZERO(_this->_v(1)) << ", " @@ -29,7 +29,7 @@ __repr__() const { * This is used to implement swizzle masks. */ INLINE_LINMATH PyObject *Extension:: -__getattr__(PyObject *self, const string &attr_name) const { +__getattr__(PyObject *self, const std::string &attr_name) const { #ifndef CPPPARSER extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint2); extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LPoint3); @@ -37,7 +37,7 @@ __getattr__(PyObject *self, const string &attr_name) const { #endif // Validate the attribute name. - for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { + for (std::string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'w' || *it > 'z') { return Dtool_Raise_AttributeError(self, attr_name.c_str()); } @@ -81,7 +81,7 @@ __getattr__(PyObject *self, const string &attr_name) const { * This is used to implement write masks. */ INLINE_LINMATH int Extension:: -__setattr__(PyObject *self, const string &attr_name, PyObject *assign) { +__setattr__(PyObject *self, const std::string &attr_name, PyObject *assign) { // Upcall to LVecBase4. return invoke_extension(_this).__setattr__(self, attr_name, assign); } diff --git a/panda/src/linmath/lpoint4_ext_src.h b/panda/src/linmath/lpoint4_ext_src.h index 88ae845ed4..82c9ea62f1 100644 --- a/panda/src/linmath/lpoint4_ext_src.h +++ b/panda/src/linmath/lpoint4_ext_src.h @@ -18,9 +18,9 @@ template<> class Extension : public ExtensionBase { public: - INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const; - INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign); - INLINE_LINMATH string __repr__() const; + INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const; + INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign); + INLINE_LINMATH std::string __repr__() const; }; #include "lpoint4_ext_src.I" diff --git a/panda/src/linmath/lpoint4_src.h b/panda/src/linmath/lpoint4_src.h index 1eda6fa4fe..7a9902f55d 100644 --- a/panda/src/linmath/lpoint4_src.h +++ b/panda/src/linmath/lpoint4_src.h @@ -22,8 +22,8 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LPoint4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w); INLINE_LINMATH FLOATNAME(LPoint4)(const FLOATNAME(LVecBase3) ©, FLOATTYPE w); - EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const); - EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign)); + EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const); + EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign)); INLINE_LINMATH static const FLOATNAME(LPoint4) &zero(); INLINE_LINMATH static const FLOATNAME(LPoint4) &unit_x(); @@ -59,7 +59,7 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LPoint4) project(const FLOATNAME(LVecBase4) &onto) const; #endif - EXTENSION(INLINE_LINMATH string __repr__() const); + EXTENSION(INLINE_LINMATH std::string __repr__() const); public: static TypeHandle get_class_type() { diff --git a/panda/src/linmath/lquaternion_src.I b/panda/src/linmath/lquaternion_src.I index 05f1d46bec..eb464d07f1 100644 --- a/panda/src/linmath/lquaternion_src.I +++ b/panda/src/linmath/lquaternion_src.I @@ -231,7 +231,7 @@ almost_same_direction(const FLOATNAME(LQuaternion) &other, * */ INLINE_LINMATH void FLOATNAME(LQuaternion):: -output(ostream& os) const { +output(std::ostream& os) const { os << MAYBE_ZERO(_v(0)) << " + " << MAYBE_ZERO(_v(1)) << "i + " << MAYBE_ZERO(_v(2)) << "j + " diff --git a/panda/src/linmath/lquaternion_src.h b/panda/src/linmath/lquaternion_src.h index 00ba2a934f..52bbc6fff7 100644 --- a/panda/src/linmath/lquaternion_src.h +++ b/panda/src/linmath/lquaternion_src.h @@ -68,7 +68,7 @@ PUBLISHED: INLINE_LINMATH bool almost_same_direction( const FLOATNAME(LQuaternion) &other, FLOATTYPE threshold) const; - INLINE_LINMATH void output(ostream&) const; + INLINE_LINMATH void output(std::ostream&) const; void extract_to_matrix(FLOATNAME(LMatrix3) &m) const; void extract_to_matrix(FLOATNAME(LMatrix4) &m) const; @@ -127,7 +127,7 @@ private: }; -INLINE ostream& operator<<(ostream& os, const FLOATNAME(LQuaternion)& q) { +INLINE std::ostream& operator<<(std::ostream& os, const FLOATNAME(LQuaternion)& q) { q.output(os); return os; } diff --git a/panda/src/linmath/lvecBase2_ext_src.I b/panda/src/linmath/lvecBase2_ext_src.I index 3e0a35fff4..c76cb6649f 100644 --- a/panda/src/linmath/lvecBase2_ext_src.I +++ b/panda/src/linmath/lvecBase2_ext_src.I @@ -27,9 +27,9 @@ /** * */ -INLINE_LINMATH string Extension:: +INLINE_LINMATH std::string Extension:: __repr__() const { - ostringstream out; + std::ostringstream out; out << "LVecBase2" << FLOATTOKEN << "(" << MAYBE_ZERO(_this->_v(0)) << ", " << MAYBE_ZERO(_this->_v(1)) << ")"; @@ -69,7 +69,7 @@ __reduce__(PyObject *self) const { * This is used to implement swizzle masks. */ INLINE_LINMATH PyObject *Extension:: -__getattr__(PyObject *self, const string &attr_name) const { +__getattr__(PyObject *self, const std::string &attr_name) const { #ifndef CPPPARSER extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2); extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase3); @@ -77,7 +77,7 @@ __getattr__(PyObject *self, const string &attr_name) const { #endif // Validate the attribute name. - for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { + for (std::string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it != 'x' && *it != 'y') { return Dtool_Raise_AttributeError(self, attr_name.c_str()); } @@ -117,10 +117,10 @@ __getattr__(PyObject *self, const string &attr_name) const { * This is used to implement write masks. */ INLINE_LINMATH int Extension:: -__setattr__(PyObject *self, const string &attr_name, PyObject *assign) { +__setattr__(PyObject *self, const std::string &attr_name, PyObject *assign) { #ifndef NDEBUG // Validate the attribute name. - for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { + for (std::string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it != 'x' && *it != 'y') { Dtool_Raise_AttributeError(self, attr_name.c_str()); return -1; @@ -189,7 +189,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Loop through the components in the attribute name, and assign the // floating-point value to every one of them. - for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { + for (std::string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { _this->_v((*it) - 'x') = value; } } diff --git a/panda/src/linmath/lvecBase2_ext_src.h b/panda/src/linmath/lvecBase2_ext_src.h index 3d6efe4831..9abffe5859 100644 --- a/panda/src/linmath/lvecBase2_ext_src.h +++ b/panda/src/linmath/lvecBase2_ext_src.h @@ -19,9 +19,9 @@ template<> class Extension : public ExtensionBase { public: INLINE_LINMATH PyObject *__reduce__(PyObject *self) const; - INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const; - INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign); - INLINE_LINMATH string __repr__() const; + INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const; + INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign); + INLINE_LINMATH std::string __repr__() const; INLINE_LINMATH FLOATNAME(LVecBase2) __pow__(FLOATTYPE exponent) const; INLINE_LINMATH PyObject *__ipow__(PyObject *self, FLOATTYPE exponent); diff --git a/panda/src/linmath/lvecBase2_src.I b/panda/src/linmath/lvecBase2_src.I index 401e2e346a..1ef2c133a7 100644 --- a/panda/src/linmath/lvecBase2_src.I +++ b/panda/src/linmath/lvecBase2_src.I @@ -631,7 +631,7 @@ almost_equal(const FLOATNAME(LVecBase2) &other) const { * */ INLINE_LINMATH void FLOATNAME(LVecBase2):: -output(ostream &out) const { +output(std::ostream &out) const { out << MAYBE_ZERO(_v(0)) << " " << MAYBE_ZERO(_v(1)); } diff --git a/panda/src/linmath/lvecBase2_src.h b/panda/src/linmath/lvecBase2_src.h index 5d35293544..c868f90d60 100644 --- a/panda/src/linmath/lvecBase2_src.h +++ b/panda/src/linmath/lvecBase2_src.h @@ -45,8 +45,8 @@ PUBLISHED: INLINE_LINMATH static const FLOATNAME(LVecBase2) &unit_y(); EXTENSION(INLINE_LINMATH PyObject *__reduce__(PyObject *self) const); - EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const); - EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign)); + EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const); + EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign)); INLINE_LINMATH FLOATTYPE operator [](int i) const; INLINE_LINMATH FLOATTYPE &operator [](int i); @@ -143,8 +143,8 @@ PUBLISHED: FLOATTYPE threshold) const; INLINE_LINMATH bool almost_equal(const FLOATNAME(LVecBase2) &other) const; - INLINE_LINMATH void output(ostream &out) const; - EXTENSION(INLINE_LINMATH string __repr__() const); + INLINE_LINMATH void output(std::ostream &out) const; + EXTENSION(INLINE_LINMATH std::string __repr__() const); INLINE_LINMATH void write_datagram_fixed(Datagram &destination) const; INLINE_LINMATH void read_datagram_fixed(DatagramIterator &source); @@ -180,7 +180,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const FLOATNAME(LVecBase2) &vec) { +INLINE std::ostream &operator << (std::ostream &out, const FLOATNAME(LVecBase2) &vec) { vec.output(out); return out; } diff --git a/panda/src/linmath/lvecBase3_ext_src.I b/panda/src/linmath/lvecBase3_ext_src.I index 871928da2f..ba163ec637 100644 --- a/panda/src/linmath/lvecBase3_ext_src.I +++ b/panda/src/linmath/lvecBase3_ext_src.I @@ -27,9 +27,9 @@ /** * */ -INLINE_LINMATH string Extension:: +INLINE_LINMATH std::string Extension:: __repr__() const { - ostringstream out; + std::ostringstream out; out << "LVecBase3" << FLOATTOKEN << "(" << MAYBE_ZERO(_this->_v(0)) << ", " << MAYBE_ZERO(_this->_v(1)) << ", " @@ -70,7 +70,7 @@ __reduce__(PyObject *self) const { * This is used to implement swizzle masks. */ INLINE_LINMATH PyObject *Extension:: -__getattr__(PyObject *self, const string &attr_name) const { +__getattr__(PyObject *self, const std::string &attr_name) const { #ifndef CPPPARSER extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2); extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase3); @@ -78,7 +78,7 @@ __getattr__(PyObject *self, const string &attr_name) const { #endif // Validate the attribute name. - for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { + for (std::string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'x' || *it > 'z') { return Dtool_Raise_AttributeError(self, attr_name.c_str()); } @@ -118,10 +118,10 @@ __getattr__(PyObject *self, const string &attr_name) const { * This is used to implement write masks. */ INLINE_LINMATH int Extension:: -__setattr__(PyObject *self, const string &attr_name, PyObject *assign) { +__setattr__(PyObject *self, const std::string &attr_name, PyObject *assign) { #ifndef NDEBUG // Validate the attribute name. - for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { + for (std::string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'x' || *it > 'z') { Dtool_Raise_AttributeError(self, attr_name.c_str()); return -1; @@ -190,7 +190,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Loop through the components in the attribute name, and assign the // floating-point value to every one of them. - for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { + for (std::string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { _this->_v((*it) - 'x') = value; } } diff --git a/panda/src/linmath/lvecBase3_ext_src.h b/panda/src/linmath/lvecBase3_ext_src.h index e88a28790b..4f91322f23 100644 --- a/panda/src/linmath/lvecBase3_ext_src.h +++ b/panda/src/linmath/lvecBase3_ext_src.h @@ -19,9 +19,9 @@ template<> class Extension : public ExtensionBase { public: INLINE_LINMATH PyObject *__reduce__(PyObject *self) const; - INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const; - INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign); - INLINE_LINMATH string __repr__() const; + INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const; + INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign); + INLINE_LINMATH std::string __repr__() const; INLINE_LINMATH FLOATNAME(LVecBase3) __pow__(FLOATTYPE exponent) const; INLINE_LINMATH PyObject *__ipow__(PyObject *self, FLOATTYPE exponent); diff --git a/panda/src/linmath/lvecBase3_src.I b/panda/src/linmath/lvecBase3_src.I index eeaea584d5..b34b783faf 100644 --- a/panda/src/linmath/lvecBase3_src.I +++ b/panda/src/linmath/lvecBase3_src.I @@ -795,7 +795,7 @@ almost_equal(const FLOATNAME(LVecBase3) &other) const { * */ INLINE_LINMATH void FLOATNAME(LVecBase3):: -output(ostream &out) const { +output(std::ostream &out) const { out << MAYBE_ZERO(_v(0)) << " " << MAYBE_ZERO(_v(1)) << " " << MAYBE_ZERO(_v(2)); diff --git a/panda/src/linmath/lvecBase3_src.h b/panda/src/linmath/lvecBase3_src.h index 5def855cdd..3536615aeb 100644 --- a/panda/src/linmath/lvecBase3_src.h +++ b/panda/src/linmath/lvecBase3_src.h @@ -47,8 +47,8 @@ PUBLISHED: INLINE_LINMATH static const FLOATNAME(LVecBase3) &unit_z(); EXTENSION(INLINE_LINMATH PyObject *__reduce__(PyObject *self) const); - EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const); - EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign)); + EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const); + EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign)); INLINE_LINMATH FLOATTYPE operator [](int i) const; INLINE_LINMATH FLOATTYPE &operator [](int i); @@ -164,8 +164,8 @@ PUBLISHED: FLOATTYPE threshold) const; INLINE_LINMATH bool almost_equal(const FLOATNAME(LVecBase3) &other) const; - INLINE_LINMATH void output(ostream &out) const; - EXTENSION(INLINE_LINMATH string __repr__() const); + INLINE_LINMATH void output(std::ostream &out) const; + EXTENSION(INLINE_LINMATH std::string __repr__() const); INLINE_LINMATH void write_datagram_fixed(Datagram &destination) const; INLINE_LINMATH void read_datagram_fixed(DatagramIterator &source); @@ -199,7 +199,7 @@ private: }; -INLINE ostream &operator << (ostream &out, const FLOATNAME(LVecBase3) &vec) { +INLINE std::ostream &operator << (std::ostream &out, const FLOATNAME(LVecBase3) &vec) { vec.output(out); return out; }; diff --git a/panda/src/linmath/lvecBase4_ext_src.I b/panda/src/linmath/lvecBase4_ext_src.I index cab78609a3..78d359c315 100644 --- a/panda/src/linmath/lvecBase4_ext_src.I +++ b/panda/src/linmath/lvecBase4_ext_src.I @@ -27,9 +27,9 @@ /** * */ -INLINE_LINMATH string Extension:: +INLINE_LINMATH std::string Extension:: __repr__() const { - ostringstream out; + std::ostringstream out; out << "LVecBase4" << FLOATTOKEN << "(" << MAYBE_ZERO(_this->_v(0)) << ", " << MAYBE_ZERO(_this->_v(1)) << ", " @@ -71,7 +71,7 @@ __reduce__(PyObject *self) const { * This is used to implement swizzle masks. */ INLINE_LINMATH PyObject *Extension:: -__getattr__(PyObject *self, const string &attr_name) const { +__getattr__(PyObject *self, const std::string &attr_name) const { #ifndef CPPPARSER extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase2); extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVecBase3); @@ -79,7 +79,7 @@ __getattr__(PyObject *self, const string &attr_name) const { #endif // Validate the attribute name. - for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { + for (std::string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'w' || *it > 'z') { return Dtool_Raise_AttributeError(self, attr_name.c_str()); } @@ -123,10 +123,10 @@ __getattr__(PyObject *self, const string &attr_name) const { * This is used to implement write masks. */ INLINE_LINMATH int Extension:: -__setattr__(PyObject *self, const string &attr_name, PyObject *assign) { +__setattr__(PyObject *self, const std::string &attr_name, PyObject *assign) { #ifndef NDEBUG // Validate the attribute name. - for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { + for (std::string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'w' || *it > 'z') { Dtool_Raise_AttributeError(self, attr_name.c_str()); return -1; @@ -196,7 +196,7 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Loop through the components in the attribute name, and assign the // floating-point value to every one of them. - for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { + for (std::string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { _this->_v(((*it) == 'w') ? 3 : (*it) - 'x') = value; } } diff --git a/panda/src/linmath/lvecBase4_ext_src.h b/panda/src/linmath/lvecBase4_ext_src.h index b7a916fd60..9d7d837c89 100644 --- a/panda/src/linmath/lvecBase4_ext_src.h +++ b/panda/src/linmath/lvecBase4_ext_src.h @@ -19,9 +19,9 @@ template<> class Extension : public ExtensionBase { public: INLINE_LINMATH PyObject *__reduce__(PyObject *self) const; - INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const; - INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign); - INLINE_LINMATH string __repr__() const; + INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const; + INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign); + INLINE_LINMATH std::string __repr__() const; INLINE_LINMATH FLOATNAME(LVecBase4) __pow__(FLOATTYPE exponent) const; INLINE_LINMATH PyObject *__ipow__(PyObject *self, FLOATTYPE exponent); diff --git a/panda/src/linmath/lvecBase4_src.I b/panda/src/linmath/lvecBase4_src.I index bdf7e917b6..9cf554454b 100644 --- a/panda/src/linmath/lvecBase4_src.I +++ b/panda/src/linmath/lvecBase4_src.I @@ -799,7 +799,7 @@ almost_equal(const FLOATNAME(LVecBase4) &other) const { * */ INLINE_LINMATH void FLOATNAME(LVecBase4):: -output(ostream &out) const { +output(std::ostream &out) const { out << MAYBE_ZERO(_v(0)) << " " << MAYBE_ZERO(_v(1)) << " " << MAYBE_ZERO(_v(2)) << " " diff --git a/panda/src/linmath/lvecBase4_src.h b/panda/src/linmath/lvecBase4_src.h index b76d89a7ae..b634791d91 100644 --- a/panda/src/linmath/lvecBase4_src.h +++ b/panda/src/linmath/lvecBase4_src.h @@ -57,8 +57,8 @@ PUBLISHED: INLINE_LINMATH static const FLOATNAME(LVecBase4) &unit_w(); EXTENSION(INLINE_LINMATH PyObject *__reduce__(PyObject *self) const); - EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const); - EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign)); + EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const); + EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign)); INLINE_LINMATH FLOATTYPE operator [](int i) const; INLINE_LINMATH FLOATTYPE &operator [](int i); @@ -170,8 +170,8 @@ PUBLISHED: FLOATTYPE threshold) const; INLINE_LINMATH bool almost_equal(const FLOATNAME(LVecBase4) &other) const; - INLINE_LINMATH void output(ostream &out) const; - EXTENSION(INLINE_LINMATH string __repr__() const); + INLINE_LINMATH void output(std::ostream &out) const; + EXTENSION(INLINE_LINMATH std::string __repr__() const); INLINE_LINMATH void write_datagram_fixed(Datagram &destination) const; INLINE_LINMATH void read_datagram_fixed(DatagramIterator &source); @@ -261,7 +261,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const FLOATNAME(LVecBase4) &vec) { +INLINE std::ostream &operator << (std::ostream &out, const FLOATNAME(LVecBase4) &vec) { vec.output(out); return out; } diff --git a/panda/src/linmath/lvector2_ext_src.I b/panda/src/linmath/lvector2_ext_src.I index dd4dc5e95e..0d9aaa0258 100644 --- a/panda/src/linmath/lvector2_ext_src.I +++ b/panda/src/linmath/lvector2_ext_src.I @@ -14,9 +14,9 @@ /** * */ -INLINE_LINMATH string Extension:: +INLINE_LINMATH std::string Extension:: __repr__() const { - ostringstream out; + std::ostringstream out; out << "LVector2" << FLOATTOKEN << "(" << MAYBE_ZERO(_this->_v(0)) << ", " << MAYBE_ZERO(_this->_v(1)) << ")"; @@ -27,7 +27,7 @@ __repr__() const { * This is used to implement swizzle masks. */ INLINE_LINMATH PyObject *Extension:: -__getattr__(PyObject *self, const string &attr_name) const { +__getattr__(PyObject *self, const std::string &attr_name) const { #ifndef CPPPARSER extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2); extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector3); @@ -35,7 +35,7 @@ __getattr__(PyObject *self, const string &attr_name) const { #endif // Validate the attribute name. - for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { + for (std::string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it != 'x' && *it != 'y') { return Dtool_Raise_AttributeError(self, attr_name.c_str()); } @@ -75,7 +75,7 @@ __getattr__(PyObject *self, const string &attr_name) const { * This is used to implement write masks. */ INLINE_LINMATH int Extension:: -__setattr__(PyObject *self, const string &attr_name, PyObject *assign) { +__setattr__(PyObject *self, const std::string &attr_name, PyObject *assign) { // Upcall to LVecBase2. return invoke_extension(_this).__setattr__(self, attr_name, assign); } diff --git a/panda/src/linmath/lvector2_ext_src.h b/panda/src/linmath/lvector2_ext_src.h index fb16cbda9d..0028c73431 100644 --- a/panda/src/linmath/lvector2_ext_src.h +++ b/panda/src/linmath/lvector2_ext_src.h @@ -18,9 +18,9 @@ template<> class Extension : public ExtensionBase { public: - INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const; - INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign); - INLINE_LINMATH string __repr__() const; + INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const; + INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign); + INLINE_LINMATH std::string __repr__() const; }; #include "lvector2_ext_src.I" diff --git a/panda/src/linmath/lvector2_src.h b/panda/src/linmath/lvector2_src.h index 9b6020e00a..1454205985 100644 --- a/panda/src/linmath/lvector2_src.h +++ b/panda/src/linmath/lvector2_src.h @@ -22,8 +22,8 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LVector2)(FLOATTYPE fill_value); INLINE_LINMATH FLOATNAME(LVector2)(FLOATTYPE x, FLOATTYPE y); - EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const); - EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign)); + EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const); + EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign)); INLINE_LINMATH static const FLOATNAME(LVector2) &zero(); INLINE_LINMATH static const FLOATNAME(LVector2) &unit_x(); @@ -47,7 +47,7 @@ PUBLISHED: INLINE_LINMATH FLOATTYPE signed_angle_deg(const FLOATNAME(LVector2) &other) const; #endif - EXTENSION(INLINE_LINMATH string __repr__() const); + EXTENSION(INLINE_LINMATH std::string __repr__() const); public: static TypeHandle get_class_type() { diff --git a/panda/src/linmath/lvector3_ext_src.I b/panda/src/linmath/lvector3_ext_src.I index 155c2a013a..ee620ba30a 100644 --- a/panda/src/linmath/lvector3_ext_src.I +++ b/panda/src/linmath/lvector3_ext_src.I @@ -14,9 +14,9 @@ /** * */ -INLINE_LINMATH string Extension:: +INLINE_LINMATH std::string Extension:: __repr__() const { - ostringstream out; + std::ostringstream out; out << "LVector3" << FLOATTOKEN << "(" << MAYBE_ZERO(_this->_v(0)) << ", " << MAYBE_ZERO(_this->_v(1)) << ", " @@ -28,7 +28,7 @@ __repr__() const { * This is used to implement swizzle masks. */ INLINE_LINMATH PyObject *Extension:: -__getattr__(PyObject *self, const string &attr_name) const { +__getattr__(PyObject *self, const std::string &attr_name) const { #ifndef CPPPARSER extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2); extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector3); @@ -36,7 +36,7 @@ __getattr__(PyObject *self, const string &attr_name) const { #endif // Validate the attribute name. - for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { + for (std::string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'x' || *it > 'z') { return Dtool_Raise_AttributeError(self, attr_name.c_str()); } @@ -76,7 +76,7 @@ __getattr__(PyObject *self, const string &attr_name) const { * This is used to implement write masks. */ INLINE_LINMATH int Extension:: -__setattr__(PyObject *self, const string &attr_name, PyObject *assign) { +__setattr__(PyObject *self, const std::string &attr_name, PyObject *assign) { // Upcall to LVecBase3. return invoke_extension(_this).__setattr__(self, attr_name, assign); } diff --git a/panda/src/linmath/lvector3_ext_src.h b/panda/src/linmath/lvector3_ext_src.h index 4283e61d36..577382dcd8 100644 --- a/panda/src/linmath/lvector3_ext_src.h +++ b/panda/src/linmath/lvector3_ext_src.h @@ -18,9 +18,9 @@ template<> class Extension : public ExtensionBase { public: - INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const; - INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign); - INLINE_LINMATH string __repr__() const; + INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const; + INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign); + INLINE_LINMATH std::string __repr__() const; }; #include "lvector3_ext_src.I" diff --git a/panda/src/linmath/lvector3_src.I b/panda/src/linmath/lvector3_src.I index 3e2404f272..3313e6e45f 100644 --- a/panda/src/linmath/lvector3_src.I +++ b/panda/src/linmath/lvector3_src.I @@ -183,10 +183,10 @@ angle_rad(const FLOATNAME(LVector3) &other) const { // poorly as dot(other) approaches 1.0. if (dot(other) < 0.0f) { FLOATTYPE a = ((*this)+other).length() / 2.0f; - return MathNumbers::cpi((FLOATTYPE)0.0f) - 2.0f * casin(min(a, (FLOATTYPE)1.0)); + return MathNumbers::cpi((FLOATTYPE)0.0f) - 2.0f * casin(std::min(a, (FLOATTYPE)1.0)); } else { FLOATTYPE a = ((*this)-other).length() / 2.0f; - return 2.0f * casin(min(a, (FLOATTYPE)1.0)); + return 2.0f * casin(std::min(a, (FLOATTYPE)1.0)); } } diff --git a/panda/src/linmath/lvector3_src.h b/panda/src/linmath/lvector3_src.h index 777a064ffd..1052e5cee8 100644 --- a/panda/src/linmath/lvector3_src.h +++ b/panda/src/linmath/lvector3_src.h @@ -26,8 +26,8 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LVector3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z); INLINE_LINMATH FLOATNAME(LVector3)(const FLOATNAME(LVecBase2) ©, FLOATTYPE z); - EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const); - EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign)); + EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const); + EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign)); INLINE_LINMATH static const FLOATNAME(LVector3) &zero(); INLINE_LINMATH static const FLOATNAME(LVector3) &unit_x(); @@ -85,7 +85,7 @@ PUBLISHED: INLINE_LINMATH static FLOATNAME(LVector3) rfu(FLOATTYPE right, FLOATTYPE fwd,FLOATTYPE up, CoordinateSystem cs = CS_default); - EXTENSION(INLINE_LINMATH string __repr__() const); + EXTENSION(INLINE_LINMATH std::string __repr__() const); public: static TypeHandle get_class_type() { diff --git a/panda/src/linmath/lvector4_ext_src.I b/panda/src/linmath/lvector4_ext_src.I index a188d6c4a2..6d4f7743b6 100644 --- a/panda/src/linmath/lvector4_ext_src.I +++ b/panda/src/linmath/lvector4_ext_src.I @@ -14,9 +14,9 @@ /** * */ -INLINE_LINMATH string Extension:: +INLINE_LINMATH std::string Extension:: __repr__() const { - ostringstream out; + std::ostringstream out; out << "LVector4" << FLOATTOKEN << "(" << MAYBE_ZERO(_this->_v(0)) << ", " << MAYBE_ZERO(_this->_v(1)) << ", " @@ -29,7 +29,7 @@ __repr__() const { * This is used to implement swizzle masks. */ INLINE_LINMATH PyObject *Extension:: -__getattr__(PyObject *self, const string &attr_name) const { +__getattr__(PyObject *self, const std::string &attr_name) const { #ifndef CPPPARSER extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector2); extern struct Dtool_PyTypedObject FLOATNAME(Dtool_LVector3); @@ -37,7 +37,7 @@ __getattr__(PyObject *self, const string &attr_name) const { #endif // Validate the attribute name. - for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { + for (std::string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { if (*it < 'w' || *it > 'z') { return Dtool_Raise_AttributeError(self, attr_name.c_str()); } @@ -81,7 +81,7 @@ __getattr__(PyObject *self, const string &attr_name) const { * This is used to implement write masks. */ INLINE_LINMATH int Extension:: -__setattr__(PyObject *self, const string &attr_name, PyObject *assign) { +__setattr__(PyObject *self, const std::string &attr_name, PyObject *assign) { // Upcall to LVecBase4. return invoke_extension(_this).__setattr__(self, attr_name, assign); } diff --git a/panda/src/linmath/lvector4_ext_src.h b/panda/src/linmath/lvector4_ext_src.h index 0cc68bca17..4aebf7c1e3 100644 --- a/panda/src/linmath/lvector4_ext_src.h +++ b/panda/src/linmath/lvector4_ext_src.h @@ -18,9 +18,9 @@ template<> class Extension : public ExtensionBase { public: - INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const; - INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign); - INLINE_LINMATH string __repr__() const; + INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const; + INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign); + INLINE_LINMATH std::string __repr__() const; }; #include "lvector4_ext_src.I" diff --git a/panda/src/linmath/lvector4_src.h b/panda/src/linmath/lvector4_src.h index 93f821b08b..cc04c5bbdf 100644 --- a/panda/src/linmath/lvector4_src.h +++ b/panda/src/linmath/lvector4_src.h @@ -22,8 +22,8 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LVector4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w); INLINE_LINMATH FLOATNAME(LVector4)(const FLOATNAME(LVecBase3) ©, FLOATTYPE w); - EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const string &attr_name) const); - EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const string &attr_name, PyObject *assign)); + EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const); + EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign)); INLINE_LINMATH static const FLOATNAME(LVector4) &zero(); INLINE_LINMATH static const FLOATNAME(LVector4) &unit_x(); @@ -53,7 +53,7 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LVector4) project(const FLOATNAME(LVecBase4) &onto) const; #endif - EXTENSION(INLINE_LINMATH string __repr__() const); + EXTENSION(INLINE_LINMATH std::string __repr__() const); public: static TypeHandle get_class_type() { diff --git a/panda/src/mathutil/boundingBox.h b/panda/src/mathutil/boundingBox.h index 2ba4b273e1..8826008ff5 100644 --- a/panda/src/mathutil/boundingBox.h +++ b/panda/src/mathutil/boundingBox.h @@ -42,7 +42,7 @@ public: virtual LPoint3 get_approx_center() const; virtual void xform(const LMatrix4 &mat); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; PUBLISHED: diff --git a/panda/src/mathutil/boundingHexahedron.h b/panda/src/mathutil/boundingHexahedron.h index 40851a219f..ac87135509 100644 --- a/panda/src/mathutil/boundingHexahedron.h +++ b/panda/src/mathutil/boundingHexahedron.h @@ -51,8 +51,8 @@ public: virtual LPoint3 get_approx_center() const; virtual void xform(const LMatrix4 &mat); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; PUBLISHED: INLINE_MATHUTIL int get_num_points() const; diff --git a/panda/src/mathutil/boundingLine.h b/panda/src/mathutil/boundingLine.h index 15e5f43417..e1dff97177 100644 --- a/panda/src/mathutil/boundingLine.h +++ b/panda/src/mathutil/boundingLine.h @@ -40,7 +40,7 @@ public: virtual LPoint3 get_approx_center() const; virtual void xform(const LMatrix4 &mat); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; PUBLISHED: INLINE_MATHUTIL const LPoint3 &get_point_a() const; diff --git a/panda/src/mathutil/boundingPlane.h b/panda/src/mathutil/boundingPlane.h index aff1ebe36b..82e02870a0 100644 --- a/panda/src/mathutil/boundingPlane.h +++ b/panda/src/mathutil/boundingPlane.h @@ -37,7 +37,7 @@ public: virtual LPoint3 get_approx_center() const; virtual void xform(const LMatrix4 &mat); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; PUBLISHED: INLINE_MATHUTIL const LPlane &get_plane() const; diff --git a/panda/src/mathutil/boundingSphere.h b/panda/src/mathutil/boundingSphere.h index 09027e3b8c..8c105daa01 100644 --- a/panda/src/mathutil/boundingSphere.h +++ b/panda/src/mathutil/boundingSphere.h @@ -38,7 +38,7 @@ public: virtual LPoint3 get_approx_center() const; virtual void xform(const LMatrix4 &mat); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; PUBLISHED: INLINE_MATHUTIL LPoint3 get_center() const; diff --git a/panda/src/mathutil/boundingVolume.I b/panda/src/mathutil/boundingVolume.I index 2778e886ba..1b5daf418b 100644 --- a/panda/src/mathutil/boundingVolume.I +++ b/panda/src/mathutil/boundingVolume.I @@ -94,7 +94,7 @@ contains(const BoundingVolume *vol) const { return vol->contains_other(this); } -INLINE_MATHUTIL ostream &operator << (ostream &out, const BoundingVolume &bound) { +INLINE_MATHUTIL std::ostream &operator << (std::ostream &out, const BoundingVolume &bound) { bound.output(out); return out; } diff --git a/panda/src/mathutil/boundingVolume.h b/panda/src/mathutil/boundingVolume.h index df904145ad..67bde45839 100644 --- a/panda/src/mathutil/boundingVolume.h +++ b/panda/src/mathutil/boundingVolume.h @@ -92,8 +92,8 @@ PUBLISHED: INLINE_MATHUTIL int contains(const BoundingVolume *vol) const; - virtual void output(ostream &out) const=0; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const=0; + virtual void write(std::ostream &out, int indent_level = 0) const; // This enum is used to control the automatic generation of bounding // volumes. @@ -115,7 +115,7 @@ public: virtual const BoundingLine *as_bounding_line() const; virtual const BoundingPlane *as_bounding_plane() const; - static BoundsType string_bounds_type(const string &str); + static BoundsType string_bounds_type(const std::string &str); protected: enum Flags { @@ -203,11 +203,11 @@ private: friend class IntersectionBoundingVolume; }; -INLINE_MATHUTIL ostream &operator << (ostream &out, const BoundingVolume &bound); +INLINE_MATHUTIL std::ostream &operator << (std::ostream &out, const BoundingVolume &bound); #include "boundingVolume.I" -EXPCL_PANDA_MATHUTIL ostream &operator << (ostream &out, BoundingVolume::BoundsType type); -EXPCL_PANDA_MATHUTIL istream &operator >> (istream &in, BoundingVolume::BoundsType &type); +EXPCL_PANDA_MATHUTIL std::ostream &operator << (std::ostream &out, BoundingVolume::BoundsType type); +EXPCL_PANDA_MATHUTIL std::istream &operator >> (std::istream &in, BoundingVolume::BoundsType &type); #endif diff --git a/panda/src/mathutil/intersectionBoundingVolume.h b/panda/src/mathutil/intersectionBoundingVolume.h index 74e750acb9..1869c92131 100644 --- a/panda/src/mathutil/intersectionBoundingVolume.h +++ b/panda/src/mathutil/intersectionBoundingVolume.h @@ -40,8 +40,8 @@ public: virtual LPoint3 get_approx_center() const; virtual void xform(const LMatrix4 &mat); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; PUBLISHED: INLINE_MATHUTIL int get_num_components() const; diff --git a/panda/src/mathutil/omniBoundingVolume.h b/panda/src/mathutil/omniBoundingVolume.h index b124de5767..631c514bd5 100644 --- a/panda/src/mathutil/omniBoundingVolume.h +++ b/panda/src/mathutil/omniBoundingVolume.h @@ -31,7 +31,7 @@ public: virtual LPoint3 get_approx_center() const; virtual void xform(const LMatrix4 &mat); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual bool extend_other(BoundingVolume *other) const; diff --git a/panda/src/mathutil/parabola_src.h b/panda/src/mathutil/parabola_src.h index 742f0c5450..8eaec14744 100644 --- a/panda/src/mathutil/parabola_src.h +++ b/panda/src/mathutil/parabola_src.h @@ -35,8 +35,8 @@ PUBLISHED: INLINE_MATHUTIL FLOATNAME(LPoint3) calc_point(FLOATTYPE t) const; - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; void write_datagram_fixed(Datagram &destination) const; void read_datagram_fixed(DatagramIterator &source); @@ -47,8 +47,8 @@ private: FLOATNAME(LVecBase3) _a, _b, _c; }; -inline ostream & -operator << (ostream &out, const FLOATNAME(LParabola) &p) { +inline std::ostream & +operator << (std::ostream &out, const FLOATNAME(LParabola) &p) { p.output(out); return out; } diff --git a/panda/src/mathutil/plane_src.I b/panda/src/mathutil/plane_src.I index 373d256e31..f357b34e60 100644 --- a/panda/src/mathutil/plane_src.I +++ b/panda/src/mathutil/plane_src.I @@ -202,8 +202,8 @@ intersects_line(FLOATTYPE &t, return true; } -INLINE_MATHUTIL ostream & -operator << (ostream &out, const FLOATNAME(LPlane) &p) { +INLINE_MATHUTIL std::ostream & +operator << (std::ostream &out, const FLOATNAME(LPlane) &p) { p.output(out); return out; } diff --git a/panda/src/mathutil/plane_src.h b/panda/src/mathutil/plane_src.h index 2e0d7aa0f6..c3301aa641 100644 --- a/panda/src/mathutil/plane_src.h +++ b/panda/src/mathutil/plane_src.h @@ -56,11 +56,11 @@ PUBLISHED: bool intersects_parabola(FLOATTYPE &t1, FLOATTYPE &t2, const FLOATNAME(LParabola) ¶bola) const; - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; }; -INLINE_MATHUTIL ostream & -operator << (ostream &out, const FLOATNAME(LPlane) &p); +INLINE_MATHUTIL std::ostream & +operator << (std::ostream &out, const FLOATNAME(LPlane) &p); #include "plane_src.I" diff --git a/panda/src/mathutil/unionBoundingVolume.h b/panda/src/mathutil/unionBoundingVolume.h index 4af835eae7..a18f6b3926 100644 --- a/panda/src/mathutil/unionBoundingVolume.h +++ b/panda/src/mathutil/unionBoundingVolume.h @@ -39,8 +39,8 @@ public: virtual LPoint3 get_approx_center() const; virtual void xform(const LMatrix4 &mat); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; PUBLISHED: INLINE_MATHUTIL int get_num_components() const; diff --git a/panda/src/movies/flacAudioCursor.h b/panda/src/movies/flacAudioCursor.h index edae05a674..55d59d5488 100644 --- a/panda/src/movies/flacAudioCursor.h +++ b/panda/src/movies/flacAudioCursor.h @@ -30,7 +30,7 @@ class FlacAudio; */ class EXPCL_PANDA_MOVIES FlacAudioCursor : public MovieAudioCursor { PUBLISHED: - explicit FlacAudioCursor(FlacAudio *src, istream *stream); + explicit FlacAudioCursor(FlacAudio *src, std::istream *stream); virtual ~FlacAudioCursor(); virtual void seek(double offset); diff --git a/panda/src/movies/movieAudio.h b/panda/src/movies/movieAudio.h index 5e04f474eb..cce8eb3465 100644 --- a/panda/src/movies/movieAudio.h +++ b/panda/src/movies/movieAudio.h @@ -25,7 +25,7 @@ class MovieAudioCursor; // Non-release build: #define movies_debug(msg) \ if (movies_cat.is_debug()) { \ - movies_cat->debug() << msg << endl; \ + movies_cat->debug() << msg << std::endl; \ } else {} #else //][ // Release build: @@ -43,7 +43,7 @@ class MovieAudioCursor; */ class EXPCL_PANDA_MOVIES MovieAudio : public TypedWritableReferenceCount, public Namable { PUBLISHED: - MovieAudio(const string &name = "Blank Audio"); + MovieAudio(const std::string &name = "Blank Audio"); virtual ~MovieAudio(); virtual PT(MovieAudioCursor) open(); static PT(MovieAudio) get(const Filename &name); diff --git a/panda/src/movies/movieAudioCursor.h b/panda/src/movies/movieAudioCursor.h index 8d49c26ccf..b2d5d9bebe 100644 --- a/panda/src/movies/movieAudioCursor.h +++ b/panda/src/movies/movieAudioCursor.h @@ -48,7 +48,7 @@ PUBLISHED: virtual int ready() const; virtual void seek(double offset); void read_samples(int n, Datagram *dg); - string read_samples(int n); + std::string read_samples(int n); public: virtual void read_samples(int n, int16_t *data); diff --git a/panda/src/movies/movieTypeRegistry.h b/panda/src/movies/movieTypeRegistry.h index 0ebe467ffb..ee5fc14da2 100644 --- a/panda/src/movies/movieTypeRegistry.h +++ b/panda/src/movies/movieTypeRegistry.h @@ -28,26 +28,26 @@ class EXPCL_PANDA_MOVIES MovieTypeRegistry { public: typedef PT(MovieAudio) (*MakeAudioFunc)(const Filename&); PT(MovieAudio) make_audio(const Filename &name); - void register_audio_type(MakeAudioFunc func, const string &extensions); + void register_audio_type(MakeAudioFunc func, const std::string &extensions); void load_audio_types(); typedef PT(MovieVideo) (*MakeVideoFunc)(const Filename&); PT(MovieVideo) make_video(const Filename &name); - void register_video_type(MakeVideoFunc func, const string &extensions); + void register_video_type(MakeVideoFunc func, const std::string &extensions); void load_video_types(); - void load_movie_library(const string &name); + void load_movie_library(const std::string &name); INLINE static MovieTypeRegistry *get_global_ptr(); private: static MovieTypeRegistry *_global_ptr; - pmap _audio_type_registry; - pmap _deferred_audio_types; + pmap _audio_type_registry; + pmap _deferred_audio_types; - pmap _video_type_registry; - pmap _deferred_video_types; + pmap _video_type_registry; + pmap _deferred_video_types; }; #include "movieTypeRegistry.I" diff --git a/panda/src/movies/movieVideo.h b/panda/src/movies/movieVideo.h index 4573495aa3..1e7da6288e 100644 --- a/panda/src/movies/movieVideo.h +++ b/panda/src/movies/movieVideo.h @@ -37,7 +37,7 @@ class BamReader; */ class EXPCL_PANDA_MOVIES MovieVideo : public TypedWritableReferenceCount, public Namable { PUBLISHED: - MovieVideo(const string &name = "Blank Video"); + MovieVideo(const std::string &name = "Blank Video"); virtual ~MovieVideo(); virtual PT(MovieVideoCursor) open(); static PT(MovieVideo) get(const Filename &name); diff --git a/panda/src/movies/opusAudioCursor.h b/panda/src/movies/opusAudioCursor.h index 51916fbc29..1a3dfa035b 100644 --- a/panda/src/movies/opusAudioCursor.h +++ b/panda/src/movies/opusAudioCursor.h @@ -31,7 +31,7 @@ class OpusAudio; */ class EXPCL_PANDA_MOVIES OpusAudioCursor : public MovieAudioCursor { PUBLISHED: - explicit OpusAudioCursor(OpusAudio *src, istream *stream); + explicit OpusAudioCursor(OpusAudio *src, std::istream *stream); virtual ~OpusAudioCursor(); virtual void seek(double offset); @@ -49,8 +49,8 @@ protected: int _bytes_per_sample; bool _is_float; - streampos _data_start; - streampos _data_pos; + std::streampos _data_start; + std::streampos _data_pos; size_t _data_size; public: diff --git a/panda/src/movies/userDataAudio.h b/panda/src/movies/userDataAudio.h index 0f56ea492f..c37831b17b 100644 --- a/panda/src/movies/userDataAudio.h +++ b/panda/src/movies/userDataAudio.h @@ -37,7 +37,7 @@ class EXPCL_PANDA_MOVIES UserDataAudio : public MovieAudio { void append(int16_t *data, int n); void append(DatagramIterator *src, int len=0x40000000); - void append(const string &str); + void append(const std::string &str); void done(); // A promise not to write any more samples. private: diff --git a/panda/src/movies/vorbisAudioCursor.h b/panda/src/movies/vorbisAudioCursor.h index 4a9bb79847..d194cb0c23 100644 --- a/panda/src/movies/vorbisAudioCursor.h +++ b/panda/src/movies/vorbisAudioCursor.h @@ -30,7 +30,7 @@ class VorbisAudio; */ class EXPCL_PANDA_MOVIES VorbisAudioCursor : public MovieAudioCursor { PUBLISHED: - explicit VorbisAudioCursor(VorbisAudio *src, istream *stream); + explicit VorbisAudioCursor(VorbisAudio *src, std::istream *stream); virtual ~VorbisAudioCursor(); virtual void seek(double offset); @@ -57,8 +57,8 @@ protected: int _bytes_per_sample; bool _is_float; - streampos _data_start; - streampos _data_pos; + std::streampos _data_start; + std::streampos _data_pos; size_t _data_size; public: diff --git a/panda/src/movies/wavAudioCursor.h b/panda/src/movies/wavAudioCursor.h index 2f37f37f4e..21133b1c62 100644 --- a/panda/src/movies/wavAudioCursor.h +++ b/panda/src/movies/wavAudioCursor.h @@ -26,7 +26,7 @@ class WavAudio; */ class EXPCL_PANDA_MOVIES WavAudioCursor : public MovieAudioCursor { PUBLISHED: - explicit WavAudioCursor(WavAudio *src, istream *stream); + explicit WavAudioCursor(WavAudio *src, std::istream *stream); virtual ~WavAudioCursor(); virtual void seek(double offset); @@ -46,7 +46,7 @@ protected: F_extensible = 0xfffe, }; - istream *_stream; + std::istream *_stream; StreamReader _reader; Format _format; @@ -54,8 +54,8 @@ protected: int _block_align; int _bytes_per_sample; - streampos _data_start; - streampos _data_pos; + std::streampos _data_start; + std::streampos _data_pos; size_t _data_size; public: diff --git a/panda/src/nativenet/socket_udp.h b/panda/src/nativenet/socket_udp.h index 58c410dd97..5f7b02c49e 100644 --- a/panda/src/nativenet/socket_udp.h +++ b/panda/src/nativenet/socket_udp.h @@ -31,11 +31,11 @@ PUBLISHED: public: inline bool Send(const char *data, int len); PUBLISHED: - inline bool Send(const string &data); + inline bool Send(const std::string &data); public: inline bool SendTo(const char *data, int len, const Socket_Address &address); PUBLISHED: - inline bool SendTo(const string &data, const Socket_Address &address); + inline bool SendTo(const std::string &data, const Socket_Address &address); inline bool SetToBroadCast(); public: @@ -96,7 +96,7 @@ Send(const char *data, int len) { * Send data to connected address */ inline bool Socket_UDP:: -Send(const string &data) { +Send(const std::string &data) { return Send(data.data(), data.size()); } @@ -112,7 +112,7 @@ SendTo(const char *data, int len, const Socket_Address &address) { * Send data to specified address */ inline bool Socket_UDP:: -SendTo(const string &data, const Socket_Address &address) { +SendTo(const std::string &data, const Socket_Address &address) { return SendTo(data.data(), data.size(), address); } diff --git a/panda/src/nativenet/socket_udp_outgoing.h b/panda/src/nativenet/socket_udp_outgoing.h index 3d1c9bb688..f8acaaccc2 100644 --- a/panda/src/nativenet/socket_udp_outgoing.h +++ b/panda/src/nativenet/socket_udp_outgoing.h @@ -16,13 +16,13 @@ PUBLISHED: public: inline bool Send(const char *data, int len); PUBLISHED: - inline bool Send(const string &data); + inline bool Send(const std::string &data); // use this interface for a none tagreted UDP connection inline bool InitNoAddress(); public: inline bool SendTo(const char *data, int len, const Socket_Address &address); PUBLISHED: - inline bool SendTo(const string &data, const Socket_Address &address); + inline bool SendTo(const std::string &data, const Socket_Address &address); inline bool SetToBroadCast(); public: @@ -98,7 +98,7 @@ Send(const char *data, int len) { * Send data to connected address */ inline bool Socket_UDP_Outgoing:: -Send(const string &data) { +Send(const std::string &data) { return Send(data.data(), data.size()); } @@ -114,7 +114,7 @@ SendTo(const char *data, int len, const Socket_Address &address) { * Send data to specified address */ inline bool Socket_UDP_Outgoing:: -SendTo(const string &data, const Socket_Address &address) { +SendTo(const std::string &data, const Socket_Address &address) { return SendTo(data.data(), data.size(), address); } diff --git a/panda/src/net/config_net.h b/panda/src/net/config_net.h index e039f6bd2a..a80faa1642 100644 --- a/panda/src/net/config_net.h +++ b/panda/src/net/config_net.h @@ -31,7 +31,7 @@ extern int get_net_max_response_queue(); extern bool get_net_error_abort(); extern double get_net_max_poll_cycle(); extern double get_net_max_block(); -extern string make_thread_name(const string &thread_name, int thread_index); +extern std::string make_thread_name(const std::string &thread_name, int thread_index); extern ConfigVariableInt net_max_read_per_epoch; extern ConfigVariableInt net_max_write_per_epoch; diff --git a/panda/src/net/connection.h b/panda/src/net/connection.h index bac0c8def0..6a7c44a744 100644 --- a/panda/src/net/connection.h +++ b/panda/src/net/connection.h @@ -68,7 +68,7 @@ private: bool _collect_tcp; double _collect_tcp_interval; double _queued_data_start; - string _queued_data; + std::string _queued_data; int _queued_count; friend class ConnectionWriter; diff --git a/panda/src/net/connectionListener.h b/panda/src/net/connectionListener.h index 9ec42ab456..7251dafe27 100644 --- a/panda/src/net/connectionListener.h +++ b/panda/src/net/connectionListener.h @@ -31,7 +31,7 @@ class NetAddress; class EXPCL_PANDA_NET ConnectionListener : public ConnectionReader { PUBLISHED: ConnectionListener(ConnectionManager *manager, int num_threads, - const string &thread_name = string()); + const std::string &thread_name = std::string()); protected: virtual void receive_datagram(const NetDatagram &datagram); diff --git a/panda/src/net/connectionManager.h b/panda/src/net/connectionManager.h index 1b00268d6c..a3a6f862c1 100644 --- a/panda/src/net/connectionManager.h +++ b/panda/src/net/connectionManager.h @@ -44,27 +44,27 @@ PUBLISHED: virtual ~ConnectionManager(); PT(Connection) open_UDP_connection(uint16_t port = 0); - PT(Connection) open_UDP_connection(const string &hostname, uint16_t port, bool for_broadcast = false); + PT(Connection) open_UDP_connection(const std::string &hostname, uint16_t port, bool for_broadcast = false); BLOCKING PT(Connection) open_TCP_server_rendezvous(uint16_t port, int backlog); - BLOCKING PT(Connection) open_TCP_server_rendezvous(const string &hostname, + BLOCKING PT(Connection) open_TCP_server_rendezvous(const std::string &hostname, uint16_t port, int backlog); BLOCKING PT(Connection) open_TCP_server_rendezvous(const NetAddress &address, int backlog); BLOCKING PT(Connection) open_TCP_client_connection(const NetAddress &address, int timeout_ms); - BLOCKING PT(Connection) open_TCP_client_connection(const string &hostname, + BLOCKING PT(Connection) open_TCP_client_connection(const std::string &hostname, uint16_t port, int timeout_ms); bool close_connection(const PT(Connection) &connection); BLOCKING bool wait_for_readers(double timeout); - static string get_host_name(); + static std::string get_host_name(); class EXPCL_PANDA_NET Interface { PUBLISHED: - const string &get_name() const { return _name; } - const string &get_mac_address() const { return _mac_address; } + const std::string &get_name() const { return _name; } + const std::string &get_mac_address() const { return _mac_address; } bool has_ip() const { return (_flags & F_has_ip) != 0; } const NetAddress &get_ip() const { return _ip; } bool has_netmask() const { return (_flags & F_has_netmask) != 0; } @@ -74,20 +74,20 @@ PUBLISHED: bool has_p2p() const { return (_flags & F_has_p2p) != 0; } const NetAddress &get_p2p() const { return _p2p; } - void output(ostream &out) const; + void output(std::ostream &out) const; public: Interface() { _flags = 0; } - void set_name(const string &name) { _name = name; } - void set_mac_address(const string &mac_address) { _mac_address = mac_address; } + void set_name(const std::string &name) { _name = name; } + void set_mac_address(const std::string &mac_address) { _mac_address = mac_address; } void set_ip(const NetAddress &ip) { _ip = ip; _flags |= F_has_ip; } void set_netmask(const NetAddress &ip) { _netmask = ip; _flags |= F_has_netmask; } void set_broadcast(const NetAddress &ip) { _broadcast = ip; _flags |= F_has_broadcast; } void set_p2p(const NetAddress &ip) { _p2p = ip; _flags |= F_has_p2p; } private: - string _name; - string _mac_address; + std::string _name; + std::string _mac_address; NetAddress _ip; NetAddress _netmask; @@ -122,7 +122,7 @@ protected: void add_writer(ConnectionWriter *writer); void remove_writer(ConnectionWriter *writer); - string format_mac_address(const unsigned char *data, size_t data_size); + std::string format_mac_address(const unsigned char *data, size_t data_size); typedef phash_set< PT(Connection) > Connections; typedef phash_set Readers; @@ -143,7 +143,7 @@ private: friend class Connection; }; -INLINE ostream &operator << (ostream &out, const ConnectionManager::Interface &iface) { +INLINE std::ostream &operator << (std::ostream &out, const ConnectionManager::Interface &iface) { iface.output(out); return out; } diff --git a/panda/src/net/connectionReader.h b/panda/src/net/connectionReader.h index fb9542df4a..a1a8bdf33a 100644 --- a/panda/src/net/connectionReader.h +++ b/panda/src/net/connectionReader.h @@ -61,7 +61,7 @@ PUBLISHED: // new call to PR_Poll(). explicit ConnectionReader(ConnectionManager *manager, int num_threads, - const string &thread_name = string()); + const std::string &thread_name = std::string()); virtual ~ConnectionReader(); bool add_connection(Connection *connection); @@ -135,7 +135,7 @@ private: class ReaderThread : public Thread { public: - ReaderThread(ConnectionReader *reader, const string &thread_name, + ReaderThread(ConnectionReader *reader, const std::string &thread_name, int thread_index); virtual void thread_main(); diff --git a/panda/src/net/connectionWriter.h b/panda/src/net/connectionWriter.h index 58a0300ef6..578cc260f8 100644 --- a/panda/src/net/connectionWriter.h +++ b/panda/src/net/connectionWriter.h @@ -35,7 +35,7 @@ class NetAddress; class EXPCL_PANDA_NET ConnectionWriter { PUBLISHED: explicit ConnectionWriter(ConnectionManager *manager, int num_threads, - const string &thread_name = string()); + const std::string &thread_name = std::string()); ~ConnectionWriter(); void set_max_queue_size(int max_size); @@ -83,7 +83,7 @@ private: class WriterThread : public Thread { public: - WriterThread(ConnectionWriter *writer, const string &thread_name, + WriterThread(ConnectionWriter *writer, const std::string &thread_name, int thread_index); virtual void thread_main(); diff --git a/panda/src/net/datagramTCPHeader.I b/panda/src/net/datagramTCPHeader.I index 1aa2cf99c8..8f7d263cff 100644 --- a/panda/src/net/datagramTCPHeader.I +++ b/panda/src/net/datagramTCPHeader.I @@ -15,7 +15,7 @@ * Returns a pointer to a block of data of length datagram_tcp_header_size, * which can be written to the network as the header information. */ -INLINE string DatagramTCPHeader:: +INLINE std::string DatagramTCPHeader:: get_header() const { return _header.get_message(); } diff --git a/panda/src/net/datagramTCPHeader.h b/panda/src/net/datagramTCPHeader.h index 51f489e3ed..3e0485ac81 100644 --- a/panda/src/net/datagramTCPHeader.h +++ b/panda/src/net/datagramTCPHeader.h @@ -38,7 +38,7 @@ public: DatagramTCPHeader(const void *data, int header_size); int get_datagram_size(int header_size) const; - INLINE string get_header() const; + INLINE std::string get_header() const; bool verify_datagram(const NetDatagram &datagram, int header_size) const; diff --git a/panda/src/net/datagramUDPHeader.I b/panda/src/net/datagramUDPHeader.I index 85ada55054..ff60db084a 100644 --- a/panda/src/net/datagramUDPHeader.I +++ b/panda/src/net/datagramUDPHeader.I @@ -24,7 +24,7 @@ get_datagram_checksum() const { * Returns a pointer to a block of data of length datagram_udp_header_size, * which can be written to the network as the header information. */ -INLINE string DatagramUDPHeader:: +INLINE std::string DatagramUDPHeader:: get_header() const { return _header.get_message(); } diff --git a/panda/src/net/datagramUDPHeader.h b/panda/src/net/datagramUDPHeader.h index e8ee0b8b1a..12d690fd53 100644 --- a/panda/src/net/datagramUDPHeader.h +++ b/panda/src/net/datagramUDPHeader.h @@ -37,7 +37,7 @@ public: DatagramUDPHeader(const void *data); INLINE int get_datagram_checksum() const; - INLINE string get_header() const; + INLINE std::string get_header() const; bool verify_datagram(const NetDatagram &datagram) const; diff --git a/panda/src/net/datagram_ui.h b/panda/src/net/datagram_ui.h index 6f0e6c4cba..3e705d3698 100644 --- a/panda/src/net/datagram_ui.h +++ b/panda/src/net/datagram_ui.h @@ -26,7 +26,7 @@ #include "netDatagram.h" -istream &operator >> (istream &in, NetDatagram &datagram); -ostream &operator << (ostream &out, const NetDatagram &datagram); +std::istream &operator >> (std::istream &in, NetDatagram &datagram); +std::ostream &operator << (std::ostream &out, const NetDatagram &datagram); #endif diff --git a/panda/src/net/netAddress.h b/panda/src/net/netAddress.h index d6b15b307e..dcb5e41fb3 100644 --- a/panda/src/net/netAddress.h +++ b/panda/src/net/netAddress.h @@ -30,20 +30,20 @@ PUBLISHED: bool set_any(int port); bool set_localhost(int port); bool set_broadcast(int port); - bool set_host(const string &hostname, int port); + bool set_host(const std::string &hostname, int port); void clear(); int get_port() const; void set_port(int port); - string get_ip_string() const; + std::string get_ip_string() const; bool is_any() const; uint32_t get_ip() const; uint8_t get_ip_component(int n) const; const Socket_Address &get_addr() const; - void output(ostream &out) const; + void output(std::ostream &out) const; size_t get_hash() const; bool operator == (const NetAddress &other) const; @@ -53,7 +53,7 @@ private: Socket_Address _addr; }; -INLINE ostream &operator << (ostream &out, const NetAddress &addr) { +INLINE std::ostream &operator << (std::ostream &out, const NetAddress &addr) { addr.output(out); return out; } diff --git a/panda/src/ode/odeBody.h b/panda/src/ode/odeBody.h index dd68389abd..8e27dd8802 100644 --- a/panda/src/ode/odeBody.h +++ b/panda/src/ode/odeBody.h @@ -143,7 +143,7 @@ PUBLISHED: INLINE void set_gravity_mode(int mode); INLINE int get_gravity_mode() const; - virtual void write(ostream &out = cout, unsigned int indent=0) const; + virtual void write(std::ostream &out = std::cout, unsigned int indent=0) const; operator bool () const; INLINE int compare_to(const OdeBody &other) const; diff --git a/panda/src/ode/odeGeom.h b/panda/src/ode/odeGeom.h index 27d62965cb..1d6c69651f 100644 --- a/panda/src/ode/odeGeom.h +++ b/panda/src/ode/odeGeom.h @@ -116,7 +116,7 @@ PUBLISHED: OdeSpace get_space() const; EXTENSION(INLINE PyObject *get_converted_space() const); - virtual void write(ostream &out = cout, unsigned int indent=0) const; + virtual void write(std::ostream &out = std::cout, unsigned int indent=0) const; operator bool () const; INLINE int compare_to(const OdeGeom &other) const; diff --git a/panda/src/ode/odeJoint.h b/panda/src/ode/odeJoint.h index ae9c23a2be..eda2a98b96 100644 --- a/panda/src/ode/odeJoint.h +++ b/panda/src/ode/odeJoint.h @@ -88,7 +88,7 @@ PUBLISHED: void attach_body(const OdeBody &body, int index); void detach(); - virtual void write(ostream &out = cout, unsigned int indent=0) const; + virtual void write(std::ostream &out = std::cout, unsigned int indent=0) const; INLINE int compare_to(const OdeJoint &other) const; INLINE bool operator == (const OdeJoint &other) const; operator bool () const; diff --git a/panda/src/ode/odeMass.h b/panda/src/ode/odeMass.h index bd2ee5a167..4320ac281a 100644 --- a/panda/src/ode/odeMass.h +++ b/panda/src/ode/odeMass.h @@ -66,7 +66,7 @@ PUBLISHED: INLINE LPoint3f get_center() const; INLINE LMatrix3f get_inertial_tensor() const; - virtual void write(ostream &out = cout, unsigned int indent=0) const; + virtual void write(std::ostream &out = std::cout, unsigned int indent=0) const; public: dMass* get_mass_ptr(); diff --git a/panda/src/ode/odeSpace.I b/panda/src/ode/odeSpace.I index d4c60779d9..93fc719e40 100644 --- a/panda/src/ode/odeSpace.I +++ b/panda/src/ode/odeSpace.I @@ -103,11 +103,11 @@ is_enabled() { } INLINE void OdeSpace:: -set_collision_event(const string &event_name) { +set_collision_event(const std::string &event_name) { _collision_event = event_name; } -INLINE string OdeSpace:: +INLINE std::string OdeSpace:: get_collision_event() { return _collision_event; } diff --git a/panda/src/ode/odeSpace.h b/panda/src/ode/odeSpace.h index 928defe8b6..c4888d70f6 100644 --- a/panda/src/ode/odeSpace.h +++ b/panda/src/ode/odeSpace.h @@ -75,7 +75,7 @@ PUBLISHED: INLINE OdeSpace get_space() const; - virtual void write(ostream &out = cout, unsigned int indent=0) const; + virtual void write(std::ostream &out = std::cout, unsigned int indent=0) const; operator bool () const; OdeSimpleSpace convert_to_simple_space() const; @@ -97,8 +97,8 @@ PUBLISHED: int get_collide_id(dGeomID o1); int get_collide_id(OdeGeom& geom); - INLINE void set_collision_event(const string &event_name); - INLINE string get_collision_event(); + INLINE void set_collision_event(const std::string &event_name); + INLINE std::string get_collision_event(); public: static void auto_callback(void*, dGeomID, dGeomID); @@ -108,7 +108,7 @@ public: static OdeSpace* _static_auto_collide_space; static dJointGroupID _static_auto_collide_joint_group; static int contactCount; - string _collision_event; + std::string _collision_event; protected: dSpaceID _id; diff --git a/panda/src/ode/odeTriMeshData.h b/panda/src/ode/odeTriMeshData.h index e8b46fad73..efdda31c78 100644 --- a/panda/src/ode/odeTriMeshData.h +++ b/panda/src/ode/odeTriMeshData.h @@ -38,7 +38,7 @@ public: static PT(OdeTriMeshData) get_data(dGeomID id); static void unlink_data(dGeomID id); static void remove_data(OdeTriMeshData *data); - static void print_data(const string &marker); + static void print_data(const std::string &marker); private: typedef pmap TriMeshDataMap; @@ -59,8 +59,8 @@ PUBLISHED: // data_id); INLINE void get_buffer(unsigned char** buf, int* buf_len) // const; INLINE void set_buffer(unsigned char* buf); INLINE void update(); - virtual void write(ostream &out = cout, unsigned int indent=0) const; - void write_faces(ostream &out) const; + virtual void write(std::ostream &out = std::cout, unsigned int indent=0) const; + void write_faces(std::ostream &out) const; public: INLINE void build_single(const void* vertices, int vertex_stride, int vertex_count, \ diff --git a/panda/src/osxdisplay/osxGraphicsBuffer.h b/panda/src/osxdisplay/osxGraphicsBuffer.h index a2ff19f76a..7ea83d1c4c 100644 --- a/panda/src/osxdisplay/osxGraphicsBuffer.h +++ b/panda/src/osxdisplay/osxGraphicsBuffer.h @@ -27,7 +27,7 @@ class osxGraphicsBuffer : public GraphicsBuffer { public: osxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/osxdisplay/osxGraphicsPipe.h b/panda/src/osxdisplay/osxGraphicsPipe.h index 018d1bb0b7..02cc60576c 100644 --- a/panda/src/osxdisplay/osxGraphicsPipe.h +++ b/panda/src/osxdisplay/osxGraphicsPipe.h @@ -29,7 +29,7 @@ public: osxGraphicsPipe(); virtual ~osxGraphicsPipe(); - virtual string get_interface_name() const; + virtual std::string get_interface_name() const; static PT(GraphicsPipe) pipe_constructor(); virtual PreferredWindowThread get_preferred_window_thread() const; @@ -39,7 +39,7 @@ private: static void release_data(void *info, const void *data, size_t size); protected: - virtual PT(GraphicsOutput) make_output(const string &name, + virtual PT(GraphicsOutput) make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/osxdisplay/osxGraphicsWindow.h b/panda/src/osxdisplay/osxGraphicsWindow.h index 431f366da1..b797cc10f4 100644 --- a/panda/src/osxdisplay/osxGraphicsWindow.h +++ b/panda/src/osxdisplay/osxGraphicsWindow.h @@ -23,7 +23,7 @@ #include #define HACK_SCREEN_HASH_CONTEXT true -OSStatus report_agl_error(const string &comment); +OSStatus report_agl_error(const std::string &comment); /** * An interface to the osx/ system for managing GL windows under X. @@ -31,7 +31,7 @@ OSStatus report_agl_error(const string &comment); class osxGraphicsWindow : public GraphicsWindow { public: osxGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/parametrics/curveFitter.I b/panda/src/parametrics/curveFitter.I index 24c4874338..57e645cd08 100644 --- a/panda/src/parametrics/curveFitter.I +++ b/panda/src/parametrics/curveFitter.I @@ -28,7 +28,7 @@ DataPoint() : * */ INLINE void CurveFitter::DataPoint:: -output(ostream &out) const { +output(std::ostream &out) const { out << "Time " << _t << " xyz " << _xyz << " hpr " << _hpr << " tan " << _tangent; } diff --git a/panda/src/parametrics/curveFitter.h b/panda/src/parametrics/curveFitter.h index a07fd532a4..0e63525ab8 100644 --- a/panda/src/parametrics/curveFitter.h +++ b/panda/src/parametrics/curveFitter.h @@ -56,14 +56,14 @@ PUBLISHED: PT(ParametricCurveCollection) make_hermite() const; PT(ParametricCurveCollection) make_nurbs() const; - void output(ostream &out) const; - void write(ostream &out) const; + void output(std::ostream &out) const; + void write(std::ostream &out) const; public: class DataPoint { public: INLINE DataPoint(); - INLINE void output(ostream &out) const; + INLINE void output(std::ostream &out) const; INLINE bool operator < (const DataPoint &other) const; PN_stdfloat _t; @@ -91,12 +91,12 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const CurveFitter::DataPoint &dp) { +INLINE std::ostream &operator << (std::ostream &out, const CurveFitter::DataPoint &dp) { dp.output(out); return out; } -INLINE ostream &operator << (ostream &out, const CurveFitter &cf) { +INLINE std::ostream &operator << (std::ostream &out, const CurveFitter &cf) { cf.output(out); return out; } diff --git a/panda/src/parametrics/hermiteCurve.h b/panda/src/parametrics/hermiteCurve.h index 5a3d350b82..eb991090cc 100644 --- a/panda/src/parametrics/hermiteCurve.h +++ b/panda/src/parametrics/hermiteCurve.h @@ -57,9 +57,9 @@ public: void set_in(const LVecBase3 &in); void set_out(const LVecBase3 &out); void set_type(int type); - void set_name(const string &name); + void set_name(const std::string &name); - void format_egg(ostream &out, int indent, int num_dimensions, + void format_egg(std::ostream &out, int indent, int num_dimensions, bool show_in, bool show_out, PN_stdfloat scale_in, PN_stdfloat scale_out) const; @@ -68,7 +68,7 @@ public: LVecBase3 _p, _in, _out; int _type; - string _name; + std::string _name; }; /** @@ -122,10 +122,10 @@ PUBLISHED: const LVecBase3 &get_cv_out(int n) const; void get_cv_out(int n, LVecBase3 &v) const; PN_stdfloat get_cv_tstart(int n) const; - string get_cv_name(int n) const; + std::string get_cv_name(int n) const; - virtual void output(ostream &out) const; - void write_cv(ostream &out, int n) const; + virtual void output(std::ostream &out) const; + void write_cv(std::ostream &out, int n) const; public: @@ -140,8 +140,8 @@ public: int rtype3, PN_stdfloat t3, const LVecBase4 &v3); protected: - virtual bool format_egg(ostream &out, const string &name, - const string &curve_type, int indent_level) const; + virtual bool format_egg(std::ostream &out, const std::string &name, + const std::string &curve_type, int indent_level) const; void invalidate_cv(int n, bool redo_all); int find_cv(PN_stdfloat t); diff --git a/panda/src/parametrics/nurbsBasisVector.I b/panda/src/parametrics/nurbsBasisVector.I index d7b207b38a..3628d7564b 100644 --- a/panda/src/parametrics/nurbsBasisVector.I +++ b/panda/src/parametrics/nurbsBasisVector.I @@ -110,5 +110,5 @@ scale_t(int segment, PN_stdfloat t) const { PN_stdfloat from = _segments[segment]._from; PN_stdfloat to = _segments[segment]._to; t = (t - from) / (to - from); - return min(max(t, (PN_stdfloat)0.0), (PN_stdfloat)1.0); + return std::min(std::max(t, (PN_stdfloat)0.0), (PN_stdfloat)1.0); } diff --git a/panda/src/parametrics/nurbsCurve.h b/panda/src/parametrics/nurbsCurve.h index 689717e47a..990d5dee59 100644 --- a/panda/src/parametrics/nurbsCurve.h +++ b/panda/src/parametrics/nurbsCurve.h @@ -85,12 +85,12 @@ public: virtual NurbsCurveInterface *get_nurbs_interface(); virtual bool convert_to_nurbs(ParametricCurve *nc) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; protected: virtual int append_cv_impl(const LVecBase4 &v); - virtual bool format_egg(ostream &out, const string &name, - const string &curve_type, int indent_level) const; + virtual bool format_egg(std::ostream &out, const std::string &name, + const std::string &curve_type, int indent_level) const; int find_cv(PN_stdfloat t); diff --git a/panda/src/parametrics/nurbsCurveEvaluator.I b/panda/src/parametrics/nurbsCurveEvaluator.I index a85ecaad69..9f4f793702 100644 --- a/panda/src/parametrics/nurbsCurveEvaluator.I +++ b/panda/src/parametrics/nurbsCurveEvaluator.I @@ -117,7 +117,7 @@ set_vertex_space(int i, const NodePath &space) { * node relative to the rel_to NodePath when the curve is evaluated. */ INLINE void NurbsCurveEvaluator:: -set_vertex_space(int i, const string &space) { +set_vertex_space(int i, const std::string &space) { nassertv(i >= 0 && i < (int)_vertices.size()); _vertices[i].set_space(space); } @@ -175,8 +175,8 @@ get_num_segments() const { return _basis.get_num_segments(); } -INLINE ostream & -operator << (ostream &out, const NurbsCurveEvaluator &n) { +INLINE std::ostream & +operator << (std::ostream &out, const NurbsCurveEvaluator &n) { n.output(out); return out; } diff --git a/panda/src/parametrics/nurbsCurveEvaluator.h b/panda/src/parametrics/nurbsCurveEvaluator.h index 86e3a79996..1a4192242d 100644 --- a/panda/src/parametrics/nurbsCurveEvaluator.h +++ b/panda/src/parametrics/nurbsCurveEvaluator.h @@ -54,7 +54,7 @@ PUBLISHED: MAKE_SEQ(get_vertices, get_num_vertices, get_vertex); INLINE void set_vertex_space(int i, const NodePath &space); - INLINE void set_vertex_space(int i, const string &space); + INLINE void set_vertex_space(int i, const std::string &space); NodePath get_vertex_space(int i, const NodePath &rel_to) const; INLINE void set_extended_vertex(int i, int d, PN_stdfloat value); @@ -74,7 +74,7 @@ PUBLISHED: PT(NurbsCurveResult) evaluate(const NodePath &rel_to, const LMatrix4 &mat) const; - void output(ostream &out) const; + void output(std::ostream &out) const; public: typedef epvector Vert4Array; @@ -99,7 +99,7 @@ private: NurbsBasisVector _basis; }; -INLINE ostream &operator << (ostream &out, const NurbsCurveEvaluator &n); +INLINE std::ostream &operator << (std::ostream &out, const NurbsCurveEvaluator &n); #include "nurbsCurveEvaluator.I" diff --git a/panda/src/parametrics/nurbsCurveInterface.h b/panda/src/parametrics/nurbsCurveInterface.h index ef09c78275..e37a24d07e 100644 --- a/panda/src/parametrics/nurbsCurveInterface.h +++ b/panda/src/parametrics/nurbsCurveInterface.h @@ -61,14 +61,14 @@ PUBLISHED: MAKE_SEQ(get_cvs, get_num_cvs, get_cv); MAKE_SEQ(get_knots, get_num_knots, get_knot); - void write_cv(ostream &out, int n) const; + void write_cv(std::ostream &out, int n) const; protected: virtual int append_cv_impl(const LVecBase4 &v)=0; - void write(ostream &out, int indent_level) const; - bool format_egg(ostream &out, const string &name, - const string &curve_type, int indent_level) const; + void write(std::ostream &out, int indent_level) const; + bool format_egg(std::ostream &out, const std::string &name, + const std::string &curve_type, int indent_level) const; bool convert_to_nurbs(ParametricCurve *nc) const; diff --git a/panda/src/parametrics/nurbsSurfaceEvaluator.I b/panda/src/parametrics/nurbsSurfaceEvaluator.I index c00408dd5f..26c0f9c0e0 100644 --- a/panda/src/parametrics/nurbsSurfaceEvaluator.I +++ b/panda/src/parametrics/nurbsSurfaceEvaluator.I @@ -155,7 +155,7 @@ set_vertex_space(int ui, int vi, const NodePath &space) { * node relative to the rel_to NodePath when the surface is evaluated. */ INLINE void NurbsSurfaceEvaluator:: -set_vertex_space(int ui, int vi, const string &space) { +set_vertex_space(int ui, int vi, const std::string &space) { nassertv(ui >= 0 && ui < _num_u_vertices && vi >= 0 && vi < _num_v_vertices); vert(ui, vi).set_space(space); @@ -255,8 +255,8 @@ vert(int ui, int vi) const { return _vertices[ui * _num_v_vertices + vi]; } -INLINE ostream & -operator << (ostream &out, const NurbsSurfaceEvaluator &n) { +INLINE std::ostream & +operator << (std::ostream &out, const NurbsSurfaceEvaluator &n) { n.output(out); return out; } diff --git a/panda/src/parametrics/nurbsSurfaceEvaluator.h b/panda/src/parametrics/nurbsSurfaceEvaluator.h index a2f468d716..ced1013016 100644 --- a/panda/src/parametrics/nurbsSurfaceEvaluator.h +++ b/panda/src/parametrics/nurbsSurfaceEvaluator.h @@ -52,7 +52,7 @@ PUBLISHED: INLINE LVecBase4 get_vertex(int ui, int vi, const NodePath &rel_to) const; INLINE void set_vertex_space(int ui, int vi, const NodePath &space); - INLINE void set_vertex_space(int ui, int vi, const string &space); + INLINE void set_vertex_space(int ui, int vi, const std::string &space); NodePath get_vertex_space(int ui, int vi, const NodePath &rel_to) const; INLINE void set_extended_vertex(int ui, int vi, int d, PN_stdfloat value); @@ -77,7 +77,7 @@ PUBLISHED: PT(NurbsSurfaceResult) evaluate(const NodePath &rel_to = NodePath()) const; - void output(ostream &out) const; + void output(std::ostream &out) const; MAKE_PROPERTY(u_order, get_u_order, set_u_order); MAKE_PROPERTY(v_order, get_v_order, set_v_order); @@ -119,7 +119,7 @@ private: NurbsBasisVector _v_basis; }; -INLINE ostream &operator << (ostream &out, const NurbsSurfaceEvaluator &n); +INLINE std::ostream &operator << (std::ostream &out, const NurbsSurfaceEvaluator &n); #include "nurbsSurfaceEvaluator.I" diff --git a/panda/src/parametrics/nurbsVertex.I b/panda/src/parametrics/nurbsVertex.I index cd6c344ac9..75a23a59e1 100644 --- a/panda/src/parametrics/nurbsVertex.I +++ b/panda/src/parametrics/nurbsVertex.I @@ -69,14 +69,14 @@ get_vertex() const { INLINE void NurbsVertex:: set_space(const NodePath &space) { _space = space; - _space_path = string(); + _space_path = std::string(); } /** * Sets the space of this vertex as a relative path from the rel_to node. */ INLINE void NurbsVertex:: -set_space(const string &space) { +set_space(const std::string &space) { _space = NodePath(); _space_path = space; } diff --git a/panda/src/parametrics/nurbsVertex.h b/panda/src/parametrics/nurbsVertex.h index 7369f3a1e6..751b36f335 100644 --- a/panda/src/parametrics/nurbsVertex.h +++ b/panda/src/parametrics/nurbsVertex.h @@ -40,7 +40,7 @@ public: INLINE const LVecBase4 &get_vertex() const; INLINE void set_space(const NodePath &space); - INLINE void set_space(const string &space); + INLINE void set_space(const std::string &space); INLINE NodePath get_space(const NodePath &rel_to) const; void set_extended_vertex(int d, PN_stdfloat value); @@ -49,7 +49,7 @@ public: private: LVecBase4 _vertex; NodePath _space; - string _space_path; + std::string _space_path; typedef pmap Extended; Extended _extended; }; diff --git a/panda/src/parametrics/parametricCurve.h b/panda/src/parametrics/parametricCurve.h index aa4dfc8f2d..0cb5d7fb9d 100644 --- a/panda/src/parametrics/parametricCurve.h +++ b/panda/src/parametrics/parametricCurve.h @@ -93,7 +93,7 @@ PUBLISHED: virtual bool stitch(const ParametricCurve *a, const ParametricCurve *b); bool write_egg(Filename filename, CoordinateSystem cs = CS_default); - bool write_egg(ostream &out, const Filename &filename, CoordinateSystem cs); + bool write_egg(std::ostream &out, const Filename &filename, CoordinateSystem cs); public: struct BezierSeg { @@ -117,8 +117,8 @@ protected: void invalidate(PN_stdfloat t1, PN_stdfloat t2); void invalidate_all(); - virtual bool format_egg(ostream &out, const string &name, - const string &curve_type, int indent_level) const; + virtual bool format_egg(std::ostream &out, const std::string &name, + const std::string &curve_type, int indent_level) const; private: PN_stdfloat r_calc_length(PN_stdfloat t1, PN_stdfloat t2, diff --git a/panda/src/parametrics/parametricCurveCollection.I b/panda/src/parametrics/parametricCurveCollection.I index ba4cf949a0..711b43b67b 100644 --- a/panda/src/parametrics/parametricCurveCollection.I +++ b/panda/src/parametrics/parametricCurveCollection.I @@ -42,7 +42,7 @@ get_curve(int index) const { */ INLINE void ParametricCurveCollection:: add_curve(ParametricCurve *curve, int index) { - insert_curve(max(index, 0), curve); + insert_curve(std::max(index, 0), curve); } /** diff --git a/panda/src/parametrics/parametricCurveCollection.h b/panda/src/parametrics/parametricCurveCollection.h index 44e588dd89..18a79c5dc8 100644 --- a/panda/src/parametrics/parametricCurveCollection.h +++ b/panda/src/parametrics/parametricCurveCollection.h @@ -91,11 +91,11 @@ PUBLISHED: bool stitch(const ParametricCurveCollection *a, const ParametricCurveCollection *b); - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; bool write_egg(Filename filename, CoordinateSystem cs = CS_default); - bool write_egg(ostream &out, const Filename &filename, CoordinateSystem cs); + bool write_egg(std::ostream &out, const Filename &filename, CoordinateSystem cs); public: int r_add_curves(PandaNode *node); @@ -115,8 +115,8 @@ private: DrawerList _drawers; }; -INLINE ostream & -operator << (ostream &out, const ParametricCurveCollection &col) { +INLINE std::ostream & +operator << (std::ostream &out, const ParametricCurveCollection &col) { col.output(out); return out; } diff --git a/panda/src/parametrics/ropeNode.h b/panda/src/parametrics/ropeNode.h index 063070c802..e4647e304d 100644 --- a/panda/src/parametrics/ropeNode.h +++ b/panda/src/parametrics/ropeNode.h @@ -33,13 +33,13 @@ class GeomVertexData; */ class EXPCL_PANDA_PARAMETRICS RopeNode : public PandaNode { PUBLISHED: - explicit RopeNode(const string &name); + explicit RopeNode(const std::string &name); protected: RopeNode(const RopeNode ©); public: - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; virtual PandaNode *make_copy() const; diff --git a/panda/src/parametrics/sheetNode.h b/panda/src/parametrics/sheetNode.h index 29374955a7..97a8d80a71 100644 --- a/panda/src/parametrics/sheetNode.h +++ b/panda/src/parametrics/sheetNode.h @@ -31,13 +31,13 @@ */ class EXPCL_PANDA_PARAMETRICS SheetNode : public PandaNode { PUBLISHED: - explicit SheetNode(const string &name); + explicit SheetNode(const std::string &name); protected: SheetNode(const SheetNode ©); public: - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; virtual PandaNode *make_copy() const; diff --git a/panda/src/particlesystem/arcEmitter.h b/panda/src/particlesystem/arcEmitter.h index 1d5a69b644..ce95891b3e 100644 --- a/panda/src/particlesystem/arcEmitter.h +++ b/panda/src/particlesystem/arcEmitter.h @@ -34,8 +34,8 @@ PUBLISHED: INLINE PN_stdfloat get_start_angle(); INLINE PN_stdfloat get_end_angle(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: // our emitter limits diff --git a/panda/src/particlesystem/baseParticle.h b/panda/src/particlesystem/baseParticle.h index e152536269..edc14ca0f1 100644 --- a/panda/src/particlesystem/baseParticle.h +++ b/panda/src/particlesystem/baseParticle.h @@ -48,8 +48,8 @@ public: // from PhysicsObject virtual PhysicsObject *make_copy() const = 0; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; protected: BaseParticle(PN_stdfloat lifespan = 1.0f, bool alive = false); diff --git a/panda/src/particlesystem/baseParticleEmitter.h b/panda/src/particlesystem/baseParticleEmitter.h index af16f43274..aad4d1ad17 100644 --- a/panda/src/particlesystem/baseParticleEmitter.h +++ b/panda/src/particlesystem/baseParticleEmitter.h @@ -49,8 +49,8 @@ PUBLISHED: INLINE LVector3 get_explicit_launch_vector() const; INLINE LPoint3 get_radiate_origin() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; protected: BaseParticleEmitter(); diff --git a/panda/src/particlesystem/baseParticleFactory.h b/panda/src/particlesystem/baseParticleFactory.h index bdb7fd6a8c..47073862f2 100644 --- a/panda/src/particlesystem/baseParticleFactory.h +++ b/panda/src/particlesystem/baseParticleFactory.h @@ -47,8 +47,8 @@ PUBLISHED: void populate_particle(BaseParticle* bp); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; protected: BaseParticleFactory(); diff --git a/panda/src/particlesystem/baseParticleRenderer.I b/panda/src/particlesystem/baseParticleRenderer.I index 38d8cf8bbb..7da2037edd 100644 --- a/panda/src/particlesystem/baseParticleRenderer.I +++ b/panda/src/particlesystem/baseParticleRenderer.I @@ -97,7 +97,7 @@ get_cur_alpha(BaseParticle* bp) { return bp->get_parameterized_age(); case PR_ALPHA_IN_OUT: - return 2.0 * min(bp->get_parameterized_age(), + return 2.0 * std::min(bp->get_parameterized_age(), 1.0f - bp->get_parameterized_age()); case PR_ALPHA_USER: diff --git a/panda/src/particlesystem/baseParticleRenderer.h b/panda/src/particlesystem/baseParticleRenderer.h index 81926f3a74..bab215567a 100644 --- a/panda/src/particlesystem/baseParticleRenderer.h +++ b/panda/src/particlesystem/baseParticleRenderer.h @@ -62,8 +62,8 @@ PUBLISHED: void set_ignore_scale(bool ignore_scale); INLINE bool get_ignore_scale() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; public: virtual BaseParticleRenderer *make_copy() = 0; diff --git a/panda/src/particlesystem/boxEmitter.h b/panda/src/particlesystem/boxEmitter.h index e9ffbe070c..830e7827af 100644 --- a/panda/src/particlesystem/boxEmitter.h +++ b/panda/src/particlesystem/boxEmitter.h @@ -33,8 +33,8 @@ PUBLISHED: INLINE LPoint3 get_min_bound() const; INLINE LPoint3 get_max_bound() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: LPoint3 _vmin; diff --git a/panda/src/particlesystem/colorInterpolationManager.I b/panda/src/particlesystem/colorInterpolationManager.I index e9b087605f..399476ab2d 100644 --- a/panda/src/particlesystem/colorInterpolationManager.I +++ b/panda/src/particlesystem/colorInterpolationManager.I @@ -239,14 +239,14 @@ get_segment(const int seg_id) { * time. */ -INLINE string ColorInterpolationManager:: +INLINE std::string ColorInterpolationManager:: get_segment_id_list() { pvector::iterator iter; - ostringstream output; + std::ostringstream output; for(iter = _i_segs.begin();iter != _i_segs.end();++iter) output << (*iter)->get_id() << " "; - string str = output.str(); + std::string str = output.str(); return str.substr(0, str.length()-1); } diff --git a/panda/src/particlesystem/colorInterpolationManager.h b/panda/src/particlesystem/colorInterpolationManager.h index 6c01d95b24..917694bee7 100644 --- a/panda/src/particlesystem/colorInterpolationManager.h +++ b/panda/src/particlesystem/colorInterpolationManager.h @@ -280,7 +280,7 @@ ColorInterpolationManager(); INLINE void set_default_color(const LColor &c); INLINE ColorInterpolationSegment* get_segment(const int seg_id); - INLINE string get_segment_id_list(); + INLINE std::string get_segment_id_list(); void clear_segment(const int seg_id); void clear_to_initial(); diff --git a/panda/src/particlesystem/discEmitter.h b/panda/src/particlesystem/discEmitter.h index 2d5c8c1367..0ce8bf9d70 100644 --- a/panda/src/particlesystem/discEmitter.h +++ b/panda/src/particlesystem/discEmitter.h @@ -41,8 +41,8 @@ PUBLISHED: INLINE PN_stdfloat get_inner_magnitude() const; INLINE bool get_cubic_lerping() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: PN_stdfloat _radius; diff --git a/panda/src/particlesystem/geomParticleRenderer.h b/panda/src/particlesystem/geomParticleRenderer.h index 1e4fccf320..f80322a5bd 100644 --- a/panda/src/particlesystem/geomParticleRenderer.h +++ b/panda/src/particlesystem/geomParticleRenderer.h @@ -57,9 +57,9 @@ PUBLISHED: public: virtual BaseParticleRenderer *make_copy(); - virtual void output(ostream &out) const; - virtual void write_linear_forces(ostream &out, int indent=0) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write_linear_forces(std::ostream &out, int indent=0) const; + virtual void write(std::ostream &out, int indent=0) const; private: PT(PandaNode) _geom_node; diff --git a/panda/src/particlesystem/lineEmitter.h b/panda/src/particlesystem/lineEmitter.h index 8d1d5f9afa..0b5a832563 100644 --- a/panda/src/particlesystem/lineEmitter.h +++ b/panda/src/particlesystem/lineEmitter.h @@ -33,8 +33,8 @@ PUBLISHED: INLINE LPoint3 get_endpoint1() const; INLINE LPoint3 get_endpoint2() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: LPoint3 _endpoint1; diff --git a/panda/src/particlesystem/lineParticleRenderer.h b/panda/src/particlesystem/lineParticleRenderer.h index ae37a833d5..86dcc5973c 100644 --- a/panda/src/particlesystem/lineParticleRenderer.h +++ b/panda/src/particlesystem/lineParticleRenderer.h @@ -51,8 +51,8 @@ PUBLISHED: INLINE void set_line_scale_factor(PN_stdfloat sf); INLINE PN_stdfloat get_line_scale_factor() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; private: LColor _head_color; diff --git a/panda/src/particlesystem/orientedParticle.h b/panda/src/particlesystem/orientedParticle.h index 5bdfd88351..0f021fed8d 100644 --- a/panda/src/particlesystem/orientedParticle.h +++ b/panda/src/particlesystem/orientedParticle.h @@ -35,8 +35,8 @@ public: virtual void update(); virtual void die(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; }; #include "orientedParticle.I" diff --git a/panda/src/particlesystem/orientedParticleFactory.h b/panda/src/particlesystem/orientedParticleFactory.h index 5258d7e256..a38d5e2ec0 100644 --- a/panda/src/particlesystem/orientedParticleFactory.h +++ b/panda/src/particlesystem/orientedParticleFactory.h @@ -32,8 +32,8 @@ PUBLISHED: INLINE LOrientation get_initial_orientation() const; INLINE LOrientation get_final_orientation() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: virtual void populate_child_particle(BaseParticle *bp) const; diff --git a/panda/src/particlesystem/particleSystem.h b/panda/src/particlesystem/particleSystem.h index e2689cf361..9c453b1b50 100644 --- a/panda/src/particlesystem/particleSystem.h +++ b/panda/src/particlesystem/particleSystem.h @@ -104,10 +104,10 @@ PUBLISHED: INLINE void soft_start(PN_stdfloat br = 0.0); void update(PN_stdfloat dt); - virtual void output(ostream &out) const; - virtual void write_free_particle_fifo(ostream &out, int indent=0) const; - virtual void write_spawn_templates(ostream &out, int indent=0) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write_free_particle_fifo(std::ostream &out, int indent=0) const; + virtual void write_spawn_templates(std::ostream &out, int indent=0) const; + virtual void write(std::ostream &out, int indent=0) const; private: #ifdef PSSANITYCHECK diff --git a/panda/src/particlesystem/particleSystemManager.h b/panda/src/particlesystem/particleSystemManager.h index 1b03fdbc06..b083076e8a 100644 --- a/panda/src/particlesystem/particleSystemManager.h +++ b/panda/src/particlesystem/particleSystemManager.h @@ -39,9 +39,9 @@ PUBLISHED: void do_particles(PN_stdfloat dt); void do_particles(PN_stdfloat dt, ParticleSystem * ps, bool do_render = true); - virtual void output(ostream &out) const; - virtual void write_ps_list(ostream &out, int indent=0) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write_ps_list(std::ostream &out, int indent=0) const; + virtual void write(std::ostream &out, int indent=0) const; private: plist< PT(ParticleSystem) > _ps_list; diff --git a/panda/src/particlesystem/pointEmitter.h b/panda/src/particlesystem/pointEmitter.h index 145dff2344..fd59ea1aea 100644 --- a/panda/src/particlesystem/pointEmitter.h +++ b/panda/src/particlesystem/pointEmitter.h @@ -30,8 +30,8 @@ PUBLISHED: INLINE void set_location(const LPoint3& p); INLINE LPoint3 get_location() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: LPoint3 _location; diff --git a/panda/src/particlesystem/pointParticle.h b/panda/src/particlesystem/pointParticle.h index f9fe566a40..44e067edaf 100644 --- a/panda/src/particlesystem/pointParticle.h +++ b/panda/src/particlesystem/pointParticle.h @@ -32,8 +32,8 @@ public: virtual PhysicsObject *make_copy() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; }; #endif // POINTPARTICLE_H diff --git a/panda/src/particlesystem/pointParticleFactory.h b/panda/src/particlesystem/pointParticleFactory.h index 0ce2b6e232..acaccf835e 100644 --- a/panda/src/particlesystem/pointParticleFactory.h +++ b/panda/src/particlesystem/pointParticleFactory.h @@ -26,8 +26,8 @@ PUBLISHED: PointParticleFactory(const PointParticleFactory ©); virtual ~PointParticleFactory(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: virtual BaseParticle *alloc_particle() const; diff --git a/panda/src/particlesystem/pointParticleRenderer.h b/panda/src/particlesystem/pointParticleRenderer.h index 3f7ed52612..114cbb0e93 100644 --- a/panda/src/particlesystem/pointParticleRenderer.h +++ b/panda/src/particlesystem/pointParticleRenderer.h @@ -64,8 +64,8 @@ PUBLISHED: INLINE PointParticleBlendType get_blend_type() const; INLINE ParticleRendererBlendMethod get_blend_method() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; private: LColor _start_color; diff --git a/panda/src/particlesystem/rectangleEmitter.h b/panda/src/particlesystem/rectangleEmitter.h index ecd95728e1..7805d3b619 100644 --- a/panda/src/particlesystem/rectangleEmitter.h +++ b/panda/src/particlesystem/rectangleEmitter.h @@ -33,8 +33,8 @@ PUBLISHED: INLINE LPoint2 get_min_bound() const; INLINE LPoint2 get_max_bound() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: LPoint2 _vmin; diff --git a/panda/src/particlesystem/ringEmitter.h b/panda/src/particlesystem/ringEmitter.h index 0278e8ac97..7bc9516148 100644 --- a/panda/src/particlesystem/ringEmitter.h +++ b/panda/src/particlesystem/ringEmitter.h @@ -37,8 +37,8 @@ PUBLISHED: INLINE PN_stdfloat get_radius_spread() const; INLINE int get_uniform_emission() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; protected: PN_stdfloat _radius; diff --git a/panda/src/particlesystem/sparkleParticleRenderer.h b/panda/src/particlesystem/sparkleParticleRenderer.h index 367dd0029d..040d4a5315 100644 --- a/panda/src/particlesystem/sparkleParticleRenderer.h +++ b/panda/src/particlesystem/sparkleParticleRenderer.h @@ -65,8 +65,8 @@ PUBLISHED: INLINE PN_stdfloat get_death_radius() const; INLINE SparkleParticleLifeScale get_life_scale() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; private: LColor _center_color; diff --git a/panda/src/particlesystem/sphereSurfaceEmitter.h b/panda/src/particlesystem/sphereSurfaceEmitter.h index 50a5dda839..e5f9cebaae 100644 --- a/panda/src/particlesystem/sphereSurfaceEmitter.h +++ b/panda/src/particlesystem/sphereSurfaceEmitter.h @@ -30,8 +30,8 @@ PUBLISHED: INLINE void set_radius(PN_stdfloat r); INLINE PN_stdfloat get_radius() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: PN_stdfloat _radius; diff --git a/panda/src/particlesystem/sphereVolumeEmitter.h b/panda/src/particlesystem/sphereVolumeEmitter.h index 29d49b92a9..14981b1b50 100644 --- a/panda/src/particlesystem/sphereVolumeEmitter.h +++ b/panda/src/particlesystem/sphereVolumeEmitter.h @@ -30,8 +30,8 @@ PUBLISHED: INLINE void set_radius(PN_stdfloat r); INLINE PN_stdfloat get_radius() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: PN_stdfloat _radius; diff --git a/panda/src/particlesystem/spriteParticleRenderer.h b/panda/src/particlesystem/spriteParticleRenderer.h index ecb9f579fd..c26f0ee7c1 100644 --- a/panda/src/particlesystem/spriteParticleRenderer.h +++ b/panda/src/particlesystem/spriteParticleRenderer.h @@ -75,12 +75,12 @@ PUBLISHED: ST_from_node, }; - void set_source_info(const string &tex) { + void set_source_info(const std::string &tex) { _source_type = ST_texture; _source_tex = tex; } - void set_source_info(const string &model, const string &node) { + void set_source_info(const std::string &model, const std::string &node) { _source_type = ST_from_node; _source_model = model; _source_node = node; @@ -90,15 +90,15 @@ PUBLISHED: return _source_type; } - string get_tex_source() const { + std::string get_tex_source() const { return _source_tex; } - string get_model_source() const { + std::string get_model_source() const { return _source_model; } - string get_node_source() const { + std::string get_node_source() const { return _source_node; } @@ -145,7 +145,7 @@ private: pvector< PT(Texture) > textures; pvector< LTexCoord > ll,ur; SourceType _source_type; - string _source_tex,_source_model,_source_node; + std::string _source_tex,_source_model,_source_node; }; /** @@ -162,9 +162,9 @@ public: PUBLISHED: void set_from_node(const NodePath &node_path, bool size_from_texels = false); - void set_from_node(const NodePath &node_path, const string &model, const string &node, bool size_from_texels = false); + void set_from_node(const NodePath &node_path, const std::string &model, const std::string &node, bool size_from_texels = false); void add_from_node(const NodePath &node_path, bool size_from_texels = false, bool resize = false); - void add_from_node(const NodePath &node_path, const string &model, const string &node, bool size_from_texels = false, bool resize = false); + void add_from_node(const NodePath &node_path, const std::string &model, const std::string &node, bool size_from_texels = false, bool resize = false); INLINE void set_texture(Texture *tex, PN_stdfloat texels_per_unit = 1.0f); INLINE void add_texture(Texture *tex, PN_stdfloat texels_per_unit = 1.0f, bool resize = false); @@ -217,8 +217,8 @@ PUBLISHED: INLINE PN_stdfloat get_animate_frames_rate() const; INLINE int get_animate_frames_index() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; private: pvector< pvector< PT(Geom) > > _sprite_primitive; diff --git a/panda/src/particlesystem/tangentRingEmitter.h b/panda/src/particlesystem/tangentRingEmitter.h index 0bea13ee17..7100b7ee80 100644 --- a/panda/src/particlesystem/tangentRingEmitter.h +++ b/panda/src/particlesystem/tangentRingEmitter.h @@ -34,8 +34,8 @@ PUBLISHED: INLINE PN_stdfloat get_radius() const; INLINE PN_stdfloat get_radius_spread() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: PN_stdfloat _radius; diff --git a/panda/src/particlesystem/zSpinParticle.h b/panda/src/particlesystem/zSpinParticle.h index 302aedc5d9..ad867d7269 100644 --- a/panda/src/particlesystem/zSpinParticle.h +++ b/panda/src/particlesystem/zSpinParticle.h @@ -50,8 +50,8 @@ public: INLINE void enable_angular_velocity(bool bEnabled); INLINE bool get_angular_velocity_enabled() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: PN_stdfloat _initial_angle; diff --git a/panda/src/particlesystem/zSpinParticleFactory.h b/panda/src/particlesystem/zSpinParticleFactory.h index ca6aa5b8d8..2ef6819069 100644 --- a/panda/src/particlesystem/zSpinParticleFactory.h +++ b/panda/src/particlesystem/zSpinParticleFactory.h @@ -44,8 +44,8 @@ PUBLISHED: INLINE void enable_angular_velocity(bool bEnabled); INLINE bool get_angular_velocity_enabled() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: PN_stdfloat _initial_angle; diff --git a/panda/src/pgraph/accumulatedAttribs.h b/panda/src/pgraph/accumulatedAttribs.h index d71da61111..3d7680cb9a 100644 --- a/panda/src/pgraph/accumulatedAttribs.h +++ b/panda/src/pgraph/accumulatedAttribs.h @@ -33,7 +33,7 @@ public: AccumulatedAttribs(const AccumulatedAttribs ©); void operator = (const AccumulatedAttribs ©); - void write(ostream &out, int attrib_types, int indent_level) const; + void write(std::ostream &out, int attrib_types, int indent_level) const; void collect(PandaNode *node, int attrib_types); CPT(RenderState) collect(const RenderState *state, int attrib_types); diff --git a/panda/src/pgraph/alphaTestAttrib.h b/panda/src/pgraph/alphaTestAttrib.h index d9aae7ec5b..96225fe902 100644 --- a/panda/src/pgraph/alphaTestAttrib.h +++ b/panda/src/pgraph/alphaTestAttrib.h @@ -41,7 +41,7 @@ PUBLISHED: MAKE_PROPERTY(mode, get_mode); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/antialiasAttrib.h b/panda/src/pgraph/antialiasAttrib.h index af149af5f6..454210516d 100644 --- a/panda/src/pgraph/antialiasAttrib.h +++ b/panda/src/pgraph/antialiasAttrib.h @@ -58,7 +58,7 @@ PUBLISHED: MAKE_PROPERTY(mode_quality, get_mode_quality); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/attribNodeRegistry.I b/panda/src/pgraph/attribNodeRegistry.I index b78c9bd78e..04a540466b 100644 --- a/panda/src/pgraph/attribNodeRegistry.I +++ b/panda/src/pgraph/attribNodeRegistry.I @@ -37,7 +37,7 @@ Entry(const NodePath &node) : * */ INLINE AttribNodeRegistry::Entry:: -Entry(TypeHandle type, const string &name) : +Entry(TypeHandle type, const std::string &name) : _type(type), _name(name) { diff --git a/panda/src/pgraph/attribNodeRegistry.h b/panda/src/pgraph/attribNodeRegistry.h index 46170e1ea9..51efa8ead0 100644 --- a/panda/src/pgraph/attribNodeRegistry.h +++ b/panda/src/pgraph/attribNodeRegistry.h @@ -43,15 +43,15 @@ PUBLISHED: NodePath get_node(int n) const; MAKE_SEQ(get_nodes, get_num_nodes, get_node); TypeHandle get_node_type(int n) const; - string get_node_name(int n) const; + std::string get_node_name(int n) const; int find_node(const NodePath &attrib_node) const; - int find_node(TypeHandle type, const string &name) const; + int find_node(TypeHandle type, const std::string &name) const; void remove_node(int n); void clear(); - void output(ostream &out) const; - void write(ostream &out) const; + void output(std::ostream &out) const; + void write(std::ostream &out) const; INLINE static AttribNodeRegistry *get_global_ptr(); @@ -61,11 +61,11 @@ private: class Entry { public: INLINE Entry(const NodePath &node); - INLINE Entry(TypeHandle type, const string &name); + INLINE Entry(TypeHandle type, const std::string &name); INLINE bool operator < (const Entry &other) const; TypeHandle _type; - string _name; + std::string _name; NodePath _node; }; diff --git a/panda/src/pgraph/audioVolumeAttrib.h b/panda/src/pgraph/audioVolumeAttrib.h index abf1216130..564db9748e 100644 --- a/panda/src/pgraph/audioVolumeAttrib.h +++ b/panda/src/pgraph/audioVolumeAttrib.h @@ -44,7 +44,7 @@ PUBLISHED: MAKE_PROPERTY2(volume, has_volume, get_volume); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/auxBitplaneAttrib.h b/panda/src/pgraph/auxBitplaneAttrib.h index 26ce021110..6283b09587 100644 --- a/panda/src/pgraph/auxBitplaneAttrib.h +++ b/panda/src/pgraph/auxBitplaneAttrib.h @@ -67,7 +67,7 @@ PUBLISHED: MAKE_PROPERTY(outputs, get_outputs); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/auxSceneData.I b/panda/src/pgraph/auxSceneData.I index e80d5f6469..f2e7912cfc 100644 --- a/panda/src/pgraph/auxSceneData.I +++ b/panda/src/pgraph/auxSceneData.I @@ -68,8 +68,8 @@ get_expiration_time() const { return _last_render_time + _duration; } -INLINE ostream & -operator << (ostream &out, const AuxSceneData &data) { +INLINE std::ostream & +operator << (std::ostream &out, const AuxSceneData &data) { data.output(out); return out; } diff --git a/panda/src/pgraph/auxSceneData.h b/panda/src/pgraph/auxSceneData.h index ec117bdc17..90741dde05 100644 --- a/panda/src/pgraph/auxSceneData.h +++ b/panda/src/pgraph/auxSceneData.h @@ -41,8 +41,8 @@ PUBLISHED: INLINE double get_expiration_time() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; protected: double _duration; @@ -66,7 +66,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const AuxSceneData &data); +INLINE std::ostream &operator << (std::ostream &out, const AuxSceneData &data); #include "auxSceneData.I" diff --git a/panda/src/pgraph/bamFile.h b/panda/src/pgraph/bamFile.h index e96581729e..a244ab3fa3 100644 --- a/panda/src/pgraph/bamFile.h +++ b/panda/src/pgraph/bamFile.h @@ -44,7 +44,7 @@ PUBLISHED: ~BamFile(); bool open_read(const Filename &bam_filename, bool report_errors = true); - bool open_read(istream &in, const string &bam_filename = "stream", + bool open_read(std::istream &in, const std::string &bam_filename = "stream", bool report_errors = true); TypedWritable *read_object(); @@ -55,7 +55,7 @@ PUBLISHED: PT(PandaNode) read_node(bool report_errors = true); bool open_write(const Filename &bam_filename, bool report_errors = true); - bool open_write(ostream &out, const string &bam_filename = "stream", + bool open_write(std::ostream &out, const std::string &bam_filename = "stream", bool report_errors = true); bool write_object(const TypedWritable *object); @@ -82,10 +82,10 @@ PUBLISHED: MAKE_PROPERTY(writer, get_writer); private: - bool continue_open_read(const string &bam_filename, bool report_errors); - bool continue_open_write(const string &bam_filename, bool report_errors); + bool continue_open_read(const std::string &bam_filename, bool report_errors); + bool continue_open_write(const std::string &bam_filename, bool report_errors); - string _bam_filename; + std::string _bam_filename; DatagramInputFile _din; DatagramOutputFile _dout; BamReader *_reader; diff --git a/panda/src/pgraph/billboardEffect.h b/panda/src/pgraph/billboardEffect.h index 284182ba91..f83ecc5323 100644 --- a/panda/src/pgraph/billboardEffect.h +++ b/panda/src/pgraph/billboardEffect.h @@ -50,7 +50,7 @@ PUBLISHED: public: virtual bool safe_to_transform() const; virtual CPT(TransformState) prepare_flatten_transform(const TransformState *net_transform) const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; virtual bool has_cull_callback() const; virtual void cull_callback(CullTraverser *trav, CullTraverserData &data, diff --git a/panda/src/pgraph/cacheStats.h b/panda/src/pgraph/cacheStats.h index 12707c4bf0..5658a0472f 100644 --- a/panda/src/pgraph/cacheStats.h +++ b/panda/src/pgraph/cacheStats.h @@ -27,7 +27,7 @@ public: constexpr CacheStats() = default; void init(); void reset(double now); - void write(ostream &out, const char *name) const; + void write(std::ostream &out, const char *name) const; INLINE void maybe_report(const char *name); INLINE void inc_hits(); diff --git a/panda/src/pgraph/camera.I b/panda/src/pgraph/camera.I index 0cfcd6277d..1ab7bc2e41 100644 --- a/panda/src/pgraph/camera.I +++ b/panda/src/pgraph/camera.I @@ -180,14 +180,14 @@ get_initial_state() const { * the value of the tag (as specified to set_tag_state()). */ INLINE void Camera:: -set_tag_state_key(const string &tag_state_key) { +set_tag_state_key(const std::string &tag_state_key) { _tag_state_key = tag_state_key; } /** * Returns the tag key as set by a previous call to set_tag_state_key(). */ -INLINE const string &Camera:: +INLINE const std::string &Camera:: get_tag_state_key() const { return _tag_state_key; } diff --git a/panda/src/pgraph/camera.h b/panda/src/pgraph/camera.h index 84b33bf55b..9182f4415c 100644 --- a/panda/src/pgraph/camera.h +++ b/panda/src/pgraph/camera.h @@ -34,7 +34,7 @@ class DisplayRegion; */ class EXPCL_PANDA_PGRAPH Camera : public LensNode { PUBLISHED: - explicit Camera(const string &name, Lens *lens = new PerspectiveLens()); + explicit Camera(const std::string &name, Lens *lens = new PerspectiveLens()); Camera(const Camera ©); public: @@ -78,26 +78,26 @@ PUBLISHED: INLINE CPT(RenderState) get_initial_state() const; MAKE_PROPERTY(initial_state, get_initial_state, set_initial_state); - INLINE void set_tag_state_key(const string &tag_state_key); - INLINE const string &get_tag_state_key() const; + INLINE void set_tag_state_key(const std::string &tag_state_key); + INLINE const std::string &get_tag_state_key() const; MAKE_PROPERTY(tag_state_key, get_tag_state_key, set_tag_state_key); INLINE void set_lod_scale(PN_stdfloat value); INLINE PN_stdfloat get_lod_scale() const; MAKE_PROPERTY(lod_scale, get_lod_scale, set_lod_scale); - void set_tag_state(const string &tag_state, const RenderState *state); - void clear_tag_state(const string &tag_state); + void set_tag_state(const std::string &tag_state, const RenderState *state); + void clear_tag_state(const std::string &tag_state); void clear_tag_states(); - bool has_tag_state(const string &tag_state) const; - CPT(RenderState) get_tag_state(const string &tag_state) const; + bool has_tag_state(const std::string &tag_state) const; + CPT(RenderState) get_tag_state(const std::string &tag_state) const; MAKE_MAP_PROPERTY(tag_states, has_tag_state, get_tag_state, set_tag_state, clear_tag_state); void set_aux_scene_data(const NodePath &node_path, AuxSceneData *data); bool clear_aux_scene_data(const NodePath &node_path); AuxSceneData *get_aux_scene_data(const NodePath &node_path) const; - void list_aux_scene_data(ostream &out) const; + void list_aux_scene_data(std::ostream &out) const; int cleanup_aux_scene_data(Thread *current_thread = Thread::get_current_thread()); MAKE_MAP_PROPERTY(aux_scene_data, get_aux_scene_data, get_aux_scene_data, set_aux_scene_data, clear_aux_scene_data); @@ -119,9 +119,9 @@ private: DisplayRegions _display_regions; CPT(RenderState) _initial_state; - string _tag_state_key; + std::string _tag_state_key; - typedef pmap TagStates; + typedef pmap TagStates; TagStates _tag_states; typedef pmap AuxData; diff --git a/panda/src/pgraph/clipPlaneAttrib.h b/panda/src/pgraph/clipPlaneAttrib.h index b59bb34f9b..511ea34b01 100644 --- a/panda/src/pgraph/clipPlaneAttrib.h +++ b/panda/src/pgraph/clipPlaneAttrib.h @@ -91,7 +91,7 @@ PUBLISHED: public: CPT(RenderAttrib) compose_off(const RenderAttrib *other) const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/colorAttrib.h b/panda/src/pgraph/colorAttrib.h index df8c1b84ce..a92543c855 100644 --- a/panda/src/pgraph/colorAttrib.h +++ b/panda/src/pgraph/colorAttrib.h @@ -47,7 +47,7 @@ PUBLISHED: MAKE_PROPERTY(color, get_color); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/colorBlendAttrib.h b/panda/src/pgraph/colorBlendAttrib.h index 641633561c..87b680425f 100644 --- a/panda/src/pgraph/colorBlendAttrib.h +++ b/panda/src/pgraph/colorBlendAttrib.h @@ -116,7 +116,7 @@ PUBLISHED: MAKE_PROPERTY(color, get_color); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; @@ -168,8 +168,8 @@ private: static int _attrib_slot; }; -EXPCL_PANDA_PGRAPH ostream &operator << (ostream &out, ColorBlendAttrib::Mode mode); -EXPCL_PANDA_PGRAPH ostream &operator << (ostream &out, ColorBlendAttrib::Operand operand); +EXPCL_PANDA_PGRAPH std::ostream &operator << (std::ostream &out, ColorBlendAttrib::Mode mode); +EXPCL_PANDA_PGRAPH std::ostream &operator << (std::ostream &out, ColorBlendAttrib::Operand operand); #include "colorBlendAttrib.I" diff --git a/panda/src/pgraph/colorScaleAttrib.h b/panda/src/pgraph/colorScaleAttrib.h index e8dded108b..918bbe9874 100644 --- a/panda/src/pgraph/colorScaleAttrib.h +++ b/panda/src/pgraph/colorScaleAttrib.h @@ -48,7 +48,7 @@ PUBLISHED: public: virtual bool lower_attrib_can_override() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/colorWriteAttrib.h b/panda/src/pgraph/colorWriteAttrib.h index a426a01659..02d4fd2ca9 100644 --- a/panda/src/pgraph/colorWriteAttrib.h +++ b/panda/src/pgraph/colorWriteAttrib.h @@ -52,7 +52,7 @@ PUBLISHED: MAKE_PROPERTY(channels, get_channels); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/compassEffect.h b/panda/src/pgraph/compassEffect.h index 6600820bb1..adba81f9e6 100644 --- a/panda/src/pgraph/compassEffect.h +++ b/panda/src/pgraph/compassEffect.h @@ -68,7 +68,7 @@ PUBLISHED: public: virtual bool safe_to_transform() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; virtual bool has_cull_callback() const; virtual void cull_callback(CullTraverser *trav, CullTraverserData &data, diff --git a/panda/src/pgraph/cullBin.I b/panda/src/pgraph/cullBin.I index 12f18c6e37..28f7b6542e 100644 --- a/panda/src/pgraph/cullBin.I +++ b/panda/src/pgraph/cullBin.I @@ -28,7 +28,7 @@ CullBin(const CullBin ©) : * */ INLINE CullBin:: -CullBin(const string &name, CullBin::BinType bin_type, +CullBin(const std::string &name, CullBin::BinType bin_type, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) : _name(name), @@ -42,7 +42,7 @@ CullBin(const string &name, CullBin::BinType bin_type, /** * */ -INLINE const string &CullBin:: +INLINE const std::string &CullBin:: get_name() const { return _name; } diff --git a/panda/src/pgraph/cullBin.h b/panda/src/pgraph/cullBin.h index 3f9615cccb..e3a2ccca55 100644 --- a/panda/src/pgraph/cullBin.h +++ b/panda/src/pgraph/cullBin.h @@ -41,12 +41,12 @@ class EXPCL_PANDA_PGRAPH CullBin : public TypedReferenceCount, public CullBinEnu protected: INLINE CullBin(const CullBin ©); public: - INLINE CullBin(const string &name, BinType bin_type, + INLINE CullBin(const std::string &name, BinType bin_type, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); virtual ~CullBin(); - INLINE const string &get_name() const; + INLINE const std::string &get_name() const; INLINE BinType get_bin_type() const; virtual PT(CullBin) make_next() const; @@ -69,7 +69,7 @@ private: void check_flash_color(); protected: - string _name; + std::string _name; BinType _bin_type; GraphicsStateGuardianBase *_gsg; diff --git a/panda/src/pgraph/cullBinAttrib.I b/panda/src/pgraph/cullBinAttrib.I index 945d3244ca..5c5a3714cd 100644 --- a/panda/src/pgraph/cullBinAttrib.I +++ b/panda/src/pgraph/cullBinAttrib.I @@ -23,7 +23,7 @@ CullBinAttrib() { * Returns the name of the bin this attribute specifies. If this is the empty * string, it refers to the default bin. */ -INLINE const string &CullBinAttrib:: +INLINE const std::string &CullBinAttrib:: get_bin_name() const { return _bin_name; } diff --git a/panda/src/pgraph/cullBinAttrib.h b/panda/src/pgraph/cullBinAttrib.h index b3590ac1c5..1104f21af7 100644 --- a/panda/src/pgraph/cullBinAttrib.h +++ b/panda/src/pgraph/cullBinAttrib.h @@ -29,10 +29,10 @@ private: INLINE CullBinAttrib(); PUBLISHED: - static CPT(RenderAttrib) make(const string &bin_name, int draw_order); + static CPT(RenderAttrib) make(const std::string &bin_name, int draw_order); static CPT(RenderAttrib) make_default(); - INLINE const string &get_bin_name() const; + INLINE const std::string &get_bin_name() const; INLINE int get_draw_order() const; PUBLISHED: @@ -40,14 +40,14 @@ PUBLISHED: MAKE_PROPERTY(draw_order, get_draw_order); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; virtual size_t get_hash_impl() const; private: - string _bin_name; + std::string _bin_name; int _draw_order; PUBLISHED: diff --git a/panda/src/pgraph/cullBinManager.I b/panda/src/pgraph/cullBinManager.I index 603622ba2f..cea6cc12b1 100644 --- a/panda/src/pgraph/cullBinManager.I +++ b/panda/src/pgraph/cullBinManager.I @@ -63,10 +63,10 @@ get_bin(int n) const { * was retrieved by get_bin() or find_bin()). The bin's name may not be * changed during the life of the bin. */ -INLINE string CullBinManager:: +INLINE std::string CullBinManager:: get_bin_name(int bin_index) const { - nassertr(bin_index >= 0 && bin_index < (int)_bin_definitions.size(), string()); - nassertr(_bin_definitions[bin_index]._in_use, string()); + nassertr(bin_index >= 0 && bin_index < (int)_bin_definitions.size(), std::string()); + nassertr(_bin_definitions[bin_index]._in_use, std::string()); return _bin_definitions[bin_index]._name; } @@ -85,7 +85,7 @@ get_bin_type(int bin_index) const { * Returns the type of the bin with the indicated name. */ INLINE CullBinManager::BinType CullBinManager:: -get_bin_type(const string &name) const { +get_bin_type(const std::string &name) const { int bin_index = find_bin(name); nassertr(bin_index != -1, BT_invalid); return get_bin_type(bin_index); @@ -112,7 +112,7 @@ set_bin_type(int bin_index, CullBinManager::BinType type) { * frame, depending on the bin type. */ INLINE void CullBinManager:: -set_bin_type(const string &name, CullBinManager::BinType type) { +set_bin_type(const std::string &name, CullBinManager::BinType type) { int bin_index = find_bin(name); nassertv(bin_index != -1); set_bin_type(bin_index, type); @@ -139,7 +139,7 @@ get_bin_sort(int bin_index) const { * may be changed from time to time to reorder the bins. */ INLINE int CullBinManager:: -get_bin_sort(const string &name) const { +get_bin_sort(const std::string &name) const { int bin_index = find_bin(name); nassertr(bin_index != -1, 0); return get_bin_sort(bin_index); @@ -167,7 +167,7 @@ set_bin_sort(int bin_index, int sort) { * may be changed from time to time to reorder the bins. */ INLINE void CullBinManager:: -set_bin_sort(const string &name, int sort) { +set_bin_sort(const std::string &name, int sort) { int bin_index = find_bin(name); nassertv(bin_index != -1); set_bin_sort(bin_index, sort); @@ -192,7 +192,7 @@ get_bin_active(int bin_index) const { * When a bin is marked inactive, all geometry assigned to it is not rendered. */ INLINE bool CullBinManager:: -get_bin_active(const string &name) const { +get_bin_active(const std::string &name) const { int bin_index = find_bin(name); nassertr(bin_index != -1, false); return get_bin_active(bin_index); @@ -217,7 +217,7 @@ set_bin_active(int bin_index, bool active) { * When a bin is marked inactive, all geometry assigned to it is not rendered. */ INLINE void CullBinManager:: -set_bin_active(const string &name, bool active) { +set_bin_active(const std::string &name, bool active) { int bin_index = find_bin(name); nassertv(bin_index != -1); set_bin_active(bin_index, active); diff --git a/panda/src/pgraph/cullBinManager.h b/panda/src/pgraph/cullBinManager.h index 79ac5d9749..1bc203ab84 100644 --- a/panda/src/pgraph/cullBinManager.h +++ b/panda/src/pgraph/cullBinManager.h @@ -39,30 +39,30 @@ protected: PUBLISHED: typedef CullBin::BinType BinType; - int add_bin(const string &name, BinType type, int sort); + int add_bin(const std::string &name, BinType type, int sort); void remove_bin(int bin_index); INLINE int get_num_bins() const; INLINE int get_bin(int n) const; MAKE_SEQ(get_bins, get_num_bins, get_bin); - int find_bin(const string &name) const; + int find_bin(const std::string &name) const; - INLINE string get_bin_name(int bin_index) const; + INLINE std::string get_bin_name(int bin_index) const; INLINE BinType get_bin_type(int bin_index) const; - INLINE BinType get_bin_type(const string &name) const; + INLINE BinType get_bin_type(const std::string &name) const; INLINE void set_bin_type(int bin_index, BinType type); - INLINE void set_bin_type(const string &name, BinType type); + INLINE void set_bin_type(const std::string &name, BinType type); INLINE int get_bin_sort(int bin_index) const; - INLINE int get_bin_sort(const string &name) const; + INLINE int get_bin_sort(const std::string &name) const; INLINE void set_bin_sort(int bin_index, int sort); - INLINE void set_bin_sort(const string &name, int sort); + INLINE void set_bin_sort(const std::string &name, int sort); INLINE bool get_bin_active(int bin_index) const; - INLINE bool get_bin_active(const string &name) const; + INLINE bool get_bin_active(const std::string &name) const; INLINE void set_bin_active(int bin_index, bool active); - INLINE void set_bin_active(const string &name, bool active); + INLINE void set_bin_active(const std::string &name, bool active); #ifndef NDEBUG INLINE bool get_bin_flash_active(int bin_index) const; @@ -71,7 +71,7 @@ PUBLISHED: INLINE void set_bin_flash_color(int bin_index, const LColor &color); #endif - void write(ostream &out) const; + void write(std::ostream &out) const; INLINE static CullBinManager *get_global_ptr(); @@ -83,7 +83,7 @@ public: // This defines the factory interface for defining constructors to bin types // (the implementations are in the cull directory, not here in pgraph, so we // can't call the constructors directly). - typedef CullBin *BinConstructor(const string &name, + typedef CullBin *BinConstructor(const std::string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); @@ -92,7 +92,7 @@ public: private: void do_sort_bins(); void setup_initial_bins(); - static BinType parse_bin_type(const string &bin_type); + static BinType parse_bin_type(const std::string &bin_type); class EXPCL_PANDA_PGRAPH BinDefinition { public: @@ -101,7 +101,7 @@ private: bool _flash_active; #endif bool _in_use; - string _name; + std::string _name; BinType _type; int _sort; bool _active; @@ -116,7 +116,7 @@ private: CullBinManager *_manager; }; - typedef pmap BinsByName; + typedef pmap BinsByName; BinsByName _bins_by_name; typedef vector_int SortedBins; @@ -131,8 +131,8 @@ private: friend class SortBins; }; -EXPCL_PANDA_PGRAPH ostream & -operator << (ostream &out, CullBinManager::BinType bin_type); +EXPCL_PANDA_PGRAPH std::ostream & +operator << (std::ostream &out, CullBinManager::BinType bin_type); #include "cullBinManager.I" diff --git a/panda/src/pgraph/cullFaceAttrib.h b/panda/src/pgraph/cullFaceAttrib.h index 1ed0450db2..def2216976 100644 --- a/panda/src/pgraph/cullFaceAttrib.h +++ b/panda/src/pgraph/cullFaceAttrib.h @@ -50,7 +50,7 @@ PUBLISHED: MAKE_PROPERTY(effective_mode, get_effective_mode); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/cullPlanes.h b/panda/src/pgraph/cullPlanes.h index 4b29fb7794..9480854853 100644 --- a/panda/src/pgraph/cullPlanes.h +++ b/panda/src/pgraph/cullPlanes.h @@ -64,7 +64,7 @@ public: CPT(CullPlanes) remove_plane(const NodePath &clip_plane) const; CPT(CullPlanes) remove_occluder(const NodePath &occluder) const; - void write(ostream &out) const; + void write(std::ostream &out) const; private: typedef pmap Planes; diff --git a/panda/src/pgraph/cullTraverser.I b/panda/src/pgraph/cullTraverser.I index 137d8105b1..bb7bb35e36 100644 --- a/panda/src/pgraph/cullTraverser.I +++ b/panda/src/pgraph/cullTraverser.I @@ -49,7 +49,7 @@ has_tag_state_key() const { * Returns the tag state key that has been specified for the scene's camera, * if any. */ -INLINE const string &CullTraverser:: +INLINE const std::string &CullTraverser:: get_tag_state_key() const { return _tag_state_key; } diff --git a/panda/src/pgraph/cullTraverser.h b/panda/src/pgraph/cullTraverser.h index c137ecbbbf..b8ecbe084b 100644 --- a/panda/src/pgraph/cullTraverser.h +++ b/panda/src/pgraph/cullTraverser.h @@ -55,7 +55,7 @@ PUBLISHED: bool dr_incomplete_render); INLINE SceneSetup *get_scene() const; INLINE bool has_tag_state_key() const; - INLINE const string &get_tag_state_key() const; + INLINE const std::string &get_tag_state_key() const; INLINE void set_camera_mask(const DrawMask &camera_mask); INLINE const DrawMask &get_camera_mask() const; @@ -115,7 +115,7 @@ private: PT(SceneSetup) _scene_setup; DrawMask _camera_mask; bool _has_tag_state_key; - string _tag_state_key; + std::string _tag_state_key; CPT(RenderState) _initial_state; PT(GeometricBoundingVolume) _view_frustum; CullHandler *_cull_handler; diff --git a/panda/src/pgraph/cullableObject.I b/panda/src/pgraph/cullableObject.I index 96564a4088..51c0c8d80a 100644 --- a/panda/src/pgraph/cullableObject.I +++ b/panda/src/pgraph/cullableObject.I @@ -28,9 +28,9 @@ CullableObject() { INLINE CullableObject:: CullableObject(CPT(Geom) geom, CPT(RenderState) state, CPT(TransformState) internal_transform) : - _geom(move(geom)), - _state(move(state)), - _internal_transform(move(internal_transform)) + _geom(std::move(geom)), + _state(std::move(state)), + _internal_transform(std::move(internal_transform)) { #ifdef DO_MEMORY_USAGE MemoryUsage::record_pointer(this, get_class_type()); diff --git a/panda/src/pgraph/cullableObject.h b/panda/src/pgraph/cullableObject.h index b02d7c79be..efde2dba5e 100644 --- a/panda/src/pgraph/cullableObject.h +++ b/panda/src/pgraph/cullableObject.h @@ -65,7 +65,7 @@ public: public: ALLOC_DELETED_CHAIN(CullableObject); - void output(ostream &out) const; + void output(std::ostream &out) const; public: CPT(Geom) _geom; @@ -127,7 +127,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const CullableObject &object) { +INLINE std::ostream &operator << (std::ostream &out, const CullableObject &object) { object.output(out); return out; } diff --git a/panda/src/pgraph/depthOffsetAttrib.h b/panda/src/pgraph/depthOffsetAttrib.h index 9ae6a6ce6f..54fef347d5 100644 --- a/panda/src/pgraph/depthOffsetAttrib.h +++ b/panda/src/pgraph/depthOffsetAttrib.h @@ -66,7 +66,7 @@ PUBLISHED: MAKE_PROPERTY(max_value, get_max_value); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/depthTestAttrib.h b/panda/src/pgraph/depthTestAttrib.h index 2dfa4763e1..f4d6c52352 100644 --- a/panda/src/pgraph/depthTestAttrib.h +++ b/panda/src/pgraph/depthTestAttrib.h @@ -37,7 +37,7 @@ PUBLISHED: MAKE_PROPERTY(mode, get_mode); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/depthWriteAttrib.h b/panda/src/pgraph/depthWriteAttrib.h index d1cdbdc98f..50e31e764d 100644 --- a/panda/src/pgraph/depthWriteAttrib.h +++ b/panda/src/pgraph/depthWriteAttrib.h @@ -43,7 +43,7 @@ PUBLISHED: MAKE_PROPERTY(mode, get_mode); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/findApproxLevelEntry.h b/panda/src/pgraph/findApproxLevelEntry.h index 48c8663869..a5c3758bd9 100644 --- a/panda/src/pgraph/findApproxLevelEntry.h +++ b/panda/src/pgraph/findApproxLevelEntry.h @@ -47,8 +47,8 @@ public: int increment) const; INLINE bool is_solution(int increment) const; - void output(ostream &out) const; - void write_level(ostream &out, int indent_level) const; + void output(std::ostream &out) const; + void write_level(std::ostream &out, int indent_level) const; // _node_path represents the most recent node that we have previously // accepted as being a partial solution. @@ -73,8 +73,8 @@ private: static TypeHandle _type_handle; }; -INLINE ostream & -operator << (ostream &out, const FindApproxLevelEntry &entry) { +INLINE std::ostream & +operator << (std::ostream &out, const FindApproxLevelEntry &entry) { entry.output(out); return out; } diff --git a/panda/src/pgraph/findApproxPath.I b/panda/src/pgraph/findApproxPath.I index 616766a3ea..d8b9ea20c4 100644 --- a/panda/src/pgraph/findApproxPath.I +++ b/panda/src/pgraph/findApproxPath.I @@ -93,7 +93,7 @@ case_insensitive() const { * Formats the nth component of the path to the indicated output stream. */ INLINE void FindApproxPath:: -output_component(ostream &out, int index) const { +output_component(std::ostream &out, int index) const { nassertv(index >= 0 && index < (int)_path.size()); out << _path[index]; } diff --git a/panda/src/pgraph/findApproxPath.h b/panda/src/pgraph/findApproxPath.h index 7b0d138d94..fe3ac5d765 100644 --- a/panda/src/pgraph/findApproxPath.h +++ b/panda/src/pgraph/findApproxPath.h @@ -32,16 +32,16 @@ class FindApproxPath { public: INLINE FindApproxPath(); - bool add_string(const string &str_path); - bool add_flags(const string &str_flags); - bool add_component(string str_component); + bool add_string(const std::string &str_path); + bool add_flags(const std::string &str_flags); + bool add_component(std::string str_component); - void add_match_name(const string &name, int flags); - void add_match_name_glob(const string &glob, int flags); + void add_match_name(const std::string &name, int flags); + void add_match_name_glob(const std::string &glob, int flags); void add_match_exact_type(TypeHandle type, int flags); void add_match_inexact_type(TypeHandle type, int flags); - void add_match_tag(const string &key, int flags); - void add_match_tag_value(const string &key, const string &value, int flags); + void add_match_tag(const std::string &key, int flags); + void add_match_tag_value(const std::string &key, const std::string &value, int flags); void add_match_one(int flags); void add_match_many(int flags); @@ -56,8 +56,8 @@ public: INLINE bool return_stashed() const; INLINE bool case_insensitive() const; - void output(ostream &out) const; - INLINE void output_component(ostream &out, int index) const; + void output(std::ostream &out) const; + INLINE void output_component(std::ostream &out, int index) const; #if !defined(WIN32_VC) && !defined(WIN64_VC) // Visual C++ won't let us define the ostream operator functions for these @@ -83,10 +83,10 @@ private: class Component { public: bool matches(PandaNode *node) const; - void output(ostream &out) const; + void output(std::ostream &out) const; ComponentType _type; - string _name; + std::string _name; GlobPattern _glob; TypeHandle _type_handle; PandaNode *_pointer; @@ -100,21 +100,21 @@ private: bool _return_stashed; bool _case_insensitive; -friend ostream &operator << (ostream &, FindApproxPath::ComponentType); -friend INLINE ostream &operator << (ostream &, const FindApproxPath::Component &); +friend std::ostream &operator << (std::ostream &, FindApproxPath::ComponentType); +friend INLINE std::ostream &operator << (std::ostream &, const FindApproxPath::Component &); }; -ostream & -operator << (ostream &out, FindApproxPath::ComponentType type); +std::ostream & +operator << (std::ostream &out, FindApproxPath::ComponentType type); -INLINE ostream & -operator << (ostream &out, const FindApproxPath::Component &component) { +INLINE std::ostream & +operator << (std::ostream &out, const FindApproxPath::Component &component) { component.output(out); return out; } -INLINE ostream & -operator << (ostream &out, const FindApproxPath &path) { +INLINE std::ostream & +operator << (std::ostream &out, const FindApproxPath &path) { path.output(out); return out; } diff --git a/panda/src/pgraph/fog.h b/panda/src/pgraph/fog.h index 3eb75603ba..5788df409f 100644 --- a/panda/src/pgraph/fog.h +++ b/panda/src/pgraph/fog.h @@ -40,7 +40,7 @@ class TransformState; */ class EXPCL_PANDA_PGRAPH Fog : public PandaNode { PUBLISHED: - explicit Fog(const string &name); + explicit Fog(const std::string &name); protected: Fog(const Fog ©); @@ -85,7 +85,7 @@ PUBLISHED: INLINE void set_exp_density(PN_stdfloat exp_density); MAKE_PROPERTY(exp_density, get_exp_density, set_exp_density); - void output(ostream &out) const; + void output(std::ostream &out) const; public: void adjust_to_camera(const TransformState *camera_transform); @@ -132,9 +132,9 @@ private: static TypeHandle _type_handle; }; -EXPCL_PANDA_PGRAPH ostream &operator << (ostream &out, Fog::Mode mode); +EXPCL_PANDA_PGRAPH std::ostream &operator << (std::ostream &out, Fog::Mode mode); -INLINE ostream &operator << (ostream &out, const Fog &fog) { +INLINE std::ostream &operator << (std::ostream &out, const Fog &fog) { fog.output(out); return out; } diff --git a/panda/src/pgraph/fogAttrib.h b/panda/src/pgraph/fogAttrib.h index 7f659b6336..8dac86fd6a 100644 --- a/panda/src/pgraph/fogAttrib.h +++ b/panda/src/pgraph/fogAttrib.h @@ -38,7 +38,7 @@ PUBLISHED: MAKE_PROPERTY(fog, get_fog); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/geomDrawCallbackData.h b/panda/src/pgraph/geomDrawCallbackData.h index 7e45f9eef2..87e9fbc401 100644 --- a/panda/src/pgraph/geomDrawCallbackData.h +++ b/panda/src/pgraph/geomDrawCallbackData.h @@ -31,7 +31,7 @@ public: GraphicsStateGuardianBase *gsg, bool force); PUBLISHED: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; INLINE CullableObject *get_object() const; INLINE GraphicsStateGuardianBase *get_gsg() const; diff --git a/panda/src/pgraph/geomNode.I b/panda/src/pgraph/geomNode.I index 91c197d1d3..5b86d95155 100644 --- a/panda/src/pgraph/geomNode.I +++ b/panda/src/pgraph/geomNode.I @@ -142,7 +142,7 @@ get_default_collide_mask() { */ INLINE void GeomNode:: count_name(GeomNode::NameCount &name_count, const InternalName *name) { - pair result = + std::pair result = name_count.insert(NameCount::value_type(name, 1)); if (!result.second) { (*result.first).second++; diff --git a/panda/src/pgraph/geomNode.h b/panda/src/pgraph/geomNode.h index 0b5bccd492..1402d07b5a 100644 --- a/panda/src/pgraph/geomNode.h +++ b/panda/src/pgraph/geomNode.h @@ -33,7 +33,7 @@ class GraphicsStateGuardianBase; */ class EXPCL_PANDA_PGRAPH GeomNode : public PandaNode { PUBLISHED: - explicit GeomNode(const string &name); + explicit GeomNode(const std::string &name); protected: GeomNode(const GeomNode ©); @@ -85,14 +85,14 @@ PUBLISHED: void decompose(); void unify(int max_indices, bool preserve_order); - void write_geoms(ostream &out, int indent_level) const; - void write_verbose(ostream &out, int indent_level) const; + void write_geoms(std::ostream &out, int indent_level) const; + void write_verbose(std::ostream &out, int indent_level) const; INLINE static CollideMask get_default_collide_mask(); MAKE_PROPERTY(default_collide_mask, get_default_collide_mask); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; virtual bool is_geom_node() const; diff --git a/panda/src/pgraph/geomTransformer.h b/panda/src/pgraph/geomTransformer.h index e20732764f..120a4ca5f8 100644 --- a/panda/src/pgraph/geomTransformer.h +++ b/panda/src/pgraph/geomTransformer.h @@ -194,7 +194,7 @@ private: public: INLINE bool operator < (const NewCollectedKey &other) const; - string _name; + std::string _name; CPT(GeomVertexFormat) _format; Geom::UsageHint _usage_hint; Geom::AnimationType _animation_type; @@ -222,7 +222,7 @@ private: int apply_collect_changes(); CPT(GeomVertexFormat) _new_format; - string _vdata_name; + std::string _vdata_name; GeomEnums::UsageHint _usage_hint; SourceDatas _source_datas; SourceGeoms _source_geoms; diff --git a/panda/src/pgraph/internalNameCollection.h b/panda/src/pgraph/internalNameCollection.h index 0c024cfaed..c409e35022 100644 --- a/panda/src/pgraph/internalNameCollection.h +++ b/panda/src/pgraph/internalNameCollection.h @@ -44,15 +44,15 @@ PUBLISHED: INLINE void operator += (const InternalNameCollection &other); INLINE InternalNameCollection operator + (const InternalNameCollection &other) const; - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; private: typedef PTA(CPT(InternalName)) InternalNames; InternalNames _names; }; -INLINE ostream &operator << (ostream &out, const InternalNameCollection &col) { +INLINE std::ostream &operator << (std::ostream &out, const InternalNameCollection &col) { col.output(out); return out; } diff --git a/panda/src/pgraph/lensNode.h b/panda/src/pgraph/lensNode.h index 9e1dd9fb00..acc4c483be 100644 --- a/panda/src/pgraph/lensNode.h +++ b/panda/src/pgraph/lensNode.h @@ -28,13 +28,13 @@ */ class EXPCL_PANDA_PGRAPH LensNode : public PandaNode { PUBLISHED: - explicit LensNode(const string &name, Lens *lens = nullptr); + explicit LensNode(const std::string &name, Lens *lens = nullptr); protected: LensNode(const LensNode ©); public: - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; virtual void xform(const LMatrix4 &mat); virtual PandaNode *make_copy() const; diff --git a/panda/src/pgraph/light.h b/panda/src/pgraph/light.h index ee6e906356..8cea78067d 100644 --- a/panda/src/pgraph/light.h +++ b/panda/src/pgraph/light.h @@ -67,8 +67,8 @@ public: virtual void attrib_ref(); virtual void attrib_unref(); - virtual void output(ostream &out) const=0; - virtual void write(ostream &out, int indent_level) const=0; + virtual void output(std::ostream &out) const=0; + virtual void write(std::ostream &out, int indent_level) const=0; virtual void bind(GraphicsStateGuardianBase *gsg, const NodePath &light, int light_id)=0; @@ -151,7 +151,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const Light &light) { +INLINE std::ostream &operator << (std::ostream &out, const Light &light) { light.output(out); return out; } diff --git a/panda/src/pgraph/lightAttrib.h b/panda/src/pgraph/lightAttrib.h index 8d8b87bfb6..4872ebc623 100644 --- a/panda/src/pgraph/lightAttrib.h +++ b/panda/src/pgraph/lightAttrib.h @@ -95,8 +95,8 @@ PUBLISHED: MAKE_SEQ_PROPERTY(off_lights, get_num_off_lights, get_off_light); public: - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/lightRampAttrib.h b/panda/src/pgraph/lightRampAttrib.h index 65a894e582..d6859676bf 100644 --- a/panda/src/pgraph/lightRampAttrib.h +++ b/panda/src/pgraph/lightRampAttrib.h @@ -56,7 +56,7 @@ PUBLISHED: MAKE_PROPERTY(mode, get_mode); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/loader.I b/panda/src/pgraph/loader.I index eddac45376..8ca4fc8f50 100644 --- a/panda/src/pgraph/loader.I +++ b/panda/src/pgraph/loader.I @@ -109,14 +109,14 @@ get_task_manager() const { * is the initial name of the Loader object. */ INLINE void Loader:: -set_task_chain(const string &task_chain) { +set_task_chain(const std::string &task_chain) { _task_chain = task_chain; } /** * Returns the task chain that is used for asynchronous loads. */ -INLINE const string &Loader:: +INLINE const std::string &Loader:: get_task_chain() const { return _task_chain; } diff --git a/panda/src/pgraph/loader.h b/panda/src/pgraph/loader.h index 46de9ff8eb..9758151ec1 100644 --- a/panda/src/pgraph/loader.h +++ b/panda/src/pgraph/loader.h @@ -70,12 +70,12 @@ PUBLISHED: Files _files; }; - explicit Loader(const string &name = "loader"); + explicit Loader(const std::string &name = "loader"); INLINE void set_task_manager(AsyncTaskManager *task_manager); INLINE AsyncTaskManager *get_task_manager() const; - INLINE void set_task_chain(const string &task_chain); - INLINE const string &get_task_chain() const; + INLINE void set_task_chain(const std::string &task_chain); + INLINE const std::string &get_task_chain() const; BLOCKING INLINE void stop_threads(); INLINE bool remove(AsyncTask *task); @@ -94,9 +94,9 @@ PUBLISHED: PandaNode *node); INLINE void save_async(AsyncTask *request); - BLOCKING PT(PandaNode) load_bam_stream(istream &in); + BLOCKING PT(PandaNode) load_bam_stream(std::istream &in); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; INLINE static Loader *get_global_ptr(); @@ -113,7 +113,7 @@ private: static void make_global_ptr(); PT(AsyncTaskManager) _task_manager; - string _task_chain; + std::string _task_chain; static void load_file_types(); static bool _file_types_loaded; diff --git a/panda/src/pgraph/loaderFileType.h b/panda/src/pgraph/loaderFileType.h index af1c21e2e7..fe2dcbfd2c 100644 --- a/panda/src/pgraph/loaderFileType.h +++ b/panda/src/pgraph/loaderFileType.h @@ -38,9 +38,9 @@ public: virtual ~LoaderFileType(); PUBLISHED: - virtual string get_name() const=0; - virtual string get_extension() const=0; - virtual string get_additional_extensions() const; + virtual std::string get_name() const=0; + virtual std::string get_extension() const=0; + virtual std::string get_additional_extensions() const; virtual bool supports_compressed() const; virtual bool get_allow_disk_cache(const LoaderOptions &options) const; diff --git a/panda/src/pgraph/loaderFileTypeBam.h b/panda/src/pgraph/loaderFileTypeBam.h index 11c5687229..3a42508709 100644 --- a/panda/src/pgraph/loaderFileTypeBam.h +++ b/panda/src/pgraph/loaderFileTypeBam.h @@ -25,8 +25,8 @@ class EXPCL_PANDA_PGRAPH LoaderFileTypeBam : public LoaderFileType { public: LoaderFileTypeBam(); - virtual string get_name() const; - virtual string get_extension() const; + virtual std::string get_name() const; + virtual std::string get_extension() const; virtual bool supports_compressed() const; virtual bool supports_load() const; diff --git a/panda/src/pgraph/loaderFileTypeRegistry.h b/panda/src/pgraph/loaderFileTypeRegistry.h index 6fedc09406..1cc1cd8f6f 100644 --- a/panda/src/pgraph/loaderFileTypeRegistry.h +++ b/panda/src/pgraph/loaderFileTypeRegistry.h @@ -33,30 +33,30 @@ public: ~LoaderFileTypeRegistry(); void register_type(LoaderFileType *type); - void register_deferred_type(const string &extension, const string &library); + void register_deferred_type(const std::string &extension, const std::string &library); PUBLISHED: int get_num_types() const; LoaderFileType *get_type(int n) const; MAKE_SEQ(get_types, get_num_types, get_type); MAKE_SEQ_PROPERTY(types, get_num_types, get_type); - LoaderFileType *get_type_from_extension(const string &extension); + LoaderFileType *get_type_from_extension(const std::string &extension); - void write(ostream &out, int indent_level = 0) const; + void write(std::ostream &out, int indent_level = 0) const; static LoaderFileTypeRegistry *get_global_ptr(); private: - void record_extension(const string &extension, LoaderFileType *type); + void record_extension(const std::string &extension, LoaderFileType *type); private: typedef pvector Types; Types _types; - typedef pmap Extensions; + typedef pmap Extensions; Extensions _extensions; - typedef pmap DeferredTypes; + typedef pmap DeferredTypes; DeferredTypes _deferred_types; static LoaderFileTypeRegistry *_global_ptr; diff --git a/panda/src/pgraph/logicOpAttrib.h b/panda/src/pgraph/logicOpAttrib.h index 99ab79d029..f5bd2ce5d9 100644 --- a/panda/src/pgraph/logicOpAttrib.h +++ b/panda/src/pgraph/logicOpAttrib.h @@ -59,7 +59,7 @@ PUBLISHED: MAKE_PROPERTY(operation, get_operation); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; @@ -105,7 +105,7 @@ private: static int _attrib_slot; }; -EXPCL_PANDA_PGRAPH ostream &operator << (ostream &out, LogicOpAttrib::Operation op); +EXPCL_PANDA_PGRAPH std::ostream &operator << (std::ostream &out, LogicOpAttrib::Operation op); #include "logicOpAttrib.I" diff --git a/panda/src/pgraph/materialAttrib.h b/panda/src/pgraph/materialAttrib.h index 88c4a4363d..0e65498d70 100644 --- a/panda/src/pgraph/materialAttrib.h +++ b/panda/src/pgraph/materialAttrib.h @@ -40,7 +40,7 @@ PUBLISHED: MAKE_PROPERTY(material, get_material); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/materialCollection.h b/panda/src/pgraph/materialCollection.h index 97bfcd71a1..1dc46aeca2 100644 --- a/panda/src/pgraph/materialCollection.h +++ b/panda/src/pgraph/materialCollection.h @@ -36,7 +36,7 @@ PUBLISHED: bool has_material(Material *material) const; void clear(); - Material *find_material(const string &name) const; + Material *find_material(const std::string &name) const; int get_num_materials() const; Material *get_material(int index) const; @@ -45,15 +45,15 @@ PUBLISHED: INLINE void operator += (const MaterialCollection &other); INLINE MaterialCollection operator + (const MaterialCollection &other) const; - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; private: typedef PTA(PT(Material)) Materials; Materials _materials; }; -INLINE ostream &operator << (ostream &out, const MaterialCollection &col) { +INLINE std::ostream &operator << (std::ostream &out, const MaterialCollection &col) { col.output(out); return out; } diff --git a/panda/src/pgraph/modelLoadRequest.h b/panda/src/pgraph/modelLoadRequest.h index e743623fa3..f99dc7c38d 100644 --- a/panda/src/pgraph/modelLoadRequest.h +++ b/panda/src/pgraph/modelLoadRequest.h @@ -34,7 +34,7 @@ public: ALLOC_DELETED_CHAIN(ModelLoadRequest); PUBLISHED: - explicit ModelLoadRequest(const string &name, + explicit ModelLoadRequest(const std::string &name, const Filename &filename, const LoaderOptions &options, Loader *loader); diff --git a/panda/src/pgraph/modelNode.I b/panda/src/pgraph/modelNode.I index da0f61b0d4..929bedd6fc 100644 --- a/panda/src/pgraph/modelNode.I +++ b/panda/src/pgraph/modelNode.I @@ -15,7 +15,7 @@ * */ INLINE ModelNode:: -ModelNode(const string &name) : +ModelNode(const std::string &name) : PandaNode(name) { _preserve_transform = PT_none; diff --git a/panda/src/pgraph/modelNode.h b/panda/src/pgraph/modelNode.h index 177f1cffb6..c57d98476c 100644 --- a/panda/src/pgraph/modelNode.h +++ b/panda/src/pgraph/modelNode.h @@ -30,7 +30,7 @@ */ class EXPCL_PANDA_PGRAPH ModelNode : public PandaNode { PUBLISHED: - explicit INLINE ModelNode(const string &name); + explicit INLINE ModelNode(const std::string &name); protected: INLINE ModelNode(const ModelNode ©); diff --git a/panda/src/pgraph/modelPool.I b/panda/src/pgraph/modelPool.I index f52be7de00..717c3eedba 100644 --- a/panda/src/pgraph/modelPool.I +++ b/panda/src/pgraph/modelPool.I @@ -130,7 +130,7 @@ garbage_collect() { * Lists the contents of the model pool to the indicated output stream. */ INLINE void ModelPool:: -list_contents(ostream &out) { +list_contents(std::ostream &out) { get_ptr()->ns_list_contents(out); } @@ -139,7 +139,7 @@ list_contents(ostream &out) { */ INLINE void ModelPool:: list_contents() { - get_ptr()->ns_list_contents(cout); + get_ptr()->ns_list_contents(std::cout); } /** diff --git a/panda/src/pgraph/modelPool.h b/panda/src/pgraph/modelPool.h index 34eefba0b5..8e0476c682 100644 --- a/panda/src/pgraph/modelPool.h +++ b/panda/src/pgraph/modelPool.h @@ -57,9 +57,9 @@ PUBLISHED: INLINE static int garbage_collect(); - INLINE static void list_contents(ostream &out); + INLINE static void list_contents(std::ostream &out); INLINE static void list_contents(); - static void write(ostream &out); + static void write(std::ostream &out); private: INLINE ModelPool(); @@ -76,7 +76,7 @@ private: void ns_release_all_models(); int ns_garbage_collect(); - void ns_list_contents(ostream &out) const; + void ns_list_contents(std::ostream &out) const; static ModelPool *get_ptr(); diff --git a/panda/src/pgraph/modelRoot.I b/panda/src/pgraph/modelRoot.I index df1bedaf7b..4478702a28 100644 --- a/panda/src/pgraph/modelRoot.I +++ b/panda/src/pgraph/modelRoot.I @@ -15,7 +15,7 @@ * */ INLINE ModelRoot:: -ModelRoot(const string &name) : +ModelRoot(const std::string &name) : ModelNode(name), _fullpath(name), _timestamp(0), diff --git a/panda/src/pgraph/modelRoot.h b/panda/src/pgraph/modelRoot.h index 7895dcab85..c73363c108 100644 --- a/panda/src/pgraph/modelRoot.h +++ b/panda/src/pgraph/modelRoot.h @@ -26,7 +26,7 @@ */ class EXPCL_PANDA_PGRAPH ModelRoot : public ModelNode { PUBLISHED: - INLINE explicit ModelRoot(const string &name); + INLINE explicit ModelRoot(const std::string &name); INLINE explicit ModelRoot(const Filename &fullpath, time_t timestamp); INLINE int get_model_ref_count() const; diff --git a/panda/src/pgraph/modelSaveRequest.h b/panda/src/pgraph/modelSaveRequest.h index 7bbe1e331d..f15225e159 100644 --- a/panda/src/pgraph/modelSaveRequest.h +++ b/panda/src/pgraph/modelSaveRequest.h @@ -33,7 +33,7 @@ public: ALLOC_DELETED_CHAIN(ModelSaveRequest); PUBLISHED: - explicit ModelSaveRequest(const string &name, + explicit ModelSaveRequest(const std::string &name, const Filename &filename, const LoaderOptions &options, PandaNode *node, Loader *loader); diff --git a/panda/src/pgraph/nodePath.I b/panda/src/pgraph/nodePath.I index 641ab1c2b7..5b7e80f7b7 100644 --- a/panda/src/pgraph/nodePath.I +++ b/panda/src/pgraph/nodePath.I @@ -26,7 +26,7 @@ NodePath() : * PandaNode is created with the indicated name. */ INLINE NodePath:: -NodePath(const string &top_node_name, Thread *current_thread) : +NodePath(const std::string &top_node_name, Thread *current_thread) : _error_type(ET_ok) { PandaNode *top_node = new PandaNode(top_node_name); @@ -95,7 +95,7 @@ operator = (const NodePath ©) { */ INLINE NodePath:: NodePath(NodePath &&from) noexcept : - _head(move(from._head)), + _head(std::move(from._head)), _backup_key(from._backup_key), _error_type(from._error_type) { @@ -106,7 +106,7 @@ NodePath(NodePath &&from) noexcept : */ INLINE void NodePath:: operator = (NodePath &&from) noexcept { - _head = move(from._head); + _head = std::move(from._head); _backup_key = from._backup_key; _error_type = from._error_type; } @@ -386,7 +386,7 @@ get_parent(Thread *current_thread) const { * returning a new NodePath that references it. */ INLINE NodePath NodePath:: -attach_new_node(const string &name, int sort, Thread *current_thread) const { +attach_new_node(const std::string &name, int sort, Thread *current_thread) const { nassertr(verify_complete(current_thread), NodePath::fail()); return attach_new_node(new PandaNode(name), sort, current_thread); @@ -404,7 +404,7 @@ ls() const { * Lists the hierarchy at and below the referenced node. */ INLINE void NodePath:: -ls(ostream &out, int indent_level) const { +ls(std::ostream &out, int indent_level) const { if (is_empty()) { out << "(empty)\n"; } else { @@ -1078,7 +1078,7 @@ get_sa() const { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_float &v, int priority) { - set_shader_input(ShaderInput(move(id), v, priority)); + set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -1086,7 +1086,7 @@ set_shader_input(CPT_InternalName id, const PTA_float &v, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_double &v, int priority) { - set_shader_input(ShaderInput(move(id), v, priority)); + set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -1094,7 +1094,7 @@ set_shader_input(CPT_InternalName id, const PTA_double &v, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_int &v, int priority) { - set_shader_input(ShaderInput(move(id), v, priority)); + set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -1102,7 +1102,7 @@ set_shader_input(CPT_InternalName id, const PTA_int &v, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_LVecBase4 &v, int priority) { - set_shader_input(ShaderInput(move(id), v, priority)); + set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -1110,7 +1110,7 @@ set_shader_input(CPT_InternalName id, const PTA_LVecBase4 &v, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_LVecBase3 &v, int priority) { - set_shader_input(ShaderInput(move(id), v, priority)); + set_shader_input(ShaderInput(std::move(id), v, priority)); } @@ -1119,7 +1119,7 @@ set_shader_input(CPT_InternalName id, const PTA_LVecBase3 &v, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_LVecBase2 &v, int priority) { - set_shader_input(ShaderInput(move(id), v, priority)); + set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -1127,7 +1127,7 @@ set_shader_input(CPT_InternalName id, const PTA_LVecBase2 &v, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const LVecBase4 &v, int priority) { - set_shader_input(ShaderInput(move(id), v, priority)); + set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -1135,7 +1135,7 @@ set_shader_input(CPT_InternalName id, const LVecBase4 &v, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const LVecBase3 &v, int priority) { - set_shader_input(ShaderInput(move(id), v, priority)); + set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -1143,7 +1143,7 @@ set_shader_input(CPT_InternalName id, const LVecBase3 &v, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const LVecBase2 &v, int priority) { - set_shader_input(ShaderInput(move(id), v, priority)); + set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -1151,7 +1151,7 @@ set_shader_input(CPT_InternalName id, const LVecBase2 &v, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_LVecBase4i &v, int priority) { - set_shader_input(ShaderInput(move(id), v, priority)); + set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -1159,7 +1159,7 @@ set_shader_input(CPT_InternalName id, const PTA_LVecBase4i &v, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_LVecBase3i &v, int priority) { - set_shader_input(ShaderInput(move(id), v, priority)); + set_shader_input(ShaderInput(std::move(id), v, priority)); } @@ -1168,7 +1168,7 @@ set_shader_input(CPT_InternalName id, const PTA_LVecBase3i &v, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_LVecBase2i &v, int priority) { - set_shader_input(ShaderInput(move(id), v, priority)); + set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -1176,7 +1176,7 @@ set_shader_input(CPT_InternalName id, const PTA_LVecBase2i &v, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const LVecBase4i &v, int priority) { - set_shader_input(ShaderInput(move(id), v, priority)); + set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -1184,7 +1184,7 @@ set_shader_input(CPT_InternalName id, const LVecBase4i &v, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const LVecBase3i &v, int priority) { - set_shader_input(ShaderInput(move(id), v, priority)); + set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -1192,7 +1192,7 @@ set_shader_input(CPT_InternalName id, const LVecBase3i &v, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const LVecBase2i &v, int priority) { - set_shader_input(ShaderInput(move(id), v, priority)); + set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -1200,7 +1200,7 @@ set_shader_input(CPT_InternalName id, const LVecBase2i &v, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_LMatrix4 &v, int priority) { - set_shader_input(ShaderInput(move(id), v, priority)); + set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -1208,7 +1208,7 @@ set_shader_input(CPT_InternalName id, const PTA_LMatrix4 &v, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_LMatrix3 &v, int priority) { - set_shader_input(ShaderInput(move(id), v, priority)); + set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -1216,7 +1216,7 @@ set_shader_input(CPT_InternalName id, const PTA_LMatrix3 &v, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const LMatrix4 &v, int priority) { - set_shader_input(ShaderInput(move(id), v, priority)); + set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -1224,7 +1224,7 @@ set_shader_input(CPT_InternalName id, const LMatrix4 &v, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const LMatrix3 &v, int priority) { - set_shader_input(ShaderInput(move(id), v, priority)); + set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -1232,7 +1232,7 @@ set_shader_input(CPT_InternalName id, const LMatrix3 &v, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, Texture *tex, int priority) { - set_shader_input(ShaderInput(move(id), tex, priority)); + set_shader_input(ShaderInput(std::move(id), tex, priority)); } /** @@ -1240,7 +1240,7 @@ set_shader_input(CPT_InternalName id, Texture *tex, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, Texture *tex, const SamplerState &sampler, int priority) { - set_shader_input(ShaderInput(move(id), tex, sampler, priority)); + set_shader_input(ShaderInput(std::move(id), tex, sampler, priority)); } /** @@ -1248,7 +1248,7 @@ set_shader_input(CPT_InternalName id, Texture *tex, const SamplerState &sampler, */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, Texture *tex, bool read, bool write, int z, int n, int priority) { - set_shader_input(ShaderInput(move(id), tex, read, write, z, n, priority)); + set_shader_input(ShaderInput(std::move(id), tex, read, write, z, n, priority)); } /** @@ -1256,7 +1256,7 @@ set_shader_input(CPT_InternalName id, Texture *tex, bool read, bool write, int z */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, ShaderBuffer *buf, int priority) { - set_shader_input(ShaderInput(move(id), buf, priority)); + set_shader_input(ShaderInput(std::move(id), buf, priority)); } /** @@ -1264,7 +1264,7 @@ set_shader_input(CPT_InternalName id, ShaderBuffer *buf, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const NodePath &np, int priority) { - set_shader_input(ShaderInput(move(id), np, priority)); + set_shader_input(ShaderInput(std::move(id), np, priority)); } /** @@ -1272,7 +1272,7 @@ set_shader_input(CPT_InternalName id, const NodePath &np, int priority) { */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, int n1, int n2, int n3, int n4, int priority) { - set_shader_input(ShaderInput(move(id), LVecBase4i(n1, n2, n3, n4), priority)); + set_shader_input(ShaderInput(std::move(id), LVecBase4i(n1, n2, n3, n4), priority)); } /** @@ -1280,7 +1280,7 @@ set_shader_input(CPT_InternalName id, int n1, int n2, int n3, int n4, int priori */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, PN_stdfloat n1, PN_stdfloat n2, PN_stdfloat n3, PN_stdfloat n4, int priority) { - set_shader_input(ShaderInput(move(id), LVecBase4(n1, n2, n3, n4), priority)); + set_shader_input(ShaderInput(std::move(id), LVecBase4(n1, n2, n3, n4), priority)); } /** @@ -1733,7 +1733,7 @@ clear_project_texture(TextureStage *stage) { * string for the default texture coordinate set. */ INLINE bool NodePath:: -has_texcoord(const string &texcoord_name) const { +has_texcoord(const std::string &texcoord_name) const { return has_vertex_column(InternalName::get_texcoord_name(texcoord_name)); } @@ -1986,7 +1986,7 @@ clear_model_nodes() { * of any one key's value. */ INLINE void NodePath:: -set_tag(const string &key, const string &value) { +set_tag(const std::string &key, const std::string &value) { nassertv_always(!is_empty()); node()->set_tag(key, value); } @@ -1996,12 +1996,12 @@ set_tag(const string &key, const string &value) { * the particular key, if any. If no value has been previously set, returns * the empty string. See also get_net_tag(). */ -INLINE string NodePath:: -get_tag(const string &key) const { +INLINE std::string NodePath:: +get_tag(const std::string &key) const { // An empty NodePath quietly returns no tags. This makes get_net_tag() // easier to implement. if (is_empty()) { - return string(); + return std::string(); } return node()->get_tag(key); } @@ -2024,7 +2024,7 @@ get_tag_keys(vector_string &keys) const { * set. See also has_net_tag(). */ INLINE bool NodePath:: -has_tag(const string &key) const { +has_tag(const std::string &key) const { // An empty NodePath quietly has no tags. This makes has_net_tag() easier // to implement. if (is_empty()) { @@ -2038,7 +2038,7 @@ has_tag(const string &key) const { * call to clear_tag(), has_tag() will return false for the indicated key. */ INLINE void NodePath:: -clear_tag(const string &key) { +clear_tag(const std::string &key) { nassertv_always(!is_empty()); node()->clear_tag(key); } @@ -2049,8 +2049,8 @@ clear_tag(const string &key) { * indicated key on any ancestor node, returns the empty string. See also * get_tag(). */ -INLINE string NodePath:: -get_net_tag(const string &key) const { +INLINE std::string NodePath:: +get_net_tag(const std::string &key) const { return find_net_tag(key).get_tag(key); } @@ -2059,7 +2059,7 @@ get_net_tag(const string &key) const { * any ancestor node, or false otherwise. See also has_tag(). */ INLINE bool NodePath:: -has_net_tag(const string &key) const { +has_net_tag(const std::string &key) const { return !find_net_tag(key).is_empty(); } @@ -2079,7 +2079,7 @@ list_tags() const { * Changes the name of the referenced node. */ INLINE void NodePath:: -set_name(const string &name) { +set_name(const std::string &name) { nassertv_always(!is_empty()); node()->set_name(name); } @@ -2087,9 +2087,9 @@ set_name(const string &name) { /** * Returns the name of the referenced node. */ -INLINE string NodePath:: +INLINE std::string NodePath:: get_name() const { - nassertr_always(!is_empty(), string()); + nassertr_always(!is_empty(), std::string()); return node()->get_name(); } @@ -2111,7 +2111,7 @@ encode_to_bam_stream() const { } -INLINE ostream &operator << (ostream &out, const NodePath &node_path) { +INLINE std::ostream &operator << (std::ostream &out, const NodePath &node_path) { node_path.output(out); return out; } diff --git a/panda/src/pgraph/nodePath.h b/panda/src/pgraph/nodePath.h index f932b48efc..cf159972c5 100644 --- a/panda/src/pgraph/nodePath.h +++ b/panda/src/pgraph/nodePath.h @@ -170,7 +170,7 @@ PUBLISHED: }; INLINE NodePath(); - INLINE explicit NodePath(const string &top_node_name, Thread *current_thread = Thread::get_current_thread()); + INLINE explicit NodePath(const std::string &top_node_name, Thread *current_thread = Thread::get_current_thread()); INLINE explicit NodePath(PandaNode *node, Thread *current_thread = Thread::get_current_thread()); INLINE static NodePath any_path(PandaNode *node, Thread *current_thread = Thread::get_current_thread()); explicit NodePath(const NodePath &parent, PandaNode *child_node, @@ -244,9 +244,9 @@ PUBLISHED: MAKE_PROPERTY2(parent, has_parent, get_parent); MAKE_PROPERTY(sort, get_sort); - NodePath find(const string &path) const; + NodePath find(const std::string &path) const; NodePath find_path_to(PandaNode *node) const; - NodePathCollection find_all_matches(const string &path) const; + NodePathCollection find_all_matches(const std::string &path) const; NodePathCollection find_all_paths_to(PandaNode *node) const; // Methods that actually move nodes around in the scene graph. The optional @@ -262,26 +262,26 @@ PUBLISHED: Thread *current_thread = Thread::get_current_thread()); NodePath instance_to(const NodePath &other, int sort = 0, Thread *current_thread = Thread::get_current_thread()) const; - NodePath instance_under_node(const NodePath &other, const string &name, + NodePath instance_under_node(const NodePath &other, const std::string &name, int sort = 0, Thread *current_thread = Thread::get_current_thread()) const; NodePath copy_to(const NodePath &other, int sort = 0, Thread *current_thread = Thread::get_current_thread()) const; NodePath attach_new_node(PandaNode *node, int sort = 0, Thread *current_thread = Thread::get_current_thread()) const; - INLINE NodePath attach_new_node(const string &name, int sort = 0, + INLINE NodePath attach_new_node(const std::string &name, int sort = 0, Thread *current_thread = Thread::get_current_thread()) const; void remove_node(Thread *current_thread = Thread::get_current_thread()); void detach_node(Thread *current_thread = Thread::get_current_thread()); // Handy ways to look at what's there, and other miscellaneous operations. - void output(ostream &out) const; + void output(std::ostream &out) const; INLINE void ls() const; - INLINE void ls(ostream &out, int indent_level = 0) const; + INLINE void ls(std::ostream &out, int indent_level = 0) const; INLINE void reverse_ls() const; - int reverse_ls(ostream &out, int indent_level = 0) const; + int reverse_ls(std::ostream &out, int indent_level = 0) const; // Aggregate transform and state information. const RenderState *get_state(Thread *current_thread = Thread::get_current_thread()) const; @@ -600,10 +600,10 @@ PUBLISHED: void clear_occluder(const NodePath &occluder); bool has_occluder(const NodePath &occluder) const; - void set_bin(const string &bin_name, int draw_order, int priority = 0); + void set_bin(const std::string &bin_name, int draw_order, int priority = 0); void clear_bin(); bool has_bin() const; - string get_bin_name() const; + std::string get_bin_name() const; int get_bin_draw_order() const; void set_texture(Texture *tex, int priority = 0); @@ -743,28 +743,28 @@ PUBLISHED: void project_texture(TextureStage *stage, Texture *tex, const NodePath &projector); INLINE void clear_project_texture(TextureStage *stage); - INLINE bool has_texcoord(const string &texcoord_name) const; + INLINE bool has_texcoord(const std::string &texcoord_name) const; bool has_vertex_column(const InternalName *name) const; InternalNameCollection find_all_vertex_columns() const; - InternalNameCollection find_all_vertex_columns(const string &name) const; + InternalNameCollection find_all_vertex_columns(const std::string &name) const; InternalNameCollection find_all_texcoords() const; - InternalNameCollection find_all_texcoords(const string &name) const; + InternalNameCollection find_all_texcoords(const std::string &name) const; - Texture *find_texture(const string &name) const; + Texture *find_texture(const std::string &name) const; Texture *find_texture(TextureStage *stage) const; TextureCollection find_all_textures() const; - TextureCollection find_all_textures(const string &name) const; + TextureCollection find_all_textures(const std::string &name) const; TextureCollection find_all_textures(TextureStage *stage) const; - TextureStage *find_texture_stage(const string &name) const; + TextureStage *find_texture_stage(const std::string &name) const; TextureStageCollection find_all_texture_stages() const; - TextureStageCollection find_all_texture_stages(const string &name) const; + TextureStageCollection find_all_texture_stages(const std::string &name) const; void unify_texture_stages(TextureStage *stage); - Material *find_material(const string &name) const; + Material *find_material(const std::string &name) const; MaterialCollection find_all_materials() const; - MaterialCollection find_all_materials(const string &name) const; + MaterialCollection find_all_materials(const std::string &name) const; void set_material(Material *tex, int priority = 0); void set_material_off(int priority = 0); @@ -895,7 +895,7 @@ PUBLISHED: void hide_bounds(); PT(BoundingVolume) get_bounds(Thread *current_thread = Thread::get_current_thread()) const; void force_recompute_bounds(); - void write_bounds(ostream &out) const; + void write_bounds(std::ostream &out) const; bool calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, const NodePath &other = NodePath(), Thread *current_thread = Thread::get_current_thread()) const; @@ -910,14 +910,14 @@ PUBLISHED: void apply_texture_colors(); INLINE int clear_model_nodes(); - INLINE void set_tag(const string &key, const string &value); - INLINE string get_tag(const string &key) const; + INLINE void set_tag(const std::string &key, const std::string &value); + INLINE std::string get_tag(const std::string &key) const; INLINE void get_tag_keys(vector_string &keys) const; - INLINE bool has_tag(const string &key) const; - INLINE void clear_tag(const string &key); - INLINE string get_net_tag(const string &key) const; - INLINE bool has_net_tag(const string &key) const; - NodePath find_net_tag(const string &key) const; + INLINE bool has_tag(const std::string &key) const; + INLINE void clear_tag(const std::string &key); + INLINE std::string get_net_tag(const std::string &key) const; + INLINE bool has_net_tag(const std::string &key) const; + NodePath find_net_tag(const std::string &key) const; MAKE_MAP_PROPERTY(net_tags, has_net_tag, get_net_tag); @@ -940,12 +940,12 @@ PUBLISHED: INLINE void list_tags() const; - INLINE void set_name(const string &name); - INLINE string get_name() const; + INLINE void set_name(const std::string &name); + INLINE std::string get_name() const; MAKE_PROPERTY(name, get_name, set_name); BLOCKING bool write_bam_file(const Filename &filename) const; - BLOCKING bool write_bam_stream(ostream &out) const; + BLOCKING bool write_bam_stream(std::ostream &out) const; INLINE vector_uchar encode_to_bam_stream() const; bool encode_to_bam_stream(vector_uchar &data, BamWriter *writer = nullptr) const; @@ -971,7 +971,7 @@ private: int n, Thread *current_thread) const; void find_matches(NodePathCollection &result, - const string &approx_path_str, + const std::string &approx_path_str, int max_matches) const; void find_matches(NodePathCollection &result, FindApproxPath &approx_path, @@ -1047,7 +1047,7 @@ private: friend class CullTraverserData; }; -INLINE ostream &operator << (ostream &out, const NodePath &node_path); +INLINE std::ostream &operator << (std::ostream &out, const NodePath &node_path); #include "nodePath.I" diff --git a/panda/src/pgraph/nodePathCollection.h b/panda/src/pgraph/nodePathCollection.h index 7535a28718..64a16d63c3 100644 --- a/panda/src/pgraph/nodePathCollection.h +++ b/panda/src/pgraph/nodePathCollection.h @@ -56,9 +56,9 @@ PUBLISHED: // Handy operations on many NodePaths at once. INLINE void ls() const; - void ls(ostream &out, int indent_level = 0) const; + void ls(std::ostream &out, int indent_level = 0) const; - NodePathCollection find_all_matches(const string &path) const; + NodePathCollection find_all_matches(const std::string &path) const; void reparent_to(const NodePath &other); void wrt_reparent_to(const NodePath &other); @@ -95,8 +95,8 @@ PUBLISHED: void set_attrib(const RenderAttrib *attrib, int priority = 0); - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; private: typedef PTA(NodePath) NodePaths; @@ -106,7 +106,7 @@ private: typedef pmap StateMap; }; -INLINE ostream &operator << (ostream &out, const NodePathCollection &col) { +INLINE std::ostream &operator << (std::ostream &out, const NodePathCollection &col) { col.output(out); return out; } diff --git a/panda/src/pgraph/nodePathComponent.I b/panda/src/pgraph/nodePathComponent.I index 00b8d6d19d..0a14e1ddd0 100644 --- a/panda/src/pgraph/nodePathComponent.I +++ b/panda/src/pgraph/nodePathComponent.I @@ -67,7 +67,7 @@ get_next(int pipeline_stage, Thread *current_thread) const { return cdata->_next; } -INLINE ostream &operator << (ostream &out, const NodePathComponent &comp) { +INLINE std::ostream &operator << (std::ostream &out, const NodePathComponent &comp) { comp.output(out); return out; } diff --git a/panda/src/pgraph/nodePathComponent.h b/panda/src/pgraph/nodePathComponent.h index b6957ffd9a..37b30c9562 100644 --- a/panda/src/pgraph/nodePathComponent.h +++ b/panda/src/pgraph/nodePathComponent.h @@ -62,7 +62,7 @@ public: bool fix_length(int pipeline_stage, Thread *current_thread); - void output(ostream &out) const; + void output(std::ostream &out) const; private: void set_next(NodePathComponent *next, int pipeline_stage, Thread *current_thread); @@ -131,7 +131,7 @@ private: template<> INLINE void PointerToBase::update_type(To *ptr) {} -INLINE ostream &operator << (ostream &out, const NodePathComponent &comp); +INLINE std::ostream &operator << (std::ostream &out, const NodePathComponent &comp); #include "nodePathComponent.I" diff --git a/panda/src/pgraph/occluderEffect.h b/panda/src/pgraph/occluderEffect.h index af2230832f..befdcee8e0 100644 --- a/panda/src/pgraph/occluderEffect.h +++ b/panda/src/pgraph/occluderEffect.h @@ -48,7 +48,7 @@ PUBLISHED: CPT(RenderEffect) remove_on_occluder(const NodePath &occluder) const; public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderEffect *other) const; diff --git a/panda/src/pgraph/occluderNode.h b/panda/src/pgraph/occluderNode.h index 0bc4381f4d..ebc5db9bc3 100644 --- a/panda/src/pgraph/occluderNode.h +++ b/panda/src/pgraph/occluderNode.h @@ -30,7 +30,7 @@ */ class EXPCL_PANDA_PGRAPH OccluderNode : public PandaNode { PUBLISHED: - explicit OccluderNode(const string &name); + explicit OccluderNode(const std::string &name); protected: OccluderNode(const OccluderNode ©); @@ -44,7 +44,7 @@ public: virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data); virtual bool is_renderable() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; PUBLISHED: INLINE void set_double_sided(bool value); diff --git a/panda/src/pgraph/pandaNode.I b/panda/src/pgraph/pandaNode.I index fcd02ae429..8cbea5c871 100644 --- a/panda/src/pgraph/pandaNode.I +++ b/panda/src/pgraph/pandaNode.I @@ -345,14 +345,14 @@ has_dirty_prev_transform() const { * the particular key, if any. If no value has been previously set, returns * the empty string. */ -INLINE string PandaNode:: -get_tag(const string &key, Thread *current_thread) const { +INLINE std::string PandaNode:: +get_tag(const std::string &key, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); int index = cdata->_tag_data.find(key); if (index >= 0) { return cdata->_tag_data.get_data((size_t)index); } else { - return string(); + return std::string(); } } @@ -362,7 +362,7 @@ get_tag(const string &key, Thread *current_thread) const { * set. */ INLINE bool PandaNode:: -has_tag(const string &key, Thread *current_thread) const { +has_tag(const std::string &key, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return cdata->_tag_data.find(key) >= 0; } @@ -379,7 +379,7 @@ get_num_tags() const { /** * Returns the key of the nth tag applied to this node. */ -INLINE string PandaNode:: +INLINE std::string PandaNode:: get_tag_key(size_t i) const { CDReader cdata(_cycler); return cdata->_tag_data.get_key(i); @@ -410,7 +410,7 @@ has_tags() const { * Lists all the nodes at and below the current path hierarchically. */ INLINE void PandaNode:: -ls(ostream &out, int indent_level) const { +ls(std::ostream &out, int indent_level) const { r_list_descendants(out, indent_level); } @@ -934,7 +934,7 @@ operator = (const PandaNode::Children ©) { */ INLINE PandaNode::Children:: Children(PandaNode::Children &&from) noexcept : - _down(move(from._down)) + _down(std::move(from._down)) { } @@ -943,7 +943,7 @@ Children(PandaNode::Children &&from) noexcept : */ INLINE void PandaNode::Children:: operator = (PandaNode::Children &&from) noexcept { - _down = move(from._down); + _down = std::move(from._down); } /** @@ -1456,13 +1456,13 @@ get_prev_transform() const { * the particular key, if any. If no value has been previously set, returns * the empty string. */ -INLINE string PandaNodePipelineReader:: -get_tag(const string &key) const { +INLINE std::string PandaNodePipelineReader:: +get_tag(const std::string &key) const { int index = _cdata->_tag_data.find(key); if (index >= 0) { return _cdata->_tag_data.get_data((size_t)index); } else { - return string(); + return std::string(); } } @@ -1472,7 +1472,7 @@ get_tag(const string &key) const { * set. */ INLINE bool PandaNodePipelineReader:: -has_tag(const string &key) const { +has_tag(const std::string &key) const { return _cdata->_tag_data.find(key) >= 0; } diff --git a/panda/src/pgraph/pandaNode.h b/panda/src/pgraph/pandaNode.h index f5cc0fee78..4011680178 100644 --- a/panda/src/pgraph/pandaNode.h +++ b/panda/src/pgraph/pandaNode.h @@ -64,7 +64,7 @@ class GraphicsStateGuardianBase; class EXPCL_PANDA_PGRAPH PandaNode : public TypedWritableReferenceCount, public Namable, public LinkedListNode { PUBLISHED: - explicit PandaNode(const string &name); + explicit PandaNode(const std::string &name); virtual ~PandaNode(); // published so that characters can be combined. virtual PandaNode *combine_with(PandaNode *other); @@ -189,19 +189,19 @@ PUBLISHED: static void reset_all_prev_transform(Thread *current_thread = Thread::get_current_thread()); MAKE_PROPERTY(prev_transform, get_prev_transform); - void set_tag(const string &key, const string &value, + void set_tag(const std::string &key, const std::string &value, Thread *current_thread = Thread::get_current_thread()); - INLINE string get_tag(const string &key, + INLINE std::string get_tag(const std::string &key, Thread *current_thread = Thread::get_current_thread()) const; - INLINE bool has_tag(const string &key, + INLINE bool has_tag(const std::string &key, Thread *current_thread = Thread::get_current_thread()) const; - void clear_tag(const string &key, + void clear_tag(const std::string &key, Thread *current_thread = Thread::get_current_thread()); public: void get_tag_keys(vector_string &keys) const; INLINE size_t get_num_tags() const; - INLINE string get_tag_key(size_t i) const; + INLINE std::string get_tag_key(size_t i) const; PUBLISHED: MAKE_MAP_PROPERTY(tags, has_tag, get_tag, set_tag, clear_tag); @@ -221,7 +221,7 @@ PUBLISHED: INLINE bool has_tags() const; void copy_tags(PandaNode *other); - void list_tags(ostream &out, const string &separator = "\n") const; + void list_tags(std::ostream &out, const std::string &separator = "\n") const; int compare_tags(const PandaNode *other) const; @@ -272,10 +272,10 @@ PUBLISHED: bool is_scene_root() const; bool is_under_scene_root() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; - INLINE void ls(ostream &out, int indent_level) const; + INLINE void ls(std::ostream &out, int indent_level) const; // A node has three bounding volumes: an "external" bounding volume that // represents the node and all of its children, an "internal" bounding @@ -437,7 +437,7 @@ private: static void new_connection(PandaNode *parent_node, PandaNode *child_node, int pipeline_stage, Thread *current_thread); void fix_path_lengths(int pipeline_stage, Thread *current_thread); - void r_list_descendants(ostream &out, int indent_level) const; + void r_list_descendants(std::ostream &out, int indent_level) const; INLINE void do_set_dirty_prev_transform(); INLINE void do_clear_dirty_prev_transform(); @@ -520,7 +520,7 @@ private: // This is used to maintain a table of keyed data on each node, for the // user's purposes. - typedef SimpleHashMap TagData; + typedef SimpleHashMap TagData; // This is actually implemented in pandaNode_ext.h, but defined here so // that we can destruct it from the C++ side. Note that it isn't cycled, @@ -647,13 +647,13 @@ private: BamWriter *manager, Datagram &dg) const; void update_up_list(const Up &up_list, BamWriter *manager) const; void update_down_list(const Down &down_list, BamWriter *manager) const; - int complete_up_list(Up &up_list, const string &tag, + int complete_up_list(Up &up_list, const std::string &tag, TypedWritable **p_list, BamReader *manager); - int complete_down_list(Down &down_list, const string &tag, + int complete_down_list(Down &down_list, const std::string &tag, TypedWritable **p_list, BamReader *manager); - void fillin_up_list(Up &up_list, const string &tag, + void fillin_up_list(Up &up_list, const std::string &tag, DatagramIterator &scan, BamReader *manager); - void fillin_down_list(Down &down_list, const string &tag, + void fillin_down_list(Down &down_list, const std::string &tag, DatagramIterator &scan, BamReader *manager); INLINE CPT(Down) get_down() const; @@ -879,8 +879,8 @@ public: INLINE const TransformState *get_transform() const; INLINE const TransformState *get_prev_transform() const; - INLINE string get_tag(const string &key) const; - INLINE bool has_tag(const string &key) const; + INLINE std::string get_tag(const std::string &key) const; + INLINE bool has_tag(const std::string &key) const; INLINE CollideMask get_net_collide_mask() const; INLINE const RenderAttrib *get_off_clip_planes() const; @@ -916,7 +916,7 @@ private: template<> INLINE void PointerToBase::update_type(To *ptr) {} -INLINE ostream &operator << (ostream &out, const PandaNode &node) { +INLINE std::ostream &operator << (std::ostream &out, const PandaNode &node) { node.output(out); return out; } diff --git a/panda/src/pgraph/paramNodePath.h b/panda/src/pgraph/paramNodePath.h index dae621443f..bd0967d5f8 100644 --- a/panda/src/pgraph/paramNodePath.h +++ b/panda/src/pgraph/paramNodePath.h @@ -32,7 +32,7 @@ PUBLISHED: INLINE virtual TypeHandle get_value_type() const; INLINE const NodePath &get_value() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: NodePath _node_path; diff --git a/panda/src/pgraph/planeNode.h b/panda/src/pgraph/planeNode.h index 463fc39b22..2b58225abd 100644 --- a/panda/src/pgraph/planeNode.h +++ b/panda/src/pgraph/planeNode.h @@ -35,12 +35,12 @@ */ class EXPCL_PANDA_PGRAPH PlaneNode : public PandaNode { PUBLISHED: - explicit PlaneNode(const string &name, const LPlane &plane = LPlane()); + explicit PlaneNode(const std::string &name, const LPlane &plane = LPlane()); protected: PlaneNode(const PlaneNode ©); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; virtual PandaNode *make_copy() const; virtual void xform(const LMatrix4 &mat); diff --git a/panda/src/pgraph/polylightEffect.h b/panda/src/pgraph/polylightEffect.h index 418ac2f5db..7416938acd 100644 --- a/panda/src/pgraph/polylightEffect.h +++ b/panda/src/pgraph/polylightEffect.h @@ -70,7 +70,7 @@ public: // CPT(RenderAttrib) do_poly_light(const NodePath &root, const // CullTraverserData *data, const TransformState *node_transform) const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: ContribType _contribution_type; @@ -101,6 +101,6 @@ private: #include "polylightEffect.I" -ostream &operator << (ostream &out, PolylightEffect::ContribType ct); +std::ostream &operator << (std::ostream &out, PolylightEffect::ContribType ct); #endif diff --git a/panda/src/pgraph/polylightNode.h b/panda/src/pgraph/polylightNode.h index cb01427e58..e5caf30735 100644 --- a/panda/src/pgraph/polylightNode.h +++ b/panda/src/pgraph/polylightNode.h @@ -52,7 +52,7 @@ PUBLISHED: AQUADRATIC, }; - explicit PolylightNode(const string &name); + explicit PolylightNode(const std::string &name); INLINE void enable(); INLINE void disable(); INLINE void set_pos(const LPoint3 &position); @@ -120,7 +120,7 @@ private: public: static void register_with_read_factory(); virtual void write_datagram(BamWriter *manager, Datagram &dg); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); diff --git a/panda/src/pgraph/portalClipper.I b/panda/src/pgraph/portalClipper.I index 221119feb5..6dd31056e2 100644 --- a/panda/src/pgraph/portalClipper.I +++ b/panda/src/pgraph/portalClipper.I @@ -161,7 +161,7 @@ is_whole_portal_in_view(const LMatrix4 &cmat) { int result = _reduced_frustum->contains(gbv); - portal_cat.spam() << "1st level test if portal: " << *_reduced_frustum << " is in view " << result << endl; + portal_cat.spam() << "1st level test if portal: " << *_reduced_frustum << " is in view " << result << std::endl; return (result != 0); } diff --git a/panda/src/pgraph/portalNode.h b/panda/src/pgraph/portalNode.h index fefe5b6bdb..de78847dab 100644 --- a/panda/src/pgraph/portalNode.h +++ b/panda/src/pgraph/portalNode.h @@ -29,8 +29,8 @@ */ class EXPCL_PANDA_PGRAPH PortalNode : public PandaNode { PUBLISHED: - explicit PortalNode(const string &name); - explicit PortalNode(const string &name, LPoint3 pos, PN_stdfloat scale=10.0); + explicit PortalNode(const std::string &name); + explicit PortalNode(const std::string &name, LPoint3 pos, PN_stdfloat scale=10.0); protected: PortalNode(const PortalNode ©); @@ -47,7 +47,7 @@ public: virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data); virtual bool is_renderable() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; PUBLISHED: INLINE void set_portal_mask(PortalMask mask); diff --git a/panda/src/pgraph/renderAttrib.h b/panda/src/pgraph/renderAttrib.h index 514a90b7d4..98b9de315c 100644 --- a/panda/src/pgraph/renderAttrib.h +++ b/panda/src/pgraph/renderAttrib.h @@ -74,11 +74,11 @@ PUBLISHED: virtual bool unref() const final; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; static int get_num_attribs(); - static void list_attribs(ostream &out); + static void list_attribs(std::ostream &out); static int garbage_collect(); static bool validate_attribs(); @@ -170,7 +170,7 @@ protected: virtual size_t get_hash_impl() const; virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const; virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const; - void output_comparefunc(ostream &out, PandaCompareFunc fn) const; + void output_comparefunc(std::ostream &out, PandaCompareFunc fn) const; public: INLINE static int register_slot(TypeHandle type_handle, int sort, @@ -226,7 +226,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const RenderAttrib &attrib) { +INLINE std::ostream &operator << (std::ostream &out, const RenderAttrib &attrib) { attrib.output(out); return out; } diff --git a/panda/src/pgraph/renderEffect.h b/panda/src/pgraph/renderEffect.h index 65a9942fa7..f3d3f8bd93 100644 --- a/panda/src/pgraph/renderEffect.h +++ b/panda/src/pgraph/renderEffect.h @@ -73,11 +73,11 @@ public: PUBLISHED: INLINE int compare_to(const RenderEffect &other) const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; static int get_num_effects(); - static void list_effects(ostream &out); + static void list_effects(std::ostream &out); static bool validate_effects(); protected: @@ -118,7 +118,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const RenderEffect &effect) { +INLINE std::ostream &operator << (std::ostream &out, const RenderEffect &effect) { effect.output(out); return out; } diff --git a/panda/src/pgraph/renderEffects.h b/panda/src/pgraph/renderEffects.h index 7a8f18aed3..404a402975 100644 --- a/panda/src/pgraph/renderEffects.h +++ b/panda/src/pgraph/renderEffects.h @@ -85,11 +85,11 @@ PUBLISHED: virtual bool unref() const; - void output(ostream &out) const; - void write(ostream &out, int indent_level) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level) const; static int get_num_states(); - static void list_states(ostream &out); + static void list_states(std::ostream &out); static bool validate_states(); public: @@ -197,7 +197,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const RenderEffects &state) { +INLINE std::ostream &operator << (std::ostream &out, const RenderEffects &state) { state.output(out); return out; } diff --git a/panda/src/pgraph/renderModeAttrib.h b/panda/src/pgraph/renderModeAttrib.h index 21a32ee5de..9684ee5176 100644 --- a/panda/src/pgraph/renderModeAttrib.h +++ b/panda/src/pgraph/renderModeAttrib.h @@ -72,7 +72,7 @@ PUBLISHED: MAKE_PROPERTY(wireframe_color, get_wireframe_color); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/renderState.h b/panda/src/pgraph/renderState.h index 053f8cc365..ab59a6648d 100644 --- a/panda/src/pgraph/renderState.h +++ b/panda/src/pgraph/renderState.h @@ -131,8 +131,8 @@ PUBLISHED: EXTENSION(PyObject *get_composition_cache() const); EXTENSION(PyObject *get_invert_composition_cache() const); - void output(ostream &out) const; - void write(ostream &out, int indent_level) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level) const; static int get_max_priority(); @@ -141,8 +141,8 @@ PUBLISHED: static int clear_cache(); static void clear_munger_cache(); static int garbage_collect(); - static void list_cycles(ostream &out); - static void list_states(ostream &out); + static void list_cycles(std::ostream &out); + static void list_states(std::ostream &out); static bool validate_states(); EXTENSION(static PyObject *get_states()); @@ -373,7 +373,7 @@ private: template<> INLINE void PointerToBase::update_type(To *ptr) {} -INLINE ostream &operator << (ostream &out, const RenderState &state) { +INLINE std::ostream &operator << (std::ostream &out, const RenderState &state) { state.output(out); return out; } diff --git a/panda/src/pgraph/rescaleNormalAttrib.h b/panda/src/pgraph/rescaleNormalAttrib.h index 589f5351cc..7f87219285 100644 --- a/panda/src/pgraph/rescaleNormalAttrib.h +++ b/panda/src/pgraph/rescaleNormalAttrib.h @@ -52,7 +52,7 @@ PUBLISHED: MAKE_PROPERTY(mode, get_mode); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; @@ -97,8 +97,8 @@ private: static int _attrib_slot; }; -EXPCL_PANDA_PGRAPH ostream &operator << (ostream &out, RescaleNormalAttrib::Mode mode); -EXPCL_PANDA_PGRAPH istream &operator >> (istream &in, RescaleNormalAttrib::Mode &mode); +EXPCL_PANDA_PGRAPH std::ostream &operator << (std::ostream &out, RescaleNormalAttrib::Mode mode); +EXPCL_PANDA_PGRAPH std::istream &operator >> (std::istream &in, RescaleNormalAttrib::Mode &mode); #include "rescaleNormalAttrib.I" diff --git a/panda/src/pgraph/scissorAttrib.h b/panda/src/pgraph/scissorAttrib.h index 9ea128e765..c7c3ff3c4e 100644 --- a/panda/src/pgraph/scissorAttrib.h +++ b/panda/src/pgraph/scissorAttrib.h @@ -51,7 +51,7 @@ PUBLISHED: MAKE_PROPERTY(frame, get_frame); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/scissorEffect.h b/panda/src/pgraph/scissorEffect.h index 4ac2e9a87d..aec8084917 100644 --- a/panda/src/pgraph/scissorEffect.h +++ b/panda/src/pgraph/scissorEffect.h @@ -60,7 +60,7 @@ PUBLISHED: public: virtual CPT(RenderEffect) xform(const LMatrix4 &mat) const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; virtual bool has_cull_callback() const; virtual void cull_callback(CullTraverser *trav, CullTraverserData &data, diff --git a/panda/src/pgraph/shadeModelAttrib.h b/panda/src/pgraph/shadeModelAttrib.h index 8f8cd8a570..c5e0819141 100644 --- a/panda/src/pgraph/shadeModelAttrib.h +++ b/panda/src/pgraph/shadeModelAttrib.h @@ -42,7 +42,7 @@ PUBLISHED: MAKE_PROPERTY(mode, get_mode); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/shaderAttrib.I b/panda/src/pgraph/shaderAttrib.I index baea58607f..fccfb98569 100644 --- a/panda/src/pgraph/shaderAttrib.I +++ b/panda/src/pgraph/shaderAttrib.I @@ -110,7 +110,7 @@ has_shader_input(CPT_InternalName id) const { */ INLINE CPT(RenderAttrib) ShaderAttrib:: set_shader_input(CPT_InternalName id, const PTA_float &v, int priority) const { - return set_shader_input(ShaderInput(move(id), v, priority)); + return set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -118,7 +118,7 @@ set_shader_input(CPT_InternalName id, const PTA_float &v, int priority) const { */ INLINE CPT(RenderAttrib) ShaderAttrib:: set_shader_input(CPT_InternalName id, const PTA_double &v, int priority) const { - return set_shader_input(ShaderInput(move(id), v, priority)); + return set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -126,7 +126,7 @@ set_shader_input(CPT_InternalName id, const PTA_double &v, int priority) const { */ INLINE CPT(RenderAttrib) ShaderAttrib:: set_shader_input(CPT_InternalName id, const PTA_LVecBase4 &v, int priority) const { - return set_shader_input(ShaderInput(move(id), v, priority)); + return set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -134,7 +134,7 @@ set_shader_input(CPT_InternalName id, const PTA_LVecBase4 &v, int priority) cons */ INLINE CPT(RenderAttrib) ShaderAttrib:: set_shader_input(CPT_InternalName id, const PTA_LVecBase3 &v, int priority) const { - return set_shader_input(ShaderInput(move(id), v, priority)); + return set_shader_input(ShaderInput(std::move(id), v, priority)); } @@ -143,7 +143,7 @@ set_shader_input(CPT_InternalName id, const PTA_LVecBase3 &v, int priority) cons */ INLINE CPT(RenderAttrib) ShaderAttrib:: set_shader_input(CPT_InternalName id, const PTA_LVecBase2 &v, int priority) const { - return set_shader_input(ShaderInput(move(id), v, priority)); + return set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -151,7 +151,7 @@ set_shader_input(CPT_InternalName id, const PTA_LVecBase2 &v, int priority) cons */ INLINE CPT(RenderAttrib) ShaderAttrib:: set_shader_input(CPT_InternalName id, const LVecBase4 &v, int priority) const { - return set_shader_input(ShaderInput(move(id), v, priority)); + return set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -159,7 +159,7 @@ set_shader_input(CPT_InternalName id, const LVecBase4 &v, int priority) const { */ INLINE CPT(RenderAttrib) ShaderAttrib:: set_shader_input(CPT_InternalName id, const LVecBase3 &v, int priority) const { - return set_shader_input(ShaderInput(move(id), v, priority)); + return set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -167,7 +167,7 @@ set_shader_input(CPT_InternalName id, const LVecBase3 &v, int priority) const { */ INLINE CPT(RenderAttrib) ShaderAttrib:: set_shader_input(CPT_InternalName id, const LVecBase2 &v, int priority) const { - return set_shader_input(ShaderInput(move(id), v, priority)); + return set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -175,7 +175,7 @@ set_shader_input(CPT_InternalName id, const LVecBase2 &v, int priority) const { */ INLINE CPT(RenderAttrib) ShaderAttrib:: set_shader_input(CPT_InternalName id, const PTA_LMatrix4 &v, int priority) const { - return set_shader_input(ShaderInput(move(id), v, priority)); + return set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -183,7 +183,7 @@ set_shader_input(CPT_InternalName id, const PTA_LMatrix4 &v, int priority) const */ INLINE CPT(RenderAttrib) ShaderAttrib:: set_shader_input(CPT_InternalName id, const PTA_LMatrix3 &v, int priority) const { - return set_shader_input(ShaderInput(move(id), v, priority)); + return set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -191,7 +191,7 @@ set_shader_input(CPT_InternalName id, const PTA_LMatrix3 &v, int priority) const */ INLINE CPT(RenderAttrib) ShaderAttrib:: set_shader_input(CPT_InternalName id, const LMatrix4 &v, int priority) const { - return set_shader_input(ShaderInput(move(id), v, priority)); + return set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -199,7 +199,7 @@ set_shader_input(CPT_InternalName id, const LMatrix4 &v, int priority) const { */ INLINE CPT(RenderAttrib) ShaderAttrib:: set_shader_input(CPT_InternalName id, const LMatrix3 &v, int priority) const { - return set_shader_input(ShaderInput(move(id), v, priority)); + return set_shader_input(ShaderInput(std::move(id), v, priority)); } /** @@ -207,7 +207,7 @@ set_shader_input(CPT_InternalName id, const LMatrix3 &v, int priority) const { */ INLINE CPT(RenderAttrib) ShaderAttrib:: set_shader_input(CPT_InternalName id, Texture *tex, int priority) const { - return set_shader_input(ShaderInput(move(id), tex, priority)); + return set_shader_input(ShaderInput(std::move(id), tex, priority)); } /** @@ -215,7 +215,7 @@ set_shader_input(CPT_InternalName id, Texture *tex, int priority) const { */ INLINE CPT(RenderAttrib) ShaderAttrib:: set_shader_input(CPT_InternalName id, const NodePath &np, int priority) const { - return set_shader_input(ShaderInput(move(id), np, priority)); + return set_shader_input(ShaderInput(std::move(id), np, priority)); } /** @@ -223,7 +223,7 @@ set_shader_input(CPT_InternalName id, const NodePath &np, int priority) const { */ INLINE CPT(RenderAttrib) ShaderAttrib:: set_shader_input(CPT_InternalName id, double n1, double n2, double n3, double n4, int priority) const { - return set_shader_input(ShaderInput(move(id), LVecBase4((PN_stdfloat)n1, (PN_stdfloat)n2, (PN_stdfloat)n3, (PN_stdfloat)n4), priority)); + return set_shader_input(ShaderInput(std::move(id), LVecBase4((PN_stdfloat)n1, (PN_stdfloat)n2, (PN_stdfloat)n3, (PN_stdfloat)n4), priority)); } INLINE bool ShaderAttrib:: diff --git a/panda/src/pgraph/shaderAttrib.h b/panda/src/pgraph/shaderAttrib.h index 33af01fc99..6cd04c6d99 100644 --- a/panda/src/pgraph/shaderAttrib.h +++ b/panda/src/pgraph/shaderAttrib.h @@ -102,7 +102,7 @@ PUBLISHED: CPT(RenderAttrib) clear_flag(int flag) const; CPT(RenderAttrib) clear_shader_input(const InternalName *id) const; - CPT(RenderAttrib) clear_shader_input(const string &id) const; + CPT(RenderAttrib) clear_shader_input(const std::string &id) const; CPT(RenderAttrib) clear_all_shader_inputs() const; @@ -111,7 +111,7 @@ PUBLISHED: const Shader *get_shader() const; const ShaderInput &get_shader_input(const InternalName *id) const; - const ShaderInput &get_shader_input(const string &id) const; + const ShaderInput &get_shader_input(const std::string &id) const; const NodePath &get_shader_input_nodepath(const InternalName *id) const; LVecBase4 get_shader_input_vector(InternalName *id) const; @@ -127,7 +127,7 @@ PUBLISHED: MAKE_PROPERTY(instance_count, get_instance_count); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/shaderPool.I b/panda/src/pgraph/shaderPool.I index 074a24e147..03a07d448d 100644 --- a/panda/src/pgraph/shaderPool.I +++ b/panda/src/pgraph/shaderPool.I @@ -84,7 +84,7 @@ garbage_collect() { * Lists the contents of the shader pool to the indicated output stream. */ INLINE void ShaderPool:: -list_contents(ostream &out) { +list_contents(std::ostream &out) { get_ptr()->ns_list_contents(out); } diff --git a/panda/src/pgraph/shaderPool.h b/panda/src/pgraph/shaderPool.h index ca9ee694fc..def32ab2d6 100644 --- a/panda/src/pgraph/shaderPool.h +++ b/panda/src/pgraph/shaderPool.h @@ -36,8 +36,8 @@ PUBLISHED: INLINE static int garbage_collect(); - INLINE static void list_contents(ostream &out); - static void write(ostream &out); + INLINE static void list_contents(std::ostream &out); + static void write(std::ostream &out); private: INLINE ShaderPool(); @@ -48,7 +48,7 @@ private: void ns_release_shader(const Filename &orig_filename); void ns_release_all_shaders(); int ns_garbage_collect(); - void ns_list_contents(ostream &out) const; + void ns_list_contents(std::ostream &out) const; void resolve_filename(Filename &new_filename, const Filename &orig_filename); diff --git a/panda/src/pgraph/stencilAttrib.h b/panda/src/pgraph/stencilAttrib.h index 6b0b773581..6382bc3cd3 100644 --- a/panda/src/pgraph/stencilAttrib.h +++ b/panda/src/pgraph/stencilAttrib.h @@ -139,7 +139,7 @@ PUBLISHED: public: static const char *stencil_render_state_name_array [SRS_total]; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/texGenAttrib.h b/panda/src/pgraph/texGenAttrib.h index b9e1cd273a..0bd9e463e8 100644 --- a/panda/src/pgraph/texGenAttrib.h +++ b/panda/src/pgraph/texGenAttrib.h @@ -61,7 +61,7 @@ PUBLISHED: INLINE int get_geom_rendering(int geom_rendering) const; public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; @@ -79,7 +79,7 @@ private: INLINE ModeDef(); INLINE int compare_to(const ModeDef &other) const; Mode _mode; - string _source_name; + std::string _source_name; NodePath _light; LTexCoord3 _constant_value; }; diff --git a/panda/src/pgraph/texMatrixAttrib.h b/panda/src/pgraph/texMatrixAttrib.h index f68238cf9f..28034a5afa 100644 --- a/panda/src/pgraph/texMatrixAttrib.h +++ b/panda/src/pgraph/texMatrixAttrib.h @@ -60,7 +60,7 @@ PUBLISHED: INLINE int get_geom_rendering(int geom_rendering) const; public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/texProjectorEffect.h b/panda/src/pgraph/texProjectorEffect.h index faf70caf82..40418b60af 100644 --- a/panda/src/pgraph/texProjectorEffect.h +++ b/panda/src/pgraph/texProjectorEffect.h @@ -68,7 +68,7 @@ PUBLISHED: int get_lens_index(TextureStage *stage) const; public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; virtual bool has_cull_callback() const; virtual void cull_callback(CullTraverser *trav, CullTraverserData &data, diff --git a/panda/src/pgraph/textureAttrib.h b/panda/src/pgraph/textureAttrib.h index 0938df8d96..908e4c50af 100644 --- a/panda/src/pgraph/textureAttrib.h +++ b/panda/src/pgraph/textureAttrib.h @@ -94,7 +94,7 @@ public: CPT(TextureAttrib) filter_to_max(int max_texture_stages) const; virtual bool lower_attrib_can_override() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; virtual bool has_cull_callback() const; virtual bool cull_callback(CullTraverser *trav, const CullTraverserData &data) const; diff --git a/panda/src/pgraph/textureStageCollection.h b/panda/src/pgraph/textureStageCollection.h index 002447decc..d29a5c222d 100644 --- a/panda/src/pgraph/textureStageCollection.h +++ b/panda/src/pgraph/textureStageCollection.h @@ -36,7 +36,7 @@ PUBLISHED: bool has_texture_stage(TextureStage *texture_stage) const; void clear(); - TextureStage *find_texture_stage(const string &name) const; + TextureStage *find_texture_stage(const std::string &name) const; int get_num_texture_stages() const; TextureStage *get_texture_stage(int index) const; @@ -48,8 +48,8 @@ PUBLISHED: void sort(); - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; private: typedef PTA(PT(TextureStage)) TextureStages; @@ -62,7 +62,7 @@ private: }; -INLINE ostream &operator << (ostream &out, const TextureStageCollection &col) { +INLINE std::ostream &operator << (std::ostream &out, const TextureStageCollection &col) { col.output(out); return out; } diff --git a/panda/src/pgraph/transformState.h b/panda/src/pgraph/transformState.h index e204402489..75b4fedb0e 100644 --- a/panda/src/pgraph/transformState.h +++ b/panda/src/pgraph/transformState.h @@ -194,16 +194,16 @@ PUBLISHED: EXTENSION(PyObject *get_composition_cache() const); EXTENSION(PyObject *get_invert_composition_cache() const); - void output(ostream &out) const; - void write(ostream &out, int indent_level) const; - void write_composition_cache(ostream &out, int indent_level) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level) const; + void write_composition_cache(std::ostream &out, int indent_level) const; static int get_num_states(); static int get_num_unused_states(); static int clear_cache(); static int garbage_collect(); - static void list_cycles(ostream &out); - static void list_states(ostream &out); + static void list_cycles(std::ostream &out); + static void list_states(std::ostream &out); static bool validate_states(); EXTENSION(static PyObject *get_states()); EXTENSION(static PyObject *get_unused_states()); @@ -407,7 +407,7 @@ private: template<> INLINE void PointerToBase::update_type(To *ptr) {} -INLINE ostream &operator << (ostream &out, const TransformState &state) { +INLINE std::ostream &operator << (std::ostream &out, const TransformState &state) { state.output(out); return out; } diff --git a/panda/src/pgraph/transparencyAttrib.h b/panda/src/pgraph/transparencyAttrib.h index 75af58c64e..4021697596 100644 --- a/panda/src/pgraph/transparencyAttrib.h +++ b/panda/src/pgraph/transparencyAttrib.h @@ -54,7 +54,7 @@ PUBLISHED: MAKE_PROPERTY(mode, get_mode); public: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual int compare_to_impl(const RenderAttrib *other) const; diff --git a/panda/src/pgraph/weakNodePath.I b/panda/src/pgraph/weakNodePath.I index 8191821b12..c2d4b0a523 100644 --- a/panda/src/pgraph/weakNodePath.I +++ b/panda/src/pgraph/weakNodePath.I @@ -221,7 +221,7 @@ get_key() const { return _backup_key; } -INLINE ostream &operator << (ostream &out, const WeakNodePath &node_path) { +INLINE std::ostream &operator << (std::ostream &out, const WeakNodePath &node_path) { node_path.output(out); return out; } diff --git a/panda/src/pgraph/weakNodePath.h b/panda/src/pgraph/weakNodePath.h index dc82431023..1137c8f46b 100644 --- a/panda/src/pgraph/weakNodePath.h +++ b/panda/src/pgraph/weakNodePath.h @@ -59,7 +59,7 @@ PUBLISHED: INLINE int get_key() const; - void output(ostream &out) const; + void output(std::ostream &out) const; private: WPT(NodePathComponent) _head; @@ -68,7 +68,7 @@ private: friend class NodePath; }; -INLINE ostream &operator << (ostream &out, const WeakNodePath &node_path); +INLINE std::ostream &operator << (std::ostream &out, const WeakNodePath &node_path); #include "weakNodePath.I" diff --git a/panda/src/pgraph/workingNodePath.I b/panda/src/pgraph/workingNodePath.I index ad5c80ba18..1b545c29b8 100644 --- a/panda/src/pgraph/workingNodePath.I +++ b/panda/src/pgraph/workingNodePath.I @@ -90,8 +90,8 @@ node() const { return _node; } -INLINE ostream & -operator << (ostream &out, const WorkingNodePath &node_path) { +INLINE std::ostream & +operator << (std::ostream &out, const WorkingNodePath &node_path) { node_path.output(out); return out; } diff --git a/panda/src/pgraph/workingNodePath.h b/panda/src/pgraph/workingNodePath.h index fefcb6b687..9e698897f5 100644 --- a/panda/src/pgraph/workingNodePath.h +++ b/panda/src/pgraph/workingNodePath.h @@ -53,7 +53,7 @@ public: int get_num_nodes() const; PandaNode *get_node(int index) const; - void output(ostream &out) const; + void output(std::ostream &out) const; PUBLISHED: MAKE_PROPERTY(valid, is_valid); @@ -71,7 +71,7 @@ private: PT(PandaNode) _node; }; -INLINE ostream &operator << (ostream &out, const WorkingNodePath &node_path); +INLINE std::ostream &operator << (std::ostream &out, const WorkingNodePath &node_path); #include "workingNodePath.I" diff --git a/panda/src/pgraphnodes/ambientLight.h b/panda/src/pgraphnodes/ambientLight.h index 959a2d1485..6c9d494b0c 100644 --- a/panda/src/pgraphnodes/ambientLight.h +++ b/panda/src/pgraphnodes/ambientLight.h @@ -25,14 +25,14 @@ */ class EXPCL_PANDA_PGRAPHNODES AmbientLight : public LightNode { PUBLISHED: - explicit AmbientLight(const string &name); + explicit AmbientLight(const std::string &name); protected: AmbientLight(const AmbientLight ©); public: virtual PandaNode *make_copy() const; - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; virtual bool is_ambient_light() const final; PUBLISHED: @@ -68,7 +68,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const AmbientLight &light) { +INLINE std::ostream &operator << (std::ostream &out, const AmbientLight &light) { light.output(out); return out; } diff --git a/panda/src/pgraphnodes/callbackNode.h b/panda/src/pgraphnodes/callbackNode.h index ba2baec389..0a4d101903 100644 --- a/panda/src/pgraphnodes/callbackNode.h +++ b/panda/src/pgraphnodes/callbackNode.h @@ -25,7 +25,7 @@ */ class EXPCL_PANDA_PGRAPHNODES CallbackNode : public PandaNode { PUBLISHED: - explicit CallbackNode(const string &name); + explicit CallbackNode(const std::string &name); INLINE void set_cull_callback(CallbackObject *object); INLINE void clear_cull_callback(); @@ -47,7 +47,7 @@ public: virtual bool is_renderable() const; virtual void add_for_draw(CullTraverser *trav, CullTraverserData &data); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: class EXPCL_PANDA_PGRAPHNODES CData : public CycleData { diff --git a/panda/src/pgraphnodes/computeNode.h b/panda/src/pgraphnodes/computeNode.h index 83f7297216..475aca2355 100644 --- a/panda/src/pgraphnodes/computeNode.h +++ b/panda/src/pgraphnodes/computeNode.h @@ -26,7 +26,7 @@ */ class EXPCL_PANDA_PGRAPHNODES ComputeNode : public PandaNode { PUBLISHED: - explicit ComputeNode(const string &name); + explicit ComputeNode(const std::string &name); INLINE void add_dispatch(const LVecBase3i &num_groups); INLINE void add_dispatch(int num_groups_x, int num_groups_y, int num_groups_z); @@ -50,7 +50,7 @@ public: virtual bool is_renderable() const; virtual void add_for_draw(CullTraverser *trav, CullTraverserData &data); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; public: class EXPCL_PANDA_PGRAPHNODES Dispatcher : public CallbackObject { diff --git a/panda/src/pgraphnodes/directionalLight.h b/panda/src/pgraphnodes/directionalLight.h index c78f76f81e..f5453399ef 100644 --- a/panda/src/pgraphnodes/directionalLight.h +++ b/panda/src/pgraphnodes/directionalLight.h @@ -24,7 +24,7 @@ */ class EXPCL_PANDA_PGRAPHNODES DirectionalLight : public LightLensNode { PUBLISHED: - explicit DirectionalLight(const string &name); + explicit DirectionalLight(const std::string &name); protected: DirectionalLight(const DirectionalLight ©); @@ -32,7 +32,7 @@ protected: public: virtual PandaNode *make_copy() const; virtual void xform(const LMatrix4 &mat); - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; virtual bool get_vector_to_light(LVector3 &result, const LPoint3 &from_object_point, @@ -106,7 +106,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const DirectionalLight &light) { +INLINE std::ostream &operator << (std::ostream &out, const DirectionalLight &light) { light.output(out); return out; } diff --git a/panda/src/pgraphnodes/fadeLodNode.I b/panda/src/pgraphnodes/fadeLodNode.I index 41f7d79299..0b2b02cd94 100644 --- a/panda/src/pgraphnodes/fadeLodNode.I +++ b/panda/src/pgraphnodes/fadeLodNode.I @@ -32,7 +32,7 @@ get_fade_time() const { * Returns the cull bin that is assigned to the fading part of the geometry * during a transition. */ -INLINE const string &FadeLODNode:: +INLINE const std::string &FadeLODNode:: get_fade_bin_name() const { return _fade_bin_name; } diff --git a/panda/src/pgraphnodes/fadeLodNode.h b/panda/src/pgraphnodes/fadeLodNode.h index 728cc8f8e6..7f748ace4e 100644 --- a/panda/src/pgraphnodes/fadeLodNode.h +++ b/panda/src/pgraphnodes/fadeLodNode.h @@ -23,22 +23,22 @@ */ class EXPCL_PANDA_PGRAPHNODES FadeLODNode : public LODNode { PUBLISHED: - explicit FadeLODNode(const string &name); + explicit FadeLODNode(const std::string &name); protected: FadeLODNode(const FadeLODNode ©); public: virtual PandaNode *make_copy() const; virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; PUBLISHED: INLINE void set_fade_time(PN_stdfloat t); INLINE PN_stdfloat get_fade_time() const; MAKE_PROPERTY(fade_time, get_fade_time, set_fade_time); - void set_fade_bin(const string &name, int draw_order); - INLINE const string &get_fade_bin_name() const; + void set_fade_bin(const std::string &name, int draw_order); + INLINE const std::string &get_fade_bin_name() const; INLINE int get_fade_bin_draw_order() const; MAKE_PROPERTY(fade_bin_name, get_fade_bin_name); MAKE_PROPERTY(fade_bin_draw_order, get_fade_bin_draw_order); @@ -56,7 +56,7 @@ private: private: PN_stdfloat _fade_time; - string _fade_bin_name; + std::string _fade_bin_name; int _fade_bin_draw_order; int _fade_state_override; diff --git a/panda/src/pgraphnodes/fadeLodNodeData.h b/panda/src/pgraphnodes/fadeLodNodeData.h index 7d629d060e..206a08bbe4 100644 --- a/panda/src/pgraphnodes/fadeLodNodeData.h +++ b/panda/src/pgraphnodes/fadeLodNodeData.h @@ -34,7 +34,7 @@ public: int _fade_out; int _fade_in; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; public: static TypeHandle get_class_type() { diff --git a/panda/src/pgraphnodes/lightLensNode.h b/panda/src/pgraphnodes/lightLensNode.h index 03c1342927..4398f02bfd 100644 --- a/panda/src/pgraphnodes/lightLensNode.h +++ b/panda/src/pgraphnodes/lightLensNode.h @@ -32,7 +32,7 @@ class GraphicsStateGuardian; */ class EXPCL_PANDA_PGRAPHNODES LightLensNode : public Light, public Camera { PUBLISHED: - explicit LightLensNode(const string &name, Lens *lens = new PerspectiveLens()); + explicit LightLensNode(const std::string &name, Lens *lens = new PerspectiveLens()); virtual ~LightLensNode(); INLINE bool has_specular_color() const; @@ -82,8 +82,8 @@ public: PUBLISHED: // We have to explicitly publish these because they resolve the multiple // inheritance. - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: virtual void write_datagram(BamWriter *manager, Datagram &dg); @@ -113,7 +113,7 @@ private: friend class GraphicsStateGuardian; }; -INLINE ostream &operator << (ostream &out, const LightLensNode &light) { +INLINE std::ostream &operator << (std::ostream &out, const LightLensNode &light) { light.output(out); return out; } diff --git a/panda/src/pgraphnodes/lightNode.h b/panda/src/pgraphnodes/lightNode.h index 9e9187ebe0..a3b85a8d90 100644 --- a/panda/src/pgraphnodes/lightNode.h +++ b/panda/src/pgraphnodes/lightNode.h @@ -26,7 +26,7 @@ */ class EXPCL_PANDA_PGRAPHNODES LightNode : public Light, public PandaNode { PUBLISHED: - explicit LightNode(const string &name); + explicit LightNode(const std::string &name); protected: LightNode(const LightNode ©); @@ -38,8 +38,8 @@ public: PUBLISHED: // We have to explicitly publish these because they resolve the multiple // inheritance. - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: virtual void write_datagram(BamWriter *manager, Datagram &dg); @@ -67,7 +67,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const LightNode &light) { +INLINE std::ostream &operator << (std::ostream &out, const LightNode &light) { light.output(out); return out; } diff --git a/panda/src/pgraphnodes/lodNode.I b/panda/src/pgraphnodes/lodNode.I index 3a042c2aa5..92398e35fe 100644 --- a/panda/src/pgraphnodes/lodNode.I +++ b/panda/src/pgraphnodes/lodNode.I @@ -15,7 +15,7 @@ * */ INLINE LODNode:: -LODNode(const string &name) : +LODNode(const std::string &name) : PandaNode(name) { set_cull_callback(); diff --git a/panda/src/pgraphnodes/lodNode.h b/panda/src/pgraphnodes/lodNode.h index 7258ebe447..c82e066ffc 100644 --- a/panda/src/pgraphnodes/lodNode.h +++ b/panda/src/pgraphnodes/lodNode.h @@ -27,9 +27,9 @@ */ class EXPCL_PANDA_PGRAPHNODES LODNode : public PandaNode { PUBLISHED: - INLINE explicit LODNode(const string &name); + INLINE explicit LODNode(const std::string &name); - static PT(LODNode) make_default_lod(const string &name); + static PT(LODNode) make_default_lod(const std::string &name); protected: INLINE LODNode(const LODNode ©); @@ -40,7 +40,7 @@ public: virtual void xform(const LMatrix4 &mat); virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; virtual bool is_lod_node() const; diff --git a/panda/src/pgraphnodes/lodNodeType.h b/panda/src/pgraphnodes/lodNodeType.h index bc1964d519..507ade03cf 100644 --- a/panda/src/pgraphnodes/lodNodeType.h +++ b/panda/src/pgraphnodes/lodNodeType.h @@ -25,7 +25,7 @@ enum LODNodeType { END_PUBLISH -EXPCL_PANDA_PGRAPH ostream &operator << (ostream &out, LODNodeType lnt); -EXPCL_PANDA_PGRAPH istream &operator >> (istream &in, LODNodeType &cs); +EXPCL_PANDA_PGRAPH std::ostream &operator << (std::ostream &out, LODNodeType lnt); +EXPCL_PANDA_PGRAPH std::istream &operator >> (std::istream &in, LODNodeType &cs); #endif diff --git a/panda/src/pgraphnodes/nodeCullCallbackData.h b/panda/src/pgraphnodes/nodeCullCallbackData.h index add737d3d6..f78acb86cb 100644 --- a/panda/src/pgraphnodes/nodeCullCallbackData.h +++ b/panda/src/pgraphnodes/nodeCullCallbackData.h @@ -28,7 +28,7 @@ public: INLINE NodeCullCallbackData(CullTraverser *trav, CullTraverserData &data); PUBLISHED: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; INLINE CullTraverser *get_trav() const; INLINE CullTraverserData &get_data() const; diff --git a/panda/src/pgraphnodes/pointLight.h b/panda/src/pgraphnodes/pointLight.h index bb37237883..d54efc04ba 100644 --- a/panda/src/pgraphnodes/pointLight.h +++ b/panda/src/pgraphnodes/pointLight.h @@ -24,7 +24,7 @@ */ class EXPCL_PANDA_PGRAPHNODES PointLight : public LightLensNode { PUBLISHED: - explicit PointLight(const string &name); + explicit PointLight(const std::string &name); protected: PointLight(const PointLight ©); @@ -32,7 +32,7 @@ protected: public: virtual PandaNode *make_copy() const; virtual void xform(const LMatrix4 &mat); - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; virtual bool get_vector_to_light(LVector3 &result, const LPoint3 &from_object_point, @@ -113,7 +113,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const PointLight &light) { +INLINE std::ostream &operator << (std::ostream &out, const PointLight &light) { light.output(out); return out; } diff --git a/panda/src/pgraphnodes/rectangleLight.h b/panda/src/pgraphnodes/rectangleLight.h index b6a4e173c1..9fafe875d6 100644 --- a/panda/src/pgraphnodes/rectangleLight.h +++ b/panda/src/pgraphnodes/rectangleLight.h @@ -25,14 +25,14 @@ */ class EXPCL_PANDA_PGRAPHNODES RectangleLight : public LightLensNode { PUBLISHED: - explicit RectangleLight(const string &name); + explicit RectangleLight(const std::string &name); protected: RectangleLight(const RectangleLight ©); public: virtual PandaNode *make_copy() const; - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; PUBLISHED: INLINE const LColor &get_specular_color() const final; diff --git a/panda/src/pgraphnodes/sceneGraphAnalyzer.h b/panda/src/pgraphnodes/sceneGraphAnalyzer.h index 68ca0d14df..a56d34f41c 100644 --- a/panda/src/pgraphnodes/sceneGraphAnalyzer.h +++ b/panda/src/pgraphnodes/sceneGraphAnalyzer.h @@ -52,7 +52,7 @@ PUBLISHED: void clear(); void add_node(PandaNode *node); - void write(ostream &out, int indent_level = 0) const; + void write(std::ostream &out, int indent_level = 0) const; INLINE int get_num_nodes() const; INLINE int get_num_instances() const; diff --git a/panda/src/pgraphnodes/selectiveChildNode.I b/panda/src/pgraphnodes/selectiveChildNode.I index a7b886d61a..beafc0669d 100644 --- a/panda/src/pgraphnodes/selectiveChildNode.I +++ b/panda/src/pgraphnodes/selectiveChildNode.I @@ -15,7 +15,7 @@ * */ INLINE SelectiveChildNode:: -SelectiveChildNode(const string &name) : +SelectiveChildNode(const std::string &name) : PandaNode(name), _selected_child(0) { diff --git a/panda/src/pgraphnodes/selectiveChildNode.h b/panda/src/pgraphnodes/selectiveChildNode.h index 76720aa933..29b0d4581a 100644 --- a/panda/src/pgraphnodes/selectiveChildNode.h +++ b/panda/src/pgraphnodes/selectiveChildNode.h @@ -24,7 +24,7 @@ */ class EXPCL_PANDA_PGRAPHNODES SelectiveChildNode : public PandaNode { PUBLISHED: - INLINE explicit SelectiveChildNode(const string &name); + INLINE explicit SelectiveChildNode(const std::string &name); protected: INLINE SelectiveChildNode(const SelectiveChildNode ©); diff --git a/panda/src/pgraphnodes/sequenceNode.I b/panda/src/pgraphnodes/sequenceNode.I index 823a19ea4c..68fb10120e 100644 --- a/panda/src/pgraphnodes/sequenceNode.I +++ b/panda/src/pgraphnodes/sequenceNode.I @@ -15,7 +15,7 @@ * */ INLINE SequenceNode:: -SequenceNode(const string &name) : +SequenceNode(const std::string &name) : SelectiveChildNode(name) { set_cull_callback(); diff --git a/panda/src/pgraphnodes/sequenceNode.h b/panda/src/pgraphnodes/sequenceNode.h index ce05b792f2..db511dd4ae 100644 --- a/panda/src/pgraphnodes/sequenceNode.h +++ b/panda/src/pgraphnodes/sequenceNode.h @@ -26,7 +26,7 @@ */ class EXPCL_PANDA_PGRAPHNODES SequenceNode : public SelectiveChildNode, public AnimInterface { PUBLISHED: - INLINE explicit SequenceNode(const string &name); + INLINE explicit SequenceNode(const std::string &name); protected: SequenceNode(const SequenceNode ©); @@ -45,7 +45,7 @@ public: virtual bool has_single_child_visibility() const; virtual int get_visible_child() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; public: static void register_with_read_factory(); diff --git a/panda/src/pgraphnodes/shaderGenerator.h b/panda/src/pgraphnodes/shaderGenerator.h index 66077c4af8..a3d37c4ad9 100644 --- a/panda/src/pgraphnodes/shaderGenerator.h +++ b/panda/src/pgraphnodes/shaderGenerator.h @@ -168,9 +168,9 @@ protected: void analyze_renderstate(ShaderKey &key, const RenderState *rs); - static string combine_mode_as_string(const ShaderKey::TextureInfo &info, + static std::string combine_mode_as_string(const ShaderKey::TextureInfo &info, TextureStage::CombineMode c_mode, bool alpha, short texindex); - static string combine_source_as_string(const ShaderKey::TextureInfo &info, + static std::string combine_source_as_string(const ShaderKey::TextureInfo &info, short num, bool alpha, short texindex); static const char *texture_type_as_string(Texture::TextureType ttype); diff --git a/panda/src/pgraphnodes/sphereLight.h b/panda/src/pgraphnodes/sphereLight.h index 7efddb9b50..d4b1fb1c32 100644 --- a/panda/src/pgraphnodes/sphereLight.h +++ b/panda/src/pgraphnodes/sphereLight.h @@ -25,7 +25,7 @@ */ class EXPCL_PANDA_PGRAPHNODES SphereLight : public PointLight { PUBLISHED: - explicit SphereLight(const string &name); + explicit SphereLight(const std::string &name); protected: SphereLight(const SphereLight ©); @@ -33,7 +33,7 @@ protected: public: virtual PandaNode *make_copy() const; virtual void xform(const LMatrix4 &mat); - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; PUBLISHED: INLINE PN_stdfloat get_radius() const; diff --git a/panda/src/pgraphnodes/spotlight.h b/panda/src/pgraphnodes/spotlight.h index d1e56a88b3..a529f1479e 100644 --- a/panda/src/pgraphnodes/spotlight.h +++ b/panda/src/pgraphnodes/spotlight.h @@ -31,7 +31,7 @@ */ class EXPCL_PANDA_PGRAPHNODES Spotlight : public LightLensNode { PUBLISHED: - Spotlight(const string &name); + Spotlight(const std::string &name); protected: Spotlight(const Spotlight ©); @@ -39,7 +39,7 @@ protected: public: virtual PandaNode *make_copy() const; virtual void xform(const LMatrix4 &mat); - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; virtual bool get_vector_to_light(LVector3 &result, const LPoint3 &from_object_point, @@ -127,7 +127,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const Spotlight &light) { +INLINE std::ostream &operator << (std::ostream &out, const Spotlight &light) { light.output(out); return out; } diff --git a/panda/src/pgraphnodes/switchNode.I b/panda/src/pgraphnodes/switchNode.I index 451ec655df..b7943210dc 100644 --- a/panda/src/pgraphnodes/switchNode.I +++ b/panda/src/pgraphnodes/switchNode.I @@ -32,7 +32,7 @@ CData(const SwitchNode::CData ©) : * */ INLINE SwitchNode:: -SwitchNode(const string &name) : +SwitchNode(const std::string &name) : SelectiveChildNode(name) { set_cull_callback(); diff --git a/panda/src/pgraphnodes/switchNode.h b/panda/src/pgraphnodes/switchNode.h index b2fefd7750..2df989cbd7 100644 --- a/panda/src/pgraphnodes/switchNode.h +++ b/panda/src/pgraphnodes/switchNode.h @@ -24,7 +24,7 @@ */ class EXPCL_PANDA_PGRAPHNODES SwitchNode : public SelectiveChildNode { PUBLISHED: - INLINE explicit SwitchNode(const string &name); + INLINE explicit SwitchNode(const std::string &name); public: SwitchNode(const SwitchNode ©); diff --git a/panda/src/pgraphnodes/uvScrollNode.I b/panda/src/pgraphnodes/uvScrollNode.I index 3fb849edc9..893f76e2cc 100644 --- a/panda/src/pgraphnodes/uvScrollNode.I +++ b/panda/src/pgraphnodes/uvScrollNode.I @@ -15,7 +15,7 @@ * */ INLINE UvScrollNode:: -UvScrollNode(const string &name, PN_stdfloat u_speed, PN_stdfloat v_speed, PN_stdfloat w_speed, PN_stdfloat r_speed) : +UvScrollNode(const std::string &name, PN_stdfloat u_speed, PN_stdfloat v_speed, PN_stdfloat w_speed, PN_stdfloat r_speed) : PandaNode(name), _u_speed(u_speed), _v_speed(v_speed), @@ -30,7 +30,7 @@ UvScrollNode(const string &name, PN_stdfloat u_speed, PN_stdfloat v_speed, PN_st * */ INLINE UvScrollNode:: -UvScrollNode(const string &name) : +UvScrollNode(const std::string &name) : PandaNode(name), _u_speed(0), _v_speed(0), diff --git a/panda/src/pgraphnodes/uvScrollNode.h b/panda/src/pgraphnodes/uvScrollNode.h index 10dff152b7..ac4c29b643 100644 --- a/panda/src/pgraphnodes/uvScrollNode.h +++ b/panda/src/pgraphnodes/uvScrollNode.h @@ -25,8 +25,8 @@ */ class EXPCL_PANDA_PGRAPH UvScrollNode : public PandaNode { PUBLISHED: - INLINE explicit UvScrollNode(const string &name, PN_stdfloat u_speed, PN_stdfloat v_speed, PN_stdfloat w_speed, PN_stdfloat r_speed); - INLINE explicit UvScrollNode(const string &name); + INLINE explicit UvScrollNode(const std::string &name, PN_stdfloat u_speed, PN_stdfloat v_speed, PN_stdfloat w_speed, PN_stdfloat r_speed); + INLINE explicit UvScrollNode(const std::string &name); protected: INLINE UvScrollNode(const UvScrollNode ©); diff --git a/panda/src/pgui/pgButton.I b/panda/src/pgui/pgButton.I index ab7f44f503..a4939634fe 100644 --- a/panda/src/pgui/pgButton.I +++ b/panda/src/pgui/pgButton.I @@ -61,7 +61,7 @@ setup(const NodePath &ready, const NodePath &depressed, * PGButtons. The click event is the concatenation of this string followed by * get_id(). */ -INLINE string PGButton:: +INLINE std::string PGButton:: get_click_prefix() { return "click-"; } @@ -70,7 +70,7 @@ get_click_prefix() { * Returns the event name that will be thrown when the button is clicked * normally. */ -INLINE string PGButton:: +INLINE std::string PGButton:: get_click_event(const ButtonHandle &button) const { LightReMutexHolder holder(_lock); return get_click_prefix() + button.get_name() + "-" + get_id(); diff --git a/panda/src/pgui/pgButton.h b/panda/src/pgui/pgButton.h index ece2359762..3405f5b5d1 100644 --- a/panda/src/pgui/pgButton.h +++ b/panda/src/pgui/pgButton.h @@ -28,7 +28,7 @@ */ class EXPCL_PANDA_PGUI PGButton : public PGItem { PUBLISHED: - explicit PGButton(const string &name); + explicit PGButton(const std::string &name); virtual ~PGButton(); protected: @@ -55,7 +55,7 @@ PUBLISHED: S_inactive }; - void setup(const string &label, PN_stdfloat bevel = 0.1f); + void setup(const std::string &label, PN_stdfloat bevel = 0.1f); INLINE void setup(const NodePath &ready); INLINE void setup(const NodePath &ready, const NodePath &depressed); INLINE void setup(const NodePath &ready, const NodePath &depressed, @@ -71,8 +71,8 @@ PUBLISHED: INLINE bool is_button_down(); - INLINE static string get_click_prefix(); - INLINE string get_click_event(const ButtonHandle &button) const; + INLINE static std::string get_click_prefix(); + INLINE std::string get_click_event(const ButtonHandle &button) const; MAKE_PROPERTY(click_prefix, get_click_prefix); private: diff --git a/panda/src/pgui/pgEntry.I b/panda/src/pgui/pgEntry.I index 2e15320b8f..7f76e3ef63 100644 --- a/panda/src/pgui/pgEntry.I +++ b/panda/src/pgui/pgEntry.I @@ -20,7 +20,7 @@ * truncated (see set_max_width(), etc.). */ INLINE bool PGEntry:: -set_text(const string &text) { +set_text(const std::string &text) { LightReMutexHolder holder(_lock); TextNode *text_node = get_text_def(S_focus); nassertr(text_node != nullptr, false); @@ -34,11 +34,11 @@ set_text(const string &text) { * This uses the Unicode encoding currently specified for the "focus" * TextNode; therefore, the TextNode must exist before calling get_text(). */ -INLINE string PGEntry:: +INLINE std::string PGEntry:: get_plain_text() const { LightReMutexHolder holder(_lock); TextNode *text_node = get_text_def(S_focus); - nassertr(text_node != nullptr, string()); + nassertr(text_node != nullptr, std::string()); return text_node->encode_wtext(get_plain_wtext()); } @@ -47,11 +47,11 @@ get_plain_text() const { * Unicode encoding currently specified for the "focus" TextNode; therefore, * the TextNode must exist before calling get_text(). */ -INLINE string PGEntry:: +INLINE std::string PGEntry:: get_text() const { LightReMutexHolder holder(_lock); TextNode *text_node = get_text_def(S_focus); - nassertr(text_node != nullptr, string()); + nassertr(text_node != nullptr, std::string()); return text_node->encode_wtext(get_wtext()); } @@ -350,7 +350,7 @@ get_overflow_mode() const { * candidate string that the user can actively scroll through. */ INLINE void PGEntry:: -set_candidate_active(const string &candidate_active) { +set_candidate_active(const std::string &candidate_active) { LightReMutexHolder holder(_lock); _candidate_active = candidate_active; } @@ -358,7 +358,7 @@ set_candidate_active(const string &candidate_active) { /** * See set_candidate_active(). */ -INLINE const string &PGEntry:: +INLINE const std::string &PGEntry:: get_candidate_active() const { LightReMutexHolder holder(_lock); return _candidate_active; @@ -377,7 +377,7 @@ get_candidate_active() const { * candidate string that the user is not actively scrolling through. */ INLINE void PGEntry:: -set_candidate_inactive(const string &candidate_inactive) { +set_candidate_inactive(const std::string &candidate_inactive) { LightReMutexHolder holder(_lock); _candidate_inactive = candidate_inactive; } @@ -385,7 +385,7 @@ set_candidate_inactive(const string &candidate_inactive) { /** * See set_candidate_inactive(). */ -INLINE const string &PGEntry:: +INLINE const std::string &PGEntry:: get_candidate_inactive() const { LightReMutexHolder holder(_lock); return _candidate_inactive; @@ -396,7 +396,7 @@ get_candidate_inactive() const { * PGEntries. The accept event is the concatenation of this string followed * by get_id(). */ -INLINE string PGEntry:: +INLINE std::string PGEntry:: get_accept_prefix() { return "accept-"; } @@ -406,7 +406,7 @@ get_accept_prefix() { * PGEntries. This event is the concatenation of this string followed by * get_id(). */ -INLINE string PGEntry:: +INLINE std::string PGEntry:: get_accept_failed_prefix() { return "acceptfailed-"; } @@ -416,7 +416,7 @@ get_accept_failed_prefix() { * PGEntries. The overflow event is the concatenation of this string followed * by get_id(). */ -INLINE string PGEntry:: +INLINE std::string PGEntry:: get_overflow_prefix() { return "overflow-"; } @@ -425,7 +425,7 @@ get_overflow_prefix() { * Returns the prefix that is used to define the type event for all PGEntries. * The type event is the concatenation of this string followed by get_id(). */ -INLINE string PGEntry:: +INLINE std::string PGEntry:: get_type_prefix() { return "type-"; } @@ -435,7 +435,7 @@ get_type_prefix() { * PGEntries. The erase event is the concatenation of this string followed by * get_id(). */ -INLINE string PGEntry:: +INLINE std::string PGEntry:: get_erase_prefix() { return "erase-"; } @@ -445,7 +445,7 @@ get_erase_prefix() { * PGEntries. The cursor event is the concatenation of this string followed * by get_id(). */ -INLINE string PGEntry:: +INLINE std::string PGEntry:: get_cursormove_prefix() { return "cursormove-"; } @@ -454,7 +454,7 @@ get_cursormove_prefix() { * Returns the event name that will be thrown when the entry is accepted * normally. */ -INLINE string PGEntry:: +INLINE std::string PGEntry:: get_accept_event(const ButtonHandle &button) const { return get_accept_prefix() + button.get_name() + "-" + get_id(); } @@ -463,7 +463,7 @@ get_accept_event(const ButtonHandle &button) const { * Returns the event name that will be thrown when the entry cannot accept an * input */ -INLINE string PGEntry:: +INLINE std::string PGEntry:: get_accept_failed_event(const ButtonHandle &button) const { return get_accept_failed_prefix() + button.get_name() + "-" + get_id(); } @@ -473,7 +473,7 @@ get_accept_failed_event(const ButtonHandle &button) const { * to be entered into the PGEntry, exceeding either the limit set via * set_max_chars() or via set_max_width(). */ -INLINE string PGEntry:: +INLINE std::string PGEntry:: get_overflow_event() const { return get_overflow_prefix() + get_id(); } @@ -482,7 +482,7 @@ get_overflow_event() const { * Returns the event name that will be thrown whenever the user extends the * text by typing. */ -INLINE string PGEntry:: +INLINE std::string PGEntry:: get_type_event() const { return get_type_prefix() + get_id(); } @@ -491,7 +491,7 @@ get_type_event() const { * Returns the event name that will be thrown whenever the user erases * characters in the text. */ -INLINE string PGEntry:: +INLINE std::string PGEntry:: get_erase_event() const { return get_erase_prefix() + get_id(); } @@ -499,7 +499,7 @@ get_erase_event() const { /** * Returns the event name that will be thrown whenever the cursor moves */ -INLINE string PGEntry:: +INLINE std::string PGEntry:: get_cursormove_event() const { return get_cursormove_prefix() + get_id(); } @@ -511,14 +511,14 @@ get_cursormove_event() const { * truncated (see set_max_width(), etc.). */ INLINE bool PGEntry:: -set_wtext(const wstring &wtext) { +set_wtext(const std::wstring &wtext) { LightReMutexHolder holder(_lock); bool ret = _text.set_wtext(wtext); if (_obscure_mode) { - ret = _obscure_text.set_wtext(wstring(_text.get_num_characters(), '*')); + ret = _obscure_text.set_wtext(std::wstring(_text.get_num_characters(), '*')); } _text_geom_stale = true; - set_cursor_position(min(_cursor_position, _text.get_num_characters())); + set_cursor_position(std::min(_cursor_position, _text.get_num_characters())); return ret; } @@ -526,7 +526,7 @@ set_wtext(const wstring &wtext) { * Returns the text currently displayed within the entry, without any embedded * properties characters. */ -INLINE wstring PGEntry:: +INLINE std::wstring PGEntry:: get_plain_wtext() const { LightReMutexHolder holder(_lock); return _text.get_plain_wtext(); @@ -535,7 +535,7 @@ get_plain_wtext() const { /** * Returns the text currently displayed within the entry. */ -INLINE wstring PGEntry:: +INLINE std::wstring PGEntry:: get_wtext() const { LightReMutexHolder holder(_lock); return _text.get_wtext(); diff --git a/panda/src/pgui/pgEntry.h b/panda/src/pgui/pgEntry.h index 88fd5aaa89..825562aa82 100644 --- a/panda/src/pgui/pgEntry.h +++ b/panda/src/pgui/pgEntry.h @@ -36,7 +36,7 @@ */ class EXPCL_PANDA_PGUI PGEntry : public PGItem { PUBLISHED: - explicit PGEntry(const string &name); + explicit PGEntry(const std::string &name); virtual ~PGEntry(); protected: @@ -68,9 +68,9 @@ PUBLISHED: void setup(PN_stdfloat width, int num_lines); void setup_minimal(PN_stdfloat width, int num_lines); - INLINE bool set_text(const string &text); - INLINE string get_plain_text() const; - INLINE string get_text() const; + INLINE bool set_text(const std::string &text); + INLINE std::string get_plain_text() const; + INLINE std::string get_text() const; INLINE int get_num_characters() const; INLINE wchar_t get_character(int n) const; @@ -105,11 +105,11 @@ PUBLISHED: INLINE void set_overflow_mode(bool flag); INLINE bool get_overflow_mode() const; - INLINE void set_candidate_active(const string &candidate_active); - INLINE const string &get_candidate_active() const; + INLINE void set_candidate_active(const std::string &candidate_active); + INLINE const std::string &get_candidate_active() const; - INLINE void set_candidate_inactive(const string &candidate_inactive); - INLINE const string &get_candidate_inactive() const; + INLINE void set_candidate_inactive(const std::string &candidate_inactive); + INLINE const std::string &get_candidate_inactive() const; void set_text_def(int state, TextNode *node); TextNode *get_text_def(int state) const; @@ -117,24 +117,24 @@ PUBLISHED: virtual void set_active(bool active); virtual void set_focus(bool focus); - INLINE static string get_accept_prefix(); - INLINE static string get_accept_failed_prefix(); - INLINE static string get_overflow_prefix(); - INLINE static string get_type_prefix(); - INLINE static string get_erase_prefix(); - INLINE static string get_cursormove_prefix(); + INLINE static std::string get_accept_prefix(); + INLINE static std::string get_accept_failed_prefix(); + INLINE static std::string get_overflow_prefix(); + INLINE static std::string get_type_prefix(); + INLINE static std::string get_erase_prefix(); + INLINE static std::string get_cursormove_prefix(); - INLINE string get_accept_event(const ButtonHandle &button) const; - INLINE string get_accept_failed_event(const ButtonHandle &button) const; - INLINE string get_overflow_event() const; - INLINE string get_type_event() const; - INLINE string get_erase_event() const; - INLINE string get_cursormove_event() const; + INLINE std::string get_accept_event(const ButtonHandle &button) const; + INLINE std::string get_accept_failed_event(const ButtonHandle &button) const; + INLINE std::string get_overflow_event() const; + INLINE std::string get_type_event() const; + INLINE std::string get_erase_event() const; + INLINE std::string get_cursormove_event() const; - INLINE bool set_wtext(const wstring &wtext); - INLINE wstring get_plain_wtext() const; - INLINE wstring get_wtext() const; + INLINE bool set_wtext(const std::wstring &wtext); + INLINE std::wstring get_plain_wtext() const; + INLINE std::wstring get_wtext() const; INLINE void set_accept_enabled(bool enabled); bool is_wtext() const; @@ -152,7 +152,7 @@ private: bool _cursor_stale; bool _cursor_visible; - wstring _candidate_wtext; + std::wstring _candidate_wtext; size_t _candidate_highlight_start; size_t _candidate_highlight_end; size_t _candidate_cursor_pos; @@ -163,8 +163,8 @@ private: bool _accept_enabled; - string _candidate_active; - string _candidate_inactive; + std::string _candidate_active; + std::string _candidate_inactive; typedef pvector< PT(TextNode) > TextDefs; TextDefs _text_defs; diff --git a/panda/src/pgui/pgFrameStyle.I b/panda/src/pgui/pgFrameStyle.I index 2882d73935..8a5f31250a 100644 --- a/panda/src/pgui/pgFrameStyle.I +++ b/panda/src/pgui/pgFrameStyle.I @@ -222,8 +222,8 @@ get_visible_scale() const { /** * */ -INLINE ostream & -operator << (ostream &out, const PGFrameStyle &pfs) { +INLINE std::ostream & +operator << (std::ostream &out, const PGFrameStyle &pfs) { pfs.output(out); return out; } diff --git a/panda/src/pgui/pgFrameStyle.h b/panda/src/pgui/pgFrameStyle.h index 107b217192..19283c962f 100644 --- a/panda/src/pgui/pgFrameStyle.h +++ b/panda/src/pgui/pgFrameStyle.h @@ -70,7 +70,7 @@ PUBLISHED: LVecBase4 get_internal_frame(const LVecBase4 &frame) const; - void output(ostream &out) const; + void output(std::ostream &out) const; public: bool xform(const LMatrix4 &mat); @@ -92,8 +92,8 @@ private: LVecBase2 _visible_scale; }; -INLINE ostream &operator << (ostream &out, const PGFrameStyle &pfs); -ostream &operator << (ostream &out, PGFrameStyle::Type type); +INLINE std::ostream &operator << (std::ostream &out, const PGFrameStyle &pfs); +std::ostream &operator << (std::ostream &out, PGFrameStyle::Type type); #include "pgFrameStyle.I" diff --git a/panda/src/pgui/pgItem.I b/panda/src/pgui/pgItem.I index ce2c9f0532..f60e4a256c 100644 --- a/panda/src/pgui/pgItem.I +++ b/panda/src/pgui/pgItem.I @@ -15,7 +15,7 @@ * */ INLINE void PGItem:: -set_name(const string &name) { +set_name(const std::string &name) { Namable::set_name(name); _lock.set_name(name); } @@ -207,7 +207,7 @@ get_suppress_flags() const { * the region created with the MouseWatcher, and will thus be used to generate * event names. */ -INLINE const string &PGItem:: +INLINE const std::string &PGItem:: get_id() const { LightReMutexHolder holder(_lock); return _region->get_name(); @@ -222,7 +222,7 @@ get_id() const { * decide to redefine the ID to be something possibly more meaningful. */ INLINE void PGItem:: -set_id(const string &id) { +set_id(const std::string &id) { LightReMutexHolder holder(_lock); _region->set_name(id); } @@ -231,7 +231,7 @@ set_id(const string &id) { * Returns the prefix that is used to define the enter event for all PGItems. * The enter event is the concatenation of this string followed by get_id(). */ -INLINE string PGItem:: +INLINE std::string PGItem:: get_enter_prefix() { return "enter-"; } @@ -240,7 +240,7 @@ get_enter_prefix() { * Returns the prefix that is used to define the exit event for all PGItems. * The exit event is the concatenation of this string followed by get_id(). */ -INLINE string PGItem:: +INLINE std::string PGItem:: get_exit_prefix() { return "exit-"; } @@ -249,7 +249,7 @@ get_exit_prefix() { * Returns the prefix that is used to define the within event for all PGItems. * The within event is the concatenation of this string followed by get_id(). */ -INLINE string PGItem:: +INLINE std::string PGItem:: get_within_prefix() { return "within-"; } @@ -259,7 +259,7 @@ get_within_prefix() { * PGItems. The without event is the concatenation of this string followed by * get_id(). */ -INLINE string PGItem:: +INLINE std::string PGItem:: get_without_prefix() { return "without-"; } @@ -271,7 +271,7 @@ get_without_prefix() { * * Unlike most item events, this event is thrown with no parameters. */ -INLINE string PGItem:: +INLINE std::string PGItem:: get_focus_in_prefix() { return "fin-"; } @@ -283,7 +283,7 @@ get_focus_in_prefix() { * * Unlike most item events, this event is thrown with no parameters. */ -INLINE string PGItem:: +INLINE std::string PGItem:: get_focus_out_prefix() { return "fout-"; } @@ -293,7 +293,7 @@ get_focus_out_prefix() { * The press event is the concatenation of this string followed by a button * name, followed by a hyphen and get_id(). */ -INLINE string PGItem:: +INLINE std::string PGItem:: get_press_prefix() { return "press-"; } @@ -303,7 +303,7 @@ get_press_prefix() { * The repeat event is the concatenation of this string followed by a button * name, followed by a hyphen and get_id(). */ -INLINE string PGItem:: +INLINE std::string PGItem:: get_repeat_prefix() { return "repeat-"; } @@ -313,7 +313,7 @@ get_repeat_prefix() { * PGItems. The release event is the concatenation of this string followed by * a button name, followed by a hyphen and get_id(). */ -INLINE string PGItem:: +INLINE std::string PGItem:: get_release_prefix() { return "release-"; } @@ -323,7 +323,7 @@ get_release_prefix() { * PGItems. The keystroke event is the concatenation of this string followed * by a hyphen and get_id(). */ -INLINE string PGItem:: +INLINE std::string PGItem:: get_keystroke_prefix() { return "keystroke-"; } @@ -332,7 +332,7 @@ get_keystroke_prefix() { * Returns the event name that will be thrown when the item is active and the * mouse enters its frame, but not any nested frames. */ -INLINE string PGItem:: +INLINE std::string PGItem:: get_enter_event() const { LightReMutexHolder holder(_lock); return get_enter_prefix() + get_id(); @@ -342,7 +342,7 @@ get_enter_event() const { * Returns the event name that will be thrown when the item is active and the * mouse exits its frame, or enters a nested frame. */ -INLINE string PGItem:: +INLINE std::string PGItem:: get_exit_event() const { LightReMutexHolder holder(_lock); return get_exit_prefix() + get_id(); @@ -354,7 +354,7 @@ get_exit_event() const { * enter_event in that the mouse is considered within the frame even if it is * also within a nested frame. */ -INLINE string PGItem:: +INLINE std::string PGItem:: get_within_event() const { LightReMutexHolder holder(_lock); return get_within_prefix() + get_id(); @@ -366,7 +366,7 @@ get_within_event() const { * different from the exit_event in that the mouse is considered within the * frame even if it is also within a nested frame. */ -INLINE string PGItem:: +INLINE std::string PGItem:: get_without_event() const { LightReMutexHolder holder(_lock); return get_without_prefix() + get_id(); @@ -376,7 +376,7 @@ get_without_event() const { * Returns the event name that will be thrown when the item gets the keyboard * focus. */ -INLINE string PGItem:: +INLINE std::string PGItem:: get_focus_in_event() const { LightReMutexHolder holder(_lock); return get_focus_in_prefix() + get_id(); @@ -386,7 +386,7 @@ get_focus_in_event() const { * Returns the event name that will be thrown when the item loses the keyboard * focus. */ -INLINE string PGItem:: +INLINE std::string PGItem:: get_focus_out_event() const { LightReMutexHolder holder(_lock); return get_focus_out_prefix() + get_id(); @@ -397,7 +397,7 @@ get_focus_out_event() const { * indicated mouse or keyboard button is depressed while the mouse is within * the frame. */ -INLINE string PGItem:: +INLINE std::string PGItem:: get_press_event(const ButtonHandle &button) const { LightReMutexHolder holder(_lock); return get_press_prefix() + button.get_name() + "-" + get_id(); @@ -408,7 +408,7 @@ get_press_event(const ButtonHandle &button) const { * indicated mouse or keyboard button is continuously held down while the * mouse is within the frame. */ -INLINE string PGItem:: +INLINE std::string PGItem:: get_repeat_event(const ButtonHandle &button) const { LightReMutexHolder holder(_lock); return get_repeat_prefix() + button.get_name() + "-" + get_id(); @@ -419,7 +419,7 @@ get_repeat_event(const ButtonHandle &button) const { * indicated mouse or keyboard button, formerly clicked down is within the * frame, is released. */ -INLINE string PGItem:: +INLINE std::string PGItem:: get_release_event(const ButtonHandle &button) const { LightReMutexHolder holder(_lock); return get_release_prefix() + button.get_name() + "-" + get_id(); @@ -429,7 +429,7 @@ get_release_event(const ButtonHandle &button) const { * Returns the event name that will be thrown when the item is active and any * key is pressed by the user. */ -INLINE string PGItem:: +INLINE std::string PGItem:: get_keystroke_event() const { LightReMutexHolder holder(_lock); return get_keystroke_prefix() + get_id(); diff --git a/panda/src/pgui/pgItem.h b/panda/src/pgui/pgItem.h index c39103154a..fc7f8ff6d4 100644 --- a/panda/src/pgui/pgItem.h +++ b/panda/src/pgui/pgItem.h @@ -52,10 +52,10 @@ class ScissorAttrib; */ class EXPCL_PANDA_PGUI PGItem : public PandaNode { PUBLISHED: - explicit PGItem(const string &name); + explicit PGItem(const std::string &name); virtual ~PGItem(); - INLINE void set_name(const string &name); + INLINE void set_name(const std::string &name); protected: PGItem(const PGItem ©); @@ -137,38 +137,38 @@ PUBLISHED: PGFrameStyle get_frame_style(int state); void set_frame_style(int state, const PGFrameStyle &style); - INLINE const string &get_id() const; - INLINE void set_id(const string &id); + INLINE const std::string &get_id() const; + INLINE void set_id(const std::string &id); - INLINE static string get_enter_prefix(); - INLINE static string get_exit_prefix(); - INLINE static string get_within_prefix(); - INLINE static string get_without_prefix(); - INLINE static string get_focus_in_prefix(); - INLINE static string get_focus_out_prefix(); - INLINE static string get_press_prefix(); - INLINE static string get_repeat_prefix(); - INLINE static string get_release_prefix(); - INLINE static string get_keystroke_prefix(); + INLINE static std::string get_enter_prefix(); + INLINE static std::string get_exit_prefix(); + INLINE static std::string get_within_prefix(); + INLINE static std::string get_without_prefix(); + INLINE static std::string get_focus_in_prefix(); + INLINE static std::string get_focus_out_prefix(); + INLINE static std::string get_press_prefix(); + INLINE static std::string get_repeat_prefix(); + INLINE static std::string get_release_prefix(); + INLINE static std::string get_keystroke_prefix(); - INLINE string get_enter_event() const; - INLINE string get_exit_event() const; - INLINE string get_within_event() const; - INLINE string get_without_event() const; - INLINE string get_focus_in_event() const; - INLINE string get_focus_out_event() const; - INLINE string get_press_event(const ButtonHandle &button) const; - INLINE string get_repeat_event(const ButtonHandle &button) const; - INLINE string get_release_event(const ButtonHandle &button) const; - INLINE string get_keystroke_event() const; + INLINE std::string get_enter_event() const; + INLINE std::string get_exit_event() const; + INLINE std::string get_within_event() const; + INLINE std::string get_without_event() const; + INLINE std::string get_focus_in_event() const; + INLINE std::string get_focus_out_event() const; + INLINE std::string get_press_event(const ButtonHandle &button) const; + INLINE std::string get_repeat_event(const ButtonHandle &button) const; + INLINE std::string get_release_event(const ButtonHandle &button) const; + INLINE std::string get_keystroke_event() const; INLINE LMatrix4 get_frame_inv_xform() const; #ifdef HAVE_AUDIO - void set_sound(const string &event, AudioSound *sound); - void clear_sound(const string &event); - AudioSound *get_sound(const string &event) const; - bool has_sound(const string &event) const; + void set_sound(const std::string &event, AudioSound *sound); + void clear_sound(const std::string &event); + AudioSound *get_sound(const std::string &event) const; + bool has_sound(const std::string &event) const; #endif static TextNode *get_text_node(); @@ -177,7 +177,7 @@ PUBLISHED: INLINE static PGItem *get_focus_item(); protected: - void play_sound(const string &event); + void play_sound(const std::string &event); void reduce_region(LVecBase4 &clip, PGItem *obscurer) const; void reduce_region(LVecBase4 &frame, PN_stdfloat px, PN_stdfloat py) const; @@ -231,7 +231,7 @@ private: StateDefs _state_defs; #ifdef HAVE_AUDIO - typedef pmap Sounds; + typedef pmap Sounds; Sounds _sounds; #endif diff --git a/panda/src/pgui/pgMouseWatcherParameter.h b/panda/src/pgui/pgMouseWatcherParameter.h index 930d1d55c2..ff8c41cfba 100644 --- a/panda/src/pgui/pgMouseWatcherParameter.h +++ b/panda/src/pgui/pgMouseWatcherParameter.h @@ -37,7 +37,7 @@ public: virtual ~PGMouseWatcherParameter(); PUBLISHED: - void output(ostream &out) const; + void output(std::ostream &out) const; public: static TypeHandle get_class_type() { diff --git a/panda/src/pgui/pgScrollFrame.h b/panda/src/pgui/pgScrollFrame.h index c60a161a78..de01954e0d 100644 --- a/panda/src/pgui/pgScrollFrame.h +++ b/panda/src/pgui/pgScrollFrame.h @@ -34,7 +34,7 @@ */ class EXPCL_PANDA_PGUI PGScrollFrame : public PGVirtualFrame, public PGSliderBarNotify { PUBLISHED: - explicit PGScrollFrame(const string &name = ""); + explicit PGScrollFrame(const std::string &name = ""); virtual ~PGScrollFrame(); protected: diff --git a/panda/src/pgui/pgSliderBar.I b/panda/src/pgui/pgSliderBar.I index 866dd1dec3..da5b97c153 100644 --- a/panda/src/pgui/pgSliderBar.I +++ b/panda/src/pgui/pgSliderBar.I @@ -360,7 +360,7 @@ get_right_button() const { * PGSliderBars. The adjust event is the concatenation of this string * followed by get_id(). */ -INLINE string PGSliderBar:: +INLINE std::string PGSliderBar:: get_adjust_prefix() { return "adjust-"; } @@ -369,7 +369,7 @@ get_adjust_prefix() { * Returns the event name that will be thrown when the slider bar value is * adjusted by the user or programmatically. */ -INLINE string PGSliderBar:: +INLINE std::string PGSliderBar:: get_adjust_event() const { LightReMutexHolder holder(_lock); return get_adjust_prefix() + get_id(); @@ -381,7 +381,7 @@ get_adjust_event() const { */ INLINE void PGSliderBar:: internal_set_ratio(PN_stdfloat ratio) { - _ratio = max(min(ratio, (PN_stdfloat)1.0), (PN_stdfloat)0.0); + _ratio = std::max(std::min(ratio, (PN_stdfloat)1.0), (PN_stdfloat)0.0); _needs_reposition = true; adjust(); } diff --git a/panda/src/pgui/pgSliderBar.h b/panda/src/pgui/pgSliderBar.h index c08a98e172..4049f9aa74 100644 --- a/panda/src/pgui/pgSliderBar.h +++ b/panda/src/pgui/pgSliderBar.h @@ -30,7 +30,7 @@ */ class EXPCL_PANDA_PGUI PGSliderBar : public PGItem, public PGButtonNotify { PUBLISHED: - explicit PGSliderBar(const string &name = ""); + explicit PGSliderBar(const std::string &name = ""); virtual ~PGSliderBar(); protected: @@ -93,8 +93,8 @@ PUBLISHED: INLINE void clear_right_button(); INLINE PGButton *get_right_button() const; - INLINE static string get_adjust_prefix(); - INLINE string get_adjust_event() const; + INLINE static std::string get_adjust_prefix(); + INLINE std::string get_adjust_event() const; virtual void set_active(bool active); diff --git a/panda/src/pgui/pgTop.h b/panda/src/pgui/pgTop.h index 45376e99f5..1d5e739c8e 100644 --- a/panda/src/pgui/pgTop.h +++ b/panda/src/pgui/pgTop.h @@ -37,7 +37,7 @@ class PGMouseWatcherGroup; */ class EXPCL_PANDA_PGUI PGTop : public PandaNode { PUBLISHED: - explicit PGTop(const string &name); + explicit PGTop(const std::string &name); virtual ~PGTop(); protected: diff --git a/panda/src/pgui/pgVirtualFrame.h b/panda/src/pgui/pgVirtualFrame.h index d6505faaaa..c8aff4fca6 100644 --- a/panda/src/pgui/pgVirtualFrame.h +++ b/panda/src/pgui/pgVirtualFrame.h @@ -42,7 +42,7 @@ class TransformState; */ class EXPCL_PANDA_PGUI PGVirtualFrame : public PGItem { PUBLISHED: - explicit PGVirtualFrame(const string &name = ""); + explicit PGVirtualFrame(const std::string &name = ""); virtual ~PGVirtualFrame(); protected: diff --git a/panda/src/pgui/pgWaitBar.h b/panda/src/pgui/pgWaitBar.h index 92381870dd..9f8415d28c 100644 --- a/panda/src/pgui/pgWaitBar.h +++ b/panda/src/pgui/pgWaitBar.h @@ -25,7 +25,7 @@ */ class EXPCL_PANDA_PGUI PGWaitBar : public PGItem { PUBLISHED: - explicit PGWaitBar(const string &name = ""); + explicit PGWaitBar(const std::string &name = ""); virtual ~PGWaitBar(); protected: diff --git a/panda/src/physics/actorNode.h b/panda/src/physics/actorNode.h index bfa4ffff66..17e704a3ce 100644 --- a/panda/src/physics/actorNode.h +++ b/panda/src/physics/actorNode.h @@ -25,7 +25,7 @@ */ class EXPCL_PANDAPHYSICS ActorNode : public PhysicalNode { PUBLISHED: - explicit ActorNode(const string &name = ""); + explicit ActorNode(const std::string &name = ""); ActorNode(const ActorNode ©); virtual ~ActorNode(); @@ -39,7 +39,7 @@ PUBLISHED: void update_transform(); void set_transform_limit(PN_stdfloat limit) { _transform_limit = limit; }; - virtual void write(ostream &out, int indent=0) const; + virtual void write(std::ostream &out, int indent=0) const; private: PhysicsObject *_mass_center; diff --git a/panda/src/physics/angularEulerIntegrator.h b/panda/src/physics/angularEulerIntegrator.h index 3e0790950c..aa9cc71a78 100644 --- a/panda/src/physics/angularEulerIntegrator.h +++ b/panda/src/physics/angularEulerIntegrator.h @@ -25,8 +25,8 @@ PUBLISHED: AngularEulerIntegrator(); virtual ~AngularEulerIntegrator(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: virtual void child_integrate(Physical *physical, diff --git a/panda/src/physics/angularForce.h b/panda/src/physics/angularForce.h index 8ee5974716..85d6b09a1a 100644 --- a/panda/src/physics/angularForce.h +++ b/panda/src/physics/angularForce.h @@ -27,8 +27,8 @@ PUBLISHED: LRotation get_quat(const PhysicsObject *po); virtual bool is_linear() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; protected: AngularForce(); diff --git a/panda/src/physics/angularIntegrator.h b/panda/src/physics/angularIntegrator.h index 5ca3fd729a..0accd60014 100644 --- a/panda/src/physics/angularIntegrator.h +++ b/panda/src/physics/angularIntegrator.h @@ -31,8 +31,8 @@ public: PN_stdfloat dt); PUBLISHED: - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; protected: AngularIntegrator(); diff --git a/panda/src/physics/angularVectorForce.h b/panda/src/physics/angularVectorForce.h index f42c2f0c81..3560f67db0 100644 --- a/panda/src/physics/angularVectorForce.h +++ b/panda/src/physics/angularVectorForce.h @@ -31,8 +31,8 @@ PUBLISHED: INLINE void set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); INLINE LRotation get_local_quat() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: LRotation _fvec; diff --git a/panda/src/physics/baseForce.h b/panda/src/physics/baseForce.h index 90d510013b..9d046596a3 100644 --- a/panda/src/physics/baseForce.h +++ b/panda/src/physics/baseForce.h @@ -37,8 +37,8 @@ PUBLISHED: INLINE ForceNode *get_force_node() const; INLINE NodePath get_force_node_path() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level=0) const; protected: BaseForce(bool active = true); diff --git a/panda/src/physics/baseIntegrator.h b/panda/src/physics/baseIntegrator.h index 9d134fa2ee..528f882021 100644 --- a/panda/src/physics/baseIntegrator.h +++ b/panda/src/physics/baseIntegrator.h @@ -40,12 +40,12 @@ public: virtual ~BaseIntegrator(); PUBLISHED: - virtual void output(ostream &out) const; - virtual void write_precomputed_linear_matrices(ostream &out, + virtual void output(std::ostream &out) const; + virtual void write_precomputed_linear_matrices(std::ostream &out, int indent=0) const; - virtual void write_precomputed_angular_matrices(ostream &out, + virtual void write_precomputed_angular_matrices(std::ostream &out, int indent=0) const; - virtual void write(ostream &out, int indent=0) const; + virtual void write(std::ostream &out, int indent=0) const; protected: BaseIntegrator(); diff --git a/panda/src/physics/config_physics.h b/panda/src/physics/config_physics.h index 5b7249d159..cfbbe5146b 100644 --- a/panda/src/physics/config_physics.h +++ b/panda/src/physics/config_physics.h @@ -32,22 +32,22 @@ extern EXPCL_PANDAPHYSICS void init_libphysics(); #define physics_spam(msg) \ if (physics_cat.is_spam()) { \ - physics_cat->spam() << msg << endl; \ + physics_cat->spam() << msg << std::endl; \ } else {} #define physics_debug(msg) \ if (physics_cat.is_debug()) { \ - physics_cat->debug() << msg << endl; \ + physics_cat->debug() << msg << std::endl; \ } else {} #define physics_info(msg) \ - physics_cat->info() << msg << endl + physics_cat->info() << msg << std::endl #define physics_warning(msg) \ - physics_cat->warning() << msg << endl + physics_cat->warning() << msg << std::endl #define physics_error(msg) \ - physics_cat->error() << msg << endl + physics_cat->error() << msg << std::endl #else //][ // Release build: #undef PHYSICS_DEBUG @@ -60,6 +60,6 @@ extern EXPCL_PANDAPHYSICS void init_libphysics(); #endif //] #define audio_error(msg) \ - audio_cat->error() << msg << endl + audio_cat->error() << msg << std::endl #endif // CONFIG_PHYSICS_H diff --git a/panda/src/physics/forceNode.h b/panda/src/physics/forceNode.h index 3c46ab3d6e..851b54259b 100644 --- a/panda/src/physics/forceNode.h +++ b/panda/src/physics/forceNode.h @@ -26,7 +26,7 @@ */ class EXPCL_PANDAPHYSICS ForceNode : public PandaNode { PUBLISHED: - explicit ForceNode(const string &name); + explicit ForceNode(const std::string &name); INLINE void clear(); INLINE BaseForce *get_force(size_t index) const; INLINE size_t get_num_forces() const; @@ -41,9 +41,9 @@ PUBLISHED: MAKE_SEQ_PROPERTY(forces, get_num_forces, get_force, set_force, remove_force, insert_force); - virtual void output(ostream &out) const; - virtual void write_forces(ostream &out, int indent=0) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write_forces(std::ostream &out, int indent=0) const; + virtual void write(std::ostream &out, int indent=0) const; public: virtual ~ForceNode(); diff --git a/panda/src/physics/linearControlForce.h b/panda/src/physics/linearControlForce.h index b1a28a5405..e769abbaa8 100644 --- a/panda/src/physics/linearControlForce.h +++ b/panda/src/physics/linearControlForce.h @@ -38,8 +38,8 @@ PUBLISHED: INLINE LVector3 get_local_vector() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: CPT(PhysicsObject) _physics_object; diff --git a/panda/src/physics/linearCylinderVortexForce.h b/panda/src/physics/linearCylinderVortexForce.h index e04328580f..d41b4b638a 100644 --- a/panda/src/physics/linearCylinderVortexForce.h +++ b/panda/src/physics/linearCylinderVortexForce.h @@ -42,8 +42,8 @@ PUBLISHED: INLINE void set_length(PN_stdfloat length); INLINE PN_stdfloat get_length() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: PN_stdfloat _radius; diff --git a/panda/src/physics/linearDistanceForce.h b/panda/src/physics/linearDistanceForce.h index 208fc38bfd..52f30411d4 100644 --- a/panda/src/physics/linearDistanceForce.h +++ b/panda/src/physics/linearDistanceForce.h @@ -39,8 +39,8 @@ PUBLISHED: INLINE PN_stdfloat get_scalar_term() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: LPoint3 _force_center; diff --git a/panda/src/physics/linearEulerIntegrator.h b/panda/src/physics/linearEulerIntegrator.h index 566c16d1d2..69c6d67649 100644 --- a/panda/src/physics/linearEulerIntegrator.h +++ b/panda/src/physics/linearEulerIntegrator.h @@ -25,8 +25,8 @@ PUBLISHED: LinearEulerIntegrator(); virtual ~LinearEulerIntegrator(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: virtual void child_integrate(Physical *physical, diff --git a/panda/src/physics/linearForce.h b/panda/src/physics/linearForce.h index b102b5f330..a3208d6e90 100644 --- a/panda/src/physics/linearForce.h +++ b/panda/src/physics/linearForce.h @@ -39,8 +39,8 @@ PUBLISHED: virtual bool is_linear() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; protected: LinearForce(PN_stdfloat a, bool mass); diff --git a/panda/src/physics/linearFrictionForce.h b/panda/src/physics/linearFrictionForce.h index 6e58b6d332..7a3dd86bef 100644 --- a/panda/src/physics/linearFrictionForce.h +++ b/panda/src/physics/linearFrictionForce.h @@ -28,8 +28,8 @@ PUBLISHED: INLINE void set_coef(PN_stdfloat coef); INLINE PN_stdfloat get_coef() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: PN_stdfloat _coef; diff --git a/panda/src/physics/linearIntegrator.h b/panda/src/physics/linearIntegrator.h index 85d717677b..4d0eca841b 100644 --- a/panda/src/physics/linearIntegrator.h +++ b/panda/src/physics/linearIntegrator.h @@ -32,8 +32,8 @@ public: PN_stdfloat dt); PUBLISHED: - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; protected: LinearIntegrator(); diff --git a/panda/src/physics/linearJitterForce.h b/panda/src/physics/linearJitterForce.h index eba7b0c9ff..79dd49be85 100644 --- a/panda/src/physics/linearJitterForce.h +++ b/panda/src/physics/linearJitterForce.h @@ -26,8 +26,8 @@ PUBLISHED: LinearJitterForce(const LinearJitterForce ©); virtual ~LinearJitterForce(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: virtual LVector3 get_child_vector(const PhysicsObject *po); diff --git a/panda/src/physics/linearNoiseForce.h b/panda/src/physics/linearNoiseForce.h index 74b1ccd2d7..1fae5f1217 100644 --- a/panda/src/physics/linearNoiseForce.h +++ b/panda/src/physics/linearNoiseForce.h @@ -27,8 +27,8 @@ PUBLISHED: LinearNoiseForce(const LinearNoiseForce ©); virtual ~LinearNoiseForce(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; public: static ConfigVariableInt _random_seed; diff --git a/panda/src/physics/linearRandomForce.h b/panda/src/physics/linearRandomForce.h index ad440c034f..7f097ca53a 100644 --- a/panda/src/physics/linearRandomForce.h +++ b/panda/src/physics/linearRandomForce.h @@ -26,8 +26,8 @@ class EXPCL_PANDAPHYSICS LinearRandomForce : public LinearForce { PUBLISHED: virtual ~LinearRandomForce(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; protected: static PN_stdfloat bounded_rand(); diff --git a/panda/src/physics/linearSinkForce.h b/panda/src/physics/linearSinkForce.h index d8127049f1..235085b253 100644 --- a/panda/src/physics/linearSinkForce.h +++ b/panda/src/physics/linearSinkForce.h @@ -27,8 +27,8 @@ PUBLISHED: LinearSinkForce(const LinearSinkForce ©); virtual ~LinearSinkForce(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: virtual LVector3 get_child_vector(const PhysicsObject *po); diff --git a/panda/src/physics/linearSourceForce.h b/panda/src/physics/linearSourceForce.h index 7d757a032f..52af5ee9c6 100644 --- a/panda/src/physics/linearSourceForce.h +++ b/panda/src/physics/linearSourceForce.h @@ -27,8 +27,8 @@ PUBLISHED: LinearSourceForce(const LinearSourceForce ©); virtual ~LinearSourceForce(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: virtual LVector3 get_child_vector(const PhysicsObject *po); diff --git a/panda/src/physics/linearUserDefinedForce.h b/panda/src/physics/linearUserDefinedForce.h index 93051290c2..2908313095 100644 --- a/panda/src/physics/linearUserDefinedForce.h +++ b/panda/src/physics/linearUserDefinedForce.h @@ -28,8 +28,8 @@ PUBLISHED: INLINE void set_proc(LVector3 (*proc)(const PhysicsObject *)); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; private: LVector3 (*_proc)(const PhysicsObject *po); diff --git a/panda/src/physics/linearVectorForce.h b/panda/src/physics/linearVectorForce.h index c0a5cd2ea6..75d624cb64 100644 --- a/panda/src/physics/linearVectorForce.h +++ b/panda/src/physics/linearVectorForce.h @@ -33,8 +33,8 @@ PUBLISHED: INLINE LVector3 get_local_vector() const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent=0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent=0) const; public: INLINE LinearVectorForce& operator += (const LinearVectorForce &other); diff --git a/panda/src/physics/physical.h b/panda/src/physics/physical.h index 8a51e43e51..3ab30e9ee4 100644 --- a/panda/src/physics/physical.h +++ b/panda/src/physics/physical.h @@ -73,14 +73,14 @@ PUBLISHED: const PhysicsObjectCollection get_objects() const; - virtual void output(ostream &out = cout) const; + virtual void output(std::ostream &out = std::cout) const; virtual void write_physics_objects( - ostream &out = cout, int indent=0) const; + std::ostream &out = std::cout, int indent=0) const; virtual void write_linear_forces( - ostream &out = cout, int indent=0) const; + std::ostream &out = std::cout, int indent=0) const; virtual void write_angular_forces( - ostream &out = cout, int indent=0) const; - virtual void write(ostream &out = cout, int indent=0) const; + std::ostream &out = std::cout, int indent=0) const; + virtual void write(std::ostream &out = std::cout, int indent=0) const; public: INLINE const PhysicsObject::Vector &get_object_vector() const; diff --git a/panda/src/physics/physicalNode.h b/panda/src/physics/physicalNode.h index 42f6822dde..57ea5026f6 100644 --- a/panda/src/physics/physicalNode.h +++ b/panda/src/physics/physicalNode.h @@ -27,7 +27,7 @@ */ class EXPCL_PANDAPHYSICS PhysicalNode : public PandaNode { PUBLISHED: - explicit PhysicalNode(const string &name); + explicit PhysicalNode(const std::string &name); INLINE void clear(); INLINE Physical *get_physical(size_t index) const; INLINE size_t get_num_physicals() const; @@ -43,7 +43,7 @@ PUBLISHED: MAKE_SEQ_PROPERTY(physicals, get_num_physicals, get_physical, set_physical, remove_physical, insert_physical); - virtual void write(ostream &out, int indent=0) const; + virtual void write(std::ostream &out, int indent=0) const; public: virtual ~PhysicalNode(); diff --git a/panda/src/physics/physicsManager.I b/panda/src/physics/physicsManager.I index 3e4704a3ba..386d53d24c 100644 --- a/panda/src/physics/physicsManager.I +++ b/panda/src/physics/physicsManager.I @@ -44,10 +44,10 @@ add_linear_force(LinearForce *f) { */ INLINE void PhysicsManager:: attach_physicalnode(PhysicalNode *p) { - cerr<<"attach_physicalnode (aka attachPhysicalnode) has been" + std::cerr<<"attach_physicalnode (aka attachPhysicalnode) has been" <<"replaced with attach_physical_node (aka attachPhysicalNode)." <<" Please change the spelling of the function in your code." - <> (istream &in, PhysxEnums::PhysxUpAxis &axis); +EXPCL_PANDAPHYSX std::ostream &operator << (std::ostream &out, PhysxEnums::PhysxUpAxis axis); +EXPCL_PANDAPHYSX std::istream &operator >> (std::istream &in, PhysxEnums::PhysxUpAxis &axis); #endif diff --git a/panda/src/physx/physxFileStream.h b/panda/src/physx/physxFileStream.h index 5b7682c9e0..3e9f4752e9 100644 --- a/panda/src/physx/physxFileStream.h +++ b/panda/src/physx/physxFileStream.h @@ -51,7 +51,7 @@ private: // read PT(VirtualFile) _vf; - istream *_in; + std::istream *_in; }; #endif // PHYSXFILESTREAM_H diff --git a/panda/src/physx/physxForceField.I b/panda/src/physx/physxForceField.I index 8a1bf87034..01dbd645ef 100644 --- a/panda/src/physx/physxForceField.I +++ b/panda/src/physx/physxForceField.I @@ -40,7 +40,7 @@ ls() const { * */ INLINE void PhysxForceField:: -ls(ostream &out, int indent_level) const { +ls(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " " << _name diff --git a/panda/src/physx/physxForceField.h b/panda/src/physx/physxForceField.h index ca9f068795..e1dbb85084 100644 --- a/panda/src/physx/physxForceField.h +++ b/panda/src/physx/physxForceField.h @@ -53,7 +53,7 @@ PUBLISHED: void release(); INLINE void ls() const; - INLINE void ls(ostream &out, int indent_level=0) const; + INLINE void ls(std::ostream &out, int indent_level=0) const; public: INLINE NxForceField *ptr() const { return _ptr; }; @@ -63,7 +63,7 @@ public: private: NxForceField *_ptr; - string _name; + std::string _name; public: static TypeHandle get_class_type() { diff --git a/panda/src/physx/physxForceFieldDesc.h b/panda/src/physx/physxForceFieldDesc.h index accacf961e..f7974acd19 100644 --- a/panda/src/physx/physxForceFieldDesc.h +++ b/panda/src/physx/physxForceFieldDesc.h @@ -63,7 +63,7 @@ public: NxForceFieldLinearKernelDesc _kernel; private: - string _name; + std::string _name; }; #include "physxForceFieldDesc.I" diff --git a/panda/src/physx/physxForceFieldShape.I b/panda/src/physx/physxForceFieldShape.I index 1dd06f5fe8..a58a90136f 100644 --- a/panda/src/physx/physxForceFieldShape.I +++ b/panda/src/physx/physxForceFieldShape.I @@ -32,7 +32,7 @@ ls() const { * */ INLINE void PhysxForceFieldShape:: -ls(ostream &out, int indent_level) const { +ls(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " " << _name diff --git a/panda/src/physx/physxForceFieldShape.h b/panda/src/physx/physxForceFieldShape.h index e9e47cf510..3e6a43fe20 100644 --- a/panda/src/physx/physxForceFieldShape.h +++ b/panda/src/physx/physxForceFieldShape.h @@ -45,7 +45,7 @@ PUBLISHED: LPoint3f get_pos() const; INLINE void ls() const; - INLINE void ls(ostream &out, int indent_level=0) const; + INLINE void ls(std::ostream &out, int indent_level=0) const; public: static PhysxForceFieldShape *factory(NxShapeType shapeType); @@ -59,7 +59,7 @@ protected: INLINE PhysxForceFieldShape(); private: - string _name; + std::string _name; public: static TypeHandle get_class_type() { diff --git a/panda/src/physx/physxForceFieldShapeDesc.h b/panda/src/physx/physxForceFieldShapeDesc.h index 1071f9dddc..fd5ab6dc1c 100644 --- a/panda/src/physx/physxForceFieldShapeDesc.h +++ b/panda/src/physx/physxForceFieldShapeDesc.h @@ -41,7 +41,7 @@ public: virtual NxForceFieldShapeDesc *ptr() const = 0; private: - string _name; + std::string _name; protected: INLINE PhysxForceFieldShapeDesc(); diff --git a/panda/src/physx/physxForceFieldShapeGroup.I b/panda/src/physx/physxForceFieldShapeGroup.I index 324b56b396..7d65ae2d18 100644 --- a/panda/src/physx/physxForceFieldShapeGroup.I +++ b/panda/src/physx/physxForceFieldShapeGroup.I @@ -40,7 +40,7 @@ ls() const { * */ INLINE void PhysxForceFieldShapeGroup:: -ls(ostream &out, int indent_level) const { +ls(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " " << _name diff --git a/panda/src/physx/physxForceFieldShapeGroup.h b/panda/src/physx/physxForceFieldShapeGroup.h index b03e34cfe9..c23b6de828 100644 --- a/panda/src/physx/physxForceFieldShapeGroup.h +++ b/panda/src/physx/physxForceFieldShapeGroup.h @@ -54,7 +54,7 @@ PUBLISHED: void release(); INLINE void ls() const; - INLINE void ls(ostream &out, int indent_level=0) const; + INLINE void ls(std::ostream &out, int indent_level=0) const; public: INLINE NxForceFieldShapeGroup *ptr() const { return _ptr; }; @@ -66,7 +66,7 @@ public: private: NxForceFieldShapeGroup *_ptr; - string _name; + std::string _name; public: static TypeHandle get_class_type() { diff --git a/panda/src/physx/physxForceFieldShapeGroupDesc.h b/panda/src/physx/physxForceFieldShapeGroupDesc.h index 1f4a9a3206..fab6c8d0f5 100644 --- a/panda/src/physx/physxForceFieldShapeGroupDesc.h +++ b/panda/src/physx/physxForceFieldShapeGroupDesc.h @@ -45,7 +45,7 @@ public: NxForceFieldShapeGroupDesc _desc; private: - string _name; + std::string _name; }; #include "physxForceFieldShapeGroupDesc.I" diff --git a/panda/src/physx/physxGroupsMask.h b/panda/src/physx/physxGroupsMask.h index 2383a2675d..bd1bfb129b 100644 --- a/panda/src/physx/physxGroupsMask.h +++ b/panda/src/physx/physxGroupsMask.h @@ -32,7 +32,7 @@ PUBLISHED: void clear_bit(unsigned int idx); bool get_bit(unsigned int idx) const; - void output(ostream &out) const; + void output(std::ostream &out) const; static PhysxGroupsMask all_on(); static PhysxGroupsMask all_off(); @@ -54,7 +54,7 @@ public: NxGroupsMask _mask; }; -INLINE ostream &operator << (ostream &out, const PhysxGroupsMask &mask) { +INLINE std::ostream &operator << (std::ostream &out, const PhysxGroupsMask &mask) { mask.output(out); return out; } diff --git a/panda/src/physx/physxHeightField.I b/panda/src/physx/physxHeightField.I index e06fb3425e..1f71266a8f 100644 --- a/panda/src/physx/physxHeightField.I +++ b/panda/src/physx/physxHeightField.I @@ -40,7 +40,7 @@ ls() const { * */ INLINE void PhysxHeightField:: -ls(ostream &out, int indent_level) const { +ls(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " (at 0x" << this << ")\n"; diff --git a/panda/src/physx/physxHeightField.h b/panda/src/physx/physxHeightField.h index 4449e09022..3741533d1b 100644 --- a/panda/src/physx/physxHeightField.h +++ b/panda/src/physx/physxHeightField.h @@ -49,7 +49,7 @@ PUBLISHED: float get_height(float x, float y) const; INLINE void ls() const; - INLINE void ls(ostream &out, int indent_level=0) const; + INLINE void ls(std::ostream &out, int indent_level=0) const; public: INLINE PhysxHeightField(); diff --git a/panda/src/physx/physxJoint.I b/panda/src/physx/physxJoint.I index 1acb52d01d..663f2b3253 100644 --- a/panda/src/physx/physxJoint.I +++ b/panda/src/physx/physxJoint.I @@ -32,7 +32,7 @@ ls() const { * */ INLINE void PhysxJoint:: -ls(ostream &out, int indent_level) const { +ls(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " " << _name diff --git a/panda/src/physx/physxJoint.h b/panda/src/physx/physxJoint.h index 25b623c2bc..adb536e2fb 100644 --- a/panda/src/physx/physxJoint.h +++ b/panda/src/physx/physxJoint.h @@ -55,7 +55,7 @@ PUBLISHED: bool get_use_acceleration_spring() const; INLINE void ls() const; - INLINE void ls(ostream &out, int indent_level=0) const; + INLINE void ls(std::ostream &out, int indent_level=0) const; public: static PhysxJoint *factory(NxJointType shapeType); @@ -69,7 +69,7 @@ protected: INLINE PhysxJoint(); private: - string _name; + std::string _name; public: static TypeHandle get_class_type() { diff --git a/panda/src/physx/physxJointDesc.h b/panda/src/physx/physxJointDesc.h index 9f24e5a214..b123dd81e2 100644 --- a/panda/src/physx/physxJointDesc.h +++ b/panda/src/physx/physxJointDesc.h @@ -57,7 +57,7 @@ public: virtual NxJointDesc *ptr() const = 0; private: - string _name; + std::string _name; protected: INLINE PhysxJointDesc(); diff --git a/panda/src/physx/physxLinearInterpolationValues.h b/panda/src/physx/physxLinearInterpolationValues.h index 4770393e34..9bc5acb4d7 100644 --- a/panda/src/physx/physxLinearInterpolationValues.h +++ b/panda/src/physx/physxLinearInterpolationValues.h @@ -28,7 +28,7 @@ public: INLINE PhysxLinearInterpolationValues(); INLINE ~PhysxLinearInterpolationValues(); - void output(ostream &out) const; + void output(std::ostream &out) const; void clear(); void insert(float index, float value); @@ -45,7 +45,7 @@ private: MapType _map; }; -INLINE ostream &operator << (ostream &out, const PhysxLinearInterpolationValues &values) { +INLINE std::ostream &operator << (std::ostream &out, const PhysxLinearInterpolationValues &values) { values.output(out); return out; } diff --git a/panda/src/physx/physxManager.I b/panda/src/physx/physxManager.I index f6011a7e43..c1bc8a59c9 100644 --- a/panda/src/physx/physxManager.I +++ b/panda/src/physx/physxManager.I @@ -192,7 +192,7 @@ ls() const { * */ INLINE void PhysxManager:: -ls(ostream &out, int indent_level) const { +ls(std::ostream &out, int indent_level) const { indent(out, indent_level) << "PhysxManager\n"; diff --git a/panda/src/physx/physxManager.h b/panda/src/physx/physxManager.h index 430bebd24f..ed5f0b79d5 100644 --- a/panda/src/physx/physxManager.h +++ b/panda/src/physx/physxManager.h @@ -89,7 +89,7 @@ PUBLISHED: MAKE_SEQ(get_ccd_skeletons, get_num_ccd_skeletons, get_ccd_skeleton); INLINE void ls() const; - INLINE void ls(ostream &out, int indent_level=0) const; + INLINE void ls(std::ostream &out, int indent_level=0) const; public: INLINE NxPhysicsSDK *get_sdk() const; diff --git a/panda/src/physx/physxMask.h b/panda/src/physx/physxMask.h index 5843d18939..9117d875bf 100644 --- a/panda/src/physx/physxMask.h +++ b/panda/src/physx/physxMask.h @@ -31,7 +31,7 @@ PUBLISHED: void clear_bit(unsigned int idx); bool get_bit(unsigned int idx) const; - void output(ostream &out) const; + void output(std::ostream &out) const; static PhysxMask all_on(); static PhysxMask all_off(); @@ -43,7 +43,7 @@ private: NxU32 _mask; }; -INLINE ostream &operator << (ostream &out, const PhysxMask &mask) { +INLINE std::ostream &operator << (std::ostream &out, const PhysxMask &mask) { mask.output(out); return out; } diff --git a/panda/src/physx/physxMaterial.I b/panda/src/physx/physxMaterial.I index 22500d8a35..7bc1f46db4 100644 --- a/panda/src/physx/physxMaterial.I +++ b/panda/src/physx/physxMaterial.I @@ -40,7 +40,7 @@ ls() const { * */ INLINE void PhysxMaterial:: -ls(ostream &out, int indent_level) const { +ls(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " (at 0x" << this << ")\n"; diff --git a/panda/src/physx/physxMaterial.h b/panda/src/physx/physxMaterial.h index c6e6b4d2d2..efbeaae9f6 100644 --- a/panda/src/physx/physxMaterial.h +++ b/panda/src/physx/physxMaterial.h @@ -74,7 +74,7 @@ PUBLISHED: PhysxCombineMode get_restitution_combine_mode() const; INLINE void ls() const; - INLINE void ls(ostream &out, int indent_level=0) const; + INLINE void ls(std::ostream &out, int indent_level=0) const; PUBLISHED: void release(); diff --git a/panda/src/physx/physxMeshPool.h b/panda/src/physx/physxMeshPool.h index 30bec8141b..b66d06df7c 100644 --- a/panda/src/physx/physxMeshPool.h +++ b/panda/src/physx/physxMeshPool.h @@ -50,7 +50,7 @@ PUBLISHED: static bool release_soft_body_mesh(PhysxSoftBodyMesh *mesh); static void list_contents(); - static void list_contents(ostream &out); + static void list_contents(std::ostream &out); private: static bool check_filename(const Filename &fn); diff --git a/panda/src/physx/physxObject.I b/panda/src/physx/physxObject.I index 844aefd182..b2331f23d1 100644 --- a/panda/src/physx/physxObject.I +++ b/panda/src/physx/physxObject.I @@ -50,11 +50,11 @@ has_python_tags() const { * */ INLINE void PhysxObject:: -set_python_tag(const string &key, PyObject *value) { +set_python_tag(const std::string &key, PyObject *value) { Py_XINCREF(value); - pair result; + std::pair result; result = _python_tag_data.insert(PythonTagData::value_type(key, value)); if (!result.second) { @@ -72,7 +72,7 @@ set_python_tag(const string &key, PyObject *value) { * */ INLINE PyObject *PhysxObject:: -get_python_tag(const string &key) const { +get_python_tag(const std::string &key) const { PythonTagData::const_iterator ti; ti = _python_tag_data.find(key); @@ -91,7 +91,7 @@ get_python_tag(const string &key) const { * */ INLINE bool PhysxObject:: -has_python_tag(const string &key) const { +has_python_tag(const std::string &key) const { PythonTagData::const_iterator ti; ti = _python_tag_data.find(key); @@ -102,7 +102,7 @@ has_python_tag(const string &key) const { * */ INLINE void PhysxObject:: -clear_python_tag(const string &key) { +clear_python_tag(const std::string &key) { PythonTagData::iterator ti; ti = _python_tag_data.find(key); diff --git a/panda/src/physx/physxObject.h b/panda/src/physx/physxObject.h index 717405736c..0a40cb66fb 100644 --- a/panda/src/physx/physxObject.h +++ b/panda/src/physx/physxObject.h @@ -29,16 +29,16 @@ class EXPCL_PANDAPHYSX PhysxObject : public TypedReferenceCount { #ifdef HAVE_PYTHON PUBLISHED: - INLINE void set_python_tag(const string &key, PyObject *value); - INLINE PyObject *get_python_tag(const string &key) const; - INLINE bool has_python_tag(const string &key) const; - INLINE void clear_python_tag(const string &key); + INLINE void set_python_tag(const std::string &key, PyObject *value); + INLINE PyObject *get_python_tag(const std::string &key) const; + INLINE bool has_python_tag(const std::string &key) const; + INLINE void clear_python_tag(const std::string &key); INLINE bool has_python_tags() const; #endif // HAVE_PYTHON PUBLISHED: virtual void ls() const = 0; - virtual void ls(ostream &out, int indent_level=0) const = 0; + virtual void ls(std::ostream &out, int indent_level=0) const = 0; protected: INLINE PhysxObject(); @@ -55,7 +55,7 @@ protected: #ifdef HAVE_PYTHON private: - typedef phash_map PythonTagData; + typedef phash_map PythonTagData; PythonTagData _python_tag_data; #endif // HAVE_PYTHON diff --git a/panda/src/physx/physxObjectCollection.I b/panda/src/physx/physxObjectCollection.I index 62270910f7..54137cec40 100644 --- a/panda/src/physx/physxObjectCollection.I +++ b/panda/src/physx/physxObjectCollection.I @@ -46,7 +46,7 @@ remove(PT(T) object) { } else { - physx_cat.warning() << "object not found in collection" << endl; + physx_cat.warning() << "object not found in collection" << std::endl; } } @@ -89,7 +89,7 @@ ls() const { */ template INLINE void PhysxObjectCollection:: -ls(ostream &out, int indent_level) const { +ls(std::ostream &out, int indent_level) const { for (unsigned int i=0; i < size(); i++) { get(i)->ls(out, indent_level + 2); diff --git a/panda/src/physx/physxObjectCollection.h b/panda/src/physx/physxObjectCollection.h index ace4799e57..77521de8aa 100644 --- a/panda/src/physx/physxObjectCollection.h +++ b/panda/src/physx/physxObjectCollection.h @@ -32,7 +32,7 @@ public: INLINE T *operator [] (unsigned int index) const; INLINE void ls() const; - INLINE void ls(ostream &out, int indent_level=0) const; + INLINE void ls(std::ostream &out, int indent_level=0) const; private: pvector _objects; diff --git a/panda/src/physx/physxScene.I b/panda/src/physx/physxScene.I index 9f9e2c5aa8..482ebf829f 100644 --- a/panda/src/physx/physxScene.I +++ b/panda/src/physx/physxScene.I @@ -42,7 +42,7 @@ ls() const { * */ INLINE void PhysxScene:: -ls(ostream &out, int indent_level) const { +ls(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " (at 0x" << this << ")\n"; diff --git a/panda/src/physx/physxScene.h b/panda/src/physx/physxScene.h index ed3b39ff4e..f8bf2b302b 100644 --- a/panda/src/physx/physxScene.h +++ b/panda/src/physx/physxScene.h @@ -220,7 +220,7 @@ PUBLISHED: void release(); INLINE void ls() const; - INLINE void ls(ostream &out, int indent_level=0) const; + INLINE void ls(std::ostream &out, int indent_level=0) const; public: INLINE NxScene *ptr() const { return _ptr; }; diff --git a/panda/src/physx/physxShape.I b/panda/src/physx/physxShape.I index 1aa796edab..110613ba2a 100644 --- a/panda/src/physx/physxShape.I +++ b/panda/src/physx/physxShape.I @@ -32,7 +32,7 @@ ls() const { * */ INLINE void PhysxShape:: -ls(ostream &out, int indent_level) const { +ls(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " " << _name diff --git a/panda/src/physx/physxShape.h b/panda/src/physx/physxShape.h index 660eecc211..fbfe01d988 100644 --- a/panda/src/physx/physxShape.h +++ b/panda/src/physx/physxShape.h @@ -72,7 +72,7 @@ PUBLISHED: PhysxRaycastHit raycast(const PhysxRay &worldRay, bool firstHit, bool smoothNormal) const; INLINE void ls() const; - INLINE void ls(ostream &out, int indent_level=0) const; + INLINE void ls(std::ostream &out, int indent_level=0) const; public: static PhysxShape *factory(NxShapeType shapeType); @@ -86,7 +86,7 @@ protected: INLINE PhysxShape(); private: - string _name; + std::string _name; PT(PhysxCcdSkeleton) _skel; public: diff --git a/panda/src/physx/physxShapeDesc.h b/panda/src/physx/physxShapeDesc.h index 6ae7452a79..0ef063fe22 100644 --- a/panda/src/physx/physxShapeDesc.h +++ b/panda/src/physx/physxShapeDesc.h @@ -59,7 +59,7 @@ public: virtual NxShapeDesc *ptr() const = 0; private: - string _name; + std::string _name; protected: INLINE PhysxShapeDesc(); diff --git a/panda/src/physx/physxSoftBody.I b/panda/src/physx/physxSoftBody.I index de1a958608..cba8af0499 100644 --- a/panda/src/physx/physxSoftBody.I +++ b/panda/src/physx/physxSoftBody.I @@ -40,7 +40,7 @@ ls() const { * */ INLINE void PhysxSoftBody:: -ls(ostream &out, int indent_level) const { +ls(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " " << _name diff --git a/panda/src/physx/physxSoftBody.h b/panda/src/physx/physxSoftBody.h index 58020ed4a8..45416148c3 100644 --- a/panda/src/physx/physxSoftBody.h +++ b/panda/src/physx/physxSoftBody.h @@ -168,7 +168,7 @@ virtual void setForceFieldMaterial (NxForceFieldMaterial)=0 */ INLINE void ls() const; - INLINE void ls(ostream &out, int indent_level=0) const; + INLINE void ls(std::ostream &out, int indent_level=0) const; public: void update(); @@ -185,7 +185,7 @@ public: private: NxSoftBody *_ptr; PT(PhysxSoftBodyNode) _node; - string _name; + std::string _name; public: static TypeHandle get_class_type() { diff --git a/panda/src/physx/physxSoftBodyDesc.h b/panda/src/physx/physxSoftBodyDesc.h index 550649a67f..10db3cabae 100644 --- a/panda/src/physx/physxSoftBodyDesc.h +++ b/panda/src/physx/physxSoftBodyDesc.h @@ -73,7 +73,7 @@ public: NxSoftBodyDesc _desc; private: - string _name; + std::string _name; }; #include "physxSoftBodyDesc.I" diff --git a/panda/src/physx/physxSoftBodyMesh.I b/panda/src/physx/physxSoftBodyMesh.I index fd2e3bfe26..314089dda6 100644 --- a/panda/src/physx/physxSoftBodyMesh.I +++ b/panda/src/physx/physxSoftBodyMesh.I @@ -40,7 +40,7 @@ ls() const { * */ INLINE void PhysxSoftBodyMesh:: -ls(ostream &out, int indent_level) const { +ls(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " (at 0x" << this << ")\n"; diff --git a/panda/src/physx/physxSoftBodyMesh.h b/panda/src/physx/physxSoftBodyMesh.h index ad6615b39e..1284582285 100644 --- a/panda/src/physx/physxSoftBodyMesh.h +++ b/panda/src/physx/physxSoftBodyMesh.h @@ -31,7 +31,7 @@ PUBLISHED: void release(); INLINE void ls() const; - INLINE void ls(ostream &out, int indent_level=0) const; + INLINE void ls(std::ostream &out, int indent_level=0) const; public: INLINE PhysxSoftBodyMesh(); diff --git a/panda/src/physx/physxTriangleMesh.I b/panda/src/physx/physxTriangleMesh.I index 3b983f3893..d4e6a6e994 100644 --- a/panda/src/physx/physxTriangleMesh.I +++ b/panda/src/physx/physxTriangleMesh.I @@ -40,7 +40,7 @@ ls() const { * */ INLINE void PhysxTriangleMesh:: -ls(ostream &out, int indent_level) const { +ls(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " (at 0x" << this << ")\n"; diff --git a/panda/src/physx/physxTriangleMesh.h b/panda/src/physx/physxTriangleMesh.h index bf2ef86301..691e012a3f 100644 --- a/panda/src/physx/physxTriangleMesh.h +++ b/panda/src/physx/physxTriangleMesh.h @@ -31,7 +31,7 @@ PUBLISHED: void release(); INLINE void ls() const; - INLINE void ls(ostream &out, int indent_level=0) const; + INLINE void ls(std::ostream &out, int indent_level=0) const; public: INLINE PhysxTriangleMesh(); diff --git a/panda/src/physx/physxVehicle.I b/panda/src/physx/physxVehicle.I index 3be65f3a92..ed095f7211 100644 --- a/panda/src/physx/physxVehicle.I +++ b/panda/src/physx/physxVehicle.I @@ -40,7 +40,7 @@ ls() const { * */ INLINE void PhysxVehicle:: -ls(ostream &out, int indent_level) const { +ls(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " (at 0x" << this << ")\n"; diff --git a/panda/src/physx/physxVehicle.h b/panda/src/physx/physxVehicle.h index 78b358e667..15c3cb6bfa 100644 --- a/panda/src/physx/physxVehicle.h +++ b/panda/src/physx/physxVehicle.h @@ -41,7 +41,7 @@ PUBLISHED: //MAKE_SEQ(get_wheels, get_num_wheels, get_wheel); INLINE void ls() const; - INLINE void ls(ostream &out, int indent_level=0) const; + INLINE void ls(std::ostream &out, int indent_level=0) const; private: diff --git a/panda/src/physx/physxWheel.I b/panda/src/physx/physxWheel.I index 71b43426fd..1aef97f663 100644 --- a/panda/src/physx/physxWheel.I +++ b/panda/src/physx/physxWheel.I @@ -40,7 +40,7 @@ ls() const { * */ INLINE void PhysxWheel:: -ls(ostream &out, int indent_level) const { +ls(std::ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " (at 0x" << this << ")\n"; diff --git a/panda/src/physx/physxWheel.h b/panda/src/physx/physxWheel.h index 84aa5a3acd..457962995c 100644 --- a/panda/src/physx/physxWheel.h +++ b/panda/src/physx/physxWheel.h @@ -40,7 +40,7 @@ PUBLISHED: //NodePath get_node_path() const; INLINE void ls() const; - INLINE void ls(ostream &out, int indent_level=0) const; + INLINE void ls(std::ostream &out, int indent_level=0) const; private: PT(PhysxWheelShape) _wheelShape; diff --git a/panda/src/pipeline/conditionVarDebug.h b/panda/src/pipeline/conditionVarDebug.h index b8243438c9..85da3fde2e 100644 --- a/panda/src/pipeline/conditionVarDebug.h +++ b/panda/src/pipeline/conditionVarDebug.h @@ -43,15 +43,15 @@ PUBLISHED: BLOCKING void wait(); BLOCKING void wait(double timeout); void notify(); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: MutexDebug &_mutex; ConditionVarImpl _impl; }; -INLINE ostream & -operator << (ostream &out, const ConditionVarDebug &cv) { +INLINE std::ostream & +operator << (std::ostream &out, const ConditionVarDebug &cv) { cv.output(out); return out; } diff --git a/panda/src/pipeline/conditionVarDirect.h b/panda/src/pipeline/conditionVarDirect.h index 7315c0b0bb..2a8c9197cb 100644 --- a/panda/src/pipeline/conditionVarDirect.h +++ b/panda/src/pipeline/conditionVarDirect.h @@ -43,15 +43,15 @@ PUBLISHED: BLOCKING INLINE void wait(); BLOCKING INLINE void wait(double timeout); INLINE void notify(); - void output(ostream &out) const; + void output(std::ostream &out) const; private: MutexDirect &_mutex; ConditionVarImpl _impl; }; -INLINE ostream & -operator << (ostream &out, const ConditionVarDirect &cv) { +INLINE std::ostream & +operator << (std::ostream &out, const ConditionVarDirect &cv) { cv.output(out); return out; } diff --git a/panda/src/pipeline/conditionVarFullDebug.h b/panda/src/pipeline/conditionVarFullDebug.h index 696a57e2cf..cefb27cad7 100644 --- a/panda/src/pipeline/conditionVarFullDebug.h +++ b/panda/src/pipeline/conditionVarFullDebug.h @@ -44,15 +44,15 @@ PUBLISHED: BLOCKING void wait(double timeout); void notify(); void notify_all(); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: MutexDebug &_mutex; ConditionVarFullImpl _impl; }; -INLINE ostream & -operator << (ostream &out, const ConditionVarFullDebug &cv) { +INLINE std::ostream & +operator << (std::ostream &out, const ConditionVarFullDebug &cv) { cv.output(out); return out; } diff --git a/panda/src/pipeline/conditionVarFullDirect.h b/panda/src/pipeline/conditionVarFullDirect.h index e2db984ab9..729185501b 100644 --- a/panda/src/pipeline/conditionVarFullDirect.h +++ b/panda/src/pipeline/conditionVarFullDirect.h @@ -44,15 +44,15 @@ PUBLISHED: BLOCKING INLINE void wait(double timeout); INLINE void notify(); INLINE void notify_all(); - void output(ostream &out) const; + void output(std::ostream &out) const; private: MutexDirect &_mutex; ConditionVarFullImpl _impl; }; -INLINE ostream & -operator << (ostream &out, const ConditionVarFullDirect &cv) { +INLINE std::ostream & +operator << (std::ostream &out, const ConditionVarFullDirect &cv) { cv.output(out); return out; } diff --git a/panda/src/pipeline/cycleData.h b/panda/src/pipeline/cycleData.h index 44c0a7b88c..bd28d4bc60 100644 --- a/panda/src/pipeline/cycleData.h +++ b/panda/src/pipeline/cycleData.h @@ -64,11 +64,11 @@ public: void *extra_data); virtual TypeHandle get_parent_type() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; }; -INLINE ostream & -operator << (ostream &out, const CycleData &cd) { +INLINE std::ostream & +operator << (std::ostream &out, const CycleData &cd) { cd.output(out); return out; } diff --git a/panda/src/pipeline/externalThread.h b/panda/src/pipeline/externalThread.h index aaff62ac18..0b6add95b1 100644 --- a/panda/src/pipeline/externalThread.h +++ b/panda/src/pipeline/externalThread.h @@ -24,7 +24,7 @@ class EXPCL_PANDA_PIPELINE ExternalThread : public Thread { private: ExternalThread(); - ExternalThread(const string &name, const string &sync_name); + ExternalThread(const std::string &name, const std::string &sync_name); virtual void thread_main(); PUBLISHED: diff --git a/panda/src/pipeline/genericThread.h b/panda/src/pipeline/genericThread.h index 3e07e6a7e1..6e6a6ade6a 100644 --- a/panda/src/pipeline/genericThread.h +++ b/panda/src/pipeline/genericThread.h @@ -25,8 +25,8 @@ class EXPCL_PANDA_PIPELINE GenericThread : public Thread { public: typedef void ThreadFunc(void *user_data); - GenericThread(const string &name, const string &sync_name); - GenericThread(const string &name, const string &sync_name, ThreadFunc *function, void *user_data); + GenericThread(const std::string &name, const std::string &sync_name); + GenericThread(const std::string &name, const std::string &sync_name, ThreadFunc *function, void *user_data); INLINE void set_function(ThreadFunc *function); INLINE ThreadFunc *get_function() const; diff --git a/panda/src/pipeline/lightMutex.I b/panda/src/pipeline/lightMutex.I index 4121d607e2..b76b743e34 100644 --- a/panda/src/pipeline/lightMutex.I +++ b/panda/src/pipeline/lightMutex.I @@ -16,7 +16,7 @@ */ INLINE LightMutex:: #ifdef DEBUG_THREADS -LightMutex() : MutexDebug(string(), false, true) +LightMutex() : MutexDebug(std::string(), false, true) #else LightMutex() #endif // DEBUG_THREADS @@ -28,7 +28,7 @@ LightMutex() */ INLINE LightMutex:: #ifdef DEBUG_THREADS -LightMutex(const char *name) : MutexDebug(string(name), false, true) +LightMutex(const char *name) : MutexDebug(std::string(name), false, true) #else LightMutex(const char *) #endif // DEBUG_THREADS @@ -40,9 +40,9 @@ LightMutex(const char *) */ INLINE LightMutex:: #ifdef DEBUG_THREADS -LightMutex(const string &name) : MutexDebug(name, false, true) +LightMutex(const std::string &name) : MutexDebug(name, false, true) #else -LightMutex(const string &) +LightMutex(const std::string &) #endif // DEBUG_THREADS { } diff --git a/panda/src/pipeline/lightMutex.h b/panda/src/pipeline/lightMutex.h index 4e2d1fa67b..4d8ae9a785 100644 --- a/panda/src/pipeline/lightMutex.h +++ b/panda/src/pipeline/lightMutex.h @@ -44,7 +44,7 @@ PUBLISHED: public: INLINE explicit LightMutex(const char *name); PUBLISHED: - INLINE explicit LightMutex(const string &name); + INLINE explicit LightMutex(const std::string &name); LightMutex(const LightMutex ©) = delete; ~LightMutex() = default; diff --git a/panda/src/pipeline/lightMutexDirect.I b/panda/src/pipeline/lightMutexDirect.I index 041f388ce2..a43921ecfb 100644 --- a/panda/src/pipeline/lightMutexDirect.I +++ b/panda/src/pipeline/lightMutexDirect.I @@ -86,7 +86,7 @@ debug_is_locked() const { * The lightMutex name is only defined when compiling in DEBUG_THREADS mode. */ INLINE void LightMutexDirect:: -set_name(const string &) { +set_name(const std::string &) { } /** @@ -107,7 +107,7 @@ has_name() const { /** * The lightMutex name is only defined when compiling in DEBUG_THREADS mode. */ -INLINE string LightMutexDirect:: +INLINE std::string LightMutexDirect:: get_name() const { - return string(); + return std::string(); } diff --git a/panda/src/pipeline/lightMutexDirect.h b/panda/src/pipeline/lightMutexDirect.h index 78ffcce433..e72bd808fe 100644 --- a/panda/src/pipeline/lightMutexDirect.h +++ b/panda/src/pipeline/lightMutexDirect.h @@ -46,12 +46,12 @@ PUBLISHED: INLINE void release() const; INLINE bool debug_is_locked() const; - INLINE void set_name(const string &name); + INLINE void set_name(const std::string &name); INLINE void clear_name(); INLINE bool has_name() const; - INLINE string get_name() const; + INLINE std::string get_name() const; - void output(ostream &out) const; + void output(std::ostream &out) const; private: #ifdef DO_PSTATS @@ -65,8 +65,8 @@ private: #endif // DO_PSTATS }; -INLINE ostream & -operator << (ostream &out, const LightMutexDirect &m) { +INLINE std::ostream & +operator << (std::ostream &out, const LightMutexDirect &m) { m.output(out); return out; } diff --git a/panda/src/pipeline/lightReMutex.I b/panda/src/pipeline/lightReMutex.I index c0cb459c87..bc27a5a711 100644 --- a/panda/src/pipeline/lightReMutex.I +++ b/panda/src/pipeline/lightReMutex.I @@ -16,7 +16,7 @@ */ INLINE LightReMutex:: #ifdef DEBUG_THREADS -LightReMutex() : MutexDebug(string(), true, true) +LightReMutex() : MutexDebug(std::string(), true, true) #else LightReMutex() #endif // DEBUG_THREADS @@ -28,7 +28,7 @@ LightReMutex() */ INLINE LightReMutex:: #ifdef DEBUG_THREADS -LightReMutex(const char *name) : MutexDebug(string(name), true, true) +LightReMutex(const char *name) : MutexDebug(std::string(name), true, true) #else LightReMutex(const char *) #endif // DEBUG_THREADS @@ -40,9 +40,9 @@ LightReMutex(const char *) */ INLINE LightReMutex:: #ifdef DEBUG_THREADS -LightReMutex(const string &name) : MutexDebug(name, true, true) +LightReMutex(const std::string &name) : MutexDebug(name, true, true) #else -LightReMutex(const string &) +LightReMutex(const std::string &) #endif // DEBUG_THREADS { } diff --git a/panda/src/pipeline/lightReMutex.h b/panda/src/pipeline/lightReMutex.h index 2fff13a1ee..b219d7d10c 100644 --- a/panda/src/pipeline/lightReMutex.h +++ b/panda/src/pipeline/lightReMutex.h @@ -35,7 +35,7 @@ PUBLISHED: public: INLINE explicit LightReMutex(const char *name); PUBLISHED: - INLINE explicit LightReMutex(const string &name); + INLINE explicit LightReMutex(const std::string &name); LightReMutex(const LightReMutex ©) = delete; ~LightReMutex() = default; diff --git a/panda/src/pipeline/lightReMutexDirect.I b/panda/src/pipeline/lightReMutexDirect.I index bdfe87059b..08bb0daa67 100644 --- a/panda/src/pipeline/lightReMutexDirect.I +++ b/panda/src/pipeline/lightReMutexDirect.I @@ -143,7 +143,7 @@ debug_is_locked() const { * The mutex name is only defined when compiling in DEBUG_THREADS mode. */ INLINE void LightReMutexDirect:: -set_name(const string &) { +set_name(const std::string &) { } /** @@ -164,7 +164,7 @@ has_name() const { /** * The mutex name is only defined when compiling in DEBUG_THREADS mode. */ -INLINE string LightReMutexDirect:: +INLINE std::string LightReMutexDirect:: get_name() const { - return string(); + return std::string(); } diff --git a/panda/src/pipeline/lightReMutexDirect.h b/panda/src/pipeline/lightReMutexDirect.h index 21f25c1c31..56371cc443 100644 --- a/panda/src/pipeline/lightReMutexDirect.h +++ b/panda/src/pipeline/lightReMutexDirect.h @@ -48,12 +48,12 @@ PUBLISHED: INLINE bool debug_is_locked() const; - INLINE void set_name(const string &name); + INLINE void set_name(const std::string &name); INLINE void clear_name(); INLINE bool has_name() const; - INLINE string get_name() const; + INLINE std::string get_name() const; - void output(ostream &out) const; + void output(std::ostream &out) const; private: #ifdef HAVE_REMUTEXTRUEIMPL @@ -66,8 +66,8 @@ private: #endif // HAVE_REMUTEXIMPL }; -INLINE ostream & -operator << (ostream &out, const LightReMutexDirect &m) { +INLINE std::ostream & +operator << (std::ostream &out, const LightReMutexDirect &m) { m.output(out); return out; } diff --git a/panda/src/pipeline/mutexDebug.h b/panda/src/pipeline/mutexDebug.h index 4fc3e4eeaa..094f2eafc6 100644 --- a/panda/src/pipeline/mutexDebug.h +++ b/panda/src/pipeline/mutexDebug.h @@ -29,7 +29,7 @@ */ class EXPCL_PANDA_PIPELINE MutexDebug : public Namable { protected: - MutexDebug(const string &name, bool allow_recursion, bool lightweight); + MutexDebug(const std::string &name, bool allow_recursion, bool lightweight); MutexDebug(const MutexDebug ©) = delete; virtual ~MutexDebug(); @@ -47,8 +47,8 @@ PUBLISHED: INLINE void release() const; INLINE bool debug_is_locked() const; - virtual void output(ostream &out) const; - void output_with_holder(ostream &out) const; + virtual void output(std::ostream &out) const; + void output_with_holder(std::ostream &out) const; typedef void VoidFunc(); @@ -86,8 +86,8 @@ private: friend class ConditionVarFullDebug; }; -INLINE ostream & -operator << (ostream &out, const MutexDebug &m) { +INLINE std::ostream & +operator << (std::ostream &out, const MutexDebug &m) { m.output(out); return out; } diff --git a/panda/src/pipeline/mutexDirect.I b/panda/src/pipeline/mutexDirect.I index e12442289c..71a26543a7 100644 --- a/panda/src/pipeline/mutexDirect.I +++ b/panda/src/pipeline/mutexDirect.I @@ -95,7 +95,7 @@ debug_is_locked() const { * The mutex name is only defined when compiling in DEBUG_THREADS mode. */ INLINE void MutexDirect:: -set_name(const string &) { +set_name(const std::string &) { } /** @@ -116,7 +116,7 @@ has_name() const { /** * The mutex name is only defined when compiling in DEBUG_THREADS mode. */ -INLINE string MutexDirect:: +INLINE std::string MutexDirect:: get_name() const { - return string(); + return std::string(); } diff --git a/panda/src/pipeline/mutexDirect.h b/panda/src/pipeline/mutexDirect.h index b288dc0648..068f5fc5c4 100644 --- a/panda/src/pipeline/mutexDirect.h +++ b/panda/src/pipeline/mutexDirect.h @@ -46,12 +46,12 @@ PUBLISHED: INLINE void release() const; INLINE bool debug_is_locked() const; - INLINE void set_name(const string &name); + INLINE void set_name(const std::string &name); INLINE void clear_name(); INLINE bool has_name() const; - INLINE string get_name() const; + INLINE std::string get_name() const; - void output(ostream &out) const; + void output(std::ostream &out) const; private: mutable MutexTrueImpl _impl; @@ -60,8 +60,8 @@ private: friend class ConditionVarFullDirect; }; -INLINE ostream & -operator << (ostream &out, const MutexDirect &m) { +INLINE std::ostream & +operator << (std::ostream &out, const MutexDirect &m) { m.output(out); return out; } diff --git a/panda/src/pipeline/pipeline.I b/panda/src/pipeline/pipeline.I index 163612e5f2..2116a030e6 100644 --- a/panda/src/pipeline/pipeline.I +++ b/panda/src/pipeline/pipeline.I @@ -27,7 +27,7 @@ get_render_pipeline() { */ INLINE void Pipeline:: set_min_stages(int min_stages) { - set_num_stages(max(min_stages, get_num_stages())); + set_num_stages(std::max(min_stages, get_num_stages())); } /** diff --git a/panda/src/pipeline/pipeline.h b/panda/src/pipeline/pipeline.h index 1dbba9429f..c06bb2ffef 100644 --- a/panda/src/pipeline/pipeline.h +++ b/panda/src/pipeline/pipeline.h @@ -37,7 +37,7 @@ struct PipelineCyclerTrueImpl; */ class EXPCL_PANDA_PIPELINE Pipeline : public Namable { public: - Pipeline(const string &name, int num_stages); + Pipeline(const std::string &name, int num_stages); ~Pipeline(); INLINE static Pipeline *get_render_pipeline(); diff --git a/panda/src/pipeline/pipelineCycler.I b/panda/src/pipeline/pipelineCycler.I index 06c6c1e5dc..2cd818a747 100644 --- a/panda/src/pipeline/pipelineCycler.I +++ b/panda/src/pipeline/pipelineCycler.I @@ -31,7 +31,7 @@ PipelineCycler(Pipeline *pipeline) : template INLINE PipelineCycler:: PipelineCycler(CycleDataType &&initial_data, Pipeline *pipeline) : - PipelineCyclerBase(new CycleDataType(move(initial_data)), pipeline) + PipelineCyclerBase(new CycleDataType(std::move(initial_data)), pipeline) { } @@ -198,7 +198,7 @@ PipelineCycler(Pipeline *pipeline) : template INLINE PipelineCycler:: PipelineCycler(CycleDataType &&initial_data, Pipeline *pipeline) : - _typed_data(move(initial_data)), + _typed_data(std::move(initial_data)), PipelineCyclerBase(&_typed_data, pipeline) { } diff --git a/panda/src/pipeline/pipelineCyclerTrueImpl.h b/panda/src/pipeline/pipelineCyclerTrueImpl.h index 809fda99f4..12232f70d0 100644 --- a/panda/src/pipeline/pipelineCyclerTrueImpl.h +++ b/panda/src/pipeline/pipelineCyclerTrueImpl.h @@ -94,7 +94,7 @@ public: INLINE CyclerMutex(PipelineCyclerTrueImpl *cycler); #ifdef DEBUG_THREADS - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; PipelineCyclerTrueImpl *_cycler; #endif // DEBUG_THREADS }; diff --git a/panda/src/pipeline/pmutex.I b/panda/src/pipeline/pmutex.I index 9a5ca4c926..e148ce22e3 100644 --- a/panda/src/pipeline/pmutex.I +++ b/panda/src/pipeline/pmutex.I @@ -16,7 +16,7 @@ */ INLINE Mutex:: #ifdef DEBUG_THREADS -Mutex() : MutexDebug(string(), false, false) +Mutex() : MutexDebug(std::string(), false, false) #else Mutex() #endif // DEBUG_THREADS @@ -28,7 +28,7 @@ Mutex() */ INLINE Mutex:: #ifdef DEBUG_THREADS -Mutex(const char *name) : MutexDebug(string(name), false, false) +Mutex(const char *name) : MutexDebug(std::string(name), false, false) #else Mutex(const char *) #endif // DEBUG_THREADS @@ -40,9 +40,9 @@ Mutex(const char *) */ INLINE Mutex:: #ifdef DEBUG_THREADS -Mutex(const string &name) : MutexDebug(name, false, false) +Mutex(const std::string &name) : MutexDebug(name, false, false) #else -Mutex(const string &) +Mutex(const std::string &) #endif // DEBUG_THREADS { } diff --git a/panda/src/pipeline/pmutex.h b/panda/src/pipeline/pmutex.h index bc547afab3..2a47b7dbac 100644 --- a/panda/src/pipeline/pmutex.h +++ b/panda/src/pipeline/pmutex.h @@ -43,7 +43,7 @@ PUBLISHED: public: INLINE Mutex(const char *name); PUBLISHED: - INLINE explicit Mutex(const string &name); + INLINE explicit Mutex(const std::string &name); Mutex(const Mutex ©) = delete; ~Mutex() = default; diff --git a/panda/src/pipeline/psemaphore.h b/panda/src/pipeline/psemaphore.h index 9c724a94c1..306992b5d9 100644 --- a/panda/src/pipeline/psemaphore.h +++ b/panda/src/pipeline/psemaphore.h @@ -41,7 +41,7 @@ PUBLISHED: INLINE int release(); INLINE int get_count() const; - void output(ostream &out) const; + void output(std::ostream &out) const; private: Mutex _lock; @@ -49,8 +49,8 @@ private: int _count; }; -INLINE ostream & -operator << (ostream &out, const Semaphore &sem) { +INLINE std::ostream & +operator << (std::ostream &out, const Semaphore &sem) { sem.output(out); return out; } diff --git a/panda/src/pipeline/pythonThread.h b/panda/src/pipeline/pythonThread.h index 66b7e45aa4..eb57351149 100644 --- a/panda/src/pipeline/pythonThread.h +++ b/panda/src/pipeline/pythonThread.h @@ -27,7 +27,7 @@ class PythonThread : public Thread { PUBLISHED: explicit PythonThread(PyObject *function, PyObject *args, - const string &name, const string &sync_name); + const std::string &name, const std::string &sync_name); virtual ~PythonThread(); BLOCKING PyObject *join(); diff --git a/panda/src/pipeline/reMutex.I b/panda/src/pipeline/reMutex.I index 361d3a1c85..af2ea3d59c 100644 --- a/panda/src/pipeline/reMutex.I +++ b/panda/src/pipeline/reMutex.I @@ -16,7 +16,7 @@ */ INLINE ReMutex:: #ifdef DEBUG_THREADS -ReMutex() : MutexDebug(string(), true, false) +ReMutex() : MutexDebug(std::string(), true, false) #else ReMutex() #endif // DEBUG_THREADS @@ -28,7 +28,7 @@ ReMutex() */ INLINE ReMutex:: #ifdef DEBUG_THREADS -ReMutex(const char *name) : MutexDebug(string(name), true, false) +ReMutex(const char *name) : MutexDebug(std::string(name), true, false) #else ReMutex(const char *) #endif // DEBUG_THREADS @@ -40,9 +40,9 @@ ReMutex(const char *) */ INLINE ReMutex:: #ifdef DEBUG_THREADS -ReMutex(const string &name) : MutexDebug(name, true, false) +ReMutex(const std::string &name) : MutexDebug(name, true, false) #else -ReMutex(const string &) +ReMutex(const std::string &) #endif // DEBUG_THREADS { } diff --git a/panda/src/pipeline/reMutex.h b/panda/src/pipeline/reMutex.h index 1597c2d7c4..bdf9031304 100644 --- a/panda/src/pipeline/reMutex.h +++ b/panda/src/pipeline/reMutex.h @@ -37,7 +37,7 @@ PUBLISHED: public: INLINE explicit ReMutex(const char *name); PUBLISHED: - INLINE explicit ReMutex(const string &name); + INLINE explicit ReMutex(const std::string &name); ReMutex(const ReMutex ©) = delete; ~ReMutex() = default; diff --git a/panda/src/pipeline/reMutexDirect.I b/panda/src/pipeline/reMutexDirect.I index 51b380ac57..0785473e7c 100644 --- a/panda/src/pipeline/reMutexDirect.I +++ b/panda/src/pipeline/reMutexDirect.I @@ -170,7 +170,7 @@ debug_is_locked() const { * The mutex name is only defined when compiling in DEBUG_THREADS mode. */ INLINE void ReMutexDirect:: -set_name(const string &) { +set_name(const std::string &) { } /** @@ -191,9 +191,9 @@ has_name() const { /** * The mutex name is only defined when compiling in DEBUG_THREADS mode. */ -INLINE string ReMutexDirect:: +INLINE std::string ReMutexDirect:: get_name() const { - return string(); + return std::string(); } #ifndef HAVE_REMUTEXTRUEIMPL diff --git a/panda/src/pipeline/reMutexDirect.h b/panda/src/pipeline/reMutexDirect.h index c47c4b02bd..b6f5215319 100644 --- a/panda/src/pipeline/reMutexDirect.h +++ b/panda/src/pipeline/reMutexDirect.h @@ -50,12 +50,12 @@ PUBLISHED: INLINE bool debug_is_locked() const; - INLINE void set_name(const string &name); + INLINE void set_name(const std::string &name); INLINE void clear_name(); INLINE bool has_name() const; - INLINE string get_name() const; + INLINE std::string get_name() const; - void output(ostream &out) const; + void output(std::ostream &out) const; private: #ifdef HAVE_REMUTEXTRUEIMPL @@ -80,8 +80,8 @@ private: friend class LightReMutexDirect; }; -INLINE ostream & -operator << (ostream &out, const ReMutexDirect &m) { +INLINE std::ostream & +operator << (std::ostream &out, const ReMutexDirect &m) { m.output(out); return out; } diff --git a/panda/src/pipeline/thread.I b/panda/src/pipeline/thread.I index d8c8503742..dc7001fd06 100644 --- a/panda/src/pipeline/thread.I +++ b/panda/src/pipeline/thread.I @@ -17,7 +17,7 @@ * the benefit of PStats; threads with the same sync name can be ticked all at * once via the thread_tick() call. */ -INLINE const string &Thread:: +INLINE const std::string &Thread:: get_sync_name() const { return _sync_name; } @@ -46,7 +46,7 @@ get_python_index() const { * Returns a string that is guaranteed to be unique to this thread, across all * processes on the machine, during at least the lifetime of this process. */ -INLINE string Thread:: +INLINE std::string Thread:: get_unique_id() const { return _impl.get_unique_id(); } @@ -75,7 +75,7 @@ get_pipeline_stage() const { */ INLINE void Thread:: set_min_pipeline_stage(int min_pipeline_stage) { - set_pipeline_stage(max(_pipeline_stage, min_pipeline_stage)); + set_pipeline_stage(std::max(_pipeline_stage, min_pipeline_stage)); } /** @@ -323,8 +323,8 @@ get_pstats_callback() const { return _pstats_callback; } -INLINE ostream & -operator << (ostream &out, const Thread &thread) { +INLINE std::ostream & +operator << (std::ostream &out, const Thread &thread) { thread.output(out); return out; } diff --git a/panda/src/pipeline/thread.h b/panda/src/pipeline/thread.h index 6749883fb6..69b878725a 100644 --- a/panda/src/pipeline/thread.h +++ b/panda/src/pipeline/thread.h @@ -45,7 +45,7 @@ class AsyncTask; */ class EXPCL_PANDA_PIPELINE Thread : public TypedReferenceCount, public Namable { protected: - Thread(const string &name, const string &sync_name); + Thread(const std::string &name, const std::string &sync_name); Thread(const Thread ©) = delete; PUBLISHED: @@ -57,13 +57,13 @@ protected: virtual void thread_main()=0; PUBLISHED: - static PT(Thread) bind_thread(const string &name, const string &sync_name); + static PT(Thread) bind_thread(const std::string &name, const std::string &sync_name); - INLINE const string &get_sync_name() const; + INLINE const std::string &get_sync_name() const; INLINE int get_pstats_index() const; INLINE int get_python_index() const; - INLINE string get_unique_id() const; + INLINE std::string get_unique_id() const; INLINE int get_pipeline_stage() const; void set_pipeline_stage(int pipeline_stage); @@ -81,9 +81,9 @@ PUBLISHED: BLOCKING INLINE static void force_yield(); BLOCKING INLINE static void consider_yield(); - virtual void output(ostream &out) const; - void output_blocker(ostream &out) const; - static void write_status(ostream &out); + virtual void output(std::ostream &out) const; + void output_blocker(std::ostream &out) const; + static void write_status(std::ostream &out); INLINE bool is_started() const; INLINE bool is_joinable() const; @@ -143,7 +143,7 @@ protected: bool _started; private: - string _sync_name; + std::string _sync_name; ThreadImpl _impl; int _pstats_index; int _pipeline_stage; @@ -194,7 +194,7 @@ private: friend class AsyncTask; }; -INLINE ostream &operator << (ostream &out, const Thread &thread); +INLINE std::ostream &operator << (std::ostream &out, const Thread &thread); #include "thread.I" diff --git a/panda/src/pipeline/threadDummyImpl.h b/panda/src/pipeline/threadDummyImpl.h index 1b2c46cd46..7721ca2d6c 100644 --- a/panda/src/pipeline/threadDummyImpl.h +++ b/panda/src/pipeline/threadDummyImpl.h @@ -45,7 +45,7 @@ public: INLINE void join(); INLINE void preempt(); - string get_unique_id() const; + std::string get_unique_id() const; INLINE static void prepare_for_exit(); diff --git a/panda/src/pipeline/threadPosixImpl.h b/panda/src/pipeline/threadPosixImpl.h index ee279c98dd..cdfd5eab8a 100644 --- a/panda/src/pipeline/threadPosixImpl.h +++ b/panda/src/pipeline/threadPosixImpl.h @@ -44,7 +44,7 @@ public: void join(); INLINE void preempt(); - string get_unique_id() const; + std::string get_unique_id() const; INLINE static void prepare_for_exit(); diff --git a/panda/src/pipeline/threadPriority.h b/panda/src/pipeline/threadPriority.h index 104b0dac3b..8d1379e98a 100644 --- a/panda/src/pipeline/threadPriority.h +++ b/panda/src/pipeline/threadPriority.h @@ -27,10 +27,10 @@ enum ThreadPriority { }; END_PUBLISH -EXPCL_PANDA_PIPELINE ostream & -operator << (ostream &out, ThreadPriority pri); -EXPCL_PANDA_PIPELINE istream & -operator >> (istream &in, ThreadPriority &pri); +EXPCL_PANDA_PIPELINE std::ostream & +operator << (std::ostream &out, ThreadPriority pri); +EXPCL_PANDA_PIPELINE std::istream & +operator >> (std::istream &in, ThreadPriority &pri); #endif diff --git a/panda/src/pipeline/threadSimpleImpl.I b/panda/src/pipeline/threadSimpleImpl.I index 41b31b2b14..001f3037d4 100644 --- a/panda/src/pipeline/threadSimpleImpl.I +++ b/panda/src/pipeline/threadSimpleImpl.I @@ -130,7 +130,7 @@ get_wake_time() const { * Writes a list of threads running and threads blocked. */ void ThreadSimpleImpl:: -write_status(ostream &out) { +write_status(std::ostream &out) { ThreadSimpleManager *manager = ThreadSimpleManager::get_global_ptr(); manager->write_status(out); } diff --git a/panda/src/pipeline/threadSimpleImpl.h b/panda/src/pipeline/threadSimpleImpl.h index aa2e4e7ab7..c552dd1357 100644 --- a/panda/src/pipeline/threadSimpleImpl.h +++ b/panda/src/pipeline/threadSimpleImpl.h @@ -54,7 +54,7 @@ public: void join(); void preempt(); - string get_unique_id() const; + std::string get_unique_id() const; static void prepare_for_exit(); @@ -75,7 +75,7 @@ public: INLINE double get_wake_time() const; - INLINE static void write_status(ostream &out); + INLINE static void write_status(std::ostream &out); private: static void st_begin_thread(void *data); diff --git a/panda/src/pipeline/threadSimpleManager.h b/panda/src/pipeline/threadSimpleManager.h index 364b59be8f..668c1451fe 100644 --- a/panda/src/pipeline/threadSimpleManager.h +++ b/panda/src/pipeline/threadSimpleManager.h @@ -78,7 +78,7 @@ public: double get_current_time() const; INLINE static ThreadSimpleManager *get_global_ptr(); - void write_status(ostream &out) const; + void write_status(std::ostream &out) const; private: static void init_pointers(); diff --git a/panda/src/pipeline/threadWin32Impl.h b/panda/src/pipeline/threadWin32Impl.h index 665e1be43c..69163230c9 100644 --- a/panda/src/pipeline/threadWin32Impl.h +++ b/panda/src/pipeline/threadWin32Impl.h @@ -39,7 +39,7 @@ public: void join(); INLINE void preempt(); - string get_unique_id() const; + std::string get_unique_id() const; INLINE static void prepare_for_exit(); diff --git a/panda/src/pnmimage/convert_srgb.I b/panda/src/pnmimage/convert_srgb.I index f49cc38203..27d6bbf802 100644 --- a/panda/src/pnmimage/convert_srgb.I +++ b/panda/src/pnmimage/convert_srgb.I @@ -44,8 +44,8 @@ INLINE unsigned char decode_sRGB_uchar(unsigned char val) { */ INLINE unsigned char decode_sRGB_uchar(float val) { return (val <= 0.04045f) - ? (unsigned char)(max(0.f, val) * (255.f / 12.92f) + 0.5f) - : (unsigned char)(cpow((min(val, 1.f) + 0.055f) * (1.f / 1.055f), 2.4f) * 255.f + 0.5f); + ? (unsigned char)(std::max(0.f, val) * (255.f / 12.92f) + 0.5f) + : (unsigned char)(cpow((std::min(val, 1.f) + 0.055f) * (1.f / 1.055f), 2.4f) * 255.f + 0.5f); } /** @@ -99,8 +99,8 @@ encode_sRGB_uchar(float val) { return encode_sRGB_uchar_sse2(val); #else return (val < 0.0031308f) - ? (unsigned char) (max(0.f, val) * 3294.6f + 0.5f) - : (unsigned char) (269.025f * cpow(min(val, 1.f), 0.41666f) - 13.525f); + ? (unsigned char) (std::max(0.f, val) * 3294.6f + 0.5f) + : (unsigned char) (269.025f * cpow(std::min(val, 1.f), 0.41666f) - 13.525f); #endif } diff --git a/panda/src/pnmimage/pfmFile.I b/panda/src/pnmimage/pfmFile.I index b8f63272f0..0ba12061ee 100644 --- a/panda/src/pnmimage/pfmFile.I +++ b/panda/src/pnmimage/pfmFile.I @@ -587,12 +587,12 @@ setup_sub_image(const PfmFile ©, int &xto, int &yto, yto = 0; } - x_size = min(x_size, copy.get_x_size() - xfrom); - y_size = min(y_size, copy.get_y_size() - yfrom); + x_size = std::min(x_size, copy.get_x_size() - xfrom); + y_size = std::min(y_size, copy.get_y_size() - yfrom); xmin = xto; ymin = yto; - xmax = min(xmin + x_size, get_x_size()); - ymax = min(ymin + y_size, get_y_size()); + xmax = std::min(xmin + x_size, get_x_size()); + ymax = std::min(ymin + y_size, get_y_size()); } diff --git a/panda/src/pnmimage/pfmFile.h b/panda/src/pnmimage/pfmFile.h index 74eda76bce..cb8dd3b309 100644 --- a/panda/src/pnmimage/pfmFile.h +++ b/panda/src/pnmimage/pfmFile.h @@ -38,10 +38,10 @@ PUBLISHED: void clear(int x_size, int y_size, int num_channels); BLOCKING bool read(const Filename &fullpath); - BLOCKING bool read(istream &in, const Filename &fullpath = Filename()); + BLOCKING bool read(std::istream &in, const Filename &fullpath = Filename()); BLOCKING bool read(PNMReader *reader); BLOCKING bool write(const Filename &fullpath); - BLOCKING bool write(ostream &out, const Filename &fullpath = Filename()); + BLOCKING bool write(std::ostream &out, const Filename &fullpath = Filename()); BLOCKING bool write(PNMWriter *writer); BLOCKING bool load(const PNMImage &pnmimage); @@ -168,7 +168,7 @@ PUBLISHED: INLINE void apply_exponent(float c0_exponent, float c1_exponent, float c2_exponent); void apply_exponent(float c0_exponent, float c1_exponent, float c2_exponent, float c3_exponent); - void output(ostream &out) const; + void output(std::ostream &out) const; #ifdef HAVE_PYTHON EXTENSION(PyObject *get_points() const); diff --git a/panda/src/pnmimage/pnmFileType.h b/panda/src/pnmimage/pnmFileType.h index 48e4a533fb..fbde4717a2 100644 --- a/panda/src/pnmimage/pnmFileType.h +++ b/panda/src/pnmimage/pnmFileType.h @@ -37,12 +37,12 @@ public: virtual ~PNMFileType(); PUBLISHED: - virtual string get_name() const=0; + virtual std::string get_name() const=0; virtual int get_num_extensions() const; - virtual string get_extension(int n) const; + virtual std::string get_extension(int n) const; MAKE_SEQ(get_extensions, get_num_extensions, get_extension); - virtual string get_suggested_extension() const; + virtual std::string get_suggested_extension() const; MAKE_PROPERTY(name, get_name); MAKE_SEQ_PROPERTY(extensions, get_num_extensions, get_extension); @@ -50,11 +50,11 @@ PUBLISHED: public: virtual bool has_magic_number() const; - virtual bool matches_magic_number(const string &magic_number) const; + virtual bool matches_magic_number(const std::string &magic_number) const; - virtual PNMReader *make_reader(istream *file, bool owns_file = true, - const string &magic_number = string()); - virtual PNMWriter *make_writer(ostream *file, bool owns_file = true); + virtual PNMReader *make_reader(std::istream *file, bool owns_file = true, + const std::string &magic_number = std::string()); + virtual PNMWriter *make_writer(std::ostream *file, bool owns_file = true); protected: static void init_pnm(); diff --git a/panda/src/pnmimage/pnmFileTypeRegistry.h b/panda/src/pnmimage/pnmFileTypeRegistry.h index 9c8702a961..ae4c6a7688 100644 --- a/panda/src/pnmimage/pnmFileTypeRegistry.h +++ b/panda/src/pnmimage/pnmFileTypeRegistry.h @@ -41,11 +41,11 @@ PUBLISHED: MAKE_SEQ(get_types, get_num_types, get_type); MAKE_SEQ_PROPERTY(types, get_num_types, get_type); - PNMFileType *get_type_from_extension(const string &filename) const; - PNMFileType *get_type_from_magic_number(const string &magic_number) const; + PNMFileType *get_type_from_extension(const std::string &filename) const; + PNMFileType *get_type_from_magic_number(const std::string &magic_number) const; PNMFileType *get_type_by_handle(TypeHandle handle) const; - void write(ostream &out, int indent_level = 0) const; + void write(std::ostream &out, int indent_level = 0) const; static PNMFileTypeRegistry *get_global_ptr(); @@ -55,7 +55,7 @@ private: typedef pvector Types; Types _types; - typedef pmap Extensions; + typedef pmap Extensions; Extensions _extensions; typedef pmap Handles; diff --git a/panda/src/pnmimage/pnmImage.I b/panda/src/pnmimage/pnmImage.I index 21c6619ea8..fe589d3f9b 100644 --- a/panda/src/pnmimage/pnmImage.I +++ b/panda/src/pnmimage/pnmImage.I @@ -68,7 +68,7 @@ INLINE PNMImage:: */ INLINE xelval PNMImage:: clamp_val(int input_value) const { - return (xelval)min(max(0, input_value), (int)get_maxval()); + return (xelval)std::min(std::max(0, input_value), (int)get_maxval()); } /** @@ -80,7 +80,7 @@ to_val(float input_value) const { switch (_xel_encoding) { case XE_generic: case XE_generic_alpha: - return (int)(min(1.0f, max(0.0f, input_value)) * get_maxval() + 0.5f); + return (int)(std::min(1.0f, std::max(0.0f, input_value)) * get_maxval() + 0.5f); case XE_generic_sRGB: case XE_generic_sRGB_alpha: @@ -97,7 +97,7 @@ to_val(float input_value) const { case XE_scRGB: case XE_scRGB_alpha: - return min(max(0, (int)((8192 * input_value) + 4096.5f)), 65535); + return std::min(std::max(0, (int)((8192 * input_value) + 4096.5f)), 65535); default: return 0; @@ -559,9 +559,9 @@ set_xel(int x, int y, const LRGBColorf &value) { case XE_scRGB_alpha: { LRGBColorf scaled = value * 8192.f + 4096.5f; - col.r = min(max(0, (int)scaled[0]), 65535); - col.g = min(max(0, (int)scaled[1]), 65535); - col.b = min(max(0, (int)scaled[2]), 65535); + col.r = std::min(std::max(0, (int)scaled[0]), 65535); + col.g = std::min(std::max(0, (int)scaled[1]), 65535); + col.b = std::min(std::max(0, (int)scaled[2]), 65535); } break; } @@ -721,19 +721,19 @@ set_xel_a(int x, int y, const LColorf &value) { case XE_scRGB: { LColorf scaled = value * 8192.0f + 4096.5f; - col.r = min(max(0, (int)scaled[0]), 65535); - col.g = min(max(0, (int)scaled[1]), 65535); - col.b = min(max(0, (int)scaled[2]), 65535); + col.r = std::min(std::max(0, (int)scaled[0]), 65535); + col.g = std::min(std::max(0, (int)scaled[1]), 65535); + col.b = std::min(std::max(0, (int)scaled[2]), 65535); } break; case XE_scRGB_alpha: { LColorf scaled = value * 8192.0f + 4096.5f; - col.r = min(max(0, (int)scaled[0]), 65535); - col.g = min(max(0, (int)scaled[1]), 65535); - col.b = min(max(0, (int)scaled[2]), 65535); - alpha_row(y)[x] = min(max(0, (int)(value[3] * 65535 + 0.5f)), 65535); + col.r = std::min(std::max(0, (int)scaled[0]), 65535); + col.g = std::min(std::max(0, (int)scaled[1]), 65535); + col.b = std::min(std::max(0, (int)scaled[2]), 65535); + alpha_row(y)[x] = std::min(std::max(0, (int)(value[3] * 65535 + 0.5f)), 65535); } break; } @@ -1210,14 +1210,14 @@ setup_sub_image(const PNMImage ©, int &xto, int &yto, yto = 0; } - x_size = min(x_size, copy.get_x_size() - xfrom); - y_size = min(y_size, copy.get_y_size() - yfrom); + x_size = std::min(x_size, copy.get_x_size() - xfrom); + y_size = std::min(y_size, copy.get_y_size() - yfrom); xmin = xto; ymin = yto; - xmax = min(xmin + x_size, get_x_size()); - ymax = min(ymin + y_size, get_y_size()); + xmax = std::min(xmin + x_size, get_x_size()); + ymax = std::min(ymin + y_size, get_y_size()); } /** diff --git a/panda/src/pnmimage/pnmImage.h b/panda/src/pnmimage/pnmImage.h index 583d5edef2..494acb8029 100644 --- a/panda/src/pnmimage/pnmImage.h +++ b/panda/src/pnmimage/pnmImage.h @@ -102,13 +102,13 @@ PUBLISHED: BLOCKING bool read(const Filename &filename, PNMFileType *type = nullptr, bool report_unknown_type = true); - BLOCKING bool read(istream &data, const string &filename = string(), + BLOCKING bool read(std::istream &data, const std::string &filename = std::string(), PNMFileType *type = nullptr, bool report_unknown_type = true); BLOCKING bool read(PNMReader *reader); BLOCKING bool write(const Filename &filename, PNMFileType *type = nullptr) const; - BLOCKING bool write(ostream &data, const string &filename = string(), + BLOCKING bool write(std::ostream &data, const std::string &filename = std::string(), PNMFileType *type = nullptr) const; BLOCKING bool write(PNMWriter *writer) const; diff --git a/panda/src/pnmimage/pnmImageHeader.I b/panda/src/pnmimage/pnmImageHeader.I index 2801d4d89d..0e4adbaf11 100644 --- a/panda/src/pnmimage/pnmImageHeader.I +++ b/panda/src/pnmimage/pnmImageHeader.I @@ -166,7 +166,7 @@ get_size() const { /** * Gets the user comment from the file. */ -INLINE string PNMImageHeader:: +INLINE std::string PNMImageHeader:: get_comment() const { return _comment; } @@ -175,7 +175,7 @@ get_comment() const { * Writes a user comment string to the image (header). */ INLINE void PNMImageHeader:: -set_comment(const string& comment) { +set_comment(const std::string& comment) { _comment = comment; } diff --git a/panda/src/pnmimage/pnmImageHeader.h b/panda/src/pnmimage/pnmImageHeader.h index 6aeb40642d..162dd21784 100644 --- a/panda/src/pnmimage/pnmImageHeader.h +++ b/panda/src/pnmimage/pnmImageHeader.h @@ -75,8 +75,8 @@ PUBLISHED: INLINE LVecBase2i get_size() const; MAKE_PROPERTY(size, get_size); - INLINE string get_comment() const; - INLINE void set_comment(const string &comment); + INLINE std::string get_comment() const; + INLINE void set_comment(const std::string &comment); MAKE_PROPERTY(comment, get_comment, set_comment); INLINE bool has_type() const; @@ -86,28 +86,28 @@ PUBLISHED: BLOCKING bool read_header(const Filename &filename, PNMFileType *type = nullptr, bool report_unknown_type = true); - BLOCKING bool read_header(istream &data, const string &filename = string(), + BLOCKING bool read_header(std::istream &data, const std::string &filename = std::string(), PNMFileType *type = nullptr, bool report_unknown_type = true); PNMReader *make_reader(const Filename &filename, PNMFileType *type = nullptr, bool report_unknown_type = true) const; - PNMReader *make_reader(istream *file, bool owns_file = true, + PNMReader *make_reader(std::istream *file, bool owns_file = true, const Filename &filename = Filename(), - string magic_number = string(), + std::string magic_number = std::string(), PNMFileType *type = nullptr, bool report_unknown_type = true) const; PNMWriter *make_writer(const Filename &filename, PNMFileType *type = nullptr) const; - PNMWriter *make_writer(ostream *file, bool owns_file = true, + PNMWriter *make_writer(std::ostream *file, bool owns_file = true, const Filename &filename = Filename(), PNMFileType *type = nullptr) const; - static bool read_magic_number(istream *file, string &magic_number, + static bool read_magic_number(std::istream *file, std::string &magic_number, int num_bytes); - void output(ostream &out) const; + void output(std::ostream &out) const; // Contains a single pixel specification used in compute_histogram() and // make_histogram(). Note that pixels are stored by integer value, not by @@ -141,7 +141,7 @@ PUBLISHED: INLINE xelval operator [](int n) const; INLINE static int size(); - void output(ostream &out) const; + void output(std::ostream &out) const; public: xelval _red, _green, _blue, _alpha; @@ -173,7 +173,7 @@ PUBLISHED: INLINE int get_count(const PixelSpec &pixel) const; MAKE_SEQ(get_pixels, get_num_pixels, get_pixel); - void write(ostream &out) const; + void write(std::ostream &out) const; public: INLINE void swap(PixelCount &pixels, HistMap &hist_map); @@ -194,16 +194,16 @@ protected: int _num_channels; xelval _maxval; ColorSpace _color_space; - string _comment; + std::string _comment; PNMFileType *_type; }; -INLINE ostream &operator << (ostream &out, const PNMImageHeader &header) { +INLINE std::ostream &operator << (std::ostream &out, const PNMImageHeader &header) { header.output(out); return out; } -INLINE ostream &operator << (ostream &out, const PNMImageHeader::PixelSpec &pixel) { +INLINE std::ostream &operator << (std::ostream &out, const PNMImageHeader::PixelSpec &pixel) { pixel.output(out); return out; } diff --git a/panda/src/pnmimage/pnmReader.I b/panda/src/pnmimage/pnmReader.I index 3e1f5d8fff..b066a2d7c3 100644 --- a/panda/src/pnmimage/pnmReader.I +++ b/panda/src/pnmimage/pnmReader.I @@ -15,7 +15,7 @@ * */ INLINE PNMReader:: -PNMReader(PNMFileType *type, istream *file, bool owns_file) : +PNMReader(PNMFileType *type, std::istream *file, bool owns_file) : _type(type), _owns_file(owns_file), _file(file), diff --git a/panda/src/pnmimage/pnmReader.h b/panda/src/pnmimage/pnmReader.h index 833c531f29..14355ec43c 100644 --- a/panda/src/pnmimage/pnmReader.h +++ b/panda/src/pnmimage/pnmReader.h @@ -26,7 +26,7 @@ class PfmFile; */ class EXPCL_PANDA_PNMIMAGE PNMReader : public PNMImageHeader { protected: - INLINE PNMReader(PNMFileType *type, istream *file, bool owns_file); + INLINE PNMReader(PNMFileType *type, std::istream *file, bool owns_file); public: virtual ~PNMReader(); @@ -51,7 +51,7 @@ private: protected: PNMFileType *_type; bool _owns_file; - istream *_file; + std::istream *_file; bool _is_valid; int _read_x_size, _read_y_size; diff --git a/panda/src/pnmimage/pnmWriter.I b/panda/src/pnmimage/pnmWriter.I index f9686a5c44..fbc64f6b5f 100644 --- a/panda/src/pnmimage/pnmWriter.I +++ b/panda/src/pnmimage/pnmWriter.I @@ -15,7 +15,7 @@ * */ INLINE PNMWriter:: -PNMWriter(PNMFileType *type, ostream *file, bool owns_file) : +PNMWriter(PNMFileType *type, std::ostream *file, bool owns_file) : _type(type), _owns_file(owns_file), _file(file), diff --git a/panda/src/pnmimage/pnmWriter.h b/panda/src/pnmimage/pnmWriter.h index 062b89602f..1da578124e 100644 --- a/panda/src/pnmimage/pnmWriter.h +++ b/panda/src/pnmimage/pnmWriter.h @@ -26,7 +26,7 @@ class PfmFile; */ class EXPCL_PANDA_PNMIMAGE PNMWriter : public PNMImageHeader { protected: - INLINE PNMWriter(PNMFileType *type, ostream *file, bool owns_file); + INLINE PNMWriter(PNMFileType *type, std::ostream *file, bool owns_file); public: @@ -62,7 +62,7 @@ public: protected: PNMFileType *_type; bool _owns_file; - ostream *_file; + std::ostream *_file; bool _is_valid; }; diff --git a/panda/src/pnmimage/pnmbitio.h b/panda/src/pnmimage/pnmbitio.h index 4213d221b8..464b48617c 100644 --- a/panda/src/pnmimage/pnmbitio.h +++ b/panda/src/pnmimage/pnmbitio.h @@ -30,8 +30,8 @@ typedef struct bitstream *BITSTREAM; * Returns 0 on error. */ -extern EXPCL_PANDA_PNMIMAGE BITSTREAM pm_bitinit(istream *f, const char *mode); -extern EXPCL_PANDA_PNMIMAGE BITSTREAM pm_bitinit(ostream *f, const char *mode); +extern EXPCL_PANDA_PNMIMAGE BITSTREAM pm_bitinit(std::istream *f, const char *mode); +extern EXPCL_PANDA_PNMIMAGE BITSTREAM pm_bitinit(std::ostream *f, const char *mode); /* * pm_bitfini() - deallocate the given BITSTREAM. diff --git a/panda/src/pnmimage/pnmimage_base.h b/panda/src/pnmimage/pnmimage_base.h index e9c36416cc..a332d693dc 100644 --- a/panda/src/pnmimage/pnmimage_base.h +++ b/panda/src/pnmimage/pnmimage_base.h @@ -61,7 +61,7 @@ PUBLISHED: #ifdef HAVE_PYTHON static int size() { return 3; } - void output(ostream &out) { + void output(std::ostream &out) { out << "pixel(r=" << r << ", g=" << g << ", b=" << b << ")"; } #endif @@ -105,14 +105,14 @@ EXPCL_PANDA_PNMIMAGE int pm_bitstomaxval(int bits); EXPCL_PANDA_PNMIMAGE char *pm_allocrow(int cols, int size); EXPCL_PANDA_PNMIMAGE void pm_freerow(char *itrow); -EXPCL_PANDA_PNMIMAGE int pm_readbigshort(istream *in, short *sP); -EXPCL_PANDA_PNMIMAGE int pm_writebigshort(ostream *out, short s); -EXPCL_PANDA_PNMIMAGE int pm_readbiglong(istream *in, long *lP); -EXPCL_PANDA_PNMIMAGE int pm_writebiglong(ostream *out, long l); -EXPCL_PANDA_PNMIMAGE int pm_readlittleshort(istream *in, short *sP); -EXPCL_PANDA_PNMIMAGE int pm_writelittleshort(ostream *out, short s); -EXPCL_PANDA_PNMIMAGE int pm_readlittlelong(istream *in, long *lP); -EXPCL_PANDA_PNMIMAGE int pm_writelittlelong(ostream *out, long l); +EXPCL_PANDA_PNMIMAGE int pm_readbigshort(std::istream *in, short *sP); +EXPCL_PANDA_PNMIMAGE int pm_writebigshort(std::ostream *out, short s); +EXPCL_PANDA_PNMIMAGE int pm_readbiglong(std::istream *in, long *lP); +EXPCL_PANDA_PNMIMAGE int pm_writebiglong(std::ostream *out, long l); +EXPCL_PANDA_PNMIMAGE int pm_readlittleshort(std::istream *in, short *sP); +EXPCL_PANDA_PNMIMAGE int pm_writelittleshort(std::ostream *out, short s); +EXPCL_PANDA_PNMIMAGE int pm_readlittlelong(std::istream *in, long *lP); +EXPCL_PANDA_PNMIMAGE int pm_writelittlelong(std::ostream *out, long l); // These ratios are used to compute the brightness of a colored pixel; they diff --git a/panda/src/pnmimagetypes/config_pnmimagetypes.h b/panda/src/pnmimagetypes/config_pnmimagetypes.h index 95ed9224a5..75fb491143 100644 --- a/panda/src/pnmimagetypes/config_pnmimagetypes.h +++ b/panda/src/pnmimagetypes/config_pnmimagetypes.h @@ -46,8 +46,8 @@ enum SGIStorageType { SST_verbatim = STORAGE_VERBATIM, }; -EXPCL_PANDA_PNMIMAGETYPES ostream &operator << (ostream &out, SGIStorageType sst); -EXPCL_PANDA_PNMIMAGETYPES istream &operator >> (istream &in, SGIStorageType &sst); +EXPCL_PANDA_PNMIMAGETYPES std::ostream &operator << (std::ostream &out, SGIStorageType sst); +EXPCL_PANDA_PNMIMAGETYPES std::istream &operator >> (std::istream &in, SGIStorageType &sst); extern ConfigVariableEnum sgi_storage_type; extern ConfigVariableString sgi_imagename; @@ -68,8 +68,8 @@ enum IMGHeaderType { IHT_long, }; -EXPCL_PANDA_PNMIMAGETYPES ostream &operator << (ostream &out, IMGHeaderType iht); -EXPCL_PANDA_PNMIMAGETYPES istream &operator >> (istream &in, IMGHeaderType &iht); +EXPCL_PANDA_PNMIMAGETYPES std::ostream &operator << (std::ostream &out, IMGHeaderType iht); +EXPCL_PANDA_PNMIMAGETYPES std::istream &operator >> (std::istream &in, IMGHeaderType &iht); extern ConfigVariableEnum img_header_type; extern ConfigVariableInt img_size; diff --git a/panda/src/pnmimagetypes/pnmFileTypeBMP.h b/panda/src/pnmimagetypes/pnmFileTypeBMP.h index 731fc06477..6cd3e8e32f 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeBMP.h +++ b/panda/src/pnmimagetypes/pnmFileTypeBMP.h @@ -29,23 +29,23 @@ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeBMP : public PNMFileType { public: PNMFileTypeBMP(); - virtual string get_name() const; + virtual std::string get_name() const; virtual int get_num_extensions() const; - virtual string get_extension(int n) const; - virtual string get_suggested_extension() const; + virtual std::string get_extension(int n) const; + virtual std::string get_suggested_extension() const; virtual bool has_magic_number() const; - virtual bool matches_magic_number(const string &magic_number) const; + virtual bool matches_magic_number(const std::string &magic_number) const; - virtual PNMReader *make_reader(istream *file, bool owns_file = true, - const string &magic_number = string()); - virtual PNMWriter *make_writer(ostream *file, bool owns_file = true); + virtual PNMReader *make_reader(std::istream *file, bool owns_file = true, + const std::string &magic_number = std::string()); + virtual PNMWriter *make_writer(std::ostream *file, bool owns_file = true); public: class Reader : public PNMReader { public: - Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number); + Reader(PNMFileType *type, std::istream *file, bool owns_file, std::string magic_number); virtual int read_data(xel *array, xelval *alpha); @@ -65,7 +65,7 @@ public: class Writer : public PNMWriter { public: - Writer(PNMFileType *type, ostream *file, bool owns_file); + Writer(PNMFileType *type, std::ostream *file, bool owns_file); virtual int write_data(xel *array, xelval *alpha); virtual bool supports_grayscale() const; diff --git a/panda/src/pnmimagetypes/pnmFileTypeEXR.h b/panda/src/pnmimagetypes/pnmFileTypeEXR.h index 58292d11a8..75a2b000e9 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeEXR.h +++ b/panda/src/pnmimagetypes/pnmFileTypeEXR.h @@ -40,23 +40,23 @@ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeEXR : public PNMFileType { public: PNMFileTypeEXR(); - virtual string get_name() const; + virtual std::string get_name() const; virtual int get_num_extensions() const; - virtual string get_extension(int n) const; - virtual string get_suggested_extension() const; + virtual std::string get_extension(int n) const; + virtual std::string get_suggested_extension() const; virtual bool has_magic_number() const; - virtual bool matches_magic_number(const string &magic_number) const; + virtual bool matches_magic_number(const std::string &magic_number) const; - virtual PNMReader *make_reader(istream *file, bool owns_file = true, - const string &magic_number = string()); - virtual PNMWriter *make_writer(ostream *file, bool owns_file = true); + virtual PNMReader *make_reader(std::istream *file, bool owns_file = true, + const std::string &magic_number = std::string()); + virtual PNMWriter *make_writer(std::ostream *file, bool owns_file = true); public: class Reader : public PNMReader { public: - Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number); + Reader(PNMFileType *type, std::istream *file, bool owns_file, std::string magic_number); virtual ~Reader(); virtual bool is_floating_point(); @@ -73,7 +73,7 @@ public: class Writer : public PNMWriter { public: - Writer(PNMFileType *type, ostream *file, bool owns_file); + Writer(PNMFileType *type, std::ostream *file, bool owns_file); virtual bool supports_floating_point(); virtual bool supports_integer(); diff --git a/panda/src/pnmimagetypes/pnmFileTypeIMG.h b/panda/src/pnmimagetypes/pnmFileTypeIMG.h index 084caf4152..2c406dfa68 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeIMG.h +++ b/panda/src/pnmimagetypes/pnmFileTypeIMG.h @@ -29,20 +29,20 @@ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeIMG : public PNMFileType { public: PNMFileTypeIMG(); - virtual string get_name() const; + virtual std::string get_name() const; virtual int get_num_extensions() const; - virtual string get_extension(int n) const; - virtual string get_suggested_extension() const; + virtual std::string get_extension(int n) const; + virtual std::string get_suggested_extension() const; - virtual PNMReader *make_reader(istream *file, bool owns_file = true, - const string &magic_number = string()); - virtual PNMWriter *make_writer(ostream *file, bool owns_file = true); + virtual PNMReader *make_reader(std::istream *file, bool owns_file = true, + const std::string &magic_number = std::string()); + virtual PNMWriter *make_writer(std::ostream *file, bool owns_file = true); public: class Reader : public PNMReader { public: - Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number); + Reader(PNMFileType *type, std::istream *file, bool owns_file, std::string magic_number); virtual bool supports_read_row() const; virtual bool read_row(xel *array, xelval *alpha, int x_size, int y_size); @@ -50,7 +50,7 @@ public: class Writer : public PNMWriter { public: - Writer(PNMFileType *type, ostream *file, bool owns_file); + Writer(PNMFileType *type, std::ostream *file, bool owns_file); virtual bool supports_write_row() const; virtual bool write_header(); diff --git a/panda/src/pnmimagetypes/pnmFileTypeJPG.h b/panda/src/pnmimagetypes/pnmFileTypeJPG.h index 591c7fe247..f851c6d226 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeJPG.h +++ b/panda/src/pnmimagetypes/pnmFileTypeJPG.h @@ -59,23 +59,23 @@ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeJPG : public PNMFileType { public: PNMFileTypeJPG(); - virtual string get_name() const; + virtual std::string get_name() const; virtual int get_num_extensions() const; - virtual string get_extension(int n) const; - virtual string get_suggested_extension() const; + virtual std::string get_extension(int n) const; + virtual std::string get_suggested_extension() const; virtual bool has_magic_number() const; - virtual bool matches_magic_number(const string &magic_number) const; + virtual bool matches_magic_number(const std::string &magic_number) const; - virtual PNMReader *make_reader(istream *file, bool owns_file = true, - const string &magic_number = string()); - virtual PNMWriter *make_writer(ostream *file, bool owns_file = true); + virtual PNMReader *make_reader(std::istream *file, bool owns_file = true, + const std::string &magic_number = std::string()); + virtual PNMWriter *make_writer(std::ostream *file, bool owns_file = true); public: class Reader : public PNMReader { public: - Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number); + Reader(PNMFileType *type, std::istream *file, bool owns_file, std::string magic_number); ~Reader(); virtual void prepare_read(); @@ -94,7 +94,7 @@ public: class Writer : public PNMWriter { public: - Writer(PNMFileType *type, ostream *file, bool owns_file); + Writer(PNMFileType *type, std::ostream *file, bool owns_file); virtual int write_data(xel *array, xelval *alpha); }; diff --git a/panda/src/pnmimagetypes/pnmFileTypePNG.h b/panda/src/pnmimagetypes/pnmFileTypePNG.h index 79b9fb1f73..3c1df88cbc 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePNG.h +++ b/panda/src/pnmimagetypes/pnmFileTypePNG.h @@ -32,23 +32,23 @@ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypePNG : public PNMFileType { public: PNMFileTypePNG(); - virtual string get_name() const; + virtual std::string get_name() const; virtual int get_num_extensions() const; - virtual string get_extension(int n) const; - virtual string get_suggested_extension() const; + virtual std::string get_extension(int n) const; + virtual std::string get_suggested_extension() const; virtual bool has_magic_number() const; - virtual bool matches_magic_number(const string &magic_number) const; + virtual bool matches_magic_number(const std::string &magic_number) const; - virtual PNMReader *make_reader(istream *file, bool owns_file = true, - const string &magic_number = string()); - virtual PNMWriter *make_writer(ostream *file, bool owns_file = true); + virtual PNMReader *make_reader(std::istream *file, bool owns_file = true, + const std::string &magic_number = std::string()); + virtual PNMWriter *make_writer(std::ostream *file, bool owns_file = true); public: class Reader : public PNMReader { public: - Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number); + Reader(PNMFileType *type, std::istream *file, bool owns_file, std::string magic_number); virtual ~Reader(); virtual int read_data(xel *array, xelval *alpha_data); @@ -72,7 +72,7 @@ public: class Writer : public PNMWriter { public: - Writer(PNMFileType *type, ostream *file, bool owns_file); + Writer(PNMFileType *type, std::ostream *file, bool owns_file); virtual ~Writer(); virtual int write_data(xel *array, xelval *alpha); diff --git a/panda/src/pnmimagetypes/pnmFileTypePNM.h b/panda/src/pnmimagetypes/pnmFileTypePNM.h index 1f5bc4cc7d..1c65c19109 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePNM.h +++ b/panda/src/pnmimagetypes/pnmFileTypePNM.h @@ -29,23 +29,23 @@ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypePNM : public PNMFileType { public: PNMFileTypePNM(); - virtual string get_name() const; + virtual std::string get_name() const; virtual int get_num_extensions() const; - virtual string get_extension(int n) const; - virtual string get_suggested_extension() const; + virtual std::string get_extension(int n) const; + virtual std::string get_suggested_extension() const; virtual bool has_magic_number() const; - virtual bool matches_magic_number(const string &magic_number) const; + virtual bool matches_magic_number(const std::string &magic_number) const; - virtual PNMReader *make_reader(istream *file, bool owns_file = true, - const string &magic_number = string()); - virtual PNMWriter *make_writer(ostream *file, bool owns_file = true); + virtual PNMReader *make_reader(std::istream *file, bool owns_file = true, + const std::string &magic_number = std::string()); + virtual PNMWriter *make_writer(std::ostream *file, bool owns_file = true); public: class Reader : public PNMReader { public: - Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number); + Reader(PNMFileType *type, std::istream *file, bool owns_file, std::string magic_number); virtual bool supports_read_row() const; virtual bool read_row(xel *array, xelval *alpha, int x_size, int y_size); @@ -56,7 +56,7 @@ public: class Writer : public PNMWriter { public: - Writer(PNMFileType *type, ostream *file, bool owns_file); + Writer(PNMFileType *type, std::ostream *file, bool owns_file); virtual bool supports_write_row() const; virtual bool write_header(); diff --git a/panda/src/pnmimagetypes/pnmFileTypePfm.h b/panda/src/pnmimagetypes/pnmFileTypePfm.h index cbc7bb4512..aa41adb1df 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePfm.h +++ b/panda/src/pnmimagetypes/pnmFileTypePfm.h @@ -29,23 +29,23 @@ class EXPCL_PANDA_PNMIMAGE PNMFileTypePfm : public PNMFileType { public: PNMFileTypePfm(); - virtual string get_name() const; + virtual std::string get_name() const; virtual int get_num_extensions() const; - virtual string get_extension(int n) const; - virtual string get_suggested_extension() const; + virtual std::string get_extension(int n) const; + virtual std::string get_suggested_extension() const; virtual bool has_magic_number() const; - virtual bool matches_magic_number(const string &magic_number) const; + virtual bool matches_magic_number(const std::string &magic_number) const; - virtual PNMReader *make_reader(istream *file, bool owns_file = true, - const string &magic_number = string()); - virtual PNMWriter *make_writer(ostream *file, bool owns_file = true); + virtual PNMReader *make_reader(std::istream *file, bool owns_file = true, + const std::string &magic_number = std::string()); + virtual PNMWriter *make_writer(std::ostream *file, bool owns_file = true); public: class Reader : public PNMReader { public: - Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number); + Reader(PNMFileType *type, std::istream *file, bool owns_file, std::string magic_number); virtual bool is_floating_point(); virtual bool read_pfm(PfmFile &pfm); @@ -56,7 +56,7 @@ public: class Writer : public PNMWriter { public: - Writer(PNMFileType *type, ostream *file, bool owns_file); + Writer(PNMFileType *type, std::ostream *file, bool owns_file); virtual bool supports_floating_point(); virtual bool supports_integer(); diff --git a/panda/src/pnmimagetypes/pnmFileTypeSGI.h b/panda/src/pnmimagetypes/pnmFileTypeSGI.h index 300ccfd777..ff026a3740 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSGI.h +++ b/panda/src/pnmimagetypes/pnmFileTypeSGI.h @@ -29,23 +29,23 @@ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeSGI : public PNMFileType { public: PNMFileTypeSGI(); - virtual string get_name() const; + virtual std::string get_name() const; virtual int get_num_extensions() const; - virtual string get_extension(int n) const; - virtual string get_suggested_extension() const; + virtual std::string get_extension(int n) const; + virtual std::string get_suggested_extension() const; virtual bool has_magic_number() const; - virtual bool matches_magic_number(const string &magic_number) const; + virtual bool matches_magic_number(const std::string &magic_number) const; - virtual PNMReader *make_reader(istream *file, bool owns_file = true, - const string &magic_number = string()); - virtual PNMWriter *make_writer(ostream *file, bool owns_file = true); + virtual PNMReader *make_reader(std::istream *file, bool owns_file = true, + const std::string &magic_number = std::string()); + virtual PNMWriter *make_writer(std::ostream *file, bool owns_file = true); public: class Reader : public PNMReader { public: - Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number); + Reader(PNMFileType *type, std::istream *file, bool owns_file, std::string magic_number); virtual ~Reader(); virtual bool supports_read_row() const; @@ -65,7 +65,7 @@ public: class Writer : public PNMWriter { public: - Writer(PNMFileType *type, ostream *file, bool owns_file); + Writer(PNMFileType *type, std::ostream *file, bool owns_file); virtual ~Writer(); virtual bool supports_write_row() const; @@ -90,7 +90,7 @@ public: void write_rgb_header(const char *imagename); void write_table(); - void write_channels(ScanLine channel[], void (*put)(ostream *, short)); + void write_channels(ScanLine channel[], void (*put)(std::ostream *, short)); void build_scanline(ScanLine output[], xel *row_data, xelval *alpha_data); ScanElem *compress(ScanElem *temp, ScanLine &output); int rle_compress(ScanElem *inbuf, int size); diff --git a/panda/src/pnmimagetypes/pnmFileTypeSoftImage.h b/panda/src/pnmimagetypes/pnmFileTypeSoftImage.h index 9fffbbd42d..c6e6860621 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSoftImage.h +++ b/panda/src/pnmimagetypes/pnmFileTypeSoftImage.h @@ -29,23 +29,23 @@ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeSoftImage : public PNMFileType { public: PNMFileTypeSoftImage(); - virtual string get_name() const; + virtual std::string get_name() const; virtual int get_num_extensions() const; - virtual string get_extension(int n) const; - virtual string get_suggested_extension() const; + virtual std::string get_extension(int n) const; + virtual std::string get_suggested_extension() const; virtual bool has_magic_number() const; - virtual bool matches_magic_number(const string &magic_number) const; + virtual bool matches_magic_number(const std::string &magic_number) const; - virtual PNMReader *make_reader(istream *file, bool owns_file = true, - const string &magic_number = string()); - virtual PNMWriter *make_writer(ostream *file, bool owns_file = true); + virtual PNMReader *make_reader(std::istream *file, bool owns_file = true, + const std::string &magic_number = std::string()); + virtual PNMWriter *make_writer(std::ostream *file, bool owns_file = true); public: class Reader : public PNMReader { public: - Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number); + Reader(PNMFileType *type, std::istream *file, bool owns_file, std::string magic_number); virtual bool supports_read_row() const; virtual bool read_row(xel *array, xelval *alpha, int x_size, int y_size); @@ -57,7 +57,7 @@ public: class Writer : public PNMWriter { public: - Writer(PNMFileType *type, ostream *file, bool owns_file); + Writer(PNMFileType *type, std::ostream *file, bool owns_file); virtual bool supports_write_row() const; virtual bool write_header(); diff --git a/panda/src/pnmimagetypes/pnmFileTypeStbImage.h b/panda/src/pnmimagetypes/pnmFileTypeStbImage.h index 08cf62e247..ce7d2d55ea 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeStbImage.h +++ b/panda/src/pnmimagetypes/pnmFileTypeStbImage.h @@ -31,16 +31,16 @@ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeStbImage : public PNMFileType { public: PNMFileTypeStbImage(); - virtual string get_name() const; + virtual std::string get_name() const; virtual int get_num_extensions() const; - virtual string get_extension(int n) const; + virtual std::string get_extension(int n) const; virtual bool has_magic_number() const; - virtual bool matches_magic_number(const string &magic_number) const; + virtual bool matches_magic_number(const std::string &magic_number) const; - virtual PNMReader *make_reader(istream *file, bool owns_file = true, - const string &magic_number = string()); + virtual PNMReader *make_reader(std::istream *file, bool owns_file = true, + const std::string &magic_number = std::string()); public: static void register_with_read_factory(); diff --git a/panda/src/pnmimagetypes/pnmFileTypeTGA.h b/panda/src/pnmimagetypes/pnmFileTypeTGA.h index 911ebb7c20..c50a09ed47 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTGA.h +++ b/panda/src/pnmimagetypes/pnmFileTypeTGA.h @@ -34,30 +34,30 @@ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeTGA : public PNMFileType { public: PNMFileTypeTGA(); - virtual string get_name() const; + virtual std::string get_name() const; virtual int get_num_extensions() const; - virtual string get_extension(int n) const; - virtual string get_suggested_extension() const; + virtual std::string get_extension(int n) const; + virtual std::string get_suggested_extension() const; - virtual PNMReader *make_reader(istream *file, bool owns_file = true, - const string &magic_number = string()); - virtual PNMWriter *make_writer(ostream *file, bool owns_file = true); + virtual PNMReader *make_reader(std::istream *file, bool owns_file = true, + const std::string &magic_number = std::string()); + virtual PNMWriter *make_writer(std::ostream *file, bool owns_file = true); public: class Reader : public PNMReader { public: - Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number); + Reader(PNMFileType *type, std::istream *file, bool owns_file, std::string magic_number); virtual ~Reader(); virtual int read_data(xel *array, xelval *alpha); private: - void readtga ( istream* ifp, struct ImageHeader* tgaP, const string &magic_number ); - void get_map_entry ( istream* ifp, pixel* Value, int Size, + void readtga ( std::istream* ifp, struct ImageHeader* tgaP, const std::string &magic_number ); + void get_map_entry ( std::istream* ifp, pixel* Value, int Size, gray* Alpha); - void get_pixel ( istream* ifp, pixel* dest, int Size, gray* alpha_p); - unsigned char getbyte ( istream* ifp ); + void get_pixel ( std::istream* ifp, pixel* dest, int Size, gray* alpha_p); + unsigned char getbyte ( std::istream* ifp ); int rows, cols, rlencoded, mapped; struct ImageHeader *tga_head; @@ -72,7 +72,7 @@ public: class Writer : public PNMWriter { public: - Writer(PNMFileType *type, ostream *file, bool owns_file); + Writer(PNMFileType *type, std::ostream *file, bool owns_file); virtual ~Writer(); virtual int write_data(xel *array, xelval *alpha); diff --git a/panda/src/pnmimagetypes/pnmFileTypeTIFF.h b/panda/src/pnmimagetypes/pnmFileTypeTIFF.h index 21466b2cd9..c61e4f53f1 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTIFF.h +++ b/panda/src/pnmimagetypes/pnmFileTypeTIFF.h @@ -34,23 +34,23 @@ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeTIFF : public PNMFileType { public: PNMFileTypeTIFF(); - virtual string get_name() const; + virtual std::string get_name() const; virtual int get_num_extensions() const; - virtual string get_extension(int n) const; - virtual string get_suggested_extension() const; + virtual std::string get_extension(int n) const; + virtual std::string get_suggested_extension() const; virtual bool has_magic_number() const; - virtual bool matches_magic_number(const string &magic_number) const; + virtual bool matches_magic_number(const std::string &magic_number) const; - virtual PNMReader *make_reader(istream *file, bool owns_file = true, - const string &magic_number = string()); - virtual PNMWriter *make_writer(ostream *file, bool owns_file = true); + virtual PNMReader *make_reader(std::istream *file, bool owns_file = true, + const std::string &magic_number = std::string()); + virtual PNMWriter *make_writer(std::ostream *file, bool owns_file = true); public: class Reader : public PNMReader { public: - Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number); + Reader(PNMFileType *type, std::istream *file, bool owns_file, std::string magic_number); virtual ~Reader(); virtual bool is_floating_point(); @@ -77,7 +77,7 @@ public: class Writer : public PNMWriter { public: - Writer(PNMFileType *type, ostream *file, bool owns_file); + Writer(PNMFileType *type, std::ostream *file, bool owns_file); virtual bool supports_floating_point(); virtual bool supports_integer(); diff --git a/panda/src/pnmtext/freetypeFace.h b/panda/src/pnmtext/freetypeFace.h index 2070e5ca66..e8c0774eee 100644 --- a/panda/src/pnmtext/freetypeFace.h +++ b/panda/src/pnmtext/freetypeFace.h @@ -46,9 +46,9 @@ private: private: // This is provided as a permanent storage for the raw font data, if needed. - string _font_data; + std::string _font_data; - string _name; + std::string _name; FT_Face _face; int _char_size; int _dpi; diff --git a/panda/src/pnmtext/freetypeFont.h b/panda/src/pnmtext/freetypeFont.h index a33059f3d7..dc89b09218 100644 --- a/panda/src/pnmtext/freetypeFont.h +++ b/panda/src/pnmtext/freetypeFont.h @@ -85,7 +85,7 @@ PUBLISHED: MAKE_PROPERTY(winding_order, get_winding_order, set_winding_order); public: - static WindingOrder string_winding_order(const string &string); + static WindingOrder string_winding_order(const std::string &string); protected: INLINE FT_Face acquire_face() const; @@ -163,8 +163,8 @@ protected: #include "freetypeFont.I" -EXPCL_PANDA_PNMTEXT ostream &operator << (ostream &out, FreetypeFont::WindingOrder wo); -EXPCL_PANDA_PNMTEXT istream &operator >> (istream &in, FreetypeFont::WindingOrder &wo); +EXPCL_PANDA_PNMTEXT std::ostream &operator << (std::ostream &out, FreetypeFont::WindingOrder wo); +EXPCL_PANDA_PNMTEXT std::istream &operator >> (std::istream &in, FreetypeFont::WindingOrder &wo); #endif // HAVE_FREETYPE diff --git a/panda/src/pnmtext/pnmTextMaker.I b/panda/src/pnmtext/pnmTextMaker.I index c8cce09b52..96eb380976 100644 --- a/panda/src/pnmtext/pnmTextMaker.I +++ b/panda/src/pnmtext/pnmTextMaker.I @@ -122,7 +122,7 @@ get_distance_field_radius() const { * position; the return value is the total width in pixels. */ INLINE int PNMTextMaker:: -generate_into(const string &text, PNMImage &dest_image, int x, int y) { +generate_into(const std::string &text, PNMImage &dest_image, int x, int y) { TextEncoder encoder; encoder.set_text(text); return generate_into(encoder.get_wtext(), dest_image, x, y); @@ -132,7 +132,7 @@ generate_into(const string &text, PNMImage &dest_image, int x, int y) { * Returns the width in pixels of the indicated line of text. */ INLINE int PNMTextMaker:: -calc_width(const string &text) { +calc_width(const std::string &text) { TextEncoder encoder; encoder.set_text(text); return calc_width(encoder.get_wtext()); diff --git a/panda/src/pnmtext/pnmTextMaker.h b/panda/src/pnmtext/pnmTextMaker.h index 4ae8f04069..213298f81c 100644 --- a/panda/src/pnmtext/pnmTextMaker.h +++ b/panda/src/pnmtext/pnmTextMaker.h @@ -63,12 +63,12 @@ PUBLISHED: INLINE void set_distance_field_radius(int radius); INLINE int get_distance_field_radius() const; - INLINE int generate_into(const string &text, + INLINE int generate_into(const std::string &text, PNMImage &dest_image, int x, int y); - int generate_into(const wstring &text, + int generate_into(const std::wstring &text, PNMImage &dest_image, int x, int y); - INLINE int calc_width(const string &text); - int calc_width(const wstring &text); + INLINE int calc_width(const std::string &text); + int calc_width(const std::wstring &text); PNMTextGlyph *get_glyph(int character); diff --git a/panda/src/pstatclient/pStatClient.I b/panda/src/pstatclient/pStatClient.I index b13eb43401..452c165901 100644 --- a/panda/src/pstatclient/pStatClient.I +++ b/panda/src/pstatclient/pStatClient.I @@ -42,18 +42,18 @@ get_num_threads() const { /** * Returns the name of the indicated thread. */ -INLINE string PStatClient:: +INLINE std::string PStatClient:: get_thread_name(int index) const { - nassertr(index >= 0 && index < AtomicAdjust::get(_num_threads), string()); + nassertr(index >= 0 && index < AtomicAdjust::get(_num_threads), std::string()); return get_thread_ptr(index)->_name; } /** * Returns the sync_name of the indicated thread. */ -INLINE string PStatClient:: +INLINE std::string PStatClient:: get_thread_sync_name(int index) const { - nassertr(index >= 0 && index < AtomicAdjust::get(_num_threads), string()); + nassertr(index >= 0 && index < AtomicAdjust::get(_num_threads), std::string()); return get_thread_ptr(index)->_sync_name; } @@ -72,7 +72,7 @@ get_thread_object(int index) const { * true if successful, false on failure. */ INLINE bool PStatClient:: -connect(const string &hostname, int port) { +connect(const std::string &hostname, int port) { return get_global_pstats()->client_connect(hostname, port); } @@ -161,7 +161,7 @@ get_thread_ptr(int thread_index) const { * */ INLINE PStatClient::Collector:: -Collector(int parent_index, const string &name) : +Collector(int parent_index, const std::string &name) : _def(nullptr), _parent_index(parent_index), _name(name) @@ -179,7 +179,7 @@ get_parent_index() const { /** * */ -INLINE const string &PStatClient::Collector:: +INLINE const std::string &PStatClient::Collector:: get_name() const { return _name; } diff --git a/panda/src/pstatclient/pStatClient.h b/panda/src/pstatclient/pStatClient.h index 6fb41c4c3c..8ee255613b 100644 --- a/panda/src/pstatclient/pStatClient.h +++ b/panda/src/pstatclient/pStatClient.h @@ -56,8 +56,8 @@ public: ~PStatClient(); PUBLISHED: - void set_client_name(const string &name); - string get_client_name() const; + void set_client_name(const std::string &name); + std::string get_client_name() const; void set_max_rate(double rate); double get_max_rate() const; @@ -65,14 +65,14 @@ PUBLISHED: PStatCollector get_collector(int index) const; MAKE_SEQ(get_collectors, get_num_collectors, get_collector); INLINE PStatCollectorDef *get_collector_def(int index) const; - string get_collector_name(int index) const; - string get_collector_fullname(int index) const; + std::string get_collector_name(int index) const; + std::string get_collector_fullname(int index) const; INLINE int get_num_threads() const; PStatThread get_thread(int index) const; MAKE_SEQ(get_threads, get_num_threads, get_thread); - INLINE string get_thread_name(int index) const; - INLINE string get_thread_sync_name(int index) const; + INLINE std::string get_thread_name(int index) const; + INLINE std::string get_thread_sync_name(int index) const; INLINE PT(Thread) get_thread_object(int index) const; PStatThread get_main_thread() const; @@ -88,18 +88,18 @@ PUBLISHED: MAKE_PROPERTY(current_thread, get_current_thread); MAKE_PROPERTY(real_time, get_real_time); - INLINE static bool connect(const string &hostname = string(), int port = -1); + INLINE static bool connect(const std::string &hostname = std::string(), int port = -1); INLINE static void disconnect(); INLINE static bool is_connected(); INLINE static void resume_after_pause(); static void main_tick(); - static void thread_tick(const string &sync_name); + static void thread_tick(const std::string &sync_name); void client_main_tick(); - void client_thread_tick(const string &sync_name); - bool client_connect(string hostname, int port); + void client_thread_tick(const std::string &sync_name); + bool client_connect(std::string hostname, int port); void client_disconnect(); bool client_is_connected() const; @@ -113,12 +113,12 @@ private: INLINE const PStatClientImpl *get_impl() const; void make_impl() const; - PStatCollector make_collector_with_relname(int parent_index, string relname); - PStatCollector make_collector_with_name(int parent_index, const string &name); + PStatCollector make_collector_with_relname(int parent_index, std::string relname); + PStatCollector make_collector_with_name(int parent_index, const std::string &name); PStatThread do_get_current_thread() const; PStatThread make_thread(Thread *thread); PStatThread do_make_thread(Thread *thread); - PStatThread make_gpu_thread(const string &name); + PStatThread make_gpu_thread(const std::string &name); bool is_active(int collector_index, int thread_index) const; bool is_started(int collector_index, int thread_index) const; @@ -152,8 +152,8 @@ private: // This mutex protects everything in this class. ReMutex _lock; - typedef pmap ThingsByName; - typedef pmap MultiThingsByName; + typedef pmap ThingsByName; + typedef pmap MultiThingsByName; MultiThingsByName _threads_by_name, _threads_by_sync_name; // This is for the data that is per-collector, per-thread. A vector of @@ -171,9 +171,9 @@ private: // in PStatCollector and PStatCollectorDef is just fluff.) class Collector { public: - INLINE Collector(int parent_index, const string &name); + INLINE Collector(int parent_index, const std::string &name); INLINE int get_parent_index() const; - INLINE const string &get_name() const; + INLINE const std::string &get_name() const; INLINE bool is_active() const; INLINE PStatCollectorDef *get_def(const PStatClient *client, int this_index) const; @@ -187,7 +187,7 @@ private: // This data is used to create the PStatCollectorDef when it is needed. int _parent_index; - string _name; + std::string _name; public: // Relations to other collectors. @@ -205,11 +205,11 @@ private: class InternalThread { public: InternalThread(Thread *thread); - InternalThread(const string &name, const string &sync_name = "Main"); + InternalThread(const std::string &name, const std::string &sync_name = "Main"); WPT(Thread) _thread; - string _name; - string _sync_name; + std::string _name; + std::string _sync_name; PStatFrameData _frame_data; bool _is_active; int _frame_number; @@ -266,13 +266,13 @@ public: ~PStatClient() { } PUBLISHED: - INLINE static bool connect(const string & = string(), int = -1) { return false; } + INLINE static bool connect(const std::string & = std::string(), int = -1) { return false; } INLINE static void disconnect() { } INLINE static bool is_connected() { return false; } INLINE static void resume_after_pause() { } INLINE static void main_tick() { } - INLINE static void thread_tick(const string &) { } + INLINE static void thread_tick(const std::string &) { } }; #endif // DO_PSTATS diff --git a/panda/src/pstatclient/pStatClientControlMessage.h b/panda/src/pstatclient/pStatClientControlMessage.h index b815f3f558..97e7dede98 100644 --- a/panda/src/pstatclient/pStatClientControlMessage.h +++ b/panda/src/pstatclient/pStatClientControlMessage.h @@ -45,8 +45,8 @@ public: Type _type; // Used for T_hello - string _client_hostname; - string _client_progname; + std::string _client_hostname; + std::string _client_progname; int _major_version; int _minor_version; @@ -55,7 +55,7 @@ public: // Used for T_define_threads int _first_thread_index; - pvector _names; + pvector _names; }; diff --git a/panda/src/pstatclient/pStatClientImpl.I b/panda/src/pstatclient/pStatClientImpl.I index 95f6f13740..8e38b9a486 100644 --- a/panda/src/pstatclient/pStatClientImpl.I +++ b/panda/src/pstatclient/pStatClientImpl.I @@ -16,14 +16,14 @@ * will presumably be written in the title bar or something. */ INLINE void PStatClientImpl:: -set_client_name(const string &name) { +set_client_name(const std::string &name) { _client_name = name; } /** * Retrieves the name of the client as set. */ -INLINE string PStatClientImpl:: +INLINE std::string PStatClientImpl:: get_client_name() const { return _client_name; } diff --git a/panda/src/pstatclient/pStatClientImpl.h b/panda/src/pstatclient/pStatClientImpl.h index 88327defb5..598a2e63e7 100644 --- a/panda/src/pstatclient/pStatClientImpl.h +++ b/panda/src/pstatclient/pStatClientImpl.h @@ -51,15 +51,15 @@ public: PStatClientImpl(PStatClient *client); ~PStatClientImpl(); - INLINE void set_client_name(const string &name); - INLINE string get_client_name() const; + INLINE void set_client_name(const std::string &name); + INLINE std::string get_client_name() const; INLINE void set_max_rate(double rate); INLINE double get_max_rate() const; INLINE double get_real_time() const; INLINE void client_main_tick(); - bool client_connect(string hostname, int port); + bool client_connect(std::string hostname, int port); void client_disconnect(); INLINE bool client_is_connected() const; @@ -79,7 +79,7 @@ private: double _last_frame; // Networking stuff - string get_hostname(); + std::string get_hostname(); void send_hello(); void report_new_collectors(); void report_new_threads(); @@ -103,8 +103,8 @@ private: int _collectors_reported; int _threads_reported; - string _hostname; - string _client_name; + std::string _hostname; + std::string _client_name; double _max_rate; double _tcp_count_factor; diff --git a/panda/src/pstatclient/pStatCollector.I b/panda/src/pstatclient/pStatCollector.I index 23a2cf6199..a729a22fa8 100644 --- a/panda/src/pstatclient/pStatCollector.I +++ b/panda/src/pstatclient/pStatCollector.I @@ -54,7 +54,7 @@ PStatCollector() : * register the collector with; otherwise, the global client is used. */ INLINE PStatCollector:: -PStatCollector(const string &name, PStatClient *client) : +PStatCollector(const std::string &name, PStatClient *client) : _level(0.0f) { if (client == nullptr) { @@ -80,7 +80,7 @@ PStatCollector(const string &name, PStatClient *client) : * collector on the same client as its parent. */ INLINE PStatCollector:: -PStatCollector(const PStatCollector &parent, const string &name) : +PStatCollector(const PStatCollector &parent, const std::string &name) : _level(0.0f) { nassertv(parent._client != nullptr); @@ -122,31 +122,31 @@ is_valid() const { * Returns the local name of this collector. This is the rightmost part of * the fullname, after the rightmost colon. */ -INLINE string PStatCollector:: +INLINE std::string PStatCollector:: get_name() const { if (_client != nullptr) { return _client->get_collector_name(_index); } - return string(); + return std::string(); } /** * Returns the full name of this collector. This includes the names of all * the collector's parents, concatenated together with colons. */ -INLINE string PStatCollector:: +INLINE std::string PStatCollector:: get_fullname() const { if (_client != nullptr) { return _client->get_collector_fullname(_index); } - return string(); + return std::string(); } /** * */ INLINE void PStatCollector:: -output(ostream &out) const { +output(std::ostream &out) const { out << "PStatCollector(\"" << get_fullname() << "\")"; } @@ -494,7 +494,7 @@ PStatCollector() * defined, meaning all these functions should compile to nothing. */ INLINE PStatCollector:: -PStatCollector(const string &, PStatClient *client) { +PStatCollector(const std::string &, PStatClient *client) { // We need this bogus comparison just to prevent the SGI compiler from // dumping core. It's perfectly meaningless. #ifdef mips @@ -509,7 +509,7 @@ PStatCollector(const string &, PStatClient *client) { * defined, meaning all these functions should compile to nothing. */ INLINE PStatCollector:: -PStatCollector(const PStatCollector &parent, const string &) { +PStatCollector(const PStatCollector &parent, const std::string &) { // We need this bogus comparison just to prevent the SGI compiler from // dumping core. It's perfectly meaningless. #ifdef mips diff --git a/panda/src/pstatclient/pStatCollector.h b/panda/src/pstatclient/pStatCollector.h index 3f96b79f41..a007faa61c 100644 --- a/panda/src/pstatclient/pStatCollector.h +++ b/panda/src/pstatclient/pStatCollector.h @@ -50,18 +50,18 @@ public: INLINE PStatCollector(); PUBLISHED: - INLINE explicit PStatCollector(const string &name, + INLINE explicit PStatCollector(const std::string &name, PStatClient *client = nullptr); INLINE explicit PStatCollector(const PStatCollector &parent, - const string &name); + const std::string &name); INLINE PStatCollector(const PStatCollector ©); INLINE void operator = (const PStatCollector ©); INLINE bool is_valid() const; - INLINE string get_name() const; - INLINE string get_fullname() const; - INLINE void output(ostream &out) const; + INLINE std::string get_name() const; + INLINE std::string get_fullname() const; + INLINE void output(std::ostream &out) const; INLINE bool is_active(); INLINE bool is_started(); @@ -110,10 +110,10 @@ public: INLINE PStatCollector(); PUBLISHED: - INLINE PStatCollector(const string &name, + INLINE PStatCollector(const std::string &name, PStatClient *client = nullptr); INLINE PStatCollector(const PStatCollector &parent, - const string &name); + const std::string &name); INLINE bool is_active() { return false; } INLINE bool is_started() { return false; } @@ -148,7 +148,7 @@ PUBLISHED: #include "pStatCollector.I" -inline ostream &operator << (ostream &out, const PStatCollector &pcol) { +inline std::ostream &operator << (std::ostream &out, const PStatCollector &pcol) { #ifdef DO_PSTATS pcol.output(out); #endif // DO_PSTATS diff --git a/panda/src/pstatclient/pStatCollectorDef.h b/panda/src/pstatclient/pStatCollectorDef.h index 79996677f2..443f72a088 100644 --- a/panda/src/pstatclient/pStatCollectorDef.h +++ b/panda/src/pstatclient/pStatCollectorDef.h @@ -29,7 +29,7 @@ class PStatClientVersion; class EXPCL_PANDA_PSTATCLIENT PStatCollectorDef { public: PStatCollectorDef(); - PStatCollectorDef(int index, const string &name); + PStatCollectorDef(int index, const std::string &name); void set_parent(const PStatCollectorDef &parent); void write_datagram(Datagram &destination) const; @@ -40,11 +40,11 @@ public: }; int _index; - string _name; + std::string _name; int _parent_index; ColorDef _suggested_color; int _sort; - string _level_units; + std::string _level_units; double _suggested_scale; double _factor; bool _is_active; diff --git a/panda/src/pstatclient/pStatServerControlMessage.h b/panda/src/pstatclient/pStatServerControlMessage.h index 332a850530..ffcf19e836 100644 --- a/panda/src/pstatclient/pStatServerControlMessage.h +++ b/panda/src/pstatclient/pStatServerControlMessage.h @@ -39,8 +39,8 @@ public: Type _type; // Used for T_hello - string _server_hostname; - string _server_progname; + std::string _server_hostname; + std::string _server_progname; int _udp_port; }; diff --git a/panda/src/putil/animInterface.I b/panda/src/putil/animInterface.I index c25e748cbb..3d09f34a00 100644 --- a/panda/src/putil/animInterface.I +++ b/panda/src/putil/animInterface.I @@ -266,8 +266,8 @@ get_frac() const { return get_full_fframe() - (double)get_full_frame(0); } -INLINE ostream & -operator << (ostream &out, const AnimInterface &ai) { +INLINE std::ostream & +operator << (std::ostream &out, const AnimInterface &ai) { ai.output(out); return out; } diff --git a/panda/src/putil/animInterface.h b/panda/src/putil/animInterface.h index 1c3b0ec6e5..80f2a3da9d 100644 --- a/panda/src/putil/animInterface.h +++ b/panda/src/putil/animInterface.h @@ -60,7 +60,7 @@ PUBLISHED: INLINE double get_full_fframe() const; INLINE bool is_playing() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; PUBLISHED: MAKE_PROPERTY(play_rate, get_play_rate, set_play_rate); @@ -113,7 +113,7 @@ private: double get_full_fframe() const; bool is_playing() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; void internal_set_rate(double frame_rate, double play_rate); double get_f() const; @@ -153,7 +153,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const AnimInterface &ai); +INLINE std::ostream &operator << (std::ostream &out, const AnimInterface &ai); #include "animInterface.I" diff --git a/panda/src/putil/autoTextureScale.h b/panda/src/putil/autoTextureScale.h index b51295881f..3c1e8b5fbe 100644 --- a/panda/src/putil/autoTextureScale.h +++ b/panda/src/putil/autoTextureScale.h @@ -26,7 +26,7 @@ enum AutoTextureScale { }; END_PUBLISH -EXPCL_PANDA_PUTIL ostream &operator << (ostream &out, AutoTextureScale ats); -EXPCL_PANDA_PUTIL istream &operator >> (istream &in, AutoTextureScale &ats); +EXPCL_PANDA_PUTIL std::ostream &operator << (std::ostream &out, AutoTextureScale ats); +EXPCL_PANDA_PUTIL std::istream &operator >> (std::istream &in, AutoTextureScale &ats); #endif diff --git a/panda/src/putil/bam.h b/panda/src/putil/bam.h index 2755f0f25d..ad7d000fd2 100644 --- a/panda/src/putil/bam.h +++ b/panda/src/putil/bam.h @@ -22,7 +22,7 @@ // The magic number for a BAM file. It includes a carriage return and newline // character to help detect files damaged due to faulty ASCIIBinary // conversion. -static const string _bam_header = string("pbj\0\n\r", 6); +static const std::string _bam_header = std::string("pbj\0\n\r", 6); static const unsigned short _bam_major_ver = 6; // Bumped to major version 2 on 2000-07-06 due to major changes in Character. diff --git a/panda/src/putil/bamCache.h b/panda/src/putil/bamCache.h index 9b533ce5c5..28b2335ff6 100644 --- a/panda/src/putil/bamCache.h +++ b/panda/src/putil/bamCache.h @@ -72,13 +72,13 @@ PUBLISHED: INLINE bool get_read_only() const; PT(BamCacheRecord) lookup(const Filename &source_filename, - const string &cache_extension); + const std::string &cache_extension); bool store(BamCacheRecord *record); void consider_flush_index(); void flush_index(); - void list_index(ostream &out, int indent_level = 0) const; + void list_index(std::ostream &out, int indent_level = 0) const; INLINE static BamCache *get_global_ptr(); INLINE static void consider_flush_global_index(); @@ -100,7 +100,7 @@ PUBLISHED: private: void read_index(); bool read_index_pathname(Filename &index_pathname, - string &index_ref_contents) const; + std::string &index_ref_contents) const; void merge_index(BamCacheIndex *new_index); void rebuild_index(); INLINE void mark_index_stale(); @@ -123,7 +123,7 @@ private: static PT(BamCacheRecord) do_read_record(const Filename &cache_pathname, bool read_data); - static string hash_filename(const string &filename); + static std::string hash_filename(const std::string &filename); static void make_global(); bool _active; @@ -141,7 +141,7 @@ private: time_t _index_stale_since; Filename _index_pathname; - string _index_ref_contents; + std::string _index_ref_contents; ReMutex _lock; }; diff --git a/panda/src/putil/bamCacheIndex.h b/panda/src/putil/bamCacheIndex.h index f7e8c2b7a5..d6f403bbf0 100644 --- a/panda/src/putil/bamCacheIndex.h +++ b/panda/src/putil/bamCacheIndex.h @@ -36,7 +36,7 @@ private: ~BamCacheIndex(); public: - void write(ostream &out, int indent_level = 0) const; + void write(std::ostream &out, int indent_level = 0) const; private: void process_new_records(); @@ -50,7 +50,7 @@ private: typedef pmap Records; Records _records; - streamsize _cache_size; + std::streamsize _cache_size; // This structure is a temporary container. It is only filled in while // reading from a bam file. diff --git a/panda/src/putil/bamCacheRecord.h b/panda/src/putil/bamCacheRecord.h index 77bccf2fbf..39b3728dfa 100644 --- a/panda/src/putil/bamCacheRecord.h +++ b/panda/src/putil/bamCacheRecord.h @@ -76,8 +76,8 @@ PUBLISHED: MAKE_PROPERTY2(data, has_data, get_data, set_data, clear_data); - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; private: // This class is used to sort BamCacheRecords by access time. @@ -86,19 +86,19 @@ private: INLINE bool operator () (const BamCacheRecord *a, const BamCacheRecord *b) const; }; - static string format_timestamp(time_t timestamp); + static std::string format_timestamp(time_t timestamp); Filename _source_pathname; Filename _cache_filename; time_t _recorded_time; - streamsize _record_size; // this is accurate only in the index file. + std::streamsize _record_size; // this is accurate only in the index file. time_t _source_timestamp; // Not record to the cache file. class DependentFile { public: Filename _pathname; time_t _timestamp; - streamsize _size; + std::streamsize _size; }; typedef pvector DependentFiles; @@ -145,7 +145,7 @@ private: friend class BamCacheRecord::SortByAccessTime; }; -INLINE ostream &operator << (ostream &out, const BamCacheRecord &record) { +INLINE std::ostream &operator << (std::ostream &out, const BamCacheRecord &record) { record.output(out); return out; } diff --git a/panda/src/putil/bamEnums.h b/panda/src/putil/bamEnums.h index c2cef20db8..1f5b481c9a 100644 --- a/panda/src/putil/bamEnums.h +++ b/panda/src/putil/bamEnums.h @@ -66,12 +66,12 @@ PUBLISHED: }; }; -EXPCL_PANDA_PUTIL ostream &operator << (ostream &out, BamEnums::BamEndian be); -EXPCL_PANDA_PUTIL istream &operator >> (istream &in, BamEnums::BamEndian &be); +EXPCL_PANDA_PUTIL std::ostream &operator << (std::ostream &out, BamEnums::BamEndian be); +EXPCL_PANDA_PUTIL std::istream &operator >> (std::istream &in, BamEnums::BamEndian &be); -EXPCL_PANDA_PUTIL ostream &operator << (ostream &out, BamEnums::BamObjectCode boc); +EXPCL_PANDA_PUTIL std::ostream &operator << (std::ostream &out, BamEnums::BamObjectCode boc); -EXPCL_PANDA_PUTIL ostream &operator << (ostream &out, BamEnums::BamTextureMode btm); -EXPCL_PANDA_PUTIL istream &operator >> (istream &in, BamEnums::BamTextureMode &btm); +EXPCL_PANDA_PUTIL std::ostream &operator << (std::ostream &out, BamEnums::BamTextureMode btm); +EXPCL_PANDA_PUTIL std::istream &operator >> (std::istream &in, BamEnums::BamTextureMode &btm); #endif diff --git a/panda/src/putil/bamReader.I b/panda/src/putil/bamReader.I index d660317a71..b0da184554 100644 --- a/panda/src/putil/bamReader.I +++ b/panda/src/putil/bamReader.I @@ -153,7 +153,7 @@ get_vfile() { * pointing to the first byte following the datagram returned after a call to * get_datagram(). */ -INLINE streampos BamReader:: +INLINE std::streampos BamReader:: get_file_pos() { nassertr(_source != nullptr, 0); return _source->get_file_pos(); diff --git a/panda/src/putil/bamReader.h b/panda/src/putil/bamReader.h index 46ec5fd56c..84312ac4a6 100644 --- a/panda/src/putil/bamReader.h +++ b/panda/src/putil/bamReader.h @@ -124,8 +124,8 @@ PUBLISHED: bool init(); class AuxData; - void set_aux_data(TypedWritable *obj, const string &name, AuxData *data); - AuxData *get_aux_data(TypedWritable *obj, const string &name) const; + void set_aux_data(TypedWritable *obj, const std::string &name, AuxData *data); + AuxData *get_aux_data(TypedWritable *obj, const std::string &name) const; INLINE const Filename &get_filename() const; @@ -172,11 +172,11 @@ public: void read_cdata(DatagramIterator &scan, PipelineCyclerBase &cycler, void *extra_data); - void set_int_tag(const string &tag, int value); - int get_int_tag(const string &tag) const; + void set_int_tag(const std::string &tag, int value); + int get_int_tag(const std::string &tag) const; - void set_aux_tag(const string &tag, BamReaderAuxData *value); - BamReaderAuxData *get_aux_tag(const string &tag) const; + void set_aux_tag(const std::string &tag, BamReaderAuxData *value); + BamReaderAuxData *get_aux_tag(const std::string &tag) const; void register_finalize(TypedWritable *whom); @@ -194,7 +194,7 @@ public: INLINE const FileReference *get_file(); INLINE VirtualFile *get_vfile(); - INLINE streampos get_file_pos(); + INLINE std::streampos get_file_pos(); public: INLINE static void register_factory(TypeHandle type, WritableFactory::CreateFunc *func, @@ -282,8 +282,8 @@ private: // which read_pointer() was called, so that we may call the appropriate // complete_pointers() later. typedef phash_map CyclerPointers; - typedef pmap IntTags; - typedef pmap AuxTags; + typedef pmap IntTags; + typedef pmap AuxTags; class PointerReference { public: vector_int _objects; @@ -328,7 +328,7 @@ private: static NewTypes _new_types; // This is used in support of set_aux_data() and get_aux_data(). - typedef pmap AuxDataNames; + typedef pmap AuxDataNames; typedef phash_map AuxDataTable; AuxDataTable _aux_data; diff --git a/panda/src/putil/bitArray.h b/panda/src/putil/bitArray.h index bb00dea0d7..0338747295 100644 --- a/panda/src/putil/bitArray.h +++ b/panda/src/putil/bitArray.h @@ -91,10 +91,10 @@ PUBLISHED: bool has_bits_in_common(const BitArray &other) const; INLINE void clear(); - void output(ostream &out) const; - void output_binary(ostream &out, int spaces_every = 4) const; - void output_hex(ostream &out, int spaces_every = 4) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void output_binary(std::ostream &out, int spaces_every = 4) const; + void output_hex(std::ostream &out, int spaces_every = 4) const; + void write(std::ostream &out, int indent_level = 0) const; INLINE bool operator == (const BitArray &other) const; INLINE bool operator != (const BitArray &other) const; @@ -156,8 +156,8 @@ private: #include "bitArray.I" -INLINE ostream & -operator << (ostream &out, const BitArray &array) { +INLINE std::ostream & +operator << (std::ostream &out, const BitArray &array) { array.output(out); return out; } diff --git a/panda/src/putil/bitMask.I b/panda/src/putil/bitMask.I index 49e72fc3e7..6bff1e70d4 100644 --- a/panda/src/putil/bitMask.I +++ b/panda/src/putil/bitMask.I @@ -402,7 +402,7 @@ clear() { */ template void BitMask:: -output(ostream &out) const { +output(std::ostream &out) const { if (num_bits >= 40) { output_hex(out); } else { @@ -415,7 +415,7 @@ output(ostream &out) const { */ template void BitMask:: -output_binary(ostream &out, int spaces_every) const { +output_binary(std::ostream &out, int spaces_every) const { for (int i = num_bits - 1; i >= 0; i--) { if (spaces_every != 0 && ((i % spaces_every) == spaces_every - 1)) { out << ' '; @@ -430,7 +430,7 @@ output_binary(ostream &out, int spaces_every) const { */ template void BitMask:: -output_hex(ostream &out, int spaces_every) const { +output_hex(std::ostream &out, int spaces_every) const { int num_digits = (num_bits + 3) / 4; for (int i = num_digits - 1; i >= 0; i--) { @@ -452,7 +452,7 @@ output_hex(ostream &out, int spaces_every) const { */ template void BitMask:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } @@ -646,7 +646,7 @@ generate_hash(ChecksumHashGenerator &hashgen) const { */ template void BitMask:: -init_type(const string &name) { +init_type(const std::string &name) { register_type(_type_handle, name); } diff --git a/panda/src/putil/bitMask.h b/panda/src/putil/bitMask.h index 8eb73a2440..cb11fe10bf 100644 --- a/panda/src/putil/bitMask.h +++ b/panda/src/putil/bitMask.h @@ -78,10 +78,10 @@ PUBLISHED: INLINE bool has_bits_in_common(const BitMask &other) const; INLINE void clear(); - void output(ostream &out) const; - void output_binary(ostream &out, int spaces_every = 4) const; - void output_hex(ostream &out, int spaces_every = 4) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void output_binary(std::ostream &out, int spaces_every = 4) const; + void output_hex(std::ostream &out, int spaces_every = 4) const; + void write(std::ostream &out, int indent_level = 0) const; INLINE bool operator == (const BitMask &other) const; INLINE bool operator != (const BitMask &other) const; @@ -137,7 +137,7 @@ public: static TypeHandle get_class_type() { return _type_handle; } - static void init_type(const string &name); + static void init_type(const std::string &name); private: static TypeHandle _type_handle; @@ -146,7 +146,7 @@ private: #include "bitMask.I" template -INLINE ostream &operator << (ostream &out, const BitMask &bitmask) { +INLINE std::ostream &operator << (std::ostream &out, const BitMask &bitmask) { bitmask.output(out); return out; } diff --git a/panda/src/putil/buttonHandle.I b/panda/src/putil/buttonHandle.I index 2df12e8cd0..c45145dd40 100644 --- a/panda/src/putil/buttonHandle.I +++ b/panda/src/putil/buttonHandle.I @@ -133,7 +133,7 @@ get_index() const { * */ INLINE void ButtonHandle:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name(); } diff --git a/panda/src/putil/buttonHandle.h b/panda/src/putil/buttonHandle.h index 4ee27b01ae..ad43ad2a86 100644 --- a/panda/src/putil/buttonHandle.h +++ b/panda/src/putil/buttonHandle.h @@ -31,7 +31,7 @@ PUBLISHED: // previously by another static initializer! INLINE ButtonHandle() = default; constexpr ButtonHandle(int index); - ButtonHandle(const string &name); + ButtonHandle(const std::string &name); PUBLISHED: INLINE bool operator == (const ButtonHandle &other) const; @@ -43,7 +43,7 @@ PUBLISHED: INLINE int compare_to(const ButtonHandle &other) const; INLINE size_t get_hash() const; - string get_name() const; + std::string get_name() const; INLINE bool has_ascii_equivalent() const; INLINE char get_ascii_equivalent() const; @@ -52,7 +52,7 @@ PUBLISHED: INLINE bool matches(const ButtonHandle &other) const; constexpr int get_index() const; - INLINE void output(ostream &out) const; + INLINE void output(std::ostream &out) const; INLINE static ButtonHandle none(); INLINE operator bool () const; @@ -83,7 +83,7 @@ friend class ButtonRegistry; // It's handy to be able to output a ButtonHandle directly, and see the button // name. -INLINE ostream &operator << (ostream &out, ButtonHandle button) { +INLINE std::ostream &operator << (std::ostream &out, ButtonHandle button) { button.output(out); return out; } diff --git a/panda/src/putil/buttonMap.I b/panda/src/putil/buttonMap.I index bd7e6e4012..49cb2f9931 100644 --- a/panda/src/putil/buttonMap.I +++ b/panda/src/putil/buttonMap.I @@ -40,7 +40,7 @@ get_mapped_button(size_t i) const { * Returns the label associated with the nth mapped button, meaning the button * that the nth raw button is mapped to. */ -INLINE const string &ButtonMap:: +INLINE const std::string &ButtonMap:: get_mapped_button_label(size_t i) const { return _buttons[i]->_label; } @@ -67,7 +67,7 @@ get_mapped_button(ButtonHandle raw) const { * given raw button. */ INLINE ButtonHandle ButtonMap:: -get_mapped_button(const string &raw_name) const { +get_mapped_button(const std::string &raw_name) const { ButtonHandle raw_button = ButtonRegistry::ptr()->find_button(raw_name); if (raw_button == ButtonHandle::none()) { return ButtonHandle::none(); @@ -84,12 +84,12 @@ get_mapped_button(const string &raw_name) const { * Note that this is not the same as get_mapped_button().get_name(), which * returns the name of the Panda event associated with the button. */ -INLINE const string &ButtonMap:: +INLINE const std::string &ButtonMap:: get_mapped_button_label(ButtonHandle raw) const { pmap::const_iterator it; it = _button_map.find(raw.get_index()); if (it == _button_map.end()) { - static const string empty = ""; + static const std::string empty = ""; return empty; } else { return it->second._label; @@ -104,11 +104,11 @@ get_mapped_button_label(ButtonHandle raw) const { * Note that this is not the same as get_mapped_button().get_name(), which * returns the name of the Panda event associated with the button. */ -INLINE const string &ButtonMap:: -get_mapped_button_label(const string &raw_name) const { +INLINE const std::string &ButtonMap:: +get_mapped_button_label(const std::string &raw_name) const { ButtonHandle raw_button = ButtonRegistry::ptr()->find_button(raw_name); if (raw_button == ButtonHandle::none()) { - static const string empty = ""; + static const std::string empty = ""; return empty; } else { return get_mapped_button_label(raw_button); diff --git a/panda/src/putil/buttonMap.h b/panda/src/putil/buttonMap.h index 1c375ad128..fca64c1146 100644 --- a/panda/src/putil/buttonMap.h +++ b/panda/src/putil/buttonMap.h @@ -32,24 +32,24 @@ PUBLISHED: INLINE size_t get_num_buttons() const; INLINE ButtonHandle get_raw_button(size_t i) const; INLINE ButtonHandle get_mapped_button(size_t i) const; - INLINE const string &get_mapped_button_label(size_t i) const; + INLINE const std::string &get_mapped_button_label(size_t i) const; INLINE ButtonHandle get_mapped_button(ButtonHandle raw) const; - INLINE ButtonHandle get_mapped_button(const string &raw_name) const; - INLINE const string &get_mapped_button_label(ButtonHandle raw) const; - INLINE const string &get_mapped_button_label(const string &raw_name) const; + INLINE ButtonHandle get_mapped_button(const std::string &raw_name) const; + INLINE const std::string &get_mapped_button_label(ButtonHandle raw) const; + INLINE const std::string &get_mapped_button_label(const std::string &raw_name) const; - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; public: - void map_button(ButtonHandle raw_button, ButtonHandle button, const string &label = ""); + void map_button(ButtonHandle raw_button, ButtonHandle button, const std::string &label = ""); private: struct ButtonNode { ButtonHandle _raw; ButtonHandle _mapped; - string _label; + std::string _label; }; pmap _button_map; diff --git a/panda/src/putil/buttonRegistry.I b/panda/src/putil/buttonRegistry.I index 8ce0b2f1ce..74fe89471c 100644 --- a/panda/src/putil/buttonRegistry.I +++ b/panda/src/putil/buttonRegistry.I @@ -17,7 +17,7 @@ * */ INLINE ButtonRegistry::RegistryNode:: -RegistryNode(ButtonHandle handle, ButtonHandle alias, const string &name) : +RegistryNode(ButtonHandle handle, ButtonHandle alias, const std::string &name) : _handle(handle), _alias(alias), _name(name) { } @@ -36,7 +36,7 @@ ptr() { /** * Returns the name of the indicated button. */ -INLINE string ButtonRegistry:: +INLINE std::string ButtonRegistry:: get_name(ButtonHandle button) const { RegistryNode *rnode = look_up(button); nassertr(rnode != nullptr, ""); diff --git a/panda/src/putil/buttonRegistry.h b/panda/src/putil/buttonRegistry.h index c57efbf089..19a315ae90 100644 --- a/panda/src/putil/buttonRegistry.h +++ b/panda/src/putil/buttonRegistry.h @@ -31,30 +31,30 @@ protected: class EXPCL_PANDA_PUTIL RegistryNode { public: INLINE RegistryNode(ButtonHandle handle, ButtonHandle alias, - const string &name); + const std::string &name); ButtonHandle _handle; ButtonHandle _alias; - string _name; + std::string _name; }; public: - bool register_button(ButtonHandle &button_handle, const string &name, + bool register_button(ButtonHandle &button_handle, const std::string &name, ButtonHandle alias = ButtonHandle::none(), char ascii_equivalent = '\0'); PUBLISHED: - ButtonHandle get_button(const string &name); - ButtonHandle find_button(const string &name); + ButtonHandle get_button(const std::string &name); + ButtonHandle find_button(const std::string &name); ButtonHandle find_ascii_button(char ascii_equivalent) const; - void write(ostream &out) const; + void write(std::ostream &out) const; // ptr() returns the pointer to the global ButtonRegistry object. INLINE static ButtonRegistry *ptr(); public: - INLINE string get_name(ButtonHandle button) const; + INLINE std::string get_name(ButtonHandle button) const; INLINE ButtonHandle get_alias(ButtonHandle button) const; private: @@ -69,7 +69,7 @@ private: typedef pvector HandleRegistry; HandleRegistry _handle_registry; - typedef pmap NameRegistry; + typedef pmap NameRegistry; NameRegistry _name_registry; static ButtonRegistry *_global_pointer; diff --git a/panda/src/putil/callbackData.h b/panda/src/putil/callbackData.h index 8380788e13..b1b084bdf9 100644 --- a/panda/src/putil/callbackData.h +++ b/panda/src/putil/callbackData.h @@ -31,7 +31,7 @@ protected: INLINE CallbackData(); PUBLISHED: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; virtual void upcall(); @@ -53,7 +53,7 @@ private: static TypeHandle _type_handle; }; -inline ostream &operator << (ostream &out, const CallbackData &cbd) { +inline std::ostream &operator << (std::ostream &out, const CallbackData &cbd) { cbd.output(out); return out; } diff --git a/panda/src/putil/callbackObject.h b/panda/src/putil/callbackObject.h index 320fb9c0ef..0702c704f5 100644 --- a/panda/src/putil/callbackObject.h +++ b/panda/src/putil/callbackObject.h @@ -32,7 +32,7 @@ public: ALLOC_DELETED_CHAIN(CallbackObject); PUBLISHED: - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; EXTENSION(static PT(CallbackObject) make(PyObject *function)); @@ -57,7 +57,7 @@ private: static TypeHandle _type_handle; }; -inline ostream &operator << (ostream &out, const CallbackObject &cbo) { +inline std::ostream &operator << (std::ostream &out, const CallbackObject &cbo) { cbo.output(out); return out; } diff --git a/panda/src/putil/clockObject.I b/panda/src/putil/clockObject.I index f8a0bbc02b..b2cb2975d1 100644 --- a/panda/src/putil/clockObject.I +++ b/panda/src/putil/clockObject.I @@ -110,7 +110,7 @@ INLINE double ClockObject:: get_dt(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); if (_max_dt > 0.0) { - return min(_max_dt, cdata->_dt); + return std::min(_max_dt, cdata->_dt); } return cdata->_dt; } diff --git a/panda/src/putil/clockObject.h b/panda/src/putil/clockObject.h index bcea511f29..4e06ec2554 100644 --- a/panda/src/putil/clockObject.h +++ b/panda/src/putil/clockObject.h @@ -188,10 +188,10 @@ private: static TypeHandle _type_handle; }; -EXPCL_PANDA_PUTIL ostream & -operator << (ostream &out, ClockObject::Mode mode); -EXPCL_PANDA_PUTIL istream & -operator >> (istream &in, ClockObject::Mode &mode); +EXPCL_PANDA_PUTIL std::ostream & +operator << (std::ostream &out, ClockObject::Mode mode); +EXPCL_PANDA_PUTIL std::istream & +operator >> (std::istream &in, ClockObject::Mode &mode); #include "clockObject.I" diff --git a/panda/src/putil/colorSpace.h b/panda/src/putil/colorSpace.h index 97d70ad49f..9c9d237cc6 100644 --- a/panda/src/putil/colorSpace.h +++ b/panda/src/putil/colorSpace.h @@ -42,12 +42,12 @@ enum ColorSpace { CS_scRGB, }; -EXPCL_PANDA_PUTIL ColorSpace parse_color_space_string(const string &str); -EXPCL_PANDA_PUTIL string format_color_space(ColorSpace cs); +EXPCL_PANDA_PUTIL ColorSpace parse_color_space_string(const std::string &str); +EXPCL_PANDA_PUTIL std::string format_color_space(ColorSpace cs); END_PUBLISH -EXPCL_PANDA_PUTIL ostream &operator << (ostream &out, ColorSpace cs); -EXPCL_PANDA_PUTIL istream &operator >> (istream &in, ColorSpace &cs); +EXPCL_PANDA_PUTIL std::ostream &operator << (std::ostream &out, ColorSpace cs); +EXPCL_PANDA_PUTIL std::istream &operator >> (std::istream &in, ColorSpace &cs); #endif diff --git a/panda/src/putil/copyOnWriteObject.I b/panda/src/putil/copyOnWriteObject.I index dccb2ec385..bcf326d87c 100644 --- a/panda/src/putil/copyOnWriteObject.I +++ b/panda/src/putil/copyOnWriteObject.I @@ -130,9 +130,9 @@ void CopyOnWriteObj:: init_type() { #if defined(HAVE_RTTI) && !defined(__EDG__) // If we have RTTI, we can determine the name of the base type. - string base_name = typeid(Base).name(); + std::string base_name = typeid(Base).name(); #else - string base_name = "unknown"; + std::string base_name = "unknown"; #endif TypeHandle base_type = register_dynamic_type(base_name); @@ -190,9 +190,9 @@ void CopyOnWriteObj1:: init_type() { #if defined(HAVE_RTTI) && !defined(__EDG__) // If we have RTTI, we can determine the name of the base type. - string base_name = typeid(Base).name(); + std::string base_name = typeid(Base).name(); #else - string base_name = "unknown"; + std::string base_name = "unknown"; #endif TypeHandle base_type = register_dynamic_type(base_name); diff --git a/panda/src/putil/datagramBuffer.I b/panda/src/putil/datagramBuffer.I index 123642db9f..4ee99b8da0 100644 --- a/panda/src/putil/datagramBuffer.I +++ b/panda/src/putil/datagramBuffer.I @@ -26,7 +26,7 @@ DatagramBuffer() : */ INLINE DatagramBuffer:: DatagramBuffer(vector_uchar data) : - _data(move(data)), + _data(std::move(data)), _read_offset(0), _wrote_first_datagram(false), _read_first_datagram(false) { @@ -56,7 +56,7 @@ get_data() const { */ INLINE void DatagramBuffer:: set_data(vector_uchar data) { - _data = move(data); + _data = std::move(data); } /** diff --git a/panda/src/putil/datagramBuffer.h b/panda/src/putil/datagramBuffer.h index 8962ddbb2b..7990b36e71 100644 --- a/panda/src/putil/datagramBuffer.h +++ b/panda/src/putil/datagramBuffer.h @@ -35,11 +35,11 @@ PUBLISHED: INLINE void clear(); public: - bool write_header(const string &header); + bool write_header(const std::string &header); virtual bool put_datagram(const Datagram &data) override; virtual void flush() override; - bool read_header(string &header, size_t num_bytes); + bool read_header(std::string &header, size_t num_bytes); virtual bool get_datagram(Datagram &data) override; virtual bool is_eof() override; diff --git a/panda/src/putil/datagramInputFile.I b/panda/src/putil/datagramInputFile.I index 0c4ba21cc3..7f60129eb1 100644 --- a/panda/src/putil/datagramInputFile.I +++ b/panda/src/putil/datagramInputFile.I @@ -43,7 +43,7 @@ open(const Filename &filename) { /** * Returns the istream represented by the input file. */ -INLINE istream &DatagramInputFile:: +INLINE std::istream &DatagramInputFile:: get_stream() { static std::ifstream null_stream; nassertr(_in != nullptr, null_stream); diff --git a/panda/src/putil/datagramInputFile.h b/panda/src/putil/datagramInputFile.h index a8f8f67341..37fdf8bbe2 100644 --- a/panda/src/putil/datagramInputFile.h +++ b/panda/src/putil/datagramInputFile.h @@ -32,12 +32,12 @@ PUBLISHED: bool open(const FileReference *file); INLINE bool open(const Filename &filename); - bool open(istream &in, const Filename &filename = Filename()); - INLINE istream &get_stream(); + bool open(std::istream &in, const Filename &filename = Filename()); + INLINE std::istream &get_stream(); void close(); - bool read_header(string &header, size_t num_bytes); + bool read_header(std::string &header, size_t num_bytes); virtual bool get_datagram(Datagram &data); virtual bool save_datagram(SubfileInfo &info); virtual bool is_eof(); @@ -47,14 +47,14 @@ PUBLISHED: virtual time_t get_timestamp() const; virtual const FileReference *get_file(); virtual VirtualFile *get_vfile(); - virtual streampos get_file_pos(); + virtual std::streampos get_file_pos(); private: bool _read_first_datagram; bool _error; CPT(FileReference) _file; PT(VirtualFile) _vfile; - istream *_in; + std::istream *_in; bool _owns_in; Filename _filename; time_t _timestamp; diff --git a/panda/src/putil/datagramOutputFile.I b/panda/src/putil/datagramOutputFile.I index 5bfee6fc9c..56060c51cf 100644 --- a/panda/src/putil/datagramOutputFile.I +++ b/panda/src/putil/datagramOutputFile.I @@ -42,7 +42,7 @@ open(const Filename &filename) { /** * Returns the ostream represented by the output file. */ -INLINE ostream &DatagramOutputFile:: +INLINE std::ostream &DatagramOutputFile:: get_stream() { static std::ofstream null_stream; nassertr(_out != nullptr, null_stream); diff --git a/panda/src/putil/datagramOutputFile.h b/panda/src/putil/datagramOutputFile.h index c81dcdf986..17402850b0 100644 --- a/panda/src/putil/datagramOutputFile.h +++ b/panda/src/putil/datagramOutputFile.h @@ -34,11 +34,11 @@ PUBLISHED: bool open(const FileReference *file); INLINE bool open(const Filename &filename); - bool open(ostream &out, const Filename &filename = Filename()); + bool open(std::ostream &out, const Filename &filename = Filename()); void close(); - bool write_header(const string &header); + bool write_header(const std::string &header); virtual bool put_datagram(const Datagram &data); virtual bool copy_datagram(SubfileInfo &result, const Filename &filename); virtual bool copy_datagram(SubfileInfo &result, const SubfileInfo &source); @@ -48,9 +48,9 @@ PUBLISHED: public: virtual const Filename &get_filename(); virtual const FileReference *get_file(); - virtual streampos get_file_pos(); + virtual std::streampos get_file_pos(); - INLINE ostream &get_stream(); + INLINE std::ostream &get_stream(); PUBLISHED: MAKE_PROPERTY(stream, get_stream); @@ -60,7 +60,7 @@ private: bool _error; CPT(FileReference) _file; PT(VirtualFile) _vfile; - ostream *_out; + std::ostream *_out; bool _owns_out; Filename _filename; }; diff --git a/panda/src/putil/doubleBitMask.I b/panda/src/putil/doubleBitMask.I index d99f8d0da0..35ede588a4 100644 --- a/panda/src/putil/doubleBitMask.I +++ b/panda/src/putil/doubleBitMask.I @@ -442,7 +442,7 @@ clear() { */ template void DoubleBitMask:: -output(ostream &out) const { +output(std::ostream &out) const { output_hex(out); } @@ -452,7 +452,7 @@ output(ostream &out) const { */ template void DoubleBitMask:: -output_binary(ostream &out, int spaces_every) const { +output_binary(std::ostream &out, int spaces_every) const { _hi.output_binary(out); out << ' '; _lo.output_binary(out); @@ -464,7 +464,7 @@ output_binary(ostream &out, int spaces_every) const { */ template void DoubleBitMask:: -output_hex(ostream &out, int spaces_every) const { +output_hex(std::ostream &out, int spaces_every) const { _hi.output_hex(out); out << ' '; _lo.output_hex(out); @@ -476,7 +476,7 @@ output_hex(ostream &out, int spaces_every) const { */ template void DoubleBitMask:: -write(ostream &out, int indent_level) const { +write(std::ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } @@ -663,7 +663,7 @@ generate_hash(ChecksumHashGenerator &hashgen) const { template void DoubleBitMask:: init_type() { - ostringstream str; + std::ostringstream str; str << "DoubleBitMask" << num_bits; register_type(_type_handle, str.str()); } diff --git a/panda/src/putil/doubleBitMask.h b/panda/src/putil/doubleBitMask.h index 2f1d1c5806..7ebc114f5f 100644 --- a/panda/src/putil/doubleBitMask.h +++ b/panda/src/putil/doubleBitMask.h @@ -76,10 +76,10 @@ PUBLISHED: INLINE bool has_bits_in_common(const DoubleBitMask &other) const; INLINE void clear(); - void output(ostream &out) const; - void output_binary(ostream &out, int spaces_every = 4) const; - void output_hex(ostream &out, int spaces_every = 4) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void output_binary(std::ostream &out, int spaces_every = 4) const; + void output_hex(std::ostream &out, int spaces_every = 4) const; + void write(std::ostream &out, int indent_level = 0) const; INLINE bool operator == (const DoubleBitMask &other) const; INLINE bool operator != (const DoubleBitMask &other) const; @@ -129,7 +129,7 @@ private: #include "doubleBitMask.I" template -INLINE ostream &operator << (ostream &out, const DoubleBitMask &doubleBitMask) { +INLINE std::ostream &operator << (std::ostream &out, const DoubleBitMask &doubleBitMask) { doubleBitMask.output(out); return out; } diff --git a/panda/src/putil/factory.I b/panda/src/putil/factory.I index 57d3fadff5..bfd170af40 100644 --- a/panda/src/putil/factory.I +++ b/panda/src/putil/factory.I @@ -34,7 +34,7 @@ make_instance(TypeHandle handle, const FactoryParams ¶ms) { */ template INLINE Type *Factory:: -make_instance(const string &type_name, const FactoryParams ¶ms) { +make_instance(const std::string &type_name, const FactoryParams ¶ms) { return (Type *)FactoryBase::make_instance(type_name, params); } @@ -60,7 +60,7 @@ make_instance_more_general(TypeHandle handle, const FactoryParams ¶ms) { */ template INLINE Type *Factory:: -make_instance_more_general(const string &type_name, +make_instance_more_general(const std::string &type_name, const FactoryParams ¶ms) { return (Type *)FactoryBase::make_instance_more_general(type_name, params); } diff --git a/panda/src/putil/factory.h b/panda/src/putil/factory.h index b7751feb30..03c1fb6f37 100644 --- a/panda/src/putil/factory.h +++ b/panda/src/putil/factory.h @@ -38,7 +38,7 @@ public: INLINE Type *make_instance(TypeHandle handle, const FactoryParams ¶ms = FactoryParams()); - INLINE Type *make_instance(const string &type_name, + INLINE Type *make_instance(const std::string &type_name, const FactoryParams ¶ms = FactoryParams()); INLINE Type * @@ -46,7 +46,7 @@ public: const FactoryParams ¶ms = FactoryParams()); INLINE Type * - make_instance_more_general(const string &type_name, + make_instance_more_general(const std::string &type_name, const FactoryParams ¶ms = FactoryParams()); INLINE void register_factory(TypeHandle handle, CreateFunc *func, diff --git a/panda/src/putil/factoryBase.I b/panda/src/putil/factoryBase.I index 199d3f8d5a..3d93306a4e 100644 --- a/panda/src/putil/factoryBase.I +++ b/panda/src/putil/factoryBase.I @@ -21,7 +21,7 @@ * desired type. It must be the name of some already-registered type. */ INLINE TypedObject *FactoryBase:: -make_instance(const string &type_name, const FactoryParams ¶ms) { +make_instance(const std::string &type_name, const FactoryParams ¶ms) { TypeHandle handle = TypeRegistry::ptr()->find_type(type_name); nassertr(handle != TypeHandle::none(), nullptr); @@ -39,7 +39,7 @@ make_instance(const string &type_name, const FactoryParams ¶ms) { * type. */ INLINE TypedObject *FactoryBase:: -make_instance_more_general(const string &type_name, +make_instance_more_general(const std::string &type_name, const FactoryParams ¶ms) { TypeHandle handle = TypeRegistry::ptr()->find_type(type_name); nassertr(handle != TypeHandle::none(), nullptr); diff --git a/panda/src/putil/factoryBase.h b/panda/src/putil/factoryBase.h index 73d0e8c6e5..7ef256f1a8 100644 --- a/panda/src/putil/factoryBase.h +++ b/panda/src/putil/factoryBase.h @@ -45,13 +45,13 @@ public: TypedObject *make_instance(TypeHandle handle, const FactoryParams ¶ms); - INLINE TypedObject *make_instance(const string &type_name, + INLINE TypedObject *make_instance(const std::string &type_name, const FactoryParams ¶ms); TypedObject *make_instance_more_general(TypeHandle handle, const FactoryParams ¶ms); - INLINE TypedObject *make_instance_more_general(const string &type_name, + INLINE TypedObject *make_instance_more_general(const std::string &type_name, const FactoryParams ¶ms); TypeHandle find_registered_type(TypeHandle handle); @@ -66,7 +66,7 @@ public: int get_num_preferred() const; TypeHandle get_preferred(int n) const; - void write_types(ostream &out, int indent_level = 0) const; + void write_types(std::ostream &out, int indent_level = 0) const; private: // These are private; we shouldn't be copy-constructing Factories. diff --git a/panda/src/putil/load_prc_file.h b/panda/src/putil/load_prc_file.h index b1711bcd6d..cf29e6c8a3 100644 --- a/panda/src/putil/load_prc_file.h +++ b/panda/src/putil/load_prc_file.h @@ -47,7 +47,7 @@ load_prc_file(const Filename &filename); * loaded prc files is listed. */ EXPCL_PANDA_PUTIL ConfigPage * -load_prc_file_data(const string &name, const string &data); +load_prc_file_data(const std::string &name, const std::string &data); /** * Unloads (and deletes) a ConfigPage that represents a prc file that was diff --git a/panda/src/putil/loaderOptions.h b/panda/src/putil/loaderOptions.h index 971353e723..c07fe798d8 100644 --- a/panda/src/putil/loaderOptions.h +++ b/panda/src/putil/loaderOptions.h @@ -68,20 +68,20 @@ PUBLISHED: MAKE_PROPERTY(auto_texture_scale, get_auto_texture_scale, set_auto_texture_scale); - void output(ostream &out) const; + void output(std::ostream &out) const; private: - void write_flag(ostream &out, string &sep, - const string &flag_name, int flag) const; - void write_texture_flag(ostream &out, string &sep, - const string &flag_name, int flag) const; + void write_flag(std::ostream &out, std::string &sep, + const std::string &flag_name, int flag) const; + void write_texture_flag(std::ostream &out, std::string &sep, + const std::string &flag_name, int flag) const; int _flags; int _texture_flags; int _texture_num_views; AutoTextureScale _auto_texture_scale; }; -INLINE ostream &operator << (ostream &out, const LoaderOptions &opts) { +INLINE std::ostream &operator << (std::ostream &out, const LoaderOptions &opts) { opts.output(out); return out; } diff --git a/panda/src/putil/modifierButtons.h b/panda/src/putil/modifierButtons.h index c95791b2a0..d879512514 100644 --- a/panda/src/putil/modifierButtons.h +++ b/panda/src/putil/modifierButtons.h @@ -61,10 +61,10 @@ PUBLISHED: INLINE bool is_down(int index) const; INLINE bool is_any_down() const; - string get_prefix() const; + std::string get_prefix() const; - void output(ostream &out) const; - void write(ostream &out) const; + void output(std::ostream &out) const; + void write(std::ostream &out) const; private: void modify_button_list(); @@ -74,7 +74,7 @@ private: BitmaskType _state; }; -INLINE ostream &operator << (ostream &out, const ModifierButtons &mb) { +INLINE std::ostream &operator << (std::ostream &out, const ModifierButtons &mb) { mb.output(out); return out; } diff --git a/panda/src/putil/mouseData.I b/panda/src/putil/mouseData.I index bdcf750af6..c0ab6997ef 100644 --- a/panda/src/putil/mouseData.I +++ b/panda/src/putil/mouseData.I @@ -67,7 +67,7 @@ get_in_window() const { } -INLINE ostream &operator << (ostream &out, const MouseData &md) { +INLINE std::ostream &operator << (std::ostream &out, const MouseData &md) { md.output(out); return out; } diff --git a/panda/src/putil/mouseData.h b/panda/src/putil/mouseData.h index 4fe2c81b4f..0d2a294568 100644 --- a/panda/src/putil/mouseData.h +++ b/panda/src/putil/mouseData.h @@ -32,7 +32,7 @@ PUBLISHED: INLINE double get_y() const; INLINE bool get_in_window() const; - void output(ostream &out) const; + void output(std::ostream &out) const; MAKE_PROPERTY(x, get_x); MAKE_PROPERTY(y, get_y); @@ -44,7 +44,7 @@ public: double _ypos; }; -INLINE ostream &operator << (ostream &out, const MouseData &md); +INLINE std::ostream &operator << (std::ostream &out, const MouseData &md); #include "mouseData.I" diff --git a/panda/src/putil/nameUniquifier.I b/panda/src/putil/nameUniquifier.I index 4ccfa1e0b0..760dad2dfc 100644 --- a/panda/src/putil/nameUniquifier.I +++ b/panda/src/putil/nameUniquifier.I @@ -24,8 +24,8 @@ * If the name is nonempty, the new name is the original name, followed by the * NameUniquifier's "separator" string, followed by a number. */ -INLINE string NameUniquifier:: -add_name(const string &name) { +INLINE std::string NameUniquifier:: +add_name(const std::string &name) { return add_name_body(name, name); } @@ -42,7 +42,7 @@ add_name(const string &name) { * If the prefix is nonempty, the new name is the prefix, followed by the * NameUniquifier's "separator" string, followed by a number. */ -INLINE string NameUniquifier:: -add_name(const string &name, const string &prefix) { +INLINE std::string NameUniquifier:: +add_name(const std::string &name, const std::string &prefix) { return add_name_body(name, prefix); } diff --git a/panda/src/putil/nameUniquifier.h b/panda/src/putil/nameUniquifier.h index 7b629771d2..1d3c3e2560 100644 --- a/panda/src/putil/nameUniquifier.h +++ b/panda/src/putil/nameUniquifier.h @@ -27,20 +27,20 @@ */ class EXPCL_PANDA_PUTIL NameUniquifier { public: - NameUniquifier(const string &separator = string(), - const string &empty = string()); + NameUniquifier(const std::string &separator = std::string(), + const std::string &empty = std::string()); ~NameUniquifier(); - INLINE string add_name(const string &name); - INLINE string add_name(const string &name, const string &prefix); + INLINE std::string add_name(const std::string &name); + INLINE std::string add_name(const std::string &name, const std::string &prefix); private: - string add_name_body(const string &name, const string &prefix); + std::string add_name_body(const std::string &name, const std::string &prefix); - typedef pset Names; + typedef pset Names; Names _names; - string _separator; - string _empty; + std::string _separator; + std::string _empty; int _counter; }; diff --git a/panda/src/putil/paramValue.I b/panda/src/putil/paramValue.I index 735e4f2ca4..0f44d4d54e 100644 --- a/panda/src/putil/paramValue.I +++ b/panda/src/putil/paramValue.I @@ -116,7 +116,7 @@ get_value() const { */ template INLINE void ParamValue:: -output(ostream &out) const { +output(std::ostream &out) const { out << _value; } diff --git a/panda/src/putil/paramValue.h b/panda/src/putil/paramValue.h index b17b2c9c37..ea3b8fcae5 100644 --- a/panda/src/putil/paramValue.h +++ b/panda/src/putil/paramValue.h @@ -35,7 +35,7 @@ public: PUBLISHED: virtual ~ParamValueBase(); INLINE virtual TypeHandle get_value_type() const; - virtual void output(ostream &out) const=0; + virtual void output(std::ostream &out) const=0; public: virtual TypeHandle get_type() const { @@ -69,7 +69,7 @@ PUBLISHED: MAKE_PROPERTY(value, get_value); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; private: PT(TypedReferenceCount) _value; @@ -114,7 +114,7 @@ PUBLISHED: MAKE_PROPERTY(value, get_value, set_value); - INLINE virtual void output(ostream &out) const; + INLINE virtual void output(std::ostream &out) const; private: Type _value; @@ -131,7 +131,7 @@ public: static TypeHandle get_class_type() { return _type_handle; } - static void init_type(const string &type_name = "UndefinedParamValue") { + static void init_type(const std::string &type_name = "UndefinedParamValue") { ParamValueBase::init_type(); _type_handle = register_dynamic_type (type_name, ParamValueBase::get_class_type()); @@ -172,8 +172,8 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue); EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, ParamValue); -typedef ParamValue ParamString; -typedef ParamValue ParamWstring; +typedef ParamValue ParamString; +typedef ParamValue ParamWstring; typedef ParamValue ParamVecBase2d; typedef ParamValue ParamVecBase2f; diff --git a/panda/src/putil/simpleHashMap.I b/panda/src/putil/simpleHashMap.I index 2cc4e006df..2ac26a54f0 100644 --- a/panda/src/putil/simpleHashMap.I +++ b/panda/src/putil/simpleHashMap.I @@ -60,7 +60,7 @@ SimpleHashMap(SimpleHashMap &&from) noexcept : _deleted_chain(from._deleted_chain), _table_size(from._table_size), _num_entries(from._num_entries), - _comp(move(from._comp)) + _comp(std::move(from._comp)) { from._table = nullptr; from._deleted_chain = nullptr; @@ -115,7 +115,7 @@ operator = (SimpleHashMap &&from) noexcept { _deleted_chain = from._deleted_chain; _table_size = from._table_size; _num_entries = from._num_entries; - _comp = move(from._comp); + _comp = std::move(from._comp); from._table = nullptr; from._deleted_chain = nullptr; @@ -275,7 +275,7 @@ remove(const Key &key) { // Swap it with the last one, so that we don't get any gaps in the table // of entries. - _table[index] = move(_table[last]); + _table[index] = std::move(_table[last]); index_array[(size_t)other_slot] = index; } @@ -422,7 +422,7 @@ template INLINE void SimpleHashMap:: set_data(size_t n, Value &&data) { nassertv(n < _num_entries); - _table[n].set_data(move(data)); + _table[n].set_data(std::move(data)); } /** @@ -460,7 +460,7 @@ is_empty() const { */ template void SimpleHashMap:: -output(ostream &out) const { +output(std::ostream &out) const { out << "SimpleHashMap (" << _num_entries << " entries): ["; const int *index_array = get_index_array(); size_t num_slots = _table_size * sparsity; @@ -487,7 +487,7 @@ output(ostream &out) const { */ template void SimpleHashMap:: -write(ostream &out) const { +write(std::ostream &out) const { output(out); out << "\n"; for (size_t i = 0; i < _num_entries; ++i) { @@ -731,7 +731,7 @@ resize_table(size_t new_size) { // have to reorder these, fortunately. Hopefully, a smart compiler will // optimize this to a memcpy. for (size_t i = 0; i < _num_entries; ++i) { - new(&_table[i]) TableEntry(move(old_table[i])); + new(&_table[i]) TableEntry(std::move(old_table[i])); old_table[i].~TableEntry(); } diff --git a/panda/src/putil/simpleHashMap.h b/panda/src/putil/simpleHashMap.h index cd759f6cbd..bae858006d 100644 --- a/panda/src/putil/simpleHashMap.h +++ b/panda/src/putil/simpleHashMap.h @@ -40,7 +40,7 @@ public: _data = data; } ALWAYS_INLINE void set_data(Value &&data) { - _data = move(data); + _data = std::move(data); } private: @@ -77,7 +77,7 @@ public: * * It can also be used as a set, by using nullptr_t as Value typename. */ -template > > +template > > class SimpleHashMap { // Per-entry overhead is determined by sizeof(int) * sparsity. Should be a // power of two. @@ -113,8 +113,8 @@ public: INLINE size_t get_num_entries() const; INLINE bool is_empty() const; - void output(ostream &out) const; - void write(ostream &out) const; + void output(std::ostream &out) const; + void write(std::ostream &out) const; bool validate() const; INLINE bool consider_shrink_table(); @@ -145,7 +145,7 @@ public: }; template -inline ostream &operator << (ostream &out, const SimpleHashMap &shm) { +inline std::ostream &operator << (std::ostream &out, const SimpleHashMap &shm) { shm.output(out); return out; } diff --git a/panda/src/putil/sparseArray.h b/panda/src/putil/sparseArray.h index a372fc240e..de6a508d29 100644 --- a/panda/src/putil/sparseArray.h +++ b/panda/src/putil/sparseArray.h @@ -80,7 +80,7 @@ PUBLISHED: bool has_bits_in_common(const SparseArray &other) const; INLINE void clear(); - void output(ostream &out) const; + void output(std::ostream &out) const; INLINE bool operator == (const SparseArray &other) const; INLINE bool operator != (const SparseArray &other) const; @@ -158,8 +158,8 @@ private: #include "sparseArray.I" -INLINE ostream & -operator << (ostream &out, const SparseArray &array) { +INLINE std::ostream & +operator << (std::ostream &out, const SparseArray &array) { array.output(out); return out; } diff --git a/panda/src/putil/test_bam.h b/panda/src/putil/test_bam.h index b49fca965a..1570f1541a 100644 --- a/panda/src/putil/test_bam.h +++ b/panda/src/putil/test_bam.h @@ -45,15 +45,15 @@ public: bool isMale() {return myGender == MALE;} void print_relationships(); - string name() {return _name;} + std::string name() {return _name;} private: Person *_bro, *_sis; sex myGender; - string _name; + std::string _name; public: Person() {} - Person(const string &name, const sex Gender) : + Person(const std::string &name, const sex Gender) : _name(name), myGender(Gender), _bro(nullptr), _sis(nullptr) { } @@ -100,7 +100,7 @@ private: public: Parent() {} - Parent(const string &name, const sex Gender) : Person(name, Gender) { + Parent(const std::string &name, const sex Gender) : Person(name, Gender) { } virtual ~Parent() { @@ -146,7 +146,7 @@ private: public: Child() {} - Child(const string &name, const sex Gender) : Person(name, Gender) { + Child(const std::string &name, const sex Gender) : Person(name, Gender) { } virtual ~Child() { diff --git a/panda/src/putil/uniqueIdAllocator.h b/panda/src/putil/uniqueIdAllocator.h index 54da7c6463..50db80b0b0 100644 --- a/panda/src/putil/uniqueIdAllocator.h +++ b/panda/src/putil/uniqueIdAllocator.h @@ -46,8 +46,8 @@ PUBLISHED: void free(uint32_t index); PN_stdfloat fraction_used() const; - void output(ostream &out) const; - void write(ostream &out) const; + void output(std::ostream &out) const; + void write(std::ostream &out) const; public: static const uint32_t IndexEnd; diff --git a/panda/src/putil/updateSeq.I b/panda/src/putil/updateSeq.I index ea9af8427c..bc620002a0 100644 --- a/panda/src/putil/updateSeq.I +++ b/panda/src/putil/updateSeq.I @@ -219,7 +219,7 @@ get_seq() const { * */ INLINE void UpdateSeq:: -output(ostream &out) const { +output(std::ostream &out) const { AtomicAdjust::Integer seq = AtomicAdjust::get(_seq); switch (seq) { case (AtomicAdjust::Integer)SC_initial: @@ -271,7 +271,7 @@ priv_le(AtomicAdjust::Integer a, AtomicAdjust::Integer b) { return (a == b) || priv_lt(a, b); } -INLINE ostream &operator << (ostream &out, const UpdateSeq &value) { +INLINE std::ostream &operator << (std::ostream &out, const UpdateSeq &value) { value.output(out); return out; } diff --git a/panda/src/putil/updateSeq.h b/panda/src/putil/updateSeq.h index bdddadde6e..f4feed804a 100644 --- a/panda/src/putil/updateSeq.h +++ b/panda/src/putil/updateSeq.h @@ -68,7 +68,7 @@ PUBLISHED: INLINE AtomicAdjust::Integer get_seq() const; MAKE_PROPERTY(seq, get_seq); - INLINE void output(ostream &out) const; + INLINE void output(std::ostream &out) const; private: INLINE static bool priv_is_special(AtomicAdjust::Integer seq); @@ -85,7 +85,7 @@ private: AtomicAdjust::Integer _seq; }; -INLINE ostream &operator << (ostream &out, const UpdateSeq &value); +INLINE std::ostream &operator << (std::ostream &out, const UpdateSeq &value); #include "updateSeq.I" diff --git a/panda/src/putil/weakKeyHashMap.I b/panda/src/putil/weakKeyHashMap.I index 6801df4ad1..b2dc97c3f4 100644 --- a/panda/src/putil/weakKeyHashMap.I +++ b/panda/src/putil/weakKeyHashMap.I @@ -306,7 +306,7 @@ template INLINE void WeakKeyHashMap:: set_data(size_t n, Value &&data) { nassertv(has_element(n)); - _table[n]._data = move(data); + _table[n]._data = std::move(data); } /** @@ -390,7 +390,7 @@ is_empty() const { */ template void WeakKeyHashMap:: -output(ostream &out) const { +output(std::ostream &out) const { out << "WeakKeyHashMap (" << _num_entries << " entries): ["; for (size_t i = 0; i < _table_size; ++i) { if (get_exists_array()[i] == 0) { @@ -414,7 +414,7 @@ output(ostream &out) const { */ template void WeakKeyHashMap:: -write(ostream &out) const { +write(std::ostream &out) const { output(out); out << "\n"; } diff --git a/panda/src/putil/weakKeyHashMap.h b/panda/src/putil/weakKeyHashMap.h index b29a846e96..8e51ae700f 100644 --- a/panda/src/putil/weakKeyHashMap.h +++ b/panda/src/putil/weakKeyHashMap.h @@ -56,8 +56,8 @@ public: INLINE size_t get_num_entries() const; INLINE bool is_empty() const; - void output(ostream &out) const; - void write(ostream &out) const; + void output(std::ostream &out) const; + void write(std::ostream &out) const; bool validate() const; private: @@ -96,7 +96,7 @@ private: }; template -inline ostream &operator << (ostream &out, const WeakKeyHashMap &shm) { +inline std::ostream &operator << (std::ostream &out, const WeakKeyHashMap &shm) { shm.output(out); return out; } diff --git a/panda/src/recorder/mouseRecorder.h b/panda/src/recorder/mouseRecorder.h index 7122c12299..a30c2d428a 100644 --- a/panda/src/recorder/mouseRecorder.h +++ b/panda/src/recorder/mouseRecorder.h @@ -33,7 +33,7 @@ class BamWriter; */ class EXPCL_PANDA_RECORDER MouseRecorder : public DataNode, public RecorderBase { PUBLISHED: - explicit MouseRecorder(const string &name); + explicit MouseRecorder(const std::string &name); virtual ~MouseRecorder(); public: @@ -41,8 +41,8 @@ public: virtual void play_frame(DatagramIterator &scan, BamReader *manager); public: - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; protected: // Inherited from DataNode diff --git a/panda/src/recorder/recorderController.I b/panda/src/recorder/recorderController.I index 043fb55fb4..7960a78ea1 100644 --- a/panda/src/recorder/recorderController.I +++ b/panda/src/recorder/recorderController.I @@ -115,7 +115,7 @@ get_frame_offset() const { * recorder will begin receiving data. */ INLINE void RecorderController:: -add_recorder(const string &name, RecorderBase *recorder) { +add_recorder(const std::string &name, RecorderBase *recorder) { _user_table->add_recorder(name, recorder); _user_table_modified = true; @@ -137,7 +137,7 @@ add_recorder(const string &name, RecorderBase *recorder) { * via add_recorder(); see get_recorder(). */ INLINE bool RecorderController:: -has_recorder(const string &name) const { +has_recorder(const std::string &name) const { return (_user_table->get_recorder(name) != nullptr); } @@ -151,7 +151,7 @@ has_recorder(const string &name) const { * return false, but get_recorder() will return a non-NULL value. */ INLINE RecorderBase *RecorderController:: -get_recorder(const string &name) const { +get_recorder(const std::string &name) const { RecorderBase *recorder = _user_table->get_recorder(name); if (is_playing() && recorder == nullptr) { recorder = _active_table->get_recorder(name); @@ -170,7 +170,7 @@ get_recorder(const string &name) const { * the data from the session file). */ INLINE bool RecorderController:: -remove_recorder(const string &name) { +remove_recorder(const std::string &name) { // If we are playing or recording, immediately remove the state flag from // the recorder. (When we are playing, the state flag will get removed // automatically at the next call to play_frame(), but we might as well be diff --git a/panda/src/recorder/recorderController.h b/panda/src/recorder/recorderController.h index 064e882373..d3d8ccd1fd 100644 --- a/panda/src/recorder/recorderController.h +++ b/panda/src/recorder/recorderController.h @@ -52,10 +52,10 @@ PUBLISHED: INLINE double get_clock_offset() const; INLINE int get_frame_offset() const; - INLINE void add_recorder(const string &name, RecorderBase *recorder); - INLINE bool has_recorder(const string &name) const; - INLINE RecorderBase *get_recorder(const string &name) const; - INLINE bool remove_recorder(const string &name); + INLINE void add_recorder(const std::string &name, RecorderBase *recorder); + INLINE bool has_recorder(const std::string &name) const; + INLINE RecorderBase *get_recorder(const std::string &name) const; + INLINE bool remove_recorder(const std::string &name); INLINE void set_frame_tie(bool frame_tie); INLINE bool get_frame_tie() const; diff --git a/panda/src/recorder/recorderTable.I b/panda/src/recorder/recorderTable.I index 088c74c52f..18e66bc3ee 100644 --- a/panda/src/recorder/recorderTable.I +++ b/panda/src/recorder/recorderTable.I @@ -45,7 +45,7 @@ operator = (const RecorderTable ©) { * Adds the named recorder to the set of recorders. */ INLINE void RecorderTable:: -add_recorder(const string &name, RecorderBase *recorder) { +add_recorder(const std::string &name, RecorderBase *recorder) { nassertv(recorder != nullptr); recorder->ref(); @@ -64,7 +64,7 @@ add_recorder(const string &name, RecorderBase *recorder) { * recorder. */ INLINE RecorderBase *RecorderTable:: -get_recorder(const string &name) const { +get_recorder(const std::string &name) const { Recorders::const_iterator ri = _recorders.find(name); if (ri != _recorders.end()) { return (*ri).second; @@ -77,7 +77,7 @@ get_recorder(const string &name) const { * false if there was no such recorder. */ INLINE bool RecorderTable:: -remove_recorder(const string &name) { +remove_recorder(const std::string &name) { Recorders::iterator ri = _recorders.find(name); if (ri != _recorders.end()) { unref_delete(ri->second); diff --git a/panda/src/recorder/recorderTable.h b/panda/src/recorder/recorderTable.h index 7a5046c651..8c6d1bf412 100644 --- a/panda/src/recorder/recorderTable.h +++ b/panda/src/recorder/recorderTable.h @@ -38,21 +38,21 @@ public: void merge_from(const RecorderTable &other); - INLINE void add_recorder(const string &name, RecorderBase *recorder); - INLINE RecorderBase *get_recorder(const string &name) const; - INLINE bool remove_recorder(const string &name); + INLINE void add_recorder(const std::string &name, RecorderBase *recorder); + INLINE RecorderBase *get_recorder(const std::string &name) const; + INLINE bool remove_recorder(const std::string &name); void record_frame(BamWriter *manager, Datagram &dg); void play_frame(DatagramIterator &scan, BamReader *manager); void set_flags(short flags); void clear_flags(short flags); - void write(ostream &out, int indent_level) const; + void write(std::ostream &out, int indent_level) const; // RecorderBase itself doesn't inherit from ReferenceCount, so we can't put // a PT() around it. Instead, we manage the reference count using calls to // ref() and unref(). - typedef pmap Recorders; + typedef pmap Recorders; Recorders _recorders; bool _error; diff --git a/panda/src/rocket/rocketFileInterface.h b/panda/src/rocket/rocketFileInterface.h index 144ccc4563..5e1f4d0f8c 100644 --- a/panda/src/rocket/rocketFileInterface.h +++ b/panda/src/rocket/rocketFileInterface.h @@ -41,7 +41,7 @@ public: protected: struct VirtualFileHandle { PT(VirtualFile) _file; - istream *_stream; + std::istream *_stream; }; VirtualFileSystem* _vfs; diff --git a/panda/src/rocket/rocketInputHandler.h b/panda/src/rocket/rocketInputHandler.h index e1637ba681..d0c20ff8e3 100644 --- a/panda/src/rocket/rocketInputHandler.h +++ b/panda/src/rocket/rocketInputHandler.h @@ -30,7 +30,7 @@ namespace Rocket { */ class EXPCL_ROCKET RocketInputHandler : public DataNode { PUBLISHED: - RocketInputHandler(const string &name = string()); + RocketInputHandler(const std::string &name = std::string()); virtual ~RocketInputHandler(); static int get_rocket_key(const ButtonHandle handle); diff --git a/panda/src/rocket/rocketRegion.I b/panda/src/rocket/rocketRegion.I index f9fe378ff7..1c9aab10da 100644 --- a/panda/src/rocket/rocketRegion.I +++ b/panda/src/rocket/rocketRegion.I @@ -18,7 +18,7 @@ * window. */ INLINE RocketRegion *RocketRegion:: -make(const string &context_name, GraphicsOutput *window) { +make(const std::string &context_name, GraphicsOutput *window) { return make(context_name, window, LVecBase4(0.0f, 1.0f, 0.0f, 1.0f)); } @@ -28,7 +28,7 @@ make(const string &context_name, GraphicsOutput *window) { * render to. */ INLINE RocketRegion *RocketRegion:: -make(const string &context_name, GraphicsOutput *window, +make(const std::string &context_name, GraphicsOutput *window, const LVecBase4 &dimensions) { return new RocketRegion(window, dimensions, context_name); diff --git a/panda/src/rocket/rocketRegion.h b/panda/src/rocket/rocketRegion.h index d978ac6305..0f0eeb5603 100644 --- a/panda/src/rocket/rocketRegion.h +++ b/panda/src/rocket/rocketRegion.h @@ -28,7 +28,7 @@ class OrthographicLens; class EXPCL_ROCKET RocketRegion : public DisplayRegion { protected: RocketRegion(GraphicsOutput *window, const LVecBase4 &dimensions, - const string &context_name); + const std::string &context_name); virtual void do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, GraphicsStateGuardian *gsg, Thread *current_thread); @@ -36,9 +36,9 @@ protected: PUBLISHED: virtual ~RocketRegion(); - INLINE static RocketRegion* make(const string &context_name, + INLINE static RocketRegion* make(const std::string &context_name, GraphicsOutput *window); - INLINE static RocketRegion* make(const string &context_name, + INLINE static RocketRegion* make(const std::string &context_name, GraphicsOutput *window, const LVecBase4 &dimensions); #ifndef CPPPARSER diff --git a/panda/src/speedtree/loaderFileTypeSrt.h b/panda/src/speedtree/loaderFileTypeSrt.h index 6d26eeff6b..ba40a0e5a1 100644 --- a/panda/src/speedtree/loaderFileTypeSrt.h +++ b/panda/src/speedtree/loaderFileTypeSrt.h @@ -27,8 +27,8 @@ class EXPCL_PANDASPEEDTREE LoaderFileTypeSrt : public LoaderFileType { public: LoaderFileTypeSrt(); - virtual string get_name() const; - virtual string get_extension() const; + virtual std::string get_name() const; + virtual std::string get_extension() const; virtual bool supports_compressed() const; virtual PT(PandaNode) load_file(const Filename &path, const LoaderOptions &options, diff --git a/panda/src/speedtree/loaderFileTypeStf.h b/panda/src/speedtree/loaderFileTypeStf.h index 8ea8eae575..04bc8207e1 100644 --- a/panda/src/speedtree/loaderFileTypeStf.h +++ b/panda/src/speedtree/loaderFileTypeStf.h @@ -26,8 +26,8 @@ class EXPCL_PANDASPEEDTREE LoaderFileTypeStf : public LoaderFileType { public: LoaderFileTypeStf(); - virtual string get_name() const; - virtual string get_extension() const; + virtual std::string get_name() const; + virtual std::string get_extension() const; virtual bool supports_compressed() const; virtual PT(PandaNode) load_file(const Filename &path, const LoaderOptions &options, diff --git a/panda/src/speedtree/speedTreeNode.h b/panda/src/speedtree/speedTreeNode.h index fb153d2542..b45a3df6ee 100644 --- a/panda/src/speedtree/speedTreeNode.h +++ b/panda/src/speedtree/speedTreeNode.h @@ -71,8 +71,8 @@ PUBLISHED: INLINE int add_instance(const STTransform &transform); INLINE void remove_instance(int n); - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; public: void write_datagram(BamWriter *manager, Datagram &dg); @@ -85,7 +85,7 @@ PUBLISHED: }; PUBLISHED: - explicit SpeedTreeNode(const string &name); + explicit SpeedTreeNode(const std::string &name); virtual ~SpeedTreeNode(); INLINE bool is_valid() const; @@ -121,7 +121,7 @@ PUBLISHED: bool add_from_stf(const Filename &stf_filename, const LoaderOptions &options = LoaderOptions()); - bool add_from_stf(istream &in, const Filename &pathname, + bool add_from_stf(std::istream &in, const Filename &pathname, const LoaderOptions &options = LoaderOptions(), Loader *loader = nullptr); @@ -145,7 +145,7 @@ PUBLISHED: MAKE_PROPERTY(global_time_delta, get_global_time_delta, set_global_time_delta); - static bool authorize(const string &license = ""); + static bool authorize(const std::string &license = ""); public: SpeedTreeNode(const SpeedTreeNode ©); @@ -167,10 +167,10 @@ public: int pipeline_stage, Thread *current_thread) const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level) const; - static void write_error(ostream &out); + static void write_error(std::ostream &out); protected: void set_transparent_texture_mode(SpeedTree::ETextureAlphaRenderMode eMode) const; @@ -219,7 +219,7 @@ private: }; private: - string _os_shaders_dir; + std::string _os_shaders_dir; // A list of instances per each unique tree. typedef ov_set > Trees; @@ -298,7 +298,7 @@ private: friend class SpeedTreeNode::DrawCallback; }; -INLINE ostream &operator << (ostream &out, const SpeedTreeNode::InstanceList &instances) { +INLINE std::ostream &operator << (std::ostream &out, const SpeedTreeNode::InstanceList &instances) { instances.output(out); return out; } diff --git a/panda/src/speedtree/stBasicTerrain.h b/panda/src/speedtree/stBasicTerrain.h index a61f15a785..048c507ac7 100644 --- a/panda/src/speedtree/stBasicTerrain.h +++ b/panda/src/speedtree/stBasicTerrain.h @@ -33,7 +33,7 @@ PUBLISHED: void clear(); bool setup_terrain(const Filename &terrain_filename); - bool setup_terrain(istream &in, const Filename &pathname); + bool setup_terrain(std::istream &in, const Filename &pathname); INLINE void set_height_map(const Filename &height_map); INLINE const Filename &get_height_map() const; @@ -49,8 +49,8 @@ PUBLISHED: PN_stdfloat start_x, PN_stdfloat start_y, PN_stdfloat size_xy, int num_xy) const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; protected: bool read_height_map(); @@ -59,7 +59,7 @@ protected: INLINE PN_stdfloat interpolate(PN_stdfloat a, PN_stdfloat b, PN_stdfloat t); private: - static void read_quoted_filename(Filename &result, istream &in, + static void read_quoted_filename(Filename &result, std::istream &in, const Filename &dirname); protected: diff --git a/panda/src/speedtree/stTerrain.h b/panda/src/speedtree/stTerrain.h index cc2bf94215..d9a2c3160a 100644 --- a/panda/src/speedtree/stTerrain.h +++ b/panda/src/speedtree/stTerrain.h @@ -68,8 +68,8 @@ PUBLISHED: PN_stdfloat start_x, PN_stdfloat start_y, PN_stdfloat size_xy, int num_xy) const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: const SpeedTree::SVertexAttribDesc *get_st_vertex_format() const; @@ -123,7 +123,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const STTerrain &terrain) { +INLINE std::ostream &operator << (std::ostream &out, const STTerrain &terrain) { terrain.output(out); return out; } diff --git a/panda/src/speedtree/stTransform.h b/panda/src/speedtree/stTransform.h index 07d66a3eae..d3329b7be1 100644 --- a/panda/src/speedtree/stTransform.h +++ b/panda/src/speedtree/stTransform.h @@ -50,7 +50,7 @@ PUBLISHED: INLINE void operator *= (const STTransform &other); INLINE STTransform operator * (const STTransform &other) const; - void output(ostream &out) const; + void output(std::ostream &out) const; public: void write_datagram(BamWriter *manager, Datagram &dg); @@ -64,7 +64,7 @@ public: static STTransform _ident_mat; }; -INLINE ostream &operator << (ostream &out, const STTransform &transform) { +INLINE std::ostream &operator << (std::ostream &out, const STTransform &transform) { transform.output(out); return out; } diff --git a/panda/src/speedtree/stTree.h b/panda/src/speedtree/stTree.h index 379223aa97..e150f70ceb 100644 --- a/panda/src/speedtree/stTree.h +++ b/panda/src/speedtree/stTree.h @@ -35,7 +35,7 @@ PUBLISHED: INLINE bool is_valid() const; - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; public: INLINE const SpeedTree::CTreeRender *get_tree() const; @@ -64,7 +64,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const STTree &tree) { +INLINE std::ostream &operator << (std::ostream &out, const STTree &tree) { tree.output(out); return out; } diff --git a/panda/src/text/config_text.h b/panda/src/text/config_text.h index 895072fdf6..131b95809d 100644 --- a/panda/src/text/config_text.h +++ b/panda/src/text/config_text.h @@ -45,9 +45,9 @@ extern ConfigVariableInt text_pop_properties_key; extern ConfigVariableInt text_soft_hyphen_key; extern ConfigVariableInt text_soft_break_key; extern ConfigVariableInt text_embed_graphic_key; -extern wstring get_text_soft_hyphen_output(); +extern std::wstring get_text_soft_hyphen_output(); extern ConfigVariableDouble text_hyphen_ratio; -extern wstring get_text_never_break_before(); +extern std::wstring get_text_never_break_before(); extern ConfigVariableInt text_max_never_break; extern EXPCL_PANDA_TEXT ConfigVariableDouble text_default_underscore_height; diff --git a/panda/src/text/dynamicTextFont.I b/panda/src/text/dynamicTextFont.I index 16fd832efe..eafa2b50f8 100644 --- a/panda/src/text/dynamicTextFont.I +++ b/panda/src/text/dynamicTextFont.I @@ -15,7 +15,7 @@ * Disambiguates the get_name() method between that inherited from TextFont * and that inherited from FreetypeFont. */ -INLINE const string &DynamicTextFont:: +INLINE const std::string &DynamicTextFont:: get_name() const { return TextFont::get_name(); } @@ -441,7 +441,7 @@ get_tex_format() const { } -INLINE ostream & -operator << (ostream &out, const DynamicTextFont &dtf) { +INLINE std::ostream & +operator << (std::ostream &out, const DynamicTextFont &dtf) { return out << dtf.get_name(); } diff --git a/panda/src/text/dynamicTextFont.h b/panda/src/text/dynamicTextFont.h index 775fa6a450..d2643cffb1 100644 --- a/panda/src/text/dynamicTextFont.h +++ b/panda/src/text/dynamicTextFont.h @@ -47,7 +47,7 @@ PUBLISHED: virtual PT(TextFont) make_copy() const; - INLINE const string &get_name() const; + INLINE const std::string &get_name() const; INLINE bool set_point_size(PN_stdfloat point_size); INLINE PN_stdfloat get_point_size() const; @@ -121,7 +121,7 @@ PUBLISHED: int garbage_collect(); void clear(); - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; public: virtual bool get_glyph(int character, CPT(TextGlyph) &glyph); @@ -198,7 +198,7 @@ private: friend class TextNode; }; -INLINE ostream &operator << (ostream &out, const DynamicTextFont &dtf); +INLINE std::ostream &operator << (std::ostream &out, const DynamicTextFont &dtf); #include "dynamicTextFont.I" diff --git a/panda/src/text/fontPool.I b/panda/src/text/fontPool.I index d0142579e1..c6fd4544e3 100644 --- a/panda/src/text/fontPool.I +++ b/panda/src/text/fontPool.I @@ -15,7 +15,7 @@ * Returns true if the font has ever been loaded, false otherwise. */ INLINE bool FontPool:: -has_font(const string &filename) { +has_font(const std::string &filename) { return get_ptr()->ns_has_font(filename); } @@ -26,7 +26,7 @@ has_font(const string &filename) { * with the same font name will return a valid Font pointer. */ INLINE bool FontPool:: -verify_font(const string &filename) { +verify_font(const std::string &filename) { return load_font(filename) != nullptr; } @@ -37,7 +37,7 @@ verify_font(const string &filename) { * returns NULL. */ INLINE TextFont *FontPool:: -load_font(const string &filename) { +load_font(const std::string &filename) { return get_ptr()->ns_load_font(filename); } @@ -46,7 +46,7 @@ load_font(const string &filename) { * replace any previously-loaded font in the pool that had the same filename. */ INLINE void FontPool:: -add_font(const string &filename, TextFont *font) { +add_font(const std::string &filename, TextFont *font) { get_ptr()->ns_add_font(filename, font); } @@ -57,7 +57,7 @@ add_font(const string &filename, TextFont *font) { * and fonts will never be freed. */ INLINE void FontPool:: -release_font(const string &filename) { +release_font(const std::string &filename) { get_ptr()->ns_release_font(filename); } @@ -83,7 +83,7 @@ garbage_collect() { * Lists the contents of the font pool to the indicated output stream. */ INLINE void FontPool:: -list_contents(ostream &out) { +list_contents(std::ostream &out) { get_ptr()->ns_list_contents(out); } diff --git a/panda/src/text/fontPool.h b/panda/src/text/fontPool.h index 363e2aade7..8852a83b0c 100644 --- a/panda/src/text/fontPool.h +++ b/panda/src/text/fontPool.h @@ -33,37 +33,37 @@ PUBLISHED: // parameters may not be entirely an actual filename: they may be a filename // followed by a face index. - INLINE static bool has_font(const string &filename); - INLINE static bool verify_font(const string &filename); - BLOCKING INLINE static TextFont *load_font(const string &filename); - INLINE static void add_font(const string &filename, TextFont *font); - INLINE static void release_font(const string &filename); + INLINE static bool has_font(const std::string &filename); + INLINE static bool verify_font(const std::string &filename); + BLOCKING INLINE static TextFont *load_font(const std::string &filename); + INLINE static void add_font(const std::string &filename, TextFont *font); + INLINE static void release_font(const std::string &filename); INLINE static void release_all_fonts(); INLINE static int garbage_collect(); - INLINE static void list_contents(ostream &out); - static void write(ostream &out); + INLINE static void list_contents(std::ostream &out); + static void write(std::ostream &out); private: INLINE FontPool(); - bool ns_has_font(const string &str); - TextFont *ns_load_font(const string &str); - void ns_add_font(const string &str, TextFont *font); - void ns_release_font(const string &str); + bool ns_has_font(const std::string &str); + TextFont *ns_load_font(const std::string &str); + void ns_add_font(const std::string &str, TextFont *font); + void ns_release_font(const std::string &str); void ns_release_all_fonts(); int ns_garbage_collect(); - void ns_list_contents(ostream &out) const; + void ns_list_contents(std::ostream &out) const; - static void lookup_filename(const string &str, string &index_str, + static void lookup_filename(const std::string &str, std::string &index_str, Filename &filename, int &face_index); static FontPool *get_ptr(); static FontPool *_global_ptr; LightMutex _lock; - typedef pmap Fonts; + typedef pmap Fonts; Fonts _fonts; }; diff --git a/panda/src/text/geomTextGlyph.h b/panda/src/text/geomTextGlyph.h index 38d5604ee7..7e697c1405 100644 --- a/panda/src/text/geomTextGlyph.h +++ b/panda/src/text/geomTextGlyph.h @@ -38,8 +38,8 @@ public: virtual bool copy_primitives_from(const Geom *other); void count_geom(const Geom *other); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; void add_glyph(const TextGlyph *glyph); diff --git a/panda/src/text/staticTextFont.h b/panda/src/text/staticTextFont.h index 99a3e2d309..0c36bf4c5e 100644 --- a/panda/src/text/staticTextFont.h +++ b/panda/src/text/staticTextFont.h @@ -41,7 +41,7 @@ PUBLISHED: virtual PT(TextFont) make_copy() const; - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; public: virtual bool get_glyph(int character, CPT(TextGlyph) &glyph); diff --git a/panda/src/text/textAssembler.I b/panda/src/text/textAssembler.I index 3cce3a4ad9..d72d3d99bf 100644 --- a/panda/src/text/textAssembler.I +++ b/panda/src/text/textAssembler.I @@ -319,7 +319,7 @@ TextCharacter(wchar_t character, * */ INLINE TextAssembler::TextCharacter:: -TextCharacter(const TextGraphic *graphic, const wstring &graphic_wname, +TextCharacter(const TextGraphic *graphic, const std::wstring &graphic_wname, TextAssembler::ComputedProperties *cprops) : _character(0), _graphic(graphic), @@ -405,7 +405,7 @@ ComputedProperties(const TextProperties &orig_properties) : * */ INLINE TextAssembler::ComputedProperties:: -ComputedProperties(ComputedProperties *based_on, const wstring &wname, +ComputedProperties(ComputedProperties *based_on, const std::wstring &wname, TextEncoder *encoder) : _based_on(based_on), _depth(_based_on->_depth + 1), @@ -417,7 +417,7 @@ ComputedProperties(ComputedProperties *based_on, const wstring &wname, // Now we have to encode the wstring into a string, for lookup in the // TextPropertiesManager. - string name = encoder->encode_wtext(wname); + std::string name = encoder->encode_wtext(wname); const TextProperties *named_props = manager->get_properties_ptr(name); if (named_props != nullptr) { diff --git a/panda/src/text/textAssembler.h b/panda/src/text/textAssembler.h index 52195f8f69..2cbede0d10 100644 --- a/panda/src/text/textAssembler.h +++ b/panda/src/text/textAssembler.h @@ -64,13 +64,13 @@ PUBLISHED: INLINE void set_properties(const TextProperties &properties); INLINE const TextProperties &get_properties() const; - bool set_wtext(const wstring &wtext); - bool set_wsubstr(const wstring &wtext, int start, int count); + bool set_wtext(const std::wstring &wtext); + bool set_wsubstr(const std::wstring &wtext, int start, int count); - wstring get_plain_wtext() const; - wstring get_wordwrapped_plain_wtext() const; - wstring get_wtext() const; - wstring get_wordwrapped_wtext() const; + std::wstring get_plain_wtext() const; + std::wstring get_wordwrapped_plain_wtext() const; + std::wstring get_wtext() const; + std::wstring get_wordwrapped_wtext() const; bool calc_r_c(int &r, int &c, int n) const; INLINE int calc_r(int n) const; @@ -116,12 +116,12 @@ private: public: INLINE ComputedProperties(const TextProperties &orig_properties); INLINE ComputedProperties(ComputedProperties *based_on, - const wstring &wname, TextEncoder *encoder); - void append_delta(wstring &wtext, ComputedProperties *other); + const std::wstring &wname, TextEncoder *encoder); + void append_delta(std::wstring &wtext, ComputedProperties *other); PT(ComputedProperties) _based_on; int _depth; - wstring _wname; + std::wstring _wname; TextProperties _properties; }; @@ -133,14 +133,14 @@ private: public: INLINE TextCharacter(wchar_t character, ComputedProperties *cprops); INLINE TextCharacter(const TextGraphic *graphic, - const wstring &graphic_wname, + const std::wstring &graphic_wname, ComputedProperties *cprops); INLINE TextCharacter(const TextCharacter ©); INLINE void operator = (const TextCharacter ©); wchar_t _character; const TextGraphic *_graphic; - wstring _graphic_wname; + std::wstring _graphic_wname; PT(ComputedProperties) _cprops; }; typedef pvector TextString; @@ -169,8 +169,8 @@ private: TextBlock _text_block; void scan_wtext(TextString &output_string, - wstring::const_iterator &si, - const wstring::const_iterator &send, + std::wstring::const_iterator &si, + const std::wstring::const_iterator &send, ComputedProperties *current_cprops); bool wordwrap_text(); diff --git a/panda/src/text/textFont.h b/panda/src/text/textFont.h index 7cea63e391..3c51c46d0c 100644 --- a/panda/src/text/textFont.h +++ b/panda/src/text/textFont.h @@ -76,7 +76,7 @@ PUBLISHED: virtual PN_stdfloat get_kerning(int first, int second) const; - virtual void write(ostream &out, int indent_level) const; + virtual void write(std::ostream &out, int indent_level) const; public: INLINE PN_stdfloat get_total_poly_margin() const; @@ -84,7 +84,7 @@ public: virtual bool get_glyph(int character, CPT(TextGlyph) &glyph)=0; TextGlyph *get_invalid_glyph(); - static RenderMode string_render_mode(const string &string); + static RenderMode string_render_mode(const std::string &string); private: void make_invalid_glyph(); @@ -114,8 +114,8 @@ private: static TypeHandle _type_handle; }; -EXPCL_PANDA_TEXT ostream &operator << (ostream &out, TextFont::RenderMode rm); -EXPCL_PANDA_TEXT istream &operator >> (istream &in, TextFont::RenderMode &rm); +EXPCL_PANDA_TEXT std::ostream &operator << (std::ostream &out, TextFont::RenderMode rm); +EXPCL_PANDA_TEXT std::istream &operator >> (std::istream &in, TextFont::RenderMode &rm); #include "textFont.I" diff --git a/panda/src/text/textNode.I b/panda/src/text/textNode.I index dd10624d27..313685c504 100644 --- a/panda/src/text/textNode.I +++ b/panda/src/text/textNode.I @@ -830,7 +830,7 @@ clear_shadow() { * "fixed". */ INLINE void TextNode:: -set_bin(const string &bin) { +set_bin(const std::string &bin) { TextProperties::set_bin(bin); invalidate_no_measure(); } @@ -935,7 +935,7 @@ clear_glyph_shift() { * Changes the text that is displayed under the TextNode. */ INLINE void TextNode:: -set_text(const string &text) { +set_text(const std::string &text) { TextEncoder::set_text(text); invalidate_with_measure(); } @@ -947,7 +947,7 @@ set_text(const string &text) { * whichever encoding is specified by set_encoding(). */ INLINE void TextNode:: -set_text(const string &text, TextNode::Encoding encoding) { +set_text(const std::string &text, TextNode::Encoding encoding) { TextEncoder::set_text(text, encoding); invalidate_with_measure(); } @@ -965,7 +965,7 @@ clear_text() { * Appends the indicates string to the end of the stored text. */ INLINE void TextNode:: -append_text(const string &text) { +append_text(const std::string &text) { TextEncoder::append_text(text); invalidate_with_measure(); } @@ -987,7 +987,7 @@ append_unicode_char(wchar_t character) { * In earlier versions, this did not contain any embedded special characters * like \1 or \3; now it does. */ -INLINE string TextNode:: +INLINE std::string TextNode:: get_wordwrapped_text() const { return encode_wtext(get_wordwrapped_wtext()); } @@ -997,7 +997,7 @@ get_wordwrapped_text() const { * should not include the newline character. */ INLINE PN_stdfloat TextNode:: -calc_width(const string &line) const { +calc_width(const std::string &line) const { return calc_width(decode_text(line)); } @@ -1007,7 +1007,7 @@ calc_width(const string &line) const { * encoded version of the same string. */ INLINE void TextNode:: -set_wtext(const wstring &wtext) { +set_wtext(const std::wstring &wtext) { TextEncoder::set_wtext(wtext); invalidate_with_measure(); } @@ -1016,7 +1016,7 @@ set_wtext(const wstring &wtext) { * Appends the indicates string to the end of the stored wide-character text. */ INLINE void TextNode:: -append_wtext(const wstring &wtext) { +append_wtext(const std::wstring &wtext) { TextEncoder::append_wtext(wtext); invalidate_with_measure(); } @@ -1028,7 +1028,7 @@ append_wtext(const wstring &wtext) { * In earlier versions, this did not contain any embedded special characters * like \1 or \3; now it does. */ -INLINE wstring TextNode:: +INLINE std::wstring TextNode:: get_wordwrapped_wtext() const { check_measure(); return _wordwrapped_wtext; diff --git a/panda/src/text/textNode.h b/panda/src/text/textNode.h index 4e24b110b9..4f37f806f4 100644 --- a/panda/src/text/textNode.h +++ b/panda/src/text/textNode.h @@ -45,8 +45,8 @@ */ class EXPCL_PANDA_TEXT TextNode : public PandaNode, public TextEncoder, public TextProperties { PUBLISHED: - explicit TextNode(const string &name); - explicit TextNode(const string &name, const TextProperties ©); + explicit TextNode(const std::string &name); + explicit TextNode(const std::string &name, const TextProperties ©); protected: TextNode(const TextNode ©); virtual PandaNode *make_copy() const; @@ -165,7 +165,7 @@ PUBLISHED: INLINE void set_shadow(const LVecBase2 &shadow_offset); INLINE void clear_shadow(); - INLINE void set_bin(const string &bin); + INLINE void set_bin(const std::string &bin); INLINE void clear_bin(); INLINE int set_draw_order(int draw_order); @@ -182,34 +182,34 @@ PUBLISHED: // These methods are inherited from TextEncoder, but we override here so we // can flag the TextNode as dirty when they have been changed. - INLINE void set_text(const string &text); - INLINE void set_text(const string &text, Encoding encoding); + INLINE void set_text(const std::string &text); + INLINE void set_text(const std::string &text, Encoding encoding); INLINE void clear_text(); - INLINE void append_text(const string &text); + INLINE void append_text(const std::string &text); INLINE void append_unicode_char(wchar_t character); // After the text has been set, you can query this to determine how it will // be wordwrapped. - INLINE string get_wordwrapped_text() const; + INLINE std::string get_wordwrapped_text() const; // These methods calculate the width of a single character or a line of text // in the current font. PN_stdfloat calc_width(wchar_t character) const; - INLINE PN_stdfloat calc_width(const string &line) const; + INLINE PN_stdfloat calc_width(const std::string &line) const; bool has_exact_character(wchar_t character) const; bool has_character(wchar_t character) const; bool is_whitespace(wchar_t character) const; // Direct support for wide-character strings. - INLINE void set_wtext(const wstring &wtext); - INLINE void append_wtext(const wstring &text); + INLINE void set_wtext(const std::wstring &wtext); + INLINE void append_wtext(const std::wstring &text); - INLINE wstring get_wordwrapped_wtext() const; - PN_stdfloat calc_width(const wstring &line) const; + INLINE std::wstring get_wordwrapped_wtext() const; + PN_stdfloat calc_width(const std::wstring &line) const; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; // The following functions return information about the text that was last // built (and is currently visible). @@ -358,7 +358,7 @@ private: // Returned from TextAssembler: LVector2 _text_ul, _text_lr; int _num_rows; - wstring _wordwrapped_wtext; + std::wstring _wordwrapped_wtext; static PStatCollector _text_generate_pcollector; diff --git a/panda/src/text/textProperties.I b/panda/src/text/textProperties.I index e3e296c95f..09bfc78dad 100644 --- a/panda/src/text/textProperties.I +++ b/panda/src/text/textProperties.I @@ -562,7 +562,7 @@ get_shadow() const { * "fixed". */ INLINE void TextProperties:: -set_bin(const string &bin) { +set_bin(const std::string &bin) { _bin = bin; _specified |= F_has_bin; _text_state.clear(); @@ -575,7 +575,7 @@ set_bin(const string &bin) { */ INLINE void TextProperties:: clear_bin() { - _bin = string(); + _bin = std::string(); _specified &= ~F_has_bin; _text_state.clear(); _shadow_state.clear(); @@ -594,7 +594,7 @@ has_bin() const { * Returns the drawing bin set with set_bin(), or empty string if no bin has * been set. */ -INLINE const string &TextProperties:: +INLINE const std::string &TextProperties:: get_bin() const { return _bin; } diff --git a/panda/src/text/textProperties.h b/panda/src/text/textProperties.h index af899f7b59..aca592e30b 100644 --- a/panda/src/text/textProperties.h +++ b/panda/src/text/textProperties.h @@ -135,10 +135,10 @@ PUBLISHED: INLINE bool has_shadow() const; INLINE LVector2 get_shadow() const; - INLINE void set_bin(const string &bin); + INLINE void set_bin(const std::string &bin); INLINE void clear_bin(); INLINE bool has_bin() const; - INLINE const string &get_bin() const; + INLINE const std::string &get_bin() const; INLINE int set_draw_order(int draw_order); INLINE void clear_draw_order(); @@ -172,7 +172,7 @@ PUBLISHED: void add_properties(const TextProperties &other); - void write(ostream &out, int indent_level = 0) const; + void write(std::ostream &out, int indent_level = 0) const; PUBLISHED: MAKE_PROPERTY2(font, has_font, get_font, set_font, clear_font); @@ -255,7 +255,7 @@ private: LColor _text_color; LColor _shadow_color; LVector2 _shadow_offset; - string _bin; + std::string _bin; int _draw_order; PN_stdfloat _tab_width; PN_stdfloat _glyph_scale; diff --git a/panda/src/text/textPropertiesManager.h b/panda/src/text/textPropertiesManager.h index 2c4f6b3c84..bae0c86e78 100644 --- a/panda/src/text/textPropertiesManager.h +++ b/panda/src/text/textPropertiesManager.h @@ -47,30 +47,30 @@ protected: ~TextPropertiesManager(); PUBLISHED: - void set_properties(const string &name, const TextProperties &properties); - TextProperties get_properties(const string &name); - bool has_properties(const string &name) const; - void clear_properties(const string &name); + void set_properties(const std::string &name, const TextProperties &properties); + TextProperties get_properties(const std::string &name); + bool has_properties(const std::string &name) const; + void clear_properties(const std::string &name); - void set_graphic(const string &name, const TextGraphic &graphic); - void set_graphic(const string &name, const NodePath &model); - TextGraphic get_graphic(const string &name); - bool has_graphic(const string &name) const; - void clear_graphic(const string &name); + void set_graphic(const std::string &name, const TextGraphic &graphic); + void set_graphic(const std::string &name, const NodePath &model); + TextGraphic get_graphic(const std::string &name); + bool has_graphic(const std::string &name) const; + void clear_graphic(const std::string &name); - void write(ostream &out, int indent_level = 0) const; + void write(std::ostream &out, int indent_level = 0) const; static TextPropertiesManager *get_global_ptr(); public: - const TextProperties *get_properties_ptr(const string &name); - const TextGraphic *get_graphic_ptr(const string &name); + const TextProperties *get_properties_ptr(const std::string &name); + const TextGraphic *get_graphic_ptr(const std::string &name); private: - typedef pmap Properties; + typedef pmap Properties; Properties _properties; - typedef pmap Graphics; + typedef pmap Graphics; Graphics _graphics; static TextPropertiesManager *_global_ptr; diff --git a/panda/src/tform/buttonThrower.I b/panda/src/tform/buttonThrower.I index 22832bc933..2e0fc4c57f 100644 --- a/panda/src/tform/buttonThrower.I +++ b/panda/src/tform/buttonThrower.I @@ -24,7 +24,7 @@ * See also set_keystroke_event(). */ INLINE void ButtonThrower:: -set_button_down_event(const string &button_down_event) { +set_button_down_event(const std::string &button_down_event) { _button_down_event = button_down_event; } @@ -32,7 +32,7 @@ set_button_down_event(const string &button_down_event) { * Returns the button_down_event that has been set on this ButtonThrower. See * set_button_down_event(). */ -INLINE const string &ButtonThrower:: +INLINE const std::string &ButtonThrower:: get_button_down_event() const { return _button_down_event; } @@ -42,7 +42,7 @@ get_button_down_event() const { * button is released. See set_button_down_event(). */ INLINE void ButtonThrower:: -set_button_up_event(const string &button_up_event) { +set_button_up_event(const std::string &button_up_event) { _button_up_event = button_up_event; } @@ -50,7 +50,7 @@ set_button_up_event(const string &button_up_event) { * Returns the button_up_event that has been set on this ButtonThrower. See * set_button_up_event(). */ -INLINE const string &ButtonThrower:: +INLINE const std::string &ButtonThrower:: get_button_up_event() const { return _button_up_event; } @@ -68,7 +68,7 @@ get_button_up_event() const { * See also set_keystroke_event(). */ INLINE void ButtonThrower:: -set_button_repeat_event(const string &button_repeat_event) { +set_button_repeat_event(const std::string &button_repeat_event) { _button_repeat_event = button_repeat_event; } @@ -76,7 +76,7 @@ set_button_repeat_event(const string &button_repeat_event) { * Returns the button_repeat_event that has been set on this ButtonThrower. * See set_button_repeat_event(). */ -INLINE const string &ButtonThrower:: +INLINE const std::string &ButtonThrower:: get_button_repeat_event() const { return _button_repeat_event; } @@ -100,7 +100,7 @@ get_button_repeat_event() const { * See also set_button_down_event(). */ INLINE void ButtonThrower:: -set_keystroke_event(const string &keystroke_event) { +set_keystroke_event(const std::string &keystroke_event) { _keystroke_event = keystroke_event; } @@ -108,7 +108,7 @@ set_keystroke_event(const string &keystroke_event) { * Returns the keystroke_event that has been set on this ButtonThrower. See * set_keystroke_event(). */ -INLINE const string &ButtonThrower:: +INLINE const std::string &ButtonThrower:: get_keystroke_event() const { return _keystroke_event; } @@ -129,7 +129,7 @@ get_keystroke_event() const { * which to end the highlight, and the current cursor position. */ INLINE void ButtonThrower:: -set_candidate_event(const string &candidate_event) { +set_candidate_event(const std::string &candidate_event) { _candidate_event = candidate_event; } @@ -137,7 +137,7 @@ set_candidate_event(const string &candidate_event) { * Returns the candidate_event that has been set on this ButtonThrower. See * set_candidate_event(). */ -INLINE const string &ButtonThrower:: +INLINE const std::string &ButtonThrower:: get_candidate_event() const { return _candidate_event; } @@ -147,7 +147,7 @@ get_candidate_event() const { * within the window. */ INLINE void ButtonThrower:: -set_move_event(const string &move_event) { +set_move_event(const std::string &move_event) { _move_event = move_event; } @@ -155,7 +155,7 @@ set_move_event(const string &move_event) { * Returns the move_event that has been set on this ButtonThrower. See * set_move_event(). */ -INLINE const string &ButtonThrower:: +INLINE const std::string &ButtonThrower:: get_move_event() const { return _move_event; } @@ -166,7 +166,7 @@ get_move_event() const { * selected keyboard layout. */ INLINE void ButtonThrower:: -set_raw_button_down_event(const string &raw_button_down_event) { +set_raw_button_down_event(const std::string &raw_button_down_event) { _raw_button_down_event = raw_button_down_event; } @@ -174,7 +174,7 @@ set_raw_button_down_event(const string &raw_button_down_event) { * Returns the raw_button_down_event that has been set on this ButtonThrower. * See set_raw_button_down_event(). */ -INLINE const string &ButtonThrower:: +INLINE const std::string &ButtonThrower:: get_raw_button_down_event() const { return _raw_button_down_event; } @@ -184,7 +184,7 @@ get_raw_button_down_event() const { * button is released. See set_raw_button_down_event(). */ INLINE void ButtonThrower:: -set_raw_button_up_event(const string &raw_button_up_event) { +set_raw_button_up_event(const std::string &raw_button_up_event) { _raw_button_up_event = raw_button_up_event; } @@ -192,7 +192,7 @@ set_raw_button_up_event(const string &raw_button_up_event) { * Returns the raw_button_up_event that has been set on this ButtonThrower. * See set_raw_button_up_event(). */ -INLINE const string &ButtonThrower:: +INLINE const std::string &ButtonThrower:: get_raw_button_up_event() const { return _raw_button_up_event; } @@ -203,7 +203,7 @@ get_raw_button_up_event() const { * generic event names like set_button_down_event) thrown by this object. */ INLINE void ButtonThrower:: -set_prefix(const string &prefix) { +set_prefix(const std::string &prefix) { _prefix = prefix; } @@ -211,7 +211,7 @@ set_prefix(const string &prefix) { * Returns the prefix that has been set on this ButtonThrower. See * set_prefix(). */ -INLINE const string &ButtonThrower:: +INLINE const std::string &ButtonThrower:: get_prefix() const { return _prefix; } diff --git a/panda/src/tform/buttonThrower.h b/panda/src/tform/buttonThrower.h index 2c1a8a3982..7aa47c1fa9 100644 --- a/panda/src/tform/buttonThrower.h +++ b/panda/src/tform/buttonThrower.h @@ -34,25 +34,25 @@ */ class EXPCL_PANDA_TFORM ButtonThrower : public DataNode { PUBLISHED: - explicit ButtonThrower(const string &name); + explicit ButtonThrower(const std::string &name); ~ButtonThrower(); - INLINE void set_button_down_event(const string &button_down_event); - INLINE const string &get_button_down_event() const; - INLINE void set_button_up_event(const string &button_up_event); - INLINE const string &get_button_up_event() const; - INLINE void set_button_repeat_event(const string &button_repeat_event); - INLINE const string &get_button_repeat_event() const; - INLINE void set_keystroke_event(const string &keystroke_event); - INLINE const string &get_keystroke_event() const; - INLINE void set_candidate_event(const string &candidate_event); - INLINE const string &get_candidate_event() const; - INLINE void set_move_event(const string &move_event); - INLINE const string &get_move_event() const; - INLINE void set_raw_button_down_event(const string &raw_button_down_event); - INLINE const string &get_raw_button_down_event() const; - INLINE void set_raw_button_up_event(const string &raw_button_up_event); - INLINE const string &get_raw_button_up_event() const; + INLINE void set_button_down_event(const std::string &button_down_event); + INLINE const std::string &get_button_down_event() const; + INLINE void set_button_up_event(const std::string &button_up_event); + INLINE const std::string &get_button_up_event() const; + INLINE void set_button_repeat_event(const std::string &button_repeat_event); + INLINE const std::string &get_button_repeat_event() const; + INLINE void set_keystroke_event(const std::string &keystroke_event); + INLINE const std::string &get_keystroke_event() const; + INLINE void set_candidate_event(const std::string &candidate_event); + INLINE const std::string &get_candidate_event() const; + INLINE void set_move_event(const std::string &move_event); + INLINE const std::string &get_move_event() const; + INLINE void set_raw_button_down_event(const std::string &raw_button_down_event); + INLINE const std::string &get_raw_button_down_event() const; + INLINE void set_raw_button_up_event(const std::string &raw_button_up_event); + INLINE const std::string &get_raw_button_up_event() const; MAKE_PROPERTY(button_down_event, get_button_down_event, set_button_down_event); MAKE_PROPERTY(button_up_event, get_button_up_event, set_button_up_event); MAKE_PROPERTY(button_repeat_event, get_button_repeat_event, set_button_repeat_event); @@ -62,8 +62,8 @@ PUBLISHED: MAKE_PROPERTY(raw_button_down_event, get_raw_button_down_event, set_raw_button_down_event); MAKE_PROPERTY(raw_button_up_event, get_raw_button_up_event, set_raw_button_up_event); - INLINE void set_prefix(const string &prefix); - INLINE const string &get_prefix() const; + INLINE void set_prefix(const std::string &prefix); + INLINE const std::string &get_prefix() const; INLINE void set_specific_flag(bool specific_flag); INLINE bool get_specific_flag() const; MAKE_PROPERTY(prefix, get_prefix, set_prefix); @@ -94,24 +94,24 @@ PUBLISHED: void clear_throw_buttons(); public: - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; private: - void do_specific_event(const string &event_name, double time); + void do_specific_event(const std::string &event_name, double time); void do_general_event(const ButtonEvent &button_event, - const string &event_name); + const std::string &event_name); private: - string _button_down_event; - string _button_up_event; - string _button_repeat_event; - string _keystroke_event; - string _candidate_event; - string _move_event; - string _raw_button_up_event; - string _raw_button_down_event; + std::string _button_down_event; + std::string _button_up_event; + std::string _button_repeat_event; + std::string _keystroke_event; + std::string _candidate_event; + std::string _move_event; + std::string _raw_button_up_event; + std::string _raw_button_down_event; bool _specific_flag; - string _prefix; + std::string _prefix; bool _time_flag; ModifierButtons _mods; diff --git a/panda/src/tform/driveInterface.h b/panda/src/tform/driveInterface.h index 89f6b069b0..516cc6be43 100644 --- a/panda/src/tform/driveInterface.h +++ b/panda/src/tform/driveInterface.h @@ -30,7 +30,7 @@ */ class EXPCL_PANDA_TFORM DriveInterface : public MouseInterfaceNode { PUBLISHED: - explicit DriveInterface(const string &name = ""); + explicit DriveInterface(const std::string &name = ""); ~DriveInterface(); INLINE void set_forward_speed(PN_stdfloat speed); diff --git a/panda/src/tform/mouseInterfaceNode.h b/panda/src/tform/mouseInterfaceNode.h index 1555dba852..b1540e6aba 100644 --- a/panda/src/tform/mouseInterfaceNode.h +++ b/panda/src/tform/mouseInterfaceNode.h @@ -30,7 +30,7 @@ class ButtonEventList; */ class EXPCL_PANDA_TFORM MouseInterfaceNode : public DataNode { public: - explicit MouseInterfaceNode(const string &name); + explicit MouseInterfaceNode(const std::string &name); virtual ~MouseInterfaceNode(); PUBLISHED: diff --git a/panda/src/tform/mouseSubregion.h b/panda/src/tform/mouseSubregion.h index f500992bcb..105dda96f9 100644 --- a/panda/src/tform/mouseSubregion.h +++ b/panda/src/tform/mouseSubregion.h @@ -32,7 +32,7 @@ */ class EXPCL_PANDA_TFORM MouseSubregion : public MouseInterfaceNode { PUBLISHED: - explicit MouseSubregion(const string &name); + explicit MouseSubregion(const std::string &name); ~MouseSubregion(); INLINE PN_stdfloat get_left() const; diff --git a/panda/src/tform/mouseWatcher.I b/panda/src/tform/mouseWatcher.I index 7d709f252e..f47c07e6e2 100644 --- a/panda/src/tform/mouseWatcher.I +++ b/panda/src/tform/mouseWatcher.I @@ -160,7 +160,7 @@ is_button_down(ButtonHandle button) const { * values. */ INLINE void MouseWatcher:: -set_button_down_pattern(const string &pattern) { +set_button_down_pattern(const std::string &pattern) { _button_down_pattern = pattern; } @@ -168,7 +168,7 @@ set_button_down_pattern(const string &pattern) { * Returns the string that indicates how event names are generated when a * button is depressed. See set_button_down_pattern(). */ -INLINE const string &MouseWatcher:: +INLINE const std::string &MouseWatcher:: get_button_down_pattern() const { return _button_down_pattern; } @@ -178,7 +178,7 @@ get_button_down_pattern() const { * when a button is released. See set_button_down_pattern(). */ INLINE void MouseWatcher:: -set_button_up_pattern(const string &pattern) { +set_button_up_pattern(const std::string &pattern) { _button_up_pattern = pattern; } @@ -186,7 +186,7 @@ set_button_up_pattern(const string &pattern) { * Returns the string that indicates how event names are generated when a * button is released. See set_button_down_pattern(). */ -INLINE const string &MouseWatcher:: +INLINE const std::string &MouseWatcher:: get_button_up_pattern() const { return _button_up_pattern; } @@ -204,7 +204,7 @@ get_button_up_pattern() const { * values. */ INLINE void MouseWatcher:: -set_button_repeat_pattern(const string &pattern) { +set_button_repeat_pattern(const std::string &pattern) { _button_repeat_pattern = pattern; } @@ -213,7 +213,7 @@ set_button_repeat_pattern(const string &pattern) { * when a button is continuously held and generates keyrepeat "down" events. * See set_button_repeat_pattern(). */ -INLINE const string &MouseWatcher:: +INLINE const std::string &MouseWatcher:: get_button_repeat_pattern() const { return _button_repeat_pattern; } @@ -225,7 +225,7 @@ get_button_repeat_pattern() const { * it might be "within" multiple nested regions. */ INLINE void MouseWatcher:: -set_enter_pattern(const string &pattern) { +set_enter_pattern(const std::string &pattern) { _enter_pattern = pattern; } @@ -235,7 +235,7 @@ set_enter_pattern(const string &pattern) { * mouse is only "entered" in the topmost region at a given time, while it * might be "within" multiple nested regions. */ -INLINE const string &MouseWatcher:: +INLINE const std::string &MouseWatcher:: get_enter_pattern() const { return _enter_pattern; } @@ -247,7 +247,7 @@ get_enter_pattern() const { * it might be "within" multiple nested regions. */ INLINE void MouseWatcher:: -set_leave_pattern(const string &pattern) { +set_leave_pattern(const std::string &pattern) { _leave_pattern = pattern; } @@ -257,7 +257,7 @@ set_leave_pattern(const string &pattern) { * mouse is only "entered" in the topmost region at a given time, while it * might be "within" multiple nested regions. */ -INLINE const string &MouseWatcher:: +INLINE const std::string &MouseWatcher:: get_leave_pattern() const { return _leave_pattern; } @@ -269,7 +269,7 @@ get_leave_pattern() const { * given time, while it might be "within" multiple nested regions. */ INLINE void MouseWatcher:: -set_within_pattern(const string &pattern) { +set_within_pattern(const std::string &pattern) { _within_pattern = pattern; } @@ -279,7 +279,7 @@ set_within_pattern(const string &pattern) { * a mouse is only "entered" in the topmost region at a given time, while it * might be "within" multiple nested regions. */ -INLINE const string &MouseWatcher:: +INLINE const std::string &MouseWatcher:: get_within_pattern() const { return _within_pattern; } @@ -291,7 +291,7 @@ get_within_pattern() const { * given time, while it might be "within" multiple nested regions. */ INLINE void MouseWatcher:: -set_without_pattern(const string &pattern) { +set_without_pattern(const std::string &pattern) { _without_pattern = pattern; } @@ -301,7 +301,7 @@ set_without_pattern(const string &pattern) { * that a mouse is only "entered" in the topmost region at a given time, while * it might be "within" multiple nested regions. */ -INLINE const string &MouseWatcher:: +INLINE const std::string &MouseWatcher:: get_without_pattern() const { return _without_pattern; } @@ -475,7 +475,7 @@ clear_inactivity_timeout() { * timeout counter expires. See set_inactivity_timeout(). */ INLINE void MouseWatcher:: -set_inactivity_timeout_event(const string &event) { +set_inactivity_timeout_event(const std::string &event) { _inactivity_timeout_event = event; } @@ -483,7 +483,7 @@ set_inactivity_timeout_event(const string &event) { * Returns the event string that will be generated when the inactivity timeout * counter expires. See set_inactivity_timeout(). */ -INLINE const string &MouseWatcher:: +INLINE const std::string &MouseWatcher:: get_inactivity_timeout_event() const { return _inactivity_timeout_event; } diff --git a/panda/src/tform/mouseWatcher.h b/panda/src/tform/mouseWatcher.h index c3b4988b7f..9f21f3d09b 100644 --- a/panda/src/tform/mouseWatcher.h +++ b/panda/src/tform/mouseWatcher.h @@ -60,7 +60,7 @@ class DisplayRegion; */ class EXPCL_PANDA_TFORM MouseWatcher : public DataNode, public MouseWatcherBase { PUBLISHED: - explicit MouseWatcher(const string &name = ""); + explicit MouseWatcher(const std::string &name = ""); ~MouseWatcher(); bool remove_region(MouseWatcherRegion *region); @@ -85,26 +85,26 @@ PUBLISHED: INLINE bool is_button_down(ButtonHandle button) const; - INLINE void set_button_down_pattern(const string &pattern); - INLINE const string &get_button_down_pattern() const; + INLINE void set_button_down_pattern(const std::string &pattern); + INLINE const std::string &get_button_down_pattern() const; - INLINE void set_button_up_pattern(const string &pattern); - INLINE const string &get_button_up_pattern() const; + INLINE void set_button_up_pattern(const std::string &pattern); + INLINE const std::string &get_button_up_pattern() const; - INLINE void set_button_repeat_pattern(const string &pattern); - INLINE const string &get_button_repeat_pattern() const; + INLINE void set_button_repeat_pattern(const std::string &pattern); + INLINE const std::string &get_button_repeat_pattern() const; - INLINE void set_enter_pattern(const string &pattern); - INLINE const string &get_enter_pattern() const; + INLINE void set_enter_pattern(const std::string &pattern); + INLINE const std::string &get_enter_pattern() const; - INLINE void set_leave_pattern(const string &pattern); - INLINE const string &get_leave_pattern() const; + INLINE void set_leave_pattern(const std::string &pattern); + INLINE const std::string &get_leave_pattern() const; - INLINE void set_within_pattern(const string &pattern); - INLINE const string &get_within_pattern() const; + INLINE void set_within_pattern(const std::string &pattern); + INLINE const std::string &get_within_pattern() const; - INLINE void set_without_pattern(const string &pattern); - INLINE const string &get_without_pattern() const; + INLINE void set_without_pattern(const std::string &pattern); + INLINE const std::string &get_without_pattern() const; INLINE void set_geometry(PandaNode *node); INLINE bool has_geometry() const; @@ -134,8 +134,8 @@ PUBLISHED: INLINE double get_inactivity_timeout() const; INLINE void clear_inactivity_timeout(); - INLINE void set_inactivity_timeout_event(const string &event); - INLINE const string &get_inactivity_timeout_event() const; + INLINE void set_inactivity_timeout_event(const std::string &event); + INLINE const std::string &get_inactivity_timeout_event() const; INLINE CPT(PointerEventList) get_trail_log() const; INLINE int num_trail_recent() const; @@ -147,8 +147,8 @@ PUBLISHED: void note_activity(); public: - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; protected: void get_over_regions(Regions ®ions, const LPoint2 &pos) const; @@ -159,7 +159,7 @@ protected: #ifndef NDEBUG virtual void do_show_regions(const NodePath &render2d, - const string &bin_name, int draw_order); + const std::string &bin_name, int draw_order); virtual void do_hide_regions(); #endif // NDEBUG @@ -173,7 +173,7 @@ protected: static bool has_region_in(const Regions ®ions, MouseWatcherRegion *region); - void throw_event_pattern(const string &pattern, + void throw_event_pattern(const std::string &pattern, const MouseWatcherRegion *region, const ButtonHandle &button); @@ -181,7 +181,7 @@ protected: void press(ButtonHandle button, bool keyrepeat); void release(ButtonHandle button); void keystroke(int keycode); - void candidate(const wstring &candidate, size_t highlight_start, + void candidate(const std::wstring &candidate, size_t highlight_start, size_t highlight_end, size_t cursor_pos); void global_keyboard_press(const MouseWatcherParameter ¶m); @@ -232,13 +232,13 @@ private: bool _enter_multiple; bool _implicit_click; - string _button_down_pattern; - string _button_up_pattern; - string _button_repeat_pattern; - string _enter_pattern; - string _leave_pattern; - string _within_pattern; - string _without_pattern; + std::string _button_down_pattern; + std::string _button_up_pattern; + std::string _button_repeat_pattern; + std::string _enter_pattern; + std::string _leave_pattern; + std::string _within_pattern; + std::string _without_pattern; PT(PandaNode) _geometry; @@ -249,7 +249,7 @@ private: bool _has_inactivity_timeout; double _inactivity_timeout; - string _inactivity_timeout_event; + std::string _inactivity_timeout_event; double _last_activity; enum InactivityState { @@ -262,7 +262,7 @@ private: #ifndef NDEBUG NodePath _show_regions_render2d; - string _show_regions_bin_name; + std::string _show_regions_bin_name; int _show_regions_draw_order; #endif diff --git a/panda/src/tform/mouseWatcherBase.h b/panda/src/tform/mouseWatcherBase.h index 8836f57023..f3b53c2ec2 100644 --- a/panda/src/tform/mouseWatcherBase.h +++ b/panda/src/tform/mouseWatcherBase.h @@ -37,7 +37,7 @@ PUBLISHED: void add_region(MouseWatcherRegion *region); bool has_region(MouseWatcherRegion *region) const; bool remove_region(MouseWatcherRegion *region); - MouseWatcherRegion *find_region(const string &name) const; + MouseWatcherRegion *find_region(const std::string &name) const; void clear_regions(); void sort_regions(); @@ -49,12 +49,12 @@ PUBLISHED: MAKE_SEQ(get_regions, get_num_regions, get_region); MAKE_SEQ_PROPERTY(regions, get_num_regions, get_region); - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; #ifndef NDEBUG void show_regions(const NodePath &render2d, - const string &bin_name, int draw_order); + const std::string &bin_name, int draw_order); void set_color(const LColor &color); void hide_regions(); @@ -67,7 +67,7 @@ protected: #ifndef NDEBUG virtual void do_show_regions(const NodePath &render2d, - const string &bin_name, int draw_order); + const std::string &bin_name, int draw_order); virtual void do_hide_regions(); void do_update_regions(); #endif // NDEBUG diff --git a/panda/src/tform/mouseWatcherParameter.I b/panda/src/tform/mouseWatcherParameter.I index 4983fcfda0..49d6314e91 100644 --- a/panda/src/tform/mouseWatcherParameter.I +++ b/panda/src/tform/mouseWatcherParameter.I @@ -88,7 +88,7 @@ set_keycode(int keycode) { * Sets the candidate string associated with this event, if any. */ INLINE void MouseWatcherParameter:: -set_candidate(const wstring &candidate_string, +set_candidate(const std::wstring &candidate_string, size_t highlight_start, size_t highlight_end, size_t cursor_pos) { _candidate_string = candidate_string; @@ -188,7 +188,7 @@ has_candidate() const { * Returns the candidate string associated with this event. If * has_candidate(), above, returns false, this returns the empty string. */ -INLINE const wstring &MouseWatcherParameter:: +INLINE const std::wstring &MouseWatcherParameter:: get_candidate_string() const { return _candidate_string; } @@ -197,7 +197,7 @@ get_candidate_string() const { * Returns the candidate string associated with this event. If * has_candidate(), above, returns false, this returns the empty string. */ -INLINE string MouseWatcherParameter:: +INLINE std::string MouseWatcherParameter:: get_candidate_string_encoded() const { return get_candidate_string_encoded(TextEncoder::get_default_encoding()); } @@ -206,7 +206,7 @@ get_candidate_string_encoded() const { * Returns the candidate string associated with this event. If * has_candidate(), above, returns false, this returns the empty string. */ -INLINE string MouseWatcherParameter:: +INLINE std::string MouseWatcherParameter:: get_candidate_string_encoded(TextEncoder::Encoding encoding) const { return TextEncoder::encode_wtext(_candidate_string, encoding); } @@ -274,8 +274,8 @@ is_outside() const { return (_flags & F_is_outside) != 0; } -INLINE ostream & -operator << (ostream &out, const MouseWatcherParameter &parm) { +INLINE std::ostream & +operator << (std::ostream &out, const MouseWatcherParameter &parm) { parm.output(out); return out; } diff --git a/panda/src/tform/mouseWatcherParameter.h b/panda/src/tform/mouseWatcherParameter.h index 1da5dcfc45..8ea454d4f2 100644 --- a/panda/src/tform/mouseWatcherParameter.h +++ b/panda/src/tform/mouseWatcherParameter.h @@ -35,7 +35,7 @@ public: INLINE void set_button(const ButtonHandle &button); INLINE void set_keyrepeat(bool flag); INLINE void set_keycode(int keycode); - INLINE void set_candidate(const wstring &candidate_string, + INLINE void set_candidate(const std::wstring &candidate_string, size_t highlight_start, size_t higlight_end, size_t cursor_pos); @@ -54,11 +54,11 @@ PUBLISHED: INLINE bool has_candidate() const; public: - INLINE const wstring &get_candidate_string() const; + INLINE const std::wstring &get_candidate_string() const; PUBLISHED: - INLINE string get_candidate_string_encoded() const; - INLINE string get_candidate_string_encoded(TextEncoder::Encoding encoding) const; + INLINE std::string get_candidate_string_encoded() const; + INLINE std::string get_candidate_string_encoded(TextEncoder::Encoding encoding) const; INLINE size_t get_highlight_start() const; INLINE size_t get_highlight_end() const; INLINE size_t get_cursor_pos() const; @@ -70,12 +70,12 @@ PUBLISHED: INLINE bool is_outside() const; - void output(ostream &out) const; + void output(std::ostream &out) const; public: ButtonHandle _button; int _keycode; - wstring _candidate_string; + std::wstring _candidate_string; size_t _highlight_start; size_t _highlight_end; size_t _cursor_pos; @@ -93,7 +93,7 @@ public: int _flags; }; -INLINE ostream &operator << (ostream &out, const MouseWatcherParameter &parm); +INLINE std::ostream &operator << (std::ostream &out, const MouseWatcherParameter &parm); #include "mouseWatcherParameter.I" diff --git a/panda/src/tform/mouseWatcherRegion.I b/panda/src/tform/mouseWatcherRegion.I index cdcc71d51e..50dfada487 100644 --- a/panda/src/tform/mouseWatcherRegion.I +++ b/panda/src/tform/mouseWatcherRegion.I @@ -15,7 +15,7 @@ * */ INLINE MouseWatcherRegion:: -MouseWatcherRegion(const string &name, PN_stdfloat left, PN_stdfloat right, +MouseWatcherRegion(const std::string &name, PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) : Namable(name), _frame(left, right, bottom, top) @@ -28,7 +28,7 @@ MouseWatcherRegion(const string &name, PN_stdfloat left, PN_stdfloat right, * */ INLINE MouseWatcherRegion:: -MouseWatcherRegion(const string &name, const LVecBase4 &frame) : +MouseWatcherRegion(const std::string &name, const LVecBase4 &frame) : Namable(name), _frame(frame) { diff --git a/panda/src/tform/mouseWatcherRegion.h b/panda/src/tform/mouseWatcherRegion.h index 0230c42d96..a49cfcbc6e 100644 --- a/panda/src/tform/mouseWatcherRegion.h +++ b/panda/src/tform/mouseWatcherRegion.h @@ -30,9 +30,9 @@ class MouseWatcherParameter; */ class EXPCL_PANDA_TFORM MouseWatcherRegion : public TypedWritableReferenceCount, public Namable { PUBLISHED: - INLINE explicit MouseWatcherRegion(const string &name, PN_stdfloat left, PN_stdfloat right, + INLINE explicit MouseWatcherRegion(const std::string &name, PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top); - INLINE explicit MouseWatcherRegion(const string &name, const LVecBase4 &frame); + INLINE explicit MouseWatcherRegion(const std::string &name, const LVecBase4 &frame); INLINE void set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top); INLINE void set_frame(const LVecBase4 &frame); @@ -58,8 +58,8 @@ PUBLISHED: INLINE void set_suppress_flags(int suppress_flags); INLINE int get_suppress_flags() const; - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; public: INLINE bool operator < (const MouseWatcherRegion &other) const; @@ -108,7 +108,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const MouseWatcherRegion ®ion) { +INLINE std::ostream &operator << (std::ostream &out, const MouseWatcherRegion ®ion) { region.output(out); return out; } diff --git a/panda/src/tform/trackball.h b/panda/src/tform/trackball.h index 634e81f61a..0ef01f6b8e 100644 --- a/panda/src/tform/trackball.h +++ b/panda/src/tform/trackball.h @@ -34,7 +34,7 @@ */ class EXPCL_PANDA_TFORM Trackball : public MouseInterfaceNode { PUBLISHED: - explicit Trackball(const string &name); + explicit Trackball(const std::string &name); ~Trackball(); void reset(); diff --git a/panda/src/tform/transform2sg.h b/panda/src/tform/transform2sg.h index 66939aa096..a385abb428 100644 --- a/panda/src/tform/transform2sg.h +++ b/panda/src/tform/transform2sg.h @@ -27,7 +27,7 @@ */ class EXPCL_PANDA_TFORM Transform2SG : public DataNode { PUBLISHED: - explicit Transform2SG(const string &name); + explicit Transform2SG(const std::string &name); void set_node(PandaNode *node); PandaNode *get_node() const; diff --git a/panda/src/tinydisplay/tinyGraphicsBuffer.h b/panda/src/tinydisplay/tinyGraphicsBuffer.h index c7f7a1e61e..79c6e8c5e5 100644 --- a/panda/src/tinydisplay/tinyGraphicsBuffer.h +++ b/panda/src/tinydisplay/tinyGraphicsBuffer.h @@ -24,7 +24,7 @@ class EXPCL_TINYDISPLAY TinyGraphicsBuffer : public GraphicsBuffer { public: TinyGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.h b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.h index 21395b1e62..94d4eb8d73 100644 --- a/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.h +++ b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.h @@ -31,11 +31,11 @@ public: TinyOffscreenGraphicsPipe(); virtual ~TinyOffscreenGraphicsPipe(); - virtual string get_interface_name() const; + virtual std::string get_interface_name() const; static PT(GraphicsPipe) pipe_constructor(); protected: - virtual PT(GraphicsOutput) make_output(const string &name, + virtual PT(GraphicsOutput) make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinyOsxGraphicsPipe.h b/panda/src/tinydisplay/tinyOsxGraphicsPipe.h index f0781dfb5b..14cc0aded0 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsPipe.h +++ b/panda/src/tinydisplay/tinyOsxGraphicsPipe.h @@ -35,7 +35,7 @@ public: TinyOsxGraphicsPipe(); virtual ~TinyOsxGraphicsPipe(); - virtual string get_interface_name() const; + virtual std::string get_interface_name() const; static PT(GraphicsPipe) pipe_constructor(); static CGImageRef create_cg_image(const PNMImage &pnm_image); @@ -44,7 +44,7 @@ private: static void release_data(void *info, const void *data, size_t size); protected: - virtual PT(GraphicsOutput) make_output(const string &name, + virtual PT(GraphicsOutput) make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinyOsxGraphicsWindow.h b/panda/src/tinydisplay/tinyOsxGraphicsWindow.h index 1d61868c9c..71682c9a3b 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsWindow.h +++ b/panda/src/tinydisplay/tinyOsxGraphicsWindow.h @@ -30,7 +30,7 @@ class TinyOsxGraphicsWindow : public GraphicsWindow { public: TinyOsxGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinySDLGraphicsPipe.h b/panda/src/tinydisplay/tinySDLGraphicsPipe.h index 6897e51b6b..a3fc009647 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsPipe.h +++ b/panda/src/tinydisplay/tinySDLGraphicsPipe.h @@ -32,11 +32,11 @@ public: TinySDLGraphicsPipe(); virtual ~TinySDLGraphicsPipe(); - virtual string get_interface_name() const; + virtual std::string get_interface_name() const; static PT(GraphicsPipe) pipe_constructor(); protected: - virtual PT(GraphicsOutput) make_output(const string &name, + virtual PT(GraphicsOutput) make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinySDLGraphicsWindow.h b/panda/src/tinydisplay/tinySDLGraphicsWindow.h index ae5793dcd4..b1be27b557 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsWindow.h +++ b/panda/src/tinydisplay/tinySDLGraphicsWindow.h @@ -30,7 +30,7 @@ class EXPCL_TINYDISPLAY TinySDLGraphicsWindow : public GraphicsWindow { public: TinySDLGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinyWinGraphicsPipe.h b/panda/src/tinydisplay/tinyWinGraphicsPipe.h index fed6c7fa12..8626a9d675 100644 --- a/panda/src/tinydisplay/tinyWinGraphicsPipe.h +++ b/panda/src/tinydisplay/tinyWinGraphicsPipe.h @@ -30,11 +30,11 @@ public: TinyWinGraphicsPipe(); virtual ~TinyWinGraphicsPipe(); - virtual string get_interface_name() const; + virtual std::string get_interface_name() const; static PT(GraphicsPipe) pipe_constructor(); protected: - virtual PT(GraphicsOutput) make_output(const string &name, + virtual PT(GraphicsOutput) make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinyWinGraphicsWindow.h b/panda/src/tinydisplay/tinyWinGraphicsWindow.h index 3140e61d27..ecc1365a0b 100644 --- a/panda/src/tinydisplay/tinyWinGraphicsWindow.h +++ b/panda/src/tinydisplay/tinyWinGraphicsWindow.h @@ -28,7 +28,7 @@ class EXPCL_TINYDISPLAY TinyWinGraphicsWindow : public WinGraphicsWindow { public: TinyWinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinyXGraphicsPipe.h b/panda/src/tinydisplay/tinyXGraphicsPipe.h index c6ecf15817..c0f7f69eeb 100644 --- a/panda/src/tinydisplay/tinyXGraphicsPipe.h +++ b/panda/src/tinydisplay/tinyXGraphicsPipe.h @@ -30,14 +30,14 @@ */ class EXPCL_TINYDISPLAY TinyXGraphicsPipe : public x11GraphicsPipe { public: - TinyXGraphicsPipe(const string &display = string()); + TinyXGraphicsPipe(const std::string &display = std::string()); virtual ~TinyXGraphicsPipe(); - virtual string get_interface_name() const; + virtual std::string get_interface_name() const; static PT(GraphicsPipe) pipe_constructor(); protected: - virtual PT(GraphicsOutput) make_output(const string &name, + virtual PT(GraphicsOutput) make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/tinydisplay/tinyXGraphicsWindow.h b/panda/src/tinydisplay/tinyXGraphicsWindow.h index e533f2b67d..da60c70eeb 100644 --- a/panda/src/tinydisplay/tinyXGraphicsWindow.h +++ b/panda/src/tinydisplay/tinyXGraphicsWindow.h @@ -28,7 +28,7 @@ class EXPCL_TINYDISPLAY TinyXGraphicsWindow : public x11GraphicsWindow { public: TinyXGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/vision/openCVTexture.h b/panda/src/vision/openCVTexture.h index ce4d279456..e3fa1a3edb 100644 --- a/panda/src/vision/openCVTexture.h +++ b/panda/src/vision/openCVTexture.h @@ -28,7 +28,7 @@ struct CvCapture; */ class EXPCL_VISION OpenCVTexture : public VideoTexture { PUBLISHED: - OpenCVTexture(const string &name = string()); + OpenCVTexture(const std::string &name = std::string()); OpenCVTexture(const OpenCVTexture ©) = delete; virtual ~OpenCVTexture(); @@ -54,7 +54,7 @@ protected: const LoaderOptions &options, bool header_only, BamCacheRecord *record); virtual bool do_load_one(Texture::CData *cdata, - const PNMImage &pnmimage, const string &name, + const PNMImage &pnmimage, const std::string &name, int z, int n, const LoaderOptions &options); private: diff --git a/panda/src/vision/webcamVideo.I b/panda/src/vision/webcamVideo.I index dcc0f473ca..c0c2e1fe74 100644 --- a/panda/src/vision/webcamVideo.I +++ b/panda/src/vision/webcamVideo.I @@ -39,7 +39,7 @@ get_fps() const { /** * Returns the camera's pixel format, as a FourCC code, if known. */ -INLINE const string &WebcamVideo:: +INLINE const std::string &WebcamVideo:: get_pixel_format() const { return _pixel_format; } @@ -49,7 +49,7 @@ get_pixel_format() const { * FPS to the output stream. */ INLINE void WebcamVideo:: -output(ostream &out) const { +output(std::ostream &out) const { out << get_name() << ": " << get_size_x() << "x" << get_size_y(); if (!_pixel_format.empty()) { @@ -59,7 +59,7 @@ output(ostream &out) const { out << " @ " << get_fps() << "Hz"; } -INLINE ostream &operator << (ostream &out, const WebcamVideo &n) { +INLINE std::ostream &operator << (std::ostream &out, const WebcamVideo &n) { n.output(out); return out; } diff --git a/panda/src/vision/webcamVideo.h b/panda/src/vision/webcamVideo.h index cdcf5e393d..903afa87f3 100644 --- a/panda/src/vision/webcamVideo.h +++ b/panda/src/vision/webcamVideo.h @@ -33,11 +33,11 @@ PUBLISHED: INLINE int get_size_x() const; INLINE int get_size_y() const; INLINE double get_fps() const; - INLINE const string &get_pixel_format() const; + INLINE const std::string &get_pixel_format() const; virtual PT(MovieVideoCursor) open() = 0; - INLINE void output(ostream &out) const; + INLINE void output(std::ostream &out) const; public: static void find_all_webcams(); @@ -46,7 +46,7 @@ protected: int _size_x; int _size_y; double _fps; - string _pixel_format; + std::string _pixel_format; static pvector _all_webcams; @@ -68,7 +68,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const WebcamVideo &n); +INLINE std::ostream &operator << (std::ostream &out, const WebcamVideo &n); #include "webcamVideo.I" diff --git a/panda/src/vision/webcamVideoV4L.h b/panda/src/vision/webcamVideoV4L.h index 374daf6f76..40045ee402 100644 --- a/panda/src/vision/webcamVideoV4L.h +++ b/panda/src/vision/webcamVideoV4L.h @@ -31,11 +31,11 @@ private: friend class WebcamVideoCursorV4L; friend void find_all_webcams_v4l(); - static void add_options_for_size(int fd, const string &dev, const char *name, + static void add_options_for_size(int fd, const std::string &dev, const char *name, unsigned width, unsigned height, unsigned pixelformat); - string _device; + std::string _device; uint32_t _pformat; public: diff --git a/panda/src/vrpn/vrpnAnalog.I b/panda/src/vrpn/vrpnAnalog.I index 61efae3f51..afd951e417 100644 --- a/panda/src/vrpn/vrpnAnalog.I +++ b/panda/src/vrpn/vrpnAnalog.I @@ -15,7 +15,7 @@ * Returns the name of the analog device that was used to create this * VrpnAnalog. */ -INLINE const string &VrpnAnalog:: +INLINE const std::string &VrpnAnalog:: get_analog_name() const { return _analog_name; } diff --git a/panda/src/vrpn/vrpnAnalog.h b/panda/src/vrpn/vrpnAnalog.h index 0816c48ff5..07f3c84b21 100644 --- a/panda/src/vrpn/vrpnAnalog.h +++ b/panda/src/vrpn/vrpnAnalog.h @@ -37,10 +37,10 @@ class VrpnAnalogDevice; */ class VrpnAnalog { public: - VrpnAnalog(const string &analog_name, vrpn_Connection *connection); + VrpnAnalog(const std::string &analog_name, vrpn_Connection *connection); ~VrpnAnalog(); - INLINE const string &get_analog_name() const; + INLINE const std::string &get_analog_name() const; INLINE bool is_empty() const; void mark(VrpnAnalogDevice *device); @@ -48,22 +48,22 @@ public: INLINE void poll(); - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; private: static void VRPN_CALLBACK vrpn_analog_callback(void *userdata, const vrpn_ANALOGCB info); private: - string _analog_name; + std::string _analog_name; vrpn_Analog_Remote *_analog; typedef pvector Devices; Devices _devices; }; -INLINE ostream &operator << (ostream &out, const VrpnAnalog &analog) { +INLINE std::ostream &operator << (std::ostream &out, const VrpnAnalog &analog) { analog.output(out); return out; } diff --git a/panda/src/vrpn/vrpnAnalogDevice.h b/panda/src/vrpn/vrpnAnalogDevice.h index e34f864d1c..a778857f60 100644 --- a/panda/src/vrpn/vrpnAnalogDevice.h +++ b/panda/src/vrpn/vrpnAnalogDevice.h @@ -29,7 +29,7 @@ class VrpnAnalog; */ class VrpnAnalogDevice : public ClientAnalogDevice { public: - VrpnAnalogDevice(VrpnClient *client, const string &device_name, + VrpnAnalogDevice(VrpnClient *client, const std::string &device_name, VrpnAnalog *vrpn_analog); virtual ~VrpnAnalogDevice(); diff --git a/panda/src/vrpn/vrpnButton.I b/panda/src/vrpn/vrpnButton.I index e5252a8e19..ed10b89fae 100644 --- a/panda/src/vrpn/vrpnButton.I +++ b/panda/src/vrpn/vrpnButton.I @@ -15,7 +15,7 @@ * Returns the name of the button device that was used to create this * VrpnButton. */ -INLINE const string &VrpnButton:: +INLINE const std::string &VrpnButton:: get_button_name() const { return _button_name; } diff --git a/panda/src/vrpn/vrpnButton.h b/panda/src/vrpn/vrpnButton.h index bdd829ab98..1b9fc14cf4 100644 --- a/panda/src/vrpn/vrpnButton.h +++ b/panda/src/vrpn/vrpnButton.h @@ -36,10 +36,10 @@ class VrpnButtonDevice; */ class VrpnButton { public: - VrpnButton(const string &button_name, vrpn_Connection *connection); + VrpnButton(const std::string &button_name, vrpn_Connection *connection); ~VrpnButton(); - INLINE const string &get_button_name() const; + INLINE const std::string &get_button_name() const; INLINE bool is_empty() const; void mark(VrpnButtonDevice *device); @@ -47,22 +47,22 @@ public: INLINE void poll(); - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; private: static void VRPN_CALLBACK vrpn_button_callback(void *userdata, const vrpn_BUTTONCB info); private: - string _button_name; + std::string _button_name; vrpn_Button_Remote *_button; typedef pvector Devices; Devices _devices; }; -INLINE ostream &operator << (ostream &out, const VrpnButton &button) { +INLINE std::ostream &operator << (std::ostream &out, const VrpnButton &button) { button.output(out); return out; } diff --git a/panda/src/vrpn/vrpnButtonDevice.h b/panda/src/vrpn/vrpnButtonDevice.h index 3c88da7f2b..45ba3df694 100644 --- a/panda/src/vrpn/vrpnButtonDevice.h +++ b/panda/src/vrpn/vrpnButtonDevice.h @@ -29,7 +29,7 @@ class VrpnButton; */ class VrpnButtonDevice : public ClientButtonDevice { public: - VrpnButtonDevice(VrpnClient *client, const string &device_name, + VrpnButtonDevice(VrpnClient *client, const std::string &device_name, VrpnButton *vrpn_button); virtual ~VrpnButtonDevice(); diff --git a/panda/src/vrpn/vrpnClient.I b/panda/src/vrpn/vrpnClient.I index 563428d917..486a4e29f6 100644 --- a/panda/src/vrpn/vrpnClient.I +++ b/panda/src/vrpn/vrpnClient.I @@ -14,7 +14,7 @@ /** * Returns the name of the server as passed to the VrpnClient constructor. */ -INLINE const string &VrpnClient:: +INLINE const std::string &VrpnClient:: get_server_name() const { return _server_name; } @@ -55,7 +55,7 @@ convert_to_secs(struct timeval msg_time) { * */ INLINE VrpnClient:: -VrpnClient(const string &server) : +VrpnClient(const std::string &server) : ClientBase(server) { _connection = vrpn_get_connection_by_name(server.c_str()); @@ -66,7 +66,7 @@ VrpnClient(const string &server) : * particular sensor we have interest in) */ INLINE void VrpnClient:: -tracker_position(const string &tracker, const vrpn_TRACKERCB info) { +tracker_position(const std::string &tracker, const vrpn_TRACKERCB info) { double ptime = convert_to_secs(info.msg_time); LPoint3 pos(info.pos[0], info.pos[1], info.pos[2]); LVector4 pquat(info.quat[0], info.quat[1], info.quat[2], info.quat[3]); @@ -79,7 +79,7 @@ tracker_position(const string &tracker, const vrpn_TRACKERCB info) { * particular sensor we have interest in) */ INLINE void VrpnClient:: -tracker_velocity(const string &tracker, const vrpn_TRACKERVELCB info) { +tracker_velocity(const std::string &tracker, const vrpn_TRACKERVELCB info) { double vtime = convert_to_secs(info.msg_time); LPoint3 vel(info.vel[0], info.vel[1], info.vel[2]); LVector4 vquat(info.vel_quat[0], info.vel_quat[1], @@ -93,7 +93,7 @@ tracker_velocity(const string &tracker, const vrpn_TRACKERVELCB info) { * particular sensor we have interest in) */ INLINE void VrpnClient:: -tracker_acceleration(const string &tracker, const vrpn_TRACKERACCCB info) { +tracker_acceleration(const std::string &tracker, const vrpn_TRACKERACCCB info) { double atime = convert_to_secs(info.msg_time); LPoint3 acc(info.acc[0], info.acc[1], info.acc[2]); LVector4 aquat(info.acc_quat[0], info.acc_quat[1], @@ -107,7 +107,7 @@ tracker_acceleration(const string &tracker, const vrpn_TRACKERACCCB info) { * Stores the latest information as sent by the analog device */ INLINE void VrpnClient:: -analog(const string &analog, const vrpn_ANALOGCB info) { +analog(const std::string &analog, const vrpn_ANALOGCB info) { double atime = convert_to_secs(info.msg_time); push_analog(analog, atime, info.channel, info.num_channel); @@ -117,7 +117,7 @@ analog(const string &analog, const vrpn_ANALOGCB info) { * Stores the latest button pressed information as sent by the button */ INLINE void VrpnClient:: -button(const string &button, const vrpn_BUTTONCB info) { +button(const std::string &button, const vrpn_BUTTONCB info) { double btime = convert_to_secs(info.msg_time); push_button(button, btime, info.button, info.state); @@ -127,7 +127,7 @@ button(const string &button, const vrpn_BUTTONCB info) { * Stores the latest change information as sent by the dial */ INLINE void VrpnClient:: -dial(const string &dial, const vrpn_DIALCB info) { +dial(const std::string &dial, const vrpn_DIALCB info) { double dtime = convert_to_secs(info.msg_time); push_dial(dial, dtime, info.dial, info.change); diff --git a/panda/src/vrpn/vrpnClient.h b/panda/src/vrpn/vrpnClient.h index 501c0e2ae8..127492d9cf 100644 --- a/panda/src/vrpn/vrpnClient.h +++ b/panda/src/vrpn/vrpnClient.h @@ -34,58 +34,58 @@ class VrpnDialDevice; */ class EXPCL_VRPN VrpnClient : public ClientBase { PUBLISHED: - explicit VrpnClient(const string &server_name); + explicit VrpnClient(const std::string &server_name); ~VrpnClient(); - INLINE const string &get_server_name() const; + INLINE const std::string &get_server_name() const; INLINE bool is_valid() const; INLINE bool is_connected() const; - void write(ostream &out, int indent_level = 0) const; + void write(std::ostream &out, int indent_level = 0) const; public: INLINE static double convert_to_secs(struct timeval msg_time); protected: virtual PT(ClientDevice) make_device(TypeHandle device_type, - const string &device_name); + const std::string &device_name); virtual bool disconnect_device(TypeHandle device_type, - const string &device_name, + const std::string &device_name, ClientDevice *device); virtual void do_poll(); private: - PT(ClientDevice) make_tracker_device(const string &device_name); - PT(ClientDevice) make_button_device(const string &device_name); - PT(ClientDevice) make_analog_device(const string &device_name); - PT(ClientDevice) make_dial_device(const string &device_name); + PT(ClientDevice) make_tracker_device(const std::string &device_name); + PT(ClientDevice) make_button_device(const std::string &device_name); + PT(ClientDevice) make_analog_device(const std::string &device_name); + PT(ClientDevice) make_dial_device(const std::string &device_name); void disconnect_tracker_device(VrpnTrackerDevice *device); void disconnect_button_device(VrpnButtonDevice *device); void disconnect_analog_device(VrpnAnalogDevice *device); void disconnect_dial_device(VrpnDialDevice *device); - VrpnTracker *get_tracker(const string &tracker_name); + VrpnTracker *get_tracker(const std::string &tracker_name); void free_tracker(VrpnTracker *vrpn_tracker); - VrpnButton *get_button(const string &button_name); + VrpnButton *get_button(const std::string &button_name); void free_button(VrpnButton *vrpn_button); - VrpnAnalog *get_analog(const string &analog_name); + VrpnAnalog *get_analog(const std::string &analog_name); void free_analog(VrpnAnalog *vrpn_analog); - VrpnDial *get_dial(const string &dial_name); + VrpnDial *get_dial(const std::string &dial_name); void free_dial(VrpnDial *vrpn_dial); private: - string _server_name; + std::string _server_name; vrpn_Connection *_connection; - typedef pmap Trackers; - typedef pmap Buttons; - typedef pmap Analogs; - typedef pmap Dials; + typedef pmap Trackers; + typedef pmap Buttons; + typedef pmap Analogs; + typedef pmap Dials; Trackers _trackers; Buttons _buttons; diff --git a/panda/src/vrpn/vrpnDial.I b/panda/src/vrpn/vrpnDial.I index 240f51fa40..2cb9981826 100644 --- a/panda/src/vrpn/vrpnDial.I +++ b/panda/src/vrpn/vrpnDial.I @@ -14,7 +14,7 @@ /** * Returns the name of the dial device that was used to create this VrpnDial. */ -INLINE const string &VrpnDial:: +INLINE const std::string &VrpnDial:: get_dial_name() const { return _dial_name; } diff --git a/panda/src/vrpn/vrpnDial.h b/panda/src/vrpn/vrpnDial.h index 5500d730e0..e98fd7d99d 100644 --- a/panda/src/vrpn/vrpnDial.h +++ b/panda/src/vrpn/vrpnDial.h @@ -36,10 +36,10 @@ class VrpnDialDevice; */ class VrpnDial { public: - VrpnDial(const string &dial_name, vrpn_Connection *connection); + VrpnDial(const std::string &dial_name, vrpn_Connection *connection); ~VrpnDial(); - INLINE const string &get_dial_name() const; + INLINE const std::string &get_dial_name() const; INLINE bool is_empty() const; void mark(VrpnDialDevice *device); @@ -47,22 +47,22 @@ public: INLINE void poll(); - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; private: static void VRPN_CALLBACK vrpn_dial_callback(void *userdata, const vrpn_DIALCB info); private: - string _dial_name; + std::string _dial_name; vrpn_Dial_Remote *_dial; typedef pvector Devices; Devices _devices; }; -INLINE ostream &operator << (ostream &out, const VrpnDial &dial) { +INLINE std::ostream &operator << (std::ostream &out, const VrpnDial &dial) { dial.output(out); return out; } diff --git a/panda/src/vrpn/vrpnDialDevice.h b/panda/src/vrpn/vrpnDialDevice.h index 533f3b3f97..52bb88c587 100644 --- a/panda/src/vrpn/vrpnDialDevice.h +++ b/panda/src/vrpn/vrpnDialDevice.h @@ -29,7 +29,7 @@ class VrpnDial; */ class VrpnDialDevice : public ClientDialDevice { public: - VrpnDialDevice(VrpnClient *client, const string &device_name, + VrpnDialDevice(VrpnClient *client, const std::string &device_name, VrpnDial *vrpn_dial); virtual ~VrpnDialDevice(); diff --git a/panda/src/vrpn/vrpnTracker.I b/panda/src/vrpn/vrpnTracker.I index 9c97e92968..b651121923 100644 --- a/panda/src/vrpn/vrpnTracker.I +++ b/panda/src/vrpn/vrpnTracker.I @@ -15,7 +15,7 @@ * Returns the name of the tracker device that was used to create this * VrpnTracker. */ -INLINE const string &VrpnTracker:: +INLINE const std::string &VrpnTracker:: get_tracker_name() const { return _tracker_name; } diff --git a/panda/src/vrpn/vrpnTracker.h b/panda/src/vrpn/vrpnTracker.h index acfdcaff5b..1b6c30347d 100644 --- a/panda/src/vrpn/vrpnTracker.h +++ b/panda/src/vrpn/vrpnTracker.h @@ -36,10 +36,10 @@ class VrpnTrackerDevice; */ class VrpnTracker { public: - VrpnTracker(const string &tracker_name, vrpn_Connection *connection); + VrpnTracker(const std::string &tracker_name, vrpn_Connection *connection); ~VrpnTracker(); - INLINE const string &get_tracker_name() const; + INLINE const std::string &get_tracker_name() const; INLINE bool is_empty() const; void mark(VrpnTrackerDevice *device); @@ -47,8 +47,8 @@ public: INLINE void poll(); - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; private: static void VRPN_CALLBACK @@ -59,14 +59,14 @@ private: vrpn_acceleration_callback(void *userdata, const vrpn_TRACKERACCCB info); private: - string _tracker_name; + std::string _tracker_name; vrpn_Tracker_Remote *_tracker; typedef pvector Devices; Devices _devices; }; -INLINE ostream &operator << (ostream &out, const VrpnTracker &tracker) { +INLINE std::ostream &operator << (std::ostream &out, const VrpnTracker &tracker) { tracker.output(out); return out; } diff --git a/panda/src/vrpn/vrpnTrackerDevice.h b/panda/src/vrpn/vrpnTrackerDevice.h index 17a626795e..58ddf9068b 100644 --- a/panda/src/vrpn/vrpnTrackerDevice.h +++ b/panda/src/vrpn/vrpnTrackerDevice.h @@ -39,7 +39,7 @@ public: DT_acceleration }; - VrpnTrackerDevice(VrpnClient *client, const string &device_name, + VrpnTrackerDevice(VrpnClient *client, const std::string &device_name, int sensor, DataType data_type, VrpnTracker *vrpn_tracker); virtual ~VrpnTrackerDevice(); diff --git a/panda/src/wgldisplay/wglGraphicsBuffer.h b/panda/src/wgldisplay/wglGraphicsBuffer.h index e5155e8653..594adc921d 100644 --- a/panda/src/wgldisplay/wglGraphicsBuffer.h +++ b/panda/src/wgldisplay/wglGraphicsBuffer.h @@ -35,7 +35,7 @@ class EXPCL_PANDAGL wglGraphicsBuffer : public GraphicsBuffer { public: wglGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/wgldisplay/wglGraphicsPipe.h b/panda/src/wgldisplay/wglGraphicsPipe.h index 2ac6d8d29d..892a8f8884 100644 --- a/panda/src/wgldisplay/wglGraphicsPipe.h +++ b/panda/src/wgldisplay/wglGraphicsPipe.h @@ -28,11 +28,11 @@ public: wglGraphicsPipe(); virtual ~wglGraphicsPipe(); - virtual string get_interface_name() const; + virtual std::string get_interface_name() const; static PT(GraphicsPipe) pipe_constructor(); protected: - virtual PT(GraphicsOutput) make_output(const string &name, + virtual PT(GraphicsOutput) make_output(const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -45,7 +45,7 @@ protected: private: - static string format_pfd_flags(DWORD pfd_flags); + static std::string format_pfd_flags(DWORD pfd_flags); static void wgl_make_current(HDC hdc, HGLRC hglrc, PStatCollector *collector); static bool _current_valid; diff --git a/panda/src/wgldisplay/wglGraphicsWindow.h b/panda/src/wgldisplay/wglGraphicsWindow.h index 9236640876..0db8f9cc73 100644 --- a/panda/src/wgldisplay/wglGraphicsWindow.h +++ b/panda/src/wgldisplay/wglGraphicsWindow.h @@ -23,7 +23,7 @@ class EXPCL_PANDAGL wglGraphicsWindow : public WinGraphicsWindow { public: wglGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, diff --git a/panda/src/windisplay/winDetectDx.h b/panda/src/windisplay/winDetectDx.h index e350c37564..df7d89f0ff 100644 --- a/panda/src/windisplay/winDetectDx.h +++ b/panda/src/windisplay/winDetectDx.h @@ -74,7 +74,7 @@ static DWORD _GetLastError (char *message_prefix) { FORMAT_MESSAGE_ALLOCATE_BUFFER |FORMAT_MESSAGE_FROM_SYSTEM, nullptr, error, MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US ), (LPTSTR)&ptr,0, nullptr)) { - cout << "ERROR: "<< message_prefix << " result = " << (char*) ptr << "\n"; + std::cout << "ERROR: "<< message_prefix << " result = " << (char*) ptr << "\n"; LocalFree( ptr ); } @@ -100,7 +100,7 @@ static DWORD print_GetLastError (char *message_prefix) (LPTSTR)&ptr, 0, nullptr)) { - cout << "ERROR: "<< message_prefix << " result = " << (char*) ptr << "\n"; + std::cout << "ERROR: "<< message_prefix << " result = " << (char*) ptr << "\n"; LocalFree( ptr ); } diff --git a/panda/src/windisplay/winGraphicsWindow.h b/panda/src/windisplay/winGraphicsWindow.h index ec7e1217ff..ffcbc79553 100644 --- a/panda/src/windisplay/winGraphicsWindow.h +++ b/panda/src/windisplay/winGraphicsWindow.h @@ -64,7 +64,7 @@ typedef struct tagTOUCHINPUT { class EXPCL_PANDAWIN WinGraphicsWindow : public GraphicsWindow { public: WinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -197,7 +197,7 @@ private: private: // We need this map to support per-window calls to window_proc(). - typedef map WindowHandles; + typedef std::map WindowHandles; static WindowHandles _window_handles; // And we need a static pointer to the current WinGraphicsWindow we are @@ -242,7 +242,7 @@ private: INLINE WindowClass(const WindowProperties &props); INLINE bool operator < (const WindowClass &other) const; - wstring _name; + std::wstring _name; HICON _icon; }; diff --git a/panda/src/x11display/x11GraphicsPipe.h b/panda/src/x11display/x11GraphicsPipe.h index 4da09d3144..c13b192627 100644 --- a/panda/src/x11display/x11GraphicsPipe.h +++ b/panda/src/x11display/x11GraphicsPipe.h @@ -46,7 +46,7 @@ class FrameBufferProperties; */ class x11GraphicsPipe : public GraphicsPipe { public: - x11GraphicsPipe(const string &display = string()); + x11GraphicsPipe(const std::string &display = std::string()); virtual ~x11GraphicsPipe(); INLINE X11_Display *get_display() const; diff --git a/panda/src/x11display/x11GraphicsWindow.h b/panda/src/x11display/x11GraphicsWindow.h index 5b55bf3619..46b93225dd 100644 --- a/panda/src/x11display/x11GraphicsWindow.h +++ b/panda/src/x11display/x11GraphicsWindow.h @@ -26,7 +26,7 @@ class x11GraphicsWindow : public GraphicsWindow { public: x11GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, - const string &name, + const std::string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, @@ -71,7 +71,7 @@ protected: private: X11_Cursor get_cursor(const Filename &filename); - X11_Cursor read_ico(istream &ico); + X11_Cursor read_ico(std::istream &ico); protected: X11_Display *_display; @@ -94,7 +94,7 @@ protected: struct MouseDeviceInfo { int _fd; int _input_device_index; - string _io_buffer; + std::string _io_buffer; }; pvector _mouse_device_info; diff --git a/pandatool/src/assimp/assimpLoader.h b/pandatool/src/assimp/assimpLoader.h index 41ac3e1dc6..35a9bb6947 100644 --- a/pandatool/src/assimp/assimpLoader.h +++ b/pandatool/src/assimp/assimpLoader.h @@ -46,7 +46,7 @@ public: AssimpLoader(); virtual ~AssimpLoader(); - void get_extensions(string &ext) const; + void get_extensions(std::string &ext) const; bool read(const Filename &filename); void build_graph(); diff --git a/pandatool/src/assimp/loaderFileTypeAssimp.h b/pandatool/src/assimp/loaderFileTypeAssimp.h index 495130a40e..45d810f964 100644 --- a/pandatool/src/assimp/loaderFileTypeAssimp.h +++ b/pandatool/src/assimp/loaderFileTypeAssimp.h @@ -28,9 +28,9 @@ public: LoaderFileTypeAssimp(); virtual ~LoaderFileTypeAssimp(); - virtual string get_name() const; - virtual string get_extension() const; - virtual string get_additional_extensions() const; + virtual std::string get_name() const; + virtual std::string get_extension() const; + virtual std::string get_additional_extensions() const; virtual bool supports_compressed() const; virtual PT(PandaNode) load_file(const Filename &path, const LoaderOptions &options, diff --git a/pandatool/src/assimp/pandaIOStream.h b/pandatool/src/assimp/pandaIOStream.h index cb4ddf251c..fa5cc2bb1e 100644 --- a/pandatool/src/assimp/pandaIOStream.h +++ b/pandatool/src/assimp/pandaIOStream.h @@ -26,7 +26,7 @@ class PandaIOSystem; */ class PandaIOStream : public Assimp::IOStream { public: - PandaIOStream(istream &stream); + PandaIOStream(std::istream &stream); virtual ~PandaIOStream() {}; size_t FileSize() const; @@ -37,7 +37,7 @@ public: size_t Write(const void *buffer, size_t size, size_t count); private: - istream &_istream; + std::istream &_istream; friend class PandaIOSystem; }; diff --git a/pandatool/src/bam/eggToBam.h b/pandatool/src/bam/eggToBam.h index a2fb838871..1ab262a52a 100644 --- a/pandatool/src/bam/eggToBam.h +++ b/pandatool/src/bam/eggToBam.h @@ -64,8 +64,8 @@ private: bool _tex_txopz; bool _tex_ctex; bool _tex_mipmap; - string _ctex_quality; - string _load_display; + std::string _ctex_quality; + std::string _load_display; // The rest of this is required to support -ctex. PT(GraphicsPipe) _pipe; diff --git a/pandatool/src/bam/ptsToBam.h b/pandatool/src/bam/ptsToBam.h index 9e6f7ac63e..20fa76e7a9 100644 --- a/pandatool/src/bam/ptsToBam.h +++ b/pandatool/src/bam/ptsToBam.h @@ -37,7 +37,7 @@ protected: virtual bool handle_args(Args &args); private: - void process_line(const string &line); + void process_line(const std::string &line); void add_point(const vector_string &words); void open_vertex_data(); diff --git a/pandatool/src/converter/eggToSomethingConverter.h b/pandatool/src/converter/eggToSomethingConverter.h index 47838859d4..0e95958c39 100644 --- a/pandatool/src/converter/eggToSomethingConverter.h +++ b/pandatool/src/converter/eggToSomethingConverter.h @@ -51,9 +51,9 @@ public: INLINE void set_output_coordinate_system(CoordinateSystem output_coordinate_system) const; INLINE CoordinateSystem get_output_coordinate_system() const; - virtual string get_name() const=0; - virtual string get_extension() const=0; - virtual string get_additional_extensions() const; + virtual std::string get_name() const=0; + virtual std::string get_extension() const=0; + virtual std::string get_additional_extensions() const; virtual bool supports_compressed() const; virtual bool write_file(const Filename &filename)=0; diff --git a/pandatool/src/converter/somethingToEggConverter.I b/pandatool/src/converter/somethingToEggConverter.I index a0259bc13d..b3fed0cb11 100644 --- a/pandatool/src/converter/somethingToEggConverter.I +++ b/pandatool/src/converter/somethingToEggConverter.I @@ -82,14 +82,14 @@ get_animation_convert() const { * its associated animations. */ INLINE void SomethingToEggConverter:: -set_character_name(const string &character_name) { +set_character_name(const std::string &character_name) { _character_name = character_name; } /** * Returns the name of the character generated. See set_character_name(). */ -INLINE const string &SomethingToEggConverter:: +INLINE const std::string &SomethingToEggConverter:: get_character_name() const { return _character_name; } diff --git a/pandatool/src/converter/somethingToEggConverter.h b/pandatool/src/converter/somethingToEggConverter.h index b3e71b6ab5..16d16df50d 100644 --- a/pandatool/src/converter/somethingToEggConverter.h +++ b/pandatool/src/converter/somethingToEggConverter.h @@ -55,8 +55,8 @@ public: INLINE void set_animation_convert(AnimationConvert animation_convert); INLINE AnimationConvert get_animation_convert() const; - INLINE void set_character_name(const string &character_name); - INLINE const string &get_character_name() const; + INLINE void set_character_name(const std::string &character_name); + INLINE const std::string &get_character_name() const; INLINE void set_start_frame(double start_frame); INLINE bool has_start_frame() const; @@ -97,9 +97,9 @@ public: INLINE void clear_egg_data(); INLINE EggData *get_egg_data(); - virtual string get_name() const=0; - virtual string get_extension() const=0; - virtual string get_additional_extensions() const; + virtual std::string get_name() const=0; + virtual std::string get_extension() const=0; + virtual std::string get_additional_extensions() const; virtual bool supports_compressed() const; virtual bool supports_convert_to_node(const LoaderOptions &options) const; @@ -119,7 +119,7 @@ protected: PT(PathReplace) _path_replace; AnimationConvert _animation_convert; - string _character_name; + std::string _character_name; double _start_frame; double _end_frame; double _frame_inc; diff --git a/pandatool/src/cvscopy/cvsCopy.h b/pandatool/src/cvscopy/cvsCopy.h index e8957eaa59..d820edf84d 100644 --- a/pandatool/src/cvscopy/cvsCopy.h +++ b/pandatool/src/cvscopy/cvsCopy.h @@ -52,14 +52,14 @@ protected: bool copy_binary_file(Filename source, Filename dest); bool cvs_add(const Filename &filename); - static string protect_from_shell(const string &source); + static std::string protect_from_shell(const std::string &source); - virtual string filter_filename(const string &source); + virtual std::string filter_filename(const std::string &source); private: bool scan_hierarchy(); - bool scan_for_root(const string &dirname); - string prompt(const string &message); + bool scan_for_root(const std::string &dirname); + std::string prompt(const std::string &message); protected: bool _force; @@ -72,7 +72,7 @@ protected: Filename _root_dirname; Filename _key_filename; bool _no_cvs; - string _cvs_binary; + std::string _cvs_binary; bool _user_aborted; typedef pvector SourceFiles; @@ -82,7 +82,7 @@ protected: CVSSourceDirectory *_model_dir; CVSSourceDirectory *_map_dir; - typedef pmap CopiedFiles; + typedef pmap CopiedFiles; CopiedFiles _copied_files; }; diff --git a/pandatool/src/cvscopy/cvsSourceDirectory.h b/pandatool/src/cvscopy/cvsSourceDirectory.h index e8e379c8f0..eb452612e4 100644 --- a/pandatool/src/cvscopy/cvsSourceDirectory.h +++ b/pandatool/src/cvscopy/cvsSourceDirectory.h @@ -35,10 +35,10 @@ class CVSSourceTree; class CVSSourceDirectory { public: CVSSourceDirectory(CVSSourceTree *tree, CVSSourceDirectory *parent, - const string &dirname); + const std::string &dirname); ~CVSSourceDirectory(); - string get_dirname() const; + std::string get_dirname() const; Filename get_fullpath() const; Filename get_path() const; Filename get_rel_to(const CVSSourceDirectory *other) const; @@ -46,16 +46,16 @@ public: int get_num_children() const; CVSSourceDirectory *get_child(int n) const; - CVSSourceDirectory *find_relpath(const string &relpath); - CVSSourceDirectory *find_dirname(const string &dirname); + CVSSourceDirectory *find_relpath(const std::string &relpath); + CVSSourceDirectory *find_dirname(const std::string &dirname); public: - bool scan(const Filename &directory, const string &key_filename); + bool scan(const Filename &directory, const std::string &key_filename); private: CVSSourceTree *_tree; CVSSourceDirectory *_parent; - string _dirname; + std::string _dirname; int _depth; typedef pvector Children; diff --git a/pandatool/src/cvscopy/cvsSourceTree.h b/pandatool/src/cvscopy/cvsSourceTree.h index b512ce6db0..238431f78d 100644 --- a/pandatool/src/cvscopy/cvsSourceTree.h +++ b/pandatool/src/cvscopy/cvsSourceTree.h @@ -41,8 +41,8 @@ public: CVSSourceDirectory *get_root() const; CVSSourceDirectory *find_directory(const Filename &path); - CVSSourceDirectory *find_relpath(const string &relpath); - CVSSourceDirectory *find_dirname(const string &dirname); + CVSSourceDirectory *find_relpath(const std::string &relpath); + CVSSourceDirectory *find_dirname(const std::string &dirname); // This nested class represents the selection of a particular directory in // which to place a given file, given its basename. The basename of the @@ -52,17 +52,17 @@ public: class FilePath { public: FilePath(); - FilePath(CVSSourceDirectory *dir, const string &basename); + FilePath(CVSSourceDirectory *dir, const std::string &basename); bool is_valid() const; Filename get_path() const; Filename get_fullpath() const; Filename get_rel_from(const CVSSourceDirectory *other) const; CVSSourceDirectory *_dir; - string _basename; + std::string _basename; }; - FilePath choose_directory(const string &basename, + FilePath choose_directory(const std::string &basename, CVSSourceDirectory *suggested_dir, bool force, bool interactive); @@ -73,22 +73,22 @@ public: static void restore_cwd(); public: - void add_file(const string &basename, CVSSourceDirectory *dir); + void add_file(const std::string &basename, CVSSourceDirectory *dir); private: typedef pvector FilePaths; FilePath - prompt_user(const string &basename, CVSSourceDirectory *suggested_dir, + prompt_user(const std::string &basename, CVSSourceDirectory *suggested_dir, const FilePaths &paths, bool force, bool interactive); - FilePath ask_existing(const string &filename, const FilePath &path); - FilePath ask_existing(const string &filename, const FilePaths &paths, + FilePath ask_existing(const std::string &filename, const FilePath &path); + FilePath ask_existing(const std::string &filename, const FilePaths &paths, CVSSourceDirectory *suggested_dir); - FilePath ask_new(const string &filename, CVSSourceDirectory *dir); - FilePath ask_any(const string &filename, const FilePaths &paths); + FilePath ask_new(const std::string &filename, CVSSourceDirectory *dir); + FilePath ask_any(const std::string &filename, const FilePaths &paths); - string prompt(const string &message); + std::string prompt(const std::string &message); static Filename get_actual_fullpath(const Filename &path); static Filename get_start_fullpath(); @@ -97,7 +97,7 @@ private: Filename _path; CVSSourceDirectory *_root; - typedef pmap Basenames; + typedef pmap Basenames; Basenames _basenames; static bool _got_start_fullpath; diff --git a/pandatool/src/daeegg/daeCharacter.h b/pandatool/src/daeegg/daeCharacter.h index 76339368c9..25378b684d 100644 --- a/pandatool/src/daeegg/daeCharacter.h +++ b/pandatool/src/daeegg/daeCharacter.h @@ -49,7 +49,7 @@ public: DaeCharacter *_character; }; typedef epvector Joints; - typedef pmap JointMap; + typedef pmap JointMap; void bind_joints(JointMap &joint_map); void adjust_joints(FCDSceneNode *node, const JointMap &joint_map, @@ -69,7 +69,7 @@ public: LMatrix4d _bind_shape_mat; private: - string _name; + std::string _name; const FCDSkinController *_skin_controller; Joints _joints; JointMap _bound_joints; diff --git a/pandatool/src/daeegg/daeMaterials.h b/pandatool/src/daeegg/daeMaterials.h index 7c2ba0d563..c18e631535 100644 --- a/pandatool/src/daeegg/daeMaterials.h +++ b/pandatool/src/daeegg/daeMaterials.h @@ -41,9 +41,9 @@ public: virtual ~DaeMaterials() {}; void add_material_instance(const FCDMaterialInstance* instance); - void apply_to_primitive(const string semantic, const PT(EggPrimitive) to); - void apply_to_group(const string semantic, const PT(EggGroup) to, bool invert_transparency=false); - const string get_uvset_name(const string semantic, FUDaeGeometryInput::Semantic input_semantic, int32 input_set); + void apply_to_primitive(const std::string semantic, const PT(EggPrimitive) to); + void apply_to_group(const std::string semantic, const PT(EggGroup) to, bool invert_transparency=false); + const std::string get_uvset_name(const std::string semantic, FUDaeGeometryInput::Semantic input_semantic, int32 input_set); static EggTexture::TextureType convert_texture_type(const FCDEffectParameterSampler::SamplerType orig_type); static EggTexture::WrapMode convert_wrap_mode(const FUDaeTextureWrapMode::WrapMode orig_mode); @@ -62,7 +62,7 @@ private: struct DaeVertexInputBinding : public ReferenceCount { int32 _input_set; FUDaeGeometryInput::Semantic _input_semantic; - string _semantic; + std::string _semantic; }; // Holds stuff for an individual material. @@ -74,11 +74,11 @@ private: PT(DaeBlendSettings) _blend; }; - void process_texture_bucket(const string semantic, const FCDEffectStandard* effect_common, FUDaeTextureChannel::Channel bucket, EggTexture::EnvType envtype = EggTexture::ET_unspecified, EggTexture::Format format = EggTexture::F_unspecified); - void process_extra(const string semantic, const FCDExtra* extra); + void process_texture_bucket(const std::string semantic, const FCDEffectStandard* effect_common, FUDaeTextureChannel::Channel bucket, EggTexture::EnvType envtype = EggTexture::ET_unspecified, EggTexture::Format format = EggTexture::F_unspecified); + void process_extra(const std::string semantic, const FCDExtra* extra); static PT(DaeBlendSettings) convert_blend(FCDEffectStandard::TransparencyMode mode, const LColor &transparent, double transparency); - pmap _materials; + pmap _materials; public: virtual TypeHandle get_type() const { diff --git a/pandatool/src/daeegg/daeToEggConverter.h b/pandatool/src/daeegg/daeToEggConverter.h index 2c1dc234c1..a1203c2f2c 100644 --- a/pandatool/src/daeegg/daeToEggConverter.h +++ b/pandatool/src/daeegg/daeToEggConverter.h @@ -49,8 +49,8 @@ public: virtual SomethingToEggConverter *make_copy(); - virtual string get_name() const; - virtual string get_extension() const; + virtual std::string get_name() const; + virtual std::string get_extension() const; virtual bool convert_file(const Filename &filename); virtual DistanceUnit get_input_units(); @@ -58,7 +58,7 @@ public: bool _invert_transparency; private: - string _unit_name; + std::string _unit_name; double _unit_meters; PT(EggTable) _table; FCDocument* _document; @@ -73,7 +73,7 @@ private: void process_instance(EggGroup *parent, const FCDEntityInstance* instance); void process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, DaeMaterials *materials, DaeCharacter *character = nullptr); - void process_spline(EggGroup *parent, const string group_name, FCDGeometrySpline* geometry_spline); + void process_spline(EggGroup *parent, const std::string group_name, FCDGeometrySpline* geometry_spline); void process_spline(EggGroup *parent, const FCDSpline* spline); void process_controller(EggGroup *parent, const FCDControllerInstance* instance); void process_extra(EggGroup *group, const FCDExtra* extra); diff --git a/pandatool/src/daeegg/fcollada_utils.h b/pandatool/src/daeegg/fcollada_utils.h index eefe990bac..cf1a3069f3 100644 --- a/pandatool/src/daeegg/fcollada_utils.h +++ b/pandatool/src/daeegg/fcollada_utils.h @@ -33,6 +33,6 @@ inline LColor TO_COLOR(FMVector4 v) { #define FROM_VEC3(v) (FMVector3(v[0], v[1], v[2])) #define FROM_VEC4(v) (FMVector4(v[0], v[1], v[2], v[3])) #define FROM_MAT4(v) (FMMatrix44(v.getData())) -#define FROM_FSTRING(fs) (string(fs.c_str())) +#define FROM_FSTRING(fs) (std::string(fs.c_str())) #endif diff --git a/pandatool/src/dxf/dxfFile.h b/pandatool/src/dxf/dxfFile.h index 59d37d3057..e555960e6a 100644 --- a/pandatool/src/dxf/dxfFile.h +++ b/pandatool/src/dxf/dxfFile.h @@ -38,7 +38,7 @@ public: virtual ~DXFFile(); void process(Filename filename); - void process(istream *in, bool owns_in); + void process(std::istream *in, bool owns_in); // These functions are called as the file is processed. These are the main // hooks for redefining how the class should dispense its data. As each @@ -57,7 +57,7 @@ public: // definition, and must allocate a DXFLayer instance. This function is // provided so that user code may force allocate of a specialized DXFLayer // instance instead. - virtual DXFLayer *new_layer(const string &name) { + virtual DXFLayer *new_layer(const std::string &name) { return new DXFLayer(name); } @@ -140,18 +140,18 @@ protected: bool _vertices_follow; LMatrix4d _ocs2wcs; - istream *_in; + std::istream *_in; bool _owns_in; int _code; - string _string; + std::string _string; void compute_ocs(); bool get_group(); void change_state(State new_state); void change_section(Section new_section); - void change_layer(const string &layer_name); + void change_layer(const std::string &layer_name); void change_entity(Entity new_entity); void reset_entity(); @@ -161,8 +161,8 @@ protected: void state_verts(); }; -ostream &operator << (ostream &out, const DXFFile::State &state); -ostream &operator << (ostream &out, const DXFFile::Section §ion); -ostream &operator << (ostream &out, const DXFFile::Entity &entity); +std::ostream &operator << (std::ostream &out, const DXFFile::State &state); +std::ostream &operator << (std::ostream &out, const DXFFile::Section §ion); +std::ostream &operator << (std::ostream &out, const DXFFile::Entity &entity); #endif diff --git a/pandatool/src/dxf/dxfLayer.h b/pandatool/src/dxf/dxfLayer.h index dab55adb4d..745197280c 100644 --- a/pandatool/src/dxf/dxfLayer.h +++ b/pandatool/src/dxf/dxfLayer.h @@ -27,7 +27,7 @@ */ class DXFLayer : public Namable { public: - DXFLayer(const string &name); + DXFLayer(const std::string &name); virtual ~DXFLayer(); }; diff --git a/pandatool/src/dxf/dxfLayerMap.h b/pandatool/src/dxf/dxfLayerMap.h index 1dfabca80b..f2fabe5373 100644 --- a/pandatool/src/dxf/dxfLayerMap.h +++ b/pandatool/src/dxf/dxfLayerMap.h @@ -25,9 +25,9 @@ class DXFFile; * ordered by name. This is used as a lookup within DXFFile to locate the * layer associated with a particular entity. */ -class DXFLayerMap : public pmap { +class DXFLayerMap : public pmap { public: - DXFLayer *get_layer(const string &name, DXFFile *dxffile); + DXFLayer *get_layer(const std::string &name, DXFFile *dxffile); }; #endif diff --git a/pandatool/src/dxfegg/dxfToEggConverter.h b/pandatool/src/dxfegg/dxfToEggConverter.h index 8a10a50fc3..56969e7482 100644 --- a/pandatool/src/dxfegg/dxfToEggConverter.h +++ b/pandatool/src/dxfegg/dxfToEggConverter.h @@ -31,14 +31,14 @@ public: virtual SomethingToEggConverter *make_copy(); - virtual string get_name() const; - virtual string get_extension() const; + virtual std::string get_name() const; + virtual std::string get_extension() const; virtual bool supports_compressed() const; virtual bool convert_file(const Filename &filename); protected: - virtual DXFLayer *new_layer(const string &name); + virtual DXFLayer *new_layer(const std::string &name); virtual void done_entity(); virtual void error(); diff --git a/pandatool/src/dxfegg/dxfToEggLayer.h b/pandatool/src/dxfegg/dxfToEggLayer.h index 45a053e4df..9067cc702f 100644 --- a/pandatool/src/dxfegg/dxfToEggLayer.h +++ b/pandatool/src/dxfegg/dxfToEggLayer.h @@ -34,7 +34,7 @@ class DXFToEggConverter; */ class DXFToEggLayer : public DXFLayer { public: - DXFToEggLayer(const string &name, EggGroupNode *parent); + DXFToEggLayer(const std::string &name, EggGroupNode *parent); void add_polygon(const DXFToEggConverter *entity); void add_line(const DXFToEggConverter *entity); diff --git a/pandatool/src/dxfprogs/eggToDXF.h b/pandatool/src/dxfprogs/eggToDXF.h index 0af0e999de..da7764fb85 100644 --- a/pandatool/src/dxfprogs/eggToDXF.h +++ b/pandatool/src/dxfprogs/eggToDXF.h @@ -34,8 +34,8 @@ public: private: void get_layers(EggGroupNode *group); - void write_tables(ostream &out); - void write_entities(ostream &out); + void write_tables(std::ostream &out); + void write_entities(std::ostream &out); EggToDXFLayers _layers; }; diff --git a/pandatool/src/dxfprogs/eggToDXFLayer.h b/pandatool/src/dxfprogs/eggToDXFLayer.h index 314346f7d0..a5fe7b7517 100644 --- a/pandatool/src/dxfprogs/eggToDXFLayer.h +++ b/pandatool/src/dxfprogs/eggToDXFLayer.h @@ -35,10 +35,10 @@ public: void add_color(const LColor &color); void choose_overall_color(); - void write_layer(ostream &out); - void write_polyline(EggPolygon *poly, ostream &out); - void write_3d_face(EggPolygon *poly, ostream &out); - void write_entities(ostream &out); + void write_layer(std::ostream &out); + void write_polyline(EggPolygon *poly, std::ostream &out); + void write_3d_face(EggPolygon *poly, std::ostream &out); + void write_entities(std::ostream &out); private: int get_autocad_color(const LColor &color); diff --git a/pandatool/src/egg-mkfont/eggMakeFont.h b/pandatool/src/egg-mkfont/eggMakeFont.h index 20bd99f01f..3df12af6fa 100644 --- a/pandatool/src/egg-mkfont/eggMakeFont.h +++ b/pandatool/src/egg-mkfont/eggMakeFont.h @@ -46,7 +46,7 @@ public: void run(); private: - static bool dispatch_range(const string &, const string &arg, void *var); + static bool dispatch_range(const std::string &, const std::string &arg, void *var); EggVertex *make_vertex(const LPoint2d &xy); void add_character(int code); @@ -55,7 +55,7 @@ private: EggTexture *make_tref(PNMTextGlyph *glyph, int character); void add_extra_glyphs(const Filename &extra_filename); void r_add_extra_glyphs(EggGroupNode *egg_group); - static bool is_numeric(const string &str); + static bool is_numeric(const std::string &str); private: @@ -79,8 +79,8 @@ private: double _palettize_scale_factor; Filename _input_font_filename; int _face_index; - string _output_glyph_pattern; - string _output_palette_pattern; + std::string _output_glyph_pattern; + std::string _output_palette_pattern; PNMTextMaker *_text_maker; diff --git a/pandatool/src/egg-mkfont/rangeDescription.I b/pandatool/src/egg-mkfont/rangeDescription.I index b19912d303..39a20162f5 100644 --- a/pandatool/src/egg-mkfont/rangeDescription.I +++ b/pandatool/src/egg-mkfont/rangeDescription.I @@ -55,7 +55,7 @@ Range(int from_code, int to_code) : { } -INLINE ostream &operator << (ostream &out, const RangeDescription &range) { +INLINE std::ostream &operator << (std::ostream &out, const RangeDescription &range) { range.output(out); return out; } diff --git a/pandatool/src/egg-mkfont/rangeDescription.h b/pandatool/src/egg-mkfont/rangeDescription.h index d1e26b573d..25119cb16f 100644 --- a/pandatool/src/egg-mkfont/rangeDescription.h +++ b/pandatool/src/egg-mkfont/rangeDescription.h @@ -25,17 +25,17 @@ class RangeDescription { public: RangeDescription(); - bool parse_parameter(const string ¶m); + bool parse_parameter(const std::string ¶m); INLINE void add_singleton(int code); INLINE void add_range(int from_code, int to_code); INLINE bool is_empty() const; - void output(ostream &out) const; + void output(std::ostream &out) const; private: - bool parse_word(const string &word); - bool parse_code(const string &word, int &code); - bool parse_bracket(const string &str); + bool parse_word(const std::string &word); + bool parse_code(const std::string &word, int &code); + bool parse_bracket(const std::string &str); private: class Range { @@ -53,7 +53,7 @@ private: friend class RangeIterator; }; -INLINE ostream &operator << (ostream &out, const RangeDescription &range); +INLINE std::ostream &operator << (std::ostream &out, const RangeDescription &range); #include "rangeDescription.I" diff --git a/pandatool/src/egg-optchar/eggOptchar.h b/pandatool/src/egg-optchar/eggOptchar.h index 5d461a3442..30ea4cddae 100644 --- a/pandatool/src/egg-optchar/eggOptchar.h +++ b/pandatool/src/egg-optchar/eggOptchar.h @@ -44,10 +44,10 @@ protected: virtual bool handle_args(Args &args); private: - static bool dispatch_vector_string_pair(const string &opt, const string &arg, void *var); - static bool dispatch_name_components(const string &opt, const string &arg, void *var); - static bool dispatch_double_components(const string &opt, const string &arg, void *var); - static bool dispatch_flag_groups(const string &opt, const string &arg, void *var); + static bool dispatch_vector_string_pair(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_name_components(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_double_components(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_flag_groups(const std::string &opt, const std::string &arg, void *var); void determine_removed_components(); void move_vertices(); @@ -73,8 +73,8 @@ private: void do_flag_groups(EggGroupNode *egg_group); void rename_joints(); - void rename_primitives(EggGroupNode *egg_group, const string &name); - void change_dart_type(EggGroupNode *egg_group, const string &new_dart_type); + void rename_primitives(EggGroupNode *egg_group, const std::string &name); + void change_dart_type(EggGroupNode *egg_group, const std::string &new_dart_type); void do_preload(); void do_defpose(); @@ -86,8 +86,8 @@ private: class StringPair { public: - string _a; - string _b; + std::string _a; + std::string _b; }; typedef pvector StringPairs; StringPairs _new_joints; @@ -100,12 +100,12 @@ private: vector_string _expose_components; vector_string _suppress_components; - string _dart_type; + std::string _dart_type; class DoubleString { public: double _a; - string _b; + std::string _b; }; typedef pvector DoubleStrings; DoubleStrings _quantize_anims; @@ -115,12 +115,12 @@ private: class FlagGroupsEntry { public: Globs _groups; - string _name; + std::string _name; }; typedef pvector FlagGroups; FlagGroups _flag_groups; - string _defpose; + std::string _defpose; bool _optimal_hierarchy; double _vref_quantum; diff --git a/pandatool/src/egg-palettize/eggPalettize.h b/pandatool/src/egg-palettize/eggPalettize.h index 8bb1c65774..d30a9d4fb6 100644 --- a/pandatool/src/egg-palettize/eggPalettize.h +++ b/pandatool/src/egg-palettize/eggPalettize.h @@ -37,19 +37,19 @@ public: bool _got_txa_filename; Filename _txa_filename; bool _got_txa_script; - string _txa_script; + std::string _txa_script; bool _nodb; - string _generated_image_pattern; + std::string _generated_image_pattern; bool _got_generated_image_pattern; - string _map_dirname; + std::string _map_dirname; bool _got_map_dirname; Filename _shadow_dirname; bool _got_shadow_dirname; Filename _rel_dirname; bool _got_rel_dirname; - string _default_groupname; + std::string _default_groupname; bool _got_default_groupname; - string _default_groupdir; + std::string _default_groupdir; bool _got_default_groupdir; private: diff --git a/pandatool/src/egg-qtess/qtessInputEntry.I b/pandatool/src/egg-qtess/qtessInputEntry.I index 1386256913..d8ab6de61e 100644 --- a/pandatool/src/egg-qtess/qtessInputEntry.I +++ b/pandatool/src/egg-qtess/qtessInputEntry.I @@ -23,7 +23,7 @@ QtessInputEntry(const QtessInputEntry ©) { * */ INLINE void QtessInputEntry:: -add_node_name(const string &name) { +add_node_name(const std::string &name) { _node_names.push_back(GlobPattern(name)); } @@ -150,7 +150,7 @@ get_num_surfaces() const { } -INLINE ostream &operator << (ostream &out, const QtessInputEntry &entry) { +INLINE std::ostream &operator << (std::ostream &out, const QtessInputEntry &entry) { entry.output(out); return out; } diff --git a/pandatool/src/egg-qtess/qtessInputEntry.h b/pandatool/src/egg-qtess/qtessInputEntry.h index 170d0fadf3..bffcca0d4a 100644 --- a/pandatool/src/egg-qtess/qtessInputEntry.h +++ b/pandatool/src/egg-qtess/qtessInputEntry.h @@ -32,11 +32,11 @@ public: T_min_u, T_min_v }; - QtessInputEntry(const string &name = string()); + QtessInputEntry(const std::string &name = std::string()); INLINE QtessInputEntry(const QtessInputEntry ©); void operator = (const QtessInputEntry ©); - INLINE void add_node_name(const string &name); + INLINE void add_node_name(const std::string &name); INLINE void set_importance(double i); INLINE void set_match_uu(); INLINE void set_match_vv(); @@ -48,7 +48,7 @@ public: INLINE void set_omit(); INLINE void set_num_tris(int nt); INLINE void set_uv(int u, int v); - void set_uv(int u, int v, const string params[], int num_params); + void set_uv(int u, int v, const std::string params[], int num_params); INLINE void set_per_isoparam(double pi); INLINE void set_per_score(double pi); void add_extra_u_isoparam(double u); @@ -58,9 +58,9 @@ public: INLINE int get_num_surfaces() const; int count_tris(double tri_factor = 1.0, int attempts = 0); - static void output_extra(ostream &out, const pvector &iso, char axis); - void output(ostream &out) const; - void write(ostream &out, int indent_level) const; + static void output_extra(std::ostream &out, const pvector &iso, char axis); + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level) const; bool _auto_place, _auto_distribute; double _curvature_ratio; @@ -83,7 +83,7 @@ private: double _num_patches; }; -INLINE ostream &operator << (ostream &out, const QtessInputEntry &entry); +INLINE std::ostream &operator << (std::ostream &out, const QtessInputEntry &entry); #include "qtessInputEntry.I" diff --git a/pandatool/src/egg-qtess/qtessInputFile.h b/pandatool/src/egg-qtess/qtessInputFile.h index 7b015b46ac..d0e6b62464 100644 --- a/pandatool/src/egg-qtess/qtessInputFile.h +++ b/pandatool/src/egg-qtess/qtessInputFile.h @@ -37,7 +37,7 @@ public: QtessInputEntry::Type match(QtessSurface *surface); int count_tris(); - void write(ostream &out, int indent_level = 0) const; + void write(std::ostream &out, int indent_level = 0) const; private: void add_default_entry(); diff --git a/pandatool/src/egg-qtess/qtessSurface.I b/pandatool/src/egg-qtess/qtessSurface.I index f603bf830f..d65f82c32c 100644 --- a/pandatool/src/egg-qtess/qtessSurface.I +++ b/pandatool/src/egg-qtess/qtessSurface.I @@ -14,7 +14,7 @@ /** * */ -INLINE const string &QtessSurface:: +INLINE const std::string &QtessSurface:: get_name() const { return _egg_surface->get_name(); } @@ -126,7 +126,7 @@ get_joint_membership_index(EggGroup *joint) { * Dxyz morph offset should be stored. */ INLINE int QtessSurface:: -get_dxyz_index(const string &morph_name) { +get_dxyz_index(const std::string &morph_name) { MorphTable::iterator mti = _dxyz_table.find(morph_name); if (mti != _dxyz_table.end()) { return (*mti).second; @@ -142,7 +142,7 @@ get_dxyz_index(const string &morph_name) { * Drgba morph offset should be stored. */ INLINE int QtessSurface:: -get_drgba_index(const string &morph_name) { +get_drgba_index(const std::string &morph_name) { MorphTable::iterator mti = _drgba_table.find(morph_name); if (mti != _drgba_table.end()) { return (*mti).second; diff --git a/pandatool/src/egg-qtess/qtessSurface.h b/pandatool/src/egg-qtess/qtessSurface.h index f93c57c52e..fc3720e524 100644 --- a/pandatool/src/egg-qtess/qtessSurface.h +++ b/pandatool/src/egg-qtess/qtessSurface.h @@ -33,7 +33,7 @@ class QtessSurface : public ReferenceCount { public: QtessSurface(EggNurbsSurface *egg_surface); - INLINE const string &get_name() const; + INLINE const std::string &get_name() const; INLINE bool is_valid() const; INLINE void set_importance(double importance2); @@ -48,7 +48,7 @@ public: double get_score(double ratio); int tesselate(); - int write_qtess_parameter(ostream &out); + int write_qtess_parameter(std::ostream &out); void omit(); void tesselate_uv(int u, int v, bool autoplace, double ratio); void tesselate_specific(const pvector &u_list, @@ -60,8 +60,8 @@ public: private: void record_vertex_extras(); INLINE int get_joint_membership_index(EggGroup *joint); - INLINE int get_dxyz_index(const string &morph_name); - INLINE int get_drgba_index(const string &morph_name); + INLINE int get_dxyz_index(const std::string &morph_name); + INLINE int get_drgba_index(const std::string &morph_name); void apply_match(); PT(EggGroup) do_uniform_tesselate(int &tris) const; @@ -75,9 +75,9 @@ private: // Mapping arbitrary attributes to integer extended dimension values, so we // can hang arbitrary data in the extra dimensional space of the surface. int _next_d; - typedef map JointTable; + typedef std::map JointTable; JointTable _joint_table; - typedef map MorphTable; + typedef std::map MorphTable; MorphTable _dxyz_table; MorphTable _drgba_table; diff --git a/pandatool/src/eggbase/eggBase.h b/pandatool/src/eggbase/eggBase.h index 3b2bb1ed68..4c6b156721 100644 --- a/pandatool/src/eggbase/eggBase.h +++ b/pandatool/src/eggbase/eggBase.h @@ -39,17 +39,17 @@ public: protected: void append_command_comment(EggData *_data); - static void append_command_comment(EggData *_data, const string &comment); + static void append_command_comment(EggData *_data, const std::string &comment); - static bool dispatch_normals(ProgramBase *self, const string &opt, const string &arg, void *mode); - bool ns_dispatch_normals(const string &opt, const string &arg, void *mode); + static bool dispatch_normals(ProgramBase *self, const std::string &opt, const std::string &arg, void *mode); + bool ns_dispatch_normals(const std::string &opt, const std::string &arg, void *mode); - static bool dispatch_scale(const string &opt, const string &arg, void *var); - static bool dispatch_rotate_xyz(ProgramBase *self, const string &opt, const string &arg, void *var); - bool ns_dispatch_rotate_xyz(const string &opt, const string &arg, void *var); - static bool dispatch_rotate_axis(ProgramBase *self, const string &opt, const string &arg, void *var); - bool ns_dispatch_rotate_axis(const string &opt, const string &arg, void *var); - static bool dispatch_translate(const string &opt, const string &arg, void *var); + static bool dispatch_scale(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_rotate_xyz(ProgramBase *self, const std::string &opt, const std::string &arg, void *var); + bool ns_dispatch_rotate_xyz(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_rotate_axis(ProgramBase *self, const std::string &opt, const std::string &arg, void *var); + bool ns_dispatch_rotate_axis(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_translate(const std::string &opt, const std::string &arg, void *var); protected: enum NormalsMode { diff --git a/pandatool/src/eggbase/eggConverter.h b/pandatool/src/eggbase/eggConverter.h index 1dfa1b00dc..3922a6b842 100644 --- a/pandatool/src/eggbase/eggConverter.h +++ b/pandatool/src/eggbase/eggConverter.h @@ -24,13 +24,13 @@ */ class EggConverter : public EggFilter { public: - EggConverter(const string &format_name, - const string &preferred_extension = string(), + EggConverter(const std::string &format_name, + const std::string &preferred_extension = std::string(), bool allow_last_param = true, bool allow_stdout = true); protected: - string _format_name; + std::string _format_name; }; #endif diff --git a/pandatool/src/eggbase/eggReader.h b/pandatool/src/eggbase/eggReader.h index c195b0c07d..134799431d 100644 --- a/pandatool/src/eggbase/eggReader.h +++ b/pandatool/src/eggbase/eggReader.h @@ -51,7 +51,7 @@ protected: private: Filename _tex_dirname; bool _got_tex_dirname; - string _tex_extension; + std::string _tex_extension; bool _got_tex_extension; PNMFileType *_tex_type; double _delod; diff --git a/pandatool/src/eggbase/eggToSomething.h b/pandatool/src/eggbase/eggToSomething.h index 56885c33aa..aafc045a3d 100644 --- a/pandatool/src/eggbase/eggToSomething.h +++ b/pandatool/src/eggbase/eggToSomething.h @@ -25,8 +25,8 @@ */ class EggToSomething : public EggConverter { public: - EggToSomething(const string &format_name, - const string &preferred_extension = string(), + EggToSomething(const std::string &format_name, + const std::string &preferred_extension = std::string(), bool allow_last_param = true, bool allow_stdout = true); diff --git a/pandatool/src/eggbase/somethingToEgg.h b/pandatool/src/eggbase/somethingToEgg.h index 263cfd5336..5c5427dcde 100644 --- a/pandatool/src/eggbase/somethingToEgg.h +++ b/pandatool/src/eggbase/somethingToEgg.h @@ -28,8 +28,8 @@ class SomethingToEggConverter; */ class SomethingToEgg : public EggConverter { public: - SomethingToEgg(const string &format_name, - const string &preferred_extension = string(), + SomethingToEgg(const std::string &format_name, + const std::string &preferred_extension = std::string(), bool allow_last_param = true, bool allow_stdout = true); @@ -45,7 +45,7 @@ protected: virtual bool post_command_line(); virtual void post_process_egg_file(); - static bool dispatch_animation_convert(const string &opt, const string &arg, void *var); + static bool dispatch_animation_convert(const std::string &opt, const std::string &arg, void *var); Filename _input_filename; @@ -54,7 +54,7 @@ protected: DistanceUnit _output_units; AnimationConvert _animation_convert; - string _character_name; + std::string _character_name; double _start_frame; double _end_frame; double _frame_inc; diff --git a/pandatool/src/eggcharbase/eggBackPointer.h b/pandatool/src/eggcharbase/eggBackPointer.h index 6a0e864046..2595c09d18 100644 --- a/pandatool/src/eggcharbase/eggBackPointer.h +++ b/pandatool/src/eggcharbase/eggBackPointer.h @@ -37,7 +37,7 @@ public: virtual void extend_to(int num_frames); virtual bool has_vertices() const; - virtual void set_name(const string &name); + virtual void set_name(const std::string &name); public: static TypeHandle get_class_type() { diff --git a/pandatool/src/eggcharbase/eggCharacterCollection.h b/pandatool/src/eggcharbase/eggCharacterCollection.h index 57c3bc984d..8a0bbd4f28 100644 --- a/pandatool/src/eggcharbase/eggCharacterCollection.h +++ b/pandatool/src/eggcharbase/eggCharacterCollection.h @@ -43,21 +43,21 @@ public: INLINE int get_num_characters() const; INLINE EggCharacterData *get_character(int i) const; - EggCharacterData *get_character_by_name(const string &character_name) const; + EggCharacterData *get_character_by_name(const std::string &character_name) const; INLINE EggCharacterData *get_character_by_model_index(int model_index) const; - void rename_char(int i, const string &name); + void rename_char(int i, const std::string &name); - virtual void write(ostream &out, int indent_level = 0) const; - void check_errors(ostream &out, bool force_initial_rest_frame); + virtual void write(std::ostream &out, int indent_level = 0) const; + void check_errors(std::ostream &out, bool force_initial_rest_frame); virtual EggCharacterData *make_character_data(); virtual EggJointData *make_joint_data(EggCharacterData *char_data); virtual EggSliderData *make_slider_data(EggCharacterData *char_data); public: - EggCharacterData *make_character(const string &character_name); + EggCharacterData *make_character(const std::string &character_name); class EggInfo { public: @@ -77,9 +77,9 @@ public: private: bool scan_hierarchy(EggNode *egg_node); void scan_for_top_joints(EggNode *egg_node, EggNode *model_root, - const string &character_name); + const std::string &character_name); void scan_for_top_tables(EggTable *bundle, EggNode *model_root, - const string &character_name); + const std::string &character_name); void scan_for_morphs(EggNode *egg_node, int model_index, EggCharacterData *char_data); void scan_for_sliders(EggNode *egg_node, int model_index, @@ -101,7 +101,7 @@ private: }; typedef pmap TopEggNodes; - typedef pmap TopEggNodesByName; + typedef pmap TopEggNodesByName; TopEggNodesByName _top_egg_nodes; int _next_model_index; diff --git a/pandatool/src/eggcharbase/eggCharacterData.I b/pandatool/src/eggcharbase/eggCharacterData.I index 7ea131a3ec..fc3d3f1bcc 100644 --- a/pandatool/src/eggcharbase/eggCharacterData.I +++ b/pandatool/src/eggcharbase/eggCharacterData.I @@ -77,7 +77,7 @@ get_root_joint() const { * has that name. */ INLINE EggJointData *EggCharacterData:: -find_joint(const string &name) const { +find_joint(const std::string &name) const { return _root_joint->find_joint(name); } @@ -87,7 +87,7 @@ find_joint(const string &name) const { * inherits the net transform of the indicated parent joint. */ INLINE EggJointData *EggCharacterData:: -make_new_joint(const string &name, EggJointData *parent) { +make_new_joint(const std::string &name, EggJointData *parent) { EggJointData *joint = parent->make_new_joint(name); _joints.push_back(joint); _components.push_back(joint); diff --git a/pandatool/src/eggcharbase/eggCharacterData.h b/pandatool/src/eggcharbase/eggCharacterData.h index d4b7125487..f488e33536 100644 --- a/pandatool/src/eggcharbase/eggCharacterData.h +++ b/pandatool/src/eggcharbase/eggCharacterData.h @@ -54,7 +54,7 @@ public: EggCharacterData(EggCharacterCollection *collection); virtual ~EggCharacterData(); - void rename_char(const string &name); + void rename_char(const std::string &name); void add_model(int model_index, EggNode *model_root, EggData *egg_data); INLINE int get_num_models() const; @@ -66,8 +66,8 @@ public: double get_frame_rate(int model_index) const; INLINE EggJointData *get_root_joint() const; - INLINE EggJointData *find_joint(const string &name) const; - INLINE EggJointData *make_new_joint(const string &name, EggJointData *parent); + INLINE EggJointData *find_joint(const std::string &name) const; + INLINE EggJointData *make_new_joint(const std::string &name, EggJointData *parent); INLINE int get_num_joints() const; INLINE EggJointData *get_joint(int n) const; @@ -76,15 +76,15 @@ public: INLINE int get_num_sliders() const; INLINE EggSliderData *get_slider(int n) const; - EggSliderData *find_slider(const string &name) const; - EggSliderData *make_slider(const string &name); + EggSliderData *find_slider(const std::string &name) const; + EggSliderData *make_slider(const std::string &name); INLINE int get_num_components() const; INLINE EggComponentData *get_component(int n) const; size_t estimate_db_size() const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; private: class Model { @@ -99,7 +99,7 @@ private: EggCharacterCollection *_collection; EggJointData *_root_joint; - typedef pmap SlidersByName; + typedef pmap SlidersByName; SlidersByName _sliders_by_name; typedef pvector Sliders; diff --git a/pandatool/src/eggcharbase/eggComponentData.h b/pandatool/src/eggcharbase/eggComponentData.h index 4445d51fe1..b54c20ffb6 100644 --- a/pandatool/src/eggcharbase/eggComponentData.h +++ b/pandatool/src/eggcharbase/eggComponentData.h @@ -37,15 +37,15 @@ public: EggCharacterData *char_data); virtual ~EggComponentData(); - void add_name(const string &name, NameUniquifier &uniquifier); - bool matches_name(const string &name) const; + void add_name(const std::string &name, NameUniquifier &uniquifier); + bool matches_name(const std::string &name) const; int get_num_frames(int model_index) const; void extend_to(int model_index, int num_frames) const; double get_frame_rate(int model_index) const; virtual void add_back_pointer(int model_index, EggObject *egg_object)=0; - virtual void write(ostream &out, int indent_level = 0) const=0; + virtual void write(std::ostream &out, int indent_level = 0) const=0; INLINE int get_num_models() const; INLINE bool has_model(int model_index) const; @@ -59,7 +59,7 @@ protected: typedef pvector BackPointers; BackPointers _back_pointers; - typedef pset Names; + typedef pset Names; Names _names; EggCharacterCollection *_collection; diff --git a/pandatool/src/eggcharbase/eggJointData.I b/pandatool/src/eggcharbase/eggJointData.I index ad0b91aee5..c8b81967ee 100644 --- a/pandatool/src/eggcharbase/eggJointData.I +++ b/pandatool/src/eggcharbase/eggJointData.I @@ -41,7 +41,7 @@ get_child(int n) const { * if no joint has that name. */ INLINE EggJointData *EggJointData:: -find_joint(const string &name) { +find_joint(const std::string &name) { EggJointData *joint = find_joint_exact(name); if (joint == nullptr) { joint = find_joint_matches(name); diff --git a/pandatool/src/eggcharbase/eggJointData.h b/pandatool/src/eggcharbase/eggJointData.h index aff56459cc..bf9cf7b3d1 100644 --- a/pandatool/src/eggcharbase/eggJointData.h +++ b/pandatool/src/eggcharbase/eggJointData.h @@ -36,7 +36,7 @@ public: INLINE EggJointData *get_parent() const; INLINE int get_num_children() const; INLINE EggJointData *get_child(int n) const; - INLINE EggJointData *find_joint(const string &name); + INLINE EggJointData *find_joint(const std::string &name); LMatrix4d get_frame(int model_index, int n) const; LMatrix4d get_net_frame(int model_index, int n, EggCharacterDb &db) const; @@ -54,12 +54,12 @@ public: bool do_rebuild_all(EggCharacterDb &db); void optimize(); void expose(EggGroup::DCSType dcs_type = EggGroup::DC_default); - void zero_channels(const string &components); - void quantize_channels(const string &components, double quantum); + void zero_channels(const std::string &components); + void quantize_channels(const std::string &components, double quantum); void apply_default_pose(int source_model, int frame); virtual void add_back_pointer(int model_index, EggObject *egg_object); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; protected: void do_begin_reparent(); @@ -70,9 +70,9 @@ protected: void do_finish_reparent(); private: - EggJointData *make_new_joint(const string &name); - EggJointData *find_joint_exact(const string &name); - EggJointData *find_joint_matches(const string &name); + EggJointData *make_new_joint(const std::string &name); + EggJointData *find_joint_exact(const std::string &name); + EggJointData *find_joint_matches(const std::string &name); bool is_new_ancestor(EggJointData *child) const; const LMatrix4d &get_new_net_frame(int model_index, int n, EggCharacterDb &db); diff --git a/pandatool/src/eggcharbase/eggJointNodePointer.h b/pandatool/src/eggcharbase/eggJointNodePointer.h index 52aacbd042..8a979f11d5 100644 --- a/pandatool/src/eggcharbase/eggJointNodePointer.h +++ b/pandatool/src/eggcharbase/eggJointNodePointer.h @@ -41,9 +41,9 @@ public: virtual bool has_vertices() const; - virtual EggJointPointer *make_new_joint(const string &name); + virtual EggJointPointer *make_new_joint(const std::string &name); - virtual void set_name(const string &name); + virtual void set_name(const std::string &name); private: PT(EggGroup) _joint; diff --git a/pandatool/src/eggcharbase/eggJointPointer.h b/pandatool/src/eggcharbase/eggJointPointer.h index cbb759c9d4..94a8a3180e 100644 --- a/pandatool/src/eggcharbase/eggJointPointer.h +++ b/pandatool/src/eggcharbase/eggJointPointer.h @@ -42,11 +42,11 @@ public: virtual void optimize(); virtual void expose(EggGroup::DCSType dcs_type); - virtual void zero_channels(const string &components); - virtual void quantize_channels(const string &components, double quantum); + virtual void zero_channels(const std::string &components); + virtual void quantize_channels(const std::string &components, double quantum); virtual void apply_default_pose(EggJointPointer *source_joint, int frame); - virtual EggJointPointer *make_new_joint(const string &name)=0; + virtual EggJointPointer *make_new_joint(const std::string &name)=0; public: static TypeHandle get_class_type() { diff --git a/pandatool/src/eggcharbase/eggMatrixTablePointer.h b/pandatool/src/eggcharbase/eggMatrixTablePointer.h index c23187955b..cbdeeecc5a 100644 --- a/pandatool/src/eggcharbase/eggMatrixTablePointer.h +++ b/pandatool/src/eggcharbase/eggMatrixTablePointer.h @@ -43,12 +43,12 @@ public: virtual bool do_rebuild(EggCharacterDb &db); virtual void optimize(); - virtual void zero_channels(const string &components); - virtual void quantize_channels(const string &components, double quantum); + virtual void zero_channels(const std::string &components); + virtual void quantize_channels(const std::string &components, double quantum); - virtual EggJointPointer *make_new_joint(const string &name); + virtual EggJointPointer *make_new_joint(const std::string &name); - virtual void set_name(const string &name); + virtual void set_name(const std::string &name); private: PT(EggTable) _table; diff --git a/pandatool/src/eggcharbase/eggScalarTablePointer.h b/pandatool/src/eggcharbase/eggScalarTablePointer.h index f1cd226c1f..c0a7487973 100644 --- a/pandatool/src/eggcharbase/eggScalarTablePointer.h +++ b/pandatool/src/eggcharbase/eggScalarTablePointer.h @@ -35,7 +35,7 @@ public: virtual void extend_to(int num_frames); virtual double get_frame(int n) const; - virtual void set_name(const string &name); + virtual void set_name(const std::string &name); private: PT(EggSAnimData) _data; diff --git a/pandatool/src/eggcharbase/eggSliderData.h b/pandatool/src/eggcharbase/eggSliderData.h index 03c1d2fe3f..dd0e4c3486 100644 --- a/pandatool/src/eggcharbase/eggSliderData.h +++ b/pandatool/src/eggcharbase/eggSliderData.h @@ -33,7 +33,7 @@ public: double get_frame(int model_index, int n) const; virtual void add_back_pointer(int model_index, EggObject *egg_object); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: diff --git a/pandatool/src/eggprogs/eggRetargetAnim.h b/pandatool/src/eggprogs/eggRetargetAnim.h index bf9d94cd38..455942ae94 100644 --- a/pandatool/src/eggprogs/eggRetargetAnim.h +++ b/pandatool/src/eggprogs/eggRetargetAnim.h @@ -37,7 +37,7 @@ public: void run(); void retarget_anim(EggCharacterData *char_data, EggJointData *joint_data, - int reference_model, const pset &keep_names, + int reference_model, const pset &keep_names, EggCharacterDb &db); Filename _reference_filename; diff --git a/pandatool/src/eggprogs/eggTextureCards.h b/pandatool/src/eggprogs/eggTextureCards.h index f3adde8b34..c30e926d8e 100644 --- a/pandatool/src/eggprogs/eggTextureCards.h +++ b/pandatool/src/eggprogs/eggTextureCards.h @@ -36,10 +36,10 @@ public: protected: virtual bool handle_args(Args &args); - static bool dispatch_wrap_mode(const string &opt, const string &arg, void *var); - static bool dispatch_filter_type(const string &opt, const string &arg, void *var); - static bool dispatch_quality_level(const string &opt, const string &arg, void *var); - static bool dispatch_format(const string &opt, const string &arg, void *var); + static bool dispatch_wrap_mode(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_filter_type(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_quality_level(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_format(const std::string &opt, const std::string &arg, void *var); private: bool scan_texture(const Filename &filename, LVecBase4d &geometry, diff --git a/pandatool/src/eggprogs/eggTopstrip.h b/pandatool/src/eggprogs/eggTopstrip.h index efdd4c0e82..8e04b7e0af 100644 --- a/pandatool/src/eggprogs/eggTopstrip.h +++ b/pandatool/src/eggprogs/eggTopstrip.h @@ -48,10 +48,10 @@ public: void adjust_transform(LMatrix4d &mat) const; - string _top_joint_name; + std::string _top_joint_name; bool _got_invert_transform; bool _invert_transform; - string _transform_channels; + std::string _transform_channels; Filename _channel_filename; }; diff --git a/pandatool/src/flt/fltBeadID.h b/pandatool/src/flt/fltBeadID.h index c14b82b4a3..d7e943b207 100644 --- a/pandatool/src/flt/fltBeadID.h +++ b/pandatool/src/flt/fltBeadID.h @@ -25,10 +25,10 @@ class FltBeadID : public FltBead { public: FltBeadID(FltHeader *header); - const string &get_id() const; - void set_id(const string &id); + const std::string &get_id() const; + void set_id(const std::string &id); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual bool extract_record(FltRecordReader &reader); @@ -38,7 +38,7 @@ protected: virtual FltError write_ancillary(FltRecordWriter &writer) const; private: - string _id; + std::string _id; public: virtual TypeHandle get_type() const { diff --git a/pandatool/src/flt/fltError.h b/pandatool/src/flt/fltError.h index 5d4ac08165..29c4453869 100644 --- a/pandatool/src/flt/fltError.h +++ b/pandatool/src/flt/fltError.h @@ -32,6 +32,6 @@ enum FltError { FE_internal }; -ostream &operator << (ostream &out, FltError error); +std::ostream &operator << (std::ostream &out, FltError error); #endif diff --git a/pandatool/src/flt/fltExternalReference.h b/pandatool/src/flt/fltExternalReference.h index 5afe57d091..03cac968cb 100644 --- a/pandatool/src/flt/fltExternalReference.h +++ b/pandatool/src/flt/fltExternalReference.h @@ -29,7 +29,7 @@ public: FltExternalReference(FltHeader *header); virtual void apply_converted_filenames(); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; enum Flags { F_color_palette_override = 0x80000000, @@ -40,9 +40,9 @@ public: F_light_palette_override = 0x04000000 }; - string _orig_filename; + std::string _orig_filename; Filename _converted_filename; - string _bead_id; + std::string _bead_id; int _flags; Filename get_ref_filename() const; diff --git a/pandatool/src/flt/fltHeader.h b/pandatool/src/flt/fltHeader.h index 0cde95d1ad..620e553ad9 100644 --- a/pandatool/src/flt/fltHeader.h +++ b/pandatool/src/flt/fltHeader.h @@ -57,9 +57,9 @@ public: const Filename &get_flt_filename() const; FltError read_flt(Filename filename); - FltError read_flt(istream &in); + FltError read_flt(std::istream &in); FltError write_flt(Filename filename); - FltError write_flt(ostream &out); + FltError write_flt(std::ostream &out); enum AttrUpdate { AU_none, @@ -113,7 +113,7 @@ public: int _format_revision_level; int _edit_revision_level; - string _last_revision; + std::string _last_revision; int _next_group_id; int _next_lod_id; int _next_object_id; @@ -181,7 +181,7 @@ public: LColor get_color(int color_index) const; LRGBColor get_rgb(int color_index) const; bool has_color_name(int color_index) const; - string get_color_name(int color_index) const; + std::string get_color_name(int color_index) const; int get_closest_color(const LColor &color) const; int get_closest_rgb(const LRGBColor &color) const; @@ -262,7 +262,7 @@ private: // Support for the color palette. bool _got_color_palette; typedef pvector Colors; - typedef pmap ColorNames; + typedef pmap ColorNames; Colors _colors; ColorNames _color_names; diff --git a/pandatool/src/flt/fltInstanceRef.h b/pandatool/src/flt/fltInstanceRef.h index 6bbbe11ebd..2f8e281c9f 100644 --- a/pandatool/src/flt/fltInstanceRef.h +++ b/pandatool/src/flt/fltInstanceRef.h @@ -33,7 +33,7 @@ public: FltInstanceDefinition *get_instance() const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; protected: virtual bool extract_record(FltRecordReader &reader); diff --git a/pandatool/src/flt/fltLightSourceDefinition.h b/pandatool/src/flt/fltLightSourceDefinition.h index 80f307de13..e96d275254 100644 --- a/pandatool/src/flt/fltLightSourceDefinition.h +++ b/pandatool/src/flt/fltLightSourceDefinition.h @@ -36,7 +36,7 @@ public: }; int _light_index; - string _light_name; + std::string _light_name; LColor _ambient; LColor _diffuse; LColor _specular; diff --git a/pandatool/src/flt/fltMaterial.h b/pandatool/src/flt/fltMaterial.h index c801efc993..fadc3accd1 100644 --- a/pandatool/src/flt/fltMaterial.h +++ b/pandatool/src/flt/fltMaterial.h @@ -34,7 +34,7 @@ public: }; int _material_index; - string _material_name; + std::string _material_name; unsigned int _flags; LRGBColor _ambient; LRGBColor _diffuse; diff --git a/pandatool/src/flt/fltOpcode.h b/pandatool/src/flt/fltOpcode.h index 2cadaeacb5..f9bbeb9eab 100644 --- a/pandatool/src/flt/fltOpcode.h +++ b/pandatool/src/flt/fltOpcode.h @@ -117,6 +117,6 @@ enum FltOpcode { FO_road_construction = 127 }; -ostream &operator << (ostream &out, FltOpcode opcode); +std::ostream &operator << (std::ostream &out, FltOpcode opcode); #endif diff --git a/pandatool/src/flt/fltPackedColor.I b/pandatool/src/flt/fltPackedColor.I index 9b42f4d64d..50ae590650 100644 --- a/pandatool/src/flt/fltPackedColor.I +++ b/pandatool/src/flt/fltPackedColor.I @@ -11,8 +11,8 @@ * @date 2000-08-25 */ -INLINE ostream & -operator << (ostream &out, const FltPackedColor &color) { +INLINE std::ostream & +operator << (std::ostream &out, const FltPackedColor &color) { color.output(out); return out; } diff --git a/pandatool/src/flt/fltPackedColor.h b/pandatool/src/flt/fltPackedColor.h index d8897363aa..1e38e02bc8 100644 --- a/pandatool/src/flt/fltPackedColor.h +++ b/pandatool/src/flt/fltPackedColor.h @@ -35,7 +35,7 @@ public: INLINE void set_color(const LColor &color); INLINE void set_rgb(const LRGBColor &rgb); - void output(ostream &out) const; + void output(std::ostream &out) const; bool extract_record(FltRecordReader &reader); bool build_record(FltRecordWriter &writer) const; @@ -46,7 +46,7 @@ public: int _r; }; -INLINE ostream &operator << (ostream &out, const FltPackedColor &color); +INLINE std::ostream &operator << (std::ostream &out, const FltPackedColor &color); #include "fltPackedColor.I" diff --git a/pandatool/src/flt/fltRecord.I b/pandatool/src/flt/fltRecord.I index 39d8765018..add78f2d7a 100644 --- a/pandatool/src/flt/fltRecord.I +++ b/pandatool/src/flt/fltRecord.I @@ -11,8 +11,8 @@ * @date 2000-08-24 */ -INLINE ostream & -operator << (ostream &out, const FltRecord &record) { +INLINE std::ostream & +operator << (std::ostream &out, const FltRecord &record) { record.output(out); return out; } diff --git a/pandatool/src/flt/fltRecord.h b/pandatool/src/flt/fltRecord.h index fc64441c7f..9fc8e3ad3e 100644 --- a/pandatool/src/flt/fltRecord.h +++ b/pandatool/src/flt/fltRecord.h @@ -59,20 +59,20 @@ public: void add_ancillary(FltRecord *ancillary); bool has_comment() const; - const string &get_comment() const; + const std::string &get_comment() const; void clear_comment(); - void set_comment(const string &comment); + void set_comment(const std::string &comment); void check_remaining_size(const DatagramIterator &di, - const string &name = string()) const; + const std::string &name = std::string()) const; virtual void apply_converted_filenames(); - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; protected: - void write_children(ostream &out, int indent_level) const; + void write_children(std::ostream &out, int indent_level) const; static bool is_ancillary(FltOpcode opcode); @@ -95,7 +95,7 @@ private: Records _extensions; Records _ancillary; - string _comment; + std::string _comment; public: @@ -116,7 +116,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const FltRecord &record); +INLINE std::ostream &operator << (std::ostream &out, const FltRecord &record); #include "fltRecord.I" diff --git a/pandatool/src/flt/fltRecordReader.h b/pandatool/src/flt/fltRecordReader.h index 09800f7e42..8817e800c2 100644 --- a/pandatool/src/flt/fltRecordReader.h +++ b/pandatool/src/flt/fltRecordReader.h @@ -29,7 +29,7 @@ */ class FltRecordReader { public: - FltRecordReader(istream &in); + FltRecordReader(std::istream &in); ~FltRecordReader(); FltOpcode get_opcode() const; @@ -45,7 +45,7 @@ public: private: void read_next_header(); - istream &_in; + std::istream &_in; Datagram _datagram; FltOpcode _opcode; int _record_length; diff --git a/pandatool/src/flt/fltRecordWriter.h b/pandatool/src/flt/fltRecordWriter.h index 6c8798937c..8cd4e4b6d1 100644 --- a/pandatool/src/flt/fltRecordWriter.h +++ b/pandatool/src/flt/fltRecordWriter.h @@ -30,7 +30,7 @@ class FltHeader; */ class FltRecordWriter { public: - FltRecordWriter(ostream &out); + FltRecordWriter(std::ostream &out); ~FltRecordWriter(); void set_opcode(FltOpcode opcode); @@ -46,7 +46,7 @@ public: FltError write_instance_def(FltHeader *header, int instance_index); private: - ostream &_out; + std::ostream &_out; Datagram _datagram; FltOpcode _opcode; diff --git a/pandatool/src/flt/fltTexture.h b/pandatool/src/flt/fltTexture.h index 21e1a24141..34a487e16b 100644 --- a/pandatool/src/flt/fltTexture.h +++ b/pandatool/src/flt/fltTexture.h @@ -30,7 +30,7 @@ public: virtual void apply_converted_filenames(); - string _orig_filename; + std::string _orig_filename; Filename _converted_filename; int _pattern_index; int _x_location; @@ -157,7 +157,7 @@ public: typedef pvector GeospecificControlPoints; struct SubtextureDef { - string _name; + std::string _name; int _left; int _bottom; int _right; @@ -216,7 +216,7 @@ public: ImageOrigin _image_origin; PointsUnits _geospecific_points_units; Hemisphere _geospecific_hemisphere; - string _comment; + std::string _comment; int _file_version; GeospecificControlPoints _geospecific_control_points; SubtextureDefs _subtexture_defs; diff --git a/pandatool/src/flt/fltUnsupportedRecord.h b/pandatool/src/flt/fltUnsupportedRecord.h index 02131f35f7..a358577dfa 100644 --- a/pandatool/src/flt/fltUnsupportedRecord.h +++ b/pandatool/src/flt/fltUnsupportedRecord.h @@ -27,7 +27,7 @@ class FltUnsupportedRecord : public FltRecord { public: FltUnsupportedRecord(FltHeader *header); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual bool extract_record(FltRecordReader &reader); diff --git a/pandatool/src/flt/fltVertexList.h b/pandatool/src/flt/fltVertexList.h index 449c5ab5ce..5fd53ad884 100644 --- a/pandatool/src/flt/fltVertexList.h +++ b/pandatool/src/flt/fltVertexList.h @@ -34,7 +34,7 @@ public: void clear_vertices(); void add_vertex(FltVertex *vertex); - virtual void output(ostream &out) const; + virtual void output(std::ostream &out) const; protected: virtual bool extract_record(FltRecordReader &reader); diff --git a/pandatool/src/fltegg/fltToEggConverter.h b/pandatool/src/fltegg/fltToEggConverter.h index 5188c3fce4..c9e8cc61c1 100644 --- a/pandatool/src/fltegg/fltToEggConverter.h +++ b/pandatool/src/fltegg/fltToEggConverter.h @@ -54,8 +54,8 @@ public: virtual SomethingToEggConverter *make_copy(); - virtual string get_name() const; - virtual string get_extension() const; + virtual std::string get_name() const; + virtual std::string get_extension() const; virtual bool supports_compressed() const; virtual bool convert_file(const Filename &filename); @@ -91,7 +91,7 @@ private: bool parse_comment(const FltBeadID *flt_bead, EggNode *egg_node); bool parse_comment(const FltBead *flt_bead, EggNode *egg_node); bool parse_comment(const FltTexture *flt_texture, EggNode *egg_node); - bool parse_comment(const string &comment, const string &name, + bool parse_comment(const std::string &comment, const std::string &name, EggNode *egg_node); PT_EggVertex make_egg_vertex(const FltVertex *flt_vertex); diff --git a/pandatool/src/fltegg/fltToEggLevelState.h b/pandatool/src/fltegg/fltToEggLevelState.h index 876d9835e1..91877e2306 100644 --- a/pandatool/src/fltegg/fltToEggLevelState.h +++ b/pandatool/src/fltegg/fltToEggLevelState.h @@ -34,7 +34,7 @@ public: INLINE void operator = (const FltToEggLevelState ©); ~FltToEggLevelState(); - EggGroupNode *get_synthetic_group(const string &name, + EggGroupNode *get_synthetic_group(const std::string &name, const FltBead *transform_bead, FltGeometry::BillboardType type = FltGeometry::BT_none); diff --git a/pandatool/src/fltprogs/eggToFlt.h b/pandatool/src/fltprogs/eggToFlt.h index ebae3de586..0cbcb2126d 100644 --- a/pandatool/src/fltprogs/eggToFlt.h +++ b/pandatool/src/fltprogs/eggToFlt.h @@ -42,7 +42,7 @@ public: void run(); private: - static bool dispatch_attr(const string &opt, const string &arg, void *var); + static bool dispatch_attr(const std::string &opt, const std::string &arg, void *var); void traverse(EggNode *egg_node, FltBead *flt_node, FltGeometry::BillboardType billboard); @@ -51,7 +51,7 @@ private: void convert_group(EggGroup *egg_group, FltBead *flt_node, FltGeometry::BillboardType billboard); void apply_transform(EggTransform *egg_transform, FltBead *flt_node); - void apply_egg_syntax(const string &egg_syntax, FltRecord *flt_record); + void apply_egg_syntax(const std::string &egg_syntax, FltRecord *flt_record); FltVertex *get_flt_vertex(EggVertex *egg_vertex, EggNode *context); FltTexture *get_flt_texture(EggTexture *egg_texture); diff --git a/pandatool/src/gtk-stats/gtkStatsLabel.h b/pandatool/src/gtk-stats/gtkStatsLabel.h index bf4834985e..624e4193f9 100644 --- a/pandatool/src/gtk-stats/gtkStatsLabel.h +++ b/pandatool/src/gtk-stats/gtkStatsLabel.h @@ -59,7 +59,7 @@ private: GtkStatsGraph *_graph; int _thread_index; int _collector_index; - string _text; + std::string _text; GtkWidget *_widget; GdkColor _fg_color; GdkColor _bg_color; diff --git a/pandatool/src/gtk-stats/gtkStatsMonitor.h b/pandatool/src/gtk-stats/gtkStatsMonitor.h index 704a919cf8..be1f1c7d42 100644 --- a/pandatool/src/gtk-stats/gtkStatsMonitor.h +++ b/pandatool/src/gtk-stats/gtkStatsMonitor.h @@ -48,7 +48,7 @@ public: GtkStatsMonitor(GtkStatsServer *server); virtual ~GtkStatsMonitor(); - virtual string get_monitor_name(); + virtual std::string get_monitor_name(); virtual void initialized(); virtual void got_hello(); @@ -100,7 +100,7 @@ private: int _next_chart_index; GtkWidget *_frame_rate_menu_item; GtkWidget *_frame_rate_label; - string _window_title; + std::string _window_title; int _time_units; double _scroll_speed; bool _pause; diff --git a/pandatool/src/gtk-stats/gtkStatsStripChart.h b/pandatool/src/gtk-stats/gtkStatsStripChart.h index 65bd50b598..484d669c9f 100644 --- a/pandatool/src/gtk-stats/gtkStatsStripChart.h +++ b/pandatool/src/gtk-stats/gtkStatsStripChart.h @@ -75,7 +75,7 @@ private: private: int _brush_origin; - string _net_value_text; + std::string _net_value_text; GtkWidget *_top_hbox; GtkWidget *_smooth_check_box; diff --git a/pandatool/src/imageprogs/imageResize.h b/pandatool/src/imageprogs/imageResize.h index c7e71076db..731786a4cb 100644 --- a/pandatool/src/imageprogs/imageResize.h +++ b/pandatool/src/imageprogs/imageResize.h @@ -29,7 +29,7 @@ public: void run(); private: - static bool dispatch_size_request(const string &opt, const string &arg, void *var); + static bool dispatch_size_request(const std::string &opt, const std::string &arg, void *var); enum RequestType { RT_none, diff --git a/pandatool/src/imageprogs/imageTrans.h b/pandatool/src/imageprogs/imageTrans.h index 8a4d3fffd6..a41d3ef5ef 100644 --- a/pandatool/src/imageprogs/imageTrans.h +++ b/pandatool/src/imageprogs/imageTrans.h @@ -29,7 +29,7 @@ public: void run(); private: - static bool dispatch_channels(const string &opt, const string &arg, void *var); + static bool dispatch_channels(const std::string &opt, const std::string &arg, void *var); void extract_alpha(); enum Channels { diff --git a/pandatool/src/imageprogs/imageTransformColors.h b/pandatool/src/imageprogs/imageTransformColors.h index d668ea5895..a6d11bb143 100644 --- a/pandatool/src/imageprogs/imageTransformColors.h +++ b/pandatool/src/imageprogs/imageTransformColors.h @@ -33,11 +33,11 @@ public: void run(); protected: - static bool dispatch_mat4(const string &opt, const string &arg, void *var); - static bool dispatch_mat3(const string &opt, const string &arg, void *var); - static bool dispatch_range(const string &opt, const string &arg, void *var); - static bool dispatch_scale(const string &opt, const string &arg, void *var); - static bool dispatch_add(const string &opt, const string &arg, void *var); + static bool dispatch_mat4(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_mat3(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_range(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_scale(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_add(const std::string &opt, const std::string &arg, void *var); virtual bool handle_args(Args &args); Filename get_output_filename(const Filename &source_filename) const; diff --git a/pandatool/src/lwo/iffChunk.h b/pandatool/src/lwo/iffChunk.h index dd162497ae..58de26470b 100644 --- a/pandatool/src/lwo/iffChunk.h +++ b/pandatool/src/lwo/iffChunk.h @@ -36,8 +36,8 @@ public: virtual bool read_iff(IffInputFile *in, size_t stop_at)=0; - virtual void output(ostream &out) const; - virtual void write(ostream &out, int indent_level = 0) const; + virtual void output(std::ostream &out) const; + virtual void write(std::ostream &out, int indent_level = 0) const; virtual IffChunk *make_new_chunk(IffInputFile *in, IffId id); @@ -64,7 +64,7 @@ private: #include "iffChunk.I" -INLINE ostream &operator << (ostream &out, const IffChunk &chunk) { +INLINE std::ostream &operator << (std::ostream &out, const IffChunk &chunk) { chunk.output(out); return out; } diff --git a/pandatool/src/lwo/iffGenericChunk.h b/pandatool/src/lwo/iffGenericChunk.h index bb50fb36d4..e1e9902443 100644 --- a/pandatool/src/lwo/iffGenericChunk.h +++ b/pandatool/src/lwo/iffGenericChunk.h @@ -33,7 +33,7 @@ public: INLINE void set_data(const Datagram &data); virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; private: Datagram _data; diff --git a/pandatool/src/lwo/iffId.I b/pandatool/src/lwo/iffId.I index b5775dcbaa..938e26c4cc 100644 --- a/pandatool/src/lwo/iffId.I +++ b/pandatool/src/lwo/iffId.I @@ -78,7 +78,7 @@ operator < (const IffId &other) const { /** * Returns the four-character name of the Id, for outputting. */ -INLINE string IffId:: +INLINE std::string IffId:: get_name() const { - return string(_id._c, 4); + return std::string(_id._c, 4); } diff --git a/pandatool/src/lwo/iffId.h b/pandatool/src/lwo/iffId.h index 2d20b9b99c..c3d14a7abd 100644 --- a/pandatool/src/lwo/iffId.h +++ b/pandatool/src/lwo/iffId.h @@ -34,9 +34,9 @@ public: INLINE bool operator != (const IffId &other) const; INLINE bool operator < (const IffId &other) const; - INLINE string get_name() const; + INLINE std::string get_name() const; - void output(ostream &out) const; + void output(std::ostream &out) const; private: union { @@ -47,7 +47,7 @@ private: #include "iffId.I" -INLINE ostream &operator << (ostream &out, const IffId &id) { +INLINE std::ostream &operator << (std::ostream &out, const IffId &id) { id.output(out); return out; } diff --git a/pandatool/src/lwo/iffInputFile.h b/pandatool/src/lwo/iffInputFile.h index 2b788f07a0..dc39be7da0 100644 --- a/pandatool/src/lwo/iffInputFile.h +++ b/pandatool/src/lwo/iffInputFile.h @@ -33,7 +33,7 @@ public: virtual ~IffInputFile(); bool open_read(Filename filename); - void set_input(istream *input, bool owns_istream); + void set_input(std::istream *input, bool owns_istream); INLINE void set_filename(const Filename &filename); INLINE const Filename &get_filename() const; @@ -52,7 +52,7 @@ public: uint32_t get_be_uint32(); PN_stdfloat get_be_float32(); - string get_string(); + std::string get_string(); IffId get_id(); @@ -66,7 +66,7 @@ public: protected: virtual IffChunk *make_new_chunk(IffId id); - istream *_input; + std::istream *_input; Filename _filename; bool _owns_istream; bool _eof; diff --git a/pandatool/src/lwo/lwoBoundingBox.h b/pandatool/src/lwo/lwoBoundingBox.h index 3120bee5b0..993425ffce 100644 --- a/pandatool/src/lwo/lwoBoundingBox.h +++ b/pandatool/src/lwo/lwoBoundingBox.h @@ -30,7 +30,7 @@ public: public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: virtual TypeHandle get_type() const { diff --git a/pandatool/src/lwo/lwoClip.h b/pandatool/src/lwo/lwoClip.h index 647a2e69dd..3955efa526 100644 --- a/pandatool/src/lwo/lwoClip.h +++ b/pandatool/src/lwo/lwoClip.h @@ -28,7 +28,7 @@ public: public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; virtual IffChunk *make_new_chunk(IffInputFile *in, IffId id); diff --git a/pandatool/src/lwo/lwoDiscontinuousVertexMap.h b/pandatool/src/lwo/lwoDiscontinuousVertexMap.h index 1404d02ccd..2f48e146e7 100644 --- a/pandatool/src/lwo/lwoDiscontinuousVertexMap.h +++ b/pandatool/src/lwo/lwoDiscontinuousVertexMap.h @@ -32,11 +32,11 @@ public: IffId _map_type; int _dimension; - string _name; + std::string _name; public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; private: typedef pmap VMap; diff --git a/pandatool/src/lwo/lwoGroupChunk.h b/pandatool/src/lwo/lwoGroupChunk.h index fb2db24f11..2a72dd7943 100644 --- a/pandatool/src/lwo/lwoGroupChunk.h +++ b/pandatool/src/lwo/lwoGroupChunk.h @@ -35,7 +35,7 @@ public: protected: bool read_chunks_iff(IffInputFile *in, size_t stop_at); bool read_subchunks_iff(IffInputFile *in, size_t stop_at); - void write_chunks(ostream &out, int indent_level) const; + void write_chunks(std::ostream &out, int indent_level) const; typedef pvector< PT(IffChunk) > Chunks; Chunks _chunks; diff --git a/pandatool/src/lwo/lwoHeader.h b/pandatool/src/lwo/lwoHeader.h index f4bbc93c8f..539d49764c 100644 --- a/pandatool/src/lwo/lwoHeader.h +++ b/pandatool/src/lwo/lwoHeader.h @@ -32,7 +32,7 @@ public: public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; private: bool _valid; diff --git a/pandatool/src/lwo/lwoLayer.h b/pandatool/src/lwo/lwoLayer.h index 641311a5e6..a959d4890e 100644 --- a/pandatool/src/lwo/lwoLayer.h +++ b/pandatool/src/lwo/lwoLayer.h @@ -36,12 +36,12 @@ public: int _number; int _flags; LPoint3 _pivot; - string _name; + std::string _name; int _parent; public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: virtual TypeHandle get_type() const { diff --git a/pandatool/src/lwo/lwoPoints.h b/pandatool/src/lwo/lwoPoints.h index 5cc44bebca..27f2a36ccb 100644 --- a/pandatool/src/lwo/lwoPoints.h +++ b/pandatool/src/lwo/lwoPoints.h @@ -30,7 +30,7 @@ public: public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; private: typedef pvector Points; diff --git a/pandatool/src/lwo/lwoPolygonTags.h b/pandatool/src/lwo/lwoPolygonTags.h index bd93f1d524..8603492cda 100644 --- a/pandatool/src/lwo/lwoPolygonTags.h +++ b/pandatool/src/lwo/lwoPolygonTags.h @@ -32,7 +32,7 @@ public: public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; private: typedef pmap TMap; diff --git a/pandatool/src/lwo/lwoPolygons.h b/pandatool/src/lwo/lwoPolygons.h index 69d2d20e8b..d7ad655669 100644 --- a/pandatool/src/lwo/lwoPolygons.h +++ b/pandatool/src/lwo/lwoPolygons.h @@ -56,7 +56,7 @@ public: public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; private: typedef pvector< PT(Polygon) > Polygons; diff --git a/pandatool/src/lwo/lwoStillImage.h b/pandatool/src/lwo/lwoStillImage.h index c2dc02e4e2..c800cfb006 100644 --- a/pandatool/src/lwo/lwoStillImage.h +++ b/pandatool/src/lwo/lwoStillImage.h @@ -29,7 +29,7 @@ public: public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: virtual TypeHandle get_type() const { diff --git a/pandatool/src/lwo/lwoSurface.h b/pandatool/src/lwo/lwoSurface.h index 96bb1f13d4..75523f0cd2 100644 --- a/pandatool/src/lwo/lwoSurface.h +++ b/pandatool/src/lwo/lwoSurface.h @@ -24,12 +24,12 @@ */ class LwoSurface : public LwoGroupChunk { public: - string _name; - string _source; + std::string _name; + std::string _source; public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; virtual IffChunk *make_new_chunk(IffInputFile *in, IffId id); diff --git a/pandatool/src/lwo/lwoSurfaceBlock.h b/pandatool/src/lwo/lwoSurfaceBlock.h index acd45a1dd9..bfac032aff 100644 --- a/pandatool/src/lwo/lwoSurfaceBlock.h +++ b/pandatool/src/lwo/lwoSurfaceBlock.h @@ -25,7 +25,7 @@ class LwoSurfaceBlock : public LwoGroupChunk { public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; virtual IffChunk *make_new_chunk(IffInputFile *in, IffId id); diff --git a/pandatool/src/lwo/lwoSurfaceBlockAxis.h b/pandatool/src/lwo/lwoSurfaceBlockAxis.h index 81633ed066..4e0920c57d 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockAxis.h +++ b/pandatool/src/lwo/lwoSurfaceBlockAxis.h @@ -34,7 +34,7 @@ public: public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: virtual TypeHandle get_type() const { diff --git a/pandatool/src/lwo/lwoSurfaceBlockChannel.h b/pandatool/src/lwo/lwoSurfaceBlockChannel.h index 0849d185a1..00e35bc28a 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockChannel.h +++ b/pandatool/src/lwo/lwoSurfaceBlockChannel.h @@ -28,7 +28,7 @@ public: public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: virtual TypeHandle get_type() const { diff --git a/pandatool/src/lwo/lwoSurfaceBlockCoordSys.h b/pandatool/src/lwo/lwoSurfaceBlockCoordSys.h index 4c9d777ff3..a9be9419c7 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockCoordSys.h +++ b/pandatool/src/lwo/lwoSurfaceBlockCoordSys.h @@ -33,7 +33,7 @@ public: public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: virtual TypeHandle get_type() const { diff --git a/pandatool/src/lwo/lwoSurfaceBlockEnabled.h b/pandatool/src/lwo/lwoSurfaceBlockEnabled.h index 59c42165e9..a07c6ea31c 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockEnabled.h +++ b/pandatool/src/lwo/lwoSurfaceBlockEnabled.h @@ -28,7 +28,7 @@ public: public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: virtual TypeHandle get_type() const { diff --git a/pandatool/src/lwo/lwoSurfaceBlockHeader.h b/pandatool/src/lwo/lwoSurfaceBlockHeader.h index 4ae37b45a5..6249db26bc 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockHeader.h +++ b/pandatool/src/lwo/lwoSurfaceBlockHeader.h @@ -23,11 +23,11 @@ */ class LwoSurfaceBlockHeader : public LwoGroupChunk { public: - string _ordinal; + std::string _ordinal; public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; virtual IffChunk *make_new_chunk(IffInputFile *in, IffId id); diff --git a/pandatool/src/lwo/lwoSurfaceBlockImage.h b/pandatool/src/lwo/lwoSurfaceBlockImage.h index b7710d7561..968f5d3a71 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockImage.h +++ b/pandatool/src/lwo/lwoSurfaceBlockImage.h @@ -28,7 +28,7 @@ public: public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: virtual TypeHandle get_type() const { diff --git a/pandatool/src/lwo/lwoSurfaceBlockOpacity.h b/pandatool/src/lwo/lwoSurfaceBlockOpacity.h index e923eb538b..906c86154b 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockOpacity.h +++ b/pandatool/src/lwo/lwoSurfaceBlockOpacity.h @@ -40,7 +40,7 @@ public: public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: virtual TypeHandle get_type() const { diff --git a/pandatool/src/lwo/lwoSurfaceBlockProjection.h b/pandatool/src/lwo/lwoSurfaceBlockProjection.h index 49c816f156..bcbbff41e0 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockProjection.h +++ b/pandatool/src/lwo/lwoSurfaceBlockProjection.h @@ -37,7 +37,7 @@ public: public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: virtual TypeHandle get_type() const { diff --git a/pandatool/src/lwo/lwoSurfaceBlockRefObj.h b/pandatool/src/lwo/lwoSurfaceBlockRefObj.h index 65b70a958b..77818957a3 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockRefObj.h +++ b/pandatool/src/lwo/lwoSurfaceBlockRefObj.h @@ -24,11 +24,11 @@ */ class LwoSurfaceBlockRefObj : public LwoChunk { public: - string _name; + std::string _name; public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: virtual TypeHandle get_type() const { diff --git a/pandatool/src/lwo/lwoSurfaceBlockRepeat.h b/pandatool/src/lwo/lwoSurfaceBlockRepeat.h index eb3beb251c..73c77a4537 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockRepeat.h +++ b/pandatool/src/lwo/lwoSurfaceBlockRepeat.h @@ -31,7 +31,7 @@ public: public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: virtual TypeHandle get_type() const { diff --git a/pandatool/src/lwo/lwoSurfaceBlockTMap.h b/pandatool/src/lwo/lwoSurfaceBlockTMap.h index 8da9841f46..273522d50a 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockTMap.h +++ b/pandatool/src/lwo/lwoSurfaceBlockTMap.h @@ -24,7 +24,7 @@ class LwoSurfaceBlockTMap : public LwoGroupChunk { public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; virtual IffChunk *make_new_chunk(IffInputFile *in, IffId id); diff --git a/pandatool/src/lwo/lwoSurfaceBlockTransform.h b/pandatool/src/lwo/lwoSurfaceBlockTransform.h index f8fce53163..e3e07a49b8 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockTransform.h +++ b/pandatool/src/lwo/lwoSurfaceBlockTransform.h @@ -33,7 +33,7 @@ public: public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: virtual TypeHandle get_type() const { diff --git a/pandatool/src/lwo/lwoSurfaceBlockVMapName.h b/pandatool/src/lwo/lwoSurfaceBlockVMapName.h index 30de8f3ad6..1433bfad9e 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockVMapName.h +++ b/pandatool/src/lwo/lwoSurfaceBlockVMapName.h @@ -24,11 +24,11 @@ */ class LwoSurfaceBlockVMapName : public LwoChunk { public: - string _name; + std::string _name; public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: virtual TypeHandle get_type() const { diff --git a/pandatool/src/lwo/lwoSurfaceBlockWrap.h b/pandatool/src/lwo/lwoSurfaceBlockWrap.h index b046657242..bf18e92da1 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockWrap.h +++ b/pandatool/src/lwo/lwoSurfaceBlockWrap.h @@ -33,7 +33,7 @@ public: public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: virtual TypeHandle get_type() const { diff --git a/pandatool/src/lwo/lwoSurfaceColor.h b/pandatool/src/lwo/lwoSurfaceColor.h index 77d0740665..584d1e7892 100644 --- a/pandatool/src/lwo/lwoSurfaceColor.h +++ b/pandatool/src/lwo/lwoSurfaceColor.h @@ -30,7 +30,7 @@ public: public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: virtual TypeHandle get_type() const { diff --git a/pandatool/src/lwo/lwoSurfaceParameter.h b/pandatool/src/lwo/lwoSurfaceParameter.h index 70a6188f40..075383b370 100644 --- a/pandatool/src/lwo/lwoSurfaceParameter.h +++ b/pandatool/src/lwo/lwoSurfaceParameter.h @@ -30,7 +30,7 @@ public: public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: virtual TypeHandle get_type() const { diff --git a/pandatool/src/lwo/lwoSurfaceSidedness.h b/pandatool/src/lwo/lwoSurfaceSidedness.h index cb8c75ebb2..f64ef112e0 100644 --- a/pandatool/src/lwo/lwoSurfaceSidedness.h +++ b/pandatool/src/lwo/lwoSurfaceSidedness.h @@ -33,7 +33,7 @@ public: public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: virtual TypeHandle get_type() const { diff --git a/pandatool/src/lwo/lwoSurfaceSmoothingAngle.h b/pandatool/src/lwo/lwoSurfaceSmoothingAngle.h index 97600b80aa..c27b9a3080 100644 --- a/pandatool/src/lwo/lwoSurfaceSmoothingAngle.h +++ b/pandatool/src/lwo/lwoSurfaceSmoothingAngle.h @@ -28,7 +28,7 @@ public: public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; public: virtual TypeHandle get_type() const { diff --git a/pandatool/src/lwo/lwoTags.h b/pandatool/src/lwo/lwoTags.h index 5812965be6..03ac6ede30 100644 --- a/pandatool/src/lwo/lwoTags.h +++ b/pandatool/src/lwo/lwoTags.h @@ -31,11 +31,11 @@ class LwoTags : public LwoChunk { public: int get_num_tags() const; - string get_tag(int n) const; + std::string get_tag(int n) const; public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; private: typedef vector_string Tags; diff --git a/pandatool/src/lwo/lwoVertexMap.h b/pandatool/src/lwo/lwoVertexMap.h index abbcc0f3cc..e2b059063d 100644 --- a/pandatool/src/lwo/lwoVertexMap.h +++ b/pandatool/src/lwo/lwoVertexMap.h @@ -31,11 +31,11 @@ public: IffId _map_type; int _dimension; - string _name; + std::string _name; public: virtual bool read_iff(IffInputFile *in, size_t stop_at); - virtual void write(ostream &out, int indent_level = 0) const; + virtual void write(std::ostream &out, int indent_level = 0) const; private: typedef pmap VMap; diff --git a/pandatool/src/lwoegg/cLwoPoints.h b/pandatool/src/lwoegg/cLwoPoints.h index b235c3de31..a4dbf642ac 100644 --- a/pandatool/src/lwoegg/cLwoPoints.h +++ b/pandatool/src/lwoegg/cLwoPoints.h @@ -36,7 +36,7 @@ public: CLwoLayer *layer); void add_vmap(const LwoVertexMap *lwo_vmap); - bool get_uv(const string &uv_name, int n, LPoint2 &uv) const; + bool get_uv(const std::string &uv_name, int n, LPoint2 &uv) const; void make_egg(); void connect_egg(); @@ -48,7 +48,7 @@ public: // A number of vertex maps of different types may be associated, but we only // care about some of the types here. - typedef pmap VMap; + typedef pmap VMap; VMap _txuv; VMap _pick; }; diff --git a/pandatool/src/lwoegg/cLwoPolygons.h b/pandatool/src/lwoegg/cLwoPolygons.h index a11dc0987a..d5c4b4afda 100644 --- a/pandatool/src/lwoegg/cLwoPolygons.h +++ b/pandatool/src/lwoegg/cLwoPolygons.h @@ -43,7 +43,7 @@ public: void add_vmad(const LwoDiscontinuousVertexMap *lwo_vmad); CLwoSurface *get_surface(int polygon_index) const; - bool get_uv(const string &uv_name, int pi, int vi, LPoint2 &uv) const; + bool get_uv(const std::string &uv_name, int pi, int vi, LPoint2 &uv) const; void make_egg(); void connect_egg(); @@ -61,7 +61,7 @@ public: // There might be named maps associated with the polygons to bring a per- // polygon mapping to the UV's. - typedef pmap VMad; + typedef pmap VMad; VMad _txuv; private: diff --git a/pandatool/src/lwoegg/cLwoSurface.I b/pandatool/src/lwoegg/cLwoSurface.I index 49c6eaf6bc..8c39871a08 100644 --- a/pandatool/src/lwoegg/cLwoSurface.I +++ b/pandatool/src/lwoegg/cLwoSurface.I @@ -15,7 +15,7 @@ * Returns the name of the surface. Each surface in a given Lightwave file * should have a unique name. */ -INLINE const string &CLwoSurface:: +INLINE const std::string &CLwoSurface:: get_name() const { return _surface->_name; } @@ -36,7 +36,7 @@ has_named_uvs() const { * Returns the name of the set of UV's that are associated with this surface, * if has_named_uvs() is true. */ -INLINE const string &CLwoSurface:: +INLINE const std::string &CLwoSurface:: get_uv_name() const { return _block->_uv_name; } diff --git a/pandatool/src/lwoegg/cLwoSurface.h b/pandatool/src/lwoegg/cLwoSurface.h index 09b3762656..ec098f182f 100644 --- a/pandatool/src/lwoegg/cLwoSurface.h +++ b/pandatool/src/lwoegg/cLwoSurface.h @@ -41,7 +41,7 @@ public: CLwoSurface(LwoToEggConverter *converter, const LwoSurface *surface); ~CLwoSurface(); - INLINE const string &get_name() const; + INLINE const std::string &get_name() const; void apply_properties(EggPrimitive *egg_prim, vector_PT_EggVertex &egg_vertices, @@ -50,7 +50,7 @@ public: bool check_material(); INLINE bool has_named_uvs() const; - INLINE const string &get_uv_name() const; + INLINE const std::string &get_uv_name() const; enum Flags { diff --git a/pandatool/src/lwoegg/cLwoSurfaceBlock.h b/pandatool/src/lwoegg/cLwoSurfaceBlock.h index d62f73684d..cf86126f26 100644 --- a/pandatool/src/lwoegg/cLwoSurfaceBlock.h +++ b/pandatool/src/lwoegg/cLwoSurfaceBlock.h @@ -38,7 +38,7 @@ public: IffId _block_type; IffId _channel_id; - string _ordinal; + std::string _ordinal; bool _enabled; LwoSurfaceBlockOpacity::Type _opacity_type; @@ -54,7 +54,7 @@ public: LwoSurfaceBlockWrap::Mode _h_wrap; PN_stdfloat _w_repeat; PN_stdfloat _h_repeat; - string _uv_name; + std::string _uv_name; LwoToEggConverter *_converter; CPT(LwoSurfaceBlock) _block; diff --git a/pandatool/src/lwoegg/cLwoSurfaceBlockTMap.h b/pandatool/src/lwoegg/cLwoSurfaceBlockTMap.h index 4fde4938ca..075ed4182e 100644 --- a/pandatool/src/lwoegg/cLwoSurfaceBlockTMap.h +++ b/pandatool/src/lwoegg/cLwoSurfaceBlockTMap.h @@ -37,7 +37,7 @@ public: LVecBase3 _size; LVecBase3 _rotation; - string _reference_object; + std::string _reference_object; LwoSurfaceBlockCoordSys::Type _csys; diff --git a/pandatool/src/lwoegg/lwoToEggConverter.h b/pandatool/src/lwoegg/lwoToEggConverter.h index bd4a5a2e41..c4380a21f7 100644 --- a/pandatool/src/lwoegg/lwoToEggConverter.h +++ b/pandatool/src/lwoegg/lwoToEggConverter.h @@ -43,8 +43,8 @@ public: virtual SomethingToEggConverter *make_copy(); - virtual string get_name() const; - virtual string get_extension() const; + virtual std::string get_name() const; + virtual std::string get_extension() const; virtual bool convert_file(const Filename &filename); bool convert_lwo(const LwoHeader *lwo_header); @@ -53,7 +53,7 @@ public: CLwoLayer *get_layer(int number) const; CLwoClip *get_clip(int number) const; - CLwoSurface *get_surface(const string &name) const; + CLwoSurface *get_surface(const std::string &name) const; bool _make_materials; @@ -83,7 +83,7 @@ private: typedef pvector Polygons; Polygons _polygons; - typedef pmap Surfaces; + typedef pmap Surfaces; Surfaces _surfaces; }; diff --git a/pandatool/src/maxegg/maxToEggConverter.h b/pandatool/src/maxegg/maxToEggConverter.h index fc2ed1843f..86cb2303c1 100644 --- a/pandatool/src/maxegg/maxToEggConverter.h +++ b/pandatool/src/maxegg/maxToEggConverter.h @@ -56,7 +56,7 @@ class MaxToEggConverter { MaxEggOptions *_options; int _current_frame; PT(EggData) _egg_data; - string _program_name; + std::string _program_name; MaxNodeTree _tree; int _cur_tref; EggTextureCollection _textures; diff --git a/pandatool/src/maya/mayaApi.h b/pandatool/src/maya/mayaApi.h index 590f7b4817..02cc421955 100644 --- a/pandatool/src/maya/mayaApi.h +++ b/pandatool/src/maya/mayaApi.h @@ -29,14 +29,14 @@ class Filename; */ class MayaApi : public ReferenceCount { protected: - MayaApi(const string &program_name, bool view_license = false, bool revertdir = true); + MayaApi(const std::string &program_name, bool view_license = false, bool revertdir = true); MayaApi(const MayaApi ©); void operator = (const MayaApi ©); public: ~MayaApi(); - static PT(MayaApi) open_api(string program_name = "", bool view_license = false, bool revertdir = true); + static PT(MayaApi) open_api(std::string program_name = "", bool view_license = false, bool revertdir = true); bool is_valid() const; bool read(const Filename &filename); diff --git a/pandatool/src/maya/mayaShader.h b/pandatool/src/maya/mayaShader.h index b998588122..41c9bdf77f 100644 --- a/pandatool/src/maya/mayaShader.h +++ b/pandatool/src/maya/mayaShader.h @@ -33,8 +33,8 @@ public: MayaShader(MObject engine, bool legacy_shader); ~MayaShader(); - void output(ostream &out) const; - void write(ostream &out) const; + void output(std::ostream &out) const; + void write(std::ostream &out) const; private: bool find_textures_modern(MObject shader); @@ -64,7 +64,7 @@ private: bool try_pair(MayaShaderColorDef *map1, MayaShaderColorDef *map2, bool perfect); - string get_file_prefix(const string &fn); + std::string get_file_prefix(const std::string &fn); bool _legacy_shader; public: // relevant only to legacy mode. MayaShaderColorList _color; @@ -73,7 +73,7 @@ public: // relevant only to legacy mode. MayaShaderColorDef *get_color_def(size_t idx=0) const; }; -INLINE ostream &operator << (ostream &out, const MayaShader &shader) { +INLINE std::ostream &operator << (std::ostream &out, const MayaShader &shader) { shader.output(out); return out; } diff --git a/pandatool/src/maya/mayaShaderColorDef.h b/pandatool/src/maya/mayaShaderColorDef.h index 522146fc53..ca2d532f13 100644 --- a/pandatool/src/maya/mayaShaderColorDef.h +++ b/pandatool/src/maya/mayaShaderColorDef.h @@ -26,7 +26,7 @@ class MPlug; class MayaShader; class MayaShaderColorDef; typedef pvector MayaShaderColorList; -typedef pmap MayaFileToUVSetMap; +typedef pmap MayaFileToUVSetMap; /** * This defines the various attributes that Maya may associate with the @@ -39,14 +39,14 @@ public: MayaShaderColorDef (MayaShaderColorDef&); ~MayaShaderColorDef(); - string strip_prefix(string full_name); + std::string strip_prefix(std::string full_name); LMatrix3d compute_texture_matrix() const; bool has_projection() const; LTexCoordd project_uv(const LPoint3d &pos, const LPoint3d &ref_point) const; bool reset_maya_texture(const Filename &texture); - void write(ostream &out) const; + void write(std::ostream &out) const; enum BlendType { BT_unspecified, @@ -85,7 +85,7 @@ public: double _v_angle; Filename _texture_filename; - string _texture_name; + std::string _texture_name; LColor _color_gain; LVector2 _coverage; @@ -103,19 +103,19 @@ public: bool _is_alpha; - string _uvset_name; + std::string _uvset_name; MayaShaderColorDef *_opposite; - string get_panda_uvset_name(); + std::string get_panda_uvset_name(); private: MObject *_color_object; private: - static void find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug inplug, bool is_alpha); + static void find_textures_modern(const std::string &shadername, MayaShaderColorList &list, MPlug inplug, bool is_alpha); void find_textures_legacy(MayaShader *shader, MObject color, bool trans=false); - void set_projection_type(const string &type); + void set_projection_type(const std::string &type); LPoint2d map_planar(const LPoint3d &pos, const LPoint3d ¢roid) const; LPoint2d map_spherical(const LPoint3d &pos, const LPoint3d ¢roid) const; diff --git a/pandatool/src/maya/mayaShaders.h b/pandatool/src/maya/mayaShaders.h index 7c92ae4416..f1c107a755 100644 --- a/pandatool/src/maya/mayaShaders.h +++ b/pandatool/src/maya/mayaShaders.h @@ -37,13 +37,13 @@ public: MayaShader *get_shader(int n) const; MayaFileToUVSetMap _file_to_uvset; - pvector _uvset_names; + pvector _uvset_names; void clear(); void bind_uvsets(MObject mesh); - string find_uv_link(const string &match); + std::string find_uv_link(const std::string &match); private: - typedef pmap Shaders; + typedef pmap Shaders; Shaders _shaders; typedef pvector ShadersInOrder; ShadersInOrder _shaders_in_order; diff --git a/pandatool/src/maya/maya_funcs.I b/pandatool/src/maya/maya_funcs.I index 422b525751..1a56126c44 100644 --- a/pandatool/src/maya/maya_funcs.I +++ b/pandatool/src/maya/maya_funcs.I @@ -14,13 +14,13 @@ /** * */ -INLINE ostream &operator << (ostream &out, const MString &str) { +INLINE std::ostream &operator << (std::ostream &out, const MString &str) { return out << str.asChar(); } /** * */ -INLINE ostream &operator << (ostream &out, const MVector &vec) { +INLINE std::ostream &operator << (std::ostream &out, const MVector &vec) { return out << vec.x << " " << vec.y << " " << vec.z; } diff --git a/pandatool/src/maya/maya_funcs.h b/pandatool/src/maya/maya_funcs.h index 7b2ef5df13..2966fef9e3 100644 --- a/pandatool/src/maya/maya_funcs.h +++ b/pandatool/src/maya/maya_funcs.h @@ -31,77 +31,77 @@ class MObject; bool -get_maya_plug(MObject &node, const string &attribute_name, MPlug &plug); +get_maya_plug(MObject &node, const std::string &attribute_name, MPlug &plug); bool -is_connected(MObject &node, const string &attribute_name); +is_connected(MObject &node, const std::string &attribute_name); template bool -get_maya_attribute(MObject &node, const string &attribute_name, +get_maya_attribute(MObject &node, const std::string &attribute_name, ValueType &value); template bool -set_maya_attribute(MObject &node, const string &attribute_name, +set_maya_attribute(MObject &node, const std::string &attribute_name, ValueType &value); bool -has_attribute(MObject &node, const string &attribute_name); +has_attribute(MObject &node, const std::string &attribute_name); bool -remove_attribute(MObject &node, const string &attribute_name); +remove_attribute(MObject &node, const std::string &attribute_name); bool -get_bool_attribute(MObject &node, const string &attribute_name, +get_bool_attribute(MObject &node, const std::string &attribute_name, bool &value); bool -get_angle_attribute(MObject &node, const string &attribute_name, +get_angle_attribute(MObject &node, const std::string &attribute_name, double &value); bool -get_vec2_attribute(MObject &node, const string &attribute_name, +get_vec2_attribute(MObject &node, const std::string &attribute_name, LVecBase2 &value); bool -get_vec3_attribute(MObject &node, const string &attribute_name, +get_vec3_attribute(MObject &node, const std::string &attribute_name, LVecBase3 &value); bool -get_vec2d_attribute(MObject &node, const string &attribute_name, +get_vec2d_attribute(MObject &node, const std::string &attribute_name, LVecBase2d &value); bool -get_vec3d_attribute(MObject &node, const string &attribute_name, +get_vec3d_attribute(MObject &node, const std::string &attribute_name, LVecBase3d &value); bool -get_mat4d_attribute(MObject &node, const string &attribute_name, +get_mat4d_attribute(MObject &node, const std::string &attribute_name, LMatrix4d &value); void -get_tag_attribute_names(MObject &node, pvector &tag_names); +get_tag_attribute_names(MObject &node, pvector &tag_names); bool -get_enum_attribute(MObject &node, const string &attribute_name, - string &value); +get_enum_attribute(MObject &node, const std::string &attribute_name, + std::string &value); bool -get_string_attribute(MObject &node, const string &attribute_name, - string &value); +get_string_attribute(MObject &node, const std::string &attribute_name, + std::string &value); bool -set_string_attribute(MObject &node, const string &attribute_name, - const string &value); +set_string_attribute(MObject &node, const std::string &attribute_name, + const std::string &value); void -describe_maya_attribute(MObject &node, const string &attribute_name); +describe_maya_attribute(MObject &node, const std::string &attribute_name); bool describe_compound_attribute(MObject &node); -string +std::string string_mfndata_type(MFnData::Type type); void @@ -110,8 +110,8 @@ list_maya_attributes(MObject &node); // Also, we must define some output functions for Maya objects, since we can't // use those built into Maya (which forward-defines the ostream type // incorrectly). -INLINE ostream &operator << (ostream &out, const MString &str); -INLINE ostream &operator << (ostream &out, const MVector &vec); +INLINE std::ostream &operator << (std::ostream &out, const MString &str); +INLINE std::ostream &operator << (std::ostream &out, const MVector &vec); #include "maya_funcs.I" #include "maya_funcs.T" diff --git a/pandatool/src/mayaegg/mayaNodeDesc.h b/pandatool/src/mayaegg/mayaNodeDesc.h index bfae4300ce..f4123ee9a2 100644 --- a/pandatool/src/mayaegg/mayaNodeDesc.h +++ b/pandatool/src/mayaegg/mayaNodeDesc.h @@ -40,7 +40,7 @@ class EggXfmSAnim; class MayaNodeDesc : public ReferenceCount, public Namable { public: MayaNodeDesc(MayaNodeTree *tree, - MayaNodeDesc *parent = nullptr, const string &name = string()); + MayaNodeDesc *parent = nullptr, const std::string &name = std::string()); ~MayaNodeDesc(); void from_dag_path(const MDagPath &dag_path, MayaToEggConverter *converter); @@ -55,7 +55,7 @@ public: bool is_tagged() const; bool is_joint_tagged() const; - bool has_object_type(string object_type) const; + bool has_object_type(std::string object_type) const; MayaNodeTree *_tree; MayaNodeDesc *_parent; @@ -74,7 +74,7 @@ private: void mark_joint_parent(); void check_pseudo_joints(bool joint_above); void check_blend_shapes(const MFnDagNode &node, - const string &attrib_name); + const std::string &attrib_name); void check_lods(); MDagPath *_dag_path; diff --git a/pandatool/src/mayaegg/mayaNodeTree.h b/pandatool/src/mayaegg/mayaNodeTree.h index febb794f23..e355c45ff3 100644 --- a/pandatool/src/mayaegg/mayaNodeTree.h +++ b/pandatool/src/mayaegg/mayaNodeTree.h @@ -60,8 +60,8 @@ public: EggXfmSAnim *get_egg_anim(MayaNodeDesc *node_desc); EggSAnimData *get_egg_slider(MayaBlendDesc *blend_desc); - bool ignore_slider(const string &name) const; - void report_ignored_slider(const string &name); + bool ignore_slider(const std::string &name) const; + void report_ignored_slider(const std::string &name); MayaBlendDesc *add_blend_desc(MayaBlendDesc *blend_desc); int get_num_blend_descs() const; @@ -70,12 +70,12 @@ public: void reset_sliders(); public: - string _subroot_parent_name; + std::string _subroot_parent_name; PT(MayaNodeDesc) _root; PN_stdfloat _fps; private: - MayaNodeDesc *r_build_node(const string &path); + MayaNodeDesc *r_build_node(const std::string &path); MayaToEggConverter *_converter; @@ -84,7 +84,7 @@ private: EggGroupNode *_skeleton_node; EggGroupNode *_morph_node; - typedef pmap NodesByPath; + typedef pmap NodesByPath; NodesByPath _nodes_by_path; typedef pvector Nodes; @@ -93,7 +93,7 @@ private: typedef ov_set > BlendDescs; BlendDescs _blend_descs; - typedef pset Strings; + typedef pset Strings; Strings _ignored_slider_names; }; diff --git a/pandatool/src/mayaegg/mayaToEggConverter.h b/pandatool/src/mayaegg/mayaToEggConverter.h index ff9d75e7b9..3e3782a601 100644 --- a/pandatool/src/mayaegg/mayaToEggConverter.h +++ b/pandatool/src/mayaegg/mayaToEggConverter.h @@ -60,15 +60,15 @@ class MFloatArray; */ class MayaToEggConverter : public SomethingToEggConverter { public: - MayaToEggConverter(const string &program_name = ""); + MayaToEggConverter(const std::string &program_name = ""); MayaToEggConverter(const MayaToEggConverter ©); virtual ~MayaToEggConverter(); virtual SomethingToEggConverter *make_copy(); - virtual string get_name() const; - virtual string get_extension() const; - virtual string get_additional_extensions() const; + virtual std::string get_name() const; + virtual std::string get_extension() const; + virtual std::string get_additional_extensions() const; virtual bool convert_file(const Filename &filename); virtual DistanceUnit get_input_units(); @@ -84,11 +84,11 @@ public: void clear_ignore_sliders(); void add_ignore_slider(const GlobPattern &glob); - bool ignore_slider(const string &name) const; + bool ignore_slider(const std::string &name) const; void clear_force_joints(); void add_force_joint(const GlobPattern &glob); - bool force_joint(const string &name) const; + bool force_joint(const std::string &name) const; void set_from_selection(bool from_selection); @@ -123,7 +123,7 @@ private: MFnNurbsSurface &surface, EggGroup *group); EggNurbsCurve *make_trim_curve(const MFnNurbsCurve &curve, - const string &nurbs_name, + const std::string &nurbs_name, EggGroupNode *egg_group, int trim_curve_index); void make_nurbs_curve(const MDagPath &dag_path, @@ -167,10 +167,10 @@ private: int round(double value); - string _program_name; + std::string _program_name; bool _from_selection; - string _subroot; + std::string _subroot; typedef pvector Globs; Globs _subsets; Globs _subroots; @@ -205,7 +205,7 @@ public: }; TransformType _transform_type; - static TransformType string_transform_type(const string &arg); + static TransformType string_transform_type(const std::string &arg); }; diff --git a/pandatool/src/mayaprogs/mayaCopy.h b/pandatool/src/mayaprogs/mayaCopy.h index e48c2f9204..90ceddfbc0 100644 --- a/pandatool/src/mayaprogs/mayaCopy.h +++ b/pandatool/src/mayaprogs/mayaCopy.h @@ -41,7 +41,7 @@ protected: CVSSourceDirectory *dir, void *extra_data, bool new_file); - virtual string filter_filename(const string &source); + virtual std::string filter_filename(const std::string &source); private: enum FileType { diff --git a/pandatool/src/mayaprogs/mayaToEgg.h b/pandatool/src/mayaprogs/mayaToEgg.h index 4b3661a104..a6ec0453f2 100644 --- a/pandatool/src/mayaprogs/mayaToEgg.h +++ b/pandatool/src/mayaprogs/mayaToEgg.h @@ -28,7 +28,7 @@ public: void run(); protected: - static bool dispatch_transform_type(const string &opt, const string &arg, void *var); + static bool dispatch_transform_type(const std::string &opt, const std::string &arg, void *var); int _verbose; bool _polygon_output; diff --git a/pandatool/src/mayaprogs/mayaToEgg_server.h b/pandatool/src/mayaprogs/mayaToEgg_server.h index 3eaf739ada..ba014f4846 100644 --- a/pandatool/src/mayaprogs/mayaToEgg_server.h +++ b/pandatool/src/mayaprogs/mayaToEgg_server.h @@ -43,7 +43,7 @@ public: protected: - static bool dispatch_transform_type(const string &opt, const string &arg, void *var); + static bool dispatch_transform_type(const std::string &opt, const std::string &arg, void *var); typedef pset< PT(Connection) > Clients; Clients _clients; diff --git a/pandatool/src/miscprogs/binToC.h b/pandatool/src/miscprogs/binToC.h index 39eff76766..f1ba6599b2 100644 --- a/pandatool/src/miscprogs/binToC.h +++ b/pandatool/src/miscprogs/binToC.h @@ -34,7 +34,7 @@ protected: virtual bool handle_args(Args &args); Filename _input_filename; - string _table_name; + std::string _table_name; bool _static_table; bool _for_string; }; diff --git a/pandatool/src/objegg/eggToObjConverter.h b/pandatool/src/objegg/eggToObjConverter.h index df54648a72..51f940d56c 100644 --- a/pandatool/src/objegg/eggToObjConverter.h +++ b/pandatool/src/objegg/eggToObjConverter.h @@ -31,8 +31,8 @@ public: virtual EggToSomethingConverter *make_copy(); - virtual string get_name() const; - virtual string get_extension() const; + virtual std::string get_name() const; + virtual std::string get_extension() const; virtual bool supports_compressed() const; virtual bool write_file(const Filename &filename); @@ -53,9 +53,9 @@ private: bool process(const Filename &filename); void collect_vertices(EggNode *egg_node); - void write_faces(ostream &out, EggNode *egg_node); - void write_group_reference(ostream &out, EggNode *egg_node); - void get_group_name(string &group_name, EggGroupNode *egg_group); + void write_faces(std::ostream &out, EggNode *egg_node); + void write_group_reference(std::ostream &out, EggNode *egg_node); + void get_group_name(std::string &group_name, EggGroupNode *egg_group); void record_vertex(EggVertex *vertex); int record_unique(UniqueVertices &unique, const LVecBase4d &vec); @@ -63,7 +63,7 @@ private: int record_unique(UniqueVertices &unique, const LVecBase2d &vec); int record_unique(UniqueVertices &unique, double pos); - void write_vertices(ostream &out, const string &prefix, int num_components, + void write_vertices(std::ostream &out, const std::string &prefix, int num_components, const UniqueVertices &unique); private: diff --git a/pandatool/src/objegg/objToEggConverter.h b/pandatool/src/objegg/objToEggConverter.h index 062f08c6cd..528dab8e7a 100644 --- a/pandatool/src/objegg/objToEggConverter.h +++ b/pandatool/src/objegg/objToEggConverter.h @@ -38,8 +38,8 @@ public: virtual SomethingToEggConverter *make_copy(); - virtual string get_name() const; - virtual string get_extension() const; + virtual std::string get_name() const; + virtual std::string get_extension() const; virtual bool supports_compressed() const; virtual bool supports_convert_to_node(const LoaderOptions &options) const; @@ -48,8 +48,8 @@ public: protected: bool process(const Filename &filename); - bool process_line(const string &line); - bool process_ref_plane_res(const string &line); + bool process_line(const std::string &line); + bool process_ref_plane_res(const std::string &line); bool process_v(vector_string &words); bool process_vt(vector_string &words); @@ -59,11 +59,11 @@ protected: bool process_f(vector_string &words); bool process_g(vector_string &words); - EggVertex *get_face_vertex(const string &face_reference); + EggVertex *get_face_vertex(const std::string &face_reference); void generate_egg_points(); bool process_node(const Filename &filename); - bool process_line_node(const string &line); + bool process_line_node(const std::string &line); bool process_f_node(vector_string &words); bool process_g_node(vector_string &words); @@ -88,7 +88,7 @@ protected: bool _v4_given, _vt3_given; bool _f_given; - pset _ignored_tags; + pset _ignored_tags; // Structures filled when creating an egg file. PT(EggVertexPool) _vpool; @@ -101,7 +101,7 @@ protected: class VertexEntry { public: VertexEntry(); - VertexEntry(const ObjToEggConverter *converter, const string &obj_vertex); + VertexEntry(const ObjToEggConverter *converter, const std::string &obj_vertex); INLINE bool operator < (const VertexEntry &other) const; INLINE bool operator == (const VertexEntry &other) const; @@ -119,7 +119,7 @@ protected: class VertexData { public: - VertexData(PandaNode *parent, const string &name); + VertexData(PandaNode *parent, const std::string &name); int add_vertex(const ObjToEggConverter *converter, const VertexEntry &entry); void add_triangle(const ObjToEggConverter *converter, const VertexEntry &v0, @@ -128,7 +128,7 @@ protected: void close_geom(const ObjToEggConverter *converter); PT(PandaNode) _parent; - string _name; + std::string _name; PT(GeomNode) _geom_node; PT(GeomPrimitive) _prim; diff --git a/pandatool/src/palettizer/destTextureImage.h b/pandatool/src/palettizer/destTextureImage.h index 0916661c6c..31075b8f99 100644 --- a/pandatool/src/palettizer/destTextureImage.h +++ b/pandatool/src/palettizer/destTextureImage.h @@ -65,8 +65,8 @@ private: static TypeHandle _type_handle; }; -INLINE ostream & -operator << (ostream &out, const DestTextureImage &dest) { +INLINE std::ostream & +operator << (std::ostream &out, const DestTextureImage &dest) { dest.output_filename(out); return out; } diff --git a/pandatool/src/palettizer/eggFile.h b/pandatool/src/palettizer/eggFile.h index 696ec833e6..cc3887242e 100644 --- a/pandatool/src/palettizer/eggFile.h +++ b/pandatool/src/palettizer/eggFile.h @@ -40,7 +40,7 @@ public: bool from_command_line(EggData *data, const Filename &source_filename, const Filename &dest_filename, - const string &egg_comment); + const std::string &egg_comment); const Filename &get_source_filename() const; @@ -73,8 +73,8 @@ public: void release_egg_data(); bool write_egg(); - void write_description(ostream &out, int indent_level = 0) const; - void write_texture_refs(ostream &out, int indent_level = 0) const; + void write_description(std::ostream &out, int indent_level = 0) const; + void write_texture_refs(std::ostream &out, int indent_level = 0) const; private: void remove_backstage(EggGroupNode *node); @@ -85,7 +85,7 @@ private: Filename _current_directory; Filename _source_filename; Filename _dest_filename; - string _egg_comment; + std::string _egg_comment; typedef pvector Textures; Textures _textures; diff --git a/pandatool/src/palettizer/filenameUnifier.h b/pandatool/src/palettizer/filenameUnifier.h index b5646f5628..0f701b3ce5 100644 --- a/pandatool/src/palettizer/filenameUnifier.h +++ b/pandatool/src/palettizer/filenameUnifier.h @@ -44,7 +44,7 @@ private: static Filename _txa_dir; static Filename _rel_dirname; - typedef pmap CanonicalFilenames; + typedef pmap CanonicalFilenames; static CanonicalFilenames _canonical_filenames; }; diff --git a/pandatool/src/palettizer/imageFile.h b/pandatool/src/palettizer/imageFile.h index 80de6266f3..c4d8ed9014 100644 --- a/pandatool/src/palettizer/imageFile.h +++ b/pandatool/src/palettizer/imageFile.h @@ -34,7 +34,7 @@ class ImageFile : public TypedWritable { public: ImageFile(); - bool make_shadow_image(const string &basename); + bool make_shadow_image(const std::string &basename); bool is_size_known() const; int get_x_size() const; @@ -46,8 +46,8 @@ public: void clear_basic_properties(); void update_properties(const TextureProperties &properties); - bool set_filename(PaletteGroup *group, const string &basename); - bool set_filename(const string &dirname, const string &basename); + bool set_filename(PaletteGroup *group, const std::string &basename); + bool set_filename(const std::string &dirname, const std::string &basename); const Filename &get_filename() const; const Filename &get_alpha_filename() const; int get_alpha_file_channel() const; @@ -59,7 +59,7 @@ public: void update_egg_tex(EggTexture *egg_tex) const; - void output_filename(ostream &out) const; + void output_filename(std::ostream &out) const; protected: TextureProperties _properties; diff --git a/pandatool/src/palettizer/omitReason.h b/pandatool/src/palettizer/omitReason.h index db2a7bb03f..c60a86f364 100644 --- a/pandatool/src/palettizer/omitReason.h +++ b/pandatool/src/palettizer/omitReason.h @@ -52,6 +52,6 @@ enum OmitReason { // The texture is omitted because _omit_everything is set true. }; -ostream &operator << (ostream &out, OmitReason omit); +std::ostream &operator << (std::ostream &out, OmitReason omit); #endif diff --git a/pandatool/src/palettizer/pal_string_utils.h b/pandatool/src/palettizer/pal_string_utils.h index 6eed342977..4f37b33063 100644 --- a/pandatool/src/palettizer/pal_string_utils.h +++ b/pandatool/src/palettizer/pal_string_utils.h @@ -19,9 +19,9 @@ class PNMFileType; -void extract_param_value(const string &str, string ¶m, string &value); +void extract_param_value(const std::string &str, std::string ¶m, std::string &value); -bool parse_image_type_request(const string &word, PNMFileType *&color_type, +bool parse_image_type_request(const std::string &word, PNMFileType *&color_type, PNMFileType *&alpha_type); #endif diff --git a/pandatool/src/palettizer/paletteGroup.h b/pandatool/src/palettizer/paletteGroup.h index 615663b571..54eaa08fc0 100644 --- a/pandatool/src/palettizer/paletteGroup.h +++ b/pandatool/src/palettizer/paletteGroup.h @@ -44,9 +44,9 @@ class PaletteGroup : public TypedWritable, public Namable { public: PaletteGroup(); - void set_dirname(const string &dirname); + void set_dirname(const std::string &dirname); bool has_dirname() const; - const string &get_dirname() const; + const std::string &get_dirname() const; void clear_depends(); void group_with(PaletteGroup *other); @@ -80,17 +80,17 @@ public: void place_all(); void update_unknown_textures(const TxaFile &txa_file); - void write_image_info(ostream &out, int indent_level = 0) const; + void write_image_info(std::ostream &out, int indent_level = 0) const; void optimal_resize(); void reset_images(); void setup_shadow_images(); void update_images(bool redo_all); - void add_texture_swap_info(const string sourceTextureName, const vector_string &swapTextures); + void add_texture_swap_info(const std::string sourceTextureName, const vector_string &swapTextures); bool is_none_texture_swap() const; private: - string _dirname; + std::string _dirname; int _egg_count; PaletteGroups _dependent; int _dependency_level; @@ -103,7 +103,7 @@ private: typedef pmap Pages; Pages _pages; - typedef pmap TextureSwapInfo; + typedef pmap TextureSwapInfo; TextureSwapInfo _textureSwapInfo; // The TypedWritable interface follows. diff --git a/pandatool/src/palettizer/paletteGroups.h b/pandatool/src/palettizer/paletteGroups.h index 2be2eb4602..9a2cdd2b52 100644 --- a/pandatool/src/palettizer/paletteGroups.h +++ b/pandatool/src/palettizer/paletteGroups.h @@ -60,8 +60,8 @@ public: iterator begin() const; iterator end() const; - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; private: void r_make_complete(Groups &result, PaletteGroup *group); @@ -103,7 +103,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const PaletteGroups &groups) { +INLINE std::ostream &operator << (std::ostream &out, const PaletteGroups &groups) { groups.output(out); return out; } diff --git a/pandatool/src/palettizer/paletteImage.h b/pandatool/src/palettizer/paletteImage.h index 314942e8ab..60395fdc39 100644 --- a/pandatool/src/palettizer/paletteImage.h +++ b/pandatool/src/palettizer/paletteImage.h @@ -51,7 +51,7 @@ public: bool resize_image(int x_size, int y_size); void resize_swapped_image(int x_size, int y_size); - void write_placements(ostream &out, int indent_level = 0) const; + void write_placements(std::ostream &out, int indent_level = 0) const; void reset_image(); void setup_shadow_image(); void update_image(bool redo_all); @@ -96,7 +96,7 @@ private: PalettePage *_page; int _index; - string _basename; + std::string _basename; bool _new_image; bool _got_image; diff --git a/pandatool/src/palettizer/palettePage.h b/pandatool/src/palettizer/palettePage.h index 35a17841dd..91ba875219 100644 --- a/pandatool/src/palettizer/palettePage.h +++ b/pandatool/src/palettizer/palettePage.h @@ -45,7 +45,7 @@ public: void place(TexturePlacement *placement); void unplace(TexturePlacement *placement); - void write_image_info(ostream &out, int indent_level = 0) const; + void write_image_info(std::ostream &out, int indent_level = 0) const; void optimal_resize(); void reset_images(); void setup_shadow_images(); diff --git a/pandatool/src/palettizer/palettizer.h b/pandatool/src/palettizer/palettizer.h index ad8c389df8..523968e952 100644 --- a/pandatool/src/palettizer/palettizer.h +++ b/pandatool/src/palettizer/palettizer.h @@ -47,7 +47,7 @@ public: void report_pi() const; void report_statistics() const; - void read_txa_file(istream &txa_file, const string &txa_filename); + void read_txa_file(std::istream &txa_file, const std::string &txa_filename); void all_params_set(); void process_command_line_eggs(bool force_texture_read, const Filename &state_filename); void process_all(bool force_texture_read, const Filename &state_filename); @@ -57,15 +57,15 @@ public: bool read_stale_eggs(bool redo_all); bool write_eggs(); - EggFile *get_egg_file(const string &name); - bool remove_egg_file(const string &name); + EggFile *get_egg_file(const std::string &name); + bool remove_egg_file(const std::string &name); void add_command_line_egg(EggFile *egg_file); - PaletteGroup *get_palette_group(const string &name); - PaletteGroup *test_palette_group(const string &name) const; + PaletteGroup *get_palette_group(const std::string &name); + PaletteGroup *test_palette_group(const std::string &name) const; PaletteGroup *get_default_group(); - TextureImage *get_texture(const string &name); + TextureImage *get_texture(const std::string &name); private: static const char *yesno(bool flag); @@ -82,22 +82,22 @@ public: RU_invalid }; - static RemapUV string_remap(const string &str); + static RemapUV string_remap(const std::string &str); bool _is_valid; // These values are not stored in the textures.boo file, but are specific to // each session. TxaFile _txa_file; - string _default_groupname; - string _default_groupdir; + std::string _default_groupname; + std::string _default_groupdir; bool _noabs; // The following parameter values specifically relate to textures and // palettes. These values are stored in the textures.boo file for future // reference. - string _generated_image_pattern; - string _map_dirname; + std::string _generated_image_pattern; + std::string _map_dirname; Filename _shadow_dirname; Filename _rel_dirname; int _pal_x_size, _pal_y_size; @@ -121,10 +121,10 @@ public: private: typedef pvector Placements; - void compute_statistics(ostream &out, int indent_level, + void compute_statistics(std::ostream &out, int indent_level, const Placements &placements) const; - typedef pmap EggFiles; + typedef pmap EggFiles; EggFiles _egg_files; typedef pvector CommandLineEggs; @@ -133,10 +133,10 @@ private: typedef pset CommandLineTextures; CommandLineTextures _command_line_textures; - typedef pmap Groups; + typedef pmap Groups; Groups _groups; - typedef pmap Textures; + typedef pmap Textures; Textures _textures; typedef pvector TextureConflicts; TextureConflicts _texture_conflicts; diff --git a/pandatool/src/palettizer/sourceTextureImage.h b/pandatool/src/palettizer/sourceTextureImage.h index 09c1792222..1f1f64b9dc 100644 --- a/pandatool/src/palettizer/sourceTextureImage.h +++ b/pandatool/src/palettizer/sourceTextureImage.h @@ -76,8 +76,8 @@ private: static TypeHandle _type_handle; }; -INLINE ostream & -operator << (ostream &out, const SourceTextureImage &source) { +INLINE std::ostream & +operator << (std::ostream &out, const SourceTextureImage &source) { source.output_filename(out); return out; } diff --git a/pandatool/src/palettizer/textureImage.h b/pandatool/src/palettizer/textureImage.h index 4d9b1b84e9..1e590da621 100644 --- a/pandatool/src/palettizer/textureImage.h +++ b/pandatool/src/palettizer/textureImage.h @@ -88,14 +88,14 @@ public: void read_header(); bool is_newer_than(const Filename &reference_filename); - void write_source_pathnames(ostream &out, int indent_level = 0) const; - void write_scale_info(ostream &out, int indent_level = 0); + void write_source_pathnames(std::ostream &out, int indent_level = 0) const; + void write_scale_info(std::ostream &out, int indent_level = 0); private: typedef pset EggFiles; typedef pvector WorkingEggs; - typedef pmap Sources; - typedef pmap Dests; + typedef pmap Sources; + typedef pmap Dests; static int compute_egg_count(PaletteGroup *group, const WorkingEggs &egg_files); @@ -107,7 +107,7 @@ private: void remove_old_dests(const Dests &a, const Dests &b); void copy_new_dests(const Dests &a, const Dests &b); - string get_source_key(const Filename &filename, + std::string get_source_key(const Filename &filename, const Filename &alpha_filename, int alpha_file_channel); diff --git a/pandatool/src/palettizer/textureMemoryCounter.h b/pandatool/src/palettizer/textureMemoryCounter.h index 47d70db230..49de474732 100644 --- a/pandatool/src/palettizer/textureMemoryCounter.h +++ b/pandatool/src/palettizer/textureMemoryCounter.h @@ -37,10 +37,10 @@ public: void reset(); void add_placement(TexturePlacement *placement); - void report(ostream &out, int indent_level); + void report(std::ostream &out, int indent_level); private: - static ostream &format_memory_fraction(ostream &out, int fraction_bytes, + static std::ostream &format_memory_fraction(std::ostream &out, int fraction_bytes, int palette_bytes); void add_palette(PaletteImage *image); void add_texture(TextureImage *texture, int bytes); diff --git a/pandatool/src/palettizer/texturePlacement.h b/pandatool/src/palettizer/texturePlacement.h index ca69f93ea0..552f50f3d6 100644 --- a/pandatool/src/palettizer/texturePlacement.h +++ b/pandatool/src/palettizer/texturePlacement.h @@ -46,7 +46,7 @@ public: TexturePlacement(TextureImage *texture, PaletteGroup *group); ~TexturePlacement(); - const string &get_name() const; + const std::string &get_name() const; TextureImage *get_texture() const; const TextureProperties &get_properties() const; PaletteGroup *get_group() const; @@ -82,7 +82,7 @@ public: void compute_tex_matrix(LMatrix3d &transform); - void write_placed(ostream &out, int indent_level = 0); + void write_placed(std::ostream &out, int indent_level = 0); bool is_filled() const; void mark_unfilled(); diff --git a/pandatool/src/palettizer/textureProperties.h b/pandatool/src/palettizer/textureProperties.h index cfd5fd36f8..5186f29308 100644 --- a/pandatool/src/palettizer/textureProperties.h +++ b/pandatool/src/palettizer/textureProperties.h @@ -42,7 +42,7 @@ public: void force_nonalpha(); bool uses_alpha() const; - string get_string() const; + std::string get_string() const; void update_properties(const TextureProperties &other); void fully_define(); @@ -64,11 +64,11 @@ public: PNMFileType *_alpha_type; private: - static string get_format_string(EggTexture::Format format); - static string get_filter_string(EggTexture::FilterType filter_type); - static string get_anisotropic_degree_string(int aniso_degree); - static string get_quality_level_string(EggTexture::QualityLevel quality_level); - static string get_type_string(PNMFileType *color_type, + static std::string get_format_string(EggTexture::Format format); + static std::string get_filter_string(EggTexture::FilterType filter_type); + static std::string get_anisotropic_degree_string(int aniso_degree); + static std::string get_quality_level_string(EggTexture::QualityLevel quality_level); + static std::string get_type_string(PNMFileType *color_type, PNMFileType *alpha_type); static EggTexture::Format union_format(EggTexture::Format a, diff --git a/pandatool/src/palettizer/textureReference.h b/pandatool/src/palettizer/textureReference.h index aa555263b9..f17d8337b2 100644 --- a/pandatool/src/palettizer/textureReference.h +++ b/pandatool/src/palettizer/textureReference.h @@ -50,7 +50,7 @@ public: EggFile *get_egg_file() const; SourceTextureImage *get_source() const; TextureImage *get_texture() const; - const string &get_tref_name() const; + const std::string &get_tref_name() const; bool operator < (const TextureReference &other) const; @@ -71,8 +71,8 @@ public: void update_egg(); void apply_properties_to_source(); - void output(ostream &out) const; - void write(ostream &out, int indent_level = 0) const; + void output(std::ostream &out) const; + void write(std::ostream &out, int indent_level = 0) const; private: @@ -93,7 +93,7 @@ private: EggTexture *_egg_tex; EggData *_egg_data; - string _tref_name; + std::string _tref_name; LMatrix3d _tex_mat, _inv_tex_mat; SourceTextureImage *_source_texture; TexturePlacement *_placement; @@ -134,8 +134,8 @@ private: static TypeHandle _type_handle; }; -INLINE ostream & -operator << (ostream &out, const TextureReference &ref) { +INLINE std::ostream & +operator << (std::ostream &out, const TextureReference &ref) { ref.output(out); return out; } diff --git a/pandatool/src/palettizer/txaFile.h b/pandatool/src/palettizer/txaFile.h index 507e0ac21a..05d0a32ae1 100644 --- a/pandatool/src/palettizer/txaFile.h +++ b/pandatool/src/palettizer/txaFile.h @@ -31,15 +31,15 @@ class TxaFile { public: TxaFile(); - bool read(istream &in, const string &filename); + bool read(std::istream &in, const std::string &filename); bool match_egg(EggFile *egg_file) const; bool match_texture(TextureImage *texture) const; - void write(ostream &out) const; + void write(std::ostream &out) const; private: - static int get_line_or_semicolon(istream &in, string &line); + static int get_line_or_semicolon(std::istream &in, std::string &line); bool parse_group_line(const vector_string &words); bool parse_palette_line(const vector_string &words); diff --git a/pandatool/src/palettizer/txaLine.h b/pandatool/src/palettizer/txaLine.h index 98166f0bec..b0fe5e2c06 100644 --- a/pandatool/src/palettizer/txaLine.h +++ b/pandatool/src/palettizer/txaLine.h @@ -37,12 +37,12 @@ class TxaLine { public: TxaLine(); - bool parse(const string &line); + bool parse(const std::string &line); bool match_egg(EggFile *egg_file) const; bool match_texture(TextureImage *texture) const; - void output(ostream &out) const; + void output(std::ostream &out) const; private: typedef pvector Patterns; @@ -93,7 +93,7 @@ private: PNMFileType *_alpha_type; }; -INLINE ostream &operator << (ostream &out, const TxaLine &line) { +INLINE std::ostream &operator << (std::ostream &out, const TxaLine &line) { line.output(out); return out; } diff --git a/pandatool/src/pandatoolbase/animationConvert.h b/pandatool/src/pandatoolbase/animationConvert.h index b5d9ec9cda..2365cfff1e 100644 --- a/pandatool/src/pandatoolbase/animationConvert.h +++ b/pandatool/src/pandatoolbase/animationConvert.h @@ -31,9 +31,9 @@ enum AnimationConvert { AC_both, // A character model and tables in the same file. }; -string format_animation_convert(AnimationConvert unit); +std::string format_animation_convert(AnimationConvert unit); -ostream &operator << (ostream &out, AnimationConvert unit); -AnimationConvert string_animation_convert(const string &str); +std::ostream &operator << (std::ostream &out, AnimationConvert unit); +AnimationConvert string_animation_convert(const std::string &str); #endif diff --git a/pandatool/src/pandatoolbase/distanceUnit.h b/pandatool/src/pandatoolbase/distanceUnit.h index 4e82b74335..2030ae09e0 100644 --- a/pandatool/src/pandatoolbase/distanceUnit.h +++ b/pandatool/src/pandatoolbase/distanceUnit.h @@ -33,12 +33,12 @@ enum DistanceUnit { DU_invalid }; -string format_abbrev_unit(DistanceUnit unit); -string format_long_unit(DistanceUnit unit); +std::string format_abbrev_unit(DistanceUnit unit); +std::string format_long_unit(DistanceUnit unit); -ostream &operator << (ostream &out, DistanceUnit unit); -istream &operator >> (istream &in, DistanceUnit &unit); -DistanceUnit string_distance_unit(const string &str); +std::ostream &operator << (std::ostream &out, DistanceUnit unit); +std::istream &operator >> (std::istream &in, DistanceUnit &unit); +DistanceUnit string_distance_unit(const std::string &str); double convert_units(DistanceUnit from, DistanceUnit to); diff --git a/pandatool/src/pandatoolbase/pathReplace.I b/pandatool/src/pandatoolbase/pathReplace.I index a2fde11ad8..282c37d306 100644 --- a/pandatool/src/pandatoolbase/pathReplace.I +++ b/pandatool/src/pandatoolbase/pathReplace.I @@ -44,7 +44,7 @@ clear() { * orig_prefix, that prefix will be replaced with replacement_prefix. */ INLINE void PathReplace:: -add_pattern(const string &orig_prefix, const string &replacement_prefix) { +add_pattern(const std::string &orig_prefix, const std::string &replacement_prefix) { _entries.push_back(Entry(orig_prefix, replacement_prefix)); } @@ -59,7 +59,7 @@ get_num_patterns() const { /** * Returns the original prefix associated with the nth pattern. */ -INLINE const string &PathReplace:: +INLINE const std::string &PathReplace:: get_orig_prefix(int n) const { nassertr(n >= 0 && n < (int)_entries.size(), _entries[0]._orig_prefix); return _entries[n]._orig_prefix; @@ -68,7 +68,7 @@ get_orig_prefix(int n) const { /** * Returns the replacement prefix associated with the nth pattern. */ -INLINE const string &PathReplace:: +INLINE const std::string &PathReplace:: get_replacement_prefix(int n) const { nassertr(n >= 0 && n < (int)_entries.size(), _entries[0]._replacement_prefix); return _entries[n]._replacement_prefix; @@ -98,7 +98,7 @@ convert_path(const Filename &orig_filename, const DSearchPath &additional_path) * */ INLINE PathReplace::Component:: -Component(const string &component) : +Component(const std::string &component) : _orig_prefix(component), _double_star(component == "**") { diff --git a/pandatool/src/pandatoolbase/pathReplace.h b/pandatool/src/pandatoolbase/pathReplace.h index a0ec064acd..edc69abc08 100644 --- a/pandatool/src/pandatoolbase/pathReplace.h +++ b/pandatool/src/pandatoolbase/pathReplace.h @@ -42,11 +42,11 @@ public: INLINE bool had_error() const; INLINE void clear(); - INLINE void add_pattern(const string &orig_prefix, const string &replacement_prefix); + INLINE void add_pattern(const std::string &orig_prefix, const std::string &replacement_prefix); INLINE int get_num_patterns() const; - INLINE const string &get_orig_prefix(int n) const; - INLINE const string &get_replacement_prefix(int n) const; + INLINE const std::string &get_orig_prefix(int n) const; + INLINE const std::string &get_replacement_prefix(int n) const; INLINE bool is_empty() const; @@ -62,7 +62,7 @@ public: Filename &resolved_path, Filename &output_path); - void write(ostream &out, int indent_level = 0) const; + void write(std::ostream &out, int indent_level = 0) const; public: // This is used (along with _entries) to support match_path(). @@ -88,7 +88,7 @@ private: class Component { public: - INLINE Component(const string &component); + INLINE Component(const std::string &component); INLINE Component(const Component ©); INLINE void operator = (const Component ©); @@ -99,17 +99,17 @@ private: class Entry { public: - Entry(const string &orig_prefix, const string &replacement_prefix); + Entry(const std::string &orig_prefix, const std::string &replacement_prefix); INLINE Entry(const Entry ©); INLINE void operator = (const Entry ©); bool try_match(const Filename &filename, Filename &new_filename) const; size_t r_try_match(const vector_string &components, size_t oi, size_t ci) const; - string _orig_prefix; + std::string _orig_prefix; Components _orig_components; bool _is_local; - string _replacement_prefix; + std::string _replacement_prefix; }; typedef pvector Entries; diff --git a/pandatool/src/pandatoolbase/pathStore.h b/pandatool/src/pandatoolbase/pathStore.h index 7c15515038..30440b70a7 100644 --- a/pandatool/src/pandatoolbase/pathStore.h +++ b/pandatool/src/pandatoolbase/pathStore.h @@ -29,9 +29,9 @@ enum PathStore { PS_keep, // Don't change the filename at all. }; -string format_path_store(PathStore unit); +std::string format_path_store(PathStore unit); -ostream &operator << (ostream &out, PathStore unit); -PathStore string_path_store(const string &str); +std::ostream &operator << (std::ostream &out, PathStore unit); +PathStore string_path_store(const std::string &str); #endif diff --git a/pandatool/src/pfmprogs/pfmTrans.h b/pandatool/src/pfmprogs/pfmTrans.h index c36a6b975d..7d79127724 100644 --- a/pandatool/src/pfmprogs/pfmTrans.h +++ b/pandatool/src/pfmprogs/pfmTrans.h @@ -38,12 +38,12 @@ public: protected: virtual bool handle_args(Args &args); - static bool dispatch_scale(const string &opt, const string &arg, void *var); - static bool dispatch_rotate_xyz(ProgramBase *self, const string &opt, const string &arg, void *var); - bool ns_dispatch_rotate_xyz(const string &opt, const string &arg, void *var); - static bool dispatch_rotate_axis(ProgramBase *self, const string &opt, const string &arg, void *var); - bool ns_dispatch_rotate_axis(const string &opt, const string &arg, void *var); - static bool dispatch_translate(const string &opt, const string &arg, void *var); + static bool dispatch_scale(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_rotate_xyz(ProgramBase *self, const std::string &opt, const std::string &arg, void *var); + bool ns_dispatch_rotate_xyz(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_rotate_axis(ProgramBase *self, const std::string &opt, const std::string &arg, void *var); + bool ns_dispatch_rotate_axis(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_translate(const std::string &opt, const std::string &arg, void *var); private: typedef pvector Filenames; diff --git a/pandatool/src/progbase/programBase.I b/pandatool/src/progbase/programBase.I index 698efedfdf..960bad09f2 100644 --- a/pandatool/src/progbase/programBase.I +++ b/pandatool/src/progbase/programBase.I @@ -15,6 +15,6 @@ * Formats the indicated text to stderr with the known _terminal_width. */ INLINE void ProgramBase:: -show_text(const string &text) { +show_text(const std::string &text) { show_text("", 0, text); } diff --git a/pandatool/src/progbase/programBase.h b/pandatool/src/progbase/programBase.h index d5d1e310a0..d3d06eb67a 100644 --- a/pandatool/src/progbase/programBase.h +++ b/pandatool/src/progbase/programBase.h @@ -33,82 +33,82 @@ */ class ProgramBase { public: - ProgramBase(const string &name = string()); + ProgramBase(const std::string &name = std::string()); virtual ~ProgramBase(); void show_description(); void show_usage(); void show_options(); - INLINE void show_text(const string &text); - void show_text(const string &prefix, int indent_width, string text); + INLINE void show_text(const std::string &text); + void show_text(const std::string &prefix, int indent_width, std::string text); - void write_man_page(ostream &out); + void write_man_page(std::ostream &out); virtual void parse_command_line(int argc, char **argv); - string get_exec_command() const; + std::string get_exec_command() const; - typedef pdeque Args; + typedef pdeque Args; Filename _program_name; Args _program_args; protected: - typedef bool (*OptionDispatchFunction)(const string &opt, const string &parm, void *data); - typedef bool (*OptionDispatchMethod)(ProgramBase *self, const string &opt, const string &parm, void *data); + typedef bool (*OptionDispatchFunction)(const std::string &opt, const std::string &parm, void *data); + typedef bool (*OptionDispatchMethod)(ProgramBase *self, const std::string &opt, const std::string &parm, void *data); virtual bool handle_args(Args &args); virtual bool post_command_line(); - void set_program_brief(const string &brief); - void set_program_description(const string &description); + void set_program_brief(const std::string &brief); + void set_program_description(const std::string &description); void clear_runlines(); - void add_runline(const string &runline); + void add_runline(const std::string &runline); void clear_options(); - void add_option(const string &option, const string &parm_name, - int index_group, const string &description, + void add_option(const std::string &option, const std::string &parm_name, + int index_group, const std::string &description, OptionDispatchFunction option_function, bool *bool_var = nullptr, void *option_data = nullptr); - void add_option(const string &option, const string &parm_name, - int index_group, const string &description, + void add_option(const std::string &option, const std::string &parm_name, + int index_group, const std::string &description, OptionDispatchMethod option_method, bool *bool_var = nullptr, void *option_data = nullptr); - bool redescribe_option(const string &option, const string &description); - bool remove_option(const string &option); + bool redescribe_option(const std::string &option, const std::string &description); + bool remove_option(const std::string &option); void add_path_replace_options(); void add_path_store_options(); - static bool dispatch_none(const string &opt, const string &arg, void *); - static bool dispatch_true(const string &opt, const string &arg, void *var); - static bool dispatch_false(const string &opt, const string &arg, void *var); - static bool dispatch_count(const string &opt, const string &arg, void *var); - static bool dispatch_int(const string &opt, const string &arg, void *var); - static bool dispatch_int_pair(const string &opt, const string &arg, void *var); - static bool dispatch_int_quad(const string &opt, const string &arg, void *var); - static bool dispatch_double(const string &opt, const string &arg, void *var); - static bool dispatch_double_pair(const string &opt, const string &arg, void *var); - static bool dispatch_double_triple(const string &opt, const string &arg, void *var); - static bool dispatch_double_quad(const string &opt, const string &arg, void *var); - static bool dispatch_color(const string &opt, const string &arg, void *var); - static bool dispatch_string(const string &opt, const string &arg, void *var); - static bool dispatch_vector_string(const string &opt, const string &arg, void *var); - static bool dispatch_vector_string_comma(const string &opt, const string &arg, void *var); - static bool dispatch_filename(const string &opt, const string &arg, void *var); - static bool dispatch_search_path(const string &opt, const string &arg, void *var); - static bool dispatch_coordinate_system(const string &opt, const string &arg, void *var); - static bool dispatch_units(const string &opt, const string &arg, void *var); - static bool dispatch_image_type(const string &opt, const string &arg, void *var); - static bool dispatch_path_replace(const string &opt, const string &arg, void *var); - static bool dispatch_path_store(const string &opt, const string &arg, void *var); + static bool dispatch_none(const std::string &opt, const std::string &arg, void *); + static bool dispatch_true(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_false(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_count(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_int(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_int_pair(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_int_quad(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_double(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_double_pair(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_double_triple(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_double_quad(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_color(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_string(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_vector_string(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_vector_string_comma(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_filename(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_search_path(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_coordinate_system(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_units(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_image_type(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_path_replace(const std::string &opt, const std::string &arg, void *var); + static bool dispatch_path_store(const std::string &opt, const std::string &arg, void *var); - static bool handle_help_option(const string &opt, const string &arg, void *); + static bool handle_help_option(const std::string &opt, const std::string &arg, void *); - static void format_text(ostream &out, bool &last_newline, - const string &prefix, int indent_width, - const string &text, int line_width); + static void format_text(std::ostream &out, bool &last_newline, + const std::string &prefix, int indent_width, + const std::string &text, int line_width); PT(PathReplace) _path_replace; bool _got_path_store; @@ -121,11 +121,11 @@ private: class Option { public: - string _option; - string _parm_name; + std::string _option; + std::string _parm_name; int _index_group; int _sequence; - string _description; + std::string _description; OptionDispatchFunction _option_function; OptionDispatchMethod _option_method; bool *_bool_var; @@ -137,20 +137,20 @@ private: bool operator () (const Option *a, const Option *b) const; }; - string _name; - string _brief; - string _description; + std::string _name; + std::string _brief; + std::string _description; typedef vector_string Runlines; Runlines _runlines; - typedef pmap OptionsByName; + typedef pmap OptionsByName; typedef pvector OptionsByIndex; OptionsByName _options_by_name; OptionsByIndex _options_by_index; int _next_sequence; bool _sorted_options; - typedef pmap GotOptions; + typedef pmap GotOptions; GotOptions _got_options; bool _last_newline; diff --git a/pandatool/src/progbase/withOutputFile.h b/pandatool/src/progbase/withOutputFile.h index 7c4c0f2af7..385114c001 100644 --- a/pandatool/src/progbase/withOutputFile.h +++ b/pandatool/src/progbase/withOutputFile.h @@ -32,7 +32,7 @@ public: bool binary_output); virtual ~WithOutputFile(); - ostream &get_output(); + std::ostream &get_output(); void close_output(); bool has_output_filename() const; Filename get_output_filename() const; @@ -47,7 +47,7 @@ protected: bool _allow_last_param; bool _allow_stdout; bool _binary_output; - string _preferred_extension; + std::string _preferred_extension; bool _got_output_filename; Filename _output_filename; diff --git a/pandatool/src/progbase/wordWrapStream.h b/pandatool/src/progbase/wordWrapStream.h index af5c2f90ab..cfa7969df1 100644 --- a/pandatool/src/progbase/wordWrapStream.h +++ b/pandatool/src/progbase/wordWrapStream.h @@ -27,7 +27,7 @@ * WordWrapStream indicates a paragraph break, and is generally printed as a * blank line. To force a line break without a paragraph break, use '\r'. */ -class WordWrapStream : public ostream { +class WordWrapStream : public std::ostream { public: WordWrapStream(ProgramBase *program); diff --git a/pandatool/src/progbase/wordWrapStreamBuf.h b/pandatool/src/progbase/wordWrapStreamBuf.h index 506f72a6ea..0bc54b01f2 100644 --- a/pandatool/src/progbase/wordWrapStreamBuf.h +++ b/pandatool/src/progbase/wordWrapStreamBuf.h @@ -25,7 +25,7 @@ class WordWrapStream; * Used by WordWrapStream to implement an ostream that flushes its output to * ProgramBase::show_text(). */ -class WordWrapStreamBuf : public streambuf { +class WordWrapStreamBuf : public std::streambuf { public: WordWrapStreamBuf(WordWrapStream *owner, ProgramBase *program); virtual ~WordWrapStreamBuf(); @@ -39,7 +39,7 @@ private: INLINE void set_literal_mode(bool mode); void flush_data(); - string _data; + std::string _data; WordWrapStream *_owner; ProgramBase *_program; bool _literal_mode; diff --git a/pandatool/src/pstatserver/pStatClientData.h b/pandatool/src/pstatserver/pStatClientData.h index 2d4ab293d5..051bb568ae 100644 --- a/pandatool/src/pstatserver/pStatClientData.h +++ b/pandatool/src/pstatserver/pStatClientData.h @@ -44,8 +44,8 @@ public: int get_num_collectors() const; bool has_collector(int index) const; const PStatCollectorDef &get_collector_def(int index) const; - string get_collector_name(int index) const; - string get_collector_fullname(int index) const; + std::string get_collector_name(int index) const; + std::string get_collector_fullname(int index) const; bool set_collector_has_level(int index, int thread_index, bool flag); bool get_collector_has_level(int index, int thread_index) const; @@ -54,14 +54,14 @@ public: int get_num_threads() const; bool has_thread(int index) const; - string get_thread_name(int index) const; + std::string get_thread_name(int index) const; const PStatThreadData *get_thread_data(int index) const; int get_child_distance(int parent, int child) const; void add_collector(PStatCollectorDef *def); - void define_thread(int thread_index, const string &name = string()); + void define_thread(int thread_index, const std::string &name = std::string()); void record_new_frame(int thread_index, int frame_number, PStatFrameData *frame_data); @@ -87,7 +87,7 @@ private: class Thread { public: - string _name; + std::string _name; PT(PStatThreadData) _data; }; typedef pvector Threads; diff --git a/pandatool/src/pstatserver/pStatGraph.I b/pandatool/src/pstatserver/pStatGraph.I index b198296fd7..3bda0cedee 100644 --- a/pandatool/src/pstatserver/pStatGraph.I +++ b/pandatool/src/pstatserver/pStatGraph.I @@ -39,9 +39,9 @@ get_label_collector(int n) const { /** * Returns the text associated with the nth label. */ -INLINE string PStatGraph:: +INLINE std::string PStatGraph:: get_label_name(int n) const { - nassertr(n >= 0 && n < (int)_labels.size(), string()); + nassertr(n >= 0 && n < (int)_labels.size(), std::string()); return _monitor->get_client_data()->get_collector_name(_labels[n]); } @@ -117,7 +117,7 @@ get_guide_bar_units() const { * is set to GBU_named | GBU_show_units. */ INLINE void PStatGraph:: -set_guide_bar_unit_name(const string &unit_name) { +set_guide_bar_unit_name(const std::string &unit_name) { _unit_name = unit_name; } @@ -125,7 +125,7 @@ set_guide_bar_unit_name(const string &unit_name) { * Returns the name of the units to be used for the guide bars if the units * type is set to GBU_named | GBU_show_units. */ -INLINE const string &PStatGraph:: +INLINE const std::string &PStatGraph:: get_guide_bar_unit_name() const { return _unit_name; } diff --git a/pandatool/src/pstatserver/pStatGraph.h b/pandatool/src/pstatserver/pStatGraph.h index b7d907f52b..5b8a2d664e 100644 --- a/pandatool/src/pstatserver/pStatGraph.h +++ b/pandatool/src/pstatserver/pStatGraph.h @@ -39,7 +39,7 @@ public: INLINE int get_num_labels() const; INLINE int get_label_collector(int n) const; - INLINE string get_label_name(int n) const; + INLINE std::string get_label_name(int n) const; INLINE LRGBColor get_label_color(int n) const; INLINE void set_target_frame_rate(double frame_rate); @@ -56,11 +56,11 @@ public: class GuideBar { public: - GuideBar(double height, const string &label, GuideBarStyle style); + GuideBar(double height, const std::string &label, GuideBarStyle style); GuideBar(const GuideBar ©); double _height; - string _label; + std::string _label; GuideBarStyle _style; }; @@ -83,12 +83,12 @@ public: INLINE void set_guide_bar_units(int unit_mask); INLINE int get_guide_bar_units() const; - INLINE void set_guide_bar_unit_name(const string &unit_name); - INLINE const string &get_guide_bar_unit_name() const; + INLINE void set_guide_bar_unit_name(const std::string &unit_name); + INLINE const std::string &get_guide_bar_unit_name() const; - static string format_number(double value); - static string format_number(double value, int guide_bar_units, - const string &unit_name = string()); + static std::string format_number(double value); + static std::string format_number(double value, int guide_bar_units, + const std::string &unit_name = std::string()); protected: virtual void normal_guide_bars()=0; @@ -113,7 +113,7 @@ protected: typedef pvector GuideBars; GuideBars _guide_bars; int _guide_bar_units; - string _unit_name; + std::string _unit_name; }; #include "pStatGraph.I" diff --git a/pandatool/src/pstatserver/pStatMonitor.I b/pandatool/src/pstatserver/pStatMonitor.I index 2b23d43a43..761b7b9a79 100644 --- a/pandatool/src/pstatserver/pStatMonitor.I +++ b/pandatool/src/pstatserver/pStatMonitor.I @@ -30,7 +30,7 @@ get_client_data() const { /** * Returns the name of the indicated collector, if it is known. */ -INLINE string PStatMonitor:: +INLINE std::string PStatMonitor:: get_collector_name(int collector_index) { if (!_client_data.is_null() && _client_data->has_collector(collector_index)) { @@ -54,7 +54,7 @@ is_client_known() const { * thereafter when we receive the client's "hello" message. See * is_client_known(). */ -INLINE string PStatMonitor:: +INLINE std::string PStatMonitor:: get_client_hostname() const { return _client_hostname; } @@ -65,7 +65,7 @@ get_client_hostname() const { * shortly thereafter when we receive the client's "hello" message. See * is_client_known(). */ -INLINE string PStatMonitor:: +INLINE std::string PStatMonitor:: get_client_progname() const { return _client_progname; } diff --git a/pandatool/src/pstatserver/pStatMonitor.h b/pandatool/src/pstatserver/pStatMonitor.h index cd4a012069..f7e92073c4 100644 --- a/pandatool/src/pstatserver/pStatMonitor.h +++ b/pandatool/src/pstatserver/pStatMonitor.h @@ -43,8 +43,8 @@ public: PStatMonitor(PStatServer *server); virtual ~PStatMonitor(); - void hello_from(const string &hostname, const string &progname); - void bad_version(const string &hostname, const string &progname, + void hello_from(const std::string &hostname, const std::string &progname); + void bad_version(const std::string &hostname, const std::string &progname, int client_major, int client_minor, int server_major, int server_minor); void set_client_data(PStatClientData *client_data); @@ -57,12 +57,12 @@ public: INLINE PStatServer *get_server(); INLINE const PStatClientData *get_client_data() const; - INLINE string get_collector_name(int collector_index); + INLINE std::string get_collector_name(int collector_index); const LRGBColor &get_collector_color(int collector_index); INLINE bool is_client_known() const; - INLINE string get_client_hostname() const; - INLINE string get_client_progname() const; + INLINE std::string get_client_hostname() const; + INLINE std::string get_client_progname() const; PStatView &get_view(int thread_index); PStatView &get_level_view(int collector_index, int thread_index); @@ -71,7 +71,7 @@ public: // The following virtual methods may be overridden by a derived monitor // class to customize behavior. - virtual string get_monitor_name()=0; + virtual std::string get_monitor_name()=0; virtual void initialized(); virtual void got_hello(); @@ -96,8 +96,8 @@ private: PT(PStatClientData) _client_data; bool _client_known; - string _client_hostname; - string _client_progname; + std::string _client_hostname; + std::string _client_progname; typedef pmap Views; Views _views; diff --git a/pandatool/src/pstatserver/pStatReader.h b/pandatool/src/pstatserver/pStatReader.h index 4f30fd93cd..40d1d9b5e0 100644 --- a/pandatool/src/pstatserver/pStatReader.h +++ b/pandatool/src/pstatserver/pStatReader.h @@ -52,7 +52,7 @@ public: PStatMonitor *get_monitor(); private: - string get_hostname(); + std::string get_hostname(); void send_hello(); virtual void receive_datagram(const NetDatagram &datagram); @@ -72,7 +72,7 @@ private: PT(PStatClientData) _client_data; - string _hostname; + std::string _hostname; class FrameData { public: diff --git a/pandatool/src/pstatserver/pStatStripChart.h b/pandatool/src/pstatserver/pStatStripChart.h index 6cfe896bf2..5cba0164e2 100644 --- a/pandatool/src/pstatserver/pStatStripChart.h +++ b/pandatool/src/pstatserver/pStatStripChart.h @@ -68,7 +68,7 @@ public: INLINE int height_to_pixel(double value) const; INLINE double pixel_to_height(int y) const; - string get_title_text(); + std::string get_title_text(); bool is_title_unknown() const; protected: diff --git a/pandatool/src/ptloader/loaderFileTypePandatool.h b/pandatool/src/ptloader/loaderFileTypePandatool.h index 721e7477c3..f50400cd4f 100644 --- a/pandatool/src/ptloader/loaderFileTypePandatool.h +++ b/pandatool/src/ptloader/loaderFileTypePandatool.h @@ -32,9 +32,9 @@ public: EggToSomethingConverter *saver = nullptr); virtual ~LoaderFileTypePandatool(); - virtual string get_name() const; - virtual string get_extension() const; - virtual string get_additional_extensions() const; + virtual std::string get_name() const; + virtual std::string get_extension() const; + virtual std::string get_additional_extensions() const; virtual bool supports_compressed() const; virtual bool supports_load() const; diff --git a/pandatool/src/softegg/softNodeDesc.h b/pandatool/src/softegg/softNodeDesc.h index af2060435a..c6512b7dda 100644 --- a/pandatool/src/softegg/softNodeDesc.h +++ b/pandatool/src/softegg/softNodeDesc.h @@ -42,7 +42,7 @@ class EggXfmSAnim; */ class SoftNodeDesc : public ReferenceCount, public Namable { public: - SoftNodeDesc(SoftNodeDesc *parent=nullptr, const string &name = string()); + SoftNodeDesc(SoftNodeDesc *parent=nullptr, const std::string &name = std::string()); ~SoftNodeDesc(); void set_parent(SoftNodeDesc *parent); diff --git a/pandatool/src/softegg/softNodeTree.h b/pandatool/src/softegg/softNodeTree.h index ba44caa810..afbef5877b 100644 --- a/pandatool/src/softegg/softNodeTree.h +++ b/pandatool/src/softegg/softNodeTree.h @@ -40,7 +40,7 @@ public: int get_num_nodes() const; SoftNodeDesc *get_node(int n) const; - SoftNodeDesc *get_node(string name) const; + SoftNodeDesc *get_node(std::string name) const; char *GetRootName(const char *); char *GetModelNoteInfo(SAA_Scene *, SAA_Elem *); @@ -66,9 +66,9 @@ private: EggGroupNode *_egg_root; EggGroupNode *_skeleton_node; - SoftNodeDesc *r_build_node(SoftNodeDesc *parent_node, const string &path); + SoftNodeDesc *r_build_node(SoftNodeDesc *parent_node, const std::string &path); - typedef pmap NodesByName; + typedef pmap NodesByName; NodesByName _nodes_by_name; typedef pvector Nodes; diff --git a/pandatool/src/softegg/softToEggConverter.h b/pandatool/src/softegg/softToEggConverter.h index 1ac9442263..05c26fa60f 100644 --- a/pandatool/src/softegg/softToEggConverter.h +++ b/pandatool/src/softegg/softToEggConverter.h @@ -50,7 +50,7 @@ class EggSAnimData; */ class SoftToEggConverter : public SomethingToEggConverter { public: - SoftToEggConverter(const string &program_name = ""); + SoftToEggConverter(const std::string &program_name = ""); SoftToEggConverter(const SoftToEggConverter ©); virtual ~SoftToEggConverter(); @@ -61,12 +61,12 @@ public: bool HandleGetopts(int &idx, int argc, char **argv); bool DoGetopts(int &argc, char **&argv); - SoftNodeDesc *find_node(string name); + SoftNodeDesc *find_node(std::string name); int *FindClosestTriVert( EggVertexPool *vpool, SAA_DVector *vertices, int numVert ); virtual SomethingToEggConverter *make_copy(); - virtual string get_name() const; - virtual string get_extension() const; + virtual std::string get_name() const; + virtual std::string get_extension() const; virtual bool convert_file(const Filename &filename); bool convert_soft(bool from_selection); @@ -93,7 +93,7 @@ private: bool reparent_decals(EggGroupNode *egg_parent); - string _program_name; + std::string _program_name; bool _from_selection; SI_Error result; @@ -165,7 +165,7 @@ public: }; TransformType _transform_type; - static TransformType string_transform_type(const string &arg); + static TransformType string_transform_type(const std::string &arg); typedef pvector MorphTable; MorphTable _morph_table; diff --git a/pandatool/src/softprogs/softCVS.h b/pandatool/src/softprogs/softCVS.h index f4907e8cbe..adbd89efa6 100644 --- a/pandatool/src/softprogs/softCVS.h +++ b/pandatool/src/softprogs/softCVS.h @@ -49,11 +49,11 @@ private: void remove_unused_elements(); bool rename_file(SceneFiles::iterator begin, SceneFiles::iterator end); - bool scan_cvs(const string &dirname, pset &cvs_elements); - bool scan_scene_file(istream &in, Multifile &multifile); + bool scan_cvs(const std::string &dirname, pset &cvs_elements); + bool scan_scene_file(std::istream &in, Multifile &multifile); - bool cvs_add(const string &path); - bool cvs_add_or_remove(const string &cvs_command, + bool cvs_add(const std::string &path); + bool cvs_add_or_remove(const std::string &cvs_command, const vector_string &paths); SceneFiles _scene_files; @@ -64,7 +64,7 @@ private: vector_string _cvs_remove; bool _no_cvs; - string _cvs_binary; + std::string _cvs_binary; }; #endif diff --git a/pandatool/src/softprogs/softFilename.h b/pandatool/src/softprogs/softFilename.h index 3c1e448b27..0565eabf89 100644 --- a/pandatool/src/softprogs/softFilename.h +++ b/pandatool/src/softprogs/softFilename.h @@ -26,21 +26,21 @@ */ class SoftFilename { public: - SoftFilename(const string &dirname, const string &filename); + SoftFilename(const std::string &dirname, const std::string &filename); SoftFilename(const SoftFilename ©); void operator = (const SoftFilename ©); - const string &get_dirname() const; - const string &get_filename() const; + const std::string &get_dirname() const; + const std::string &get_filename() const; bool has_version() const; - string get_1_0_filename() const; + std::string get_1_0_filename() const; - const string &get_base() const; + const std::string &get_base() const; int get_major() const; int get_minor() const; - const string &get_extension() const; - string get_non_extension() const; + const std::string &get_extension() const; + std::string get_non_extension() const; bool is_1_0() const; void make_1_0(); @@ -58,13 +58,13 @@ public: int get_use_count() const; private: - string _dirname; - string _filename; + std::string _dirname; + std::string _filename; bool _has_version; - string _base; + std::string _base; int _major; int _minor; - string _ext; + std::string _ext; bool _in_cvs; bool _wants_cvs; int _use_count; diff --git a/pandatool/src/text-stats/textMonitor.h b/pandatool/src/text-stats/textMonitor.h index 7be48fc07c..4c88340e46 100644 --- a/pandatool/src/text-stats/textMonitor.h +++ b/pandatool/src/text-stats/textMonitor.h @@ -29,10 +29,10 @@ class TextStats; */ class TextMonitor : public PStatMonitor { public: - TextMonitor(TextStats *server, ostream *outStream, bool show_raw_data); + TextMonitor(TextStats *server, std::ostream *outStream, bool show_raw_data); TextStats *get_server(); - virtual string get_monitor_name(); + virtual std::string get_monitor_name(); virtual void got_hello(); virtual void got_bad_version(int client_major, int client_minor, @@ -45,7 +45,7 @@ public: void show_level(const PStatViewLevel *level, int indent_level); private: - ostream *_outStream; //[PECI] + std::ostream *_outStream; //[PECI] bool _show_raw_data; }; diff --git a/pandatool/src/text-stats/textStats.h b/pandatool/src/text-stats/textStats.h index 0f8ec97ed6..b6853ecb46 100644 --- a/pandatool/src/text-stats/textStats.h +++ b/pandatool/src/text-stats/textStats.h @@ -40,8 +40,8 @@ private: // [PECI] bool _got_outputFileName; - string _outputFileName; - ostream *_outFile; + std::string _outputFileName; + std::ostream *_outFile; }; #endif diff --git a/pandatool/src/vrml/parse_vrml.h b/pandatool/src/vrml/parse_vrml.h index 88c52e16f7..81a04847bf 100644 --- a/pandatool/src/vrml/parse_vrml.h +++ b/pandatool/src/vrml/parse_vrml.h @@ -18,6 +18,6 @@ #include "filename.h" VrmlScene *parse_vrml(Filename filename); -VrmlScene *parse_vrml(istream &in, const string &filename); +VrmlScene *parse_vrml(std::istream &in, const std::string &filename); #endif diff --git a/pandatool/src/vrml/vrmlLexerDefs.h b/pandatool/src/vrml/vrmlLexerDefs.h index f33a444fe4..5cbdc81b14 100644 --- a/pandatool/src/vrml/vrmlLexerDefs.h +++ b/pandatool/src/vrml/vrmlLexerDefs.h @@ -16,12 +16,12 @@ #include "pandatoolbase.h" -void vrml_init_lexer(istream &in, const string &filename); +void vrml_init_lexer(std::istream &in, const std::string &filename); int vrml_error_count(); int vrml_warning_count(); -void vrmlyyerror(const string &msg); -void vrmlyywarning(const string &msg); +void vrmlyyerror(const std::string &msg); +void vrmlyywarning(const std::string &msg); int vrmlyylex(); diff --git a/pandatool/src/vrml/vrmlNode.h b/pandatool/src/vrml/vrmlNode.h index dad8a1bce1..648f477c90 100644 --- a/pandatool/src/vrml/vrmlNode.h +++ b/pandatool/src/vrml/vrmlNode.h @@ -27,7 +27,7 @@ public: const VrmlFieldValue &get_value(const char *field_name) const; - void output(ostream &out, int indent) const; + void output(std::ostream &out, int indent) const; class Field { public: @@ -38,7 +38,7 @@ public: VrmlFieldValue _value; }; - typedef vector Fields; + typedef std::vector Fields; Fields _fields; int _use_count; @@ -46,7 +46,7 @@ public: const VrmlNodeType *_type; }; -inline ostream &operator << (ostream &out, const VrmlNode &node) { +inline std::ostream &operator << (std::ostream &out, const VrmlNode &node) { node.output(out, 0); return out; } @@ -55,16 +55,16 @@ class Declaration { public: SFNodeRef _node; - void output(ostream &out, int indent) const; + void output(std::ostream &out, int indent) const; }; -inline ostream &operator << (ostream &out, const Declaration &dec) { +inline std::ostream &operator << (std::ostream &out, const Declaration &dec) { dec.output(out, 0); return out; } typedef pvector VrmlScene; -ostream &operator << (ostream &out, const VrmlScene &scene); +std::ostream &operator << (std::ostream &out, const VrmlScene &scene); #endif diff --git a/pandatool/src/vrml/vrmlNodeType.h b/pandatool/src/vrml/vrmlNodeType.h index ae259af055..1852429ad1 100644 --- a/pandatool/src/vrml/vrmlNodeType.h +++ b/pandatool/src/vrml/vrmlNodeType.h @@ -42,7 +42,7 @@ union VrmlFieldValue { typedef pvector MFArray; -ostream &output_value(ostream &out, const VrmlFieldValue &value, int type, +std::ostream &output_value(std::ostream &out, const VrmlFieldValue &value, int type, int indent = 0); diff --git a/pandatool/src/vrml/vrmlParserDefs.h b/pandatool/src/vrml/vrmlParserDefs.h index 75464abd46..cad0d5b263 100644 --- a/pandatool/src/vrml/vrmlParserDefs.h +++ b/pandatool/src/vrml/vrmlParserDefs.h @@ -16,7 +16,7 @@ #include "pandatoolbase.h" -void vrml_init_parser(istream &in, const string &filename); +void vrml_init_parser(std::istream &in, const std::string &filename); void vrml_cleanup_parser(); int vrmlyyparse(); diff --git a/pandatool/src/vrmlegg/vrmlToEggConverter.h b/pandatool/src/vrmlegg/vrmlToEggConverter.h index 612881d770..34a9b6843d 100644 --- a/pandatool/src/vrmlegg/vrmlToEggConverter.h +++ b/pandatool/src/vrmlegg/vrmlToEggConverter.h @@ -37,14 +37,14 @@ public: virtual SomethingToEggConverter *make_copy(); - virtual string get_name() const; - virtual string get_extension() const; + virtual std::string get_name() const; + virtual std::string get_extension() const; virtual bool supports_compressed() const; virtual bool convert_file(const Filename &filename); private: - typedef pmap Nodes; + typedef pmap Nodes; void get_all_defs(SFNodeRef &vrml, Nodes &nodes); void vrml_node(const SFNodeRef &vrml, EggGroupNode *egg, diff --git a/pandatool/src/win-stats/winStatsLabel.h b/pandatool/src/win-stats/winStatsLabel.h index 8c98f09f12..0317f0dcfb 100644 --- a/pandatool/src/win-stats/winStatsLabel.h +++ b/pandatool/src/win-stats/winStatsLabel.h @@ -59,7 +59,7 @@ private: WinStatsGraph *_graph; int _thread_index; int _collector_index; - string _text; + std::string _text; HWND _window; COLORREF _bg_color; COLORREF _fg_color; diff --git a/pandatool/src/win-stats/winStatsMonitor.h b/pandatool/src/win-stats/winStatsMonitor.h index 8d4ccf473d..de74aa0d68 100644 --- a/pandatool/src/win-stats/winStatsMonitor.h +++ b/pandatool/src/win-stats/winStatsMonitor.h @@ -47,7 +47,7 @@ public: WinStatsMonitor(WinStatsServer *server); virtual ~WinStatsMonitor(); - virtual string get_monitor_name(); + virtual std::string get_monitor_name(); virtual void initialized(); virtual void got_hello(); @@ -102,7 +102,7 @@ private: HMENU _menu_bar; HMENU _options_menu; HMENU _speed_menu; - string _window_title; + std::string _window_title; int _time_units; double _scroll_speed; bool _pause; diff --git a/pandatool/src/win-stats/winStatsStripChart.h b/pandatool/src/win-stats/winStatsStripChart.h index 8ca08fee23..59953fbe8c 100644 --- a/pandatool/src/win-stats/winStatsStripChart.h +++ b/pandatool/src/win-stats/winStatsStripChart.h @@ -73,7 +73,7 @@ private: static LONG WINAPI static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); int _brush_origin; - string _net_value_text; + std::string _net_value_text; HWND _smooth_check_box; static size_t _check_box_height, _check_box_width; diff --git a/pandatool/src/xfile/windowsGuid.I b/pandatool/src/xfile/windowsGuid.I index 95591161d0..5d0ce22046 100644 --- a/pandatool/src/xfile/windowsGuid.I +++ b/pandatool/src/xfile/windowsGuid.I @@ -91,8 +91,8 @@ compare_to(const WindowsGuid &other) const { return memcmp(this, &other, sizeof(WindowsGuid)); } -INLINE ostream & -operator << (ostream &out, const WindowsGuid &guid) { +INLINE std::ostream & +operator << (std::ostream &out, const WindowsGuid &guid) { guid.output(out); return out; } diff --git a/pandatool/src/xfile/windowsGuid.h b/pandatool/src/xfile/windowsGuid.h index 30296782f4..ea79d0be5a 100644 --- a/pandatool/src/xfile/windowsGuid.h +++ b/pandatool/src/xfile/windowsGuid.h @@ -39,10 +39,10 @@ public: INLINE bool operator < (const WindowsGuid &other) const; INLINE int compare_to(const WindowsGuid &other) const; - bool parse_string(const string &str); - string format_string() const; + bool parse_string(const std::string &str); + std::string format_string() const; - void output(ostream &out) const; + void output(std::ostream &out) const; private: unsigned long _data1; @@ -51,7 +51,7 @@ private: unsigned char _b1, _b2, _b3, _b4, _b5, _b6, _b7, _b8; }; -INLINE ostream &operator << (ostream &out, const WindowsGuid &guid); +INLINE std::ostream &operator << (std::ostream &out, const WindowsGuid &guid); #include "windowsGuid.I" diff --git a/pandatool/src/xfile/xFile.h b/pandatool/src/xfile/xFile.h index fa43e5ab77..c53bdd8313 100644 --- a/pandatool/src/xfile/xFile.h +++ b/pandatool/src/xfile/xFile.h @@ -37,21 +37,21 @@ public: virtual void clear(); bool read(Filename filename); - bool read(istream &in, const string &filename = string()); + bool read(std::istream &in, const std::string &filename = std::string()); bool write(Filename filename) const; - bool write(ostream &out) const; + bool write(std::ostream &out) const; - XFileTemplate *find_template(const string &name) const; + XFileTemplate *find_template(const std::string &name) const; XFileTemplate *find_template(const WindowsGuid &guid) const; - static XFileTemplate *find_standard_template(const string &name); + static XFileTemplate *find_standard_template(const std::string &name); static XFileTemplate *find_standard_template(const WindowsGuid &guid); - XFileDataNodeTemplate *find_data_object(const string &name) const; + XFileDataNodeTemplate *find_data_object(const std::string &name) const; XFileDataNodeTemplate *find_data_object(const WindowsGuid &guid) const; - virtual void write_text(ostream &out, int indent_level) const; + virtual void write_text(std::ostream &out, int indent_level) const; enum FormatType { FT_text, @@ -64,8 +64,8 @@ public: }; private: - bool read_header(istream &in); - bool write_header(ostream &out) const; + bool read_header(std::istream &in); + bool write_header(std::ostream &out) const; static const XFile *get_standard_templates(); diff --git a/pandatool/src/xfile/xFileArrayDef.h b/pandatool/src/xfile/xFileArrayDef.h index 2c8f79d443..5871e6e28c 100644 --- a/pandatool/src/xfile/xFileArrayDef.h +++ b/pandatool/src/xfile/xFileArrayDef.h @@ -34,7 +34,7 @@ public: int get_size(const XFileNode::PrevData &prev_data) const; - void output(ostream &out) const; + void output(std::ostream &out) const; bool matches(const XFileArrayDef &other, const XFileDataDef *parent, const XFileDataDef *other_parent) const; diff --git a/pandatool/src/xfile/xFileDataDef.I b/pandatool/src/xfile/xFileDataDef.I index 59dd89db50..65a7d9c36a 100644 --- a/pandatool/src/xfile/xFileDataDef.I +++ b/pandatool/src/xfile/xFileDataDef.I @@ -15,7 +15,7 @@ * */ INLINE XFileDataDef:: -XFileDataDef(XFile *x_file, const string &name, +XFileDataDef(XFile *x_file, const std::string &name, XFileDataDef::Type type, XFileTemplate *xtemplate) : XFileNode(x_file, name), _type(type), diff --git a/pandatool/src/xfile/xFileDataDef.h b/pandatool/src/xfile/xFileDataDef.h index 93d85c2b36..3921619cdb 100644 --- a/pandatool/src/xfile/xFileDataDef.h +++ b/pandatool/src/xfile/xFileDataDef.h @@ -45,7 +45,7 @@ public: T_template, }; - INLINE XFileDataDef(XFile *x_file, const string &name, + INLINE XFileDataDef(XFile *x_file, const std::string &name, Type type, XFileTemplate *xtemplate = nullptr); virtual ~XFileDataDef(); @@ -58,7 +58,7 @@ public: INLINE int get_num_array_defs() const; INLINE const XFileArrayDef &get_array_def(int i) const; - virtual void write_text(ostream &out, int indent_level) const; + virtual void write_text(std::ostream &out, int indent_level) const; virtual bool repack_data(XFileDataObject *object, const XFileParseDataList &parse_data_list, diff --git a/pandatool/src/xfile/xFileDataNode.I b/pandatool/src/xfile/xFileDataNode.I index 23e63eb321..5591778ee6 100644 --- a/pandatool/src/xfile/xFileDataNode.I +++ b/pandatool/src/xfile/xFileDataNode.I @@ -39,7 +39,7 @@ get_template() const { * A convenience function to return the name of the template used to define * this data object. */ -INLINE const string &XFileDataNode:: +INLINE const std::string &XFileDataNode:: get_template_name() const { return _template->get_name(); } diff --git a/pandatool/src/xfile/xFileDataNode.h b/pandatool/src/xfile/xFileDataNode.h index 78bf6da05d..c04df4a3d1 100644 --- a/pandatool/src/xfile/xFileDataNode.h +++ b/pandatool/src/xfile/xFileDataNode.h @@ -32,17 +32,17 @@ */ class XFileDataNode : public XFileNode, public XFileDataObject { public: - XFileDataNode(XFile *x_file, const string &name, + XFileDataNode(XFile *x_file, const std::string &name, XFileTemplate *xtemplate); virtual bool is_object() const; - virtual bool is_standard_object(const string &template_name) const; - virtual string get_type_name() const; + virtual bool is_standard_object(const std::string &template_name) const; + virtual std::string get_type_name() const; INLINE const XFileDataNode &get_data_child(int n) const; INLINE XFileTemplate *get_template() const; - INLINE const string &get_template_name() const; + INLINE const std::string &get_template_name() const; protected: PT(XFileTemplate) _template; diff --git a/pandatool/src/xfile/xFileDataNodeReference.h b/pandatool/src/xfile/xFileDataNodeReference.h index 294b8a105d..f1e9eb4c80 100644 --- a/pandatool/src/xfile/xFileDataNodeReference.h +++ b/pandatool/src/xfile/xFileDataNodeReference.h @@ -36,12 +36,12 @@ public: virtual bool is_reference() const; virtual bool is_complex_object() const; - virtual void write_text(ostream &out, int indent_level) const; + virtual void write_text(std::ostream &out, int indent_level) const; protected: virtual int get_num_elements() const; virtual XFileDataObject *get_element(int n); - virtual XFileDataObject *get_element(const string &name); + virtual XFileDataObject *get_element(const std::string &name); private: PT(XFileDataNodeTemplate) _object; diff --git a/pandatool/src/xfile/xFileDataNodeTemplate.h b/pandatool/src/xfile/xFileDataNodeTemplate.h index 32c3a74460..521c3752e2 100644 --- a/pandatool/src/xfile/xFileDataNodeTemplate.h +++ b/pandatool/src/xfile/xFileDataNodeTemplate.h @@ -29,7 +29,7 @@ */ class XFileDataNodeTemplate : public XFileDataNode { public: - XFileDataNodeTemplate(XFile *x_file, const string &name, + XFileDataNodeTemplate(XFile *x_file, const std::string &name, XFileTemplate *xtemplate); void zero_fill(); @@ -38,19 +38,19 @@ public: void add_parse_double(PTA_double double_list); void add_parse_int(PTA_int int_list); - void add_parse_string(const string &str); + void add_parse_string(const std::string &str); bool finalize_parse_data(); virtual bool add_element(XFileDataObject *element); - virtual void write_text(ostream &out, int indent_level) const; - virtual void write_data(ostream &out, int indent_level, + virtual void write_text(std::ostream &out, int indent_level) const; + virtual void write_data(std::ostream &out, int indent_level, const char *separator) const; protected: virtual int get_num_elements() const; virtual XFileDataObject *get_element(int n); - virtual XFileDataObject *get_element(const string &name); + virtual XFileDataObject *get_element(const std::string &name); private: XFileParseDataList _parse_data_list; diff --git a/pandatool/src/xfile/xFileDataObject.I b/pandatool/src/xfile/xFileDataObject.I index e68f383e1c..269bc0b0e9 100644 --- a/pandatool/src/xfile/xFileDataObject.I +++ b/pandatool/src/xfile/xFileDataObject.I @@ -55,7 +55,7 @@ operator = (double double_value) { * value. */ INLINE void XFileDataObject:: -operator = (const string &string_value) { +operator = (const std::string &string_value) { set(string_value); } @@ -125,7 +125,7 @@ set(double double_value) { * value. */ INLINE void XFileDataObject:: -set(const string &string_value) { +set(const std::string &string_value) { set_string_value(string_value); } @@ -194,7 +194,7 @@ d() const { * string if the object has no string representation. See also get_data_def() * to determine what kind of representation this object has. */ -INLINE string XFileDataObject:: +INLINE std::string XFileDataObject:: s() const { return get_string_value(); } @@ -268,7 +268,7 @@ operator [] (int n) const { * doubt. */ INLINE const XFileDataObject &XFileDataObject:: -operator [] (const string &name) const { +operator [] (const std::string &name) const { const XFileDataObject *element = ((XFileDataObject *)this)->get_element(name); nassertr(element != nullptr, *this); return *element; @@ -291,14 +291,14 @@ operator [] (int n) { * doubt. */ INLINE XFileDataObject &XFileDataObject:: -operator [] (const string &name) { +operator [] (const std::string &name) { XFileDataObject *element = get_element(name); nassertr(element != nullptr, *this); return *element; } -INLINE ostream & -operator << (ostream &out, const XFileDataObject &data_object) { +INLINE std::ostream & +operator << (std::ostream &out, const XFileDataObject &data_object) { data_object.output_data(out); return out; } diff --git a/pandatool/src/xfile/xFileDataObject.h b/pandatool/src/xfile/xFileDataObject.h index 6b40c5f399..814d5f3c3f 100644 --- a/pandatool/src/xfile/xFileDataObject.h +++ b/pandatool/src/xfile/xFileDataObject.h @@ -35,11 +35,11 @@ public: INLINE const XFileDataDef *get_data_def() const; virtual bool is_complex_object() const; - virtual string get_type_name() const; + virtual std::string get_type_name() const; INLINE void operator = (int int_value); INLINE void operator = (double double_value); - INLINE void operator = (const string &string_value); + INLINE void operator = (const std::string &string_value); INLINE void operator = (const LVecBase2d &vec); INLINE void operator = (const LVecBase3d &vec); INLINE void operator = (const LVecBase4d &vec); @@ -47,7 +47,7 @@ public: INLINE void set(int int_value); INLINE void set(double double_value); - INLINE void set(const string &string_value); + INLINE void set(const std::string &string_value); INLINE void set(const LVecBase2d &vec); INLINE void set(const LVecBase3d &vec); INLINE void set(const LVecBase4d &vec); @@ -55,7 +55,7 @@ public: INLINE int i() const; INLINE double d() const; - INLINE string s() const; + INLINE std::string s() const; INLINE LVecBase2d vec2() const; INLINE LVecBase3d vec3() const; INLINE LVecBase4d vec4() const; @@ -63,17 +63,17 @@ public: INLINE int size() const; INLINE const XFileDataObject &operator [] (int n) const; - INLINE const XFileDataObject &operator [] (const string &name) const; + INLINE const XFileDataObject &operator [] (const std::string &name) const; INLINE XFileDataObject &operator [] (int n); - INLINE XFileDataObject &operator [] (const string &name); + INLINE XFileDataObject &operator [] (const std::string &name); // The following methods can be used to add elements of a specific type to a // complex object, e.g. an array or a template object. XFileDataObject &add_int(int int_value); XFileDataObject &add_double(double double_value); - XFileDataObject &add_string(const string &string_value); + XFileDataObject &add_string(const std::string &string_value); // The following methods can be used to add elements of a specific type, // based on one of the standard templates. @@ -87,24 +87,24 @@ public: public: virtual bool add_element(XFileDataObject *element); - virtual void output_data(ostream &out) const; - virtual void write_data(ostream &out, int indent_level, + virtual void output_data(std::ostream &out) const; + virtual void write_data(std::ostream &out, int indent_level, const char *separator) const; protected: virtual void set_int_value(int int_value); virtual void set_double_value(double double_value); - virtual void set_string_value(const string &string_value); + virtual void set_string_value(const std::string &string_value); void store_double_array(int num_elements, const double *values); virtual int get_int_value() const; virtual double get_double_value() const; - virtual string get_string_value() const; + virtual std::string get_string_value() const; void get_double_array(int num_elements, double *values) const; virtual int get_num_elements() const; virtual XFileDataObject *get_element(int n); - virtual XFileDataObject *get_element(const string &name); + virtual XFileDataObject *get_element(const std::string &name); const XFileDataDef *_data_def; @@ -126,7 +126,7 @@ private: static TypeHandle _type_handle; }; -INLINE ostream &operator << (ostream &out, const XFileDataObject &data_object); +INLINE std::ostream &operator << (std::ostream &out, const XFileDataObject &data_object); #include "xFileDataObject.I" diff --git a/pandatool/src/xfile/xFileDataObjectArray.h b/pandatool/src/xfile/xFileDataObjectArray.h index e42df7845d..3b9000c9ee 100644 --- a/pandatool/src/xfile/xFileDataObjectArray.h +++ b/pandatool/src/xfile/xFileDataObjectArray.h @@ -28,7 +28,7 @@ public: virtual bool add_element(XFileDataObject *element); - virtual void write_data(ostream &out, int indent_level, + virtual void write_data(std::ostream &out, int indent_level, const char *separator) const; protected: diff --git a/pandatool/src/xfile/xFileDataObjectDouble.h b/pandatool/src/xfile/xFileDataObjectDouble.h index afa20ee859..4450f45288 100644 --- a/pandatool/src/xfile/xFileDataObjectDouble.h +++ b/pandatool/src/xfile/xFileDataObjectDouble.h @@ -25,8 +25,8 @@ class XFileDataObjectDouble : public XFileDataObject { public: XFileDataObjectDouble(const XFileDataDef *data_def, double value); - virtual void output_data(ostream &out) const; - virtual void write_data(ostream &out, int indent_level, + virtual void output_data(std::ostream &out) const; + virtual void write_data(std::ostream &out, int indent_level, const char *separator) const; protected: @@ -35,7 +35,7 @@ protected: virtual int get_int_value() const; virtual double get_double_value() const; - virtual string get_string_value() const; + virtual std::string get_string_value() const; private: double _value; diff --git a/pandatool/src/xfile/xFileDataObjectInteger.h b/pandatool/src/xfile/xFileDataObjectInteger.h index 59e3ea13d3..b185ea9310 100644 --- a/pandatool/src/xfile/xFileDataObjectInteger.h +++ b/pandatool/src/xfile/xFileDataObjectInteger.h @@ -25,8 +25,8 @@ class XFileDataObjectInteger : public XFileDataObject { public: XFileDataObjectInteger(const XFileDataDef *data_def, int value); - virtual void output_data(ostream &out) const; - virtual void write_data(ostream &out, int indent_level, + virtual void output_data(std::ostream &out) const; + virtual void write_data(std::ostream &out, int indent_level, const char *separator) const; protected: @@ -34,7 +34,7 @@ protected: virtual int get_int_value() const; virtual double get_double_value() const; - virtual string get_string_value() const; + virtual std::string get_string_value() const; private: int _value; diff --git a/pandatool/src/xfile/xFileDataObjectString.h b/pandatool/src/xfile/xFileDataObjectString.h index 20dd503e06..1fd10dea2b 100644 --- a/pandatool/src/xfile/xFileDataObjectString.h +++ b/pandatool/src/xfile/xFileDataObjectString.h @@ -23,20 +23,20 @@ */ class XFileDataObjectString : public XFileDataObject { public: - XFileDataObjectString(const XFileDataDef *data_def, const string &value); + XFileDataObjectString(const XFileDataDef *data_def, const std::string &value); - virtual void output_data(ostream &out) const; - virtual void write_data(ostream &out, int indent_level, + virtual void output_data(std::ostream &out) const; + virtual void write_data(std::ostream &out, int indent_level, const char *separator) const; protected: - virtual void set_string_value(const string &string_value); - virtual string get_string_value() const; + virtual void set_string_value(const std::string &string_value); + virtual std::string get_string_value() const; private: - void enquote_string(ostream &out) const; + void enquote_string(std::ostream &out) const; - string _value; + std::string _value; public: static TypeHandle get_class_type() { diff --git a/pandatool/src/xfile/xFileNode.h b/pandatool/src/xfile/xFileNode.h index 89ab1a1ba8..a954b8f9fd 100644 --- a/pandatool/src/xfile/xFileNode.h +++ b/pandatool/src/xfile/xFileNode.h @@ -39,17 +39,17 @@ class Filename; class XFileNode : public TypedObject, public Namable, virtual public ReferenceCount { public: - XFileNode(XFile *x_file, const string &name); + XFileNode(XFile *x_file, const std::string &name); virtual ~XFileNode(); INLINE XFile *get_x_file() const; INLINE int get_num_children() const; INLINE XFileNode *get_child(int n) const; - XFileNode *find_child(const string &name) const; - int find_child_index(const string &name) const; + XFileNode *find_child(const std::string &name) const; + int find_child_index(const std::string &name) const; int find_child_index(const XFileNode *child) const; - XFileNode *find_descendent(const string &name) const; + XFileNode *find_descendent(const std::string &name) const; INLINE int get_num_objects() const; INLINE XFileDataNode *get_object(int n) const; @@ -60,12 +60,12 @@ public: virtual bool is_template_def() const; virtual bool is_reference() const; virtual bool is_object() const; - virtual bool is_standard_object(const string &template_name) const; + virtual bool is_standard_object(const std::string &template_name) const; void add_child(XFileNode *node); virtual void clear(); - virtual void write_text(ostream &out, int indent_level) const; + virtual void write_text(std::ostream &out, int indent_level) const; typedef pmap PrevData; @@ -81,21 +81,21 @@ public: // The following methods can be used to create instances of the standard // template objects. These definitions match those defined in // standardTemplates.x in this directory (and compiled into the executable). - XFileDataNode *add_Mesh(const string &name); - XFileDataNode *add_MeshNormals(const string &name); - XFileDataNode *add_MeshVertexColors(const string &name); - XFileDataNode *add_MeshTextureCoords(const string &name); - XFileDataNode *add_MeshMaterialList(const string &name); - XFileDataNode *add_Material(const string &name, const LColor &face_color, + XFileDataNode *add_Mesh(const std::string &name); + XFileDataNode *add_MeshNormals(const std::string &name); + XFileDataNode *add_MeshVertexColors(const std::string &name); + XFileDataNode *add_MeshTextureCoords(const std::string &name); + XFileDataNode *add_MeshMaterialList(const std::string &name); + XFileDataNode *add_Material(const std::string &name, const LColor &face_color, double power, const LRGBColor &specular_color, const LRGBColor &emissive_color); - XFileDataNode *add_TextureFilename(const string &name, + XFileDataNode *add_TextureFilename(const std::string &name, const Filename &filename); - XFileDataNode *add_Frame(const string &name); + XFileDataNode *add_Frame(const std::string &name); XFileDataNode *add_FrameTransformMatrix(const LMatrix4d &mat); public: - static string make_nice_name(const string &str); + static std::string make_nice_name(const std::string &str); protected: XFile *_x_file; @@ -106,7 +106,7 @@ protected: typedef pvector Objects; Objects _objects; - typedef pmap ChildrenByName; + typedef pmap ChildrenByName; ChildrenByName _children_by_name; public: diff --git a/pandatool/src/xfile/xFileParseData.h b/pandatool/src/xfile/xFileParseData.h index c31089274b..2e7ef8dbc0 100644 --- a/pandatool/src/xfile/xFileParseData.h +++ b/pandatool/src/xfile/xFileParseData.h @@ -31,7 +31,7 @@ class XFileParseData { public: XFileParseData(); - void yyerror(const string &message) const; + void yyerror(const std::string &message) const; enum ParseFlags { PF_object = 0x001, @@ -45,12 +45,12 @@ public: PT(XFileDataObject) _object; PTA_double _double_list; PTA_int _int_list; - string _string; + std::string _string; int _parse_flags; int _line_number; int _col_number; - string _current_line; + std::string _current_line; }; /** diff --git a/pandatool/src/xfile/xFileTemplate.h b/pandatool/src/xfile/xFileTemplate.h index 2f4770c66a..5acc117072 100644 --- a/pandatool/src/xfile/xFileTemplate.h +++ b/pandatool/src/xfile/xFileTemplate.h @@ -26,7 +26,7 @@ class XFileDataDef; */ class XFileTemplate : public XFileNode { public: - XFileTemplate(XFile *x_file, const string &name, const WindowsGuid &guid); + XFileTemplate(XFile *x_file, const std::string &name, const WindowsGuid &guid); virtual ~XFileTemplate(); virtual bool has_guid() const; @@ -35,7 +35,7 @@ public: virtual bool is_template_def() const; virtual void clear(); - virtual void write_text(ostream &out, int indent_level) const; + virtual void write_text(std::ostream &out, int indent_level) const; INLINE bool is_standard() const; diff --git a/pandatool/src/xfile/xLexerDefs.h b/pandatool/src/xfile/xLexerDefs.h index eb600edb32..c256cd0d05 100644 --- a/pandatool/src/xfile/xLexerDefs.h +++ b/pandatool/src/xfile/xLexerDefs.h @@ -16,14 +16,14 @@ #include "pandatoolbase.h" -void x_init_lexer(istream &in, const string &filename); +void x_init_lexer(std::istream &in, const std::string &filename); int x_error_count(); int x_warning_count(); -void xyyerror(const string &msg); -void xyyerror(const string &msg, int line_number, int col_number, - const string ¤t_line); -void xyywarning(const string &msg); +void xyyerror(const std::string &msg); +void xyyerror(const std::string &msg, int line_number, int col_number, + const std::string ¤t_line); +void xyywarning(const std::string &msg); int xyylex(); diff --git a/pandatool/src/xfile/xParserDefs.h b/pandatool/src/xfile/xParserDefs.h index 898d4a150e..0900ae4267 100644 --- a/pandatool/src/xfile/xParserDefs.h +++ b/pandatool/src/xfile/xParserDefs.h @@ -23,7 +23,7 @@ class XFile; class XFileNode; -void x_init_parser(istream &in, const string &filename, XFile &file); +void x_init_parser(std::istream &in, const std::string &filename, XFile &file); void x_cleanup_parser(); int xyyparse(); @@ -40,7 +40,7 @@ public: XFileNode *node; XFileDataDef::Type primitive_type; } u; - string str; + std::string str; WindowsGuid guid; PTA_double double_list; PTA_int int_list; diff --git a/pandatool/src/xfileegg/xFileAnimationSet.h b/pandatool/src/xfileegg/xFileAnimationSet.h index 9ef7e1d134..a0bec7d43a 100644 --- a/pandatool/src/xfileegg/xFileAnimationSet.h +++ b/pandatool/src/xfileegg/xFileAnimationSet.h @@ -36,7 +36,7 @@ public: ~XFileAnimationSet(); bool create_hierarchy(XFileToEggConverter *converter); - EggXfmSAnim *get_table(const string &joint_name) const; + EggXfmSAnim *get_table(const std::string &joint_name) const; enum FrameDataFlags { FDF_scale = 0x01, @@ -65,7 +65,7 @@ public: int _flags; }; - FrameData &create_frame_data(const string &joint_name); + FrameData &create_frame_data(const std::string &joint_name); public: double _frame_rate; @@ -74,7 +74,7 @@ private: void mirror_table(XFileToEggConverter *converter, EggGroup *model_node, EggTable *anim_node); - typedef pmap JointData; + typedef pmap JointData; JointData _joint_data; class TablePair { @@ -83,7 +83,7 @@ private: EggXfmSAnim *_table; }; - typedef pmap Tables; + typedef pmap Tables; Tables _tables; }; diff --git a/pandatool/src/xfileegg/xFileMaterial.h b/pandatool/src/xfileegg/xFileMaterial.h index 915bff11b0..dc6a586d09 100644 --- a/pandatool/src/xfileegg/xFileMaterial.h +++ b/pandatool/src/xfileegg/xFileMaterial.h @@ -41,7 +41,7 @@ public: bool has_material() const; bool has_texture() const; - XFileDataNode *make_x_material(XFileNode *x_meshMaterials, const string &suffix); + XFileDataNode *make_x_material(XFileNode *x_meshMaterials, const std::string &suffix); bool fill_material(XFileDataNode *obj); private: diff --git a/pandatool/src/xfileegg/xFileMesh.h b/pandatool/src/xfileegg/xFileMesh.h index 8c300f2db6..417d7c4253 100644 --- a/pandatool/src/xfileegg/xFileMesh.h +++ b/pandatool/src/xfileegg/xFileMesh.h @@ -68,11 +68,11 @@ public: int get_num_materials() const; XFileMaterial *get_material(int n) const; - XFileDataNode *make_x_mesh(XFileNode *x_parent, const string &suffix); - XFileDataNode *make_x_normals(XFileNode *x_mesh, const string &suffix); - XFileDataNode *make_x_colors(XFileNode *x_mesh, const string &suffix); - XFileDataNode *make_x_uvs(XFileNode *x_mesh, const string &suffix); - XFileDataNode *make_x_material_list(XFileNode *x_mesh, const string &suffix); + XFileDataNode *make_x_mesh(XFileNode *x_parent, const std::string &suffix); + XFileDataNode *make_x_normals(XFileNode *x_mesh, const std::string &suffix); + XFileDataNode *make_x_colors(XFileNode *x_mesh, const std::string &suffix); + XFileDataNode *make_x_uvs(XFileNode *x_mesh, const std::string &suffix); + XFileDataNode *make_x_material_list(XFileNode *x_mesh, const std::string &suffix); bool fill_mesh(XFileDataNode *obj); bool fill_mesh_child(XFileDataNode *obj); @@ -100,7 +100,7 @@ private: class SkinWeightsData { public: LMatrix4d _matrix_offset; - string _joint_name; + std::string _joint_name; WeightMap _weight_map; }; typedef epvector SkinWeights; diff --git a/pandatool/src/xfileegg/xFileToEggConverter.h b/pandatool/src/xfileegg/xFileToEggConverter.h index c853cae4ca..d92f4c2325 100644 --- a/pandatool/src/xfileegg/xFileToEggConverter.h +++ b/pandatool/src/xfileegg/xFileToEggConverter.h @@ -45,8 +45,8 @@ public: virtual SomethingToEggConverter *make_copy(); - virtual string get_name() const; - virtual string get_extension() const; + virtual std::string get_name() const; + virtual std::string get_extension() const; virtual bool supports_compressed() const; virtual bool convert_file(const Filename &filename); @@ -56,12 +56,12 @@ public: EggTexture *create_unique_texture(const EggTexture ©); EggMaterial *create_unique_material(const EggMaterial ©); - EggGroup *find_joint(const string &joint_name); + EggGroup *find_joint(const std::string &joint_name); void strip_nodes(TypeHandle t); public: bool _make_char; - string _char_name; + std::string _char_name; double _frame_rate; bool _keep_model; bool _keep_animation; @@ -80,10 +80,10 @@ private: bool convert_animation(XFileDataNode *obj, XFileAnimationSet &animation_set); bool convert_animation_object(XFileDataNode *obj, - const string &joint_name, FrameData &table); - bool convert_animation_key(XFileDataNode *obj, const string &joint_name, + const std::string &joint_name, FrameData &table); + bool convert_animation_key(XFileDataNode *obj, const std::string &joint_name, FrameData &table); - bool set_animation_frame(const string &joint_name, FrameData &table, + bool set_animation_frame(const std::string &joint_name, FrameData &table, int frame, int key_type, const XFileDataObject &values); bool convert_mesh(XFileDataNode *obj, EggGroupNode *egg_parent); @@ -105,7 +105,7 @@ private: typedef pvector AnimationSets; AnimationSets _animation_sets; - typedef pmap Joints; + typedef pmap Joints; Joints _joints; EggGroup *_dart_node; diff --git a/pandatool/src/xfileprogs/xFileToEgg.h b/pandatool/src/xfileprogs/xFileToEgg.h index 2adbc7e2f7..c95815fe2c 100644 --- a/pandatool/src/xfileprogs/xFileToEgg.h +++ b/pandatool/src/xfileprogs/xFileToEgg.h @@ -31,7 +31,7 @@ public: public: bool _make_char; - string _char_name; + std::string _char_name; double _frame_rate; bool _keep_model; bool _keep_animation;